@byloth/core 1.5.3 → 2.0.0-rc.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/core.js +1468 -826
- package/dist/core.js.map +1 -1
- package/dist/core.umd.cjs +3 -3
- package/dist/core.umd.cjs.map +1 -1
- package/package.json +8 -10
- package/src/helpers.ts +10 -0
- package/src/index.ts +33 -16
- package/src/models/aggregators/aggregated-async-iterator.ts +129 -81
- package/src/models/aggregators/aggregated-iterator.ts +128 -82
- package/src/models/aggregators/index.ts +1 -3
- package/src/models/aggregators/reduced-iterator.ts +119 -31
- package/src/models/aggregators/types.ts +15 -10
- package/src/models/callbacks/callable-object.ts +23 -0
- package/src/models/callbacks/index.ts +5 -0
- package/src/models/callbacks/publisher.ts +45 -0
- package/src/models/callbacks/switchable-callback.ts +108 -0
- package/src/models/callbacks/types.ts +1 -0
- package/src/models/exceptions/core.ts +6 -7
- package/src/models/exceptions/index.ts +50 -10
- package/src/models/game-loop.ts +83 -0
- package/src/models/index.ts +10 -7
- package/src/models/iterators/smart-async-iterator.ts +112 -24
- package/src/models/iterators/smart-iterator.ts +108 -13
- package/src/models/iterators/types.ts +17 -7
- package/src/models/json/index.ts +3 -0
- package/src/models/{json-storage.ts → json/json-storage.ts} +40 -28
- package/src/models/json/types.ts +5 -0
- package/src/models/promises/deferred-promise.ts +1 -1
- package/src/models/promises/index.ts +3 -1
- package/src/models/promises/long-running-task.ts +294 -0
- package/src/models/promises/smart-promise.ts +6 -1
- package/src/models/promises/thenable.ts +97 -0
- package/src/models/promises/timed-promise.ts +1 -1
- package/src/models/promises/types.ts +2 -0
- package/src/models/timers/clock.ts +69 -0
- package/src/models/timers/countdown.ts +117 -0
- package/src/models/timers/index.ts +4 -0
- package/src/models/types.ts +20 -9
- package/src/utils/async.ts +9 -4
- package/src/utils/date.ts +7 -4
- package/src/utils/index.ts +2 -2
- package/src/utils/random.ts +4 -3
- package/src/models/aggregators/aggregator.ts +0 -46
- package/src/models/aggregators/async-aggregator.ts +0 -56
- package/src/models/subscribers.ts +0 -35
package/dist/core.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(l,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(l=typeof globalThis<"u"?globalThis:l||self,d(l.Core={}))})(this,function(l){"use strict";var St=Object.defineProperty;var Tt=(l,d,k)=>d in l?St(l,d,{enumerable:!0,configurable:!0,writable:!0,value:k}):l[d]=k;var a=(l,d,k)=>Tt(l,typeof d!="symbol"?d+"":d,k);var B,G,K,H,Q,X,Z,U,ee,te,ne,ie,re,se,oe,ae,le,ue,ce,he,fe,de,me,_e,we,ye,pe,ge,be,ve,xe,ke,Se,Te,Ee,Me,Fe,Re,Pe,Ie,Ce,De,je,Oe,Ae,Ne,$e,qe,ze,Ve,We,Je,Le,Ye;const d=typeof window<"u"&&typeof window.document<"u",k=typeof process<"u"&&((B=process.versions)==null?void 0:B.node),Ge=typeof self=="object"&&((G=self.constructor)==null?void 0:G.name)==="DedicatedWorkerGlobalScope";class m extends(H=Error,K=Symbol.toStringTag,H){constructor(e,n,i="Exception"){super(e);a(this,K,"Exception");this.cause=n,this.name=i,n&&(n instanceof Error?this.stack+=`
|
|
2
2
|
|
|
3
|
-
Caused by ${
|
|
3
|
+
Caused by ${n.stack}`:this.stack+=`
|
|
4
4
|
|
|
5
|
-
Caused by ${t}`)}get[Symbol.toStringTag](){return"Exception"}}class I extends l{constructor(e,t,n="FatalErrorException"){e===void 0&&(e="The routine has encountered an unrecoverable error and cannot continue as expected. Please, refresh the page and try again. If the problem persists, contact the support team."),super(e,t,n)}get[Symbol.toStringTag](){return"FatalErrorException"}}class P extends l{constructor(e,t,n="NotImplementedException"){e===void 0&&(e="This feature is not implemented yet. Please, try again later."),super(e,t,n)}get[Symbol.toStringTag](){return"NotImplementedException"}}class R extends l{constructor(e,t,n="FileNotFoundException"){super(e,t,n)}get[Symbol.toStringTag](){return"FileNotFoundException"}}class F extends l{constructor(e,t,n="KeyException"){super(e,t,n)}get[Symbol.toStringTag](){return"KeyException"}}class j extends l{constructor(e,t,n="NetworkException"){super(e,t,n)}get[Symbol.toStringTag](){return"NetworkException"}}class A extends l{constructor(e,t,n="PermissionException"){super(e,t,n)}get[Symbol.toStringTag](){return"PermissionException"}}class S extends l{constructor(e,t,n="ReferenceException"){super(e,t,n)}get[Symbol.toStringTag](){return"ReferenceException"}}class q extends l{constructor(e,t,n="RuntimeException"){super(e,t,n)}get[Symbol.toStringTag](){return"RuntimeException"}}class b extends l{constructor(e,t,n="TimeoutException"){super(e,t,n)}get[Symbol.toStringTag](){return"TimeoutException"}}class k extends l{constructor(e,t,n="TypeException"){super(e,t,n)}get[Symbol.toStringTag](){return"TypeException"}}class d extends l{constructor(e,t,n="ValueException"){super(e,t,n)}get[Symbol.toStringTag](){return"ValueException"}}class f{constructor(e){a(this,"_elements");this._elements=new c(e)}filter(e){const t=this._elements;return new f(function*(){for(const[n,[r,s]]of t.enumerate())e(r,s,n)&&(yield[r,s])})}map(e){const t=this._elements;return new f(function*(){for(const[n,[r,s]]of t.enumerate())yield[r,e(r,s,n)]})}reduce(e,t){let n=0,r;if(t!==void 0)r=t;else{const s=this._elements.next();if(s.done)throw new k("Reduce of empty iterator with no initial value");n+=1,r=s.value[1]}for(const[s,u]of this._elements)r=e(s,r,u,n),n+=1;return r}keys(){const e=this._elements;return new c(function*(){for(const[t]of e)yield t})}items(){return this._elements}values(){const e=this._elements;return new c(function*(){for(const[t,n]of e)yield n})}toArray(){return Array.from(this.values())}toMap(){return new Map(this.items())}toObject(){return Object.fromEntries(this.items())}get[Symbol.toStringTag](){return"ReducedIterator"}}class y{constructor(e){a(this,"_elements");this._elements=new c(e)}every(e){const t=new Map;for(const[n,r]of this._elements){const[s,u]=t.get(n)??[0,!0];u&&t.set(n,[s+1,e(n,r,s)])}return new f(function*(){for(const[n,[r,s]]of t)yield[n,s]})}some(e){const t=new Map;for(const[n,r]of this._elements){const[s,u]=t.get(n)??[0,!1];u||t.set(n,[s+1,e(n,r,s)])}return new f(function*(){for(const[n,[r,s]]of t)yield[n,s]})}filter(e){const t=this._elements;return new y(function*(){const n=new Map;for(const[r,s]of t){const u=n.get(r)??0;n.set(r,u+1),e(r,s,u)&&(yield[r,s])}})}map(e){const t=this._elements;return new y(function*(){const n=new Map;for(const[r,s]of t){const u=n.get(r)??0;n.set(r,u+1),yield[r,e(r,s,u)]}})}reduce(e,t){const n=new Map;for(const[r,s]of this._elements){let u,h;if(n.has(r))[u,h]=n.get(r),u+=1;else if(t!==void 0)u=0,h=t(r);else{n.set(r,[0,s]);continue}h=e(r,h,s,u),n.set(r,[u,h])}return new f(function*(){for(const[r,[s,u]]of n)yield[r,u]})}unique(){const e=this._elements;return new y(function*(){const t=new Map;for(const[n,r]of e){const s=t.get(n)??new Set;s.has(r)||(s.add(r),t.set(n,s),yield[n,r])}})}count(){const e=new Map;for(const[t]of this._elements){const n=e.get(t)??0;e.set(t,n+1)}return new f(function*(){for(const[t,n]of e)yield[t,n]})}first(){const e=new Map;for(const[t,n]of this._elements)e.has(t)||e.set(t,n);return new f(function*(){for(const[t,n]of e)yield[t,n]})}last(){const e=new Map;for(const[t,n]of this._elements)e.set(t,n);return new f(function*(){for(const[t,n]of e)yield[t,n]})}keys(){const e=this._elements;return new c(function*(){const t=new Set;for(const[n]of e)t.has(n)||(t.add(n),yield n)})}items(){return this._elements}values(){const e=this._elements;return new c(function*(){for(const[t,n]of e)yield n})}toArray(){return Array.from(this.toMap().values())}toMap(){const e=new Map;for(const[t,n]of this._elements){const r=e.get(t)??[];r.push(n),e.set(t,r)}return e}toObject(){const e={};for(const[t,n]of this._elements){const r=e[t]??[];r.push(n),e[t]=r}return e}get[Symbol.toStringTag](){return"AggregatedIterator"}}class _{constructor(e){a(this,"_elements");this._elements=new c(e)}filter(e){return new _(this._elements.filter(e))}map(e){return new _(this._elements.map(e))}unique(){return new _(this._elements.unique())}groupBy(e){return new y(this._elements.map((t,n)=>[e(t,n),t]))}get[Symbol.toStringTag](){return"Aggregator"}}class w{constructor(e){a(this,"_elements");this._elements=new m(e)}async every(e){const t=new Map;for await(const[n,r]of this._elements){const[s,u]=t.get(n)??[0,!0];u&&t.set(n,[s+1,await e(n,r,s)])}return new f(function*(){for(const[n,[r,s]]of t)yield[n,s]})}async some(e){const t=new Map;for await(const[n,r]of this._elements){const[s,u]=t.get(n)??[0,!1];u||t.set(n,[s+1,await e(n,r,s)])}return new f(function*(){for(const[n,[r,s]]of t)yield[n,s]})}filter(e){const t=this._elements;return new w(async function*(){const n=new Map;for await(const[r,s]of t){const u=n.get(r)??0;n.set(r,u+1),await e(r,s,u)&&(yield[r,s])}})}map(e){const t=this._elements;return new w(async function*(){const n=new Map;for await(const[r,s]of t){const u=n.get(r)??0;n.set(r,u+1),yield[r,await e(r,s,u)]}})}async reduce(e,t){const n=new Map;for await(const[r,s]of this._elements){let u,h;if(n.has(r))[u,h]=n.get(r),u+=1;else if(t!==void 0)u=0,h=await t(r);else{n.set(r,[0,s]);continue}h=await e(r,h,s,u),n.set(r,[u,h])}return new f(function*(){for(const[r,[s,u]]of n)yield[r,u]})}unique(){const e=this._elements;return new w(async function*(){const t=new Map;for await(const[n,r]of e){const s=t.get(n)??new Set;s.has(r)||(s.add(r),t.set(n,s),yield[n,r])}})}async count(){const e=new Map;for await(const[t]of this._elements){const n=e.get(t)??0;e.set(t,n+1)}return new f(function*(){for(const[t,n]of e)yield[t,n]})}async first(){const e=new Map;for await(const[t,n]of this._elements)e.has(t)||e.set(t,n);return new f(function*(){for(const[t,n]of e)yield[t,n]})}async last(){const e=new Map;for await(const[t,n]of this._elements)e.set(t,n);return new f(function*(){for(const[t,n]of e)yield[t,n]})}keys(){const e=this._elements;return new m(async function*(){const t=new Set;for await(const[n]of e)t.has(n)||(t.add(n),yield n)})}items(){return this._elements}values(){const e=this._elements;return new m(async function*(){for await(const[t,n]of e)yield n})}async toArray(){const e=await this.toMap();return Array.from(e.values())}async toMap(){const e=new Map;for await(const[t,n]of this._elements){const r=e.get(t)??[];r.push(n),e.set(t,r)}return e}async toObject(){const e={};for await(const[t,n]of this._elements){const r=e[t]??[];r.push(n),e[t]=r}return e}get[Symbol.toStringTag](){return"AggregatedAsyncIterator"}}class g{constructor(e){a(this,"_elements");this._elements=new m(e)}filter(e){return new g(this._elements.filter(e))}map(e){return new g(this._elements.map(e))}unique(){return new g(this._elements.unique())}groupBy(e){return new w(this._elements.map(async(t,n)=>[await e(t,n),t]))}get[Symbol.toStringTag](){return"AsyncAggregator"}}class N{constructor(e=!0){a(this,"_preferPersistence");a(this,"_volatile");a(this,"_persistent");this._preferPersistence=e,this._volatile=window.sessionStorage,this._persistent=window.localStorage}_get(e,t,n){const r=e.getItem(t);if(r)try{return JSON.parse(r)}catch{console.warn(`The "${r}" value for "${t}" property cannot be parsed. Clearing the storage...`),e.removeItem(t)}return n}_set(e,t,n){const r=JSON.stringify(n);r?e.setItem(t,r):e.removeItem(t)}get(e,t,n=this._preferPersistence){const r=n?this._persistent:this._volatile;return this._get(r,e,t)}recall(e,t){return this._get(this._volatile,e,t)}retrieve(e,t){return this.recall(e)??this.read(e,t)}read(e,t){return this._get(this._persistent,e,t)}has(e,t){return(t?this._persistent:this._volatile).getItem(e)!==null}knows(e){return this._volatile.getItem(e)!==null}find(e){return this.knows(e)??this.exists(e)}exists(e){return this._persistent.getItem(e)!==null}set(e,t,n=this._preferPersistence){const r=n?this._persistent:this._volatile;this._set(r,e,t)}remember(e,t){this._set(this._volatile,e,t)}write(e,t){this._set(this._persistent,e,t)}forget(e){this._volatile.removeItem(e)}erase(e){this._persistent.removeItem(e)}clear(e){this._volatile.removeItem(e),this._persistent.removeItem(e)}get[Symbol.toStringTag](){return"JsonStorage"}}class O{constructor(){a(this,"_subscribers");this._subscribers=[]}add(e){this._subscribers.push(e)}remove(e){const t=this._subscribers.indexOf(e);if(t<0)throw new S("Unable to remove the requested subscriber. It was not found.");this._subscribers.splice(t,1)}call(...e){return this._subscribers.slice().map(t=>t(...e))}get[Symbol.toStringTag](){return"Subscribers"}}class p{constructor(e){a(this,"_isPending");a(this,"_isFulfilled");a(this,"_isRejected");a(this,"_promise");this._isPending=!0,this._isFulfilled=!1,this._isRejected=!1;const t=r=>(this._isPending=!1,this._isFulfilled=!0,r),n=r=>{throw this._isPending=!1,this._isRejected=!0,r};this._promise=new Promise(e).then(t,n)}get isPending(){return this._isPending}get isFulfilled(){return this._isFulfilled}get isRejected(){return this._isRejected}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}get[Symbol.toStringTag](){return"SmartPromise"}}class C extends p{constructor(t,n){let r,s;super((u,h)=>{r=u,s=h});a(this,"_resolve");a(this,"_reject");this._promise.then(t,n),this._resolve=r,this._reject=s}get resolve(){return this._resolve}get reject(){return this._reject}watch(t){return t.then(this.resolve,this.reject),this}get[Symbol.toStringTag](){return"DeferredPromise"}}class $ extends p{constructor(e,t){super((n,r)=>{const s=x=>{clearTimeout(M),n(x)},u=x=>{clearTimeout(M),r(x)},M=setTimeout(()=>u(new b("The operation has timed out.")),t);e(s,u)})}get[Symbol.toStringTag](){return"TimedPromise"}}class v{static Boolean(e=.5){return Math.random()<e}static Integer(e,t){return Math.floor(t===void 0?Math.random()*e:Math.random()*(t-e)+e)}static Decimal(e,t){return e===void 0?Math.random():t===void 0?Math.random()*e:Math.random()*(t-e)+e}static Index(e){if(e.length===0)throw new d("You must provide at least one element.");return this.Integer(e.length)}static Choice(e){return e[v.Index(e)]}constructor(){}}async function z(o){return new Promise((e,t)=>setTimeout(e,o))}async function V(){return new Promise((o,e)=>requestAnimationFrame(()=>o()))}var E=(o=>(o[o.Millisecond=1]="Millisecond",o[o.Second=1e3]="Second",o[o.Minute=6e4]="Minute",o[o.Hour=36e5]="Hour",o[o.Day=864e5]="Day",o[o.Week=6048e5]="Week",o[o.Month=2592e6]="Month",o[o.Year=31536e6]="Year",o))(E||{});function J(o,e,t=864e5){return o=new Date(o),e=new Date(e),Math.floor((e.getTime()-o.getTime())/t)}function Y(o,e,t=864e5){return o=new Date(o),e=new Date(e),new c(function*(){const n=e.getTime();let r=o.getTime();for(;r<n;)yield new Date(r),r+=t})}function K(o,e=864e5){return o=new Date(o),new Date(Math.floor(o.getTime()/e)*e)}function B(o,e="text/javascript"){return new Promise((t,n)=>{const r=document.createElement("script");r.async=!0,r.defer=!0,r.src=o,r.type=e,r.onload=()=>t(),r.onerror=()=>n(),document.body.appendChild(r)})}function H(...o){return new c(function*(){for(const e of o)for(const t of e)yield t})}function W(o){if(Array.isArray(o))return o.length;let e=0;for(const t of o)e+=1;return e}function D(o){return new c(function*(){let e=0;for(const t of o)yield[e,t],e+=1})}function G(o,e,t=1){return new c(function*(){e===void 0&&(e=o,o=0),o>e&&(t=t??-1);for(let n=o;n<e;n+=t)yield n})}function L(o){const e=Array.from(o);for(let t=e.length-1;t>0;t-=1){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function Q(o){return new c(function*(){const e=new Set;for(const t of o)e.has(t)||(e.add(t),yield t)})}function T(o,e){return new c(function*(){const t=o[Symbol.iterator](),n=e[Symbol.iterator]();for(;;){const r=t.next(),s=n.next();if(r.done||s.done)break;yield[r.value,s.value]}})}function X(o,e){if(e===void 0){let s=0,u=0;for(const h of o)s+=h,u+=1;if(u===0)throw new d("You must provide at least one value.");return s/u}let t=0,n=0,r=0;for(const[s,u]of T(o,e)){if(u<=0)throw new d(`The weight for the value #${r} must be greater than zero.`);t+=s*u,n+=u,r+=1}if(r===0)throw new d("You must provide at least one value and weight.");if(n>0)throw new d("The sum of weights must be greater than zero.");return t/n}function Z(o){let e=0;for(let t=0;t<o.length;t+=1){const n=o.charCodeAt(t);e=(e<<5)-e+n,e|=0}return e}function U(o){let e=0;for(const t of o)e+=t;return e}function ee(o){return`${o.charAt(0).toUpperCase()}${o.slice(1)}`}const te="1.5.3";i.AggregatedAsyncIterator=w,i.AggregatedIterator=y,i.Aggregator=_,i.AsyncAggregator=g,i.DateUnit=E,i.DeferredPromise=C,i.Exception=l,i.FatalErrorException=I,i.FileNotFoundException=R,i.JsonStorage=N,i.KeyException=F,i.NetworkException=j,i.NotImplementedException=P,i.PermissionException=A,i.Random=v,i.ReducedIterator=f,i.ReferenceException=S,i.RuntimeException=q,i.SmartAsyncIterator=m,i.SmartIterator=c,i.SmartPromise=p,i.Subscribers=O,i.TimedPromise=$,i.TimeoutException=b,i.TypeException=k,i.VERSION=te,i.ValueException=d,i.average=X,i.capitalize=ee,i.chain=H,i.count=W,i.dateDifference=J,i.dateRange=Y,i.dateRound=K,i.delay=z,i.enumerate=D,i.hash=Z,i.loadScript=B,i.nextAnimationFrame=V,i.range=G,i.shuffle=L,i.sum=U,i.unique=Q,i.zip=T,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
5
|
+
Caused by ${n}`)}static FromUnknown(e){if(e instanceof m)return e;if(e instanceof Error){const n=new m(e.message);return n.stack=e.stack,n.name=e.name,n}return new m(`${e}`)}}class S extends(X=m,Q=Symbol.toStringTag,X){constructor(e,n,i="FatalErrorException"){e===void 0&&(e="The program has encountered an unrecoverable error and cannot continue as expected. Please, try again later. If the problem persists, contact the support team.");super(e,n,i);a(this,Q,"FatalErrorException")}}class z extends(U=S,Z=Symbol.toStringTag,U){constructor(e,n,i="NotImplementedException"){e===void 0&&(e="This feature is not implemented yet. Please, try again later.");super(e,n,i);a(this,Z,"NotImplementedException")}}class C extends(te=m,ee=Symbol.toStringTag,te){constructor(e,n,i="FileException"){super(e,n,i);a(this,ee,"FileException")}}class Ke extends(ie=C,ne=Symbol.toStringTag,ie){constructor(e,n,i="FileExistsException"){super(e,n,i);a(this,ne,"FileExistsException")}}class He extends(se=C,re=Symbol.toStringTag,se){constructor(e,n,i="FileNotFoundException"){super(e,n,i);a(this,re,"FileNotFoundException")}}class T extends(ae=m,oe=Symbol.toStringTag,ae){constructor(e,n,i="KeyException"){super(e,n,i);a(this,oe,"KeyException")}}class Qe extends(ue=m,le=Symbol.toStringTag,ue){constructor(e,n,i="NetworkException"){super(e,n,i);a(this,le,"NetworkException")}}class Xe extends(he=m,ce=Symbol.toStringTag,he){constructor(e,n,i="PermissionException"){super(e,n,i);a(this,ce,"PermissionException")}}class V extends(de=m,fe=Symbol.toStringTag,de){constructor(e,n,i="ReferenceException"){super(e,n,i);a(this,fe,"ReferenceException")}}class w extends(_e=m,me=Symbol.toStringTag,_e){constructor(e,n,i="RuntimeException"){super(e,n,i);a(this,me,"RuntimeException")}}class Ze extends(ye=w,we=Symbol.toStringTag,ye){constructor(e,n,i="EnvironmentException"){super(e,n,i);a(this,we,"EnvironmentException")}}class W extends(ge=m,pe=Symbol.toStringTag,ge){constructor(e,n,i="TimeoutException"){super(e,n,i);a(this,pe,"TimeoutException")}}class Ue extends(ve=m,be=Symbol.toStringTag,ve){constructor(e,n,i="TypeException"){super(e,n,i);a(this,be,"TypeException")}}class p extends(ke=m,xe=Symbol.toStringTag,ke){constructor(e,n,i="ValueException"){super(e,n,i);a(this,xe,"ValueException")}}class D extends(Te=p,Se=Symbol.toStringTag,Te){constructor(e,n,i="RangeException"){super(e,n,i);a(this,Se,"RangeException")}}class c{constructor(t){a(this,"_iterator");a(this,"return");a(this,"throw");a(this,Ee,"SmartIterator");t instanceof Function?this._iterator=t():Symbol.iterator in t?this._iterator=t[Symbol.iterator]():this._iterator=t,this._iterator.return&&(this.return=e=>this._iterator.return(e)),this._iterator.throw&&(this.throw=e=>this._iterator.throw(e))}every(t){let e=0;for(;;){const n=this._iterator.next();if(n.done)return!0;if(!t(n.value,e))return!1;e+=1}}some(t){let e=0;for(;;){const n=this._iterator.next();if(n.done)return!1;if(t(n.value,e))return!0;e+=1}}filter(t){const e=this._iterator;return new c(function*(){let n=0;for(;;){const i=e.next();if(i.done)return i.value;t(i.value,n)&&(yield i.value),n+=1}})}map(t){const e=this._iterator;return new c(function*(){let n=0;for(;;){const i=e.next();if(i.done)return i.value;yield t(i.value,n),n+=1}})}reduce(t,e){let n=0,i=e;if(i===void 0){const r=this._iterator.next();if(r.done)throw new p("Cannot reduce an empty iterator without an initial value.");i=r.value,n+=1}for(;;){const r=this._iterator.next();if(r.done)return i;i=t(i,r.value,n),n+=1}}flatMap(t){const e=this._iterator;return new c(function*(){let n=0;for(;;){const i=e.next();if(i.done)return i.value;const r=t(i.value,n);for(const s of r)yield s;n+=1}})}drop(t){const e=this._iterator;return new c(function*(){let n=0;for(;n<t;){if(e.next().done)return;n+=1}for(;;){const i=e.next();if(i.done)return i.value;yield i.value}})}take(t){const e=this._iterator;return new c(function*(){let n=0;for(;n<t;){const i=e.next();if(i.done)return i.value;yield i.value,n+=1}})}find(t){let e=0;for(;;){const n=this._iterator.next();if(n.done)return;if(t(n.value,e))return n.value;e+=1}}enumerate(){return this.map((t,e)=>[e,t])}unique(){const t=this._iterator;return new c(function*(){const e=new Set;for(;;){const n=t.next();if(n.done)return n.value;e.has(n.value)||(e.add(n.value),yield n.value)}})}count(){let t=0;for(;;){if(this._iterator.next().done)return t;t+=1}}forEach(t){let e=0;for(;;){const n=this._iterator.next();if(n.done)return;t(n.value,e),e+=1}}next(...t){return this._iterator.next(...t)}groupBy(t){return new E(this.map((e,n)=>[t(e,n),e]))}toArray(){return Array.from(this)}[(Ee=Symbol.toStringTag,Symbol.iterator)](){return this}}Me=Symbol.toStringTag;const x=class x{constructor(t){a(this,"_elements");a(this,Me,"ReducedIterator");this._elements=new c(t)}every(t){for(const[e,[n,i]]of this._elements.enumerate())if(!t(n,i,e))return!1;return!0}some(t){for(const[e,[n,i]]of this._elements.enumerate())if(t(n,i,e))return!0;return!1}filter(t){const e=this._elements.enumerate();return new x(function*(){for(const[n,[i,r]]of e)t(i,r,n)&&(yield[i,r])})}map(t){const e=this._elements.enumerate();return new x(function*(){for(const[n,[i,r]]of e)yield[i,t(i,r,n)]})}reduce(t,e){let n=0,i=e;if(i===void 0){const r=this._elements.next();if(r.done)throw new p("Cannot reduce an empty iterator without an initial value.");i=r.value[1],n+=1}for(const[r,s]of this._elements)i=t(r,i,s,n),n+=1;return i}flatMap(t){const e=this._elements.enumerate();return new E(function*(){for(const[n,[i,r]]of e)for(const s of t(i,r,n))yield[i,s]})}drop(t){const e=this._elements.enumerate();return new x(function*(){for(const[n,[i,r]]of e)n>=t&&(yield[i,r])})}take(t){const e=this._elements.enumerate();return new x(function*(){for(const[n,[i,r]]of e){if(n>=t)break;yield[i,r]}})}enumerate(){return this.map((t,e,n)=>[n,e])}unique(){const t=this._elements;return new x(function*(){const e=new Set;for(const[n,i]of t)e.has(i)||(e.add(i),yield[n,i])})}count(){let t=0;for(const e of this._elements)t+=1;return t}forEach(t){for(const[e,[n,i]]of this._elements.enumerate())t(n,i,e)}keys(){const t=this._elements;return new c(function*(){for(const[e]of t)yield e})}items(){return this._elements}values(){const t=this._elements;return new c(function*(){for(const[e,n]of t)yield n})}toArray(){return Array.from(this.values())}toMap(){return new Map(this.items())}toObject(){return Object.fromEntries(this.items())}};let _=x;Fe=Symbol.toStringTag;const b=class b{constructor(t){a(this,"_elements");a(this,Fe,"AggregatedAsyncIterator");this._elements=new y(t)}async every(t){const e=new Map;for await(const[n,i]of this._elements){const[r,s]=e.get(n)??[0,!0];s&&e.set(n,[r+1,await t(n,i,r)])}return new _(function*(){for(const[n,[i,r]]of e)yield[n,r]})}async some(t){const e=new Map;for await(const[n,i]of this._elements){const[r,s]=e.get(n)??[0,!1];s||e.set(n,[r+1,await t(n,i,r)])}return new _(function*(){for(const[n,[i,r]]of e)yield[n,r]})}filter(t){const e=this._elements;return new b(async function*(){const n=new Map;for await(const[i,r]of e){const s=n.get(i)??0;await t(i,r,s)&&(yield[i,r]),n.set(i,s+1)}})}map(t){const e=this._elements;return new b(async function*(){const n=new Map;for await(const[i,r]of e){const s=n.get(i)??0;yield[i,await t(i,r,s)],n.set(i,s+1)}})}async reduce(t,e){const n=new Map;for await(const[i,r]of this._elements){let s,u;if(n.has(i))[s,u]=n.get(i);else if(e!==void 0)s=0,u=await e(i);else{n.set(i,[0,r]);continue}n.set(i,[s+1,await t(i,u,r,s)])}return new _(function*(){for(const[i,[r,s]]of n)yield[i,s]})}flatMap(t){const e=this._elements;return new b(async function*(){const n=new Map;for await(const[i,r]of e){const s=n.get(i)??0,u=await t(i,r,s);for await(const h of u)yield[i,h];n.set(i,s+1)}})}drop(t){const e=this._elements;return new b(async function*(){const n=new Map;for await(const[i,r]of e){const s=n.get(i)??0;if(s<t){n.set(i,s+1);continue}yield[i,r]}})}take(t){const e=this._elements;return new b(async function*(){const n=new Map;for await(const[i,r]of e){const s=n.get(i)??0;s>=t||(yield[i,r],n.set(i,s+1))}})}async find(t){const e=new Map;for await(const[n,i]of this._elements){let[r,s]=e.get(n)??[0,void 0];s===void 0&&(await t(n,i,r)&&(s=i),e.set(n,[r+1,s]))}return new _(function*(){for(const[n,[i,r]]of e)yield[n,r]})}unique(){const t=this._elements;return new b(async function*(){const e=new Map;for await(const[n,i]of t){const r=e.get(n)??new Set;r.has(i)||(r.add(i),e.set(n,r),yield[n,i])}})}async count(){const t=new Map;for await(const[e]of this._elements){const n=t.get(e)??0;t.set(e,n+1)}return new _(function*(){for(const[e,n]of t)yield[e,n]})}async forEach(t){const e=new Map;for await(const[n,i]of this._elements){const r=e.get(n)??0;t(n,i,r),e.set(n,r+1)}}keys(){const t=this._elements;return new y(async function*(){const e=new Set;for await(const[n]of t)e.has(n)||(e.add(n),yield n)})}items(){return this._elements}values(){const t=this._elements;return new y(async function*(){for await(const[e,n]of t)yield n})}async toArray(){const t=await this.toMap();return Array.from(t.values())}async toMap(){const t=new Map;for await(const[e,n]of this._elements){const i=t.get(e)??[];i.push(n),t.set(e,i)}return t}async toObject(){const t={};for await(const[e,n]of this._elements){const i=t[e]??[];i.push(n),t[e]=i}return t}};let R=b;class y{constructor(t){a(this,"_iterator");a(this,"return");a(this,"throw");a(this,Re,"SmartAsyncIterator");if(t instanceof Function){const e=t();Symbol.asyncIterator in e?this._iterator=e:this._iterator=async function*(){let n=[];for(;;){const i=e.next(...n);if(i.done)return i.value;n=[yield i.value]}}()}else if(Symbol.asyncIterator in t)this._iterator=t[Symbol.asyncIterator]();else if(Symbol.iterator in t){const e=t[Symbol.iterator]();this._iterator=async function*(){for(;;){const n=e.next();if(n.done)return n.value;yield n.value}}()}else this._iterator=async function*(){let e=[];for(;;){const n=await t.next(...e);if(n.done)return n.value;e=[yield n.value]}}();this._iterator.return&&(this.return=e=>this._iterator.return(e)),this._iterator.throw&&(this.throw=e=>this._iterator.throw(e))}async every(t){let e=0;for(;;){const n=await this._iterator.next();if(n.done)return!0;if(!await t(n.value,e))return!1;e+=1}}async some(t){let e=0;for(;;){const n=await this._iterator.next();if(n.done)return!1;if(await t(n.value,e))return!0;e+=1}}filter(t){const e=this._iterator;return new y(async function*(){let n=0;for(;;){const i=await e.next();if(i.done)return i.value;await t(i.value,n)&&(yield i.value),n+=1}})}map(t){const e=this._iterator;return new y(async function*(){let n=0;for(;;){const i=await e.next();if(i.done)return i.value;yield await t(i.value,n),n+=1}})}async reduce(t,e){let n=0,i=e;if(i===void 0){const r=await this._iterator.next();if(r.done)throw new p("Cannot reduce an empty iterator without an initial value.");i=r.value,n+=1}for(;;){const r=await this._iterator.next();if(r.done)return i;i=await t(i,r.value,n),n+=1}}flatMap(t){const e=this._iterator;return new y(async function*(){let n=0;for(;;){const i=await e.next();if(i.done)return i.value;const r=await t(i.value,n);for await(const s of r)yield s;n+=1}})}drop(t){const e=this._iterator;return new y(async function*(){let n=0;for(;n<t;){if((await e.next()).done)return;n+=1}for(;;){const i=await e.next();if(i.done)return i.value;yield i.value}})}take(t){const e=this._iterator;return new y(async function*(){let n=0;for(;n<t;){const i=await e.next();if(i.done)return i.value;yield i.value,n+=1}})}async find(t){let e=0;for(;;){const n=await this._iterator.next();if(n.done)return;if(await t(n.value,e))return n.value;e+=1}}enumerate(){return this.map((t,e)=>[e,t])}unique(){const t=this._iterator;return new y(async function*(){const e=new Set;for(;;){const n=await t.next();if(n.done)return n.value;e.has(n.value)||(e.add(n.value),yield n.value)}})}async count(){let t=0;for(;;){if((await this._iterator.next()).done)return t;t+=1}}async forEach(t){let e=0;for(;;){const n=await this._iterator.next();if(n.done)return;await t(n.value,e),e+=1}}next(...t){return this._iterator.next(...t)}groupBy(t){return new R(this.map(async(e,n)=>[await t(e,n),e]))}toArray(){return Array.fromAsync(this)}[(Re=Symbol.toStringTag,Symbol.asyncIterator)](){return this}}Pe=Symbol.toStringTag;const v=class v{constructor(t){a(this,"_elements");a(this,Pe,"AggregatedIterator");this._elements=new c(t)}every(t){const e=new Map;for(const[n,i]of this._elements){const[r,s]=e.get(n)??[0,!0];s&&e.set(n,[r+1,t(n,i,r)])}return new _(function*(){for(const[n,[i,r]]of e)yield[n,r]})}some(t){const e=new Map;for(const[n,i]of this._elements){const[r,s]=e.get(n)??[0,!1];s||e.set(n,[r+1,t(n,i,r)])}return new _(function*(){for(const[n,[i,r]]of e)yield[n,r]})}filter(t){const e=this._elements;return new v(function*(){const n=new Map;for(const[i,r]of e){const s=n.get(i)??0;t(i,r,s)&&(yield[i,r]),n.set(i,s+1)}})}map(t){const e=this._elements;return new v(function*(){const n=new Map;for(const[i,r]of e){const s=n.get(i)??0;yield[i,t(i,r,s)],n.set(i,s+1)}})}reduce(t,e){const n=new Map;for(const[i,r]of this._elements){let s,u;if(n.has(i))[s,u]=n.get(i);else if(e!==void 0)s=0,u=e(i);else{n.set(i,[0,r]);continue}n.set(i,[s+1,t(i,u,r,s)])}return new _(function*(){for(const[i,[r,s]]of n)yield[i,s]})}flatMap(t){const e=this._elements;return new v(function*(){const n=new Map;for(const[i,r]of e){const s=n.get(i)??0,u=t(i,r,s);for(const h of u)yield[i,h];n.set(i,s+1)}})}drop(t){const e=this._elements;return new v(function*(){const n=new Map;for(const[i,r]of e){const s=n.get(i)??0;if(s<t){n.set(i,s+1);continue}yield[i,r]}})}take(t){const e=this._elements;return new v(function*(){const n=new Map;for(const[i,r]of e){const s=n.get(i)??0;s>=t||(yield[i,r],n.set(i,s+1))}})}find(t){const e=new Map;for(const[n,i]of this._elements){let[r,s]=e.get(n)??[0,void 0];s===void 0&&(t(n,i,r)&&(s=i),e.set(n,[r+1,s]))}return new _(function*(){for(const[n,[i,r]]of e)yield[n,r]})}enumerate(){return this.map((t,e,n)=>[n,e])}unique(){const t=this._elements;return new v(function*(){const e=new Map;for(const[n,i]of t){const r=e.get(n)??new Set;r.has(i)||(r.add(i),e.set(n,r),yield[n,i])}})}count(){const t=new Map;for(const[e]of this._elements){const n=t.get(e)??0;t.set(e,n+1)}return new _(function*(){for(const[e,n]of t)yield[e,n]})}forEach(t){const e=new Map;for(const[n,i]of this._elements){const r=e.get(n)??0;t(n,i,r),e.set(n,r+1)}}keys(){const t=this._elements;return new c(function*(){const e=new Set;for(const[n]of t)e.has(n)||(e.add(n),yield n)})}items(){return this._elements}values(){const t=this._elements;return new c(function*(){for(const[e,n]of t)yield n})}toArray(){const t=this.toMap();return Array.from(t.values())}toMap(){const t=new Map;for(const[e,n]of this._elements){const i=t.get(e)??[];i.push(n),t.set(e,i)}return t}toObject(){const t={};for(const[e,n]of this._elements){const i=t[e]??[];i.push(n),t[e]=i}return t}};let E=v;const et=Function;class J extends et{constructor(){super("return this.invoke(...arguments);");const t=this.bind(this);return Object.setPrototypeOf(this,t),t}}Ie=Symbol.toStringTag;class P{constructor(){a(this,"_subscribers");a(this,Ie,"Publisher");this._subscribers=new Map}subscribe(t,e){this._subscribers.has(t)||this._subscribers.set(t,[]);const n=this._subscribers.get(t);return n.push(e),()=>{const i=n.indexOf(e);if(i<0)throw new V("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed.");n.splice(i,1)}}publish(t,...e){const n=this._subscribers.get(t);return n?n.slice().map(i=>i(...e)):[]}}class tt extends J{constructor(){const e=()=>{throw new z("The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?")};super();a(this,"_callback");a(this,"_callbacks");a(this,"_isEnabled");a(this,"_key");a(this,"invoke");this._callback=e,this._callbacks=new Map,this._isEnabled=!0,this._key="",this.invoke=(...n)=>this._callback(...n)}get isEnabled(){return this._isEnabled}get key(){return this._key}enable(){if(!this._key)throw new T("The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?");if(this._isEnabled)throw new w("The `SwitchableCallback` is already enabled.");this._callback=this._callbacks.get(this._key),this._isEnabled=!0}disable(){if(!this._isEnabled)throw new w("The `SwitchableCallback` is already disabled.");this._callback=()=>{},this._isEnabled=!1}register(e,n){if(this._callbacks.size===0)this._key=e,this._callback=n;else if(this._callbacks.has(e))throw new T(`The key '${e}' has already been used for another callback.`);this._callbacks.set(e,n)}unregister(e){if(!this._callbacks.has(e))throw new T(`The key '${e}' doesn't yet have any associated callback.`);this._callbacks.delete(e)}switch(e){if(!this._callbacks.has(e))throw new T(`The key '${e}' doesn't yet have any associated callback.`);this._key=e,this._isEnabled&&(this._callback=this._callbacks.get(e))}}Ce=Symbol.toStringTag;class j{constructor(t,e=40){a(this,"_handle");a(this,"_startTime");a(this,"_isRunning");a(this,"_start");a(this,"_stop");a(this,Ce,"GameLoop");this._startTime=0,this._isRunning=!1,d?(this._start=()=>{t(this.elapsedTime),this._handle=window.requestAnimationFrame(this._start)},this._stop=()=>window.cancelAnimationFrame(this._handle)):(console.warn(`Not a browser environment detected. Using setInterval@${e}ms instead of requestAnimationFrame...`),this._start=()=>{this._handle=setInterval(()=>t(this.elapsedTime),e)},this._stop=()=>clearInterval(this._handle))}get startTime(){return this._startTime}get isRunning(){return this._isRunning}get elapsedTime(){return performance.now()-this._startTime}start(t=0){if(this._isRunning)throw new w("The game loop has already been started.");this._startTime=performance.now()-t,this._start(),this._isRunning=!0}stop(){if(!this._isRunning)throw new w("The game loop hadn't yet started.");if(!this._handle)throw new S;this._stop(),this._handle=void 0,this._isRunning=!1}}De=Symbol.toStringTag;class nt{constructor(t=!0){a(this,"_preferPersistence");a(this,"_volatile");a(this,"_persistent");a(this,De,"JSONStorage");if(this._preferPersistence=t,!d)throw new Ze("The `JSONStorage` class can only be instantiated within a browser environment.");this._volatile=window.sessionStorage,this._persistent=window.localStorage}_get(t,e,n){const i=t.getItem(e);if(i)try{return JSON.parse(i)}catch{console.warn(`The "${i}" value for "${e}" property cannot be parsed. Clearing the storage...`),t.removeItem(e)}return n}_set(t,e,n){const i=JSON.stringify(n);i?t.setItem(e,i):t.removeItem(e)}get(t,e,n=this._preferPersistence){const i=n?this._persistent:this._volatile;return this._get(i,t,e)}recall(t,e){return this._get(this._volatile,t,e)}retrieve(t,e){return this.recall(t)??this.read(t,e)}read(t,e){return this._get(this._persistent,t,e)}has(t,e){return(e?this._persistent:this._volatile).getItem(t)!==null}knows(t){return this._volatile.getItem(t)!==null}find(t){return this.knows(t)??this.exists(t)}exists(t){return this._persistent.getItem(t)!==null}set(t,e,n=this._preferPersistence){const i=n?this._persistent:this._volatile;this._set(i,t,e)}remember(t,e){this._set(this._volatile,t,e)}write(t,e){this._set(this._persistent,t,e)}forget(t){this._volatile.removeItem(t)}erase(t){this._persistent.removeItem(t)}clear(t){this._volatile.removeItem(t),this._persistent.removeItem(t)}}je=Symbol.toStringTag;const N=class N{constructor(t){a(this,"_isPending");a(this,"_isFulfilled");a(this,"_isRejected");a(this,"_promise");a(this,je,"SmartPromise");this._isPending=!0,this._isFulfilled=!1,this._isRejected=!1;const e=i=>(this._isPending=!1,this._isFulfilled=!0,i),n=i=>{throw this._isPending=!1,this._isRejected=!0,i};this._promise=new Promise(t).then(e,n)}static FromPromise(t){return new N((e,n)=>t.then(e,n))}get isPending(){return this._isPending}get isFulfilled(){return this._isFulfilled}get isRejected(){return this._isRejected}then(t,e){return this._promise.then(t,e)}catch(t){return this._promise.catch(t)}finally(t){return this._promise.finally(t)}};let M=N;class L extends(Ae=M,Oe=Symbol.toStringTag,Ae){constructor(e,n){let i,r;super((s,u)=>{i=s,r=u});a(this,"_resolve");a(this,"_reject");a(this,Oe,"DeferredPromise");this._promise.then(e,n),this._resolve=i,this._reject=r}get resolve(){return this._resolve}get reject(){return this._reject}watch(e){return e.then(this.resolve,this.reject),this}}function it(o){return new Promise(t=>setTimeout(t,o))}function rt(){return new Promise(o=>requestAnimationFrame(()=>o()))}function F(){return new Promise(o=>setTimeout(o))}Ne=Symbol.toStringTag;const $=class ${constructor(t,e){a(this,"_startTime");a(this,"_estimatedTime");a(this,"_endTime");a(this,"_currentStep");a(this,"_percentage");a(this,"_isRunning");a(this,"_hasCompleted");a(this,"_hasFailed");a(this,"_promise");a(this,"_publisher");a(this,Ne,"LongRunningTask");this._startTime=0,this._estimatedTime=0,this._currentStep=0,this._percentage=0,this._isRunning=!0,this._hasCompleted=!1,this._hasFailed=!1;const n=s=>(this._estimatedTime=0,this._endTime=Date.now(),this._percentage=100,this._isRunning=!1,this._hasCompleted=!0,s),i=s=>{throw this._endTime=Date.now(),this._isRunning=!1,this._hasFailed=!0,s};let r;if(e={...$._DefaultOptions,...e},e.trackProgress){let s;this._publisher=new P,e.totalSteps?e.stepIncrement?s=u=>{u?this._currentStep+=u:this._currentStep+=e.stepIncrement,this._percentage=this._currentStep/e.totalSteps*100;const h=Date.now()-this._startTime,f=e.totalSteps-this._currentStep;this._estimatedTime=h/this._currentStep*f}:s=u=>{if(u){this._currentStep+=u,this._percentage=this._currentStep/e.totalSteps*100;const h=Date.now()-this._startTime,f=e.totalSteps-this._currentStep;this._estimatedTime=h/this._currentStep*f}}:e.stepIncrement?s=u=>{u?this._currentStep+=u:this._currentStep+=e.stepIncrement}:s=u=>{u&&(this._currentStep+=u)},e.ignoreErrors?r=async u=>{const h=t();for(this._startTime=Date.now();;){try{const{done:f,value:g}=await h.next();if(f)return u(g);s(g)}catch(f){console.error(f)}this._publisher.publish("progress"),await F()}}:r=async(u,h)=>{try{const f=t();for(this._startTime=Date.now();;){const{done:g,value:Be}=await f.next();if(g)return u(Be);s(Be),this._publisher.publish("progress"),await F()}}catch(f){h(f)}}}else e.ignoreErrors?r=async s=>{const u=t();for(this._startTime=Date.now();;){try{const{done:h,value:f}=await u.next();if(h)return s(f)}catch(h){console.error(h)}await F()}}:r=async(s,u)=>{try{const h=t();for(this._startTime=Date.now();;){const{done:f,value:g}=await h.next();if(f)return s(g);await F()}}catch(h){u(h)}};this._promise=new Promise(r).then(n,i)}static get _DefaultOptions(){return{ignoreErrors:!1,stepIncrement:1,totalSteps:null,trackProgress:!1}}get startTime(){return this._startTime}get elapsedTime(){return this._isRunning?Date.now()-this._startTime:this._endTime-this._startTime}get estimatedTime(){return this._estimatedTime}get endTime(){if(this._isRunning)throw new w("The task is still running and has no end time yet.");return this._endTime}get currentStep(){return this._currentStep}get percentage(){return this._percentage}get isRunning(){return this._isRunning}get hasCompleted(){return this._hasCompleted}get hasFailed(){return this._hasFailed}then(t,e){return this._promise.then(t,e)}catch(t){return this._promise.catch(t)}finally(t){return this._promise.finally(t)}onProgress(t){if(!this._publisher)throw new w("You cannot subscribe to progress events without enabling progress tracking. Did you forget to set the `trackProgress` option to `true` when creating the task?");return this._publisher.subscribe("progress",t)}};let O=$;$e=Symbol.toStringTag;class st{constructor(){a(this,"_onFulfilled");a(this,$e,"Thenable");this._onFulfilled=t=>t}_resolve(t){return this._onFulfilled(t)}then(t,e){if(e){const n=this._onFulfilled;this._onFulfilled=i=>{try{return i=n(i),t(i)}catch(r){return e(r)}}}else if(t){const n=this._onFulfilled;this._onFulfilled=i=>(i=n(i),t(i))}return this}catch(t){if(t){const e=this._onFulfilled;this._onFulfilled=n=>{try{return e(n)}catch(i){return t(i)}}}return this}finally(t){if(t){const e=this._onFulfilled;this._onFulfilled=n=>{try{return e(n)}finally{t()}}}return this}}class ot extends(ze=M,qe=Symbol.toStringTag,ze){constructor(e,n){super((i,r)=>{const s=g=>{clearTimeout(f),i(g)},u=g=>{clearTimeout(f),r(g)},f=setTimeout(()=>u(new W("The operation has timed out.")),n);e(s,u)});a(this,qe,"TimedPromise")}}var I=(o=>(o[o.Millisecond=1]="Millisecond",o[o.Second=1e3]="Second",o[o.Minute=6e4]="Minute",o[o.Hour=36e5]="Hour",o[o.Day=864e5]="Day",o[o.Week=6048e5]="Week",o[o.Month=2592e6]="Month",o[o.Year=31536e6]="Year",o))(I||{});function at(o,t,e=864e5){return o=new Date(o),t=new Date(t),Math.floor((t.getTime()-o.getTime())/e)}function lt(o,t,e=864e5){return o=new Date(o),t=new Date(t),new c(function*(){const n=t.getTime();let i=o.getTime();for(;i<n;)yield new Date(i),i+=e})}function ut(o,t=864e5){return o=new Date(o),new Date(Math.floor(o.getTime()/t)*t)}class ct extends(We=j,Ve=Symbol.toStringTag,We){constructor(e=I.Second){super(n=>this._publisher.publish("tick",n),e);a(this,"_publisher");a(this,Ve,"Clock");this._publisher=new P}start(e=0){if(this._isRunning)throw new w("The clock has already been started.");super.start(e),this._publisher.publish("start")}stop(){if(!this._isRunning)throw new w("The clock hadn't yet started.");super.stop(),this._publisher.publish("stop")}onStart(e){return this._publisher.subscribe("start",e)}onStop(e){return this._publisher.subscribe("stop",e)}onTick(e,n=0){if(n<0)throw new D("The tick step must be a non-negative number.");if(n===0)return this._publisher.subscribe("tick",e);let i=0;return this._publisher.subscribe("tick",r=>{r-i<n||(e(r),i=r)})}}class ht extends(Le=j,Je=Symbol.toStringTag,Le){constructor(e,n=I.Second){super(()=>{const r=this.remainingTime;this._publisher.publish("tick",r),r<=0&&(this._deferrerStop(),this._publisher.publish("expire"))},n);a(this,"_deferrer");a(this,"_publisher");a(this,"_duration");a(this,Je,"Countdown");this._publisher=new P,this._duration=e}get duration(){return this._duration}get remainingTime(){return this._duration-this.elapsedTime}_deferrerStop(e){if(!this._isRunning)throw new w("The countdown hadn't yet started.");if(!this._deferrer)throw new S;super.stop(),e!==void 0?this._deferrer.reject(e):this._deferrer.resolve(),this._deferrer=void 0}start(e=this.duration){if(this._isRunning)throw new w("The countdown has already been started.");if(this._deferrer)throw new S;return this._deferrer=new L,super.start(this.duration-e),this._publisher.publish("start"),this._deferrer}stop(e){this._deferrerStop(e),this._publisher.publish("stop",e)}onExpire(e){return this._publisher.subscribe("expire",e)}onStart(e){return this._publisher.subscribe("start",e)}onStop(e){return this._publisher.subscribe("stop",e)}onTick(e,n=0){if(n<0)throw new D("The tick step must be a non-negative number.");if(n===0)return this._publisher.subscribe("tick",e);let i=0;return this._publisher.subscribe("tick",r=>{i-r<n||(e(r),i=r)})}}Ye=Symbol.toStringTag;const q=class q{constructor(){a(this,Ye,"Random")}static Boolean(t=.5){return Math.random()<t}static Integer(t,e){return Math.floor(e===void 0?Math.random()*t:Math.random()*(e-t)+t)}static Decimal(t,e){return t===void 0?Math.random():e===void 0?Math.random()*t:Math.random()*(e-t)+t}static Index(t){if(t.length===0)throw new p("You must provide at least one element.");return this.Integer(t.length)}static Choice(t){return t[q.Index(t)]}};let A=q;function ft(o,t="text/javascript"){return new Promise((e,n)=>{const i=document.createElement("script");i.async=!0,i.defer=!0,i.src=o,i.type=t,i.onload=()=>e(),i.onerror=()=>n(),document.body.appendChild(i)})}function dt(...o){return new c(function*(){for(const t of o)for(const e of t)yield e})}function mt(o){if(Array.isArray(o))return o.length;let t=0;for(const e of o)t+=1;return t}function _t(o){return new c(function*(){let t=0;for(const e of o)yield[t,e],t+=1})}function wt(o,t,e=1){return new c(function*(){t===void 0&&(t=o,o=0),o>t&&(e=e??-1);for(let n=o;n<t;n+=e)yield n})}function yt(o){const t=Array.from(o);for(let e=t.length-1;e>0;e-=1){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}function pt(o){return new c(function*(){const t=new Set;for(const e of o)t.has(e)||(t.add(e),yield e)})}function Y(o,t){return new c(function*(){const e=o[Symbol.iterator](),n=t[Symbol.iterator]();for(;;){const i=e.next(),r=n.next();if(i.done||r.done)break;yield[i.value,r.value]}})}function gt(o,t){if(t===void 0){let r=0,s=0;for(const u of o)r+=u,s+=1;if(s===0)throw new p("You must provide at least one value.");return r/s}let e=0,n=0,i=0;for(const[r,s]of Y(o,t)){if(s<=0)throw new p(`The weight for the value #${i} must be greater than zero.`);e+=r*s,n+=s,i+=1}if(i===0)throw new p("You must provide at least one value and weight.");if(n>0)throw new p("The sum of weights must be greater than zero.");return e/n}function bt(o){let t=0;for(let e=0;e<o.length;e+=1){const n=o.charCodeAt(e);t=(t<<5)-t+n,t|=0}return t}function vt(o){let t=0;for(const e of o)t+=e;return t}function xt(o){return`${o.charAt(0).toUpperCase()}${o.slice(1)}`}const kt="2.0.0-rc.10";l.AggregatedAsyncIterator=R,l.AggregatedIterator=E,l.CallableObject=J,l.Clock=ct,l.Countdown=ht,l.DeferredPromise=L,l.Exception=m,l.FatalErrorException=S,l.FileException=C,l.FileExistsException=Ke,l.FileNotFoundException=He,l.GameLoop=j,l.JSONStorage=nt,l.KeyException=T,l.LongRunningTask=O,l.NetworkException=Qe,l.NotImplementedException=z,l.PermissionException=Xe,l.Publisher=P,l.Random=A,l.RangeException=D,l.ReducedIterator=_,l.ReferenceException=V,l.RuntimeException=w,l.SmartAsyncIterator=y,l.SmartIterator=c,l.SmartPromise=M,l.SwitchableCallback=tt,l.Thenable=st,l.TimeUnit=I,l.TimedPromise=ot,l.TimeoutException=W,l.TypeException=Ue,l.VERSION=kt,l.ValueException=p,l.average=gt,l.capitalize=xt,l.chain=dt,l.count=mt,l.dateDifference=at,l.dateRange=lt,l.dateRound=ut,l.delay=it,l.enumerate=_t,l.hash=bt,l.isBrowser=d,l.isNode=k,l.isWebWorker=Ge,l.loadScript=ft,l.nextAnimationFrame=rt,l.range=wt,l.shuffle=yt,l.sum=vt,l.unique=pt,l.yieldToEventLoop=F,l.zip=Y,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
6
6
|
//# sourceMappingURL=core.umd.cjs.map
|