@devfamily/admiral
Version:
Admiral is a frontend framework for creating back office using React. It provides out-of-the-box components and tools that make developing an admin interface easy and fast.
1,717 lines • 3.73 MB
JavaScript
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a3, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp.call(b3, prop))
__defNormalProp(a3, prop, b3[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b3)) {
if (__propIsEnum.call(b3, prop))
__defNormalProp(a3, prop, b3[prop]);
}
return a3;
};
var __spreadProps = (a3, b3) => __defProps(a3, __getOwnPropDescs(b3));
var __objRest = (source2, exclude) => {
var target = {};
for (var prop in source2)
if (__hasOwnProp.call(source2, prop) && exclude.indexOf(prop) < 0)
target[prop] = source2[prop];
if (source2 != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source2)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source2, prop))
target[prop] = source2[prop];
}
return target;
};
import * as React$4 from "react";
import React__default, { useEffect, useState as useState$1, useRef, forwardRef as forwardRef$3, useCallback as useCallback$1, useContext as useContext$1, useMemo as useMemo$3, isValidElement, createContext, useReducer, Component, useLayoutEffect as useLayoutEffect$6, memo, PureComponent, cloneElement as cloneElement$1, useImperativeHandle, createElement } from "react";
import * as ReactDOM from "react-dom";
import ReactDOM__default, { unstable_batchedUpdates, createPortal } from "react-dom";
let updateQueue = makeQueue();
const raf$2 = (fn3) => schedule(fn3, updateQueue);
let writeQueue = makeQueue();
raf$2.write = (fn3) => schedule(fn3, writeQueue);
let onStartQueue = makeQueue();
raf$2.onStart = (fn3) => schedule(fn3, onStartQueue);
let onFrameQueue = makeQueue();
raf$2.onFrame = (fn3) => schedule(fn3, onFrameQueue);
let onFinishQueue = makeQueue();
raf$2.onFinish = (fn3) => schedule(fn3, onFinishQueue);
let timeouts = [];
raf$2.setTimeout = (handler, ms) => {
let time = raf$2.now() + ms;
let cancel = () => {
let i2 = timeouts.findIndex((t3) => t3.cancel == cancel);
if (~i2)
timeouts.splice(i2, 1);
pendingCount -= ~i2 ? 1 : 0;
};
let timeout = {
time,
handler,
cancel
};
timeouts.splice(findTimeout(time), 0, timeout);
pendingCount += 1;
start$1();
return timeout;
};
let findTimeout = (time) => ~(~timeouts.findIndex((t3) => t3.time > time) || ~timeouts.length);
raf$2.cancel = (fn3) => {
onStartQueue.delete(fn3);
onFrameQueue.delete(fn3);
updateQueue.delete(fn3);
writeQueue.delete(fn3);
onFinishQueue.delete(fn3);
};
raf$2.sync = (fn3) => {
sync = true;
raf$2.batchedUpdates(fn3);
sync = false;
};
raf$2.throttle = (fn3) => {
let lastArgs;
function queuedFn() {
try {
fn3(...lastArgs);
} finally {
lastArgs = null;
}
}
function throttled(...args) {
lastArgs = args;
raf$2.onStart(queuedFn);
}
throttled.handler = fn3;
throttled.cancel = () => {
onStartQueue.delete(queuedFn);
lastArgs = null;
};
return throttled;
};
let nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : () => {
};
raf$2.use = (impl) => nativeRaf = impl;
raf$2.now = typeof performance != "undefined" ? () => performance.now() : Date.now;
raf$2.batchedUpdates = (fn3) => fn3();
raf$2.catch = console.error;
raf$2.frameLoop = "always";
raf$2.advance = () => {
if (raf$2.frameLoop !== "demand") {
console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand");
} else {
update$1();
}
};
let ts = -1;
let pendingCount = 0;
let sync = false;
function schedule(fn3, queue) {
if (sync) {
queue.delete(fn3);
fn3(0);
} else {
queue.add(fn3);
start$1();
}
}
function start$1() {
if (ts < 0) {
ts = 0;
if (raf$2.frameLoop !== "demand") {
nativeRaf(loop$1);
}
}
}
function stop() {
ts = -1;
}
function loop$1() {
if (~ts) {
nativeRaf(loop$1);
raf$2.batchedUpdates(update$1);
}
}
function update$1() {
let prevTs = ts;
ts = raf$2.now();
let count2 = findTimeout(ts);
if (count2) {
eachSafely(timeouts.splice(0, count2), (t3) => t3.handler());
pendingCount -= count2;
}
onStartQueue.flush();
updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
onFrameQueue.flush();
writeQueue.flush();
onFinishQueue.flush();
if (!pendingCount) {
stop();
}
}
function makeQueue() {
let next = /* @__PURE__ */ new Set();
let current = next;
return {
add(fn3) {
pendingCount += current == next && !next.has(fn3) ? 1 : 0;
next.add(fn3);
},
delete(fn3) {
pendingCount -= current == next && next.has(fn3) ? 1 : 0;
return next.delete(fn3);
},
flush(arg) {
if (current.size) {
next = /* @__PURE__ */ new Set();
pendingCount -= current.size;
eachSafely(current, (fn3) => fn3(arg) && next.add(fn3));
pendingCount += next.size;
current = next;
}
}
};
}
function eachSafely(values2, each2) {
values2.forEach((value) => {
try {
each2(value);
} catch (e3) {
raf$2.catch(e3);
}
});
}
function noop$8() {
}
const defineHidden = (obj, key, value) => Object.defineProperty(obj, key, {
value,
writable: true,
configurable: true
});
const is$1 = {
arr: Array.isArray,
obj: (a3) => !!a3 && a3.constructor.name === "Object",
fun: (a3) => typeof a3 === "function",
str: (a3) => typeof a3 === "string",
num: (a3) => typeof a3 === "number",
und: (a3) => a3 === void 0
};
function isEqual$7(a3, b3) {
if (is$1.arr(a3)) {
if (!is$1.arr(b3) || a3.length !== b3.length)
return false;
for (let i2 = 0; i2 < a3.length; i2++) {
if (a3[i2] !== b3[i2])
return false;
}
return true;
}
return a3 === b3;
}
const each$1 = (obj, fn3) => obj.forEach(fn3);
function eachProp(obj, fn3, ctx2) {
if (is$1.arr(obj)) {
for (let i2 = 0; i2 < obj.length; i2++) {
fn3.call(ctx2, obj[i2], `${i2}`);
}
return;
}
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
fn3.call(ctx2, obj[key], key);
}
}
}
const toArray$8 = (a3) => is$1.und(a3) ? [] : is$1.arr(a3) ? a3 : [a3];
function flush$1(queue, iterator) {
if (queue.size) {
const items2 = Array.from(queue);
queue.clear();
each$1(items2, iterator);
}
}
const flushCalls = (queue, ...args) => flush$1(queue, (fn3) => fn3(...args));
const isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
let createStringInterpolator$1;
let to;
let colors$1 = null;
let skipAnimation = false;
let willAdvance = noop$8;
const assign$3 = (globals2) => {
if (globals2.to)
to = globals2.to;
if (globals2.now)
raf$2.now = globals2.now;
if (globals2.colors !== void 0)
colors$1 = globals2.colors;
if (globals2.skipAnimation != null)
skipAnimation = globals2.skipAnimation;
if (globals2.createStringInterpolator)
createStringInterpolator$1 = globals2.createStringInterpolator;
if (globals2.requestAnimationFrame)
raf$2.use(globals2.requestAnimationFrame);
if (globals2.batchedUpdates)
raf$2.batchedUpdates = globals2.batchedUpdates;
if (globals2.willAdvance)
willAdvance = globals2.willAdvance;
if (globals2.frameLoop)
raf$2.frameLoop = globals2.frameLoop;
};
var globals = /* @__PURE__ */ Object.freeze({
__proto__: null,
get createStringInterpolator() {
return createStringInterpolator$1;
},
get to() {
return to;
},
get colors() {
return colors$1;
},
get skipAnimation() {
return skipAnimation;
},
get willAdvance() {
return willAdvance;
},
assign: assign$3
});
const startQueue = /* @__PURE__ */ new Set();
let currentFrame = [];
let prevFrame = [];
let priority = 0;
const frameLoop = {
get idle() {
return !startQueue.size && !currentFrame.length;
},
start(animation) {
if (priority > animation.priority) {
startQueue.add(animation);
raf$2.onStart(flushStartQueue);
} else {
startSafely(animation);
raf$2(advance);
}
},
advance,
sort(animation) {
if (priority) {
raf$2.onFrame(() => frameLoop.sort(animation));
} else {
const prevIndex = currentFrame.indexOf(animation);
if (~prevIndex) {
currentFrame.splice(prevIndex, 1);
startUnsafely(animation);
}
}
},
clear() {
currentFrame = [];
startQueue.clear();
}
};
function flushStartQueue() {
startQueue.forEach(startSafely);
startQueue.clear();
raf$2(advance);
}
function startSafely(animation) {
if (!currentFrame.includes(animation))
startUnsafely(animation);
}
function startUnsafely(animation) {
currentFrame.splice(findIndex$3(currentFrame, (other) => other.priority > animation.priority), 0, animation);
}
function advance(dt) {
const nextFrame = prevFrame;
for (let i2 = 0; i2 < currentFrame.length; i2++) {
const animation = currentFrame[i2];
priority = animation.priority;
if (!animation.idle) {
willAdvance(animation);
animation.advance(dt);
if (!animation.idle) {
nextFrame.push(animation);
}
}
}
priority = 0;
prevFrame = currentFrame;
prevFrame.length = 0;
currentFrame = nextFrame;
return currentFrame.length > 0;
}
function findIndex$3(arr, test) {
const index2 = arr.findIndex(test);
return index2 < 0 ? arr.length : index2;
}
const colors = {
transparent: 0,
aliceblue: 4042850303,
antiquewhite: 4209760255,
aqua: 16777215,
aquamarine: 2147472639,
azure: 4043309055,
beige: 4126530815,
bisque: 4293182719,
black: 255,
blanchedalmond: 4293643775,
blue: 65535,
blueviolet: 2318131967,
brown: 2771004159,
burlywood: 3736635391,
burntsienna: 3934150143,
cadetblue: 1604231423,
chartreuse: 2147418367,
chocolate: 3530104575,
coral: 4286533887,
cornflowerblue: 1687547391,
cornsilk: 4294499583,
crimson: 3692313855,
cyan: 16777215,
darkblue: 35839,
darkcyan: 9145343,
darkgoldenrod: 3095792639,
darkgray: 2846468607,
darkgreen: 6553855,
darkgrey: 2846468607,
darkkhaki: 3182914559,
darkmagenta: 2332068863,
darkolivegreen: 1433087999,
darkorange: 4287365375,
darkorchid: 2570243327,
darkred: 2332033279,
darksalmon: 3918953215,
darkseagreen: 2411499519,
darkslateblue: 1211993087,
darkslategray: 793726975,
darkslategrey: 793726975,
darkturquoise: 13554175,
darkviolet: 2483082239,
deeppink: 4279538687,
deepskyblue: 12582911,
dimgray: 1768516095,
dimgrey: 1768516095,
dodgerblue: 512819199,
firebrick: 2988581631,
floralwhite: 4294635775,
forestgreen: 579543807,
fuchsia: 4278255615,
gainsboro: 3705462015,
ghostwhite: 4177068031,
gold: 4292280575,
goldenrod: 3668254975,
gray: 2155905279,
green: 8388863,
greenyellow: 2919182335,
grey: 2155905279,
honeydew: 4043305215,
hotpink: 4285117695,
indianred: 3445382399,
indigo: 1258324735,
ivory: 4294963455,
khaki: 4041641215,
lavender: 3873897215,
lavenderblush: 4293981695,
lawngreen: 2096890111,
lemonchiffon: 4294626815,
lightblue: 2916673279,
lightcoral: 4034953471,
lightcyan: 3774873599,
lightgoldenrodyellow: 4210742015,
lightgray: 3553874943,
lightgreen: 2431553791,
lightgrey: 3553874943,
lightpink: 4290167295,
lightsalmon: 4288707327,
lightseagreen: 548580095,
lightskyblue: 2278488831,
lightslategray: 2005441023,
lightslategrey: 2005441023,
lightsteelblue: 2965692159,
lightyellow: 4294959359,
lime: 16711935,
limegreen: 852308735,
linen: 4210091775,
magenta: 4278255615,
maroon: 2147483903,
mediumaquamarine: 1724754687,
mediumblue: 52735,
mediumorchid: 3126187007,
mediumpurple: 2473647103,
mediumseagreen: 1018393087,
mediumslateblue: 2070474495,
mediumspringgreen: 16423679,
mediumturquoise: 1221709055,
mediumvioletred: 3340076543,
midnightblue: 421097727,
mintcream: 4127193855,
mistyrose: 4293190143,
moccasin: 4293178879,
navajowhite: 4292783615,
navy: 33023,
oldlace: 4260751103,
olive: 2155872511,
olivedrab: 1804477439,
orange: 4289003775,
orangered: 4282712319,
orchid: 3664828159,
palegoldenrod: 4008225535,
palegreen: 2566625535,
paleturquoise: 2951671551,
palevioletred: 3681588223,
papayawhip: 4293907967,
peachpuff: 4292524543,
peru: 3448061951,
pink: 4290825215,
plum: 3718307327,
powderblue: 2967529215,
purple: 2147516671,
rebeccapurple: 1714657791,
red: 4278190335,
rosybrown: 3163525119,
royalblue: 1097458175,
saddlebrown: 2336560127,
salmon: 4202722047,
sandybrown: 4104413439,
seagreen: 780883967,
seashell: 4294307583,
sienna: 2689740287,
silver: 3233857791,
skyblue: 2278484991,
slateblue: 1784335871,
slategray: 1887473919,
slategrey: 1887473919,
snow: 4294638335,
springgreen: 16744447,
steelblue: 1182971135,
tan: 3535047935,
teal: 8421631,
thistle: 3636451583,
tomato: 4284696575,
turquoise: 1088475391,
violet: 4001558271,
wheat: 4125012991,
white: 4294967295,
whitesmoke: 4126537215,
yellow: 4294902015,
yellowgreen: 2597139199
};
const NUMBER = "[-+]?\\d*\\.?\\d+";
const PERCENTAGE = NUMBER + "%";
function call$3(...parts) {
return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)";
}
const rgb = new RegExp("rgb" + call$3(NUMBER, NUMBER, NUMBER));
const rgba = new RegExp("rgba" + call$3(NUMBER, NUMBER, NUMBER, NUMBER));
const hsl = new RegExp("hsl" + call$3(NUMBER, PERCENTAGE, PERCENTAGE));
const hsla = new RegExp("hsla" + call$3(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
const hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
const hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
const hex6 = /^#([0-9a-fA-F]{6})$/;
const hex8 = /^#([0-9a-fA-F]{8})$/;
function normalizeColor(color) {
let match2;
if (typeof color === "number") {
return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null;
}
if (match2 = hex6.exec(color))
return parseInt(match2[1] + "ff", 16) >>> 0;
if (colors$1 && colors$1[color] !== void 0) {
return colors$1[color];
}
if (match2 = rgb.exec(color)) {
return (parse255(match2[1]) << 24 | parse255(match2[2]) << 16 | parse255(match2[3]) << 8 | 255) >>> 0;
}
if (match2 = rgba.exec(color)) {
return (parse255(match2[1]) << 24 | parse255(match2[2]) << 16 | parse255(match2[3]) << 8 | parse1(match2[4])) >>> 0;
}
if (match2 = hex3.exec(color)) {
return parseInt(match2[1] + match2[1] + match2[2] + match2[2] + match2[3] + match2[3] + "ff", 16) >>> 0;
}
if (match2 = hex8.exec(color))
return parseInt(match2[1], 16) >>> 0;
if (match2 = hex4.exec(color)) {
return parseInt(match2[1] + match2[1] + match2[2] + match2[2] + match2[3] + match2[3] + match2[4] + match2[4], 16) >>> 0;
}
if (match2 = hsl.exec(color)) {
return (hslToRgb(parse360(match2[1]), parsePercentage(match2[2]), parsePercentage(match2[3])) | 255) >>> 0;
}
if (match2 = hsla.exec(color)) {
return (hslToRgb(parse360(match2[1]), parsePercentage(match2[2]), parsePercentage(match2[3])) | parse1(match2[4])) >>> 0;
}
return null;
}
function hue2rgb(p2, q3, t3) {
if (t3 < 0)
t3 += 1;
if (t3 > 1)
t3 -= 1;
if (t3 < 1 / 6)
return p2 + (q3 - p2) * 6 * t3;
if (t3 < 1 / 2)
return q3;
if (t3 < 2 / 3)
return p2 + (q3 - p2) * (2 / 3 - t3) * 6;
return p2;
}
function hslToRgb(h4, s3, l2) {
const q3 = l2 < 0.5 ? l2 * (1 + s3) : l2 + s3 - l2 * s3;
const p2 = 2 * l2 - q3;
const r2 = hue2rgb(p2, q3, h4 + 1 / 3);
const g2 = hue2rgb(p2, q3, h4);
const b3 = hue2rgb(p2, q3, h4 - 1 / 3);
return Math.round(r2 * 255) << 24 | Math.round(g2 * 255) << 16 | Math.round(b3 * 255) << 8;
}
function parse255(str) {
const int = parseInt(str, 10);
if (int < 0)
return 0;
if (int > 255)
return 255;
return int;
}
function parse360(str) {
const int = parseFloat(str);
return (int % 360 + 360) % 360 / 360;
}
function parse1(str) {
const num = parseFloat(str);
if (num < 0)
return 0;
if (num > 1)
return 255;
return Math.round(num * 255);
}
function parsePercentage(str) {
const int = parseFloat(str);
if (int < 0)
return 0;
if (int > 100)
return 1;
return int / 100;
}
function colorToRgba(input2) {
let int32Color = normalizeColor(input2);
if (int32Color === null)
return input2;
int32Color = int32Color || 0;
let r2 = (int32Color & 4278190080) >>> 24;
let g2 = (int32Color & 16711680) >>> 16;
let b3 = (int32Color & 65280) >>> 8;
let a3 = (int32Color & 255) / 255;
return `rgba(${r2}, ${g2}, ${b3}, ${a3})`;
}
const createInterpolator = (range, output, extrapolate) => {
if (is$1.fun(range)) {
return range;
}
if (is$1.arr(range)) {
return createInterpolator({
range,
output,
extrapolate
});
}
if (is$1.str(range.output[0])) {
return createStringInterpolator$1(range);
}
const config2 = range;
const outputRange = config2.output;
const inputRange = config2.range || [0, 1];
const extrapolateLeft = config2.extrapolateLeft || config2.extrapolate || "extend";
const extrapolateRight = config2.extrapolateRight || config2.extrapolate || "extend";
const easing = config2.easing || ((t3) => t3);
return (input2) => {
const range2 = findRange(input2, inputRange);
return interpolate(input2, inputRange[range2], inputRange[range2 + 1], outputRange[range2], outputRange[range2 + 1], easing, extrapolateLeft, extrapolateRight, config2.map);
};
};
function interpolate(input2, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map2) {
let result = map2 ? map2(input2) : input2;
if (result < inputMin) {
if (extrapolateLeft === "identity")
return result;
else if (extrapolateLeft === "clamp")
result = inputMin;
}
if (result > inputMax) {
if (extrapolateRight === "identity")
return result;
else if (extrapolateRight === "clamp")
result = inputMax;
}
if (outputMin === outputMax)
return outputMin;
if (inputMin === inputMax)
return input2 <= inputMin ? outputMin : outputMax;
if (inputMin === -Infinity)
result = -result;
else if (inputMax === Infinity)
result = result - inputMin;
else
result = (result - inputMin) / (inputMax - inputMin);
result = easing(result);
if (outputMin === -Infinity)
result = -result;
else if (outputMax === Infinity)
result = result + outputMin;
else
result = result * (outputMax - outputMin) + outputMin;
return result;
}
function findRange(input2, inputRange) {
for (var i2 = 1; i2 < inputRange.length - 1; ++i2)
if (inputRange[i2] >= input2)
break;
return i2 - 1;
}
function _extends$j() {
_extends$j = Object.assign || function(target) {
for (var i2 = 1; i2 < arguments.length; i2++) {
var source2 = arguments[i2];
for (var key in source2) {
if (Object.prototype.hasOwnProperty.call(source2, key)) {
target[key] = source2[key];
}
}
}
return target;
};
return _extends$j.apply(this, arguments);
}
const $get = Symbol.for("FluidValue.get");
const $observers = Symbol.for("FluidValue.observers");
const hasFluidValue = (arg) => Boolean(arg && arg[$get]);
const getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg;
const getFluidObservers = (target) => target[$observers] || null;
function callFluidObserver(observer, event) {
if (observer.eventObserved) {
observer.eventObserved(event);
} else {
observer(event);
}
}
function callFluidObservers(target, event) {
let observers2 = target[$observers];
if (observers2) {
observers2.forEach((observer) => {
callFluidObserver(observer, event);
});
}
}
class FluidValue {
constructor(get4) {
this[$get] = void 0;
this[$observers] = void 0;
if (!get4 && !(get4 = this.get)) {
throw Error("Unknown getter");
}
setFluidGetter(this, get4);
}
}
const setFluidGetter = (target, get4) => setHidden(target, $get, get4);
function addFluidObserver(target, observer) {
if (target[$get]) {
let observers2 = target[$observers];
if (!observers2) {
setHidden(target, $observers, observers2 = /* @__PURE__ */ new Set());
}
if (!observers2.has(observer)) {
observers2.add(observer);
if (target.observerAdded) {
target.observerAdded(observers2.size, observer);
}
}
}
return observer;
}
function removeFluidObserver(target, observer) {
let observers2 = target[$observers];
if (observers2 && observers2.has(observer)) {
const count2 = observers2.size - 1;
if (count2) {
observers2.delete(observer);
} else {
target[$observers] = null;
}
if (target.observerRemoved) {
target.observerRemoved(count2, observer);
}
}
}
const setHidden = (target, key, value) => Object.defineProperty(target, key, {
value,
writable: true,
configurable: true
});
const numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
const colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
const unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, "i");
const rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
const cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
const variableToRgba = (input2) => {
const [token, fallback] = parseCSSVariable(input2);
if (!token || isSSR()) {
return input2;
}
const value = window.getComputedStyle(document.documentElement).getPropertyValue(token);
if (value) {
return value.trim();
} else if (fallback && fallback.startsWith("--")) {
const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback);
if (_value) {
return _value;
} else {
return input2;
}
} else if (fallback && cssVariableRegex.test(fallback)) {
return variableToRgba(fallback);
} else if (fallback) {
return fallback;
}
return input2;
};
const parseCSSVariable = (current) => {
const match2 = cssVariableRegex.exec(current);
if (!match2)
return [,];
const [, token, fallback] = match2;
return [token, fallback];
};
let namedColorRegex;
const rgbaRound = (_, p1, p2, p3, p4) => `rgba(${Math.round(p1)}, ${Math.round(p2)}, ${Math.round(p3)}, ${p4})`;
const createStringInterpolator = (config2) => {
if (!namedColorRegex)
namedColorRegex = colors$1 ? new RegExp(`(${Object.keys(colors$1).join("|")})(?!\\w)`, "g") : /^\b$/;
const output = config2.output.map((value) => {
return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba);
});
const keyframes = output.map((value) => value.match(numberRegex).map(Number));
const outputRanges = keyframes[0].map((_, i2) => keyframes.map((values2) => {
if (!(i2 in values2)) {
throw Error('The arity of each "output" value must be equal');
}
return values2[i2];
}));
const interpolators = outputRanges.map((output2) => createInterpolator(_extends$j({}, config2, {
output: output2
})));
return (input2) => {
var _output$find;
const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find((value) => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, ""));
let i2 = 0;
return output[0].replace(numberRegex, () => `${interpolators[i2++](input2)}${missingUnit || ""}`).replace(rgbaRegex, rgbaRound);
};
};
const prefix$3 = "react-spring: ";
const once = (fn3) => {
const func = fn3;
let called = false;
if (typeof func != "function") {
throw new TypeError(`${prefix$3}once requires a function parameter`);
}
return (...args) => {
if (!called) {
func(...args);
called = true;
}
};
};
const warnInterpolate = once(console.warn);
function deprecateInterpolate() {
warnInterpolate(`${prefix$3}The "interpolate" function is deprecated in v9 (use "to" instead)`);
}
const warnDirectCall = once(console.warn);
function deprecateDirectCall() {
warnDirectCall(`${prefix$3}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`);
}
function isAnimatedString(value) {
return is$1.str(value) && (value[0] == "#" || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {}));
}
const useOnce = (effect3) => useEffect(effect3, emptyDeps);
const emptyDeps = [];
function useForceUpdate$1() {
const update2 = useState$1()[1];
const mounted = useState$1(makeMountedRef)[0];
useOnce(mounted.unmount);
return () => {
if (mounted.current) {
update2({});
}
};
}
function makeMountedRef() {
const mounted = {
current: true,
unmount: () => () => {
mounted.current = false;
}
};
return mounted;
}
function useMemoOne$1(getResult, inputs) {
const [initial] = useState$1(() => ({
inputs,
result: getResult()
}));
const committed = useRef();
const prevCache = committed.current;
let cache2 = prevCache;
if (cache2) {
const useCache2 = Boolean(inputs && cache2.inputs && areInputsEqual$2(inputs, cache2.inputs));
if (!useCache2) {
cache2 = {
inputs,
result: getResult()
};
}
} else {
cache2 = initial;
}
useEffect(() => {
committed.current = cache2;
if (prevCache == initial) {
initial.inputs = initial.result = void 0;
}
}, [cache2]);
return cache2.result;
}
function areInputsEqual$2(next, prev) {
if (next.length !== prev.length) {
return false;
}
for (let i2 = 0; i2 < next.length; i2++) {
if (next[i2] !== prev[i2]) {
return false;
}
}
return true;
}
function usePrev(value) {
const prevRef = useRef();
useEffect(() => {
prevRef.current = value;
});
return prevRef.current;
}
const useLayoutEffect$5 = typeof window !== "undefined" && window.document && window.document.createElement ? React$4.useLayoutEffect : React$4.useEffect;
const $node = Symbol.for("Animated:node");
const isAnimated = (value) => !!value && value[$node] === value;
const getAnimated = (owner) => owner && owner[$node];
const setAnimated = (owner, node) => defineHidden(owner, $node, node);
const getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload();
class Animated {
constructor() {
this.payload = void 0;
setAnimated(this, this);
}
getPayload() {
return this.payload || [];
}
}
class AnimatedValue extends Animated {
constructor(_value) {
super();
this.done = true;
this.elapsedTime = void 0;
this.lastPosition = void 0;
this.lastVelocity = void 0;
this.v0 = void 0;
this.durationProgress = 0;
this._value = _value;
if (is$1.num(this._value)) {
this.lastPosition = this._value;
}
}
static create(value) {
return new AnimatedValue(value);
}
getPayload() {
return [this];
}
getValue() {
return this._value;
}
setValue(value, step) {
if (is$1.num(value)) {
this.lastPosition = value;
if (step) {
value = Math.round(value / step) * step;
if (this.done) {
this.lastPosition = value;
}
}
}
if (this._value === value) {
return false;
}
this._value = value;
return true;
}
reset() {
const {
done
} = this;
this.done = false;
if (is$1.num(this._value)) {
this.elapsedTime = 0;
this.durationProgress = 0;
this.lastPosition = this._value;
if (done)
this.lastVelocity = null;
this.v0 = null;
}
}
}
class AnimatedString extends AnimatedValue {
constructor(value) {
super(0);
this._string = null;
this._toString = void 0;
this._toString = createInterpolator({
output: [value, value]
});
}
static create(value) {
return new AnimatedString(value);
}
getValue() {
let value = this._string;
return value == null ? this._string = this._toString(this._value) : value;
}
setValue(value) {
if (is$1.str(value)) {
if (value == this._string) {
return false;
}
this._string = value;
this._value = 1;
} else if (super.setValue(value)) {
this._string = null;
} else {
return false;
}
return true;
}
reset(goal) {
if (goal) {
this._toString = createInterpolator({
output: [this.getValue(), goal]
});
}
this._value = 0;
super.reset();
}
}
const TreeContext = {
dependencies: null
};
class AnimatedObject extends Animated {
constructor(source2) {
super();
this.source = source2;
this.setValue(source2);
}
getValue(animated2) {
const values2 = {};
eachProp(this.source, (source2, key) => {
if (isAnimated(source2)) {
values2[key] = source2.getValue(animated2);
} else if (hasFluidValue(source2)) {
values2[key] = getFluidValue(source2);
} else if (!animated2) {
values2[key] = source2;
}
});
return values2;
}
setValue(source2) {
this.source = source2;
this.payload = this._makePayload(source2);
}
reset() {
if (this.payload) {
each$1(this.payload, (node) => node.reset());
}
}
_makePayload(source2) {
if (source2) {
const payload = /* @__PURE__ */ new Set();
eachProp(source2, this._addToPayload, payload);
return Array.from(payload);
}
}
_addToPayload(source2) {
if (TreeContext.dependencies && hasFluidValue(source2)) {
TreeContext.dependencies.add(source2);
}
const payload = getPayload(source2);
if (payload) {
each$1(payload, (node) => this.add(node));
}
}
}
class AnimatedArray extends AnimatedObject {
constructor(source2) {
super(source2);
}
static create(source2) {
return new AnimatedArray(source2);
}
getValue() {
return this.source.map((node) => node.getValue());
}
setValue(source2) {
const payload = this.getPayload();
if (source2.length == payload.length) {
return payload.map((node, i2) => node.setValue(source2[i2])).some(Boolean);
}
super.setValue(source2.map(makeAnimated));
return true;
}
}
function makeAnimated(value) {
const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
return nodeType.create(value);
}
function getAnimatedType(value) {
const parentNode = getAnimated(value);
return parentNode ? parentNode.constructor : is$1.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
}
function _extends$i() {
_extends$i = Object.assign || function(target) {
for (var i2 = 1; i2 < arguments.length; i2++) {
var source2 = arguments[i2];
for (var key in source2) {
if (Object.prototype.hasOwnProperty.call(source2, key)) {
target[key] = source2[key];
}
}
}
return target;
};
return _extends$i.apply(this, arguments);
}
const withAnimated = (Component2, host2) => {
const hasInstance = !is$1.fun(Component2) || Component2.prototype && Component2.prototype.isReactComponent;
return forwardRef$3((givenProps, givenRef) => {
const instanceRef = useRef(null);
const ref = hasInstance && useCallback$1((value) => {
instanceRef.current = updateRef$1(givenRef, value);
}, [givenRef]);
const [props, deps] = getAnimatedState(givenProps, host2);
const forceUpdate = useForceUpdate$1();
const callback = () => {
const instance = instanceRef.current;
if (hasInstance && !instance) {
return;
}
const didUpdate = instance ? host2.applyAnimatedValues(instance, props.getValue(true)) : false;
if (didUpdate === false) {
forceUpdate();
}
};
const observer = new PropsObserver(callback, deps);
const observerRef = useRef();
useLayoutEffect$5(() => {
const lastObserver = observerRef.current;
observerRef.current = observer;
each$1(deps, (dep) => addFluidObserver(dep, observer));
if (lastObserver) {
each$1(lastObserver.deps, (dep) => removeFluidObserver(dep, lastObserver));
raf$2.cancel(lastObserver.update);
}
});
useEffect(callback, []);
useOnce(() => () => {
const observer2 = observerRef.current;
each$1(observer2.deps, (dep) => removeFluidObserver(dep, observer2));
});
const usedProps = host2.getComponentProps(props.getValue());
return React$4.createElement(Component2, _extends$i({}, usedProps, {
ref
}));
});
};
class PropsObserver {
constructor(update2, deps) {
this.update = update2;
this.deps = deps;
}
eventObserved(event) {
if (event.type == "change") {
raf$2.write(this.update);
}
}
}
function getAnimatedState(props, host2) {
const dependencies = /* @__PURE__ */ new Set();
TreeContext.dependencies = dependencies;
if (props.style)
props = _extends$i({}, props, {
style: host2.createAnimatedStyle(props.style)
});
props = new AnimatedObject(props);
TreeContext.dependencies = null;
return [props, dependencies];
}
function updateRef$1(ref, value) {
if (ref) {
if (is$1.fun(ref))
ref(value);
else
ref.current = value;
}
return value;
}
const cacheKey = Symbol.for("AnimatedComponent");
const createHost = (components, {
applyAnimatedValues: _applyAnimatedValues = () => false,
createAnimatedStyle: _createAnimatedStyle = (style2) => new AnimatedObject(style2),
getComponentProps: _getComponentProps = (props) => props
} = {}) => {
const hostConfig = {
applyAnimatedValues: _applyAnimatedValues,
createAnimatedStyle: _createAnimatedStyle,
getComponentProps: _getComponentProps
};
const animated2 = (Component2) => {
const displayName = getDisplayName(Component2) || "Anonymous";
if (is$1.str(Component2)) {
Component2 = animated2[Component2] || (animated2[Component2] = withAnimated(Component2, hostConfig));
} else {
Component2 = Component2[cacheKey] || (Component2[cacheKey] = withAnimated(Component2, hostConfig));
}
Component2.displayName = `Animated(${displayName})`;
return Component2;
};
eachProp(components, (Component2, key) => {
if (is$1.arr(components)) {
key = getDisplayName(Component2);
}
animated2[key] = animated2(Component2);
});
return {
animated: animated2
};
};
const getDisplayName = (arg) => is$1.str(arg) ? arg : arg && is$1.str(arg.displayName) ? arg.displayName : is$1.fun(arg) && arg.name || null;
function _extends$h() {
_extends$h = Object.assign || function(target) {
for (var i2 = 1; i2 < arguments.length; i2++) {
var source2 = arguments[i2];
for (var key in source2) {
if (Object.prototype.hasOwnProperty.call(source2, key)) {
target[key] = source2[key];
}
}
}
return target;
};
return _extends$h.apply(this, arguments);
}
function callProp(value, ...args) {
return is$1.fun(value) ? value(...args) : value;
}
const matchProp = (value, key) => value === true || !!(key && value && (is$1.fun(value) ? value(key) : toArray$8(value).includes(key)));
const resolveProp = (prop, key) => is$1.obj(prop) ? key && prop[key] : prop;
const getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
const noopTransform = (value) => value;
const getDefaultProps = (props, transform2 = noopTransform) => {
let keys2 = DEFAULT_PROPS;
if (props.default && props.default !== true) {
props = props.default;
keys2 = Object.keys(props);
}
const defaults2 = {};
for (const key of keys2) {
const value = transform2(props[key], key);
if (!is$1.und(value)) {
defaults2[key] = value;
}
}
return defaults2;
};
const DEFAULT_PROPS = ["config", "onProps", "onStart", "onChange", "onPause", "onResume", "onRest"];
const RESERVED_PROPS = {
config: 1,
from: 1,
to: 1,
ref: 1,
loop: 1,
reset: 1,
pause: 1,
cancel: 1,
reverse: 1,
immediate: 1,
default: 1,
delay: 1,
onProps: 1,
onStart: 1,
onChange: 1,
onPause: 1,
onResume: 1,
onRest: 1,
onResolve: 1,
items: 1,
trail: 1,
sort: 1,
expires: 1,
initial: 1,
enter: 1,
update: 1,
leave: 1,
children: 1,
onDestroyed: 1,
keys: 1,
callId: 1,
parentId: 1
};
function getForwardProps(props) {
const forward = {};
let count2 = 0;
eachProp(props, (value, prop) => {
if (!RESERVED_PROPS[prop]) {
forward[prop] = value;
count2++;
}
});
if (count2) {
return forward;
}
}
function inferTo(props) {
const to2 = getForwardProps(props);
if (to2) {
const out = {
to: to2
};
eachProp(props, (val, key) => key in to2 || (out[key] = val));
return out;
}
return _extends$h({}, props);
}
function computeGoal(value) {
value = getFluidValue(value);
return is$1.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({
range: [0, 1],
output: [value, value]
})(1) : value;
}
function hasProps(props) {
for (const _ in props)
return true;
return false;
}
function isAsyncTo(to2) {
return is$1.fun(to2) || is$1.arr(to2) && is$1.obj(to2[0]);
}
function detachRefs(ctrl, ref) {
var _ctrl$ref;
(_ctrl$ref = ctrl.ref) == null ? void 0 : _ctrl$ref.delete(ctrl);
ref == null ? void 0 : ref.delete(ctrl);
}
function replaceRef(ctrl, ref) {
if (ref && ctrl.ref !== ref) {
var _ctrl$ref2;
(_ctrl$ref2 = ctrl.ref) == null ? void 0 : _ctrl$ref2.delete(ctrl);
ref.add(ctrl);
ctrl.ref = ref;
}
}
const config$2 = {
default: {
tension: 170,
friction: 26
},
gentle: {
tension: 120,
friction: 14
},
wobbly: {
tension: 180,
friction: 12
},
stiff: {
tension: 210,
friction: 20
},
slow: {
tension: 280,
friction: 60
},
molasses: {
tension: 280,
friction: 120
}
};
const c1 = 1.70158;
const c2 = c1 * 1.525;
const c3 = c1 + 1;
const c4 = 2 * Math.PI / 3;
const c5 = 2 * Math.PI / 4.5;
const bounceOut = (x2) => {
const n1 = 7.5625;
const d1 = 2.75;
if (x2 < 1 / d1) {
return n1 * x2 * x2;
} else if (x2 < 2 / d1) {
return n1 * (x2 -= 1.5 / d1) * x2 + 0.75;
} else if (x2 < 2.5 / d1) {
return n1 * (x2 -= 2.25 / d1) * x2 + 0.9375;
} else {
return n1 * (x2 -= 2.625 / d1) * x2 + 0.984375;
}
};
const easings = {
linear: (x2) => x2,
easeInQuad: (x2) => x2 * x2,
easeOutQuad: (x2) => 1 - (1 - x2) * (1 - x2),
easeInOutQuad: (x2) => x2 < 0.5 ? 2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 2) / 2,
easeInCubic: (x2) => x2 * x2 * x2,
easeOutCubic: (x2) => 1 - Math.pow(1 - x2, 3),
easeInOutCubic: (x2) => x2 < 0.5 ? 4 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 3) / 2,
easeInQuart: (x2) => x2 * x2 * x2 * x2,
easeOutQuart: (x2) => 1 - Math.pow(1 - x2, 4),
easeInOutQuart: (x2) => x2 < 0.5 ? 8 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 4) / 2,
easeInQuint: (x2) => x2 * x2 * x2 * x2 * x2,
easeOutQuint: (x2) => 1 - Math.pow(1 - x2, 5),
easeInOutQuint: (x2) => x2 < 0.5 ? 16 * x2 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 5) / 2,
easeInSine: (x2) => 1 - Math.cos(x2 * Math.PI / 2),
easeOutSine: (x2) => Math.sin(x2 * Math.PI / 2),
easeInOutSine: (x2) => -(Math.cos(Math.PI * x2) - 1) / 2,
easeInExpo: (x2) => x2 === 0 ? 0 : Math.pow(2, 10 * x2 - 10),
easeOutExpo: (x2) => x2 === 1 ? 1 : 1 - Math.pow(2, -10 * x2),
easeInOutExpo: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : x2 < 0.5 ? Math.pow(2, 20 * x2 - 10) / 2 : (2 - Math.pow(2, -20 * x2 + 10)) / 2,
easeInCirc: (x2) => 1 - Math.sqrt(1 - Math.pow(x2, 2)),
easeOutCirc: (x2) => Math.sqrt(1 - Math.pow(x2 - 1, 2)),
easeInOutCirc: (x2) => x2 < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x2, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x2 + 2, 2)) + 1) / 2,
easeInBack: (x2) => c3 * x2 * x2 * x2 - c1 * x2 * x2,
easeOutBack: (x2) => 1 + c3 * Math.pow(x2 - 1, 3) + c1 * Math.pow(x2 - 1, 2),
easeInOutBack: (x2) => x2 < 0.5 ? Math.pow(2 * x2, 2) * ((c2 + 1) * 2 * x2 - c2) / 2 : (Math.pow(2 * x2 - 2, 2) * ((c2 + 1) * (x2 * 2 - 2) + c2) + 2) / 2,
easeInElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : -Math.pow(2, 10 * x2 - 10) * Math.sin((x2 * 10 - 10.75) * c4),
easeOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : Math.pow(2, -10 * x2) * Math.sin((x2 * 10 - 0.75) * c4) + 1,
easeInOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : x2 < 0.5 ? -(Math.pow(2, 20 * x2 - 10) * Math.sin((20 * x2 - 11.125) * c5)) / 2 : Math.pow(2, -20 * x2 + 10) * Math.sin((20 * x2 - 11.125) * c5) / 2 + 1,
easeInBounce: (x2) => 1 - bounceOut(1 - x2),
easeOutBounce: bounceOut,
easeInOutBounce: (x2) => x2 < 0.5 ? (1 - bounceOut(1 - 2 * x2)) / 2 : (1 + bounceOut(2 * x2 - 1)) / 2
};
const defaults$7 = _extends$h({}, config$2.default, {
mass: 1,
damping: 1,
easing: easings.linear,
clamp: false
});
class AnimationConfig {
constructor() {
this.tension = void 0;
this.friction = void 0;
this.frequency = void 0;
this.damping = void 0;
this.mass = void 0;
this.velocity = 0;
this.restVelocity = void 0;
this.precision = void 0;
this.progress = void 0;
this.duration = void 0;
this.easing = void 0;
this.clamp = void 0;
this.bounce = void 0;
this.decay = void 0;
this.round = void 0;
Object.assign(this, defaults$7);
}
}
function mergeConfig$3(config2, newConfig, defaultConfig2) {
if (defaultConfig2) {
defaultConfig2 = _extends$h({}, defaultConfig2);
sanitizeConfig(defaultConfig2, newConfig);
newConfig = _extends$h({}, defaultConfig2, newConfig);
}
sanitizeConfig(config2, newConfig);
Object.assign(config2, newConfig);
for (const key in defaults$7) {
if (config2[key] == null) {
config2[key] = defaults$7[key];
}
}
let {
mass,
frequency,
damping
} = config2;
if (!is$1.und(frequency)) {
if (frequency < 0.01)
frequency = 0.01;
if (damping < 0)
damping = 0;
config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
config2.friction = 4 * Math.PI * damping * mass / frequency;
}
return config2;
}
function sanitizeConfig(config2, props) {
if (!is$1.und(props.decay)) {
config2.duration = void 0;
} else {
const isTensionConfig = !is$1.und(props.tension) || !is$1.und(props.friction);
if (isTensionConfig || !is$1.und(props.frequency) || !is$1.und(props.damping) || !is$1.und(props.mass)) {
config2.duration = void 0;
config2.decay = void 0;
}
if (isTensionConfig) {
config2.frequency = void 0;
}
}
}
const emptyArray = [];
class Animation {
constructor() {
this.changed = false;
this.values = emptyArray;
this.toValues = null;
this.fromValues = emptyArray;
this.to = void 0;
this.from = void 0;
this.config = new AnimationConfig();
this.immediate = false;
}
}
function scheduleProps(callId, {
key,
props,
defaultProps: defaultProps2,
state,
actions: actions2
}) {
return new Promise((resolve, reject) => {
var _props$cancel;
let delay;
let timeout;
let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps2 == null ? void 0 : defaultProps2.cancel, key);
if (cancel) {
onStart();
} else {
if (!is$1.und(props.pause)) {
state.paused = matchProp(props.pause, key);
}
let pause = defaultProps2 == null ? void 0 : defaultProps2.pause;
if (pause !== true) {
pause = state.paused || matchProp(pause, key);
}
delay = callProp(props.delay || 0, key);
if (pause) {
state.resumeQueue.add(onResume);
actions2.pause();
} else {
actions2.resume();
onResume();
}
}
function onPause() {
state.resumeQueue.add(onResume);
state.timeouts.delete(timeout);
timeout.cancel();
delay = timeout.time - raf$2.now();
}
function onResume() {
if (delay > 0 && !globals.skipAnimation) {
state.delayed = true;
timeout = raf$2.setTimeout(onStart, delay);
state.pauseQueue.add(onPause);
state.timeouts.add(timeout);
} else {
onStart();
}
}
function onStart() {
if (state.delayed) {
state.delayed = false;
}
state.pauseQueue.delete(onPause);
state.timeouts.delete(timeout);
if (callId <= (state.cancelId || 0)) {
cancel = true;
}
try {
actions2.start(_extends$h({}, props, {
callId,
cancel
}), resolve);
} catch (err) {
reject(err);
}
}
});
}
const getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some((result) => result.cancelled) ? getCancelledResult(target.get()) : results.every((result) => result.noop) ? getNoopResult(target.get()) : getFinishedResult(target.get(), results.every((result) => result.finished));
const getNoopResult = (value) => ({
value,
noop: true,
finished: true,
cancelled: false
});
const getFinishedResult = (value, finished, cancelled = false) => ({
value,
finished,
cancelled
});
const getCancelledResult = (value) => ({
value,
cancelled: true,
finished: false
});
function runAsync(to2, props, state, target) {
const {
callId,
parentId,
onRest
} = props;
const {
asyncTo: prevTo,
promise: prevPromise
} = state;
if (!parentId && to2 === prevTo && !props.reset) {
return prevPromise;
}
return state.promise = (async () => {
state.asyncId = callId;
state.asyncTo = to2;
const defaultProps2 = getDefaultProps(props, (value, key) => key === "onRest" ? void 0 : value);
let preventBail;
let bail;
const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject));
const bailIfEnded = (bailSignal) => {
const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false);
if (bailResult) {
bailSignal.result = bailResult;
bail(bailSignal);
throw bailSignal;
}
};
const animate = (arg1, arg2) => {
const bailSignal = new BailSignal();
const skipAnimationSignal = new SkipAniamtionSignal();
return (async () => {
if (globals.skipAnimation) {
stopAsync(state);
skipAnimationSignal.result = getFinishedResult(target, false);
bail(skipAnimationSignal);
throw skipAnimationSignal;
}
bailIfEnded(bailSignal);
const props2 = is$1.obj(arg1) ? _extends$h({}, arg1) : _extends$h({}, arg2, {
to: arg1
});
props2.parentId = callId;
eachProp(defaultProps2, (value, key) => {
if (is$1.und(props2[key])) {
props2[key] = value;
}
});
const result2 = await target.start(props2);
bailIfEnded(bailSignal);
if (state.paused) {
await new Promise((resume) => {
state.resumeQueue.add(resume);
});
}
return result2;
})();
};
let result;
if (globals.skipAnimation) {
stopAsync(state);
return getFinishedResult(target, false);
}
try {
let animating;
if (is$1.arr(to2)) {
animating = (async (queue) => {
for (const props2 of queue) {
await animate(props2);
}
})(to2);
} else {
animating = Promise.resolve(to2(animate, target.stop.bind(target)));
}
await Promise.all([animating.then(preventBail), bailPromise]);
result = getFinishedResult(target.get(), true, false);
} catch (err) {
if (err instanceof BailSignal) {
result = err.result;
} else if (err instanceof SkipAniamtionSignal) {
result = err.result;
} else {
throw err;
}
} finally {
if (callId == state.asyncId) {
state.asyncId = parentId;
state.asyncTo = parentId ? prevTo : void 0;
state.promise = parentId ? prevPromise : void 0;
}
}
if (is$1.fun(onRest)) {
raf$2.batchedUpdates(() => {
onRest(result, target, target.item);
});
}
return result;
})();
}
function stopAsync(state, cancelId) {
flush$1(state.timeouts, (t3) => t3.cancel());
state.pauseQueue.clear();
state.resumeQueue.clear();
state.asyncId = state.asyncTo = state.promise = void 0;
if (cancelId)
state.cancelId = cancelId;
}
class BailSignal extends Error {
constructor() {
super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise.");
this.result = void 0;
}
}
class SkipAniamtionSignal extends Error {
constructor() {
super("SkipAnimationSignal");
this.result = void 0;
}
}
const isFrameValue = (value) => value instanceof FrameValue;
let nextId$1 = 1;
class FrameValue extends FluidValue {
constructor(...args) {
super(...args);
this.id = nextId$1++;
this.key = void 0;
this._priority = 0;
}
get priority() {
return this._priority;
}
set priority(priority2) {
if (this._priority != priority2) {
this._priority = priority2;
this._onPriorityChange(priority2);
}
}
get() {
const node = getAnimated(this);
return node && node.getValue();
}
to(...args) {
return globals.to(this, args);
}
interpolate(...args) {
deprecateInterpolate();
return g