@polymarket-developers/clob-client 1.0.7

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 (48) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +78 -0
  4. package/cache/LICENSE +21 -0
  5. package/cache/README.md +62 -0
  6. package/cache/dist/declarations/src/index.d.ts +2 -0
  7. package/cache/dist/declarations/types/index.d.ts +45 -0
  8. package/cache/dist/emotion-cache.browser.cjs.default.js +1 -0
  9. package/cache/dist/emotion-cache.browser.cjs.js +471 -0
  10. package/cache/dist/emotion-cache.browser.cjs.mjs +2 -0
  11. package/cache/dist/emotion-cache.browser.development.cjs.default.js +1 -0
  12. package/cache/dist/emotion-cache.browser.development.cjs.js +616 -0
  13. package/cache/dist/emotion-cache.browser.development.cjs.mjs +2 -0
  14. package/cache/dist/emotion-cache.browser.development.esm.js +612 -0
  15. package/cache/dist/emotion-cache.browser.esm.js +467 -0
  16. package/cache/dist/emotion-cache.cjs.d.mts +3 -0
  17. package/cache/dist/emotion-cache.cjs.d.ts +3 -0
  18. package/cache/dist/emotion-cache.cjs.default.d.ts +1 -0
  19. package/cache/dist/emotion-cache.cjs.default.js +1 -0
  20. package/cache/dist/emotion-cache.cjs.js +565 -0
  21. package/cache/dist/emotion-cache.cjs.mjs +2 -0
  22. package/cache/dist/emotion-cache.development.cjs.default.js +1 -0
  23. package/cache/dist/emotion-cache.development.cjs.js +714 -0
  24. package/cache/dist/emotion-cache.development.cjs.mjs +2 -0
  25. package/cache/dist/emotion-cache.development.edge-light.cjs.default.js +1 -0
  26. package/cache/dist/emotion-cache.development.edge-light.cjs.js +621 -0
  27. package/cache/dist/emotion-cache.development.edge-light.cjs.mjs +2 -0
  28. package/cache/dist/emotion-cache.development.edge-light.esm.js +612 -0
  29. package/cache/dist/emotion-cache.development.esm.js +705 -0
  30. package/cache/dist/emotion-cache.edge-light.cjs.default.js +1 -0
  31. package/cache/dist/emotion-cache.edge-light.cjs.js +490 -0
  32. package/cache/dist/emotion-cache.edge-light.cjs.mjs +2 -0
  33. package/cache/dist/emotion-cache.edge-light.esm.js +481 -0
  34. package/cache/dist/emotion-cache.esm.js +556 -0
  35. package/cache/package.json +100 -0
  36. package/cache/src/conditions/false.js +1 -0
  37. package/cache/src/conditions/is-browser.js +1 -0
  38. package/cache/src/conditions/true.js +1 -0
  39. package/cache/src/index.d.ts +2 -0
  40. package/cache/src/index.js +257 -0
  41. package/cache/src/prefixer.js +340 -0
  42. package/cache/src/stylis-plugins.js +269 -0
  43. package/cache/src/types.js +26 -0
  44. package/cache/types/index.d.ts +45 -0
  45. package/index.d.ts +63 -0
  46. package/index.js +204 -0
  47. package/package.json +27 -0
  48. package/utils.js +15 -0
@@ -0,0 +1,714 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var sheet = require('@emotion/sheet');
6
+ var stylis = require('stylis');
7
+ var weakMemoize = require('@emotion/weak-memoize');
8
+ var memoize = require('@emotion/memoize');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
11
+
12
+ var weakMemoize__default = /*#__PURE__*/_interopDefault(weakMemoize);
13
+ var memoize__default = /*#__PURE__*/_interopDefault(memoize);
14
+
15
+ var isBrowser = typeof document !== 'undefined';
16
+
17
+ var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
18
+ var previous = 0;
19
+ var character = 0;
20
+
21
+ while (true) {
22
+ previous = character;
23
+ character = stylis.peek(); // &\f
24
+
25
+ if (previous === 38 && character === 12) {
26
+ points[index] = 1;
27
+ }
28
+
29
+ if (stylis.token(character)) {
30
+ break;
31
+ }
32
+
33
+ stylis.next();
34
+ }
35
+
36
+ return stylis.slice(begin, stylis.position);
37
+ };
38
+
39
+ var toRules = function toRules(parsed, points) {
40
+ // pretend we've started with a comma
41
+ var index = -1;
42
+ var character = 44;
43
+
44
+ do {
45
+ switch (stylis.token(character)) {
46
+ case 0:
47
+ // &\f
48
+ if (character === 38 && stylis.peek() === 12) {
49
+ // this is not 100% correct, we don't account for literal sequences here - like for example quoted strings
50
+ // stylis inserts \f after & to know when & where it should replace this sequence with the context selector
51
+ // and when it should just concatenate the outer and inner selectors
52
+ // it's very unlikely for this sequence to actually appear in a different context, so we just leverage this fact here
53
+ points[index] = 1;
54
+ }
55
+
56
+ parsed[index] += identifierWithPointTracking(stylis.position - 1, points, index);
57
+ break;
58
+
59
+ case 2:
60
+ parsed[index] += stylis.delimit(character);
61
+ break;
62
+
63
+ case 4:
64
+ // comma
65
+ if (character === 44) {
66
+ // colon
67
+ parsed[++index] = stylis.peek() === 58 ? '&\f' : '';
68
+ points[index] = parsed[index].length;
69
+ break;
70
+ }
71
+
72
+ // fallthrough
73
+
74
+ default:
75
+ parsed[index] += stylis.from(character);
76
+ }
77
+ } while (character = stylis.next());
78
+
79
+ return parsed;
80
+ };
81
+
82
+ var getRules = function getRules(value, points) {
83
+ return stylis.dealloc(toRules(stylis.alloc(value), points));
84
+ }; // WeakSet would be more appropriate, but only WeakMap is supported in IE11
85
+
86
+
87
+ var fixedElements = /* #__PURE__ */new WeakMap();
88
+ var compat = function compat(element) {
89
+ if (element.type !== 'rule' || !element.parent || // positive .length indicates that this rule contains pseudo
90
+ // negative .length indicates that this rule has been already prefixed
91
+ element.length < 1) {
92
+ return;
93
+ }
94
+
95
+ var value = element.value,
96
+ parent = element.parent;
97
+ var isImplicitRule = element.column === parent.column && element.line === parent.line;
98
+
99
+ while (parent.type !== 'rule') {
100
+ parent = parent.parent;
101
+ if (!parent) return;
102
+ } // short-circuit for the simplest case
103
+
104
+
105
+ if (element.props.length === 1 && value.charCodeAt(0) !== 58
106
+ /* colon */
107
+ && !fixedElements.get(parent)) {
108
+ return;
109
+ } // if this is an implicitly inserted rule (the one eagerly inserted at the each new nested level)
110
+ // then the props has already been manipulated beforehand as they that array is shared between it and its "rule parent"
111
+
112
+
113
+ if (isImplicitRule) {
114
+ return;
115
+ }
116
+
117
+ fixedElements.set(element, true);
118
+ var points = [];
119
+ var rules = getRules(value, points);
120
+ var parentRules = parent.props;
121
+
122
+ for (var i = 0, k = 0; i < rules.length; i++) {
123
+ for (var j = 0; j < parentRules.length; j++, k++) {
124
+ element.props[k] = points[i] ? rules[i].replace(/&\f/g, parentRules[j]) : parentRules[j] + " " + rules[i];
125
+ }
126
+ }
127
+ };
128
+ var removeLabel = function removeLabel(element) {
129
+ if (element.type === 'decl') {
130
+ var value = element.value;
131
+
132
+ if ( // charcode for l
133
+ value.charCodeAt(0) === 108 && // charcode for b
134
+ value.charCodeAt(2) === 98) {
135
+ // this ignores label
136
+ element["return"] = '';
137
+ element.value = '';
138
+ }
139
+ }
140
+ };
141
+ var ignoreFlag = 'emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason';
142
+
143
+ var isIgnoringComment = function isIgnoringComment(element) {
144
+ return element.type === 'comm' && element.children.indexOf(ignoreFlag) > -1;
145
+ };
146
+
147
+ var createUnsafeSelectorsAlarm = function createUnsafeSelectorsAlarm(cache) {
148
+ return function (element, index, children) {
149
+ if (element.type !== 'rule' || cache.compat) return;
150
+ var unsafePseudoClasses = element.value.match(/(:first|:nth|:nth-last)-child/g);
151
+
152
+ if (unsafePseudoClasses) {
153
+ var isNested = !!element.parent; // in nested rules comments become children of the "auto-inserted" rule and that's always the `element.parent`
154
+ //
155
+ // considering this input:
156
+ // .a {
157
+ // .b /* comm */ {}
158
+ // color: hotpink;
159
+ // }
160
+ // we get output corresponding to this:
161
+ // .a {
162
+ // & {
163
+ // /* comm */
164
+ // color: hotpink;
165
+ // }
166
+ // .b {}
167
+ // }
168
+
169
+ var commentContainer = isNested ? element.parent.children : // global rule at the root level
170
+ children;
171
+
172
+ for (var i = commentContainer.length - 1; i >= 0; i--) {
173
+ var node = commentContainer[i];
174
+
175
+ if (node.line < element.line) {
176
+ break;
177
+ } // it is quite weird but comments are *usually* put at `column: element.column - 1`
178
+ // so we seek *from the end* for the node that is earlier than the rule's `element` and check that
179
+ // this will also match inputs like this:
180
+ // .a {
181
+ // /* comm */
182
+ // .b {}
183
+ // }
184
+ //
185
+ // but that is fine
186
+ //
187
+ // it would be the easiest to change the placement of the comment to be the first child of the rule:
188
+ // .a {
189
+ // .b { /* comm */ }
190
+ // }
191
+ // with such inputs we wouldn't have to search for the comment at all
192
+ // TODO: consider changing this comment placement in the next major version
193
+
194
+
195
+ if (node.column < element.column) {
196
+ if (isIgnoringComment(node)) {
197
+ return;
198
+ }
199
+
200
+ break;
201
+ }
202
+ }
203
+
204
+ unsafePseudoClasses.forEach(function (unsafePseudoClass) {
205
+ console.error("The pseudo class \"" + unsafePseudoClass + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + unsafePseudoClass.split('-child')[0] + "-of-type\".");
206
+ });
207
+ }
208
+ };
209
+ };
210
+
211
+ var isImportRule = function isImportRule(element) {
212
+ return element.type.charCodeAt(1) === 105 && element.type.charCodeAt(0) === 64;
213
+ };
214
+
215
+ var isPrependedWithRegularRules = function isPrependedWithRegularRules(index, children) {
216
+ for (var i = index - 1; i >= 0; i--) {
217
+ if (!isImportRule(children[i])) {
218
+ return true;
219
+ }
220
+ }
221
+
222
+ return false;
223
+ }; // use this to remove incorrect elements from further processing
224
+ // so they don't get handed to the `sheet` (or anything else)
225
+ // as that could potentially lead to additional logs which in turn could be overhelming to the user
226
+
227
+
228
+ var nullifyElement = function nullifyElement(element) {
229
+ element.type = '';
230
+ element.value = '';
231
+ element["return"] = '';
232
+ element.children = '';
233
+ element.props = '';
234
+ };
235
+
236
+ var incorrectImportAlarm = function incorrectImportAlarm(element, index, children) {
237
+ if (!isImportRule(element)) {
238
+ return;
239
+ }
240
+
241
+ if (element.parent) {
242
+ console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles.");
243
+ nullifyElement(element);
244
+ } else if (isPrependedWithRegularRules(index, children)) {
245
+ console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules.");
246
+ nullifyElement(element);
247
+ }
248
+ };
249
+
250
+ /* eslint-disable no-fallthrough */
251
+
252
+ function prefix(value, length) {
253
+ switch (stylis.hash(value, length)) {
254
+ // color-adjust
255
+ case 5103:
256
+ return stylis.WEBKIT + 'print-' + value + value;
257
+ // animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
258
+
259
+ case 5737:
260
+ case 4201:
261
+ case 3177:
262
+ case 3433:
263
+ case 1641:
264
+ case 4457:
265
+ case 2921: // text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
266
+
267
+ case 5572:
268
+ case 6356:
269
+ case 5844:
270
+ case 3191:
271
+ case 6645:
272
+ case 3005: // mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
273
+
274
+ case 6391:
275
+ case 5879:
276
+ case 5623:
277
+ case 6135:
278
+ case 4599:
279
+ case 4855: // background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
280
+
281
+ case 4215:
282
+ case 6389:
283
+ case 5109:
284
+ case 5365:
285
+ case 5621:
286
+ case 3829:
287
+ return stylis.WEBKIT + value + value;
288
+ // appearance, user-select, transform, hyphens, text-size-adjust
289
+
290
+ case 5349:
291
+ case 4246:
292
+ case 4810:
293
+ case 6968:
294
+ case 2756:
295
+ return stylis.WEBKIT + value + stylis.MOZ + value + stylis.MS + value + value;
296
+ // flex, flex-direction
297
+
298
+ case 6828:
299
+ case 4268:
300
+ return stylis.WEBKIT + value + stylis.MS + value + value;
301
+ // order
302
+
303
+ case 6165:
304
+ return stylis.WEBKIT + value + stylis.MS + 'flex-' + value + value;
305
+ // align-items
306
+
307
+ case 5187:
308
+ return stylis.WEBKIT + value + stylis.replace(value, /(\w+).+(:[^]+)/, stylis.WEBKIT + 'box-$1$2' + stylis.MS + 'flex-$1$2') + value;
309
+ // align-self
310
+
311
+ case 5443:
312
+ return stylis.WEBKIT + value + stylis.MS + 'flex-item-' + stylis.replace(value, /flex-|-self/, '') + value;
313
+ // align-content
314
+
315
+ case 4675:
316
+ return stylis.WEBKIT + value + stylis.MS + 'flex-line-pack' + stylis.replace(value, /align-content|flex-|-self/, '') + value;
317
+ // flex-shrink
318
+
319
+ case 5548:
320
+ return stylis.WEBKIT + value + stylis.MS + stylis.replace(value, 'shrink', 'negative') + value;
321
+ // flex-basis
322
+
323
+ case 5292:
324
+ return stylis.WEBKIT + value + stylis.MS + stylis.replace(value, 'basis', 'preferred-size') + value;
325
+ // flex-grow
326
+
327
+ case 6060:
328
+ return stylis.WEBKIT + 'box-' + stylis.replace(value, '-grow', '') + stylis.WEBKIT + value + stylis.MS + stylis.replace(value, 'grow', 'positive') + value;
329
+ // transition
330
+
331
+ case 4554:
332
+ return stylis.WEBKIT + stylis.replace(value, /([^-])(transform)/g, '$1' + stylis.WEBKIT + '$2') + value;
333
+ // cursor
334
+
335
+ case 6187:
336
+ return stylis.replace(stylis.replace(stylis.replace(value, /(zoom-|grab)/, stylis.WEBKIT + '$1'), /(image-set)/, stylis.WEBKIT + '$1'), value, '') + value;
337
+ // background, background-image
338
+
339
+ case 5495:
340
+ case 3959:
341
+ return stylis.replace(value, /(image-set\([^]*)/, stylis.WEBKIT + '$1' + '$`$1');
342
+ // justify-content
343
+
344
+ case 4968:
345
+ return stylis.replace(stylis.replace(value, /(.+:)(flex-)?(.*)/, stylis.WEBKIT + 'box-pack:$3' + stylis.MS + 'flex-pack:$3'), /s.+-b[^;]+/, 'justify') + stylis.WEBKIT + value + value;
346
+ // (margin|padding)-inline-(start|end)
347
+
348
+ case 4095:
349
+ case 3583:
350
+ case 4068:
351
+ case 2532:
352
+ return stylis.replace(value, /(.+)-inline(.+)/, stylis.WEBKIT + '$1$2') + value;
353
+ // (min|max)?(width|height|inline-size|block-size)
354
+
355
+ case 8116:
356
+ case 7059:
357
+ case 5753:
358
+ case 5535:
359
+ case 5445:
360
+ case 5701:
361
+ case 4933:
362
+ case 4677:
363
+ case 5533:
364
+ case 5789:
365
+ case 5021:
366
+ case 4765:
367
+ // stretch, max-content, min-content, fill-available
368
+ if (stylis.strlen(value) - 1 - length > 6) switch (stylis.charat(value, length + 1)) {
369
+ // (m)ax-content, (m)in-content
370
+ case 109:
371
+ // -
372
+ if (stylis.charat(value, length + 4) !== 45) break;
373
+ // (f)ill-available, (f)it-content
374
+
375
+ case 102:
376
+ return stylis.replace(value, /(.+:)(.+)-([^]+)/, '$1' + stylis.WEBKIT + '$2-$3' + '$1' + stylis.MOZ + (stylis.charat(value, length + 3) == 108 ? '$3' : '$2-$3')) + value;
377
+ // (s)tretch
378
+
379
+ case 115:
380
+ return ~stylis.indexof(value, 'stretch') ? prefix(stylis.replace(value, 'stretch', 'fill-available'), length) + value : value;
381
+ }
382
+ break;
383
+ // position: sticky
384
+
385
+ case 4949:
386
+ // (s)ticky?
387
+ if (stylis.charat(value, length + 1) !== 115) break;
388
+ // display: (flex|inline-flex)
389
+
390
+ case 6444:
391
+ switch (stylis.charat(value, stylis.strlen(value) - 3 - (~stylis.indexof(value, '!important') && 10))) {
392
+ // stic(k)y
393
+ case 107:
394
+ return stylis.replace(value, ':', ':' + stylis.WEBKIT) + value;
395
+ // (inline-)?fl(e)x
396
+
397
+ case 101:
398
+ return stylis.replace(value, /(.+:)([^;!]+)(;|!.+)?/, '$1' + stylis.WEBKIT + (stylis.charat(value, 14) === 45 ? 'inline-' : '') + 'box$3' + '$1' + stylis.WEBKIT + '$2$3' + '$1' + stylis.MS + '$2box$3') + value;
399
+ }
400
+
401
+ break;
402
+ // writing-mode
403
+
404
+ case 5936:
405
+ switch (stylis.charat(value, length + 11)) {
406
+ // vertical-l(r)
407
+ case 114:
408
+ return stylis.WEBKIT + value + stylis.MS + stylis.replace(value, /[svh]\w+-[tblr]{2}/, 'tb') + value;
409
+ // vertical-r(l)
410
+
411
+ case 108:
412
+ return stylis.WEBKIT + value + stylis.MS + stylis.replace(value, /[svh]\w+-[tblr]{2}/, 'tb-rl') + value;
413
+ // horizontal(-)tb
414
+
415
+ case 45:
416
+ return stylis.WEBKIT + value + stylis.MS + stylis.replace(value, /[svh]\w+-[tblr]{2}/, 'lr') + value;
417
+ }
418
+
419
+ return stylis.WEBKIT + value + stylis.MS + value + value;
420
+ }
421
+
422
+ return value;
423
+ }
424
+
425
+ var prefixer = function prefixer(element, index, children, callback) {
426
+ if (element.length > -1) if (!element["return"]) switch (element.type) {
427
+ case stylis.DECLARATION:
428
+ element["return"] = prefix(element.value, element.length);
429
+ break;
430
+
431
+ case stylis.KEYFRAMES:
432
+ return stylis.serialize([stylis.copy(element, {
433
+ value: stylis.replace(element.value, '@', '@' + stylis.WEBKIT)
434
+ })], callback);
435
+
436
+ case stylis.RULESET:
437
+ if (element.length) return stylis.combine(element.props, function (value) {
438
+ switch (stylis.match(value, /(::plac\w+|:read-\w+)/)) {
439
+ // :read-(only|write)
440
+ case ':read-only':
441
+ case ':read-write':
442
+ return stylis.serialize([stylis.copy(element, {
443
+ props: [stylis.replace(value, /:(read-\w+)/, ':' + stylis.MOZ + '$1')]
444
+ })], callback);
445
+ // :placeholder
446
+
447
+ case '::placeholder':
448
+ return stylis.serialize([stylis.copy(element, {
449
+ props: [stylis.replace(value, /:(plac\w+)/, ':' + stylis.WEBKIT + 'input-$1')]
450
+ }), stylis.copy(element, {
451
+ props: [stylis.replace(value, /:(plac\w+)/, ':' + stylis.MOZ + '$1')]
452
+ }), stylis.copy(element, {
453
+ props: [stylis.replace(value, /:(plac\w+)/, stylis.MS + 'input-$1')]
454
+ })], callback);
455
+ }
456
+
457
+ return '';
458
+ });
459
+ }
460
+ };
461
+
462
+ /* import type { StylisPlugin } from './types' */
463
+
464
+ /*
465
+ export type Options = {
466
+ nonce?: string,
467
+ stylisPlugins?: StylisPlugin[],
468
+ key: string,
469
+ container?: HTMLElement,
470
+ speedy?: boolean,
471
+ prepend?: boolean,
472
+ insertionPoint?: HTMLElement
473
+ }
474
+ */
475
+
476
+ var getServerStylisCache = isBrowser ? undefined : weakMemoize__default["default"](function () {
477
+ return memoize__default["default"](function () {
478
+ var cache = {};
479
+ return function (name) {
480
+ return cache[name];
481
+ };
482
+ });
483
+ });
484
+ var defaultStylisPlugins = [prefixer];
485
+
486
+ var createCache = function
487
+ /*: EmotionCache */
488
+ createCache(options
489
+ /*: Options */
490
+ ) {
491
+ var key = options.key;
492
+
493
+ if (!key) {
494
+ throw new Error("You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\n" + "If multiple caches share the same key they might \"fight\" for each other's style elements.");
495
+ }
496
+
497
+ if (isBrowser && key === 'css') {
498
+ var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); // get SSRed styles out of the way of React's hydration
499
+ // document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
500
+ // note this very very intentionally targets all style elements regardless of the key to ensure
501
+ // that creating a cache works inside of render of a React component
502
+
503
+ Array.prototype.forEach.call(ssrStyles, function (node
504
+ /*: HTMLStyleElement */
505
+ ) {
506
+ // we want to only move elements which have a space in the data-emotion attribute value
507
+ // because that indicates that it is an Emotion 11 server-side rendered style elements
508
+ // while we will already ignore Emotion 11 client-side inserted styles because of the :not([data-s]) part in the selector
509
+ // Emotion 10 client-side inserted styles did not have data-s (but importantly did not have a space in their data-emotion attributes)
510
+ // so checking for the space ensures that loading Emotion 11 after Emotion 10 has inserted some styles
511
+ // will not result in the Emotion 10 styles being destroyed
512
+ var dataEmotionAttribute = node.getAttribute('data-emotion');
513
+
514
+ if (dataEmotionAttribute.indexOf(' ') === -1) {
515
+ return;
516
+ }
517
+
518
+ document.head.appendChild(node);
519
+ node.setAttribute('data-s', '');
520
+ });
521
+ }
522
+
523
+ var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
524
+
525
+ {
526
+ if (/[^a-z-]/.test(key)) {
527
+ throw new Error("Emotion key must only contain lower case alphabetical characters and - but \"" + key + "\" was passed");
528
+ }
529
+ }
530
+
531
+ var inserted = {};
532
+ var container;
533
+ /* : Node */
534
+
535
+ var nodesToHydrate = [];
536
+
537
+ if (isBrowser) {
538
+ container = options.container || document.head;
539
+ Array.prototype.forEach.call( // this means we will ignore elements which don't have a space in them which
540
+ // means that the style elements we're looking at are only Emotion 11 server-rendered style elements
541
+ document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node
542
+ /*: HTMLStyleElement */
543
+ ) {
544
+ var attrib = node.getAttribute("data-emotion").split(' ');
545
+
546
+ for (var i = 1; i < attrib.length; i++) {
547
+ inserted[attrib[i]] = true;
548
+ }
549
+
550
+ nodesToHydrate.push(node);
551
+ });
552
+ }
553
+
554
+ var _insert;
555
+ /*: (
556
+ selector: string,
557
+ serialized: SerializedStyles,
558
+ sheet: StyleSheet,
559
+ shouldCache: boolean
560
+ ) => string | void */
561
+
562
+
563
+ var omnipresentPlugins = [compat, removeLabel];
564
+
565
+ {
566
+ omnipresentPlugins.push(createUnsafeSelectorsAlarm({
567
+ get compat() {
568
+ return cache.compat;
569
+ }
570
+
571
+ }), incorrectImportAlarm);
572
+ }
573
+
574
+ if (isBrowser) {
575
+ var currentSheet;
576
+ var finalizingPlugins = [stylis.stringify, function (element) {
577
+ if (!element.root) {
578
+ if (element["return"]) {
579
+ currentSheet.insert(element["return"]);
580
+ } else if (element.value && element.type !== stylis.COMMENT) {
581
+ // insert empty rule in non-production environments
582
+ // so @emotion/jest can grab `key` from the (JS)DOM for caches without any rules inserted yet
583
+ currentSheet.insert(element.value + "{}");
584
+ }
585
+ }
586
+ } ];
587
+ var serializer = stylis.middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
588
+
589
+ var stylis$1 = function stylis$1(styles) {
590
+ return stylis.serialize(stylis.compile(styles), serializer);
591
+ };
592
+
593
+ _insert = function
594
+ /*: void */
595
+ insert(selector
596
+ /*: string */
597
+ , serialized
598
+ /*: SerializedStyles */
599
+ , sheet
600
+ /*: StyleSheet */
601
+ , shouldCache
602
+ /*: boolean */
603
+ ) {
604
+ currentSheet = sheet;
605
+
606
+ if (serialized.map !== undefined) {
607
+ currentSheet = {
608
+ insert: function insert(rule
609
+ /*: string */
610
+ ) {
611
+ sheet.insert(rule + serialized.map);
612
+ }
613
+ };
614
+ }
615
+
616
+ stylis$1(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
617
+
618
+ if (shouldCache) {
619
+ cache.inserted[serialized.name] = true;
620
+ }
621
+ };
622
+ } else {
623
+ var _finalizingPlugins = [stylis.stringify];
624
+
625
+ var _serializer = stylis.middleware(omnipresentPlugins.concat(stylisPlugins, _finalizingPlugins));
626
+
627
+ var _stylis = function _stylis(styles) {
628
+ return stylis.serialize(stylis.compile(styles), _serializer);
629
+ };
630
+
631
+ var serverStylisCache = getServerStylisCache(stylisPlugins)(key);
632
+
633
+ var getRules = function
634
+ /*: string */
635
+ getRules(selector
636
+ /*: string */
637
+ , serialized
638
+ /*: SerializedStyles */
639
+ ) {
640
+ var name = serialized.name;
641
+
642
+ if (serverStylisCache[name] === undefined) {
643
+ serverStylisCache[name] = _stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
644
+ }
645
+
646
+ return serverStylisCache[name];
647
+ };
648
+
649
+ _insert = function
650
+ /*: string | void */
651
+ _insert(selector
652
+ /*: string */
653
+ , serialized
654
+ /*: SerializedStyles */
655
+ , sheet
656
+ /*: StyleSheet */
657
+ , shouldCache
658
+ /*: boolean */
659
+ ) {
660
+ var name = serialized.name;
661
+ var rules = getRules(selector, serialized);
662
+
663
+ if (cache.compat === undefined) {
664
+ // in regular mode, we don't set the styles on the inserted cache
665
+ // since we don't need to and that would be wasting memory
666
+ // we return them so that they are rendered in a style tag
667
+ if (shouldCache) {
668
+ cache.inserted[name] = true;
669
+ }
670
+
671
+ if (serialized.map !== undefined) {
672
+ return rules + serialized.map;
673
+ }
674
+
675
+ return rules;
676
+ } else {
677
+ // in compat mode, we put the styles on the inserted cache so
678
+ // that emotion-server can pull out the styles
679
+ // except when we don't want to cache it which was in Global but now
680
+ // is nowhere but we don't want to do a major right now
681
+ // and just in case we're going to leave the case here
682
+ // it's also not affecting client side bundle size
683
+ // so it's really not a big deal
684
+ if (shouldCache) {
685
+ cache.inserted[name] = rules;
686
+ } else {
687
+ return rules;
688
+ }
689
+ }
690
+ };
691
+ }
692
+
693
+ var cache
694
+ /*: EmotionCache */
695
+ = {
696
+ key: key,
697
+ sheet: new sheet.StyleSheet({
698
+ key: key,
699
+ container: container,
700
+ nonce: options.nonce,
701
+ speedy: options.speedy,
702
+ prepend: options.prepend,
703
+ insertionPoint: options.insertionPoint
704
+ }),
705
+ nonce: options.nonce,
706
+ inserted: inserted,
707
+ registered: {},
708
+ insert: _insert
709
+ };
710
+ cache.sheet.hydrate(nodesToHydrate);
711
+ return cache;
712
+ };
713
+
714
+ exports["default"] = createCache;