styled-components 6.0.0-beta.9 → 6.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/base.d.ts +2 -8
  2. package/dist/constructors/constructWithOptions.d.ts +6 -6
  3. package/dist/hoc/withTheme.d.ts +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/models/ComponentStyle.d.ts +0 -1
  6. package/dist/models/StyleSheetManager.d.ts +27 -9
  7. package/dist/models/ThemeProvider.d.ts +4 -3
  8. package/dist/native/index.d.ts +25 -26
  9. package/dist/sheet/GroupedTag.d.ts +1 -1
  10. package/dist/sheet/Sheet.d.ts +3 -3
  11. package/dist/sheet/types.d.ts +1 -1
  12. package/dist/styled-components-macro.cjs.js +0 -1
  13. package/dist/styled-components-macro.cjs.js.map +1 -1
  14. package/dist/styled-components-macro.esm.js +0 -1
  15. package/dist/styled-components-macro.esm.js.map +1 -1
  16. package/dist/styled-components.browser.cjs.js +1 -1845
  17. package/dist/styled-components.browser.cjs.js.map +1 -1
  18. package/dist/styled-components.browser.esm.js +1 -1819
  19. package/dist/styled-components.browser.esm.js.map +1 -1
  20. package/dist/styled-components.cjs.js +1 -1865
  21. package/dist/styled-components.cjs.js.map +1 -1
  22. package/dist/styled-components.esm.js +1 -1839
  23. package/dist/styled-components.esm.js.map +1 -1
  24. package/dist/styled-components.js +258 -235
  25. package/dist/styled-components.js.map +1 -1
  26. package/dist/styled-components.min.js +1 -1
  27. package/dist/styled-components.min.js.map +1 -1
  28. package/dist/test/types.d.ts +9 -0
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/dist/types.d.ts +34 -41
  31. package/dist/utils/determineTheme.d.ts +4 -2
  32. package/dist/utils/domElements.d.ts +1 -1
  33. package/dist/utils/flatten.d.ts +1 -1
  34. package/dist/utils/hoist.d.ts +3 -3
  35. package/dist/utils/isFunction.d.ts +1 -1
  36. package/dist/utils/isPlainObject.d.ts +1 -1
  37. package/dist/utils/isStatelessFunction.d.ts +1 -1
  38. package/dist/utils/joinStrings.d.ts +2 -1
  39. package/dist/utils/stylis.d.ts +1 -1
  40. package/native/dist/base.d.ts +2 -8
  41. package/native/dist/constructors/constructWithOptions.d.ts +6 -6
  42. package/native/dist/hoc/withTheme.d.ts +1 -1
  43. package/native/dist/index.d.ts +1 -1
  44. package/native/dist/models/ComponentStyle.d.ts +0 -1
  45. package/native/dist/models/StyleSheetManager.d.ts +27 -9
  46. package/native/dist/models/ThemeProvider.d.ts +4 -3
  47. package/native/dist/native/index.d.ts +25 -26
  48. package/native/dist/sheet/GroupedTag.d.ts +1 -1
  49. package/native/dist/sheet/Sheet.d.ts +3 -3
  50. package/native/dist/sheet/types.d.ts +1 -1
  51. package/native/dist/styled-components.native.cjs.js +1 -1305
  52. package/native/dist/styled-components.native.cjs.js.map +1 -1
  53. package/native/dist/styled-components.native.esm.js +1 -1287
  54. package/native/dist/styled-components.native.esm.js.map +1 -1
  55. package/native/dist/test/types.d.ts +9 -0
  56. package/native/dist/types.d.ts +34 -41
  57. package/native/dist/utils/determineTheme.d.ts +4 -2
  58. package/native/dist/utils/domElements.d.ts +1 -1
  59. package/native/dist/utils/flatten.d.ts +1 -1
  60. package/native/dist/utils/hoist.d.ts +3 -3
  61. package/native/dist/utils/isFunction.d.ts +1 -1
  62. package/native/dist/utils/isPlainObject.d.ts +1 -1
  63. package/native/dist/utils/isStatelessFunction.d.ts +1 -1
  64. package/native/dist/utils/joinStrings.d.ts +2 -1
  65. package/native/dist/utils/stylis.d.ts +1 -1
  66. package/package.json +23 -48
  67. package/dist/hooks/useTheme.d.ts +0 -3
@@ -1,1820 +1,2 @@
1
- import { __spreadArray, __assign } from 'tslib';
2
- import React, { useRef, useState, useMemo, useEffect, useContext, useDebugValue, createElement } from 'react';
3
- import shallowequal from 'shallowequal';
4
- import { prefixer, stringify, middleware, compile, RULESET } from 'stylis';
5
- import unitless from '@emotion/unitless';
6
-
7
- var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
8
- 'data-styled';
9
- var SC_ATTR_ACTIVE = 'active';
10
- var SC_ATTR_VERSION = 'data-styled-version';
11
- var SC_VERSION = "6.0.0-beta.9";
12
- var SPLITTER = '/*!sc*/\n';
13
- var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
14
- var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
15
- ? SC_DISABLE_SPEEDY
16
- : typeof process !== 'undefined' &&
17
- typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' &&
18
- process.env.REACT_APP_SC_DISABLE_SPEEDY !== ''
19
- ? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false'
20
- ? false
21
- : process.env.REACT_APP_SC_DISABLE_SPEEDY
22
- : typeof process !== 'undefined' &&
23
- typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' &&
24
- process.env.SC_DISABLE_SPEEDY !== ''
25
- ? process.env.SC_DISABLE_SPEEDY === 'false'
26
- ? false
27
- : process.env.SC_DISABLE_SPEEDY
28
- : process.env.NODE_ENV !== 'production');
29
- // Shared empty execution context when generating static styles
30
- var STATIC_EXECUTION_CONTEXT = {};
31
-
32
- var invalidHookCallRe = /invalid hook call/i;
33
- var seen = new Set();
34
- var checkDynamicCreation = function (displayName, componentId) {
35
- if (process.env.NODE_ENV !== 'production') {
36
- var parsedIdString = componentId ? " with the id of \"".concat(componentId, "\"") : '';
37
- var message_1 = "The component ".concat(displayName).concat(parsedIdString, " has been created dynamically.\n") +
38
- "You may see this warning because you've called styled inside another component.\n" +
39
- 'To resolve this only create new StyledComponents outside of any render method and function component.';
40
- // If a hook is called outside of a component:
41
- // React 17 and earlier throw an error
42
- // React 18 and above use console.error
43
- var originalConsoleError_1 = console.error;
44
- try {
45
- var didNotCallInvalidHook_1 = true;
46
- console.error = function (consoleErrorMessage) {
47
- var consoleErrorArgs = [];
48
- for (var _i = 1; _i < arguments.length; _i++) {
49
- consoleErrorArgs[_i - 1] = arguments[_i];
50
- }
51
- // The error here is expected, since we're expecting anything that uses `checkDynamicCreation` to
52
- // be called outside of a React component.
53
- if (invalidHookCallRe.test(consoleErrorMessage)) {
54
- didNotCallInvalidHook_1 = false;
55
- // This shouldn't happen, but resets `warningSeen` if we had this error happen intermittently
56
- seen.delete(message_1);
57
- }
58
- else {
59
- originalConsoleError_1.apply(void 0, __spreadArray([consoleErrorMessage], consoleErrorArgs, false));
60
- }
61
- };
62
- // We purposefully call `useRef` outside of a component and expect it to throw
63
- // If it doesn't, then we're inside another component.
64
- // eslint-disable-next-line react-hooks/rules-of-hooks
65
- useRef();
66
- if (didNotCallInvalidHook_1 && !seen.has(message_1)) {
67
- // eslint-disable-next-line no-console
68
- console.warn(message_1);
69
- seen.add(message_1);
70
- }
71
- }
72
- catch (error) {
73
- // The error here is expected, since we're expecting anything that uses `checkDynamicCreation` to
74
- // be called outside of a React component.
75
- if (invalidHookCallRe.test(error.message)) {
76
- // This shouldn't happen, but resets `warningSeen` if we had this error happen intermittently
77
- seen.delete(message_1);
78
- }
79
- }
80
- finally {
81
- console.error = originalConsoleError_1;
82
- }
83
- }
84
- };
85
-
86
- var LIMIT = 200;
87
- var createWarnTooManyClasses = (function (displayName, componentId) {
88
- var generatedClasses = {};
89
- var warningSeen = false;
90
- return function (className) {
91
- if (!warningSeen) {
92
- generatedClasses[className] = true;
93
- if (Object.keys(generatedClasses).length >= LIMIT) {
94
- // Unable to find latestRule in test environment.
95
- /* eslint-disable no-console, prefer-template */
96
- var parsedIdString = componentId ? " with the id of \"".concat(componentId, "\"") : '';
97
- console.warn("Over ".concat(LIMIT, " classes were generated for component ").concat(displayName).concat(parsedIdString, ".\n") +
98
- 'Consider using the attrs method, together with a style object for frequently changed styles.\n' +
99
- 'Example:\n' +
100
- ' const Component = styled.div.attrs(props => ({\n' +
101
- ' style: {\n' +
102
- ' background: props.background,\n' +
103
- ' },\n' +
104
- ' }))`width: 100%;`\n\n' +
105
- ' <Component />');
106
- warningSeen = true;
107
- generatedClasses = {};
108
- }
109
- }
110
- };
111
- });
112
-
113
- var EMPTY_ARRAY = Object.freeze([]);
114
- var EMPTY_OBJECT = Object.freeze({});
115
-
116
- function determineTheme(props, providedTheme, defaultProps) {
117
- if (defaultProps === void 0) { defaultProps = EMPTY_OBJECT; }
118
- return (props.theme !== defaultProps.theme && props.theme) || providedTheme || defaultProps.theme;
119
- }
120
-
121
- // Thanks to ReactDOMFactories for this handy list!
122
- var domElements = [
123
- 'a',
124
- 'abbr',
125
- 'address',
126
- 'area',
127
- 'article',
128
- 'aside',
129
- 'audio',
130
- 'b',
131
- 'base',
132
- 'bdi',
133
- 'bdo',
134
- 'big',
135
- 'blockquote',
136
- 'body',
137
- 'br',
138
- 'button',
139
- 'canvas',
140
- 'caption',
141
- 'cite',
142
- 'code',
143
- 'col',
144
- 'colgroup',
145
- 'data',
146
- 'datalist',
147
- 'dd',
148
- 'del',
149
- 'details',
150
- 'dfn',
151
- 'dialog',
152
- 'div',
153
- 'dl',
154
- 'dt',
155
- 'em',
156
- 'embed',
157
- 'fieldset',
158
- 'figcaption',
159
- 'figure',
160
- 'footer',
161
- 'form',
162
- 'h1',
163
- 'h2',
164
- 'h3',
165
- 'h4',
166
- 'h5',
167
- 'h6',
168
- 'head',
169
- 'header',
170
- 'hgroup',
171
- 'hr',
172
- 'html',
173
- 'i',
174
- 'iframe',
175
- 'img',
176
- 'input',
177
- 'ins',
178
- 'kbd',
179
- 'keygen',
180
- 'label',
181
- 'legend',
182
- 'li',
183
- 'link',
184
- 'main',
185
- 'map',
186
- 'mark',
187
- 'menu',
188
- 'menuitem',
189
- 'meta',
190
- 'meter',
191
- 'nav',
192
- 'noscript',
193
- 'object',
194
- 'ol',
195
- 'optgroup',
196
- 'option',
197
- 'output',
198
- 'p',
199
- 'param',
200
- 'picture',
201
- 'pre',
202
- 'progress',
203
- 'q',
204
- 'rp',
205
- 'rt',
206
- 'ruby',
207
- 's',
208
- 'samp',
209
- 'script',
210
- 'section',
211
- 'select',
212
- 'small',
213
- 'source',
214
- 'span',
215
- 'strong',
216
- 'style',
217
- 'sub',
218
- 'summary',
219
- 'sup',
220
- 'table',
221
- 'tbody',
222
- 'td',
223
- 'textarea',
224
- 'tfoot',
225
- 'th',
226
- 'thead',
227
- 'time',
228
- 'title',
229
- 'tr',
230
- 'track',
231
- 'u',
232
- 'ul',
233
- 'use',
234
- 'var',
235
- 'video',
236
- 'wbr',
237
- 'circle',
238
- 'clipPath',
239
- 'defs',
240
- 'ellipse',
241
- 'foreignObject',
242
- 'g',
243
- 'image',
244
- 'line',
245
- 'linearGradient',
246
- 'marker',
247
- 'mask',
248
- 'path',
249
- 'pattern',
250
- 'polygon',
251
- 'polyline',
252
- 'radialGradient',
253
- 'rect',
254
- 'stop',
255
- 'svg',
256
- 'text',
257
- 'tspan',
258
- ];
259
-
260
- // Source: https://www.w3.org/TR/cssom-1/#serialize-an-identifier
261
- // Control characters and non-letter first symbols are not supported
262
- var escapeRegex = /[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g;
263
- var dashesAtEnds = /(^-|-$)/g;
264
- /**
265
- * TODO: Explore using CSS.escape when it becomes more available
266
- * in evergreen browsers.
267
- */
268
- function escape(str) {
269
- return str // Replace all possible CSS selectors
270
- .replace(escapeRegex, '-') // Remove extraneous hyphens at the start and end
271
- .replace(dashesAtEnds, '');
272
- }
273
-
274
- var AD_REPLACER_R = /(a)(d)/gi;
275
- /* This is the "capacity" of our alphabet i.e. 2x26 for all letters plus their capitalised
276
- * counterparts */
277
- var charsLength = 52;
278
- /* start at 75 for 'a' until 'z' (25) and then start at 65 for capitalised letters */
279
- var getAlphabeticChar = function (code) { return String.fromCharCode(code + (code > 25 ? 39 : 97)); };
280
- /* input a number, usually a hash and convert it to base-52 */
281
- function generateAlphabeticName(code) {
282
- var name = '';
283
- var x;
284
- /* get a char and divide by alphabet-length */
285
- for (x = Math.abs(code); x > charsLength; x = (x / charsLength) | 0) {
286
- name = getAlphabeticChar(x % charsLength) + name;
287
- }
288
- return (getAlphabeticChar(x % charsLength) + name).replace(AD_REPLACER_R, '$1-$2');
289
- }
290
-
291
- var SEED$1 = 5381;
292
- // When we have separate strings it's useful to run a progressive
293
- // version of djb2 where we pretend that we're still looping over
294
- // the same string
295
- var phash = function (h, x) {
296
- var i = x.length;
297
- while (i) {
298
- h = (h * 33) ^ x.charCodeAt(--i);
299
- }
300
- return h;
301
- };
302
- // This is a djb2 hashing function
303
- var hash = function (x) {
304
- return phash(SEED$1, x);
305
- };
306
-
307
- function generateComponentId(str) {
308
- return generateAlphabeticName(hash(str) >>> 0);
309
- }
310
-
311
- function getComponentName(target) {
312
- return ((process.env.NODE_ENV !== 'production' ? typeof target === 'string' && target : false) ||
313
- target.displayName ||
314
- target.name ||
315
- 'Component');
316
- }
317
-
318
- function isTag(target) {
319
- return (typeof target === 'string' &&
320
- (process.env.NODE_ENV !== 'production'
321
- ? target.charAt(0) === target.charAt(0).toLowerCase()
322
- : true));
323
- }
324
-
325
- function generateDisplayName(target) {
326
- return isTag(target) ? "styled.".concat(target) : "Styled(".concat(getComponentName(target), ")");
327
- }
328
-
329
- var _a;
330
- var hasSymbol = typeof Symbol === 'function' && Symbol.for;
331
- // copied from react-is
332
- var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
333
- var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
334
- /**
335
- * Adapted from hoist-non-react-statics to avoid the react-is dependency.
336
- */
337
- var REACT_STATICS = {
338
- childContextTypes: true,
339
- contextType: true,
340
- contextTypes: true,
341
- defaultProps: true,
342
- displayName: true,
343
- getDefaultProps: true,
344
- getDerivedStateFromError: true,
345
- getDerivedStateFromProps: true,
346
- mixins: true,
347
- propTypes: true,
348
- type: true,
349
- };
350
- var KNOWN_STATICS = {
351
- name: true,
352
- length: true,
353
- prototype: true,
354
- caller: true,
355
- callee: true,
356
- arguments: true,
357
- arity: true,
358
- };
359
- var FORWARD_REF_STATICS = {
360
- $$typeof: true,
361
- render: true,
362
- defaultProps: true,
363
- displayName: true,
364
- propTypes: true,
365
- };
366
- var MEMO_STATICS = {
367
- $$typeof: true,
368
- compare: true,
369
- defaultProps: true,
370
- displayName: true,
371
- propTypes: true,
372
- type: true,
373
- };
374
- var TYPE_STATICS = (_a = {},
375
- _a[REACT_FORWARD_REF_TYPE] = FORWARD_REF_STATICS,
376
- _a[REACT_MEMO_TYPE] = MEMO_STATICS,
377
- _a);
378
- // adapted from react-is
379
- function isMemo(object) {
380
- var $$typeofType = 'type' in object && object.type.$$typeof;
381
- return $$typeofType === REACT_MEMO_TYPE;
382
- }
383
- function getStatics(component) {
384
- // React v16.11 and below
385
- if (isMemo(component)) {
386
- return MEMO_STATICS;
387
- }
388
- // React v16.12 and above
389
- return '$$typeof' in component
390
- ? TYPE_STATICS[component['$$typeof']]
391
- : REACT_STATICS;
392
- }
393
- var defineProperty = Object.defineProperty;
394
- var getOwnPropertyNames = Object.getOwnPropertyNames;
395
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
396
- var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
397
- var getPrototypeOf = Object.getPrototypeOf;
398
- var objectPrototype = Object.prototype;
399
- function hoistNonReactStatics(targetComponent, sourceComponent, excludelist) {
400
- if (typeof sourceComponent !== 'string') {
401
- // don't hoist over string (html) components
402
- if (objectPrototype) {
403
- var inheritedComponent = getPrototypeOf(sourceComponent);
404
- if (inheritedComponent && inheritedComponent !== objectPrototype) {
405
- hoistNonReactStatics(targetComponent, inheritedComponent, excludelist);
406
- }
407
- }
408
- var keys = getOwnPropertyNames(sourceComponent);
409
- if (getOwnPropertySymbols) {
410
- keys = keys.concat(getOwnPropertySymbols(sourceComponent));
411
- }
412
- var targetStatics = getStatics(targetComponent);
413
- var sourceStatics = getStatics(sourceComponent);
414
- for (var i = 0; i < keys.length; ++i) {
415
- var key = keys[i];
416
- if (!(key in KNOWN_STATICS) &&
417
- !(excludelist && excludelist[key]) &&
418
- !(sourceStatics && key in sourceStatics) &&
419
- !(targetStatics && key in targetStatics)) {
420
- var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
421
- try {
422
- // Avoid failures from read-only properties
423
- defineProperty(targetComponent, key, descriptor);
424
- }
425
- catch (e) {
426
- /* ignore */
427
- }
428
- }
429
- }
430
- }
431
- return targetComponent;
432
- }
433
-
434
- function isStyledComponent(target) {
435
- return typeof target === 'object' && 'styledComponentId' in target;
436
- }
437
-
438
- /**
439
- * Convenience function for joining strings to form className chains
440
- */
441
- function joinStrings() {
442
- var args = [];
443
- for (var _i = 0; _i < arguments.length; _i++) {
444
- args[_i] = arguments[_i];
445
- }
446
- return args.filter(Boolean).join(' ');
447
- }
448
-
449
- function isPlainObject(x) {
450
- return (x !== null &&
451
- typeof x === 'object' &&
452
- /* a check for empty prototype would be more typical, but that
453
- doesn't play well with objects created in different vm contexts */
454
- (!x.constructor || x.constructor.name === 'Object') &&
455
- (x.toString ? x.toString() : Object.prototype.toString.call(x)) === '[object Object]' &&
456
- /* check for reasonable markers that the object isn't an element for react & preact/compat */
457
- !('props' in x && (x.$$typeof || x.constructor === undefined)));
458
- }
459
-
460
- function mixinRecursively(target, source, forceMerge) {
461
- if (forceMerge === void 0) { forceMerge = false; }
462
- /* only merge into POJOs, Arrays, but for top level objects only
463
- * allow to merge into anything by passing forceMerge = true */
464
- if (!forceMerge && !isPlainObject(target) && !Array.isArray(target)) {
465
- return source;
466
- }
467
- if (Array.isArray(source)) {
468
- for (var key = 0; key < source.length; key++) {
469
- target[key] = mixinRecursively(target[key], source[key]);
470
- }
471
- }
472
- else if (isPlainObject(source)) {
473
- for (var key in source) {
474
- target[key] = mixinRecursively(target[key], source[key]);
475
- }
476
- }
477
- return target;
478
- }
479
- /**
480
- * Arrays & POJOs merged recursively, other objects and value types are overridden
481
- * If target is not a POJO or an Array, it will get source properties injected via shallow merge
482
- * Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
483
- */
484
- function mixinDeep(target) {
485
- var sources = [];
486
- for (var _i = 1; _i < arguments.length; _i++) {
487
- sources[_i - 1] = arguments[_i];
488
- }
489
- for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
490
- var source = sources_1[_a];
491
- mixinRecursively(target, source, true);
492
- }
493
- return target;
494
- }
495
-
496
- var errorMap = {
497
- '1': 'Cannot create styled-component for component: %s.\n\n',
498
- '2': "Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",
499
- '3': 'Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n',
500
- '4': 'The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n',
501
- '5': 'The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n',
502
- '6': "Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",
503
- '7': 'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',
504
- '8': 'ThemeProvider: Please make your "theme" prop an object.\n\n',
505
- '9': 'Missing document `<head>`\n\n',
506
- '10': 'Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n',
507
- '11': '_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n',
508
- '12': 'It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n',
509
- '13': '%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n',
510
- '14': 'ThemeProvider: "theme" prop is required.\n\n',
511
- '15': "A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",
512
- '16': "Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",
513
- '17': "CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",
514
- };
515
-
516
- var ERRORS = process.env.NODE_ENV !== 'production' ? errorMap : {};
517
- /**
518
- * super basic version of sprintf
519
- */
520
- function format() {
521
- var args = [];
522
- for (var _i = 0; _i < arguments.length; _i++) {
523
- args[_i] = arguments[_i];
524
- }
525
- var a = args[0];
526
- var b = [];
527
- for (var c = 1, len = args.length; c < len; c += 1) {
528
- b.push(args[c]);
529
- }
530
- b.forEach(function (d) {
531
- a = a.replace(/%[a-z]/, d);
532
- });
533
- return a;
534
- }
535
- /**
536
- * Create an error file out of errors.md for development and a simple web link to the full errors
537
- * in production mode.
538
- */
539
- function throwStyledComponentsError(code) {
540
- var interpolations = [];
541
- for (var _i = 1; _i < arguments.length; _i++) {
542
- interpolations[_i - 1] = arguments[_i];
543
- }
544
- if (process.env.NODE_ENV === 'production') {
545
- return new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(code, " for more information.").concat(interpolations.length > 0 ? " Args: ".concat(interpolations.join(', ')) : ''));
546
- }
547
- else {
548
- return new Error(format.apply(void 0, __spreadArray([ERRORS[code]], interpolations, false)).trim());
549
- }
550
- }
551
-
552
- /** Create a GroupedTag with an underlying Tag implementation */
553
- var makeGroupedTag = function (tag) {
554
- return new DefaultGroupedTag(tag);
555
- };
556
- var BASE_SIZE = 1 << 9;
557
- var DefaultGroupedTag = /** @class */ (function () {
558
- function DefaultGroupedTag(tag) {
559
- this.groupSizes = new Uint32Array(BASE_SIZE);
560
- this.length = BASE_SIZE;
561
- this.tag = tag;
562
- }
563
- DefaultGroupedTag.prototype.indexOfGroup = function (group) {
564
- var index = 0;
565
- for (var i = 0; i < group; i++) {
566
- index += this.groupSizes[i];
567
- }
568
- return index;
569
- };
570
- DefaultGroupedTag.prototype.insertRules = function (group, rules) {
571
- if (group >= this.groupSizes.length) {
572
- var oldBuffer = this.groupSizes;
573
- var oldSize = oldBuffer.length;
574
- var newSize = oldSize;
575
- while (group >= newSize) {
576
- newSize <<= 1;
577
- if (newSize < 0) {
578
- throw throwStyledComponentsError(16, "".concat(group));
579
- }
580
- }
581
- this.groupSizes = new Uint32Array(newSize);
582
- this.groupSizes.set(oldBuffer);
583
- this.length = newSize;
584
- for (var i = oldSize; i < newSize; i++) {
585
- this.groupSizes[i] = 0;
586
- }
587
- }
588
- var ruleIndex = this.indexOfGroup(group + 1);
589
- if (Array.isArray(rules)) {
590
- for (var i = 0, l = rules.length; i < l; i++) {
591
- if (this.tag.insertRule(ruleIndex, rules[i])) {
592
- this.groupSizes[group]++;
593
- ruleIndex++;
594
- }
595
- }
596
- }
597
- else {
598
- if (this.tag.insertRule(ruleIndex, rules)) {
599
- this.groupSizes[group]++;
600
- }
601
- }
602
- };
603
- DefaultGroupedTag.prototype.clearGroup = function (group) {
604
- if (group < this.length) {
605
- var length_1 = this.groupSizes[group];
606
- var startIndex = this.indexOfGroup(group);
607
- var endIndex = startIndex + length_1;
608
- this.groupSizes[group] = 0;
609
- for (var i = startIndex; i < endIndex; i++) {
610
- this.tag.deleteRule(startIndex);
611
- }
612
- }
613
- };
614
- DefaultGroupedTag.prototype.getGroup = function (group) {
615
- var css = '';
616
- if (group >= this.length || this.groupSizes[group] === 0) {
617
- return css;
618
- }
619
- var length = this.groupSizes[group];
620
- var startIndex = this.indexOfGroup(group);
621
- var endIndex = startIndex + length;
622
- for (var i = startIndex; i < endIndex; i++) {
623
- css += "".concat(this.tag.getRule(i)).concat(SPLITTER);
624
- }
625
- return css;
626
- };
627
- return DefaultGroupedTag;
628
- }());
629
-
630
- var MAX_SMI = 1 << (31 - 1);
631
- var groupIDRegister = new Map();
632
- var reverseRegister = new Map();
633
- var nextFreeGroup = 1;
634
- var getGroupForId = function (id) {
635
- if (groupIDRegister.has(id)) {
636
- return groupIDRegister.get(id);
637
- }
638
- while (reverseRegister.has(nextFreeGroup)) {
639
- nextFreeGroup++;
640
- }
641
- var group = nextFreeGroup++;
642
- if (process.env.NODE_ENV !== 'production' && ((group | 0) < 0 || group > MAX_SMI)) {
643
- throw throwStyledComponentsError(16, "".concat(group));
644
- }
645
- groupIDRegister.set(id, group);
646
- reverseRegister.set(group, id);
647
- return group;
648
- };
649
- var getIdForGroup = function (group) {
650
- return reverseRegister.get(group);
651
- };
652
- var setGroupForId = function (id, group) {
653
- groupIDRegister.set(id, group);
654
- reverseRegister.set(group, id);
655
- };
656
-
657
- var SELECTOR = "style[".concat(SC_ATTR, "][").concat(SC_ATTR_VERSION, "=\"").concat(SC_VERSION, "\"]");
658
- var MARKER_RE = new RegExp("^".concat(SC_ATTR, "\\.g(\\d+)\\[id=\"([\\w\\d-]+)\"\\].*?\"([^\"]*)"));
659
- var outputSheet = function (sheet) {
660
- var tag = sheet.getTag();
661
- var length = tag.length;
662
- var css = '';
663
- var _loop_1 = function (group) {
664
- var id = getIdForGroup(group);
665
- if (id === undefined)
666
- return "continue";
667
- var names = sheet.names.get(id);
668
- var rules = tag.getGroup(group);
669
- if (names === undefined || rules.length === 0)
670
- return "continue";
671
- var selector = "".concat(SC_ATTR, ".g").concat(group, "[id=\"").concat(id, "\"]");
672
- var content = '';
673
- if (names !== undefined) {
674
- names.forEach(function (name) {
675
- if (name.length > 0) {
676
- content += "".concat(name, ",");
677
- }
678
- });
679
- }
680
- // NOTE: It's easier to collect rules and have the marker
681
- // after the actual rules to simplify the rehydration
682
- css += "".concat(rules).concat(selector, "{content:\"").concat(content, "\"}").concat(SPLITTER);
683
- };
684
- for (var group = 0; group < length; group++) {
685
- _loop_1(group);
686
- }
687
- return css;
688
- };
689
- var rehydrateNamesFromContent = function (sheet, id, content) {
690
- var names = content.split(',');
691
- var name;
692
- for (var i = 0, l = names.length; i < l; i++) {
693
- // eslint-disable-next-line
694
- if ((name = names[i])) {
695
- sheet.registerName(id, name);
696
- }
697
- }
698
- };
699
- var rehydrateSheetFromTag = function (sheet, style) {
700
- var _a;
701
- var parts = ((_a = style.textContent) !== null && _a !== void 0 ? _a : '').split(SPLITTER);
702
- var rules = [];
703
- for (var i = 0, l = parts.length; i < l; i++) {
704
- var part = parts[i].trim();
705
- if (!part)
706
- continue;
707
- var marker = part.match(MARKER_RE);
708
- if (marker) {
709
- var group = parseInt(marker[1], 10) | 0;
710
- var id = marker[2];
711
- if (group !== 0) {
712
- // Rehydrate componentId to group index mapping
713
- setGroupForId(id, group);
714
- // Rehydrate names and rules
715
- // looks like: data-styled.g11[id="idA"]{content:"nameA,"}
716
- rehydrateNamesFromContent(sheet, id, marker[3]);
717
- sheet.getTag().insertRules(group, rules);
718
- }
719
- rules.length = 0;
720
- }
721
- else {
722
- rules.push(part);
723
- }
724
- }
725
- };
726
- var rehydrateSheet = function (sheet) {
727
- var nodes = document.querySelectorAll(SELECTOR);
728
- for (var i = 0, l = nodes.length; i < l; i++) {
729
- var node = nodes[i];
730
- if (node && node.getAttribute(SC_ATTR) !== SC_ATTR_ACTIVE) {
731
- rehydrateSheetFromTag(sheet, node);
732
- if (node.parentNode) {
733
- node.parentNode.removeChild(node);
734
- }
735
- }
736
- }
737
- };
738
-
739
- function getNonce() {
740
- return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
741
- }
742
-
743
- var ELEMENT_TYPE = 1;
744
- /* Node.ELEMENT_TYPE */
745
- /** Find last style element if any inside target */
746
- var findLastStyleTag = function (target) {
747
- var childNodes = target.childNodes;
748
- for (var i = childNodes.length; i >= 0; i--) {
749
- var child = childNodes[i];
750
- if (child && child.nodeType === ELEMENT_TYPE && child.hasAttribute(SC_ATTR)) {
751
- return child;
752
- }
753
- }
754
- return undefined;
755
- };
756
- /** Create a style element inside `target` or <head> after the last */
757
- var makeStyleTag = function (target) {
758
- var head = document.head;
759
- var parent = target || head;
760
- var style = document.createElement('style');
761
- var prevStyle = findLastStyleTag(parent);
762
- var nextSibling = prevStyle !== undefined ? prevStyle.nextSibling : null;
763
- style.setAttribute(SC_ATTR, SC_ATTR_ACTIVE);
764
- style.setAttribute(SC_ATTR_VERSION, SC_VERSION);
765
- var nonce = getNonce();
766
- if (nonce)
767
- style.setAttribute('nonce', nonce);
768
- parent.insertBefore(style, nextSibling);
769
- return style;
770
- };
771
- /** Get the CSSStyleSheet instance for a given style element */
772
- var getSheet = function (tag) {
773
- if (tag.sheet) {
774
- return tag.sheet;
775
- }
776
- // Avoid Firefox quirk where the style element might not have a sheet property
777
- var styleSheets = document.styleSheets;
778
- for (var i = 0, l = styleSheets.length; i < l; i++) {
779
- var sheet = styleSheets[i];
780
- if (sheet.ownerNode === tag) {
781
- return sheet;
782
- }
783
- }
784
- throw throwStyledComponentsError(17);
785
- };
786
-
787
- /** Create a CSSStyleSheet-like tag depending on the environment */
788
- var makeTag = function (_a) {
789
- var isServer = _a.isServer, useCSSOMInjection = _a.useCSSOMInjection, target = _a.target;
790
- if (isServer) {
791
- return new VirtualTag(target);
792
- }
793
- else if (useCSSOMInjection) {
794
- return new CSSOMTag(target);
795
- }
796
- else {
797
- return new TextTag(target);
798
- }
799
- };
800
- var CSSOMTag = /** @class */ (function () {
801
- function CSSOMTag(target) {
802
- var element = (this.element = makeStyleTag(target));
803
- // Avoid Edge bug where empty style elements don't create sheets
804
- element.appendChild(document.createTextNode(''));
805
- this.sheet = getSheet(element);
806
- this.length = 0;
807
- }
808
- CSSOMTag.prototype.insertRule = function (index, rule) {
809
- try {
810
- this.sheet.insertRule(rule, index);
811
- this.length++;
812
- return true;
813
- }
814
- catch (_error) {
815
- return false;
816
- }
817
- };
818
- CSSOMTag.prototype.deleteRule = function (index) {
819
- this.sheet.deleteRule(index);
820
- this.length--;
821
- };
822
- CSSOMTag.prototype.getRule = function (index) {
823
- var rule = this.sheet.cssRules[index];
824
- // Avoid IE11 quirk where cssText is inaccessible on some invalid rules
825
- if (rule !== undefined && typeof rule.cssText === 'string') {
826
- return rule.cssText;
827
- }
828
- else {
829
- return '';
830
- }
831
- };
832
- return CSSOMTag;
833
- }());
834
- /** A Tag that emulates the CSSStyleSheet API but uses text nodes */
835
- var TextTag = /** @class */ (function () {
836
- function TextTag(target) {
837
- var element = (this.element = makeStyleTag(target));
838
- this.nodes = element.childNodes;
839
- this.length = 0;
840
- }
841
- TextTag.prototype.insertRule = function (index, rule) {
842
- if (index <= this.length && index >= 0) {
843
- var node = document.createTextNode(rule);
844
- var refNode = this.nodes[index];
845
- this.element.insertBefore(node, refNode || null);
846
- this.length++;
847
- return true;
848
- }
849
- else {
850
- return false;
851
- }
852
- };
853
- TextTag.prototype.deleteRule = function (index) {
854
- this.element.removeChild(this.nodes[index]);
855
- this.length--;
856
- };
857
- TextTag.prototype.getRule = function (index) {
858
- if (index < this.length) {
859
- return this.nodes[index].textContent;
860
- }
861
- else {
862
- return '';
863
- }
864
- };
865
- return TextTag;
866
- }());
867
- /** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
868
- var VirtualTag = /** @class */ (function () {
869
- function VirtualTag(_target) {
870
- this.rules = [];
871
- this.length = 0;
872
- }
873
- VirtualTag.prototype.insertRule = function (index, rule) {
874
- if (index <= this.length) {
875
- this.rules.splice(index, 0, rule);
876
- this.length++;
877
- return true;
878
- }
879
- else {
880
- return false;
881
- }
882
- };
883
- VirtualTag.prototype.deleteRule = function (index) {
884
- this.rules.splice(index, 1);
885
- this.length--;
886
- };
887
- VirtualTag.prototype.getRule = function (index) {
888
- if (index < this.length) {
889
- return this.rules[index];
890
- }
891
- else {
892
- return '';
893
- }
894
- };
895
- return VirtualTag;
896
- }());
897
-
898
- var SHOULD_REHYDRATE = IS_BROWSER;
899
- var defaultOptions = {
900
- isServer: !IS_BROWSER,
901
- useCSSOMInjection: !DISABLE_SPEEDY,
902
- };
903
- /** Contains the main stylesheet logic for stringification and caching */
904
- var StyleSheet = /** @class */ (function () {
905
- function StyleSheet(options, globalStyles, names) {
906
- if (options === void 0) { options = EMPTY_OBJECT; }
907
- if (globalStyles === void 0) { globalStyles = {}; }
908
- this.options = __assign(__assign({}, defaultOptions), options);
909
- this.gs = globalStyles;
910
- this.names = new Map(names);
911
- this.server = !!options.isServer;
912
- // We rehydrate only once and use the sheet that is created first
913
- if (!this.server && IS_BROWSER && SHOULD_REHYDRATE) {
914
- SHOULD_REHYDRATE = false;
915
- rehydrateSheet(this);
916
- }
917
- }
918
- /** Register a group ID to give it an index */
919
- StyleSheet.registerId = function (id) {
920
- return getGroupForId(id);
921
- };
922
- StyleSheet.prototype.reconstructWithOptions = function (options, withNames) {
923
- if (withNames === void 0) { withNames = true; }
924
- return new StyleSheet(__assign(__assign({}, this.options), options), this.gs, (withNames && this.names) || undefined);
925
- };
926
- StyleSheet.prototype.allocateGSInstance = function (id) {
927
- return (this.gs[id] = (this.gs[id] || 0) + 1);
928
- };
929
- /** Lazily initialises a GroupedTag for when it's actually needed */
930
- StyleSheet.prototype.getTag = function () {
931
- return this.tag || (this.tag = makeGroupedTag(makeTag(this.options)));
932
- };
933
- /** Check whether a name is known for caching */
934
- StyleSheet.prototype.hasNameForId = function (id, name) {
935
- return this.names.has(id) && this.names.get(id).has(name);
936
- };
937
- /** Mark a group's name as known for caching */
938
- StyleSheet.prototype.registerName = function (id, name) {
939
- getGroupForId(id);
940
- if (!this.names.has(id)) {
941
- var groupNames = new Set();
942
- groupNames.add(name);
943
- this.names.set(id, groupNames);
944
- }
945
- else {
946
- this.names.get(id).add(name);
947
- }
948
- };
949
- /** Insert new rules which also marks the name as known */
950
- StyleSheet.prototype.insertRules = function (id, name, rules) {
951
- this.registerName(id, name);
952
- this.getTag().insertRules(getGroupForId(id), rules);
953
- };
954
- /** Clears all cached names for a given group ID */
955
- StyleSheet.prototype.clearNames = function (id) {
956
- if (this.names.has(id)) {
957
- this.names.get(id).clear();
958
- }
959
- };
960
- /** Clears all rules for a given group ID */
961
- StyleSheet.prototype.clearRules = function (id) {
962
- this.getTag().clearGroup(getGroupForId(id));
963
- this.clearNames(id);
964
- };
965
- /** Clears the entire tag which deletes all rules but not its names */
966
- StyleSheet.prototype.clearTag = function () {
967
- // NOTE: This does not clear the names, since it's only used during SSR
968
- // so that we can continuously output only new rules
969
- this.tag = undefined;
970
- };
971
- /** Outputs the current sheet as a CSS string with markers for SSR */
972
- StyleSheet.prototype.toString = function () {
973
- return outputSheet(this);
974
- };
975
- return StyleSheet;
976
- }());
977
-
978
- var COMMENT_REGEX = /^\s*\/\/.*$/gm;
979
- var COMPLEX_SELECTOR_PREFIX = [':', '[', '.', '#'];
980
- /**
981
- * Serialize stylis output as an array of css strings. It is important that rules are
982
- * separated when using CSSOM injection.
983
- */
984
- function serialize(children, callback) {
985
- return children.map(function (c, i) { return callback(c, i, children, callback); }).filter(Boolean);
986
- }
987
- function createStylisInstance(_a) {
988
- var _b = _a === void 0 ? EMPTY_OBJECT : _a, _c = _b.options, options = _c === void 0 ? EMPTY_OBJECT : _c, _d = _b.plugins, plugins = _d === void 0 ? EMPTY_ARRAY : _d;
989
- var _componentId;
990
- var _selector;
991
- var _selectorRegexp;
992
- var _consecutiveSelfRefRegExp;
993
- var selfReferenceReplacer = function (match, offset, string) {
994
- if (
995
- // do not replace the first occurrence if it is complex (has a modifier)
996
- (offset === 0 ? !COMPLEX_SELECTOR_PREFIX.includes(string[_selector.length]) : true) && // no consecutive self refs (.b.b); that is a precedence boost and treated differently
997
- !string.match(_consecutiveSelfRefRegExp)) {
998
- return ".".concat(_componentId);
999
- }
1000
- return match;
1001
- };
1002
- /**
1003
- * When writing a style like
1004
- *
1005
- * & + & {
1006
- * color: red;
1007
- * }
1008
- *
1009
- * The second ampersand should be a reference to the static component class. stylis
1010
- * has no knowledge of static class so we have to intelligently replace the base selector.
1011
- *
1012
- * https://github.com/thysultan/stylis.js/tree/v4.0.2#abstract-syntax-structure
1013
- */
1014
- var selfReferenceReplacementPlugin = function (element) {
1015
- if (element.type === RULESET && element.value.includes('&')) {
1016
- var props = element.props;
1017
- props[0] = props[0].replace(_selectorRegexp, selfReferenceReplacer);
1018
- }
1019
- };
1020
- var stringifyRules = function (css, selector,
1021
- /**
1022
- * This "prefix" referes to a _selector_ prefix.
1023
- */
1024
- prefix, componentId) {
1025
- if (selector === void 0) { selector = ''; }
1026
- if (prefix === void 0) { prefix = ''; }
1027
- if (componentId === void 0) { componentId = '&'; }
1028
- var flatCSS = css.replace(COMMENT_REGEX, '');
1029
- // stylis has no concept of state to be passed to plugins
1030
- // but since JS is single-threaded, we can rely on that to ensure
1031
- // these properties stay in sync with the current stylis run
1032
- _componentId = componentId;
1033
- _selector = selector;
1034
- _selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
1035
- _consecutiveSelfRefRegExp = new RegExp("(\\".concat(_selector, "\\b){2,}"));
1036
- var middlewares = plugins.slice();
1037
- /**
1038
- * Enables automatic vendor-prefixing for styles.
1039
- */
1040
- if (options.prefix || options.prefix === undefined) {
1041
- middlewares.unshift(prefixer);
1042
- }
1043
- middlewares.push(selfReferenceReplacementPlugin, stringify);
1044
- return serialize(compile(options.namespace || prefix || selector
1045
- ? "".concat(options.namespace ? options.namespace + ' ' : '').concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }")
1046
- : flatCSS), middleware(middlewares));
1047
- };
1048
- stringifyRules.hash = plugins.length
1049
- ? plugins
1050
- .reduce(function (acc, plugin) {
1051
- if (!plugin.name) {
1052
- throwStyledComponentsError(15);
1053
- }
1054
- return phash(acc, plugin.name);
1055
- }, SEED$1)
1056
- .toString()
1057
- : '';
1058
- return stringifyRules;
1059
- }
1060
-
1061
- var StyleSheetContext = React.createContext(undefined);
1062
- var StyleSheetConsumer = StyleSheetContext.Consumer;
1063
- var StylisContext = React.createContext(undefined);
1064
- StylisContext.Consumer;
1065
- var mainSheet = new StyleSheet();
1066
- var mainStylis = createStylisInstance();
1067
- function useStyleSheet() {
1068
- return useContext(StyleSheetContext) || mainSheet;
1069
- }
1070
- function useStylis() {
1071
- return useContext(StylisContext) || mainStylis;
1072
- }
1073
- function StyleSheetManager(props) {
1074
- var _a = useState(props.stylisPlugins), plugins = _a[0], setPlugins = _a[1];
1075
- var contextStyleSheet = useStyleSheet();
1076
- var styleSheet = useMemo(function () {
1077
- var sheet = contextStyleSheet;
1078
- if (props.sheet) {
1079
- // eslint-disable-next-line prefer-destructuring
1080
- sheet = props.sheet;
1081
- }
1082
- else if (props.target) {
1083
- sheet = sheet.reconstructWithOptions({ target: props.target }, false);
1084
- }
1085
- if (props.disableCSSOMInjection) {
1086
- sheet = sheet.reconstructWithOptions({ useCSSOMInjection: false });
1087
- }
1088
- return sheet;
1089
- }, [props.disableCSSOMInjection, props.sheet, props.target]);
1090
- var stylis = useMemo(function () {
1091
- return createStylisInstance({
1092
- options: { namespace: props.namespace, prefix: !props.disableVendorPrefixes },
1093
- plugins: plugins,
1094
- });
1095
- }, [props.disableVendorPrefixes, props.namespace, plugins]);
1096
- useEffect(function () {
1097
- if (!shallowequal(plugins, props.stylisPlugins))
1098
- setPlugins(props.stylisPlugins);
1099
- }, [props.stylisPlugins]);
1100
- return (React.createElement(StyleSheetContext.Provider, { value: styleSheet },
1101
- React.createElement(StylisContext.Provider, { value: stylis }, process.env.NODE_ENV !== 'production'
1102
- ? React.Children.only(props.children)
1103
- : props.children)));
1104
- }
1105
-
1106
- var Keyframes = /** @class */ (function () {
1107
- function Keyframes(name, rules) {
1108
- var _this = this;
1109
- this.inject = function (styleSheet, stylisInstance) {
1110
- if (stylisInstance === void 0) { stylisInstance = mainStylis; }
1111
- var resolvedName = _this.name + stylisInstance.hash;
1112
- if (!styleSheet.hasNameForId(_this.id, resolvedName)) {
1113
- styleSheet.insertRules(_this.id, resolvedName, stylisInstance(_this.rules, resolvedName, '@keyframes'));
1114
- }
1115
- };
1116
- this.toString = function () {
1117
- throw throwStyledComponentsError(12, String(_this.name));
1118
- };
1119
- this.name = name;
1120
- this.id = "sc-keyframes-".concat(name);
1121
- this.rules = rules;
1122
- }
1123
- Keyframes.prototype.getName = function (stylisInstance) {
1124
- if (stylisInstance === void 0) { stylisInstance = mainStylis; }
1125
- return this.name + stylisInstance.hash;
1126
- };
1127
- return Keyframes;
1128
- }());
1129
-
1130
- // Taken from https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/shared/dangerousStyleValue.js
1131
- function addUnitIfNeeded(name, value) {
1132
- // https://github.com/amilajack/eslint-plugin-flowtype-errors/issues/133
1133
- if (value == null || typeof value === 'boolean' || value === '') {
1134
- return '';
1135
- }
1136
- if (typeof value === 'number' && value !== 0 && !(name in unitless)) {
1137
- return "".concat(value, "px"); // Presumes implicit 'px' suffix for unitless numbers
1138
- }
1139
- return String(value).trim();
1140
- }
1141
-
1142
- /**
1143
- * inlined version of
1144
- * https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
1145
- */
1146
- var uppercaseCheck = /[A-Z]/;
1147
- var uppercasePattern = /[A-Z]/g;
1148
- var msPattern = /^ms-/;
1149
- var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
1150
- /**
1151
- * Hyphenates a camelcased CSS property name, for example:
1152
- *
1153
- * > hyphenateStyleName('backgroundColor')
1154
- * < "background-color"
1155
- * > hyphenateStyleName('MozTransition')
1156
- * < "-moz-transition"
1157
- * > hyphenateStyleName('msTransition')
1158
- * < "-ms-transition"
1159
- *
1160
- * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
1161
- * is converted to `-ms-`.
1162
- */
1163
- function hyphenateStyleName(string) {
1164
- return uppercaseCheck.test(string) && !string.startsWith('--')
1165
- ? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
1166
- : string;
1167
- }
1168
-
1169
- function isFunction(test) {
1170
- return typeof test === 'function';
1171
- }
1172
-
1173
- function isStatelessFunction(test) {
1174
- return typeof test === 'function' && !(test.prototype && test.prototype.isReactComponent);
1175
- }
1176
-
1177
- /**
1178
- * It's falsish not falsy because 0 is allowed.
1179
- */
1180
- var isFalsish = function (chunk) {
1181
- return chunk === undefined || chunk === null || chunk === false || chunk === '';
1182
- };
1183
- var objToCssArray = function (obj, prevKey) {
1184
- var rules = [];
1185
- for (var key in obj) {
1186
- if (!obj.hasOwnProperty(key) || isFalsish(obj[key]))
1187
- continue;
1188
- if ((Array.isArray(obj[key]) && obj[key].isCss) || isFunction(obj[key])) {
1189
- rules.push("".concat(hyphenateStyleName(key), ":"), obj[key], ';');
1190
- }
1191
- else if (isPlainObject(obj[key])) {
1192
- rules.push.apply(rules, objToCssArray(obj[key], key));
1193
- }
1194
- else {
1195
- rules.push("".concat(hyphenateStyleName(key), ": ").concat(addUnitIfNeeded(key, obj[key]), ";"));
1196
- }
1197
- }
1198
- return prevKey ? __spreadArray(__spreadArray(["".concat(prevKey, " {")], rules, true), ['}'], false) : rules;
1199
- };
1200
- function flatten(chunk, executionContext, styleSheet, stylisInstance) {
1201
- if (Array.isArray(chunk)) {
1202
- var ruleSet = [];
1203
- for (var i = 0, len = chunk.length, result = void 0; i < len; i += 1) {
1204
- result = flatten(chunk[i], executionContext, styleSheet, stylisInstance);
1205
- if (result.length === 0)
1206
- continue;
1207
- ruleSet.push.apply(ruleSet, result);
1208
- }
1209
- return ruleSet;
1210
- }
1211
- if (isFalsish(chunk)) {
1212
- return [];
1213
- }
1214
- /* Handle other components */
1215
- if (isStyledComponent(chunk)) {
1216
- return [".".concat(chunk.styledComponentId)];
1217
- }
1218
- /* Either execute or defer the function */
1219
- if (isFunction(chunk)) {
1220
- if (isStatelessFunction(chunk) && executionContext) {
1221
- var chunkFn = chunk;
1222
- var result = chunkFn(executionContext);
1223
- if (process.env.NODE_ENV !== 'production' &&
1224
- typeof result === 'object' &&
1225
- !Array.isArray(result) &&
1226
- !(result instanceof Keyframes) &&
1227
- !isPlainObject(result)) {
1228
- // eslint-disable-next-line no-console
1229
- console.error("".concat(getComponentName(chunkFn), " is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details."));
1230
- }
1231
- return flatten(result, executionContext, styleSheet, stylisInstance);
1232
- }
1233
- else {
1234
- return [chunk];
1235
- }
1236
- }
1237
- if (chunk instanceof Keyframes) {
1238
- if (styleSheet) {
1239
- chunk.inject(styleSheet, stylisInstance);
1240
- return [chunk.getName(stylisInstance)];
1241
- }
1242
- else {
1243
- return [chunk];
1244
- }
1245
- }
1246
- /* Handle objects */
1247
- return isPlainObject(chunk) ? objToCssArray(chunk) : [chunk.toString()];
1248
- }
1249
-
1250
- function isStaticRules(rules) {
1251
- for (var i = 0; i < rules.length; i += 1) {
1252
- var rule = rules[i];
1253
- if (isFunction(rule) && !isStyledComponent(rule)) {
1254
- // functions are allowed to be static if they're just being
1255
- // used to get the classname of a nested styled component
1256
- return false;
1257
- }
1258
- }
1259
- return true;
1260
- }
1261
-
1262
- var SEED = hash(SC_VERSION);
1263
- /**
1264
- * ComponentStyle is all the CSS-specific stuff, not the React-specific stuff.
1265
- */
1266
- var ComponentStyle = /** @class */ (function () {
1267
- function ComponentStyle(rules, componentId, baseStyle) {
1268
- this.names = [];
1269
- this.rules = rules;
1270
- this.staticRulesId = '';
1271
- this.isStatic =
1272
- process.env.NODE_ENV === 'production' &&
1273
- (baseStyle === undefined || baseStyle.isStatic) &&
1274
- isStaticRules(rules);
1275
- this.componentId = componentId;
1276
- // SC_VERSION gives us isolation between multiple runtimes on the page at once
1277
- // this is improved further with use of the babel plugin "namespace" feature
1278
- this.baseHash = phash(SEED, componentId);
1279
- this.baseStyle = baseStyle;
1280
- // NOTE: This registers the componentId, which ensures a consistent order
1281
- // for this component's styles compared to others
1282
- StyleSheet.registerId(componentId);
1283
- }
1284
- /*
1285
- * Flattens a rule set into valid CSS
1286
- * Hashes it, wraps the whole chunk in a .hash1234 {}
1287
- * Returns the hash to be injected on render()
1288
- * */
1289
- ComponentStyle.prototype.generateAndInjectStyles = function (executionContext, styleSheet, stylis) {
1290
- var componentId = this.componentId;
1291
- this.names.length = 0;
1292
- if (this.baseStyle) {
1293
- this.names.push(this.baseStyle.generateAndInjectStyles(executionContext, styleSheet, stylis));
1294
- }
1295
- // force dynamic classnames if user-supplied stylis plugins are in use
1296
- if (this.isStatic && !stylis.hash) {
1297
- if (this.staticRulesId && styleSheet.hasNameForId(componentId, this.staticRulesId)) {
1298
- this.names.push(this.staticRulesId);
1299
- }
1300
- else {
1301
- var cssStatic = flatten(this.rules, executionContext, styleSheet, stylis).join('');
1302
- var name_1 = generateAlphabeticName(phash(this.baseHash, cssStatic) >>> 0);
1303
- if (!styleSheet.hasNameForId(componentId, name_1)) {
1304
- var cssStaticFormatted = stylis(cssStatic, ".".concat(name_1), undefined, componentId);
1305
- styleSheet.insertRules(componentId, name_1, cssStaticFormatted);
1306
- }
1307
- this.names.push(name_1);
1308
- this.staticRulesId = name_1;
1309
- }
1310
- }
1311
- else {
1312
- var length_1 = this.rules.length;
1313
- var dynamicHash = phash(this.baseHash, stylis.hash);
1314
- var css = '';
1315
- for (var i = 0; i < length_1; i++) {
1316
- var partRule = this.rules[i];
1317
- if (typeof partRule === 'string') {
1318
- css += partRule;
1319
- if (process.env.NODE_ENV !== 'production')
1320
- dynamicHash = phash(dynamicHash, partRule);
1321
- }
1322
- else if (partRule) {
1323
- var partChunk = flatten(partRule, executionContext, styleSheet, stylis);
1324
- var partString = Array.isArray(partChunk) ? partChunk.join('') : partChunk;
1325
- dynamicHash = phash(dynamicHash, partString);
1326
- css += partString;
1327
- }
1328
- }
1329
- if (css) {
1330
- var name_2 = generateAlphabeticName(dynamicHash >>> 0);
1331
- if (!styleSheet.hasNameForId(componentId, name_2)) {
1332
- var cssFormatted = stylis(css, ".".concat(name_2), undefined, componentId);
1333
- styleSheet.insertRules(componentId, name_2, cssFormatted);
1334
- }
1335
- this.names.push(name_2);
1336
- }
1337
- }
1338
- return this.names.join(' ');
1339
- };
1340
- return ComponentStyle;
1341
- }());
1342
-
1343
- var ThemeContext = React.createContext(undefined);
1344
- var ThemeConsumer = ThemeContext.Consumer;
1345
- function mergeTheme(theme, outerTheme) {
1346
- if (!theme) {
1347
- throw throwStyledComponentsError(14);
1348
- }
1349
- if (isFunction(theme)) {
1350
- var themeFn = theme;
1351
- var mergedTheme = themeFn(outerTheme);
1352
- if (process.env.NODE_ENV !== 'production' &&
1353
- (mergedTheme === null || Array.isArray(mergedTheme) || typeof mergedTheme !== 'object')) {
1354
- throw throwStyledComponentsError(7);
1355
- }
1356
- return mergedTheme;
1357
- }
1358
- if (Array.isArray(theme) || typeof theme !== 'object') {
1359
- throw throwStyledComponentsError(8);
1360
- }
1361
- return outerTheme ? __assign(__assign({}, outerTheme), theme) : theme;
1362
- }
1363
- /**
1364
- * Provide a theme to an entire react component tree via context
1365
- */
1366
- function ThemeProvider(props) {
1367
- var outerTheme = useContext(ThemeContext);
1368
- var themeContext = useMemo(function () { return mergeTheme(props.theme, outerTheme); }, [props.theme, outerTheme]);
1369
- if (!props.children) {
1370
- return null;
1371
- }
1372
- return React.createElement(ThemeContext.Provider, { value: themeContext }, props.children);
1373
- }
1374
-
1375
- var identifiers = {};
1376
- /* We depend on components having unique IDs */
1377
- function generateId(displayName, parentComponentId) {
1378
- var name = typeof displayName !== 'string' ? 'sc' : escape(displayName);
1379
- // Ensure that no displayName can lead to duplicate componentIds
1380
- identifiers[name] = (identifiers[name] || 0) + 1;
1381
- var componentId = "".concat(name, "-").concat(generateComponentId(
1382
- // SC_VERSION gives us isolation between multiple runtimes on the page at once
1383
- // this is improved further with use of the babel plugin "namespace" feature
1384
- SC_VERSION + name + identifiers[name]));
1385
- return parentComponentId ? "".concat(parentComponentId, "-").concat(componentId) : componentId;
1386
- }
1387
- function useInjectedStyle(componentStyle, isStatic, resolvedAttrs, warnTooManyClasses) {
1388
- var styleSheet = useStyleSheet();
1389
- var stylis = useStylis();
1390
- var className = componentStyle.generateAndInjectStyles(isStatic ? EMPTY_OBJECT : resolvedAttrs, styleSheet, stylis);
1391
- // eslint-disable-next-line react-hooks/rules-of-hooks
1392
- if (process.env.NODE_ENV !== 'production')
1393
- useDebugValue(className);
1394
- if (process.env.NODE_ENV !== 'production' && !isStatic && warnTooManyClasses) {
1395
- warnTooManyClasses(className);
1396
- }
1397
- return className;
1398
- }
1399
- function useStyledComponentImpl(forwardedComponent, props, forwardedRef, isStatic) {
1400
- var componentAttrs = forwardedComponent.attrs, componentStyle = forwardedComponent.componentStyle, defaultProps = forwardedComponent.defaultProps, foldedComponentIds = forwardedComponent.foldedComponentIds, shouldForwardProp = forwardedComponent.shouldForwardProp, styledComponentId = forwardedComponent.styledComponentId, target = forwardedComponent.target;
1401
- // eslint-disable-next-line react-hooks/rules-of-hooks
1402
- if (process.env.NODE_ENV !== 'production')
1403
- useDebugValue(styledComponentId);
1404
- // NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
1405
- // but that'd be against the rules-of-hooks. We could be naughty and do it anyway as it
1406
- // should be an immutable value, but behave for now.
1407
- var theme = determineTheme(props, useContext(ThemeContext), defaultProps) || EMPTY_OBJECT;
1408
- var context = componentAttrs.reduce(function (p, attrDef) {
1409
- var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(p) : attrDef;
1410
- /* eslint-disable guard-for-in */
1411
- for (var key in resolvedAttrDef) {
1412
- // @ts-expect-error bad types
1413
- p[key] =
1414
- key === 'className'
1415
- ? joinStrings(p[key], resolvedAttrDef[key])
1416
- : key === 'style'
1417
- ? __assign(__assign({}, p[key]), resolvedAttrDef[key]) : resolvedAttrDef[key];
1418
- }
1419
- /* eslint-enable guard-for-in */
1420
- return p;
1421
- }, __assign(__assign({}, props), { theme: theme }));
1422
- var generatedClassName = useInjectedStyle(componentStyle, isStatic, context, process.env.NODE_ENV !== 'production' ? forwardedComponent.warnTooManyClasses : undefined);
1423
- var refToForward = forwardedRef;
1424
- var elementToBeCreated = context.as || target;
1425
- var isTargetTag = isTag(elementToBeCreated);
1426
- var propsForElement = {};
1427
- // eslint-disable-next-line guard-for-in
1428
- for (var key in context) {
1429
- // @ts-expect-error for..in iterates strings instead of keyof
1430
- if (context[key] === undefined) ;
1431
- else if (key[0] === '$' || key === 'as' || key === 'theme') ;
1432
- else if (key === 'forwardedAs') {
1433
- propsForElement.as = context.forwardedAs;
1434
- }
1435
- else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
1436
- // @ts-expect-error for..in iterates strings instead of keyof
1437
- propsForElement[key] = context[key];
1438
- }
1439
- }
1440
- propsForElement[
1441
- // handle custom elements which React doesn't properly alias
1442
- isTargetTag &&
1443
- domElements.indexOf(elementToBeCreated) === -1
1444
- ? 'class'
1445
- : 'className'] = foldedComponentIds
1446
- .concat(styledComponentId, generatedClassName !== styledComponentId ? generatedClassName : '', context.className || '')
1447
- .filter(Boolean)
1448
- .join(' ');
1449
- propsForElement.ref = refToForward;
1450
- return createElement(elementToBeCreated, propsForElement);
1451
- }
1452
- function createStyledComponent(target, options, rules) {
1453
- var isTargetStyledComp = isStyledComponent(target);
1454
- var styledComponentTarget = target;
1455
- var isCompositeComponent = !isTag(target);
1456
- var _a = options.attrs, attrs = _a === void 0 ? EMPTY_ARRAY : _a, _b = options.componentId, componentId = _b === void 0 ? generateId(options.displayName, options.parentComponentId) : _b, _c = options.displayName, displayName = _c === void 0 ? generateDisplayName(target) : _c;
1457
- var styledComponentId = options.displayName && options.componentId
1458
- ? "".concat(escape(options.displayName), "-").concat(options.componentId)
1459
- : options.componentId || componentId;
1460
- // fold the underlying StyledComponent attrs up (implicit extend)
1461
- var finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
1462
- ? styledComponentTarget.attrs
1463
- .concat(attrs)
1464
- .filter(Boolean)
1465
- : attrs;
1466
- var shouldForwardProp = options.shouldForwardProp;
1467
- if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
1468
- var shouldForwardPropFn_1 = styledComponentTarget.shouldForwardProp;
1469
- if (options.shouldForwardProp) {
1470
- var passedShouldForwardPropFn_1 = options.shouldForwardProp;
1471
- // compose nested shouldForwardProp calls
1472
- shouldForwardProp = function (prop, elementToBeCreated) {
1473
- return shouldForwardPropFn_1(prop, elementToBeCreated) &&
1474
- passedShouldForwardPropFn_1(prop, elementToBeCreated);
1475
- };
1476
- }
1477
- else {
1478
- shouldForwardProp = shouldForwardPropFn_1;
1479
- }
1480
- }
1481
- var componentStyle = new ComponentStyle(rules, styledComponentId, isTargetStyledComp ? styledComponentTarget.componentStyle : undefined);
1482
- // statically styled-components don't need to build an execution context object,
1483
- // and shouldn't be increasing the number of class names
1484
- var isStatic = componentStyle.isStatic && attrs.length === 0;
1485
- function forwardRef(props, ref) {
1486
- // eslint-disable-next-line
1487
- return useStyledComponentImpl(WrappedStyledComponent, props, ref, isStatic);
1488
- }
1489
- forwardRef.displayName = displayName;
1490
- /**
1491
- * forwardRef creates a new interim component, which we'll take advantage of
1492
- * instead of extending ParentComponent to create _another_ interim class
1493
- */
1494
- var WrappedStyledComponent = React.forwardRef(forwardRef);
1495
- WrappedStyledComponent.attrs = finalAttrs;
1496
- WrappedStyledComponent.componentStyle = componentStyle;
1497
- WrappedStyledComponent.displayName = displayName;
1498
- WrappedStyledComponent.shouldForwardProp = shouldForwardProp;
1499
- // this static is used to preserve the cascade of static classes for component selector
1500
- // purposes; this is especially important with usage of the css prop
1501
- WrappedStyledComponent.foldedComponentIds = isTargetStyledComp
1502
- ? styledComponentTarget.foldedComponentIds.concat(styledComponentTarget.styledComponentId)
1503
- : EMPTY_ARRAY;
1504
- WrappedStyledComponent.styledComponentId = styledComponentId;
1505
- // fold the underlying StyledComponent target up since we folded the styles
1506
- WrappedStyledComponent.target = isTargetStyledComp ? styledComponentTarget.target : target;
1507
- Object.defineProperty(WrappedStyledComponent, 'defaultProps', {
1508
- get: function () {
1509
- return this._foldedDefaultProps;
1510
- },
1511
- set: function (obj) {
1512
- this._foldedDefaultProps = isTargetStyledComp
1513
- ? mixinDeep({}, styledComponentTarget.defaultProps, obj)
1514
- : obj;
1515
- },
1516
- });
1517
- if (process.env.NODE_ENV !== 'production') {
1518
- checkDynamicCreation(displayName, styledComponentId);
1519
- WrappedStyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName, styledComponentId);
1520
- }
1521
- WrappedStyledComponent.toString = function () { return ".".concat(WrappedStyledComponent.styledComponentId); };
1522
- if (isCompositeComponent) {
1523
- var compositeComponentTarget = target;
1524
- hoistNonReactStatics(WrappedStyledComponent, compositeComponentTarget, {
1525
- // all SC-specific things should not be hoisted
1526
- attrs: true,
1527
- componentStyle: true,
1528
- displayName: true,
1529
- foldedComponentIds: true,
1530
- shouldForwardProp: true,
1531
- styledComponentId: true,
1532
- target: true,
1533
- });
1534
- }
1535
- return WrappedStyledComponent;
1536
- }
1537
-
1538
- function interleave(strings, interpolations) {
1539
- var result = [strings[0]];
1540
- for (var i = 0, len = interpolations.length; i < len; i += 1) {
1541
- result.push(interpolations[i], strings[i + 1]);
1542
- }
1543
- return result;
1544
- }
1545
-
1546
- /**
1547
- * Used when flattening object styles to determine if we should
1548
- * expand an array of styles.
1549
- */
1550
- var addTag = function (arg) {
1551
- return Object.assign(arg, { isCss: true });
1552
- };
1553
- function css(styles) {
1554
- var interpolations = [];
1555
- for (var _i = 1; _i < arguments.length; _i++) {
1556
- interpolations[_i - 1] = arguments[_i];
1557
- }
1558
- if (isFunction(styles) || isPlainObject(styles)) {
1559
- var styleFunctionOrObject = styles;
1560
- return addTag(flatten(interleave(EMPTY_ARRAY, __spreadArray([
1561
- styleFunctionOrObject
1562
- ], interpolations, true))));
1563
- }
1564
- var styleStringArray = styles;
1565
- if (interpolations.length === 0 &&
1566
- styleStringArray.length === 1 &&
1567
- typeof styleStringArray[0] === 'string') {
1568
- return flatten(styleStringArray);
1569
- }
1570
- return addTag(flatten(interleave(styleStringArray, interpolations)));
1571
- }
1572
-
1573
- function constructWithOptions(componentConstructor, tag, options) {
1574
- if (options === void 0) { options = EMPTY_OBJECT; }
1575
- // We trust that the tag is a valid component as long as it isn't falsish
1576
- // Typically the tag here is a string or function (i.e. class or pure function component)
1577
- // However a component may also be an object if it uses another utility, e.g. React.memo
1578
- // React will output an appropriate warning however if the `tag` isn't valid
1579
- if (!tag) {
1580
- throw throwStyledComponentsError(1, tag);
1581
- }
1582
- /* This is callable directly as a template function */
1583
- var templateFunction = function (initialStyles) {
1584
- var interpolations = [];
1585
- for (var _i = 1; _i < arguments.length; _i++) {
1586
- interpolations[_i - 1] = arguments[_i];
1587
- }
1588
- return componentConstructor(tag, options, css.apply(void 0, __spreadArray([initialStyles], interpolations, false)));
1589
- };
1590
- /* Modify/inject new props at runtime */
1591
- templateFunction.attrs = function (attrs) {
1592
- return constructWithOptions(componentConstructor, tag, __assign(__assign({}, options), { attrs: Array.prototype.concat(options.attrs, attrs).filter(Boolean) }));
1593
- };
1594
- /**
1595
- * If config methods are called, wrap up a new template function and merge options */
1596
- templateFunction.withConfig = function (config) {
1597
- return constructWithOptions(componentConstructor, tag, __assign(__assign({}, options), config));
1598
- };
1599
- return templateFunction;
1600
- }
1601
-
1602
- var baseStyled = function (tag) {
1603
- return constructWithOptions(createStyledComponent, tag);
1604
- };
1605
- var styled = baseStyled;
1606
- // Shorthands for all valid HTML Elements
1607
- domElements.forEach(function (domElement) {
1608
- // @ts-expect-error someday they'll handle imperative assignment properly
1609
- styled[domElement] = baseStyled(domElement);
1610
- });
1611
-
1612
- var GlobalStyle = /** @class */ (function () {
1613
- function GlobalStyle(rules, componentId) {
1614
- this.rules = rules;
1615
- this.componentId = componentId;
1616
- this.isStatic = isStaticRules(rules);
1617
- // pre-register the first instance to ensure global styles
1618
- // load before component ones
1619
- StyleSheet.registerId(this.componentId + 1);
1620
- }
1621
- GlobalStyle.prototype.createStyles = function (instance, executionContext, styleSheet, stylis) {
1622
- var flatCSS = flatten(this.rules, executionContext, styleSheet, stylis);
1623
- var css = stylis(flatCSS.join(''), '');
1624
- var id = this.componentId + instance;
1625
- // NOTE: We use the id as a name as well, since these rules never change
1626
- styleSheet.insertRules(id, id, css);
1627
- };
1628
- GlobalStyle.prototype.removeStyles = function (instance, styleSheet) {
1629
- styleSheet.clearRules(this.componentId + instance);
1630
- };
1631
- GlobalStyle.prototype.renderStyles = function (instance, executionContext, styleSheet, stylis) {
1632
- if (instance > 2)
1633
- StyleSheet.registerId(this.componentId + instance);
1634
- // NOTE: Remove old styles, then inject the new ones
1635
- this.removeStyles(instance, styleSheet);
1636
- this.createStyles(instance, executionContext, styleSheet, stylis);
1637
- };
1638
- return GlobalStyle;
1639
- }());
1640
-
1641
- function createGlobalStyle(strings) {
1642
- var interpolations = [];
1643
- for (var _i = 1; _i < arguments.length; _i++) {
1644
- interpolations[_i - 1] = arguments[_i];
1645
- }
1646
- var rules = css.apply(void 0, __spreadArray([strings], interpolations, false));
1647
- var styledComponentId = "sc-global-".concat(generateComponentId(JSON.stringify(rules)));
1648
- var globalStyle = new GlobalStyle(rules, styledComponentId);
1649
- if (process.env.NODE_ENV !== 'production') {
1650
- checkDynamicCreation(styledComponentId);
1651
- }
1652
- var GlobalStyleComponent = function (props) {
1653
- var styleSheet = useStyleSheet();
1654
- var stylis = useStylis();
1655
- var theme = React.useContext(ThemeContext);
1656
- var instanceRef = React.useRef(styleSheet.allocateGSInstance(styledComponentId));
1657
- var instance = instanceRef.current;
1658
- if (process.env.NODE_ENV !== 'production' && React.Children.count(props.children)) {
1659
- // eslint-disable-next-line no-console
1660
- console.warn("The global style component ".concat(styledComponentId, " was given child JSX. createGlobalStyle does not render children."));
1661
- }
1662
- if (process.env.NODE_ENV !== 'production' &&
1663
- rules.some(function (rule) { return typeof rule === 'string' && rule.indexOf('@import') !== -1; })) {
1664
- // eslint-disable-next-line no-console
1665
- console.warn("Please do not use @import CSS syntax in createGlobalStyle at this time, as the CSSOM APIs we use in production do not handle it well. Instead, we recommend using a library such as react-helmet to inject a typical <link> meta tag to the stylesheet, or simply embedding it manually in your index.html <head> section for a simpler app.");
1666
- }
1667
- if (styleSheet.server) {
1668
- renderStyles(instance, props, styleSheet, theme, stylis);
1669
- }
1670
- {
1671
- // eslint-disable-next-line react-hooks/rules-of-hooks
1672
- // @ts-expect-error still using React 17 types for the time being
1673
- (React.useInsertionEffect || React.useLayoutEffect)(function () {
1674
- if (!styleSheet.server) {
1675
- renderStyles(instance, props, styleSheet, theme, stylis);
1676
- return function () { return globalStyle.removeStyles(instance, styleSheet); };
1677
- }
1678
- }, [instance, props, styleSheet, theme, stylis]);
1679
- }
1680
- return null;
1681
- };
1682
- function renderStyles(instance, props, styleSheet, theme, stylis) {
1683
- if (globalStyle.isStatic) {
1684
- globalStyle.renderStyles(instance, STATIC_EXECUTION_CONTEXT, styleSheet, stylis);
1685
- }
1686
- else {
1687
- var context = __assign(__assign({}, props), { theme: determineTheme(props, theme, GlobalStyleComponent.defaultProps) });
1688
- globalStyle.renderStyles(instance, context, styleSheet, stylis);
1689
- }
1690
- }
1691
- return React.memo(GlobalStyleComponent);
1692
- }
1693
-
1694
- function keyframes(strings) {
1695
- var interpolations = [];
1696
- for (var _i = 1; _i < arguments.length; _i++) {
1697
- interpolations[_i - 1] = arguments[_i];
1698
- }
1699
- /* Warning if you've used keyframes on React Native */
1700
- if (process.env.NODE_ENV !== 'production' &&
1701
- typeof navigator !== 'undefined' &&
1702
- navigator.product === 'ReactNative') {
1703
- // eslint-disable-next-line no-console
1704
- console.warn('`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.');
1705
- }
1706
- var rules = css.apply(void 0, __spreadArray([strings], interpolations, false)).join('');
1707
- var name = generateComponentId(rules);
1708
- return new Keyframes(name, rules);
1709
- }
1710
-
1711
- function withTheme(Component) {
1712
- var WithTheme = React.forwardRef(function (props, ref) {
1713
- var theme = React.useContext(ThemeContext);
1714
- var themeProp = determineTheme(props, theme, Component.defaultProps);
1715
- if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
1716
- // eslint-disable-next-line no-console
1717
- console.warn("[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class \"".concat(getComponentName(Component), "\""));
1718
- }
1719
- return React.createElement(Component, __assign({}, props, { theme: themeProp, ref: ref }));
1720
- });
1721
- WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
1722
- return hoistNonReactStatics(WithTheme, Component);
1723
- }
1724
-
1725
- var useTheme = function () { return useContext(ThemeContext); };
1726
-
1727
- var ServerStyleSheet = /** @class */ (function () {
1728
- function ServerStyleSheet() {
1729
- var _this = this;
1730
- this._emitSheetCSS = function () {
1731
- var css = _this.instance.toString();
1732
- var nonce = getNonce();
1733
- var attrs = [
1734
- nonce && "nonce=\"".concat(nonce, "\""),
1735
- "".concat(SC_ATTR, "=\"true\""),
1736
- "".concat(SC_ATTR_VERSION, "=\"").concat(SC_VERSION, "\""),
1737
- ];
1738
- var htmlAttr = attrs.filter(Boolean).join(' ');
1739
- return "<style ".concat(htmlAttr, ">").concat(css, "</style>");
1740
- };
1741
- this.getStyleTags = function () {
1742
- if (_this.sealed) {
1743
- throw throwStyledComponentsError(2);
1744
- }
1745
- return _this._emitSheetCSS();
1746
- };
1747
- this.getStyleElement = function () {
1748
- var _a;
1749
- if (_this.sealed) {
1750
- throw throwStyledComponentsError(2);
1751
- }
1752
- var props = (_a = {},
1753
- _a[SC_ATTR] = '',
1754
- _a[SC_ATTR_VERSION] = SC_VERSION,
1755
- _a.dangerouslySetInnerHTML = {
1756
- __html: _this.instance.toString(),
1757
- },
1758
- _a);
1759
- var nonce = getNonce();
1760
- if (nonce) {
1761
- props.nonce = nonce;
1762
- }
1763
- // v4 returned an array for this fn, so we'll do the same for v5 for backward compat
1764
- return [React.createElement("style", __assign({}, props, { key: "sc-0-0" }))];
1765
- };
1766
- this.seal = function () {
1767
- _this.sealed = true;
1768
- };
1769
- this.instance = new StyleSheet({ isServer: true });
1770
- this.sealed = false;
1771
- }
1772
- ServerStyleSheet.prototype.collectStyles = function (children) {
1773
- if (this.sealed) {
1774
- throw throwStyledComponentsError(2);
1775
- }
1776
- return React.createElement(StyleSheetManager, { sheet: this.instance }, children);
1777
- };
1778
- // eslint-disable-next-line consistent-return
1779
- // @ts-expect-error alternate return types are not possible due to code transformation
1780
- ServerStyleSheet.prototype.interleaveWithNodeStream = function (input) {
1781
- {
1782
- throw throwStyledComponentsError(3);
1783
- }
1784
- };
1785
- return ServerStyleSheet;
1786
- }());
1787
-
1788
- /* eslint-disable */
1789
- var __PRIVATE__ = {
1790
- StyleSheet: StyleSheet,
1791
- mainSheet: mainSheet,
1792
- };
1793
-
1794
- /* Import singletons */
1795
- /* Warning if you've imported this file on React Native */
1796
- if (process.env.NODE_ENV !== 'production' &&
1797
- typeof navigator !== 'undefined' &&
1798
- navigator.product === 'ReactNative') {
1799
- // eslint-disable-next-line no-console
1800
- console.warn("It looks like you've imported 'styled-components' on React Native.\n" +
1801
- "Perhaps you're looking to import 'styled-components/native'?\n" +
1802
- 'Read more about this at https://www.styled-components.com/docs/basics#react-native');
1803
- }
1804
- /* Warning if there are several instances of styled-components */
1805
- if (process.env.NODE_ENV !== 'production' &&
1806
- process.env.NODE_ENV !== 'test' &&
1807
- typeof window !== 'undefined') {
1808
- window['__styled-components-init__'] || (window['__styled-components-init__'] = 0);
1809
- if (window['__styled-components-init__'] === 1) {
1810
- // eslint-disable-next-line no-console
1811
- console.warn("It looks like there are several instances of 'styled-components' initialized in this application. " +
1812
- 'This may cause dynamic styles to not render properly, errors during the rehydration process, ' +
1813
- 'a missing theme prop, and makes your application bigger without good reason.\n\n' +
1814
- 'See https://s-c.sh/2BAXzed for more info.');
1815
- }
1816
- window['__styled-components-init__'] += 1;
1817
- }
1818
-
1819
- export { ServerStyleSheet, StyleSheetConsumer, StyleSheetContext, StyleSheetManager, ThemeConsumer, ThemeContext, ThemeProvider, __PRIVATE__, createGlobalStyle, css, styled as default, isStyledComponent, keyframes, styled, useTheme, SC_VERSION as version, withTheme };
1
+ import{__spreadArray as e,__assign as t}from"tslib";import n,{useRef as r,useState as o,useMemo as s,useEffect as i,useContext as a,useDebugValue as c,createElement as l}from"react";import u from"shallowequal";import{prefixer as p,stringify as d,RULESET as h,compile as f,middleware as m}from"stylis";import y from"@emotion/unitless";var v="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",g="6.0.0-rc.0",S="undefined"!=typeof window&&"HTMLElement"in window,w=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV),b={},E=/invalid hook call/i,N=new Set,P=function(t,n){if("production"!==process.env.NODE_ENV){var o=n?' with the id of "'.concat(n,'"'):"",s="The component ".concat(t).concat(o," has been created dynamically.\n")+"You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.",i=console.error;try{var a=!0;console.error=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];E.test(t)?(a=!1,N.delete(s)):i.apply(void 0,e([t],n,!1))},r(),a&&!N.has(s)&&(console.warn(s),N.add(s))}catch(e){E.test(e.message)&&N.delete(s)}finally{console.error=i}}},_=Object.freeze([]),C=Object.freeze({});function I(e,t,n){return void 0===n&&(n=C),e.theme!==n.theme&&e.theme||t||n.theme}var A=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),O=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,D=/(^-|-$)/g;function R(e){return e.replace(O,"-").replace(D,"")}var T=/(a)(d)/gi,j=function(e){return String.fromCharCode(e+(e>25?39:97))};function x(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=j(t%52)+n;return(j(t%52)+n).replace(T,"$1-$2")}var k,V=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},M=function(e){return V(5381,e)};function F(e){return x(M(e)>>>0)}function B(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function $(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var z="function"==typeof Symbol&&Symbol.for,L=z?Symbol.for("react.memo"):60115,G=z?Symbol.for("react.forward_ref"):60112,Y={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},W={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},q={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},H=((k={})[G]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},k[L]=q,k);function U(e){return("type"in(t=e)&&t.type.$$typeof)===L?q:"$$typeof"in e?H[e.$$typeof]:Y;var t}var J=Object.defineProperty,X=Object.getOwnPropertyNames,Z=Object.getOwnPropertySymbols,K=Object.getOwnPropertyDescriptor,Q=Object.getPrototypeOf,ee=Object.prototype;function te(e,t,n){if("string"!=typeof t){if(ee){var r=Q(t);r&&r!==ee&&te(e,r,n)}var o=X(t);Z&&(o=o.concat(Z(t)));for(var s=U(e),i=U(t),a=0;a<o.length;++a){var c=o[a];if(!(c in W||n&&n[c]||i&&c in i||s&&c in s)){var l=K(t,c);try{J(e,c,l)}catch(e){}}}}return e}function ne(e){return"function"==typeof e}function re(e){return"object"==typeof e&&"styledComponentId"in e}function oe(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function se(e,t){if(0===e.length)return"";for(var n=e[0],r=1;r<e.length;r++)n+=t?t+e[r]:e[r];return n}function ie(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function ae(e,t,n){if(void 0===n&&(n=!1),!n&&!ie(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var r=0;r<t.length;r++)e[r]=ae(e[r],t[r]);else if(ie(t))for(var r in t)e[r]=ae(e[r],t[r]);return e}var ce="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",2:"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",4:"The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",5:"The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",6:"Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",10:"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",11:"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",12:"It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",13:"%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n",14:'ThemeProvider: "theme" prop is required.\n\n',15:"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",16:"Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n"}:{};function le(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],r=[],o=1,s=e.length;o<s;o+=1)r.push(e[o]);return r.forEach(function(e){n=n.replace(/%[a-z]/,e)}),n}function ue(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return"production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(n.length>0?" Args: ".concat(n.join(", ")):"")):new Error(le.apply(void 0,e([ce[t]],n,!1)).trim())}var pe=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}return e.prototype.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},e.prototype.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,r=n.length,o=r;e>=o;)if((o<<=1)<0)throw ue(16,"".concat(e));this.groupSizes=new Uint32Array(o),this.groupSizes.set(n),this.length=o;for(var s=r;s<o;s++)this.groupSizes[s]=0}for(var i=this.indexOfGroup(e+1),a=(s=0,t.length);s<a;s++)this.tag.insertRule(i,t[s])&&(this.groupSizes[e]++,i++)},e.prototype.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),r=n+t;this.groupSizes[e]=0;for(var o=n;o<r;o++)this.tag.deleteRule(n)}},e.prototype.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],r=this.indexOfGroup(e),o=r+n,s=r;s<o;s++)t+="".concat(this.tag.getRule(s)).concat("/*!sc*/\n");return t},e}(),de=new Map,he=new Map,fe=1,me=function(e){if(de.has(e))return de.get(e);for(;he.has(fe);)fe++;var t=fe++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>1073741824))throw ue(16,"".concat(t));return de.set(e,t),he.set(t,e),t},ye=function(e,t){de.set(e,t),he.set(t,e)},ve="style[".concat(v,"][").concat("data-styled-version",'="').concat("6.0.0-rc.0",'"]'),ge=new RegExp("^".concat(v,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Se=function(e,t,n){for(var r,o=n.split(","),s=0,i=o.length;s<i;s++)(r=o[s])&&e.registerName(t,r)},we=function(e,t){for(var n,r=(null!==(n=t.textContent)&&void 0!==n?n:"").split("/*!sc*/\n"),o=[],s=0,i=r.length;s<i;s++){var a=r[s].trim();if(a){var c=a.match(ge);if(c){var l=0|parseInt(c[1],10),u=c[2];0!==l&&(ye(u,l),Se(e,u,c[3]),e.getTag().insertRules(l,o)),o.length=0}else o.push(a)}}};function be(){return"undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null}var Ee=function(e){var t=document.head,n=e||t,r=document.createElement("style"),o=function(e){for(var t=e.childNodes,n=t.length;n>=0;n--){var r=t[n];if(r&&1===r.nodeType&&r.hasAttribute(v))return r}}(n),s=void 0!==o?o.nextSibling:null;r.setAttribute(v,"active"),r.setAttribute("data-styled-version","6.0.0-rc.0");var i=be();return i&&r.setAttribute("nonce",i),n.insertBefore(r,s),r},Ne=function(){function e(e){this.element=Ee(e),this.element.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,r=t.length;n<r;n++){var o=t[n];if(o.ownerNode===e)return o}throw ue(17)}(this.element),this.length=0}return e.prototype.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},e.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},e.prototype.getRule=function(e){var t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""},e}(),Pe=function(){function e(e){this.element=Ee(e),this.nodes=this.element.childNodes,this.length=0}return e.prototype.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1},e.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},e.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),_e=function(){function e(e){this.rules=[],this.length=0}return e.prototype.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},e.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--},e.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),Ce=S,Ie={isServer:!S,useCSSOMInjection:!w},Ae=function(){function e(e,n,r){void 0===e&&(e=C),void 0===n&&(n={}),this.options=t(t({},Ie),e),this.gs=n,this.names=new Map(r),this.server=!!e.isServer,!this.server&&S&&Ce&&(Ce=!1,function(e){for(var t=document.querySelectorAll(ve),n=0,r=t.length;n<r;n++){var o=t[n];o&&"active"!==o.getAttribute(v)&&(we(e,o),o.parentNode&&o.parentNode.removeChild(o))}}(this))}return e.registerId=function(e){return me(e)},e.prototype.reconstructWithOptions=function(n,r){return void 0===r&&(r=!0),new e(t(t({},this.options),n),this.gs,r&&this.names||void 0)},e.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(e=function(e){var t=e.useCSSOMInjection,n=e.target;return e.isServer?new _e(n):t?new Ne(n):new Pe(n)}(this.options),new pe(e)));var e},e.prototype.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},e.prototype.registerName=function(e,t){if(me(e),this.names.has(e))this.names.get(e).add(t);else{var n=new Set;n.add(t),this.names.set(e,n)}},e.prototype.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(me(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(me(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e.prototype.toString=function(){return function(e){for(var t=e.getTag(),n=t.length,r="",o=function(n){var o=function(e){return he.get(e)}(n);if(void 0===o)return"continue";var s=e.names.get(o),i=t.getGroup(n);if(void 0===s||0===i.length)return"continue";var a="".concat(v,".g").concat(n,'[id="').concat(o,'"]'),c="";void 0!==s&&s.forEach(function(e){e.length>0&&(c+="".concat(e,","))}),r+="".concat(i).concat(a,'{content:"').concat(c,'"}').concat("/*!sc*/\n")},s=0;s<n;s++)o(s);return r}(this)},e}(),Oe=/&/g,De=/^\s*\/\/.*$/gm;function Re(e,t){return e.map(function(e){return"rule"===e.type&&(e.value="".concat(t," ").concat(e.value),e.value=e.value.replaceAll(",",",".concat(t," ")),e.props=e.props.map(function(e){return"".concat(t," ").concat(e)})),Array.isArray(e.children)&&"@keyframes"!==e.type&&(e.children=Re(e.children,t)),e})}function Te(e){var t,n,r,o=void 0===e?C:e,s=o.options,i=void 0===s?C:s,a=o.plugins,c=void 0===a?_:a,l=function(e,r,o){return o===n||o.startsWith(n)&&o.endsWith(n)&&o.replaceAll(n,"").length>0?".".concat(t):e},u=c.slice();i.prefix&&u.unshift(p),u.push(function(e){e.type===h&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(Oe,n).replace(r,l))},d);var y=function(e,o,s,a){void 0===o&&(o=""),void 0===s&&(s=""),void 0===a&&(a="&"),t=a,n=o,r=new RegExp("\\".concat(n,"\\b"),"g");var c=e.replace(De,""),l=f(s||o?"".concat(s," ").concat(o," { ").concat(c," }"):c);return i.namespace&&(l=Re(l,i.namespace)),function(e,t){for(var n=[],r=0,o=void 0;r<e.length;r+=1)(o=t(e[r],r,e,t))&&n.push(o);return n}(l,m(u))};return y.hash=c.length?c.reduce(function(e,t){return t.name||ue(15),V(e,t.name)},5381).toString():"",y}var je=new Ae,xe=Te(),ke=n.createContext({shouldForwardProp:void 0,styleSheet:je,stylis:xe}),Ve=ke.Consumer,Me=n.createContext(void 0);function Fe(){return a(ke)}function Be(e){var t=o(e.stylisPlugins),r=t[0],a=t[1],c=Fe().styleSheet,l=s(function(){var t=c;return e.sheet?t=e.sheet:e.target&&(t=t.reconstructWithOptions({target:e.target},!1)),e.disableCSSOMInjection&&(t=t.reconstructWithOptions({useCSSOMInjection:!1})),t},[e.disableCSSOMInjection,e.sheet,e.target,c]),p=s(function(){return Te({options:{namespace:e.namespace,prefix:e.enableVendorPrefixes},plugins:r})},[e.enableVendorPrefixes,e.namespace,r]);return i(function(){u(r,e.stylisPlugins)||a(e.stylisPlugins)},[e.stylisPlugins]),n.createElement(ke.Provider,{value:{shouldForwardProp:e.shouldForwardProp,styleSheet:l,stylis:p}},n.createElement(Me.Provider,{value:p},e.children))}var $e=function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=xe);var r=n.name+t.hash;e.hasNameForId(n.id,r)||e.insertRules(n.id,r,t(n.rules,r,"@keyframes"))},this.toString=function(){throw ue(12,String(n.name))},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=t}return e.prototype.getName=function(e){return void 0===e&&(e=xe),this.name+e.hash},e}(),ze=function(e){return e>="A"&&e<="Z"};function Le(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(1===n&&"-"===r&&"-"===e[0])return e;ze(r)?t+="-"+r.toLowerCase():t+=r}return t.startsWith("ms-")?"-"+t:t}var Ge=function(e){return null==e||!1===e||""===e},Ye=function(t){var n,r,o=[];for(var s in t){var i=t[s];t.hasOwnProperty(s)&&!Ge(i)&&(Array.isArray(i)&&i.isCss||ne(i)?o.push("".concat(Le(s),":"),i,";"):ie(i)?o.push.apply(o,e(e(["".concat(s," {")],Ye(i),!1),["}"],!1)):o.push("".concat(Le(s),": ").concat((n=s,null==(r=i)||"boolean"==typeof r||""===r?"":"number"!=typeof r||0===r||n in y||n.startsWith("--")?String(r).trim():"".concat(r,"px")),";")))}return o};function We(e,t,n,r){if(Ge(e))return[];if(re(e))return[".".concat(e.styledComponentId)];if(ne(e)){if(!ne(s=e)||s.prototype&&s.prototype.isReactComponent||!t)return[e];var o=e(t);return"production"===process.env.NODE_ENV||"object"!=typeof o||Array.isArray(o)||o instanceof $e||ie(o)||null===o||console.error("".concat(B(e)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),We(o,t,n,r)}var s;return e instanceof $e?n?(e.inject(n,r),[e.getName(r)]):[e]:ie(e)?Ye(e):Array.isArray(e)?e.flatMap(function(e){return We(e,t,n,r)}):[e.toString()]}function qe(e){for(var t=0;t<e.length;t+=1){var n=e[t];if(ne(n)&&!re(n))return!1}return!0}var He=M("6.0.0-rc.0"),Ue=function(){function e(e,t,n){this.rules=e,this.staticRulesId="",this.isStatic="production"===process.env.NODE_ENV&&(void 0===n||n.isStatic)&&qe(e),this.componentId=t,this.baseHash=V(He,t),this.baseStyle=n,Ae.registerId(t)}return e.prototype.generateAndInjectStyles=function(e,t,n){var r=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,t,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&t.hasNameForId(this.componentId,this.staticRulesId))r=oe(r,this.staticRulesId);else{var o=se(We(this.rules,e,t,n)),s=x(V(this.baseHash,o)>>>0);if(!t.hasNameForId(this.componentId,s)){var i=n(o,".".concat(s),void 0,this.componentId);t.insertRules(this.componentId,s,i)}r=oe(r,s),this.staticRulesId=s}else{for(var a=V(this.baseHash,n.hash),c="",l=0;l<this.rules.length;l++){var u=this.rules[l];if("string"==typeof u)c+=u,"production"!==process.env.NODE_ENV&&(a=V(a,u));else if(u){var p=se(We(u,e,t,n));a=V(a,p),c+=p}}if(c){var d=x(a>>>0);t.hasNameForId(this.componentId,d)||t.insertRules(this.componentId,d,n(c,".".concat(d),void 0,this.componentId)),r=oe(r,d)}}return r},e}(),Je=n.createContext(void 0),Xe=Je.Consumer;function Ze(){return a(Je)}function Ke(e){var r=Ze(),o=s(function(){return function(e,n){if(!e)throw ue(14);if(ne(e)){var r=e(n);if("production"!==process.env.NODE_ENV&&(null===r||Array.isArray(r)||"object"!=typeof r))throw ue(7);return r}if(Array.isArray(e)||"object"!=typeof e)throw ue(8);return n?t(t({},n),e):e}(e.theme,r)},[e.theme,r]);return e.children?n.createElement(Je.Provider,{value:o},e.children):null}var Qe={};function et(e,r,o){var s=re(e),i=e,a=!$(e),u=r.attrs,p=void 0===u?_:u,d=r.componentId,h=void 0===d?function(e,t){var n="string"!=typeof e?"sc":R(e);Qe[n]=(Qe[n]||0)+1;var r="".concat(n,"-").concat(F("6.0.0-rc.0"+n+Qe[n]));return t?"".concat(t,"-").concat(r):r}(r.displayName,r.parentComponentId):d,f=r.displayName,m=void 0===f?function(e){return $(e)?"styled.".concat(e):"Styled(".concat(B(e),")")}(e):f,y=r.displayName&&r.componentId?"".concat(R(r.displayName),"-").concat(r.componentId):r.componentId||h,v=s&&i.attrs?i.attrs.concat(p).filter(Boolean):p,g=r.shouldForwardProp;if(s&&i.shouldForwardProp){var S=i.shouldForwardProp;if(r.shouldForwardProp){var w=r.shouldForwardProp;g=function(e,t){return S(e,t)&&w(e,t)}}else g=S}var b=new Ue(o,y,s?i.componentStyle:void 0),E=b.isStatic&&0===p.length;function N(e,n){return function(e,n,r,o){var s=e.attrs,i=e.componentStyle,a=e.defaultProps,u=e.foldedComponentIds,p=e.styledComponentId,d=e.target,h=Ze(),f=Fe(),m=e.shouldForwardProp||f.shouldForwardProp;"production"!==process.env.NODE_ENV&&c(p);var y=function(e,n,r){for(var o,s=t(t({},n),{className:void 0,theme:r}),i=0;i<e.length;i+=1){var a=ne(o=e[i])?o(s):o;for(var c in a)s[c]="className"===c?oe(s[c],a[c]):"style"===c?t(t({},s[c]),a[c]):a[c]}return n.className&&(s.className=oe(s.className,n.className)),s}(s,n,I(n,h,a)||C),v=y.as||d,g={};for(var S in y)void 0===y[S]||"$"===S[0]||"as"===S||"theme"===S||("forwardedAs"===S?g.as=y.forwardedAs:m&&!m(S,v)||(g[S]=y[S]));var w=function(e,t,n){var r=Fe(),o=e.generateAndInjectStyles(t?C:n,r.styleSheet,r.stylis);return"production"!==process.env.NODE_ENV&&c(o),o}(i,o,y);"production"!==process.env.NODE_ENV&&!o&&e.warnTooManyClasses&&e.warnTooManyClasses(w);var b=oe(u,p);return w&&(b+=" "+w),y.className&&(b+=" "+y.className),g[$(v)&&!A.has(v)?"class":"className"]=b,g.ref=r,l(v,g)}(O,e,n,E)}N.displayName=m;var O=n.forwardRef(N);return O.attrs=v,O.componentStyle=b,O.displayName=m,O.shouldForwardProp=g,O.foldedComponentIds=s?oe(i.foldedComponentIds,i.styledComponentId):"",O.styledComponentId=y,O.target=s?i.target:e,Object.defineProperty(O,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=s?function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0,o=t;r<o.length;r++)ae(e,o[r],!0);return e}({},i.defaultProps,e):e}}),"production"!==process.env.NODE_ENV&&(P(m,y),O.warnTooManyClasses=function(e,t){var n={},r=!1;return function(o){if(!r&&(n[o]=!0,Object.keys(n).length>=200)){var s=t?' with the id of "'.concat(t,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(e).concat(s,".\n")+"Consider using the attrs method, together with a style object for frequently changed styles.\nExample:\n const Component = styled.div.attrs(props => ({\n style: {\n background: props.background,\n },\n }))`width: 100%;`\n\n <Component />"),r=!0,n={}}}}(m,y)),Object.defineProperty(O,"toString",{value:function(){return".".concat(O.styledComponentId)}}),a&&te(O,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),O}function tt(e,t){for(var n=[e[0]],r=0,o=t.length;r<o;r+=1)n.push(t[r],e[r+1]);return n}var nt=function(e){return Object.assign(e,{isCss:!0})};function rt(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(ne(t)||ie(t)){var o=t;return nt(We(tt(_,e([o],n,!0))))}var s=t;return 0===n.length&&1===s.length&&"string"==typeof s[0]?We(s):nt(We(tt(s,n)))}function ot(n,r,o){if(void 0===o&&(o=C),!r)throw ue(1,r);var s=function(t){for(var s=[],i=1;i<arguments.length;i++)s[i-1]=arguments[i];return n(r,o,rt.apply(void 0,e([t],s,!1)))};return s.attrs=function(e){return ot(n,r,t(t({},o),{attrs:Array.prototype.concat(o.attrs,e).filter(Boolean)}))},s.withConfig=function(e){return ot(n,r,t(t({},o),e))},s}var st=function(e){return ot(et,e)},it=st;A.forEach(function(e){it[e]=st(e)});var at=function(){function e(e,t){this.rules=e,this.componentId=t,this.isStatic=qe(e),Ae.registerId(this.componentId+1)}return e.prototype.createStyles=function(e,t,n,r){var o=r(se(We(this.rules,t,n,r)),""),s=this.componentId+e;n.insertRules(s,s,o)},e.prototype.removeStyles=function(e,t){t.clearRules(this.componentId+e)},e.prototype.renderStyles=function(e,t,n,r){e>2&&Ae.registerId(this.componentId+e),this.removeStyles(e,n),this.createStyles(e,t,n,r)},e}();function ct(r){for(var o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];var i=rt.apply(void 0,e([r],o,!1)),a="sc-global-".concat(F(JSON.stringify(i))),c=new at(i,a);"production"!==process.env.NODE_ENV&&P(a);var l=function(e){var t=Fe(),r=Ze(),o=n.useRef(t.styleSheet.allocateGSInstance(a)).current;return"production"!==process.env.NODE_ENV&&n.Children.count(e.children)&&console.warn("The global style component ".concat(a," was given child JSX. createGlobalStyle does not render children.")),"production"!==process.env.NODE_ENV&&i.some(function(e){return"string"==typeof e&&-1!==e.indexOf("@import")})&&console.warn("Please do not use @import CSS syntax in createGlobalStyle at this time, as the CSSOM APIs we use in production do not handle it well. Instead, we recommend using a library such as react-helmet to inject a typical <link> meta tag to the stylesheet, or simply embedding it manually in your index.html <head> section for a simpler app."),t.styleSheet.server&&u(o,e,t.styleSheet,r,t.stylis),(n.useInsertionEffect||n.useLayoutEffect)(function(){if(!t.styleSheet.server)return u(o,e,t.styleSheet,r,t.stylis),function(){return c.removeStyles(o,t.styleSheet)}},[o,e,t.styleSheet,r,t.stylis]),null};function u(e,n,r,o,s){if(c.isStatic)c.renderStyles(e,b,r,s);else{var i=t(t({},n),{theme:I(n,o,l.defaultProps)});c.renderStyles(e,i,r,s)}}return n.memo(l)}function lt(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");var o=se(rt.apply(void 0,e([t],n,!1))),s=F(o);return new $e(s,o)}function ut(e){var r=n.forwardRef(function(r,o){var s=I(r,Ze(),e.defaultProps);return"production"!==process.env.NODE_ENV&&void 0===s&&console.warn('[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class "'.concat(B(e),'"')),n.createElement(e,t({},r,{theme:s,ref:o}))});return r.displayName="WithTheme(".concat(B(e),")"),te(r,e)}var pt=function(){function e(){var e=this;this._emitSheetCSS=function(){var t=e.instance.toString(),n=be(),r=se([n&&'nonce="'.concat(n,'"'),"".concat(v,'="true"'),"".concat("data-styled-version",'="').concat("6.0.0-rc.0",'"')].filter(Boolean)," ");return"<style ".concat(r,">").concat(t,"</style>")},this.getStyleTags=function(){if(e.sealed)throw ue(2);return e._emitSheetCSS()},this.getStyleElement=function(){var r;if(e.sealed)throw ue(2);var o=((r={})[v]="",r["data-styled-version"]="6.0.0-rc.0",r.dangerouslySetInnerHTML={__html:e.instance.toString()},r),s=be();return s&&(o.nonce=s),[n.createElement("style",t({},o,{key:"sc-0-0"}))]},this.seal=function(){e.sealed=!0},this.instance=new Ae({isServer:!0}),this.sealed=!1}return e.prototype.collectStyles=function(e){if(this.sealed)throw ue(2);return n.createElement(Be,{sheet:this.instance},e)},e.prototype.interleaveWithNodeStream=function(e){throw ue(3)},e}(),dt={StyleSheet:Ae,mainSheet:je};"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");var ht="__sc-".concat(v,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[ht]||(window[ht]=0),1===window[ht]&&console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."),window[ht]+=1);export{pt as ServerStyleSheet,Ve as StyleSheetConsumer,ke as StyleSheetContext,Be as StyleSheetManager,Xe as ThemeConsumer,Je as ThemeContext,Ke as ThemeProvider,dt as __PRIVATE__,ct as createGlobalStyle,rt as css,it as default,re as isStyledComponent,lt as keyframes,it as styled,Ze as useTheme,g as version,ut as withTheme};
1820
2
  //# sourceMappingURL=styled-components.browser.esm.js.map