1 | import React, { useRef, useEffect, useMemo, useReducer, useState, useContext } from 'react';
|
2 | import styled from 'styled-components';
|
3 | import { debounce } from 'lodash';
|
4 | import { BehaviorSubject } from 'rxjs';
|
5 |
|
6 | function _typeof(obj) {
|
7 | "@babel/helpers - typeof";
|
8 |
|
9 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
10 | _typeof = function (obj) {
|
11 | return typeof obj;
|
12 | };
|
13 | } else {
|
14 | _typeof = function (obj) {
|
15 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
16 | };
|
17 | }
|
18 |
|
19 | return _typeof(obj);
|
20 | }
|
21 |
|
22 | function _defineProperty(obj, key, value) {
|
23 | if (key in obj) {
|
24 | Object.defineProperty(obj, key, {
|
25 | value: value,
|
26 | enumerable: true,
|
27 | configurable: true,
|
28 | writable: true
|
29 | });
|
30 | } else {
|
31 | obj[key] = value;
|
32 | }
|
33 |
|
34 | return obj;
|
35 | }
|
36 |
|
37 | function ownKeys(object, enumerableOnly) {
|
38 | var keys = Object.keys(object);
|
39 |
|
40 | if (Object.getOwnPropertySymbols) {
|
41 | var symbols = Object.getOwnPropertySymbols(object);
|
42 | if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
43 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
44 | });
|
45 | keys.push.apply(keys, symbols);
|
46 | }
|
47 |
|
48 | return keys;
|
49 | }
|
50 |
|
51 | function _objectSpread2(target) {
|
52 | for (var i = 1; i < arguments.length; i++) {
|
53 | var source = arguments[i] != null ? arguments[i] : {};
|
54 |
|
55 | if (i % 2) {
|
56 | ownKeys(Object(source), true).forEach(function (key) {
|
57 | _defineProperty(target, key, source[key]);
|
58 | });
|
59 | } else if (Object.getOwnPropertyDescriptors) {
|
60 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
61 | } else {
|
62 | ownKeys(Object(source)).forEach(function (key) {
|
63 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
64 | });
|
65 | }
|
66 | }
|
67 |
|
68 | return target;
|
69 | }
|
70 |
|
71 | function _taggedTemplateLiteral(strings, raw) {
|
72 | if (!raw) {
|
73 | raw = strings.slice(0);
|
74 | }
|
75 |
|
76 | return Object.freeze(Object.defineProperties(strings, {
|
77 | raw: {
|
78 | value: Object.freeze(raw)
|
79 | }
|
80 | }));
|
81 | }
|
82 |
|
83 | function _slicedToArray(arr, i) {
|
84 | return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
85 | }
|
86 |
|
87 | function _arrayWithHoles(arr) {
|
88 | if (Array.isArray(arr)) return arr;
|
89 | }
|
90 |
|
91 | function _iterableToArrayLimit(arr, i) {
|
92 | if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
93 | var _arr = [];
|
94 | var _n = true;
|
95 | var _d = false;
|
96 | var _e = undefined;
|
97 |
|
98 | try {
|
99 | for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
100 | _arr.push(_s.value);
|
101 |
|
102 | if (i && _arr.length === i) break;
|
103 | }
|
104 | } catch (err) {
|
105 | _d = true;
|
106 | _e = err;
|
107 | } finally {
|
108 | try {
|
109 | if (!_n && _i["return"] != null) _i["return"]();
|
110 | } finally {
|
111 | if (_d) throw _e;
|
112 | }
|
113 | }
|
114 |
|
115 | return _arr;
|
116 | }
|
117 |
|
118 | function _unsupportedIterableToArray(o, minLen) {
|
119 | if (!o) return;
|
120 | if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
121 | var n = Object.prototype.toString.call(o).slice(8, -1);
|
122 | if (n === "Object" && o.constructor) n = o.constructor.name;
|
123 | if (n === "Map" || n === "Set") return Array.from(o);
|
124 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
125 | }
|
126 |
|
127 | function _arrayLikeToArray(arr, len) {
|
128 | if (len == null || len > arr.length) len = arr.length;
|
129 |
|
130 | for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
131 |
|
132 | return arr2;
|
133 | }
|
134 |
|
135 | function _nonIterableRest() {
|
136 | throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
137 | }
|
138 |
|
139 | function _templateObject5() {
|
140 | var data = _taggedTemplateLiteral(["\n .leo {\n position: absolute;\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: 50%;\n }\n\n .blue-orbit {\n width: 165px;\n height: 165px;\n border: 1px solid #91daffa5;\n -webkit-animation: spin3D 3s linear 0.2s infinite;\n }\n\n .green-orbit {\n width: 120px;\n height: 120px;\n border: 1px solid #91ffbfa5;\n -webkit-animation: spin3D 2s linear 0s infinite;\n }\n\n .red-orbit {\n width: 90px;\n height: 90px;\n border: 1px solid #ffca91a5;\n -webkit-animation: spin3D 1s linear 0s infinite;\n }\n\n .white-orbit {\n width: 60px;\n height: 60px;\n border: 2px solid #ffffff;\n -webkit-animation: spin3D 10s linear 0s infinite;\n }\n\n .w1 {\n transform: rotate3D(1, 1, 1, 90deg);\n }\n\n .w2 {\n transform: rotate3D(1, 2, 0.5, 90deg);\n }\n\n .w3 {\n transform: rotate3D(0.5, 1, 2, 90deg);\n }\n\n @keyframes spin {\n from {\n transform: rotate(0);\n }\n to {\n transform: rotate(359deg);\n }\n }\n\n @keyframes spin3D {\n from {\n transform: rotate3d(0.5, 0.5, 0.5, 360deg);\n }\n to {\n transform: rotate3d(0deg);\n }\n }\n"]);
|
141 |
|
142 | _templateObject5 = function _templateObject5() {
|
143 | return data;
|
144 | };
|
145 |
|
146 | return data;
|
147 | }
|
148 |
|
149 | function _templateObject4() {
|
150 | var data = _taggedTemplateLiteral(["\n .solar-system {\n width: 250px;\n height: 250px;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .orbit {\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n border: 1px solid #ffffffa5;\n border-radius: 50%;\n }\n\n .earth-orbit {\n width: 165px;\n height: 165px;\n animation: spin 12s linear 0s infinite;\n }\n\n .venus-orbit {\n width: 120px;\n height: 120px;\n animation: spin 7.4s linear 0s infinite;\n }\n\n .mercury-orbit {\n width: 90px;\n height: 90px;\n animation: spin 3s linear 0s infinite;\n }\n\n .planet {\n position: absolute;\n top: -5px;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background-color: #3ff9dc;\n }\n\n .sun {\n width: 35px;\n height: 35px;\n border-radius: 50%;\n background-color: #ffab91;\n }\n"]);
|
151 |
|
152 | _templateObject4 = function _templateObject4() {
|
153 | return data;
|
154 | };
|
155 |
|
156 | return data;
|
157 | }
|
158 |
|
159 | function _templateObject3() {
|
160 | var data = _taggedTemplateLiteral(["\n .pulse-container {\n width: 120px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .pulse-bubble {\n width: 20px;\n height: 20px;\n border-radius: 50%;\n background-color: #3ff9dc;\n }\n\n .pulse-bubble-1 {\n animation: pulse 0.4s ease 0s infinite alternate;\n }\n .pulse-bubble-2 {\n animation: pulse 0.4s ease 0.2s infinite alternate;\n }\n .pulse-bubble-3 {\n animation: pulse 0.4s ease 0.4s infinite alternate;\n }\n @keyframes pulse {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0.25;\n transform: scale(0.75);\n }\n }\n"]);
|
161 |
|
162 | _templateObject3 = function _templateObject3() {
|
163 | return data;
|
164 | };
|
165 |
|
166 | return data;
|
167 | }
|
168 |
|
169 | function _templateObject2() {
|
170 | var data = _taggedTemplateLiteral(["\n .circle-border {\n width: 150px;\n height: 150px;\n padding: 3px;\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: 50%;\n background: rgb(63, 249, 220);\n background: linear-gradient(0deg, rgba(63, 249, 220, 0.1) 33%, rgba(63, 249, 220, 1) 100%);\n animation: spin 0.8s linear 0s infinite;\n }\n\n .circle-core {\n width: 100%;\n height: 100%;\n background-color: #37474f;\n border-radius: 50%;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0);\n }\n to {\n transform: rotate(359deg);\n }\n }\n"]);
|
171 |
|
172 | _templateObject2 = function _templateObject2() {
|
173 | return data;
|
174 | };
|
175 |
|
176 | return data;
|
177 | }
|
178 |
|
179 | function _templateObject() {
|
180 | var data = _taggedTemplateLiteral(["\n width: 300px;\n height: 300px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: transparent;\n"]);
|
181 |
|
182 | _templateObject = function _templateObject() {
|
183 | return data;
|
184 | };
|
185 |
|
186 | return data;
|
187 | }
|
188 |
|
189 | var SpinnerBox = styled.div(_templateObject());
|
190 | var GradientSpinnerBox = styled(SpinnerBox)(_templateObject2());
|
191 | var PulseBubbleBox = styled(SpinnerBox)(_templateObject3());
|
192 | var GradientSpinner = function GradientSpinner() {
|
193 | return React.createElement(GradientSpinnerBox, null, React.createElement("div", {
|
194 | className: "circle-border"
|
195 | }, React.createElement("div", {
|
196 | className: "circle-core"
|
197 | })));
|
198 | };
|
199 | var PulseBubble = function PulseBubble() {
|
200 | return React.createElement(PulseBubbleBox, null, React.createElement("div", {
|
201 | className: "pulse-container"
|
202 | }, React.createElement("div", {
|
203 | className: "pulse-bubble pulse-bubble-1"
|
204 | }), React.createElement("div", {
|
205 | className: "pulse-bubble pulse-bubble-2"
|
206 | }), React.createElement("div", {
|
207 | className: "pulse-bubble pulse-bubble-3"
|
208 | })));
|
209 | };
|
210 | var SolarSystemBox = styled(SpinnerBox)(_templateObject4());
|
211 | var SolarSystemSpinner = function SolarSystemSpinner() {
|
212 | return React.createElement(SolarSystemBox, null, React.createElement("div", {
|
213 | className: "solar-system"
|
214 | }, React.createElement("div", {
|
215 | className: "earth-orbit orbit"
|
216 | }, React.createElement("div", {
|
217 | className: "planet earth"
|
218 | }), React.createElement("div", {
|
219 | className: "venus-orbit orbit"
|
220 | }, React.createElement("div", {
|
221 | className: "planet venus"
|
222 | }), React.createElement("div", {
|
223 | className: "mercury-orbit orbit"
|
224 | }, React.createElement("div", {
|
225 | className: "planet mercury"
|
226 | }), React.createElement("div", {
|
227 | className: "sun"
|
228 | }))))));
|
229 | };
|
230 | var PlanetRotatingBox = styled(SpinnerBox)(_templateObject5());
|
231 | var PlantRotating = function PlantRotating() {
|
232 | return React.createElement(PlanetRotatingBox, null, React.createElement("div", {
|
233 | className: "blue-orbit leo"
|
234 | }), React.createElement("div", {
|
235 | className: "green-orbit leo"
|
236 | }), React.createElement("div", {
|
237 | className: "red-orbit leo"
|
238 | }), React.createElement("div", {
|
239 | className: "white-orbit w1 leo"
|
240 | }), React.createElement("div", {
|
241 | className: "white-orbit w2 leo"
|
242 | }), React.createElement("div", {
|
243 | className: "white-orbit w3 leo"
|
244 | }));
|
245 | };
|
246 |
|
247 | function _templateObject$1() {
|
248 | var data = _taggedTemplateLiteral(["\n position: absolute;\n width: 35px;\n height: 35px;\n left: 50%;\n top: 50%;\n & > div {\n position: absolute;\n width: 2px;\n height: 8px;\n background-color: #25363f;\n opacity: 0.05;\n animation: fadeit 0.8s linear infinite;\n }\n\n ", "\n\n @keyframes fadeit {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n"]);
|
249 |
|
250 | _templateObject$1 = function _templateObject() {
|
251 | return data;
|
252 | };
|
253 |
|
254 | return data;
|
255 | }
|
256 |
|
257 | var BarsSpinnerBox = styled.div(_templateObject$1(), function (_ref) {
|
258 | var bars = _ref.bars;
|
259 | return Array(bars).fill(null).map(function (_, i) {
|
260 | return "\n & > div:nth-child(".concat(i + 1, ") {\n transform: rotate(").concat((360 / bars * i).toFixed(2), "deg) translate(0, -12px);\n animation-delay:").concat((0.8 / bars * (i + 1)).toFixed(2), "s;\n }\n ");
|
261 | });
|
262 | });
|
263 | var BarsSpinner = function BarsSpinner(_ref2) {
|
264 | var _ref2$bars = _ref2.bars,
|
265 | bars = _ref2$bars === void 0 ? 16 : _ref2$bars;
|
266 | return React.createElement(BarsSpinnerBox, {
|
267 | bars: bars
|
268 | }, Array(bars).fill(null).map(function (_, i) {
|
269 | return React.createElement("div", {
|
270 | key: i
|
271 | });
|
272 | }));
|
273 | };
|
274 |
|
275 | function _extends() {
|
276 | _extends = Object.assign || function (target) {
|
277 | for (var i = 1; i < arguments.length; i++) {
|
278 | var source = arguments[i];
|
279 |
|
280 | for (var key in source) {
|
281 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
282 | target[key] = source[key];
|
283 | }
|
284 | }
|
285 | }
|
286 |
|
287 | return target;
|
288 | };
|
289 |
|
290 | return _extends.apply(this, arguments);
|
291 | }
|
292 |
|
293 | function _assertThisInitialized(self) {
|
294 | if (self === void 0) {
|
295 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
296 | }
|
297 |
|
298 | return self;
|
299 | }
|
300 |
|
301 | function _inheritsLoose(subClass, superClass) {
|
302 | subClass.prototype = Object.create(superClass.prototype);
|
303 | subClass.prototype.constructor = subClass;
|
304 | subClass.__proto__ = superClass;
|
305 | }
|
306 |
|
307 | function _getPrototypeOf(o) {
|
308 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
309 | return o.__proto__ || Object.getPrototypeOf(o);
|
310 | };
|
311 | return _getPrototypeOf(o);
|
312 | }
|
313 |
|
314 | function _setPrototypeOf(o, p) {
|
315 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
316 | o.__proto__ = p;
|
317 | return o;
|
318 | };
|
319 |
|
320 | return _setPrototypeOf(o, p);
|
321 | }
|
322 |
|
323 | function _isNativeFunction(fn) {
|
324 | return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
325 | }
|
326 |
|
327 | function _isNativeReflectConstruct() {
|
328 | if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
329 | if (Reflect.construct.sham) return false;
|
330 | if (typeof Proxy === "function") return true;
|
331 |
|
332 | try {
|
333 | Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
334 | return true;
|
335 | } catch (e) {
|
336 | return false;
|
337 | }
|
338 | }
|
339 |
|
340 | function _construct(Parent, args, Class) {
|
341 | if (_isNativeReflectConstruct()) {
|
342 | _construct = Reflect.construct;
|
343 | } else {
|
344 | _construct = function _construct(Parent, args, Class) {
|
345 | var a = [null];
|
346 | a.push.apply(a, args);
|
347 | var Constructor = Function.bind.apply(Parent, a);
|
348 | var instance = new Constructor();
|
349 | if (Class) _setPrototypeOf(instance, Class.prototype);
|
350 | return instance;
|
351 | };
|
352 | }
|
353 |
|
354 | return _construct.apply(null, arguments);
|
355 | }
|
356 |
|
357 | function _wrapNativeSuper(Class) {
|
358 | var _cache = typeof Map === "function" ? new Map() : undefined;
|
359 |
|
360 | _wrapNativeSuper = function _wrapNativeSuper(Class) {
|
361 | if (Class === null || !_isNativeFunction(Class)) return Class;
|
362 |
|
363 | if (typeof Class !== "function") {
|
364 | throw new TypeError("Super expression must either be null or a function");
|
365 | }
|
366 |
|
367 | if (typeof _cache !== "undefined") {
|
368 | if (_cache.has(Class)) return _cache.get(Class);
|
369 |
|
370 | _cache.set(Class, Wrapper);
|
371 | }
|
372 |
|
373 | function Wrapper() {
|
374 | return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
375 | }
|
376 |
|
377 | Wrapper.prototype = Object.create(Class.prototype, {
|
378 | constructor: {
|
379 | value: Wrapper,
|
380 | enumerable: false,
|
381 | writable: true,
|
382 | configurable: true
|
383 | }
|
384 | });
|
385 | return _setPrototypeOf(Wrapper, Class);
|
386 | };
|
387 |
|
388 | return _wrapNativeSuper(Class);
|
389 | }
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 | var ERRORS = {
|
397 | "1": "Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",
|
398 | "2": "Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",
|
399 | "3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
|
400 | "4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
|
401 | "5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
|
402 | "6": "Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",
|
403 | "7": "Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",
|
404 | "8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
|
405 | "9": "Please provide a number of steps to the modularScale helper.\n\n",
|
406 | "10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
407 | "11": "Invalid value passed as base to modularScale, expected number or em string but got \"%s\"\n\n",
|
408 | "12": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got \"%s\" instead.\n\n",
|
409 | "13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
|
410 | "14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
|
411 | "15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
|
412 | "16": "You must provide a template to this method.\n\n",
|
413 | "17": "You passed an unsupported selector state to this method.\n\n",
|
414 | "18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
415 | "19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
416 | "20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
417 | "21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
418 | "22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
419 | "23": "fontFace expects a name of a font-family.\n\n",
|
420 | "24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
421 | "25": "fontFace expects localFonts to be an array.\n\n",
|
422 | "26": "fontFace expects fileFormats to be an array.\n\n",
|
423 | "27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
424 | "28": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
425 | "29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
426 | "30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
427 | "31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
|
428 | "32": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",
|
429 | "33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
|
430 | "34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
431 | "35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
|
432 | "36": "Property must be a string value.\n\n",
|
433 | "37": "Syntax Error at %s.\n\n",
|
434 | "38": "Formula contains a function that needs parentheses at %s.\n\n",
|
435 | "39": "Formula is missing closing parenthesis at %s.\n\n",
|
436 | "40": "Formula has too many closing parentheses at %s.\n\n",
|
437 | "41": "All values in a formula must have the same unit or be unitless.\n\n",
|
438 | "42": "Please provide a number of steps to the modularScale helper.\n\n",
|
439 | "43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
440 | "44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
|
441 | "45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
|
442 | "46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
|
443 | "47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
444 | "48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
445 | "49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
446 | "50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
|
447 | "51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
|
448 | "52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
449 | "53": "fontFace expects localFonts to be an array.\n\n",
|
450 | "54": "fontFace expects fileFormats to be an array.\n\n",
|
451 | "55": "fontFace expects a name of a font-family.\n\n",
|
452 | "56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
|
453 | "57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
454 | "58": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
455 | "59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
456 | "60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
457 | "61": "Property must be a string value.\n\n",
|
458 | "62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
459 | "63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
|
460 | "64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
|
461 | "65": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",
|
462 | "66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
|
463 | "67": "You must provide a template to this method.\n\n",
|
464 | "68": "You passed an unsupported selector state to this method.\n\n",
|
465 | "69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
|
466 | "70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
|
467 | "71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
468 | "72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
469 | "73": "Please provide a valid CSS variable.\n\n",
|
470 | "74": "CSS variable not found.\n"
|
471 | };
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 | function format() {
|
478 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
479 | args[_key] = arguments[_key];
|
480 | }
|
481 |
|
482 | var a = args[0];
|
483 | var b = [];
|
484 | var c;
|
485 |
|
486 | for (c = 1; c < args.length; c += 1) {
|
487 | b.push(args[c]);
|
488 | }
|
489 |
|
490 | b.forEach(function (d) {
|
491 | a = a.replace(/%[a-z]/, d);
|
492 | });
|
493 | return a;
|
494 | }
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 | var PolishedError = function (_Error) {
|
503 | _inheritsLoose(PolishedError, _Error);
|
504 |
|
505 | function PolishedError(code) {
|
506 | var _this;
|
507 |
|
508 | if (process.env.NODE_ENV === 'production') {
|
509 | _this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/master/src/internalHelpers/errors.md#" + code + " for more information.") || this;
|
510 | } else {
|
511 | for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
512 | args[_key2 - 1] = arguments[_key2];
|
513 | }
|
514 |
|
515 | _this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
|
516 | }
|
517 |
|
518 | return _assertThisInitialized(_this);
|
519 | }
|
520 |
|
521 | return PolishedError;
|
522 | }( _wrapNativeSuper(Error));
|
523 |
|
524 | function colorToInt(color) {
|
525 | return Math.round(color * 255);
|
526 | }
|
527 |
|
528 | function convertToInt(red, green, blue) {
|
529 | return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
|
530 | }
|
531 |
|
532 | function hslToRgb(hue, saturation, lightness, convert) {
|
533 | if (convert === void 0) {
|
534 | convert = convertToInt;
|
535 | }
|
536 |
|
537 | if (saturation === 0) {
|
538 |
|
539 | return convert(lightness, lightness, lightness);
|
540 | }
|
541 |
|
542 |
|
543 | var huePrime = (hue % 360 + 360) % 360 / 60;
|
544 | var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
545 | var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
546 | var red = 0;
|
547 | var green = 0;
|
548 | var blue = 0;
|
549 |
|
550 | if (huePrime >= 0 && huePrime < 1) {
|
551 | red = chroma;
|
552 | green = secondComponent;
|
553 | } else if (huePrime >= 1 && huePrime < 2) {
|
554 | red = secondComponent;
|
555 | green = chroma;
|
556 | } else if (huePrime >= 2 && huePrime < 3) {
|
557 | green = chroma;
|
558 | blue = secondComponent;
|
559 | } else if (huePrime >= 3 && huePrime < 4) {
|
560 | green = secondComponent;
|
561 | blue = chroma;
|
562 | } else if (huePrime >= 4 && huePrime < 5) {
|
563 | red = secondComponent;
|
564 | blue = chroma;
|
565 | } else if (huePrime >= 5 && huePrime < 6) {
|
566 | red = chroma;
|
567 | blue = secondComponent;
|
568 | }
|
569 |
|
570 | var lightnessModification = lightness - chroma / 2;
|
571 | var finalRed = red + lightnessModification;
|
572 | var finalGreen = green + lightnessModification;
|
573 | var finalBlue = blue + lightnessModification;
|
574 | return convert(finalRed, finalGreen, finalBlue);
|
575 | }
|
576 |
|
577 | var namedColorMap = {
|
578 | aliceblue: 'f0f8ff',
|
579 | antiquewhite: 'faebd7',
|
580 | aqua: '00ffff',
|
581 | aquamarine: '7fffd4',
|
582 | azure: 'f0ffff',
|
583 | beige: 'f5f5dc',
|
584 | bisque: 'ffe4c4',
|
585 | black: '000',
|
586 | blanchedalmond: 'ffebcd',
|
587 | blue: '0000ff',
|
588 | blueviolet: '8a2be2',
|
589 | brown: 'a52a2a',
|
590 | burlywood: 'deb887',
|
591 | cadetblue: '5f9ea0',
|
592 | chartreuse: '7fff00',
|
593 | chocolate: 'd2691e',
|
594 | coral: 'ff7f50',
|
595 | cornflowerblue: '6495ed',
|
596 | cornsilk: 'fff8dc',
|
597 | crimson: 'dc143c',
|
598 | cyan: '00ffff',
|
599 | darkblue: '00008b',
|
600 | darkcyan: '008b8b',
|
601 | darkgoldenrod: 'b8860b',
|
602 | darkgray: 'a9a9a9',
|
603 | darkgreen: '006400',
|
604 | darkgrey: 'a9a9a9',
|
605 | darkkhaki: 'bdb76b',
|
606 | darkmagenta: '8b008b',
|
607 | darkolivegreen: '556b2f',
|
608 | darkorange: 'ff8c00',
|
609 | darkorchid: '9932cc',
|
610 | darkred: '8b0000',
|
611 | darksalmon: 'e9967a',
|
612 | darkseagreen: '8fbc8f',
|
613 | darkslateblue: '483d8b',
|
614 | darkslategray: '2f4f4f',
|
615 | darkslategrey: '2f4f4f',
|
616 | darkturquoise: '00ced1',
|
617 | darkviolet: '9400d3',
|
618 | deeppink: 'ff1493',
|
619 | deepskyblue: '00bfff',
|
620 | dimgray: '696969',
|
621 | dimgrey: '696969',
|
622 | dodgerblue: '1e90ff',
|
623 | firebrick: 'b22222',
|
624 | floralwhite: 'fffaf0',
|
625 | forestgreen: '228b22',
|
626 | fuchsia: 'ff00ff',
|
627 | gainsboro: 'dcdcdc',
|
628 | ghostwhite: 'f8f8ff',
|
629 | gold: 'ffd700',
|
630 | goldenrod: 'daa520',
|
631 | gray: '808080',
|
632 | green: '008000',
|
633 | greenyellow: 'adff2f',
|
634 | grey: '808080',
|
635 | honeydew: 'f0fff0',
|
636 | hotpink: 'ff69b4',
|
637 | indianred: 'cd5c5c',
|
638 | indigo: '4b0082',
|
639 | ivory: 'fffff0',
|
640 | khaki: 'f0e68c',
|
641 | lavender: 'e6e6fa',
|
642 | lavenderblush: 'fff0f5',
|
643 | lawngreen: '7cfc00',
|
644 | lemonchiffon: 'fffacd',
|
645 | lightblue: 'add8e6',
|
646 | lightcoral: 'f08080',
|
647 | lightcyan: 'e0ffff',
|
648 | lightgoldenrodyellow: 'fafad2',
|
649 | lightgray: 'd3d3d3',
|
650 | lightgreen: '90ee90',
|
651 | lightgrey: 'd3d3d3',
|
652 | lightpink: 'ffb6c1',
|
653 | lightsalmon: 'ffa07a',
|
654 | lightseagreen: '20b2aa',
|
655 | lightskyblue: '87cefa',
|
656 | lightslategray: '789',
|
657 | lightslategrey: '789',
|
658 | lightsteelblue: 'b0c4de',
|
659 | lightyellow: 'ffffe0',
|
660 | lime: '0f0',
|
661 | limegreen: '32cd32',
|
662 | linen: 'faf0e6',
|
663 | magenta: 'f0f',
|
664 | maroon: '800000',
|
665 | mediumaquamarine: '66cdaa',
|
666 | mediumblue: '0000cd',
|
667 | mediumorchid: 'ba55d3',
|
668 | mediumpurple: '9370db',
|
669 | mediumseagreen: '3cb371',
|
670 | mediumslateblue: '7b68ee',
|
671 | mediumspringgreen: '00fa9a',
|
672 | mediumturquoise: '48d1cc',
|
673 | mediumvioletred: 'c71585',
|
674 | midnightblue: '191970',
|
675 | mintcream: 'f5fffa',
|
676 | mistyrose: 'ffe4e1',
|
677 | moccasin: 'ffe4b5',
|
678 | navajowhite: 'ffdead',
|
679 | navy: '000080',
|
680 | oldlace: 'fdf5e6',
|
681 | olive: '808000',
|
682 | olivedrab: '6b8e23',
|
683 | orange: 'ffa500',
|
684 | orangered: 'ff4500',
|
685 | orchid: 'da70d6',
|
686 | palegoldenrod: 'eee8aa',
|
687 | palegreen: '98fb98',
|
688 | paleturquoise: 'afeeee',
|
689 | palevioletred: 'db7093',
|
690 | papayawhip: 'ffefd5',
|
691 | peachpuff: 'ffdab9',
|
692 | peru: 'cd853f',
|
693 | pink: 'ffc0cb',
|
694 | plum: 'dda0dd',
|
695 | powderblue: 'b0e0e6',
|
696 | purple: '800080',
|
697 | rebeccapurple: '639',
|
698 | red: 'f00',
|
699 | rosybrown: 'bc8f8f',
|
700 | royalblue: '4169e1',
|
701 | saddlebrown: '8b4513',
|
702 | salmon: 'fa8072',
|
703 | sandybrown: 'f4a460',
|
704 | seagreen: '2e8b57',
|
705 | seashell: 'fff5ee',
|
706 | sienna: 'a0522d',
|
707 | silver: 'c0c0c0',
|
708 | skyblue: '87ceeb',
|
709 | slateblue: '6a5acd',
|
710 | slategray: '708090',
|
711 | slategrey: '708090',
|
712 | snow: 'fffafa',
|
713 | springgreen: '00ff7f',
|
714 | steelblue: '4682b4',
|
715 | tan: 'd2b48c',
|
716 | teal: '008080',
|
717 | thistle: 'd8bfd8',
|
718 | tomato: 'ff6347',
|
719 | turquoise: '40e0d0',
|
720 | violet: 'ee82ee',
|
721 | wheat: 'f5deb3',
|
722 | white: 'fff',
|
723 | whitesmoke: 'f5f5f5',
|
724 | yellow: 'ff0',
|
725 | yellowgreen: '9acd32'
|
726 | };
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 | function nameToHex(color) {
|
733 | if (typeof color !== 'string') return color;
|
734 | var normalizedColorName = color.toLowerCase();
|
735 | return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
|
736 | }
|
737 |
|
738 | var hexRegex = /^#[a-fA-F0-9]{6}$/;
|
739 | var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
|
740 | var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
|
741 | var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
|
742 | var rgbRegex = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i;
|
743 | var rgbaRegex = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
|
744 | var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
|
745 | var hslaRegex = /^hsla\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 |
|
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 | function parseToRgb(color) {
|
759 | if (typeof color !== 'string') {
|
760 | throw new PolishedError(3);
|
761 | }
|
762 |
|
763 | var normalizedColor = nameToHex(color);
|
764 |
|
765 | if (normalizedColor.match(hexRegex)) {
|
766 | return {
|
767 | red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
768 | green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
769 | blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
|
770 | };
|
771 | }
|
772 |
|
773 | if (normalizedColor.match(hexRgbaRegex)) {
|
774 | var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
|
775 | return {
|
776 | red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
777 | green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
778 | blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
|
779 | alpha: alpha
|
780 | };
|
781 | }
|
782 |
|
783 | if (normalizedColor.match(reducedHexRegex)) {
|
784 | return {
|
785 | red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
786 | green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
787 | blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
|
788 | };
|
789 | }
|
790 |
|
791 | if (normalizedColor.match(reducedRgbaHexRegex)) {
|
792 | var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
|
793 |
|
794 | return {
|
795 | red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
796 | green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
797 | blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
|
798 | alpha: _alpha
|
799 | };
|
800 | }
|
801 |
|
802 | var rgbMatched = rgbRegex.exec(normalizedColor);
|
803 |
|
804 | if (rgbMatched) {
|
805 | return {
|
806 | red: parseInt("" + rgbMatched[1], 10),
|
807 | green: parseInt("" + rgbMatched[2], 10),
|
808 | blue: parseInt("" + rgbMatched[3], 10)
|
809 | };
|
810 | }
|
811 |
|
812 | var rgbaMatched = rgbaRegex.exec(normalizedColor);
|
813 |
|
814 | if (rgbaMatched) {
|
815 | return {
|
816 | red: parseInt("" + rgbaMatched[1], 10),
|
817 | green: parseInt("" + rgbaMatched[2], 10),
|
818 | blue: parseInt("" + rgbaMatched[3], 10),
|
819 | alpha: parseFloat("" + rgbaMatched[4])
|
820 | };
|
821 | }
|
822 |
|
823 | var hslMatched = hslRegex.exec(normalizedColor);
|
824 |
|
825 | if (hslMatched) {
|
826 | var hue = parseInt("" + hslMatched[1], 10);
|
827 | var saturation = parseInt("" + hslMatched[2], 10) / 100;
|
828 | var lightness = parseInt("" + hslMatched[3], 10) / 100;
|
829 | var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
|
830 | var hslRgbMatched = rgbRegex.exec(rgbColorString);
|
831 |
|
832 | if (!hslRgbMatched) {
|
833 | throw new PolishedError(4, normalizedColor, rgbColorString);
|
834 | }
|
835 |
|
836 | return {
|
837 | red: parseInt("" + hslRgbMatched[1], 10),
|
838 | green: parseInt("" + hslRgbMatched[2], 10),
|
839 | blue: parseInt("" + hslRgbMatched[3], 10)
|
840 | };
|
841 | }
|
842 |
|
843 | var hslaMatched = hslaRegex.exec(normalizedColor);
|
844 |
|
845 | if (hslaMatched) {
|
846 | var _hue = parseInt("" + hslaMatched[1], 10);
|
847 |
|
848 | var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
|
849 |
|
850 | var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
|
851 |
|
852 | var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
|
853 |
|
854 | var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
855 |
|
856 | if (!_hslRgbMatched) {
|
857 | throw new PolishedError(4, normalizedColor, _rgbColorString);
|
858 | }
|
859 |
|
860 | return {
|
861 | red: parseInt("" + _hslRgbMatched[1], 10),
|
862 | green: parseInt("" + _hslRgbMatched[2], 10),
|
863 | blue: parseInt("" + _hslRgbMatched[3], 10),
|
864 | alpha: parseFloat("" + hslaMatched[4])
|
865 | };
|
866 | }
|
867 |
|
868 | throw new PolishedError(5);
|
869 | }
|
870 |
|
871 | function rgbToHsl(color) {
|
872 |
|
873 | var red = color.red / 255;
|
874 | var green = color.green / 255;
|
875 | var blue = color.blue / 255;
|
876 | var max = Math.max(red, green, blue);
|
877 | var min = Math.min(red, green, blue);
|
878 | var lightness = (max + min) / 2;
|
879 |
|
880 | if (max === min) {
|
881 |
|
882 | if (color.alpha !== undefined) {
|
883 | return {
|
884 | hue: 0,
|
885 | saturation: 0,
|
886 | lightness: lightness,
|
887 | alpha: color.alpha
|
888 | };
|
889 | } else {
|
890 | return {
|
891 | hue: 0,
|
892 | saturation: 0,
|
893 | lightness: lightness
|
894 | };
|
895 | }
|
896 | }
|
897 |
|
898 | var hue;
|
899 | var delta = max - min;
|
900 | var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
901 |
|
902 | switch (max) {
|
903 | case red:
|
904 | hue = (green - blue) / delta + (green < blue ? 6 : 0);
|
905 | break;
|
906 |
|
907 | case green:
|
908 | hue = (blue - red) / delta + 2;
|
909 | break;
|
910 |
|
911 | default:
|
912 |
|
913 | hue = (red - green) / delta + 4;
|
914 | break;
|
915 | }
|
916 |
|
917 | hue *= 60;
|
918 |
|
919 | if (color.alpha !== undefined) {
|
920 | return {
|
921 | hue: hue,
|
922 | saturation: saturation,
|
923 | lightness: lightness,
|
924 | alpha: color.alpha
|
925 | };
|
926 | }
|
927 |
|
928 | return {
|
929 | hue: hue,
|
930 | saturation: saturation,
|
931 | lightness: lightness
|
932 | };
|
933 | }
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 |
|
947 | function parseToHsl(color) {
|
948 |
|
949 |
|
950 | return rgbToHsl(parseToRgb(color));
|
951 | }
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 | var reduceHexValue = function reduceHexValue(value) {
|
959 | if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
|
960 | return "#" + value[1] + value[3] + value[5];
|
961 | }
|
962 |
|
963 | return value;
|
964 | };
|
965 |
|
966 | function numberToHex(value) {
|
967 | var hex = value.toString(16);
|
968 | return hex.length === 1 ? "0" + hex : hex;
|
969 | }
|
970 |
|
971 | function colorToHex(color) {
|
972 | return numberToHex(Math.round(color * 255));
|
973 | }
|
974 |
|
975 | function convertToHex(red, green, blue) {
|
976 | return reduceHexValue("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
|
977 | }
|
978 |
|
979 | function hslToHex(hue, saturation, lightness) {
|
980 | return hslToRgb(hue, saturation, lightness, convertToHex);
|
981 | }
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 | function hsl(value, saturation, lightness) {
|
1008 | if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number') {
|
1009 | return hslToHex(value, saturation, lightness);
|
1010 | } else if (_typeof(value) === 'object' && saturation === undefined && lightness === undefined) {
|
1011 | return hslToHex(value.hue, value.saturation, value.lightness);
|
1012 | }
|
1013 |
|
1014 | throw new PolishedError(1);
|
1015 | }
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 | function hsla(value, saturation, lightness, alpha) {
|
1045 | if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number' && typeof alpha === 'number') {
|
1046 | return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
|
1047 | } else if (_typeof(value) === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
|
1048 | return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
|
1049 | }
|
1050 |
|
1051 | throw new PolishedError(2);
|
1052 | }
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 | function rgb(value, green, blue) {
|
1079 | if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
|
1080 | return reduceHexValue("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
|
1081 | } else if (_typeof(value) === 'object' && green === undefined && blue === undefined) {
|
1082 | return reduceHexValue("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
1083 | }
|
1084 |
|
1085 | throw new PolishedError(6);
|
1086 | }
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 |
|
1117 |
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 |
|
1123 | function rgba(firstValue, secondValue, thirdValue, fourthValue) {
|
1124 | if (typeof firstValue === 'string' && typeof secondValue === 'number') {
|
1125 | var rgbValue = parseToRgb(firstValue);
|
1126 | return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
|
1127 | } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
|
1128 | return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
|
1129 | } else if (_typeof(firstValue) === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
|
1130 | return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
1131 | }
|
1132 |
|
1133 | throw new PolishedError(7);
|
1134 | }
|
1135 |
|
1136 | var isRgb = function isRgb(color) {
|
1137 | return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
1138 | };
|
1139 |
|
1140 | var isRgba = function isRgba(color) {
|
1141 | return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
|
1142 | };
|
1143 |
|
1144 | var isHsl = function isHsl(color) {
|
1145 | return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
1146 | };
|
1147 |
|
1148 | var isHsla = function isHsla(color) {
|
1149 | return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
|
1150 | };
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 | function toColorString(color) {
|
1184 | if (_typeof(color) !== 'object') throw new PolishedError(8);
|
1185 | if (isRgba(color)) return rgba(color);
|
1186 | if (isRgb(color)) return rgb(color);
|
1187 | if (isHsla(color)) return hsla(color);
|
1188 | if (isHsl(color)) return hsl(color);
|
1189 | throw new PolishedError(8);
|
1190 | }
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 | function curried(f, length, acc) {
|
1197 | return function fn() {
|
1198 |
|
1199 | var combined = acc.concat(Array.prototype.slice.call(arguments));
|
1200 | return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
1201 | };
|
1202 | }
|
1203 |
|
1204 |
|
1205 | function curry(f) {
|
1206 |
|
1207 | return curried(f, f.length, []);
|
1208 | }
|
1209 |
|
1210 | function guard(lowerBoundary, upperBoundary, value) {
|
1211 | return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
1212 | }
|
1213 |
|
1214 |
|
1215 |
|
1216 |
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 |
|
1227 |
|
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 | function darken(amount, color) {
|
1239 | if (color === 'transparent') return color;
|
1240 | var hslColor = parseToHsl(color);
|
1241 | return toColorString(_extends({}, hslColor, {
|
1242 | lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
|
1243 | }));
|
1244 | }
|
1245 |
|
1246 |
|
1247 | var curriedDarken = curry
|
1248 |
|
1249 | (darken);
|
1250 |
|
1251 | function _templateObject$2() {
|
1252 | var data = _taggedTemplateLiteral(["\n --size: ", ";\n\n .container {\n ", ";\n transform-style: preserve-3d;\n perspective: 2000px;\n transform: rotateX(-30deg) rotateY(-45deg);\n\n *,\n *:before,\n *:after {\n box-sizing: border-box;\n }\n }\n\n .holder {\n ", ";\n transform-style: preserve-3d;\n transform: translate3d(0em, var(--size), calc(var(--size) * 0.5));\n &:nth-child(3) {\n transform: rotateY(-90deg) rotateX(90deg) translate3d(0, var(--size), calc(var(--size) * 0.5));\n }\n &:first-child {\n transform: rotateZ(-90deg) rotateX(-90deg) translate3d(0, var(--size), calc(var(--size) * 0.5));\n }\n }\n\n ", "\n\n .info {\n ", ";\n padding-top: 180px;\n\n .title {\n font-size: 20px;\n font-weight: 400;\n text-align: center;\n color: #212121;\n }\n\n .detail {\n font-size: 14px;\n font-weight: 200;\n text-align: center;\n }\n }\n\n .box {\n ", ";\n transform-style: preserve-3d;\n animation: ani-box 6s infinite;\n width: var(--size);\n height: var(--size);\n //opacity: .9;\n &:before,\n &:after {\n position: absolute;\n width: 100%;\n height: 100%;\n content: '';\n }\n &:before {\n left: 100%;\n bottom: 0;\n transform: rotateY(90deg);\n transform-origin: 0 50%;\n }\n &:after {\n left: 0;\n bottom: 100%;\n transform: rotateX(90deg);\n transform-origin: 0 100%;\n }\n }\n\n @keyframes ani-box {\n 8.33% {\n transform: translate3d(-50%, -50%, 0) scaleZ(2);\n }\n 16.7% {\n transform: translate3d(-50%, -50%, calc(-1 * var(--size))) scaleZ(1);\n }\n 25% {\n transform: translate3d(-50%, -100%, calc(-1 * var(--size))) scaleY(2);\n }\n 33.3% {\n transform: translate3d(-50%, -150%, calc(-1 * var(--size))) scaleY(1);\n }\n 41.7% {\n transform: translate3d(-100%, -150%, calc(-1 * var(--size))) scaleX(2);\n }\n 50% {\n transform: translate3d(-150%, -150%, calc(-1 * var(--size))) scaleX(1);\n }\n 58.3% {\n transform: translate3d(-150%, -150%, 0) scaleZ(2);\n }\n 66.7% {\n transform: translate3d(-150%, -150%, 0) scaleZ(1);\n }\n 75% {\n transform: translate3d(-150%, -100%, 0) scaleY(2);\n }\n 83.3% {\n transform: translate3d(-150%, -50%, 0) scaleY(1);\n }\n 91.7% {\n transform: translate3d(-100%, -50%, 0) scaleX(2);\n }\n 100% {\n transform: translate3d(-50%, -50%, 0) scaleX(1);\n }\n }\n"]);
|
1253 |
|
1254 | _templateObject$2 = function _templateObject() {
|
1255 | return data;
|
1256 | };
|
1257 |
|
1258 | return data;
|
1259 | }
|
1260 |
|
1261 | var cbox = function cbox(props) {
|
1262 | return "\nposition: absolute;\ntop: 50%;\nleft: 50%;\ntransform: translate(-50%, -50%);\n";
|
1263 | };
|
1264 |
|
1265 | var BoxShuffleContainer = styled.div(_templateObject$2(), function (props) {
|
1266 | return props['size'] || '3em';
|
1267 | }, cbox, cbox, function (props) {
|
1268 | return (props.colors || ['#1FBCD3', '#CBE2B4', '#F6B6CA']).map(function (color, i) {
|
1269 | return "\n .holder:nth-child(".concat(i + 1, "){\n .box{\n background-color: ").concat(color, ";\n &:before{\n background-color: ").concat(curriedDarken(0.2, color), ";\n }\n &:after{\n background-color: ").concat(curriedDarken(0.1, color), ";\n }\n }\n }\n }\n");
|
1270 | });
|
1271 | }, cbox, cbox);
|
1272 | var BoxShuffle = function BoxShuffle(props) {
|
1273 | var title = props.title,
|
1274 | detail = props.detail;
|
1275 | return React.createElement(BoxShuffleContainer, null, React.createElement("div", {
|
1276 | className: "container"
|
1277 | }, React.createElement("div", {
|
1278 | className: "holder"
|
1279 | }, React.createElement("div", {
|
1280 | className: "box"
|
1281 | })), React.createElement("div", {
|
1282 | className: "holder"
|
1283 | }, React.createElement("div", {
|
1284 | className: "box"
|
1285 | })), React.createElement("div", {
|
1286 | className: "holder"
|
1287 | }, React.createElement("div", {
|
1288 | className: "box"
|
1289 | }))), React.createElement("div", {
|
1290 | className: "info"
|
1291 | }, React.createElement("div", {
|
1292 | className: "title"
|
1293 | }, title), React.createElement("div", {
|
1294 | className: "detail"
|
1295 | }, detail)));
|
1296 | };
|
1297 |
|
1298 | function _templateObject$3() {
|
1299 | var data = _taggedTemplateLiteral(["\n width: 200px;\n height: 200px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: auto;\n filter: url('#gooey-loader-filter');\n animation: rotate-move 2s ease-in-out infinite;\n\n .dot {\n width: 70px;\n height: 70px;\n border-radius: 50%;\n background-color: #000;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n margin: auto;\n }\n\n .dot-3 {\n background-color: #f74d75;\n animation: dot-3-move 2s ease infinite, index 6s ease infinite;\n }\n\n .dot-2 {\n background-color: #10beae;\n animation: dot-2-move 2s ease infinite, index 6s -4s ease infinite;\n }\n\n .dot-1 {\n background-color: #ffe386;\n animation: dot-1-move 2s ease infinite, index 6s -2s ease infinite;\n }\n\n @keyframes dot-3-move {\n 20% {\n transform: scale(1);\n }\n 45% {\n transform: translateY(-18px) scale(0.45);\n }\n 60% {\n transform: translateY(-90px) scale(0.45);\n }\n 80% {\n transform: translateY(-90px) scale(0.45);\n }\n 100% {\n transform: translateY(0px) scale(1);\n }\n }\n\n @keyframes dot-2-move {\n 20% {\n transform: scale(1);\n }\n 45% {\n transform: translate(-16px, 12px) scale(0.45);\n }\n 60% {\n transform: translate(-80px, 60px) scale(0.45);\n }\n 80% {\n transform: translate(-80px, 60px) scale(0.45);\n }\n 100% {\n transform: translateY(0px) scale(1);\n }\n }\n\n @keyframes dot-1-move {\n 20% {\n transform: scale(1);\n }\n 45% {\n transform: translate(16px, 12px) scale(0.45);\n }\n 60% {\n transform: translate(80px, 60px) scale(0.45);\n }\n 80% {\n transform: translate(80px, 60px) scale(0.45);\n }\n 100% {\n transform: translateY(0px) scale(1);\n }\n }\n\n @keyframes rotate-move {\n 55% {\n transform: translate(-50%, -50%) rotate(0deg);\n }\n 80% {\n transform: translate(-50%, -50%) rotate(360deg);\n }\n 100% {\n transform: translate(-50%, -50%) rotate(360deg);\n }\n }\n\n @keyframes index {\n 0%,\n 100% {\n z-index: 3;\n }\n 33.3% {\n z-index: 2;\n }\n 66.6% {\n z-index: 1;\n }\n }\n"]);
|
1300 |
|
1301 | _templateObject$3 = function _templateObject() {
|
1302 | return data;
|
1303 | };
|
1304 |
|
1305 | return data;
|
1306 | }
|
1307 | var GooeyLoaderContainer = styled.div(_templateObject$3());
|
1308 |
|
1309 | function loadSvgFilter() {
|
1310 | if (typeof window === 'undefined') {
|
1311 | return;
|
1312 | }
|
1313 |
|
1314 | if (document.querySelector('#GooeyLoaderSvgFilter')) {
|
1315 | return;
|
1316 | }
|
1317 |
|
1318 | var el = document.createElement('div');
|
1319 | el.id = 'GooeyLoaderSvgFilter';
|
1320 | el.innerHTML = "\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <defs>\n <filter id=\"gooey-loader-filter\">\n <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"10\" result=\"blur\" />\n <feColorMatrix in=\"blur\" mode=\"matrix\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 21 -7\"/>\n </filter>\n </defs>\n</svg>\n";
|
1321 | document.body.appendChild(el);
|
1322 | }
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 | var GooeyLoader = function GooeyLoader() {
|
1331 | loadSvgFilter();
|
1332 | return React.createElement(GooeyLoaderContainer, null, React.createElement("div", {
|
1333 | className: "dot dot-1"
|
1334 | }), React.createElement("div", {
|
1335 | className: "dot dot-2"
|
1336 | }), React.createElement("div", {
|
1337 | className: "dot dot-3"
|
1338 | }));
|
1339 | };
|
1340 |
|
1341 | function useAsyncEffect(effect, deps) {
|
1342 | var ref = useRef();
|
1343 | useEffect(function () {
|
1344 | effect({
|
1345 | setCloser: function setCloser(v) {
|
1346 | return ref.current = v;
|
1347 | }
|
1348 | }).then(function (v) {
|
1349 | return typeof v === 'function' ? ref.current = v : null;
|
1350 | })["catch"](function (e) {
|
1351 | console.trace("useAsyncEffect error", deps, e);
|
1352 | });
|
1353 | return function () {
|
1354 | var _ref$current;
|
1355 |
|
1356 | return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.call(ref);
|
1357 | };
|
1358 | }, deps);
|
1359 | }
|
1360 |
|
1361 |
|
1362 |
|
1363 |
|
1364 |
|
1365 |
|
1366 |
|
1367 | function useConstant(fn) {
|
1368 | var ref = React.useRef();
|
1369 |
|
1370 | if (!ref.current) {
|
1371 | ref.current = {
|
1372 | v: fn()
|
1373 | };
|
1374 | }
|
1375 |
|
1376 | return ref.current.v;
|
1377 | }
|
1378 |
|
1379 | function useDebounceEffect(cb, deps, wait) {
|
1380 | var bounce = useMemo(function () {
|
1381 | return debounce(function () {
|
1382 | cb === null || cb === void 0 ? void 0 : cb();
|
1383 | }, wait);
|
1384 | }, [cb, wait]);
|
1385 | useEffect(function () {
|
1386 | bounce();
|
1387 | return function () {
|
1388 | return bounce.cancel();
|
1389 | };
|
1390 | }, deps);
|
1391 | }
|
1392 |
|
1393 | function useForceRender() {
|
1394 |
|
1395 |
|
1396 | var _useReducer = useReducer(function (s) {
|
1397 | return s + 1;
|
1398 | }, 0),
|
1399 | _useReducer2 = _slicedToArray(_useReducer, 2),
|
1400 | forceRender = _useReducer2[1];
|
1401 |
|
1402 | return forceRender;
|
1403 | }
|
1404 |
|
1405 | function useInterval(handler, interval) {
|
1406 | var ref = useRef();
|
1407 |
|
1408 |
|
1409 | useEffect(function () {
|
1410 |
|
1411 | ref.current = setInterval(handler, interval);
|
1412 | return function () {
|
1413 | return clearInterval(ref.current);
|
1414 | };
|
1415 | }, [interval]);
|
1416 | }
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 | function useMounted() {
|
1424 | var _useState = useState(false),
|
1425 | _useState2 = _slicedToArray(_useState, 2),
|
1426 | mounted = _useState2[0],
|
1427 | setMounted = _useState2[1];
|
1428 |
|
1429 | useEffect(function () {
|
1430 | return setMounted(true);
|
1431 | }, []);
|
1432 | return mounted;
|
1433 | }
|
1434 |
|
1435 | function useOnlineEffect() {
|
1436 | var _window, _window$navigator;
|
1437 |
|
1438 | var _useState = useState((_window = window) === null || _window === void 0 ? void 0 : (_window$navigator = _window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.onLine),
|
1439 | _useState2 = _slicedToArray(_useState, 2),
|
1440 | online = _useState2[0],
|
1441 | setOnline = _useState2[1];
|
1442 |
|
1443 | useEffect(function () {
|
1444 | var handler = function handler(e) {
|
1445 | return setOnline(e.type === 'online');
|
1446 | };
|
1447 |
|
1448 | window.addEventListener('online', handler);
|
1449 | window.addEventListener('offline', handler);
|
1450 | return function () {
|
1451 | window.removeEventListener('online', handler);
|
1452 | window.removeEventListener('offline', handler);
|
1453 | };
|
1454 | }, []);
|
1455 | return online;
|
1456 | }
|
1457 |
|
1458 | var NamedThemeContext = React.createContext(new BehaviorSubject(null));
|
1459 | function NamedThemeProvider(_ref) {
|
1460 | var children = _ref.children,
|
1461 | initialTheme = _ref.initialTheme;
|
1462 | var state = useConstant(function () {
|
1463 | return new BehaviorSubject(typeof initialTheme === 'function' ? initialTheme() : initialTheme);
|
1464 | });
|
1465 | useEffect(function () {
|
1466 | return function () {
|
1467 | return state.complete();
|
1468 | };
|
1469 | }, []);
|
1470 | return React.createElement(NamedThemeContext.Provider, {
|
1471 | value: state
|
1472 | }, children);
|
1473 | }
|
1474 | function useNamedTheme() {
|
1475 | var state = useContext(NamedThemeContext);
|
1476 |
|
1477 | var _useState = useState(state.value),
|
1478 | _useState2 = _slicedToArray(_useState, 2),
|
1479 | theme = _useState2[0],
|
1480 | setTheme = _useState2[1];
|
1481 |
|
1482 | useEffect(function () {
|
1483 | var subscribe = state.subscribe(setTheme);
|
1484 | return subscribe.unsubscribe.bind(subscribe);
|
1485 | }, [state]);
|
1486 | return [theme, function (v) {
|
1487 | return state.next(v);
|
1488 | }];
|
1489 | }
|
1490 |
|
1491 | function useEffectOnce(effect) {
|
1492 | React.useEffect(effect, []);
|
1493 | }
|
1494 |
|
1495 | function isPromise(v) {
|
1496 | return v && v.then && v["catch"];
|
1497 | }
|
1498 |
|
1499 | function usePromiseEffect(v) {
|
1500 | var _React$useState = React.useState(function () {
|
1501 | if (isPromise(v)) {
|
1502 | return {
|
1503 | loading: true
|
1504 | };
|
1505 | }
|
1506 |
|
1507 | return {
|
1508 | loading: false,
|
1509 | data: v
|
1510 | };
|
1511 | }),
|
1512 | _React$useState2 = _slicedToArray(_React$useState, 2),
|
1513 | state = _React$useState2[0],
|
1514 | setState = _React$useState2[1];
|
1515 |
|
1516 | React.useEffect(function () {
|
1517 | if (isPromise(v)) {
|
1518 | setState(function (state) {
|
1519 | return _objectSpread2(_objectSpread2({}, state), {}, {
|
1520 | loading: true,
|
1521 | error: undefined
|
1522 | });
|
1523 | });
|
1524 | v.then(function (data) {
|
1525 | return setState({
|
1526 | loading: false,
|
1527 | data: data
|
1528 | });
|
1529 | })["catch"](function (error) {
|
1530 | return setState({
|
1531 | loading: false,
|
1532 | error: error
|
1533 | });
|
1534 | });
|
1535 | } else {
|
1536 |
|
1537 | setState(function (state) {
|
1538 | if (state.data === v) {
|
1539 | return state;
|
1540 | }
|
1541 |
|
1542 | return {
|
1543 | loading: false,
|
1544 | data: v
|
1545 | };
|
1546 | });
|
1547 | }
|
1548 | }, [v]);
|
1549 | return state;
|
1550 | }
|
1551 |
|
1552 | function useFetchEffect(fetcher, deps) {
|
1553 | var _React$useState = React.useState(function () {
|
1554 | try {
|
1555 | return fetcher();
|
1556 | } catch (error) {
|
1557 | return Promise.reject(error);
|
1558 | }
|
1559 | }),
|
1560 | _React$useState2 = _slicedToArray(_React$useState, 2),
|
1561 | result = _React$useState2[0],
|
1562 | setResult = _React$useState2[1];
|
1563 |
|
1564 | var initial = React.useRef(true);
|
1565 | React.useEffect(function () {
|
1566 | if (initial.current) {
|
1567 | initial.current = false;
|
1568 | return;
|
1569 | }
|
1570 |
|
1571 | try {
|
1572 | setResult(fetcher());
|
1573 | } catch (error) {
|
1574 | setResult(Promise.reject(error));
|
1575 | }
|
1576 | }, deps);
|
1577 | return usePromiseEffect(result);
|
1578 | }
|
1579 |
|
1580 |
|
1581 |
|
1582 |
|
1583 |
|
1584 |
|
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 | var _extendStatics = function extendStatics(d, b) {
|
1597 | _extendStatics = Object.setPrototypeOf || {
|
1598 | __proto__: []
|
1599 | } instanceof Array && function (d, b) {
|
1600 | d.__proto__ = b;
|
1601 | } || function (d, b) {
|
1602 | for (var p in b) {
|
1603 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
1604 | }
|
1605 | };
|
1606 |
|
1607 | return _extendStatics(d, b);
|
1608 | };
|
1609 |
|
1610 | function __extends(d, b) {
|
1611 | _extendStatics(d, b);
|
1612 |
|
1613 | function __() {
|
1614 | this.constructor = d;
|
1615 | }
|
1616 |
|
1617 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1618 | }
|
1619 |
|
1620 |
|
1621 | function isFunction(x) {
|
1622 | return typeof x === 'function';
|
1623 | }
|
1624 |
|
1625 |
|
1626 | var _enable_super_gross_mode_that_will_cause_bad_things = false;
|
1627 | var config = {
|
1628 | Promise: undefined,
|
1629 |
|
1630 | set useDeprecatedSynchronousErrorHandling(value) {
|
1631 | if (value) {
|
1632 | var error = new Error();
|
1633 |
|
1634 |
|
1635 | console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
|
1636 | }
|
1637 |
|
1638 | _enable_super_gross_mode_that_will_cause_bad_things = value;
|
1639 | },
|
1640 |
|
1641 | get useDeprecatedSynchronousErrorHandling() {
|
1642 | return _enable_super_gross_mode_that_will_cause_bad_things;
|
1643 | }
|
1644 |
|
1645 | };
|
1646 |
|
1647 |
|
1648 | function hostReportError(err) {
|
1649 | setTimeout(function () {
|
1650 | throw err;
|
1651 | }, 0);
|
1652 | }
|
1653 |
|
1654 |
|
1655 | var empty = {
|
1656 | closed: true,
|
1657 | next: function next(value) {},
|
1658 | error: function error(err) {
|
1659 | if (config.useDeprecatedSynchronousErrorHandling) {
|
1660 | throw err;
|
1661 | } else {
|
1662 | hostReportError(err);
|
1663 | }
|
1664 | },
|
1665 | complete: function complete() {}
|
1666 | };
|
1667 |
|
1668 |
|
1669 | var isArray = function () {
|
1670 | return Array.isArray || function (x) {
|
1671 | return x && typeof x.length === 'number';
|
1672 | };
|
1673 | }();
|
1674 |
|
1675 |
|
1676 | function isObject(x) {
|
1677 | return x !== null && _typeof(x) === 'object';
|
1678 | }
|
1679 |
|
1680 |
|
1681 | var UnsubscriptionErrorImpl = function () {
|
1682 | function UnsubscriptionErrorImpl(errors) {
|
1683 | Error.call(this);
|
1684 | this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) {
|
1685 | return i + 1 + ") " + err.toString();
|
1686 | }).join('\n ') : '';
|
1687 | this.name = 'UnsubscriptionError';
|
1688 | this.errors = errors;
|
1689 | return this;
|
1690 | }
|
1691 |
|
1692 | UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
|
1693 | return UnsubscriptionErrorImpl;
|
1694 | }();
|
1695 |
|
1696 | var UnsubscriptionError = UnsubscriptionErrorImpl;
|
1697 |
|
1698 | var Subscription = function () {
|
1699 | function Subscription(unsubscribe) {
|
1700 | this.closed = false;
|
1701 | this._parentOrParents = null;
|
1702 | this._subscriptions = null;
|
1703 |
|
1704 | if (unsubscribe) {
|
1705 | this._unsubscribe = unsubscribe;
|
1706 | }
|
1707 | }
|
1708 |
|
1709 | Subscription.prototype.unsubscribe = function () {
|
1710 | var errors;
|
1711 |
|
1712 | if (this.closed) {
|
1713 | return;
|
1714 | }
|
1715 |
|
1716 | var _a = this,
|
1717 | _parentOrParents = _a._parentOrParents,
|
1718 | _unsubscribe = _a._unsubscribe,
|
1719 | _subscriptions = _a._subscriptions;
|
1720 |
|
1721 | this.closed = true;
|
1722 | this._parentOrParents = null;
|
1723 | this._subscriptions = null;
|
1724 |
|
1725 | if (_parentOrParents instanceof Subscription) {
|
1726 | _parentOrParents.remove(this);
|
1727 | } else if (_parentOrParents !== null) {
|
1728 | for (var index = 0; index < _parentOrParents.length; ++index) {
|
1729 | var parent_1 = _parentOrParents[index];
|
1730 | parent_1.remove(this);
|
1731 | }
|
1732 | }
|
1733 |
|
1734 | if (isFunction(_unsubscribe)) {
|
1735 | try {
|
1736 | _unsubscribe.call(this);
|
1737 | } catch (e) {
|
1738 | errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
|
1739 | }
|
1740 | }
|
1741 |
|
1742 | if (isArray(_subscriptions)) {
|
1743 | var index = -1;
|
1744 | var len = _subscriptions.length;
|
1745 |
|
1746 | while (++index < len) {
|
1747 | var sub = _subscriptions[index];
|
1748 |
|
1749 | if (isObject(sub)) {
|
1750 | try {
|
1751 | sub.unsubscribe();
|
1752 | } catch (e) {
|
1753 | errors = errors || [];
|
1754 |
|
1755 | if (e instanceof UnsubscriptionError) {
|
1756 | errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
|
1757 | } else {
|
1758 | errors.push(e);
|
1759 | }
|
1760 | }
|
1761 | }
|
1762 | }
|
1763 | }
|
1764 |
|
1765 | if (errors) {
|
1766 | throw new UnsubscriptionError(errors);
|
1767 | }
|
1768 | };
|
1769 |
|
1770 | Subscription.prototype.add = function (teardown) {
|
1771 | var subscription = teardown;
|
1772 |
|
1773 | if (!teardown) {
|
1774 | return Subscription.EMPTY;
|
1775 | }
|
1776 |
|
1777 | switch (_typeof(teardown)) {
|
1778 | case 'function':
|
1779 | subscription = new Subscription(teardown);
|
1780 |
|
1781 | case 'object':
|
1782 | if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
|
1783 | return subscription;
|
1784 | } else if (this.closed) {
|
1785 | subscription.unsubscribe();
|
1786 | return subscription;
|
1787 | } else if (!(subscription instanceof Subscription)) {
|
1788 | var tmp = subscription;
|
1789 | subscription = new Subscription();
|
1790 | subscription._subscriptions = [tmp];
|
1791 | }
|
1792 |
|
1793 | break;
|
1794 |
|
1795 | default:
|
1796 | {
|
1797 | throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
|
1798 | }
|
1799 | }
|
1800 |
|
1801 | var _parentOrParents = subscription._parentOrParents;
|
1802 |
|
1803 | if (_parentOrParents === null) {
|
1804 | subscription._parentOrParents = this;
|
1805 | } else if (_parentOrParents instanceof Subscription) {
|
1806 | if (_parentOrParents === this) {
|
1807 | return subscription;
|
1808 | }
|
1809 |
|
1810 | subscription._parentOrParents = [_parentOrParents, this];
|
1811 | } else if (_parentOrParents.indexOf(this) === -1) {
|
1812 | _parentOrParents.push(this);
|
1813 | } else {
|
1814 | return subscription;
|
1815 | }
|
1816 |
|
1817 | var subscriptions = this._subscriptions;
|
1818 |
|
1819 | if (subscriptions === null) {
|
1820 | this._subscriptions = [subscription];
|
1821 | } else {
|
1822 | subscriptions.push(subscription);
|
1823 | }
|
1824 |
|
1825 | return subscription;
|
1826 | };
|
1827 |
|
1828 | Subscription.prototype.remove = function (subscription) {
|
1829 | var subscriptions = this._subscriptions;
|
1830 |
|
1831 | if (subscriptions) {
|
1832 | var subscriptionIndex = subscriptions.indexOf(subscription);
|
1833 |
|
1834 | if (subscriptionIndex !== -1) {
|
1835 | subscriptions.splice(subscriptionIndex, 1);
|
1836 | }
|
1837 | }
|
1838 | };
|
1839 |
|
1840 | Subscription.EMPTY = function (empty) {
|
1841 | empty.closed = true;
|
1842 | return empty;
|
1843 | }(new Subscription());
|
1844 |
|
1845 | return Subscription;
|
1846 | }();
|
1847 |
|
1848 | function flattenUnsubscriptionErrors(errors) {
|
1849 | return errors.reduce(function (errs, err) {
|
1850 | return errs.concat(err instanceof UnsubscriptionError ? err.errors : err);
|
1851 | }, []);
|
1852 | }
|
1853 |
|
1854 |
|
1855 | var rxSubscriber = function () {
|
1856 | return typeof Symbol === 'function' ? Symbol('rxSubscriber') : '@@rxSubscriber_' + Math.random();
|
1857 | }();
|
1858 |
|
1859 | var Subscriber = function (_super) {
|
1860 | __extends(Subscriber, _super);
|
1861 |
|
1862 | function Subscriber(destinationOrNext, error, complete) {
|
1863 | var _this = _super.call(this) || this;
|
1864 |
|
1865 | _this.syncErrorValue = null;
|
1866 | _this.syncErrorThrown = false;
|
1867 | _this.syncErrorThrowable = false;
|
1868 | _this.isStopped = false;
|
1869 |
|
1870 | switch (arguments.length) {
|
1871 | case 0:
|
1872 | _this.destination = empty;
|
1873 | break;
|
1874 |
|
1875 | case 1:
|
1876 | if (!destinationOrNext) {
|
1877 | _this.destination = empty;
|
1878 | break;
|
1879 | }
|
1880 |
|
1881 | if (_typeof(destinationOrNext) === 'object') {
|
1882 | if (destinationOrNext instanceof Subscriber) {
|
1883 | _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
|
1884 | _this.destination = destinationOrNext;
|
1885 | destinationOrNext.add(_this);
|
1886 | } else {
|
1887 | _this.syncErrorThrowable = true;
|
1888 | _this.destination = new SafeSubscriber(_this, destinationOrNext);
|
1889 | }
|
1890 |
|
1891 | break;
|
1892 | }
|
1893 |
|
1894 | default:
|
1895 | _this.syncErrorThrowable = true;
|
1896 | _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
|
1897 | break;
|
1898 | }
|
1899 |
|
1900 | return _this;
|
1901 | }
|
1902 |
|
1903 | Subscriber.prototype[rxSubscriber] = function () {
|
1904 | return this;
|
1905 | };
|
1906 |
|
1907 | Subscriber.create = function (next, error, complete) {
|
1908 | var subscriber = new Subscriber(next, error, complete);
|
1909 | subscriber.syncErrorThrowable = false;
|
1910 | return subscriber;
|
1911 | };
|
1912 |
|
1913 | Subscriber.prototype.next = function (value) {
|
1914 | if (!this.isStopped) {
|
1915 | this._next(value);
|
1916 | }
|
1917 | };
|
1918 |
|
1919 | Subscriber.prototype.error = function (err) {
|
1920 | if (!this.isStopped) {
|
1921 | this.isStopped = true;
|
1922 |
|
1923 | this._error(err);
|
1924 | }
|
1925 | };
|
1926 |
|
1927 | Subscriber.prototype.complete = function () {
|
1928 | if (!this.isStopped) {
|
1929 | this.isStopped = true;
|
1930 |
|
1931 | this._complete();
|
1932 | }
|
1933 | };
|
1934 |
|
1935 | Subscriber.prototype.unsubscribe = function () {
|
1936 | if (this.closed) {
|
1937 | return;
|
1938 | }
|
1939 |
|
1940 | this.isStopped = true;
|
1941 |
|
1942 | _super.prototype.unsubscribe.call(this);
|
1943 | };
|
1944 |
|
1945 | Subscriber.prototype._next = function (value) {
|
1946 | this.destination.next(value);
|
1947 | };
|
1948 |
|
1949 | Subscriber.prototype._error = function (err) {
|
1950 | this.destination.error(err);
|
1951 | this.unsubscribe();
|
1952 | };
|
1953 |
|
1954 | Subscriber.prototype._complete = function () {
|
1955 | this.destination.complete();
|
1956 | this.unsubscribe();
|
1957 | };
|
1958 |
|
1959 | Subscriber.prototype._unsubscribeAndRecycle = function () {
|
1960 | var _parentOrParents = this._parentOrParents;
|
1961 | this._parentOrParents = null;
|
1962 | this.unsubscribe();
|
1963 | this.closed = false;
|
1964 | this.isStopped = false;
|
1965 | this._parentOrParents = _parentOrParents;
|
1966 | return this;
|
1967 | };
|
1968 |
|
1969 | return Subscriber;
|
1970 | }(Subscription);
|
1971 |
|
1972 | var SafeSubscriber = function (_super) {
|
1973 | __extends(SafeSubscriber, _super);
|
1974 |
|
1975 | function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
|
1976 | var _this = _super.call(this) || this;
|
1977 |
|
1978 | _this._parentSubscriber = _parentSubscriber;
|
1979 | var next;
|
1980 | var context = _this;
|
1981 |
|
1982 | if (isFunction(observerOrNext)) {
|
1983 | next = observerOrNext;
|
1984 | } else if (observerOrNext) {
|
1985 | next = observerOrNext.next;
|
1986 | error = observerOrNext.error;
|
1987 | complete = observerOrNext.complete;
|
1988 |
|
1989 | if (observerOrNext !== empty) {
|
1990 | context = Object.create(observerOrNext);
|
1991 |
|
1992 | if (isFunction(context.unsubscribe)) {
|
1993 | _this.add(context.unsubscribe.bind(context));
|
1994 | }
|
1995 |
|
1996 | context.unsubscribe = _this.unsubscribe.bind(_this);
|
1997 | }
|
1998 | }
|
1999 |
|
2000 | _this._context = context;
|
2001 | _this._next = next;
|
2002 | _this._error = error;
|
2003 | _this._complete = complete;
|
2004 | return _this;
|
2005 | }
|
2006 |
|
2007 | SafeSubscriber.prototype.next = function (value) {
|
2008 | if (!this.isStopped && this._next) {
|
2009 | var _parentSubscriber = this._parentSubscriber;
|
2010 |
|
2011 | if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
2012 | this.__tryOrUnsub(this._next, value);
|
2013 | } else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
|
2014 | this.unsubscribe();
|
2015 | }
|
2016 | }
|
2017 | };
|
2018 |
|
2019 | SafeSubscriber.prototype.error = function (err) {
|
2020 | if (!this.isStopped) {
|
2021 | var _parentSubscriber = this._parentSubscriber;
|
2022 | var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
|
2023 |
|
2024 | if (this._error) {
|
2025 | if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
2026 | this.__tryOrUnsub(this._error, err);
|
2027 |
|
2028 | this.unsubscribe();
|
2029 | } else {
|
2030 | this.__tryOrSetError(_parentSubscriber, this._error, err);
|
2031 |
|
2032 | this.unsubscribe();
|
2033 | }
|
2034 | } else if (!_parentSubscriber.syncErrorThrowable) {
|
2035 | this.unsubscribe();
|
2036 |
|
2037 | if (useDeprecatedSynchronousErrorHandling) {
|
2038 | throw err;
|
2039 | }
|
2040 |
|
2041 | hostReportError(err);
|
2042 | } else {
|
2043 | if (useDeprecatedSynchronousErrorHandling) {
|
2044 | _parentSubscriber.syncErrorValue = err;
|
2045 | _parentSubscriber.syncErrorThrown = true;
|
2046 | } else {
|
2047 | hostReportError(err);
|
2048 | }
|
2049 |
|
2050 | this.unsubscribe();
|
2051 | }
|
2052 | }
|
2053 | };
|
2054 |
|
2055 | SafeSubscriber.prototype.complete = function () {
|
2056 | var _this = this;
|
2057 |
|
2058 | if (!this.isStopped) {
|
2059 | var _parentSubscriber = this._parentSubscriber;
|
2060 |
|
2061 | if (this._complete) {
|
2062 | var wrappedComplete = function wrappedComplete() {
|
2063 | return _this._complete.call(_this._context);
|
2064 | };
|
2065 |
|
2066 | if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
2067 | this.__tryOrUnsub(wrappedComplete);
|
2068 |
|
2069 | this.unsubscribe();
|
2070 | } else {
|
2071 | this.__tryOrSetError(_parentSubscriber, wrappedComplete);
|
2072 |
|
2073 | this.unsubscribe();
|
2074 | }
|
2075 | } else {
|
2076 | this.unsubscribe();
|
2077 | }
|
2078 | }
|
2079 | };
|
2080 |
|
2081 | SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
|
2082 | try {
|
2083 | fn.call(this._context, value);
|
2084 | } catch (err) {
|
2085 | this.unsubscribe();
|
2086 |
|
2087 | if (config.useDeprecatedSynchronousErrorHandling) {
|
2088 | throw err;
|
2089 | } else {
|
2090 | hostReportError(err);
|
2091 | }
|
2092 | }
|
2093 | };
|
2094 |
|
2095 | SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
|
2096 | if (!config.useDeprecatedSynchronousErrorHandling) {
|
2097 | throw new Error('bad call');
|
2098 | }
|
2099 |
|
2100 | try {
|
2101 | fn.call(this._context, value);
|
2102 | } catch (err) {
|
2103 | if (config.useDeprecatedSynchronousErrorHandling) {
|
2104 | parent.syncErrorValue = err;
|
2105 | parent.syncErrorThrown = true;
|
2106 | return true;
|
2107 | } else {
|
2108 | hostReportError(err);
|
2109 | return true;
|
2110 | }
|
2111 | }
|
2112 |
|
2113 | return false;
|
2114 | };
|
2115 |
|
2116 | SafeSubscriber.prototype._unsubscribe = function () {
|
2117 | var _parentSubscriber = this._parentSubscriber;
|
2118 | this._context = null;
|
2119 | this._parentSubscriber = null;
|
2120 |
|
2121 | _parentSubscriber.unsubscribe();
|
2122 | };
|
2123 |
|
2124 | return SafeSubscriber;
|
2125 | }(Subscriber);
|
2126 |
|
2127 |
|
2128 | function skip(count) {
|
2129 | return function (source) {
|
2130 | return source.lift(new SkipOperator(count));
|
2131 | };
|
2132 | }
|
2133 |
|
2134 | var SkipOperator = function () {
|
2135 | function SkipOperator(total) {
|
2136 | this.total = total;
|
2137 | }
|
2138 |
|
2139 | SkipOperator.prototype.call = function (subscriber, source) {
|
2140 | return source.subscribe(new SkipSubscriber(subscriber, this.total));
|
2141 | };
|
2142 |
|
2143 | return SkipOperator;
|
2144 | }();
|
2145 |
|
2146 | var SkipSubscriber = function (_super) {
|
2147 | __extends(SkipSubscriber, _super);
|
2148 |
|
2149 | function SkipSubscriber(destination, total) {
|
2150 | var _this = _super.call(this, destination) || this;
|
2151 |
|
2152 | _this.total = total;
|
2153 | _this.count = 0;
|
2154 | return _this;
|
2155 | }
|
2156 |
|
2157 | SkipSubscriber.prototype._next = function (x) {
|
2158 | if (++this.count > this.total) {
|
2159 | this.destination.next(x);
|
2160 | }
|
2161 | };
|
2162 |
|
2163 | return SkipSubscriber;
|
2164 | }(Subscriber);
|
2165 |
|
2166 | function n(n) {
|
2167 | for (var t = arguments.length, r = Array(t > 1 ? t - 1 : 0), e = 1; e < t; e++) {
|
2168 | r[e - 1] = arguments[e];
|
2169 | }
|
2170 |
|
2171 | if ("production" !== process.env.NODE_ENV) {
|
2172 | var i = L[n],
|
2173 | o = i ? "function" == typeof i ? i.apply(null, r) : i : "unknown error nr: " + n;
|
2174 | throw Error("[Immer] " + o);
|
2175 | }
|
2176 |
|
2177 | throw Error("[Immer] minified error nr: " + n + (r.length ? " " + r.join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
|
2178 | }
|
2179 |
|
2180 | function t(n) {
|
2181 | return !!n && !!n[G];
|
2182 | }
|
2183 |
|
2184 | function r(n) {
|
2185 | return !!n && (function (n) {
|
2186 | if (!n || "object" != _typeof(n)) return !1;
|
2187 | var t = Object.getPrototypeOf(n);
|
2188 | return !t || t === Object.prototype;
|
2189 | }(n) || Array.isArray(n) || !!n[B] || !!n.constructor[B] || c(n) || s(n));
|
2190 | }
|
2191 |
|
2192 | function i(n, t, r) {
|
2193 | void 0 === r && (r = !1), 0 === o(n) ? (r ? Object.keys : Q)(n).forEach(function (r) {
|
2194 | return t(r, n[r], n);
|
2195 | }) : n.forEach(function (r, e) {
|
2196 | return t(e, r, n);
|
2197 | });
|
2198 | }
|
2199 |
|
2200 | function o(n) {
|
2201 | var t = n[G];
|
2202 | return t ? t.i > 3 ? t.i - 4 : t.i : Array.isArray(n) ? 1 : c(n) ? 2 : s(n) ? 3 : 0;
|
2203 | }
|
2204 |
|
2205 | function u(n, t) {
|
2206 | return 2 === o(n) ? n.has(t) : Object.prototype.hasOwnProperty.call(n, t);
|
2207 | }
|
2208 |
|
2209 | function a(n, t) {
|
2210 | return 2 === o(n) ? n.get(t) : n[t];
|
2211 | }
|
2212 |
|
2213 | function f(n, t) {
|
2214 | return n === t ? 0 !== n || 1 / n == 1 / t : n != n && t != t;
|
2215 | }
|
2216 |
|
2217 | function c(n) {
|
2218 | return U && n instanceof Map;
|
2219 | }
|
2220 |
|
2221 | function s(n) {
|
2222 | return W && n instanceof Set;
|
2223 | }
|
2224 |
|
2225 | function v(n) {
|
2226 | return n.o || n.t;
|
2227 | }
|
2228 |
|
2229 | function p(t, r) {
|
2230 | if (void 0 === r && (r = !1), Array.isArray(t)) return t.slice();
|
2231 | var e = Object.create(Object.getPrototypeOf(t));
|
2232 | return i(t, function (i) {
|
2233 | if (i !== G) {
|
2234 | var o = Object.getOwnPropertyDescriptor(t, i),
|
2235 | u = o.value;
|
2236 | o.get && (r || n(1), u = o.get.call(t)), o.enumerable ? e[i] = u : Object.defineProperty(e, i, {
|
2237 | value: u,
|
2238 | writable: !0,
|
2239 | configurable: !0
|
2240 | });
|
2241 | }
|
2242 | }), e;
|
2243 | }
|
2244 |
|
2245 | function d(n, e) {
|
2246 | t(n) || h(n) || !r(n) || (o(n) > 1 && (n.set = n.add = n.clear = n["delete"] = l), Object.freeze(n), e && i(n, function (n, t) {
|
2247 | return d(t, !0);
|
2248 | }, !0));
|
2249 | }
|
2250 |
|
2251 | function l() {
|
2252 | n(2);
|
2253 | }
|
2254 |
|
2255 | function h(n) {
|
2256 | return null == n || "object" != _typeof(n) || Object.isFrozen(n);
|
2257 | }
|
2258 |
|
2259 | function y(t) {
|
2260 | var r = V[t];
|
2261 | return r || n("production" !== process.env.NODE_ENV ? 18 : 19, t), r;
|
2262 | }
|
2263 |
|
2264 | function m() {
|
2265 | return "production" === process.env.NODE_ENV || K || n(0), K;
|
2266 | }
|
2267 |
|
2268 | function _(n, t) {
|
2269 | t && (y("Patches"), n.u = [], n.s = [], n.v = t);
|
2270 | }
|
2271 |
|
2272 | function j(n) {
|
2273 | O(n), n.p.forEach(w), n.p = null;
|
2274 | }
|
2275 |
|
2276 | function O(n) {
|
2277 | n === K && (K = n.l);
|
2278 | }
|
2279 |
|
2280 | function g(n) {
|
2281 | return K = {
|
2282 | p: [],
|
2283 | l: K,
|
2284 | h: n,
|
2285 | m: !0,
|
2286 | _: 0
|
2287 | };
|
2288 | }
|
2289 |
|
2290 | function w(n) {
|
2291 | var t = n[G];
|
2292 | 0 === t.i || 1 === t.i ? t.j() : t.O = !0;
|
2293 | }
|
2294 |
|
2295 | function S(t, e) {
|
2296 | e._ = e.p.length;
|
2297 | var i = e.p[0],
|
2298 | o = void 0 !== t && t !== i;
|
2299 | return e.h.g || y("ES5").S(e, t, o), o ? (i[G].P && (j(e), n(4)), r(t) && (t = P(e, t), e.l || A(e, t)), e.u && y("Patches").M(i[G], t, e.u, e.s)) : t = P(e, i, []), j(e), e.u && e.v(e.u, e.s), t !== q ? t : void 0;
|
2300 | }
|
2301 |
|
2302 | function P(n, t, r) {
|
2303 | if (h(t)) return t;
|
2304 | var e = t[G];
|
2305 | if (!e) return i(t, function (i, o) {
|
2306 | return M(n, e, t, i, o, r);
|
2307 | }, !0), t;
|
2308 | if (e.A !== n) return t;
|
2309 | if (!e.P) return A(n, e.t, !0), e.t;
|
2310 |
|
2311 | if (!e.I) {
|
2312 | e.I = !0, e.A._--;
|
2313 | var o = 4 === e.i || 5 === e.i ? e.o = p(e.k, !0) : e.o;
|
2314 | i(o, function (t, i) {
|
2315 | return M(n, e, o, t, i, r);
|
2316 | }), A(n, o, !1), r && n.u && y("Patches").R(e, r, n.u, n.s);
|
2317 | }
|
2318 |
|
2319 | return e.o;
|
2320 | }
|
2321 |
|
2322 | function M(e, i, c, s, v, p) {
|
2323 | if ("production" !== process.env.NODE_ENV && v === c && n(5), t(v)) {
|
2324 | var d = P(e, v, p && i && 3 !== i.i && !u(i.D, s) ? p.concat(s) : void 0);
|
2325 | if (h = s, y = d, 2 === (b = o(l = c)) ? l.set(h, y) : 3 === b ? (l["delete"](h), l.add(y)) : l[h] = y, !t(d)) return;
|
2326 | e.m = !1;
|
2327 | }
|
2328 |
|
2329 | var l, h, y, b;
|
2330 |
|
2331 | if ((!i || !f(v, a(i.t, s))) && r(v)) {
|
2332 | if (!e.h.N && e._ < 1) return;
|
2333 | P(e, v), i && i.A.l || A(e, v);
|
2334 | }
|
2335 | }
|
2336 |
|
2337 | function A(n, t, r) {
|
2338 | void 0 === r && (r = !1), n.h.N && n.m && d(t, r);
|
2339 | }
|
2340 |
|
2341 | function x(n, t) {
|
2342 | var r = n[G],
|
2343 | e = Reflect.getOwnPropertyDescriptor(r ? v(r) : n, t);
|
2344 | return e && e.value;
|
2345 | }
|
2346 |
|
2347 | function z(n) {
|
2348 | if (!n.P) {
|
2349 | if (n.P = !0, 0 === n.i || 1 === n.i) {
|
2350 | var t = n.o = p(n.t);
|
2351 | i(n.p, function (n, r) {
|
2352 | t[n] = r;
|
2353 | }), n.p = void 0;
|
2354 | }
|
2355 |
|
2356 | n.l && z(n.l);
|
2357 | }
|
2358 | }
|
2359 |
|
2360 | function I(n) {
|
2361 | n.o || (n.o = p(n.t));
|
2362 | }
|
2363 |
|
2364 | function E(n, t, r) {
|
2365 | var e = c(t) ? y("MapSet").T(t, r) : s(t) ? y("MapSet").F(t, r) : n.g ? function (n, t) {
|
2366 | var r = Array.isArray(n),
|
2367 | e = {
|
2368 | i: r ? 1 : 0,
|
2369 | A: t ? t.A : m(),
|
2370 | P: !1,
|
2371 | I: !1,
|
2372 | D: {},
|
2373 | l: t,
|
2374 | t: n,
|
2375 | k: null,
|
2376 | p: {},
|
2377 | o: null,
|
2378 | j: null,
|
2379 | C: !1
|
2380 | },
|
2381 | i = e,
|
2382 | o = Y;
|
2383 | r && (i = [e], o = Z);
|
2384 | var u = Proxy.revocable(i, o),
|
2385 | a = u.revoke,
|
2386 | f = u.proxy;
|
2387 | return e.k = f, e.j = a, f;
|
2388 | }(t, r) : y("ES5").J(t, r);
|
2389 | return (r ? r.A : m()).p.push(e), e;
|
2390 | }
|
2391 |
|
2392 | var J,
|
2393 | K,
|
2394 | $ = "undefined" != typeof Symbol && "symbol" == _typeof(Symbol("x")),
|
2395 | U = "undefined" != typeof Map,
|
2396 | W = "undefined" != typeof Set,
|
2397 | X = "undefined" != typeof Proxy && void 0 !== Proxy.revocable && "undefined" != typeof Reflect,
|
2398 | q = $ ? Symbol("immer-nothing") : ((J = {})["immer-nothing"] = !0, J),
|
2399 | B = $ ? Symbol("immer-draftable") : "__$immer_draftable",
|
2400 | G = $ ? Symbol("immer-state") : "__$immer_state",
|
2401 | L = {
|
2402 | 0: "Illegal state",
|
2403 | 1: "Immer drafts cannot have computed properties",
|
2404 | 2: "This object has been frozen and should not be mutated",
|
2405 | 3: function _(n) {
|
2406 | return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + n;
|
2407 | },
|
2408 | 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
|
2409 | 5: "Immer forbids circular references",
|
2410 | 6: "The first or second argument to `produce` must be a function",
|
2411 | 7: "The third argument to `produce` must be a function or undefined",
|
2412 | 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object",
|
2413 | 9: "First argument to `finishDraft` must be a draft returned by `createDraft`",
|
2414 | 10: "The given draft is already finalized",
|
2415 | 11: "Object.defineProperty() cannot be used on an Immer draft",
|
2416 | 12: "Object.setPrototypeOf() cannot be used on an Immer draft",
|
2417 | 13: "Immer only supports deleting array indices",
|
2418 | 14: "Immer only supports setting array indices and the 'length' property",
|
2419 | 15: function _(n) {
|
2420 | return "Cannot apply patch, path doesn't resolve: " + n;
|
2421 | },
|
2422 | 16: 'Sets cannot have "replace" patches.',
|
2423 | 17: function _(n) {
|
2424 | return "Unsupported patch operation: " + n;
|
2425 | },
|
2426 | 18: function _(n) {
|
2427 | return "The plugin for '" + n + "' has not been loaded into Immer. To enable the plugin, import and call `enable" + n + "()` when initializing your application.";
|
2428 | },
|
2429 | 19: function _(n) {
|
2430 | return "plugin not loaded: " + n;
|
2431 | },
|
2432 | 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available"
|
2433 | },
|
2434 | Q = "undefined" != typeof Reflect && Reflect.ownKeys ? Reflect.ownKeys : void 0 !== Object.getOwnPropertySymbols ? function (n) {
|
2435 | return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n));
|
2436 | } : Object.getOwnPropertyNames,
|
2437 | V = {},
|
2438 | Y = {
|
2439 | get: function get(n, t) {
|
2440 | if (t === G) return n;
|
2441 | var e = n.p;
|
2442 | if (!n.P && u(e, t)) return e[t];
|
2443 | var i = v(n)[t];
|
2444 | if (n.I || !r(i)) return i;
|
2445 |
|
2446 | if (n.P) {
|
2447 | if (i !== x(n.t, t)) return i;
|
2448 | e = n.o;
|
2449 | }
|
2450 |
|
2451 | return e[t] = E(n.A.h, i, n);
|
2452 | },
|
2453 | has: function has(n, t) {
|
2454 | return t in v(n);
|
2455 | },
|
2456 | ownKeys: function ownKeys(n) {
|
2457 | return Reflect.ownKeys(v(n));
|
2458 | },
|
2459 | set: function set(n, t, r) {
|
2460 | if (!n.P) {
|
2461 | var e = x(n.t, t);
|
2462 | if (r ? f(e, r) || r === n.p[t] : f(e, r) && t in n.t) return !0;
|
2463 | I(n), z(n);
|
2464 | }
|
2465 |
|
2466 | return n.D[t] = !0, n.o[t] = r, !0;
|
2467 | },
|
2468 | deleteProperty: function deleteProperty(n, t) {
|
2469 | return void 0 !== x(n.t, t) || t in n.t ? (n.D[t] = !1, I(n), z(n)) : n.D[t] && delete n.D[t], n.o && delete n.o[t], !0;
|
2470 | },
|
2471 | getOwnPropertyDescriptor: function getOwnPropertyDescriptor(n, t) {
|
2472 | var r = v(n),
|
2473 | e = Reflect.getOwnPropertyDescriptor(r, t);
|
2474 | return e && (e.writable = !0, e.configurable = 1 !== n.i || "length" !== t), e;
|
2475 | },
|
2476 | defineProperty: function defineProperty() {
|
2477 | n(11);
|
2478 | },
|
2479 | getPrototypeOf: function getPrototypeOf(n) {
|
2480 | return Object.getPrototypeOf(n.t);
|
2481 | },
|
2482 | setPrototypeOf: function setPrototypeOf() {
|
2483 | n(12);
|
2484 | }
|
2485 | },
|
2486 | Z = {};
|
2487 |
|
2488 | i(Y, function (n, t) {
|
2489 | Z[n] = function () {
|
2490 | return arguments[0] = arguments[0][0], t.apply(this, arguments);
|
2491 | };
|
2492 | }), Z.deleteProperty = function (t, r) {
|
2493 | return "production" !== process.env.NODE_ENV && isNaN(parseInt(r)) && n(13), Y.deleteProperty.call(this, t[0], r);
|
2494 | }, Z.set = function (t, r, e) {
|
2495 | return "production" !== process.env.NODE_ENV && "length" !== r && isNaN(parseInt(r)) && n(14), Y.set.call(this, t[0], r, e, t[0]);
|
2496 | };
|
2497 |
|
2498 | var nn = function () {
|
2499 | function e(n) {
|
2500 | this.g = X, this.N = "production" !== process.env.NODE_ENV, "boolean" == typeof (null == n ? void 0 : n.useProxies) && this.setUseProxies(n.useProxies), "boolean" == typeof (null == n ? void 0 : n.autoFreeze) && this.setAutoFreeze(n.autoFreeze), this.produce = this.produce.bind(this), this.produceWithPatches = this.produceWithPatches.bind(this);
|
2501 | }
|
2502 |
|
2503 | var i = e.prototype;
|
2504 | return i.produce = function (t, e, i) {
|
2505 | if ("function" == typeof t && "function" != typeof e) {
|
2506 | var o = e;
|
2507 | e = t;
|
2508 | var u = this;
|
2509 | return function (n) {
|
2510 | var t = this;
|
2511 | void 0 === n && (n = o);
|
2512 |
|
2513 | for (var r = arguments.length, i = Array(r > 1 ? r - 1 : 0), a = 1; a < r; a++) {
|
2514 | i[a - 1] = arguments[a];
|
2515 | }
|
2516 |
|
2517 | return u.produce(n, function (n) {
|
2518 | var r;
|
2519 | return (r = e).call.apply(r, [t, n].concat(i));
|
2520 | });
|
2521 | };
|
2522 | }
|
2523 |
|
2524 | var a;
|
2525 |
|
2526 | if ("function" != typeof e && n(6), void 0 !== i && "function" != typeof i && n(7), r(t)) {
|
2527 | var f = g(this),
|
2528 | c = E(this, t, void 0),
|
2529 | s = !0;
|
2530 |
|
2531 | try {
|
2532 | a = e(c), s = !1;
|
2533 | } finally {
|
2534 | s ? j(f) : O(f);
|
2535 | }
|
2536 |
|
2537 | return "undefined" != typeof Promise && a instanceof Promise ? a.then(function (n) {
|
2538 | return _(f, i), S(n, f);
|
2539 | }, function (n) {
|
2540 | throw j(f), n;
|
2541 | }) : (_(f, i), S(a, f));
|
2542 | }
|
2543 |
|
2544 | if ((a = e(t)) !== q) return void 0 === a && (a = t), this.N && d(a, !0), a;
|
2545 | }, i.produceWithPatches = function (n, t) {
|
2546 | var r,
|
2547 | e,
|
2548 | i = this;
|
2549 | return "function" == typeof n ? function (t) {
|
2550 | for (var r = arguments.length, e = Array(r > 1 ? r - 1 : 0), o = 1; o < r; o++) {
|
2551 | e[o - 1] = arguments[o];
|
2552 | }
|
2553 |
|
2554 | return i.produceWithPatches(t, function (t) {
|
2555 | return n.apply(void 0, [t].concat(e));
|
2556 | });
|
2557 | } : [this.produce(n, t, function (n, t) {
|
2558 | r = n, e = t;
|
2559 | }), r, e];
|
2560 | }, i.createDraft = function (t) {
|
2561 | r(t) || n(8);
|
2562 | var e = g(this),
|
2563 | i = E(this, t, void 0);
|
2564 | return i[G].C = !0, O(e), i;
|
2565 | }, i.finishDraft = function (t, r) {
|
2566 | var e = t && t[G];
|
2567 | "production" !== process.env.NODE_ENV && (e && e.C || n(9), e.I && n(10));
|
2568 | var i = e.A;
|
2569 | return _(i, r), S(void 0, i);
|
2570 | }, i.setAutoFreeze = function (n) {
|
2571 | this.N = n;
|
2572 | }, i.setUseProxies = function (t) {
|
2573 | X || n(20), this.g = t;
|
2574 | }, i.applyPatches = function (n, r) {
|
2575 | var e;
|
2576 |
|
2577 | for (e = r.length - 1; e >= 0; e--) {
|
2578 | var i = r[e];
|
2579 |
|
2580 | if (0 === i.path.length && "replace" === i.op) {
|
2581 | n = i.value;
|
2582 | break;
|
2583 | }
|
2584 | }
|
2585 |
|
2586 | var o = y("Patches").U;
|
2587 | return t(n) ? o(n, r) : this.produce(n, function (n) {
|
2588 | return o(n, r.slice(e + 1));
|
2589 | });
|
2590 | }, e;
|
2591 | }(),
|
2592 | tn = new nn(),
|
2593 | rn = tn.produce,
|
2594 | en = tn.produceWithPatches.bind(tn),
|
2595 | on = tn.setAutoFreeze.bind(tn),
|
2596 | un = tn.setUseProxies.bind(tn),
|
2597 | an = tn.applyPatches.bind(tn),
|
2598 | fn = tn.createDraft.bind(tn),
|
2599 | cn = tn.finishDraft.bind(tn);
|
2600 |
|
2601 | var EMPTY = Symbol();
|
2602 | function createSubscriptionContainer(useHook) {
|
2603 | var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
2604 | isEqual: function isEqual(a, b) {
|
2605 | return a === b;
|
2606 | }
|
2607 | },
|
2608 | isEqual = _ref.isEqual;
|
2609 |
|
2610 | var Context = React.createContext(EMPTY);
|
2611 |
|
2612 | function Provider(props) {
|
2613 | var subject = useConstant(function () {
|
2614 | var initialState = props.initialState;
|
2615 |
|
2616 | return new BehaviorSubject(typeof initialState === 'function' ? initialState() : initialState);
|
2617 | });
|
2618 | var container = useConstant(function () {
|
2619 | var setStateReal = function setStateReal(state) {
|
2620 | var next;
|
2621 |
|
2622 | if (typeof state === 'function') {
|
2623 | next = state(subject.getValue());
|
2624 | } else {
|
2625 | next = state;
|
2626 | }
|
2627 |
|
2628 | subject.next(next);
|
2629 | };
|
2630 |
|
2631 |
|
2632 | var changing = false;
|
2633 |
|
2634 | var setState = function setState(state) {
|
2635 | if (changing) {
|
2636 | setTimeout(function () {
|
2637 | return setState(state);
|
2638 | }, 0);
|
2639 | return;
|
2640 | }
|
2641 |
|
2642 | changing = true;
|
2643 |
|
2644 | try {
|
2645 | setStateReal(state);
|
2646 | } finally {
|
2647 | changing = false;
|
2648 | }
|
2649 | };
|
2650 |
|
2651 | var options = {
|
2652 | getState: function getState() {
|
2653 | return subject.getValue();
|
2654 | },
|
2655 | setState: setState,
|
2656 | updateState: function updateState(fn) {
|
2657 |
|
2658 | setState(rn(function (v) {
|
2659 | fn(v);
|
2660 | }));
|
2661 | },
|
2662 | subscribe: function subscribe(cb) {
|
2663 | var subscription = subject.subscribe(cb);
|
2664 | return subscription.unsubscribe.bind(subscription);
|
2665 | }
|
2666 | };
|
2667 | return useHook(options);
|
2668 | });
|
2669 | return React.createElement(Context.Provider, {
|
2670 | value: {
|
2671 | container: container,
|
2672 | subject: subject
|
2673 | }
|
2674 | }, props.children);
|
2675 | }
|
2676 |
|
2677 | function useContainer() {
|
2678 | var context = React.useContext(Context);
|
2679 |
|
2680 | if (context === EMPTY) {
|
2681 | throw new Error('Component must be wrapped with <SubscriptionContainer.Provider>');
|
2682 | }
|
2683 |
|
2684 | return context.container;
|
2685 | }
|
2686 |
|
2687 | function useSelector(selector) {
|
2688 | var eq = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isEqual;
|
2689 | var context = React.useContext(Context);
|
2690 |
|
2691 | if (context === EMPTY) {
|
2692 | throw new Error('Component must be wrapped with <SubscriptionContainer.Provider>');
|
2693 | }
|
2694 |
|
2695 | var subject = context.subject;
|
2696 |
|
2697 | var _React$useState = React.useState(function () {
|
2698 | return selector(subject.getValue());
|
2699 | }),
|
2700 | _React$useState2 = _slicedToArray(_React$useState, 2),
|
2701 | state = _React$useState2[0],
|
2702 | setState = _React$useState2[1];
|
2703 |
|
2704 | useEffect(function () {
|
2705 | var subscription = subject.pipe(skip(1)).subscribe(function (s) {
|
2706 | setState(function (old) {
|
2707 | var next = selector(s);
|
2708 |
|
2709 | if (eq(old, next)) {
|
2710 | return old;
|
2711 | }
|
2712 |
|
2713 | return next;
|
2714 | });
|
2715 | });
|
2716 | return function () {
|
2717 | return subscription.unsubscribe();
|
2718 | };
|
2719 | }, []);
|
2720 | return state;
|
2721 | }
|
2722 |
|
2723 | function useState() {
|
2724 | return useSelector(function (v) {
|
2725 | return v;
|
2726 | });
|
2727 | }
|
2728 |
|
2729 | function useWhenValueChange(selector, cb) {
|
2730 | var eq = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isEqual;
|
2731 | var context = React.useContext(Context);
|
2732 |
|
2733 | if (context === EMPTY) {
|
2734 | throw new Error('Component must be wrapped with <SubscriptionContainer.Provider>');
|
2735 | }
|
2736 |
|
2737 | var subject = context.subject;
|
2738 | var ref = React.useRef();
|
2739 | useEffect(function () {
|
2740 | ref.current = selector(subject.getValue());
|
2741 | var subscription = subject.subscribe(function (s) {
|
2742 | var old = ref.current;
|
2743 | var next = selector(s);
|
2744 |
|
2745 | if (!eq(old, next)) {
|
2746 | cb(next);
|
2747 | ref.current = next;
|
2748 | }
|
2749 | });
|
2750 | return function () {
|
2751 | return subscription.unsubscribe();
|
2752 | };
|
2753 | }, []);
|
2754 | }
|
2755 |
|
2756 | return {
|
2757 | Provider: Provider,
|
2758 | useContainer: useContainer,
|
2759 | useSelector: useSelector,
|
2760 | useState: useState,
|
2761 | useWhenValueChange: useWhenValueChange
|
2762 | };
|
2763 | }
|
2764 |
|
2765 |
|
2766 | var EMPTY$1 = Symbol();
|
2767 | function createContainer(useHook) {
|
2768 | var Context = React.createContext(EMPTY$1);
|
2769 |
|
2770 | function Provider(props) {
|
2771 | var value = useHook(props.initialState);
|
2772 | return React.createElement(Context.Provider, {
|
2773 | value: value
|
2774 | }, props.children);
|
2775 | }
|
2776 |
|
2777 | function useContainer() {
|
2778 | var value = React.useContext(Context);
|
2779 |
|
2780 | if (value === EMPTY$1) {
|
2781 | throw new Error('Component must be wrapped with <Container.Provider>');
|
2782 | }
|
2783 |
|
2784 | return value;
|
2785 | }
|
2786 |
|
2787 | return {
|
2788 | Provider: Provider,
|
2789 | useContainer: useContainer
|
2790 | };
|
2791 | }
|
2792 | function useContainer(container) {
|
2793 | return container.useContainer();
|
2794 | }
|
2795 |
|
2796 | function withProps(WrappedComponent, extra) {
|
2797 | return function (props) {
|
2798 | return React.createElement(WrappedComponent, Object.assign({}, props, extra));
|
2799 | };
|
2800 | }
|
2801 |
|
2802 | export { BarsSpinner, BoxShuffle, GooeyLoader, GradientSpinner, NamedThemeProvider, PlanetRotatingBox, PlantRotating, PulseBubble, SolarSystemSpinner, createContainer, createSubscriptionContainer, useAsyncEffect, useConstant, useContainer, useDebounceEffect, useEffectOnce, useFetchEffect, useForceRender, useInterval, useMounted, useNamedTheme, useOnlineEffect, usePromiseEffect, withProps };
|
2803 |
|