@eightshift/ui-components 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +27 -0
  2. package/dist/Checkbox-BLcVbhiO.js +178 -0
  3. package/dist/ColorSwatch-Cmlex_kT.js +66 -0
  4. package/dist/FieldError-wtMA4667.js +42 -0
  5. package/dist/FocusScope-1u9yyfIN.js +725 -0
  6. package/dist/Form-Cq3fu75_.js +5 -0
  7. package/dist/GridList-BZPXp3_O.js +1256 -0
  8. package/dist/Group-DyqpTRPe.js +49 -0
  9. package/dist/Input-jsbb4ugq.js +130 -0
  10. package/dist/Label-BPzS-sR7.js +17 -0
  11. package/dist/ListBox-w9gDaJkV.js +4423 -0
  12. package/dist/LiveAnnouncer-IsokfWQ5.js +73 -0
  13. package/dist/NumberFormatter-LzoKy975.js +160 -0
  14. package/dist/RSPContexts-CrNYmadY.js +14 -0
  15. package/dist/Select-49a62830.esm-C-RFtLiD.js +2541 -0
  16. package/dist/SelectionManager-mefd0ThJ.js +2155 -0
  17. package/dist/Separator-DHn0CwdK.js +325 -0
  18. package/dist/Slider-Pyh2V4bY.js +885 -0
  19. package/dist/Text-BM136LvS.js +17 -0
  20. package/dist/VisuallyHidden-BYRI1Lfo.js +51 -0
  21. package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
  22. package/dist/ariaHideOutside-ByKBPHmX.js +113 -0
  23. package/dist/assets/style.css +1 -0
  24. package/dist/button-BkkdyHfJ.js +307 -0
  25. package/dist/components/animated-visibility/animated-visibility.js +7165 -0
  26. package/dist/components/base-control/base-control.js +97 -0
  27. package/dist/components/breakpoint-preview/breakpoint-preview.js +218 -0
  28. package/dist/components/button/button.js +10 -0
  29. package/dist/components/checkbox/checkbox.js +119 -0
  30. package/dist/components/color-pickers/color-picker.js +242 -0
  31. package/dist/components/color-pickers/color-swatch.js +62 -0
  32. package/dist/components/color-pickers/gradient-editor.js +516 -0
  33. package/dist/components/color-pickers/solid-color-picker.js +1633 -0
  34. package/dist/components/component-toggle/component-toggle.js +71 -0
  35. package/dist/components/container-panel/container-panel.js +39 -0
  36. package/dist/components/expandable/expandable.js +144 -0
  37. package/dist/components/input-field/input-field.js +224 -0
  38. package/dist/components/link-input/link-input.js +937 -0
  39. package/dist/components/list-box/list-box.js +152 -0
  40. package/dist/components/matrix-align/matrix-align.js +185 -0
  41. package/dist/components/menu/menu.js +1608 -0
  42. package/dist/components/notice/notice.js +119 -0
  43. package/dist/components/number-picker/number-picker.js +277 -0
  44. package/dist/components/popover/popover.js +9 -0
  45. package/dist/components/radio/radio.js +552 -0
  46. package/dist/components/repeater/repeater-item.js +127 -0
  47. package/dist/components/repeater/repeater.js +248 -0
  48. package/dist/components/responsive/responsive-legacy.js +326 -0
  49. package/dist/components/responsive/responsive.js +499 -0
  50. package/dist/components/responsive-preview/responsive-preview.js +119 -0
  51. package/dist/components/rich-label/rich-label.js +56 -0
  52. package/dist/components/select/async-multi-select.js +144 -0
  53. package/dist/components/select/async-single-select.js +126 -0
  54. package/dist/components/select/custom-select-default-components.js +38 -0
  55. package/dist/components/select/multi-select-components.js +8 -0
  56. package/dist/components/select/multi-select.js +134 -0
  57. package/dist/components/select/react-select-component-wrappers.js +90 -0
  58. package/dist/components/select/shared.js +45 -0
  59. package/dist/components/select/single-select.js +116 -0
  60. package/dist/components/select/styles.js +55 -0
  61. package/dist/components/slider/column-config-slider.js +225 -0
  62. package/dist/components/slider/slider.js +362 -0
  63. package/dist/components/slider/utils.js +45 -0
  64. package/dist/components/spacer/spacer.js +93 -0
  65. package/dist/components/tabs/tabs.js +626 -0
  66. package/dist/components/toggle/switch.js +140 -0
  67. package/dist/components/toggle/toggle.js +58 -0
  68. package/dist/components/toggle-button/toggle-button.js +206 -0
  69. package/dist/components/tooltip/tooltip.js +10 -0
  70. package/dist/context-jMy6xdVq.js +98 -0
  71. package/dist/default-i18n-BhE-OUmt.js +873 -0
  72. package/dist/filterDOMProps-DG2RfOUr.js +30 -0
  73. package/dist/focusSafely-C3K8zAKj.js +743 -0
  74. package/dist/hooks/use-cell-edit-mode.js +35 -0
  75. package/dist/icons/block-icon.js +42 -0
  76. package/dist/icons/generic-color-swatch.js +21 -0
  77. package/dist/icons/icons.js +3636 -0
  78. package/dist/index-Bfb9bWcb.js +28844 -0
  79. package/dist/index-a301f526.esm-Bioi4cGX.js +3576 -0
  80. package/dist/index.js +109 -0
  81. package/dist/intlStrings-CUhoK9EN.js +2484 -0
  82. package/dist/isScrollable-PcyglExV.js +10 -0
  83. package/dist/modifiers.esm-BuJQPI1X.js +31 -0
  84. package/dist/multi-select-components-CjVpCNko.js +3677 -0
  85. package/dist/number-rWqELA8W.js +39 -0
  86. package/dist/popover-Dx3vKXUX.js +1061 -0
  87. package/dist/react-select-async.esm-TFb_ZX6C.js +111 -0
  88. package/dist/react-select.esm-BjRWqf0E.js +15 -0
  89. package/dist/style.js +1 -0
  90. package/dist/textSelection-BosCCRVE.js +89 -0
  91. package/dist/tooltip-CkCndvTI.js +1094 -0
  92. package/dist/useButton-CuG5UzUw.js +74 -0
  93. package/dist/useEvent-DHv-yhOH.js +24 -0
  94. package/dist/useFocusRing-Cc-4eouh.js +41 -0
  95. package/dist/useFocusable-5q1Gek1J.js +81 -0
  96. package/dist/useFormReset-Buc9YJcv.js +23 -0
  97. package/dist/useFormValidationState-BAPPNXic.js +238 -0
  98. package/dist/useHasTabbableChild-D3uUNhJ0.js +37 -0
  99. package/dist/useLabel-CGlkoFG0.js +28 -0
  100. package/dist/useLabels-Dg62M_3P.js +25 -0
  101. package/dist/useListData-BelKu4kx.js +211 -0
  102. package/dist/useListState-Domq0blV.js +137 -0
  103. package/dist/useLocalizedStringFormatter-Prmz0h0A.js +130 -0
  104. package/dist/useNumberFieldState-BLU3uhSR.js +1253 -0
  105. package/dist/useNumberFormatter-BLc2xjZn.js +13 -0
  106. package/dist/usePress-BQgVor4T.js +698 -0
  107. package/dist/useToggle-C9ETOBaZ.js +58 -0
  108. package/dist/useToggleState-DJ_z5E2S.js +21 -0
  109. package/dist/utilities/classnames.js +16 -0
  110. package/dist/utilities/text-helpers.js +79 -0
  111. package/dist/utils-BsiH7-5Y.js +488 -0
  112. package/package.json +71 -0
@@ -0,0 +1,873 @@
1
+ import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.js";
2
+ function memize(fn, options) {
3
+ var size = 0;
4
+ var head;
5
+ var tail;
6
+ options = options || {};
7
+ function memoized() {
8
+ var node = head, len = arguments.length, args, i;
9
+ searchCache:
10
+ while (node) {
11
+ if (node.args.length !== arguments.length) {
12
+ node = node.next;
13
+ continue;
14
+ }
15
+ for (i = 0; i < len; i++) {
16
+ if (node.args[i] !== arguments[i]) {
17
+ node = node.next;
18
+ continue searchCache;
19
+ }
20
+ }
21
+ if (node !== head) {
22
+ if (node === tail) {
23
+ tail = node.prev;
24
+ }
25
+ node.prev.next = node.next;
26
+ if (node.next) {
27
+ node.next.prev = node.prev;
28
+ }
29
+ node.next = head;
30
+ node.prev = null;
31
+ head.prev = node;
32
+ head = node;
33
+ }
34
+ return node.val;
35
+ }
36
+ args = new Array(len);
37
+ for (i = 0; i < len; i++) {
38
+ args[i] = arguments[i];
39
+ }
40
+ node = {
41
+ args,
42
+ // Generate the result from original function
43
+ val: fn.apply(null, args)
44
+ };
45
+ if (head) {
46
+ head.prev = node;
47
+ node.next = head;
48
+ } else {
49
+ tail = node;
50
+ }
51
+ if (size === /** @type {MemizeOptions} */
52
+ options.maxSize) {
53
+ tail = /** @type {MemizeCacheNode} */
54
+ tail.prev;
55
+ tail.next = null;
56
+ } else {
57
+ size++;
58
+ }
59
+ head = node;
60
+ return node.val;
61
+ }
62
+ memoized.clear = function() {
63
+ head = null;
64
+ tail = null;
65
+ size = 0;
66
+ };
67
+ return memoized;
68
+ }
69
+ var sprintf$1 = {};
70
+ (function(exports) {
71
+ !function() {
72
+ var re = {
73
+ not_string: /[^s]/,
74
+ not_bool: /[^t]/,
75
+ not_type: /[^T]/,
76
+ not_primitive: /[^v]/,
77
+ number: /[diefg]/,
78
+ numeric_arg: /[bcdiefguxX]/,
79
+ json: /[j]/,
80
+ not_json: /[^j]/,
81
+ text: /^[^\x25]+/,
82
+ modulo: /^\x25{2}/,
83
+ placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
84
+ key: /^([a-z_][a-z_\d]*)/i,
85
+ key_access: /^\.([a-z_][a-z_\d]*)/i,
86
+ index_access: /^\[(\d+)\]/,
87
+ sign: /^[+-]/
88
+ };
89
+ function sprintf2(key) {
90
+ return sprintf_format(sprintf_parse(key), arguments);
91
+ }
92
+ function vsprintf(fmt, argv) {
93
+ return sprintf2.apply(null, [fmt].concat(argv || []));
94
+ }
95
+ function sprintf_format(parse_tree, argv) {
96
+ var cursor = 1, tree_length = parse_tree.length, arg, output = "", i, k, ph, pad, pad_character, pad_length, is_positive, sign;
97
+ for (i = 0; i < tree_length; i++) {
98
+ if (typeof parse_tree[i] === "string") {
99
+ output += parse_tree[i];
100
+ } else if (typeof parse_tree[i] === "object") {
101
+ ph = parse_tree[i];
102
+ if (ph.keys) {
103
+ arg = argv[cursor];
104
+ for (k = 0; k < ph.keys.length; k++) {
105
+ if (arg == void 0) {
106
+ throw new Error(sprintf2('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k - 1]));
107
+ }
108
+ arg = arg[ph.keys[k]];
109
+ }
110
+ } else if (ph.param_no) {
111
+ arg = argv[ph.param_no];
112
+ } else {
113
+ arg = argv[cursor++];
114
+ }
115
+ if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {
116
+ arg = arg();
117
+ }
118
+ if (re.numeric_arg.test(ph.type) && (typeof arg !== "number" && isNaN(arg))) {
119
+ throw new TypeError(sprintf2("[sprintf] expecting number but found %T", arg));
120
+ }
121
+ if (re.number.test(ph.type)) {
122
+ is_positive = arg >= 0;
123
+ }
124
+ switch (ph.type) {
125
+ case "b":
126
+ arg = parseInt(arg, 10).toString(2);
127
+ break;
128
+ case "c":
129
+ arg = String.fromCharCode(parseInt(arg, 10));
130
+ break;
131
+ case "d":
132
+ case "i":
133
+ arg = parseInt(arg, 10);
134
+ break;
135
+ case "j":
136
+ arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0);
137
+ break;
138
+ case "e":
139
+ arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential();
140
+ break;
141
+ case "f":
142
+ arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg);
143
+ break;
144
+ case "g":
145
+ arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg);
146
+ break;
147
+ case "o":
148
+ arg = (parseInt(arg, 10) >>> 0).toString(8);
149
+ break;
150
+ case "s":
151
+ arg = String(arg);
152
+ arg = ph.precision ? arg.substring(0, ph.precision) : arg;
153
+ break;
154
+ case "t":
155
+ arg = String(!!arg);
156
+ arg = ph.precision ? arg.substring(0, ph.precision) : arg;
157
+ break;
158
+ case "T":
159
+ arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase();
160
+ arg = ph.precision ? arg.substring(0, ph.precision) : arg;
161
+ break;
162
+ case "u":
163
+ arg = parseInt(arg, 10) >>> 0;
164
+ break;
165
+ case "v":
166
+ arg = arg.valueOf();
167
+ arg = ph.precision ? arg.substring(0, ph.precision) : arg;
168
+ break;
169
+ case "x":
170
+ arg = (parseInt(arg, 10) >>> 0).toString(16);
171
+ break;
172
+ case "X":
173
+ arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase();
174
+ break;
175
+ }
176
+ if (re.json.test(ph.type)) {
177
+ output += arg;
178
+ } else {
179
+ if (re.number.test(ph.type) && (!is_positive || ph.sign)) {
180
+ sign = is_positive ? "+" : "-";
181
+ arg = arg.toString().replace(re.sign, "");
182
+ } else {
183
+ sign = "";
184
+ }
185
+ pad_character = ph.pad_char ? ph.pad_char === "0" ? "0" : ph.pad_char.charAt(1) : " ";
186
+ pad_length = ph.width - (sign + arg).length;
187
+ pad = ph.width ? pad_length > 0 ? pad_character.repeat(pad_length) : "" : "";
188
+ output += ph.align ? sign + arg + pad : pad_character === "0" ? sign + pad + arg : pad + sign + arg;
189
+ }
190
+ }
191
+ }
192
+ return output;
193
+ }
194
+ var sprintf_cache = /* @__PURE__ */ Object.create(null);
195
+ function sprintf_parse(fmt) {
196
+ if (sprintf_cache[fmt]) {
197
+ return sprintf_cache[fmt];
198
+ }
199
+ var _fmt = fmt, match, parse_tree = [], arg_names = 0;
200
+ while (_fmt) {
201
+ if ((match = re.text.exec(_fmt)) !== null) {
202
+ parse_tree.push(match[0]);
203
+ } else if ((match = re.modulo.exec(_fmt)) !== null) {
204
+ parse_tree.push("%");
205
+ } else if ((match = re.placeholder.exec(_fmt)) !== null) {
206
+ if (match[2]) {
207
+ arg_names |= 1;
208
+ var field_list = [], replacement_field = match[2], field_match = [];
209
+ if ((field_match = re.key.exec(replacement_field)) !== null) {
210
+ field_list.push(field_match[1]);
211
+ while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") {
212
+ if ((field_match = re.key_access.exec(replacement_field)) !== null) {
213
+ field_list.push(field_match[1]);
214
+ } else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
215
+ field_list.push(field_match[1]);
216
+ } else {
217
+ throw new SyntaxError("[sprintf] failed to parse named argument key");
218
+ }
219
+ }
220
+ } else {
221
+ throw new SyntaxError("[sprintf] failed to parse named argument key");
222
+ }
223
+ match[2] = field_list;
224
+ } else {
225
+ arg_names |= 2;
226
+ }
227
+ if (arg_names === 3) {
228
+ throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");
229
+ }
230
+ parse_tree.push(
231
+ {
232
+ placeholder: match[0],
233
+ param_no: match[1],
234
+ keys: match[2],
235
+ sign: match[3],
236
+ pad_char: match[4],
237
+ align: match[5],
238
+ width: match[6],
239
+ precision: match[7],
240
+ type: match[8]
241
+ }
242
+ );
243
+ } else {
244
+ throw new SyntaxError("[sprintf] unexpected placeholder");
245
+ }
246
+ _fmt = _fmt.substring(match[0].length);
247
+ }
248
+ return sprintf_cache[fmt] = parse_tree;
249
+ }
250
+ {
251
+ exports["sprintf"] = sprintf2;
252
+ exports["vsprintf"] = vsprintf;
253
+ }
254
+ if (typeof window !== "undefined") {
255
+ window["sprintf"] = sprintf2;
256
+ window["vsprintf"] = vsprintf;
257
+ }
258
+ }();
259
+ })(sprintf$1);
260
+ const sprintfjs = /* @__PURE__ */ getDefaultExportFromCjs(sprintf$1);
261
+ const logErrorOnce = memize(console.error);
262
+ function sprintf(format, ...args) {
263
+ try {
264
+ return sprintfjs.sprintf(format, ...args);
265
+ } catch (error) {
266
+ if (error instanceof Error) {
267
+ logErrorOnce("sprintf error: \n\n" + error.toString());
268
+ }
269
+ return format;
270
+ }
271
+ }
272
+ var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
273
+ PRECEDENCE = {
274
+ "(": 9,
275
+ "!": 8,
276
+ "*": 7,
277
+ "/": 7,
278
+ "%": 7,
279
+ "+": 6,
280
+ "-": 6,
281
+ "<": 5,
282
+ "<=": 5,
283
+ ">": 5,
284
+ ">=": 5,
285
+ "==": 4,
286
+ "!=": 4,
287
+ "&&": 3,
288
+ "||": 2,
289
+ "?": 1,
290
+ "?:": 1
291
+ };
292
+ OPENERS = ["(", "?"];
293
+ TERMINATORS = {
294
+ ")": ["("],
295
+ ":": ["?", "?:"]
296
+ };
297
+ PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;
298
+ function postfix(expression) {
299
+ var terms = [], stack = [], match, operator, term, element;
300
+ while (match = expression.match(PATTERN)) {
301
+ operator = match[0];
302
+ term = expression.substr(0, match.index).trim();
303
+ if (term) {
304
+ terms.push(term);
305
+ }
306
+ while (element = stack.pop()) {
307
+ if (TERMINATORS[operator]) {
308
+ if (TERMINATORS[operator][0] === element) {
309
+ operator = TERMINATORS[operator][1] || operator;
310
+ break;
311
+ }
312
+ } else if (OPENERS.indexOf(element) >= 0 || PRECEDENCE[element] < PRECEDENCE[operator]) {
313
+ stack.push(element);
314
+ break;
315
+ }
316
+ terms.push(element);
317
+ }
318
+ if (!TERMINATORS[operator]) {
319
+ stack.push(operator);
320
+ }
321
+ expression = expression.substr(match.index + operator.length);
322
+ }
323
+ expression = expression.trim();
324
+ if (expression) {
325
+ terms.push(expression);
326
+ }
327
+ return terms.concat(stack.reverse());
328
+ }
329
+ var OPERATORS = {
330
+ "!": function(a) {
331
+ return !a;
332
+ },
333
+ "*": function(a, b) {
334
+ return a * b;
335
+ },
336
+ "/": function(a, b) {
337
+ return a / b;
338
+ },
339
+ "%": function(a, b) {
340
+ return a % b;
341
+ },
342
+ "+": function(a, b) {
343
+ return a + b;
344
+ },
345
+ "-": function(a, b) {
346
+ return a - b;
347
+ },
348
+ "<": function(a, b) {
349
+ return a < b;
350
+ },
351
+ "<=": function(a, b) {
352
+ return a <= b;
353
+ },
354
+ ">": function(a, b) {
355
+ return a > b;
356
+ },
357
+ ">=": function(a, b) {
358
+ return a >= b;
359
+ },
360
+ "==": function(a, b) {
361
+ return a === b;
362
+ },
363
+ "!=": function(a, b) {
364
+ return a !== b;
365
+ },
366
+ "&&": function(a, b) {
367
+ return a && b;
368
+ },
369
+ "||": function(a, b) {
370
+ return a || b;
371
+ },
372
+ "?:": function(a, b, c) {
373
+ if (a) {
374
+ throw b;
375
+ }
376
+ return c;
377
+ }
378
+ };
379
+ function evaluate(postfix2, variables) {
380
+ var stack = [], i, j, args, getOperatorResult, term, value;
381
+ for (i = 0; i < postfix2.length; i++) {
382
+ term = postfix2[i];
383
+ getOperatorResult = OPERATORS[term];
384
+ if (getOperatorResult) {
385
+ j = getOperatorResult.length;
386
+ args = Array(j);
387
+ while (j--) {
388
+ args[j] = stack.pop();
389
+ }
390
+ try {
391
+ value = getOperatorResult.apply(null, args);
392
+ } catch (earlyReturn) {
393
+ return earlyReturn;
394
+ }
395
+ } else if (variables.hasOwnProperty(term)) {
396
+ value = variables[term];
397
+ } else {
398
+ value = +term;
399
+ }
400
+ stack.push(value);
401
+ }
402
+ return stack[0];
403
+ }
404
+ function compile(expression) {
405
+ var terms = postfix(expression);
406
+ return function(variables) {
407
+ return evaluate(terms, variables);
408
+ };
409
+ }
410
+ function pluralForms(expression) {
411
+ var evaluate2 = compile(expression);
412
+ return function(n) {
413
+ return +evaluate2({ n });
414
+ };
415
+ }
416
+ var DEFAULT_OPTIONS = {
417
+ contextDelimiter: "",
418
+ onMissingKey: null
419
+ };
420
+ function getPluralExpression(pf) {
421
+ var parts, i, part;
422
+ parts = pf.split(";");
423
+ for (i = 0; i < parts.length; i++) {
424
+ part = parts[i].trim();
425
+ if (part.indexOf("plural=") === 0) {
426
+ return part.substr(7);
427
+ }
428
+ }
429
+ }
430
+ function Tannin(data, options) {
431
+ var key;
432
+ this.data = data;
433
+ this.pluralForms = {};
434
+ this.options = {};
435
+ for (key in DEFAULT_OPTIONS) {
436
+ this.options[key] = options !== void 0 && key in options ? options[key] : DEFAULT_OPTIONS[key];
437
+ }
438
+ }
439
+ Tannin.prototype.getPluralForm = function(domain, n) {
440
+ var getPluralForm = this.pluralForms[domain], config, plural, pf;
441
+ if (!getPluralForm) {
442
+ config = this.data[domain][""];
443
+ pf = config["Plural-Forms"] || config["plural-forms"] || // Ignore reason: As known, there's no way to document the empty
444
+ // string property on a key to guarantee this as metadata.
445
+ // @ts-ignore
446
+ config.plural_forms;
447
+ if (typeof pf !== "function") {
448
+ plural = getPluralExpression(
449
+ config["Plural-Forms"] || config["plural-forms"] || // Ignore reason: As known, there's no way to document the empty
450
+ // string property on a key to guarantee this as metadata.
451
+ // @ts-ignore
452
+ config.plural_forms
453
+ );
454
+ pf = pluralForms(plural);
455
+ }
456
+ getPluralForm = this.pluralForms[domain] = pf;
457
+ }
458
+ return getPluralForm(n);
459
+ };
460
+ Tannin.prototype.dcnpgettext = function(domain, context, singular, plural, n) {
461
+ var index, key, entry;
462
+ if (n === void 0) {
463
+ index = 0;
464
+ } else {
465
+ index = this.getPluralForm(domain, n);
466
+ }
467
+ key = singular;
468
+ if (context) {
469
+ key = context + this.options.contextDelimiter + singular;
470
+ }
471
+ entry = this.data[domain][key];
472
+ if (entry && entry[index]) {
473
+ return entry[index];
474
+ }
475
+ if (this.options.onMissingKey) {
476
+ this.options.onMissingKey(singular, domain);
477
+ }
478
+ return index === 0 ? singular : plural;
479
+ };
480
+ const DEFAULT_LOCALE_DATA = {
481
+ "": {
482
+ /** @param {number} n */
483
+ plural_forms(n) {
484
+ return n === 1 ? 0 : 1;
485
+ }
486
+ }
487
+ };
488
+ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
489
+ const createI18n = (initialData, initialDomain, hooks) => {
490
+ const tannin = new Tannin({});
491
+ const listeners = /* @__PURE__ */ new Set();
492
+ const notifyListeners = () => {
493
+ listeners.forEach((listener) => listener());
494
+ };
495
+ const subscribe = (callback) => {
496
+ listeners.add(callback);
497
+ return () => listeners.delete(callback);
498
+ };
499
+ const getLocaleData = (domain = "default") => tannin.data[domain];
500
+ const doSetLocaleData = (data, domain = "default") => {
501
+ var _a;
502
+ tannin.data[domain] = {
503
+ ...tannin.data[domain],
504
+ ...data
505
+ };
506
+ tannin.data[domain][""] = {
507
+ ...DEFAULT_LOCALE_DATA[""],
508
+ ...(_a = tannin.data[domain]) == null ? void 0 : _a[""]
509
+ };
510
+ delete tannin.pluralForms[domain];
511
+ };
512
+ const setLocaleData = (data, domain) => {
513
+ doSetLocaleData(data, domain);
514
+ notifyListeners();
515
+ };
516
+ const addLocaleData = (data, domain = "default") => {
517
+ var _a;
518
+ tannin.data[domain] = {
519
+ ...tannin.data[domain],
520
+ ...data,
521
+ // Populate default domain configuration (supported locale date which omits
522
+ // a plural forms expression).
523
+ "": {
524
+ ...DEFAULT_LOCALE_DATA[""],
525
+ ...(_a = tannin.data[domain]) == null ? void 0 : _a[""],
526
+ ...data == null ? void 0 : data[""]
527
+ }
528
+ };
529
+ delete tannin.pluralForms[domain];
530
+ notifyListeners();
531
+ };
532
+ const resetLocaleData = (data, domain) => {
533
+ tannin.data = {};
534
+ tannin.pluralForms = {};
535
+ setLocaleData(data, domain);
536
+ };
537
+ const dcnpgettext = (domain = "default", context, single, plural, number) => {
538
+ if (!tannin.data[domain]) {
539
+ doSetLocaleData(void 0, domain);
540
+ }
541
+ return tannin.dcnpgettext(domain, context, single, plural, number);
542
+ };
543
+ const getFilterDomain = (domain = "default") => domain;
544
+ const __2 = (text, domain) => {
545
+ let translation = dcnpgettext(domain, void 0, text);
546
+ if (!hooks) {
547
+ return translation;
548
+ }
549
+ translation = /** @type {string} */
550
+ /** @type {*} */
551
+ hooks.applyFilters("i18n.gettext", translation, text, domain);
552
+ return (
553
+ /** @type {string} */
554
+ /** @type {*} */
555
+ hooks.applyFilters("i18n.gettext_" + getFilterDomain(domain), translation, text, domain)
556
+ );
557
+ };
558
+ const _x = (text, context, domain) => {
559
+ let translation = dcnpgettext(domain, context, text);
560
+ if (!hooks) {
561
+ return translation;
562
+ }
563
+ translation = /** @type {string} */
564
+ /** @type {*} */
565
+ hooks.applyFilters("i18n.gettext_with_context", translation, text, context, domain);
566
+ return (
567
+ /** @type {string} */
568
+ /** @type {*} */
569
+ hooks.applyFilters("i18n.gettext_with_context_" + getFilterDomain(domain), translation, text, context, domain)
570
+ );
571
+ };
572
+ const _n2 = (single, plural, number, domain) => {
573
+ let translation = dcnpgettext(domain, void 0, single, plural, number);
574
+ if (!hooks) {
575
+ return translation;
576
+ }
577
+ translation = /** @type {string} */
578
+ /** @type {*} */
579
+ hooks.applyFilters("i18n.ngettext", translation, single, plural, number, domain);
580
+ return (
581
+ /** @type {string} */
582
+ /** @type {*} */
583
+ hooks.applyFilters("i18n.ngettext_" + getFilterDomain(domain), translation, single, plural, number, domain)
584
+ );
585
+ };
586
+ const _nx = (single, plural, number, context, domain) => {
587
+ let translation = dcnpgettext(domain, context, single, plural, number);
588
+ if (!hooks) {
589
+ return translation;
590
+ }
591
+ translation = /** @type {string} */
592
+ /** @type {*} */
593
+ hooks.applyFilters("i18n.ngettext_with_context", translation, single, plural, number, context, domain);
594
+ return (
595
+ /** @type {string} */
596
+ /** @type {*} */
597
+ hooks.applyFilters("i18n.ngettext_with_context_" + getFilterDomain(domain), translation, single, plural, number, context, domain)
598
+ );
599
+ };
600
+ const isRTL = () => {
601
+ return "rtl" === _x("ltr", "text direction");
602
+ };
603
+ const hasTranslation = (single, context, domain) => {
604
+ var _a, _b;
605
+ const key = context ? context + "" + single : single;
606
+ let result = !!((_b = (_a = tannin.data) == null ? void 0 : _a[domain !== null && domain !== void 0 ? domain : "default"]) == null ? void 0 : _b[key]);
607
+ if (hooks) {
608
+ result = /** @type { boolean } */
609
+ /** @type {*} */
610
+ hooks.applyFilters("i18n.has_translation", result, single, context, domain);
611
+ result = /** @type { boolean } */
612
+ /** @type {*} */
613
+ hooks.applyFilters("i18n.has_translation_" + getFilterDomain(domain), result, single, context, domain);
614
+ }
615
+ return result;
616
+ };
617
+ if (hooks) {
618
+ const onHookAddedOrRemoved = (hookName) => {
619
+ if (I18N_HOOK_REGEXP.test(hookName)) {
620
+ notifyListeners();
621
+ }
622
+ };
623
+ hooks.addAction("hookAdded", "core/i18n", onHookAddedOrRemoved);
624
+ hooks.addAction("hookRemoved", "core/i18n", onHookAddedOrRemoved);
625
+ }
626
+ return {
627
+ getLocaleData,
628
+ setLocaleData,
629
+ addLocaleData,
630
+ resetLocaleData,
631
+ subscribe,
632
+ __: __2,
633
+ _x,
634
+ _n: _n2,
635
+ _nx,
636
+ isRTL,
637
+ hasTranslation
638
+ };
639
+ };
640
+ function validateNamespace(namespace) {
641
+ if ("string" !== typeof namespace || "" === namespace) {
642
+ console.error("The namespace must be a non-empty string.");
643
+ return false;
644
+ }
645
+ if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
646
+ console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.");
647
+ return false;
648
+ }
649
+ return true;
650
+ }
651
+ function validateHookName(hookName) {
652
+ if ("string" !== typeof hookName || "" === hookName) {
653
+ console.error("The hook name must be a non-empty string.");
654
+ return false;
655
+ }
656
+ if (/^__/.test(hookName)) {
657
+ console.error("The hook name cannot begin with `__`.");
658
+ return false;
659
+ }
660
+ if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
661
+ console.error("The hook name can only contain numbers, letters, dashes, periods and underscores.");
662
+ return false;
663
+ }
664
+ return true;
665
+ }
666
+ function createAddHook(hooks, storeKey) {
667
+ return function addHook(hookName, namespace, callback, priority = 10) {
668
+ const hooksStore = hooks[storeKey];
669
+ if (!validateHookName(hookName)) {
670
+ return;
671
+ }
672
+ if (!validateNamespace(namespace)) {
673
+ return;
674
+ }
675
+ if ("function" !== typeof callback) {
676
+ console.error("The hook callback must be a function.");
677
+ return;
678
+ }
679
+ if ("number" !== typeof priority) {
680
+ console.error("If specified, the hook priority must be a number.");
681
+ return;
682
+ }
683
+ const handler = {
684
+ callback,
685
+ priority,
686
+ namespace
687
+ };
688
+ if (hooksStore[hookName]) {
689
+ const handlers = hooksStore[hookName].handlers;
690
+ let i;
691
+ for (i = handlers.length; i > 0; i--) {
692
+ if (priority >= handlers[i - 1].priority) {
693
+ break;
694
+ }
695
+ }
696
+ if (i === handlers.length) {
697
+ handlers[i] = handler;
698
+ } else {
699
+ handlers.splice(i, 0, handler);
700
+ }
701
+ hooksStore.__current.forEach((hookInfo) => {
702
+ if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
703
+ hookInfo.currentIndex++;
704
+ }
705
+ });
706
+ } else {
707
+ hooksStore[hookName] = {
708
+ handlers: [handler],
709
+ runs: 0
710
+ };
711
+ }
712
+ if (hookName !== "hookAdded") {
713
+ hooks.doAction("hookAdded", hookName, namespace, callback, priority);
714
+ }
715
+ };
716
+ }
717
+ function createRemoveHook(hooks, storeKey, removeAll = false) {
718
+ return function removeHook(hookName, namespace) {
719
+ const hooksStore = hooks[storeKey];
720
+ if (!validateHookName(hookName)) {
721
+ return;
722
+ }
723
+ if (!removeAll && !validateNamespace(namespace)) {
724
+ return;
725
+ }
726
+ if (!hooksStore[hookName]) {
727
+ return 0;
728
+ }
729
+ let handlersRemoved = 0;
730
+ if (removeAll) {
731
+ handlersRemoved = hooksStore[hookName].handlers.length;
732
+ hooksStore[hookName] = {
733
+ runs: hooksStore[hookName].runs,
734
+ handlers: []
735
+ };
736
+ } else {
737
+ const handlers = hooksStore[hookName].handlers;
738
+ for (let i = handlers.length - 1; i >= 0; i--) {
739
+ if (handlers[i].namespace === namespace) {
740
+ handlers.splice(i, 1);
741
+ handlersRemoved++;
742
+ hooksStore.__current.forEach((hookInfo) => {
743
+ if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
744
+ hookInfo.currentIndex--;
745
+ }
746
+ });
747
+ }
748
+ }
749
+ }
750
+ if (hookName !== "hookRemoved") {
751
+ hooks.doAction("hookRemoved", hookName, namespace);
752
+ }
753
+ return handlersRemoved;
754
+ };
755
+ }
756
+ function createHasHook(hooks, storeKey) {
757
+ return function hasHook(hookName, namespace) {
758
+ const hooksStore = hooks[storeKey];
759
+ if ("undefined" !== typeof namespace) {
760
+ return hookName in hooksStore && hooksStore[hookName].handlers.some((hook) => hook.namespace === namespace);
761
+ }
762
+ return hookName in hooksStore;
763
+ };
764
+ }
765
+ function createRunHook(hooks, storeKey, returnFirstArg = false) {
766
+ return function runHooks(hookName, ...args) {
767
+ const hooksStore = hooks[storeKey];
768
+ if (!hooksStore[hookName]) {
769
+ hooksStore[hookName] = {
770
+ handlers: [],
771
+ runs: 0
772
+ };
773
+ }
774
+ hooksStore[hookName].runs++;
775
+ const handlers = hooksStore[hookName].handlers;
776
+ if ("production" !== process.env.NODE_ENV) {
777
+ if ("hookAdded" !== hookName && hooksStore.all) {
778
+ handlers.push(...hooksStore.all.handlers);
779
+ }
780
+ }
781
+ if (!handlers || !handlers.length) {
782
+ return returnFirstArg ? args[0] : void 0;
783
+ }
784
+ const hookInfo = {
785
+ name: hookName,
786
+ currentIndex: 0
787
+ };
788
+ hooksStore.__current.push(hookInfo);
789
+ while (hookInfo.currentIndex < handlers.length) {
790
+ const handler = handlers[hookInfo.currentIndex];
791
+ const result = handler.callback.apply(null, args);
792
+ if (returnFirstArg) {
793
+ args[0] = result;
794
+ }
795
+ hookInfo.currentIndex++;
796
+ }
797
+ hooksStore.__current.pop();
798
+ if (returnFirstArg) {
799
+ return args[0];
800
+ }
801
+ return void 0;
802
+ };
803
+ }
804
+ function createCurrentHook(hooks, storeKey) {
805
+ return function currentHook() {
806
+ var _a;
807
+ var _hooksStore$__current;
808
+ const hooksStore = hooks[storeKey];
809
+ return (_hooksStore$__current = (_a = hooksStore.__current[hooksStore.__current.length - 1]) == null ? void 0 : _a.name) !== null && _hooksStore$__current !== void 0 ? _hooksStore$__current : null;
810
+ };
811
+ }
812
+ function createDoingHook(hooks, storeKey) {
813
+ return function doingHook(hookName) {
814
+ const hooksStore = hooks[storeKey];
815
+ if ("undefined" === typeof hookName) {
816
+ return "undefined" !== typeof hooksStore.__current[0];
817
+ }
818
+ return hooksStore.__current[0] ? hookName === hooksStore.__current[0].name : false;
819
+ };
820
+ }
821
+ function createDidHook(hooks, storeKey) {
822
+ return function didHook(hookName) {
823
+ const hooksStore = hooks[storeKey];
824
+ if (!validateHookName(hookName)) {
825
+ return;
826
+ }
827
+ return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
828
+ };
829
+ }
830
+ class _Hooks {
831
+ constructor() {
832
+ this.actions = /* @__PURE__ */ Object.create(null);
833
+ this.actions.__current = [];
834
+ this.filters = /* @__PURE__ */ Object.create(null);
835
+ this.filters.__current = [];
836
+ this.addAction = createAddHook(this, "actions");
837
+ this.addFilter = createAddHook(this, "filters");
838
+ this.removeAction = createRemoveHook(this, "actions");
839
+ this.removeFilter = createRemoveHook(this, "filters");
840
+ this.hasAction = createHasHook(this, "actions");
841
+ this.hasFilter = createHasHook(this, "filters");
842
+ this.removeAllActions = createRemoveHook(this, "actions", true);
843
+ this.removeAllFilters = createRemoveHook(this, "filters", true);
844
+ this.doAction = createRunHook(this, "actions");
845
+ this.applyFilters = createRunHook(this, "filters", true);
846
+ this.currentAction = createCurrentHook(this, "actions");
847
+ this.currentFilter = createCurrentHook(this, "filters");
848
+ this.doingAction = createDoingHook(this, "actions");
849
+ this.doingFilter = createDoingHook(this, "filters");
850
+ this.didAction = createDidHook(this, "actions");
851
+ this.didFilter = createDidHook(this, "filters");
852
+ }
853
+ }
854
+ function createHooks() {
855
+ return new _Hooks();
856
+ }
857
+ const defaultHooks = createHooks();
858
+ const i18n = createI18n(void 0, void 0, defaultHooks);
859
+ i18n.getLocaleData.bind(i18n);
860
+ i18n.setLocaleData.bind(i18n);
861
+ i18n.resetLocaleData.bind(i18n);
862
+ i18n.subscribe.bind(i18n);
863
+ const __ = i18n.__.bind(i18n);
864
+ i18n._x.bind(i18n);
865
+ const _n = i18n._n.bind(i18n);
866
+ i18n._nx.bind(i18n);
867
+ i18n.isRTL.bind(i18n);
868
+ i18n.hasTranslation.bind(i18n);
869
+ export {
870
+ __ as _,
871
+ _n as a,
872
+ sprintf as s
873
+ };