taggedjs 2.5.21 → 2.5.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle.js +1 -1
- package/bundle.js.gz +0 -0
- package/bundle.js.map +1 -1
- package/bundle.js.map.gz +0 -0
- package/js/interpolations/afterInterpolateElement.function.js +1 -1
- package/js/interpolations/afterInterpolateElement.function.js.map +1 -1
- package/js/tag/TagSupport.class.d.ts +2 -1
- package/js/tag/TagSupport.class.js +27 -26
- package/js/tag/TagSupport.class.js.map +1 -1
- package/js/tag/TemplaterResult.class.d.ts +1 -0
- package/js/tag/TemplaterResult.class.js.map +1 -1
- package/js/tag/render/destroyUnlikeTags.function.js +4 -2
- package/js/tag/render/destroyUnlikeTags.function.js.map +1 -1
- package/js/tag/render/renderSubjectComponent.function.js +4 -4
- package/js/tag/render/renderSubjectComponent.function.js.map +1 -1
- package/js/tag/render/softDestroySupport.function.d.ts +4 -0
- package/js/tag/render/softDestroySupport.function.js +19 -0
- package/js/tag/render/softDestroySupport.function.js.map +1 -0
- package/js/tag/update/processTagArray.js +1 -1
- package/js/tag/update/processTagArray.js.map +1 -1
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t,e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},n={};e.d(n,{W9:()=>C,t3:()=>ee,Y2:()=>r,ei:()=>S,B7:()=>g,XF:()=>T,vw:()=>et,PC:()=>w,uX:()=>ne,O9:()=>ct,Ot:()=>d,tD:()=>t,E2:()=>me,OH:()=>he,Y_:()=>Se,zV:()=>u,WJ:()=>f,AZ:()=>at,cF:()=>Be,qy:()=>Ae,u2:()=>Yt,zl:()=>qt,O5:()=>I,Ze:()=>o,_4:()=>i,iO:()=>c,dk:()=>l,mn:()=>a,NM:()=>s,z:()=>_,bc:()=>O,sA:()=>we,MG:()=>ve,t2:()=>Jt,r5:()=>J,pG:()=>K,yN:()=>ge,QB:()=>ce,vJ:()=>L,AI:()=>v,wk:()=>E,uz:()=>F,Tc:()=>xe,Hf:()=>Ee,_A:()=>Te,NU:()=>q,wB:()=>B,id:()=>h,MC:()=>b,zC:()=>m});class r{get(t){return"todo"}}function o(e){return[t.tag,t.templater].includes(e?.tagJsType)}function s(e){return e?.tagJsType===t.templater}function a(e){return e?.tagJsType===t.tagComponent}function l(e){return e?.tagJsType===t.tag}function i(t){return!(!0!==t?.isSubject&&!t?.subscribe)}function c(e){return e instanceof Array&&e.every((e=>[t.tag,t.templater,t.tag,t.tagComponent].includes(e?.tagJsType)))}function u(t){const e=new g;return e.subscribeWith=e=>{const n=[],r=[],o=(o,s)=>{n[s]=!0,r[s]=o;if(n.length===t.length){for(let t=n.length-1;t>=0;--t)if(!n[t])return;e(r,a)}},s=[...t],a=s.shift().subscribe((t=>o(t,0))),l=s.map(((t,e)=>t.subscribe((t=>o(t,e+1)))));return a.subscriptions=l,a},e}function p(t,e,n){const r=[...e],o=r.shift(),s=t=>{if(r.length)return p(t,r,n);n(t)};let a=s;const l=o(t,{setHandler:t=>a=t,next:s});a(l)}!function(t){t.unknown="unknown",t.tag="tag",t.templater="templater",t.tagComponent="tag-component",t.tagArray="tag-array",t.subject="subject",t.date="date",t.string="string",t.boolean="boolean",t.function="function",t[void 0]="undefined"}(t||(t={}));class g{value;onSubscription;methods=[];isSubject=!0;subscribers=[];subscribeWith;_value;set;constructor(t,e){this.value=t,this.onSubscription=e,this._value=t,f(this)}subscribe(t){const e=function(t,e,n){const r=g.globalSubCount$;g.globalSubCount$.next(r._value+1);const o=()=>{o.unsubscribe()};return o.callback=e,o.subscriptions=[],o.unsubscribe=()=>{!function(t,e){const n=t.findIndex((t=>t.callback===e));-1!==n&&t.splice(n,1)}(n,e),g.globalSubCount$.next(r._value-1),o.unsubscribe=()=>o;const t=o.subscriptions;for(let e=t.length-1;e>=0;--e)t[e].unsubscribe();return o},o.add=t=>(o.subscriptions.push(t),o),o.next=t=>{e(t,o)},o}(0,t,this.subscribers),n=this.subscribeWith;if(n){if(this.methods.length){const n=t;t=t=>{p(t,this.methods,(t=>n(t,e)))}}return n(t)}return this.subscribers.push(e),this.onSubscription&&this.onSubscription(e),e}next(t){this._value=t,this.emit()}emit(){const t=this._value,e=[...this.subscribers],n=e.length;for(let r=0;r<n;++r){const n=e[r];n.callback(t,n)}}toPromise(){return new Promise((t=>{this.subscribe(((e,n)=>{n.unsubscribe(),t(e)}))}))}toCallback(t){const e=this.subscribe(((n,r)=>{e.unsubscribe(),t(n)}));return this}pipe(...t){const e=new g(this._value);return e.setMethods(t),e.subscribeWith=t=>this.subscribe(t),e.next=t=>this.next(t),e}setMethods(t){this.methods=t}static all(t){return u(t.map((t=>{if(i(t))return t;return new g(t,(e=>(e.next(t),e)))})))}static globalSubCount$=new g(0)}function f(t){Object.defineProperty(t,"value",{set(e){t._value=e,t.emit()},get:()=>t._value}),Object.defineProperty(t,"set",{set:e=>t.next(e),get:()=>e=>t.next(e)})}class d extends g{value;constructor(t){super(t),this.value=t,f(this)}subscribe(t){const e=super.subscribe(t);return t(this._value,e),e}}function h(t){return(e,n)=>{n.setHandler((()=>{})),t(e,n.next)}}function b(t){return(e,n)=>{n.setHandler((()=>{}));t(e).then((t=>n.next(t)))}}const m=t=>(e,n)=>{n.setHandler((()=>{}));const r=t(e).subscribe((t=>{r.unsubscribe(),n.next(t)}))};function y(){return v.memory.stateConfig.tagSupport}function v(t){const e={beforeRender:t.beforeRender||(()=>{}),beforeRedraw:t.beforeRedraw||(()=>{}),afterRender:t.afterRender||(()=>{}),beforeDestroy:t.beforeDestroy||(()=>{})};v.tagUse.push(e)}v.tagUse=[],v.memory={};class w extends Error{details;constructor(t,e,n={}){super(t),this.name=w.name,this.details={...n,errorCode:e}}}class C extends w{constructor(t,e){super(t,"array-no-key-error",e),this.name=C.name}}class S extends w{constructor(t,e){super(t,"state-mismatch-error",e),this.name=S.name}}class T extends w{constructor(t,e){super(t,"sync-callback-error",e),this.name=T.name}}v.memory.stateConfig={array:[]};const A=t=>function(t){const e=t.memory,n=e.state,r=v.memory.stateConfig;r.rearray=[];const o=n?.length;if(o){for(let t=0;t<o;++t)k(n[t]);r.rearray.push(...n)}r.tagSupport=t}(t);function k(t){const e=t.callback;if(!e)return t.defaultValue;const[n,r]=function(t){const e=t(x),[n]=e,[r]=t(n);return[n,r]}(e);if(r!==x){const o='letState function incorrectly used. Second item in array is not setting expected value.\n\nFor "let" state use `let name = state(default)(x => [name, name = x])`\n\nFor "const" state use `const name = state(default)()`\n\nProblem state:\n'+(e?e.toString():JSON.stringify(t))+"\n";throw console.error(o,{state:t,callback:e,value:n,checkValue:r}),new Error(o)}return n}v({beforeRender:A,beforeRedraw:A,afterRender:t=>{const e=t.memory,n=v.memory.stateConfig,r=n.rearray;if(r.length&&r.length!==n.array.length){const e=`States lengths have changed ${r.length} !== ${n.array.length}. State tracking requires the same amount of function calls every render. Typically this errors is thrown when a state like function call occurs only for certain conditions or when a function is intended to be wrapped with a tag() call`,o=t.templater?.wrapper,s={oldStates:n.array,newStates:n.rearray,tagFunction:o.parentWrap.original},a=new S(e,s);throw console.warn(e,s),a}delete n.rearray,delete n.tagSupport,e.state.length=0,e.state.push(...n.array);const o=e.state;for(let t=o.length-1;t>=0;--t){const e=o[t];e.lastValue=k(e)}n.array=[]}});class x{}function j(t,e){for(let n=t.length-1;n>=0;--n){const r=t[n].get(),o=e[n].callback;o&&o(r),e[n].lastValue=r}}function E(t){const e=v.memory.stateConfig;let n;const r=e.rearray[e.array.length];if(r){let t=k(r);n=e=>[t,t=e];const o={get:()=>k(o),callback:n,lastValue:t,defaultValue:r.defaultValue};return e.array.push(o),t}let o=(t instanceof Function?t:()=>t)();if(o instanceof Function){const t=e.array,n=e.tagSupport,r=o;o=(...e)=>{const o=n.global.newest.memory.state;j(o,t);const s=r(...e);return j(t,o),s},o.original=r}n=t=>[o,o=t];const s={get:()=>k(s),callback:n,lastValue:o,defaultValue:o};return e.array.push(s),o}const B=(t,e)=>P(t,e),R=t=>t;const P=(t,e,{init:n,before:r=(()=>!0),final:o=R}={})=>{let s=E({pastResult:void 0,values:void 0});const a=s.values;if(void 0===a){if(!r(t))return s.values=t,s.pastResult;const l=(n||e)(t,a);return s.pastResult=o(l),s.values=t,s.pastResult}if(t.every(((t,e)=>t===a[e])))return s.pastResult;if(!r(t))return s.values=t,s.pastResult;const l=e(t,a);return s.pastResult=o(l),a.length=0,a.push(...t),s.pastResult};function V(t,e){return Object.defineProperty(e,"noInit",{get(){const e=t();return e.setup.init=()=>{},e}}),Object.defineProperty(e,"asSubject",{get(){const e=t(),n=E((()=>y())),r=E((()=>new d(void 0))),o=(t,o)=>(P(t,((t,e)=>{const s=y(),a=o(t,e);if(s!==n){j(v.memory.stateConfig.array,n.memory.state)}r.next(a)}),e.setup),r);return o.setup=e.setup,V((()=>o),o),o}}),Object.defineProperty(e,"truthy",{get(){const e=t();return e.setup.before=t=>t.every((t=>t)),e}}),e}function F(t,e){const n=E((()=>v.memory.stateConfig.array)),r=y();return E((()=>new g(t,e).pipe((t=>(j(r.memory.state,n),t)))))}function O(t){const e=v.memory.stateConfig;let n;const r=e.rearray[e.array.length];if(r){let t=k(r);n=e=>[t,t=e];const o={get:()=>k(o),callback:n,lastValue:t,defaultValue:r.defaultValue};return e.array.push(o),N(t,o)}let o=(t instanceof Function?t:()=>t)();n=t=>[o,o=t];const s={get:()=>k(s),callback:n,lastValue:o,defaultValue:o};return e.array.push(s),N(o,s)}function N(t,e){return n=>(e.callback=n||(e=>[t,t=e]),t)}function _(t){return e=>{let n=O(t)(e);return B([t],(()=>e(n=t))),e(n),n}}function D(t){return $(t,new WeakMap)}function $(t,e){if(null===t||"object"!=typeof t)return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));if(e.set(t,n),Array.isArray(t))for(let r=0;r<t.length;r++)n[r]=$(t[r],e);else for(const r in t)t.hasOwnProperty(r)&&(n[r]=$(t[r],e));return n}function M(t,e){return W(t,e,new WeakMap)}function W(t,e,n){return!!(t===e||(r=t,o=e,r instanceof Function&&o instanceof Function&&r.toString()===o.toString()))||(!!n.has(t)||"object"==typeof t&&"object"==typeof e&&(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():(n.set(t,0),Array.isArray(t)&&Array.isArray(e)?function(t,e,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!W(t[r],e[r],n))return!1;return!0}(t,e,n):!Array.isArray(t)&&!Array.isArray(e)&&function(t,e,n){const r=Object.keys(t),o=Object.keys(e);if(0===r.length&&0===o.length)return!0;if(r.length!==o.length)return!1;for(const s of r){if(!o.includes(s)||!W(t[s],e[s],n))return!1}return!0}(t,e,n))));var r,o}V((()=>function(t){const e=(e,n)=>P(e,n,t);return e.setup=t,V((()=>e),e),e}({})),B),F._value=t=>{const e=E((()=>v.memory.stateConfig.array)),n=y();return E((()=>new d(t).pipe((t=>(j(n.memory.state,e),t)))))},F.all=function(t){const e=E((()=>v.memory.stateConfig.array)),n=y();return g.all(t).pipe((t=>(j(n.memory.state,e),t)))};const J={create:t=>{const e=E((()=>({stateDiff:0,provider:void 0})));if(e.stateDiff){for(let t=e.stateDiff;t>0;--t)E(void 0);return E(void 0)}const n=E((()=>{const n=v.memory.stateConfig,r=n.array.length,o="prototype"in t?new t:t(),s=n.tagSupport,a=n.array.length-r,l={constructMethod:t,instance:o,clone:D(o),stateDiff:a,owner:s,children:[]};return e.provider=l,s.global.providers.push(l),e.stateDiff=a,o})),r=t,o=r.compareTo=r.toString();return e.provider.constructMethod.compareTo=o,n},inject:t=>E((()=>{const e=v.memory,n=t,r=n.compareTo=n.compareTo||t.toString(),o=e.stateConfig.tagSupport,s=[];let a={ownerTagSupport:o.ownerTagSupport};for(;a.ownerTagSupport;){const t=a.ownerTagSupport.global.providers.find((t=>{s.push(t);if(t.constructMethod.compareTo===r)return!0}));if(t){t.clone=D(t.instance);const n=e.stateConfig.tagSupport;return n.global.providers.push(t),t.children.push(n),t.instance}a=a.ownerTagSupport}const l=`Could not inject provider: ${t.name} ${t}`;throw console.warn(`${l}. Available providers`,s),new Error(l)}))};function U(t,e){const n=t.templater,r=e.templater,o=n?.tag||t,s=r.tag,a=o.strings,l=e.strings||s.strings;if(a.length!==l.length)return!1;if(!a.every(((t,e)=>l[e]===t)))return!1;return I(t.values||o.values,e.values||s.values)}function I(t,e){if(!(t.length===e.length))return!1;return!!e.every(((e,n)=>{const r=t[n];if(e instanceof Function&&r instanceof Function){return!!(e.toString()===r.toString())}return!0}))}function L(t,e){const n=v.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].beforeRender(t,e)}function z(t,e){const n=v.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].afterRender(t,e);v.memory.tagClosed$.next(e)}function H(t,e){const n=v.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].beforeDestroy(t,e);if(t.global.deleted=!0,t.hasLiveElements=!1,e){e.global.childTags=e.global.childTags.filter((e=>e!==t.global.oldest));const n=t.global;n.providers.forEach((t=>t.children.forEach(((e,r)=>{e.global===n&&t.children.splice(r,1)}))))}}function K(t,e,n,r){const o=t.global.renderCount;!function(t,e,n){const r=n?.ownerTagSupport,o=r||e;if(n){if(n!==t){const e=n.memory.state,r=t.memory;t.global=n.global,r.state.length=0,r.state.push(...e)}return function(t,e){const n=v.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].beforeRedraw(t,e)}(t,n)}L(t,o)}(t,r,e);let s=(0,t.templater.wrapper)(t,n);return z(t,r),t.global.newest=s,!e&&r&&r.global.childTags.push(s),s.global.renderCount>o+1?t.global.newest:s}function X(t){t.global.oldest.destroy(),t.global.context={}}function G(t,e){let n=t,r=e;if("object"==typeof t){if(!e)return 3;n=[...t],r=[...e||[]];if(!n.every(((t,e)=>{let o=r[e];if(t&&"object"==typeof t){const e={...t},n={...o||{}},r=Object.entries(e).every((([t,r])=>Y(r,n[t],(()=>{delete e[t],delete n[t]}))));return r}return Y(t,o,(()=>{n.splice(e,1),r.splice(e,1)}))})))return 6}return!1}function Y(t,e,n){if(!(t instanceof Function))return!!M(t,e)&&4;if(!(e instanceof Function))return!1;const r=e?.original;r&&(e=r);t.original&&(t=t.original);return t.toString()===e.toString()?(n(),3):(n(),5)}function Z(t,e,n,{counts:r}){const o=e,s=o.tagSupport,a=s?.global.oldest||void 0;return a&&a?function(t,e,n){if(e instanceof Function){const t=e(n);return n.updateBy(t),e.tagSupport=t,t}return n.updateBy(t),e.tagSupport=t,t}(t,o,a):(t.buildBeforeElement(n,{counts:r}),t)}v.memory.tagClosed$=new g(void 0,(t=>{y()||t.next()}));const q="__tagvar",Q="--"+q+"--",tt=new RegExp(Q,"g");class et{strings;values;tagJsType=t.tag;memory={};templater;constructor(t,e){this.strings=t,this.values=e}key(t){return this.memory.arrayValue=t,this}children;html(t,...e){return this.children={strings:t,values:e},this}}function nt(t,e){e.parentNode.insertBefore(t,e.nextSibling)}function rt(t){return["string","number","boolean"].includes(t)}function ot(t,e){t.destroy({stagger:e.removed++});const n=t.global.insertBefore;n.parentNode.removeChild(n)}function st(t){const e=t.global.insertBefore,n=t.global,r=n.placeholder;r&&(nt(e,r),delete n.placeholder)}function at(e){if(null==e)return t.undefined;const n=typeof e;if(e instanceof Function)return t.function;if("object"===n){if(e instanceof Date)return t.date;if(rt(n))return n;const r=e.tagJsType;if(r){if([t.tagComponent,t.templater,t.tag].includes(r))return r}if(c(e))return t.tagArray;if(i(e))return t.subject}return t.unknown}function lt(e){return e.map((e=>{const n=e;switch(at(e)){case t.tagComponent:return D(e.props);case t.tag:case t.templater:return lt(n.values);case t.tagArray:return lt(n)}return D(e)}))}function it(t,e=[]){for(let n=t.length-1;n>=0;--n){const r=t[n];e.push(r),t.splice(n,1),it(r.global.childTags,e)}return e}class ct{props;tagJsType="templater";tagged;wrapper;madeChildIntoSubject;tag;children=new d([]);arrayValue;constructor(t){this.props=t}key(t){return this.arrayValue=t,this}html(t,...e){const n=function(t,e){if(i(t))return t;if(c(t))return e.madeChildIntoSubject=!0,new d(t);const n=t;return n?(e.madeChildIntoSubject=!0,n.memory.arrayValue=0,new d([n])):(e.madeChildIntoSubject=!0,new d([]))}(new et(t,e),this);return this.children=n,this}}function ut(t,e){const n=t;let r=n.templater;r||(r=new ct([]),r.tag=n,n.templater=r);const o=new d(r);return o.tagSupport=new ne(r,e,o),e.global.childTags.push(o.tagSupport),o}function pt(t){const e=document.createTextNode(""),n=t.parentNode;return n.insertBefore(e,t),n.removeChild(t),e}function gt(t,e,n){const r=t.split(".");if("style"===r[0]&&(n.style[r[1]]=e),"class"===r[0])if(r.shift(),e)for(let t=0;t<r.length;++t)n.classList.add(r[t]);else for(let t=0;t<r.length;++t)n.classList.remove(r[t])}const ft=!0;function dt(t,e,n,r){const o=ht(e),s=t.bind(n);o.global.locked=ft;return function(t,e){if(delete t.global.locked,t.global.blocked.length){let n;return t.global.blocked.forEach((e=>{const r=e;n=le(r.ownerTagSupport,r,r.subject,r.global.insertBefore,!0),t.global.newest=n,t.global.blocked.splice(0,1)})),t.global.blocked.length=0,bt(e,n,n.global)}const n=function(t,e,n){if(n.deleted)return"no-data-ever";return ge(t,!0),bt(e,t,n)}(t.global.newest,e,t.global);return n}(o,s(...r))}function ht(e){if(e.templater.tagJsType===t.templater){return ht(e.ownerTagSupport)}return e}function bt(t,e,n){return t instanceof Promise?(e.global.locked=ft,t.then((()=>(delete e.global.locked,n.deleted||(delete e.global.locked,ge(n.newest,!0)),"promise-no-data-ever")))):"no-data-ever"}const mt=/^\s*{__tagvar/,yt=/}\s*$/;function vt(t){return t&&t.search(mt)>=0&&t.search(yt)>=0}function wt(t,e,n,r,o,s){if(vt(e))return function(t,e,n,r,o,s){const a=Ct(r,e);return St(t,a,n,o,s)}(t,e,n,r,o,s);if(vt(t)){let e;const a=Ct(r,t).subscribe((t=>{t!==e&&(!function(t,e,n,r,o){if(e&&e!=t)if("string"==typeof e)n.removeAttribute(e);else if(e instanceof Object)for(const t in e)n.removeAttribute(t);if("string"==typeof t){if(!t.length)return;return void St(t,"",n,r,o)}if(t instanceof Object)for(const e in t)St(e,t[e],n,r,o)}(t,e,n,o,s),e=t)}));return o.global.subscriptions.push(a),void n.removeAttribute(t)}return At(t)?gt(t,e,n):void 0}function Ct(t,e){return t[e.replace("{","").split("").reverse().join("").replace("}","").split("").reverse().join("")]}function St(t,e,n,r,o){const s=At(t);if(e instanceof Function){const r=function(...t){return e(n,t)};n[t].action=r}if(i(e)){let a;n.removeAttribute(t);const l=e=>e instanceof Function?function(t,e,n,r,o,s){const a=t.templater.wrapper,l=a?.parentWrap,i=l?.oneRender;i||(e=function(t,e){if(t.isChildOverride)return t;v.memory.stateConfig;const n=(n,r)=>dt(t,e,n,r);return n.tagFunction=t,n}(e,t));return Tt(e,n,r,o,s)}(r,e,n,t,s,o):a===e?a:(a=e,Tt(e,n,t,s,o)),i=e.subscribe(l);r.global.subscriptions.push(i)}else o(n,t,e)}function Tt(t,e,n,r,o){if(t instanceof Function){const r=function(...n){return t(e,n)};return r.tagFunction=t,"ondoubleclick"===n&&(n="ondblclick"),void(e[n]=r)}if(r)return void gt(n,t,e);if(t)return void o(e,n,t);[void 0,!1,null].includes(t)?e.removeAttribute(n):o(e,n,t)}function At(t){return t.search(/^(class|style)(\.)/)>=0}function kt(t,e,n){t.setAttribute(e,n)}function xt(t,e,n){t[e]=n}function jt(t,e,n){const r=t.getAttributeNames();let o=kt;for(let s=0;s<r.length;++s){const a=r[s];"INPUT"===t.nodeName&&"value"===a&&(o=xt);wt(a,t.getAttribute(a),t,e,n,o),o=kt}}const Et=/(?:<[^>]*?(?:(?:\s+\w+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+)))*\s*)\/?>)|({__tagvar[^}]+})/g;function Bt(t,e,n,r){let o=r.tagSupport;return o||(o=Vt(t,n,r)),r.tagSupport=o,o.ownerTagSupport=n,o.buildBeforeElement(e,{counts:{added:0,removed:0}}),o}function Rt(t){const e=Pt();return e.tag=t,t.templater=e,e}function Pt(){const t={children:new d([]),props:[],isTag:!0,tagJsType:"templater",tagged:!1,html:()=>t,key:()=>t};return t}function Vt(t,e,n){const r=new ne(t,e,n);return Ft(r,e,n),e.global.childTags.push(r),r}function Ft(t,e,n){t.global.oldest=t,t.global.newest=t,t.ownerTagSupport=e,n.tagSupport=t}function Ot(t,e,n,r,o){const s=r.clones;let a=t.lastArray=t.lastArray||[];t.placeholder||function(t,e){if("TEMPLATE"!==t.nodeName)return void(e.placeholder=t);const n=e.placeholder=document.createTextNode(""),r=t.parentNode;r.insertBefore(n,t),r.removeChild(t)}(n,t);const i=t.placeholder;let c=0;a=t.lastArray=t.lastArray.filter(((t,n)=>{if(e.length-1<n-c)return Dt(a,n,o),++c,!1;const r=e[n-c],s=l(r);let i,u=r,p=r.templater;s?i=u.memory.arrayValue:(p=r,u=p.tag,i=p.arrayValue);const g=!function(t,e){if(t===e)return!0;if(t instanceof Array&&e instanceof Array&&t.length==e.length)return t.every(((t,n)=>t==e[n]));return!1}(i,t.tagSupport.templater.tag.memory.arrayValue);return!g||(Dt(a,n,o),++c,!1)}));const u=e.length;for(let t=0;t<u;++t){const n=e[t],s=a[t],c=s?.tagSupport,u=n,p=l(u),g=new d(void 0);let f,h=u.templater;if(p?(h||(h=Rt(u)),f=new ne(h,r,g)):(h=u,f=_t(h,r,g)),c){Ft(f,r,c.subject);const t=c.global;f.global=t,t.newest=f}if(!("arrayValue"in(h.tag||u).memory)){const t={template:f.getTemplate().string,array:e},n="Use html`...`.key(item) instead of html`...` to template an Array";console.error(n,t);throw new C(n,t)}if(a.length>t){s.tagSupport.global.oldest.updateBy(f)}else Nt(i,f,t,o,a),r.global.childTags.push(f)}return s}function Nt(t,e,n,r,o){const s={tagSupport:e,index:n};o.push(s);const a={added:r.counts.added+n,removed:r.counts.removed},l=document.createDocumentFragment(),i=document.createElement("template");l.appendChild(i),e.buildBeforeElement(i,{counts:a});t.parentNode.insertBefore(l,t)}function _t(t,e,n){const r=Vt(t,e,n);return K(r,r,n,e),r}function Dt(t,e,n){const r=t[e];ot(r.tagSupport,n.counts),r.deleted=!0,++n.counts.removed}function $t(t,e){const n=e.parentNode,r=document.createTextNode(t);return n.insertBefore(r,e),n.removeChild(e),r}function Mt(t){return[void 0,!1,null].includes(t)?"":t}function Wt(t,e,n){e.insertBefore=n;const r=e.clone||n;if(e.lastValue===t&&"lastValue"in e)return;e.lastValue=t;const o=Mt(t),s=e.clone;if(s)return void(s.textContent=o);const a=$t(o,r);e.clone=a}function Jt(t,e,n){const r=new ct([]);r.tagJsType="oneRender";const o=Vt(r,n,e);const s=()=>(r.tag=t(),o);return r.wrapper=s,s.parentWrap=s,s.oneRender=!0,s.parentWrap.original=t,o}function Ut(e,n,r,o,s){switch(at(e)){case t.templater:return void Bt(e,r,o,n);case t.tag:const a=e;let l=a.templater;return l||(l=Rt(a)),void Bt(l,r,o,n);case t.tagArray:return Ot(n,e,r,o,s);case t.tagComponent:return re(e,n,r,o,s);case t.function:const i=e;if(i.oneRender){const t=Jt(i,n,o);return K(t,t,n,o),void Bt(t.templater,r,o,n)}}!function(t,e,n){e.lastValue=t;const r=$t(Mt(t),n);e.clone=r}(e,n,r)}const It=new RegExp('\\s*<template interpolate end id="__tagvar(\\d{1,4})"([^>]*)></template>(\\s*)');function Lt(e,n,r,a){const i=e,c=at(n);if(function(e,n,r,s){const a=e,l="lastValue"in a,i=a.lastValue;if(l&&i!==n){const t=typeof n;return(!rt(t)||typeof i!==t)&&!(n instanceof Function&&i instanceof Function)&&(function(t,e){const n=e.clone,r=n.parentNode;r.insertBefore(t,n),r.removeChild(n),delete e.clone,delete e.lastValue}(r,a),"changed-simple-value")}const c=e,u=c.lastArray;if(u&&s!==t.tagArray){const t=c.placeholder;delete c.lastArray,delete c.placeholder,nt(r,t);for(let t=u.length-1;t>=0;--t){const{tagSupport:e}=u[t];ot(e,{added:0,removed:0})}return"array"}const p=e.tagSupport;if(p){const r=o(n);return o(e._value)&&r?!U(n,p)&&(st(p),X(p),2):s!==t.tagComponent&&(!n||!n.oneRender)&&(st(p),X(p),"different-tag")}}(e,n,a,c),c===t.tagComponent)return function(t,e,n,r){if(!e.tagSupport)return re(t,e,n,r,{counts:{added:0,removed:0}}),e;const o=new ne(t,r,e),s=e.tagSupport,a=s.global.newest;if(!a)return st(s),re(t,e,n,r,{counts:{added:0,removed:0}}),e;{const t=a.memory.state;o.memory.state.length=0,o.memory.state.push(...t)}return o.global=s.global,e.tagSupport=o,le(r,o,e,n),e}(n,i,a,r);if(i.tagSupport)return c===t.function||function(t,e,n){const r=t.tagSupport;let o=e;const a=l(e);if(a){const t=e;o=t.templater,o||(o=new ct([]),o.tag=t,t.templater=o)}const i=new ne(o,n,t);a&&(i.global=r.global);const c=e&&U(r,i);s(e)&&Ft(i,n,t);if(c)return void r.updateBy(i);if(c){return Bt(o,r.global.insertBefore,n,t)}Wt(e,t,t.insertBefore)}(e,n,r),i;switch(c){case t.tagArray:return Ot(e,n,a,r,{counts:{added:0,removed:0}}),e;case t.templater:return Bt(n,a,r,i),i;case t.tag:const o=n;let s=o.templater;return s||(s=Pt(),o.templater=s,s.tag=o),Bt(s,a,r,i),i;case t.subject:return n;case t.function:return e.clone||(e.clone=pt(a)),e}return Wt(n,e,a),i}function zt(t,e,n,r){if(!t.hasAttribute("end"))return;const o=t.getAttribute("id");if(o?.substring(0,q.length)!==q)return;const s=e[o];if(a(s._value)||c(s.value))return{variableName:o,ownerSupport:n,subject:s,insertBefore:t};Ht(t,s,n,r)}function Ht(t,e,n,r){let o=!1;const s=s=>{if(o)return void Lt(e,s,n,t);Ut(s,e,t,n,{counts:{...r}}),o=!0};let a=s;const l=e.subscribe((t=>a(t)));if(t.parentNode){const n=e.clone=pt(t);a=r=>{const o=n.parentNode;o.insertBefore(t,n),o.removeChild(n),delete e.clone,a=s,s(r)}}n.global.subscriptions.push(l)}function Kt(t,e,n,r){if(!t.getAttribute)return;"TEXTAREA"===t.nodeName&&function(t,e,n){const r=t.value;if(r.search(It)>=0){const o=r.match(/__tagvar(\d{1,4})/),s="{"+(o?o[0]:"")+"}";t.value="",t.setAttribute("text-var-value",s);const a=(e,n,r)=>t.value=r;wt("text-var-value",s,t,e,n,a)}}(t,n,r);let o=e.counts.added;o=function(t,e){const n=t.oninit;if(!n)return e.added;const r=n.tagFunction;if(!r)return e.added;const o=r.tagFunction;return o?(o({target:t,stagger:e.added}),++e.added):e.added}(t,e.counts)-o;t.focus&&(t.hasAttribute("autofocus")&&t.focus(),t.hasAttribute("autoselect")&&t.select());const s=t.children;if(s)for(let t=s.length-1;t>=0;--t){Kt(s[t],{...e,counts:e.counts},n,r)}}function Xt(t,e,n,r){const o=n.counts,s=[],a=[];for(let l=r.length-1;l>=0;--l){const i=r[l],c=zt(i,t,e,o);if(c)a.push(c);else if(i.children)for(let r=i.children.length-1;r>=0;--r){const l=i.children[r];if(Gt(l)){const n=zt(l,t,e,o);n&&a.push(n)}const{clones:c,tagComponents:u}=Xt(t,e,n,l.children);s.push(...c),a.push(...u)}}return{clones:s,tagComponents:a}}function Gt(t){return"TEMPLATE"===t.tagName&&void 0!==t.getAttribute("interpolate")&&void 0!==t.getAttribute("end")}function Yt(t,e,n,r,o){const s=[],a=[],l=n.interpolation,i=t.children[0],c=i.content.children;if(l.keys.length){const{clones:t,tagComponents:n}=Xt(e,r,o,c);s.push(...t),a.push(...n)}return jt(i,e,r),Zt(c,e,r),{clones:s,tagComponents:a}}function Zt(t,e,n){for(let r=t.length-1;r>=0;--r){const o=t[r];jt(o,e,n),o.children&&Zt(o.children,e,n)}}function qt(t){const e=function(t){const e=[];return{string:t.replace(Et,((t,n)=>{if(t.startsWith("<"))return t;const r=n.substring(1,n.length-1);return e.push(r),`<template interpolate end id="${r}"></template>`})),keys:e}}(t);return e.string=e.string.replace(tt,q),e}function Qt(t,e,n,r,o){const s=function(t,e){const n=[];let r=t.children[0].content.firstChild;const o=document.createDocumentFragment();for(;r;){const t=r.nextSibling;n.push(r),o.appendChild(r),r=t}e.parentNode&&e.parentNode.insertBefore(o,e);return n}(t,e);if(!s.length)return s;for(let t=s.length-1;t>=0;--t){const e=s[t];Kt(e,o,r,n),n.clones.push(e)}return s}const te=new RegExp(q,"g");class ee{templater;subject;isApp=!0;appElement;strings;values;propsConfig;memory={state:[]};clones=[];global={destroy$:new g,context:{},providers:[],renderCount:0,subscriptions:[],oldest:this,blocked:[],childTags:[]};hasLiveElements=!1;constructor(t,e,n){this.templater=t,this.subject=e;const r=t.props;this.propsConfig=this.clonePropsBy(r,n)}clonePropsBy(t,e){const n=this.templater.children.value,r=t.map((t=>D(t)));return this.propsConfig={latest:t,latestCloned:r,castProps:e,lastClonedKidValues:n.map((t=>lt(t.values)))}}buildBeforeElement(t,e={counts:{added:0,removed:0}}){const n=this.subject,r=this.global;r.insertBefore=t,r.placeholder||function(t){const e=t.insertBefore;t.placeholder=pt(e)}(r);const o=r.placeholder;r.oldest=this,r.newest=this,n.tagSupport=this,this.hasLiveElements=!0;const s=this.update(),a=this.getTemplate(),l=document.createDocumentFragment(),i=document.createElement("template");i.innerHTML=a.string,l.appendChild(i);const{tagComponents:c}=Yt(l,s,a,this,{counts:e.counts});Qt(l,o,this,s,e);const u=c.length;for(let t=0;t<u;++t){const n=c[t];Ht(n.insertBefore,n.subject,n.ownerSupport,e.counts),Qt(l,n.insertBefore,n.ownerSupport,s,e)}}getTemplate(){const t=this.templater.tag,e=this.strings||t.strings,n=this.values||t.values,r=qt(e.map(((t,e)=>(t.replace(te,Q)+(n.length>e?`{${q}${e}}`:"")).replace(/>\s*/g,">").replace(/\s*</g,"<"))).join(""));return{interpolation:r,string:r.string,strings:e,values:n,context:this.global.context||{}}}update(){return this.updateContext(this.global.context)}updateContext(e){const n=this.templater.tag,r=this.strings||n.strings,o=this.values||n.values;return r.forEach(((n,r)=>{if(!(o.length>r))return;const s=q+r,a=o[r];if(s in e){if(this.global.deleted){const t=a&&a.tagSupport;if(t)return t.destroy(),e}return function(t,e,n){const r=t[e];i(n)||r.next(n)}(e,s,a)}e[s]=function(e,n){switch(at(e)){case t.tagComponent:return new d(e);case t.templater:return ut(e.tag,n);case t.tag:return ut(e,n);case t.subject:return e}return new d(e)}(a,this)})),e}updateBy(t){const e=t.templater.tag;this.updateConfig(e.strings,e.values)}updateConfig(t,e){this.strings=t,this.updateValues(e)}updateValues(t){return this.values=t,this.updateContext(this.global.context)}destroy(t={stagger:0,byParent:!1}){const e=!t.byParent,n=this.global,r=this.subject,o=t.byParent?[]:it(this.global.childTags);e&&a(this.templater)&&(n.destroy$.next(),H(this,this)),this.destroySubscriptions();for(let t=o.length-1;t>=0;--t){const e=o[t],n=e.global;delete n.newest,n.deleted=!0,a(e.templater)&&H(e,e)}let s;if("TEMPLATE"===n.insertBefore.nodeName){n.placeholder&&!("arrayValue"in this.memory)&&(t.byParent||st(this))}if(e){const{stagger:e,promise:n}=this.destroyClones(t);t.stagger=e,n&&(s=n)}else this.destroyClones();return delete n.placeholder,n.context={},delete n.oldest,delete n.newest,this.global.childTags.length=0,delete r.tagSupport,s=s?s.then((async()=>{const t=o.map((t=>t.destroy({stagger:0,byParent:!0})));return Promise.all(t)})):Promise.all(o.map((t=>t.destroy({stagger:0,byParent:!0})))),s.then((()=>t.stagger))}destroyClones({stagger:t}={stagger:0}){const e=[...this.clones];this.clones.length=0;const n=e.map((e=>this.checkCloneRemoval(e,t))).filter((t=>t)),r=this.global.context;for(const t in r){const e=r[t].clone;e?.parentNode&&e.parentNode.removeChild(e)}return n.length?{promise:Promise.all(n),stagger:t}:{stagger:t}}checkCloneRemoval(t,e){let n;const r=t;r.ondestroy&&(n=function(t,e){const n=t.ondestroy;if(!n)return;const r=n.tagFunction;if(!r)return;const o=r.tagFunction;if(!o)return;return o({target:t,stagger:e})}(r,e));const o=()=>{const e=t.parentNode;e&&e.removeChild(t);const n=this.ownerTagSupport;n&&(n.clones=n.clones.filter((e=>e!==t)))};return n instanceof Promise?n.then(o):(o(),n)}destroySubscriptions(){const t=this.global.subscriptions;for(let e=t.length-1;e>=0;--e)t[e].unsubscribe();t.length=0}}class ne extends ee{templater;ownerTagSupport;subject;version;isApp=!1;constructor(t,e,n,r,o=0){super(t,n,r),this.templater=t,this.ownerTagSupport=e,this.subject=n,this.version=o}getAppTagSupport(){let t=this;for(;t.ownerTagSupport;)t=t.ownerTagSupport;return t}}function re(t,e,n,r,o){if(!0!==t.tagged){const e=t.wrapper.parentWrap.original;let n=e.name||e.constructor?.name;"Function"===n&&(n=void 0);const r=n||e.toString().substring(0,120);throw new Error(`Not a tag component. Wrap your function with tag(). Example tag(props => html\`\`) on component:\n\n${r}\n\n`)}const s=new ne(t,r,e);let a=e.tagSupport;(s.global=a?.global||s.global).insertBefore=n;if(!a){a=function(t,e,n){const r=n.clones.map((t=>t));if(e=ce(e,t.tagSupport,t,n),n.clones.length>r.length){const t=n.clones.filter((t=>!r.find((e=>e===t))));e.clones.push(...t)}return e}(e,a||s,r)}const l=Z(a,e,n,o);return r.global.childTags.push(l),a}function oe(t,e,n){return t.map((t=>function(t,e,n,r){if(o(t)||!t)return t;if(!e)return t;return se(t,e,n,r)}(t,e.ownerTagSupport,n,e)))}function se(t,e,n,r,o,s,a=[]){if(t instanceof Function)return function(t,e,n,r,o,s){const a=t.toCall;if(a)return t;const l=(...t)=>l.toCall(...t);return l.toCall=(...t)=>function(t,e,n,r){const o=n.global.newest,s=void 0===y(),a=t(...e),l=()=>{if(!1===s){const t=o.memory.state.every((t=>{const e=t.lastValue,n=t.get();return M(D(e),n)}));if(t)return a}return ge(o,!0),a};if(s)return l();return v.memory.tagClosed$.toCallback(l),a}(l.prop,t,e,l.stateArray),l.original=t,l.prop=t,l.stateArray=n,Object.assign(l,t),l}(t,e,n);if(a.includes(t))return t;if(a.push(t),"object"!=typeof t||!t)return t;if(t instanceof Array){for(let o=t.length-1;o>=0;--o){const s=t[o];if(t[o]=se(s,e,n,r,o,t,a),s instanceof Function){if(s.toCall)continue;ae(o,s,t,r)}}return t}for(const o in t){const s=t[o],l=se(s,e,n,r,o,t,a),i=Object.getOwnPropertyDescriptor(t,o)?.set;if(!i&&(t[o]=l,l instanceof Function)){if(s.toCall)continue;ae(o,s,t,r)}}return t}function ae(t,e,n,r){e?.toCall||r.global.destroy$.toCallback((()=>n[t]=e))}function le(t,e,n,r,o=!1){let s=n.tagSupport?.global.newest;const a=s.templater.wrapper,l=e.templater.wrapper;let i=!1;if(a&&l){i=a.parentWrap.original===l.parentWrap.original}const c=e.templater;if(!i){X(s.global.oldest);return re(c,n,r,t,{counts:{added:0,removed:0}})}{const n=function(t,e,n){const r=G(n.props,t.propsConfig.latestCloned);if(r)return r;const o=G(t.propsConfig.latestCloned,e.propsConfig.latestCloned);if(o)return o;const s=function(t,e){const n=t.propsConfig.lastClonedKidValues,r=e.propsConfig.lastClonedKidValues;return!n.every(((t,e)=>{const n=r[e];return t.every(((t,e)=>t===n[e]))}))&&9}(t,e);return s}(s,e,c);if(!n){const n=function(t,e,n,r){const o=e.global.newest;if(!o){const e=n.memory.state;r.length=0;const o=oe(r,t,e);return r.push(...o),t.propsConfig.castProps=o,r}e=o||e;const s=e.propsConfig,a=s.castProps,l=[];for(let e=r.length-1;e>=0;--e){const o=r[e],s=ie(a[e],o,t,n);l.push(s)}return t.propsConfig.castProps=l,l}(e,s,t,c.props);return e.propsConfig.castProps=n,s.propsConfig.latestCloned=e.propsConfig.latestCloned,s.propsConfig.lastClonedKidValues=e.propsConfig.lastClonedKidValues,s}}const u=s.global.oldest;if(e.global.locked)return e.global.blocked.push(e),e;return function(t,e,n,r,o,s){let a=t.tagSupport;if(e&&n.children._value.length){e.templater.children.next(n.children._value)}const l=s&&U(r,o);if(l){const e=a.global.oldest;return t.tagSupport=o,e.updateBy(o),o}s&&a&&(r.global.deleted||X(r),o.global.context={});return function(t,e,n,r){return t.buildBeforeElement(e,{counts:{added:0,removed:0}}),t.global.oldest=t,t.global.newest=t,n.global.oldest=t,n.global.newest=t,r.tagSupport=t,r.tagSupport.ownerTagSupport.global.childTags.push(t),t}(o,o.global.insertBefore,o,t)}(n,u,c,s.global.newest,ge(e,o),i)}function ie(t,e,n,r,o=[]){if(t instanceof Function){if(e.toCall)return t.toCall=e.toCall,e;const n=r.global.newest.memory.state;return t.prop=e,t.stateArray=n,t}if(o.includes(e))return e;if(o.push(e),"object"!=typeof e||!e)return e;if(e instanceof Array){for(let s=e.length-1;s>=0;--s){const a=e[s];e[s]=ie(t[s],a,n,r,o)}return e}if(void 0===t)return e;for(const s in e){const a=e[s],l=ie(t[s],a,n,r,o),i=Object.getOwnPropertyDescriptor(e,s)?.set;i||(e[s]=l)}return e}function ce(t,e,n,r){const o=K(t,e,n,r);!e||U(e,o)||(!function(t,e,n){const r=t.global,o=r.insertBefore,s=e.global={...r};!function(t,e){t.global.destroy$,t.global.providers.forEach((n=>{n.children.forEach(((r,o)=>{if(t.global.destroy$===r.global.destroy$)return n.children.splice(o,1),void n.children.push(e)}))}))}(t,e),X(t),s.insertBefore=o,delete s.deleted,s.oldest=e,s.newest=e,n.tagSupport=e;const a=e.global.placeholder?.parentNode,l=o.parentNode;a&&l&&l.removeChild(o)}(e,o,n),o.global.oldest=o);const s=e?.ownerTagSupport;return o.ownerTagSupport=r||s,o}function ue(t,e){const n=function(t,e,n=[]){n.push({tagSupport:t,renderCount:t.global.renderCount,provider:e});const r=e.children;for(let t=r.length-1;t>=0;--t)n.push({tagSupport:r[t],renderCount:r[t].global.renderCount,provider:e});return n}(t,e);for(let t=n.length-1;t>=0;--t){const{tagSupport:e,renderCount:r,provider:o}=n[t];if(e.global.deleted)continue;r===e.global.renderCount&&(o.clone=D(o.instance),ge(e.global.newest,!1))}}function pe(t,e,n,r){const o=r.tagSupport,s=o.global;e.global=s;const a=s.renderCount;!function(t){const e=t.global.providers.filter((t=>!M(t.instance,t.clone)));for(let t=e.length-1;t>=0;--t){const n=e[t];ue(n.owner,n),n.clone=D(n.instance)}}(t);const l=s.newest;if(a!==s.renderCount)return t.global.oldest.updateBy(l),l;const i=ce(e,l||o||s.oldest,r,n),c=s.oldest||t;return U(l,i)&&(r.tagSupport=i,c.updateBy(i)),i}function ge(t,e){const n=t.global,r=t.templater;if(!r.wrapper){const e=t.ownerTagSupport;return++n.renderCount,e.global.deleted?t:ge(e.global.newest,!0)}if(t.global.locked)return t.global.blocked.push(t),t;const o=t.subject,s=t.global.oldest;let a,l=!1;if(e&&t&&(a=t.ownerTagSupport,a)){l=!M(r.props,t.propsConfig.latestCloned)}const i=pe(s,t,a,o);if(a&&l){return ge(a.global.newest,!0),i}return i}function fe(t,e,n,...r){const o=t.memory.state;j(o,n);const s=e(...r);return j(n,o),ge(t,!1),s instanceof Promise&&s.finally((()=>{j(n,o),ge(t,!1)})),s}let de=t=>(t,e,n,r,o,s)=>{throw new T("Callback function was called immediately in sync and must instead be call async")};const he=()=>de,be=de;function me(t){const e=y();if(!e){throw new T("callback() was called outside of synchronous rendering. Use `callback = callbackMaker()` to create a callback that could be called out of sync with rendering")}const n=v.memory.stateConfig.array;return(...r)=>e.global.callbackMaker?fe(e,t,n,...r):t(...r)}function ye(t){const e=v.memory.stateConfig.array;de=n=>(...r)=>t.global.callbackMaker?fe(t,n,e,...r):n(...r)}function ve(t){E(t)}function we(t){E((()=>{const e=y();e?.global.destroy$.toCallback(t)}))}function Ce(t){v.memory.childrenCurrentSupport=t}function Se(){return v.memory.childrenCurrentSupport.templater.children}v({beforeRender:t=>ye(t),beforeRedraw:t=>ye(t),afterRender:t=>{t.global.callbackMaker=!0,de=be}}),v({beforeRender:t=>Ce(t),beforeRedraw:t=>Ce(t)});const Te=[];function Ae(t,...e){return new et(t,e)}let ke=0;function xe(e){const n=function(...e){const r=new ct(e);r.tagJsType=t.tagComponent;const o=function(e,n){const r=v.memory.stateConfig.array;return function(o,s){const a=o.global;++a.renderCount;const l=e.children,i=a.oldest?.templater.children.lastArray;i&&(l.lastArray=i);const c=n.original;let u=e.props;const p=o.propsConfig.castProps||oe(u,o,r);u.map((t=>D(t)));let g=c(...p);g instanceof Function&&(g=g()),g&&g.tagJsType===t.tag||(g=Ae`${g}`),g.templater=e,e.tag=g,g.memory.arrayValue=e.arrayValue;const f=new ne(e,o.ownerTagSupport,s,p,a.renderCount);f.global=a;const d=v.memory.stateConfig.array;if(f.memory.state.push(...d),e.madeChildIntoSubject){const t=l.value;for(let e=t.length-1;e>=0;--e){const n=t[e],r=n.values;for(let t=r.length-1;t>=0;--t){const e=r[t];if(!(e instanceof Function))continue;const o=n.values[t];o.isChildOverride||(n.values[t]=function(...t){const n=f.ownerTagSupport;return dt(e,n,this,t)},o.isChildOverride=!0)}}}return f}}(r,n);return o.parentWrap||(o.parentWrap=n),r.tagged=!0,r.wrapper=o,r};n.original=e,n.compareTo=e.toString();const r=e;return n.isTag=!0,n.original=r,r.tags=Te,r.setUse=v,r.tagIndex=ke++,Te.push(n),n}xe.oneRender=(...t)=>{throw new Error("Do not call function tag.oneRender but instead set it as: `(props) => tag.oneRender = (state) => html`` `")},xe.route=t=>{throw new Error("Do not call function tag.route but instead set it as: `tag.route = (routeProps: RouteProps) => (state) => html`` `")},xe.app=t=>{throw new Error("Do not call function tag.route but instead set it as: `tag.route = (routeProps: RouteProps) => (state) => html`` `")},Object.defineProperty(xe,"oneRender",{set(t){t.oneRender=!0}});const je=[];function Ee(t,e,n){const r=je.findIndex((t=>t.element===e));r>=0&&(je[r].tagSupport.destroy(),je.splice(r,1),console.warn("Found and destroyed app element already rendered to element",{element:e}));const o=function(t){let e={};const n=new d(e);e=new ee(t,n),n.next(t),n.tagSupport=e,L(e,void 0);const r=t.wrapper,o=r(e,n);return z(e,o),o}(t(n));o.appElement=e,o.isApp=!0,o.global.isApp=!0;const s=document.createElement("template");s.setAttribute("id","app-tag-"+je.length),s.setAttribute("app-tag-detail",je.length.toString());const a=document.createDocumentFragment();return a.appendChild(s),e.destroy=async()=>{await o.destroy();const t=o.global.insertBefore;t.parentNode.removeChild(t)},o.buildBeforeElement(s),o.global.oldest=o,o.global.newest=o,e.setUse=t.original.setUse,je.push({element:e,tagSupport:o}),e.appendChild(a),{tagSupport:o,tags:t.original.tags}}const Be={tagElement:Ee,renderWithSupport:ce,renderTagSupport:ge,renderTagOnly:K};var Re=n.W9,Pe=n.t3,Ve=n.Y2,Fe=n.ei,Oe=n.B7,Ne=n.XF,_e=n.vw,De=n.PC,$e=n.uX,Me=n.O9,We=n.Ot,Je=n.tD,Ue=n.E2,Ie=n.OH,Le=n.Y_,ze=n.zV,He=n.WJ,Ke=n.AZ,Xe=n.cF,Ge=n.qy,Ye=n.u2,Ze=n.zl,qe=n.O5,Qe=n.Ze,tn=n._4,en=n.iO,nn=n.dk,rn=n.mn,on=n.NM,sn=n.z,an=n.bc,ln=n.sA,cn=n.MG,un=n.t2,pn=n.r5,gn=n.pG,fn=n.yN,dn=n.QB,hn=n.vJ,bn=n.AI,mn=n.wk,yn=n.uz,vn=n.Tc,wn=n.Hf,Cn=n._A,Sn=n.NU,Tn=n.wB,An=n.id,kn=n.MC,xn=n.zC;export{Re as ArrayNoKeyError,Pe as BaseTagSupport,Ve as RouteQuery,Fe as StateMismatchError,Oe as Subject,Ne as SyncCallbackError,_e as Tag,De as TagError,$e as TagSupport,Me as TemplaterResult,We as ValueSubject,Je as ValueTypes,Ue as callback,Ie as callbackMaker,Le as children,ze as combineLatest,He as defineValueOn,Ke as getValueType,Xe as hmr,Ge as html,Ye as interpolateElement,Ze as interpolateString,qe as isLikeValueSets,Qe as isStaticTag,tn as isSubjectInstance,en as isTagArray,nn as isTagClass,rn as isTagComponent,on as isTagTemplater,sn as letProp,an as letState,ln as onDestroy,cn as onInit,un as oneRenderToTagSupport,pn as providers,gn as renderTagOnly,fn as renderTagSupport,dn as renderWithSupport,hn as runBeforeRender,bn as setUse,mn as state,yn as subject,vn as tag,wn as tagElement,Cn as tags,Sn as variablePrefix,Tn as watch,An as willCallback,kn as willPromise,xn as willSubscribe};
|
|
1
|
+
var t,e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},n={};e.d(n,{W9:()=>C,t3:()=>le,Y2:()=>r,ei:()=>S,B7:()=>g,XF:()=>T,vw:()=>Y,PC:()=>w,uX:()=>ie,O9:()=>at,Ot:()=>d,tD:()=>t,E2:()=>Ce,OH:()=>ve,fq:()=>ce,Y_:()=>xe,zV:()=>u,WJ:()=>f,AZ:()=>rt,cF:()=>Fe,qy:()=>Ee,u2:()=>ne,zl:()=>oe,O5:()=>I,Ze:()=>o,_4:()=>i,iO:()=>c,dk:()=>l,mn:()=>a,NM:()=>s,z:()=>_,bc:()=>O,sA:()=>ke,MG:()=>Te,t2:()=>Kt,r5:()=>J,pG:()=>K,yN:()=>be,QB:()=>fe,Ps:()=>ue,vJ:()=>L,AI:()=>v,wk:()=>E,uz:()=>F,Tc:()=>Re,Hf:()=>Ve,_A:()=>je,NU:()=>q,wB:()=>P,id:()=>h,MC:()=>b,zC:()=>m});class r{get(t){return"todo"}}function o(e){return[t.tag,t.templater].includes(e?.tagJsType)}function s(e){return e?.tagJsType===t.templater}function a(e){return e?.tagJsType===t.tagComponent}function l(e){return e?.tagJsType===t.tag}function i(t){return!(!0!==t?.isSubject&&!t?.subscribe)}function c(e){return e instanceof Array&&e.every((e=>[t.tag,t.templater,t.tag,t.tagComponent].includes(e?.tagJsType)))}function u(t){const e=new g;return e.subscribeWith=e=>{const n=[],r=[],o=(o,s)=>{n[s]=!0,r[s]=o;if(n.length===t.length){for(let t=n.length-1;t>=0;--t)if(!n[t])return;e(r,a)}},s=[...t],a=s.shift().subscribe((t=>o(t,0))),l=s.map(((t,e)=>t.subscribe((t=>o(t,e+1)))));return a.subscriptions=l,a},e}function p(t,e,n){const r=[...e],o=r.shift(),s=t=>{if(r.length)return p(t,r,n);n(t)};let a=s;const l=o(t,{setHandler:t=>a=t,next:s});a(l)}!function(t){t.unknown="unknown",t.tag="tag",t.templater="templater",t.tagComponent="tag-component",t.tagArray="tag-array",t.subject="subject",t.date="date",t.string="string",t.boolean="boolean",t.function="function",t[void 0]="undefined"}(t||(t={}));class g{value;onSubscription;methods=[];isSubject=!0;subscribers=[];subscribeWith;_value;set;constructor(t,e){this.value=t,this.onSubscription=e,this._value=t,f(this)}subscribe(t){const e=function(t,e,n){const r=g.globalSubCount$;g.globalSubCount$.next(r._value+1);const o=()=>{o.unsubscribe()};return o.callback=e,o.subscriptions=[],o.unsubscribe=()=>{!function(t,e){const n=t.findIndex((t=>t.callback===e));-1!==n&&t.splice(n,1)}(n,e),g.globalSubCount$.next(r._value-1),o.unsubscribe=()=>o;const t=o.subscriptions;for(let e=t.length-1;e>=0;--e)t[e].unsubscribe();return o},o.add=t=>(o.subscriptions.push(t),o),o.next=t=>{e(t,o)},o}(0,t,this.subscribers),n=this.subscribeWith;if(n){if(this.methods.length){const n=t;t=t=>{p(t,this.methods,(t=>n(t,e)))}}return n(t)}return this.subscribers.push(e),this.onSubscription&&this.onSubscription(e),e}next(t){this._value=t,this.emit()}emit(){const t=this._value,e=[...this.subscribers],n=e.length;for(let r=0;r<n;++r){const n=e[r];n.callback(t,n)}}toPromise(){return new Promise((t=>{this.subscribe(((e,n)=>{n.unsubscribe(),t(e)}))}))}toCallback(t){const e=this.subscribe(((n,r)=>{e.unsubscribe(),t(n)}));return this}pipe(...t){const e=new g(this._value);return e.setMethods(t),e.subscribeWith=t=>this.subscribe(t),e.next=t=>this.next(t),e}setMethods(t){this.methods=t}static all(t){return u(t.map((t=>{if(i(t))return t;return new g(t,(e=>(e.next(t),e)))})))}static globalSubCount$=new g(0)}function f(t){Object.defineProperty(t,"value",{set(e){t._value=e,t.emit()},get:()=>t._value}),Object.defineProperty(t,"set",{set:e=>t.next(e),get:()=>e=>t.next(e)})}class d extends g{value;constructor(t){super(t),this.value=t,f(this)}subscribe(t){const e=super.subscribe(t);return t(this._value,e),e}}function h(t){return(e,n)=>{n.setHandler((()=>{})),t(e,n.next)}}function b(t){return(e,n)=>{n.setHandler((()=>{}));t(e).then((t=>n.next(t)))}}const m=t=>(e,n)=>{n.setHandler((()=>{}));const r=t(e).subscribe((t=>{r.unsubscribe(),n.next(t)}))};function y(){return v.memory.stateConfig.tagSupport}function v(t){const e={beforeRender:t.beforeRender||(()=>{}),beforeRedraw:t.beforeRedraw||(()=>{}),afterRender:t.afterRender||(()=>{}),beforeDestroy:t.beforeDestroy||(()=>{})};v.tagUse.push(e)}v.tagUse=[],v.memory={};class w extends Error{details;constructor(t,e,n={}){super(t),this.name=w.name,this.details={...n,errorCode:e}}}class C extends w{constructor(t,e){super(t,"array-no-key-error",e),this.name=C.name}}class S extends w{constructor(t,e){super(t,"state-mismatch-error",e),this.name=S.name}}class T extends w{constructor(t,e){super(t,"sync-callback-error",e),this.name=T.name}}v.memory.stateConfig={array:[]};const k=t=>function(t){const e=t.memory,n=e.state,r=v.memory.stateConfig;r.rearray=[];const o=n?.length;if(o){for(let t=0;t<o;++t)A(n[t]);r.rearray.push(...n)}r.tagSupport=t}(t);function A(t){const e=t.callback;if(!e)return t.defaultValue;const[n,r]=function(t){const e=t(x),[n]=e,[r]=t(n);return[n,r]}(e);if(r!==x){const o='letState function incorrectly used. Second item in array is not setting expected value.\n\nFor "let" state use `let name = state(default)(x => [name, name = x])`\n\nFor "const" state use `const name = state(default)()`\n\nProblem state:\n'+(e?e.toString():JSON.stringify(t))+"\n";throw console.error(o,{state:t,callback:e,value:n,checkValue:r}),new Error(o)}return n}v({beforeRender:k,beforeRedraw:k,afterRender:t=>{const e=t.memory,n=v.memory.stateConfig,r=n.rearray;if(r.length&&r.length!==n.array.length){const e=`States lengths have changed ${r.length} !== ${n.array.length}. State tracking requires the same amount of function calls every render. Typically this errors is thrown when a state like function call occurs only for certain conditions or when a function is intended to be wrapped with a tag() call`,o=t.templater?.wrapper,s={oldStates:n.array,newStates:n.rearray,tagFunction:o.parentWrap.original},a=new S(e,s);throw console.warn(e,s),a}delete n.rearray,delete n.tagSupport,e.state.length=0,e.state.push(...n.array);const o=e.state;for(let t=o.length-1;t>=0;--t){const e=o[t];e.lastValue=A(e)}n.array=[]}});class x{}function j(t,e){for(let n=t.length-1;n>=0;--n){const r=t[n].get(),o=e[n].callback;o&&o(r),e[n].lastValue=r}}function E(t){const e=v.memory.stateConfig;let n;const r=e.rearray[e.array.length];if(r){let t=A(r);n=e=>[t,t=e];const o={get:()=>A(o),callback:n,lastValue:t,defaultValue:r.defaultValue};return e.array.push(o),t}let o=(t instanceof Function?t:()=>t)();if(o instanceof Function){const t=e.array,n=e.tagSupport,r=o;o=(...e)=>{const o=n.global.newest.memory.state;j(o,t);const s=r(...e);return j(t,o),s},o.original=r}n=t=>[o,o=t];const s={get:()=>A(s),callback:n,lastValue:o,defaultValue:o};return e.array.push(s),o}const P=(t,e)=>B(t,e),R=t=>t;const B=(t,e,{init:n,before:r=(()=>!0),final:o=R}={})=>{let s=E({pastResult:void 0,values:void 0});const a=s.values;if(void 0===a){if(!r(t))return s.values=t,s.pastResult;const l=(n||e)(t,a);return s.pastResult=o(l),s.values=t,s.pastResult}if(t.every(((t,e)=>t===a[e])))return s.pastResult;if(!r(t))return s.values=t,s.pastResult;const l=e(t,a);return s.pastResult=o(l),a.length=0,a.push(...t),s.pastResult};function V(t,e){return Object.defineProperty(e,"noInit",{get(){const e=t();return e.setup.init=()=>{},e}}),Object.defineProperty(e,"asSubject",{get(){const e=t(),n=E((()=>y())),r=E((()=>new d(void 0))),o=(t,o)=>(B(t,((t,e)=>{const s=y(),a=o(t,e);if(s!==n){j(v.memory.stateConfig.array,n.memory.state)}r.next(a)}),e.setup),r);return o.setup=e.setup,V((()=>o),o),o}}),Object.defineProperty(e,"truthy",{get(){const e=t();return e.setup.before=t=>t.every((t=>t)),e}}),e}function F(t,e){const n=E((()=>v.memory.stateConfig.array)),r=y();return E((()=>new g(t,e).pipe((t=>(j(r.memory.state,n),t)))))}function O(t){const e=v.memory.stateConfig;let n;const r=e.rearray[e.array.length];if(r){let t=A(r);n=e=>[t,t=e];const o={get:()=>A(o),callback:n,lastValue:t,defaultValue:r.defaultValue};return e.array.push(o),N(t,o)}let o=(t instanceof Function?t:()=>t)();n=t=>[o,o=t];const s={get:()=>A(s),callback:n,lastValue:o,defaultValue:o};return e.array.push(s),N(o,s)}function N(t,e){return n=>(e.callback=n||(e=>[t,t=e]),t)}function _(t){return e=>{let n=O(t)(e);return P([t],(()=>e(n=t))),e(n),n}}function D(t){return $(t,new WeakMap)}function $(t,e){if(null===t||"object"!=typeof t)return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));if(e.set(t,n),Array.isArray(t))for(let r=0;r<t.length;r++)n[r]=$(t[r],e);else for(const r in t)t.hasOwnProperty(r)&&(n[r]=$(t[r],e));return n}function M(t,e){return W(t,e,new WeakMap)}function W(t,e,n){return!!(t===e||(r=t,o=e,r instanceof Function&&o instanceof Function&&r.toString()===o.toString()))||(!!n.has(t)||"object"==typeof t&&"object"==typeof e&&(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():(n.set(t,0),Array.isArray(t)&&Array.isArray(e)?function(t,e,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!W(t[r],e[r],n))return!1;return!0}(t,e,n):!Array.isArray(t)&&!Array.isArray(e)&&function(t,e,n){const r=Object.keys(t),o=Object.keys(e);if(0===r.length&&0===o.length)return!0;if(r.length!==o.length)return!1;for(const s of r){if(!o.includes(s)||!W(t[s],e[s],n))return!1}return!0}(t,e,n))));var r,o}V((()=>function(t){const e=(e,n)=>B(e,n,t);return e.setup=t,V((()=>e),e),e}({})),P),F._value=t=>{const e=E((()=>v.memory.stateConfig.array)),n=y();return E((()=>new d(t).pipe((t=>(j(n.memory.state,e),t)))))},F.all=function(t){const e=E((()=>v.memory.stateConfig.array)),n=y();return g.all(t).pipe((t=>(j(n.memory.state,e),t)))};const J={create:t=>{const e=E((()=>({stateDiff:0,provider:void 0})));if(e.stateDiff){for(let t=e.stateDiff;t>0;--t)E(void 0);return E(void 0)}const n=E((()=>{const n=v.memory.stateConfig,r=n.array.length,o="prototype"in t?new t:t(),s=n.tagSupport,a=n.array.length-r,l={constructMethod:t,instance:o,clone:D(o),stateDiff:a,owner:s,children:[]};return e.provider=l,s.global.providers.push(l),e.stateDiff=a,o})),r=t,o=r.compareTo=r.toString();return e.provider.constructMethod.compareTo=o,n},inject:t=>E((()=>{const e=v.memory,n=t,r=n.compareTo=n.compareTo||t.toString(),o=e.stateConfig.tagSupport,s=[];let a={ownerTagSupport:o.ownerTagSupport};for(;a.ownerTagSupport;){const t=a.ownerTagSupport.global.providers.find((t=>{s.push(t);if(t.constructMethod.compareTo===r)return!0}));if(t){t.clone=D(t.instance);const n=e.stateConfig.tagSupport;return n.global.providers.push(t),t.children.push(n),t.instance}a=a.ownerTagSupport}const l=`Could not inject provider: ${t.name} ${t}`;throw console.warn(`${l}. Available providers`,s),new Error(l)}))};function U(t,e){const n=t.templater,r=e.templater,o=n?.tag||t,s=r.tag,a=o.strings,l=e.strings||s.strings;if(a.length!==l.length)return!1;if(!a.every(((t,e)=>l[e]===t)))return!1;return I(t.values||o.values,e.values||s.values)}function I(t,e){if(!(t.length===e.length))return!1;return!!e.every(((e,n)=>{const r=t[n];if(e instanceof Function&&r instanceof Function){return!!(e.toString()===r.toString())}return!0}))}function L(t,e){const n=v.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].beforeRender(t,e)}function z(t,e){const n=v.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].afterRender(t,e);v.memory.tagClosed$.next(e)}function H(t,e){const n=v.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].beforeDestroy(t,e);if(t.global.deleted=!0,t.hasLiveElements=!1,e){e.global.childTags=e.global.childTags.filter((e=>e!==t.global.oldest));const n=t.global;n.providers.forEach((t=>t.children.forEach(((e,r)=>{e.global===n&&t.children.splice(r,1)}))))}}function K(t,e,n,r){const o=t.global.renderCount;!function(t,e,n){const r=n?.ownerTagSupport,o=r||e;if(n){if(n!==t){const e=n.memory.state,r=t.memory;t.global=n.global,r.state.length=0,r.state.push(...e)}return function(t,e){const n=v.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].beforeRedraw(t,e)}(t,n)}L(t,o)}(t,r,e);let s=(0,t.templater.wrapper)(t,n);return z(t,r),t.global.newest=s,!e&&r&&r.global.childTags.push(s),s.global.renderCount>o+1?t.global.newest:s}v.memory.tagClosed$=new g(void 0,(t=>{y()||t.next()}));const q="__tagvar",X="--"+q+"--",G=new RegExp(X,"g");class Y{strings;values;tagJsType=t.tag;memory={};templater;constructor(t,e){this.strings=t,this.values=e}key(t){return this.memory.arrayValue=t,this}children;html(t,...e){return this.children={strings:t,values:e},this}}function Z(t){t.global.oldest.destroy(),t.global.context={}}function Q(t,e){e.parentNode.insertBefore(t,e.nextSibling)}function tt(t){return["string","number","boolean"].includes(t)}function et(t,e){t.destroy({stagger:e.removed++});const n=t.global.insertBefore;n.parentNode.removeChild(n)}function nt(t){const e=t.global.insertBefore,n=t.global,r=n.placeholder;r&&(Q(e,r),delete n.placeholder)}function rt(e){if(null==e)return t.undefined;const n=typeof e;if(e instanceof Function)return t.function;if("object"===n){if(e instanceof Date)return t.date;if(tt(n))return n;const r=e.tagJsType;if(r){if([t.tagComponent,t.templater,t.tag].includes(r))return r}if(c(e))return t.tagArray;if(i(e))return t.subject}return t.unknown}function ot(e){return e.map((e=>{const n=e;switch(rt(e)){case t.tagComponent:return D(e.props);case t.tag:case t.templater:return ot(n.values);case t.tagArray:return ot(n)}return D(e)}))}function st(t,e=[]){for(let n=t.length-1;n>=0;--n){const r=t[n];e.push(r),t.splice(n,1),st(r.global.childTags,e)}return e}class at{props;tagJsType="templater";tagged;wrapper;madeChildIntoSubject;tag;children=new d([]);arrayValue;constructor(t){this.props=t}key(t){return this.arrayValue=t,this}html(t,...e){const n=function(t,e){if(i(t))return t;if(c(t))return e.madeChildIntoSubject=!0,new d(t);const n=t;return n?(e.madeChildIntoSubject=!0,n.memory.arrayValue=0,new d([n])):(e.madeChildIntoSubject=!0,new d([]))}(new Y(t,e),this);return this.children=n,this}}function lt(t,e){const n=t;let r=n.templater;r||(r=new at([]),r.tag=n,n.templater=r);const o=new d(r);return o.tagSupport=new ie(r,e,o),e.global.childTags.push(o.tagSupport),o}function it(t){const e=document.createTextNode(""),n=t.parentNode;return n.insertBefore(e,t),n.removeChild(t),e}function ct(t,e,n){const r=t.split(".");if("style"===r[0]&&(n.style[r[1]]=e),"class"===r[0])if(r.shift(),e)for(let t=0;t<r.length;++t)n.classList.add(r[t]);else for(let t=0;t<r.length;++t)n.classList.remove(r[t])}function ut(t,e){let n=t,r=e;if("object"==typeof t){if(!e)return 3;n=[...t],r=[...e||[]];if(!n.every(((t,e)=>{let o=r[e];if(t&&"object"==typeof t){const e={...t},n={...o||{}},r=Object.entries(e).every((([t,r])=>pt(r,n[t],(()=>{delete e[t],delete n[t]}))));return r}return pt(t,o,(()=>{n.splice(e,1),r.splice(e,1)}))})))return 6}return!1}function pt(t,e,n){if(!(t instanceof Function))return!!M(t,e)&&4;if(!(e instanceof Function))return!1;const r=e?.original;r&&(e=r);t.original&&(t=t.original);return t.toString()===e.toString()?(n(),3):(n(),5)}function gt(t,e,n,{counts:r}){const o=e,s=o.tagSupport,a=s?.global.oldest||void 0;return a&&a?function(t,e,n){if(e instanceof Function){const t=e(n);return n.updateBy(t),e.tagSupport=t,t}return n.updateBy(t),e.tagSupport=t,t}(t,o,a):(t.buildBeforeElement(n,{counts:r}),t)}function ft(t,e,n,r,o){if(!0!==t.tagged){const e=t.wrapper.parentWrap.original;let n=e.name||e.constructor?.name;"Function"===n&&(n=void 0);const r=n||e.toString().substring(0,120);throw new Error(`Not a tag component. Wrap your function with tag(). Example tag(props => html\`\`) on component:\n\n${r}\n\n`)}const s=new ie(t,r,e);let a=e.tagSupport;(s.global=a?.global||s.global).insertBefore=n;if(!a){a=function(t,e,n){const r=n.global.clones.map((t=>t));if(e=fe(e,t.tagSupport,t,n),n.global.clones.length>r.length){const t=n.global.clones.filter((t=>!r.find((e=>e===t))));e.global.clones.push(...t)}return e}(e,a||s,r)}const l=gt(a,e,n,o);return r.global.childTags.push(l),a}function dt(t,e,n){return t.map((t=>function(t,e,n,r){if(o(t)||!t)return t;if(!e)return t;return ht(t,e,n,r)}(t,e.ownerTagSupport,n,e)))}function ht(t,e,n,r,o,s,a=[]){if(t instanceof Function)return function(t,e,n,r,o,s){const a=t.toCall;if(a)return t;const l=(...t)=>l.toCall(...t);return l.toCall=(...t)=>function(t,e,n,r){const o=n.global.newest,s=void 0===y(),a=t(...e),l=()=>{if(!1===s){const t=o.memory.state.every((t=>{const e=t.lastValue,n=t.get();return M(D(e),n)}));if(t)return a}return be(o,!0),a};if(s)return l();return v.memory.tagClosed$.toCallback(l),a}(l.prop,t,e,l.stateArray),l.original=t,l.prop=t,l.stateArray=n,Object.assign(l,t),l}(t,e,n);if(a.includes(t))return t;if(a.push(t),"object"!=typeof t||!t)return t;if(t instanceof Array){for(let o=t.length-1;o>=0;--o){const s=t[o];if(t[o]=ht(s,e,n,r,o,t,a),s instanceof Function){if(s.toCall)continue;bt(o,s,t,r)}}return t}for(const o in t){const s=t[o],l=ht(s,e,n,r,o,t,a),i=Object.getOwnPropertyDescriptor(t,o)?.set;if(!i&&(t[o]=l,l instanceof Function)){if(s.toCall)continue;bt(o,s,t,r)}}return t}function bt(t,e,n,r){e?.toCall||r.global.destroy$.toCallback((()=>n[t]=e))}function mt(t,e,n,r,o=!1){let s=n.tagSupport?.global.newest;const a=s.templater.wrapper,l=e.templater.wrapper;let i=!1;if(a&&l){i=a.parentWrap.original===l.parentWrap.original}const c=e.templater;if(!i){Z(s.global.oldest);return ft(c,n,r,t,{counts:{added:0,removed:0}})}{const n=function(t,e,n){const r=ut(n.props,t.propsConfig.latestCloned);if(r)return r;const o=ut(t.propsConfig.latestCloned,e.propsConfig.latestCloned);if(o)return o;const s=function(t,e){const n=t.propsConfig.lastClonedKidValues,r=e.propsConfig.lastClonedKidValues;return!n.every(((t,e)=>{const n=r[e];return t.every(((t,e)=>t===n[e]))}))&&9}(t,e);return s}(s,e,c);if(!n){const n=function(t,e,n,r){const o=e.global.newest;if(!o){const e=n.memory.state;r.length=0;const o=dt(r,t,e);return r.push(...o),t.propsConfig.castProps=o,r}e=o||e;const s=e.propsConfig,a=s.castProps,l=[];for(let e=r.length-1;e>=0;--e){const o=r[e],s=yt(a[e],o,t,n);l.push(s)}return t.propsConfig.castProps=l,l}(e,s,t,c.props);return e.propsConfig.castProps=n,s.propsConfig.latestCloned=e.propsConfig.latestCloned,s.propsConfig.lastClonedKidValues=e.propsConfig.lastClonedKidValues,s}}const u=s.global.oldest;if(e.global.locked)return e.global.blocked.push(e),e;return function(t,e,n,r,o,s){let a=t.tagSupport;if(e&&n.children._value.length){e.templater.children.next(n.children._value)}const l=s&&U(r,o);if(l){const e=a.global.oldest;return t.tagSupport=o,e.updateBy(o),o}s&&a&&(r.global.deleted||Z(r),o.global.context={});return function(t,e,n,r){return t.buildBeforeElement(e,{counts:{added:0,removed:0}}),t.global.oldest=t,t.global.newest=t,n.global.oldest=t,n.global.newest=t,r.tagSupport=t,r.tagSupport.ownerTagSupport.global.childTags.push(t),t}(o,o.global.insertBefore,o,t)}(n,u,c,s.global.newest,be(e,o),i)}function yt(t,e,n,r,o=[]){if(t instanceof Function){if(e.toCall)return t.toCall=e.toCall,e;const n=r.global.newest.memory.state;return t.prop=e,t.stateArray=n,t}if(o.includes(e))return e;if(o.push(e),"object"!=typeof e||!e)return e;if(e instanceof Array){for(let s=e.length-1;s>=0;--s){const a=e[s];e[s]=yt(t[s],a,n,r,o)}return e}if(void 0===t)return e;for(const s in e){const a=e[s],l=yt(t[s],a,n,r,o),i=Object.getOwnPropertyDescriptor(e,s)?.set;i||(e[s]=l)}return e}const vt=!0;function wt(t,e,n,r){const o=Ct(e),s=t.bind(n);o.global.locked=vt;return function(t,e){if(delete t.global.locked,t.global.blocked.length){let n;return t.global.blocked.forEach((e=>{const r=e;n=mt(r.ownerTagSupport,r,r.subject,r.global.insertBefore,!0),t.global.newest=n,t.global.blocked.splice(0,1)})),t.global.blocked.length=0,St(e,n,n.global)}const n=function(t,e,n){if(n.deleted)return"no-data-ever";return be(t,!0),St(e,t,n)}(t.global.newest,e,t.global);return n}(o,s(...r))}function Ct(e){if(e.templater.tagJsType===t.templater){return Ct(e.ownerTagSupport)}return e}function St(t,e,n){return t instanceof Promise?(e.global.locked=vt,t.then((()=>(delete e.global.locked,n.deleted||(delete e.global.locked,be(n.newest,!0)),"promise-no-data-ever")))):"no-data-ever"}const Tt=/^\s*{__tagvar/,kt=/}\s*$/;function At(t){return t&&t.search(Tt)>=0&&t.search(kt)>=0}function xt(t,e,n,r,o,s){if(At(e))return function(t,e,n,r,o,s){const a=jt(r,e);return Et(t,a,n,o,s)}(t,e,n,r,o,s);if(At(t)){let e;const a=jt(r,t).subscribe((t=>{t!==e&&(!function(t,e,n,r,o){if(e&&e!=t)if("string"==typeof e)n.removeAttribute(e);else if(e instanceof Object)for(const t in e)n.removeAttribute(t);if("string"==typeof t){if(!t.length)return;return void Et(t,"",n,r,o)}if(t instanceof Object)for(const e in t)Et(e,t[e],n,r,o)}(t,e,n,o,s),e=t)}));return o.global.subscriptions.push(a),void n.removeAttribute(t)}return Rt(t)?ct(t,e,n):void 0}function jt(t,e){return t[e.replace("{","").split("").reverse().join("").replace("}","").split("").reverse().join("")]}function Et(t,e,n,r,o){const s=Rt(t);if(e instanceof Function){const r=function(...t){return e(n,t)};n[t].action=r}if(i(e)){let a;n.removeAttribute(t);const l=e=>e instanceof Function?function(t,e,n,r,o,s){const a=t.templater.wrapper,l=a?.parentWrap,i=l?.oneRender;i||(e=function(t,e){if(t.isChildOverride)return t;v.memory.stateConfig;const n=(n,r)=>wt(t,e,n,r);return n.tagFunction=t,n}(e,t));return Pt(e,n,r,o,s)}(r,e,n,t,s,o):a===e?a:(a=e,Pt(e,n,t,s,o)),i=e.subscribe(l);r.global.subscriptions.push(i)}else o(n,t,e)}function Pt(t,e,n,r,o){if(t instanceof Function){const r=function(...n){return t(e,n)};return r.tagFunction=t,"ondoubleclick"===n&&(n="ondblclick"),void(e[n]=r)}if(r)return void ct(n,t,e);if(t)return void o(e,n,t);[void 0,!1,null].includes(t)?e.removeAttribute(n):o(e,n,t)}function Rt(t){return t.search(/^(class|style)(\.)/)>=0}function Bt(t,e,n){t.setAttribute(e,n)}function Vt(t,e,n){t[e]=n}function Ft(t,e,n){const r=t.getAttributeNames();let o=Bt;for(let s=0;s<r.length;++s){const a=r[s];"INPUT"===t.nodeName&&"value"===a&&(o=Vt);xt(a,t.getAttribute(a),t,e,n,o),o=Bt}}const Ot=/(?:<[^>]*?(?:(?:\s+\w+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+)))*\s*)\/?>)|({__tagvar[^}]+})/g;function Nt(t,e,n,r){let o=r.tagSupport;return o||(o=$t(t,n,r)),r.tagSupport=o,o.ownerTagSupport=n,o.buildBeforeElement(e,{counts:{added:0,removed:0}}),o}function _t(t){const e=Dt();return e.tag=t,t.templater=e,e}function Dt(){const t={children:new d([]),props:[],isTag:!0,tagJsType:"templater",tagged:!1,html:()=>t,key:()=>t};return t}function $t(t,e,n){const r=new ie(t,e,n);return Mt(r,e,n),e.global.childTags.push(r),r}function Mt(t,e,n){t.global.oldest=t,t.global.newest=t,t.ownerTagSupport=e,n.tagSupport=t}function Wt(t,e,n,r,o){const s=r.global.clones;let a=t.lastArray=t.lastArray||[];t.placeholder||function(t,e){if("TEMPLATE"!==t.nodeName)return void(e.placeholder=t);const n=e.placeholder=document.createTextNode(""),r=t.parentNode;r.insertBefore(n,t),r.removeChild(t)}(n,t);const i=t.placeholder;let c=0;a=t.lastArray=t.lastArray.filter(((t,n)=>{if(e.length-1<n-c)return It(a,n,o),++c,!1;const r=e[n-c],s=l(r);let i,u=r,p=r.templater;s?i=u.memory.arrayValue:(p=r,u=p.tag,i=p.arrayValue);const g=!function(t,e){if(t===e)return!0;if(t instanceof Array&&e instanceof Array&&t.length==e.length)return t.every(((t,n)=>t==e[n]));return!1}(i,t.tagSupport.templater.tag.memory.arrayValue);return!g||(It(a,n,o),++c,!1)}));const u=e.length;for(let t=0;t<u;++t){const n=e[t],s=a[t],c=s?.tagSupport,u=n,p=l(u),g=new d(void 0);let f,h=u.templater;if(p?(h||(h=_t(u)),f=new ie(h,r,g)):(h=u,f=Ut(h,r,g)),c){Mt(f,r,c.subject);const t=c.global;f.global=t,t.newest=f}if(!("arrayValue"in(h.tag||u).memory)){const t={template:f.getTemplate().string,array:e},n="Use html`...`.key(item) instead of html`...` to template an Array";console.error(n,t);throw new C(n,t)}if(a.length>t){s.tagSupport.global.oldest.updateBy(f)}else Jt(i,f,t,o,a),r.global.childTags.push(f)}return s}function Jt(t,e,n,r,o){const s={tagSupport:e,index:n};o.push(s);const a={added:r.counts.added+n,removed:r.counts.removed},l=document.createDocumentFragment(),i=document.createElement("template");l.appendChild(i),e.buildBeforeElement(i,{counts:a});t.parentNode.insertBefore(l,t)}function Ut(t,e,n){const r=$t(t,e,n);return K(r,r,n,e),r}function It(t,e,n){const r=t[e];et(r.tagSupport,n.counts),r.deleted=!0,++n.counts.removed}function Lt(t,e){const n=e.parentNode,r=document.createTextNode(t);return n.insertBefore(r,e),n.removeChild(e),r}function zt(t){return[void 0,!1,null].includes(t)?"":t}function Ht(t,e,n){e.insertBefore=n;const r=e.clone||n;if(e.lastValue===t&&"lastValue"in e)return;e.lastValue=t;const o=zt(t),s=e.clone;if(s)return void(s.textContent=o);const a=Lt(o,r);e.clone=a}function Kt(t,e,n){const r=new at([]);r.tagJsType="oneRender";const o=$t(r,n,e);const s=()=>(r.tag=t(),o);return r.wrapper=s,s.parentWrap=s,s.oneRender=!0,s.parentWrap.original=t,o}function qt(e,n,r,o,s){switch(rt(e)){case t.templater:return void Nt(e,r,o,n);case t.tag:const a=e;let l=a.templater;return l||(l=_t(a)),void Nt(l,r,o,n);case t.tagArray:return Wt(n,e,r,o,s);case t.tagComponent:return ft(e,n,r,o,s);case t.function:const i=e;if(i.oneRender){const t=Kt(i,n,o);return K(t,t,n,o),void Nt(t.templater,r,o,n)}}!function(t,e,n){e.lastValue=t;const r=Lt(zt(t),n);e.clone=r}(e,n,r)}const Xt=new RegExp('\\s*<template interpolate end id="__tagvar(\\d{1,4})"([^>]*)></template>(\\s*)');function Gt(e,n,r,a){const i=e,c=rt(n);if(function(e,n,r,s){const a=e,l="lastValue"in a,i=a.lastValue;if(l&&i!==n){const t=typeof n;return(!tt(t)||typeof i!==t)&&!(n instanceof Function&&i instanceof Function)&&(function(t,e){const n=e.clone,r=n.parentNode;r.insertBefore(t,n),r.removeChild(n),delete e.clone,delete e.lastValue}(r,a),"changed-simple-value")}const c=e,u=c.lastArray;if(u&&s!==t.tagArray){const t=c.placeholder;delete c.lastArray,delete c.placeholder,Q(r,t);for(let t=u.length-1;t>=0;--t){const{tagSupport:e}=u[t];et(e,{added:0,removed:0})}return"array"}const p=e.tagSupport;if(p){const r=o(n);return o(e._value)&&r?!U(n,p)&&(nt(p),Z(p),2):s!==t.tagComponent&&(!n||!n.oneRender)&&(nt(p),Z(p),"different-tag")}}(e,n,a,c),c===t.tagComponent)return function(t,e,n,r){if(!e.tagSupport)return ft(t,e,n,r,{counts:{added:0,removed:0}}),e;const o=new ie(t,r,e),s=e.tagSupport,a=s.global.newest;if(!a)return nt(s),ft(t,e,n,r,{counts:{added:0,removed:0}}),e;{const t=a.memory.state;o.memory.state.length=0,o.memory.state.push(...t)}return o.global=s.global,e.tagSupport=o,mt(r,o,e,n),e}(n,i,a,r);if(i.tagSupport)return c===t.function||function(t,e,n){const r=t.tagSupport;let o=e;const a=l(e);if(a){const t=e;o=t.templater,o||(o=new at([]),o.tag=t,t.templater=o)}const i=new ie(o,n,t);a&&(i.global=r.global);const c=e&&U(r,i);s(e)&&Mt(i,n,t);if(c)return void r.updateBy(i);if(c){return Nt(o,r.global.insertBefore,n,t)}Ht(e,t,t.insertBefore)}(e,n,r),i;switch(c){case t.tagArray:return Wt(e,n,a,r,{counts:{added:0,removed:0}}),e;case t.templater:return Nt(n,a,r,i),i;case t.tag:const o=n;let s=o.templater;return s||(s=Dt(),o.templater=s,s.tag=o),Nt(s,a,r,i),i;case t.subject:return n;case t.function:return e.clone||(e.clone=it(a)),e}return Ht(n,e,a),i}function Yt(t,e,n,r){if(!t.hasAttribute("end"))return;const o=t.getAttribute("id");if(o?.substring(0,q.length)!==q)return;const s=e[o];if(a(s._value)||c(s.value))return{variableName:o,ownerSupport:n,subject:s,insertBefore:t};Zt(t,s,n,r)}function Zt(t,e,n,r){let o=!1;const s=s=>{if(o)return void Gt(e,s,n,t);qt(s,e,t,n,{counts:{...r}}),o=!0};let a=s;const l=e.subscribe((t=>a(t)));if(t.parentNode){const n=e.clone=it(t);a=r=>{const o=n.parentNode;o.insertBefore(t,n),o.removeChild(n),delete e.clone,a=s,s(r)}}n.global.subscriptions.push(l)}function Qt(t,e,n,r){if(!t.getAttribute)return;"TEXTAREA"===t.nodeName&&function(t,e,n){const r=t.value;if(r.search(Xt)>=0){const o=r.match(/__tagvar(\d{1,4})/),s="{"+(o?o[0]:"")+"}";t.value="",t.setAttribute("text-var-value",s);const a=(e,n,r)=>t.value=r;xt("text-var-value",s,t,e,n,a)}}(t,n,r);let o=e.counts.added;o=function(t,e){const n=t.oninit;if(!n)return e.added;const r=n.tagFunction;if(!r)return e.added;const o=r.tagFunction;return o?(o({target:t,stagger:e.added}),++e.added):e.added}(t,e.counts)-o;t.focus&&(t.hasAttribute("autofocus")&&t.focus(),t.hasAttribute("autoselect")&&t.select());const s=t.children;if(s)for(let t=s.length-1;t>=0;--t){Qt(s[t],{...e,counts:e.counts},n,r)}}function te(t,e,n,r){const o=n.counts,s=[],a=[];for(let l=r.length-1;l>=0;--l){const i=r[l],c=Yt(i,t,e,o);if(c)a.push(c);else if(i.children)for(let r=i.children.length-1;r>=0;--r){const l=i.children[r];if(ee(l)){const n=Yt(l,t,e,o);n&&a.push(n)}const{clones:c,tagComponents:u}=te(t,e,n,l.children);s.push(...c),a.push(...u)}}return{clones:s,tagComponents:a}}function ee(t){return"TEMPLATE"===t.tagName&&void 0!==t.getAttribute("interpolate")&&void 0!==t.getAttribute("end")}function ne(t,e,n,r,o){const s=[],a=[],l=n.interpolation,i=t.children[0],c=i.content.children;if(l.keys.length){const{clones:t,tagComponents:n}=te(e,r,o,c);s.push(...t),a.push(...n)}return Ft(i,e,r),re(c,e,r),{clones:s,tagComponents:a}}function re(t,e,n){for(let r=t.length-1;r>=0;--r){const o=t[r];Ft(o,e,n),o.children&&re(o.children,e,n)}}function oe(t){const e=function(t){const e=[];return{string:t.replace(Ot,((t,n)=>{if(t.startsWith("<"))return t;const r=n.substring(1,n.length-1);return e.push(r),`<template interpolate end id="${r}"></template>`})),keys:e}}(t);return e.string=e.string.replace(G,q),e}function se(t,e,n,r,o){const s=function(t,e){const n=[];let r=t.children[0].content.firstChild;const o=document.createDocumentFragment();for(;r;){const t=r.nextSibling;n.push(r),o.appendChild(r),r=t}e.parentNode&&e.parentNode.insertBefore(o,e);return n}(t,e);if(!s.length)return s;for(let t=s.length-1;t>=0;--t){const e=s[t];Qt(e,o,r,n),n.global.clones.push(e)}return s}const ae=new RegExp(q,"g");class le{templater;subject;isApp=!0;appElement;strings;values;propsConfig;memory={state:[]};global={destroy$:new g,context:{},providers:[],renderCount:0,subscriptions:[],oldest:this,blocked:[],childTags:[],clones:[]};hasLiveElements=!1;constructor(t,e,n){this.templater=t,this.subject=e;const r=t.props;this.propsConfig=this.clonePropsBy(r,n)}clonePropsBy(t,e){const n=this.templater.children.value,r=t.map((t=>D(t)));return this.propsConfig={latest:t,latestCloned:r,castProps:e,lastClonedKidValues:n.map((t=>ot(t.values)))}}buildBeforeElement(t,e={counts:{added:0,removed:0}}){const n=this.subject,r=this.global;r.insertBefore=t,r.placeholder||function(t){const e=t.insertBefore;t.placeholder=it(e)}(r);const o=r.placeholder;r.oldest=this,r.newest=this,n.tagSupport=this,this.hasLiveElements=!0;const s=this.update(),a=this.getTemplate(),l=document.createDocumentFragment(),i=document.createElement("template");i.innerHTML=a.string,l.appendChild(i);const{tagComponents:c}=ne(l,s,a,this,{counts:e.counts});se(l,o,this,s,e);const u=c.length;for(let t=0;t<u;++t){const n=c[t];Zt(n.insertBefore,n.subject,n.ownerSupport,e.counts),se(l,n.insertBefore,n.ownerSupport,s,e)}}getTemplate(){const t=this.templater.tag,e=this.strings||t.strings,n=this.values||t.values,r=oe(e.map(((t,e)=>(t.replace(ae,X)+(n.length>e?`{${q}${e}}`:"")).replace(/>\s*/g,">").replace(/\s*</g,"<"))).join(""));return{interpolation:r,string:r.string,strings:e,values:n,context:this.global.context||{}}}update(){return this.updateContext(this.global.context)}updateContext(e){const n=this.templater.tag,r=this.strings||n.strings,o=this.values||n.values;return r.forEach(((n,r)=>{if(!(o.length>r))return;const s=q+r,a=o[r];if(s in e){if(this.global.deleted){const t=a&&a.tagSupport;if(t)return t.destroy(),e}return function(t,e,n){const r=t[e];i(n)||r.next(n)}(e,s,a)}e[s]=function(e,n){switch(rt(e)){case t.tagComponent:return new d(e);case t.templater:return lt(e.tag,n);case t.tag:return lt(e,n);case t.subject:return e}return new d(e)}(a,this)})),e}updateBy(t){const e=t.templater.tag;this.updateConfig(e.strings,e.values)}updateConfig(t,e){this.strings=t,this.updateValues(e)}updateValues(t){return this.values=t,this.updateContext(this.global.context)}destroy(t={stagger:0,byParent:!1}){const e=!t.byParent,n=this.global,r=t.byParent?[]:st(this.global.childTags);e&&a(this.templater)&&(n.destroy$.next(),H(this,this)),this.destroySubscriptions();for(let t=r.length-1;t>=0;--t){const e=r[t],n=e.global;delete n.newest,n.deleted=!0,a(e.templater)&&H(e,e)}let o;if(ce(this,t),e){const{stagger:e,promise:n}=this.destroyClones(t);t.stagger=e,n&&(o=n)}else this.destroyClones();return ue(this),o=o?o.then((async()=>{const t=r.map((t=>t.destroy({stagger:0,byParent:!0})));return Promise.all(t)})):Promise.all(r.map((t=>t.destroy({stagger:0,byParent:!0})))),o.then((()=>t.stagger))}destroyClones({stagger:t}={stagger:0}){const e=[...this.global.clones];this.global.clones.length=0;const n=e.map((e=>this.checkCloneRemoval(e,t))).filter((t=>t)),r=this.global.context;for(const t in r){const e=r[t].clone;e?.parentNode&&e.parentNode.removeChild(e)}return n.length?{promise:Promise.all(n),stagger:t}:{stagger:t}}checkCloneRemoval(t,e){let n;const r=t;r.ondestroy&&(n=function(t,e){const n=t.ondestroy;if(!n)return;const r=n.tagFunction;if(!r)return;const o=r.tagFunction;if(!o)return;return o({target:t,stagger:e})}(r,e));const o=()=>{const e=t.parentNode;e&&e.removeChild(t);const n=this.ownerTagSupport;n&&(n.global.clones=n.global.clones.filter((e=>e!==t)))};return n instanceof Promise?n.then(o):(o(),n)}destroySubscriptions(){const t=this.global.subscriptions;for(let e=t.length-1;e>=0;--e)t[e].unsubscribe();t.length=0}}class ie extends le{templater;ownerTagSupport;subject;version;isApp=!1;constructor(t,e,n,r,o=0){super(t,n,r),this.templater=t,this.ownerTagSupport=e,this.subject=n,this.version=o}getAppTagSupport(){let t=this;for(;t.ownerTagSupport;)t=t.ownerTagSupport;return t}}function ce(t,e){const n=t.global;if("TEMPLATE"===n.insertBefore.nodeName){n.placeholder&&!("arrayValue"in t.memory)&&(e.byParent||nt(t))}}function ue(t){const e=t.global;delete e.placeholder,e.context={},delete e.oldest,delete e.newest,t.global.childTags.length=0;delete t.subject.tagSupport}function pe(t,e={byParent:!1,stagger:0}){t.global.deleted=!0,t.global.context={};const n=st(t.global.childTags);t.destroySubscriptions(),n.forEach((t=>{const e=t.global;delete e.newest,e.deleted=!0})),ce(t,e),ue(t),t.destroyClones(),n.forEach((t=>pe(t,{byParent:!0,stagger:0})))}function ge(t,e,n){const r=t.global,o=r.insertBefore,s=e.global={...r};!function(t,e){t.global.destroy$,t.global.providers.forEach((n=>{n.children.forEach(((r,o)=>{if(t.global.destroy$===r.global.destroy$)return n.children.splice(o,1),void n.children.push(e)}))}))}(t,e),pe(t),t.global.oldest=e,s.insertBefore=o,delete s.deleted,s.oldest=e,s.newest=e,n.tagSupport=e;const a=e.global.placeholder?.parentNode,l=o.parentNode;a&&l&&l.removeChild(o)}function fe(t,e,n,r){const o=K(t,e,n,r);!e||U(e,o)||(ge(e,o,n),o.global.oldest=o);const s=e?.ownerTagSupport;return o.ownerTagSupport=r||s,o}function de(t,e){const n=function(t,e,n=[]){n.push({tagSupport:t,renderCount:t.global.renderCount,provider:e});const r=e.children;for(let t=r.length-1;t>=0;--t)n.push({tagSupport:r[t],renderCount:r[t].global.renderCount,provider:e});return n}(t,e);for(let t=n.length-1;t>=0;--t){const{tagSupport:e,renderCount:r,provider:o}=n[t];if(e.global.deleted)continue;r===e.global.renderCount&&(o.clone=D(o.instance),be(e.global.newest,!1))}}function he(t,e,n,r){const o=r.tagSupport,s=o.global;e.global=s;const a=s.renderCount;!function(t){const e=t.global.providers.filter((t=>!M(t.instance,t.clone)));for(let t=e.length-1;t>=0;--t){const n=e[t];de(n.owner,n),n.clone=D(n.instance)}}(t);const l=s.newest;if(a!==s.renderCount)return t.global.oldest.updateBy(l),l;const i=fe(e,l||o||s.oldest,r,n),c=s.oldest||t;return U(l,i)&&(r.tagSupport=i,c.updateBy(i)),i}function be(t,e){const n=t.global,r=t.templater;if(!r.wrapper){const e=t.ownerTagSupport;return++n.renderCount,e.global.deleted?t:be(e.global.newest,!0)}if(t.global.locked)return t.global.blocked.push(t),t;const o=t.subject,s=t.global.oldest;let a,l=!1;if(e&&t&&(a=t.ownerTagSupport,a)){l=!M(r.props,t.propsConfig.latestCloned)}const i=he(s,t,a,o);if(a&&l){return be(a.global.newest,!0),i}return i}function me(t,e,n,...r){const o=t.memory.state;j(o,n);const s=e(...r);return j(n,o),be(t,!1),s instanceof Promise&&s.finally((()=>{j(n,o),be(t,!1)})),s}let ye=t=>(t,e,n,r,o,s)=>{throw new T("Callback function was called immediately in sync and must instead be call async")};const ve=()=>ye,we=ye;function Ce(t){const e=y();if(!e){throw new T("callback() was called outside of synchronous rendering. Use `callback = callbackMaker()` to create a callback that could be called out of sync with rendering")}const n=v.memory.stateConfig.array;return(...r)=>e.global.callbackMaker?me(e,t,n,...r):t(...r)}function Se(t){const e=v.memory.stateConfig.array;ye=n=>(...r)=>t.global.callbackMaker?me(t,n,e,...r):n(...r)}function Te(t){E(t)}function ke(t){E((()=>{const e=y();e?.global.destroy$.toCallback(t)}))}function Ae(t){v.memory.childrenCurrentSupport=t}function xe(){return v.memory.childrenCurrentSupport.templater.children}v({beforeRender:t=>Se(t),beforeRedraw:t=>Se(t),afterRender:t=>{t.global.callbackMaker=!0,ye=we}}),v({beforeRender:t=>Ae(t),beforeRedraw:t=>Ae(t)});const je=[];function Ee(t,...e){return new Y(t,e)}let Pe=0;function Re(e){const n=function(...e){const r=new at(e);r.tagJsType=t.tagComponent;const o=function(e,n){const r=v.memory.stateConfig.array;return function(o,s){const a=o.global;++a.renderCount;const l=e.children,i=a.oldest?.templater.children.lastArray;i&&(l.lastArray=i);const c=n.original;let u=e.props;const p=o.propsConfig.castProps||dt(u,o,r);u.map((t=>D(t)));let g=c(...p);g instanceof Function&&(g=g()),g&&g.tagJsType===t.tag||(g=Ee`${g}`),g.templater=e,e.tag=g,g.memory.arrayValue=e.arrayValue;const f=new ie(e,o.ownerTagSupport,s,p,a.renderCount);f.global=a;const d=v.memory.stateConfig.array;if(f.memory.state.push(...d),e.madeChildIntoSubject){const t=l.value;for(let e=t.length-1;e>=0;--e){const n=t[e],r=n.values;for(let t=r.length-1;t>=0;--t){const e=r[t];if(!(e instanceof Function))continue;const o=n.values[t];o.isChildOverride||(n.values[t]=function(...t){const n=f.ownerTagSupport;return wt(e,n,this,t)},o.isChildOverride=!0)}}}return f}}(r,n);return o.parentWrap||(o.parentWrap=n),r.tagged=!0,r.wrapper=o,r};n.original=e,n.compareTo=e.toString();const r=e;return n.isTag=!0,n.original=r,r.tags=je,r.setUse=v,r.tagIndex=Pe++,je.push(n),n}Re.oneRender=(...t)=>{throw new Error("Do not call function tag.oneRender but instead set it as: `(props) => tag.oneRender = (state) => html`` `")},Re.route=t=>{throw new Error("Do not call function tag.route but instead set it as: `tag.route = (routeProps: RouteProps) => (state) => html`` `")},Re.app=t=>{throw new Error("Do not call function tag.route but instead set it as: `tag.route = (routeProps: RouteProps) => (state) => html`` `")},Object.defineProperty(Re,"oneRender",{set(t){t.oneRender=!0}});const Be=[];function Ve(t,e,n){const r=Be.findIndex((t=>t.element===e));r>=0&&(Be[r].tagSupport.destroy(),Be.splice(r,1),console.warn("Found and destroyed app element already rendered to element",{element:e}));const o=function(t){let e={};const n=new d(e);e=new le(t,n),n.next(t),n.tagSupport=e,L(e,void 0);const r=t.wrapper,o=r(e,n);return z(e,o),o}(t(n));o.appElement=e,o.isApp=!0,o.global.isApp=!0;const s=document.createElement("template");s.setAttribute("id","app-tag-"+Be.length),s.setAttribute("app-tag-detail",Be.length.toString());const a=document.createDocumentFragment();return a.appendChild(s),e.destroy=async()=>{await o.destroy();const t=o.global.insertBefore;t.parentNode.removeChild(t)},o.buildBeforeElement(s),o.global.oldest=o,o.global.newest=o,e.setUse=t.original.setUse,Be.push({element:e,tagSupport:o}),e.appendChild(a),{tagSupport:o,tags:t.original.tags}}const Fe={tagElement:Ve,renderWithSupport:fe,renderTagSupport:be,renderTagOnly:K};var Oe=n.W9,Ne=n.t3,_e=n.Y2,De=n.ei,$e=n.B7,Me=n.XF,We=n.vw,Je=n.PC,Ue=n.uX,Ie=n.O9,Le=n.Ot,ze=n.tD,He=n.E2,Ke=n.OH,qe=n.fq,Xe=n.Y_,Ge=n.zV,Ye=n.WJ,Ze=n.AZ,Qe=n.cF,tn=n.qy,en=n.u2,nn=n.zl,rn=n.O5,on=n.Ze,sn=n._4,an=n.iO,ln=n.dk,cn=n.mn,un=n.NM,pn=n.z,gn=n.bc,fn=n.sA,dn=n.MG,hn=n.t2,bn=n.r5,mn=n.pG,yn=n.yN,vn=n.QB,wn=n.Ps,Cn=n.vJ,Sn=n.AI,Tn=n.wk,kn=n.uz,An=n.Tc,xn=n.Hf,jn=n._A,En=n.NU,Pn=n.wB,Rn=n.id,Bn=n.MC,Vn=n.zC;export{Oe as ArrayNoKeyError,Ne as BaseTagSupport,_e as RouteQuery,De as StateMismatchError,$e as Subject,Me as SyncCallbackError,We as Tag,Je as TagError,Ue as TagSupport,Ie as TemplaterResult,Le as ValueSubject,ze as ValueTypes,He as callback,Ke as callbackMaker,qe as checkRestoreTagMarker,Xe as children,Ge as combineLatest,Ye as defineValueOn,Ze as getValueType,Qe as hmr,tn as html,en as interpolateElement,nn as interpolateString,rn as isLikeValueSets,on as isStaticTag,sn as isSubjectInstance,an as isTagArray,ln as isTagClass,cn as isTagComponent,un as isTagTemplater,pn as letProp,gn as letState,fn as onDestroy,dn as onInit,hn as oneRenderToTagSupport,bn as providers,mn as renderTagOnly,yn as renderTagSupport,vn as renderWithSupport,wn as resetTagSupport,Cn as runBeforeRender,Sn as setUse,Tn as state,kn as subject,An as tag,xn as tagElement,jn as tags,En as variablePrefix,Pn as watch,Rn as willCallback,Bn as willPromise,Vn as willSubscribe};
|
|
2
2
|
//# sourceMappingURL=bundle.js.map
|
package/bundle.js.gz
CHANGED
|
Binary file
|