Socket
Socket
Sign inDemoInstall

@neuronet.io/vido

Package Overview
Dependencies
Maintainers
1
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neuronet.io/vido - npm Package Compare versions

Comparing version 4.2.2 to 4.2.3

17

dist/src/helpers.js

@@ -33,3 +33,5 @@ /**

}
function getEmpty(value) {
function getEmpty(value, targetValue) {
if (targetValue)
return targetValue;
if (Array.isArray(value))

@@ -54,12 +56,17 @@ return new Array(value.length);

else if (isObject(source)) {
if (!target) {
target = {};
}
for (const key in source) {
const value = source[key];
target[key] = mergeDeep(getEmpty(value), value);
target[key] = mergeDeep(getEmpty(value, target[key]), value);
}
}
else if (Array.isArray(source)) {
target = getEmpty(source);
if (!target) {
target = new Array(source.length);
}
let index = 0;
for (const value of source) {
target[index] = mergeDeep(getEmpty(value), value);
target[index] = mergeDeep(getEmpty(value, target[index]), value);
index++;

@@ -74,3 +81,3 @@ }

const value = source[propName];
target[propName] = mergeDeep(getEmpty(value), value);
target[propName] = mergeDeep(getEmpty(value, target[propName]), value);
}

@@ -77,0 +84,0 @@ }

@@ -788,3 +788,5 @@ /**

}
function getEmpty(value) {
function getEmpty(value, targetValue) {
if (targetValue)
return targetValue;
if (Array.isArray(value))

@@ -809,12 +811,17 @@ return new Array(value.length);

else if (isObject(source)) {
if (!target) {
target = {};
}
for (const key in source) {
const value = source[key];
target[key] = mergeDeep(getEmpty(value), value);
target[key] = mergeDeep(getEmpty(value, target[key]), value);
}
}
else if (Array.isArray(source)) {
target = getEmpty(source);
if (!target) {
target = new Array(source.length);
}
let index = 0;
for (const value of source) {
target[index] = mergeDeep(getEmpty(value), value);
target[index] = mergeDeep(getEmpty(value, target[index]), value);
index++;

@@ -829,3 +836,3 @@ }

const value = source[propName];
target[propName] = mergeDeep(getEmpty(value), value);
target[propName] = mergeDeep(getEmpty(value, target[propName]), value);
}

@@ -832,0 +839,0 @@ }

@@ -67,3 +67,3 @@ /**

* SPDX-License-Identifier: BSD-3-Clause
*/const Mt=R(class extends O{constructor(t){var e;if(super(t),t.type!==k.ATTRIBUTE||"class"!==t.name||(null===(e=t.strings)||void 0===e?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((e=>t[e])).join(" ")+" "}update(t,[e]){var s,n;if(void 0===this.et){this.et=new Set,void 0!==t.strings&&(this.st=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in e)e[t]&&!(null===(s=this.st)||void 0===s?void 0:s.has(t))&&this.et.add(t);return this.render(e)}const i=t.element.classList;this.et.forEach((t=>{t in e||(i.remove(t),this.et.delete(t))}));for(const t in e){const s=!!e[t];s===this.et.has(t)||(null===(n=this.st)||void 0===n?void 0:n.has(t))||(s?(i.add(t),this.et.add(t)):(i.remove(t),this.et.delete(t)))}return _}});class Pt{constructor(){this.isAction=!0}}Pt.prototype.isAction=!0;const Yt={element:document.createTextNode(""),axis:"xy",threshold:10,onDown(){},onMove(){},onUp(){},onWheel(){}},Xt="undefined"!=typeof PointerEvent;let St=0;class Ht extends Pt{constructor(t,e){super(),this.moving="",this.initialX=0,this.initialY=0,this.lastY=0,this.lastX=0,this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onWheel=this.onWheel.bind(this),this.element=t,this.id=++St,this.options=Object.assign(Object.assign({},Yt),e.pointerOptions),Xt?(t.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp)):(t.addEventListener("touchstart",this.onPointerDown),document.addEventListener("touchmove",this.onPointerMove,{passive:!1}),document.addEventListener("touchend",this.onPointerUp),document.addEventListener("touchcancel",this.onPointerUp),t.addEventListener("mousedown",this.onPointerDown),document.addEventListener("mousemove",this.onPointerMove,{passive:!1}),document.addEventListener("mouseup",this.onPointerUp))}normalizeMouseWheelEvent(t){let e=t.deltaX||0,s=t.deltaY||0,n=t.deltaZ||0;const i=t.deltaMode,o=parseInt(getComputedStyle(t.target).getPropertyValue("line-height"));let r=1;switch(i){case 1:r=o;break;case 2:r=window.height}return e*=r,s*=r,n*=r,{x:e,y:s,z:n,event:t}}onWheel(t){const e=this.normalizeMouseWheelEvent(t);this.options.onWheel(e)}normalizePointerEvent(t){let e={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,screenX:0,screenY:0,event:t};switch(t.type){case"wheel":const s=this.normalizeMouseWheelEvent(t);e.x=s.x,e.y=s.y,e.pageX=e.x,e.pageY=e.y,e.screenX=e.x,e.screenY=e.y,e.clientX=e.x,e.clientY=e.y;break;case"touchstart":case"touchmove":case"touchend":case"touchcancel":e.x=t.changedTouches[0].screenX,e.y=t.changedTouches[0].screenY,e.pageX=t.changedTouches[0].pageX,e.pageY=t.changedTouches[0].pageY,e.screenX=t.changedTouches[0].screenX,e.screenY=t.changedTouches[0].screenY,e.clientX=t.changedTouches[0].clientX,e.clientY=t.changedTouches[0].clientY;break;default:e.x=t.x,e.y=t.y,e.pageX=t.pageX,e.pageY=t.pageY,e.screenX=t.screenX,e.screenY=t.screenY,e.clientX=t.clientX,e.clientY=t.clientY}return e}onPointerDown(t){if("mousedown"===t.type&&0!==t.button)return;this.moving="xy";const e=this.normalizePointerEvent(t);this.lastX=e.x,this.lastY=e.y,this.initialX=e.x,this.initialY=e.y,this.options.onDown(e)}handleX(t){let e=t.x-this.lastX;return this.lastY=t.y,this.lastX=t.x,e}handleY(t){let e=t.y-this.lastY;return this.lastY=t.y,this.lastX=t.x,e}onPointerMove(t){if(""===this.moving||"mousemove"===t.type&&0!==t.button)return;const e=this.normalizePointerEvent(t);if("x|y"===this.options.axis){let s=0,n=0;("x"===this.moving||"xy"===this.moving&&Math.abs(e.x-this.initialX)>this.options.threshold)&&(this.moving="x",s=this.handleX(e)),("y"===this.moving||"xy"===this.moving&&Math.abs(e.y-this.initialY)>this.options.threshold)&&(this.moving="y",n=this.handleY(e)),this.options.onMove({movementX:s,movementY:n,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}else if("xy"===this.options.axis){let s=0,n=0;Math.abs(e.x-this.initialX)>this.options.threshold&&(s=this.handleX(e)),Math.abs(e.y-this.initialY)>this.options.threshold&&(n=this.handleY(e)),this.options.onMove({movementX:s,movementY:n,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}else if("x"===this.options.axis)("x"===this.moving||"xy"===this.moving&&Math.abs(e.x-this.initialX)>this.options.threshold)&&(this.moving="x",this.options.onMove({movementX:this.handleX(e),movementY:0,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t}));else if("y"===this.options.axis){let s=0;("y"===this.moving||"xy"===this.moving&&Math.abs(e.y-this.initialY)>this.options.threshold)&&(this.moving="y",s=this.handleY(e)),this.options.onMove({movementX:0,movementY:s,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}}onPointerUp(t){this.moving="";const e=this.normalizePointerEvent(t);this.options.onUp({movementX:0,movementY:0,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t}),this.lastY=0,this.lastX=0}destroy(t){Xt?(t.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp)):(t.removeEventListener("mousedown",this.onPointerDown),document.removeEventListener("mousemove",this.onPointerMove),document.removeEventListener("mouseup",this.onPointerUp),t.removeEventListener("touchstart",this.onPointerDown),document.removeEventListener("touchmove",this.onPointerMove),document.removeEventListener("touchend",this.onPointerUp),document.removeEventListener("touchcancel",this.onPointerUp))}}function Nt(t){let e=0;return function(s){e||(e=requestAnimationFrame((function(){e=0,t.apply(void 0,[s])})))}}function Lt(t){return t&&t.constructor?"Object"===t.constructor.name:"object"==typeof t&&null!==t}function Ut(t){return Array.isArray(t)?new Array(t.length):Lt(t)?{}:t}function Bt(t,...e){const s=e.shift();if(s&&"function"==typeof s.clone)t=s.clone();else if(Lt(s))for(const e in s){const n=s[e];t[e]=Bt(Ut(n),n)}else if(Array.isArray(s)){t=Ut(s);let e=0;for(const n of s)t[e]=Bt(Ut(n),n),e++;const n=Object.keys(s);if(n.length>e){const i=n.length;for(let o=e;o<i;o++){const e=n[o],i=s[e];t[e]=Bt(Ut(i),i)}}}else t=s;return e.length?Bt(t,...e):t}function Dt(t){if(void 0!==t.actions){const e=t.actions.map((t=>{const e=Object.assign({},t),s=Object.assign({},e.props);return delete s.state,delete s.api,delete e.element,e.props=s,e}));t.actions=e}return Bt({},t)}var kt={mergeDeep:Bt,clone:Dt,schedule:Nt};class Rt{constructor(t,e){this.slotInstances={},this.destroyed=!1,this.vido=t,this.props=e,this.destroy=this.destroy.bind(this),this.change=this.change.bind(this),this.html=this.html.bind(this),this.getInstances=this.getInstances.bind(this),this.setComponents=this.setComponents.bind(this),this.vido.onDestroy((()=>{this.destroy()}))}setComponents(t){if(t&&!this.destroyed){for(const e in t){const s=t[e];void 0===this.slotInstances[e]&&(this.slotInstances[e]=[]);for(const t of this.slotInstances[e])t.destroy();this.slotInstances[e].length=0;for(const t of s)this.slotInstances[e].push(this.vido.createComponent(t,this.props))}this.vido.update()}}destroy(){if(!this.destroyed){for(const t in this.slotInstances){for(const e of this.slotInstances[t])e.destroy();this.slotInstances[t].length=0}this.destroyed=!0}}change(t,e){if(!this.destroyed)for(const s in this.slotInstances){const n=this.slotInstances[s];for(const s of n)s.change(t,e)}}getInstances(t){return this.destroyed?[]:void 0===t?this.slotInstances:this.slotInstances[t]}html(t,e){if(this.destroyed)return;if(!this.slotInstances[t]||0===this.slotInstances[t].length)return e;let s=e;for(const e of this.slotInstances[t])s=e.html(s);return s}getProps(){return this.props}isDestroyed(){return this.destroyed}}class Ot extends O{update(t,e){if("function"!=typeof e[0])throw new Error("[vido] GetElementDirective argument should be a function.");(0,e[0])(t.element)}render(){return b}}function jt(t,e){let s=0;const n=new Map;let i,o,r=new Map,h=0;const l=[],c=Promise.resolve(),a={},d=function(t){return class extends O{update(e,s){const n=e.element,i=s[0],o=s[1],r=s[2];for(const e of o)if(void 0!==e){let s;if(t.has(i))for(const o of t.get(i))if(o.componentAction.create===e&&o.element===n){s=o;break}if(s)s.props=r;else{void 0!==n.vido&&delete n.vido;const s={instance:i,componentAction:{create:e,update(){},destroy(){}},element:n,props:r};let o=[];t.has(i)&&(o=t.get(i)),o.push(s),t.set(i,o)}}}render(t,e,s){return b}}}(r);class u{constructor(t){this.instance=t}create(t,e){const s=R(d);return()=>s(this.instance,t,e)}}const p=function(t,e,s){return class{constructor(t,e,s={}){this.destroyed=!1,this.instance=t,this.name=e.name,this.vidoInstance=e,this.props=s,this.destroy=this.destroy.bind(this),this.update=this.update.bind(this),this.change=this.change.bind(this),this.html=this.html.bind(this)}destroy(){this.destroyed||(this.vidoInstance.debug&&(console.groupCollapsed(`destroying component ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.vidoInstance.destroyComponent(this.instance,this.vidoInstance),this.destroyed=!0)}update(n){return this.vidoInstance.debug&&(console.groupCollapsed(`updating component ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.vidoInstance.updateTemplate(n)}change(n,i={}){this.vidoInstance.debug&&(console.groupCollapsed(`changing component ${this.instance}`),console.log(s({props:this.props,newProps:n,components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd());const o=t.get(this.instance);o&&o.change(n,i)}html(e={}){const s=t.get(this.instance);if(s&&!s.destroyed)return s.update(e,this.vidoInstance)}_getComponents(){return t}_getActions(){return e}}}(n,r,Dt),v=function(t,e,s){return class{constructor(t,e,s){this.destroyed=!1,this.instance=t,this.vidoInstance=e,this.renderFunction=s,this.destroy=this.destroy.bind(this),this.update=this.update.bind(this),this.change=this.change.bind(this)}destroy(){if(!this.destroyed){this.vidoInstance.debug&&(console.groupCollapsed(`component destroy method fired ${this.instance}`),console.log(s({props:this.vidoInstance.props,components:t.keys(),destroyable:this.vidoInstance.destroyable,actionsByInstance:e})),console.trace(),console.groupEnd()),this.content&&"function"==typeof this.content.destroy&&this.content.destroy();for(const t of this.vidoInstance.destroyable)t();this.vidoInstance.onChangeFunctions.length=0,this.vidoInstance.destroyable.length=0,this.vidoInstance.destroyed=!0,this.destroyed=!0,this.vidoInstance.update()}}update(n={}){return this.vidoInstance.debug&&(console.groupCollapsed(`component update method fired ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.renderFunction(n)}change(n,i={leave:!1}){const o=n;this.vidoInstance.debug&&(console.groupCollapsed(`component change method fired ${this.instance}`),console.log(s({props:o,components:t.keys(),onChangeFunctions:this.vidoInstance.onChangeFunctions,changedProps:n,actionsByInstance:e})),console.trace(),console.groupEnd());for(const t of this.vidoInstance.onChangeFunctions)t(n,i)}}}(n,r,Dt);class y{constructor(s="",i=""){this.instance="",this.name="",this.destroyable=[],this.destroyed=!1,this.onChangeFunctions=[],this.debug=!1,this.state=t,this.api=e,this.lastProps={},this.html=$,this.svg=A,this.lithtml=D,this.directive=R,this.asyncAppend=dt,this.asyncReplace=at,this.cache=ut,this.classMap=Mt,this.styleMap=wt,this.StyleMap=Tt,this.guard=vt,this.live=bt,this.ifDefined=yt,this.repeat=ft,this.unsafeHTML=$t,this.until=_t,this.schedule=Nt,this.getElement=R(Ot),this.actionsByInstance=()=>{},this.detach=Ct,this.PointerAction=Ht,this.Action=Pt,this.Slots=Rt,this._components=n,this._actions=r,this.instance=s,this.reuseComponents=this.reuseComponents.bind(this),this.onDestroy=this.onDestroy.bind(this),this.onChange=this.onChange.bind(this),this.update=this.update.bind(this),this.destroyComponent=this.destroyComponent.bind(this);for(const t in a)this[t]=a[t].bind(this);this.name=i,this.Actions=new u(s)}static addMethod(t,e){a[t]=e}onDestroy(t){this.destroyable.push(t)}onChange(t){this.onChangeFunctions.push(t)}update(t){return this.updateTemplate(t)}reuseComponents(t,e,s,n,i=!0,o=!1){const r=[],h=t.length,l=e.length;let c=!1;!i||void 0!==e&&0!==e.length||(c=!0);let a=0;if(h<l){let i=l-h;for(;i;){const o=e[l-i],h=this.createComponent(n,s(o));t.push(h),r.push(h),i--}}else if(h>l){let e=h-l;if(i)c=!0,a=h-e;else{for(;e;){const s=h-e;r.push(t[s]),t[s].destroy(),e--}t.length=l}}let d=0;o&&console.log("modified components",r),o&&console.log("current components",t),o&&console.log("data array",e);for(const n of t){const t=e[d];o&&console.log(`reuse components data at '${d}'`,t),n&&!r.includes(n)&&(o&&console.log("getProps fn result",s(t)),n.change(s(t),{leave:c&&d>=a})),d++}}createComponent(t,e={}){const i=t.name+":"+s++;let o;o=new y(i,t.name);const h=new p(i,o,e),l=new v(i,o,t(o,e));return n.set(i,l),n.get(i).change(e),o.debug&&(console.groupCollapsed(`component created ${i}`),console.log(Dt({props:e,components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd()),h}destroyComponent(t,e){if(e.debug&&(console.groupCollapsed(`destroying component ${t}...`),console.log(Dt({components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd()),r.has(t))for(const e of r.get(t))"function"==typeof e.componentAction.destroy&&e.componentAction.destroy(e.element,e.props);r.delete(t);const s=n.get(t);s?(s.destroy(),n.delete(t),e.debug&&(console.groupCollapsed(`component destroyed ${t}`),console.log(Dt({components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd())):console.warn(`No component to destroy! [${t}]`)}executeActions(){for(const t of r.values()){for(const e of t)if(void 0===e.element.vido){const t=n.get(e.instance);e.isActive=function(){return t&&!1===t.destroyed};const s=e.componentAction,i=s.create;if(void 0!==i){let t;t=i.prototype&&(i.prototype.isAction||i.prototype.update||i.prototype.destroy)||i.isAction?new i(e.element,e.props):i(e.element,e.props),void 0!==t&&("function"==typeof t?s.destroy=t:("function"==typeof t.update&&(s.update=t.update.bind(t)),"function"==typeof t.destroy&&(s.destroy=t.destroy.bind(t))))}}else e.element.vido=e.props,"function"==typeof e.componentAction.update&&e.isActive()&&e.componentAction.update(e.element,e.props);for(const e of t)e.element.vido=e.props}}updateTemplate(t){return t&&l.push(t),new Promise((t=>{const e=++h,s=this;c.then((function(){if(e===h){h=0,s.render();for(const t of l)t();l.length=0,t(null)}}))}))}createApp(t){o=t.element;const e=this.createComponent(t.component,t.props);return i=e.instance,this.render(),e}render(){const t=n.get(i);t?(C(t.update(),o),this.executeActions()):o&&o.remove()}}return new y}jt.prototype.lithtml=D,jt.prototype.Action=Pt,jt.prototype.Directive=O,jt.prototype.schedule=Nt,jt.prototype.detach=Ct,jt.prototype.styleMap=wt,jt.prototype.classMap=Mt,jt.prototype.StyleMap=Tt,jt.prototype.PointerAction=Ht,jt.prototype.asyncAppend=dt,jt.prototype.asyncReplace=at,jt.prototype.cache=ut,jt.prototype.guard=vt,jt.prototype.live=bt,jt.prototype.ifDefined=yt,jt.prototype.repeat=ft,jt.prototype.unsafeHTML=$t,jt.prototype.until=_t,jt.prototype.Slots=Rt;const Wt=D;export{Pt as Action,O as Directive,k as PartType,Ht as PointerAction,Rt as Slots,Tt as StyleMap,U as _$LH,dt as asyncAppend,at as asyncReplace,ut as cache,Mt as classMap,jt as default,Ct as detach,R as directive,vt as guard,kt as helpers,$ as html,yt as ifDefined,Wt as lit,D as lithtml,_ as noChange,b as nothing,C as render,ft as repeat,Nt as schedule,wt as styleMap,A as svg,$t as unsafeHTML,_t as until};
*/const Mt=R(class extends O{constructor(t){var e;if(super(t),t.type!==k.ATTRIBUTE||"class"!==t.name||(null===(e=t.strings)||void 0===e?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((e=>t[e])).join(" ")+" "}update(t,[e]){var s,n;if(void 0===this.et){this.et=new Set,void 0!==t.strings&&(this.st=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in e)e[t]&&!(null===(s=this.st)||void 0===s?void 0:s.has(t))&&this.et.add(t);return this.render(e)}const i=t.element.classList;this.et.forEach((t=>{t in e||(i.remove(t),this.et.delete(t))}));for(const t in e){const s=!!e[t];s===this.et.has(t)||(null===(n=this.st)||void 0===n?void 0:n.has(t))||(s?(i.add(t),this.et.add(t)):(i.remove(t),this.et.delete(t)))}return _}});class Pt{constructor(){this.isAction=!0}}Pt.prototype.isAction=!0;const Yt={element:document.createTextNode(""),axis:"xy",threshold:10,onDown(){},onMove(){},onUp(){},onWheel(){}},Xt="undefined"!=typeof PointerEvent;let St=0;class Ht extends Pt{constructor(t,e){super(),this.moving="",this.initialX=0,this.initialY=0,this.lastY=0,this.lastX=0,this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onWheel=this.onWheel.bind(this),this.element=t,this.id=++St,this.options=Object.assign(Object.assign({},Yt),e.pointerOptions),Xt?(t.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp)):(t.addEventListener("touchstart",this.onPointerDown),document.addEventListener("touchmove",this.onPointerMove,{passive:!1}),document.addEventListener("touchend",this.onPointerUp),document.addEventListener("touchcancel",this.onPointerUp),t.addEventListener("mousedown",this.onPointerDown),document.addEventListener("mousemove",this.onPointerMove,{passive:!1}),document.addEventListener("mouseup",this.onPointerUp))}normalizeMouseWheelEvent(t){let e=t.deltaX||0,s=t.deltaY||0,n=t.deltaZ||0;const i=t.deltaMode,o=parseInt(getComputedStyle(t.target).getPropertyValue("line-height"));let r=1;switch(i){case 1:r=o;break;case 2:r=window.height}return e*=r,s*=r,n*=r,{x:e,y:s,z:n,event:t}}onWheel(t){const e=this.normalizeMouseWheelEvent(t);this.options.onWheel(e)}normalizePointerEvent(t){let e={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,screenX:0,screenY:0,event:t};switch(t.type){case"wheel":const s=this.normalizeMouseWheelEvent(t);e.x=s.x,e.y=s.y,e.pageX=e.x,e.pageY=e.y,e.screenX=e.x,e.screenY=e.y,e.clientX=e.x,e.clientY=e.y;break;case"touchstart":case"touchmove":case"touchend":case"touchcancel":e.x=t.changedTouches[0].screenX,e.y=t.changedTouches[0].screenY,e.pageX=t.changedTouches[0].pageX,e.pageY=t.changedTouches[0].pageY,e.screenX=t.changedTouches[0].screenX,e.screenY=t.changedTouches[0].screenY,e.clientX=t.changedTouches[0].clientX,e.clientY=t.changedTouches[0].clientY;break;default:e.x=t.x,e.y=t.y,e.pageX=t.pageX,e.pageY=t.pageY,e.screenX=t.screenX,e.screenY=t.screenY,e.clientX=t.clientX,e.clientY=t.clientY}return e}onPointerDown(t){if("mousedown"===t.type&&0!==t.button)return;this.moving="xy";const e=this.normalizePointerEvent(t);this.lastX=e.x,this.lastY=e.y,this.initialX=e.x,this.initialY=e.y,this.options.onDown(e)}handleX(t){let e=t.x-this.lastX;return this.lastY=t.y,this.lastX=t.x,e}handleY(t){let e=t.y-this.lastY;return this.lastY=t.y,this.lastX=t.x,e}onPointerMove(t){if(""===this.moving||"mousemove"===t.type&&0!==t.button)return;const e=this.normalizePointerEvent(t);if("x|y"===this.options.axis){let s=0,n=0;("x"===this.moving||"xy"===this.moving&&Math.abs(e.x-this.initialX)>this.options.threshold)&&(this.moving="x",s=this.handleX(e)),("y"===this.moving||"xy"===this.moving&&Math.abs(e.y-this.initialY)>this.options.threshold)&&(this.moving="y",n=this.handleY(e)),this.options.onMove({movementX:s,movementY:n,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}else if("xy"===this.options.axis){let s=0,n=0;Math.abs(e.x-this.initialX)>this.options.threshold&&(s=this.handleX(e)),Math.abs(e.y-this.initialY)>this.options.threshold&&(n=this.handleY(e)),this.options.onMove({movementX:s,movementY:n,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}else if("x"===this.options.axis)("x"===this.moving||"xy"===this.moving&&Math.abs(e.x-this.initialX)>this.options.threshold)&&(this.moving="x",this.options.onMove({movementX:this.handleX(e),movementY:0,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t}));else if("y"===this.options.axis){let s=0;("y"===this.moving||"xy"===this.moving&&Math.abs(e.y-this.initialY)>this.options.threshold)&&(this.moving="y",s=this.handleY(e)),this.options.onMove({movementX:0,movementY:s,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}}onPointerUp(t){this.moving="";const e=this.normalizePointerEvent(t);this.options.onUp({movementX:0,movementY:0,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t}),this.lastY=0,this.lastX=0}destroy(t){Xt?(t.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp)):(t.removeEventListener("mousedown",this.onPointerDown),document.removeEventListener("mousemove",this.onPointerMove),document.removeEventListener("mouseup",this.onPointerUp),t.removeEventListener("touchstart",this.onPointerDown),document.removeEventListener("touchmove",this.onPointerMove),document.removeEventListener("touchend",this.onPointerUp),document.removeEventListener("touchcancel",this.onPointerUp))}}function Nt(t){let e=0;return function(s){e||(e=requestAnimationFrame((function(){e=0,t.apply(void 0,[s])})))}}function Lt(t){return t&&t.constructor?"Object"===t.constructor.name:"object"==typeof t&&null!==t}function Ut(t,e){return e||(Array.isArray(t)?new Array(t.length):Lt(t)?{}:t)}function Bt(t,...e){const s=e.shift();if(s&&"function"==typeof s.clone)t=s.clone();else if(Lt(s)){t||(t={});for(const e in s){const n=s[e];t[e]=Bt(Ut(n,t[e]),n)}}else if(Array.isArray(s)){t||(t=new Array(s.length));let e=0;for(const n of s)t[e]=Bt(Ut(n,t[e]),n),e++;const n=Object.keys(s);if(n.length>e){const i=n.length;for(let o=e;o<i;o++){const e=n[o],i=s[e];t[e]=Bt(Ut(i,t[e]),i)}}}else t=s;return e.length?Bt(t,...e):t}function Dt(t){if(void 0!==t.actions){const e=t.actions.map((t=>{const e=Object.assign({},t),s=Object.assign({},e.props);return delete s.state,delete s.api,delete e.element,e.props=s,e}));t.actions=e}return Bt({},t)}var kt={mergeDeep:Bt,clone:Dt,schedule:Nt};class Rt{constructor(t,e){this.slotInstances={},this.destroyed=!1,this.vido=t,this.props=e,this.destroy=this.destroy.bind(this),this.change=this.change.bind(this),this.html=this.html.bind(this),this.getInstances=this.getInstances.bind(this),this.setComponents=this.setComponents.bind(this),this.vido.onDestroy((()=>{this.destroy()}))}setComponents(t){if(t&&!this.destroyed){for(const e in t){const s=t[e];void 0===this.slotInstances[e]&&(this.slotInstances[e]=[]);for(const t of this.slotInstances[e])t.destroy();this.slotInstances[e].length=0;for(const t of s)this.slotInstances[e].push(this.vido.createComponent(t,this.props))}this.vido.update()}}destroy(){if(!this.destroyed){for(const t in this.slotInstances){for(const e of this.slotInstances[t])e.destroy();this.slotInstances[t].length=0}this.destroyed=!0}}change(t,e){if(!this.destroyed)for(const s in this.slotInstances){const n=this.slotInstances[s];for(const s of n)s.change(t,e)}}getInstances(t){return this.destroyed?[]:void 0===t?this.slotInstances:this.slotInstances[t]}html(t,e){if(this.destroyed)return;if(!this.slotInstances[t]||0===this.slotInstances[t].length)return e;let s=e;for(const e of this.slotInstances[t])s=e.html(s);return s}getProps(){return this.props}isDestroyed(){return this.destroyed}}class Ot extends O{update(t,e){if("function"!=typeof e[0])throw new Error("[vido] GetElementDirective argument should be a function.");(0,e[0])(t.element)}render(){return b}}function jt(t,e){let s=0;const n=new Map;let i,o,r=new Map,h=0;const l=[],c=Promise.resolve(),a={},d=function(t){return class extends O{update(e,s){const n=e.element,i=s[0],o=s[1],r=s[2];for(const e of o)if(void 0!==e){let s;if(t.has(i))for(const o of t.get(i))if(o.componentAction.create===e&&o.element===n){s=o;break}if(s)s.props=r;else{void 0!==n.vido&&delete n.vido;const s={instance:i,componentAction:{create:e,update(){},destroy(){}},element:n,props:r};let o=[];t.has(i)&&(o=t.get(i)),o.push(s),t.set(i,o)}}}render(t,e,s){return b}}}(r);class u{constructor(t){this.instance=t}create(t,e){const s=R(d);return()=>s(this.instance,t,e)}}const p=function(t,e,s){return class{constructor(t,e,s={}){this.destroyed=!1,this.instance=t,this.name=e.name,this.vidoInstance=e,this.props=s,this.destroy=this.destroy.bind(this),this.update=this.update.bind(this),this.change=this.change.bind(this),this.html=this.html.bind(this)}destroy(){this.destroyed||(this.vidoInstance.debug&&(console.groupCollapsed(`destroying component ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.vidoInstance.destroyComponent(this.instance,this.vidoInstance),this.destroyed=!0)}update(n){return this.vidoInstance.debug&&(console.groupCollapsed(`updating component ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.vidoInstance.updateTemplate(n)}change(n,i={}){this.vidoInstance.debug&&(console.groupCollapsed(`changing component ${this.instance}`),console.log(s({props:this.props,newProps:n,components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd());const o=t.get(this.instance);o&&o.change(n,i)}html(e={}){const s=t.get(this.instance);if(s&&!s.destroyed)return s.update(e,this.vidoInstance)}_getComponents(){return t}_getActions(){return e}}}(n,r,Dt),v=function(t,e,s){return class{constructor(t,e,s){this.destroyed=!1,this.instance=t,this.vidoInstance=e,this.renderFunction=s,this.destroy=this.destroy.bind(this),this.update=this.update.bind(this),this.change=this.change.bind(this)}destroy(){if(!this.destroyed){this.vidoInstance.debug&&(console.groupCollapsed(`component destroy method fired ${this.instance}`),console.log(s({props:this.vidoInstance.props,components:t.keys(),destroyable:this.vidoInstance.destroyable,actionsByInstance:e})),console.trace(),console.groupEnd()),this.content&&"function"==typeof this.content.destroy&&this.content.destroy();for(const t of this.vidoInstance.destroyable)t();this.vidoInstance.onChangeFunctions.length=0,this.vidoInstance.destroyable.length=0,this.vidoInstance.destroyed=!0,this.destroyed=!0,this.vidoInstance.update()}}update(n={}){return this.vidoInstance.debug&&(console.groupCollapsed(`component update method fired ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.renderFunction(n)}change(n,i={leave:!1}){const o=n;this.vidoInstance.debug&&(console.groupCollapsed(`component change method fired ${this.instance}`),console.log(s({props:o,components:t.keys(),onChangeFunctions:this.vidoInstance.onChangeFunctions,changedProps:n,actionsByInstance:e})),console.trace(),console.groupEnd());for(const t of this.vidoInstance.onChangeFunctions)t(n,i)}}}(n,r,Dt);class y{constructor(s="",i=""){this.instance="",this.name="",this.destroyable=[],this.destroyed=!1,this.onChangeFunctions=[],this.debug=!1,this.state=t,this.api=e,this.lastProps={},this.html=$,this.svg=A,this.lithtml=D,this.directive=R,this.asyncAppend=dt,this.asyncReplace=at,this.cache=ut,this.classMap=Mt,this.styleMap=wt,this.StyleMap=Tt,this.guard=vt,this.live=bt,this.ifDefined=yt,this.repeat=ft,this.unsafeHTML=$t,this.until=_t,this.schedule=Nt,this.getElement=R(Ot),this.actionsByInstance=()=>{},this.detach=Ct,this.PointerAction=Ht,this.Action=Pt,this.Slots=Rt,this._components=n,this._actions=r,this.instance=s,this.reuseComponents=this.reuseComponents.bind(this),this.onDestroy=this.onDestroy.bind(this),this.onChange=this.onChange.bind(this),this.update=this.update.bind(this),this.destroyComponent=this.destroyComponent.bind(this);for(const t in a)this[t]=a[t].bind(this);this.name=i,this.Actions=new u(s)}static addMethod(t,e){a[t]=e}onDestroy(t){this.destroyable.push(t)}onChange(t){this.onChangeFunctions.push(t)}update(t){return this.updateTemplate(t)}reuseComponents(t,e,s,n,i=!0,o=!1){const r=[],h=t.length,l=e.length;let c=!1;!i||void 0!==e&&0!==e.length||(c=!0);let a=0;if(h<l){let i=l-h;for(;i;){const o=e[l-i],h=this.createComponent(n,s(o));t.push(h),r.push(h),i--}}else if(h>l){let e=h-l;if(i)c=!0,a=h-e;else{for(;e;){const s=h-e;r.push(t[s]),t[s].destroy(),e--}t.length=l}}let d=0;o&&console.log("modified components",r),o&&console.log("current components",t),o&&console.log("data array",e);for(const n of t){const t=e[d];o&&console.log(`reuse components data at '${d}'`,t),n&&!r.includes(n)&&(o&&console.log("getProps fn result",s(t)),n.change(s(t),{leave:c&&d>=a})),d++}}createComponent(t,e={}){const i=t.name+":"+s++;let o;o=new y(i,t.name);const h=new p(i,o,e),l=new v(i,o,t(o,e));return n.set(i,l),n.get(i).change(e),o.debug&&(console.groupCollapsed(`component created ${i}`),console.log(Dt({props:e,components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd()),h}destroyComponent(t,e){if(e.debug&&(console.groupCollapsed(`destroying component ${t}...`),console.log(Dt({components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd()),r.has(t))for(const e of r.get(t))"function"==typeof e.componentAction.destroy&&e.componentAction.destroy(e.element,e.props);r.delete(t);const s=n.get(t);s?(s.destroy(),n.delete(t),e.debug&&(console.groupCollapsed(`component destroyed ${t}`),console.log(Dt({components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd())):console.warn(`No component to destroy! [${t}]`)}executeActions(){for(const t of r.values()){for(const e of t)if(void 0===e.element.vido){const t=n.get(e.instance);e.isActive=function(){return t&&!1===t.destroyed};const s=e.componentAction,i=s.create;if(void 0!==i){let t;t=i.prototype&&(i.prototype.isAction||i.prototype.update||i.prototype.destroy)||i.isAction?new i(e.element,e.props):i(e.element,e.props),void 0!==t&&("function"==typeof t?s.destroy=t:("function"==typeof t.update&&(s.update=t.update.bind(t)),"function"==typeof t.destroy&&(s.destroy=t.destroy.bind(t))))}}else e.element.vido=e.props,"function"==typeof e.componentAction.update&&e.isActive()&&e.componentAction.update(e.element,e.props);for(const e of t)e.element.vido=e.props}}updateTemplate(t){return t&&l.push(t),new Promise((t=>{const e=++h,s=this;c.then((function(){if(e===h){h=0,s.render();for(const t of l)t();l.length=0,t(null)}}))}))}createApp(t){o=t.element;const e=this.createComponent(t.component,t.props);return i=e.instance,this.render(),e}render(){const t=n.get(i);t?(C(t.update(),o),this.executeActions()):o&&o.remove()}}return new y}jt.prototype.lithtml=D,jt.prototype.Action=Pt,jt.prototype.Directive=O,jt.prototype.schedule=Nt,jt.prototype.detach=Ct,jt.prototype.styleMap=wt,jt.prototype.classMap=Mt,jt.prototype.StyleMap=Tt,jt.prototype.PointerAction=Ht,jt.prototype.asyncAppend=dt,jt.prototype.asyncReplace=at,jt.prototype.cache=ut,jt.prototype.guard=vt,jt.prototype.live=bt,jt.prototype.ifDefined=yt,jt.prototype.repeat=ft,jt.prototype.unsafeHTML=$t,jt.prototype.until=_t,jt.prototype.Slots=Rt;const Wt=D;export{Pt as Action,O as Directive,k as PartType,Ht as PointerAction,Rt as Slots,Tt as StyleMap,U as _$LH,dt as asyncAppend,at as asyncReplace,ut as cache,Mt as classMap,jt as default,Ct as detach,R as directive,vt as guard,kt as helpers,$ as html,yt as ifDefined,Wt as lit,D as lithtml,_ as noChange,b as nothing,C as render,ft as repeat,Nt as schedule,wt as styleMap,A as svg,$t as unsafeHTML,_t as until};
//# sourceMappingURL=vido.min.js.map

@@ -67,3 +67,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Vido=e()}(this,(function(){"use strict";

* SPDX-License-Identifier: BSD-3-Clause
*/const St=W(class extends z{constructor(t){var e;if(super(t),t.type!==B||"class"!==t.name||(null===(e=t.strings)||void 0===e?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((e=>t[e])).join(" ")+" "}update(t,[e]){var s,n;if(void 0===this.et){this.et=new Set,void 0!==t.strings&&(this.st=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in e)e[t]&&!(null===(s=this.st)||void 0===s?void 0:s.has(t))&&this.et.add(t);return this.render(e)}const i=t.element.classList;this.et.forEach((t=>{t in e||(i.remove(t),this.et.delete(t))}));for(const t in e){const s=!!e[t];s===this.et.has(t)||(null===(n=this.st)||void 0===n?void 0:n.has(t))||(s?(i.add(t),this.et.add(t)):(i.remove(t),this.et.delete(t)))}return _}});class Tt{constructor(){this.isAction=!0}}Tt.prototype.isAction=!0;const Ht={element:document.createTextNode(""),axis:"xy",threshold:10,onDown(){},onMove(){},onUp(){},onWheel(){}},Nt="undefined"!=typeof PointerEvent;let kt=0;class Ut extends Tt{constructor(t,e){super(),this.moving="",this.initialX=0,this.initialY=0,this.lastY=0,this.lastX=0,this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onWheel=this.onWheel.bind(this),this.element=t,this.id=++kt,this.options=Object.assign(Object.assign({},Ht),e.pointerOptions),Nt?(t.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp)):(t.addEventListener("touchstart",this.onPointerDown),document.addEventListener("touchmove",this.onPointerMove,{passive:!1}),document.addEventListener("touchend",this.onPointerUp),document.addEventListener("touchcancel",this.onPointerUp),t.addEventListener("mousedown",this.onPointerDown),document.addEventListener("mousemove",this.onPointerMove,{passive:!1}),document.addEventListener("mouseup",this.onPointerUp))}normalizeMouseWheelEvent(t){let e=t.deltaX||0,s=t.deltaY||0,n=t.deltaZ||0;const i=t.deltaMode,o=parseInt(getComputedStyle(t.target).getPropertyValue("line-height"));let r=1;switch(i){case 1:r=o;break;case 2:r=window.height}return e*=r,s*=r,n*=r,{x:e,y:s,z:n,event:t}}onWheel(t){const e=this.normalizeMouseWheelEvent(t);this.options.onWheel(e)}normalizePointerEvent(t){let e={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,screenX:0,screenY:0,event:t};switch(t.type){case"wheel":const s=this.normalizeMouseWheelEvent(t);e.x=s.x,e.y=s.y,e.pageX=e.x,e.pageY=e.y,e.screenX=e.x,e.screenY=e.y,e.clientX=e.x,e.clientY=e.y;break;case"touchstart":case"touchmove":case"touchend":case"touchcancel":e.x=t.changedTouches[0].screenX,e.y=t.changedTouches[0].screenY,e.pageX=t.changedTouches[0].pageX,e.pageY=t.changedTouches[0].pageY,e.screenX=t.changedTouches[0].screenX,e.screenY=t.changedTouches[0].screenY,e.clientX=t.changedTouches[0].clientX,e.clientY=t.changedTouches[0].clientY;break;default:e.x=t.x,e.y=t.y,e.pageX=t.pageX,e.pageY=t.pageY,e.screenX=t.screenX,e.screenY=t.screenY,e.clientX=t.clientX,e.clientY=t.clientY}return e}onPointerDown(t){if("mousedown"===t.type&&0!==t.button)return;this.moving="xy";const e=this.normalizePointerEvent(t);this.lastX=e.x,this.lastY=e.y,this.initialX=e.x,this.initialY=e.y,this.options.onDown(e)}handleX(t){let e=t.x-this.lastX;return this.lastY=t.y,this.lastX=t.x,e}handleY(t){let e=t.y-this.lastY;return this.lastY=t.y,this.lastX=t.x,e}onPointerMove(t){if(""===this.moving||"mousemove"===t.type&&0!==t.button)return;const e=this.normalizePointerEvent(t);if("x|y"===this.options.axis){let s=0,n=0;("x"===this.moving||"xy"===this.moving&&Math.abs(e.x-this.initialX)>this.options.threshold)&&(this.moving="x",s=this.handleX(e)),("y"===this.moving||"xy"===this.moving&&Math.abs(e.y-this.initialY)>this.options.threshold)&&(this.moving="y",n=this.handleY(e)),this.options.onMove({movementX:s,movementY:n,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}else if("xy"===this.options.axis){let s=0,n=0;Math.abs(e.x-this.initialX)>this.options.threshold&&(s=this.handleX(e)),Math.abs(e.y-this.initialY)>this.options.threshold&&(n=this.handleY(e)),this.options.onMove({movementX:s,movementY:n,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}else if("x"===this.options.axis)("x"===this.moving||"xy"===this.moving&&Math.abs(e.x-this.initialX)>this.options.threshold)&&(this.moving="x",this.options.onMove({movementX:this.handleX(e),movementY:0,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t}));else if("y"===this.options.axis){let s=0;("y"===this.moving||"xy"===this.moving&&Math.abs(e.y-this.initialY)>this.options.threshold)&&(this.moving="y",s=this.handleY(e)),this.options.onMove({movementX:0,movementY:s,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}}onPointerUp(t){this.moving="";const e=this.normalizePointerEvent(t);this.options.onUp({movementX:0,movementY:0,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t}),this.lastY=0,this.lastX=0}destroy(t){Nt?(t.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp)):(t.removeEventListener("mousedown",this.onPointerDown),document.removeEventListener("mousemove",this.onPointerMove),document.removeEventListener("mouseup",this.onPointerUp),t.removeEventListener("touchstart",this.onPointerDown),document.removeEventListener("touchmove",this.onPointerMove),document.removeEventListener("touchend",this.onPointerUp),document.removeEventListener("touchcancel",this.onPointerUp))}}function Lt(t){let e=0;return function(s){e||(e=requestAnimationFrame((function(){e=0,t.apply(void 0,[s])})))}}function Dt(t){return t&&t.constructor?"Object"===t.constructor.name:"object"==typeof t&&null!==t}function Bt(t){return Array.isArray(t)?new Array(t.length):Dt(t)?{}:t}function Ot(t,...e){const s=e.shift();if(s&&"function"==typeof s.clone)t=s.clone();else if(Dt(s))for(const e in s){const n=s[e];t[e]=Ot(Bt(n),n)}else if(Array.isArray(s)){t=Bt(s);let e=0;for(const n of s)t[e]=Ot(Bt(n),n),e++;const n=Object.keys(s);if(n.length>e){const i=n.length;for(let o=e;o<i;o++){const e=n[o],i=s[e];t[e]=Ot(Bt(i),i)}}}else t=s;return e.length?Ot(t,...e):t}function jt(t){if(void 0!==t.actions){const e=t.actions.map((t=>{const e=Object.assign({},t),s=Object.assign({},e.props);return delete s.state,delete s.api,delete e.element,e.props=s,e}));t.actions=e}return Ot({},t)}class Rt{constructor(t,e){this.slotInstances={},this.destroyed=!1,this.vido=t,this.props=e,this.destroy=this.destroy.bind(this),this.change=this.change.bind(this),this.html=this.html.bind(this),this.getInstances=this.getInstances.bind(this),this.setComponents=this.setComponents.bind(this),this.vido.onDestroy((()=>{this.destroy()}))}setComponents(t){if(t&&!this.destroyed){for(const e in t){const s=t[e];void 0===this.slotInstances[e]&&(this.slotInstances[e]=[]);for(const t of this.slotInstances[e])t.destroy();this.slotInstances[e].length=0;for(const t of s)this.slotInstances[e].push(this.vido.createComponent(t,this.props))}this.vido.update()}}destroy(){if(!this.destroyed){for(const t in this.slotInstances){for(const e of this.slotInstances[t])e.destroy();this.slotInstances[t].length=0}this.destroyed=!0}}change(t,e){if(!this.destroyed)for(const s in this.slotInstances){const n=this.slotInstances[s];for(const s of n)s.change(t,e)}}getInstances(t){return this.destroyed?[]:void 0===t?this.slotInstances:this.slotInstances[t]}html(t,e){if(this.destroyed)return;if(!this.slotInstances[t]||0===this.slotInstances[t].length)return e;let s=e;for(const e of this.slotInstances[t])s=e.html(s);return s}getProps(){return this.props}isDestroyed(){return this.destroyed}}class Wt extends z{update(t,e){if("function"!=typeof e[0])throw new Error("[vido] GetElementDirective argument should be a function.");(0,e[0])(t.element)}render(){return b}}function zt(t,e){let s=0;const n=new Map;let i,o,r=new Map,h=0;const l=[],c=Promise.resolve(),a={},d=function(t){return class extends z{update(e,s){const n=e.element,i=s[0],o=s[1],r=s[2];for(const e of o)if(void 0!==e){let s;if(t.has(i))for(const o of t.get(i))if(o.componentAction.create===e&&o.element===n){s=o;break}if(s)s.props=r;else{void 0!==n.vido&&delete n.vido;const s={instance:i,componentAction:{create:e,update(){},destroy(){}},element:n,props:r};let o=[];t.has(i)&&(o=t.get(i)),o.push(s),t.set(i,o)}}}render(t,e,s){return b}}}(r);class u{constructor(t){this.instance=t}create(t,e){const s=W(d);return()=>s(this.instance,t,e)}}const p=function(t,e,s){return class{constructor(t,e,s={}){this.destroyed=!1,this.instance=t,this.name=e.name,this.vidoInstance=e,this.props=s,this.destroy=this.destroy.bind(this),this.update=this.update.bind(this),this.change=this.change.bind(this),this.html=this.html.bind(this)}destroy(){this.destroyed||(this.vidoInstance.debug&&(console.groupCollapsed(`destroying component ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.vidoInstance.destroyComponent(this.instance,this.vidoInstance),this.destroyed=!0)}update(n){return this.vidoInstance.debug&&(console.groupCollapsed(`updating component ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.vidoInstance.updateTemplate(n)}change(n,i={}){this.vidoInstance.debug&&(console.groupCollapsed(`changing component ${this.instance}`),console.log(s({props:this.props,newProps:n,components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd());const o=t.get(this.instance);o&&o.change(n,i)}html(e={}){const s=t.get(this.instance);if(s&&!s.destroyed)return s.update(e,this.vidoInstance)}_getComponents(){return t}_getActions(){return e}}}(n,r,jt),v=function(t,e,s){return class{constructor(t,e,s){this.destroyed=!1,this.instance=t,this.vidoInstance=e,this.renderFunction=s,this.destroy=this.destroy.bind(this),this.update=this.update.bind(this),this.change=this.change.bind(this)}destroy(){if(!this.destroyed){this.vidoInstance.debug&&(console.groupCollapsed(`component destroy method fired ${this.instance}`),console.log(s({props:this.vidoInstance.props,components:t.keys(),destroyable:this.vidoInstance.destroyable,actionsByInstance:e})),console.trace(),console.groupEnd()),this.content&&"function"==typeof this.content.destroy&&this.content.destroy();for(const t of this.vidoInstance.destroyable)t();this.vidoInstance.onChangeFunctions.length=0,this.vidoInstance.destroyable.length=0,this.vidoInstance.destroyed=!0,this.destroyed=!0,this.vidoInstance.update()}}update(n={}){return this.vidoInstance.debug&&(console.groupCollapsed(`component update method fired ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.renderFunction(n)}change(n,i={leave:!1}){const o=n;this.vidoInstance.debug&&(console.groupCollapsed(`component change method fired ${this.instance}`),console.log(s({props:o,components:t.keys(),onChangeFunctions:this.vidoInstance.onChangeFunctions,changedProps:n,actionsByInstance:e})),console.trace(),console.groupEnd());for(const t of this.vidoInstance.onChangeFunctions)t(n,i)}}}(n,r,jt);class y{constructor(s="",i=""){this.instance="",this.name="",this.destroyable=[],this.destroyed=!1,this.onChangeFunctions=[],this.debug=!1,this.state=t,this.api=e,this.lastProps={},this.html=$,this.svg=A,this.lithtml=D,this.directive=W,this.asyncAppend=vt,this.asyncReplace=pt,this.cache=yt,this.classMap=St,this.styleMap=Yt,this.StyleMap=Et,this.guard=ft,this.live=wt,this.ifDefined=gt,this.repeat=At,this.unsafeHTML=bt,this.until=Ct,this.schedule=Lt,this.getElement=W(Wt),this.actionsByInstance=()=>{},this.detach=It,this.PointerAction=Ut,this.Action=Tt,this.Slots=Rt,this._components=n,this._actions=r,this.instance=s,this.reuseComponents=this.reuseComponents.bind(this),this.onDestroy=this.onDestroy.bind(this),this.onChange=this.onChange.bind(this),this.update=this.update.bind(this),this.destroyComponent=this.destroyComponent.bind(this);for(const t in a)this[t]=a[t].bind(this);this.name=i,this.Actions=new u(s)}static addMethod(t,e){a[t]=e}onDestroy(t){this.destroyable.push(t)}onChange(t){this.onChangeFunctions.push(t)}update(t){return this.updateTemplate(t)}reuseComponents(t,e,s,n,i=!0,o=!1){const r=[],h=t.length,l=e.length;let c=!1;!i||void 0!==e&&0!==e.length||(c=!0);let a=0;if(h<l){let i=l-h;for(;i;){const o=e[l-i],h=this.createComponent(n,s(o));t.push(h),r.push(h),i--}}else if(h>l){let e=h-l;if(i)c=!0,a=h-e;else{for(;e;){const s=h-e;r.push(t[s]),t[s].destroy(),e--}t.length=l}}let d=0;o&&console.log("modified components",r),o&&console.log("current components",t),o&&console.log("data array",e);for(const n of t){const t=e[d];o&&console.log(`reuse components data at '${d}'`,t),n&&!r.includes(n)&&(o&&console.log("getProps fn result",s(t)),n.change(s(t),{leave:c&&d>=a})),d++}}createComponent(t,e={}){const i=t.name+":"+s++;let o;o=new y(i,t.name);const h=new p(i,o,e),l=new v(i,o,t(o,e));return n.set(i,l),n.get(i).change(e),o.debug&&(console.groupCollapsed(`component created ${i}`),console.log(jt({props:e,components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd()),h}destroyComponent(t,e){if(e.debug&&(console.groupCollapsed(`destroying component ${t}...`),console.log(jt({components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd()),r.has(t))for(const e of r.get(t))"function"==typeof e.componentAction.destroy&&e.componentAction.destroy(e.element,e.props);r.delete(t);const s=n.get(t);s?(s.destroy(),n.delete(t),e.debug&&(console.groupCollapsed(`component destroyed ${t}`),console.log(jt({components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd())):console.warn(`No component to destroy! [${t}]`)}executeActions(){for(const t of r.values()){for(const e of t)if(void 0===e.element.vido){const t=n.get(e.instance);e.isActive=function(){return t&&!1===t.destroyed};const s=e.componentAction,i=s.create;if(void 0!==i){let t;t=i.prototype&&(i.prototype.isAction||i.prototype.update||i.prototype.destroy)||i.isAction?new i(e.element,e.props):i(e.element,e.props),void 0!==t&&("function"==typeof t?s.destroy=t:("function"==typeof t.update&&(s.update=t.update.bind(t)),"function"==typeof t.destroy&&(s.destroy=t.destroy.bind(t))))}}else e.element.vido=e.props,"function"==typeof e.componentAction.update&&e.isActive()&&e.componentAction.update(e.element,e.props);for(const e of t)e.element.vido=e.props}}updateTemplate(t){return t&&l.push(t),new Promise((t=>{const e=++h,s=this;c.then((function(){if(e===h){h=0,s.render();for(const t of l)t();l.length=0,t(null)}}))}))}createApp(t){o=t.element;const e=this.createComponent(t.component,t.props);return i=e.instance,this.render(),e}render(){const t=n.get(i);t?(C(t.update(),o),this.executeActions()):o&&o.remove()}}return new y}return zt.prototype.lithtml=D,zt.prototype.Action=Tt,zt.prototype.Directive=z,zt.prototype.schedule=Lt,zt.prototype.detach=It,zt.prototype.styleMap=Yt,zt.prototype.classMap=St,zt.prototype.StyleMap=Et,zt.prototype.PointerAction=Ut,zt.prototype.asyncAppend=vt,zt.prototype.asyncReplace=pt,zt.prototype.cache=yt,zt.prototype.guard=ft,zt.prototype.live=wt,zt.prototype.ifDefined=gt,zt.prototype.repeat=At,zt.prototype.unsafeHTML=bt,zt.prototype.until=Ct,zt.prototype.Slots=Rt,zt}));
*/const St=W(class extends z{constructor(t){var e;if(super(t),t.type!==B||"class"!==t.name||(null===(e=t.strings)||void 0===e?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((e=>t[e])).join(" ")+" "}update(t,[e]){var s,n;if(void 0===this.et){this.et=new Set,void 0!==t.strings&&(this.st=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in e)e[t]&&!(null===(s=this.st)||void 0===s?void 0:s.has(t))&&this.et.add(t);return this.render(e)}const i=t.element.classList;this.et.forEach((t=>{t in e||(i.remove(t),this.et.delete(t))}));for(const t in e){const s=!!e[t];s===this.et.has(t)||(null===(n=this.st)||void 0===n?void 0:n.has(t))||(s?(i.add(t),this.et.add(t)):(i.remove(t),this.et.delete(t)))}return _}});class Tt{constructor(){this.isAction=!0}}Tt.prototype.isAction=!0;const Ht={element:document.createTextNode(""),axis:"xy",threshold:10,onDown(){},onMove(){},onUp(){},onWheel(){}},Nt="undefined"!=typeof PointerEvent;let kt=0;class Ut extends Tt{constructor(t,e){super(),this.moving="",this.initialX=0,this.initialY=0,this.lastY=0,this.lastX=0,this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onWheel=this.onWheel.bind(this),this.element=t,this.id=++kt,this.options=Object.assign(Object.assign({},Ht),e.pointerOptions),Nt?(t.addEventListener("pointerdown",this.onPointerDown),document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp)):(t.addEventListener("touchstart",this.onPointerDown),document.addEventListener("touchmove",this.onPointerMove,{passive:!1}),document.addEventListener("touchend",this.onPointerUp),document.addEventListener("touchcancel",this.onPointerUp),t.addEventListener("mousedown",this.onPointerDown),document.addEventListener("mousemove",this.onPointerMove,{passive:!1}),document.addEventListener("mouseup",this.onPointerUp))}normalizeMouseWheelEvent(t){let e=t.deltaX||0,s=t.deltaY||0,n=t.deltaZ||0;const i=t.deltaMode,o=parseInt(getComputedStyle(t.target).getPropertyValue("line-height"));let r=1;switch(i){case 1:r=o;break;case 2:r=window.height}return e*=r,s*=r,n*=r,{x:e,y:s,z:n,event:t}}onWheel(t){const e=this.normalizeMouseWheelEvent(t);this.options.onWheel(e)}normalizePointerEvent(t){let e={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,screenX:0,screenY:0,event:t};switch(t.type){case"wheel":const s=this.normalizeMouseWheelEvent(t);e.x=s.x,e.y=s.y,e.pageX=e.x,e.pageY=e.y,e.screenX=e.x,e.screenY=e.y,e.clientX=e.x,e.clientY=e.y;break;case"touchstart":case"touchmove":case"touchend":case"touchcancel":e.x=t.changedTouches[0].screenX,e.y=t.changedTouches[0].screenY,e.pageX=t.changedTouches[0].pageX,e.pageY=t.changedTouches[0].pageY,e.screenX=t.changedTouches[0].screenX,e.screenY=t.changedTouches[0].screenY,e.clientX=t.changedTouches[0].clientX,e.clientY=t.changedTouches[0].clientY;break;default:e.x=t.x,e.y=t.y,e.pageX=t.pageX,e.pageY=t.pageY,e.screenX=t.screenX,e.screenY=t.screenY,e.clientX=t.clientX,e.clientY=t.clientY}return e}onPointerDown(t){if("mousedown"===t.type&&0!==t.button)return;this.moving="xy";const e=this.normalizePointerEvent(t);this.lastX=e.x,this.lastY=e.y,this.initialX=e.x,this.initialY=e.y,this.options.onDown(e)}handleX(t){let e=t.x-this.lastX;return this.lastY=t.y,this.lastX=t.x,e}handleY(t){let e=t.y-this.lastY;return this.lastY=t.y,this.lastX=t.x,e}onPointerMove(t){if(""===this.moving||"mousemove"===t.type&&0!==t.button)return;const e=this.normalizePointerEvent(t);if("x|y"===this.options.axis){let s=0,n=0;("x"===this.moving||"xy"===this.moving&&Math.abs(e.x-this.initialX)>this.options.threshold)&&(this.moving="x",s=this.handleX(e)),("y"===this.moving||"xy"===this.moving&&Math.abs(e.y-this.initialY)>this.options.threshold)&&(this.moving="y",n=this.handleY(e)),this.options.onMove({movementX:s,movementY:n,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}else if("xy"===this.options.axis){let s=0,n=0;Math.abs(e.x-this.initialX)>this.options.threshold&&(s=this.handleX(e)),Math.abs(e.y-this.initialY)>this.options.threshold&&(n=this.handleY(e)),this.options.onMove({movementX:s,movementY:n,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}else if("x"===this.options.axis)("x"===this.moving||"xy"===this.moving&&Math.abs(e.x-this.initialX)>this.options.threshold)&&(this.moving="x",this.options.onMove({movementX:this.handleX(e),movementY:0,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t}));else if("y"===this.options.axis){let s=0;("y"===this.moving||"xy"===this.moving&&Math.abs(e.y-this.initialY)>this.options.threshold)&&(this.moving="y",s=this.handleY(e)),this.options.onMove({movementX:0,movementY:s,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t})}}onPointerUp(t){this.moving="";const e=this.normalizePointerEvent(t);this.options.onUp({movementX:0,movementY:0,x:e.x,y:e.y,initialX:this.initialX,initialY:this.initialY,lastX:this.lastX,lastY:this.lastY,event:t}),this.lastY=0,this.lastX=0}destroy(t){Nt?(t.removeEventListener("pointerdown",this.onPointerDown),document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp)):(t.removeEventListener("mousedown",this.onPointerDown),document.removeEventListener("mousemove",this.onPointerMove),document.removeEventListener("mouseup",this.onPointerUp),t.removeEventListener("touchstart",this.onPointerDown),document.removeEventListener("touchmove",this.onPointerMove),document.removeEventListener("touchend",this.onPointerUp),document.removeEventListener("touchcancel",this.onPointerUp))}}function Lt(t){let e=0;return function(s){e||(e=requestAnimationFrame((function(){e=0,t.apply(void 0,[s])})))}}function Dt(t){return t&&t.constructor?"Object"===t.constructor.name:"object"==typeof t&&null!==t}function Bt(t,e){return e||(Array.isArray(t)?new Array(t.length):Dt(t)?{}:t)}function Ot(t,...e){const s=e.shift();if(s&&"function"==typeof s.clone)t=s.clone();else if(Dt(s)){t||(t={});for(const e in s){const n=s[e];t[e]=Ot(Bt(n,t[e]),n)}}else if(Array.isArray(s)){t||(t=new Array(s.length));let e=0;for(const n of s)t[e]=Ot(Bt(n,t[e]),n),e++;const n=Object.keys(s);if(n.length>e){const i=n.length;for(let o=e;o<i;o++){const e=n[o],i=s[e];t[e]=Ot(Bt(i,t[e]),i)}}}else t=s;return e.length?Ot(t,...e):t}function jt(t){if(void 0!==t.actions){const e=t.actions.map((t=>{const e=Object.assign({},t),s=Object.assign({},e.props);return delete s.state,delete s.api,delete e.element,e.props=s,e}));t.actions=e}return Ot({},t)}class Rt{constructor(t,e){this.slotInstances={},this.destroyed=!1,this.vido=t,this.props=e,this.destroy=this.destroy.bind(this),this.change=this.change.bind(this),this.html=this.html.bind(this),this.getInstances=this.getInstances.bind(this),this.setComponents=this.setComponents.bind(this),this.vido.onDestroy((()=>{this.destroy()}))}setComponents(t){if(t&&!this.destroyed){for(const e in t){const s=t[e];void 0===this.slotInstances[e]&&(this.slotInstances[e]=[]);for(const t of this.slotInstances[e])t.destroy();this.slotInstances[e].length=0;for(const t of s)this.slotInstances[e].push(this.vido.createComponent(t,this.props))}this.vido.update()}}destroy(){if(!this.destroyed){for(const t in this.slotInstances){for(const e of this.slotInstances[t])e.destroy();this.slotInstances[t].length=0}this.destroyed=!0}}change(t,e){if(!this.destroyed)for(const s in this.slotInstances){const n=this.slotInstances[s];for(const s of n)s.change(t,e)}}getInstances(t){return this.destroyed?[]:void 0===t?this.slotInstances:this.slotInstances[t]}html(t,e){if(this.destroyed)return;if(!this.slotInstances[t]||0===this.slotInstances[t].length)return e;let s=e;for(const e of this.slotInstances[t])s=e.html(s);return s}getProps(){return this.props}isDestroyed(){return this.destroyed}}class Wt extends z{update(t,e){if("function"!=typeof e[0])throw new Error("[vido] GetElementDirective argument should be a function.");(0,e[0])(t.element)}render(){return b}}function zt(t,e){let s=0;const n=new Map;let i,o,r=new Map,h=0;const l=[],c=Promise.resolve(),a={},d=function(t){return class extends z{update(e,s){const n=e.element,i=s[0],o=s[1],r=s[2];for(const e of o)if(void 0!==e){let s;if(t.has(i))for(const o of t.get(i))if(o.componentAction.create===e&&o.element===n){s=o;break}if(s)s.props=r;else{void 0!==n.vido&&delete n.vido;const s={instance:i,componentAction:{create:e,update(){},destroy(){}},element:n,props:r};let o=[];t.has(i)&&(o=t.get(i)),o.push(s),t.set(i,o)}}}render(t,e,s){return b}}}(r);class u{constructor(t){this.instance=t}create(t,e){const s=W(d);return()=>s(this.instance,t,e)}}const p=function(t,e,s){return class{constructor(t,e,s={}){this.destroyed=!1,this.instance=t,this.name=e.name,this.vidoInstance=e,this.props=s,this.destroy=this.destroy.bind(this),this.update=this.update.bind(this),this.change=this.change.bind(this),this.html=this.html.bind(this)}destroy(){this.destroyed||(this.vidoInstance.debug&&(console.groupCollapsed(`destroying component ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.vidoInstance.destroyComponent(this.instance,this.vidoInstance),this.destroyed=!0)}update(n){return this.vidoInstance.debug&&(console.groupCollapsed(`updating component ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.vidoInstance.updateTemplate(n)}change(n,i={}){this.vidoInstance.debug&&(console.groupCollapsed(`changing component ${this.instance}`),console.log(s({props:this.props,newProps:n,components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd());const o=t.get(this.instance);o&&o.change(n,i)}html(e={}){const s=t.get(this.instance);if(s&&!s.destroyed)return s.update(e,this.vidoInstance)}_getComponents(){return t}_getActions(){return e}}}(n,r,jt),v=function(t,e,s){return class{constructor(t,e,s){this.destroyed=!1,this.instance=t,this.vidoInstance=e,this.renderFunction=s,this.destroy=this.destroy.bind(this),this.update=this.update.bind(this),this.change=this.change.bind(this)}destroy(){if(!this.destroyed){this.vidoInstance.debug&&(console.groupCollapsed(`component destroy method fired ${this.instance}`),console.log(s({props:this.vidoInstance.props,components:t.keys(),destroyable:this.vidoInstance.destroyable,actionsByInstance:e})),console.trace(),console.groupEnd()),this.content&&"function"==typeof this.content.destroy&&this.content.destroy();for(const t of this.vidoInstance.destroyable)t();this.vidoInstance.onChangeFunctions.length=0,this.vidoInstance.destroyable.length=0,this.vidoInstance.destroyed=!0,this.destroyed=!0,this.vidoInstance.update()}}update(n={}){return this.vidoInstance.debug&&(console.groupCollapsed(`component update method fired ${this.instance}`),console.log(s({components:t.keys(),actionsByInstance:e})),console.trace(),console.groupEnd()),this.renderFunction(n)}change(n,i={leave:!1}){const o=n;this.vidoInstance.debug&&(console.groupCollapsed(`component change method fired ${this.instance}`),console.log(s({props:o,components:t.keys(),onChangeFunctions:this.vidoInstance.onChangeFunctions,changedProps:n,actionsByInstance:e})),console.trace(),console.groupEnd());for(const t of this.vidoInstance.onChangeFunctions)t(n,i)}}}(n,r,jt);class y{constructor(s="",i=""){this.instance="",this.name="",this.destroyable=[],this.destroyed=!1,this.onChangeFunctions=[],this.debug=!1,this.state=t,this.api=e,this.lastProps={},this.html=$,this.svg=A,this.lithtml=D,this.directive=W,this.asyncAppend=vt,this.asyncReplace=pt,this.cache=yt,this.classMap=St,this.styleMap=Yt,this.StyleMap=Et,this.guard=ft,this.live=wt,this.ifDefined=gt,this.repeat=At,this.unsafeHTML=bt,this.until=Ct,this.schedule=Lt,this.getElement=W(Wt),this.actionsByInstance=()=>{},this.detach=It,this.PointerAction=Ut,this.Action=Tt,this.Slots=Rt,this._components=n,this._actions=r,this.instance=s,this.reuseComponents=this.reuseComponents.bind(this),this.onDestroy=this.onDestroy.bind(this),this.onChange=this.onChange.bind(this),this.update=this.update.bind(this),this.destroyComponent=this.destroyComponent.bind(this);for(const t in a)this[t]=a[t].bind(this);this.name=i,this.Actions=new u(s)}static addMethod(t,e){a[t]=e}onDestroy(t){this.destroyable.push(t)}onChange(t){this.onChangeFunctions.push(t)}update(t){return this.updateTemplate(t)}reuseComponents(t,e,s,n,i=!0,o=!1){const r=[],h=t.length,l=e.length;let c=!1;!i||void 0!==e&&0!==e.length||(c=!0);let a=0;if(h<l){let i=l-h;for(;i;){const o=e[l-i],h=this.createComponent(n,s(o));t.push(h),r.push(h),i--}}else if(h>l){let e=h-l;if(i)c=!0,a=h-e;else{for(;e;){const s=h-e;r.push(t[s]),t[s].destroy(),e--}t.length=l}}let d=0;o&&console.log("modified components",r),o&&console.log("current components",t),o&&console.log("data array",e);for(const n of t){const t=e[d];o&&console.log(`reuse components data at '${d}'`,t),n&&!r.includes(n)&&(o&&console.log("getProps fn result",s(t)),n.change(s(t),{leave:c&&d>=a})),d++}}createComponent(t,e={}){const i=t.name+":"+s++;let o;o=new y(i,t.name);const h=new p(i,o,e),l=new v(i,o,t(o,e));return n.set(i,l),n.get(i).change(e),o.debug&&(console.groupCollapsed(`component created ${i}`),console.log(jt({props:e,components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd()),h}destroyComponent(t,e){if(e.debug&&(console.groupCollapsed(`destroying component ${t}...`),console.log(jt({components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd()),r.has(t))for(const e of r.get(t))"function"==typeof e.componentAction.destroy&&e.componentAction.destroy(e.element,e.props);r.delete(t);const s=n.get(t);s?(s.destroy(),n.delete(t),e.debug&&(console.groupCollapsed(`component destroyed ${t}`),console.log(jt({components:n.keys(),actionsByInstance:r})),console.trace(),console.groupEnd())):console.warn(`No component to destroy! [${t}]`)}executeActions(){for(const t of r.values()){for(const e of t)if(void 0===e.element.vido){const t=n.get(e.instance);e.isActive=function(){return t&&!1===t.destroyed};const s=e.componentAction,i=s.create;if(void 0!==i){let t;t=i.prototype&&(i.prototype.isAction||i.prototype.update||i.prototype.destroy)||i.isAction?new i(e.element,e.props):i(e.element,e.props),void 0!==t&&("function"==typeof t?s.destroy=t:("function"==typeof t.update&&(s.update=t.update.bind(t)),"function"==typeof t.destroy&&(s.destroy=t.destroy.bind(t))))}}else e.element.vido=e.props,"function"==typeof e.componentAction.update&&e.isActive()&&e.componentAction.update(e.element,e.props);for(const e of t)e.element.vido=e.props}}updateTemplate(t){return t&&l.push(t),new Promise((t=>{const e=++h,s=this;c.then((function(){if(e===h){h=0,s.render();for(const t of l)t();l.length=0,t(null)}}))}))}createApp(t){o=t.element;const e=this.createComponent(t.component,t.props);return i=e.instance,this.render(),e}render(){const t=n.get(i);t?(C(t.update(),o),this.executeActions()):o&&o.remove()}}return new y}return zt.prototype.lithtml=D,zt.prototype.Action=Tt,zt.prototype.Directive=z,zt.prototype.schedule=Lt,zt.prototype.detach=It,zt.prototype.styleMap=Yt,zt.prototype.classMap=St,zt.prototype.StyleMap=Et,zt.prototype.PointerAction=Ut,zt.prototype.asyncAppend=vt,zt.prototype.asyncReplace=pt,zt.prototype.cache=yt,zt.prototype.guard=ft,zt.prototype.live=wt,zt.prototype.ifDefined=gt,zt.prototype.repeat=At,zt.prototype.unsafeHTML=bt,zt.prototype.until=Ct,zt.prototype.Slots=Rt,zt}));
//# sourceMappingURL=vido.umd.min.js.map
{
"name": "@neuronet.io/vido",
"version": "4.2.2",
"version": "4.2.3",
"description": "Compilation-less and eval free frontend framework for fast scalable apps.",

@@ -5,0 +5,0 @@ "main": "dist/vido.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc