@bigbinary/neeto-time-zones 0.5.0 → 0.5.2

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