@maptiler/weather
Version:
Weather layers for MapTiler Cloud and MapTiler SDK
1,175 lines • 236 kB
JavaScript
var Fo = Object.defineProperty;
var Ht = (s) => {
throw TypeError(s);
};
var zo = (s, t, e) => t in s ? Fo(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
var h = (s, t, e) => zo(s, typeof t != "symbol" ? t + "" : t, e), Ft = (s, t, e) => t.has(s) || Ht("Cannot " + e);
var l = (s, t, e) => (Ft(s, t, "read from private field"), e ? e.call(s) : t.get(s)), A = (s, t, e) => t.has(s) ? Ht("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, e), P = (s, t, e, o) => (Ft(s, t, "write to private field"), o ? o.call(s, e) : t.set(s, e), e), w = (s, t, e) => (Ft(s, t, "access private method"), e);
var mt = (s, t, e, o) => ({
set _(i) {
P(s, t, i, e);
},
get _() {
return l(s, t, o);
}
});
import * as g from "three";
import { OrthographicCamera as No, Scene as Do, RawShaderMaterial as Oo, GLSL3 as Uo, Vector2 as Go, WebGLRenderTarget as Kt, LinearFilter as vt, RGBAFormat as zt, Mesh as Lo, PlaneGeometry as Wo, DataTexture as Vo, WebGLRenderer as Bo } from "three";
import { EventEmitter as $o } from "events";
function ko(s, t) {
return s.length !== t.length ? !1 : s.every((e, o) => e === t[o]);
}
function Zo(s, t) {
const e = s.get(t);
if (e === void 0)
throw new Error(`Element with key ${t} not found in map`);
return e;
}
function qt(s, t, e) {
const o = s[0] * t[0] + s[1] * t[1] + s[2] * t[2], i = Math.min(Math.max(o, -1), 1), r = Math.acos(i);
if (r < 1e-6) return s;
const n = Math.sin(r), a = Math.sin((1 - e) * r) / n, c = Math.sin(e * r) / n;
return [
s[0] * a + t[0] * c,
s[1] * a + t[1] * c,
s[2] * a + t[2] * c
];
}
const Be = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, uo = /* @__PURE__ */ new Set(), Vt = typeof process == "object" && process ? process : {}, ho = (s, t, e, o) => {
typeof Vt.emitWarning == "function" ? Vt.emitWarning(s, t, e, o) : console.error(`[${e}] ${t}: ${s}`);
};
let Mt = globalThis.AbortController, Jt = globalThis.AbortSignal;
var lo;
if (typeof Mt > "u") {
Jt = class {
constructor() {
h(this, "onabort");
h(this, "_onabort", []);
h(this, "reason");
h(this, "aborted", !1);
}
addEventListener(o, i) {
this._onabort.push(i);
}
}, Mt = class {
constructor() {
h(this, "signal", new Jt());
t();
}
abort(o) {
var i, r;
if (!this.signal.aborted) {
this.signal.reason = o, this.signal.aborted = !0;
for (const n of this.signal._onabort)
n(o);
(r = (i = this.signal).onabort) == null || r.call(i, o);
}
}
};
let s = ((lo = Vt.env) == null ? void 0 : lo.LRU_CACHE_IGNORE_AC_WARNING) !== "1";
const t = () => {
s && (s = !1, ho("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
};
}
const Yo = (s) => !uo.has(s), Me = (s) => s && s === Math.floor(s) && s > 0 && isFinite(s), fo = (s) => Me(s) ? s <= Math.pow(2, 8) ? Uint8Array : s <= Math.pow(2, 16) ? Uint16Array : s <= Math.pow(2, 32) ? Uint32Array : s <= Number.MAX_SAFE_INTEGER ? wt : null : null;
class wt extends Array {
constructor(t) {
super(t), this.fill(0);
}
}
var He;
const Ue = class Ue {
constructor(t, e) {
h(this, "heap");
h(this, "length");
if (!l(Ue, He))
throw new TypeError("instantiate Stack using Stack.create(n)");
this.heap = new e(t), this.length = 0;
}
static create(t) {
const e = fo(t);
if (!e)
return [];
P(Ue, He, !0);
const o = new Ue(t, e);
return P(Ue, He, !1), o;
}
push(t) {
this.heap[this.length++] = t;
}
pop() {
return this.heap[--this.length];
}
};
He = new WeakMap(), // private constructor
A(Ue, He, !1);
let Bt = Ue;
var ao, co, de, re, me, ve, Ke, qe, $, xe, V, D, M, Q, se, K, k, pe, Z, ge, Se, ne, ye, Ie, ee, p, $t, Ge, _e, lt, le, mo, Le, Je, at, Re, Ce, kt, _t, Et, N, Zt, it, be, Yt, Qe;
let Xo = (Qe = class {
constructor(t) {
A(this, p);
// options that cannot be changed without disaster
A(this, de);
A(this, re);
A(this, me);
A(this, ve);
A(this, Ke);
A(this, qe);
/**
* {@link LRUCache.OptionsBase.ttl}
*/
h(this, "ttl");
/**
* {@link LRUCache.OptionsBase.ttlResolution}
*/
h(this, "ttlResolution");
/**
* {@link LRUCache.OptionsBase.ttlAutopurge}
*/
h(this, "ttlAutopurge");
/**
* {@link LRUCache.OptionsBase.updateAgeOnGet}
*/
h(this, "updateAgeOnGet");
/**
* {@link LRUCache.OptionsBase.updateAgeOnHas}
*/
h(this, "updateAgeOnHas");
/**
* {@link LRUCache.OptionsBase.allowStale}
*/
h(this, "allowStale");
/**
* {@link LRUCache.OptionsBase.noDisposeOnSet}
*/
h(this, "noDisposeOnSet");
/**
* {@link LRUCache.OptionsBase.noUpdateTTL}
*/
h(this, "noUpdateTTL");
/**
* {@link LRUCache.OptionsBase.maxEntrySize}
*/
h(this, "maxEntrySize");
/**
* {@link LRUCache.OptionsBase.sizeCalculation}
*/
h(this, "sizeCalculation");
/**
* {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
*/
h(this, "noDeleteOnFetchRejection");
/**
* {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
*/
h(this, "noDeleteOnStaleGet");
/**
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
*/
h(this, "allowStaleOnFetchAbort");
/**
* {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
*/
h(this, "allowStaleOnFetchRejection");
/**
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
*/
h(this, "ignoreFetchAbort");
// computed properties
A(this, $);
A(this, xe);
A(this, V);
A(this, D);
A(this, M);
A(this, Q);
A(this, se);
A(this, K);
A(this, k);
A(this, pe);
A(this, Z);
A(this, ge);
A(this, Se);
A(this, ne);
A(this, ye);
A(this, Ie);
A(this, ee);
// conditionally set private methods related to TTL
A(this, Ge, () => {
});
A(this, _e, () => {
});
A(this, lt, () => {
});
/* c8 ignore stop */
A(this, le, () => !1);
A(this, Le, (t) => {
});
A(this, Je, (t, e, o) => {
});
A(this, at, (t, e, o, i) => {
if (o || i)
throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
return 0;
});
/**
* A String value that is used in the creation of the default string
* description of an object. Called by the built-in method
* `Object.prototype.toString`.
*/
h(this, ao, "LRUCache");
const { max: e = 0, ttl: o, ttlResolution: i = 1, ttlAutopurge: r, updateAgeOnGet: n, updateAgeOnHas: a, allowStale: c, dispose: u, disposeAfter: f, noDisposeOnSet: d, noUpdateTTL: v, maxSize: m = 0, maxEntrySize: _ = 0, sizeCalculation: S, fetchMethod: y, memoMethod: x, noDeleteOnFetchRejection: E, noDeleteOnStaleGet: C, allowStaleOnFetchRejection: R, allowStaleOnFetchAbort: I, ignoreFetchAbort: B } = t;
if (e !== 0 && !Me(e))
throw new TypeError("max option must be a nonnegative integer");
const G = e ? fo(e) : Array;
if (!G)
throw new Error("invalid max value: " + e);
if (P(this, de, e), P(this, re, m), this.maxEntrySize = _ || l(this, re), this.sizeCalculation = S, this.sizeCalculation) {
if (!l(this, re) && !this.maxEntrySize)
throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
if (typeof this.sizeCalculation != "function")
throw new TypeError("sizeCalculation set to non-function");
}
if (x !== void 0 && typeof x != "function")
throw new TypeError("memoMethod must be a function if defined");
if (P(this, qe, x), y !== void 0 && typeof y != "function")
throw new TypeError("fetchMethod must be a function if specified");
if (P(this, Ke, y), P(this, Ie, !!y), P(this, V, /* @__PURE__ */ new Map()), P(this, D, new Array(e).fill(void 0)), P(this, M, new Array(e).fill(void 0)), P(this, Q, new G(e)), P(this, se, new G(e)), P(this, K, 0), P(this, k, 0), P(this, pe, Bt.create(e)), P(this, $, 0), P(this, xe, 0), typeof u == "function" && P(this, me, u), typeof f == "function" ? (P(this, ve, f), P(this, Z, [])) : (P(this, ve, void 0), P(this, Z, void 0)), P(this, ye, !!l(this, me)), P(this, ee, !!l(this, ve)), this.noDisposeOnSet = !!d, this.noUpdateTTL = !!v, this.noDeleteOnFetchRejection = !!E, this.allowStaleOnFetchRejection = !!R, this.allowStaleOnFetchAbort = !!I, this.ignoreFetchAbort = !!B, this.maxEntrySize !== 0) {
if (l(this, re) !== 0 && !Me(l(this, re)))
throw new TypeError("maxSize must be a positive integer if specified");
if (!Me(this.maxEntrySize))
throw new TypeError("maxEntrySize must be a positive integer if specified");
w(this, p, mo).call(this);
}
if (this.allowStale = !!c, this.noDeleteOnStaleGet = !!C, this.updateAgeOnGet = !!n, this.updateAgeOnHas = !!a, this.ttlResolution = Me(i) || i === 0 ? i : 1, this.ttlAutopurge = !!r, this.ttl = o || 0, this.ttl) {
if (!Me(this.ttl))
throw new TypeError("ttl must be a positive integer if specified");
w(this, p, $t).call(this);
}
if (l(this, de) === 0 && this.ttl === 0 && l(this, re) === 0)
throw new TypeError("At least one of max, maxSize, or ttl is required");
if (!this.ttlAutopurge && !l(this, de) && !l(this, re)) {
const fe = "LRU_CACHE_UNBOUNDED";
Yo(fe) && (uo.add(fe), ho("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", fe, Qe));
}
}
/**
* Do not call this method unless you need to inspect the
* inner workings of the cache. If anything returned by this
* object is modified in any way, strange breakage may occur.
*
* These fields are private for a reason!
*
* @internal
*/
static unsafeExposeInternals(t) {
return {
// properties
starts: l(t, Se),
ttls: l(t, ne),
sizes: l(t, ge),
keyMap: l(t, V),
keyList: l(t, D),
valList: l(t, M),
next: l(t, Q),
prev: l(t, se),
get head() {
return l(t, K);
},
get tail() {
return l(t, k);
},
free: l(t, pe),
// methods
isBackgroundFetch: (e) => {
var o;
return w(o = t, p, N).call(o, e);
},
backgroundFetch: (e, o, i, r) => {
var n;
return w(n = t, p, Et).call(n, e, o, i, r);
},
moveToTail: (e) => {
var o;
return w(o = t, p, it).call(o, e);
},
indexes: (e) => {
var o;
return w(o = t, p, Re).call(o, e);
},
rindexes: (e) => {
var o;
return w(o = t, p, Ce).call(o, e);
},
isStale: (e) => {
var o;
return l(o = t, le).call(o, e);
}
};
}
// Protected read-only members
/**
* {@link LRUCache.OptionsBase.max} (read-only)
*/
get max() {
return l(this, de);
}
/**
* {@link LRUCache.OptionsBase.maxSize} (read-only)
*/
get maxSize() {
return l(this, re);
}
/**
* The total computed size of items in the cache (read-only)
*/
get calculatedSize() {
return l(this, xe);
}
/**
* The number of items stored in the cache (read-only)
*/
get size() {
return l(this, $);
}
/**
* {@link LRUCache.OptionsBase.fetchMethod} (read-only)
*/
get fetchMethod() {
return l(this, Ke);
}
get memoMethod() {
return l(this, qe);
}
/**
* {@link LRUCache.OptionsBase.dispose} (read-only)
*/
get dispose() {
return l(this, me);
}
/**
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
*/
get disposeAfter() {
return l(this, ve);
}
/**
* Return the number of ms left in the item's TTL. If item is not in cache,
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
*/
getRemainingTTL(t) {
return l(this, V).has(t) ? 1 / 0 : 0;
}
/**
* Return a generator yielding `[key, value]` pairs,
* in order from most recently used to least recently used.
*/
*entries() {
for (const t of w(this, p, Re).call(this))
l(this, M)[t] !== void 0 && l(this, D)[t] !== void 0 && !w(this, p, N).call(this, l(this, M)[t]) && (yield [l(this, D)[t], l(this, M)[t]]);
}
/**
* Inverse order version of {@link LRUCache.entries}
*
* Return a generator yielding `[key, value]` pairs,
* in order from least recently used to most recently used.
*/
*rentries() {
for (const t of w(this, p, Ce).call(this))
l(this, M)[t] !== void 0 && l(this, D)[t] !== void 0 && !w(this, p, N).call(this, l(this, M)[t]) && (yield [l(this, D)[t], l(this, M)[t]]);
}
/**
* Return a generator yielding the keys in the cache,
* in order from most recently used to least recently used.
*/
*keys() {
for (const t of w(this, p, Re).call(this)) {
const e = l(this, D)[t];
e !== void 0 && !w(this, p, N).call(this, l(this, M)[t]) && (yield e);
}
}
/**
* Inverse order version of {@link LRUCache.keys}
*
* Return a generator yielding the keys in the cache,
* in order from least recently used to most recently used.
*/
*rkeys() {
for (const t of w(this, p, Ce).call(this)) {
const e = l(this, D)[t];
e !== void 0 && !w(this, p, N).call(this, l(this, M)[t]) && (yield e);
}
}
/**
* Return a generator yielding the values in the cache,
* in order from most recently used to least recently used.
*/
*values() {
for (const t of w(this, p, Re).call(this))
l(this, M)[t] !== void 0 && !w(this, p, N).call(this, l(this, M)[t]) && (yield l(this, M)[t]);
}
/**
* Inverse order version of {@link LRUCache.values}
*
* Return a generator yielding the values in the cache,
* in order from least recently used to most recently used.
*/
*rvalues() {
for (const t of w(this, p, Ce).call(this))
l(this, M)[t] !== void 0 && !w(this, p, N).call(this, l(this, M)[t]) && (yield l(this, M)[t]);
}
/**
* Iterating over the cache itself yields the same results as
* {@link LRUCache.entries}
*/
[(co = Symbol.iterator, ao = Symbol.toStringTag, co)]() {
return this.entries();
}
/**
* Find a value for which the supplied fn method returns a truthy value,
* similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
*/
find(t, e = {}) {
for (const o of w(this, p, Re).call(this)) {
const i = l(this, M)[o], r = w(this, p, N).call(this, i) ? i.__staleWhileFetching : i;
if (r !== void 0 && t(r, l(this, D)[o], this))
return this.get(l(this, D)[o], e);
}
}
/**
* Call the supplied function on each item in the cache, in order from most
* recently used to least recently used.
*
* `fn` is called as `fn(value, key, cache)`.
*
* If `thisp` is provided, function will be called in the `this`-context of
* the provided object, or the cache if no `thisp` object is provided.
*
* Does not update age or recenty of use, or iterate over stale values.
*/
forEach(t, e = this) {
for (const o of w(this, p, Re).call(this)) {
const i = l(this, M)[o], r = w(this, p, N).call(this, i) ? i.__staleWhileFetching : i;
r !== void 0 && t.call(e, r, l(this, D)[o], this);
}
}
/**
* The same as {@link LRUCache.forEach} but items are iterated over in
* reverse order. (ie, less recently used items are iterated over first.)
*/
rforEach(t, e = this) {
for (const o of w(this, p, Ce).call(this)) {
const i = l(this, M)[o], r = w(this, p, N).call(this, i) ? i.__staleWhileFetching : i;
r !== void 0 && t.call(e, r, l(this, D)[o], this);
}
}
/**
* Delete any stale entries. Returns true if anything was removed,
* false otherwise.
*/
purgeStale() {
let t = !1;
for (const e of w(this, p, Ce).call(this, { allowStale: !0 }))
l(this, le).call(this, e) && (w(this, p, be).call(this, l(this, D)[e], "expire"), t = !0);
return t;
}
/**
* Get the extended info about a given entry, to get its value, size, and
* TTL info simultaneously. Returns `undefined` if the key is not present.
*
* Unlike {@link LRUCache#dump}, which is designed to be portable and survive
* serialization, the `start` value is always the current timestamp, and the
* `ttl` is a calculated remaining time to live (negative if expired).
*
* Always returns stale values, if their info is found in the cache, so be
* sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
* if relevant.
*/
info(t) {
const e = l(this, V).get(t);
if (e === void 0)
return;
const o = l(this, M)[e], i = w(this, p, N).call(this, o) ? o.__staleWhileFetching : o;
if (i === void 0)
return;
const r = { value: i };
if (l(this, ne) && l(this, Se)) {
const n = l(this, ne)[e], a = l(this, Se)[e];
if (n && a) {
const c = n - (Be.now() - a);
r.ttl = c, r.start = Date.now();
}
}
return l(this, ge) && (r.size = l(this, ge)[e]), r;
}
/**
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
* passed to {@link LRUCache#load}.
*
* The `start` fields are calculated relative to a portable `Date.now()`
* timestamp, even if `performance.now()` is available.
*
* Stale entries are always included in the `dump`, even if
* {@link LRUCache.OptionsBase.allowStale} is false.
*
* Note: this returns an actual array, not a generator, so it can be more
* easily passed around.
*/
dump() {
const t = [];
for (const e of w(this, p, Re).call(this, { allowStale: !0 })) {
const o = l(this, D)[e], i = l(this, M)[e], r = w(this, p, N).call(this, i) ? i.__staleWhileFetching : i;
if (r === void 0 || o === void 0)
continue;
const n = { value: r };
if (l(this, ne) && l(this, Se)) {
n.ttl = l(this, ne)[e];
const a = Be.now() - l(this, Se)[e];
n.start = Math.floor(Date.now() - a);
}
l(this, ge) && (n.size = l(this, ge)[e]), t.unshift([o, n]);
}
return t;
}
/**
* Reset the cache and load in the items in entries in the order listed.
*
* The shape of the resulting cache may be different if the same options are
* not used in both caches.
*
* The `start` fields are assumed to be calculated relative to a portable
* `Date.now()` timestamp, even if `performance.now()` is available.
*/
load(t) {
this.clear();
for (const [e, o] of t) {
if (o.start) {
const i = Date.now() - o.start;
o.start = Be.now() - i;
}
this.set(e, o.value, o);
}
}
/**
* Add a value to the cache.
*
* Note: if `undefined` is specified as a value, this is an alias for
* {@link LRUCache#delete}
*
* Fields on the {@link LRUCache.SetOptions} options param will override
* their corresponding values in the constructor options for the scope
* of this single `set()` operation.
*
* If `start` is provided, then that will set the effective start
* time for the TTL calculation. Note that this must be a previous
* value of `performance.now()` if supported, or a previous value of
* `Date.now()` if not.
*
* Options object may also include `size`, which will prevent
* calling the `sizeCalculation` function and just use the specified
* number if it is a positive integer, and `noDisposeOnSet` which
* will prevent calling a `dispose` function in the case of
* overwrites.
*
* If the `size` (or return value of `sizeCalculation`) for a given
* entry is greater than `maxEntrySize`, then the item will not be
* added to the cache.
*
* Will update the recency of the entry.
*
* If the value is `undefined`, then this is an alias for
* `cache.delete(key)`. `undefined` is never stored in the cache.
*/
set(t, e, o = {}) {
var v, m, _, S, y;
if (e === void 0)
return this.delete(t), this;
const { ttl: i = this.ttl, start: r, noDisposeOnSet: n = this.noDisposeOnSet, sizeCalculation: a = this.sizeCalculation, status: c } = o;
let { noUpdateTTL: u = this.noUpdateTTL } = o;
const f = l(this, at).call(this, t, e, o.size || 0, a);
if (this.maxEntrySize && f > this.maxEntrySize)
return c && (c.set = "miss", c.maxEntrySizeExceeded = !0), w(this, p, be).call(this, t, "set"), this;
let d = l(this, $) === 0 ? void 0 : l(this, V).get(t);
if (d === void 0)
d = l(this, $) === 0 ? l(this, k) : l(this, pe).length !== 0 ? l(this, pe).pop() : l(this, $) === l(this, de) ? w(this, p, _t).call(this, !1) : l(this, $), l(this, D)[d] = t, l(this, M)[d] = e, l(this, V).set(t, d), l(this, Q)[l(this, k)] = d, l(this, se)[d] = l(this, k), P(this, k, d), mt(this, $)._++, l(this, Je).call(this, d, f, c), c && (c.set = "add"), u = !1;
else {
w(this, p, it).call(this, d);
const x = l(this, M)[d];
if (e !== x) {
if (l(this, Ie) && w(this, p, N).call(this, x)) {
x.__abortController.abort(new Error("replaced"));
const { __staleWhileFetching: E } = x;
E !== void 0 && !n && (l(this, ye) && ((v = l(this, me)) == null || v.call(this, E, t, "set")), l(this, ee) && ((m = l(this, Z)) == null || m.push([E, t, "set"])));
} else n || (l(this, ye) && ((_ = l(this, me)) == null || _.call(this, x, t, "set")), l(this, ee) && ((S = l(this, Z)) == null || S.push([x, t, "set"])));
if (l(this, Le).call(this, d), l(this, Je).call(this, d, f, c), l(this, M)[d] = e, c) {
c.set = "replace";
const E = x && w(this, p, N).call(this, x) ? x.__staleWhileFetching : x;
E !== void 0 && (c.oldValue = E);
}
} else c && (c.set = "update");
}
if (i !== 0 && !l(this, ne) && w(this, p, $t).call(this), l(this, ne) && (u || l(this, lt).call(this, d, i, r), c && l(this, _e).call(this, c, d)), !n && l(this, ee) && l(this, Z)) {
const x = l(this, Z);
let E;
for (; E = x == null ? void 0 : x.shift(); )
(y = l(this, ve)) == null || y.call(this, ...E);
}
return this;
}
/**
* Evict the least recently used item, returning its value or
* `undefined` if cache is empty.
*/
pop() {
var t;
try {
for (; l(this, $); ) {
const e = l(this, M)[l(this, K)];
if (w(this, p, _t).call(this, !0), w(this, p, N).call(this, e)) {
if (e.__staleWhileFetching)
return e.__staleWhileFetching;
} else if (e !== void 0)
return e;
}
} finally {
if (l(this, ee) && l(this, Z)) {
const e = l(this, Z);
let o;
for (; o = e == null ? void 0 : e.shift(); )
(t = l(this, ve)) == null || t.call(this, ...o);
}
}
}
/**
* Check if a key is in the cache, without updating the recency of use.
* Will return false if the item is stale, even though it is technically
* in the cache.
*
* Check if a key is in the cache, without updating the recency of
* use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
* to `true` in either the options or the constructor.
*
* Will return `false` if the item is stale, even though it is technically in
* the cache. The difference can be determined (if it matters) by using a
* `status` argument, and inspecting the `has` field.
*
* Will not update item age unless
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
*/
has(t, e = {}) {
const { updateAgeOnHas: o = this.updateAgeOnHas, status: i } = e, r = l(this, V).get(t);
if (r !== void 0) {
const n = l(this, M)[r];
if (w(this, p, N).call(this, n) && n.__staleWhileFetching === void 0)
return !1;
if (l(this, le).call(this, r))
i && (i.has = "stale", l(this, _e).call(this, i, r));
else return o && l(this, Ge).call(this, r), i && (i.has = "hit", l(this, _e).call(this, i, r)), !0;
} else i && (i.has = "miss");
return !1;
}
/**
* Like {@link LRUCache#get} but doesn't update recency or delete stale
* items.
*
* Returns `undefined` if the item is stale, unless
* {@link LRUCache.OptionsBase.allowStale} is set.
*/
peek(t, e = {}) {
const { allowStale: o = this.allowStale } = e, i = l(this, V).get(t);
if (i === void 0 || !o && l(this, le).call(this, i))
return;
const r = l(this, M)[i];
return w(this, p, N).call(this, r) ? r.__staleWhileFetching : r;
}
async fetch(t, e = {}) {
const {
// get options
allowStale: o = this.allowStale,
updateAgeOnGet: i = this.updateAgeOnGet,
noDeleteOnStaleGet: r = this.noDeleteOnStaleGet,
// set options
ttl: n = this.ttl,
noDisposeOnSet: a = this.noDisposeOnSet,
size: c = 0,
sizeCalculation: u = this.sizeCalculation,
noUpdateTTL: f = this.noUpdateTTL,
// fetch exclusive options
noDeleteOnFetchRejection: d = this.noDeleteOnFetchRejection,
allowStaleOnFetchRejection: v = this.allowStaleOnFetchRejection,
ignoreFetchAbort: m = this.ignoreFetchAbort,
allowStaleOnFetchAbort: _ = this.allowStaleOnFetchAbort,
context: S,
forceRefresh: y = !1,
status: x,
signal: E
} = e;
if (!l(this, Ie))
return x && (x.fetch = "get"), this.get(t, {
allowStale: o,
updateAgeOnGet: i,
noDeleteOnStaleGet: r,
status: x
});
const C = {
allowStale: o,
updateAgeOnGet: i,
noDeleteOnStaleGet: r,
ttl: n,
noDisposeOnSet: a,
size: c,
sizeCalculation: u,
noUpdateTTL: f,
noDeleteOnFetchRejection: d,
allowStaleOnFetchRejection: v,
allowStaleOnFetchAbort: _,
ignoreFetchAbort: m,
status: x,
signal: E
};
let R = l(this, V).get(t);
if (R === void 0) {
x && (x.fetch = "miss");
const I = w(this, p, Et).call(this, t, R, C, S);
return I.__returned = I;
} else {
const I = l(this, M)[R];
if (w(this, p, N).call(this, I)) {
const H = o && I.__staleWhileFetching !== void 0;
return x && (x.fetch = "inflight", H && (x.returnedStale = !0)), H ? I.__staleWhileFetching : I.__returned = I;
}
const B = l(this, le).call(this, R);
if (!y && !B)
return x && (x.fetch = "hit"), w(this, p, it).call(this, R), i && l(this, Ge).call(this, R), x && l(this, _e).call(this, x, R), I;
const G = w(this, p, Et).call(this, t, R, C, S), O = G.__staleWhileFetching !== void 0 && o;
return x && (x.fetch = B ? "stale" : "refresh", O && B && (x.returnedStale = !0)), O ? G.__staleWhileFetching : G.__returned = G;
}
}
async forceFetch(t, e = {}) {
const o = await this.fetch(t, e);
if (o === void 0)
throw new Error("fetch() returned undefined");
return o;
}
memo(t, e = {}) {
const o = l(this, qe);
if (!o)
throw new Error("no memoMethod provided to constructor");
const { context: i, forceRefresh: r, ...n } = e, a = this.get(t, n);
if (!r && a !== void 0)
return a;
const c = o(t, a, {
options: n,
context: i
});
return this.set(t, c, n), c;
}
/**
* Return a value from the cache. Will update the recency of the cache
* entry found.
*
* If the key is not found, get() will return `undefined`.
*/
get(t, e = {}) {
const { allowStale: o = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, status: n } = e, a = l(this, V).get(t);
if (a !== void 0) {
const c = l(this, M)[a], u = w(this, p, N).call(this, c);
return n && l(this, _e).call(this, n, a), l(this, le).call(this, a) ? (n && (n.get = "stale"), u ? (n && o && c.__staleWhileFetching !== void 0 && (n.returnedStale = !0), o ? c.__staleWhileFetching : void 0) : (r || w(this, p, be).call(this, t, "expire"), n && o && (n.returnedStale = !0), o ? c : void 0)) : (n && (n.get = "hit"), u ? c.__staleWhileFetching : (w(this, p, it).call(this, a), i && l(this, Ge).call(this, a), c));
} else n && (n.get = "miss");
}
/**
* Deletes a key out of the cache.
*
* Returns true if the key was deleted, false otherwise.
*/
delete(t) {
return w(this, p, be).call(this, t, "delete");
}
/**
* Clear the cache entirely, throwing away all values.
*/
clear() {
return w(this, p, Yt).call(this, "delete");
}
}, de = new WeakMap(), re = new WeakMap(), me = new WeakMap(), ve = new WeakMap(), Ke = new WeakMap(), qe = new WeakMap(), $ = new WeakMap(), xe = new WeakMap(), V = new WeakMap(), D = new WeakMap(), M = new WeakMap(), Q = new WeakMap(), se = new WeakMap(), K = new WeakMap(), k = new WeakMap(), pe = new WeakMap(), Z = new WeakMap(), ge = new WeakMap(), Se = new WeakMap(), ne = new WeakMap(), ye = new WeakMap(), Ie = new WeakMap(), ee = new WeakMap(), p = new WeakSet(), $t = function() {
const t = new wt(l(this, de)), e = new wt(l(this, de));
P(this, ne, t), P(this, Se, e), P(this, lt, (r, n, a = Be.now()) => {
if (e[r] = n !== 0 ? a : 0, t[r] = n, n !== 0 && this.ttlAutopurge) {
const c = setTimeout(() => {
l(this, le).call(this, r) && w(this, p, be).call(this, l(this, D)[r], "expire");
}, n + 1);
c.unref && c.unref();
}
}), P(this, Ge, (r) => {
e[r] = t[r] !== 0 ? Be.now() : 0;
}), P(this, _e, (r, n) => {
if (t[n]) {
const a = t[n], c = e[n];
if (!a || !c)
return;
r.ttl = a, r.start = c, r.now = o || i();
const u = r.now - c;
r.remainingTTL = a - u;
}
});
let o = 0;
const i = () => {
const r = Be.now();
if (this.ttlResolution > 0) {
o = r;
const n = setTimeout(() => o = 0, this.ttlResolution);
n.unref && n.unref();
}
return r;
};
this.getRemainingTTL = (r) => {
const n = l(this, V).get(r);
if (n === void 0)
return 0;
const a = t[n], c = e[n];
if (!a || !c)
return 1 / 0;
const u = (o || i()) - c;
return a - u;
}, P(this, le, (r) => {
const n = e[r], a = t[r];
return !!a && !!n && (o || i()) - n > a;
});
}, Ge = new WeakMap(), _e = new WeakMap(), lt = new WeakMap(), le = new WeakMap(), mo = function() {
const t = new wt(l(this, de));
P(this, xe, 0), P(this, ge, t), P(this, Le, (e) => {
P(this, xe, l(this, xe) - t[e]), t[e] = 0;
}), P(this, at, (e, o, i, r) => {
if (w(this, p, N).call(this, o))
return 0;
if (!Me(i))
if (r) {
if (typeof r != "function")
throw new TypeError("sizeCalculation must be a function");
if (i = r(o, e), !Me(i))
throw new TypeError("sizeCalculation return invalid (expect positive integer)");
} else
throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
return i;
}), P(this, Je, (e, o, i) => {
if (t[e] = o, l(this, re)) {
const r = l(this, re) - t[e];
for (; l(this, xe) > r; )
w(this, p, _t).call(this, !0);
}
P(this, xe, l(this, xe) + t[e]), i && (i.entrySize = o, i.totalCalculatedSize = l(this, xe));
});
}, Le = new WeakMap(), Je = new WeakMap(), at = new WeakMap(), Re = function* ({ allowStale: t = this.allowStale } = {}) {
if (l(this, $))
for (let e = l(this, k); !(!w(this, p, kt).call(this, e) || ((t || !l(this, le).call(this, e)) && (yield e), e === l(this, K))); )
e = l(this, se)[e];
}, Ce = function* ({ allowStale: t = this.allowStale } = {}) {
if (l(this, $))
for (let e = l(this, K); !(!w(this, p, kt).call(this, e) || ((t || !l(this, le).call(this, e)) && (yield e), e === l(this, k))); )
e = l(this, Q)[e];
}, kt = function(t) {
return t !== void 0 && l(this, V).get(l(this, D)[t]) === t;
}, _t = function(t) {
var r, n;
const e = l(this, K), o = l(this, D)[e], i = l(this, M)[e];
return l(this, Ie) && w(this, p, N).call(this, i) ? i.__abortController.abort(new Error("evicted")) : (l(this, ye) || l(this, ee)) && (l(this, ye) && ((r = l(this, me)) == null || r.call(this, i, o, "evict")), l(this, ee) && ((n = l(this, Z)) == null || n.push([i, o, "evict"]))), l(this, Le).call(this, e), t && (l(this, D)[e] = void 0, l(this, M)[e] = void 0, l(this, pe).push(e)), l(this, $) === 1 ? (P(this, K, P(this, k, 0)), l(this, pe).length = 0) : P(this, K, l(this, Q)[e]), l(this, V).delete(o), mt(this, $)._--, e;
}, Et = function(t, e, o, i) {
const r = e === void 0 ? void 0 : l(this, M)[e];
if (w(this, p, N).call(this, r))
return r;
const n = new Mt(), { signal: a } = o;
a == null || a.addEventListener("abort", () => n.abort(a.reason), {
signal: n.signal
});
const c = {
signal: n.signal,
options: o,
context: i
}, u = (S, y = !1) => {
const { aborted: x } = n.signal, E = o.ignoreFetchAbort && S !== void 0;
if (o.status && (x && !y ? (o.status.fetchAborted = !0, o.status.fetchError = n.signal.reason, E && (o.status.fetchAbortIgnored = !0)) : o.status.fetchResolved = !0), x && !E && !y)
return d(n.signal.reason);
const C = m;
return l(this, M)[e] === m && (S === void 0 ? C.__staleWhileFetching ? l(this, M)[e] = C.__staleWhileFetching : w(this, p, be).call(this, t, "fetch") : (o.status && (o.status.fetchUpdated = !0), this.set(t, S, c.options))), S;
}, f = (S) => (o.status && (o.status.fetchRejected = !0, o.status.fetchError = S), d(S)), d = (S) => {
const { aborted: y } = n.signal, x = y && o.allowStaleOnFetchAbort, E = x || o.allowStaleOnFetchRejection, C = E || o.noDeleteOnFetchRejection, R = m;
if (l(this, M)[e] === m && (!C || R.__staleWhileFetching === void 0 ? w(this, p, be).call(this, t, "fetch") : x || (l(this, M)[e] = R.__staleWhileFetching)), E)
return o.status && R.__staleWhileFetching !== void 0 && (o.status.returnedStale = !0), R.__staleWhileFetching;
if (R.__returned === R)
throw S;
}, v = (S, y) => {
var E;
const x = (E = l(this, Ke)) == null ? void 0 : E.call(this, t, r, c);
x && x instanceof Promise && x.then((C) => S(C === void 0 ? void 0 : C), y), n.signal.addEventListener("abort", () => {
(!o.ignoreFetchAbort || o.allowStaleOnFetchAbort) && (S(void 0), o.allowStaleOnFetchAbort && (S = (C) => u(C, !0)));
});
};
o.status && (o.status.fetchDispatched = !0);
const m = new Promise(v).then(u, f), _ = Object.assign(m, {
__abortController: n,
__staleWhileFetching: r,
__returned: void 0
});
return e === void 0 ? (this.set(t, _, { ...c.options, status: void 0 }), e = l(this, V).get(t)) : l(this, M)[e] = _, _;
}, N = function(t) {
if (!l(this, Ie))
return !1;
const e = t;
return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof Mt;
}, Zt = function(t, e) {
l(this, se)[e] = t, l(this, Q)[t] = e;
}, it = function(t) {
t !== l(this, k) && (t === l(this, K) ? P(this, K, l(this, Q)[t]) : w(this, p, Zt).call(this, l(this, se)[t], l(this, Q)[t]), w(this, p, Zt).call(this, l(this, k), t), P(this, k, t));
}, be = function(t, e) {
var i, r, n, a;
let o = !1;
if (l(this, $) !== 0) {
const c = l(this, V).get(t);
if (c !== void 0)
if (o = !0, l(this, $) === 1)
w(this, p, Yt).call(this, e);
else {
l(this, Le).call(this, c);
const u = l(this, M)[c];
if (w(this, p, N).call(this, u) ? u.__abortController.abort(new Error("deleted")) : (l(this, ye) || l(this, ee)) && (l(this, ye) && ((i = l(this, me)) == null || i.call(this, u, t, e)), l(this, ee) && ((r = l(this, Z)) == null || r.push([u, t, e]))), l(this, V).delete(t), l(this, D)[c] = void 0, l(this, M)[c] = void 0, c === l(this, k))
P(this, k, l(this, se)[c]);
else if (c === l(this, K))
P(this, K, l(this, Q)[c]);
else {
const f = l(this, se)[c];
l(this, Q)[f] = l(this, Q)[c];
const d = l(this, Q)[c];
l(this, se)[d] = l(this, se)[c];
}
mt(this, $)._--, l(this, pe).push(c);
}
}
if (l(this, ee) && ((n = l(this, Z)) != null && n.length)) {
const c = l(this, Z);
let u;
for (; u = c == null ? void 0 : c.shift(); )
(a = l(this, ve)) == null || a.call(this, ...u);
}
return o;
}, Yt = function(t) {
var e, o, i;
for (const r of w(this, p, Ce).call(this, { allowStale: !0 })) {
const n = l(this, M)[r];
if (w(this, p, N).call(this, n))
n.__abortController.abort(new Error("deleted"));
else {
const a = l(this, D)[r];
l(this, ye) && ((e = l(this, me)) == null || e.call(this, n, a, t)), l(this, ee) && ((o = l(this, Z)) == null || o.push([n, a, t]));
}
}
if (l(this, V).clear(), l(this, M).fill(void 0), l(this, D).fill(void 0), l(this, ne) && l(this, Se) && (l(this, ne).fill(0), l(this, Se).fill(0)), l(this, ge) && l(this, ge).fill(0), P(this, K, 0), P(this, k, 0), l(this, pe).length = 0, P(this, xe, 0), P(this, $, 0), l(this, ee) && l(this, Z)) {
const r = l(this, Z);
let n;
for (; n = r == null ? void 0 : r.shift(); )
(i = l(this, ve)) == null || i.call(this, ...n);
}
}, Qe);
var jo = /* @__PURE__ */ ((s) => (s[s.r = 0] = "r", s[s.g = 1] = "g", s[s.b = 2] = "b", s[s.a = 3] = "a", s))(jo || {});
let rt = null, Nt = null, ze = null;
function vo() {
if (!Nt || !ze) {
Nt = document.createElement("canvas"), ze = Nt.getContext("webgl2");
const s = ze == null ? void 0 : ze.getParameter(ze.MAX_TEXTURE_IMAGE_UNITS);
rt = new Xo({
max: s,
// When a new texture added while the cache is full, we clear the least recently used texture from GPU memory
dispose: (t, e) => {
vo().deleteTexture(t);
}
});
}
return ze;
}
function je(s) {
return `vec4(${(s[0] / 255).toFixed(3)},${(s[1] / 255).toFixed(3)},${(s[2] / 255).toFixed(3)},${((s[3] ?? 255) / 255).toFixed(3)})`;
}
function Er(s) {
return [s[0] / 255, s[1] / 255, s[2] / 255, (s[3] ?? 255) / 255];
}
function Ho(s) {
return 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + s * Math.PI / 360)) / 360;
}
function Rt(s, t) {
return [s / 360, Ho(t)];
}
function Ko(s) {
const t = Math.PI, e = Math.atan, o = Math.exp, i = o(s * 2 * t);
return (e(i) - t / 4) * 360 / t;
}
function Pr(s, t) {
const e = -0.5 * (s / t * 2 - 1);
return Ko(e);
}
const qo = 6378137, Pt = 2 * Math.PI * qo;
function ot(s, t) {
return Rt(s, t).map((e) => e * Pt);
}
function Ne(s, t, e) {
const o = Math.floor(t * s.width), i = Math.floor(e * s.height), r = vo();
if (r == null)
throw new Error("Failed to obtain WebGL2 context");
if (!rt)
throw new Error("Could not initialize texture cache");
r.activeTexture(r.TEXTURE0);
let n;
rt.has(s) ? n = rt.get(s) : (n = r.createTexture(), r.bindTexture(r.TEXTURE_2D, n), r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, r.RGBA, r.UNSIGNED_BYTE, s), rt.set(s, n));
const a = r.createFramebuffer();
r.bindFramebuffer(r.FRAMEBUFFER, a), r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, n, 0), r.drawBuffers([r.COLOR_ATTACHMENT0]);
const c = new Uint8Array(4);
return r.readPixels(o, i, 1, 1, r.RGBA, r.UNSIGNED_BYTE, c), r.deleteFramebuffer(a), {
r: c[0] / 255,
g: c[1] / 255,
b: c[2] / 255,
a: c[3] / 255
};
}
function Mr(s, t, e = "") {
s.isStyleLoaded() ? s.addLayer(t, e) : s.once("load", () => {
s.addLayer(t, e);
});
}
function Jo(s) {
const t = [
"N",
"NNE",
"NE",
"ENE",
"E",
"ESE",
"SE",
"SSE",
"S",
"SSW",
"SW",
"WSW",
"W",
"WNW",
"NW",
"NNW"
], e = Math.round((s + 360) % 360 / 22.5) % 16;
return t[e];
}
function Qo(s, t) {
const e = Rt(s, t);
return [e[0] + 0.5, e[1] * -1 + 0.5];
}
function Qt(s, t) {
const e = Qo(s.lng, s.lat), o = 2 ** t;
return {
z: t,
x: e[0] * o,
y: e[1] * o
};
}
function ei(s, t) {
const e = ~~t, o = Qt(s.getNorthWest(), e), i = Qt(s.getSouthEast(), e), r = [];
for (let n = Math.floor(o.x); n <= i.x; n += 1)
for (let a = Math.floor(o.y); a <= Math.floor(i.y); a += 1)
r.push(`${t}/${n}/${a}`);
return r;
}
var ti = `precision highp float;precision highp sampler2D;
#define USES_CATEGORIES <uses_categories>
#define VALUE_NUMBER_CHANNELS <value_number_channels>
uniform float opacity;uniform float time;uniform sampler2D tex0;uniform sampler2D tex1;uniform float tex0size;uniform float tex1size;uniform float tilePixelSize;uniform bool categorySmoothTransition;uniform bool timeInterpolation;uniform bool interpolateTileEdge;uniform sampler2D texN0;uniform sampler2D texN1;uniform bool availableN;uniform sampler2D texE0;uniform sampler2D texE1;uniform bool availableE;uniform sampler2D texS0;uniform sampler2D texS1;uniform bool availableS;uniform sampler2D texW0;uniform sampler2D texW1;uniform bool availableW;in vec2 tex0coord;in vec2 tex1coord;out vec4 fragColor;<gradient_function_definitions><getColor_code>float xNoTileEdgeInterpolation(sampler2D tex,vec2 texCoord){vec4 texColorFull=texture(tex,texCoord);vec3 texColorFull255=texColorFull.rgb*255.;
#if (VALUE_NUMBER_CHANNELS == 3)
vec3 texColor=texColorFull255.<value_channels>;return texColor.r*256.*256.+texColor.g*256.+texColor.b;
#endif
#if (VALUE_NUMBER_CHANNELS == 2)
vec2 texColor=texColorFull255.<value_channels>;return texColor.r*256.+texColor.g;
#endif
#if (VALUE_NUMBER_CHANNELS == 1)
return texColorFull255.<value_channels>;
#endif
}vec4 blerp(vec4 color_x0_y0,vec4 color_x0_y1,vec4 color_x1_y0,vec4 color_x1_y1,float x0,float y0,float x1,float y1,float x,float y){vec4 q11=(((x1-x)*(y1-y))/((x1-x0)*(y1-y0)))*color_x0_y0;vec4 q21=(((x-x0)*(y1-y))/((x1-x0)*(y1-y0)))*color_x1_y0;vec4 q12=(((x1-x)*(y-y0))/((x1-x0)*(y1-y0)))*color_x0_y1;vec4 q22=(((x-x0)*(y-y0))/((x1-x0)*(y1-y0)))*color_x1_y1;return q11+q21+q12+q22;}void main(){vec2 tileImageCoord=tex0coord*tilePixelSize;vec2 centerPixelUV=(floor(tileImageCoord)+0.5)/tilePixelSize;float xTex0=xNoTileEdgeInterpolation(tex0,tex0coord);float xTex1=xNoTileEdgeInterpolation(tex1,tex1coord);if(interpolateTileEdge){if(tileImageCoord.x<0.5&&availableW){float xTexW0=xNoTileEdgeInterpolation(texW0,vec2(1.,tex0coord.y));float xTexW1=xNoTileEdgeInterpolation(texW1,vec2(1.,tex0coord.y));float ratioCurrentTile=tileImageCoord.x+0.5;xTex0=ratioCurrentTile*xTex0+(1.-ratioCurrentTile)*xTexW0;xTex1=ratioCurrentTile*xTex1+(1.-ratioCurrentTile)*xTexW1;}else if(tileImageCoord.x>(tilePixelSize-0.5)&&availableE){float xTexE0=xNoTileEdgeInterpolation(texE0,vec2(0.,tex0coord.y));float xTexE1=xNoTileEdgeInterpolation(texE1,vec2(0.,tex0coord.y));float ratioCurrentTile=1.+((tilePixelSize-0.5)-tileImageCoord.x);xTex0=ratioCurrentTile*xTex0+(1.-ratioCurrentTile)*xTexE0;xTex1=ratioCurrentTile*xTex1+(1.-ratioCurrentTile)*xTexE1;}if(tileImageCoord.y<0.5&&availableS){float xTexS0=xNoTileEdgeInterpolation(texS0,vec2(tex0coord.x,1.));float xTexS1=xNoTileEdgeInterpolation(texS1,vec2(tex0coord.x,1.));float ratioCurrentTile=tileImageCoord.y+0.5;xTex0=ratioCurrentTile*xTex0+(1.-ratioCurrentTile)*xTexS0;xTex1=ratioCurrentTile*xTex1+(1.-ratioCurrentTile)*xTexS1;}else if(tileImageCoord.y>(tilePixelSize-0.5)&&availableN){float xTexN0=xNoTileEdgeInterpolation(texN0,vec2(tex0coord.x,0.));float xTexN1=xNoTileEdgeInterpolation(texN1,vec2(tex0coord.x,0.));float ratioCurrentTile=1.+((tilePixelSize-0.5)-tileImageCoord.y);xTex0=ratioCurrentTile*xTex0+(1.-ratioCurrentTile)*xTexN0;xTex1=ratioCurrentTile*xTex1+(1.-ratioCurrentTile)*xTexN1;}}float x=timeInterpolation ? mix(xTex0,xTex1,time):(time<0.5 ? xTex0 : xTex1);float polynomialCoefDegree2=<polynomialCoefDegree2>;float polynomialCoefDegree1=<polynomialCoefDegree1>;float polynomialConstant=<polynomialConstant>;float y=polynomialCoefDegree2*x*x+polynomialCoefDegree1*x+polynomialConstant;int category=0;
#if (USES_CATEGORIES == 1)
category=int((time<0.5 ? texture(tex0,centerPixelUV).a : texture(tex1,centerPixelUV).a)*255.);
#endif
vec4 color_Center=getColor(category,y);vec4 color=vec4(0.,0.,0.,0.);if(categorySmoothTransition){vec2 centerPixelUV_N=vec2((floor(tex0coord.x*tilePixelSize)+0.5)/tilePixelSize,(floor(tex0coord.y*tilePixelSize)+0.5+1.)/tilePixelSize);vec2 centerPixelUV_S=vec2((floor(tex0coord.x*tilePixelSize)+0.5)/tilePixelSize,(floor(tex0coord.y*tilePixelSize)+0.5-1.)/tilePixelSize);vec2 centerPixelUV_E=vec2((floor(tex0coord.x*tilePixelSize)+0.5+1.)/tilePixelSize,(floor(tex0coord.y*tilePixelSize)+0.5)/tilePixelSize);vec2 centerPixelUV_W=vec2((floor(tex0coord.x*tilePixelSize)+0.5-1.)/tilePixelSize,(floor(tex0coord.y*tilePixelSize)+0.5)/tilePixelSize);if(tex0coord.x>=centerPixelUV.x){int category_E=0;
#if (USES_CATEGORIES == 1)
category_E=int((time<0.5 ? texture(tex0,centerPixelUV_E).<category_channel>: texture(tex1,centerPixelUV_E).<category_channel>)*255.);
#endif
vec4 color_E=getColor(category_E,y);if(tex0coord.y>=centerPixelUV.y){int category_N=0;
#if (USES_CATEGORIES == 1)
category_N=int((time<0.5 ? texture(tex0,centerPixelUV_N).<category_channel>: texture(tex1,centerPixelUV_N).<category_channel>)*255.);
#endif
vec4 color_N=getColor(category_N,y);vec2 centerPixelUV_NE=vec2((floor(tex0coord.x*tilePixelSize)+0.5+1.)/tilePixelSize,(floor(tex0coord.y*tilePixelSize)+0.5+1.)/tilePixelSize);int category_NE=0;
#if (USES_CATEGORIES == 1)
category_NE=int((time<0.5 ? texture(tex0,centerPixelUV_NE).<category_channel>: texture(tex1,centerPixelUV_NE).<category_channel>)*255.);
#endif
vec4 color_NE=getColor(category_NE,y);color=blerp(color_Center,color_N,color_E,color_NE,centerPixelUV.x,centerPixelUV.y,centerPixelUV_NE.x,centerPixelUV_NE.y,tex0coord.x,tex0coord.y);}else{int category_S=0;
#if (USES_CATEGORIES == 1)
category_S=int((time<0.5 ? texture(tex0,centerPixelUV_S).<category_channel>: texture(tex1,centerPixelUV_S).<category_channel>)*255.);
#endif
vec4 color_S=getColor(category_S,y);vec2 centerPixelUV_SE=vec2((floor(tex0coord.x*tilePixelSize)+0.5+1.)/tilePixelSize,(floor(tex0coord.y*tilePixelSize)+0.5-1.)/tilePixelSize);int category_SE=0;
#if (USES_CATEGORIES == 1)
category_SE=int((time<0.5 ? texture(tex0,centerPixelUV_SE).<category_channel>: texture(tex1,centerPixelUV_SE).<category_channel>)*255.);
#endif
vec4 color_SE=getColor(category_SE,y);color=blerp(color_S,color_Center,color_SE,color_E,centerPixelUV_S.x,centerPixelUV_S.y,centerPixelUV_E.x,centerPixelUV_E.y,tex0coord.x,tex0coord.y);}}else{int category_W=0;
#if (USES_CATEGORIES == 1)
category_W=int((time<0.5 ? texture(tex0,centerPixelUV_W).<category_channel>: texture(tex1,centerPixelUV_W).<category_channel>)*255.);
#endif
vec4 color_W=getColor(category_W,y);if(tex0coord.y>=centerPixelUV.y){int category_N=0;
#if (USES_CATEGORIES == 1)
category_N=int((time<0.5 ? texture(tex0,centerPixelUV_N).<category_channel>: texture(tex1,centerPixelUV_N).<category_channel>)*255.);
#endif
vec4 color_N=getColor(category_N,y);vec2 centerPixelUV_NW=vec2((floor(tex0coord.x*tilePixelSize)+0.5-1.)/tilePixelSize,(floor(tex0coord.y*tilePixelSize)+0.5+1.)/tilePixelSize);int category_NW=0;
#if (USES_CATEGORIES == 1)
category_NW=int((time<0.5 ? texture(tex0,centerPixelUV_NW).<category_channel>: texture(tex1,centerPixelUV_NW).<category_channel>)*255.);
#endif
vec4 color_NW=getColor(category_NW,y);color=blerp(color_W,color_NW,color_Center,color_N,centerPixelUV_W.x,centerPixelUV_W.y,centerPixelUV_N.x,centerPixelUV_N.y,tex0coord.x,tex0coord.y);}else{int category_S=0;
#if (USES_CATEGORIES == 1)
category_S=int((time<0.5 ? texture(tex0,centerPixelUV_S).<category_channel>: texture(tex1,centerPixelUV_S).<category_channel>)*255.);
#endif
vec4 color_S=getColor(category_S,y);vec2 centerPixelUV_SW=vec2((floor(tex0coord.x*tilePixelSize)+0.5-1.)/tilePixelSize,(floor(tex0coord.y*tilePixelSize)+0.5-1.)/tilePixelSize);int category_SW=0;
#if (USES_CATEGORIES == 1)
category_SW=int((time<0.5 ? texture(tex0,centerPixelUV_SW).<category_channel>: texture(tex1,centerPixelUV_SW).<category_channel>)*255.);
#endif
vec4 color_SW=getColor(category_SW,y);color=blerp(color_SW,color_W,color_S,color_Center,centerPixelUV_SW.x,centerPixelUV_SW.y,centerPixelUV.x,centerPixelUV.y,tex0coord.x,tex0coord.y);}}}else{color=color_Center;}color.a*=opacity;fragColor=color;}`;
const Te = 7;
function oi(s) {
return s.filter((t, e) => e === 0 || e % 2 || e === s.length - 1);
}
function xo(s, t = 50) {
if (s.length <= t)
return s;
const e = oi(s);
return xo(e, t);
}
function po(s, t, e = {
inputName: "v",
outputName: "c"
}) {
const o = xo(s);
let i = "";
for (let r = 0; r < o.length; r++) {
const n = o[r];
r === 0 && (i += `vec4 ${e.outputName}=${je(n.color)};
`);
const a = n.value, c = je(n.color);
if (t && r + 1 < o.length) {
const u = o[r + 1].value, f = je(o[r + 1].color), d = Number.parseFloat((a - u).toFixed(Te)) === 0 ? "0." : `(${e.inputName} - ${a.toFixed(Te)}) / (${(u - a).toFixed(Te)})`;
i += `${r > 0 ? " else " : ""} if(${e.inputName}>=${a.toFixed(
Te
)}&&${e.inputName}<${u.toFixed(Te)}) { ${e.outputName}=mix(${c},${f}, ${d} ); }
`;
} else
i += `if(${e.inputName}>=${a.toFixed(Te)})${e.outputName}=${c};
`;
}
return i;
}
class go {
/**
* @param code Inputs: `vec4 dst`, `vec4 data`. Outputs into `dst`.
*/
constructor(t, e) {
this.code = t, this.decode = e, this.decode.min = this.decode.min ?? 0, this.decode.max = this.decode.max ?? 1;
}
/**
* Get the value in the unit interval [0, 1] computed with `.decode.min` and `.decode.max`
* @param