yvee 0.0.8 → 0.0.10
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/dist/index.d.ts +763 -476
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Pr=Object.defineProperty;var Lr=(t,r)=>{for(var n in r)Pr(t,n,{get:r[n],enumerable:!0,configurable:!0,set:(o)=>r[n]=()=>o})};var At={};Lr(At,{isWindow:()=>q,isUndefined:()=>Ir,isStr:()=>v,isPromise:()=>Zr,isPlainObject:()=>H,isObject:()=>Fr,isObj:()=>E,isNumber:()=>Z,isNum:()=>St,isNull:()=>lt,isNotWindow:()=>p,isNotNull:()=>qr,isInt:()=>Rt,isFN:()=>w,isDefined:()=>Ur,isClassOrId:()=>Xr,isBool:()=>k,isAsync:()=>Cr,isArraybuff:()=>Br,isArr:()=>g});var w=(t)=>typeof t==="function",Cr=(t)=>t.constructor.name==="AsyncFunction",Zr=(t)=>!!t&&typeof t.then==="function",Z=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},Fr=(t)=>{return t&&typeof t==="object"&&!Array.isArray(t)},H=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype&&!Array.isArray(t)},Br=(t)=>{return t instanceof Uint8Array||t instanceof ArrayBuffer||typeof t==="string"},Xr=(t)=>{return t.startsWith(".")||t.startsWith("#")},k=(t)=>typeof t==="boolean",v=(t)=>typeof t==="string",g=(t)=>Array.isArray(t),E=(t)=>typeof t==="object",St=(t)=>typeof t==="number",lt=(t)=>t===null,qr=(t)=>t===null,Ir=(t)=>typeof t==="undefined",Ur=(t)=>typeof t!=="undefined",Rt=(t)=>{return Number.isInteger(Number(t))},q=typeof window!=="undefined",p=typeof window==="undefined";function ct(t,r){l(r).forEach(([n,o])=>{Ot(t,n,{value:o,writable:!1,configurable:!1,enumerable:!0})})}var Dt=(t)=>{return g(t)?t:[t]};class ${static set i(t){console.info(...Dt(t))}static set e(t){console.error(...Dt(t))}static set w(t){console.warn(...Dt(t))}}class D{_c=0;_id="";constructor(t){if(this._c=0,this._id=t??x(5),t?.includes("-")){let[r,n]=[t.split("-").slice(0,-1).join("-"),t.split("-").slice(-1)[0]];this._id=r,this._c=Z(n)?parseInt(n):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var Jr=(t)=>Array.from({length:t},(r,n)=>n),kt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",vt="abcdefghijklmnopqrstuvwxyz";var S=(t)=>JSON.stringify(t),tr=(t)=>{return JSON.parse(t)};var M=(t)=>{if(t.startsWith("webkit"))t="-"+t;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},x=(t)=>{let r=kt+vt,n=Jr(10).join("");return Array.from({length:t},(o,i)=>r+(i?n:"")).reduce((o,i)=>{return o+=i.charAt(Math.floor(Math.random()*i.length))},"")},Wr=(t=6,r)=>{if(!r)return Math.floor(Math.random()*t);return Math.round(Math.random()*(r-t)+t)},rr=()=>{let t=[...kt,...vt],r=Wr(0,t.length);return t[r]};var nr=(t,r)=>{let n=r==="/"?"":r;if(r.startsWith("#"))return t+r;return r.startsWith("/")?t+n:r};class a extends Map{obj(t){t&&l(t).forEach(([r,n])=>this.set(r,n))}map(t){t.forEach((r,n)=>{if(r instanceof a)this.set(n,r);else if(g(r)){if(this.lacks(n))this.set(n,[]);this.get(n).push(...r)}else if(E(r))this.ass(n,r);else this.set(n,r)})}ass(t,r){if(!this.has(t))this.set(t,{});d(this.get(t),r)}lacks(t){return!this.has(t)}init(t,r){return this.has(t)?this.get(t):this.set(t,r).get(t)}}var{values:A,keys:W,entries:l}=Object;var{defineProperty:Ot,assign:d}=Object,or=(t,r)=>Object.hasOwn(t,r),R=(t)=>{return Object.keys(t).length},dt=(t,r)=>{if(!r.has(t))r.set(t,new a);return r.get(t)},tt=(t,r)=>{if(!r.has(t))r.set(t,[]);return r.get(t)},Ht=(t,r)=>{let n={added:{},removed:{},modified:{}},o=W(t),i=W(r);for(let e of i){let f=t[e],s=r[e];if(!(e in t))n.added[e]=s;else if(g(f)&&g(s)){if(S(f)!==S(s))n.modified[e]={old:f,new:s}}else if(E(f)&&E(s)&&!lt(f)&&!lt(s)){let u=Ht(f,s);if(R(u.added)||R(u.removed)||R(u.modified))n.modified[e]={old:f,new:s}}else if(f!==s)n.modified[e]={old:f,new:s}}for(let e of o)if(!(e in r))n.removed[e]=t[e];return n};function ir(t,r){if(t.size!==r.size)return!1;for(let n of t)if(!r.has(n))return!1;return!0}var er=(t)=>{return A(t).some((r)=>{return R(r)})};var I=(t,r)=>{return{name:t,content:r}},Gr=(t,r)=>{return{property:t,content:r}},Qr=(t,r)=>{return{"http-equiv":t,content:r}};class rt{metas=[];constructor(t){t&&this.metas.push(I("description",t))}author(t){return this.meta=I("author",t),this}charset(t){return this.meta={charset:t},this}keywords(...t){return this.meta=I("keywords",t.join(", ")),this}viewport(t){let r=l(t).map(([n,o])=>[M(n),String(o)].join("="));return this.meta=I("viewport",r.join(", ")),this}httpEquiv(t){return l(t).forEach(([r,n])=>{this.meta=Qr(M(r),String(n))}),this}robots(...t){return this.meta=I("robots",t.join(", ")),this}themeColor(t){return this.meta=I("theme-color",t),this}openGraph(t){return l(t).forEach(([r,n])=>{this.meta=Gr("og:"+r,String(n))}),this}twitter(t){return l(t).forEach(([r,n])=>{this.meta=I("twitter:"+r,String(n))}),this}push(t){this.metas.unshift(...t)}set meta(t){this.metas.push(t)}}class Mt{title;description;base;meta;link;script;css}var Kr=["charset","name","property","http-equiv"],sr=(t,r)=>{r.forEach((n)=>{for(let o of Kr)if(o in n){let i=n[o];t[`${o}_${o==="charset"?"":i}`]=n}})},zr=(t,r)=>{r.forEach((n)=>{if("href"in n){let o=n.href;t[`${o}`]=n}})};class G{_head;idm;constructor(t){this._head=new a(t)}set head(t){l(t).forEach(([r,n])=>{if(r==="title"||r==="base"){if(n!==void 0)this._head.set(r,n);return}if(n instanceof rt)return sr(this._head.init("meta",{}),n.metas);if(!g(n))return;switch(r){case"meta":return sr(this._head.init("meta",{}),n);case"link":return zr(this._head.init("link",{}),n);case"script":if(n.length){this._head.init(r,[]);let o=n.map((i)=>{if(!i.yid&&this.idm)i.yid="sc"+this.idm.mid;return i});this._head.get(r).push(...o)}return}})}get head(){return this._head}set id(t){this.idm=new D(t)}}var nt=(t)=>{return l(t??{}).reduce((r,[n,o])=>{return r.push(k(o)&&o?n:`${n}="${o}"`),r},[""]).join(" ")},fr=(t)=>{let r=new Set;if(!t)return"";let n=[...t].reduce((o,[i,e])=>{if(i==="meta"||i==="link")e=A(e);if(v(e)){if(i==="title")r.add(`<${i}>${e}</${i}>`);else o.add(`<${i}>${e}</${i}>`);return o}if(!g(e))return o;if(i==="base"){let s=e.slice(-1);if(s)return r.add(`<${i}${nt(s[0])}>`),o}return e.map((s)=>{if(i==="script"){let u={...s},h="";if("importmap"in u)u.type="importmap",h=JSON.stringify(u.importmap),delete u.importmap;else if("body"in u)h=u.body,delete u.body;return`<${i}${nt(u)}>${h}</${i}>`}return`<${i}${nt(s)}>`}).forEach((s)=>{if(s.includes('type="module"'))r.add(s);else if(s.includes("<meta"))r.add(s);else o.add(s)}),o},new Set);return[...r,...n].join("")};class ot{lang="en";htmlHead;head;constructor(){this.htmlHead=new a,this.head=(t={})=>{let r=new G(this.htmlHead),{css:n,description:o,...i}=t;if(o)r.head={meta:[{name:"description",content:o}]};if(n){let f=(g(n)?n:[n]).map((s)=>({rel:"preload stylesheet",href:s,as:"style"}));r.head={link:[...f]}}r.head=i,this.htmlHead=r.head}}}var jt=(t)=>{if(p)return;return new Promise((r,n)=>{let o=null;if(t.href)o=document.querySelector(`link[href="${t.href}"]`);if(o){r(o);return}let i=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";l(t).forEach(([e,f])=>{i.setAttribute(e,f)}),i.onload=()=>r(i),i.onerror=()=>n(new Error("Failed to load CSS")),document.head.appendChild(i)})},ur=(t)=>{if(p)return;return new Promise((r,n)=>{let o=document.createElement("script"),i="";if("importmap"in t)t.type="importmap",i=JSON.stringify(t.importmap),delete t.importmap;else if("body"in t)i=t.body,delete t.body;if(i)o.textContent=i;l(t).forEach(([e,f])=>{o.setAttribute(e,f)}),o.onload=()=>r(o),o.onerror=()=>n(new Error("Failed to load Script")),document.head.appendChild(o),requestAnimationFrame(()=>r("Script executed"))})},Nr=()=>{let r=document.querySelector("#d-css")?.sheet;if(r)return r;let n=document.createElement("style");return n.id="d-css",document.head.appendChild(n),n.sheet},Vr=(t,r)=>{for(let n=0;n<t.cssRules.length;n++)if(t.cssRules[n].selectorText===r)return!0;return!1},_r=(t)=>Object.entries(t).map(([r,n])=>`${M(r)}: ${n};`).join(" ");function Or(t,r={}){if(p)return;let n=Nr();if(!n)return;if(!Vr(n,t))n.insertRule(`${t} { ${_r(r)} }`,n.cssRules.length)}var Yt=(t,r=!1)=>{if(Z(t))return[+t,Rt(t)?"int":"float"];if(r&&/\.\w+$/.test(t))return[t,"file"];if(t==="/")return[t,"-"];if(t.length===36&&t.match(/\-/g)?.length===4)return[t,"uuid"];return[t,"string"]},Q=(t)=>{let r=t.startsWith("/")?t:"/"+t,n=r.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[o,i]=n.reduce(([e,f],s)=>{if(s.includes("<")){let u=s.match(/(?<=<)[^/].*?(?=>|$)/g);if(u?.length){let[h,m]=u[0].split(":");if(h)e.push(h),f.push(m||"_")}}else e.push(s===">"?"/":s);return[e,f]},[[],[]]);if(r.endsWith("/")&&r.length>1)o.push("/");return{parsed:o,args:i}};class pt{storage;constructor(){this.storage=new a}cache(t,r){if(this.storage.lacks(t))this.storage.set(t,r());return this.storage.get(t)}}var hr=["int","float","file","uuid","string"],Tt=(t,r)=>{let n={},o=[],{parsed:i}=Q(t),{parsed:e,args:f}=Q(r);if(i.length===e.length)e.map((s,u)=>{let h=Yt(i[u],i.length-1===u);if(s===h[0])return h[0];if(hr.includes(h[1]))return o.push(h[0]),h[1];return s}),f.forEach((s,u)=>{n[s]=o[u]});return n};class K{_storage;CC;constructor(){this._storage=new a,this.CC=new pt}set(t){let{parsed:r,path:n}=t,o=S(r);if(!this._storage.get(o))this._storage.set(o,t);else throw`path: ${n} already used.`}get(t){let{parsed:r}=this.CC.cache(t,()=>Q(t)),n={},o=this._storage.get(S(r));if(!o&&t!=="/")for(let i of this._storage.keys()){let e=[],f=tr(i);if(r.length===f.length){let s=f.map((m,b)=>{let T=Yt(r[b],r.length-1===b);if(m===T[0])return T[0];if(hr.includes(T[1]))return e.push(T[0]),T[1];return m}),u=S(s);if(this._storage.has(u)){o=this._storage.get(u),o?.args.forEach((m,b)=>{n[m]=e[b]});break}}}return[o,n]}}class it{path="";parsed=[];args=[];constructor(t){ct(this,{path:t,...Q(t)})}}class Pt{date;constructor(t){this.date=t?new Date(t):new Date}delta(t=null,r=!1){let n=Pt.delta(this.date.getTime(),t);return r?new Date(n):n}timed(t){if(!t)return this.date;return[["year","FullYear"],["month","Month"],["day","Date"],["hour","Hours"],["minute","Minutes"],["second","Seconds"]].reduce((n,[o,i])=>{let e=t[o];return e?new Date(n[`set${i}`](n[`get${i}`]()+e)):n},new Date(this.date))}static delta(t,r=null){return r?r-t:t-Date.now()}static local(t){return new Date(t).toLocaleString()}static get now(){return Date.now()}}class Lt{static rand(t=6,r){if(r)return Math.floor(Math.random()*(r-t+1)+t);return Math.floor(Math.random()*t)+1-1}static fill(t,r=null){return Array(t).fill(r)}static new({dom:t,id:r,inner:n}){let o=document.createElement(t);if(r)o.id=r;if(n)o.innerHTML=n;return o}static randFrom(t){if(Array.isArray(t)){let r=t.length,n=this.rand(0,r-1);return t[n]}else if(typeof t=="object"){let r=W(t),n=r.length,o=this.rand(0,n-1);return r[o]}}static randArray(t=[],r=1,n=!1){let o=[],i=n?new Set:null;while((n?i.size:o.length)<r){let e=t[Lt.rand(0,t.length-1)];n?i.add(e):o.push(e)}return n?[...i]:o}static randomAZ=rr;static makeID=x;static class(t,...r){let n=r;if(t?.class)n.push(...g(t.class)?t.class:[t.class]);t.class=r}static get O(){return{vals:A,keys:W,items:l,has:or,ass:d,len:(t={})=>W(t).length}}static get is(){return At}static get return(){return ar}static sleep=(t=1000)=>new Promise((r)=>setTimeout(r,t));static get screen(){let{innerWidth:t}=window,r={xs:t<=480,sm:t>=480,smd:t>=624,md:t>=768,lg:t>=1024,xl:t>=1280,xxl:t>=1536},n=l(r).reverse();for(let o=0;o<n.length;o++){let[i,e]=n[o];if(e)return i}return}bytes(t){if(t===0)return"0 Bytes";let r=1024,n=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(t)/Math.log(r));return parseFloat((t/Math.pow(r,o)).toFixed(2))+" "+n[o]}static format(t){return new mr(t)}}class ar{static arr(t){return t?g(t)?t:[t]:[]}static num(t,r=0){let n=parseFloat(t);return isNaN(n)?r:n}static str(t){return String(t)}static arr2obj(t,r=!1){return t.reduce((n,o,i)=>{if(r)n[o]=i;else n[i]=o;return n},{})}}class mr{val;constructor(t){this.val=t}get px(){return`${this.val}px`}get rem(){return`${this.val}rem`}get pr(){return`${this.val}%`}}var Ct={},U={};class gr{stream;url;constructor(t,r){if(this.url=t,t in Ct)this.stream=Ct[t];else this.stream=new EventSource(t,{withCredentials:r}),Ct[t]=this.stream,U[this.url]={}}on(t){let r=this.stream;return l(t).forEach(([n,o])=>{if(n in U[this.url])U[this.url][n].forEach((i)=>{this.stream.removeEventListener(n,i)}),U[this.url][n]=[];if(r.addEventListener(n,o),!(n in U[this.url]))U[this.url][n]=[];U[this.url][n].push(o)}),this}}function lr(t,r=!0){return new gr(t,r)}class cr{value;constructor(t){this.value=t}get str(){return String(this.value).toString()=="null"?null:String(this.value).toString()}get int(){if(Z(this.value))return parseInt(this.value);else return null}get float(){if(Z(this.value))return parseFloat(this.value);else return null}get bool(){if(this.value==="true")return!0;else if(this.value=="false")return!1;else return null}get json(){if(this.value)return JSON.parse(this.value);return null}}class z{key;state;storage;constructor(t,r="local",n){if(this.storage=r=="local"?localStorage:sessionStorage,typeof t=="object"){let[o,i]=l(t)[0];if(this.key=o,this.state=i,n){let e=this.as[n];this.state.value=e}N((e)=>{this.set=e},[this.state],{id:this.key})}else this.key=t,this.state=null}get as(){return new cr(this.storage.getItem(this.key))}get value(){return this.storage.getItem(this.key)}set set(t){let r=E(t)?S(t):String(t);this.storage.setItem(this.key,r)}get remove(){this.storage.removeItem(this.key);return}}var dr={get:(t)=>new z(t,"local"),init:(t,r)=>new z(t,"local",r)};var pr={get:(t)=>new z(t,"session")};class bt extends it{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class Tr extends it{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class Zt extends ot{storage=new K;errorStorage=new K;wssStorage=new K;route;error;wss;base;constructor(t=""){super();this.base=t?t.startsWith("/")?t:`/${t}`:"",this.route=(r)=>{let n=this._base(r);return(o)=>{return o.route=n,this.storage.set(new bt(n,x(5),o)),o}},this.wss=(r)=>{let n=this._base(r);return(o)=>{return o.route=n,this.wssStorage.set(new Tr(n,x(5),o)),o}},this.error=(...r)=>{return(n)=>{if(r.length)r.forEach((o)=>{this.errorStorage.set(new bt(o.toString(),x(5),n))});else this.errorStorage.set(new bt("404",x(5),n));return n}}}_base(t){return nr(this.base,t)}async getPath(t){return this.storage.get(t)}async loadError(t){return this.errorStorage.get(t.toString())}async loadWSS(t){return this.wssStorage.get(t)}}var et=new a,V=(t)=>{if(p)return;let r=et.get(t);if(r?.isConnected)return r;et.delete(t);let n=document.getElementById(t);if(!n)return;return et.set(t,n),n};function br(){let t=[];return et.forEach((r,n)=>{if(!r.isConnected)t.push(n),et.delete(n)}),t}function N(t,r,{id:n="stateHook",init:o}={}){if(p)return()=>{};let i=[],e=()=>r.map((s)=>s.value),f=()=>{t(...e())};if(r.forEach((s)=>{i.push(s.hook(f)(n))}),o)f();return()=>{i.forEach((s)=>s())}}var yr=(t)=>{t.forEach((r)=>r())};var kr=(t,r)=>{for(let[n,o]of t){let i=V(n);if(!i){t.delete(n);continue}o.forEach((e)=>{e.call(i,r)})}};class j extends EventTarget{options;deep;verify;hooks=new a;states=new a;_value;listening=!1;end;constructor(t,r={},n=!0,o=!0){super();this.options=r;this.deep=n;this.verify=o;this._value=t}get value(){return this._value}set value(t){if(!this.verify){this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(!this.deep){if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(H(this._value)||g(this._value)){let r=Ht(this._value,t);if(!er(r))return}else if(this._value instanceof Set){if(!ir(this._value,t))return}else if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let t=(r)=>{if(yr(this.hooks),kr(this.states,r.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",t,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",t,this.options),this.end=void 0,this.listening=!1}}call(t,r){return(n)=>{if(dt(n,this.states).set(r,t),!p&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(n))this.states.get(n)?.delete(r)}}}hook(t){return(r)=>{if(this.hooks.set(r,t),!p&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(r))this.hooks.delete(r)}}}}function Y(t,r={}){return new j(t,r,!0)}function vr(t,r=!1){return new j(t,{},!1,r)}var _=(t)=>{if(g(t))return t.filter((r)=>r!==void 0).join(" ");else if(E(t)){if(H(t))return S(t)}else if(w(t))return _(t());else if(t!==void 0&&t!==null)return k(t)?t?"":"false":String(t);return""};function tn(t,r){switch(r??t){case"style":return function(n){this.style.setProperty(t,n)};default:return function(n){this.setAttribute(t,n)}}}class Ft{attr;constructor(t={}){this.attr=t}get(t,r=this.attr,n){let o=(i,e)=>{if(g(e))t.attr_push(i,_(e));else if(e instanceof j){let f=n?`${n}_${i}`:i;t.states.push(e.call(tn(i,n),f)),o(i,e.value)}else if(E(e)){if(H(e)&&!n)this.get(t,e,i)}else t.attr_push(i,_(e),n)};l(r).forEach(([i,e])=>{if(i==="ref"){if(e instanceof st)t.events.obj({element(){e.element=this}})}else if(["on"].includes(i))E(r.on)&&t.events.obj(r.on);else o(i,e)})}unload(t){let r=void 0;if(t in this.attr)r=this.attr[t],delete this.attr[t];return r}}class F{xid;IDM;map=new a;states=[];events=new a;OZ;constructor(t,r=new D,n){this.xid=t;this.IDM=r;this.OZ=n??new yt}attr_push(t,r,n){let o=n??t;if(!this.map.has(o))this.map.set(o,[]);let i=n?`${M(t)}:${r};`:r;this.map.get(o).push(i)}get attr(){let t=[""];return this.map.forEach((r,n)=>{let o=r.join("");t.push(o?`${n}="${o}"`:n)}),t.join(" ")}set id(t){if(!this.map.has("id"))this.map.set("id",[t])}get id(){return this.map.get("id")?.join("")}}var rn=(t,r,n)=>{return t.addEventListener(r,n),()=>{t.removeEventListener(r,n)}},ft={};class yt{events=new a;states=new a;winStates=new a;windowEvents=new a;resetST=new a;resetEV=new a;constructor(){}get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(t){let{id:r,events:n,states:o}=t;if(r){if(n.size)this.events.set(r,n);if(o.length)this.states.set(r,o)}return this}push(t){return t.events.forEach((r,n)=>{r.forEach((o,i)=>{dt(n,this.events).set(i,o)})}),t.states.forEach((r,n)=>{tt(n,this.states).push(...r)}),this}get stage(){return this.events.forEach((t,r)=>{this.events.delete(r);let n=V(r);if(!n){this.events.delete(r);return}t.forEach((o,i)=>{switch(i){case"ready":case"element":o.apply(n,[n]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let e=i.replace(/^win/,"");this.windowEvents.init(e,new a).set(r,o);break;case"state":let[f,s,u]=o.apply(n,[n]),h=g(s)?s:[s];if(!h.length)break;let m=()=>h.map((T)=>T.value),b=()=>f(...m());if(u)b();h.forEach((T)=>tt(r,this.resetST).push(T.call(b,r+"_state")(r)));break;default:tt(r,this.resetEV).push(rn(n,i,o))}})}),this.processWindowEvents,this.states.forEach((t,r)=>{this.states.delete(r),t.forEach((n)=>{tt(r,this.resetST).push(n(r))})}),this}get processWindowEvents(){let t=(r,n)=>{let o=0,i=!1,e=(s)=>{if(o=window.scrollY,!i)window.requestAnimationFrame(()=>{n.forEach((u,h)=>{let m=V(h);if(m)u.call(m,s);else this.windowEvents.get(r)?.delete(h)}),i=!1}),i=!0},f=(s)=>{n.forEach((u,h)=>{let m=V(h);if(m)u.call(m,s);else this.windowEvents.get(r)?.delete(h)})};return window.addEventListener(r,r==="scroll"?e:f),()=>{window.removeEventListener(r,r==="scroll"?e:f)}};return this.windowEvents.forEach((r,n)=>{if(r.size){if(!ft[n])ft[n]=t(n,r)}else if(ft[n])ft[n](),delete ft[n]}),this}reset(t){return t.forEach((r)=>{this.windowEvents.forEach((n,o)=>{if(n.has(r))n.delete(r)}),this.resetEV.get(r)?.forEach((n)=>{n()}),this.resetST.get(r)?.forEach((n)=>{n()}),this.resetST.delete(r),this.resetEV.delete(r)}),this}RPS(t){if(t){let r=br();this.reset(r);let n=t.keys;if(n.length)this.reset(n).push(t).stage}return this}}var P=new yt;var nn=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],on=(t)=>nn.includes(t);function en(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var xt=(t,r)=>{if(g(t))return t.map((n)=>xt(n,r)).join("");else if(t instanceof ht){let n=t.__(r.IDM),{ctx:o,oz:i}=n;return r.OZ.push(i),o}else if(E(t))return S(t);else if(w(t))return xt(t(),r);else if(t!==void 0&&t!==null)return en(t);return""},wt=(t,r)=>{let n=new D(r),o=new F(n.id,n);return{ctx:xt(t,o),catt:o}};function sn(t){let r=this.id;if(r){let{ctx:n,catt:o}=wt(t,r);if(this.innerHTML!==n)this.innerHTML=n,P.RPS(o.OZ)}}var ut=(t,r,n,o=[])=>{if(g(t))t.forEach((i)=>{ut(i,t.length,n,o)});else if(t instanceof j)if(r>1)ut(B("div",{},t),r,n,o);else{let i=t.value,e=i instanceof ht?"dom":"ctx",{ctx:f,catt:s}=wt(i,n.xid+"-0");n.xid=s.xid,o.push(f),n.OZ.push(s.OZ),n.states.push(t.call(sn,e))}else o.push(xt(t,n))};class Bt{tag;ctx;closing;constructor(t,r){this.tag=t;this.ctx=r;let n=on(t);this.closing=n?"":`</${t}>`}process(t,r=this.ctx,n=[]){return r.forEach((o)=>{ut(o,r.length,t,n)}),n.join("")}get(t){let r=this.process(t);if(t.events.size||t.states.length)t.id=t.xid;return`<${this.tag}${t.attr}>${r}${this.closing}`}}class ht{tag;constructor(t,r={},...n){this.tag=t;ct(this,{attr:new Ft(r),ctx:new Bt(t,n)})}__(t=new D){let r=t.mid,n=new F(r,t);return this.attr.get(n),{ctx:this.ctx.get(n),oz:n.OZ.set(n),id:n.id}}}function B(t,r={},...n){if(w(t))return $.i=t,t(r??{},...n);return new ht(t,r??{},n)}var fn=(t,...r)=>r;class Xt{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,r={}){return this.e.animate(t,r)}get slide(){let t=({x:r=0,y:n=0},o={})=>{d(this.opt,o);let i=[[r,n],[0,0]].map(([e,f])=>({transform:`translateX(${e}rem) translateY(${f}rem)`}));return this.e.animate(i,this.opt),this};return{left:(r={})=>{return t({x:-2},r)},right:(r={})=>{return t({x:2},r)},up:(r={})=>{return t({y:2},r)},down:(r={})=>{return t({y:-2},r)}}}fade(t={}){d(this.opt,t);let r=[0,1].map((n)=>({opacity:n}));return this.e.animate(r,this.opt),this}shake(t="Y",r={}){d(this.opt,r);let n=[0,5,-5,5,0].map((o)=>({transform:`translate${t}(${o}px)`}));return this.e.animate(n,this.opt),this}color(t=[],r={}){d(this.opt,r);let n=Array.isArray(t)?t.map((o)=>({color:o})):{color:t};return this.e.animate(n,this.opt),this}bg(t=[],r={}){d(this.opt,r);let n=Array.isArray(t)?t.map((o)=>({backgroundColor:o})):{backgroundColor:t};return this.e.animate(n,this.opt),this}bounce(t=1,r={}){d(this.opt,r);let n=[0.5,t,1].map((o)=>({transform:`scale(${o})`}));return this.e.animate(n),this}}class Ut{e;query;constructor(t,r){this.e=t;this.query=r}get a(){return new Xt(this)}get all(){if(this.query){let t=document.querySelectorAll(this.query);if(t.length)return Array.from(t).map((r)=>r)}return[]}get attr(){let t=this.e;return{has:(r)=>{return t.hasAttribute(r)},get:(r)=>{return t.getAttribute(r)},del:(r)=>{return t.removeAttribute(r),this},set:(r)=>{for(let n in r){let o=r[n];if(r[n]!==void 0)t.setAttribute(n,_(o))}return this}}}get children(){return Array.from(this.e.children).map((t)=>c(t))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return this.e.disabled??!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let t=this.e.offsetParent;if(t)return new L(t);return}get parent(){let t=this.e.parentElement;if(t)return new L(t);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let t=this.e.style,r=this;return{set:(n,o=0)=>{let i=t,e=()=>{l(n).forEach(([f,s])=>{if(f in i){if(i[f]!==s)i[f]=s}else if(s!==null)t.setProperty(f,String(s))})};if(w(o))r.on("transitionend",o);if(St(o))setTimeout(e,o);else e();return r},get:(n)=>{let o=M(String(n));return t.getPropertyValue(o)},del:(...n)=>{n.forEach((o)=>{let i=M(String(o));t.removeProperty(i)})}}}get submit(){let t=this.e;if("submit"in t)return t.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.insertAdjacentHTML("beforeend",r),P.RPS(n)}set appendfirst(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.insertAdjacentHTML("afterbegin",r),P.RPS(n)}set inner(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.innerHTML=r,P.RPS(n)}set disabled(t){let r=this.e;if("disabled"in r)r.disabled=t}set id(t){this.e.id=t}set value(t){let r=this.e;r.value=t}}var qt=(t,r)=>{let{ctx:n,catt:o}=wt(t,r);return{ctx:n,oz:o.OZ}},It=(t)=>t?`${t}-0`:t;class L extends Ut{constructor(t,r){super(t,r)}add(...t){return this.e.classList.add(...t.map((r)=>r.replace(/[^\w-]/,""))),()=>{this.e.classList.remove(...t.map((r)=>r.replace(/[^\w-]/,"")))}}remove(...t){return this.e.classList.remove(...t.map((r)=>r.replace(/[^\w-]/,""))),this}toggle(t,r){let n=typeof t!="string"?t.apply(this):t;return this.e.classList.toggle(n,r)}hasNode(t){return this.e.contains(t)}has(...t){let r=this.e.classList;return t.every((n)=>r.contains(n))}insert(t){return{HTML:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentHTML(t,n)}),this},element:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentElement(t,n)}),this},text:function(...r){return r.forEach((n)=>{this.e.insertAdjacentText(t,n)}),this}}}is(t){let r=this.e.classList,n=this.e.tagName.toLocaleLowerCase(),o=!0,i=!0;if(t.dom)i=t.dom==n?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((e)=>{o=o?r.contains(e):!1});else o=o?r.contains(t.class):!1;return o&&i}on(t,r,n=!1){let o=!1;if(t.indexOf("touch")>-1)o=!0;return this.e.addEventListener(t,r,{capture:n,passive:o}),this}remove_on(t,r,n=!1){return this.e.removeEventListener(t,r,n),this}timed(t,r=250){return setTimeout(()=>t(this),r),this}animate(t,r,n){let o={duration:300,easing:"ease",fill:"forwards"};if(w(r))n=r;else d(o,r);let i=this.e.animate(t,o);if(n)i.finished.then(n);return this}}function c(t,r){let n=r?r:document;if(v(t)){let o=n.querySelector(t);if(o)return new L(o,t);return}else if(H(t)){let[[o,i]]=l(t),f=`${o==="id"?"#":"."}${i}`,s=n.querySelector(f);if(s)return new L(s,f);return}else return new L(t)}class st{state=new j(void 0);constructor(){}get element(){return this.state.value?.e}set element(t){if(t)this.state.value=new L(t);else this.state.value=void 0}get $(){return this.state.value}}var un=()=>{return new st};class Jt{lang;head="";constructor(t,r){if(this.lang=t,r)this.head=fr(r)}body(t,r,n){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${r??x(5)}"${n?" "+n:""}>${t}</body>`,"</html>"].join("")}}class $t extends Mt{path;args;id;status;lang;import;_data={};static route="/";constructor(t,r={},n,o=200){super();this.path=t;this.args=r;this.id=n;this.status=o}async loader(){if(this.import)try{let t=await this.import;if(t.default)this.import=await t.default({...this.args,...this.data});else this.import=void 0}catch(t){return $.e=["import",{error:"loader"}],this.import=void 0,[]}if(this.body){let t=await this.body();return g(t)?t:[t]}if(this.import){let t=this.import;return g(t)?t:[t]}return[]}getHeadAttr(t={},...r){let n=new G;if(R(t))n.head=t;n.id=this.id;let o=n.head;return r.forEach((i)=>{o.map(i)}),hn(n,this),o}set data(t){d(this._data,t)}get data(){return this._data}}class Wt extends $t{head(){this.title=`error ${this.status}`}body(){return B("div",{},this.path+" not found...")}}function hn(t,r){let{link:n,script:o,meta:i,title:e,base:f,description:s,css:u}=r;if(t.head={title:e,base:f,meta:i,link:n,script:o},s)t.head={meta:[{name:"description",content:s}]};if(u){let m=(g(u)?u:[u]).map((b)=>({rel:"preload stylesheet",href:b,as:"style"}));t.head={link:[...m]}}}function xr(t){let r=[];if(t?.length){let{href:n,target:o}=t[0],i=c("base");if(i){if(i.attr.get("href")!==n)i.attr.set({href:n,target:o})}else{let e=c(document.createElement("base"));e.attr.set({href:n,target:o}),document.head.append(e.e)}}return r}var wr=new a;async function $r(t,r={},n=!1){let o=at.value,i={};if(c("link")?.all.forEach((e)=>{let f=c(e),s=f.attr.get("href");if(s){let u=f.attr.get("rt");if(n){let h=wr.get(o);if(h){if(!h.has(s))i[s]=f.unload}else i[s]=f.unload}else if(u){if(u===t)i[s]=f.unload}}}),r&&R(r))for(let e of A(r)){let f=e.href;if(!(f in i))try{let s=void 0;if(!n){if(s=c(`link[href='${f}']`),s)s.attr.set({rt:t});e.rt=t;let u=wr.init(o,new Set);if(!u.has(f))u.add(f)}if(!s)await jt(e)}catch(s){$.e=["link error",{error:"yvee @ link"}]}else delete i[f]}return A(i)}var an=["charset","name","property","http-equiv"];function Er(t){let r={};if(c("meta")?.all.forEach((n)=>{let o=n.attributes;for(let i of an)if(i in o){let e=o[i].value;r[`${i}_${i==="charset"?"":e}`]=n}}),t)l(t).forEach(([n,o])=>{if(n in r)c(r[n]).attr.set(o),delete r[n];else{let i=c(document.createElement("meta"));i.attr.set(o),document.head.append(i.e)}});return A(r).map((n)=>c(n).unload)}var Sr=new a;async function Rr(t,r,n=!1){let o=at.value,i={};if(c("script[yid]")?.all.forEach((e)=>{let f=c(e),s=f.attr.get("yid");if(s){let u=f.attr.get("rt");if(n){let h=Sr.get(o);if(h){if(!h.has(s))i[s]=f.unload}else i[s]=f.unload}else if(u){if(u===t)i[s]=f.unload}}}),r){for(let e of r)if("yid"in e)if(e.yid in i)delete i[e.yid];else try{if(!n){e.rt=t;let f=e.yid,s=Sr.init(o,new Set);if(!s.has(f))s.add(f)}await ur(e)}catch(f){$.e=["script error",{error:"yvee @ script"}]}}return A(i)}async function Ar(t,r){let n=[];if(p)return[];let o=t.get("title")??"",{pushState:i}=this.config;if(i){let e=this.path.value,f=this.lastPath.value;if(f!==e)if(!f.startsWith(e))X(e,o);else if(e===this.base)X(e,o);else X(e,o)}if(o&&(document.title=o),this.isYvee)document.documentElement.lang=r,n.push(...xr(t.get("base"))),n.push(...Er(t.get("meta")));return n.push(...await $r(this.id,t.get("link"),this.isYvee)),n.push(...await Rr(this.id,t.get("script"),this.isYvee)),n}function X(t,r){if(p)return;let{pathname:n,hash:o}=window.location,i=n+o;if(t&&i!==t)history.pushState({},r??"",t)}class Gt{path;args;static route="/";isConnected=Y(!1);data={};constructor(t,r={}){this.path=t;this.args=r;this.data=r}open(t){}message(t){}close(t){}error(t){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(t)=>{this.isConnected.value=!0,await this.open.call(this,t)},this.ws.onmessage=async(t)=>{await this.message.call(this,t)},this.ws.onclose=async(t)=>{this.isConnected.value=!1,await this.close.call(this,t)},this.ws.onerror=async(t)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,t)},this}get reconnect(){if(this.state>=2)this.connect;return this}get disconnect(){if(this.state<=1)this.ws.close();return this}get state(){return this.ws?.readyState??3}set send(t){if(this.isConnected.value)this.ws.send(t);else throw new Error(`websocket path ${this.path} not connected`)}}var O=new a;class Qt{yvee;constructor(t){this.yvee=t}async load(t){if(p)return;if(!O.has(t)){let[n,o]=await this.yvee.loadWSS(t);if(!n)return;let{cls:i,path:e,id:f}=n,s=new i(e,o).connect;return O.set(t,s),s}let r=O.get(t);return r.reconnect,r}unload(t){if(p)return;if(O.has(t)){let r=O.get(t);if(!r)return;r.disconnect,O.delete(t)}}}var Kt=new a;function mn(t,r,n,o){let{on:i,top:e,topRef:f,...s}=t,u={...i??{},click(h){h.preventDefault();let m=c(this),b=m.path;o.value=n.value,n.value=b;let T=m.hash;if(T){let J=c(T),y=window.scrollY;if(J)y+=J.rect.top;if(f)y-=f?.value?.e.offsetHeight||0;if(e)if(typeof e==="number")y-=e;else y-=e();window.scrollTo({top:y,behavior:"smooth"}),X(b+T)}else if(o.value===n.value)window.scrollTo({top:m.rect.top||0,behavior:"smooth"}),X(window.location.pathname)}};return B("a",{...s,on:{...u}},...r)}function gn(t,r,n){let{classes:o}=t.config,{on:i,...e}=r,f={...r.on??{},...n&&{popstate(s){let h=s.target.location.pathname;t.path.value=h}},...{element(s){t.mainElement=this}}};return B("div",{...e,...o&&{class:o},on:f},t.root)}async function ln(t,r){let[n,o]=await this.loadError(r??0);if(n){let{cls:i,id:e}=n;return new i(t,o,e,r)}else{let i=new Wt(t,o,x(5));return i.title=`error ${r}`,i}}function zt(){if(q)return parseInt(c('meta[name="error"]')?.attr.get("content")??"200");return 200}class mt extends Zt{config;hook;root=Y([]);socket;id=x(4);path=Y("");lastPath=Y("");loading=Y(!1);mainElement;A;Main;load;matchPath;isYvee=!1;constructor(t={},r={}){super(t.base??"");this.config=t;if(this.socket=new Qt(this),t.id)this.id=t.id;this.A=(n,...o)=>{if(this.base){if(!n.href.startsWith(this.base))n.href=this._base(n.href)}return mn(n,o,this.path,this.lastPath)},this.Main=(n)=>{if(R(r))if(!n.on)n.on=r;else d(n.on,r);return gn(this,n,this.isYvee)},this.load=async(n,o={})=>{if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,o),this.hooker()}catch(i){$.e=["render error",{error:"Pager loader"}]}}return this},this.matchPath=(n)=>{let o=this._base(n),i=this.path.value,e=this.base;if(i===o)return!0;else{let f=i.replace(e,""),s=o.replace(e,"");if(s){if(f.startsWith(s))return!0}else if(!i)return!0}return!1}}hooker(){let t={},r={},n=this.path.value;if(this.hook)this.hook();this.hook=N(async(o)=>{if(r[n]=window.scrollY,t[n]=this.mainElement?.scrollTop??0,(await this.render(o,404)).done){let i=r[o]??0;if(i)window.scrollTo({top:i,behavior:"instant"});let e=t[o]??0;if(e)this.mainElement?.scrollTo({top:e,behavior:"instant"});n=o}},[this.path],{id:"router"})}async class(t,r,n=!1){let[o,i]=await this.getPath(t);if(o&&!n){let{cls:e,id:f}=o;return new e(t,i,f)}else return await ln.call(this,t,404)}async fetch(t){if(t)try{if(t.fetch){let r=await t.fetch();if(H(r)&&R(r))t.data=r}}catch(r){$.e=["class fetch",{error:"fetch"}]}}async processHead(t,r={}){return t?await this.processClassHead(t,r):await this.processDefaultHead(r)}async processClassHead(t,r){if(t.head)await t.head();return t.getHeadAttr(r,this.htmlHead)}async processDefaultHead(t){let r=new G;if(R(t))r.head=t;return r.head.map(this.htmlHead),r.head}async render(t,r=404,n={},o={},i=!0,e=!1){let f=await this.class(t,r??zt(),e);f.data=n,await this.fetch(f);let s=await this.processHead(f,o);if(p)Kt.set(this.id,s);if(!f)return{lang:this.lang,heads:s,done:!1};let u=[];if(this.loading.value=!0,this.isYvee)u=await f.loader();let h=[];if(i)h=await Ar.call(this,s,f?.lang||this.lang);if(!this.isYvee)u=await f.loader(),h.forEach((m)=>m());if(this.isYvee)h.forEach((m)=>m());if(u.length)this.root.value=u;else await this.render(t,r,n,o,i,!0);return this.loading.value=!1,{heads:s,lang:f.lang??this.lang,done:!0}}}var at=Y("");class Et extends mt{config;isYvee=!0;unload=!0;constructor(t={},r={}){super(t,r);this.config=t;this.path=at,this.load=async(n,o={})=>{if(q)n=dn()||this._base(n??"/");if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,o),this.hooker()}catch(i){$.e=["render error",{error:"Yvee loader"}]}}return this}}}var cn=(t)=>{return(r)=>{t(r)}};function dn(){if(q)return c('meta[name="yvee"]')?.attr.get("content")??"/";return""}var Dr=(t,r,n,o=!1)=>{let i=[];if(i.push({charset:"utf-8"}),i.push({name:"viewport",content:"width=device-width, initial-scale=1.0"}),n)switch(n){case 404:i.push({name:"error",content:n.toString()});break;default:break}if(o)i.push({name:"yvee",content:r});if(t.meta)if(g(t.meta))t.meta.unshift(...i);else t.meta.push(i);else t.meta=i},Hr=async(t,r,n={},o=[])=>{let i=await r(n),e=g(i)?i:[i],f=new F(t,new D(t));return e.forEach((s)=>{ut(s,e.length,f,o)}),f.OZ.set(f),f.OZ};async function pn(t,r,n={}){let{bodyattr:o={},id:i,route:e,base:f="",index:s,data:u}=n;if(q){let h={},m=window.location.pathname,b=document.body.id;if(r)if(r instanceof Et)await r.load();else{if(u)if(w(u))h=await u();else h=u;if(e){if(e.length>1&&e.slice(-1)!=="/")m=m.replace(/^\/|\/$/g,"");d(h,Tt(m,e))}d(h,{path:m,status:zt()})}let T=await Hr(b,t,h);P.push(T),requestAnimationFrame(()=>{P.stage})}return async({path:h,data:m={},status:b=200})=>{let T=x(4),J=new a,y={};if(i)T=i;if(o.id)T=o.id.toString();let Nt="en";if(r instanceof Et){let{base:C,path:gt,id:Mr,lang:jr}=r;if(y.base=[{href:C==="/"?C:`${C}/`,target:"_blank"}],y.script)y.script.push({type:"module",src:"./index.js"});else y.script=[{type:"module",src:"./index.js"}];gt.value=h,Dr(y,h,b,!0);let{heads:_t}=await r.render(h,b,m,y,!1);Kt.values().forEach((Yr)=>{d(_t.init("link",{}),Yr.get("link")??{})}),T=Mr,J=_t,Nt=jr}else{let C=h==="/"?h:`${h}/`;if(s)C=`${s}/`;if(f)C=`${f}${C}`;if(y.base=[{href:C,target:"_self"}],y.script)y.script.push({type:"module",src:"./index.js"});else y.script=[{type:"module",src:"./index.js"}];if(e)d(m,Tt(h,e));d(m,{status:b,path:h,base:f}),d(y,w(r)?await r(m):r),Dr(y,h,b);let gt=new ot;gt.head(y),J=gt.htmlHead}let Vt=[];return await Hr(T,t,m,Vt),new Jt(Nt,J).body(Vt.join(""),T,nt(o))}}var Us=(t,r)=>{return`${t.replace(/\/+$/,"")}/${r.replace(/^\.\/+/,"")}`},Js=(t)=>{if(p)return;return t()};export{Gt as websocket,un as useRef,pr as session,Us as resolvePath,X as pushHistory,$ as log,dr as local,fn as frag,lr as eventStream,B as dom,$t as doc,jt as cssLoader,Or as addCSS,Lt as __,Et as Yvee,Pt as Time,j as Stateful,N as StateHook,Y as State,cn as Routes,pn as Render,st as Ref,vr as QState,mt as Pager,rt as Meta,Js as IfClient,c as $};
|
|
1
|
+
var Mn=Object.defineProperty;var Xn=(o,n)=>{for(var i in n)Mn(o,i,{get:n[i],enumerable:!0,configurable:!0,set:(t)=>n[i]=()=>t})};var B=function(o,n,i,t){var r=arguments.length,f=r<3?n:t===null?t=Object.getOwnPropertyDescriptor(n,i):t,m;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")f=Reflect.decorate(o,n,i,t);else for(var u=o.length-1;u>=0;u--)if(m=o[u])f=(r<3?m(f):r>3?m(n,i,f):m(n,i))||f;return r>3&&f&&Object.defineProperty(n,i,f),f};var g=(o,n)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(o,n)};var Zo={};Xn(Zo,{isWindow:()=>c,isUndefined:()=>Wn,isStr:()=>p,isPromise:()=>Jn,isPlainObject:()=>j,isObject:()=>Fn,isObj:()=>R,isNumber:()=>_,isNum:()=>Uo,isNull:()=>fo,isNotWindow:()=>U,isNotNull:()=>En,isModule:()=>Lo,isInt:()=>Bo,isFN:()=>L,isDefined:()=>Sn,isClassOrId:()=>jn,isBool:()=>N,isAsync:()=>qn,isArraybuff:()=>Qn,isArr:()=>b});var L=(o)=>typeof o==="function",qn=(o)=>o.constructor.name==="AsyncFunction",Jn=(o)=>!!o&&typeof o.then==="function",_=(o)=>{return!isNaN(parseFloat(o))&&isFinite(o)},Fn=(o)=>{return o&&typeof o==="object"&&!Array.isArray(o)},j=(o)=>{return typeof o==="object"&&o!==null&&Object.getPrototypeOf(o)===Object.prototype&&!Array.isArray(o)},Lo=(o)=>{return o&&typeof o==="object"&&o[Symbol.toStringTag]==="Module"},Qn=(o)=>{return o instanceof Uint8Array||o instanceof ArrayBuffer||typeof o==="string"},jn=(o)=>{return o.startsWith(".")||o.startsWith("#")},N=(o)=>typeof o==="boolean",p=(o)=>typeof o==="string",b=(o)=>Array.isArray(o),R=(o)=>typeof o==="object",Uo=(o)=>typeof o==="number",fo=(o)=>o===null,En=(o)=>o===null,Wn=(o)=>typeof o==="undefined",Sn=(o)=>typeof o!=="undefined",Bo=(o)=>{return Number.isInteger(Number(o))},c=typeof window!=="undefined",U=typeof window==="undefined";var zn=(o)=>{if(U)return;return o()};function lo(o,n){$(n).forEach(([i,t])=>{ao(o,i,{value:t,writable:!1,configurable:!1,enumerable:!0})})}var Ao=(o)=>{return b(o)?o:[o]};class I{static set i(o){console.info(...Ao(o))}static set e(o){console.error(...Ao(o))}static set w(o){console.warn(...Ao(o))}}class A{_c=0;_id="";constructor(o){if(this._c=0,this._id=o??E(5),o?.includes("-")){let[n,i]=[o.split("-").slice(0,-1).join("-"),o.split("-").slice(-1)[0]];this._id=n,this._c=_(i)?parseInt(i):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var In=(o)=>Array.from({length:o},(n,i)=>i),ko="ABCDEFGHIJKLMNOPQRSTUVWXYZ",eo="abcdefghijklmnopqrstuvwxyz";var w=(o)=>JSON.stringify(o),vo=(o)=>{return JSON.parse(o)};var X=(o)=>{if(o.startsWith("webkit"))o="-"+o;return o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},E=(o)=>{let n=ko+eo,i=In(10).join("");return Array.from({length:o},(t,r)=>n+(r?i:"")).reduce((t,r)=>{return t+=r.charAt(Math.floor(Math.random()*r.length))},"")},Kn=(o=6,n)=>{if(!n)return Math.floor(Math.random()*o);return Math.round(Math.random()*(n-o)+o)},on=()=>{let o=[...ko,...eo],n=Kn(0,o.length);return o[n]};class y extends Map{obj(o){o&&$(o).forEach(([n,i])=>this.set(n,i))}map(o){o.forEach((n,i)=>{if(n instanceof y)this.set(i,n);else if(b(n)){if(this.lacks(i))this.set(i,[]);this.get(i).push(...n)}else if(R(n))this.ass(i,n);else this.set(i,n)})}ass(o,n){if(!this.has(o))this.set(o,{});T(this.get(o),n)}lacks(o){return!this.has(o)}init(o,n){return this.has(o)?this.get(o):this.set(o,n).get(o)}}var{values:G,keys:K,entries:$}=Object;var{defineProperty:ao,assign:T}=Object,nn=(o,n)=>Object.hasOwn(o,n),W=(o)=>{return Object.keys(o).length},uo=(o,n)=>{if(!n.has(o))n.set(o,new y);return n.get(o)},l=(o,n)=>{if(!n.has(o))n.set(o,[]);return n.get(o)},d=(o,n)=>{let i={added:{},removed:{},modified:{}},t=K(o),r=K(n);for(let f of r){let m=o[f],u=n[f];if(!(f in o))i.added[f]=u;else if(b(m)&&b(u)){if(w(m)!==w(u))i.modified[f]={old:m,new:u}}else if(R(m)&&R(u)&&!fo(m)&&!fo(u)){let x=d(m,u);if(W(x.added)||W(x.removed)||W(x.modified))i.modified[f]={old:m,new:u}}else if(m!==u)i.modified[f]={old:m,new:u}}for(let f of t)if(!(f in n))i.removed[f]=o[f];return i};function tn(o,n){if(o.size!==n.size)return!1;for(let i of o)if(!n.has(i))return!1;return!0}var mo=(o)=>{return G(o).some((n)=>{return W(n)})};var Z=(o,n,i)=>{let t=i.value;return{configurable:!0,get(){if(this===o.constructor.prototype)return t;let r=t.bind(this);return Object.defineProperty(this,n,{value:r,configurable:!0,writable:!0}),r}}};var z=(o,n)=>{return{name:o,content:n}},sn=(o,n)=>{return{property:o,content:n}},Cn=(o,n)=>{return{"http-equiv":o,content:n}};class a{metas=[];constructor(o){o&&this.metas.push(z("description",o))}author(o){return this.meta=z("author",o),this}charset(o){return this.meta={charset:o},this}keywords(...o){return this.meta=z("keywords",o.join(", ")),this}viewport(o){let n=$(o).map(([i,t])=>[X(i),String(t)].join("="));return this.meta=z("viewport",n.join(", ")),this}httpEquiv(o){return $(o).forEach(([n,i])=>{this.meta=Cn(X(n),String(i))}),this}robots(...o){return this.meta=z("robots",o.join(", ")),this}themeColor(o){return this.meta=z("theme-color",o),this}openGraph(o){return $(o).forEach(([n,i])=>{this.meta=sn("og:"+n,String(i))}),this}twitter(o){return $(o).forEach(([n,i])=>{this.meta=z("twitter:"+n,String(i))}),this}push(o){this.metas.unshift(...o)}set meta(o){this.metas.push(o)}}class wo{}var Pn=["charset","name","property","http-equiv"],rn=(o,n,i=!1,t={})=>{n.forEach((r)=>{for(let f of Pn)if(f in r){let m=r[f];if(i)T(r,{x:!0});else if(!("x"in r))T(r,t);o[`${f}_${f==="charset"?"":m}`]=r}})},Vn=(o,n,i=!1,t={})=>{n.forEach((r)=>{if("href"in r){let f=r.href;if(i)T(r,{x:!0});else if(!("x"in r))T(r,t);o[`${f}`]=r}})};class fn{_head;idm;mark;push;constructor({initial:o,mark:n,push:i}={}){this._head=new y(o),this.mark=n||!1,this.push=i||{}}set head(o){$(o).forEach(([n,i])=>{if(n==="title"||n==="base"){if(i!==void 0){if(n=="base"){if(this.mark)T(i[0]||{},{x:!0})}this._head.set(n,i)}return}if(i instanceof a)return rn(this._head.init("meta",{}),i.metas,this.mark,this.push);if(!b(i))return;switch(n){case"meta":return rn(this._head.init("meta",{}),i,this.mark,this.push);case"link":return Vn(this._head.init("link",{}),i,this.mark,this.push);case"script":if(i.length){this._head.init(n,[]);let t=i.map((r)=>{if(!r.yid&&this.idm)r.yid="sc"+this.idm.mid;if(this.mark)T(r,{x:!0});else if(!("x"in r))T(r,this.push);return r});this._head.get(n).push(...t)}return}})}get head(){return this._head}set id(o){this.idm=new A(o)}}var Ro=(o)=>{return $(o??{}).reduce((n,[i,t])=>{return n.push(N(t)&&t?i:`${i}="${t}"`),n},[""]).join(" ")},un=(o)=>{let n=new Set;if(!o)return"";let i=[...o].reduce((t,[r,f])=>{if(r==="meta"||r==="link")f=G(f);if(p(f)){if(r==="title")n.add(`<${r}>${f}</${r}>`);else t.add(`<${r}>${f}</${r}>`);return t}if(!b(f))return t;if(r==="base"){let u=f.slice(-1);if(u)return n.add(`<${r}${Ro(u[0])}>`),t}return f.map((u)=>{if(r==="script"){let x={...u},h="";if("importmap"in x)x.type="importmap",h=JSON.stringify(x.importmap),delete x.importmap;else if("body"in x)h=x.body,delete x.body;return`<${r}${Ro(x)}>${h}</${r}>`}return`<${r}${Ro(u)}>`}).forEach((u)=>{if(u.includes('type="module"'))n.add(u);else if(u.includes("<meta"))n.add(u);else t.add(u)}),t},new Set);return[...n,...i].join("")};class k{lang="en";htmlHead;head;constructor({mark:o,push:n}={}){this.htmlHead=new y,this.head=(i={})=>{let t=new fn({initial:this.htmlHead,mark:o,push:n}),{link:r,script:f,meta:m,title:u,description:x,css:h,js:H}=i;if(x)t.head={meta:[{name:"description",content:x}]};if(On(t,{css:h,js:H}),"base"in i)t.head={base:i.base};t.head={script:f,title:u,meta:m,link:r},this.htmlHead=t.head}}}var On=(o,n)=>{let{css:i,js:t}=n;if(i){let f=(b(i)?i:[i]).map((m)=>({rel:"preload stylesheet",href:m,as:"style"}));o.head={link:[...f]}}if(t){let f=(b(t)?t:[t]).map((m)=>({src:m}));o.head={script:[...f]}}};var Go=async(o)=>{if(U)return;return new Promise((n,i)=>{let t=document.createElement("link");if(o.rel!=="stylesheet")o.rel="stylesheet",o.as="style";$(o).forEach(([r,f])=>{t.setAttribute(r,f)}),t.onload=()=>n(t),t.onerror=()=>i(new Error("Failed to load CSS")),document.head.appendChild(t)})};var mn=(o)=>{if(U)return;return new Promise((n,i)=>{let t=document.createElement("script"),r="";if("importmap"in o)o.type="importmap",r=JSON.stringify(o.importmap),delete o.importmap;else if("body"in o)r=o.body,delete o.body;if(r)t.textContent=r;$(o).forEach(([f,m])=>{t.setAttribute(f,m)}),t.onload=()=>n(t),t.onerror=()=>i(new Error("Failed to load Script")),document.head.appendChild(t),requestAnimationFrame(()=>n("Script executed"))})},_n=()=>{let n=document.querySelector("#d-css")?.sheet;if(n)return n;let i=document.createElement("style");return i.id="d-css",document.head.appendChild(i),i.sheet},Nn=(o,n)=>{for(let i=0;i<o.cssRules.length;i++)if(o.cssRules[i].selectorText===n)return!0;return!1},pn=(o)=>Object.entries(o).map(([n,i])=>`${X(n)}: ${i};`).join(" ");function cn(o,n={}){if(U)return;let i=_n();if(!i)return;if(!Nn(i,o))i.insertRule(`${o} { ${pn(n)} }`,i.cssRules.length)}var xn=(o,n=!1)=>{if(_(o))return[+o,Bo(o)?"int":"float"];if(n&&/\.\w+$/.test(o))return[o,"file"];if(o==="/")return[o,"-"];if(o.length===36&&o.match(/\-/g)?.length===4)return[o,"uuid"];return[o,"string"]},xo=(o)=>{let n=o.startsWith("/")?o:"/"+o,i=n.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[t,r]=i.reduce(([f,m],u)=>{if(u.includes("<")){let x=u.match(/(?<=<)[^/].*?(?=>|$)/g);if(x?.length){let[h,H]=x[0].split(":");if(h)f.push(h),m.push(H||"_")}}else f.push(u===">"?"/":u);return[f,m]},[[],[]]);if(n.endsWith("/")&&n.length>1)t.push("/");return{parsed:t,args:r}};class go{storage;constructor(){this.storage=new y}cache(o,n){if(this.storage.lacks(o))this.storage.set(o,n());return this.storage.get(o)}}var ln=["int","float","file","uuid","string"];class s{_storage;CC;constructor(){this._storage=new y,this.CC=new go}set(o){let{parsed:n,path:i}=o,t=w(n);if(!this._storage.get(t))this._storage.set(t,o);else throw`path: ${i} already used.`}get(o){let{parsed:n}=this.CC.cache(o,()=>xo(o)),i={},t=this._storage.get(w(n));if(!t&&o!=="/")for(let r of this._storage.keys()){let f=[],m=vo(r);if(n.length===m.length){let u=m.map((H,S)=>{let J=xn(n[S],n.length-1===S);if(H===J[0])return J[0];if(ln.includes(J[1]))return f.push(J[0]),J[1];return H}),x=w(u);if(this._storage.has(x)){t=this._storage.get(x),t?.args.forEach((H,S)=>{i[H]=f[S]});break}}}return[t,i]}keys(){return this._storage.keys()}}class To{path="";parsed=[];args=[];constructor(o){lo(this,{path:o,...xo(o)})}}class Mo{date;constructor(o){this.date=o?new Date(o):new Date}delta(o=null,n=!1){let i=Mo.delta(this.date.getTime(),o);return n?new Date(i):i}timed(o){if(!o)return this.date;return[["year","FullYear"],["month","Month"],["day","Date"],["hour","Hours"],["minute","Minutes"],["second","Seconds"]].reduce((i,[t,r])=>{let f=o[t];return f?new Date(i[`set${r}`](i[`get${r}`]()+f)):i},new Date(this.date))}static delta(o,n=null){return n?n-o:o-Date.now()}static local(o){return new Date(o).toLocaleString()}static get now(){return Date.now()}}class Xo{static rand(o=6,n){if(n)return Math.floor(Math.random()*(n-o+1)+o);return Math.floor(Math.random()*o)+1-1}static fill(o,n=null){return Array(o).fill(n)}static new({dom:o,id:n,inner:i}){let t=document.createElement(o);if(n)t.id=n;if(i)t.innerHTML=i;return t}static randFrom(o){if(Array.isArray(o)){let n=o.length,i=this.rand(0,n-1);return o[i]}else if(typeof o=="object"){let n=K(o),i=n.length,t=this.rand(0,i-1);return n[t]}}static randArray(o=[],n=1,i=!1){let t=[],r=i?new Set:null;while((i?r.size:t.length)<n){let f=o[Xo.rand(0,o.length-1)];i?r.add(f):t.push(f)}return i?[...r]:t}static randomAZ=on;static makeID=E;static class(o,...n){let i=n.filter(Boolean);if(o?.class)i.push(...b(o.class)?o.class:[o.class]);if(i.length)o.class=i}static get O(){return{vals:G,keys:K,items:$,has:nn,ass:T,len:(o={})=>K(o).length}}static get is(){return Zo}static get return(){return gn}static isHREF(o,n){return o===n?!0:o.startsWith(n)&&n!=="/"?!0:!1}static sleep=(o=1000)=>new Promise((n)=>setTimeout(n,o));static get screen(){let{innerWidth:o}=window,n={xs:o<=480,sm:o>=480,smd:o>=624,md:o>=768,lg:o>=1024,xl:o>=1280,xxl:o>=1536},i=$(n).reverse();for(let t=0;t<i.length;t++){let[r,f]=i[t];if(f)return r}return}bytes(o){if(o===0)return"0 Bytes";let n=1024,i=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(o)/Math.log(n));return parseFloat((o/Math.pow(n,t)).toFixed(2))+" "+i[t]}static format(o){return new Tn(o)}static compareObjects=d;static isObjectUdpated=mo}class gn{static arr(o){return o?b(o)?o:[o]:[]}static num(o,n=0){let i=parseFloat(o);return isNaN(i)?n:i}static str(o){return String(o)}static arr2obj(o,n=!1){return o.reduce((i,t,r)=>{if(n)i[t]=r;else i[r]=t;return i},{})}}class Tn{val;constructor(o){this.val=o}get px(){return`${this.val}px`}get rem(){return`${this.val}rem`}get pr(){return`${this.val}%`}}async function C(o,n,{id:i="stateHook",init:t}={}){let r=[],f=()=>n.map((u)=>u.value),m=async()=>{await o(...f())};if(n.forEach((u)=>{r.push(u.hook(m)(i))}),t)await m();return()=>{r.forEach((u)=>u())}}var bn=(o)=>{o.forEach((n)=>n())};var dn=(o,n)=>{for(let[i,t]of o){let r=P(i);if(!r){o.delete(i);continue}t.forEach((f)=>{f.call(r,n)})}};class q extends EventTarget{options;deep;verify;hooks=new y;states=new y;_value;listening=!1;end;constructor(o,n={},i=!0,t=!0){super();this.options=n;this.deep=i;this.verify=t;this._value=o}get value(){return this._value}set value(o){if(!this.verify){this._value=o,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(!this.deep){if(this._value===o)return;this._value=o,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(j(this._value)||b(this._value)){let n=d(this._value,o);if(!mo(n))return}else if(this._value instanceof Set){if(!tn(this._value,o))return}else if(this._value===o)return;this._value=o,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let o=(n)=>{if(bn(this.hooks),dn(this.states,n.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",o,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",o,this.options),this.end=void 0,this.listening=!1}}call(o,n){return(i)=>{if(uo(i,this.states).set(n,o),!U&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(i))this.states.get(i)?.delete(n)}}}hook(o){return(n)=>{if(this.hooks.set(n,o),!U&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(n))this.hooks.delete(n)}}}}function M(o,n={}){return new q(o,n,!0)}function an(o,n=!1){return new q(o,{},!1,n)}class qo{e;opt;constructor(o){this.e=o;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(o,n={}){return this.e.animate(o,n)}get slide(){let o=({x:n=0,y:i=0},t={})=>{T(this.opt,t);let r=[[n,i],[0,0]].map(([f,m])=>({transform:`translateX(${f}rem) translateY(${m}rem)`}));return this.e.animate(r,this.opt),this};return{left:(n={})=>{return o({x:-2},n)},right:(n={})=>{return o({x:2},n)},up:(n={})=>{return o({y:2},n)},down:(n={})=>{return o({y:-2},n)}}}fade(o={}){T(this.opt,o);let n=[0,1].map((i)=>({opacity:i}));return this.e.animate(n,this.opt),this}shake(o="Y",n={}){T(this.opt,n);let i=[0,5,-5,5,0].map((t)=>({transform:`translate${o}(${t}px)`}));return this.e.animate(i,this.opt),this}color(o=[],n={}){T(this.opt,n);let i=Array.isArray(o)?o.map((t)=>({color:t})):{color:o};return this.e.animate(i,this.opt),this}bg(o=[],n={}){T(this.opt,n);let i=Array.isArray(o)?o.map((t)=>({backgroundColor:t})):{backgroundColor:o};return this.e.animate(i,this.opt),this}bounce(o=1,n={}){T(this.opt,n);let i=[0.5,o,1].map((t)=>({transform:`scale(${t})`}));return this.e.animate(i),this}}var e=(o)=>{if(b(o))return o.filter((n)=>n!==void 0).join(" ");else if(R(o)){if(j(o))return w(o)}else if(L(o))return e(o());else if(o!==void 0&&o!==null)return N(o)?o?"":"false":String(o);return""};function kn(o,n){switch(n??o){case"style":return function(i){this.style.setProperty(o,i)};default:return function(i){this.setAttribute(o,i)}}}class Jo{attr;constructor(o={}){this.attr=o}get(o,n=this.attr,i){let t=(r,f)=>{if(b(f))o.attr_push(r,e(f),i);else if(f instanceof q){let m=i?`${i}_${r}`:r;o.states.push(f.call(kn(r,i),m)),t(r,f.value)}else if(R(f)){if(j(f)&&!i)this.get(o,f,r)}else o.attr_push(r,e(f),i)};$(n).forEach(([r,f])=>{if(r==="ref"){if(f instanceof v)o.events.obj({element(){f.element=this}})}else if(["on"].includes(r))R(n.on)&&o.events.obj(n.on);else{if(f===void 0)return;t(r,f)}})}unload(o){let n=void 0;if(o in this.attr)n=this.attr[o],delete this.attr[o];return n}}var en=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],vn=(o)=>en.includes(o);function oi(o){return String(o).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var bo=async(o,n)=>{if(o=await Promise.resolve(o),b(o)){let i=[];for(let t of o)i.push(await bo(t,n));return i.join("")}else if(o instanceof V){let{ctx:i,oz:t}=await jo(o,n.IDM);return n.OZ.push(t),i}else if(R(o))return w(o);else if(L(o))return await bo(o(),n);else if(o!==void 0&&o!==null)return oi(o);return""},yo=async(o,n)=>{let i=new A(n),t=new oo(i.id,i);return{ctx:await bo(o,t),catt:t}};async function ni(o){let n=this.id;if(n){let{ctx:i,catt:t}=await yo(o,n);if(this.innerHTML!==i)this.innerHTML=i,F.RPS(t.OZ)}}var Fo=async(o,n,i,t=[])=>{if(b(o))for(let r of o)await Fo(r,o.length,i,t);else if(o instanceof q)if(n>1)await Fo(await Y("div",{},o),n,i,t);else{let r=o.value,f=r instanceof V?"dom":"ctx",{ctx:m,catt:u}=await yo(r,i.xid+"-0");i.xid=u.xid,t.push(m),i.OZ.push(u.OZ),i.states.push(o.call(ni,f))}else t.push(await bo(o,i))};class Qo{tag;ctx;closing;constructor(o="",n){this.tag=o;this.ctx=n;let i=vn(o);this.closing=i?"":`</${o}>`}async process(o,n=this.ctx,i=[]){for(let t of n)await Fo(await Promise.resolve(t),n.length,o,i);return i.join("")}async get(o){let n=await this.process(o);if(!this.tag)return n;if(o.events.size||o.states.length)o.id=o.xid;return`<${this.tag}${o.attr}>${n}${this.closing}`}}class So{e;query;constructor(o,n){this.e=o;this.query=n}get a(){return new qo(this)}get all(){if(this.query){let o=document.querySelectorAll(this.query);if(o.length)return Array.from(o).map((n)=>n)}return[]}get attr(){let o=this.e;return{has:(n)=>{return o.hasAttribute(n)},get:(n)=>{return o.getAttribute(n)},del:(n)=>{return o.removeAttribute(n),this},set:(n)=>{for(let i in n){let t=n[i];if(n[i]!==void 0)o.setAttribute(i,e(t))}return this}}}get children(){return Array.from(this.e.children).map((o)=>D(o))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return this.e.disabled??!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let o=this.e.offsetParent;if(o)return new Q(o);return}get parent(){let o=this.e.parentElement;if(o)return new Q(o);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let o=this.e.style,n=this;return{set:(i,t=0)=>{let r=o,f=()=>{$(i).forEach(([m,u])=>{if(m in r){if(r[m]!==u)r[m]=u}else if(u!==null)o.setProperty(m,String(u))})};if(L(t))n.on("transitionend",t);if(Uo(t))setTimeout(f,t);else f();return n},get:(i)=>{let t=X(String(i));return o.getPropertyValue(t)},del:(...i)=>{i.forEach((t)=>{let r=X(String(t));o.removeProperty(r)})}}}get submit(){let o=this.e;if("submit"in o)return o.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(o){Eo(o,Wo(this.id)).then((n)=>{let{ctx:i,catt:t}=n;this.e.insertAdjacentHTML("beforeend",i),F.RPS(t.OZ)})}set appendfirst(o){Eo(o,Wo(this.id)).then((n)=>{let{ctx:i,catt:t}=n;this.e.insertAdjacentHTML("afterbegin",i),F.RPS(t.OZ)})}set inner(o){Eo(o,Wo(this.id)).then((n)=>{let{ctx:i,catt:t}=n;this.e.innerHTML=i,F.RPS(t.OZ)})}set disabled(o){let n=this.e;if("disabled"in n)n.disabled=o}set id(o){this.e.id=o}set value(o){let n=this.e;n.value=o}}var Eo=(o,n)=>{return yo(o,n)},Wo=(o)=>o?`${o}-0`:o;class Q extends So{constructor(o,n){super(o,n)}add(...o){return this.e.classList.add(...o.map((n)=>n.replace(/[^\w-]/,""))),()=>{this.e.classList.remove(...o.map((n)=>n.replace(/[^\w-]/,"")))}}remove(...o){return this.e.classList.remove(...o.map((n)=>n.replace(/[^\w-]/,""))),this}toggle(o,n){let i=typeof o!="string"?o.apply(this):o;return this.e.classList.toggle(i,n)}hasNode(o){return this.e.contains(o)}has(...o){let n=this.e.classList;return o.every((i)=>n.contains(i))}insert(o){return{HTML:(...n)=>{return n.forEach((i)=>{this.e.insertAdjacentHTML(o,i)}),this},element:(...n)=>{return n.forEach((i)=>{this.e.insertAdjacentElement(o,i)}),this},text:function(...n){return n.forEach((i)=>{this.e.insertAdjacentText(o,i)}),this}}}is(o){let n=this.e.classList,i=this.e.tagName.toLocaleLowerCase(),t=!0,r=!0;if(o.dom)r=o.dom==i?!0:!1;if(o.class)if(Array.isArray(o.class))o.class.forEach((f)=>{t=t?n.contains(f):!1});else t=t?n.contains(o.class):!1;return t&&r}on(o,n,i=!1){let t=!1;if(o.indexOf("touch")>-1)t=!0;return this.e.addEventListener(o,n,{capture:i,passive:t}),this}remove_on(o,n,i=!1){return this.e.removeEventListener(o,n,i),this}timed(o,n=250){return setTimeout(()=>o(this),n),this}animate(o,n,i){let t={duration:300,easing:"ease",fill:"forwards"};if(L(n))i=n;else T(t,n);let r=this.e.animate(o,t);if(i)r.finished.then(i);return this}}var no=new y,P=(o)=>{if(U)return;let n=no.get(o);if(n?.isConnected)return n;no.delete(o);let i=document.getElementById(o);if(!i)return;return no.set(o,i),i};function yn(){let o=[];for(let[n,i]of no)if(!i.isConnected)o.push(n),no.delete(n);return o}function D(o,n){let i=n?n:document;if(p(o)){let t=i.querySelector(o);if(t)return new Q(t,o);return}else if(j(o)){let[[t,r]]=$(o),m=`${t==="id"?"#":"."}${r}`,u=i.querySelector(m);if(u)return new Q(u,m);return}else return new Q(o)}class v{state=new q(void 0);constructor(){}get element(){return this.state.value?.e}set element(o){if(o)this.state.value=new Q(o);else this.state.value=void 0}get $(){return this.state.value}}var ii=()=>{return new v};var ti=(o,n,i)=>{return o.addEventListener(n,i),()=>{o.removeEventListener(n,i)}},io={};class $o{events=new y;states=new y;windowEvents=new y;resetST=new y;resetEV=new y;get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(o){let{id:n,events:i,states:t}=o;if(n){if(i.size)this.events.set(n,i);if(t.length)this.states.set(n,t)}return this}push(o){return o.events.forEach((n,i)=>{n.forEach((t,r)=>{uo(i,this.events).set(r,t)})}),o.states.forEach((n,i)=>{l(i,this.states).push(...n)}),this}get stage(){return this.events.forEach((o,n)=>{this.events.delete(n);let i=P(n);if(!i){this.events.delete(n);return}o.forEach((t,r)=>{switch(r){case"ready":case"element":t.apply(i,[i]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let f=r.replace(/^win/,"");this.windowEvents.init(f,new y).set(n,t);break;case"state":let[m,u,x]=t.apply(i,[i]),h=b(u)?u:[u];if(!h.length)break;let H=()=>h.map((J)=>J.value),S=()=>m(...H());if(x)S();h.forEach((J)=>l(n,this.resetST).push(J.call(S,n+"_state")(n)));break;default:l(n,this.resetEV).push(ti(i,r,t))}})}),this.processWindowEvents,this.states.forEach((o,n)=>{this.states.delete(n),o.forEach((i)=>{l(n,this.resetST).push(i(n))})}),this}get processWindowEvents(){let o=(n,i)=>{let t=0,r=!1,f=(u)=>{if(t=window.scrollY,!r)window.requestAnimationFrame(()=>{i.forEach((x,h)=>{let H=P(h);if(H)x.call(H,u);else this.windowEvents.get(n)?.delete(h)}),r=!1}),r=!0},m=(u)=>{i.forEach((x,h)=>{let H=P(h);if(H)x.call(H,u);else this.windowEvents.get(n)?.delete(h)})};return window.addEventListener(n,n==="scroll"?f:m),()=>{window.removeEventListener(n,n==="scroll"?f:m)}};return this.windowEvents.forEach((n,i)=>{if(n.size){if(!io[i])io[i]=o(i,n)}else if(io[i])io[i](),delete io[i]}),this}reset(o){return o.forEach((n)=>{this.windowEvents.forEach((i,t)=>{if(i.has(n))i.delete(n)}),this.resetEV.get(n)?.forEach((i)=>{i()}),this.resetST.get(n)?.forEach((i)=>{i()}),this.resetST.delete(n),this.resetEV.delete(n)}),this}RPS(o){if(o){let n=yn();this.reset(n);let i=o.keys;if(i.length)this.reset(i).push(o).stage}return this}}var F=new $o;class oo{xid;IDM;map=new y;states=[];events=new y;OZ;constructor(o,n=new A,i){this.xid=o;this.IDM=n;this.OZ=i??new $o}attr_push(o,n,i){let t=i??o;if(!this.map.has(t))this.map.set(t,[]);let r=i?`${X(o)}:${n};`:n;this.map.get(t).push(r)}get attr(){let o=[""];return this.map.forEach((n,i)=>{let t=n.join("");o.push(t?`${i}="${t}"`:i)}),o.join(" ")}set id(o){if(!this.map.has("id"))this.map.set("id",[o])}get id(){return this.map.get("id")?.join("")}}async function $n(o,n){return await jo(o,new A(n))}async function jo(o,n=new A){let{tag:i,attr:t,ctx:r}=o,f=n instanceof A?n:new A(n),m=f.mid,u=new oo(m,f),x=new Jo(t),h=new Qo(i,r);return x.get(u),{ctx:await h.get(u),oz:u.OZ.set(u),id:u.id}}class V{tag;attr;ctx;constructor(o,n,i){this.tag=o;this.attr=n;this.ctx=i}}async function Y(o,n={},...i){if(L(o))return await o(n??{},...i);return new V(o,n??{},i)}var ri=async(o,...n)=>new V("",{},n);async function hn(o={},n){let i=D("link[rt]")?.all.map((t)=>()=>t.remove())||[];if(o&&W(o))for(let t of G(o)){if(t.x)continue;try{await Go(t)}catch(r){I.e=["link error",{error:"Huntr @ link"}]}}return i}var fi=["charset","name","property","http-equiv"];async function Hn(o){let n={};if(D("meta")?.all.forEach((i)=>{let t=i.attributes;for(let r of fi)if(r in t){let f=t[r].value;n[`${r}_${r==="charset"?"":f}`]=i}}),o)$(o).forEach(([i,t])=>{if(i in n)D(n[i]).attr.set(t),delete n[i];else{let r=D(document.createElement("meta"));r.attr.set(t),document.head.append(r.e)}});return G(n).map((i)=>D(i).unload)}async function Yn(o,n=!1){let i=D("script[rt]")?.all.map((t)=>()=>t.remove())||[];if(o&&W(o))for(let t of G(o)){if(t.x)continue;try{await mn(t)}catch(r){I.e=["script error",{error:"Huntr @ script"}]}}return i}class to extends wo{path="";data={};args={};importArgs=[];static A=(o,...n)=>{return Y("a",o||{},...n)}}async function Dn(o,n=!1){if(!n&&o.fetch)T(o.data,await o.fetch());return[await Io(await o.body?.(),o.importArgs),ui.call(this,o)]}async function Io(o,n=[]){let i=o||"";if(Lo(o)){let t=o.default,r=L(n)?n():n;i=L(t)?await t.apply({},r):t}return b(i)?i:[i]}function ui(o){let n=new k({push:{rt:this.id}});return n.htmlHead=structuredClone(this.htmlHead),n.head(o),n.htmlHead}async function Ln(o,n){document.title=o.get("title")||"",zo(await hn(o.get("link"),n)),zo(await Yn(o.get("script")));let i=await Hn(o.get("meta"));zo(i)}var zo=(o)=>{o.forEach((n)=>n())};class ho{onChange;popListener;constructor(o=M(""),n=!1,i){if(this.onChange=i,this.onChange?.(this.path(),history.state??{path:this.path()}),this.popListener=(t)=>{let r=t.state??{path:this.path()},f=r?.path;if(n&&f)f=f==="/"?f:f.replace(/\/+$/g,"");o.value=f||o.value,this.onChange?.(this.path(),r)},c)window.addEventListener("popstate",this.popListener)}path(){let{pathname:o,search:n,hash:i}=window.location;return`${o}${n}${i}`}state(){return window.history.state??{path:this.path()}}navigate(o,n,i=""){let t=this.resolve(o),r=this.path();if(this.samePath(r,t))return;let f={...n,path:t};window.history.pushState(f,i,t),this.onChange?.(this.path(),f)}replace(o,n,i=""){let t=this.resolve(o),r=this.path();if(this.samePath(r,t))return;let f={...n,path:t};window.history.replaceState(f,i,t),this.onChange?.(this.path(),f)}back(){window.history.back()}forward(){window.history.forward()}destroy(){if(this.popListener)window.removeEventListener("popstate",this.popListener),this.popListener=void 0}resolve(o){let n=new URL(o,window.location.origin);return`${n.pathname}${n.search}${n.hash}`}samePath(o,n){return o===n}}class Ko{lang;head="";constructor(o,n){if(this.lang=o,n)this.head=un(n)}body(o,n,i){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${n}"${i?" "+i:""}>${o}</body>`,"</html>"].join("")}}class ro{path="";data={};args={};importArgs=[];static Button=(o,...n)=>{return Y("button",o||{},...n)}}class Do extends To{cls;constructor(o,n){super(o);this.cls=n}}class Ho extends Do{}class Un extends Do{}class so{storage=new s;error=new s}class Co extends so{wss=new s;setRoute(o,n){this.storage.set(new Ho(o,n))}getRoute(o,n){let[i,t]=this.storage.get(o);if(!i){let[f=new Ho(o,Bn)]=this.getError(n),m=new f.cls;return m.args=t,T(m,{args:t})}let r=new i.cls;return T(r,{args:t})}setWss(o,n){this.wss.set(new Un(o,n))}getWss(o){return this.wss.get(o)}setError(o,n){this.error.set(new Ho(o.toString(),n))}getError(o=404){return this.error.get(o.toString())}}class Yo extends Do{}class Po extends so{setRoute(o,n){this.storage.set(new Yo(o,n))}getRoute(o,n){let[i,t]=this.storage.get(o);if(!i){let[f=new Yo(o,Zn)]=this.getError(n),m=new f.cls;return m.args=t,T(m,{args:t})}let r=new i.cls;return T(r,{args:t})}setWss(o){}getWss(o){}setError(o,n){this.error.set(new Yo(o.toString(),n))}getError(o=404){return this.error.get(o.toString())}}class Bn extends to{body(){return Y("div",{},this.path+" not found...")}}class Zn extends ro{body(){return Y("div",{},`${this.path} not found...`)}}class Vo extends k{id;data;path;_root;constructor(){super({mark:!0});this.id=E(6),this.path=M("/"),this._root=M([]),this.data={}}A(o,...n){let{on:i,...t}=o,r=this.path,f={...i||{},click(m){m.preventDefault();let u=D(this).path;r.value=u}};return Y("a",{on:f,...t},...n)}_main;async getMain(o){return await Y("main",{...o&&{class:o}},await this._main?.(this._root)||this._root)}}B([Z,g("design:type",Function),g("design:paramtypes",[typeof aAttr==="undefined"?Object:aAttr,Object]),g("design:returntype",void 0)],Vo.prototype,"A",null);class Oo extends Vo{pushHistory;storage=new Co;base;constructor(o="/",n="",i=!1){super();this.pushHistory=i;this.base=o?o.startsWith("/")?o:`/${o}`:"";let t=this.base;this.head({script:[{type:"module",src:"./index.js"}],...{base:[{href:t==="/"?t:`${t}/`,target:"_blank"}]},meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}]})}route(o){return(n)=>{return n.A=(i,...t)=>{if(i.href&&b(i.href))i.href=_o(o,i.href);else if(!i.href)i.href=o;return this.A(i,...t)},this.storage.setRoute(o,n),n}}error(...o){return(n)=>{if(o.length)o.forEach((i)=>{this.storage.setError(i,n)});return n}}wss(o){return(n)=>{return this.storage.setWss(o,n),n}}}B([Z,g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",void 0)],Oo.prototype,"route",null),B([Z,g("design:type",Function),g("design:paramtypes",[Object]),g("design:returntype",void 0)],Oo.prototype,"error",null),B([Z,g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",void 0)],Oo.prototype,"wss",null);function _o(o,n){let i=0;return o.replace(/<[^>]+>/g,()=>n[i++])}class An{id=E(5);path=M("");_root=M([]);Button(o,...n){let i=this.path,{on:t,...r}=o,f={...t||{},click(m){m.preventDefault();let x=D(this).attr.get("tab");if(!x)return;i.value=x}};return Y("button",{on:f,...r},...n)}}B([Z,g("design:type",Function),g("design:paramtypes",[Object,Object]),g("design:returntype",void 0)],An.prototype,"Button",null);class No extends An{storage=new Po;hasLoaded=!1;constructor({path:o}={}){super();if(o)this.path=o}tab(o){return(n)=>{return n.Button=(i,...t)=>{if(i.tab&&b(i.tab))i.tab=_o(o,i.tab);else if(!i.tab)i.tab=o;return this.Button(i,...t)},this.storage.setRoute(o,n),n}}Main(o){let{tab:n,data:i={},...t}=o;if(n)this.load(n,i);return Y("main",{...t},this._root)}async load(o,n={}){this.path.value=this.path.value||o,await C(async(i)=>{this._root.value=await mi.call(this,i,n)},[this.path],{id:this.id,init:!0})}}B([Z,g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",void 0)],No.prototype,"tab",null),B([Z,g("design:type",Function),g("design:paramtypes",[Object]),g("design:returntype",void 0)],No.prototype,"Main",null),B([Z,g("design:type",Function),g("design:paramtypes",[String,typeof obj==="undefined"?Object:obj]),g("design:returntype",Promise)],No.prototype,"load",null);async function mi(o,n={},i){let t=this.storage.getRoute(o,i);return T(t,{path:o,data:n}),Io(await t.body?.(),t.importArgs)}class po{path;args;route="/";isConnected=M(!1);data={};constructor(o,n={}){this.path=o;this.args=n;this.data=n}open(o){}message(o){}close(o){}error(o){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(o)=>{this.isConnected.value=!0,await this.open.call(this,o)},this.ws.onmessage=async(o)=>{await this.message.call(this,o)},this.ws.onclose=async(o)=>{this.isConnected.value=!1,await this.close.call(this,o)},this.ws.onerror=async(o)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,o)},this}get reconnect(){if(this.state>=2)this.connect;return this}get disconnect(){if(this.state<=1)this.ws.close();return this}get state(){return this.ws?.readyState??3}set send(o){if(this.isConnected.value)this.ws.send(o);else throw new Error(`websocket path ${this.path} not connected`)}}var O=new y;class co{yvee;constructor(o){this.yvee=o}async load(o){if(U)return;if(!O.has(o)){let[i,t]=this.yvee.storage.getWss(o);if(!i)return;let{cls:r,path:f}=i,m=new r(f,t).connect;return O.set(o,m),m}let n=O.get(o);return n.reconnect,n}unload(o){if(U)return;if(O.has(o)){let n=O.get(o);if(!n)return;n.disconnect,O.delete(o)}}}class wn extends Oo{isDev;history;constructor({base:o,history:n,index:i,isDev:t=!1}={}){super(o,i,n);let r=this;this.isDev=t,this.history=new ho(this.path,this.isDev),T(this,{get yvee(){return r}})}Main(o){this._main=o}async render(o={}){let{id:n,data:i,class:t}=o;if(c){let r=window.location.pathname;if(this.isDev)r=r.replace(/\/+$/g,"");this.path.value=r;let f=document.body.id;this.id=f;let[m,u]=await Rn.call(this,this.path.value,t);return F.push(u.oz),requestAnimationFrame(()=>{F.stage,this.init(i)}),()=>{}}return async({path:r,data:f={},error:m=0})=>{if(n)this.id=n;this.path.value=r;let[u,x]=await Rn.call(this,this.path.value,t,m,f,!0);return new Ko(this.lang,u).body(x.ctx,this.id)}}async init(o={}){let n=this.id;C(async(i)=>{let[t,r]=await Gn.call(this,i,o);await Ln(r,n),this._root.value=t,this.pushHistory&&this.history.navigate(i)},[this.path],{id:n})}}B([Z,g("design:type",Function),g("design:paramtypes",[Function]),g("design:returntype",void 0)],wn.prototype,"Main",null),B([Z,g("design:type",Function),g("design:paramtypes",[typeof renderConfig==="undefined"?Object:renderConfig]),g("design:returntype",Promise)],wn.prototype,"render",null);async function Gn(o,n={},i=!1,t){let r=this.storage.getRoute(o,t);return T(r,{path:o,data:n}),await Dn.call(this,r,i)}async function Rn(o,n,i,t={},r=!1){let[f,m]=await Gn.call(this,o,t,r,i);this._root.value=f;let u=await this.getMain(n),x=await $n(await this.getMain(n),this.id);return[m,x]}var xi=(o)=>{return(n)=>{return o(n)}};export{po as websocket,ii as useRef,co as socket,I as log,ri as frag,Y as dom,to as doc,Go as cssLoader,ro as content,cn as addCSS,Xo as __,wn as Yvee,Mo as Time,No as Tabs,q as Stateful,C as StateHook,M as State,xi as Routes,v as Ref,an as QState,ho as PathHistory,a as Meta,zn as IfClient,D as $};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yvee",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Yvee JS framework",
|
|
5
5
|
"author": "Marky <markjotep@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"homepage": "https://github.com/MARKjotep/yvee#readme",
|
|
28
28
|
"dependencies": {},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"rollup": "^4.
|
|
31
|
-
"rollup-plugin-dts": "^6.2.
|
|
30
|
+
"rollup": "^4.47.1",
|
|
31
|
+
"rollup-plugin-dts": "^6.2.3"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"typescript": "^5.7.3"
|