UNPKG

mettle-web-components

Version:

Fast, lightweight web components for creating web pages.

7 lines (6 loc) 23.5 kB
/*! * Mettle-web-components v0.1.1 * (c) 2023-2024 maomincoding * Released under the MIT License. */ function t(t,e){const n=Object.create(null),s=t.split(",");for(let t=0;t<s.length;t++)n[s[t]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e=Object.assign,n=Object.prototype.hasOwnProperty,s=(t,e)=>n.call(t,e),r=Array.isArray,o=t=>"[object Map]"===u(t),i=t=>"function"==typeof t,c=t=>"symbol"==typeof t,l=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,u=t=>a.call(t),f=t=>u(t).slice(8,-1),h=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t=>{const e=Object.create(null);return n=>e[n]||(e[n]=t(n))})((t=>t.charAt(0).toUpperCase()+t.slice(1))),p=(t,e)=>!Object.is(t,e);function g(t,...e){console.warn(`[mettle-web-components warn] ${t}`,...e)}let _;class v{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=_,!t&&_&&(this.index=(_.scopes||(_.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=_;try{return _=this,t()}finally{_=e}}else g("cannot run an inactive effect scope.")}on(){_=this}off(){_=this.parent}stop(t){if(this._active){let e,n;for(e=0,n=this.effects.length;e<n;e++)this.effects[e].stop();for(e=0,n=this.cleanups.length;e<n;e++)this.cleanups[e]();if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function y(t){return new v(t)}function m(t,e=_){e&&e.active&&e.effects.push(t)}function w(){return _}function b(t){_?_.cleanups.push(t):g("onScopeDispose() is called when there is no active effect scope to be associated with.")}const k=t=>{const e=new Set(t);return e.w=0,e.n=0,e},S=t=>(t.w&x)>0,j=t=>(t.n&x)>0,R=new WeakMap;let O=0,x=1;let M;const E=Symbol("iterate"),C=Symbol("Map key iterate");class A{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,m(this,n)}run(){if(!this.active)return this.fn();let t=M,e=$;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=M,M=this,$=!0,x=1<<++O,O<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=x})(this):P(this),this.fn()}finally{O<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const r=e[s];S(r)&&!j(r)?r.delete(t):e[n++]=r,r.w&=~x,r.n&=~x}e.length=n}})(this),x=1<<--O,M=this.parent,$=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){M===this?this.deferStop=!0:this.active&&(P(this),this.onStop&&this.onStop(),this.active=!1)}}function P(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}function T(t,n){t.effect instanceof A&&(t=t.effect.fn);const s=new A(t);n&&(e(s,n),n.scope&&m(s,n.scope)),n&&n.lazy||s.run();const r=s.run.bind(s);return r.effect=s,r}function L(t){t.effect.stop()}let $=!0;const N=[];function W(){N.push($),$=!1}function V(){N.push($),$=!0}function z(){const t=N.pop();$=void 0===t||t}function B(t,e,n){if($&&M){let s=R.get(t);s||R.set(t,s=new Map);let r=s.get(n);r||s.set(n,r=k());D(r,{effect:M,target:t,type:e,key:n})}}function D(t,n){let s=!1;O<=30?j(t)||(t.n|=x,s=!S(t)):s=!t.has(M),s&&(t.add(M),M.deps.push(t),M.onTrack&&M.onTrack(e({effect:M},n)))}function I(t,e,n,s,i,l){const a=R.get(t);if(!a)return;let u=[];if("clear"===e)u=[...a.values()];else if("length"===n&&r(t)){const t=Number(s);a.forEach(((e,n)=>{("length"===n||!c(n)&&n>=t)&&u.push(e)}))}else switch(void 0!==n&&u.push(a.get(n)),e){case"add":r(t)?h(n)&&u.push(a.get("length")):(u.push(a.get(E)),o(t)&&u.push(a.get(C)));break;case"delete":r(t)||(u.push(a.get(E)),o(t)&&u.push(a.get(C)));break;case"set":o(t)&&u.push(a.get(E))}const f={target:t,type:e,key:n,newValue:s,oldValue:i,oldTarget:l};if(1===u.length)u[0]&&q(u[0],f);else{const t=[];for(const e of u)e&&t.push(...e);q(k(t),f)}}function q(t,e){const n=r(t)?t:[...t];for(const t of n)t.computed&&F(t,e);for(const t of n)t.computed||F(t,e)}function F(t,n){(t!==M||t.allowRecurse)&&(t.onTrigger&&t.onTrigger(e({effect:t},n)),t.scheduler?t.scheduler():t.run())}const G=t("__proto__,__v_isRef,__isMettle-web-components"),H=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(c)),J=K();function K(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const n=zt(this);for(let t=0,e=this.length;t<e;t++)B(n,"get",t+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(zt)):s}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){W();const n=zt(this)[e].apply(this,t);return z(),n}})),t}function U(t){const e=zt(this);return B(e,"has",t),e.hasOwnProperty(t)}class Q{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,n){const o=this._isReadonly,i=this._shallow;if("__v_isReactive"===e)return!o;if("__v_isReadonly"===e)return o;if("__v_isShallow"===e)return i;if("__v_raw"===e)return n===(o?i?Et:Mt:i?xt:Ot).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(n)?t:void 0;const a=r(t);if(!o){if(a&&s(J,e))return Reflect.get(J,e,n);if("hasOwnProperty"===e)return U}const u=Reflect.get(t,e,n);return(c(e)?H.has(e):G(e))?u:(o||B(t,"get",e),i?u:Gt(u)?a&&h(e)?u:u.value:l(u)?o?Pt(u):Ct(u):u)}}class X extends Q{constructor(t=!1){super(!1,t)}set(t,e,n,o){let i=t[e];if(Nt(i)&&Gt(i)&&!Gt(n))return!1;if(!this._shallow&&(Wt(n)||Nt(n)||(i=zt(i),n=zt(n)),!r(t)&&Gt(i)&&!Gt(n)))return i.value=n,!0;const c=r(t)&&h(e)?Number(e)<t.length:s(t,e),l=Reflect.set(t,e,n,o);return t===zt(o)&&(c?p(n,i)&&I(t,"set",e,n,i):I(t,"add",e,n)),l}deleteProperty(t,e){const n=s(t,e),r=t[e],o=Reflect.deleteProperty(t,e);return o&&n&&I(t,"delete",e,void 0,r),o}has(t,e){const n=Reflect.has(t,e);return c(e)&&H.has(e)||B(t,"has",e),n}ownKeys(t){return B(t,"iterate",r(t)?"length":E),Reflect.ownKeys(t)}}class Y extends Q{constructor(t=!1){super(!0,t)}set(t,e){return g(`Set operation on key "${String(e)}" failed: target is readonly.`,t),!0}deleteProperty(t,e){return g(`Delete operation on key "${String(e)}" failed: target is readonly.`,t),!0}}const Z=new X,tt=new Y,et=new X(!0),nt=new Y(!0),st=t=>t,rt=t=>Reflect.getPrototypeOf(t);function ot(t,e,n=!1,s=!1){const r=zt(t=t.__v_raw),o=zt(e);n||(p(e,o)&&B(r,"get",e),B(r,"get",o));const{has:i}=rt(r),c=s?st:n?It:Dt;return i.call(r,e)?c(t.get(e)):i.call(r,o)?c(t.get(o)):void(t!==r&&t.get(e))}function it(t,e=!1){const n=this.__v_raw,s=zt(n),r=zt(t);return e||(p(t,r)&&B(s,"has",t),B(s,"has",r)),t===r?n.has(t):n.has(t)||n.has(r)}function ct(t,e=!1){return t=t.__v_raw,!e&&B(zt(t),"iterate",E),Reflect.get(t,"size",t)}function lt(t){t=zt(t);const e=zt(this);return rt(e).has.call(e,t)||(e.add(t),I(e,"add",t,t)),this}function at(t,e){e=zt(e);const n=zt(this),{has:s,get:r}=rt(n);let o=s.call(n,t);o?Rt(n,s,t):(t=zt(t),o=s.call(n,t));const i=r.call(n,t);return n.set(t,e),o?p(e,i)&&I(n,"set",t,e,i):I(n,"add",t,e),this}function ut(t){const e=zt(this),{has:n,get:s}=rt(e);let r=n.call(e,t);r?Rt(e,n,t):(t=zt(t),r=n.call(e,t));const o=s?s.call(e,t):void 0,i=e.delete(t);return r&&I(e,"delete",t,void 0,o),i}function ft(){const t=zt(this),e=0!==t.size,n=o(t)?new Map(t):new Set(t),s=t.clear();return e&&I(t,"clear",void 0,void 0,n),s}function ht(t,e){return function(n,s){const r=this,o=r.__v_raw,i=zt(o),c=e?st:t?It:Dt;return!t&&B(i,"iterate",E),o.forEach(((t,e)=>n.call(s,c(t),c(e),r)))}}function dt(t,e,n){return function(...s){const r=this.__v_raw,i=zt(r),c=o(i),l="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,u=r[t](...s),f=n?st:e?It:Dt;return!e&&B(i,"iterate",a?C:E),{next(){const{value:t,done:e}=u.next();return e?{value:t,done:e}:{value:l?[f(t[0]),f(t[1])]:f(t),done:e}},[Symbol.iterator](){return this}}}}function pt(t){return function(...e){{const n=e[0]?`on key "${e[0]}" `:"";console.warn(`${d(t)} operation ${n}failed: target is readonly.`,zt(this))}return"delete"!==t&&("clear"===t?void 0:this)}}function gt(){const t={get(t){return ot(this,t)},get size(){return ct(this)},has:it,add:lt,set:at,delete:ut,clear:ft,forEach:ht(!1,!1)},e={get(t){return ot(this,t,!1,!0)},get size(){return ct(this)},has:it,add:lt,set:at,delete:ut,clear:ft,forEach:ht(!1,!0)},n={get(t){return ot(this,t,!0)},get size(){return ct(this,!0)},has(t){return it.call(this,t,!0)},add:pt("add"),set:pt("set"),delete:pt("delete"),clear:pt("clear"),forEach:ht(!0,!1)},s={get(t){return ot(this,t,!0,!0)},get size(){return ct(this,!0)},has(t){return it.call(this,t,!0)},add:pt("add"),set:pt("set"),delete:pt("delete"),clear:pt("clear"),forEach:ht(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((r=>{t[r]=dt(r,!1,!1),n[r]=dt(r,!0,!1),e[r]=dt(r,!1,!0),s[r]=dt(r,!0,!0)})),[t,n,e,s]}const[_t,vt,yt,mt]=gt();function wt(t,e){const n=e?t?mt:yt:t?vt:_t;return(e,r,o)=>"__v_isReactive"===r?!t:"__v_isReadonly"===r?t:"__v_raw"===r?e:Reflect.get(s(n,r)&&r in e?n:e,r,o)}const bt={get:wt(!1,!1)},kt={get:wt(!1,!0)},St={get:wt(!0,!1)},jt={get:wt(!0,!0)};function Rt(t,e,n){const s=zt(n);if(s!==n&&e.call(t,s)){const e=f(t);console.warn(`Reactive ${e} contains both the raw and reactive versions of the same object${"Map"===e?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const Ot=new WeakMap,xt=new WeakMap,Mt=new WeakMap,Et=new WeakMap;function Ct(t){return Nt(t)?t:Lt(t,!1,Z,bt,Ot)}function At(t){return Lt(t,!1,et,kt,xt)}function Pt(t){return Lt(t,!0,tt,St,Mt)}function Tt(t){return Lt(t,!0,nt,jt,Et)}function Lt(t,e,n,s,r){if(!l(t))return console.warn(`value cannot be made reactive: ${String(t)}`),t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const o=r.get(t);if(o)return o;const i=(c=t).__v_skip||!Object.isExtensible(c)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(c));var c;if(0===i)return t;const a=new Proxy(t,2===i?s:n);return r.set(t,a),a}function $t(t){return Nt(t)?$t(t.__v_raw):!(!t||!t.__v_isReactive)}function Nt(t){return!(!t||!t.__v_isReadonly)}function Wt(t){return!(!t||!t.__v_isShallow)}function Vt(t){return $t(t)||Nt(t)}function zt(t){const e=t&&t.__v_raw;return e?zt(e):t}function Bt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const Dt=t=>l(t)?Ct(t):t,It=t=>l(t)?Pt(t):t;function qt(t){$&&M&&D((t=zt(t)).dep||(t.dep=k()),{target:t,type:"get",key:"value"})}function Ft(t,e){const n=(t=zt(t)).dep;n&&q(n,{target:t,type:"set",key:"value",newValue:e})}function Gt(t){return!(!t||!0!==t.__v_isRef)}function Ht(t){return Kt(t,!1)}function Jt(t){return Kt(t,!0)}function Kt(t,e){return Gt(t)?t:new Ut(t,e)}class Ut{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:zt(t),this._value=e?t:Dt(t)}get value(){return qt(this),this._value}set value(t){const e=this.__v_isShallow||Wt(t)||Nt(t);t=e?t:zt(t),p(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Dt(t),Ft(this,t))}}function Qt(t){Ft(t,t.value)}function Xt(t){return Gt(t)?t.value:t}function Yt(t){return i(t)?t():Xt(t)}const Zt={get:(t,e,n)=>Xt(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const r=t[e];return Gt(r)&&!Gt(n)?(r.value=n,!0):Reflect.set(t,e,n,s)}};function te(t){return $t(t)?t:new Proxy(t,Zt)}class ee{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t((()=>qt(this)),(()=>Ft(this)));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function ne(t){return new ee(t)}function se(t){Vt(t)||console.warn("toRefs() expects a reactive object but received a plain one.");const e=r(t)?new Array(t.length):{};for(const n in t)e[n]=ce(t,n);return e}class re{constructor(t,e,n){this._object=t,this._key=e,this._defaultValue=n,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=zt(this._object),e=this._key,null==(n=R.get(t))?void 0:n.get(e);var t,e,n}}class oe{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function ie(t,e,n){return Gt(t)?t:i(t)?new oe(t):l(t)&&arguments.length>1?ce(t,e,n):Ht(t)}function ce(t,e,n){const s=t[e];return Gt(s)?s:new re(t,e,n)}class le{constructor(t,e,n,s){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new A(t,(()=>{this._dirty||(this._dirty=!0,Ft(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!s,this.__v_isReadonly=n}get value(){const t=zt(this);return qt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ae(t,e,n=!1){let s,r;const o=i(t);o?(s=t,r=()=>{console.warn("Write operation failed: computed value is readonly")}):(s=t.get,r=t.set);const c=new le(s,r,o||!r,n);return e&&!n&&(c.effect.onTrack=e.onTrack,c.effect.onTrigger=e.onTrigger),c}const ue=Promise.resolve(),fe=[];let he=!1;const de=()=>{for(let t=0;t<fe.length;t++)fe[t]();fe.length=0,he=!1};class pe{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let n=!1,s=!1;this.effect=new A(t,(t=>{if(this.dep){if(t)e=this._value,n=!0;else if(!s){const t=n?e:this._value;s=!0,n=!1,r=()=>{this.effect.active&&this._get()!==t&&Ft(this),s=!1},fe.push(r),he||(he=!0,ue.then(de))}for(const t of this.dep)t.computed instanceof pe&&t.scheduler(!0)}var r;this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return qt(this),zt(this)._get()}}function ge(t){return new pe(t)}function _e(t){const e=Object.create(null),n=t.split(",");for(let t=0;t<n.length;t++)e[n[t]]=!0;return function(t){return e[t]}}const ve=_e("html,body,base,head,link,meta,style,title,address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot"),ye=_e("svg,animate,circle,clippath,cursor,image,defs,desc,ellipse,filter,font-faceforeignobject,g,glyph,line,marker,mask,missing-glyph,path,pattern,polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feFlood,feGaussianBlur,feImage,feMerge,feMorphology,feOffset,feSpecularLighting,feTile,feTurbulence,feDistantLight,fePointLight,feSpotLight,linearGradient,stop,radialGradient,animateTransform,animateMotion");function me(t){return":"===t.charAt(5)&&"xlink"===t.slice(0,5)}const we={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};function be(t){return Object.prototype.toString.call(t).match(/\[object (.+?)\]/)[1].toLowerCase()}const ke=["object","array","function","regexp","date","math"];function Se(t){return ke.includes(be(t))}function je(t){return null==t}function Re(t,e){return t.tag===e.tag&&t.key===e.key}function Oe(t,e){return t.hasOwnProperty(e)}function xe(t){if(t)return Oe(t,"tag")&&Oe(t,"props")&&Oe(t,"children")&&Oe(t,"key")&&Oe(t,"el")}function Me(t){return Array.isArray(t)?function(t){return t.every(xe)}(t):xe(t)}function Ee(t){console.warn(`[mettle-web-components warn]: ${t}`)}function Ce(t,e){Object.assign(t.style,e)}function Ae(t,e){for(const[n,s]of Object.entries(e))if(n.startsWith("on")){const e=n.slice(2).toLowerCase();t.addEventListener(e,s)}}function Pe(t,e,n){if(e.startsWith("on")){const s=e.slice(2,3).toLowerCase()+e.slice(3);"function"==typeof n[e]&&t.removeEventListener(s,n[e])}}function Te(t,e,n){if(me(e)){const s="http://www.w3.org/1999/xlink";t.setAttributeNS(s,e,n.toString())}else t.setAttribute(e,n.toString())}function Le(t,e){var n;me(e)?t.removeAttributeNS("http://www.w3.org/1999/xlink",me(n=e)?n.slice(6,n.length):""):t.removeAttribute(e)}function $e(t){switch(!0){case ve(t):return document.createElement(t);case ye(t):return e=function(t){return ye(t)?"svg":"math"===t?"math":void 0}(t),n=t,document.createElementNS(we[e],n);case"fragment"===t:return document.createDocumentFragment();case"comment"===t||"null"===t:return document.createComment(t);default:return document.createElement(t)}var e,n}const Ne=["$ref"],We=Object.create(null);function Ve(t,e){let n="";if(Array.isArray(t))if(t.length>1){let e=[];for(let n=0;n<t.length;n++){const s=t[n];e.push(Se(s)?JSON.stringify(s):s)}n=e.join("")}else n=0===t.length?"":JSON.stringify(t).replace(/,/g,"");else n=Se(t)?JSON.stringify(t):t;e.textContent=n}function ze(t,e,n){const{tag:s,props:r,children:o}=t;if(!je(s)){const i=$e(s);if(t.el=i,!je(r)){Ae(i,r);const t=Object.keys(r);for(let e=0;e<t.length;e++){const n=t[e],s=r[n],o=be(s);"function"===o||"key"===n||Ne.includes(n)||Te(i,n,s),"style"===n&&"object"===o&&Ce(i,s),n===Ne[0]&&"string"===o&&(We[s]=i)}}if(!je(o))if(Me(o)){const t=be(o);if("array"===t)for(let t=0;t<o.length;t++){const e=o[t];xe(e)&&ze(e,i)}else"object"===t&&ze(o,i)}else i&&Ve(o,i);if(n)e.insertBefore(i,n);else{if(!e)return i;e.appendChild(i)}}}function Be(t,e){if(Re(t,e)){const n=e.el=t.el,s=t.props||{},r=e.props||{},o=Object.keys(r),i=Object.keys(s);for(let t=0;t<o.length;t++){const e=o[t],i=r[e],c=s[e],l=be(i);i!==c&&(je(i)?Le(n,e):("function"===l||"key"===e||Ne.includes(e)||Te(n,e,i),"style"===e&&"object"===l&&Ce(n,i),"function"===l&&i.toString()!==c.toString()&&(Pe(n,e,s),Ae(n,r))))}for(let t=0;t<i.length;t++){const e=i[t];o.includes(e)||Le(n,e)}const c=t.children,l=e.children;"array"===be(c)&&"array"===be(l)?function(t,e,n){const s=e.length;let r=0,o=t.length-1,i=s-1;for(;r<=o&&r<=i&&Re(t[r],e[r]);)Be(t[r],e[r]),r++;for(;r<=o&&r<=i&&Re(t[o],e[i]);)Be(t[o],e[i]),o--,i--;if(r>o){if(r<=i){const t=i+1,o=t<s?e[t].el:null;for(;r<=i;)n.insertBefore(ze(e[r]),o),r++}}else if(r>i)for(;r<=o;)n.removeChild(t[r].el),r++;else{const c=r,l=r,a=new Map;for(r=l;r<=i;r++){const t=e[r];null!=t.key&&a.set(t.key,r)}let u,f=0;const h=i-l+1;let d=!1,p=0;const g=new Array(h);for(r=0;r<h;r++)g[r]=0;for(let s=c;s<=o;s++){if(f>=h){n.removeChild(t[s].el);continue}let r;if(null!==t[s].key)r=a.get(t[s].key);else for(u=l;u<=i;u++)if(0===g[u-l]&&Re(t[s],e[u])){r=u;break}void 0===r?n.removeChild(t[s].el):(g[r-l]=s+1,r>p?p=r:d=!0,Be(t[s],e[r]),f++)}const _=d?function(t){const e=t.slice(),n=[0];let s,r,o,i,c;const l=t.length;for(s=0;s<l;s++){const l=t[s];if(0!==l){if(r=n[n.length-1],t[r]<l){e[s]=r,n.push(s);continue}for(o=0,i=n.length-1;o<i;)c=(o+i)/2|0,t[n[c]]<l?o=c+1:i=c;l<t[n[o]]&&(o>0&&(e[s]=n[o-1]),n[o]=s)}}for(o=n.length,i=n[o-1];o-- >0;)n[o]=i,i=e[i];return n}(g):[];u=_.length-1;for(let t=h-1;t>=0;t--){const r=t+l,o=r+1<s?e[r+1].el:null;0===g[t]?n.insertBefore(ze(e[r]),o):d&&(u<0||t!==_[u]?n.insertBefore(e[r].el,o):u--)}}}(c,l,n):xe(c)&&xe(l)?Be(c,l):Me(c)||Me(l)||c===l||Ve(l,n)}else{const n=t.el.parentNode,s=t.el.nextSibling;n.removeChild(t.el),ze(e,n,s)}}let De=null,Ie=null;function qe(){De.innerHTML="";ze(Ie(),De)}function Fe(t){return{mount(e){const n=function(t){if("string"==typeof t){const e=document.querySelector(t);if(!e){let e=null;return t.startsWith("#")?(e=document.createElement("div"),e.setAttribute("id",t.substring(1,t.length))):t.startsWith(".")?(e=document.createElement("div"),e.setAttribute("class",t.substring(1,t.length))):Ee(`Failed to mount app: mount target selector "${t}" returned null.`),document.body.insertAdjacentElement("afterbegin",e),e}return e}return t instanceof HTMLElement?t:window.ShadowRoot&&t instanceof window.ShadowRoot&&"closed"===t.mode?(Ee('mounting on a ShadowRoot with `{mode: "closed"}` may lead to unpredictable bugs.'),null):null}(e);if(n){const e=t();"array"===be(e)?Ee("Please provide a root node."):(De=n,Ie=t,ze(e,n))}else Ee("There must be a mount element node.")}}}let Ge=!1,He=!1;const Je=[];let Ke=0;const Ue=[];let Qe=null,Xe=0;const Ye=Promise.resolve();let Ze=null;function tn(t){const e=Ze||Ye;return t?e.then(this?t.bind(this):t):e}function en(t,e,n,s){let r;try{r=s?t(...s):t()}catch(t){console.error(t)}return r}function nn(t){Je.length&&Je.includes(t,Ge&&t.allowRecurse?Ke+1:Ke)||(null==t.id?Je.push(t):Je.splice(function(t){let e=Ke+1,n=Je.length;for(;e<n;){const s=e+n>>>1;sn(Je[s])<t?e=s+1:n=s}return e}(t.id),0,t),Ge||He||(He=!0,Ze=Ye.then(on)))}const sn=t=>null==t.id?1/0:t.id,rn=(t,e)=>{const n=sn(t)-sn(e);if(0===n){if(t.pre&&!e.pre)return-1;if(e.pre&&!t.pre)return 1}return n};function on(t){He=!1,Ge=!0,t=t||new Map,Je.sort(rn);const e=e=>ln(t,e);try{for(Ke=0;Ke<Je.length;Ke++){const t=Je[Ke];if(t&&!1!==t.active){if(e(t))continue;en(t)}}}finally{Ke=0,Je.length=0,function(t){if(Ue.length){const e=[...new Set(Ue)];if(Ue.length=0,Qe)return void Qe.push(...e);for(Qe=e,t=t||new Map,Qe.sort(((t,e)=>sn(t)-sn(e))),Xe=0;Xe<Qe.length;Xe++)ln(t,Qe[Xe])||Qe[Xe]();Qe=null,Xe=0}}(t),Ge=!1,Ze=null,(Je.length||Ue.length)&&on(t)}}const cn=t=>"function"==typeof t;function ln(t,e){if(t.has(e)){const n=t.get(e);if(n>100){const t=e.ownerInstance,n=t&&function(t,e=!0){return cn(t)?t.displayName||t.name:t.name||e&&t.__name}(t.type);return console.warn(`Maximum recursive updates exceeded${n?` in component <${n}>`:""}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`),!0}t.set(e,n+1)}else t.set(e,1)}let an;function un(t,e){"function"==typeof t&&(e=t,t=Object.create(null));class n extends HTMLElement{static get observedAttributes(){return t.props}constructor(){super();const n=this._props={};an=this;const s=(t,e)=>{this.dispatchEvent(new CustomEvent(t,{detail:e}))};this.emit=(t,...e)=>{s(t,e)};const r={props:n,content:this},o=e.call(this,r);an=null;const i=this.attachShadow({mode:"open"});if(t.styles&&Array.isArray(t.styles)){const e=document.createElement("style");e.textContent=t.styles.join(""),i.appendChild(e)}let c=!1,l=null;const a=new A((()=>{const t=o();c?Be(l,t):(ze(t,i),c=!0),l=t}),(()=>nn(u))),u=()=>a.run();u()}connectedCallback(){this._m&&this._m.forEach((t=>t()))}disconnectedCallback(){this._um&&this._um.forEach((t=>t()))}attributeChangedCallback(t,e,n){this._props[t]=n,this._w&&this._w.forEach((t=>t()))}}return n}function fn(t){return e=>{an&&(an[t]||(an[t]=[])).push(e)}}const hn=fn("_m"),dn=fn("_um"),pn=fn("_w");function gn(t,e,n){customElements.get(t)||customElements.define(t,e,n)}export{v as EffectScope,A as ReactiveEffect,ae as computed,Fe as createApp,ne as customRef,ge as deferredComputed,un as defineComponent,We as domInfo,T as effect,y as effectScope,V as enableTracking,w as getCurrentScope,Vt as isProxy,$t as isReactive,Nt as isReadonly,Gt as isRef,Wt as isShallow,Bt as markRaw,tn as nextTick,hn as onMounted,b as onScopeDispose,dn as onUnmounted,W as pauseTracking,te as proxyRefs,Ct as reactive,Pt as readonly,Ht as ref,gn as registerComponent,z as resetTracking,qe as resetView,At as shallowReactive,Tt as shallowReadonly,Jt as shallowRef,L as stop,zt as toRaw,ie as toRef,se as toRefs,Yt as toValue,B as track,I as trigger,Qt as triggerRef,Xt as unref,pn as watchProps};