@bigbinary/neeto-time-zones 0.5.0 → 0.5.1
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/README.md +7 -7
- package/dist/{index-3103b741.js → index-8bd145b1.js} +1352 -60
- package/dist/index-9da7f148.cjs +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +2 -2
- package/dist/react.cjs.js +4 -11
- package/dist/react.es.js +556 -384
- package/dist/style.css +1 -1
- package/package.json +30 -10
- package/dist/index-72a4a60c.cjs +0 -1
|
@@ -1633,6 +1633,30 @@ function z(n2, t2) {
|
|
|
1633
1633
|
function B(n2, t2) {
|
|
1634
1634
|
return "function" == typeof t2 ? t2(n2) : t2;
|
|
1635
1635
|
}
|
|
1636
|
+
const getFromLocalStorage = (key) => {
|
|
1637
|
+
let response = null;
|
|
1638
|
+
try {
|
|
1639
|
+
const value = localStorage.getItem(key);
|
|
1640
|
+
response = value !== null ? JSON.parse(value) : null;
|
|
1641
|
+
} catch (error) {
|
|
1642
|
+
response = null;
|
|
1643
|
+
}
|
|
1644
|
+
return response;
|
|
1645
|
+
};
|
|
1646
|
+
const setToLocalStorage = (key, value) => {
|
|
1647
|
+
if (value !== null) {
|
|
1648
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
1649
|
+
} else
|
|
1650
|
+
localStorage.removeItem(key);
|
|
1651
|
+
};
|
|
1652
|
+
const hyphenize = (value, fallbackString = "") => {
|
|
1653
|
+
if (typeof value === "number")
|
|
1654
|
+
return String(value);
|
|
1655
|
+
if (value && typeof value === "string" && value.replace) {
|
|
1656
|
+
return value.replace(/[\s_]/g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").replace(/-+/g, "-").toLowerCase();
|
|
1657
|
+
}
|
|
1658
|
+
return fallbackString;
|
|
1659
|
+
};
|
|
1636
1660
|
function Button$1({
|
|
1637
1661
|
children,
|
|
1638
1662
|
customClass = "",
|
|
@@ -1666,16 +1690,12 @@ function Button$1({
|
|
|
1666
1690
|
return /* @__PURE__ */ y(
|
|
1667
1691
|
"button",
|
|
1668
1692
|
{
|
|
1669
|
-
...{
|
|
1670
|
-
id,
|
|
1671
|
-
key,
|
|
1672
|
-
onClick,
|
|
1673
|
-
value
|
|
1674
|
-
},
|
|
1693
|
+
...{ id, key, onClick, value },
|
|
1675
1694
|
className: `flex items-center gap-2 py-2 text-md ${customClass}`,
|
|
1695
|
+
"data-cy": `${hyphenize(label)}-select-option`,
|
|
1676
1696
|
type: "button"
|
|
1677
1697
|
},
|
|
1678
|
-
/* @__PURE__ */ y("div", { className: "min-w-0 text-left break-words grow
|
|
1698
|
+
/* @__PURE__ */ y("div", { className: "flex min-w-0 space-x-1 text-left break-words grow" }, hideCitiesTooltip ? label : /* @__PURE__ */ y("span", { ...{ value }, title: cities }, label), isDst && /* @__PURE__ */ y("span", { ...{ value }, title: "Daylight savings time applicable" }, "🌞")),
|
|
1679
1699
|
/* @__PURE__ */ y("span", { className: "flex items-center shrink-0" }, getCurrentTimeInTimezone(timezone.utc[0])),
|
|
1680
1700
|
children
|
|
1681
1701
|
);
|
|
@@ -1699,14 +1719,14 @@ function Button({
|
|
|
1699
1719
|
searchBox.focus();
|
|
1700
1720
|
}
|
|
1701
1721
|
}, [isOverlayVisible]);
|
|
1702
|
-
return /* @__PURE__ */ y("div", { className: "flex flex-col justify-between w-full text-gray-700 bg-white rounded" }, /* @__PURE__ */ y(
|
|
1722
|
+
return /* @__PURE__ */ y("div", { className: "flex flex-col justify-between w-full neeto-ui-text-gray-700 neeto-ui-bg-white neeto-ui-rounded" }, /* @__PURE__ */ y(
|
|
1703
1723
|
Button$1,
|
|
1704
1724
|
{
|
|
1705
1725
|
onClick: handleClick,
|
|
1706
1726
|
customClass: "px-4 ntsp-button-border",
|
|
1707
1727
|
timezone: selectedValue,
|
|
1708
1728
|
hideCitiesTooltip: true,
|
|
1709
|
-
is24H
|
|
1729
|
+
...{ is24H }
|
|
1710
1730
|
},
|
|
1711
1731
|
/* @__PURE__ */ y("span", { className: "flex items-center shrink-0" }, /* @__PURE__ */ y(
|
|
1712
1732
|
"svg",
|
|
@@ -1730,8 +1750,9 @@ function Search({ searchInput, setSearchInput, elementId }) {
|
|
|
1730
1750
|
type: "text",
|
|
1731
1751
|
placeholder: "Search",
|
|
1732
1752
|
onInput: (event) => setSearchInput(event.target.value),
|
|
1733
|
-
className: "p-2 m-2 border-2 border-blue-400 rounded shadow-lg
|
|
1734
|
-
value: searchInput
|
|
1753
|
+
className: "p-2 m-2 border-2 border-blue-400 outline-none neeto-ui-rounded neeto-ui-shadow-lg",
|
|
1754
|
+
value: searchInput,
|
|
1755
|
+
dataCy: `${elementId}-search-box`
|
|
1735
1756
|
}
|
|
1736
1757
|
);
|
|
1737
1758
|
}
|
|
@@ -1757,23 +1778,1318 @@ const findBrowserTimezone = () => {
|
|
|
1757
1778
|
const browserTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1758
1779
|
return getTimezoneObject(browserTimezone);
|
|
1759
1780
|
};
|
|
1760
|
-
const
|
|
1781
|
+
const getDefaultValue = findBrowserTimezone() || allTimezones[0];
|
|
1761
1782
|
const valueToId = (value) => `option-${value.replaceAll(" ", "_").toLowerCase()}`;
|
|
1762
|
-
const createGroupedOptionButton = (group, selectedValue, handleSelect, is24H) => /* @__PURE__ */ y("div", null, group.map((groupItem
|
|
1783
|
+
const createGroupedOptionButton = (group, selectedValue, handleSelect, is24H) => /* @__PURE__ */ y("div", null, group.map((groupItem) => {
|
|
1763
1784
|
const key = Object.keys(groupItem)[0];
|
|
1764
1785
|
const element = groupItem[key];
|
|
1765
|
-
return /* @__PURE__ */ y("div", { className: "flex flex-col px-2 py-1", key:
|
|
1786
|
+
return /* @__PURE__ */ y("div", { className: "flex flex-col px-2 py-1", key: key.toLowerCase() }, /* @__PURE__ */ y("span", { className: "pb-1 font-bold uppercase text-md" }, key), element.map((timezone) => /* @__PURE__ */ y(
|
|
1766
1787
|
Button$1,
|
|
1767
1788
|
{
|
|
1768
1789
|
id: valueToId(timezone.keywords),
|
|
1769
1790
|
onClick: handleSelect,
|
|
1770
1791
|
customClass: `px-2 hover:bg-slate-100 ${selectedValue.keywords === timezone.keywords ? "bg-blue-300" : ""}`,
|
|
1771
|
-
key:
|
|
1772
|
-
timezone
|
|
1773
|
-
is24H
|
|
1792
|
+
key: timezone.label,
|
|
1793
|
+
...{ is24H, timezone }
|
|
1774
1794
|
}
|
|
1775
1795
|
)));
|
|
1776
1796
|
}));
|
|
1797
|
+
function _isPlaceholder(a2) {
|
|
1798
|
+
return a2 != null && typeof a2 === "object" && a2["@@functional/placeholder"] === true;
|
|
1799
|
+
}
|
|
1800
|
+
function _curry1(fn) {
|
|
1801
|
+
return function f1(a2) {
|
|
1802
|
+
if (arguments.length === 0 || _isPlaceholder(a2)) {
|
|
1803
|
+
return f1;
|
|
1804
|
+
} else {
|
|
1805
|
+
return fn.apply(this, arguments);
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
function _curry2(fn) {
|
|
1810
|
+
return function f2(a2, b2) {
|
|
1811
|
+
switch (arguments.length) {
|
|
1812
|
+
case 0:
|
|
1813
|
+
return f2;
|
|
1814
|
+
case 1:
|
|
1815
|
+
return _isPlaceholder(a2) ? f2 : _curry1(function(_b) {
|
|
1816
|
+
return fn(a2, _b);
|
|
1817
|
+
});
|
|
1818
|
+
default:
|
|
1819
|
+
return _isPlaceholder(a2) && _isPlaceholder(b2) ? f2 : _isPlaceholder(a2) ? _curry1(function(_a) {
|
|
1820
|
+
return fn(_a, b2);
|
|
1821
|
+
}) : _isPlaceholder(b2) ? _curry1(function(_b) {
|
|
1822
|
+
return fn(a2, _b);
|
|
1823
|
+
}) : fn(a2, b2);
|
|
1824
|
+
}
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
function _concat(set1, set2) {
|
|
1828
|
+
set1 = set1 || [];
|
|
1829
|
+
set2 = set2 || [];
|
|
1830
|
+
var idx;
|
|
1831
|
+
var len1 = set1.length;
|
|
1832
|
+
var len2 = set2.length;
|
|
1833
|
+
var result = [];
|
|
1834
|
+
idx = 0;
|
|
1835
|
+
while (idx < len1) {
|
|
1836
|
+
result[result.length] = set1[idx];
|
|
1837
|
+
idx += 1;
|
|
1838
|
+
}
|
|
1839
|
+
idx = 0;
|
|
1840
|
+
while (idx < len2) {
|
|
1841
|
+
result[result.length] = set2[idx];
|
|
1842
|
+
idx += 1;
|
|
1843
|
+
}
|
|
1844
|
+
return result;
|
|
1845
|
+
}
|
|
1846
|
+
function _arity(n2, fn) {
|
|
1847
|
+
switch (n2) {
|
|
1848
|
+
case 0:
|
|
1849
|
+
return function() {
|
|
1850
|
+
return fn.apply(this, arguments);
|
|
1851
|
+
};
|
|
1852
|
+
case 1:
|
|
1853
|
+
return function(a0) {
|
|
1854
|
+
return fn.apply(this, arguments);
|
|
1855
|
+
};
|
|
1856
|
+
case 2:
|
|
1857
|
+
return function(a0, a1) {
|
|
1858
|
+
return fn.apply(this, arguments);
|
|
1859
|
+
};
|
|
1860
|
+
case 3:
|
|
1861
|
+
return function(a0, a1, a2) {
|
|
1862
|
+
return fn.apply(this, arguments);
|
|
1863
|
+
};
|
|
1864
|
+
case 4:
|
|
1865
|
+
return function(a0, a1, a2, a3) {
|
|
1866
|
+
return fn.apply(this, arguments);
|
|
1867
|
+
};
|
|
1868
|
+
case 5:
|
|
1869
|
+
return function(a0, a1, a2, a3, a4) {
|
|
1870
|
+
return fn.apply(this, arguments);
|
|
1871
|
+
};
|
|
1872
|
+
case 6:
|
|
1873
|
+
return function(a0, a1, a2, a3, a4, a5) {
|
|
1874
|
+
return fn.apply(this, arguments);
|
|
1875
|
+
};
|
|
1876
|
+
case 7:
|
|
1877
|
+
return function(a0, a1, a2, a3, a4, a5, a6) {
|
|
1878
|
+
return fn.apply(this, arguments);
|
|
1879
|
+
};
|
|
1880
|
+
case 8:
|
|
1881
|
+
return function(a0, a1, a2, a3, a4, a5, a6, a7) {
|
|
1882
|
+
return fn.apply(this, arguments);
|
|
1883
|
+
};
|
|
1884
|
+
case 9:
|
|
1885
|
+
return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
1886
|
+
return fn.apply(this, arguments);
|
|
1887
|
+
};
|
|
1888
|
+
case 10:
|
|
1889
|
+
return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
1890
|
+
return fn.apply(this, arguments);
|
|
1891
|
+
};
|
|
1892
|
+
default:
|
|
1893
|
+
throw new Error("First argument to _arity must be a non-negative integer no greater than ten");
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
function _curryN(length, received, fn) {
|
|
1897
|
+
return function() {
|
|
1898
|
+
var combined = [];
|
|
1899
|
+
var argsIdx = 0;
|
|
1900
|
+
var left = length;
|
|
1901
|
+
var combinedIdx = 0;
|
|
1902
|
+
var hasPlaceholder = false;
|
|
1903
|
+
while (combinedIdx < received.length || argsIdx < arguments.length) {
|
|
1904
|
+
var result;
|
|
1905
|
+
if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) {
|
|
1906
|
+
result = received[combinedIdx];
|
|
1907
|
+
} else {
|
|
1908
|
+
result = arguments[argsIdx];
|
|
1909
|
+
argsIdx += 1;
|
|
1910
|
+
}
|
|
1911
|
+
combined[combinedIdx] = result;
|
|
1912
|
+
if (!_isPlaceholder(result)) {
|
|
1913
|
+
left -= 1;
|
|
1914
|
+
} else {
|
|
1915
|
+
hasPlaceholder = true;
|
|
1916
|
+
}
|
|
1917
|
+
combinedIdx += 1;
|
|
1918
|
+
}
|
|
1919
|
+
return !hasPlaceholder && left <= 0 ? fn.apply(this, combined) : _arity(Math.max(0, left), _curryN(length, combined, fn));
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
var curryN = /* @__PURE__ */ _curry2(function curryN2(length, fn) {
|
|
1923
|
+
if (length === 1) {
|
|
1924
|
+
return _curry1(fn);
|
|
1925
|
+
}
|
|
1926
|
+
return _arity(length, _curryN(length, [], fn));
|
|
1927
|
+
});
|
|
1928
|
+
const curryN$1 = curryN;
|
|
1929
|
+
const _isArray = Array.isArray || function _isArray2(val) {
|
|
1930
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
|
1931
|
+
};
|
|
1932
|
+
function _isTransformer(obj) {
|
|
1933
|
+
return obj != null && typeof obj["@@transducer/step"] === "function";
|
|
1934
|
+
}
|
|
1935
|
+
function _dispatchable(methodNames, transducerCreator, fn) {
|
|
1936
|
+
return function() {
|
|
1937
|
+
if (arguments.length === 0) {
|
|
1938
|
+
return fn();
|
|
1939
|
+
}
|
|
1940
|
+
var obj = arguments[arguments.length - 1];
|
|
1941
|
+
if (!_isArray(obj)) {
|
|
1942
|
+
var idx = 0;
|
|
1943
|
+
while (idx < methodNames.length) {
|
|
1944
|
+
if (typeof obj[methodNames[idx]] === "function") {
|
|
1945
|
+
return obj[methodNames[idx]].apply(obj, Array.prototype.slice.call(arguments, 0, -1));
|
|
1946
|
+
}
|
|
1947
|
+
idx += 1;
|
|
1948
|
+
}
|
|
1949
|
+
if (_isTransformer(obj)) {
|
|
1950
|
+
var transducer = transducerCreator.apply(null, Array.prototype.slice.call(arguments, 0, -1));
|
|
1951
|
+
return transducer(obj);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
return fn.apply(this, arguments);
|
|
1955
|
+
};
|
|
1956
|
+
}
|
|
1957
|
+
const _xfBase = {
|
|
1958
|
+
init: function() {
|
|
1959
|
+
return this.xf["@@transducer/init"]();
|
|
1960
|
+
},
|
|
1961
|
+
result: function(result) {
|
|
1962
|
+
return this.xf["@@transducer/result"](result);
|
|
1963
|
+
}
|
|
1964
|
+
};
|
|
1965
|
+
function _arrayFromIterator(iter) {
|
|
1966
|
+
var list = [];
|
|
1967
|
+
var next;
|
|
1968
|
+
while (!(next = iter.next()).done) {
|
|
1969
|
+
list.push(next.value);
|
|
1970
|
+
}
|
|
1971
|
+
return list;
|
|
1972
|
+
}
|
|
1973
|
+
function _includesWith(pred, x2, list) {
|
|
1974
|
+
var idx = 0;
|
|
1975
|
+
var len = list.length;
|
|
1976
|
+
while (idx < len) {
|
|
1977
|
+
if (pred(x2, list[idx])) {
|
|
1978
|
+
return true;
|
|
1979
|
+
}
|
|
1980
|
+
idx += 1;
|
|
1981
|
+
}
|
|
1982
|
+
return false;
|
|
1983
|
+
}
|
|
1984
|
+
function _functionName(f2) {
|
|
1985
|
+
var match = String(f2).match(/^function (\w*)/);
|
|
1986
|
+
return match == null ? "" : match[1];
|
|
1987
|
+
}
|
|
1988
|
+
function _has(prop, obj) {
|
|
1989
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1990
|
+
}
|
|
1991
|
+
function _objectIs(a2, b2) {
|
|
1992
|
+
if (a2 === b2) {
|
|
1993
|
+
return a2 !== 0 || 1 / a2 === 1 / b2;
|
|
1994
|
+
} else {
|
|
1995
|
+
return a2 !== a2 && b2 !== b2;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
const _objectIs$1 = typeof Object.is === "function" ? Object.is : _objectIs;
|
|
1999
|
+
var toString = Object.prototype.toString;
|
|
2000
|
+
var _isArguments = /* @__PURE__ */ function() {
|
|
2001
|
+
return toString.call(arguments) === "[object Arguments]" ? function _isArguments2(x2) {
|
|
2002
|
+
return toString.call(x2) === "[object Arguments]";
|
|
2003
|
+
} : function _isArguments2(x2) {
|
|
2004
|
+
return _has("callee", x2);
|
|
2005
|
+
};
|
|
2006
|
+
}();
|
|
2007
|
+
const _isArguments$1 = _isArguments;
|
|
2008
|
+
var hasEnumBug = !/* @__PURE__ */ {
|
|
2009
|
+
toString: null
|
|
2010
|
+
}.propertyIsEnumerable("toString");
|
|
2011
|
+
var nonEnumerableProps = ["constructor", "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString"];
|
|
2012
|
+
var hasArgsEnumBug = /* @__PURE__ */ function() {
|
|
2013
|
+
return arguments.propertyIsEnumerable("length");
|
|
2014
|
+
}();
|
|
2015
|
+
var contains = function contains2(list, item) {
|
|
2016
|
+
var idx = 0;
|
|
2017
|
+
while (idx < list.length) {
|
|
2018
|
+
if (list[idx] === item) {
|
|
2019
|
+
return true;
|
|
2020
|
+
}
|
|
2021
|
+
idx += 1;
|
|
2022
|
+
}
|
|
2023
|
+
return false;
|
|
2024
|
+
};
|
|
2025
|
+
var keys = typeof Object.keys === "function" && !hasArgsEnumBug ? /* @__PURE__ */ _curry1(function keys2(obj) {
|
|
2026
|
+
return Object(obj) !== obj ? [] : Object.keys(obj);
|
|
2027
|
+
}) : /* @__PURE__ */ _curry1(function keys3(obj) {
|
|
2028
|
+
if (Object(obj) !== obj) {
|
|
2029
|
+
return [];
|
|
2030
|
+
}
|
|
2031
|
+
var prop, nIdx;
|
|
2032
|
+
var ks = [];
|
|
2033
|
+
var checkArgsLength = hasArgsEnumBug && _isArguments$1(obj);
|
|
2034
|
+
for (prop in obj) {
|
|
2035
|
+
if (_has(prop, obj) && (!checkArgsLength || prop !== "length")) {
|
|
2036
|
+
ks[ks.length] = prop;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
if (hasEnumBug) {
|
|
2040
|
+
nIdx = nonEnumerableProps.length - 1;
|
|
2041
|
+
while (nIdx >= 0) {
|
|
2042
|
+
prop = nonEnumerableProps[nIdx];
|
|
2043
|
+
if (_has(prop, obj) && !contains(ks, prop)) {
|
|
2044
|
+
ks[ks.length] = prop;
|
|
2045
|
+
}
|
|
2046
|
+
nIdx -= 1;
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
return ks;
|
|
2050
|
+
});
|
|
2051
|
+
const keys$1 = keys;
|
|
2052
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
|
2053
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
|
2054
|
+
});
|
|
2055
|
+
const type$1 = type;
|
|
2056
|
+
function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
|
|
2057
|
+
var a2 = _arrayFromIterator(aIterator);
|
|
2058
|
+
var b2 = _arrayFromIterator(bIterator);
|
|
2059
|
+
function eq(_a, _b) {
|
|
2060
|
+
return _equals(_a, _b, stackA.slice(), stackB.slice());
|
|
2061
|
+
}
|
|
2062
|
+
return !_includesWith(function(b3, aItem) {
|
|
2063
|
+
return !_includesWith(eq, aItem, b3);
|
|
2064
|
+
}, b2, a2);
|
|
2065
|
+
}
|
|
2066
|
+
function _equals(a2, b2, stackA, stackB) {
|
|
2067
|
+
if (_objectIs$1(a2, b2)) {
|
|
2068
|
+
return true;
|
|
2069
|
+
}
|
|
2070
|
+
var typeA = type$1(a2);
|
|
2071
|
+
if (typeA !== type$1(b2)) {
|
|
2072
|
+
return false;
|
|
2073
|
+
}
|
|
2074
|
+
if (typeof a2["fantasy-land/equals"] === "function" || typeof b2["fantasy-land/equals"] === "function") {
|
|
2075
|
+
return typeof a2["fantasy-land/equals"] === "function" && a2["fantasy-land/equals"](b2) && typeof b2["fantasy-land/equals"] === "function" && b2["fantasy-land/equals"](a2);
|
|
2076
|
+
}
|
|
2077
|
+
if (typeof a2.equals === "function" || typeof b2.equals === "function") {
|
|
2078
|
+
return typeof a2.equals === "function" && a2.equals(b2) && typeof b2.equals === "function" && b2.equals(a2);
|
|
2079
|
+
}
|
|
2080
|
+
switch (typeA) {
|
|
2081
|
+
case "Arguments":
|
|
2082
|
+
case "Array":
|
|
2083
|
+
case "Object":
|
|
2084
|
+
if (typeof a2.constructor === "function" && _functionName(a2.constructor) === "Promise") {
|
|
2085
|
+
return a2 === b2;
|
|
2086
|
+
}
|
|
2087
|
+
break;
|
|
2088
|
+
case "Boolean":
|
|
2089
|
+
case "Number":
|
|
2090
|
+
case "String":
|
|
2091
|
+
if (!(typeof a2 === typeof b2 && _objectIs$1(a2.valueOf(), b2.valueOf()))) {
|
|
2092
|
+
return false;
|
|
2093
|
+
}
|
|
2094
|
+
break;
|
|
2095
|
+
case "Date":
|
|
2096
|
+
if (!_objectIs$1(a2.valueOf(), b2.valueOf())) {
|
|
2097
|
+
return false;
|
|
2098
|
+
}
|
|
2099
|
+
break;
|
|
2100
|
+
case "Error":
|
|
2101
|
+
return a2.name === b2.name && a2.message === b2.message;
|
|
2102
|
+
case "RegExp":
|
|
2103
|
+
if (!(a2.source === b2.source && a2.global === b2.global && a2.ignoreCase === b2.ignoreCase && a2.multiline === b2.multiline && a2.sticky === b2.sticky && a2.unicode === b2.unicode)) {
|
|
2104
|
+
return false;
|
|
2105
|
+
}
|
|
2106
|
+
break;
|
|
2107
|
+
}
|
|
2108
|
+
var idx = stackA.length - 1;
|
|
2109
|
+
while (idx >= 0) {
|
|
2110
|
+
if (stackA[idx] === a2) {
|
|
2111
|
+
return stackB[idx] === b2;
|
|
2112
|
+
}
|
|
2113
|
+
idx -= 1;
|
|
2114
|
+
}
|
|
2115
|
+
switch (typeA) {
|
|
2116
|
+
case "Map":
|
|
2117
|
+
if (a2.size !== b2.size) {
|
|
2118
|
+
return false;
|
|
2119
|
+
}
|
|
2120
|
+
return _uniqContentEquals(a2.entries(), b2.entries(), stackA.concat([a2]), stackB.concat([b2]));
|
|
2121
|
+
case "Set":
|
|
2122
|
+
if (a2.size !== b2.size) {
|
|
2123
|
+
return false;
|
|
2124
|
+
}
|
|
2125
|
+
return _uniqContentEquals(a2.values(), b2.values(), stackA.concat([a2]), stackB.concat([b2]));
|
|
2126
|
+
case "Arguments":
|
|
2127
|
+
case "Array":
|
|
2128
|
+
case "Object":
|
|
2129
|
+
case "Boolean":
|
|
2130
|
+
case "Number":
|
|
2131
|
+
case "String":
|
|
2132
|
+
case "Date":
|
|
2133
|
+
case "Error":
|
|
2134
|
+
case "RegExp":
|
|
2135
|
+
case "Int8Array":
|
|
2136
|
+
case "Uint8Array":
|
|
2137
|
+
case "Uint8ClampedArray":
|
|
2138
|
+
case "Int16Array":
|
|
2139
|
+
case "Uint16Array":
|
|
2140
|
+
case "Int32Array":
|
|
2141
|
+
case "Uint32Array":
|
|
2142
|
+
case "Float32Array":
|
|
2143
|
+
case "Float64Array":
|
|
2144
|
+
case "ArrayBuffer":
|
|
2145
|
+
break;
|
|
2146
|
+
default:
|
|
2147
|
+
return false;
|
|
2148
|
+
}
|
|
2149
|
+
var keysA = keys$1(a2);
|
|
2150
|
+
if (keysA.length !== keys$1(b2).length) {
|
|
2151
|
+
return false;
|
|
2152
|
+
}
|
|
2153
|
+
var extendedStackA = stackA.concat([a2]);
|
|
2154
|
+
var extendedStackB = stackB.concat([b2]);
|
|
2155
|
+
idx = keysA.length - 1;
|
|
2156
|
+
while (idx >= 0) {
|
|
2157
|
+
var key = keysA[idx];
|
|
2158
|
+
if (!(_has(key, b2) && _equals(b2[key], a2[key], extendedStackA, extendedStackB))) {
|
|
2159
|
+
return false;
|
|
2160
|
+
}
|
|
2161
|
+
idx -= 1;
|
|
2162
|
+
}
|
|
2163
|
+
return true;
|
|
2164
|
+
}
|
|
2165
|
+
var equals = /* @__PURE__ */ _curry2(function equals2(a2, b2) {
|
|
2166
|
+
return _equals(a2, b2, [], []);
|
|
2167
|
+
});
|
|
2168
|
+
const equals$1 = equals;
|
|
2169
|
+
function _map(fn, functor) {
|
|
2170
|
+
var idx = 0;
|
|
2171
|
+
var len = functor.length;
|
|
2172
|
+
var result = Array(len);
|
|
2173
|
+
while (idx < len) {
|
|
2174
|
+
result[idx] = fn(functor[idx]);
|
|
2175
|
+
idx += 1;
|
|
2176
|
+
}
|
|
2177
|
+
return result;
|
|
2178
|
+
}
|
|
2179
|
+
function _arrayReduce(reducer, acc, list) {
|
|
2180
|
+
var index = 0;
|
|
2181
|
+
var length = list.length;
|
|
2182
|
+
while (index < length) {
|
|
2183
|
+
acc = reducer(acc, list[index]);
|
|
2184
|
+
index += 1;
|
|
2185
|
+
}
|
|
2186
|
+
return acc;
|
|
2187
|
+
}
|
|
2188
|
+
function _isObject(x2) {
|
|
2189
|
+
return Object.prototype.toString.call(x2) === "[object Object]";
|
|
2190
|
+
}
|
|
2191
|
+
var XMap = /* @__PURE__ */ function() {
|
|
2192
|
+
function XMap2(f2, xf) {
|
|
2193
|
+
this.xf = xf;
|
|
2194
|
+
this.f = f2;
|
|
2195
|
+
}
|
|
2196
|
+
XMap2.prototype["@@transducer/init"] = _xfBase.init;
|
|
2197
|
+
XMap2.prototype["@@transducer/result"] = _xfBase.result;
|
|
2198
|
+
XMap2.prototype["@@transducer/step"] = function(result, input) {
|
|
2199
|
+
return this.xf["@@transducer/step"](result, this.f(input));
|
|
2200
|
+
};
|
|
2201
|
+
return XMap2;
|
|
2202
|
+
}();
|
|
2203
|
+
var _xmap = function _xmap2(f2) {
|
|
2204
|
+
return function(xf) {
|
|
2205
|
+
return new XMap(f2, xf);
|
|
2206
|
+
};
|
|
2207
|
+
};
|
|
2208
|
+
const _xmap$1 = _xmap;
|
|
2209
|
+
var map = /* @__PURE__ */ _curry2(
|
|
2210
|
+
/* @__PURE__ */ _dispatchable(["fantasy-land/map", "map"], _xmap$1, function map2(fn, functor) {
|
|
2211
|
+
switch (Object.prototype.toString.call(functor)) {
|
|
2212
|
+
case "[object Function]":
|
|
2213
|
+
return curryN$1(functor.length, function() {
|
|
2214
|
+
return fn.call(this, functor.apply(this, arguments));
|
|
2215
|
+
});
|
|
2216
|
+
case "[object Object]":
|
|
2217
|
+
return _arrayReduce(function(acc, key) {
|
|
2218
|
+
acc[key] = fn(functor[key]);
|
|
2219
|
+
return acc;
|
|
2220
|
+
}, {}, keys$1(functor));
|
|
2221
|
+
default:
|
|
2222
|
+
return _map(fn, functor);
|
|
2223
|
+
}
|
|
2224
|
+
})
|
|
2225
|
+
);
|
|
2226
|
+
const map$1 = map;
|
|
2227
|
+
function _isString(x2) {
|
|
2228
|
+
return Object.prototype.toString.call(x2) === "[object String]";
|
|
2229
|
+
}
|
|
2230
|
+
var _isArrayLike = /* @__PURE__ */ _curry1(function isArrayLike(x2) {
|
|
2231
|
+
if (_isArray(x2)) {
|
|
2232
|
+
return true;
|
|
2233
|
+
}
|
|
2234
|
+
if (!x2) {
|
|
2235
|
+
return false;
|
|
2236
|
+
}
|
|
2237
|
+
if (typeof x2 !== "object") {
|
|
2238
|
+
return false;
|
|
2239
|
+
}
|
|
2240
|
+
if (_isString(x2)) {
|
|
2241
|
+
return false;
|
|
2242
|
+
}
|
|
2243
|
+
if (x2.length === 0) {
|
|
2244
|
+
return true;
|
|
2245
|
+
}
|
|
2246
|
+
if (x2.length > 0) {
|
|
2247
|
+
return x2.hasOwnProperty(0) && x2.hasOwnProperty(x2.length - 1);
|
|
2248
|
+
}
|
|
2249
|
+
return false;
|
|
2250
|
+
});
|
|
2251
|
+
const _isArrayLike$1 = _isArrayLike;
|
|
2252
|
+
var symIterator = typeof Symbol !== "undefined" ? Symbol.iterator : "@@iterator";
|
|
2253
|
+
function _createReduce(arrayReduce, methodReduce, iterableReduce) {
|
|
2254
|
+
return function _reduce2(xf, acc, list) {
|
|
2255
|
+
if (_isArrayLike$1(list)) {
|
|
2256
|
+
return arrayReduce(xf, acc, list);
|
|
2257
|
+
}
|
|
2258
|
+
if (list == null) {
|
|
2259
|
+
return acc;
|
|
2260
|
+
}
|
|
2261
|
+
if (typeof list["fantasy-land/reduce"] === "function") {
|
|
2262
|
+
return methodReduce(xf, acc, list, "fantasy-land/reduce");
|
|
2263
|
+
}
|
|
2264
|
+
if (list[symIterator] != null) {
|
|
2265
|
+
return iterableReduce(xf, acc, list[symIterator]());
|
|
2266
|
+
}
|
|
2267
|
+
if (typeof list.next === "function") {
|
|
2268
|
+
return iterableReduce(xf, acc, list);
|
|
2269
|
+
}
|
|
2270
|
+
if (typeof list.reduce === "function") {
|
|
2271
|
+
return methodReduce(xf, acc, list, "reduce");
|
|
2272
|
+
}
|
|
2273
|
+
throw new TypeError("reduce: list must be array or iterable");
|
|
2274
|
+
};
|
|
2275
|
+
}
|
|
2276
|
+
function _iterableReduce(reducer, acc, iter) {
|
|
2277
|
+
var step = iter.next();
|
|
2278
|
+
while (!step.done) {
|
|
2279
|
+
acc = reducer(acc, step.value);
|
|
2280
|
+
step = iter.next();
|
|
2281
|
+
}
|
|
2282
|
+
return acc;
|
|
2283
|
+
}
|
|
2284
|
+
function _methodReduce(reducer, acc, obj, methodName) {
|
|
2285
|
+
return obj[methodName](reducer, acc);
|
|
2286
|
+
}
|
|
2287
|
+
var _reduce = /* @__PURE__ */ _createReduce(_arrayReduce, _methodReduce, _iterableReduce);
|
|
2288
|
+
const _reduce$1 = _reduce;
|
|
2289
|
+
var ap = /* @__PURE__ */ _curry2(function ap2(applyF, applyX) {
|
|
2290
|
+
return typeof applyX["fantasy-land/ap"] === "function" ? applyX["fantasy-land/ap"](applyF) : typeof applyF.ap === "function" ? applyF.ap(applyX) : typeof applyF === "function" ? function(x2) {
|
|
2291
|
+
return applyF(x2)(applyX(x2));
|
|
2292
|
+
} : _reduce$1(function(acc, f2) {
|
|
2293
|
+
return _concat(acc, map$1(f2, applyX));
|
|
2294
|
+
}, [], applyF);
|
|
2295
|
+
});
|
|
2296
|
+
const ap$1 = ap;
|
|
2297
|
+
var isNil = /* @__PURE__ */ _curry1(function isNil2(x2) {
|
|
2298
|
+
return x2 == null;
|
|
2299
|
+
});
|
|
2300
|
+
const isNil$1 = isNil;
|
|
2301
|
+
var liftN = /* @__PURE__ */ _curry2(function liftN2(arity, fn) {
|
|
2302
|
+
var lifted = curryN$1(arity, fn);
|
|
2303
|
+
return curryN$1(arity, function() {
|
|
2304
|
+
return _arrayReduce(ap$1, map$1(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1));
|
|
2305
|
+
});
|
|
2306
|
+
});
|
|
2307
|
+
const liftN$1 = liftN;
|
|
2308
|
+
var lift = /* @__PURE__ */ _curry1(function lift2(fn) {
|
|
2309
|
+
return liftN$1(fn.length, fn);
|
|
2310
|
+
});
|
|
2311
|
+
const lift$1 = lift;
|
|
2312
|
+
var not = /* @__PURE__ */ _curry1(function not2(a2) {
|
|
2313
|
+
return !a2;
|
|
2314
|
+
});
|
|
2315
|
+
const not$1 = not;
|
|
2316
|
+
var complement = /* @__PURE__ */ lift$1(not$1);
|
|
2317
|
+
const complement$1 = complement;
|
|
2318
|
+
var curry = /* @__PURE__ */ _curry1(function curry2(fn) {
|
|
2319
|
+
return curryN$1(fn.length, fn);
|
|
2320
|
+
});
|
|
2321
|
+
const curry$1 = curry;
|
|
2322
|
+
function _isTypedArray(val) {
|
|
2323
|
+
var type3 = Object.prototype.toString.call(val);
|
|
2324
|
+
return type3 === "[object Uint8ClampedArray]" || type3 === "[object Int8Array]" || type3 === "[object Uint8Array]" || type3 === "[object Int16Array]" || type3 === "[object Uint16Array]" || type3 === "[object Int32Array]" || type3 === "[object Uint32Array]" || type3 === "[object Float32Array]" || type3 === "[object Float64Array]" || type3 === "[object BigInt64Array]" || type3 === "[object BigUint64Array]";
|
|
2325
|
+
}
|
|
2326
|
+
var empty = /* @__PURE__ */ _curry1(function empty2(x2) {
|
|
2327
|
+
return x2 != null && typeof x2["fantasy-land/empty"] === "function" ? x2["fantasy-land/empty"]() : x2 != null && x2.constructor != null && typeof x2.constructor["fantasy-land/empty"] === "function" ? x2.constructor["fantasy-land/empty"]() : x2 != null && typeof x2.empty === "function" ? x2.empty() : x2 != null && x2.constructor != null && typeof x2.constructor.empty === "function" ? x2.constructor.empty() : _isArray(x2) ? [] : _isString(x2) ? "" : _isObject(x2) ? {} : _isArguments$1(x2) ? function() {
|
|
2328
|
+
return arguments;
|
|
2329
|
+
}() : _isTypedArray(x2) ? x2.constructor.from("") : void 0;
|
|
2330
|
+
});
|
|
2331
|
+
const empty$1 = empty;
|
|
2332
|
+
var isEmpty = /* @__PURE__ */ _curry1(function isEmpty2(x2) {
|
|
2333
|
+
return x2 != null && equals$1(x2, empty$1(x2));
|
|
2334
|
+
});
|
|
2335
|
+
const isEmpty$1 = isEmpty;
|
|
2336
|
+
function _arrayWithHoles(arr) {
|
|
2337
|
+
if (Array.isArray(arr))
|
|
2338
|
+
return arr;
|
|
2339
|
+
}
|
|
2340
|
+
function _iterableToArrayLimit(arr, i2) {
|
|
2341
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2342
|
+
if (null != _i) {
|
|
2343
|
+
var _s, _e, _x, _r, _arr = [], _n = true, _d = false;
|
|
2344
|
+
try {
|
|
2345
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i2) {
|
|
2346
|
+
if (Object(_i) !== _i)
|
|
2347
|
+
return;
|
|
2348
|
+
_n = false;
|
|
2349
|
+
} else
|
|
2350
|
+
for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i2); _n = true)
|
|
2351
|
+
;
|
|
2352
|
+
} catch (err) {
|
|
2353
|
+
_d = true, _e = err;
|
|
2354
|
+
} finally {
|
|
2355
|
+
try {
|
|
2356
|
+
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r))
|
|
2357
|
+
return;
|
|
2358
|
+
} finally {
|
|
2359
|
+
if (_d)
|
|
2360
|
+
throw _e;
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
return _arr;
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
function _arrayLikeToArray(arr, len) {
|
|
2367
|
+
if (len == null || len > arr.length)
|
|
2368
|
+
len = arr.length;
|
|
2369
|
+
for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++)
|
|
2370
|
+
arr2[i2] = arr[i2];
|
|
2371
|
+
return arr2;
|
|
2372
|
+
}
|
|
2373
|
+
function _unsupportedIterableToArray(o2, minLen) {
|
|
2374
|
+
if (!o2)
|
|
2375
|
+
return;
|
|
2376
|
+
if (typeof o2 === "string")
|
|
2377
|
+
return _arrayLikeToArray(o2, minLen);
|
|
2378
|
+
var n2 = Object.prototype.toString.call(o2).slice(8, -1);
|
|
2379
|
+
if (n2 === "Object" && o2.constructor)
|
|
2380
|
+
n2 = o2.constructor.name;
|
|
2381
|
+
if (n2 === "Map" || n2 === "Set")
|
|
2382
|
+
return Array.from(o2);
|
|
2383
|
+
if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2))
|
|
2384
|
+
return _arrayLikeToArray(o2, minLen);
|
|
2385
|
+
}
|
|
2386
|
+
function _nonIterableRest() {
|
|
2387
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2388
|
+
}
|
|
2389
|
+
function _slicedToArray(arr, i2) {
|
|
2390
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i2) || _unsupportedIterableToArray(arr, i2) || _nonIterableRest();
|
|
2391
|
+
}
|
|
2392
|
+
function _typeof(obj) {
|
|
2393
|
+
"@babel/helpers - typeof";
|
|
2394
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
2395
|
+
return typeof obj2;
|
|
2396
|
+
} : function(obj2) {
|
|
2397
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
2398
|
+
}, _typeof(obj);
|
|
2399
|
+
}
|
|
2400
|
+
var NOTHING = Symbol.for("immer-nothing");
|
|
2401
|
+
var DRAFTABLE = Symbol.for("immer-draftable");
|
|
2402
|
+
var DRAFT_STATE = Symbol.for("immer-state");
|
|
2403
|
+
var errors = process.env.NODE_ENV !== "production" ? [
|
|
2404
|
+
// All error codes, starting by 0:
|
|
2405
|
+
function(plugin) {
|
|
2406
|
+
return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
|
|
2407
|
+
},
|
|
2408
|
+
function(thing) {
|
|
2409
|
+
return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
|
|
2410
|
+
},
|
|
2411
|
+
"This object has been frozen and should not be mutated",
|
|
2412
|
+
function(data) {
|
|
2413
|
+
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
|
|
2414
|
+
},
|
|
2415
|
+
"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
|
|
2416
|
+
"Immer forbids circular references",
|
|
2417
|
+
"The first or second argument to `produce` must be a function",
|
|
2418
|
+
"The third argument to `produce` must be a function or undefined",
|
|
2419
|
+
"First argument to `createDraft` must be a plain object, an array, or an immerable object",
|
|
2420
|
+
"First argument to `finishDraft` must be a draft returned by `createDraft`",
|
|
2421
|
+
function(thing) {
|
|
2422
|
+
return `'current' expects a draft, got: ${thing}`;
|
|
2423
|
+
},
|
|
2424
|
+
"Object.defineProperty() cannot be used on an Immer draft",
|
|
2425
|
+
"Object.setPrototypeOf() cannot be used on an Immer draft",
|
|
2426
|
+
"Immer only supports deleting array indices",
|
|
2427
|
+
"Immer only supports setting array indices and the 'length' property",
|
|
2428
|
+
function(thing) {
|
|
2429
|
+
return `'original' expects a draft, got: ${thing}`;
|
|
2430
|
+
}
|
|
2431
|
+
// Note: if more errors are added, the errorOffset in Patches.ts should be increased
|
|
2432
|
+
// See Patches.ts for additional errors
|
|
2433
|
+
] : [];
|
|
2434
|
+
function die(error, ...args) {
|
|
2435
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2436
|
+
const e2 = errors[error];
|
|
2437
|
+
const msg = typeof e2 === "function" ? e2.apply(null, args) : e2;
|
|
2438
|
+
throw new Error(`[Immer] ${msg}`);
|
|
2439
|
+
}
|
|
2440
|
+
throw new Error(
|
|
2441
|
+
`[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
|
|
2442
|
+
);
|
|
2443
|
+
}
|
|
2444
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
|
2445
|
+
function isDraft(value) {
|
|
2446
|
+
return !!value && !!value[DRAFT_STATE];
|
|
2447
|
+
}
|
|
2448
|
+
function isDraftable(value) {
|
|
2449
|
+
var _a;
|
|
2450
|
+
if (!value)
|
|
2451
|
+
return false;
|
|
2452
|
+
return isPlainObject(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!((_a = value.constructor) == null ? void 0 : _a[DRAFTABLE]) || isMap(value) || isSet(value);
|
|
2453
|
+
}
|
|
2454
|
+
var objectCtorString = Object.prototype.constructor.toString();
|
|
2455
|
+
function isPlainObject(value) {
|
|
2456
|
+
if (!value || typeof value !== "object")
|
|
2457
|
+
return false;
|
|
2458
|
+
const proto = getPrototypeOf(value);
|
|
2459
|
+
if (proto === null) {
|
|
2460
|
+
return true;
|
|
2461
|
+
}
|
|
2462
|
+
const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
2463
|
+
if (Ctor === Object)
|
|
2464
|
+
return true;
|
|
2465
|
+
return typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString;
|
|
2466
|
+
}
|
|
2467
|
+
function each(obj, iter) {
|
|
2468
|
+
if (getArchtype(obj) === 0) {
|
|
2469
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
2470
|
+
iter(key, value, obj);
|
|
2471
|
+
});
|
|
2472
|
+
} else {
|
|
2473
|
+
obj.forEach((entry, index) => iter(index, entry, obj));
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
function getArchtype(thing) {
|
|
2477
|
+
const state = thing[DRAFT_STATE];
|
|
2478
|
+
return state ? state.type_ : Array.isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
|
|
2479
|
+
}
|
|
2480
|
+
function has(thing, prop) {
|
|
2481
|
+
return getArchtype(thing) === 2 ? thing.has(prop) : Object.prototype.hasOwnProperty.call(thing, prop);
|
|
2482
|
+
}
|
|
2483
|
+
function set(thing, propOrOldValue, value) {
|
|
2484
|
+
const t2 = getArchtype(thing);
|
|
2485
|
+
if (t2 === 2)
|
|
2486
|
+
thing.set(propOrOldValue, value);
|
|
2487
|
+
else if (t2 === 3) {
|
|
2488
|
+
thing.add(value);
|
|
2489
|
+
} else
|
|
2490
|
+
thing[propOrOldValue] = value;
|
|
2491
|
+
}
|
|
2492
|
+
function is(x2, y2) {
|
|
2493
|
+
if (x2 === y2) {
|
|
2494
|
+
return x2 !== 0 || 1 / x2 === 1 / y2;
|
|
2495
|
+
} else {
|
|
2496
|
+
return x2 !== x2 && y2 !== y2;
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
function isMap(target) {
|
|
2500
|
+
return target instanceof Map;
|
|
2501
|
+
}
|
|
2502
|
+
function isSet(target) {
|
|
2503
|
+
return target instanceof Set;
|
|
2504
|
+
}
|
|
2505
|
+
function latest(state) {
|
|
2506
|
+
return state.copy_ || state.base_;
|
|
2507
|
+
}
|
|
2508
|
+
function shallowCopy(base, strict) {
|
|
2509
|
+
if (isMap(base)) {
|
|
2510
|
+
return new Map(base);
|
|
2511
|
+
}
|
|
2512
|
+
if (isSet(base)) {
|
|
2513
|
+
return new Set(base);
|
|
2514
|
+
}
|
|
2515
|
+
if (Array.isArray(base))
|
|
2516
|
+
return Array.prototype.slice.call(base);
|
|
2517
|
+
if (!strict && isPlainObject(base)) {
|
|
2518
|
+
if (!getPrototypeOf(base)) {
|
|
2519
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
2520
|
+
return Object.assign(obj, base);
|
|
2521
|
+
}
|
|
2522
|
+
return { ...base };
|
|
2523
|
+
}
|
|
2524
|
+
const descriptors = Object.getOwnPropertyDescriptors(base);
|
|
2525
|
+
delete descriptors[DRAFT_STATE];
|
|
2526
|
+
let keys4 = Reflect.ownKeys(descriptors);
|
|
2527
|
+
for (let i2 = 0; i2 < keys4.length; i2++) {
|
|
2528
|
+
const key = keys4[i2];
|
|
2529
|
+
const desc = descriptors[key];
|
|
2530
|
+
if (desc.writable === false) {
|
|
2531
|
+
desc.writable = true;
|
|
2532
|
+
desc.configurable = true;
|
|
2533
|
+
}
|
|
2534
|
+
if (desc.get || desc.set)
|
|
2535
|
+
descriptors[key] = {
|
|
2536
|
+
configurable: true,
|
|
2537
|
+
writable: true,
|
|
2538
|
+
// could live with !!desc.set as well here...
|
|
2539
|
+
enumerable: desc.enumerable,
|
|
2540
|
+
value: base[key]
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
return Object.create(getPrototypeOf(base), descriptors);
|
|
2544
|
+
}
|
|
2545
|
+
function freeze(obj, deep = false) {
|
|
2546
|
+
if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
|
|
2547
|
+
return obj;
|
|
2548
|
+
if (getArchtype(obj) > 1) {
|
|
2549
|
+
obj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections;
|
|
2550
|
+
}
|
|
2551
|
+
Object.freeze(obj);
|
|
2552
|
+
if (deep)
|
|
2553
|
+
each(obj, (_key, value) => freeze(value, true));
|
|
2554
|
+
return obj;
|
|
2555
|
+
}
|
|
2556
|
+
function dontMutateFrozenCollections() {
|
|
2557
|
+
die(2);
|
|
2558
|
+
}
|
|
2559
|
+
function isFrozen(obj) {
|
|
2560
|
+
return Object.isFrozen(obj);
|
|
2561
|
+
}
|
|
2562
|
+
var plugins = {};
|
|
2563
|
+
function getPlugin(pluginKey) {
|
|
2564
|
+
const plugin = plugins[pluginKey];
|
|
2565
|
+
if (!plugin) {
|
|
2566
|
+
die(0, pluginKey);
|
|
2567
|
+
}
|
|
2568
|
+
return plugin;
|
|
2569
|
+
}
|
|
2570
|
+
var currentScope;
|
|
2571
|
+
function getCurrentScope() {
|
|
2572
|
+
return currentScope;
|
|
2573
|
+
}
|
|
2574
|
+
function createScope(parent_, immer_) {
|
|
2575
|
+
return {
|
|
2576
|
+
drafts_: [],
|
|
2577
|
+
parent_,
|
|
2578
|
+
immer_,
|
|
2579
|
+
// Whenever the modified draft contains a draft from another scope, we
|
|
2580
|
+
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
2581
|
+
canAutoFreeze_: true,
|
|
2582
|
+
unfinalizedDrafts_: 0
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
function usePatchesInScope(scope, patchListener) {
|
|
2586
|
+
if (patchListener) {
|
|
2587
|
+
getPlugin("Patches");
|
|
2588
|
+
scope.patches_ = [];
|
|
2589
|
+
scope.inversePatches_ = [];
|
|
2590
|
+
scope.patchListener_ = patchListener;
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
function revokeScope(scope) {
|
|
2594
|
+
leaveScope(scope);
|
|
2595
|
+
scope.drafts_.forEach(revokeDraft);
|
|
2596
|
+
scope.drafts_ = null;
|
|
2597
|
+
}
|
|
2598
|
+
function leaveScope(scope) {
|
|
2599
|
+
if (scope === currentScope) {
|
|
2600
|
+
currentScope = scope.parent_;
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
function enterScope(immer2) {
|
|
2604
|
+
return currentScope = createScope(currentScope, immer2);
|
|
2605
|
+
}
|
|
2606
|
+
function revokeDraft(draft) {
|
|
2607
|
+
const state = draft[DRAFT_STATE];
|
|
2608
|
+
if (state.type_ === 0 || state.type_ === 1)
|
|
2609
|
+
state.revoke_();
|
|
2610
|
+
else
|
|
2611
|
+
state.revoked_ = true;
|
|
2612
|
+
}
|
|
2613
|
+
function processResult(result, scope) {
|
|
2614
|
+
scope.unfinalizedDrafts_ = scope.drafts_.length;
|
|
2615
|
+
const baseDraft = scope.drafts_[0];
|
|
2616
|
+
const isReplaced = result !== void 0 && result !== baseDraft;
|
|
2617
|
+
if (isReplaced) {
|
|
2618
|
+
if (baseDraft[DRAFT_STATE].modified_) {
|
|
2619
|
+
revokeScope(scope);
|
|
2620
|
+
die(4);
|
|
2621
|
+
}
|
|
2622
|
+
if (isDraftable(result)) {
|
|
2623
|
+
result = finalize(scope, result);
|
|
2624
|
+
if (!scope.parent_)
|
|
2625
|
+
maybeFreeze(scope, result);
|
|
2626
|
+
}
|
|
2627
|
+
if (scope.patches_) {
|
|
2628
|
+
getPlugin("Patches").generateReplacementPatches_(
|
|
2629
|
+
baseDraft[DRAFT_STATE].base_,
|
|
2630
|
+
result,
|
|
2631
|
+
scope.patches_,
|
|
2632
|
+
scope.inversePatches_
|
|
2633
|
+
);
|
|
2634
|
+
}
|
|
2635
|
+
} else {
|
|
2636
|
+
result = finalize(scope, baseDraft, []);
|
|
2637
|
+
}
|
|
2638
|
+
revokeScope(scope);
|
|
2639
|
+
if (scope.patches_) {
|
|
2640
|
+
scope.patchListener_(scope.patches_, scope.inversePatches_);
|
|
2641
|
+
}
|
|
2642
|
+
return result !== NOTHING ? result : void 0;
|
|
2643
|
+
}
|
|
2644
|
+
function finalize(rootScope, value, path) {
|
|
2645
|
+
if (isFrozen(value))
|
|
2646
|
+
return value;
|
|
2647
|
+
const state = value[DRAFT_STATE];
|
|
2648
|
+
if (!state) {
|
|
2649
|
+
each(
|
|
2650
|
+
value,
|
|
2651
|
+
(key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path)
|
|
2652
|
+
);
|
|
2653
|
+
return value;
|
|
2654
|
+
}
|
|
2655
|
+
if (state.scope_ !== rootScope)
|
|
2656
|
+
return value;
|
|
2657
|
+
if (!state.modified_) {
|
|
2658
|
+
maybeFreeze(rootScope, state.base_, true);
|
|
2659
|
+
return state.base_;
|
|
2660
|
+
}
|
|
2661
|
+
if (!state.finalized_) {
|
|
2662
|
+
state.finalized_ = true;
|
|
2663
|
+
state.scope_.unfinalizedDrafts_--;
|
|
2664
|
+
const result = state.copy_;
|
|
2665
|
+
let resultEach = result;
|
|
2666
|
+
let isSet2 = false;
|
|
2667
|
+
if (state.type_ === 3) {
|
|
2668
|
+
resultEach = new Set(result);
|
|
2669
|
+
result.clear();
|
|
2670
|
+
isSet2 = true;
|
|
2671
|
+
}
|
|
2672
|
+
each(
|
|
2673
|
+
resultEach,
|
|
2674
|
+
(key, childValue) => finalizeProperty(rootScope, state, result, key, childValue, path, isSet2)
|
|
2675
|
+
);
|
|
2676
|
+
maybeFreeze(rootScope, result, false);
|
|
2677
|
+
if (path && rootScope.patches_) {
|
|
2678
|
+
getPlugin("Patches").generatePatches_(
|
|
2679
|
+
state,
|
|
2680
|
+
path,
|
|
2681
|
+
rootScope.patches_,
|
|
2682
|
+
rootScope.inversePatches_
|
|
2683
|
+
);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
return state.copy_;
|
|
2687
|
+
}
|
|
2688
|
+
function finalizeProperty(rootScope, parentState, targetObject, prop, childValue, rootPath, targetIsSet) {
|
|
2689
|
+
if (process.env.NODE_ENV !== "production" && childValue === targetObject)
|
|
2690
|
+
die(5);
|
|
2691
|
+
if (isDraft(childValue)) {
|
|
2692
|
+
const path = rootPath && parentState && parentState.type_ !== 3 && // Set objects are atomic since they have no keys.
|
|
2693
|
+
!has(parentState.assigned_, prop) ? rootPath.concat(prop) : void 0;
|
|
2694
|
+
const res = finalize(rootScope, childValue, path);
|
|
2695
|
+
set(targetObject, prop, res);
|
|
2696
|
+
if (isDraft(res)) {
|
|
2697
|
+
rootScope.canAutoFreeze_ = false;
|
|
2698
|
+
} else
|
|
2699
|
+
return;
|
|
2700
|
+
} else if (targetIsSet) {
|
|
2701
|
+
targetObject.add(childValue);
|
|
2702
|
+
}
|
|
2703
|
+
if (isDraftable(childValue) && !isFrozen(childValue)) {
|
|
2704
|
+
if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
finalize(rootScope, childValue);
|
|
2708
|
+
if (!parentState || !parentState.scope_.parent_)
|
|
2709
|
+
maybeFreeze(rootScope, childValue);
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
function maybeFreeze(scope, value, deep = false) {
|
|
2713
|
+
if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
|
|
2714
|
+
freeze(value, deep);
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
function createProxyProxy(base, parent) {
|
|
2718
|
+
const isArray = Array.isArray(base);
|
|
2719
|
+
const state = {
|
|
2720
|
+
type_: isArray ? 1 : 0,
|
|
2721
|
+
// Track which produce call this is associated with.
|
|
2722
|
+
scope_: parent ? parent.scope_ : getCurrentScope(),
|
|
2723
|
+
// True for both shallow and deep changes.
|
|
2724
|
+
modified_: false,
|
|
2725
|
+
// Used during finalization.
|
|
2726
|
+
finalized_: false,
|
|
2727
|
+
// Track which properties have been assigned (true) or deleted (false).
|
|
2728
|
+
assigned_: {},
|
|
2729
|
+
// The parent draft state.
|
|
2730
|
+
parent_: parent,
|
|
2731
|
+
// The base state.
|
|
2732
|
+
base_: base,
|
|
2733
|
+
// The base proxy.
|
|
2734
|
+
draft_: null,
|
|
2735
|
+
// set below
|
|
2736
|
+
// The base copy with any updated values.
|
|
2737
|
+
copy_: null,
|
|
2738
|
+
// Called by the `produce` function.
|
|
2739
|
+
revoke_: null,
|
|
2740
|
+
isManual_: false
|
|
2741
|
+
};
|
|
2742
|
+
let target = state;
|
|
2743
|
+
let traps = objectTraps;
|
|
2744
|
+
if (isArray) {
|
|
2745
|
+
target = [state];
|
|
2746
|
+
traps = arrayTraps;
|
|
2747
|
+
}
|
|
2748
|
+
const { revoke, proxy } = Proxy.revocable(target, traps);
|
|
2749
|
+
state.draft_ = proxy;
|
|
2750
|
+
state.revoke_ = revoke;
|
|
2751
|
+
return proxy;
|
|
2752
|
+
}
|
|
2753
|
+
var objectTraps = {
|
|
2754
|
+
get(state, prop) {
|
|
2755
|
+
if (prop === DRAFT_STATE)
|
|
2756
|
+
return state;
|
|
2757
|
+
const source = latest(state);
|
|
2758
|
+
if (!has(source, prop)) {
|
|
2759
|
+
return readPropFromProto(state, source, prop);
|
|
2760
|
+
}
|
|
2761
|
+
const value = source[prop];
|
|
2762
|
+
if (state.finalized_ || !isDraftable(value)) {
|
|
2763
|
+
return value;
|
|
2764
|
+
}
|
|
2765
|
+
if (value === peek(state.base_, prop)) {
|
|
2766
|
+
prepareCopy(state);
|
|
2767
|
+
return state.copy_[prop] = createProxy(value, state);
|
|
2768
|
+
}
|
|
2769
|
+
return value;
|
|
2770
|
+
},
|
|
2771
|
+
has(state, prop) {
|
|
2772
|
+
return prop in latest(state);
|
|
2773
|
+
},
|
|
2774
|
+
ownKeys(state) {
|
|
2775
|
+
return Reflect.ownKeys(latest(state));
|
|
2776
|
+
},
|
|
2777
|
+
set(state, prop, value) {
|
|
2778
|
+
const desc = getDescriptorFromProto(latest(state), prop);
|
|
2779
|
+
if (desc == null ? void 0 : desc.set) {
|
|
2780
|
+
desc.set.call(state.draft_, value);
|
|
2781
|
+
return true;
|
|
2782
|
+
}
|
|
2783
|
+
if (!state.modified_) {
|
|
2784
|
+
const current2 = peek(latest(state), prop);
|
|
2785
|
+
const currentState = current2 == null ? void 0 : current2[DRAFT_STATE];
|
|
2786
|
+
if (currentState && currentState.base_ === value) {
|
|
2787
|
+
state.copy_[prop] = value;
|
|
2788
|
+
state.assigned_[prop] = false;
|
|
2789
|
+
return true;
|
|
2790
|
+
}
|
|
2791
|
+
if (is(value, current2) && (value !== void 0 || has(state.base_, prop)))
|
|
2792
|
+
return true;
|
|
2793
|
+
prepareCopy(state);
|
|
2794
|
+
markChanged(state);
|
|
2795
|
+
}
|
|
2796
|
+
if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
|
|
2797
|
+
(value !== void 0 || prop in state.copy_) || // special case: NaN
|
|
2798
|
+
Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
|
|
2799
|
+
return true;
|
|
2800
|
+
state.copy_[prop] = value;
|
|
2801
|
+
state.assigned_[prop] = true;
|
|
2802
|
+
return true;
|
|
2803
|
+
},
|
|
2804
|
+
deleteProperty(state, prop) {
|
|
2805
|
+
if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
|
|
2806
|
+
state.assigned_[prop] = false;
|
|
2807
|
+
prepareCopy(state);
|
|
2808
|
+
markChanged(state);
|
|
2809
|
+
} else {
|
|
2810
|
+
delete state.assigned_[prop];
|
|
2811
|
+
}
|
|
2812
|
+
if (state.copy_) {
|
|
2813
|
+
delete state.copy_[prop];
|
|
2814
|
+
}
|
|
2815
|
+
return true;
|
|
2816
|
+
},
|
|
2817
|
+
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
2818
|
+
// the same guarantee in ES5 mode.
|
|
2819
|
+
getOwnPropertyDescriptor(state, prop) {
|
|
2820
|
+
const owner = latest(state);
|
|
2821
|
+
const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
2822
|
+
if (!desc)
|
|
2823
|
+
return desc;
|
|
2824
|
+
return {
|
|
2825
|
+
writable: true,
|
|
2826
|
+
configurable: state.type_ !== 1 || prop !== "length",
|
|
2827
|
+
enumerable: desc.enumerable,
|
|
2828
|
+
value: owner[prop]
|
|
2829
|
+
};
|
|
2830
|
+
},
|
|
2831
|
+
defineProperty() {
|
|
2832
|
+
die(11);
|
|
2833
|
+
},
|
|
2834
|
+
getPrototypeOf(state) {
|
|
2835
|
+
return getPrototypeOf(state.base_);
|
|
2836
|
+
},
|
|
2837
|
+
setPrototypeOf() {
|
|
2838
|
+
die(12);
|
|
2839
|
+
}
|
|
2840
|
+
};
|
|
2841
|
+
var arrayTraps = {};
|
|
2842
|
+
each(objectTraps, (key, fn) => {
|
|
2843
|
+
arrayTraps[key] = function() {
|
|
2844
|
+
arguments[0] = arguments[0][0];
|
|
2845
|
+
return fn.apply(this, arguments);
|
|
2846
|
+
};
|
|
2847
|
+
});
|
|
2848
|
+
arrayTraps.deleteProperty = function(state, prop) {
|
|
2849
|
+
if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
|
|
2850
|
+
die(13);
|
|
2851
|
+
return arrayTraps.set.call(this, state, prop, void 0);
|
|
2852
|
+
};
|
|
2853
|
+
arrayTraps.set = function(state, prop, value) {
|
|
2854
|
+
if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
|
|
2855
|
+
die(14);
|
|
2856
|
+
return objectTraps.set.call(this, state[0], prop, value, state[0]);
|
|
2857
|
+
};
|
|
2858
|
+
function peek(draft, prop) {
|
|
2859
|
+
const state = draft[DRAFT_STATE];
|
|
2860
|
+
const source = state ? latest(state) : draft;
|
|
2861
|
+
return source[prop];
|
|
2862
|
+
}
|
|
2863
|
+
function readPropFromProto(state, source, prop) {
|
|
2864
|
+
var _a;
|
|
2865
|
+
const desc = getDescriptorFromProto(source, prop);
|
|
2866
|
+
return desc ? `value` in desc ? desc.value : (
|
|
2867
|
+
// This is a very special case, if the prop is a getter defined by the
|
|
2868
|
+
// prototype, we should invoke it with the draft as context!
|
|
2869
|
+
(_a = desc.get) == null ? void 0 : _a.call(state.draft_)
|
|
2870
|
+
) : void 0;
|
|
2871
|
+
}
|
|
2872
|
+
function getDescriptorFromProto(source, prop) {
|
|
2873
|
+
if (!(prop in source))
|
|
2874
|
+
return void 0;
|
|
2875
|
+
let proto = getPrototypeOf(source);
|
|
2876
|
+
while (proto) {
|
|
2877
|
+
const desc = Object.getOwnPropertyDescriptor(proto, prop);
|
|
2878
|
+
if (desc)
|
|
2879
|
+
return desc;
|
|
2880
|
+
proto = getPrototypeOf(proto);
|
|
2881
|
+
}
|
|
2882
|
+
return void 0;
|
|
2883
|
+
}
|
|
2884
|
+
function markChanged(state) {
|
|
2885
|
+
if (!state.modified_) {
|
|
2886
|
+
state.modified_ = true;
|
|
2887
|
+
if (state.parent_) {
|
|
2888
|
+
markChanged(state.parent_);
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
function prepareCopy(state) {
|
|
2893
|
+
if (!state.copy_) {
|
|
2894
|
+
state.copy_ = shallowCopy(
|
|
2895
|
+
state.base_,
|
|
2896
|
+
state.scope_.immer_.useStrictShallowCopy_
|
|
2897
|
+
);
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
var Immer2 = class {
|
|
2901
|
+
constructor(config) {
|
|
2902
|
+
this.autoFreeze_ = true;
|
|
2903
|
+
this.useStrictShallowCopy_ = false;
|
|
2904
|
+
this.produce = (base, recipe, patchListener) => {
|
|
2905
|
+
if (typeof base === "function" && typeof recipe !== "function") {
|
|
2906
|
+
const defaultBase = recipe;
|
|
2907
|
+
recipe = base;
|
|
2908
|
+
const self = this;
|
|
2909
|
+
return function curriedProduce(base2 = defaultBase, ...args) {
|
|
2910
|
+
return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
|
|
2911
|
+
};
|
|
2912
|
+
}
|
|
2913
|
+
if (typeof recipe !== "function")
|
|
2914
|
+
die(6);
|
|
2915
|
+
if (patchListener !== void 0 && typeof patchListener !== "function")
|
|
2916
|
+
die(7);
|
|
2917
|
+
let result;
|
|
2918
|
+
if (isDraftable(base)) {
|
|
2919
|
+
const scope = enterScope(this);
|
|
2920
|
+
const proxy = createProxy(base, void 0);
|
|
2921
|
+
let hasError = true;
|
|
2922
|
+
try {
|
|
2923
|
+
result = recipe(proxy);
|
|
2924
|
+
hasError = false;
|
|
2925
|
+
} finally {
|
|
2926
|
+
if (hasError)
|
|
2927
|
+
revokeScope(scope);
|
|
2928
|
+
else
|
|
2929
|
+
leaveScope(scope);
|
|
2930
|
+
}
|
|
2931
|
+
usePatchesInScope(scope, patchListener);
|
|
2932
|
+
return processResult(result, scope);
|
|
2933
|
+
} else if (!base || typeof base !== "object") {
|
|
2934
|
+
result = recipe(base);
|
|
2935
|
+
if (result === void 0)
|
|
2936
|
+
result = base;
|
|
2937
|
+
if (result === NOTHING)
|
|
2938
|
+
result = void 0;
|
|
2939
|
+
if (this.autoFreeze_)
|
|
2940
|
+
freeze(result, true);
|
|
2941
|
+
if (patchListener) {
|
|
2942
|
+
const p2 = [];
|
|
2943
|
+
const ip = [];
|
|
2944
|
+
getPlugin("Patches").generateReplacementPatches_(base, result, p2, ip);
|
|
2945
|
+
patchListener(p2, ip);
|
|
2946
|
+
}
|
|
2947
|
+
return result;
|
|
2948
|
+
} else
|
|
2949
|
+
die(1, base);
|
|
2950
|
+
};
|
|
2951
|
+
this.produceWithPatches = (base, recipe) => {
|
|
2952
|
+
if (typeof base === "function") {
|
|
2953
|
+
return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
|
|
2954
|
+
}
|
|
2955
|
+
let patches, inversePatches;
|
|
2956
|
+
const result = this.produce(base, recipe, (p2, ip) => {
|
|
2957
|
+
patches = p2;
|
|
2958
|
+
inversePatches = ip;
|
|
2959
|
+
});
|
|
2960
|
+
return [result, patches, inversePatches];
|
|
2961
|
+
};
|
|
2962
|
+
if (typeof (config == null ? void 0 : config.autoFreeze) === "boolean")
|
|
2963
|
+
this.setAutoFreeze(config.autoFreeze);
|
|
2964
|
+
if (typeof (config == null ? void 0 : config.useStrictShallowCopy) === "boolean")
|
|
2965
|
+
this.setUseStrictShallowCopy(config.useStrictShallowCopy);
|
|
2966
|
+
}
|
|
2967
|
+
createDraft(base) {
|
|
2968
|
+
if (!isDraftable(base))
|
|
2969
|
+
die(8);
|
|
2970
|
+
if (isDraft(base))
|
|
2971
|
+
base = current(base);
|
|
2972
|
+
const scope = enterScope(this);
|
|
2973
|
+
const proxy = createProxy(base, void 0);
|
|
2974
|
+
proxy[DRAFT_STATE].isManual_ = true;
|
|
2975
|
+
leaveScope(scope);
|
|
2976
|
+
return proxy;
|
|
2977
|
+
}
|
|
2978
|
+
finishDraft(draft, patchListener) {
|
|
2979
|
+
const state = draft && draft[DRAFT_STATE];
|
|
2980
|
+
if (!state || !state.isManual_)
|
|
2981
|
+
die(9);
|
|
2982
|
+
const { scope_: scope } = state;
|
|
2983
|
+
usePatchesInScope(scope, patchListener);
|
|
2984
|
+
return processResult(void 0, scope);
|
|
2985
|
+
}
|
|
2986
|
+
/**
|
|
2987
|
+
* Pass true to automatically freeze all copies created by Immer.
|
|
2988
|
+
*
|
|
2989
|
+
* By default, auto-freezing is enabled.
|
|
2990
|
+
*/
|
|
2991
|
+
setAutoFreeze(value) {
|
|
2992
|
+
this.autoFreeze_ = value;
|
|
2993
|
+
}
|
|
2994
|
+
/**
|
|
2995
|
+
* Pass true to enable strict shallow copy.
|
|
2996
|
+
*
|
|
2997
|
+
* By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
|
|
2998
|
+
*/
|
|
2999
|
+
setUseStrictShallowCopy(value) {
|
|
3000
|
+
this.useStrictShallowCopy_ = value;
|
|
3001
|
+
}
|
|
3002
|
+
applyPatches(base, patches) {
|
|
3003
|
+
let i2;
|
|
3004
|
+
for (i2 = patches.length - 1; i2 >= 0; i2--) {
|
|
3005
|
+
const patch = patches[i2];
|
|
3006
|
+
if (patch.path.length === 0 && patch.op === "replace") {
|
|
3007
|
+
base = patch.value;
|
|
3008
|
+
break;
|
|
3009
|
+
}
|
|
3010
|
+
}
|
|
3011
|
+
if (i2 > -1) {
|
|
3012
|
+
patches = patches.slice(i2 + 1);
|
|
3013
|
+
}
|
|
3014
|
+
const applyPatchesImpl = getPlugin("Patches").applyPatches_;
|
|
3015
|
+
if (isDraft(base)) {
|
|
3016
|
+
return applyPatchesImpl(base, patches);
|
|
3017
|
+
}
|
|
3018
|
+
return this.produce(
|
|
3019
|
+
base,
|
|
3020
|
+
(draft) => applyPatchesImpl(draft, patches)
|
|
3021
|
+
);
|
|
3022
|
+
}
|
|
3023
|
+
};
|
|
3024
|
+
function createProxy(value, parent) {
|
|
3025
|
+
const draft = isMap(value) ? getPlugin("MapSet").proxyMap_(value, parent) : isSet(value) ? getPlugin("MapSet").proxySet_(value, parent) : createProxyProxy(value, parent);
|
|
3026
|
+
const scope = parent ? parent.scope_ : getCurrentScope();
|
|
3027
|
+
scope.drafts_.push(draft);
|
|
3028
|
+
return draft;
|
|
3029
|
+
}
|
|
3030
|
+
function current(value) {
|
|
3031
|
+
if (!isDraft(value))
|
|
3032
|
+
die(10, value);
|
|
3033
|
+
return currentImpl(value);
|
|
3034
|
+
}
|
|
3035
|
+
function currentImpl(value) {
|
|
3036
|
+
if (!isDraftable(value) || isFrozen(value))
|
|
3037
|
+
return value;
|
|
3038
|
+
const state = value[DRAFT_STATE];
|
|
3039
|
+
let copy;
|
|
3040
|
+
if (state) {
|
|
3041
|
+
if (!state.modified_)
|
|
3042
|
+
return state.base_;
|
|
3043
|
+
state.finalized_ = true;
|
|
3044
|
+
copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
|
|
3045
|
+
} else {
|
|
3046
|
+
copy = shallowCopy(value, true);
|
|
3047
|
+
}
|
|
3048
|
+
each(copy, (key, childValue) => {
|
|
3049
|
+
set(copy, key, currentImpl(childValue));
|
|
3050
|
+
});
|
|
3051
|
+
if (state) {
|
|
3052
|
+
state.finalized_ = false;
|
|
3053
|
+
}
|
|
3054
|
+
return copy;
|
|
3055
|
+
}
|
|
3056
|
+
var immer = new Immer2();
|
|
3057
|
+
immer.produce;
|
|
3058
|
+
immer.produceWithPatches.bind(
|
|
3059
|
+
immer
|
|
3060
|
+
);
|
|
3061
|
+
immer.setAutoFreeze.bind(immer);
|
|
3062
|
+
immer.setUseStrictShallowCopy.bind(immer);
|
|
3063
|
+
immer.applyPatches.bind(immer);
|
|
3064
|
+
immer.createDraft.bind(immer);
|
|
3065
|
+
immer.finishDraft.bind(immer);
|
|
3066
|
+
var nullSafe = function nullSafe2(func) {
|
|
3067
|
+
return (
|
|
3068
|
+
// @ts-ignore
|
|
3069
|
+
curryN$1(func.length, function() {
|
|
3070
|
+
var _ref;
|
|
3071
|
+
var dataArg = (_ref = func.length - 1, _ref < 0 || arguments.length <= _ref ? void 0 : arguments[_ref]);
|
|
3072
|
+
return isNil$1(dataArg) ? dataArg : func.apply(void 0, arguments);
|
|
3073
|
+
})
|
|
3074
|
+
);
|
|
3075
|
+
};
|
|
3076
|
+
var noop = function noop2() {
|
|
3077
|
+
};
|
|
3078
|
+
var isNotEmpty = /* @__PURE__ */ complement$1(isEmpty$1);
|
|
3079
|
+
var notEquals = /* @__PURE__ */ curry$1(function(x2, y2) {
|
|
3080
|
+
return x2 !== y2;
|
|
3081
|
+
});
|
|
3082
|
+
var isNot = notEquals;
|
|
3083
|
+
var filterNonNull = function filterNonNull2(object) {
|
|
3084
|
+
return Object.fromEntries(Object.entries(object).filter(function(_ref5) {
|
|
3085
|
+
var _ref6 = _slicedToArray(_ref5, 2), v2 = _ref6[1];
|
|
3086
|
+
return !isNil$1(v2);
|
|
3087
|
+
}).map(function(_ref7) {
|
|
3088
|
+
var _ref8 = _slicedToArray(_ref7, 2), k2 = _ref8[0], v2 = _ref8[1];
|
|
3089
|
+
return [k2, _typeof(v2) === "object" && !Array.isArray(v2) ? filterNonNull2(v2) : v2];
|
|
3090
|
+
}));
|
|
3091
|
+
};
|
|
3092
|
+
nullSafe(filterNonNull);
|
|
1777
3093
|
const filterTimezones = (inputValue) => {
|
|
1778
3094
|
if (inputValue === "") {
|
|
1779
3095
|
return groupedOptions;
|
|
@@ -1783,9 +3099,9 @@ const filterTimezones = (inputValue) => {
|
|
|
1783
3099
|
const element = group[key].filter(
|
|
1784
3100
|
(timezone) => timezone.label.toLowerCase().includes(inputValue.toLowerCase()) || timezone.keywords.toLowerCase().includes(inputValue.toLowerCase())
|
|
1785
3101
|
);
|
|
1786
|
-
return element
|
|
3102
|
+
return isNotEmpty(element) ? { [key]: element } : null;
|
|
1787
3103
|
});
|
|
1788
|
-
return filteredOptions.filter((
|
|
3104
|
+
return filteredOptions.filter(isNot(null));
|
|
1789
3105
|
};
|
|
1790
3106
|
function Options({
|
|
1791
3107
|
elementId,
|
|
@@ -1823,8 +3139,7 @@ function Options({
|
|
|
1823
3139
|
}
|
|
1824
3140
|
function Switch({
|
|
1825
3141
|
id = "ntsp-switch",
|
|
1826
|
-
onChange =
|
|
1827
|
-
},
|
|
3142
|
+
onChange = noop,
|
|
1828
3143
|
labelRight = "Toggle switch",
|
|
1829
3144
|
labelLeft = "Toggle switch",
|
|
1830
3145
|
defaultValue = false
|
|
@@ -1836,33 +3151,17 @@ function Switch({
|
|
|
1836
3151
|
setIsChecked(checked);
|
|
1837
3152
|
onChange(checked);
|
|
1838
3153
|
};
|
|
1839
|
-
return /* @__PURE__ */ y("label", { htmlFor: id, className: "flex items-center space-x-1 cursor-pointer" }, /* @__PURE__ */ y("span", { className: `ml-3 text-sm text-gray-700 ${labelLeftBold}` }, labelLeft), /* @__PURE__ */ y("span", { className: "relative" }, /* @__PURE__ */ y(
|
|
3154
|
+
return /* @__PURE__ */ y("label", { htmlFor: id, className: "flex items-center space-x-1 cursor-pointer" }, /* @__PURE__ */ y("span", { className: `ml-3 text-sm neeto-ui-text-gray-700 ${labelLeftBold}` }, labelLeft), /* @__PURE__ */ y("span", { className: "relative" }, /* @__PURE__ */ y(
|
|
1840
3155
|
"input",
|
|
1841
3156
|
{
|
|
1842
3157
|
type: "checkbox",
|
|
1843
|
-
id,
|
|
3158
|
+
...{ id },
|
|
1844
3159
|
className: "sr-only",
|
|
1845
3160
|
checked: isChecked,
|
|
1846
3161
|
onChange: handleChange
|
|
1847
3162
|
}
|
|
1848
|
-
), /* @__PURE__ */ y("span", { className: "block w-10 h-6 bg-gray-600 rounded-full" }), /* @__PURE__ */ y("span", { className: "absolute w-4 h-4 transition bg-white rounded-full dot left-1 top-1" })), /* @__PURE__ */ y("span", { className: `ml-3 text-sm text-gray-700 ${labelRightBold}` }, labelRight));
|
|
3163
|
+
), /* @__PURE__ */ y("span", { className: "block w-10 h-6 neeto-ui-bg-gray-600 neeto-ui-rounded-full" }), /* @__PURE__ */ y("span", { className: "absolute w-4 h-4 transition neeto-ui-bg-white neeto-ui-rounded-full dot left-1 top-1" })), /* @__PURE__ */ y("span", { className: `ml-3 text-sm neeto-ui-text-gray-700 ${labelRightBold}` }, labelRight));
|
|
1849
3164
|
}
|
|
1850
|
-
const getFromLocalStorage = (key) => {
|
|
1851
|
-
let response = null;
|
|
1852
|
-
try {
|
|
1853
|
-
const value = localStorage.getItem(key);
|
|
1854
|
-
response = value !== null ? JSON.parse(value) : null;
|
|
1855
|
-
} catch (error) {
|
|
1856
|
-
response = null;
|
|
1857
|
-
}
|
|
1858
|
-
return response;
|
|
1859
|
-
};
|
|
1860
|
-
const setToLocalStorage = (key, value) => {
|
|
1861
|
-
if (value !== null) {
|
|
1862
|
-
localStorage.setItem(key, JSON.stringify(value));
|
|
1863
|
-
} else
|
|
1864
|
-
localStorage.removeItem(key);
|
|
1865
|
-
};
|
|
1866
3165
|
function OptionsContainer({
|
|
1867
3166
|
className,
|
|
1868
3167
|
is24H,
|
|
@@ -1880,20 +3179,20 @@ function OptionsContainer({
|
|
|
1880
3179
|
return /* @__PURE__ */ y(
|
|
1881
3180
|
"div",
|
|
1882
3181
|
{
|
|
1883
|
-
className: `w-full px-2 py-4 flex flex-col text-gray-700 bg-white border border-gray-300 rounded shadow h-80 ${className}`
|
|
3182
|
+
className: `w-full px-2 py-4 flex flex-col neeto-ui-text-gray-700 neeto-ui-bg-white border neeto-ui-border-gray-300 neeto-ui-rounded shadow h-80 ${className}`
|
|
1884
3183
|
},
|
|
1885
3184
|
/* @__PURE__ */ y(Search, { ...{ elementId, searchInput, setSearchInput } }),
|
|
1886
|
-
/* @__PURE__ */ y("div", { className: "flex items-center justify-between w-full pb-2 pr-4 mb-1 shadow-sm gap-x-4" }, /* @__PURE__ */ y("span", null), /* @__PURE__ */ y(Switch, { defaultValue: is24H, labelRight: "24H", labelLeft: "AM/PM", onChange: handleTimeFormatChange })),
|
|
3185
|
+
/* @__PURE__ */ y("div", { className: "flex items-center justify-between w-full pb-2 pr-4 mb-1 neeto-ui-shadow-sm gap-x-4" }, /* @__PURE__ */ y("span", null), /* @__PURE__ */ y(Switch, { defaultValue: is24H, labelRight: "24H", labelLeft: "AM/PM", onChange: handleTimeFormatChange })),
|
|
1887
3186
|
/* @__PURE__ */ y(
|
|
1888
3187
|
Options,
|
|
1889
3188
|
{
|
|
1890
3189
|
...{
|
|
1891
3190
|
elementId,
|
|
3191
|
+
is24H,
|
|
1892
3192
|
searchInput,
|
|
1893
3193
|
selectedValue,
|
|
1894
|
-
setSelectedValue,
|
|
1895
3194
|
setIsOverlayVisible,
|
|
1896
|
-
|
|
3195
|
+
setSelectedValue
|
|
1897
3196
|
}
|
|
1898
3197
|
}
|
|
1899
3198
|
)
|
|
@@ -1912,7 +3211,7 @@ function Selector({
|
|
|
1912
3211
|
}
|
|
1913
3212
|
}) {
|
|
1914
3213
|
const [selectedValue, setSelectedValue] = h(
|
|
1915
|
-
getTimezoneObject(initialValue) ||
|
|
3214
|
+
getTimezoneObject(initialValue) || getDefaultValue
|
|
1916
3215
|
);
|
|
1917
3216
|
const [isOverlayVisible, setIsOverlayVisible] = h(false);
|
|
1918
3217
|
const [is24H, setIs24H] = h(getFromLocalStorage("ntsp-24-hr-time-format") || false);
|
|
@@ -1936,34 +3235,27 @@ function Selector({
|
|
|
1936
3235
|
const hourFormat = is24H ? "24H" : "12H";
|
|
1937
3236
|
onHourFormatChange(hourFormat);
|
|
1938
3237
|
}, [is24H]);
|
|
3238
|
+
p(() => {
|
|
3239
|
+
const timeZone = getTimezoneObject(initialValue) || getDefaultValue;
|
|
3240
|
+
setSelectedValue(timeZone);
|
|
3241
|
+
}, [initialValue]);
|
|
1939
3242
|
return /* @__PURE__ */ y("div", { className: "ntsp", id: elementId }, /* @__PURE__ */ y(
|
|
1940
3243
|
"div",
|
|
1941
3244
|
{
|
|
1942
3245
|
className: `flex flex-col relative ${className}`
|
|
1943
3246
|
},
|
|
1944
|
-
/* @__PURE__ */ y(
|
|
1945
|
-
Button,
|
|
1946
|
-
{
|
|
1947
|
-
...{
|
|
1948
|
-
isOverlayVisible,
|
|
1949
|
-
setIsOverlayVisible,
|
|
1950
|
-
selectedValue,
|
|
1951
|
-
elementId,
|
|
1952
|
-
is24H
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
),
|
|
3247
|
+
/* @__PURE__ */ y(Button, { ...{ elementId, is24H, isOverlayVisible, selectedValue, setIsOverlayVisible } }),
|
|
1956
3248
|
isOverlayVisible === true && /* @__PURE__ */ y(
|
|
1957
3249
|
OptionsContainer,
|
|
1958
3250
|
{
|
|
1959
3251
|
className: `absolute ${top ? "bottom-16" : "top-16"}`,
|
|
1960
3252
|
...{
|
|
1961
3253
|
elementId,
|
|
3254
|
+
is24H,
|
|
1962
3255
|
selectedValue,
|
|
1963
|
-
|
|
3256
|
+
setIs24H,
|
|
1964
3257
|
setIsOverlayVisible,
|
|
1965
|
-
|
|
1966
|
-
setIs24H
|
|
3258
|
+
setSelectedValue
|
|
1967
3259
|
}
|
|
1968
3260
|
}
|
|
1969
3261
|
)
|