1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2"use strict";
3var wp;
4(wp ||= {}).editor = (() => {
5 var __create = Object.create;
6 var __defProp = Object.defineProperty;
7 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8 var __getOwnPropNames = Object.getOwnPropertyNames;
9 var __getProtoOf = Object.getPrototypeOf;
10 var __hasOwnProp = Object.prototype.hasOwnProperty;
11 var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
12 get: (a3, b3) => (typeof require !== "undefined" ? require : a3)[b3]
13 }) : x2)(function(x2) {
14 if (typeof require !== "undefined") return require.apply(this, arguments);
15 throw Error('Dynamic require of "' + x2 + '" is not supported');
16 });
17 var __commonJS = (cb, mod) => function __require4() {
18 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19 };
20 var __export = (target, all) => {
21 for (var name2 in all)
22 __defProp(target, name2, { get: all[name2], enumerable: true });
23 };
24 var __copyProps = (to2, from, except, desc) => {
25 if (from && typeof from === "object" || typeof from === "function") {
26 for (let key of __getOwnPropNames(from))
27 if (!__hasOwnProp.call(to2, key) && key !== except)
28 __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29 }
30 return to2;
31 };
32 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33 // If the importer is in node compatibility mode or this is not an ESM
34 // file that has been converted to a CommonJS file using a Babel-
35 // compatible transform (i.e. "__esModule" has not been set), then set
36 // "default" to the CommonJS "module.exports" for node compatibility.
37 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38 mod
39 ));
40 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
42 // package-external:@wordpress/data
43 var require_data = __commonJS({
44 "package-external:@wordpress/data"(exports, module) {
45 module.exports = window.wp.data;
46 }
47 });
48
49 // package-external:@wordpress/core-data
50 var require_core_data = __commonJS({
51 "package-external:@wordpress/core-data"(exports, module) {
52 module.exports = window.wp.coreData;
53 }
54 });
55
56 // package-external:@wordpress/element
57 var require_element = __commonJS({
58 "package-external:@wordpress/element"(exports, module) {
59 module.exports = window.wp.element;
60 }
61 });
62
63 // package-external:@wordpress/compose
64 var require_compose = __commonJS({
65 "package-external:@wordpress/compose"(exports, module) {
66 module.exports = window.wp.compose;
67 }
68 });
69
70 // package-external:@wordpress/hooks
71 var require_hooks = __commonJS({
72 "package-external:@wordpress/hooks"(exports, module) {
73 module.exports = window.wp.hooks;
74 }
75 });
76
77 // package-external:@wordpress/block-editor
78 var require_block_editor = __commonJS({
79 "package-external:@wordpress/block-editor"(exports, module) {
80 module.exports = window.wp.blockEditor;
81 }
82 });
83
84 // package-external:@wordpress/blocks
85 var require_blocks = __commonJS({
86 "package-external:@wordpress/blocks"(exports, module) {
87 module.exports = window.wp.blocks;
88 }
89 });
90
91 // package-external:@wordpress/date
92 var require_date = __commonJS({
93 "package-external:@wordpress/date"(exports, module) {
94 module.exports = window.wp.date;
95 }
96 });
97
98 // package-external:@wordpress/url
99 var require_url = __commonJS({
100 "package-external:@wordpress/url"(exports, module) {
101 module.exports = window.wp.url;
102 }
103 });
104
105 // package-external:@wordpress/deprecated
106 var require_deprecated = __commonJS({
107 "package-external:@wordpress/deprecated"(exports, module) {
108 module.exports = window.wp.deprecated;
109 }
110 });
111
112 // package-external:@wordpress/preferences
113 var require_preferences = __commonJS({
114 "package-external:@wordpress/preferences"(exports, module) {
115 module.exports = window.wp.preferences;
116 }
117 });
118
119 // package-external:@wordpress/primitives
120 var require_primitives = __commonJS({
121 "package-external:@wordpress/primitives"(exports, module) {
122 module.exports = window.wp.primitives;
123 }
124 });
125
126 // vendor-external:react/jsx-runtime
127 var require_jsx_runtime = __commonJS({
128 "vendor-external:react/jsx-runtime"(exports, module) {
129 module.exports = window.ReactJSXRuntime;
130 }
131 });
132
133 // package-external:@wordpress/private-apis
134 var require_private_apis = __commonJS({
135 "package-external:@wordpress/private-apis"(exports, module) {
136 module.exports = window.wp.privateApis;
137 }
138 });
139
140 // package-external:@wordpress/a11y
141 var require_a11y = __commonJS({
142 "package-external:@wordpress/a11y"(exports, module) {
143 module.exports = window.wp.a11y;
144 }
145 });
146
147 // package-external:@wordpress/api-fetch
148 var require_api_fetch = __commonJS({
149 "package-external:@wordpress/api-fetch"(exports, module) {
150 module.exports = window.wp.apiFetch;
151 }
152 });
153
154 // package-external:@wordpress/notices
155 var require_notices = __commonJS({
156 "package-external:@wordpress/notices"(exports, module) {
157 module.exports = window.wp.notices;
158 }
159 });
160
161 // package-external:@wordpress/i18n
162 var require_i18n = __commonJS({
163 "package-external:@wordpress/i18n"(exports, module) {
164 module.exports = window.wp.i18n;
165 }
166 });
167
168 // package-external:@wordpress/html-entities
169 var require_html_entities = __commonJS({
170 "package-external:@wordpress/html-entities"(exports, module) {
171 module.exports = window.wp.htmlEntities;
172 }
173 });
174
175 // node_modules/fast-deep-equal/index.js
176 var require_fast_deep_equal = __commonJS({
177 "node_modules/fast-deep-equal/index.js"(exports, module) {
178 "use strict";
179 module.exports = function equal(a3, b3) {
180 if (a3 === b3) return true;
181 if (a3 && b3 && typeof a3 == "object" && typeof b3 == "object") {
182 if (a3.constructor !== b3.constructor) return false;
183 var length, i3, keys;
184 if (Array.isArray(a3)) {
185 length = a3.length;
186 if (length != b3.length) return false;
187 for (i3 = length; i3-- !== 0; )
188 if (!equal(a3[i3], b3[i3])) return false;
189 return true;
190 }
191 if (a3.constructor === RegExp) return a3.source === b3.source && a3.flags === b3.flags;
192 if (a3.valueOf !== Object.prototype.valueOf) return a3.valueOf() === b3.valueOf();
193 if (a3.toString !== Object.prototype.toString) return a3.toString() === b3.toString();
194 keys = Object.keys(a3);
195 length = keys.length;
196 if (length !== Object.keys(b3).length) return false;
197 for (i3 = length; i3-- !== 0; )
198 if (!Object.prototype.hasOwnProperty.call(b3, keys[i3])) return false;
199 for (i3 = length; i3-- !== 0; ) {
200 var key = keys[i3];
201 if (!equal(a3[key], b3[key])) return false;
202 }
203 return true;
204 }
205 return a3 !== a3 && b3 !== b3;
206 };
207 }
208 });
209
210 // package-external:@wordpress/media-utils
211 var require_media_utils = __commonJS({
212 "package-external:@wordpress/media-utils"(exports, module) {
213 module.exports = window.wp.mediaUtils;
214 }
215 });
216
217 // package-external:@wordpress/components
218 var require_components = __commonJS({
219 "package-external:@wordpress/components"(exports, module) {
220 module.exports = window.wp.components;
221 }
222 });
223
224 // package-external:@wordpress/patterns
225 var require_patterns = __commonJS({
226 "package-external:@wordpress/patterns"(exports, module) {
227 module.exports = window.wp.patterns;
228 }
229 });
230
231 // package-external:@wordpress/blob
232 var require_blob = __commonJS({
233 "package-external:@wordpress/blob"(exports, module) {
234 module.exports = window.wp.blob;
235 }
236 });
237
238 // vendor-external:react
239 var require_react = __commonJS({
240 "vendor-external:react"(exports, module) {
241 module.exports = window.React;
242 }
243 });
244
245 // vendor-external:react-dom
246 var require_react_dom = __commonJS({
247 "vendor-external:react-dom"(exports, module) {
248 module.exports = window.ReactDOM;
249 }
250 });
251
252 // node_modules/remove-accents/index.js
253 var require_remove_accents = __commonJS({
254 "node_modules/remove-accents/index.js"(exports, module) {
255 var characterMap = {
256 "\xC0": "A",
257 "\xC1": "A",
258 "\xC2": "A",
259 "\xC3": "A",
260 "\xC4": "A",
261 "\xC5": "A",
262 "\u1EA4": "A",
263 "\u1EAE": "A",
264 "\u1EB2": "A",
265 "\u1EB4": "A",
266 "\u1EB6": "A",
267 "\xC6": "AE",
268 "\u1EA6": "A",
269 "\u1EB0": "A",
270 "\u0202": "A",
271 "\u1EA2": "A",
272 "\u1EA0": "A",
273 "\u1EA8": "A",
274 "\u1EAA": "A",
275 "\u1EAC": "A",
276 "\xC7": "C",
277 "\u1E08": "C",
278 "\xC8": "E",
279 "\xC9": "E",
280 "\xCA": "E",
281 "\xCB": "E",
282 "\u1EBE": "E",
283 "\u1E16": "E",
284 "\u1EC0": "E",
285 "\u1E14": "E",
286 "\u1E1C": "E",
287 "\u0206": "E",
288 "\u1EBA": "E",
289 "\u1EBC": "E",
290 "\u1EB8": "E",
291 "\u1EC2": "E",
292 "\u1EC4": "E",
293 "\u1EC6": "E",
294 "\xCC": "I",
295 "\xCD": "I",
296 "\xCE": "I",
297 "\xCF": "I",
298 "\u1E2E": "I",
299 "\u020A": "I",
300 "\u1EC8": "I",
301 "\u1ECA": "I",
302 "\xD0": "D",
303 "\xD1": "N",
304 "\xD2": "O",
305 "\xD3": "O",
306 "\xD4": "O",
307 "\xD5": "O",
308 "\xD6": "O",
309 "\xD8": "O",
310 "\u1ED0": "O",
311 "\u1E4C": "O",
312 "\u1E52": "O",
313 "\u020E": "O",
314 "\u1ECE": "O",
315 "\u1ECC": "O",
316 "\u1ED4": "O",
317 "\u1ED6": "O",
318 "\u1ED8": "O",
319 "\u1EDC": "O",
320 "\u1EDE": "O",
321 "\u1EE0": "O",
322 "\u1EDA": "O",
323 "\u1EE2": "O",
324 "\xD9": "U",
325 "\xDA": "U",
326 "\xDB": "U",
327 "\xDC": "U",
328 "\u1EE6": "U",
329 "\u1EE4": "U",
330 "\u1EEC": "U",
331 "\u1EEE": "U",
332 "\u1EF0": "U",
333 "\xDD": "Y",
334 "\xE0": "a",
335 "\xE1": "a",
336 "\xE2": "a",
337 "\xE3": "a",
338 "\xE4": "a",
339 "\xE5": "a",
340 "\u1EA5": "a",
341 "\u1EAF": "a",
342 "\u1EB3": "a",
343 "\u1EB5": "a",
344 "\u1EB7": "a",
345 "\xE6": "ae",
346 "\u1EA7": "a",
347 "\u1EB1": "a",
348 "\u0203": "a",
349 "\u1EA3": "a",
350 "\u1EA1": "a",
351 "\u1EA9": "a",
352 "\u1EAB": "a",
353 "\u1EAD": "a",
354 "\xE7": "c",
355 "\u1E09": "c",
356 "\xE8": "e",
357 "\xE9": "e",
358 "\xEA": "e",
359 "\xEB": "e",
360 "\u1EBF": "e",
361 "\u1E17": "e",
362 "\u1EC1": "e",
363 "\u1E15": "e",
364 "\u1E1D": "e",
365 "\u0207": "e",
366 "\u1EBB": "e",
367 "\u1EBD": "e",
368 "\u1EB9": "e",
369 "\u1EC3": "e",
370 "\u1EC5": "e",
371 "\u1EC7": "e",
372 "\xEC": "i",
373 "\xED": "i",
374 "\xEE": "i",
375 "\xEF": "i",
376 "\u1E2F": "i",
377 "\u020B": "i",
378 "\u1EC9": "i",
379 "\u1ECB": "i",
380 "\xF0": "d",
381 "\xF1": "n",
382 "\xF2": "o",
383 "\xF3": "o",
384 "\xF4": "o",
385 "\xF5": "o",
386 "\xF6": "o",
387 "\xF8": "o",
388 "\u1ED1": "o",
389 "\u1E4D": "o",
390 "\u1E53": "o",
391 "\u020F": "o",
392 "\u1ECF": "o",
393 "\u1ECD": "o",
394 "\u1ED5": "o",
395 "\u1ED7": "o",
396 "\u1ED9": "o",
397 "\u1EDD": "o",
398 "\u1EDF": "o",
399 "\u1EE1": "o",
400 "\u1EDB": "o",
401 "\u1EE3": "o",
402 "\xF9": "u",
403 "\xFA": "u",
404 "\xFB": "u",
405 "\xFC": "u",
406 "\u1EE7": "u",
407 "\u1EE5": "u",
408 "\u1EED": "u",
409 "\u1EEF": "u",
410 "\u1EF1": "u",
411 "\xFD": "y",
412 "\xFF": "y",
413 "\u0100": "A",
414 "\u0101": "a",
415 "\u0102": "A",
416 "\u0103": "a",
417 "\u0104": "A",
418 "\u0105": "a",
419 "\u0106": "C",
420 "\u0107": "c",
421 "\u0108": "C",
422 "\u0109": "c",
423 "\u010A": "C",
424 "\u010B": "c",
425 "\u010C": "C",
426 "\u010D": "c",
427 "C\u0306": "C",
428 "c\u0306": "c",
429 "\u010E": "D",
430 "\u010F": "d",
431 "\u0110": "D",
432 "\u0111": "d",
433 "\u0112": "E",
434 "\u0113": "e",
435 "\u0114": "E",
436 "\u0115": "e",
437 "\u0116": "E",
438 "\u0117": "e",
439 "\u0118": "E",
440 "\u0119": "e",
441 "\u011A": "E",
442 "\u011B": "e",
443 "\u011C": "G",
444 "\u01F4": "G",
445 "\u011D": "g",
446 "\u01F5": "g",
447 "\u011E": "G",
448 "\u011F": "g",
449 "\u0120": "G",
450 "\u0121": "g",
451 "\u0122": "G",
452 "\u0123": "g",
453 "\u0124": "H",
454 "\u0125": "h",
455 "\u0126": "H",
456 "\u0127": "h",
457 "\u1E2A": "H",
458 "\u1E2B": "h",
459 "\u0128": "I",
460 "\u0129": "i",
461 "\u012A": "I",
462 "\u012B": "i",
463 "\u012C": "I",
464 "\u012D": "i",
465 "\u012E": "I",
466 "\u012F": "i",
467 "\u0130": "I",
468 "\u0131": "i",
469 "\u0132": "IJ",
470 "\u0133": "ij",
471 "\u0134": "J",
472 "\u0135": "j",
473 "\u0136": "K",
474 "\u0137": "k",
475 "\u1E30": "K",
476 "\u1E31": "k",
477 "K\u0306": "K",
478 "k\u0306": "k",
479 "\u0139": "L",
480 "\u013A": "l",
481 "\u013B": "L",
482 "\u013C": "l",
483 "\u013D": "L",
484 "\u013E": "l",
485 "\u013F": "L",
486 "\u0140": "l",
487 "\u0141": "l",
488 "\u0142": "l",
489 "\u1E3E": "M",
490 "\u1E3F": "m",
491 "M\u0306": "M",
492 "m\u0306": "m",
493 "\u0143": "N",
494 "\u0144": "n",
495 "\u0145": "N",
496 "\u0146": "n",
497 "\u0147": "N",
498 "\u0148": "n",
499 "\u0149": "n",
500 "N\u0306": "N",
501 "n\u0306": "n",
502 "\u014C": "O",
503 "\u014D": "o",
504 "\u014E": "O",
505 "\u014F": "o",
506 "\u0150": "O",
507 "\u0151": "o",
508 "\u0152": "OE",
509 "\u0153": "oe",
510 "P\u0306": "P",
511 "p\u0306": "p",
512 "\u0154": "R",
513 "\u0155": "r",
514 "\u0156": "R",
515 "\u0157": "r",
516 "\u0158": "R",
517 "\u0159": "r",
518 "R\u0306": "R",
519 "r\u0306": "r",
520 "\u0212": "R",
521 "\u0213": "r",
522 "\u015A": "S",
523 "\u015B": "s",
524 "\u015C": "S",
525 "\u015D": "s",
526 "\u015E": "S",
527 "\u0218": "S",
528 "\u0219": "s",
529 "\u015F": "s",
530 "\u0160": "S",
531 "\u0161": "s",
532 "\u0162": "T",
533 "\u0163": "t",
534 "\u021B": "t",
535 "\u021A": "T",
536 "\u0164": "T",
537 "\u0165": "t",
538 "\u0166": "T",
539 "\u0167": "t",
540 "T\u0306": "T",
541 "t\u0306": "t",
542 "\u0168": "U",
543 "\u0169": "u",
544 "\u016A": "U",
545 "\u016B": "u",
546 "\u016C": "U",
547 "\u016D": "u",
548 "\u016E": "U",
549 "\u016F": "u",
550 "\u0170": "U",
551 "\u0171": "u",
552 "\u0172": "U",
553 "\u0173": "u",
554 "\u0216": "U",
555 "\u0217": "u",
556 "V\u0306": "V",
557 "v\u0306": "v",
558 "\u0174": "W",
559 "\u0175": "w",
560 "\u1E82": "W",
561 "\u1E83": "w",
562 "X\u0306": "X",
563 "x\u0306": "x",
564 "\u0176": "Y",
565 "\u0177": "y",
566 "\u0178": "Y",
567 "Y\u0306": "Y",
568 "y\u0306": "y",
569 "\u0179": "Z",
570 "\u017A": "z",
571 "\u017B": "Z",
572 "\u017C": "z",
573 "\u017D": "Z",
574 "\u017E": "z",
575 "\u017F": "s",
576 "\u0192": "f",
577 "\u01A0": "O",
578 "\u01A1": "o",
579 "\u01AF": "U",
580 "\u01B0": "u",
581 "\u01CD": "A",
582 "\u01CE": "a",
583 "\u01CF": "I",
584 "\u01D0": "i",
585 "\u01D1": "O",
586 "\u01D2": "o",
587 "\u01D3": "U",
588 "\u01D4": "u",
589 "\u01D5": "U",
590 "\u01D6": "u",
591 "\u01D7": "U",
592 "\u01D8": "u",
593 "\u01D9": "U",
594 "\u01DA": "u",
595 "\u01DB": "U",
596 "\u01DC": "u",
597 "\u1EE8": "U",
598 "\u1EE9": "u",
599 "\u1E78": "U",
600 "\u1E79": "u",
601 "\u01FA": "A",
602 "\u01FB": "a",
603 "\u01FC": "AE",
604 "\u01FD": "ae",
605 "\u01FE": "O",
606 "\u01FF": "o",
607 "\xDE": "TH",
608 "\xFE": "th",
609 "\u1E54": "P",
610 "\u1E55": "p",
611 "\u1E64": "S",
612 "\u1E65": "s",
613 "X\u0301": "X",
614 "x\u0301": "x",
615 "\u0403": "\u0413",
616 "\u0453": "\u0433",
617 "\u040C": "\u041A",
618 "\u045C": "\u043A",
619 "A\u030B": "A",
620 "a\u030B": "a",
621 "E\u030B": "E",
622 "e\u030B": "e",
623 "I\u030B": "I",
624 "i\u030B": "i",
625 "\u01F8": "N",
626 "\u01F9": "n",
627 "\u1ED2": "O",
628 "\u1ED3": "o",
629 "\u1E50": "O",
630 "\u1E51": "o",
631 "\u1EEA": "U",
632 "\u1EEB": "u",
633 "\u1E80": "W",
634 "\u1E81": "w",
635 "\u1EF2": "Y",
636 "\u1EF3": "y",
637 "\u0200": "A",
638 "\u0201": "a",
639 "\u0204": "E",
640 "\u0205": "e",
641 "\u0208": "I",
642 "\u0209": "i",
643 "\u020C": "O",
644 "\u020D": "o",
645 "\u0210": "R",
646 "\u0211": "r",
647 "\u0214": "U",
648 "\u0215": "u",
649 "B\u030C": "B",
650 "b\u030C": "b",
651 "\u010C\u0323": "C",
652 "\u010D\u0323": "c",
653 "\xCA\u030C": "E",
654 "\xEA\u030C": "e",
655 "F\u030C": "F",
656 "f\u030C": "f",
657 "\u01E6": "G",
658 "\u01E7": "g",
659 "\u021E": "H",
660 "\u021F": "h",
661 "J\u030C": "J",
662 "\u01F0": "j",
663 "\u01E8": "K",
664 "\u01E9": "k",
665 "M\u030C": "M",
666 "m\u030C": "m",
667 "P\u030C": "P",
668 "p\u030C": "p",
669 "Q\u030C": "Q",
670 "q\u030C": "q",
671 "\u0158\u0329": "R",
672 "\u0159\u0329": "r",
673 "\u1E66": "S",
674 "\u1E67": "s",
675 "V\u030C": "V",
676 "v\u030C": "v",
677 "W\u030C": "W",
678 "w\u030C": "w",
679 "X\u030C": "X",
680 "x\u030C": "x",
681 "Y\u030C": "Y",
682 "y\u030C": "y",
683 "A\u0327": "A",
684 "a\u0327": "a",
685 "B\u0327": "B",
686 "b\u0327": "b",
687 "\u1E10": "D",
688 "\u1E11": "d",
689 "\u0228": "E",
690 "\u0229": "e",
691 "\u0190\u0327": "E",
692 "\u025B\u0327": "e",
693 "\u1E28": "H",
694 "\u1E29": "h",
695 "I\u0327": "I",
696 "i\u0327": "i",
697 "\u0197\u0327": "I",
698 "\u0268\u0327": "i",
699 "M\u0327": "M",
700 "m\u0327": "m",
701 "O\u0327": "O",
702 "o\u0327": "o",
703 "Q\u0327": "Q",
704 "q\u0327": "q",
705 "U\u0327": "U",
706 "u\u0327": "u",
707 "X\u0327": "X",
708 "x\u0327": "x",
709 "Z\u0327": "Z",
710 "z\u0327": "z",
711 "\u0439": "\u0438",
712 "\u0419": "\u0418",
713 "\u0451": "\u0435",
714 "\u0401": "\u0415"
715 };
716 var chars = Object.keys(characterMap).join("|");
717 var allAccents = new RegExp(chars, "g");
718 var firstAccent = new RegExp(chars, "");
719 function matcher(match3) {
720 return characterMap[match3];
721 }
722 var removeAccents4 = function(string) {
723 return string.replace(allAccents, matcher);
724 };
725 var hasAccents = function(string) {
726 return !!string.match(firstAccent);
727 };
728 module.exports = removeAccents4;
729 module.exports.has = hasAccents;
730 module.exports.remove = removeAccents4;
731 }
732 });
733
734 // package-external:@wordpress/style-engine
735 var require_style_engine = __commonJS({
736 "package-external:@wordpress/style-engine"(exports, module) {
737 module.exports = window.wp.styleEngine;
738 }
739 });
740
741 // node_modules/fast-deep-equal/es6/index.js
742 var require_es6 = __commonJS({
743 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
744 "use strict";
745 module.exports = function equal(a3, b3) {
746 if (a3 === b3) return true;
747 if (a3 && b3 && typeof a3 == "object" && typeof b3 == "object") {
748 if (a3.constructor !== b3.constructor) return false;
749 var length, i3, keys;
750 if (Array.isArray(a3)) {
751 length = a3.length;
752 if (length != b3.length) return false;
753 for (i3 = length; i3-- !== 0; )
754 if (!equal(a3[i3], b3[i3])) return false;
755 return true;
756 }
757 if (a3 instanceof Map && b3 instanceof Map) {
758 if (a3.size !== b3.size) return false;
759 for (i3 of a3.entries())
760 if (!b3.has(i3[0])) return false;
761 for (i3 of a3.entries())
762 if (!equal(i3[1], b3.get(i3[0]))) return false;
763 return true;
764 }
765 if (a3 instanceof Set && b3 instanceof Set) {
766 if (a3.size !== b3.size) return false;
767 for (i3 of a3.entries())
768 if (!b3.has(i3[0])) return false;
769 return true;
770 }
771 if (ArrayBuffer.isView(a3) && ArrayBuffer.isView(b3)) {
772 length = a3.length;
773 if (length != b3.length) return false;
774 for (i3 = length; i3-- !== 0; )
775 if (a3[i3] !== b3[i3]) return false;
776 return true;
777 }
778 if (a3.constructor === RegExp) return a3.source === b3.source && a3.flags === b3.flags;
779 if (a3.valueOf !== Object.prototype.valueOf) return a3.valueOf() === b3.valueOf();
780 if (a3.toString !== Object.prototype.toString) return a3.toString() === b3.toString();
781 keys = Object.keys(a3);
782 length = keys.length;
783 if (length !== Object.keys(b3).length) return false;
784 for (i3 = length; i3-- !== 0; )
785 if (!Object.prototype.hasOwnProperty.call(b3, keys[i3])) return false;
786 for (i3 = length; i3-- !== 0; ) {
787 var key = keys[i3];
788 if (!equal(a3[key], b3[key])) return false;
789 }
790 return true;
791 }
792 return a3 !== a3 && b3 !== b3;
793 };
794 }
795 });
796
797 // node_modules/deepmerge/dist/cjs.js
798 var require_cjs = __commonJS({
799 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
800 "use strict";
801 var isMergeableObject = function isMergeableObject2(value) {
802 return isNonNullObject(value) && !isSpecial(value);
803 };
804 function isNonNullObject(value) {
805 return !!value && typeof value === "object";
806 }
807 function isSpecial(value) {
808 var stringValue = Object.prototype.toString.call(value);
809 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
810 }
811 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
812 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
813 function isReactElement(value) {
814 return value.$$typeof === REACT_ELEMENT_TYPE;
815 }
816 function emptyTarget(val) {
817 return Array.isArray(val) ? [] : {};
818 }
819 function cloneUnlessOtherwiseSpecified(value, options) {
820 return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value;
821 }
822 function defaultArrayMerge(target, source, options) {
823 return target.concat(source).map(function(element) {
824 return cloneUnlessOtherwiseSpecified(element, options);
825 });
826 }
827 function getMergeFunction(key, options) {
828 if (!options.customMerge) {
829 return deepmerge2;
830 }
831 var customMerge = options.customMerge(key);
832 return typeof customMerge === "function" ? customMerge : deepmerge2;
833 }
834 function getEnumerableOwnPropertySymbols(target) {
835 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
836 return Object.propertyIsEnumerable.call(target, symbol);
837 }) : [];
838 }
839 function getKeys(target) {
840 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
841 }
842 function propertyIsOnObject(object, property) {
843 try {
844 return property in object;
845 } catch (_) {
846 return false;
847 }
848 }
849 function propertyIsUnsafe(target, key) {
850 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
851 }
852 function mergeObject(target, source, options) {
853 var destination = {};
854 if (options.isMergeableObject(target)) {
855 getKeys(target).forEach(function(key) {
856 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
857 });
858 }
859 getKeys(source).forEach(function(key) {
860 if (propertyIsUnsafe(target, key)) {
861 return;
862 }
863 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
864 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
865 } else {
866 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
867 }
868 });
869 return destination;
870 }
871 function deepmerge2(target, source, options) {
872 options = options || {};
873 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
874 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
875 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
876 var sourceIsArray = Array.isArray(source);
877 var targetIsArray = Array.isArray(target);
878 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
879 if (!sourceAndTargetTypesMatch) {
880 return cloneUnlessOtherwiseSpecified(source, options);
881 } else if (sourceIsArray) {
882 return options.arrayMerge(target, source, options);
883 } else {
884 return mergeObject(target, source, options);
885 }
886 }
887 deepmerge2.all = function deepmergeAll(array, options) {
888 if (!Array.isArray(array)) {
889 throw new Error("first argument should be an array");
890 }
891 return array.reduce(function(prev, next) {
892 return deepmerge2(prev, next, options);
893 }, {});
894 };
895 var deepmerge_1 = deepmerge2;
896 module.exports = deepmerge_1;
897 }
898 });
899
900 // node_modules/diff/lib/diff/base.js
901 var require_base = __commonJS({
902 "node_modules/diff/lib/diff/base.js"(exports) {
903 "use strict";
904 Object.defineProperty(exports, "__esModule", {
905 value: true
906 });
907 exports.default = Diff;
908 function Diff() {
909 }
910 Diff.prototype = {
911 /*istanbul ignore start*/
912 /*istanbul ignore end*/
913 diff: function diff(oldString, newString) {
914 var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
915 var callback = options.callback;
916 if (typeof options === "function") {
917 callback = options;
918 options = {};
919 }
920 this.options = options;
921 var self = this;
922 function done(value) {
923 if (callback) {
924 setTimeout(function() {
925 callback(void 0, value);
926 }, 0);
927 return true;
928 } else {
929 return value;
930 }
931 }
932 oldString = this.castInput(oldString);
933 newString = this.castInput(newString);
934 oldString = this.removeEmpty(this.tokenize(oldString));
935 newString = this.removeEmpty(this.tokenize(newString));
936 var newLen = newString.length, oldLen = oldString.length;
937 var editLength = 1;
938 var maxEditLength = newLen + oldLen;
939 var bestPath = [{
940 newPos: -1,
941 components: []
942 }];
943 var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
944 if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
945 return done([{
946 value: this.join(newString),
947 count: newString.length
948 }]);
949 }
950 function execEditLength() {
951 for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
952 var basePath = (
953 /*istanbul ignore start*/
954 void 0
955 );
956 var addPath = bestPath[diagonalPath - 1], removePath = bestPath[diagonalPath + 1], _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
957 if (addPath) {
958 bestPath[diagonalPath - 1] = void 0;
959 }
960 var canAdd = addPath && addPath.newPos + 1 < newLen, canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
961 if (!canAdd && !canRemove) {
962 bestPath[diagonalPath] = void 0;
963 continue;
964 }
965 if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
966 basePath = clonePath(removePath);
967 self.pushComponent(basePath.components, void 0, true);
968 } else {
969 basePath = addPath;
970 basePath.newPos++;
971 self.pushComponent(basePath.components, true, void 0);
972 }
973 _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
974 if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
975 return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
976 } else {
977 bestPath[diagonalPath] = basePath;
978 }
979 }
980 editLength++;
981 }
982 if (callback) {
983 (function exec() {
984 setTimeout(function() {
985 if (editLength > maxEditLength) {
986 return callback();
987 }
988 if (!execEditLength()) {
989 exec();
990 }
991 }, 0);
992 })();
993 } else {
994 while (editLength <= maxEditLength) {
995 var ret = execEditLength();
996 if (ret) {
997 return ret;
998 }
999 }
1000 }
1001 },
1002 /*istanbul ignore start*/
1003 /*istanbul ignore end*/
1004 pushComponent: function pushComponent(components, added, removed) {
1005 var last = components[components.length - 1];
1006 if (last && last.added === added && last.removed === removed) {
1007 components[components.length - 1] = {
1008 count: last.count + 1,
1009 added,
1010 removed
1011 };
1012 } else {
1013 components.push({
1014 count: 1,
1015 added,
1016 removed
1017 });
1018 }
1019 },
1020 /*istanbul ignore start*/
1021 /*istanbul ignore end*/
1022 extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
1023 var newLen = newString.length, oldLen = oldString.length, newPos = basePath.newPos, oldPos = newPos - diagonalPath, commonCount = 0;
1024 while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
1025 newPos++;
1026 oldPos++;
1027 commonCount++;
1028 }
1029 if (commonCount) {
1030 basePath.components.push({
1031 count: commonCount
1032 });
1033 }
1034 basePath.newPos = newPos;
1035 return oldPos;
1036 },
1037 /*istanbul ignore start*/
1038 /*istanbul ignore end*/
1039 equals: function equals(left, right) {
1040 if (this.options.comparator) {
1041 return this.options.comparator(left, right);
1042 } else {
1043 return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
1044 }
1045 },
1046 /*istanbul ignore start*/
1047 /*istanbul ignore end*/
1048 removeEmpty: function removeEmpty(array) {
1049 var ret = [];
1050 for (var i3 = 0; i3 < array.length; i3++) {
1051 if (array[i3]) {
1052 ret.push(array[i3]);
1053 }
1054 }
1055 return ret;
1056 },
1057 /*istanbul ignore start*/
1058 /*istanbul ignore end*/
1059 castInput: function castInput(value) {
1060 return value;
1061 },
1062 /*istanbul ignore start*/
1063 /*istanbul ignore end*/
1064 tokenize: function tokenize(value) {
1065 return value.split("");
1066 },
1067 /*istanbul ignore start*/
1068 /*istanbul ignore end*/
1069 join: function join(chars) {
1070 return chars.join("");
1071 }
1072 };
1073 function buildValues(diff, components, newString, oldString, useLongestToken) {
1074 var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
1075 for (; componentPos < componentLen; componentPos++) {
1076 var component = components[componentPos];
1077 if (!component.removed) {
1078 if (!component.added && useLongestToken) {
1079 var value = newString.slice(newPos, newPos + component.count);
1080 value = value.map(function(value2, i3) {
1081 var oldValue = oldString[oldPos + i3];
1082 return oldValue.length > value2.length ? oldValue : value2;
1083 });
1084 component.value = diff.join(value);
1085 } else {
1086 component.value = diff.join(newString.slice(newPos, newPos + component.count));
1087 }
1088 newPos += component.count;
1089 if (!component.added) {
1090 oldPos += component.count;
1091 }
1092 } else {
1093 component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
1094 oldPos += component.count;
1095 if (componentPos && components[componentPos - 1].added) {
1096 var tmp = components[componentPos - 1];
1097 components[componentPos - 1] = components[componentPos];
1098 components[componentPos] = tmp;
1099 }
1100 }
1101 }
1102 var lastComponent = components[componentLen - 1];
1103 if (componentLen > 1 && typeof lastComponent.value === "string" && (lastComponent.added || lastComponent.removed) && diff.equals("", lastComponent.value)) {
1104 components[componentLen - 2].value += lastComponent.value;
1105 components.pop();
1106 }
1107 return components;
1108 }
1109 function clonePath(path) {
1110 return {
1111 newPos: path.newPos,
1112 components: path.components.slice(0)
1113 };
1114 }
1115 }
1116 });
1117
1118 // node_modules/diff/lib/diff/array.js
1119 var require_array = __commonJS({
1120 "node_modules/diff/lib/diff/array.js"(exports) {
1121 "use strict";
1122 Object.defineProperty(exports, "__esModule", {
1123 value: true
1124 });
1125 exports.diffArrays = diffArrays3;
1126 exports.arrayDiff = void 0;
1127 var _base = _interopRequireDefault(require_base());
1128 function _interopRequireDefault(obj) {
1129 return obj && obj.__esModule ? obj : { default: obj };
1130 }
1131 var arrayDiff = new /*istanbul ignore start*/
1132 _base.default();
1133 exports.arrayDiff = arrayDiff;
1134 arrayDiff.tokenize = function(value) {
1135 return value.slice();
1136 };
1137 arrayDiff.join = arrayDiff.removeEmpty = function(value) {
1138 return value;
1139 };
1140 function diffArrays3(oldArr, newArr, callback) {
1141 return arrayDiff.diff(oldArr, newArr, callback);
1142 }
1143 }
1144 });
1145
1146 // node_modules/diff/lib/util/params.js
1147 var require_params = __commonJS({
1148 "node_modules/diff/lib/util/params.js"(exports) {
1149 "use strict";
1150 Object.defineProperty(exports, "__esModule", {
1151 value: true
1152 });
1153 exports.generateOptions = generateOptions;
1154 function generateOptions(options, defaults2) {
1155 if (typeof options === "function") {
1156 defaults2.callback = options;
1157 } else if (options) {
1158 for (var name2 in options) {
1159 if (options.hasOwnProperty(name2)) {
1160 defaults2[name2] = options[name2];
1161 }
1162 }
1163 }
1164 return defaults2;
1165 }
1166 }
1167 });
1168
1169 // node_modules/diff/lib/diff/word.js
1170 var require_word = __commonJS({
1171 "node_modules/diff/lib/diff/word.js"(exports) {
1172 "use strict";
1173 Object.defineProperty(exports, "__esModule", {
1174 value: true
1175 });
1176 exports.diffWords = diffWords3;
1177 exports.diffWordsWithSpace = diffWordsWithSpace;
1178 exports.wordDiff = void 0;
1179 var _base = _interopRequireDefault(require_base());
1180 var _params = require_params();
1181 function _interopRequireDefault(obj) {
1182 return obj && obj.__esModule ? obj : { default: obj };
1183 }
1184 var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
1185 var reWhitespace = /\S/;
1186 var wordDiff = new /*istanbul ignore start*/
1187 _base.default();
1188 exports.wordDiff = wordDiff;
1189 wordDiff.equals = function(left, right) {
1190 if (this.options.ignoreCase) {
1191 left = left.toLowerCase();
1192 right = right.toLowerCase();
1193 }
1194 return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
1195 };
1196 wordDiff.tokenize = function(value) {
1197 var tokens = value.split(/(\s+|[()[\]{}'"]|\b)/);
1198 for (var i3 = 0; i3 < tokens.length - 1; i3++) {
1199 if (!tokens[i3 + 1] && tokens[i3 + 2] && extendedWordChars.test(tokens[i3]) && extendedWordChars.test(tokens[i3 + 2])) {
1200 tokens[i3] += tokens[i3 + 2];
1201 tokens.splice(i3 + 1, 2);
1202 i3--;
1203 }
1204 }
1205 return tokens;
1206 };
1207 function diffWords3(oldStr, newStr, options) {
1208 options = /*istanbul ignore start*/
1209 (0, /*istanbul ignore end*/
1210 /*istanbul ignore start*/
1211 _params.generateOptions)(options, {
1212 ignoreWhitespace: true
1213 });
1214 return wordDiff.diff(oldStr, newStr, options);
1215 }
1216 function diffWordsWithSpace(oldStr, newStr, options) {
1217 return wordDiff.diff(oldStr, newStr, options);
1218 }
1219 }
1220 });
1221
1222 // package-external:@wordpress/block-serialization-default-parser
1223 var require_block_serialization_default_parser = __commonJS({
1224 "package-external:@wordpress/block-serialization-default-parser"(exports, module) {
1225 module.exports = window.wp.blockSerializationDefaultParser;
1226 }
1227 });
1228
1229 // package-external:@wordpress/rich-text
1230 var require_rich_text = __commonJS({
1231 "package-external:@wordpress/rich-text"(exports, module) {
1232 module.exports = window.wp.richText;
1233 }
1234 });
1235
1236 // package-external:@wordpress/commands
1237 var require_commands = __commonJS({
1238 "package-external:@wordpress/commands"(exports, module) {
1239 module.exports = window.wp.commands;
1240 }
1241 });
1242
1243 // package-external:@wordpress/viewport
1244 var require_viewport = __commonJS({
1245 "package-external:@wordpress/viewport"(exports, module) {
1246 module.exports = window.wp.viewport;
1247 }
1248 });
1249
1250 // package-external:@wordpress/plugins
1251 var require_plugins = __commonJS({
1252 "package-external:@wordpress/plugins"(exports, module) {
1253 module.exports = window.wp.plugins;
1254 }
1255 });
1256
1257 // package-external:@wordpress/upload-media
1258 var require_upload_media = __commonJS({
1259 "package-external:@wordpress/upload-media"(exports, module) {
1260 module.exports = window.wp.uploadMedia;
1261 }
1262 });
1263
1264 // package-external:@wordpress/keyboard-shortcuts
1265 var require_keyboard_shortcuts = __commonJS({
1266 "package-external:@wordpress/keyboard-shortcuts"(exports, module) {
1267 module.exports = window.wp.keyboardShortcuts;
1268 }
1269 });
1270
1271 // package-external:@wordpress/keycodes
1272 var require_keycodes = __commonJS({
1273 "package-external:@wordpress/keycodes"(exports, module) {
1274 module.exports = window.wp.keycodes;
1275 }
1276 });
1277
1278 // package-external:@wordpress/dom
1279 var require_dom = __commonJS({
1280 "package-external:@wordpress/dom"(exports, module) {
1281 module.exports = window.wp.dom;
1282 }
1283 });
1284
1285 // package-external:@wordpress/warning
1286 var require_warning = __commonJS({
1287 "package-external:@wordpress/warning"(exports, module) {
1288 module.exports = window.wp.warning;
1289 }
1290 });
1291
1292 // node_modules/react-is/cjs/react-is.development.js
1293 var require_react_is_development = __commonJS({
1294 "node_modules/react-is/cjs/react-is.development.js"(exports) {
1295 "use strict";
1296 if (true) {
1297 (function() {
1298 "use strict";
1299 var hasSymbol = typeof Symbol === "function" && Symbol.for;
1300 var REACT_ELEMENT_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
1301 var REACT_PORTAL_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.portal") : 60106;
1302 var REACT_FRAGMENT_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.fragment") : 60107;
1303 var REACT_STRICT_MODE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.strict_mode") : 60108;
1304 var REACT_PROFILER_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.profiler") : 60114;
1305 var REACT_PROVIDER_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.provider") : 60109;
1306 var REACT_CONTEXT_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.context") : 60110;
1307 var REACT_ASYNC_MODE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.async_mode") : 60111;
1308 var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.concurrent_mode") : 60111;
1309 var REACT_FORWARD_REF_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.forward_ref") : 60112;
1310 var REACT_SUSPENSE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.suspense") : 60113;
1311 var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.suspense_list") : 60120;
1312 var REACT_MEMO_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.memo") : 60115;
1313 var REACT_LAZY_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.lazy") : 60116;
1314 var REACT_BLOCK_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.block") : 60121;
1315 var REACT_FUNDAMENTAL_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.fundamental") : 60117;
1316 var REACT_RESPONDER_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.responder") : 60118;
1317 var REACT_SCOPE_TYPE = hasSymbol ? /* @__PURE__ */ Symbol.for("react.scope") : 60119;
1318 function isValidElementType(type) {
1319 return typeof type === "string" || typeof type === "function" || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
1320 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
1321 }
1322 function typeOf(object) {
1323 if (typeof object === "object" && object !== null) {
1324 var $$typeof = object.$$typeof;
1325 switch ($$typeof) {
1326 case REACT_ELEMENT_TYPE:
1327 var type = object.type;
1328 switch (type) {
1329 case REACT_ASYNC_MODE_TYPE:
1330 case REACT_CONCURRENT_MODE_TYPE:
1331 case REACT_FRAGMENT_TYPE:
1332 case REACT_PROFILER_TYPE:
1333 case REACT_STRICT_MODE_TYPE:
1334 case REACT_SUSPENSE_TYPE:
1335 return type;
1336 default:
1337 var $$typeofType = type && type.$$typeof;
1338 switch ($$typeofType) {
1339 case REACT_CONTEXT_TYPE:
1340 case REACT_FORWARD_REF_TYPE:
1341 case REACT_LAZY_TYPE:
1342 case REACT_MEMO_TYPE:
1343 case REACT_PROVIDER_TYPE:
1344 return $$typeofType;
1345 default:
1346 return $$typeof;
1347 }
1348 }
1349 case REACT_PORTAL_TYPE:
1350 return $$typeof;
1351 }
1352 }
1353 return void 0;
1354 }
1355 var AsyncMode = REACT_ASYNC_MODE_TYPE;
1356 var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
1357 var ContextConsumer = REACT_CONTEXT_TYPE;
1358 var ContextProvider = REACT_PROVIDER_TYPE;
1359 var Element2 = REACT_ELEMENT_TYPE;
1360 var ForwardRef = REACT_FORWARD_REF_TYPE;
1361 var Fragment96 = REACT_FRAGMENT_TYPE;
1362 var Lazy = REACT_LAZY_TYPE;
1363 var Memo = REACT_MEMO_TYPE;
1364 var Portal = REACT_PORTAL_TYPE;
1365 var Profiler = REACT_PROFILER_TYPE;
1366 var StrictMode = REACT_STRICT_MODE_TYPE;
1367 var Suspense = REACT_SUSPENSE_TYPE;
1368 var hasWarnedAboutDeprecatedIsAsyncMode = false;
1369 function isAsyncMode(object) {
1370 {
1371 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
1372 hasWarnedAboutDeprecatedIsAsyncMode = true;
1373 console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.");
1374 }
1375 }
1376 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
1377 }
1378 function isConcurrentMode(object) {
1379 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
1380 }
1381 function isContextConsumer(object) {
1382 return typeOf(object) === REACT_CONTEXT_TYPE;
1383 }
1384 function isContextProvider(object) {
1385 return typeOf(object) === REACT_PROVIDER_TYPE;
1386 }
1387 function isElement2(object) {
1388 return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1389 }
1390 function isForwardRef(object) {
1391 return typeOf(object) === REACT_FORWARD_REF_TYPE;
1392 }
1393 function isFragment(object) {
1394 return typeOf(object) === REACT_FRAGMENT_TYPE;
1395 }
1396 function isLazy(object) {
1397 return typeOf(object) === REACT_LAZY_TYPE;
1398 }
1399 function isMemo(object) {
1400 return typeOf(object) === REACT_MEMO_TYPE;
1401 }
1402 function isPortal(object) {
1403 return typeOf(object) === REACT_PORTAL_TYPE;
1404 }
1405 function isProfiler(object) {
1406 return typeOf(object) === REACT_PROFILER_TYPE;
1407 }
1408 function isStrictMode(object) {
1409 return typeOf(object) === REACT_STRICT_MODE_TYPE;
1410 }
1411 function isSuspense(object) {
1412 return typeOf(object) === REACT_SUSPENSE_TYPE;
1413 }
1414 exports.AsyncMode = AsyncMode;
1415 exports.ConcurrentMode = ConcurrentMode;
1416 exports.ContextConsumer = ContextConsumer;
1417 exports.ContextProvider = ContextProvider;
1418 exports.Element = Element2;
1419 exports.ForwardRef = ForwardRef;
1420 exports.Fragment = Fragment96;
1421 exports.Lazy = Lazy;
1422 exports.Memo = Memo;
1423 exports.Portal = Portal;
1424 exports.Profiler = Profiler;
1425 exports.StrictMode = StrictMode;
1426 exports.Suspense = Suspense;
1427 exports.isAsyncMode = isAsyncMode;
1428 exports.isConcurrentMode = isConcurrentMode;
1429 exports.isContextConsumer = isContextConsumer;
1430 exports.isContextProvider = isContextProvider;
1431 exports.isElement = isElement2;
1432 exports.isForwardRef = isForwardRef;
1433 exports.isFragment = isFragment;
1434 exports.isLazy = isLazy;
1435 exports.isMemo = isMemo;
1436 exports.isPortal = isPortal;
1437 exports.isProfiler = isProfiler;
1438 exports.isStrictMode = isStrictMode;
1439 exports.isSuspense = isSuspense;
1440 exports.isValidElementType = isValidElementType;
1441 exports.typeOf = typeOf;
1442 })();
1443 }
1444 }
1445 });
1446
1447 // node_modules/react-is/index.js
1448 var require_react_is = __commonJS({
1449 "node_modules/react-is/index.js"(exports, module) {
1450 "use strict";
1451 if (false) {
1452 module.exports = null;
1453 } else {
1454 module.exports = require_react_is_development();
1455 }
1456 }
1457 });
1458
1459 // node_modules/object-assign/index.js
1460 var require_object_assign = __commonJS({
1461 "node_modules/object-assign/index.js"(exports, module) {
1462 "use strict";
1463 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
1464 var hasOwnProperty = Object.prototype.hasOwnProperty;
1465 var propIsEnumerable = Object.prototype.propertyIsEnumerable;
1466 function toObject(val) {
1467 if (val === null || val === void 0) {
1468 throw new TypeError("Object.assign cannot be called with null or undefined");
1469 }
1470 return Object(val);
1471 }
1472 function shouldUseNative() {
1473 try {
1474 if (!Object.assign) {
1475 return false;
1476 }
1477 var test1 = new String("abc");
1478 test1[5] = "de";
1479 if (Object.getOwnPropertyNames(test1)[0] === "5") {
1480 return false;
1481 }
1482 var test2 = {};
1483 for (var i3 = 0; i3 < 10; i3++) {
1484 test2["_" + String.fromCharCode(i3)] = i3;
1485 }
1486 var order2 = Object.getOwnPropertyNames(test2).map(function(n3) {
1487 return test2[n3];
1488 });
1489 if (order2.join("") !== "0123456789") {
1490 return false;
1491 }
1492 var test3 = {};
1493 "abcdefghijklmnopqrst".split("").forEach(function(letter) {
1494 test3[letter] = letter;
1495 });
1496 if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
1497 return false;
1498 }
1499 return true;
1500 } catch (err) {
1501 return false;
1502 }
1503 }
1504 module.exports = shouldUseNative() ? Object.assign : function(target, source) {
1505 var from;
1506 var to2 = toObject(target);
1507 var symbols;
1508 for (var s3 = 1; s3 < arguments.length; s3++) {
1509 from = Object(arguments[s3]);
1510 for (var key in from) {
1511 if (hasOwnProperty.call(from, key)) {
1512 to2[key] = from[key];
1513 }
1514 }
1515 if (getOwnPropertySymbols) {
1516 symbols = getOwnPropertySymbols(from);
1517 for (var i3 = 0; i3 < symbols.length; i3++) {
1518 if (propIsEnumerable.call(from, symbols[i3])) {
1519 to2[symbols[i3]] = from[symbols[i3]];
1520 }
1521 }
1522 }
1523 }
1524 return to2;
1525 };
1526 }
1527 });
1528
1529 // node_modules/prop-types/lib/ReactPropTypesSecret.js
1530 var require_ReactPropTypesSecret = __commonJS({
1531 "node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
1532 "use strict";
1533 var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
1534 module.exports = ReactPropTypesSecret;
1535 }
1536 });
1537
1538 // node_modules/prop-types/lib/has.js
1539 var require_has = __commonJS({
1540 "node_modules/prop-types/lib/has.js"(exports, module) {
1541 module.exports = Function.call.bind(Object.prototype.hasOwnProperty);
1542 }
1543 });
1544
1545 // node_modules/prop-types/checkPropTypes.js
1546 var require_checkPropTypes = __commonJS({
1547 "node_modules/prop-types/checkPropTypes.js"(exports, module) {
1548 "use strict";
1549 var printWarning = function() {
1550 };
1551 if (true) {
1552 ReactPropTypesSecret = require_ReactPropTypesSecret();
1553 loggedTypeFailures = {};
1554 has = require_has();
1555 printWarning = function(text) {
1556 var message2 = "Warning: " + text;
1557 if (typeof console !== "undefined") {
1558 console.error(message2);
1559 }
1560 try {
1561 throw new Error(message2);
1562 } catch (x2) {
1563 }
1564 };
1565 }
1566 var ReactPropTypesSecret;
1567 var loggedTypeFailures;
1568 var has;
1569 function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
1570 if (true) {
1571 for (var typeSpecName in typeSpecs) {
1572 if (has(typeSpecs, typeSpecName)) {
1573 var error;
1574 try {
1575 if (typeof typeSpecs[typeSpecName] !== "function") {
1576 var err = Error(
1577 (componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
1578 );
1579 err.name = "Invariant Violation";
1580 throw err;
1581 }
1582 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
1583 } catch (ex) {
1584 error = ex;
1585 }
1586 if (error && !(error instanceof Error)) {
1587 printWarning(
1588 (componentName || "React class") + ": type specification of " + location + " `" + typeSpecName + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof error + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."
1589 );
1590 }
1591 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
1592 loggedTypeFailures[error.message] = true;
1593 var stack = getStack ? getStack() : "";
1594 printWarning(
1595 "Failed " + location + " type: " + error.message + (stack != null ? stack : "")
1596 );
1597 }
1598 }
1599 }
1600 }
1601 }
1602 checkPropTypes.resetWarningCache = function() {
1603 if (true) {
1604 loggedTypeFailures = {};
1605 }
1606 };
1607 module.exports = checkPropTypes;
1608 }
1609 });
1610
1611 // node_modules/prop-types/factoryWithTypeCheckers.js
1612 var require_factoryWithTypeCheckers = __commonJS({
1613 "node_modules/prop-types/factoryWithTypeCheckers.js"(exports, module) {
1614 "use strict";
1615 var ReactIs = require_react_is();
1616 var assign2 = require_object_assign();
1617 var ReactPropTypesSecret = require_ReactPropTypesSecret();
1618 var has = require_has();
1619 var checkPropTypes = require_checkPropTypes();
1620 var printWarning = function() {
1621 };
1622 if (true) {
1623 printWarning = function(text) {
1624 var message2 = "Warning: " + text;
1625 if (typeof console !== "undefined") {
1626 console.error(message2);
1627 }
1628 try {
1629 throw new Error(message2);
1630 } catch (x2) {
1631 }
1632 };
1633 }
1634 function emptyFunctionThatReturnsNull() {
1635 return null;
1636 }
1637 module.exports = function(isValidElement2, throwOnDirectAccess) {
1638 var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
1639 var FAUX_ITERATOR_SYMBOL = "@@iterator";
1640 function getIteratorFn(maybeIterable) {
1641 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
1642 if (typeof iteratorFn === "function") {
1643 return iteratorFn;
1644 }
1645 }
1646 var ANONYMOUS = "<<anonymous>>";
1647 var ReactPropTypes = {
1648 array: createPrimitiveTypeChecker("array"),
1649 bigint: createPrimitiveTypeChecker("bigint"),
1650 bool: createPrimitiveTypeChecker("boolean"),
1651 func: createPrimitiveTypeChecker("function"),
1652 number: createPrimitiveTypeChecker("number"),
1653 object: createPrimitiveTypeChecker("object"),
1654 string: createPrimitiveTypeChecker("string"),
1655 symbol: createPrimitiveTypeChecker("symbol"),
1656 any: createAnyTypeChecker(),
1657 arrayOf: createArrayOfTypeChecker,
1658 element: createElementTypeChecker(),
1659 elementType: createElementTypeTypeChecker(),
1660 instanceOf: createInstanceTypeChecker,
1661 node: createNodeChecker(),
1662 objectOf: createObjectOfTypeChecker,
1663 oneOf: createEnumTypeChecker,
1664 oneOfType: createUnionTypeChecker,
1665 shape: createShapeTypeChecker,
1666 exact: createStrictShapeTypeChecker
1667 };
1668 function is2(x2, y3) {
1669 if (x2 === y3) {
1670 return x2 !== 0 || 1 / x2 === 1 / y3;
1671 } else {
1672 return x2 !== x2 && y3 !== y3;
1673 }
1674 }
1675 function PropTypeError(message2, data) {
1676 this.message = message2;
1677 this.data = data && typeof data === "object" ? data : {};
1678 this.stack = "";
1679 }
1680 PropTypeError.prototype = Error.prototype;
1681 function createChainableTypeChecker(validate) {
1682 if (true) {
1683 var manualPropTypeCallCache = {};
1684 var manualPropTypeWarningCount = 0;
1685 }
1686 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
1687 componentName = componentName || ANONYMOUS;
1688 propFullName = propFullName || propName;
1689 if (secret !== ReactPropTypesSecret) {
1690 if (throwOnDirectAccess) {
1691 var err = new Error(
1692 "Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types"
1693 );
1694 err.name = "Invariant Violation";
1695 throw err;
1696 } else if (typeof console !== "undefined") {
1697 var cacheKey2 = componentName + ":" + propName;
1698 if (!manualPropTypeCallCache[cacheKey2] && // Avoid spamming the console because they are often not actionable except for lib authors
1699 manualPropTypeWarningCount < 3) {
1700 printWarning(
1701 "You are manually calling a React.PropTypes validation function for the `" + propFullName + "` prop on `" + componentName + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."
1702 );
1703 manualPropTypeCallCache[cacheKey2] = true;
1704 manualPropTypeWarningCount++;
1705 }
1706 }
1707 }
1708 if (props[propName] == null) {
1709 if (isRequired) {
1710 if (props[propName] === null) {
1711 return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
1712 }
1713 return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
1714 }
1715 return null;
1716 } else {
1717 return validate(props, propName, componentName, location, propFullName);
1718 }
1719 }
1720 var chainedCheckType = checkType.bind(null, false);
1721 chainedCheckType.isRequired = checkType.bind(null, true);
1722 return chainedCheckType;
1723 }
1724 function createPrimitiveTypeChecker(expectedType) {
1725 function validate(props, propName, componentName, location, propFullName, secret) {
1726 var propValue = props[propName];
1727 var propType = getPropType(propValue);
1728 if (propType !== expectedType) {
1729 var preciseType = getPreciseType(propValue);
1730 return new PropTypeError(
1731 "Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."),
1732 { expectedType }
1733 );
1734 }
1735 return null;
1736 }
1737 return createChainableTypeChecker(validate);
1738 }
1739 function createAnyTypeChecker() {
1740 return createChainableTypeChecker(emptyFunctionThatReturnsNull);
1741 }
1742 function createArrayOfTypeChecker(typeChecker) {
1743 function validate(props, propName, componentName, location, propFullName) {
1744 if (typeof typeChecker !== "function") {
1745 return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf.");
1746 }
1747 var propValue = props[propName];
1748 if (!Array.isArray(propValue)) {
1749 var propType = getPropType(propValue);
1750 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array."));
1751 }
1752 for (var i3 = 0; i3 < propValue.length; i3++) {
1753 var error = typeChecker(propValue, i3, componentName, location, propFullName + "[" + i3 + "]", ReactPropTypesSecret);
1754 if (error instanceof Error) {
1755 return error;
1756 }
1757 }
1758 return null;
1759 }
1760 return createChainableTypeChecker(validate);
1761 }
1762 function createElementTypeChecker() {
1763 function validate(props, propName, componentName, location, propFullName) {
1764 var propValue = props[propName];
1765 if (!isValidElement2(propValue)) {
1766 var propType = getPropType(propValue);
1767 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement."));
1768 }
1769 return null;
1770 }
1771 return createChainableTypeChecker(validate);
1772 }
1773 function createElementTypeTypeChecker() {
1774 function validate(props, propName, componentName, location, propFullName) {
1775 var propValue = props[propName];
1776 if (!ReactIs.isValidElementType(propValue)) {
1777 var propType = getPropType(propValue);
1778 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement type."));
1779 }
1780 return null;
1781 }
1782 return createChainableTypeChecker(validate);
1783 }
1784 function createInstanceTypeChecker(expectedClass) {
1785 function validate(props, propName, componentName, location, propFullName) {
1786 if (!(props[propName] instanceof expectedClass)) {
1787 var expectedClassName = expectedClass.name || ANONYMOUS;
1788 var actualClassName = getClassName(props[propName]);
1789 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
1790 }
1791 return null;
1792 }
1793 return createChainableTypeChecker(validate);
1794 }
1795 function createEnumTypeChecker(expectedValues) {
1796 if (!Array.isArray(expectedValues)) {
1797 if (true) {
1798 if (arguments.length > 1) {
1799 printWarning(
1800 "Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."
1801 );
1802 } else {
1803 printWarning("Invalid argument supplied to oneOf, expected an array.");
1804 }
1805 }
1806 return emptyFunctionThatReturnsNull;
1807 }
1808 function validate(props, propName, componentName, location, propFullName) {
1809 var propValue = props[propName];
1810 for (var i3 = 0; i3 < expectedValues.length; i3++) {
1811 if (is2(propValue, expectedValues[i3])) {
1812 return null;
1813 }
1814 }
1815 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
1816 var type = getPreciseType(value);
1817 if (type === "symbol") {
1818 return String(value);
1819 }
1820 return value;
1821 });
1822 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + String(propValue) + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + "."));
1823 }
1824 return createChainableTypeChecker(validate);
1825 }
1826 function createObjectOfTypeChecker(typeChecker) {
1827 function validate(props, propName, componentName, location, propFullName) {
1828 if (typeof typeChecker !== "function") {
1829 return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf.");
1830 }
1831 var propValue = props[propName];
1832 var propType = getPropType(propValue);
1833 if (propType !== "object") {
1834 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object."));
1835 }
1836 for (var key in propValue) {
1837 if (has(propValue, key)) {
1838 var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
1839 if (error instanceof Error) {
1840 return error;
1841 }
1842 }
1843 }
1844 return null;
1845 }
1846 return createChainableTypeChecker(validate);
1847 }
1848 function createUnionTypeChecker(arrayOfTypeCheckers) {
1849 if (!Array.isArray(arrayOfTypeCheckers)) {
1850 true ? printWarning("Invalid argument supplied to oneOfType, expected an instance of array.") : void 0;
1851 return emptyFunctionThatReturnsNull;
1852 }
1853 for (var i3 = 0; i3 < arrayOfTypeCheckers.length; i3++) {
1854 var checker = arrayOfTypeCheckers[i3];
1855 if (typeof checker !== "function") {
1856 printWarning(
1857 "Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + getPostfixForTypeWarning(checker) + " at index " + i3 + "."
1858 );
1859 return emptyFunctionThatReturnsNull;
1860 }
1861 }
1862 function validate(props, propName, componentName, location, propFullName) {
1863 var expectedTypes = [];
1864 for (var i4 = 0; i4 < arrayOfTypeCheckers.length; i4++) {
1865 var checker2 = arrayOfTypeCheckers[i4];
1866 var checkerResult = checker2(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
1867 if (checkerResult == null) {
1868 return null;
1869 }
1870 if (checkerResult.data && has(checkerResult.data, "expectedType")) {
1871 expectedTypes.push(checkerResult.data.expectedType);
1872 }
1873 }
1874 var expectedTypesMessage = expectedTypes.length > 0 ? ", expected one of type [" + expectedTypes.join(", ") + "]" : "";
1875 return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`" + expectedTypesMessage + "."));
1876 }
1877 return createChainableTypeChecker(validate);
1878 }
1879 function createNodeChecker() {
1880 function validate(props, propName, componentName, location, propFullName) {
1881 if (!isNode2(props[propName])) {
1882 return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode."));
1883 }
1884 return null;
1885 }
1886 return createChainableTypeChecker(validate);
1887 }
1888 function invalidValidatorError(componentName, location, propFullName, key, type) {
1889 return new PropTypeError(
1890 (componentName || "React class") + ": " + location + " type `" + propFullName + "." + key + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + type + "`."
1891 );
1892 }
1893 function createShapeTypeChecker(shapeTypes) {
1894 function validate(props, propName, componentName, location, propFullName) {
1895 var propValue = props[propName];
1896 var propType = getPropType(propValue);
1897 if (propType !== "object") {
1898 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
1899 }
1900 for (var key in shapeTypes) {
1901 var checker = shapeTypes[key];
1902 if (typeof checker !== "function") {
1903 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
1904 }
1905 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
1906 if (error) {
1907 return error;
1908 }
1909 }
1910 return null;
1911 }
1912 return createChainableTypeChecker(validate);
1913 }
1914 function createStrictShapeTypeChecker(shapeTypes) {
1915 function validate(props, propName, componentName, location, propFullName) {
1916 var propValue = props[propName];
1917 var propType = getPropType(propValue);
1918 if (propType !== "object") {
1919 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
1920 }
1921 var allKeys = assign2({}, props[propName], shapeTypes);
1922 for (var key in allKeys) {
1923 var checker = shapeTypes[key];
1924 if (has(shapeTypes, key) && typeof checker !== "function") {
1925 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
1926 }
1927 if (!checker) {
1928 return new PropTypeError(
1929 "Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, " ")
1930 );
1931 }
1932 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
1933 if (error) {
1934 return error;
1935 }
1936 }
1937 return null;
1938 }
1939 return createChainableTypeChecker(validate);
1940 }
1941 function isNode2(propValue) {
1942 switch (typeof propValue) {
1943 case "number":
1944 case "string":
1945 case "undefined":
1946 return true;
1947 case "boolean":
1948 return !propValue;
1949 case "object":
1950 if (Array.isArray(propValue)) {
1951 return propValue.every(isNode2);
1952 }
1953 if (propValue === null || isValidElement2(propValue)) {
1954 return true;
1955 }
1956 var iteratorFn = getIteratorFn(propValue);
1957 if (iteratorFn) {
1958 var iterator = iteratorFn.call(propValue);
1959 var step;
1960 if (iteratorFn !== propValue.entries) {
1961 while (!(step = iterator.next()).done) {
1962 if (!isNode2(step.value)) {
1963 return false;
1964 }
1965 }
1966 } else {
1967 while (!(step = iterator.next()).done) {
1968 var entry = step.value;
1969 if (entry) {
1970 if (!isNode2(entry[1])) {
1971 return false;
1972 }
1973 }
1974 }
1975 }
1976 } else {
1977 return false;
1978 }
1979 return true;
1980 default:
1981 return false;
1982 }
1983 }
1984 function isSymbol(propType, propValue) {
1985 if (propType === "symbol") {
1986 return true;
1987 }
1988 if (!propValue) {
1989 return false;
1990 }
1991 if (propValue["@@toStringTag"] === "Symbol") {
1992 return true;
1993 }
1994 if (typeof Symbol === "function" && propValue instanceof Symbol) {
1995 return true;
1996 }
1997 return false;
1998 }
1999 function getPropType(propValue) {
2000 var propType = typeof propValue;
2001 if (Array.isArray(propValue)) {
2002 return "array";
2003 }
2004 if (propValue instanceof RegExp) {
2005 return "object";
2006 }
2007 if (isSymbol(propType, propValue)) {
2008 return "symbol";
2009 }
2010 return propType;
2011 }
2012 function getPreciseType(propValue) {
2013 if (typeof propValue === "undefined" || propValue === null) {
2014 return "" + propValue;
2015 }
2016 var propType = getPropType(propValue);
2017 if (propType === "object") {
2018 if (propValue instanceof Date) {
2019 return "date";
2020 } else if (propValue instanceof RegExp) {
2021 return "regexp";
2022 }
2023 }
2024 return propType;
2025 }
2026 function getPostfixForTypeWarning(value) {
2027 var type = getPreciseType(value);
2028 switch (type) {
2029 case "array":
2030 case "object":
2031 return "an " + type;
2032 case "boolean":
2033 case "date":
2034 case "regexp":
2035 return "a " + type;
2036 default:
2037 return type;
2038 }
2039 }
2040 function getClassName(propValue) {
2041 if (!propValue.constructor || !propValue.constructor.name) {
2042 return ANONYMOUS;
2043 }
2044 return propValue.constructor.name;
2045 }
2046 ReactPropTypes.checkPropTypes = checkPropTypes;
2047 ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
2048 ReactPropTypes.PropTypes = ReactPropTypes;
2049 return ReactPropTypes;
2050 };
2051 }
2052 });
2053
2054 // node_modules/prop-types/index.js
2055 var require_prop_types = __commonJS({
2056 "node_modules/prop-types/index.js"(exports, module) {
2057 if (true) {
2058 ReactIs = require_react_is();
2059 throwOnDirectAccess = true;
2060 module.exports = require_factoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
2061 } else {
2062 module.exports = null();
2063 }
2064 var ReactIs;
2065 var throwOnDirectAccess;
2066 }
2067 });
2068
2069 // node_modules/autosize/dist/autosize.js
2070 var require_autosize = __commonJS({
2071 "node_modules/autosize/dist/autosize.js"(exports, module) {
2072 (function(global, factory) {
2073 if (typeof define === "function" && define.amd) {
2074 define(["module", "exports"], factory);
2075 } else if (typeof exports !== "undefined") {
2076 factory(module, exports);
2077 } else {
2078 var mod = {
2079 exports: {}
2080 };
2081 factory(mod, mod.exports);
2082 global.autosize = mod.exports;
2083 }
2084 })(exports, function(module2, exports2) {
2085 "use strict";
2086 var map = typeof Map === "function" ? /* @__PURE__ */ new Map() : /* @__PURE__ */ (function() {
2087 var keys = [];
2088 var values = [];
2089 return {
2090 has: function has(key) {
2091 return keys.indexOf(key) > -1;
2092 },
2093 get: function get(key) {
2094 return values[keys.indexOf(key)];
2095 },
2096 set: function set(key, value) {
2097 if (keys.indexOf(key) === -1) {
2098 keys.push(key);
2099 values.push(value);
2100 }
2101 },
2102 delete: function _delete(key) {
2103 var index2 = keys.indexOf(key);
2104 if (index2 > -1) {
2105 keys.splice(index2, 1);
2106 values.splice(index2, 1);
2107 }
2108 }
2109 };
2110 })();
2111 var createEvent = function createEvent2(name2) {
2112 return new Event(name2, { bubbles: true });
2113 };
2114 try {
2115 new Event("test");
2116 } catch (e3) {
2117 createEvent = function createEvent2(name2) {
2118 var evt = document.createEvent("Event");
2119 evt.initEvent(name2, true, false);
2120 return evt;
2121 };
2122 }
2123 function assign2(ta) {
2124 if (!ta || !ta.nodeName || ta.nodeName !== "TEXTAREA" || map.has(ta)) return;
2125 var heightOffset = null;
2126 var clientWidth = null;
2127 var cachedHeight = null;
2128 function init() {
2129 var style = window.getComputedStyle(ta, null);
2130 if (style.resize === "vertical") {
2131 ta.style.resize = "none";
2132 } else if (style.resize === "both") {
2133 ta.style.resize = "horizontal";
2134 }
2135 if (style.boxSizing === "content-box") {
2136 heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
2137 } else {
2138 heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
2139 }
2140 if (isNaN(heightOffset)) {
2141 heightOffset = 0;
2142 }
2143 update5();
2144 }
2145 function changeOverflow(value) {
2146 {
2147 var width = ta.style.width;
2148 ta.style.width = "0px";
2149 ta.offsetWidth;
2150 ta.style.width = width;
2151 }
2152 ta.style.overflowY = value;
2153 }
2154 function getParentOverflows(el) {
2155 var arr = [];
2156 while (el && el.parentNode && el.parentNode instanceof Element) {
2157 if (el.parentNode.scrollTop) {
2158 arr.push({
2159 node: el.parentNode,
2160 scrollTop: el.parentNode.scrollTop
2161 });
2162 }
2163 el = el.parentNode;
2164 }
2165 return arr;
2166 }
2167 function resize() {
2168 if (ta.scrollHeight === 0) {
2169 return;
2170 }
2171 var overflows = getParentOverflows(ta);
2172 var docTop = document.documentElement && document.documentElement.scrollTop;
2173 ta.style.height = "";
2174 ta.style.height = ta.scrollHeight + heightOffset + "px";
2175 clientWidth = ta.clientWidth;
2176 overflows.forEach(function(el) {
2177 el.node.scrollTop = el.scrollTop;
2178 });
2179 if (docTop) {
2180 document.documentElement.scrollTop = docTop;
2181 }
2182 }
2183 function update5() {
2184 resize();
2185 var styleHeight = Math.round(parseFloat(ta.style.height));
2186 var computed = window.getComputedStyle(ta, null);
2187 var actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
2188 if (actualHeight < styleHeight) {
2189 if (computed.overflowY === "hidden") {
2190 changeOverflow("scroll");
2191 resize();
2192 actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
2193 }
2194 } else {
2195 if (computed.overflowY !== "hidden") {
2196 changeOverflow("hidden");
2197 resize();
2198 actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
2199 }
2200 }
2201 if (cachedHeight !== actualHeight) {
2202 cachedHeight = actualHeight;
2203 var evt = createEvent("autosize:resized");
2204 try {
2205 ta.dispatchEvent(evt);
2206 } catch (err) {
2207 }
2208 }
2209 }
2210 var pageResize = function pageResize2() {
2211 if (ta.clientWidth !== clientWidth) {
2212 update5();
2213 }
2214 };
2215 var destroy2 = function(style) {
2216 window.removeEventListener("resize", pageResize, false);
2217 ta.removeEventListener("input", update5, false);
2218 ta.removeEventListener("keyup", update5, false);
2219 ta.removeEventListener("autosize:destroy", destroy2, false);
2220 ta.removeEventListener("autosize:update", update5, false);
2221 Object.keys(style).forEach(function(key) {
2222 ta.style[key] = style[key];
2223 });
2224 map.delete(ta);
2225 }.bind(ta, {
2226 height: ta.style.height,
2227 resize: ta.style.resize,
2228 overflowY: ta.style.overflowY,
2229 overflowX: ta.style.overflowX,
2230 wordWrap: ta.style.wordWrap
2231 });
2232 ta.addEventListener("autosize:destroy", destroy2, false);
2233 if ("onpropertychange" in ta && "oninput" in ta) {
2234 ta.addEventListener("keyup", update5, false);
2235 }
2236 window.addEventListener("resize", pageResize, false);
2237 ta.addEventListener("input", update5, false);
2238 ta.addEventListener("autosize:update", update5, false);
2239 ta.style.overflowX = "hidden";
2240 ta.style.wordWrap = "break-word";
2241 map.set(ta, {
2242 destroy: destroy2,
2243 update: update5
2244 });
2245 init();
2246 }
2247 function destroy(ta) {
2248 var methods = map.get(ta);
2249 if (methods) {
2250 methods.destroy();
2251 }
2252 }
2253 function update4(ta) {
2254 var methods = map.get(ta);
2255 if (methods) {
2256 methods.update();
2257 }
2258 }
2259 var autosize = null;
2260 if (typeof window === "undefined" || typeof window.getComputedStyle !== "function") {
2261 autosize = function autosize2(el) {
2262 return el;
2263 };
2264 autosize.destroy = function(el) {
2265 return el;
2266 };
2267 autosize.update = function(el) {
2268 return el;
2269 };
2270 } else {
2271 autosize = function autosize2(el, options) {
2272 if (el) {
2273 Array.prototype.forEach.call(el.length ? el : [el], function(x2) {
2274 return assign2(x2, options);
2275 });
2276 }
2277 return el;
2278 };
2279 autosize.destroy = function(el) {
2280 if (el) {
2281 Array.prototype.forEach.call(el.length ? el : [el], destroy);
2282 }
2283 return el;
2284 };
2285 autosize.update = function(el) {
2286 if (el) {
2287 Array.prototype.forEach.call(el.length ? el : [el], update4);
2288 }
2289 return el;
2290 };
2291 }
2292 exports2.default = autosize;
2293 module2.exports = exports2["default"];
2294 });
2295 }
2296 });
2297
2298 // node_modules/computed-style/dist/computedStyle.commonjs.js
2299 var require_computedStyle_commonjs = __commonJS({
2300 "node_modules/computed-style/dist/computedStyle.commonjs.js"(exports, module) {
2301 var computedStyle = function(el, prop, getComputedStyle3) {
2302 getComputedStyle3 = window.getComputedStyle;
2303 return (
2304 // If we have getComputedStyle
2305 (getComputedStyle3 ? (
2306 // Query it
2307 // TODO: From CSS-Query notes, we might need (node, null) for FF
2308 getComputedStyle3(el)
2309 ) : (
2310 // Otherwise, we are in IE and use currentStyle
2311 el.currentStyle
2312 ))[
2313 // Switch to camelCase for CSSOM
2314 // DEV: Grabbed from jQuery
2315 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
2316 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
2317 prop.replace(/-(\w)/gi, function(word, letter) {
2318 return letter.toUpperCase();
2319 })
2320 ]
2321 );
2322 };
2323 module.exports = computedStyle;
2324 }
2325 });
2326
2327 // node_modules/line-height/lib/line-height.js
2328 var require_line_height = __commonJS({
2329 "node_modules/line-height/lib/line-height.js"(exports, module) {
2330 var computedStyle = require_computedStyle_commonjs();
2331 function lineHeight(node) {
2332 var lnHeightStr = computedStyle(node, "line-height");
2333 var lnHeight = parseFloat(lnHeightStr, 10);
2334 if (lnHeightStr === lnHeight + "") {
2335 var _lnHeightStyle = node.style.lineHeight;
2336 node.style.lineHeight = lnHeightStr + "em";
2337 lnHeightStr = computedStyle(node, "line-height");
2338 lnHeight = parseFloat(lnHeightStr, 10);
2339 if (_lnHeightStyle) {
2340 node.style.lineHeight = _lnHeightStyle;
2341 } else {
2342 delete node.style.lineHeight;
2343 }
2344 }
2345 if (lnHeightStr.indexOf("pt") !== -1) {
2346 lnHeight *= 4;
2347 lnHeight /= 3;
2348 } else if (lnHeightStr.indexOf("mm") !== -1) {
2349 lnHeight *= 96;
2350 lnHeight /= 25.4;
2351 } else if (lnHeightStr.indexOf("cm") !== -1) {
2352 lnHeight *= 96;
2353 lnHeight /= 2.54;
2354 } else if (lnHeightStr.indexOf("in") !== -1) {
2355 lnHeight *= 96;
2356 } else if (lnHeightStr.indexOf("pc") !== -1) {
2357 lnHeight *= 16;
2358 }
2359 lnHeight = Math.round(lnHeight);
2360 if (lnHeightStr === "normal") {
2361 var nodeName = node.nodeName;
2362 var _node = document.createElement(nodeName);
2363 _node.innerHTML = " ";
2364 if (nodeName.toUpperCase() === "TEXTAREA") {
2365 _node.setAttribute("rows", "1");
2366 }
2367 var fontSizeStr = computedStyle(node, "font-size");
2368 _node.style.fontSize = fontSizeStr;
2369 _node.style.padding = "0px";
2370 _node.style.border = "0px";
2371 var body = document.body;
2372 body.appendChild(_node);
2373 var height = _node.offsetHeight;
2374 lnHeight = height;
2375 body.removeChild(_node);
2376 }
2377 return lnHeight;
2378 }
2379 module.exports = lineHeight;
2380 }
2381 });
2382
2383 // node_modules/react-autosize-textarea/lib/TextareaAutosize.js
2384 var require_TextareaAutosize = __commonJS({
2385 "node_modules/react-autosize-textarea/lib/TextareaAutosize.js"(exports) {
2386 "use strict";
2387 var __extends = exports && exports.__extends || (function() {
2388 var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) {
2389 d3.__proto__ = b3;
2390 } || function(d3, b3) {
2391 for (var p4 in b3) if (b3.hasOwnProperty(p4)) d3[p4] = b3[p4];
2392 };
2393 return function(d3, b3) {
2394 extendStatics(d3, b3);
2395 function __268() {
2396 this.constructor = d3;
2397 }
2398 d3.prototype = b3 === null ? Object.create(b3) : (__268.prototype = b3.prototype, new __268());
2399 };
2400 })();
2401 var __assign2 = exports && exports.__assign || Object.assign || function(t4) {
2402 for (var s3, i3 = 1, n3 = arguments.length; i3 < n3; i3++) {
2403 s3 = arguments[i3];
2404 for (var p4 in s3) if (Object.prototype.hasOwnProperty.call(s3, p4))
2405 t4[p4] = s3[p4];
2406 }
2407 return t4;
2408 };
2409 var __rest = exports && exports.__rest || function(s3, e3) {
2410 var t4 = {};
2411 for (var p4 in s3) if (Object.prototype.hasOwnProperty.call(s3, p4) && e3.indexOf(p4) < 0)
2412 t4[p4] = s3[p4];
2413 if (s3 != null && typeof Object.getOwnPropertySymbols === "function") {
2414 for (var i3 = 0, p4 = Object.getOwnPropertySymbols(s3); i3 < p4.length; i3++) if (e3.indexOf(p4[i3]) < 0)
2415 t4[p4[i3]] = s3[p4[i3]];
2416 }
2417 return t4;
2418 };
2419 exports.__esModule = true;
2420 var React8 = require_react();
2421 var PropTypes = require_prop_types();
2422 var autosize = require_autosize();
2423 var _getLineHeight = require_line_height();
2424 var getLineHeight = _getLineHeight;
2425 var RESIZED = "autosize:resized";
2426 var TextareaAutosizeClass = (
2427 /** @class */
2428 (function(_super) {
2429 __extends(TextareaAutosizeClass2, _super);
2430 function TextareaAutosizeClass2() {
2431 var _this = _super !== null && _super.apply(this, arguments) || this;
2432 _this.state = {
2433 lineHeight: null
2434 };
2435 _this.textarea = null;
2436 _this.onResize = function(e3) {
2437 if (_this.props.onResize) {
2438 _this.props.onResize(e3);
2439 }
2440 };
2441 _this.updateLineHeight = function() {
2442 if (_this.textarea) {
2443 _this.setState({
2444 lineHeight: getLineHeight(_this.textarea)
2445 });
2446 }
2447 };
2448 _this.onChange = function(e3) {
2449 var onChange = _this.props.onChange;
2450 _this.currentValue = e3.currentTarget.value;
2451 onChange && onChange(e3);
2452 };
2453 return _this;
2454 }
2455 TextareaAutosizeClass2.prototype.componentDidMount = function() {
2456 var _this = this;
2457 var _a = this.props, maxRows = _a.maxRows, async = _a.async;
2458 if (typeof maxRows === "number") {
2459 this.updateLineHeight();
2460 }
2461 if (typeof maxRows === "number" || async) {
2462 setTimeout(function() {
2463 return _this.textarea && autosize(_this.textarea);
2464 });
2465 } else {
2466 this.textarea && autosize(this.textarea);
2467 }
2468 if (this.textarea) {
2469 this.textarea.addEventListener(RESIZED, this.onResize);
2470 }
2471 };
2472 TextareaAutosizeClass2.prototype.componentWillUnmount = function() {
2473 if (this.textarea) {
2474 this.textarea.removeEventListener(RESIZED, this.onResize);
2475 autosize.destroy(this.textarea);
2476 }
2477 };
2478 TextareaAutosizeClass2.prototype.render = function() {
2479 var _this = this;
2480 var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight;
2481 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
2482 return React8.createElement("textarea", __assign2({}, props, { onChange: this.onChange, style: maxHeight ? __assign2({}, style, { maxHeight }) : style, ref: function(element) {
2483 _this.textarea = element;
2484 if (typeof _this.props.innerRef === "function") {
2485 _this.props.innerRef(element);
2486 } else if (_this.props.innerRef) {
2487 _this.props.innerRef.current = element;
2488 }
2489 } }), children);
2490 };
2491 TextareaAutosizeClass2.prototype.componentDidUpdate = function() {
2492 this.textarea && autosize.update(this.textarea);
2493 };
2494 TextareaAutosizeClass2.defaultProps = {
2495 rows: 1,
2496 async: false
2497 };
2498 TextareaAutosizeClass2.propTypes = {
2499 rows: PropTypes.number,
2500 maxRows: PropTypes.number,
2501 onResize: PropTypes.func,
2502 innerRef: PropTypes.any,
2503 async: PropTypes.bool
2504 };
2505 return TextareaAutosizeClass2;
2506 })(React8.Component)
2507 );
2508 exports.TextareaAutosize = React8.forwardRef(function(props, ref) {
2509 return React8.createElement(TextareaAutosizeClass, __assign2({}, props, { innerRef: ref }));
2510 });
2511 }
2512 });
2513
2514 // node_modules/react-autosize-textarea/lib/index.js
2515 var require_lib = __commonJS({
2516 "node_modules/react-autosize-textarea/lib/index.js"(exports, module) {
2517 "use strict";
2518 var TextareaAutosize_1 = require_TextareaAutosize();
2519 module.exports = TextareaAutosize_1.TextareaAutosize;
2520 }
2521 });
2522
2523 // package-external:@wordpress/wordcount
2524 var require_wordcount = __commonJS({
2525 "package-external:@wordpress/wordcount"(exports, module) {
2526 module.exports = window.wp.wordcount;
2527 }
2528 });
2529
2530 // package-external:@wordpress/server-side-render
2531 var require_server_side_render = __commonJS({
2532 "package-external:@wordpress/server-side-render"(exports, module) {
2533 module.exports = window.wp.serverSideRender;
2534 }
2535 });
2536
2537 // packages/editor/build-module/index.mjs
2538 var index_exports = {};
2539 __export(index_exports, {
2540 AlignmentToolbar: () => AlignmentToolbar,
2541 Autocomplete: () => Autocomplete,
2542 AutosaveMonitor: () => autosave_monitor_default,
2543 BlockAlignmentToolbar: () => BlockAlignmentToolbar,
2544 BlockControls: () => BlockControls,
2545 BlockEdit: () => BlockEdit,
2546 BlockEditorKeyboardShortcuts: () => BlockEditorKeyboardShortcuts2,
2547 BlockFormatControls: () => BlockFormatControls,
2548 BlockIcon: () => BlockIcon3,
2549 BlockInspector: () => BlockInspector,
2550 BlockList: () => BlockList4,
2551 BlockMover: () => BlockMover,
2552 BlockNavigationDropdown: () => BlockNavigationDropdown,
2553 BlockSelectionClearer: () => BlockSelectionClearer,
2554 BlockSettingsMenu: () => BlockSettingsMenu,
2555 BlockTitle: () => BlockTitle,
2556 BlockToolbar: () => BlockToolbar,
2557 CharacterCount: () => CharacterCount,
2558 ColorPalette: () => ColorPalette2,
2559 ContrastChecker: () => ContrastChecker,
2560 CopyHandler: () => CopyHandler,
2561 DefaultBlockAppender: () => DefaultBlockAppender,
2562 DocumentBar: () => DocumentBar,
2563 DocumentOutline: () => DocumentOutline,
2564 DocumentOutlineCheck: () => DocumentOutlineCheck,
2565 EditorHistoryRedo: () => redo_default2,
2566 EditorHistoryUndo: () => undo_default2,
2567 EditorKeyboardShortcuts: () => EditorKeyboardShortcuts,
2568 EditorKeyboardShortcutsRegister: () => register_shortcuts_default,
2569 EditorNotices: () => editor_notices_default,
2570 EditorProvider: () => provider_default,
2571 EditorSnackbars: () => EditorSnackbars,
2572 EntitiesSavedStates: () => EntitiesSavedStates,
2573 ErrorBoundary: () => error_boundary_default,
2574 FontSizePicker: () => FontSizePicker,
2575 InnerBlocks: () => InnerBlocks,
2576 Inserter: () => Inserter,
2577 InspectorAdvancedControls: () => InspectorAdvancedControls,
2578 InspectorControls: () => InspectorControls,
2579 LocalAutosaveMonitor: () => local_autosave_monitor_default,
2580 MediaPlaceholder: () => MediaPlaceholder,
2581 MediaUpload: () => MediaUpload3,
2582 MediaUploadCheck: () => MediaUploadCheck2,
2583 MultiSelectScrollIntoView: () => MultiSelectScrollIntoView,
2584 NavigableToolbar: () => NavigableToolbar,
2585 ObserveTyping: () => ObserveTyping,
2586 PageAttributesCheck: () => check_default2,
2587 PageAttributesOrder: () => PageAttributesOrderWithChecks,
2588 PageAttributesPanel: () => PageAttributesPanel,
2589 PageAttributesParent: () => parent_default2,
2590 PageTemplate: () => classic_theme_default,
2591 PanelColorSettings: () => PanelColorSettings,
2592 PlainText: () => PlainText,
2593 PluginBlockSettingsMenuItem: () => plugin_block_settings_menu_item_default,
2594 PluginDocumentSettingPanel: () => plugin_document_setting_panel_default,
2595 PluginMoreMenuItem: () => PluginMoreMenuItem,
2596 PluginPostPublishPanel: () => plugin_post_publish_panel_default,
2597 PluginPostStatusInfo: () => plugin_post_status_info_default,
2598 PluginPrePublishPanel: () => plugin_pre_publish_panel_default,
2599 PluginPreviewMenuItem: () => PluginPreviewMenuItem,
2600 PluginSidebar: () => PluginSidebar,
2601 PluginSidebarMoreMenuItem: () => PluginSidebarMoreMenuItem,
2602 PostAuthor: () => post_author_default,
2603 PostAuthorCheck: () => PostAuthorCheck,
2604 PostAuthorPanel: () => panel_default,
2605 PostComments: () => post_comments_default,
2606 PostDiscussionPanel: () => PostDiscussionPanel,
2607 PostExcerpt: () => PostExcerpt,
2608 PostExcerptCheck: () => check_default3,
2609 PostExcerptPanel: () => PostExcerptPanel,
2610 PostFeaturedImage: () => post_featured_image_default,
2611 PostFeaturedImageCheck: () => check_default4,
2612 PostFeaturedImagePanel: () => PostFeaturedImagePanel,
2613 PostFormat: () => PostFormat,
2614 PostFormatCheck: () => PostFormatCheck,
2615 PostLastRevision: () => post_last_revision_default,
2616 PostLastRevisionCheck: () => check_default5,
2617 PostLastRevisionPanel: () => panel_default2,
2618 PostLockedModal: () => post_locked_modal_default,
2619 PostPendingStatus: () => post_pending_status_default,
2620 PostPendingStatusCheck: () => check_default6,
2621 PostPingbacks: () => post_pingbacks_default,
2622 PostPreviewButton: () => PostPreviewButton,
2623 PostPublishButton: () => post_publish_button_default,
2624 PostPublishButtonLabel: () => PublishButtonLabel,
2625 PostPublishPanel: () => post_publish_panel_default,
2626 PostSavedState: () => PostSavedState,
2627 PostSchedule: () => PostSchedule,
2628 PostScheduleCheck: () => PostScheduleCheck,
2629 PostScheduleLabel: () => PostScheduleLabel,
2630 PostSchedulePanel: () => PostSchedulePanel,
2631 PostSticky: () => PostSticky,
2632 PostStickyCheck: () => PostStickyCheck,
2633 PostSwitchToDraftButton: () => PostSwitchToDraftButton,
2634 PostSyncStatus: () => PostSyncStatus,
2635 PostTaxonomies: () => post_taxonomies_default,
2636 PostTaxonomiesCheck: () => PostTaxonomiesCheck,
2637 PostTaxonomiesFlatTermSelector: () => FlatTermSelector,
2638 PostTaxonomiesHierarchicalTermSelector: () => HierarchicalTermSelector,
2639 PostTaxonomiesPanel: () => PostTaxonomies2,
2640 PostTemplatePanel: () => PostTemplatePanel,
2641 PostTextEditor: () => PostTextEditor,
2642 PostTitle: () => post_title_default,
2643 PostTitleRaw: () => post_title_raw_default,
2644 PostTrash: () => PostTrash,
2645 PostTrashCheck: () => PostTrashCheck,
2646 PostTypeSupportCheck: () => post_type_support_check_default,
2647 PostURL: () => PostURL,
2648 PostURLCheck: () => PostURLCheck,
2649 PostURLLabel: () => PostURLLabel,
2650 PostURLPanel: () => PostURLPanel,
2651 PostVisibility: () => PostVisibility,
2652 PostVisibilityCheck: () => PostVisibilityCheck,
2653 PostVisibilityLabel: () => PostVisibilityLabel,
2654 RichText: () => RichText,
2655 RichTextShortcut: () => RichTextShortcut,
2656 RichTextToolbarButton: () => RichTextToolbarButton,
2657 ServerSideRender: () => import_server_side_render.default,
2658 SkipToSelectedBlock: () => SkipToSelectedBlock,
2659 TableOfContents: () => table_of_contents_default,
2660 TextEditorGlobalKeyboardShortcuts: () => TextEditorGlobalKeyboardShortcuts,
2661 ThemeSupportCheck: () => ThemeSupportCheck,
2662 TimeToRead: () => TimeToRead,
2663 URLInput: () => URLInput,
2664 URLInputButton: () => URLInputButton,
2665 URLPopover: () => URLPopover,
2666 UnsavedChangesWarning: () => UnsavedChangesWarning,
2667 VisualEditorGlobalKeyboardShortcuts: () => VisualEditorGlobalKeyboardShortcuts,
2668 Warning: () => Warning,
2669 WordCount: () => WordCount,
2670 WritingFlow: () => WritingFlow,
2671 __unstableRichTextInputEvent: () => __unstableRichTextInputEvent,
2672 cleanForSlug: () => cleanForSlug2,
2673 createCustomColorsHOC: () => createCustomColorsHOC,
2674 getColorClassName: () => getColorClassName2,
2675 getColorObjectByAttributeValues: () => getColorObjectByAttributeValues,
2676 getColorObjectByColorValue: () => getColorObjectByColorValue,
2677 getFontSize: () => getFontSize,
2678 getFontSizeClass: () => getFontSizeClass,
2679 getTemplatePartIcon: () => getTemplatePartIcon,
2680 mediaUpload: () => mediaUpload,
2681 privateApis: () => privateApis18,
2682 registerEntityAction: () => registerEntityAction2,
2683 registerEntityField: () => registerEntityField2,
2684 store: () => store,
2685 storeConfig: () => storeConfig,
2686 transformStyles: () => import_block_editor105.transformStyles,
2687 unregisterEntityAction: () => unregisterEntityAction2,
2688 unregisterEntityField: () => unregisterEntityField2,
2689 useEntitiesSavedStatesIsDirty: () => useIsDirty,
2690 usePostScheduleLabel: () => usePostScheduleLabel,
2691 usePostURLLabel: () => usePostURLLabel,
2692 usePostVisibilityLabel: () => usePostVisibilityLabel,
2693 userAutocompleter: () => user_default,
2694 withColorContext: () => withColorContext,
2695 withColors: () => withColors,
2696 withFontSizes: () => withFontSizes
2697 });
2698
2699 // packages/editor/build-module/hooks/custom-sources-backwards-compatibility.mjs
2700 var import_data73 = __toESM(require_data(), 1);
2701 var import_core_data54 = __toESM(require_core_data(), 1);
2702 var import_element82 = __toESM(require_element(), 1);
2703 var import_compose16 = __toESM(require_compose(), 1);
2704 var import_hooks39 = __toESM(require_hooks(), 1);
2705
2706 // packages/editor/build-module/store/index.mjs
2707 var import_data72 = __toESM(require_data(), 1);
2708
2709 // packages/editor/build-module/store/reducer.mjs
2710 var import_data2 = __toESM(require_data(), 1);
2711
2712 // packages/editor/build-module/store/defaults.mjs
2713 var import_block_editor = __toESM(require_block_editor(), 1);
2714 var EDITOR_SETTINGS_DEFAULTS = {
2715 ...import_block_editor.SETTINGS_DEFAULTS,
2716 richEditingEnabled: true,
2717 codeEditingEnabled: true,
2718 fontLibraryEnabled: true,
2719 enableCustomFields: void 0,
2720 defaultRenderingMode: "post-only"
2721 };
2722
2723 // packages/editor/build-module/dataviews/store/reducer.mjs
2724 var import_data = __toESM(require_data(), 1);
2725 function isReady(state = {}, action) {
2726 switch (action.type) {
2727 case "SET_IS_READY":
2728 return {
2729 ...state,
2730 [action.kind]: {
2731 ...state[action.kind],
2732 [action.name]: true
2733 }
2734 };
2735 }
2736 return state;
2737 }
2738 function actions(state = {}, action) {
2739 switch (action.type) {
2740 case "REGISTER_ENTITY_ACTION":
2741 return {
2742 ...state,
2743 [action.kind]: {
2744 ...state[action.kind],
2745 [action.name]: [
2746 ...(state[action.kind]?.[action.name] ?? []).filter(
2747 (_action) => _action.id !== action.config.id
2748 ),
2749 action.config
2750 ]
2751 }
2752 };
2753 case "UNREGISTER_ENTITY_ACTION": {
2754 return {
2755 ...state,
2756 [action.kind]: {
2757 ...state[action.kind],
2758 [action.name]: (state[action.kind]?.[action.name] ?? []).filter((_action) => _action.id !== action.actionId)
2759 }
2760 };
2761 }
2762 }
2763 return state;
2764 }
2765 function fields(state = {}, action) {
2766 switch (action.type) {
2767 case "REGISTER_ENTITY_FIELD":
2768 return {
2769 ...state,
2770 [action.kind]: {
2771 ...state[action.kind],
2772 [action.name]: [
2773 ...(state[action.kind]?.[action.name] ?? []).filter(
2774 (_field) => _field.id !== action.config.id
2775 ),
2776 action.config
2777 ]
2778 }
2779 };
2780 case "UNREGISTER_ENTITY_FIELD":
2781 return {
2782 ...state,
2783 [action.kind]: {
2784 ...state[action.kind],
2785 [action.name]: (state[action.kind]?.[action.name] ?? []).filter((_field) => _field.id !== action.fieldId)
2786 }
2787 };
2788 }
2789 return state;
2790 }
2791 var reducer_default = (0, import_data.combineReducers)({
2792 actions,
2793 fields,
2794 isReady
2795 });
2796
2797 // packages/editor/build-module/store/reducer.mjs
2798 function getPostRawValue(value) {
2799 if (value && "object" === typeof value && "raw" in value) {
2800 return value.raw;
2801 }
2802 return value;
2803 }
2804 function postId(state = null, action) {
2805 switch (action.type) {
2806 case "SET_EDITED_POST":
2807 return action.postId;
2808 }
2809 return state;
2810 }
2811 function templateId(state = null, action) {
2812 switch (action.type) {
2813 case "SET_CURRENT_TEMPLATE_ID":
2814 return action.id;
2815 }
2816 return state;
2817 }
2818 function postType(state = null, action) {
2819 switch (action.type) {
2820 case "SET_EDITED_POST":
2821 return action.postType;
2822 }
2823 return state;
2824 }
2825 function template(state = { isValid: true }, action) {
2826 switch (action.type) {
2827 case "SET_TEMPLATE_VALIDITY":
2828 return {
2829 ...state,
2830 isValid: action.isValid
2831 };
2832 }
2833 return state;
2834 }
2835 function saving(state = {}, action) {
2836 switch (action.type) {
2837 case "REQUEST_POST_UPDATE_START":
2838 case "REQUEST_POST_UPDATE_FINISH":
2839 return {
2840 pending: action.type === "REQUEST_POST_UPDATE_START",
2841 options: action.options || {}
2842 };
2843 }
2844 return state;
2845 }
2846 function deleting(state = {}, action) {
2847 switch (action.type) {
2848 case "REQUEST_POST_DELETE_START":
2849 case "REQUEST_POST_DELETE_FINISH":
2850 return {
2851 pending: action.type === "REQUEST_POST_DELETE_START"
2852 };
2853 }
2854 return state;
2855 }
2856 function postLock(state = { isLocked: false }, action) {
2857 switch (action.type) {
2858 case "UPDATE_POST_LOCK":
2859 return action.lock;
2860 }
2861 return state;
2862 }
2863 function postSavingLock(state = {}, action) {
2864 switch (action.type) {
2865 case "LOCK_POST_SAVING":
2866 return { ...state, [action.lockName]: true };
2867 case "UNLOCK_POST_SAVING": {
2868 const { [action.lockName]: removedLockName, ...restState } = state;
2869 return restState;
2870 }
2871 }
2872 return state;
2873 }
2874 function postAutosavingLock(state = {}, action) {
2875 switch (action.type) {
2876 case "LOCK_POST_AUTOSAVING":
2877 return { ...state, [action.lockName]: true };
2878 case "UNLOCK_POST_AUTOSAVING": {
2879 const { [action.lockName]: removedLockName, ...restState } = state;
2880 return restState;
2881 }
2882 }
2883 return state;
2884 }
2885 function editorSettings(state = EDITOR_SETTINGS_DEFAULTS, action) {
2886 switch (action.type) {
2887 case "UPDATE_EDITOR_SETTINGS":
2888 return {
2889 ...state,
2890 ...action.settings
2891 };
2892 }
2893 return state;
2894 }
2895 function renderingMode(state = "post-only", action) {
2896 switch (action.type) {
2897 case "SET_RENDERING_MODE":
2898 return action.mode;
2899 }
2900 return state;
2901 }
2902 function deviceType(state = "Desktop", action) {
2903 switch (action.type) {
2904 case "SET_DEVICE_TYPE":
2905 return action.deviceType;
2906 }
2907 return state;
2908 }
2909 function removedPanels(state = [], action) {
2910 switch (action.type) {
2911 case "REMOVE_PANEL":
2912 if (!state.includes(action.panelName)) {
2913 return [...state, action.panelName];
2914 }
2915 }
2916 return state;
2917 }
2918 function blockInserterPanel(state = false, action) {
2919 switch (action.type) {
2920 case "SET_IS_LIST_VIEW_OPENED":
2921 return action.isOpen ? false : state;
2922 case "SET_IS_INSERTER_OPENED":
2923 return action.value;
2924 }
2925 return state;
2926 }
2927 function listViewPanel(state = false, action) {
2928 switch (action.type) {
2929 case "SET_IS_INSERTER_OPENED":
2930 return action.value ? false : state;
2931 case "SET_IS_LIST_VIEW_OPENED":
2932 return action.isOpen;
2933 }
2934 return state;
2935 }
2936 function listViewToggleRef(state = { current: null }) {
2937 return state;
2938 }
2939 function inserterSidebarToggleRef(state = { current: null }) {
2940 return state;
2941 }
2942 function publishSidebarActive(state = false, action) {
2943 switch (action.type) {
2944 case "OPEN_PUBLISH_SIDEBAR":
2945 return true;
2946 case "CLOSE_PUBLISH_SIDEBAR":
2947 return false;
2948 case "TOGGLE_PUBLISH_SIDEBAR":
2949 return !state;
2950 }
2951 return state;
2952 }
2953 function stylesPath(state = "/", action) {
2954 switch (action.type) {
2955 case "SET_STYLES_PATH":
2956 return action.path;
2957 case "RESET_STYLES_NAVIGATION":
2958 return "/";
2959 }
2960 return state;
2961 }
2962 function showStylebook(state = false, action) {
2963 switch (action.type) {
2964 case "SET_SHOW_STYLEBOOK":
2965 return action.show;
2966 case "RESET_STYLES_NAVIGATION":
2967 return false;
2968 }
2969 return state;
2970 }
2971 function canvasMinHeight(state = 0, action) {
2972 switch (action.type) {
2973 case "SET_CANVAS_MIN_HEIGHT":
2974 return action.minHeight;
2975 }
2976 return state;
2977 }
2978 function revisionId(state = null, action) {
2979 switch (action.type) {
2980 case "SET_CURRENT_REVISION_ID":
2981 return action.revisionId;
2982 }
2983 return state;
2984 }
2985 function revisionPage(state = 1, action) {
2986 switch (action.type) {
2987 case "SET_REVISION_PAGE":
2988 return action.page;
2989 case "SET_CURRENT_REVISION_ID":
2990 if (!action.revisionId) {
2991 return 1;
2992 }
2993 return state;
2994 }
2995 return state;
2996 }
2997 function showRevisionDiff(state = true, action) {
2998 switch (action.type) {
2999 case "SET_SHOW_REVISION_DIFF":
3000 return action.showDiff;
3001 case "SET_CURRENT_REVISION_ID":
3002 return !action.revisionId ? true : state;
3003 }
3004 return state;
3005 }
3006 function selectedNote(state = {}, action) {
3007 switch (action.type) {
3008 case "SELECT_NOTE":
3009 return { noteId: action.noteId, options: action.options };
3010 }
3011 return state;
3012 }
3013 var reducer_default2 = (0, import_data2.combineReducers)({
3014 postId,
3015 postType,
3016 templateId,
3017 saving,
3018 deleting,
3019 postLock,
3020 template,
3021 postSavingLock,
3022 editorSettings,
3023 postAutosavingLock,
3024 renderingMode,
3025 deviceType,
3026 removedPanels,
3027 blockInserterPanel,
3028 inserterSidebarToggleRef,
3029 listViewPanel,
3030 listViewToggleRef,
3031 publishSidebarActive,
3032 stylesPath,
3033 showStylebook,
3034 canvasMinHeight,
3035 revisionId,
3036 revisionPage,
3037 showRevisionDiff,
3038 selectedNote,
3039 dataviews: reducer_default
3040 });
3041
3042 // packages/editor/build-module/store/selectors.mjs
3043 var selectors_exports = {};
3044 __export(selectors_exports, {
3045 __experimentalGetDefaultTemplatePartAreas: () => __experimentalGetDefaultTemplatePartAreas,
3046 __experimentalGetDefaultTemplateType: () => __experimentalGetDefaultTemplateType,
3047 __experimentalGetDefaultTemplateTypes: () => __experimentalGetDefaultTemplateTypes,
3048 __experimentalGetTemplateInfo: () => __experimentalGetTemplateInfo,
3049 __unstableIsEditorReady: () => __unstableIsEditorReady,
3050 canInsertBlockType: () => canInsertBlockType,
3051 canUserUseUnfilteredHTML: () => canUserUseUnfilteredHTML,
3052 didPostSaveRequestFail: () => didPostSaveRequestFail,
3053 didPostSaveRequestSucceed: () => didPostSaveRequestSucceed,
3054 getActivePostLock: () => getActivePostLock,
3055 getAdjacentBlockClientId: () => getAdjacentBlockClientId,
3056 getAutosaveAttribute: () => getAutosaveAttribute,
3057 getBlock: () => getBlock,
3058 getBlockAttributes: () => getBlockAttributes,
3059 getBlockCount: () => getBlockCount,
3060 getBlockHierarchyRootClientId: () => getBlockHierarchyRootClientId,
3061 getBlockIndex: () => getBlockIndex,
3062 getBlockInsertionPoint: () => getBlockInsertionPoint,
3063 getBlockListSettings: () => getBlockListSettings,
3064 getBlockMode: () => getBlockMode,
3065 getBlockName: () => getBlockName,
3066 getBlockOrder: () => getBlockOrder,
3067 getBlockRootClientId: () => getBlockRootClientId,
3068 getBlockSelectionEnd: () => getBlockSelectionEnd,
3069 getBlockSelectionStart: () => getBlockSelectionStart,
3070 getBlocks: () => getBlocks,
3071 getBlocksByClientId: () => getBlocksByClientId,
3072 getClientIdsOfDescendants: () => getClientIdsOfDescendants,
3073 getClientIdsWithDescendants: () => getClientIdsWithDescendants,
3074 getCurrentPost: () => getCurrentPost,
3075 getCurrentPostAttribute: () => getCurrentPostAttribute,
3076 getCurrentPostId: () => getCurrentPostId,
3077 getCurrentPostLastRevisionId: () => getCurrentPostLastRevisionId,
3078 getCurrentPostRevisionsCount: () => getCurrentPostRevisionsCount,
3079 getCurrentPostType: () => getCurrentPostType,
3080 getCurrentTemplateId: () => getCurrentTemplateId,
3081 getDeviceType: () => getDeviceType,
3082 getEditedPostAttribute: () => getEditedPostAttribute,
3083 getEditedPostContent: () => getEditedPostContent,
3084 getEditedPostPreviewLink: () => getEditedPostPreviewLink,
3085 getEditedPostSlug: () => getEditedPostSlug,
3086 getEditedPostVisibility: () => getEditedPostVisibility,
3087 getEditorBlocks: () => getEditorBlocks,
3088 getEditorMode: () => getEditorMode,
3089 getEditorSelection: () => getEditorSelection,
3090 getEditorSelectionEnd: () => getEditorSelectionEnd,
3091 getEditorSelectionStart: () => getEditorSelectionStart,
3092 getEditorSettings: () => getEditorSettings,
3093 getFirstMultiSelectedBlockClientId: () => getFirstMultiSelectedBlockClientId,
3094 getGlobalBlockCount: () => getGlobalBlockCount,
3095 getInserterItems: () => getInserterItems,
3096 getLastMultiSelectedBlockClientId: () => getLastMultiSelectedBlockClientId,
3097 getMultiSelectedBlockClientIds: () => getMultiSelectedBlockClientIds,
3098 getMultiSelectedBlocks: () => getMultiSelectedBlocks,
3099 getMultiSelectedBlocksEndClientId: () => getMultiSelectedBlocksEndClientId,
3100 getMultiSelectedBlocksStartClientId: () => getMultiSelectedBlocksStartClientId,
3101 getNextBlockClientId: () => getNextBlockClientId,
3102 getPermalink: () => getPermalink,
3103 getPermalinkParts: () => getPermalinkParts,
3104 getPostEdits: () => getPostEdits,
3105 getPostLockUser: () => getPostLockUser,
3106 getPostTypeLabel: () => getPostTypeLabel,
3107 getPreviousBlockClientId: () => getPreviousBlockClientId,
3108 getRenderingMode: () => getRenderingMode,
3109 getSelectedBlock: () => getSelectedBlock,
3110 getSelectedBlockClientId: () => getSelectedBlockClientId,
3111 getSelectedBlockCount: () => getSelectedBlockCount,
3112 getSelectedBlocksInitialCaretPosition: () => getSelectedBlocksInitialCaretPosition,
3113 getStateBeforeOptimisticTransaction: () => getStateBeforeOptimisticTransaction,
3114 getSuggestedPostFormat: () => getSuggestedPostFormat,
3115 getTemplate: () => getTemplate,
3116 getTemplateLock: () => getTemplateLock,
3117 hasChangedContent: () => hasChangedContent,
3118 hasEditorRedo: () => hasEditorRedo,
3119 hasEditorUndo: () => hasEditorUndo,
3120 hasInserterItems: () => hasInserterItems,
3121 hasMultiSelection: () => hasMultiSelection,
3122 hasNonPostEntityChanges: () => hasNonPostEntityChanges,
3123 hasSelectedBlock: () => hasSelectedBlock,
3124 hasSelectedInnerBlock: () => hasSelectedInnerBlock,
3125 inSomeHistory: () => inSomeHistory,
3126 isAncestorMultiSelected: () => isAncestorMultiSelected,
3127 isAutosavingPost: () => isAutosavingPost,
3128 isBlockInsertionPointVisible: () => isBlockInsertionPointVisible,
3129 isBlockMultiSelected: () => isBlockMultiSelected,
3130 isBlockSelected: () => isBlockSelected,
3131 isBlockValid: () => isBlockValid,
3132 isBlockWithinSelection: () => isBlockWithinSelection,
3133 isCaretWithinFormattedText: () => isCaretWithinFormattedText,
3134 isCleanNewPost: () => isCleanNewPost,
3135 isCurrentPostPending: () => isCurrentPostPending,
3136 isCurrentPostPublished: () => isCurrentPostPublished,
3137 isCurrentPostScheduled: () => isCurrentPostScheduled,
3138 isDeletingPost: () => isDeletingPost,
3139 isEditedPostAutosaveable: () => isEditedPostAutosaveable,
3140 isEditedPostBeingScheduled: () => isEditedPostBeingScheduled,
3141 isEditedPostDateFloating: () => isEditedPostDateFloating,
3142 isEditedPostDirty: () => isEditedPostDirty,
3143 isEditedPostEmpty: () => isEditedPostEmpty,
3144 isEditedPostNew: () => isEditedPostNew,
3145 isEditedPostPublishable: () => isEditedPostPublishable,
3146 isEditedPostSaveable: () => isEditedPostSaveable,
3147 isEditorPanelEnabled: () => isEditorPanelEnabled,
3148 isEditorPanelOpened: () => isEditorPanelOpened,
3149 isEditorPanelRemoved: () => isEditorPanelRemoved,
3150 isFirstMultiSelectedBlock: () => isFirstMultiSelectedBlock,
3151 isInserterOpened: () => isInserterOpened,
3152 isListViewOpened: () => isListViewOpened,
3153 isMultiSelecting: () => isMultiSelecting,
3154 isPermalinkEditable: () => isPermalinkEditable,
3155 isPostAutosavingLocked: () => isPostAutosavingLocked,
3156 isPostLockTakeover: () => isPostLockTakeover,
3157 isPostLocked: () => isPostLocked,
3158 isPostSavingLocked: () => isPostSavingLocked,
3159 isPreviewingPost: () => isPreviewingPost,
3160 isPublishSidebarEnabled: () => isPublishSidebarEnabled,
3161 isPublishSidebarOpened: () => isPublishSidebarOpened,
3162 isPublishingPost: () => isPublishingPost,
3163 isSavingNonPostEntityChanges: () => isSavingNonPostEntityChanges,
3164 isSavingPost: () => isSavingPost,
3165 isSelectionEnabled: () => isSelectionEnabled,
3166 isTyping: () => isTyping,
3167 isValidTemplate: () => isValidTemplate
3168 });
3169 var import_blocks = __toESM(require_blocks(), 1);
3170 var import_date = __toESM(require_date(), 1);
3171 var import_url = __toESM(require_url(), 1);
3172 var import_data3 = __toESM(require_data(), 1);
3173 var import_deprecated = __toESM(require_deprecated(), 1);
3174 var import_element2 = __toESM(require_element(), 1);
3175 var import_block_editor2 = __toESM(require_block_editor(), 1);
3176 var import_core_data = __toESM(require_core_data(), 1);
3177 var import_preferences = __toESM(require_preferences(), 1);
3178
3179 // packages/editor/build-module/store/constants.mjs
3180 var EDIT_MERGE_PROPERTIES = /* @__PURE__ */ new Set(["meta"]);
3181 var STORE_NAME = "core/editor";
3182 var PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
3183 var ONE_MINUTE_IN_MS = 60 * 1e3;
3184 var AUTOSAVE_PROPERTIES = ["title", "excerpt", "content"];
3185 var TEMPLATE_POST_TYPE = "wp_template";
3186 var TEMPLATE_PART_POST_TYPE = "wp_template_part";
3187 var PATTERN_POST_TYPE = "wp_block";
3188 var NAVIGATION_POST_TYPE = "wp_navigation";
3189 var ATTACHMENT_POST_TYPE = "attachment";
3190 var TEMPLATE_ORIGINS = {
3191 custom: "custom",
3192 theme: "theme",
3193 plugin: "plugin"
3194 };
3195 var TEMPLATE_POST_TYPES = ["wp_template", "wp_template_part"];
3196 var GLOBAL_POST_TYPES = [
3197 ...TEMPLATE_POST_TYPES,
3198 "wp_block",
3199 "wp_navigation"
3200 ];
3201 var DESIGN_POST_TYPES = [
3202 TEMPLATE_POST_TYPE,
3203 TEMPLATE_PART_POST_TYPE,
3204 PATTERN_POST_TYPE,
3205 NAVIGATION_POST_TYPE
3206 ];
3207
3208 // packages/icons/build-module/icon/index.mjs
3209 var import_element = __toESM(require_element(), 1);
3210 var icon_default = (0, import_element.forwardRef)(
3211 ({ icon, size: size3 = 24, ...props }, ref) => {
3212 return (0, import_element.cloneElement)(icon, {
3213 width: size3,
3214 height: size3,
3215 ...props,
3216 ref
3217 });
3218 }
3219 );
3220
3221 // packages/icons/build-module/library/add-template.mjs
3222 var import_primitives = __toESM(require_primitives(), 1);
3223 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
3224 var add_template_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18.5 5.5V8H20V5.5H22.5V4H20V1.5H18.5V4H16V5.5H18.5ZM13.9624 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V10.0391H18.5V18C18.5 18.2761 18.2761 18.5 18 18.5H10L10 10.4917L16.4589 10.5139L16.4641 9.01389L5.5 8.97618V6C5.5 5.72386 5.72386 5.5 6 5.5H13.9624V4ZM5.5 10.4762V18C5.5 18.2761 5.72386 18.5 6 18.5H8.5L8.5 10.4865L5.5 10.4762Z" }) });
3225
3226 // packages/icons/build-module/library/archive.mjs
3227 var import_primitives2 = __toESM(require_primitives(), 1);
3228 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3229 var archive_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M11.934 7.406a1 1 0 0 0 .914.594H19a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5h5.764a.5.5 0 0 1 .447.276l.723 1.63Zm1.064-1.216a.5.5 0 0 0 .462.31H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h5.764a2 2 0 0 1 1.789 1.106l.445 1.084ZM8.5 10.5h7V12h-7v-1.5Zm7 3.5h-7v1.5h7V14Z" }) });
3230
3231 // packages/icons/build-module/library/audio.mjs
3232 var import_primitives3 = __toESM(require_primitives(), 1);
3233 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3234 var audio_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "M17.7 4.3c-1.2 0-2.8 0-3.8 1-.6.6-.9 1.5-.9 2.6V14c-.6-.6-1.5-1-2.5-1C8.6 13 7 14.6 7 16.5S8.6 20 10.5 20c1.5 0 2.8-1 3.3-2.3.5-.8.7-1.8.7-2.5V7.9c0-.7.2-1.2.5-1.6.6-.6 1.8-.6 2.8-.6h.3V4.3h-.4z" }) });
3235
3236 // packages/icons/build-module/library/background.mjs
3237 var import_primitives4 = __toESM(require_primitives(), 1);
3238 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3239 var background_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M11.53 4.47a.75.75 0 1 0-1.06 1.06l8 8a.75.75 0 1 0 1.06-1.06l-8-8Zm5 1a.75.75 0 1 0-1.06 1.06l2 2a.75.75 0 1 0 1.06-1.06l-2-2Zm-11.06 10a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06l-2-2a.75.75 0 0 1 0-1.06Zm.06-5a.75.75 0 0 0-1.06 1.06l8 8a.75.75 0 1 0 1.06-1.06l-8-8Zm-.06-3a.75.75 0 0 1 1.06 0l10 10a.75.75 0 1 1-1.06 1.06l-10-10a.75.75 0 0 1 0-1.06Zm3.06-2a.75.75 0 0 0-1.06 1.06l10 10a.75.75 0 1 0 1.06-1.06l-10-10Z" }) });
3240
3241 // packages/icons/build-module/library/backup.mjs
3242 var import_primitives5 = __toESM(require_primitives(), 1);
3243 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
3244 var backup_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M5.5 12h1.75l-2.5 3-2.5-3H4a8 8 0 113.134 6.35l.907-1.194A6.5 6.5 0 105.5 12zm9.53 1.97l-2.28-2.28V8.5a.75.75 0 00-1.5 0V12a.747.747 0 00.218.529l1.282-.84-1.28.842 2.5 2.5a.75.75 0 101.06-1.061z" }) });
3245
3246 // packages/icons/build-module/library/block-default.mjs
3247 var import_primitives6 = __toESM(require_primitives(), 1);
3248 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
3249 var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) });
3250
3251 // packages/icons/build-module/library/check.mjs
3252 var import_primitives7 = __toESM(require_primitives(), 1);
3253 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
3254 var check_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
3255
3256 // packages/icons/build-module/library/chevron-down.mjs
3257 var import_primitives8 = __toESM(require_primitives(), 1);
3258 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
3259 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
3260
3261 // packages/icons/build-module/library/chevron-left-small.mjs
3262 var import_primitives9 = __toESM(require_primitives(), 1);
3263 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
3264 var chevron_left_small_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z" }) });
3265
3266 // packages/icons/build-module/library/chevron-left.mjs
3267 var import_primitives10 = __toESM(require_primitives(), 1);
3268 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
3269 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });
3270
3271 // packages/icons/build-module/library/chevron-right-small.mjs
3272 var import_primitives11 = __toESM(require_primitives(), 1);
3273 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
3274 var chevron_right_small_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" }) });
3275
3276 // packages/icons/build-module/library/chevron-right.mjs
3277 var import_primitives12 = __toESM(require_primitives(), 1);
3278 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
3279 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });
3280
3281 // packages/icons/build-module/library/chevron-up.mjs
3282 var import_primitives13 = __toESM(require_primitives(), 1);
3283 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
3284 var chevron_up_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" }) });
3285
3286 // packages/icons/build-module/library/close-small.mjs
3287 var import_primitives14 = __toESM(require_primitives(), 1);
3288 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
3289 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) });
3290
3291 // packages/icons/build-module/library/close.mjs
3292 var import_primitives15 = __toESM(require_primitives(), 1);
3293 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
3294 var close_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { d: "m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z" }) });
3295
3296 // packages/icons/build-module/library/cloud-upload.mjs
3297 var import_primitives16 = __toESM(require_primitives(), 1);
3298 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
3299 var cloud_upload_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "M17.3 10.1C17.3 7.60001 15.2 5.70001 12.5 5.70001C10.3 5.70001 8.4 7.10001 7.9 9.00001H7.7C5.7 9.00001 4 10.7 4 12.8C4 14.9 5.7 16.6 7.7 16.6H9.5V15.2H7.7C6.5 15.2 5.5 14.1 5.5 12.9C5.5 11.7 6.5 10.5 7.7 10.5H9L9.3 9.40001C9.7 8.10001 11 7.20001 12.5 7.20001C14.3 7.20001 15.8 8.50001 15.8 10.1V11.4L17.1 11.6C17.9 11.7 18.5 12.5 18.5 13.4C18.5 14.4 17.7 15.2 16.8 15.2H14.5V16.6H16.7C18.5 16.6 19.9 15.1 19.9 13.3C20 11.7 18.8 10.4 17.3 10.1Z M14.1245 14.2426L15.1852 13.182L12.0032 10L8.82007 13.1831L9.88072 14.2438L11.25 12.8745V18H12.75V12.8681L14.1245 14.2426Z" }) });
3300
3301 // packages/icons/build-module/library/cloud.mjs
3302 var import_primitives17 = __toESM(require_primitives(), 1);
3303 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
3304 var cloud_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.Path, { d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-9c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4h1.3l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8-.1 1-.9 1.8-1.8 1.8z" }) });
3305
3306 // packages/icons/build-module/library/code.mjs
3307 var import_primitives18 = __toESM(require_primitives(), 1);
3308 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
3309 var code_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z" }) });
3310
3311 // packages/icons/build-module/library/color.mjs
3312 var import_primitives19 = __toESM(require_primitives(), 1);
3313 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
3314 var color_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.Path, { d: "M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z" }) });
3315
3316 // packages/icons/build-module/library/comment-author-avatar.mjs
3317 var import_primitives20 = __toESM(require_primitives(), 1);
3318 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
3319 var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z" }) });
3320
3321 // packages/icons/build-module/library/comment.mjs
3322 var import_primitives21 = __toESM(require_primitives(), 1);
3323 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
3324 var comment_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.Path, { d: "M18 4H6c-1.1 0-2 .9-2 2v12.9c0 .6.5 1.1 1.1 1.1.3 0 .5-.1.8-.3L8.5 17H18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 11c0 .3-.2.5-.5.5H7.9l-2.4 2.4V6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v9z" }) });
3325
3326 // packages/icons/build-module/library/copy-small.mjs
3327 var import_primitives22 = __toESM(require_primitives(), 1);
3328 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
3329 var copy_small_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5.625 5.5h9.75c.069 0 .125.056.125.125v9.75a.125.125 0 0 1-.125.125h-9.75a.125.125 0 0 1-.125-.125v-9.75c0-.069.056-.125.125-.125ZM4 5.625C4 4.728 4.728 4 5.625 4h9.75C16.273 4 17 4.728 17 5.625v9.75c0 .898-.727 1.625-1.625 1.625h-9.75A1.625 1.625 0 0 1 4 15.375v-9.75Zm14.5 11.656v-9H20v9C20 18.8 18.77 20 17.251 20H6.25v-1.5h11.001c.69 0 1.249-.528 1.249-1.219Z" }) });
3330
3331 // packages/icons/build-module/library/desktop.mjs
3332 var import_primitives23 = __toESM(require_primitives(), 1);
3333 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
3334 var desktop_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z" }) });
3335
3336 // packages/icons/build-module/library/download.mjs
3337 var import_primitives24 = __toESM(require_primitives(), 1);
3338 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
3339 var download_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.Path, { d: "M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z" }) });
3340
3341 // packages/icons/build-module/library/drafts.mjs
3342 var import_primitives25 = __toESM(require_primitives(), 1);
3343 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
3344 var drafts_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm8 4a4 4 0 0 0 4-4H8a4 4 0 0 0 4 4Z" }) });
3345
3346 // packages/icons/build-module/library/drawer-left.mjs
3347 var import_primitives26 = __toESM(require_primitives(), 1);
3348 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
3349 var drawer_left_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z" }) });
3350
3351 // packages/icons/build-module/library/drawer-right.mjs
3352 var import_primitives27 = __toESM(require_primitives(), 1);
3353 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
3354 var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z" }) });
3355
3356 // packages/icons/build-module/library/envelope.mjs
3357 var import_primitives28 = __toESM(require_primitives(), 1);
3358 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
3359 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z" }) });
3360
3361 // packages/icons/build-module/library/error.mjs
3362 var import_primitives29 = __toESM(require_primitives(), 1);
3363 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3364 var error_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z" }) });
3365
3366 // packages/icons/build-module/library/external.mjs
3367 var import_primitives30 = __toESM(require_primitives(), 1);
3368 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
3369 var external_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.Path, { d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" }) });
3370
3371 // packages/icons/build-module/library/file.mjs
3372 var import_primitives31 = __toESM(require_primitives(), 1);
3373 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3374 var file_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives31.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z" }) });
3375
3376 // packages/icons/build-module/library/footer.mjs
3377 var import_primitives32 = __toESM(require_primitives(), 1);
3378 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3379 var footer_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives32.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives32.Path, { fillRule: "evenodd", d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
3380
3381 // packages/icons/build-module/library/format-list-bullets.mjs
3382 var import_primitives33 = __toESM(require_primitives(), 1);
3383 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3384 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives33.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives33.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) });
3385
3386 // packages/icons/build-module/library/header.mjs
3387 var import_primitives34 = __toESM(require_primitives(), 1);
3388 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3389 var header_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives34.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives34.Path, { d: "M18.5 10.5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
3390
3391 // packages/icons/build-module/library/info.mjs
3392 var import_primitives35 = __toESM(require_primitives(), 1);
3393 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
3394 var info_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives35.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives35.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z" }) });
3395
3396 // packages/icons/build-module/library/keyboard.mjs
3397 var import_primitives36 = __toESM(require_primitives(), 1);
3398 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
3399 var keyboard_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_primitives36.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [
3400 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives36.Path, { d: "m16 15.5h-8v-1.5h8zm-7.5-2.5h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm-9-3h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2z" }),
3401 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives36.Path, { d: "m18.5 6.5h-13a.5.5 0 0 0 -.5.5v9.5a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9.5a.5.5 0 0 0 -.5-.5zm-13-1.5h13a2 2 0 0 1 2 2v9.5a2 2 0 0 1 -2 2h-13a2 2 0 0 1 -2-2v-9.5a2 2 0 0 1 2-2z" })
3402 ] });
3403
3404 // packages/icons/build-module/library/layout.mjs
3405 var import_primitives37 = __toESM(require_primitives(), 1);
3406 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
3407 var layout_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives37.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives37.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
3408
3409 // packages/icons/build-module/library/link.mjs
3410 var import_primitives38 = __toESM(require_primitives(), 1);
3411 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
3412 var link_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives38.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives38.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) });
3413
3414 // packages/icons/build-module/library/list-view.mjs
3415 var import_primitives39 = __toESM(require_primitives(), 1);
3416 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
3417 var list_view_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives39.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives39.Path, { d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" }) });
3418
3419 // packages/icons/build-module/library/lock-small.mjs
3420 var import_primitives40 = __toESM(require_primitives(), 1);
3421 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
3422 var lock_small_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives40.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives40.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M15 11h-.2V9c0-1.5-1.2-2.8-2.8-2.8S9.2 7.5 9.2 9v2H9c-.6 0-1 .4-1 1v4c0 .6.4 1 1 1h6c.6 0 1-.4 1-1v-4c0-.6-.4-1-1-1zm-1.8 0h-2.5V9c0-.7.6-1.2 1.2-1.2s1.2.6 1.2 1.2v2z" }) });
3423
3424 // packages/icons/build-module/library/mobile.mjs
3425 var import_primitives41 = __toESM(require_primitives(), 1);
3426 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
3427 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives41.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives41.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) });
3428
3429 // packages/icons/build-module/library/more-vertical.mjs
3430 var import_primitives42 = __toESM(require_primitives(), 1);
3431 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
3432 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives42.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives42.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
3433
3434 // packages/icons/build-module/library/navigation-overlay.mjs
3435 var import_primitives43 = __toESM(require_primitives(), 1);
3436 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
3437 var navigation_overlay_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives43.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives43.Path, { d: "M18.5 10a1.5 1.5 0 0 1 1.5 1.5v7a1.5 1.5 0 0 1-1.5 1.5h-7a1.5 1.5 0 0 1-1.5-1.5v-7a1.5 1.5 0 0 1 1.5-1.5zM16 4a2 2 0 0 1 2 2v2h-1.5V6a.5.5 0 0 0-.5-.5H6a.5.5 0 0 0-.5.5v3H8v1.5H5.5V16a.5.5 0 0 0 .5.5h2V18H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z" }) });
3438
3439 // packages/icons/build-module/library/navigation.mjs
3440 var import_primitives44 = __toESM(require_primitives(), 1);
3441 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
3442 var navigation_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives44.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives44.Path, { d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z" }) });
3443
3444 // packages/icons/build-module/library/next.mjs
3445 var import_primitives45 = __toESM(require_primitives(), 1);
3446 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
3447 var next_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives45.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives45.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) });
3448
3449 // packages/icons/build-module/library/not-allowed.mjs
3450 var import_primitives46 = __toESM(require_primitives(), 1);
3451 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
3452 var not_allowed_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives46.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives46.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5A6.5 6.5 0 0 1 6.93 7.931l9.139 9.138A6.473 6.473 0 0 1 12 18.5Zm5.123-2.498a6.5 6.5 0 0 0-9.124-9.124l9.124 9.124ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Z" }) });
3453
3454 // packages/icons/build-module/library/page.mjs
3455 var import_primitives47 = __toESM(require_primitives(), 1);
3456 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
3457 var page_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_primitives47.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [
3458 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives47.Path, { d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" }),
3459 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives47.Path, { d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z" })
3460 ] });
3461
3462 // packages/icons/build-module/library/pencil.mjs
3463 var import_primitives48 = __toESM(require_primitives(), 1);
3464 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
3465 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives48.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives48.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) });
3466
3467 // packages/icons/build-module/library/pending.mjs
3468 var import_primitives49 = __toESM(require_primitives(), 1);
3469 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
3470 var pending_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives49.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives49.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm8 4a4 4 0 0 1-4-4h4V8a4 4 0 0 1 0 8Z" }) });
3471
3472 // packages/icons/build-module/library/plus.mjs
3473 var import_primitives50 = __toESM(require_primitives(), 1);
3474 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
3475 var plus_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives50.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives50.Path, { d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" }) });
3476
3477 // packages/icons/build-module/library/previous.mjs
3478 var import_primitives51 = __toESM(require_primitives(), 1);
3479 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
3480 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives51.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives51.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) });
3481
3482 // packages/icons/build-module/library/published.mjs
3483 var import_primitives52 = __toESM(require_primitives(), 1);
3484 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
3485 var published_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives52.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives52.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm11.53-1.47-1.06-1.06L11 12.94l-1.47-1.47-1.06 1.06L11 15.06l4.53-4.53Z" }) });
3486
3487 // packages/icons/build-module/library/redo.mjs
3488 var import_primitives53 = __toESM(require_primitives(), 1);
3489 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
3490 var redo_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives53.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives53.Path, { d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z" }) });
3491
3492 // packages/icons/build-module/library/reset.mjs
3493 var import_primitives54 = __toESM(require_primitives(), 1);
3494 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
3495 var reset_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives54.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives54.Path, { d: "M7 11.5h10V13H7z" }) });
3496
3497 // packages/icons/build-module/library/rotate-left.mjs
3498 var import_primitives55 = __toESM(require_primitives(), 1);
3499 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
3500 var rotate_left_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives55.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives55.Path, { d: "M12 4V2.2L9 4.8l3 2.5V5.5c3.6 0 6.5 2.9 6.5 6.5 0 2.9-1.9 5.3-4.5 6.2v.2l-.1-.2c-.4.1-.7.2-1.1.2l.2 1.5c.3 0 .6-.1 1-.2 3.5-.9 6-4 6-7.7 0-4.4-3.6-8-8-8zm-7.9 7l1.5.2c.1-1.2.5-2.3 1.2-3.2l-1.1-.9C4.8 8.2 4.3 9.6 4.1 11zm1.5 1.8l-1.5.2c.1.7.3 1.4.5 2 .3.7.6 1.3 1 1.8l1.2-.8c-.3-.5-.6-1-.8-1.5s-.4-1.1-.4-1.7zm1.5 5.5c1.1.9 2.4 1.4 3.8 1.6l.2-1.5c-1.1-.1-2.2-.5-3.1-1.2l-.9 1.1z" }) });
3501
3502 // packages/icons/build-module/library/rotate-right.mjs
3503 var import_primitives56 = __toESM(require_primitives(), 1);
3504 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
3505 var rotate_right_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives56.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives56.Path, { d: "M15.1 4.8l-3-2.5V4c-4.4 0-8 3.6-8 8 0 3.7 2.5 6.9 6 7.7.3.1.6.1 1 .2l.2-1.5c-.4 0-.7-.1-1.1-.2l-.1.2v-.2c-2.6-.8-4.5-3.3-4.5-6.2 0-3.6 2.9-6.5 6.5-6.5v1.8l3-2.5zM20 11c-.2-1.4-.7-2.7-1.6-3.8l-1.2.8c.7.9 1.1 2 1.3 3.1L20 11zm-1.5 1.8c-.1.5-.2 1.1-.4 1.6s-.5 1-.8 1.5l1.2.9c.4-.5.8-1.1 1-1.8s.5-1.3.5-2l-1.5-.2zm-5.6 5.6l.2 1.5c1.4-.2 2.7-.7 3.8-1.6l-.9-1.1c-.9.7-2 1.1-3.1 1.2z" }) });
3506
3507 // packages/icons/build-module/library/scheduled.mjs
3508 var import_primitives57 = __toESM(require_primitives(), 1);
3509 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
3510 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives57.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives57.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" }) });
3511
3512 // packages/icons/build-module/library/seen.mjs
3513 var import_primitives58 = __toESM(require_primitives(), 1);
3514 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
3515 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives58.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives58.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" }) });
3516
3517 // packages/icons/build-module/library/settings.mjs
3518 var import_primitives59 = __toESM(require_primitives(), 1);
3519 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
3520 var settings_default = /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_primitives59.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [
3521 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives59.Path, { d: "m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z" }),
3522 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives59.Path, { d: "m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z" })
3523 ] });
3524
3525 // packages/icons/build-module/library/shadow.mjs
3526 var import_primitives60 = __toESM(require_primitives(), 1);
3527 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
3528 var shadow_default = /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives60.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives60.Path, { d: "M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6.5c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5zM12.8 3h-1.5v3h1.5V3zm-1.6 18h1.5v-3h-1.5v3zm6.8-9.8v1.5h3v-1.5h-3zm-12 0H3v1.5h3v-1.5zm9.7 5.6 2.1 2.1 1.1-1.1-2.1-2.1-1.1 1.1zM8.3 7.2 6.2 5.1 5.1 6.2l2.1 2.1 1.1-1.1zM5.1 17.8l1.1 1.1 2.1-2.1-1.1-1.1-2.1 2.1zM18.9 6.2l-1.1-1.1-2.1 2.1 1.1 1.1 2.1-2.1z" }) });
3529
3530 // packages/icons/build-module/library/shuffle.mjs
3531 var import_primitives61 = __toESM(require_primitives(), 1);
3532 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
3533 var shuffle_default = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives61.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives61.Path, { d: "M17.192 6.75L15.47 5.03l1.06-1.06 3.537 3.53-3.537 3.53-1.06-1.06 1.723-1.72h-3.19c-.602 0-.993.202-1.28.498-.309.319-.538.792-.695 1.383-.13.488-.222 1.023-.296 1.508-.034.664-.116 1.413-.303 2.117-.193.721-.513 1.467-1.068 2.04-.575.594-1.359.954-2.357.954H4v-1.5h4.003c.601 0 .993-.202 1.28-.498.308-.319.538-.792.695-1.383.149-.557.216-1.093.288-1.662l.039-.31a9.653 9.653 0 0 1 .272-1.653c.193-.722.513-1.467 1.067-2.04.576-.594 1.36-.954 2.358-.954h3.19zM8.004 6.75c.8 0 1.46.23 1.988.628a6.24 6.24 0 0 0-.684 1.396 1.725 1.725 0 0 0-.024-.026c-.287-.296-.679-.498-1.28-.498H4v-1.5h4.003zM12.699 14.726c-.161.459-.38.94-.684 1.396.527.397 1.188.628 1.988.628h3.19l-1.722 1.72 1.06 1.06L20.067 16l-3.537-3.53-1.06 1.06 1.723 1.72h-3.19c-.602 0-.993-.202-1.28-.498a1.96 1.96 0 0 1-.024-.026z" }) });
3534
3535 // packages/icons/build-module/library/sidebar.mjs
3536 var import_primitives62 = __toESM(require_primitives(), 1);
3537 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
3538 var sidebar_default = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives62.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives62.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) });
3539
3540 // packages/icons/build-module/library/square.mjs
3541 var import_primitives63 = __toESM(require_primitives(), 1);
3542 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
3543 var square_default = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives63.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives63.Path, { fill: "none", d: "M5.75 12.75V18.25H11.25M12.75 5.75H18.25V11.25", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "square" }) });
3544
3545 // packages/icons/build-module/library/star-empty.mjs
3546 var import_primitives64 = __toESM(require_primitives(), 1);
3547 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
3548 var star_empty_default = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives64.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives64.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z" }) });
3549
3550 // packages/icons/build-module/library/star-filled.mjs
3551 var import_primitives65 = __toESM(require_primitives(), 1);
3552 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
3553 var star_filled_default = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives65.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives65.Path, { d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" }) });
3554
3555 // packages/icons/build-module/library/styles.mjs
3556 var import_primitives66 = __toESM(require_primitives(), 1);
3557 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
3558 var styles_default = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives66.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives66.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 0 1-6.5 6.5v-13a6.5 6.5 0 0 1 6.5 6.5Z" }) });
3559
3560 // packages/icons/build-module/library/symbol-filled.mjs
3561 var import_primitives67 = __toESM(require_primitives(), 1);
3562 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
3563 var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives67.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives67.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) });
3564
3565 // packages/icons/build-module/library/symbol.mjs
3566 var import_primitives68 = __toESM(require_primitives(), 1);
3567 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
3568 var symbol_default = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_primitives68.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_primitives68.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) });
3569
3570 // packages/icons/build-module/library/tablet.mjs
3571 var import_primitives69 = __toESM(require_primitives(), 1);
3572 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
3573 var tablet_default = /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_primitives69.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_primitives69.Path, { d: "M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z" }) });
3574
3575 // packages/icons/build-module/library/trash.mjs
3576 var import_primitives70 = __toESM(require_primitives(), 1);
3577 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
3578 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_primitives70.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_primitives70.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" }) });
3579
3580 // packages/icons/build-module/library/typography.mjs
3581 var import_primitives71 = __toESM(require_primitives(), 1);
3582 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
3583 var typography_default = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_primitives71.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_primitives71.Path, { d: "m8.6 7 3.9 10.8h-1.7l-1-2.8H5.7l-1 2.8H3L6.9 7h1.7Zm-2.4 6.6h3L7.7 9.3l-1.5 4.3ZM17.691 8.879c.473 0 .88.055 1.221.165.352.1.643.264.875.495.274.253.456.572.544.957.088.374.132.83.132 1.37v4.554c0 .274.033.472.099.593.077.11.198.166.363.166.11 0 .215-.028.313-.083.11-.055.237-.137.38-.247l.165.28a3.304 3.304 0 0 1-.71.446c-.23.11-.527.165-.89.165-.352 0-.639-.055-.858-.165-.22-.11-.386-.27-.495-.479-.1-.209-.149-.468-.149-.775-.286.462-.627.814-1.023 1.056-.396.242-.858.363-1.386.363-.462 0-.858-.088-1.188-.264a1.752 1.752 0 0 1-.742-.726 2.201 2.201 0 0 1-.248-1.056c0-.484.11-.875.33-1.172.22-.308.5-.556.841-.742.352-.187.721-.341 1.106-.462.396-.132.765-.253 1.106-.363.351-.121.637-.259.857-.413.232-.154.347-.357.347-.61V10.81c0-.396-.066-.71-.198-.941a1.05 1.05 0 0 0-.511-.511 1.763 1.763 0 0 0-.76-.149c-.253 0-.522.039-.808.116a1.165 1.165 0 0 0-.677.412 1.1 1.1 0 0 1 .595.396c.165.187.247.424.247.71 0 .307-.104.55-.313.726-.198.176-.451.263-.76.263-.34 0-.594-.104-.758-.313a1.231 1.231 0 0 1-.248-.759c0-.297.072-.539.214-.726.154-.187.352-.363.595-.528.264-.176.6-.324 1.006-.445.418-.121.88-.182 1.386-.182Zm.99 3.729a1.57 1.57 0 0 1-.528.462c-.231.121-.479.248-.742.38a5.377 5.377 0 0 0-.76.462c-.23.165-.423.38-.577.643-.154.264-.231.6-.231 1.007 0 .429.11.77.33 1.023.22.242.517.363.891.363.308 0 .594-.088.858-.264.275-.176.528-.44.759-.792v-3.284Z" }) });
3584
3585 // packages/icons/build-module/library/undo.mjs
3586 var import_primitives72 = __toESM(require_primitives(), 1);
3587 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
3588 var undo_default = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_primitives72.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_primitives72.Path, { d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z" }) });
3589
3590 // packages/icons/build-module/library/unseen.mjs
3591 var import_primitives73 = __toESM(require_primitives(), 1);
3592 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
3593 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_primitives73.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_primitives73.Path, { d: "M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z" }) });
3594
3595 // packages/icons/build-module/library/verse.mjs
3596 var import_primitives74 = __toESM(require_primitives(), 1);
3597 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
3598 var verse_default = /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_primitives74.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_primitives74.Path, { d: "M17.8 2l-.9.3c-.1 0-3.6 1-5.2 2.1C10 5.5 9.3 6.5 8.9 7.1c-.6.9-1.7 4.7-1.7 6.3l-.9 2.3c-.2.4 0 .8.4 1 .1 0 .2.1.3.1.3 0 .6-.2.7-.5l.6-1.5c.3 0 .7-.1 1.2-.2.7-.1 1.4-.3 2.2-.5.8-.2 1.6-.5 2.4-.8.7-.3 1.4-.7 1.9-1.2s.8-1.2 1-1.9c.2-.7.3-1.6.4-2.4.1-.8.1-1.7.2-2.5 0-.8.1-1.5.2-2.1V2zm-1.9 5.6c-.1.8-.2 1.5-.3 2.1-.2.6-.4 1-.6 1.3-.3.3-.8.6-1.4.9-.7.3-1.4.5-2.2.8-.6.2-1.3.3-1.8.4L15 7.5c.3-.3.6-.7 1-1.1 0 .4 0 .8-.1 1.2zM6 20h8v-1.5H6V20z" }) });
3599
3600 // packages/icons/build-module/library/video.mjs
3601 var import_primitives75 = __toESM(require_primitives(), 1);
3602 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
3603 var video_default = /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_primitives75.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_primitives75.Path, { d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z" }) });
3604
3605 // packages/icons/build-module/library/wordpress.mjs
3606 var import_primitives76 = __toESM(require_primitives(), 1);
3607 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
3608 var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_primitives76.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_primitives76.Path, { d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" }) });
3609
3610 // packages/editor/build-module/utils/get-template-part-icon.mjs
3611 function getTemplatePartIcon(areaOrIconName) {
3612 if ("header" === areaOrIconName) {
3613 return header_default;
3614 } else if ("footer" === areaOrIconName) {
3615 return footer_default;
3616 } else if ("sidebar" === areaOrIconName) {
3617 return sidebar_default;
3618 } else if ("navigation-overlay" === areaOrIconName) {
3619 return navigation_overlay_default;
3620 }
3621 return symbol_filled_default;
3622 }
3623
3624 // packages/editor/build-module/lock-unlock.mjs
3625 var import_private_apis = __toESM(require_private_apis(), 1);
3626 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
3627 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
3628 "@wordpress/editor"
3629 );
3630
3631 // packages/editor/build-module/utils/get-template-info.mjs
3632 var EMPTY_OBJECT = {};
3633 var getTemplateInfo = (params) => {
3634 if (!params) {
3635 return EMPTY_OBJECT;
3636 }
3637 const { templateTypes, templateAreas, template: template2 } = params;
3638 const { description, slug, title, area } = template2;
3639 const { title: defaultTitle, description: defaultDescription } = Object.values(templateTypes).find((type) => type.slug === slug) ?? EMPTY_OBJECT;
3640 const templateTitle = typeof title === "string" ? title : title?.rendered;
3641 const templateDescription = typeof description === "string" ? description : description?.raw;
3642 const templateAreasWithIcon = templateAreas?.map((item) => ({
3643 ...item,
3644 icon: getTemplatePartIcon(item.icon)
3645 }));
3646 const templateIcon = templateAreasWithIcon?.find((item) => area === item.area)?.icon || layout_default;
3647 return {
3648 title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
3649 description: templateDescription || defaultDescription,
3650 icon: templateIcon
3651 };
3652 };
3653
3654 // packages/editor/build-module/store/selectors.mjs
3655 var EMPTY_OBJECT2 = {};
3656 var hasEditorUndo = (0, import_data3.createRegistrySelector)((select6) => () => {
3657 return select6(import_core_data.store).hasUndo();
3658 });
3659 var hasEditorRedo = (0, import_data3.createRegistrySelector)((select6) => () => {
3660 return select6(import_core_data.store).hasRedo();
3661 });
3662 function isEditedPostNew(state) {
3663 return getCurrentPost(state).status === "auto-draft";
3664 }
3665 function hasChangedContent(state) {
3666 const edits = getPostEdits(state);
3667 return "content" in edits;
3668 }
3669 var isEditedPostDirty = (0, import_data3.createRegistrySelector)(
3670 (select6) => (state) => {
3671 const postType2 = getCurrentPostType(state);
3672 const postId2 = getCurrentPostId(state);
3673 return select6(import_core_data.store).hasEditsForEntityRecord(
3674 "postType",
3675 postType2,
3676 postId2
3677 );
3678 }
3679 );
3680 var hasNonPostEntityChanges = (0, import_data3.createRegistrySelector)(
3681 (select6) => (state) => {
3682 const dirtyEntityRecords = select6(import_core_data.store).__experimentalGetDirtyEntityRecords();
3683 const { type, id } = getCurrentPost(state);
3684 return dirtyEntityRecords.some(
3685 (entityRecord) => entityRecord.kind !== "postType" || entityRecord.name !== type || entityRecord.key !== id
3686 );
3687 }
3688 );
3689 function isCleanNewPost(state) {
3690 return !isEditedPostDirty(state) && isEditedPostNew(state);
3691 }
3692 var getCurrentPost = (0, import_data3.createRegistrySelector)(
3693 (select6) => (state) => {
3694 const postId2 = getCurrentPostId(state);
3695 const postType2 = getCurrentPostType(state);
3696 const post2 = select6(import_core_data.store).getRawEntityRecord(
3697 "postType",
3698 postType2,
3699 postId2
3700 );
3701 if (post2) {
3702 return post2;
3703 }
3704 return EMPTY_OBJECT2;
3705 }
3706 );
3707 function getCurrentPostType(state) {
3708 return state.postType;
3709 }
3710 function getCurrentPostId(state) {
3711 return state.postId;
3712 }
3713 function getCurrentTemplateId(state) {
3714 return state.templateId;
3715 }
3716 function getCurrentPostRevisionsCount(state) {
3717 return getCurrentPost(state)._links?.["version-history"]?.[0]?.count ?? 0;
3718 }
3719 function getCurrentPostLastRevisionId(state) {
3720 return getCurrentPost(state)._links?.["predecessor-version"]?.[0]?.id ?? null;
3721 }
3722 var getPostEdits = (0, import_data3.createRegistrySelector)((select6) => (state) => {
3723 const postType2 = getCurrentPostType(state);
3724 const postId2 = getCurrentPostId(state);
3725 return select6(import_core_data.store).getEntityRecordEdits(
3726 "postType",
3727 postType2,
3728 postId2
3729 ) || EMPTY_OBJECT2;
3730 });
3731 function getCurrentPostAttribute(state, attributeName) {
3732 switch (attributeName) {
3733 case "type":
3734 return getCurrentPostType(state);
3735 case "id":
3736 return getCurrentPostId(state);
3737 default:
3738 const post2 = getCurrentPost(state);
3739 if (!post2.hasOwnProperty(attributeName)) {
3740 break;
3741 }
3742 return getPostRawValue(post2[attributeName]);
3743 }
3744 }
3745 var getNestedEditedPostProperty = (0, import_data3.createSelector)(
3746 (state, attributeName) => {
3747 const edits = getPostEdits(state);
3748 if (!edits.hasOwnProperty(attributeName)) {
3749 return getCurrentPostAttribute(state, attributeName);
3750 }
3751 return {
3752 ...getCurrentPostAttribute(state, attributeName),
3753 ...edits[attributeName]
3754 };
3755 },
3756 (state, attributeName) => [
3757 getCurrentPostAttribute(state, attributeName),
3758 getPostEdits(state)[attributeName]
3759 ]
3760 );
3761 function getEditedPostAttribute(state, attributeName) {
3762 switch (attributeName) {
3763 case "content":
3764 return getEditedPostContent(state);
3765 }
3766 const edits = getPostEdits(state);
3767 if (!edits.hasOwnProperty(attributeName)) {
3768 return getCurrentPostAttribute(state, attributeName);
3769 }
3770 if (EDIT_MERGE_PROPERTIES.has(attributeName)) {
3771 return getNestedEditedPostProperty(state, attributeName);
3772 }
3773 return edits[attributeName];
3774 }
3775 var getAutosaveAttribute = (0, import_data3.createRegistrySelector)(
3776 (select6) => (state, attributeName) => {
3777 if (!AUTOSAVE_PROPERTIES.includes(attributeName) && attributeName !== "preview_link") {
3778 return;
3779 }
3780 const postType2 = getCurrentPostType(state);
3781 const postId2 = getCurrentPostId(state);
3782 const currentUserId = select6(import_core_data.store).getCurrentUser()?.id;
3783 const autosave2 = select6(import_core_data.store).getAutosave(
3784 postType2,
3785 postId2,
3786 currentUserId
3787 );
3788 if (autosave2) {
3789 return getPostRawValue(autosave2[attributeName]);
3790 }
3791 }
3792 );
3793 function getEditedPostVisibility(state) {
3794 const status = getEditedPostAttribute(state, "status");
3795 if (status === "private") {
3796 return "private";
3797 }
3798 const password = getEditedPostAttribute(state, "password");
3799 if (password) {
3800 return "password";
3801 }
3802 return "public";
3803 }
3804 function isCurrentPostPending(state) {
3805 return getCurrentPost(state).status === "pending";
3806 }
3807 function isCurrentPostPublished(state, currentPost) {
3808 const post2 = currentPost || getCurrentPost(state);
3809 return ["publish", "private"].indexOf(post2.status) !== -1 || post2.status === "future" && !(0, import_date.isInTheFuture)(
3810 new Date(Number((0, import_date.getDate)(post2.date)) - ONE_MINUTE_IN_MS)
3811 );
3812 }
3813 function isCurrentPostScheduled(state) {
3814 return getCurrentPost(state).status === "future" && !isCurrentPostPublished(state);
3815 }
3816 function isEditedPostPublishable(state) {
3817 const post2 = getCurrentPost(state);
3818 if (post2.type === ATTACHMENT_POST_TYPE) {
3819 return isEditedPostDirty(state);
3820 }
3821 return isEditedPostDirty(state) || ["publish", "private", "future"].indexOf(post2.status) === -1;
3822 }
3823 function isEditedPostSaveable(state) {
3824 if (isSavingPost(state)) {
3825 return false;
3826 }
3827 return !!getEditedPostAttribute(state, "title") || !!getEditedPostAttribute(state, "excerpt") || !isEditedPostEmpty(state) || import_element2.Platform.OS === "native";
3828 }
3829 var isEditedPostEmpty = (0, import_data3.createRegistrySelector)(
3830 (select6) => (state) => {
3831 const postId2 = getCurrentPostId(state);
3832 const postType2 = getCurrentPostType(state);
3833 const record = select6(import_core_data.store).getEditedEntityRecord(
3834 "postType",
3835 postType2,
3836 postId2
3837 );
3838 if (typeof record.content !== "function") {
3839 return !record.content;
3840 }
3841 const blocks = getEditedPostAttribute(state, "blocks");
3842 if (blocks.length === 0) {
3843 return true;
3844 }
3845 if (blocks.length > 1) {
3846 return false;
3847 }
3848 const blockName = blocks[0].name;
3849 if (blockName !== (0, import_blocks.getDefaultBlockName)() && blockName !== (0, import_blocks.getFreeformContentHandlerName)()) {
3850 return false;
3851 }
3852 return !getEditedPostContent(state);
3853 }
3854 );
3855 var isEditedPostAutosaveable = (0, import_data3.createRegistrySelector)(
3856 (select6) => (state) => {
3857 if (!isEditedPostSaveable(state)) {
3858 return false;
3859 }
3860 if (isPostAutosavingLocked(state)) {
3861 return false;
3862 }
3863 const postType2 = getCurrentPostType(state);
3864 const postTypeObject = select6(import_core_data.store).getPostType(postType2);
3865 if (!postTypeObject?.supports?.autosave) {
3866 return false;
3867 }
3868 const postId2 = getCurrentPostId(state);
3869 const hasFetchedAutosave = select6(import_core_data.store).hasFetchedAutosaves(
3870 postType2,
3871 postId2
3872 );
3873 const currentUserId = select6(import_core_data.store).getCurrentUser()?.id;
3874 const autosave2 = select6(import_core_data.store).getAutosave(
3875 postType2,
3876 postId2,
3877 currentUserId
3878 );
3879 if (!hasFetchedAutosave) {
3880 return false;
3881 }
3882 if (!autosave2) {
3883 return true;
3884 }
3885 if (hasChangedContent(state)) {
3886 return true;
3887 }
3888 return ["title", "excerpt", "meta"].some(
3889 (field) => getPostRawValue(autosave2[field]) !== getEditedPostAttribute(state, field)
3890 );
3891 }
3892 );
3893 function isEditedPostBeingScheduled(state) {
3894 const date = getEditedPostAttribute(state, "date");
3895 const checkedDate = new Date(
3896 Number((0, import_date.getDate)(date)) - ONE_MINUTE_IN_MS
3897 );
3898 return (0, import_date.isInTheFuture)(checkedDate);
3899 }
3900 function isEditedPostDateFloating(state) {
3901 const date = getEditedPostAttribute(state, "date");
3902 const modified = getEditedPostAttribute(state, "modified");
3903 const status = getCurrentPost(state).status;
3904 if (status === "draft" || status === "auto-draft" || status === "pending") {
3905 return date === modified || date === null;
3906 }
3907 return false;
3908 }
3909 function isDeletingPost(state) {
3910 return !!state.deleting.pending;
3911 }
3912 function isSavingPost(state) {
3913 return !!state.saving.pending;
3914 }
3915 var isSavingNonPostEntityChanges = (0, import_data3.createRegistrySelector)(
3916 (select6) => (state) => {
3917 const entitiesBeingSaved = select6(import_core_data.store).__experimentalGetEntitiesBeingSaved();
3918 const { type, id } = getCurrentPost(state);
3919 return entitiesBeingSaved.some(
3920 (entityRecord) => entityRecord.kind !== "postType" || entityRecord.name !== type || entityRecord.key !== id
3921 );
3922 }
3923 );
3924 var didPostSaveRequestSucceed = (0, import_data3.createRegistrySelector)(
3925 (select6) => (state) => {
3926 const postType2 = getCurrentPostType(state);
3927 const postId2 = getCurrentPostId(state);
3928 return !select6(import_core_data.store).getLastEntitySaveError(
3929 "postType",
3930 postType2,
3931 postId2
3932 );
3933 }
3934 );
3935 var didPostSaveRequestFail = (0, import_data3.createRegistrySelector)(
3936 (select6) => (state) => {
3937 const postType2 = getCurrentPostType(state);
3938 const postId2 = getCurrentPostId(state);
3939 return !!select6(import_core_data.store).getLastEntitySaveError(
3940 "postType",
3941 postType2,
3942 postId2
3943 );
3944 }
3945 );
3946 function isAutosavingPost(state) {
3947 return isSavingPost(state) && Boolean(state.saving.options?.isAutosave);
3948 }
3949 function isPreviewingPost(state) {
3950 return isSavingPost(state) && Boolean(state.saving.options?.isPreview);
3951 }
3952 function getEditedPostPreviewLink(state) {
3953 if (state.saving.pending || isSavingPost(state)) {
3954 return;
3955 }
3956 let previewLink = getAutosaveAttribute(state, "preview_link");
3957 if (!previewLink || "draft" === getCurrentPost(state).status) {
3958 previewLink = getEditedPostAttribute(state, "link");
3959 if (previewLink) {
3960 previewLink = (0, import_url.addQueryArgs)(previewLink, { preview: true });
3961 }
3962 }
3963 const featuredImageId = getEditedPostAttribute(state, "featured_media");
3964 if (previewLink && featuredImageId) {
3965 return (0, import_url.addQueryArgs)(previewLink, { _thumbnail_id: featuredImageId });
3966 }
3967 return previewLink;
3968 }
3969 var getSuggestedPostFormat = (0, import_data3.createRegistrySelector)(
3970 (select6) => () => {
3971 const blocks = select6(import_block_editor2.store).getBlocks();
3972 if (blocks.length > 2) {
3973 return null;
3974 }
3975 let name2;
3976 if (blocks.length === 1) {
3977 name2 = blocks[0].name;
3978 if (name2 === "core/embed") {
3979 const provider = blocks[0].attributes?.providerNameSlug;
3980 if (["youtube", "vimeo"].includes(provider)) {
3981 name2 = "core/video";
3982 } else if (["spotify", "soundcloud"].includes(provider)) {
3983 name2 = "core/audio";
3984 }
3985 }
3986 }
3987 if (blocks.length === 2 && blocks[1].name === "core/paragraph") {
3988 name2 = blocks[0].name;
3989 }
3990 switch (name2) {
3991 case "core/image":
3992 return "image";
3993 case "core/quote":
3994 case "core/pullquote":
3995 return "quote";
3996 case "core/gallery":
3997 return "gallery";
3998 case "core/video":
3999 return "video";
4000 case "core/audio":
4001 return "audio";
4002 default:
4003 return null;
4004 }
4005 }
4006 );
4007 var getEditedPostContent = (0, import_data3.createRegistrySelector)(
4008 (select6) => (state) => {
4009 const postId2 = getCurrentPostId(state);
4010 const postType2 = getCurrentPostType(state);
4011 const record = select6(import_core_data.store).getEditedEntityRecord(
4012 "postType",
4013 postType2,
4014 postId2
4015 );
4016 if (record) {
4017 if (typeof record.content === "function") {
4018 return record.content(record);
4019 } else if (record.blocks) {
4020 return (0, import_blocks.__unstableSerializeAndClean)(record.blocks);
4021 } else if (record.content) {
4022 return record.content;
4023 }
4024 }
4025 return "";
4026 }
4027 );
4028 function isPublishingPost(state) {
4029 return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, "status") === "publish";
4030 }
4031 function isPermalinkEditable(state) {
4032 const permalinkTemplate = getEditedPostAttribute(
4033 state,
4034 "permalink_template"
4035 );
4036 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
4037 }
4038 function getPermalink(state) {
4039 const permalinkParts = getPermalinkParts(state);
4040 if (!permalinkParts) {
4041 return null;
4042 }
4043 const { prefix: prefix2, postName, suffix } = permalinkParts;
4044 if (isPermalinkEditable(state)) {
4045 return prefix2 + postName + suffix;
4046 }
4047 return prefix2;
4048 }
4049 function getEditedPostSlug(state) {
4050 return getEditedPostAttribute(state, "slug") || (0, import_url.cleanForSlug)(getEditedPostAttribute(state, "title")) || getCurrentPostId(state);
4051 }
4052 function getPermalinkParts(state) {
4053 const permalinkTemplate = getEditedPostAttribute(
4054 state,
4055 "permalink_template"
4056 );
4057 if (!permalinkTemplate) {
4058 return null;
4059 }
4060 const postName = getEditedPostAttribute(state, "slug") || getEditedPostAttribute(state, "generated_slug");
4061 const [prefix2, suffix] = permalinkTemplate.split(
4062 PERMALINK_POSTNAME_REGEX
4063 );
4064 return {
4065 prefix: prefix2,
4066 postName,
4067 suffix
4068 };
4069 }
4070 function isPostLocked(state) {
4071 return state.postLock.isLocked;
4072 }
4073 function isPostSavingLocked(state) {
4074 return Object.keys(state.postSavingLock).length > 0;
4075 }
4076 function isPostAutosavingLocked(state) {
4077 return Object.keys(state.postAutosavingLock).length > 0;
4078 }
4079 function isPostLockTakeover(state) {
4080 return state.postLock.isTakeover;
4081 }
4082 function getPostLockUser(state) {
4083 return state.postLock.user;
4084 }
4085 function getActivePostLock(state) {
4086 return state.postLock.activePostLock;
4087 }
4088 function canUserUseUnfilteredHTML(state) {
4089 return Boolean(
4090 getCurrentPost(state)._links?.hasOwnProperty(
4091 "wp:action-unfiltered-html"
4092 )
4093 );
4094 }
4095 var isPublishSidebarEnabled = (0, import_data3.createRegistrySelector)(
4096 (select6) => () => !!select6(import_preferences.store).get("core", "isPublishSidebarEnabled")
4097 );
4098 var getEditorBlocks = (0, import_data3.createSelector)(
4099 (state) => {
4100 return getEditedPostAttribute(state, "blocks") || (0, import_blocks.parse)(getEditedPostContent(state));
4101 },
4102 (state) => [
4103 getEditedPostAttribute(state, "blocks"),
4104 getEditedPostContent(state)
4105 ]
4106 );
4107 function isEditorPanelRemoved(state, panelName) {
4108 return state.removedPanels.includes(panelName);
4109 }
4110 var isEditorPanelEnabled = (0, import_data3.createRegistrySelector)(
4111 (select6) => (state, panelName) => {
4112 const inactivePanels = select6(import_preferences.store).get(
4113 "core",
4114 "inactivePanels"
4115 );
4116 return !isEditorPanelRemoved(state, panelName) && !inactivePanels?.includes(panelName);
4117 }
4118 );
4119 var isEditorPanelOpened = (0, import_data3.createRegistrySelector)(
4120 (select6) => (state, panelName) => {
4121 const openPanels = select6(import_preferences.store).get(
4122 "core",
4123 "openPanels"
4124 );
4125 return !!openPanels?.includes(panelName);
4126 }
4127 );
4128 function getEditorSelectionStart(state) {
4129 (0, import_deprecated.default)("select('core/editor').getEditorSelectionStart", {
4130 since: "5.8",
4131 alternative: "select('core/editor').getEditorSelection"
4132 });
4133 return getEditedPostAttribute(state, "selection")?.selectionStart;
4134 }
4135 function getEditorSelectionEnd(state) {
4136 (0, import_deprecated.default)("select('core/editor').getEditorSelectionStart", {
4137 since: "5.8",
4138 alternative: "select('core/editor').getEditorSelection"
4139 });
4140 return getEditedPostAttribute(state, "selection")?.selectionEnd;
4141 }
4142 function getEditorSelection(state) {
4143 return getEditedPostAttribute(state, "selection");
4144 }
4145 function __unstableIsEditorReady(state) {
4146 return !!state.postId;
4147 }
4148 function getEditorSettings(state) {
4149 return state.editorSettings;
4150 }
4151 function getRenderingMode(state) {
4152 return state.renderingMode;
4153 }
4154 var getDeviceType = (0, import_data3.createRegistrySelector)(
4155 (select6) => (state) => {
4156 const isZoomOut = unlock(select6(import_block_editor2.store)).isZoomOut();
4157 if (isZoomOut) {
4158 return "Desktop";
4159 }
4160 return state.deviceType;
4161 }
4162 );
4163 function isListViewOpened(state) {
4164 return state.listViewPanel;
4165 }
4166 function isInserterOpened(state) {
4167 return !!state.blockInserterPanel;
4168 }
4169 var getEditorMode = (0, import_data3.createRegistrySelector)(
4170 (select6) => () => select6(import_preferences.store).get("core", "editorMode") ?? "visual"
4171 );
4172 function getStateBeforeOptimisticTransaction() {
4173 (0, import_deprecated.default)("select('core/editor').getStateBeforeOptimisticTransaction", {
4174 since: "5.7",
4175 hint: "No state history is kept on this store anymore"
4176 });
4177 return null;
4178 }
4179 function inSomeHistory() {
4180 (0, import_deprecated.default)("select('core/editor').inSomeHistory", {
4181 since: "5.7",
4182 hint: "No state history is kept on this store anymore"
4183 });
4184 return false;
4185 }
4186 function getBlockEditorSelector(name2) {
4187 return (0, import_data3.createRegistrySelector)((select6) => (state, ...args) => {
4188 (0, import_deprecated.default)("`wp.data.select( 'core/editor' )." + name2 + "`", {
4189 since: "5.3",
4190 alternative: "`wp.data.select( 'core/block-editor' )." + name2 + "`",
4191 version: "6.2"
4192 });
4193 return select6(import_block_editor2.store)[name2](...args);
4194 });
4195 }
4196 var getBlockName = getBlockEditorSelector("getBlockName");
4197 var isBlockValid = getBlockEditorSelector("isBlockValid");
4198 var getBlockAttributes = getBlockEditorSelector("getBlockAttributes");
4199 var getBlock = getBlockEditorSelector("getBlock");
4200 var getBlocks = getBlockEditorSelector("getBlocks");
4201 var getClientIdsOfDescendants = getBlockEditorSelector(
4202 "getClientIdsOfDescendants"
4203 );
4204 var getClientIdsWithDescendants = getBlockEditorSelector(
4205 "getClientIdsWithDescendants"
4206 );
4207 var getGlobalBlockCount = getBlockEditorSelector(
4208 "getGlobalBlockCount"
4209 );
4210 var getBlocksByClientId = getBlockEditorSelector(
4211 "getBlocksByClientId"
4212 );
4213 var getBlockCount = getBlockEditorSelector("getBlockCount");
4214 var getBlockSelectionStart = getBlockEditorSelector(
4215 "getBlockSelectionStart"
4216 );
4217 var getBlockSelectionEnd = getBlockEditorSelector(
4218 "getBlockSelectionEnd"
4219 );
4220 var getSelectedBlockCount = getBlockEditorSelector(
4221 "getSelectedBlockCount"
4222 );
4223 var hasSelectedBlock = getBlockEditorSelector("hasSelectedBlock");
4224 var getSelectedBlockClientId = getBlockEditorSelector(
4225 "getSelectedBlockClientId"
4226 );
4227 var getSelectedBlock = getBlockEditorSelector("getSelectedBlock");
4228 var getBlockRootClientId = getBlockEditorSelector(
4229 "getBlockRootClientId"
4230 );
4231 var getBlockHierarchyRootClientId = getBlockEditorSelector(
4232 "getBlockHierarchyRootClientId"
4233 );
4234 var getAdjacentBlockClientId = getBlockEditorSelector(
4235 "getAdjacentBlockClientId"
4236 );
4237 var getPreviousBlockClientId = getBlockEditorSelector(
4238 "getPreviousBlockClientId"
4239 );
4240 var getNextBlockClientId = getBlockEditorSelector(
4241 "getNextBlockClientId"
4242 );
4243 var getSelectedBlocksInitialCaretPosition = getBlockEditorSelector(
4244 "getSelectedBlocksInitialCaretPosition"
4245 );
4246 var getMultiSelectedBlockClientIds = getBlockEditorSelector(
4247 "getMultiSelectedBlockClientIds"
4248 );
4249 var getMultiSelectedBlocks = getBlockEditorSelector(
4250 "getMultiSelectedBlocks"
4251 );
4252 var getFirstMultiSelectedBlockClientId = getBlockEditorSelector(
4253 "getFirstMultiSelectedBlockClientId"
4254 );
4255 var getLastMultiSelectedBlockClientId = getBlockEditorSelector(
4256 "getLastMultiSelectedBlockClientId"
4257 );
4258 var isFirstMultiSelectedBlock = getBlockEditorSelector(
4259 "isFirstMultiSelectedBlock"
4260 );
4261 var isBlockMultiSelected = getBlockEditorSelector(
4262 "isBlockMultiSelected"
4263 );
4264 var isAncestorMultiSelected = getBlockEditorSelector(
4265 "isAncestorMultiSelected"
4266 );
4267 var getMultiSelectedBlocksStartClientId = getBlockEditorSelector(
4268 "getMultiSelectedBlocksStartClientId"
4269 );
4270 var getMultiSelectedBlocksEndClientId = getBlockEditorSelector(
4271 "getMultiSelectedBlocksEndClientId"
4272 );
4273 var getBlockOrder = getBlockEditorSelector("getBlockOrder");
4274 var getBlockIndex = getBlockEditorSelector("getBlockIndex");
4275 var isBlockSelected = getBlockEditorSelector("isBlockSelected");
4276 var hasSelectedInnerBlock = getBlockEditorSelector(
4277 "hasSelectedInnerBlock"
4278 );
4279 var isBlockWithinSelection = getBlockEditorSelector(
4280 "isBlockWithinSelection"
4281 );
4282 var hasMultiSelection = getBlockEditorSelector("hasMultiSelection");
4283 var isMultiSelecting = getBlockEditorSelector("isMultiSelecting");
4284 var isSelectionEnabled = getBlockEditorSelector("isSelectionEnabled");
4285 var getBlockMode = getBlockEditorSelector("getBlockMode");
4286 var isTyping = getBlockEditorSelector("isTyping");
4287 var isCaretWithinFormattedText = getBlockEditorSelector(
4288 "isCaretWithinFormattedText"
4289 );
4290 var getBlockInsertionPoint = getBlockEditorSelector(
4291 "getBlockInsertionPoint"
4292 );
4293 var isBlockInsertionPointVisible = getBlockEditorSelector(
4294 "isBlockInsertionPointVisible"
4295 );
4296 var isValidTemplate = getBlockEditorSelector("isValidTemplate");
4297 var getTemplate = getBlockEditorSelector("getTemplate");
4298 var getTemplateLock = getBlockEditorSelector("getTemplateLock");
4299 var canInsertBlockType = getBlockEditorSelector("canInsertBlockType");
4300 var getInserterItems = getBlockEditorSelector("getInserterItems");
4301 var hasInserterItems = getBlockEditorSelector("hasInserterItems");
4302 var getBlockListSettings = getBlockEditorSelector(
4303 "getBlockListSettings"
4304 );
4305 var __experimentalGetDefaultTemplateTypes = (0, import_data3.createRegistrySelector)(
4306 (select6) => () => {
4307 (0, import_deprecated.default)(
4308 "select('core/editor').__experimentalGetDefaultTemplateTypes",
4309 {
4310 since: "6.8",
4311 alternative: "select('core/core-data').getCurrentTheme()?.default_template_types"
4312 }
4313 );
4314 return select6(import_core_data.store).getCurrentTheme()?.default_template_types;
4315 }
4316 );
4317 var __experimentalGetDefaultTemplatePartAreas = (0, import_data3.createRegistrySelector)(
4318 (select6) => (0, import_data3.createSelector)(() => {
4319 (0, import_deprecated.default)(
4320 "select('core/editor').__experimentalGetDefaultTemplatePartAreas",
4321 {
4322 since: "6.8",
4323 alternative: "select('core/core-data').getCurrentTheme()?.default_template_part_areas"
4324 }
4325 );
4326 const areas = select6(import_core_data.store).getCurrentTheme()?.default_template_part_areas || [];
4327 return areas.map((item) => {
4328 return { ...item, icon: getTemplatePartIcon(item.icon) };
4329 });
4330 })
4331 );
4332 var __experimentalGetDefaultTemplateType = (0, import_data3.createRegistrySelector)(
4333 (select6) => (0, import_data3.createSelector)((state, slug) => {
4334 (0, import_deprecated.default)(
4335 "select('core/editor').__experimentalGetDefaultTemplateType",
4336 {
4337 since: "6.8"
4338 }
4339 );
4340 const templateTypes = select6(import_core_data.store).getCurrentTheme()?.default_template_types;
4341 if (!templateTypes) {
4342 return EMPTY_OBJECT2;
4343 }
4344 return Object.values(templateTypes).find(
4345 (type) => type.slug === slug
4346 ) ?? EMPTY_OBJECT2;
4347 })
4348 );
4349 var __experimentalGetTemplateInfo = (0, import_data3.createRegistrySelector)(
4350 (select6) => (0, import_data3.createSelector)((state, template2) => {
4351 (0, import_deprecated.default)("select('core/editor').__experimentalGetTemplateInfo", {
4352 since: "6.8"
4353 });
4354 if (!template2) {
4355 return EMPTY_OBJECT2;
4356 }
4357 const currentTheme = select6(import_core_data.store).getCurrentTheme();
4358 const templateTypes = currentTheme?.default_template_types || [];
4359 const templateAreas = currentTheme?.default_template_part_areas || [];
4360 return getTemplateInfo({
4361 template: template2,
4362 templateAreas,
4363 templateTypes
4364 });
4365 })
4366 );
4367 var getPostTypeLabel = (0, import_data3.createRegistrySelector)(
4368 (select6) => (state) => {
4369 const currentPostType = getCurrentPostType(state);
4370 const postType2 = select6(import_core_data.store).getPostType(currentPostType);
4371 return postType2?.labels?.singular_name;
4372 }
4373 );
4374 function isPublishSidebarOpened(state) {
4375 return state.publishSidebarActive;
4376 }
4377
4378 // packages/editor/build-module/store/actions.mjs
4379 var actions_exports = {};
4380 __export(actions_exports, {
4381 __experimentalTearDownEditor: () => __experimentalTearDownEditor,
4382 __unstableSaveForPreview: () => __unstableSaveForPreview,
4383 autosave: () => autosave,
4384 clearSelectedBlock: () => clearSelectedBlock,
4385 closePublishSidebar: () => closePublishSidebar,
4386 createUndoLevel: () => createUndoLevel,
4387 disablePublishSidebar: () => disablePublishSidebar,
4388 editPost: () => editPost,
4389 enablePublishSidebar: () => enablePublishSidebar,
4390 enterFormattedText: () => enterFormattedText,
4391 exitFormattedText: () => exitFormattedText,
4392 hideInsertionPoint: () => hideInsertionPoint,
4393 insertBlock: () => insertBlock,
4394 insertBlocks: () => insertBlocks,
4395 insertDefaultBlock: () => insertDefaultBlock,
4396 lockPostAutosaving: () => lockPostAutosaving,
4397 lockPostSaving: () => lockPostSaving,
4398 mergeBlocks: () => mergeBlocks,
4399 moveBlockToPosition: () => moveBlockToPosition,
4400 moveBlocksDown: () => moveBlocksDown,
4401 moveBlocksUp: () => moveBlocksUp,
4402 multiSelect: () => multiSelect,
4403 openPublishSidebar: () => openPublishSidebar,
4404 receiveBlocks: () => receiveBlocks,
4405 redo: () => redo,
4406 refreshPost: () => refreshPost,
4407 removeBlock: () => removeBlock,
4408 removeBlocks: () => removeBlocks,
4409 removeEditorPanel: () => removeEditorPanel,
4410 replaceBlock: () => replaceBlock,
4411 replaceBlocks: () => replaceBlocks,
4412 resetBlocks: () => resetBlocks,
4413 resetEditorBlocks: () => resetEditorBlocks,
4414 resetPost: () => resetPost,
4415 savePost: () => savePost,
4416 selectBlock: () => selectBlock,
4417 setDeviceType: () => setDeviceType,
4418 setEditedPost: () => setEditedPost,
4419 setIsInserterOpened: () => setIsInserterOpened,
4420 setIsListViewOpened: () => setIsListViewOpened,
4421 setRenderingMode: () => setRenderingMode,
4422 setTemplateValidity: () => setTemplateValidity,
4423 setupEditor: () => setupEditor,
4424 setupEditorState: () => setupEditorState,
4425 showInsertionPoint: () => showInsertionPoint,
4426 startMultiSelect: () => startMultiSelect,
4427 startTyping: () => startTyping,
4428 stopMultiSelect: () => stopMultiSelect,
4429 stopTyping: () => stopTyping,
4430 switchEditorMode: () => switchEditorMode,
4431 synchronizeTemplate: () => synchronizeTemplate,
4432 toggleBlockMode: () => toggleBlockMode,
4433 toggleDistractionFree: () => toggleDistractionFree,
4434 toggleEditorPanelEnabled: () => toggleEditorPanelEnabled,
4435 toggleEditorPanelOpened: () => toggleEditorPanelOpened,
4436 togglePublishSidebar: () => togglePublishSidebar,
4437 toggleSelection: () => toggleSelection,
4438 toggleSpotlightMode: () => toggleSpotlightMode,
4439 toggleTopToolbar: () => toggleTopToolbar,
4440 trashPost: () => trashPost,
4441 undo: () => undo,
4442 unlockPostAutosaving: () => unlockPostAutosaving,
4443 unlockPostSaving: () => unlockPostSaving,
4444 updateBlock: () => updateBlock,
4445 updateBlockAttributes: () => updateBlockAttributes,
4446 updateBlockListSettings: () => updateBlockListSettings,
4447 updateEditorSettings: () => updateEditorSettings,
4448 updatePost: () => updatePost,
4449 updatePostLock: () => updatePostLock
4450 });
4451 var import_a11y = __toESM(require_a11y(), 1);
4452 var import_api_fetch = __toESM(require_api_fetch(), 1);
4453 var import_deprecated2 = __toESM(require_deprecated(), 1);
4454 var import_blocks2 = __toESM(require_blocks(), 1);
4455 var import_notices = __toESM(require_notices(), 1);
4456 var import_core_data2 = __toESM(require_core_data(), 1);
4457 var import_block_editor3 = __toESM(require_block_editor(), 1);
4458 var import_hooks = __toESM(require_hooks(), 1);
4459 var import_preferences2 = __toESM(require_preferences(), 1);
4460 var import_i18n2 = __toESM(require_i18n(), 1);
4461
4462 // packages/editor/build-module/store/local-autosave.mjs
4463 function postKey(postId2, isPostNew) {
4464 return `wp-autosave-block-editor-post-${isPostNew ? "auto-draft" : postId2}`;
4465 }
4466 function localAutosaveGet(postId2, isPostNew) {
4467 return window.sessionStorage.getItem(postKey(postId2, isPostNew));
4468 }
4469 function localAutosaveSet(postId2, isPostNew, title, content, excerpt) {
4470 window.sessionStorage.setItem(
4471 postKey(postId2, isPostNew),
4472 JSON.stringify({
4473 post_title: title,
4474 content,
4475 excerpt
4476 })
4477 );
4478 }
4479 function localAutosaveClear(postId2, isPostNew) {
4480 window.sessionStorage.removeItem(postKey(postId2, isPostNew));
4481 }
4482
4483 // packages/editor/build-module/store/utils/notice-builder.mjs
4484 var import_i18n = __toESM(require_i18n(), 1);
4485 function getNotificationArgumentsForSaveSuccess(data) {
4486 const { previousPost, post: post2, postType: postType2 } = data;
4487 if (data.options?.isAutosave) {
4488 return [];
4489 }
4490 const publishStatus = ["publish", "private", "future"];
4491 const isPublished = publishStatus.includes(previousPost.status);
4492 const willPublish = publishStatus.includes(post2.status);
4493 const willTrash = post2.status === "trash" && previousPost.status !== "trash";
4494 let noticeMessage;
4495 let shouldShowLink = postType2?.viewable ?? false;
4496 let isDraft;
4497 if (willTrash) {
4498 noticeMessage = postType2.labels.item_trashed;
4499 shouldShowLink = false;
4500 } else if (post2.type === ATTACHMENT_POST_TYPE) {
4501 noticeMessage = (0, import_i18n.__)("Media updated.");
4502 shouldShowLink = false;
4503 } else if (!isPublished && !willPublish) {
4504 noticeMessage = (0, import_i18n.__)("Draft saved.");
4505 isDraft = true;
4506 } else if (isPublished && !willPublish) {
4507 noticeMessage = postType2.labels.item_reverted_to_draft;
4508 shouldShowLink = false;
4509 } else if (!isPublished && willPublish) {
4510 noticeMessage = {
4511 publish: postType2.labels.item_published,
4512 private: postType2.labels.item_published_privately,
4513 future: postType2.labels.item_scheduled
4514 }[post2.status];
4515 } else {
4516 noticeMessage = postType2.labels.item_updated;
4517 }
4518 const actions2 = [];
4519 if (shouldShowLink) {
4520 actions2.push({
4521 label: isDraft ? (0, import_i18n.__)("View Preview") : postType2.labels.view_item,
4522 url: post2.link,
4523 openInNewTab: true
4524 });
4525 }
4526 return [
4527 noticeMessage,
4528 {
4529 id: "editor-save",
4530 type: "snackbar",
4531 actions: actions2
4532 }
4533 ];
4534 }
4535 function getNotificationArgumentsForSaveFail(data) {
4536 const { post: post2, edits, error } = data;
4537 if (error && "rest_autosave_no_changes" === error.code) {
4538 return [];
4539 }
4540 const publishStatus = ["publish", "private", "future"];
4541 const isPublished = publishStatus.indexOf(post2.status) !== -1;
4542 if (error.code === "offline_error") {
4543 const messages2 = {
4544 publish: (0, import_i18n.__)(
4545 "Publishing failed because you were offline. Please verify your connection and try again."
4546 ),
4547 private: (0, import_i18n.__)(
4548 "Publishing failed because you were offline. Please verify your connection and try again."
4549 ),
4550 future: (0, import_i18n.__)(
4551 "Scheduling failed because you were offline. Please verify your connection and try again."
4552 ),
4553 default: (0, import_i18n.__)(
4554 "Updating failed because you were offline. Please verify your connection and try again."
4555 )
4556 };
4557 const noticeMessage2 = !isPublished && edits.status in messages2 ? messages2[edits.status] : messages2.default;
4558 return [noticeMessage2, { id: "editor-save" }];
4559 }
4560 const messages = {
4561 publish: (0, import_i18n.__)("Publishing failed."),
4562 private: (0, import_i18n.__)("Publishing failed."),
4563 future: (0, import_i18n.__)("Scheduling failed."),
4564 default: (0, import_i18n.__)("Updating failed.")
4565 };
4566 let noticeMessage = !isPublished && edits.status in messages ? messages[edits.status] : messages.default;
4567 if (error.message && !/<\/?[^>]*>/.test(error.message)) {
4568 noticeMessage = [noticeMessage, error.message].join(" ");
4569 }
4570 return [
4571 noticeMessage,
4572 {
4573 id: "editor-save"
4574 }
4575 ];
4576 }
4577 function getNotificationArgumentsForTrashFail(data) {
4578 return [
4579 data.error.message && data.error.code !== "unknown_error" ? data.error.message : (0, import_i18n.__)("Trashing failed"),
4580 {
4581 id: "editor-trash-fail"
4582 }
4583 ];
4584 }
4585
4586 // packages/editor/build-module/store/actions.mjs
4587 var setupEditor = (post2, edits, template2) => ({ dispatch: dispatch7 }) => {
4588 dispatch7.setEditedPost(post2.type, post2.id);
4589 const isNewPost = post2.status === "auto-draft";
4590 if (isNewPost && template2) {
4591 let content;
4592 if ("content" in edits) {
4593 content = edits.content;
4594 } else {
4595 content = post2.content.raw;
4596 }
4597 let blocks = (0, import_blocks2.parse)(content);
4598 blocks = (0, import_blocks2.synchronizeBlocksWithTemplate)(blocks, template2);
4599 dispatch7.resetEditorBlocks(blocks, {
4600 __unstableShouldCreateUndoLevel: false
4601 });
4602 }
4603 if (edits && Object.entries(edits).some(
4604 ([key, edit]) => edit !== (post2[key]?.raw ?? post2[key])
4605 )) {
4606 dispatch7.editPost(edits);
4607 }
4608 };
4609 function __experimentalTearDownEditor() {
4610 (0, import_deprecated2.default)(
4611 "wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor",
4612 {
4613 since: "6.5"
4614 }
4615 );
4616 return { type: "DO_NOTHING" };
4617 }
4618 function resetPost() {
4619 (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).resetPost", {
4620 since: "6.0",
4621 version: "6.3",
4622 alternative: "Initialize the editor with the setupEditorState action"
4623 });
4624 return { type: "DO_NOTHING" };
4625 }
4626 function updatePost() {
4627 (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).updatePost", {
4628 since: "5.7",
4629 alternative: "Use the core entities store instead"
4630 });
4631 return {
4632 type: "DO_NOTHING"
4633 };
4634 }
4635 function setupEditorState(post2) {
4636 (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).setupEditorState", {
4637 since: "6.5",
4638 alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost"
4639 });
4640 return setEditedPost(post2.type, post2.id);
4641 }
4642 function setEditedPost(postType2, postId2) {
4643 return {
4644 type: "SET_EDITED_POST",
4645 postType: postType2,
4646 postId: postId2
4647 };
4648 }
4649 var editPost = (edits, options) => ({ select: select6, registry }) => {
4650 const { id, type } = select6.getCurrentPost();
4651 registry.dispatch(import_core_data2.store).editEntityRecord("postType", type, id, edits, options);
4652 };
4653 var savePost = (options = {}) => async ({ select: select6, dispatch: dispatch7, registry }) => {
4654 if (!select6.isEditedPostSaveable()) {
4655 return;
4656 }
4657 const content = select6.getEditedPostContent();
4658 if (!options.isAutosave) {
4659 dispatch7.editPost({ content }, { undoIgnore: true });
4660 }
4661 const previousRecord = select6.getCurrentPost();
4662 let edits = {
4663 id: previousRecord.id,
4664 ...registry.select(import_core_data2.store).getEntityRecordNonTransientEdits(
4665 "postType",
4666 previousRecord.type,
4667 previousRecord.id
4668 ),
4669 content
4670 };
4671 dispatch7({ type: "REQUEST_POST_UPDATE_START", options });
4672 let error = false;
4673 try {
4674 edits = await (0, import_hooks.applyFiltersAsync)(
4675 "editor.preSavePost",
4676 edits,
4677 options
4678 );
4679 } catch (err) {
4680 error = err;
4681 }
4682 if (!error) {
4683 try {
4684 await registry.dispatch(import_core_data2.store).saveEntityRecord(
4685 "postType",
4686 previousRecord.type,
4687 edits,
4688 options
4689 );
4690 } catch (err) {
4691 error = err.message && err.code !== "unknown_error" ? err.message : (0, import_i18n2.__)("An error occurred while updating.");
4692 }
4693 }
4694 if (!error) {
4695 error = registry.select(import_core_data2.store).getLastEntitySaveError(
4696 "postType",
4697 previousRecord.type,
4698 previousRecord.id
4699 );
4700 }
4701 if (!error) {
4702 try {
4703 await (0, import_hooks.applyFilters)(
4704 "editor.__unstableSavePost",
4705 Promise.resolve(),
4706 options
4707 );
4708 } catch (err) {
4709 error = err;
4710 }
4711 }
4712 if (!error) {
4713 try {
4714 await (0, import_hooks.doActionAsync)(
4715 "editor.savePost",
4716 { id: previousRecord.id, type: previousRecord.type },
4717 options
4718 );
4719 } catch (err) {
4720 error = err;
4721 }
4722 }
4723 dispatch7({ type: "REQUEST_POST_UPDATE_FINISH", options });
4724 if (typeof window !== "undefined" && window.__experimentalTemplateActivate && !options.isAutosave && previousRecord.type === "wp_template" && (typeof previousRecord.id === "number" || /^\d+$/.test(previousRecord.id))) {
4725 templateActivationNotice({ select: select6, dispatch: dispatch7, registry });
4726 }
4727 if (error) {
4728 const args = getNotificationArgumentsForSaveFail({
4729 post: previousRecord,
4730 edits,
4731 error
4732 });
4733 if (args.length) {
4734 registry.dispatch(import_notices.store).createErrorNotice(...args);
4735 }
4736 } else {
4737 const updatedRecord = select6.getCurrentPost();
4738 const args = getNotificationArgumentsForSaveSuccess({
4739 previousPost: previousRecord,
4740 post: updatedRecord,
4741 postType: await registry.resolveSelect(import_core_data2.store).getPostType(updatedRecord.type),
4742 options
4743 });
4744 if (args.length) {
4745 registry.dispatch(import_notices.store).createSuccessNotice(...args);
4746 }
4747 if (!options.isAutosave) {
4748 registry.dispatch(import_block_editor3.store).__unstableMarkLastChangeAsPersistent();
4749 }
4750 }
4751 };
4752 async function templateActivationNotice({ select: select6, registry }) {
4753 const editorSettings2 = select6.getEditorSettings();
4754 if (editorSettings2.onNavigateToPreviousEntityRecord) {
4755 return;
4756 }
4757 const { id, slug } = select6.getCurrentPost();
4758 const site = await registry.select(import_core_data2.store).getEntityRecord("root", "site");
4759 if (site.active_templates[slug] === id) {
4760 return;
4761 }
4762 const currentTheme = await registry.resolveSelect(import_core_data2.store).getCurrentTheme();
4763 const templateType = currentTheme?.default_template_types.find(
4764 (type) => type.slug === slug
4765 );
4766 await registry.dispatch(import_notices.store).createNotice(
4767 "info",
4768 (0, import_i18n2.sprintf)(
4769 // translators: %s: The name (or slug) of the type of template.
4770 (0, import_i18n2.__)('Do you want to activate this "%s" template?'),
4771 templateType?.title ?? slug
4772 ),
4773 {
4774 id: "template-activate-notice",
4775 actions: [
4776 {
4777 label: (0, import_i18n2.__)("Activate"),
4778 onClick: async () => {
4779 await registry.dispatch(import_notices.store).createNotice(
4780 "info",
4781 (0, import_i18n2.__)("Activating template\u2026"),
4782 { id: "template-activate-notice" }
4783 );
4784 try {
4785 const currentSite = await registry.select(import_core_data2.store).getEntityRecord("root", "site");
4786 await registry.dispatch(import_core_data2.store).saveEntityRecord(
4787 "root",
4788 "site",
4789 {
4790 active_templates: {
4791 ...currentSite.active_templates,
4792 [slug]: id
4793 }
4794 },
4795 { throwOnError: true }
4796 );
4797 await registry.dispatch(import_notices.store).createSuccessNotice(
4798 (0, import_i18n2.__)("Template activated."),
4799 { id: "template-activate-notice" }
4800 );
4801 } catch (error) {
4802 await registry.dispatch(import_notices.store).createErrorNotice(
4803 (0, import_i18n2.__)("Template activation failed."),
4804 { id: "template-activate-notice" }
4805 );
4806 throw error;
4807 }
4808 }
4809 }
4810 ]
4811 }
4812 );
4813 }
4814 function refreshPost() {
4815 (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).refreshPost", {
4816 since: "6.0",
4817 version: "6.3",
4818 alternative: "Use the core entities store instead"
4819 });
4820 return { type: "DO_NOTHING" };
4821 }
4822 var trashPost = () => async ({ select: select6, dispatch: dispatch7, registry }) => {
4823 const postTypeSlug = select6.getCurrentPostType();
4824 const postType2 = await registry.resolveSelect(import_core_data2.store).getPostType(postTypeSlug);
4825 const { rest_base: restBase, rest_namespace: restNamespace = "wp/v2" } = postType2;
4826 dispatch7({ type: "REQUEST_POST_DELETE_START" });
4827 try {
4828 const post2 = select6.getCurrentPost();
4829 await (0, import_api_fetch.default)({
4830 path: `/${restNamespace}/${restBase}/${post2.id}`,
4831 method: "DELETE"
4832 });
4833 await dispatch7.savePost();
4834 } catch (error) {
4835 registry.dispatch(import_notices.store).createErrorNotice(
4836 ...getNotificationArgumentsForTrashFail({ error })
4837 );
4838 }
4839 dispatch7({ type: "REQUEST_POST_DELETE_FINISH" });
4840 };
4841 var autosave = ({ local = false, ...options } = {}) => async ({ select: select6, dispatch: dispatch7 }) => {
4842 const post2 = select6.getCurrentPost();
4843 if (local) {
4844 const isPostNew = select6.isEditedPostNew();
4845 const title = select6.getEditedPostAttribute("title");
4846 const content = select6.getEditedPostAttribute("content");
4847 const excerpt = select6.getEditedPostAttribute("excerpt");
4848 localAutosaveSet(post2.id, isPostNew, title, content, excerpt);
4849 } else {
4850 await dispatch7.savePost({ isAutosave: true, ...options });
4851 }
4852 };
4853 var __unstableSaveForPreview = ({ forceIsAutosaveable } = {}) => async ({ select: select6, dispatch: dispatch7 }) => {
4854 if ((forceIsAutosaveable || select6.isEditedPostAutosaveable()) && !select6.isPostLocked()) {
4855 const isDraft = ["draft", "auto-draft"].includes(
4856 select6.getEditedPostAttribute("status")
4857 );
4858 if (isDraft) {
4859 await dispatch7.savePost({ isPreview: true });
4860 } else {
4861 await dispatch7.autosave({ isPreview: true });
4862 }
4863 }
4864 return select6.getEditedPostPreviewLink();
4865 };
4866 var redo = () => ({ registry }) => {
4867 registry.dispatch(import_core_data2.store).redo();
4868 };
4869 var undo = () => ({ registry }) => {
4870 registry.dispatch(import_core_data2.store).undo();
4871 };
4872 function createUndoLevel() {
4873 (0, import_deprecated2.default)("wp.data.dispatch( 'core/editor' ).createUndoLevel", {
4874 since: "6.0",
4875 version: "6.3",
4876 alternative: "Use the core entities store instead"
4877 });
4878 return { type: "DO_NOTHING" };
4879 }
4880 function updatePostLock(lock5) {
4881 return {
4882 type: "UPDATE_POST_LOCK",
4883 lock: lock5
4884 };
4885 }
4886 var enablePublishSidebar = () => ({ registry }) => {
4887 registry.dispatch(import_preferences2.store).set("core", "isPublishSidebarEnabled", true);
4888 };
4889 var disablePublishSidebar = () => ({ registry }) => {
4890 registry.dispatch(import_preferences2.store).set("core", "isPublishSidebarEnabled", false);
4891 };
4892 function lockPostSaving(lockName) {
4893 return {
4894 type: "LOCK_POST_SAVING",
4895 lockName
4896 };
4897 }
4898 function unlockPostSaving(lockName) {
4899 return {
4900 type: "UNLOCK_POST_SAVING",
4901 lockName
4902 };
4903 }
4904 function lockPostAutosaving(lockName) {
4905 return {
4906 type: "LOCK_POST_AUTOSAVING",
4907 lockName
4908 };
4909 }
4910 function unlockPostAutosaving(lockName) {
4911 return {
4912 type: "UNLOCK_POST_AUTOSAVING",
4913 lockName
4914 };
4915 }
4916 var resetEditorBlocks = (blocks, options = {}) => ({ select: select6, dispatch: dispatch7, registry }) => {
4917 const { __unstableShouldCreateUndoLevel, selection } = options;
4918 const edits = { blocks, selection };
4919 if (__unstableShouldCreateUndoLevel !== false) {
4920 const { id, type } = select6.getCurrentPost();
4921 const noChange = registry.select(import_core_data2.store).getEditedEntityRecord("postType", type, id).blocks === edits.blocks;
4922 if (noChange) {
4923 registry.dispatch(import_core_data2.store).__unstableCreateUndoLevel("postType", type, id);
4924 return;
4925 }
4926 edits.content = ({ blocks: blocksForSerialization = [] }) => (0, import_blocks2.__unstableSerializeAndClean)(blocksForSerialization);
4927 }
4928 dispatch7.editPost(edits);
4929 };
4930 function updateEditorSettings(settings) {
4931 return {
4932 type: "UPDATE_EDITOR_SETTINGS",
4933 settings
4934 };
4935 }
4936 var setRenderingMode = (mode) => ({ dispatch: dispatch7, registry, select: select6 }) => {
4937 if (select6.__unstableIsEditorReady() && !select6.getEditorSettings().isPreviewMode) {
4938 registry.dispatch(import_block_editor3.store).clearSelectedBlock();
4939 }
4940 dispatch7({
4941 type: "SET_RENDERING_MODE",
4942 mode
4943 });
4944 };
4945 function setDeviceType(deviceType2) {
4946 return {
4947 type: "SET_DEVICE_TYPE",
4948 deviceType: deviceType2
4949 };
4950 }
4951 var toggleEditorPanelEnabled = (panelName) => ({ registry }) => {
4952 const inactivePanels = registry.select(import_preferences2.store).get("core", "inactivePanels") ?? [];
4953 const isPanelInactive = !!inactivePanels?.includes(panelName);
4954 let updatedInactivePanels;
4955 if (isPanelInactive) {
4956 updatedInactivePanels = inactivePanels.filter(
4957 (invactivePanelName) => invactivePanelName !== panelName
4958 );
4959 } else {
4960 updatedInactivePanels = [...inactivePanels, panelName];
4961 }
4962 registry.dispatch(import_preferences2.store).set("core", "inactivePanels", updatedInactivePanels);
4963 };
4964 var toggleEditorPanelOpened = (panelName) => ({ registry }) => {
4965 const openPanels = registry.select(import_preferences2.store).get("core", "openPanels") ?? [];
4966 const isPanelOpen = !!openPanels?.includes(panelName);
4967 let updatedOpenPanels;
4968 if (isPanelOpen) {
4969 updatedOpenPanels = openPanels.filter(
4970 (openPanelName) => openPanelName !== panelName
4971 );
4972 } else {
4973 updatedOpenPanels = [...openPanels, panelName];
4974 }
4975 registry.dispatch(import_preferences2.store).set("core", "openPanels", updatedOpenPanels);
4976 };
4977 function removeEditorPanel(panelName) {
4978 return {
4979 type: "REMOVE_PANEL",
4980 panelName
4981 };
4982 }
4983 var setIsInserterOpened = (value) => ({ dispatch: dispatch7, registry }) => {
4984 if (typeof value === "object" && value.hasOwnProperty("rootClientId") && value.hasOwnProperty("insertionIndex")) {
4985 unlock(registry.dispatch(import_block_editor3.store)).setInsertionPoint({
4986 rootClientId: value.rootClientId,
4987 index: value.insertionIndex
4988 });
4989 }
4990 dispatch7({
4991 type: "SET_IS_INSERTER_OPENED",
4992 value
4993 });
4994 };
4995 function setIsListViewOpened(isOpen) {
4996 return {
4997 type: "SET_IS_LIST_VIEW_OPENED",
4998 isOpen
4999 };
5000 }
5001 var toggleDistractionFree = ({ createNotice = true } = {}) => ({ dispatch: dispatch7, registry }) => {
5002 const isDistractionFree = registry.select(import_preferences2.store).get("core", "distractionFree");
5003 if (isDistractionFree) {
5004 registry.dispatch(import_preferences2.store).set("core", "fixedToolbar", false);
5005 }
5006 if (!isDistractionFree) {
5007 registry.batch(() => {
5008 registry.dispatch(import_preferences2.store).set("core", "fixedToolbar", true);
5009 dispatch7.setIsInserterOpened(false);
5010 dispatch7.setIsListViewOpened(false);
5011 unlock(
5012 registry.dispatch(import_block_editor3.store)
5013 ).resetZoomLevel();
5014 });
5015 }
5016 registry.batch(() => {
5017 registry.dispatch(import_preferences2.store).set("core", "distractionFree", !isDistractionFree);
5018 if (createNotice) {
5019 registry.dispatch(import_notices.store).createInfoNotice(
5020 isDistractionFree ? (0, import_i18n2.__)("Distraction free mode deactivated.") : (0, import_i18n2.__)("Distraction free mode activated."),
5021 {
5022 id: "core/editor/distraction-free-mode/notice",
5023 type: "snackbar",
5024 actions: [
5025 {
5026 label: (0, import_i18n2.__)("Undo"),
5027 onClick: () => {
5028 registry.batch(() => {
5029 registry.dispatch(import_preferences2.store).set(
5030 "core",
5031 "fixedToolbar",
5032 isDistractionFree
5033 );
5034 registry.dispatch(import_preferences2.store).toggle(
5035 "core",
5036 "distractionFree"
5037 );
5038 });
5039 }
5040 }
5041 ]
5042 }
5043 );
5044 }
5045 });
5046 };
5047 var toggleSpotlightMode = () => ({ registry }) => {
5048 registry.dispatch(import_preferences2.store).toggle("core", "focusMode");
5049 const isFocusMode = registry.select(import_preferences2.store).get("core", "focusMode");
5050 registry.dispatch(import_notices.store).createInfoNotice(
5051 isFocusMode ? (0, import_i18n2.__)("Spotlight mode activated.") : (0, import_i18n2.__)("Spotlight mode deactivated."),
5052 {
5053 id: "core/editor/toggle-spotlight-mode/notice",
5054 type: "snackbar",
5055 actions: [
5056 {
5057 label: (0, import_i18n2.__)("Undo"),
5058 onClick: () => {
5059 registry.dispatch(import_preferences2.store).toggle("core", "focusMode");
5060 }
5061 }
5062 ]
5063 }
5064 );
5065 };
5066 var toggleTopToolbar = () => ({ registry }) => {
5067 registry.dispatch(import_preferences2.store).toggle("core", "fixedToolbar");
5068 const isTopToolbar = registry.select(import_preferences2.store).get("core", "fixedToolbar");
5069 registry.dispatch(import_notices.store).createInfoNotice(
5070 isTopToolbar ? (0, import_i18n2.__)("Top toolbar activated.") : (0, import_i18n2.__)("Top toolbar deactivated."),
5071 {
5072 id: "core/editor/toggle-top-toolbar/notice",
5073 type: "snackbar",
5074 actions: [
5075 {
5076 label: (0, import_i18n2.__)("Undo"),
5077 onClick: () => {
5078 registry.dispatch(import_preferences2.store).toggle("core", "fixedToolbar");
5079 }
5080 }
5081 ]
5082 }
5083 );
5084 };
5085 var switchEditorMode = (mode) => ({ dispatch: dispatch7, registry }) => {
5086 registry.dispatch(import_preferences2.store).set("core", "editorMode", mode);
5087 if (mode !== "visual") {
5088 registry.dispatch(import_block_editor3.store).clearSelectedBlock();
5089 unlock(registry.dispatch(import_block_editor3.store)).resetZoomLevel();
5090 }
5091 if (mode === "visual") {
5092 (0, import_a11y.speak)((0, import_i18n2.__)("Visual editor selected"), "assertive");
5093 } else if (mode === "text") {
5094 const isDistractionFree = registry.select(import_preferences2.store).get("core", "distractionFree");
5095 if (isDistractionFree) {
5096 dispatch7.toggleDistractionFree();
5097 }
5098 (0, import_a11y.speak)((0, import_i18n2.__)("Code editor selected"), "assertive");
5099 }
5100 };
5101 function openPublishSidebar() {
5102 return {
5103 type: "OPEN_PUBLISH_SIDEBAR"
5104 };
5105 }
5106 function closePublishSidebar() {
5107 return {
5108 type: "CLOSE_PUBLISH_SIDEBAR"
5109 };
5110 }
5111 function togglePublishSidebar() {
5112 return {
5113 type: "TOGGLE_PUBLISH_SIDEBAR"
5114 };
5115 }
5116 var getBlockEditorAction = (name2) => (...args) => ({ registry }) => {
5117 (0, import_deprecated2.default)("`wp.data.dispatch( 'core/editor' )." + name2 + "`", {
5118 since: "5.3",
5119 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name2 + "`",
5120 version: "6.2"
5121 });
5122 registry.dispatch(import_block_editor3.store)[name2](...args);
5123 };
5124 var resetBlocks = getBlockEditorAction("resetBlocks");
5125 var receiveBlocks = getBlockEditorAction("receiveBlocks");
5126 var updateBlock = getBlockEditorAction("updateBlock");
5127 var updateBlockAttributes = getBlockEditorAction(
5128 "updateBlockAttributes"
5129 );
5130 var selectBlock = getBlockEditorAction("selectBlock");
5131 var startMultiSelect = getBlockEditorAction("startMultiSelect");
5132 var stopMultiSelect = getBlockEditorAction("stopMultiSelect");
5133 var multiSelect = getBlockEditorAction("multiSelect");
5134 var clearSelectedBlock = getBlockEditorAction("clearSelectedBlock");
5135 var toggleSelection = getBlockEditorAction("toggleSelection");
5136 var replaceBlocks = getBlockEditorAction("replaceBlocks");
5137 var replaceBlock = getBlockEditorAction("replaceBlock");
5138 var moveBlocksDown = getBlockEditorAction("moveBlocksDown");
5139 var moveBlocksUp = getBlockEditorAction("moveBlocksUp");
5140 var moveBlockToPosition = getBlockEditorAction(
5141 "moveBlockToPosition"
5142 );
5143 var insertBlock = getBlockEditorAction("insertBlock");
5144 var insertBlocks = getBlockEditorAction("insertBlocks");
5145 var showInsertionPoint = getBlockEditorAction("showInsertionPoint");
5146 var hideInsertionPoint = getBlockEditorAction("hideInsertionPoint");
5147 var setTemplateValidity = getBlockEditorAction(
5148 "setTemplateValidity"
5149 );
5150 var synchronizeTemplate = getBlockEditorAction(
5151 "synchronizeTemplate"
5152 );
5153 var mergeBlocks = getBlockEditorAction("mergeBlocks");
5154 var removeBlocks = getBlockEditorAction("removeBlocks");
5155 var removeBlock = getBlockEditorAction("removeBlock");
5156 var toggleBlockMode = getBlockEditorAction("toggleBlockMode");
5157 var startTyping = getBlockEditorAction("startTyping");
5158 var stopTyping = getBlockEditorAction("stopTyping");
5159 var enterFormattedText = getBlockEditorAction("enterFormattedText");
5160 var exitFormattedText = getBlockEditorAction("exitFormattedText");
5161 var insertDefaultBlock = getBlockEditorAction("insertDefaultBlock");
5162 var updateBlockListSettings = getBlockEditorAction(
5163 "updateBlockListSettings"
5164 );
5165
5166 // packages/editor/build-module/store/private-actions.mjs
5167 var private_actions_exports = {};
5168 __export(private_actions_exports, {
5169 createTemplate: () => createTemplate,
5170 hideBlockTypes: () => hideBlockTypes,
5171 registerEntityAction: () => registerEntityAction,
5172 registerEntityField: () => registerEntityField,
5173 registerPostTypeSchema: () => registerPostTypeSchema,
5174 removeTemplates: () => removeTemplates,
5175 resetStylesNavigation: () => resetStylesNavigation,
5176 restoreRevision: () => restoreRevision,
5177 revertTemplate: () => revertTemplate2,
5178 saveDirtyEntities: () => saveDirtyEntities,
5179 selectNote: () => selectNote,
5180 setCanvasMinHeight: () => setCanvasMinHeight,
5181 setCurrentRevisionId: () => setCurrentRevisionId,
5182 setCurrentTemplateId: () => setCurrentTemplateId,
5183 setDefaultRenderingMode: () => setDefaultRenderingMode,
5184 setIsReady: () => setIsReady,
5185 setRevisionPage: () => setRevisionPage,
5186 setShowRevisionDiff: () => setShowRevisionDiff,
5187 setShowStylebook: () => setShowStylebook,
5188 setStylesPath: () => setStylesPath,
5189 showBlockTypes: () => showBlockTypes,
5190 unregisterEntityAction: () => unregisterEntityAction,
5191 unregisterEntityField: () => unregisterEntityField
5192 });
5193 var import_core_data53 = __toESM(require_core_data(), 1);
5194 var import_i18n122 = __toESM(require_i18n(), 1);
5195 var import_notices17 = __toESM(require_notices(), 1);
5196 var import_block_editor35 = __toESM(require_block_editor(), 1);
5197 var import_preferences10 = __toESM(require_preferences(), 1);
5198 var import_url11 = __toESM(require_url(), 1);
5199 var import_api_fetch5 = __toESM(require_api_fetch(), 1);
5200 var import_blocks20 = __toESM(require_blocks(), 1);
5201 var import_html_entities9 = __toESM(require_html_entities(), 1);
5202 var import_date6 = __toESM(require_date(), 1);
5203
5204 // packages/editor/build-module/store/utils/is-template-revertable.mjs
5205 function isTemplateRevertable(templateOrTemplatePart) {
5206 if (!templateOrTemplatePart) {
5207 return false;
5208 }
5209 return templateOrTemplatePart.source === TEMPLATE_ORIGINS.custom && (Boolean(templateOrTemplatePart?.plugin) || templateOrTemplatePart?.has_theme_file);
5210 }
5211
5212 // packages/editor/build-module/store/private-selectors.mjs
5213 var private_selectors_exports = {};
5214 __export(private_selectors_exports, {
5215 buildRevisionsPageQuery: () => buildRevisionsPageQuery,
5216 getCanvasMinHeight: () => getCanvasMinHeight,
5217 getCurrentRevision: () => getCurrentRevision,
5218 getCurrentRevisionId: () => getCurrentRevisionId,
5219 getDefaultRenderingMode: () => getDefaultRenderingMode,
5220 getEntityActions: () => getEntityActions2,
5221 getEntityFields: () => getEntityFields2,
5222 getInserter: () => getInserter,
5223 getInserterSidebarToggleRef: () => getInserterSidebarToggleRef,
5224 getListViewToggleRef: () => getListViewToggleRef,
5225 getPageRevisions: () => getPageRevisions,
5226 getPostBlocksByName: () => getPostBlocksByName,
5227 getPostIcon: () => getPostIcon,
5228 getPreviousRevision: () => getPreviousRevision,
5229 getRevisionPage: () => getRevisionPage,
5230 getRevisionsPerPage: () => getRevisionsPerPage,
5231 getSelectedNote: () => getSelectedNote,
5232 getShowStylebook: () => getShowStylebook,
5233 getStylesPath: () => getStylesPath,
5234 hasPostMetaChanges: () => hasPostMetaChanges,
5235 isCollaborationEnabledForCurrentPost: () => isCollaborationEnabledForCurrentPost,
5236 isEntityReady: () => isEntityReady2,
5237 isNoteFocused: () => isNoteFocused,
5238 isRevisionsMode: () => isRevisionsMode,
5239 isShowingRevisionDiff: () => isShowingRevisionDiff
5240 });
5241 var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
5242 var import_block_editor4 = __toESM(require_block_editor(), 1);
5243 var import_data5 = __toESM(require_data(), 1);
5244 var import_core_data4 = __toESM(require_core_data(), 1);
5245 var import_preferences3 = __toESM(require_preferences(), 1);
5246
5247 // packages/editor/build-module/dataviews/store/private-selectors.mjs
5248 var EMPTY_ARRAY = [];
5249 function getEntityActions(state, kind, name2) {
5250 return state.actions[kind]?.[name2] ?? EMPTY_ARRAY;
5251 }
5252 function getEntityFields(state, kind, name2) {
5253 return state.fields[kind]?.[name2] ?? EMPTY_ARRAY;
5254 }
5255 function isEntityReady(state, kind, name2) {
5256 return state.isReady[kind]?.[name2];
5257 }
5258
5259 // node_modules/uuid/dist/esm-browser/rng.js
5260 var getRandomValues;
5261 var rnds8 = new Uint8Array(16);
5262 function rng() {
5263 if (!getRandomValues) {
5264 getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
5265 if (!getRandomValues) {
5266 throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
5267 }
5268 }
5269 return getRandomValues(rnds8);
5270 }
5271
5272 // node_modules/uuid/dist/esm-browser/stringify.js
5273 var byteToHex = [];
5274 for (let i3 = 0; i3 < 256; ++i3) {
5275 byteToHex.push((i3 + 256).toString(16).slice(1));
5276 }
5277 function unsafeStringify(arr, offset3 = 0) {
5278 return byteToHex[arr[offset3 + 0]] + byteToHex[arr[offset3 + 1]] + byteToHex[arr[offset3 + 2]] + byteToHex[arr[offset3 + 3]] + "-" + byteToHex[arr[offset3 + 4]] + byteToHex[arr[offset3 + 5]] + "-" + byteToHex[arr[offset3 + 6]] + byteToHex[arr[offset3 + 7]] + "-" + byteToHex[arr[offset3 + 8]] + byteToHex[arr[offset3 + 9]] + "-" + byteToHex[arr[offset3 + 10]] + byteToHex[arr[offset3 + 11]] + byteToHex[arr[offset3 + 12]] + byteToHex[arr[offset3 + 13]] + byteToHex[arr[offset3 + 14]] + byteToHex[arr[offset3 + 15]];
5279 }
5280
5281 // node_modules/uuid/dist/esm-browser/native.js
5282 var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
5283 var native_default = {
5284 randomUUID
5285 };
5286
5287 // node_modules/uuid/dist/esm-browser/v4.js
5288 function v4(options, buf, offset3) {
5289 if (native_default.randomUUID && !buf && !options) {
5290 return native_default.randomUUID();
5291 }
5292 options = options || {};
5293 const rnds = options.random || (options.rng || rng)();
5294 rnds[6] = rnds[6] & 15 | 64;
5295 rnds[8] = rnds[8] & 63 | 128;
5296 if (buf) {
5297 offset3 = offset3 || 0;
5298 for (let i3 = 0; i3 < 16; ++i3) {
5299 buf[offset3 + i3] = rnds[i3];
5300 }
5301 return buf;
5302 }
5303 return unsafeStringify(rnds);
5304 }
5305 var v4_default = v4;
5306
5307 // packages/editor/build-module/utils/media-upload/index.mjs
5308 var import_data4 = __toESM(require_data(), 1);
5309 var import_core_data3 = __toESM(require_core_data(), 1);
5310 var import_media_utils = __toESM(require_media_utils(), 1);
5311 var noop = () => {
5312 };
5313 function mediaUpload({
5314 additionalData = {},
5315 allowedTypes,
5316 filesList,
5317 maxUploadFileSize,
5318 onError = noop,
5319 onFileChange,
5320 onSuccess,
5321 multiple = true
5322 }) {
5323 const { receiveEntityRecords } = (0, import_data4.dispatch)(import_core_data3.store);
5324 const { getCurrentPost: getCurrentPost2, getEditorSettings: getEditorSettings2 } = (0, import_data4.select)(store);
5325 const {
5326 lockPostAutosaving: lockPostAutosaving2,
5327 unlockPostAutosaving: unlockPostAutosaving2,
5328 lockPostSaving: lockPostSaving2,
5329 unlockPostSaving: unlockPostSaving2
5330 } = (0, import_data4.dispatch)(store);
5331 const wpAllowedMimeTypes = getEditorSettings2().allowedMimeTypes;
5332 const lockKey = `image-upload-${v4_default()}`;
5333 let imageIsUploading = false;
5334 maxUploadFileSize = maxUploadFileSize || getEditorSettings2().maxUploadFileSize;
5335 const currentPost = getCurrentPost2();
5336 const currentPostId = typeof currentPost?.id === "number" ? currentPost.id : currentPost?.wp_id;
5337 const setSaveLock = () => {
5338 if (window.__clientSideMediaProcessing) {
5339 return;
5340 }
5341 lockPostSaving2(lockKey);
5342 lockPostAutosaving2(lockKey);
5343 imageIsUploading = true;
5344 };
5345 const postData = currentPostId ? { post: currentPostId } : {};
5346 const clearSaveLock = () => {
5347 if (window.__clientSideMediaProcessing) {
5348 return;
5349 }
5350 unlockPostSaving2(lockKey);
5351 unlockPostAutosaving2(lockKey);
5352 imageIsUploading = false;
5353 };
5354 (0, import_media_utils.uploadMedia)({
5355 allowedTypes,
5356 filesList,
5357 onFileChange: (file) => {
5358 if (!window.__clientSideMediaProcessing) {
5359 if (!imageIsUploading) {
5360 setSaveLock();
5361 } else {
5362 clearSaveLock();
5363 }
5364 }
5365 onFileChange?.(file);
5366 const entityFiles = file.filter((_file) => _file?.id);
5367 if (entityFiles?.length) {
5368 const invalidateCache = true;
5369 receiveEntityRecords(
5370 "postType",
5371 "attachment",
5372 entityFiles,
5373 void 0,
5374 invalidateCache
5375 );
5376 }
5377 },
5378 onSuccess,
5379 additionalData: {
5380 ...postData,
5381 ...additionalData
5382 },
5383 maxUploadFileSize,
5384 onError: ({ message: message2 }) => {
5385 if (!window.__clientSideMediaProcessing) {
5386 clearSaveLock();
5387 }
5388 onError(message2);
5389 },
5390 wpAllowedMimeTypes,
5391 multiple
5392 });
5393 }
5394
5395 // packages/editor/build-module/utils/url.mjs
5396 var import_url2 = __toESM(require_url(), 1);
5397 var import_deprecated3 = __toESM(require_deprecated(), 1);
5398 function cleanForSlug2(string) {
5399 (0, import_deprecated3.default)("wp.editor.cleanForSlug", {
5400 since: "12.7",
5401 plugin: "Gutenberg",
5402 alternative: "wp.url.cleanForSlug"
5403 });
5404 return (0, import_url2.cleanForSlug)(string);
5405 }
5406
5407 // packages/editor/build-module/store/private-selectors.mjs
5408 var EMPTY_INSERTION_POINT = {
5409 rootClientId: void 0,
5410 insertionIndex: void 0,
5411 filterValue: void 0
5412 };
5413 var RENDERING_MODES = ["post-only", "template-locked"];
5414 var getInserter = (0, import_data5.createRegistrySelector)(
5415 (select6) => (0, import_data5.createSelector)(
5416 (state) => {
5417 if (typeof state.blockInserterPanel === "object") {
5418 return state.blockInserterPanel;
5419 }
5420 if (getRenderingMode(state) === "template-locked") {
5421 const {
5422 getBlocksByName,
5423 getSelectedBlockClientId: getSelectedBlockClientId2,
5424 getBlockParents,
5425 getBlockOrder: getBlockOrder2
5426 } = select6(import_block_editor4.store);
5427 const [postContentClientId] = getBlocksByName("core/post-content");
5428 if (postContentClientId) {
5429 const selectedBlockClientId = getSelectedBlockClientId2();
5430 if (selectedBlockClientId && selectedBlockClientId !== postContentClientId && getBlockParents(selectedBlockClientId).includes(
5431 postContentClientId
5432 )) {
5433 return EMPTY_INSERTION_POINT;
5434 }
5435 return {
5436 rootClientId: postContentClientId,
5437 insertionIndex: getBlockOrder2(postContentClientId).length,
5438 filterValue: void 0
5439 };
5440 }
5441 }
5442 return EMPTY_INSERTION_POINT;
5443 },
5444 (state) => {
5445 const {
5446 getBlocksByName,
5447 getSelectedBlockClientId: getSelectedBlockClientId2,
5448 getBlockParents,
5449 getBlockOrder: getBlockOrder2
5450 } = select6(import_block_editor4.store);
5451 const [postContentClientId] = getBlocksByName("core/post-content");
5452 const selectedBlockClientId = getSelectedBlockClientId2();
5453 return [
5454 state.blockInserterPanel,
5455 getRenderingMode(state),
5456 postContentClientId,
5457 selectedBlockClientId,
5458 selectedBlockClientId ? getBlockParents(selectedBlockClientId) : void 0,
5459 postContentClientId ? getBlockOrder2(postContentClientId).length : void 0
5460 ];
5461 }
5462 )
5463 );
5464 function getListViewToggleRef(state) {
5465 return state.listViewToggleRef;
5466 }
5467 function getInserterSidebarToggleRef(state) {
5468 return state.inserterSidebarToggleRef;
5469 }
5470 var CARD_ICONS = {
5471 wp_block: symbol_default,
5472 wp_navigation: navigation_default,
5473 page: page_default,
5474 post: verse_default
5475 };
5476 var getPostIcon = (0, import_data5.createRegistrySelector)(
5477 (select6) => (state, postType2, options) => {
5478 {
5479 if (postType2 === "wp_template_part" || postType2 === "wp_template") {
5480 const templateAreas = select6(import_core_data4.store).getCurrentTheme()?.default_template_part_areas || [];
5481 const areaData = templateAreas.find(
5482 (item) => options.area === item.area
5483 );
5484 if (areaData?.icon) {
5485 return getTemplatePartIcon(areaData.icon);
5486 }
5487 return layout_default;
5488 }
5489 if (CARD_ICONS[postType2]) {
5490 return CARD_ICONS[postType2];
5491 }
5492 const postTypeEntity = select6(import_core_data4.store).getPostType(postType2);
5493 if (typeof postTypeEntity?.icon === "string" && postTypeEntity.icon.startsWith("dashicons-")) {
5494 return postTypeEntity.icon.slice(10);
5495 }
5496 return page_default;
5497 }
5498 }
5499 );
5500 var hasPostMetaChanges = (0, import_data5.createRegistrySelector)(
5501 (select6) => (state, postType2, postId2) => {
5502 const { type: currentPostType, id: currentPostId } = getCurrentPost(state);
5503 const edits = select6(import_core_data4.store).getEntityRecordNonTransientEdits(
5504 "postType",
5505 postType2 || currentPostType,
5506 postId2 || currentPostId
5507 );
5508 if (!edits?.meta) {
5509 return false;
5510 }
5511 const originalPostMeta = select6(import_core_data4.store).getEntityRecord(
5512 "postType",
5513 postType2 || currentPostType,
5514 postId2 || currentPostId
5515 )?.meta;
5516 return !(0, import_fast_deep_equal.default)(
5517 { ...originalPostMeta, footnotes: void 0 },
5518 { ...edits.meta, footnotes: void 0 }
5519 );
5520 }
5521 );
5522 function getEntityActions2(state, ...args) {
5523 return getEntityActions(state.dataviews, ...args);
5524 }
5525 function isEntityReady2(state, ...args) {
5526 return isEntityReady(state.dataviews, ...args);
5527 }
5528 function getEntityFields2(state, ...args) {
5529 return getEntityFields(state.dataviews, ...args);
5530 }
5531 var getPostBlocksByName = (0, import_data5.createRegistrySelector)(
5532 (select6) => (0, import_data5.createSelector)(
5533 (state, blockNames) => {
5534 blockNames = Array.isArray(blockNames) ? blockNames : [blockNames];
5535 const { getBlocksByName, getBlockParents, getBlockName: getBlockName2 } = select6(import_block_editor4.store);
5536 return getBlocksByName(blockNames).filter(
5537 (clientId) => getBlockParents(clientId).every((parentClientId) => {
5538 const parentBlockName = getBlockName2(parentClientId);
5539 return (
5540 // Ignore descendents of the query block.
5541 parentBlockName !== "core/query" && // Enable only the top-most block.
5542 !blockNames.includes(parentBlockName)
5543 );
5544 })
5545 );
5546 },
5547 (state, blockNames) => {
5548 blockNames = Array.isArray(blockNames) ? blockNames : [blockNames];
5549 const { getBlocksByName, getBlockParents } = select6(import_block_editor4.store);
5550 const clientIds = getBlocksByName(blockNames);
5551 const parentsOfClientIds = clientIds.map(
5552 (id) => getBlockParents(id)
5553 );
5554 return [clientIds, ...parentsOfClientIds];
5555 }
5556 )
5557 );
5558 var getDefaultRenderingMode = (0, import_data5.createRegistrySelector)(
5559 (select6) => (state, postType2) => {
5560 const { getPostType, getCurrentTheme, hasFinishedResolution } = select6(import_core_data4.store);
5561 const currentTheme = getCurrentTheme();
5562 const postTypeEntity = getPostType(postType2);
5563 if (!hasFinishedResolution("getPostType", [postType2]) || !hasFinishedResolution("getCurrentTheme")) {
5564 return void 0;
5565 }
5566 const theme = currentTheme?.stylesheet;
5567 const defaultModePreference = select6(import_preferences3.store).get(
5568 "core",
5569 "renderingModes"
5570 )?.[theme]?.[postType2];
5571 const postTypeDefaultMode = Array.isArray(
5572 postTypeEntity?.supports?.editor
5573 ) ? postTypeEntity.supports.editor.find(
5574 (features) => "default-mode" in features
5575 )?.["default-mode"] : void 0;
5576 const defaultMode = defaultModePreference || postTypeDefaultMode;
5577 if (!RENDERING_MODES.includes(defaultMode)) {
5578 return "post-only";
5579 }
5580 return defaultMode;
5581 }
5582 );
5583 function getStylesPath(state) {
5584 return state.stylesPath ?? "/";
5585 }
5586 function getShowStylebook(state) {
5587 return state.showStylebook ?? false;
5588 }
5589 function getCanvasMinHeight(state) {
5590 return state.canvasMinHeight;
5591 }
5592 function getRevisionPage(state) {
5593 return state.revisionPage;
5594 }
5595 function buildRevisionsPageQuery(revisionKey, page) {
5596 return {
5597 per_page: REVISIONS_PER_PAGE,
5598 page,
5599 context: "edit",
5600 orderby: "date",
5601 order: "desc",
5602 _fields: [
5603 .../* @__PURE__ */ new Set([
5604 "id",
5605 "date",
5606 "modified",
5607 "author",
5608 "meta",
5609 "title.raw",
5610 "excerpt.raw",
5611 "content.raw",
5612 revisionKey
5613 ])
5614 ].join()
5615 };
5616 }
5617 var REVISIONS_PER_PAGE = 100;
5618 function getRevisionsPerPage() {
5619 return REVISIONS_PER_PAGE;
5620 }
5621 var getPageRevisions = (0, import_data5.createRegistrySelector)(
5622 (select6) => (state, page) => {
5623 if (!page) {
5624 return null;
5625 }
5626 const { type: postType2, id: postId2 } = getCurrentPost(state);
5627 if (!postType2 || !postId2) {
5628 return null;
5629 }
5630 const entityConfig = select6(import_core_data4.store).getEntityConfig(
5631 "postType",
5632 postType2
5633 );
5634 const revisionKey = entityConfig?.revisionKey || "id";
5635 return select6(import_core_data4.store).getRevisions(
5636 "postType",
5637 postType2,
5638 postId2,
5639 buildRevisionsPageQuery(revisionKey, page)
5640 );
5641 }
5642 );
5643 function isRevisionsMode(state) {
5644 return state.revisionId !== null;
5645 }
5646 function isShowingRevisionDiff(state) {
5647 return state.showRevisionDiff;
5648 }
5649 function getCurrentRevisionId(state) {
5650 return state.revisionId;
5651 }
5652 var getCurrentRevision = (0, import_data5.createRegistrySelector)(
5653 (select6) => (state) => {
5654 const revisionId2 = getCurrentRevisionId(state);
5655 if (!revisionId2) {
5656 return void 0;
5657 }
5658 const page = getRevisionPage(state);
5659 if (!page) {
5660 return null;
5661 }
5662 const { type: postType2, id: postId2 } = getCurrentPost(state);
5663 const entityConfig = select6(import_core_data4.store).getEntityConfig(
5664 "postType",
5665 postType2
5666 );
5667 const revisionKey = entityConfig?.revisionKey || "id";
5668 const revisions = select6(import_core_data4.store).getRevisions(
5669 "postType",
5670 postType2,
5671 postId2,
5672 buildRevisionsPageQuery(revisionKey, page)
5673 );
5674 if (!revisions) {
5675 return null;
5676 }
5677 return revisions.find((r4) => r4[revisionKey] === revisionId2) ?? null;
5678 }
5679 );
5680 function getSelectedNote(state) {
5681 return state.selectedNote?.noteId;
5682 }
5683 function isNoteFocused(state) {
5684 return !!state.selectedNote?.options?.focus;
5685 }
5686 var getPreviousRevision = (0, import_data5.createRegistrySelector)(
5687 (select6) => (state) => {
5688 const currentRevisionId = getCurrentRevisionId(state);
5689 if (!currentRevisionId) {
5690 return void 0;
5691 }
5692 const page = getRevisionPage(state);
5693 if (!page) {
5694 return null;
5695 }
5696 const { type: postType2, id: postId2 } = getCurrentPost(state);
5697 const entityConfig = select6(import_core_data4.store).getEntityConfig(
5698 "postType",
5699 postType2
5700 );
5701 const revisionKey = entityConfig?.revisionKey || "id";
5702 const query = buildRevisionsPageQuery(revisionKey, page);
5703 const revisions = select6(import_core_data4.store).getRevisions(
5704 "postType",
5705 postType2,
5706 postId2,
5707 query
5708 );
5709 if (!revisions) {
5710 return null;
5711 }
5712 const currentIndex = revisions.findIndex(
5713 (r4) => r4[revisionKey] === currentRevisionId
5714 );
5715 if (currentIndex >= 0 && currentIndex < revisions.length - 1) {
5716 return revisions[currentIndex + 1];
5717 }
5718 const totalRevisions = getCurrentPostRevisionsCount(state);
5719 const totalPages = Math.ceil(totalRevisions / query.per_page) || 1;
5720 if (currentIndex === revisions.length - 1 && page < totalPages) {
5721 const nextPageRevisions = select6(import_core_data4.store).getRevisions(
5722 "postType",
5723 postType2,
5724 postId2,
5725 buildRevisionsPageQuery(revisionKey, page + 1)
5726 );
5727 return nextPageRevisions?.[0] ?? null;
5728 }
5729 return null;
5730 }
5731 );
5732 var isCollaborationEnabledForCurrentPost = (0, import_data5.createRegistrySelector)(
5733 (select6) => (state) => {
5734 if (!unlock(select6(import_core_data4.store)).isCollaborationSupported()) {
5735 return false;
5736 }
5737 const currentPostType = getCurrentPostType(state);
5738 const entityConfig = select6(import_core_data4.store).getEntityConfig(
5739 "postType",
5740 currentPostType
5741 );
5742 return Boolean(
5743 entityConfig?.syncConfig && window._wpCollaborationEnabled
5744 );
5745 }
5746 );
5747
5748 // packages/editor/build-module/dataviews/store/private-actions.mjs
5749 var import_core_data52 = __toESM(require_core_data(), 1);
5750 var import_hooks38 = __toESM(require_hooks(), 1);
5751
5752 // packages/fields/build-module/fields/slug/index.mjs
5753 var import_i18n5 = __toESM(require_i18n(), 1);
5754
5755 // packages/fields/build-module/fields/slug/slug-edit.mjs
5756 var import_components = __toESM(require_components(), 1);
5757 var import_compose = __toESM(require_compose(), 1);
5758 var import_data6 = __toESM(require_data(), 1);
5759 var import_element3 = __toESM(require_element(), 1);
5760 var import_notices2 = __toESM(require_notices(), 1);
5761 var import_url5 = __toESM(require_url(), 1);
5762 var import_i18n4 = __toESM(require_i18n(), 1);
5763
5764 // packages/fields/build-module/fields/slug/utils.mjs
5765 var import_url4 = __toESM(require_url(), 1);
5766
5767 // packages/fields/build-module/actions/utils.mjs
5768 var import_html_entities = __toESM(require_html_entities(), 1);
5769 var import_i18n3 = __toESM(require_i18n(), 1);
5770 function isTemplate(post2) {
5771 return post2.type === "wp_template";
5772 }
5773 function isTemplatePart(post2) {
5774 return post2.type === "wp_template_part";
5775 }
5776 function isTemplateOrTemplatePart(p4) {
5777 return p4.type === "wp_template" || p4.type === "wp_template_part";
5778 }
5779 function getItemTitle(item, fallback = (0, import_i18n3.__)("(no title)")) {
5780 let title = "";
5781 if (typeof item.title === "string") {
5782 title = (0, import_html_entities.decodeEntities)(item.title);
5783 } else if (item.title && "rendered" in item.title) {
5784 title = (0, import_html_entities.decodeEntities)(item.title.rendered);
5785 } else if (item.title && "raw" in item.title) {
5786 title = (0, import_html_entities.decodeEntities)(item.title.raw);
5787 }
5788 return title || fallback;
5789 }
5790 function isTemplateRemovable(template2) {
5791 if (!template2) {
5792 return false;
5793 }
5794 return [template2.source, template2.source].includes("custom") && !Boolean(template2.type === "wp_template" && template2?.plugin) && !template2.has_theme_file;
5795 }
5796
5797 // packages/fields/build-module/fields/slug/utils.mjs
5798 var getSlug = (item) => {
5799 if (typeof item !== "object") {
5800 return "";
5801 }
5802 return item.slug || (0, import_url4.cleanForSlug)(getItemTitle(item)) || item.id.toString();
5803 };
5804
5805 // packages/fields/build-module/fields/slug/slug-edit.mjs
5806 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
5807 var SlugEdit = ({
5808 field,
5809 onChange,
5810 data
5811 }) => {
5812 const { id } = field;
5813 const slug = field.getValue({ item: data }) || getSlug(data);
5814 const permalinkTemplate = data.permalink_template || "";
5815 const PERMALINK_POSTNAME_REGEX2 = /%(?:postname|pagename)%/;
5816 const [prefix2, suffix] = permalinkTemplate.split(
5817 PERMALINK_POSTNAME_REGEX2
5818 );
5819 const permalinkPrefix = prefix2;
5820 const permalinkSuffix = suffix;
5821 const isEditable = PERMALINK_POSTNAME_REGEX2.test(permalinkTemplate);
5822 const originalSlugRef = (0, import_element3.useRef)(slug);
5823 const slugToDisplay = slug || originalSlugRef.current;
5824 const permalink = isEditable ? `${permalinkPrefix}${slugToDisplay}${permalinkSuffix}` : (0, import_url5.safeDecodeURIComponent)(data.link || "");
5825 (0, import_element3.useEffect)(() => {
5826 if (slug && originalSlugRef.current === void 0) {
5827 originalSlugRef.current = slug;
5828 }
5829 }, [slug]);
5830 const onChangeControl = (0, import_element3.useCallback)(
5831 (newValue) => onChange({
5832 [id]: newValue
5833 }),
5834 [id, onChange]
5835 );
5836 const { createNotice } = (0, import_data6.useDispatch)(import_notices2.store);
5837 const copyButtonRef = (0, import_compose.useCopyToClipboard)(permalink, () => {
5838 createNotice("info", (0, import_i18n4.__)("Copied Permalink to clipboard."), {
5839 isDismissible: true,
5840 type: "snackbar"
5841 });
5842 });
5843 const postUrlSlugDescriptionId = "editor-post-url__slug-description-" + (0, import_compose.useInstanceId)(SlugEdit);
5844 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("fieldset", { className: "fields-controls__slug", children: [
5845 isEditable && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_components.__experimentalVStack, { children: [
5846 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_components.__experimentalVStack, { spacing: "0px", children: [
5847 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { children: (0, import_i18n4.__)(
5848 "Customize the last part of the Permalink."
5849 ) }),
5850 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components.ExternalLink, { href: "https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink", children: (0, import_i18n4.__)("Learn more") })
5851 ] }),
5852 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
5853 import_components.__experimentalInputControl,
5854 {
5855 __next40pxDefaultSize: true,
5856 prefix: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components.__experimentalInputControlPrefixWrapper, { children: "/" }),
5857 suffix: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
5858 import_components.Button,
5859 {
5860 size: "small",
5861 icon: copy_small_default,
5862 ref: copyButtonRef,
5863 label: (0, import_i18n4.__)("Copy")
5864 }
5865 ) }),
5866 label: (0, import_i18n4.__)("Link"),
5867 hideLabelFromVision: true,
5868 value: slug,
5869 autoComplete: "off",
5870 spellCheck: "false",
5871 type: "text",
5872 className: "fields-controls__slug-input",
5873 onChange: (newValue) => {
5874 onChangeControl(newValue);
5875 },
5876 onBlur: () => {
5877 if (slug === "") {
5878 onChangeControl(originalSlugRef.current);
5879 }
5880 },
5881 "aria-describedby": postUrlSlugDescriptionId
5882 }
5883 ),
5884 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "fields-controls__slug-help", children: [
5885 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { className: "fields-controls__slug-help-visual-label", children: (0, import_i18n4.__)("Permalink:") }),
5886 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
5887 import_components.ExternalLink,
5888 {
5889 className: "fields-controls__slug-help-link",
5890 href: permalink,
5891 children: [
5892 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { className: "fields-controls__slug-help-prefix", children: permalinkPrefix }),
5893 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { className: "fields-controls__slug-help-slug", children: slugToDisplay }),
5894 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { className: "fields-controls__slug-help-suffix", children: permalinkSuffix })
5895 ]
5896 }
5897 )
5898 ] })
5899 ] }),
5900 !isEditable && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
5901 import_components.ExternalLink,
5902 {
5903 className: "fields-controls__slug-help",
5904 href: permalink,
5905 children: permalink
5906 }
5907 )
5908 ] });
5909 };
5910 var slug_edit_default = SlugEdit;
5911
5912 // packages/fields/build-module/fields/slug/slug-view.mjs
5913 var import_element4 = __toESM(require_element(), 1);
5914 var SlugView = ({ item }) => {
5915 const slug = getSlug(item);
5916 const originalSlugRef = (0, import_element4.useRef)(slug);
5917 (0, import_element4.useEffect)(() => {
5918 if (slug && originalSlugRef.current === void 0) {
5919 originalSlugRef.current = slug;
5920 }
5921 }, [slug]);
5922 const slugToDisplay = slug || originalSlugRef.current;
5923 return `${slugToDisplay}`;
5924 };
5925 var slug_view_default = SlugView;
5926
5927 // packages/fields/build-module/fields/slug/index.mjs
5928 var slugField = {
5929 id: "slug",
5930 type: "text",
5931 label: (0, import_i18n5.__)("Slug"),
5932 Edit: slug_edit_default,
5933 render: slug_view_default,
5934 filterBy: false
5935 };
5936 var slug_default = slugField;
5937
5938 // packages/fields/build-module/fields/title/index.mjs
5939 var import_i18n7 = __toESM(require_i18n(), 1);
5940
5941 // node_modules/clsx/dist/clsx.mjs
5942 function r(e3) {
5943 var t4, f3, n3 = "";
5944 if ("string" == typeof e3 || "number" == typeof e3) n3 += e3;
5945 else if ("object" == typeof e3) if (Array.isArray(e3)) {
5946 var o4 = e3.length;
5947 for (t4 = 0; t4 < o4; t4++) e3[t4] && (f3 = r(e3[t4])) && (n3 && (n3 += " "), n3 += f3);
5948 } else for (f3 in e3) e3[f3] && (n3 && (n3 += " "), n3 += f3);
5949 return n3;
5950 }
5951 function clsx() {
5952 for (var e3, t4, f3 = 0, n3 = "", o4 = arguments.length; f3 < o4; f3++) (e3 = arguments[f3]) && (t4 = r(e3)) && (n3 && (n3 += " "), n3 += t4);
5953 return n3;
5954 }
5955 var clsx_default = clsx;
5956
5957 // packages/fields/build-module/fields/title/view.mjs
5958 var import_components2 = __toESM(require_components(), 1);
5959 var import_i18n6 = __toESM(require_i18n(), 1);
5960 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
5961 function BaseTitleView({
5962 item,
5963 className,
5964 children
5965 }) {
5966 const renderedTitle = getItemTitle(item);
5967 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
5968 import_components2.__experimentalHStack,
5969 {
5970 className: clsx_default("fields-field__title", className),
5971 alignment: "center",
5972 justify: "flex-start",
5973 children: [
5974 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { children: renderedTitle || (0, import_i18n6.__)("(no title)") }),
5975 children
5976 ]
5977 }
5978 );
5979 }
5980 function TitleView({ item }) {
5981 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(BaseTitleView, { item });
5982 }
5983
5984 // packages/fields/build-module/fields/title/index.mjs
5985 var titleField = {
5986 type: "text",
5987 id: "title",
5988 label: (0, import_i18n7.__)("Title"),
5989 placeholder: (0, import_i18n7.__)("No title"),
5990 getValue: ({ item }) => getItemTitle(item),
5991 render: TitleView,
5992 enableHiding: true,
5993 enableGlobalSearch: true,
5994 filterBy: false
5995 };
5996 var title_default = titleField;
5997
5998 // packages/fields/build-module/fields/page-title/index.mjs
5999 var import_i18n9 = __toESM(require_i18n(), 1);
6000
6001 // packages/fields/build-module/fields/page-title/view.mjs
6002 var import_i18n8 = __toESM(require_i18n(), 1);
6003 var import_data7 = __toESM(require_data(), 1);
6004 var import_core_data5 = __toESM(require_core_data(), 1);
6005 var import_components3 = __toESM(require_components(), 1);
6006
6007 // packages/fields/build-module/lock-unlock.mjs
6008 var import_private_apis2 = __toESM(require_private_apis(), 1);
6009 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
6010 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
6011 "@wordpress/fields"
6012 );
6013
6014 // packages/fields/build-module/fields/page-title/view.mjs
6015 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
6016 var { Badge } = unlock2(import_components3.privateApis);
6017 function PageTitleView({ item }) {
6018 const { frontPageId, postsPageId } = (0, import_data7.useSelect)((select6) => {
6019 const { getEntityRecord } = select6(import_core_data5.store);
6020 const siteSettings = getEntityRecord(
6021 "root",
6022 "site"
6023 );
6024 return {
6025 frontPageId: siteSettings?.page_on_front,
6026 postsPageId: siteSettings?.page_for_posts
6027 };
6028 }, []);
6029 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(BaseTitleView, { item, className: "fields-field__page-title", children: [frontPageId, postsPageId].includes(item.id) && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Badge, { children: item.id === frontPageId ? (0, import_i18n8.__)("Homepage") : (0, import_i18n8.__)("Posts Page") }) });
6030 }
6031
6032 // packages/fields/build-module/fields/page-title/index.mjs
6033 var pageTitleField = {
6034 type: "text",
6035 id: "title",
6036 label: (0, import_i18n9.__)("Title"),
6037 placeholder: (0, import_i18n9.__)("No title"),
6038 getValue: ({ item }) => getItemTitle(item),
6039 render: PageTitleView,
6040 enableHiding: false,
6041 enableGlobalSearch: true,
6042 filterBy: false
6043 };
6044 var page_title_default = pageTitleField;
6045
6046 // packages/fields/build-module/fields/template-title/index.mjs
6047 var import_i18n10 = __toESM(require_i18n(), 1);
6048 var templateTitleField = {
6049 type: "text",
6050 label: (0, import_i18n10.__)("Template"),
6051 placeholder: (0, import_i18n10.__)("No title"),
6052 id: "title",
6053 getValue: ({ item }) => getItemTitle(item),
6054 render: TitleView,
6055 enableHiding: false,
6056 enableGlobalSearch: true,
6057 filterBy: false
6058 };
6059 var template_title_default = templateTitleField;
6060
6061 // packages/fields/build-module/fields/pattern-title/index.mjs
6062 var import_i18n12 = __toESM(require_i18n(), 1);
6063
6064 // packages/fields/build-module/fields/pattern-title/view.mjs
6065 var import_i18n11 = __toESM(require_i18n(), 1);
6066 var import_components4 = __toESM(require_components(), 1);
6067 var import_patterns = __toESM(require_patterns(), 1);
6068 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
6069 var { PATTERN_TYPES } = unlock2(import_patterns.privateApis);
6070 function PatternTitleView({ item }) {
6071 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(BaseTitleView, { item, className: "fields-field__pattern-title", children: item.type === PATTERN_TYPES.theme && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
6072 import_components4.Tooltip,
6073 {
6074 placement: "top",
6075 text: (0, import_i18n11.__)("This pattern cannot be edited."),
6076 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(icon_default, { icon: lock_small_default, size: 24 })
6077 }
6078 ) });
6079 }
6080
6081 // packages/fields/build-module/fields/pattern-title/index.mjs
6082 var patternTitleField = {
6083 type: "text",
6084 id: "title",
6085 label: (0, import_i18n12.__)("Title"),
6086 placeholder: (0, import_i18n12.__)("No title"),
6087 getValue: ({ item }) => getItemTitle(item),
6088 render: PatternTitleView,
6089 enableHiding: false,
6090 enableGlobalSearch: true,
6091 filterBy: false
6092 };
6093 var pattern_title_default = patternTitleField;
6094
6095 // packages/fields/build-module/fields/featured-image/index.mjs
6096 var import_i18n14 = __toESM(require_i18n(), 1);
6097
6098 // packages/fields/build-module/components/media-edit/index.mjs
6099 var import_components5 = __toESM(require_components(), 1);
6100 var import_blob = __toESM(require_blob(), 1);
6101 var import_core_data6 = __toESM(require_core_data(), 1);
6102 var import_data8 = __toESM(require_data(), 1);
6103 var import_element6 = __toESM(require_element(), 1);
6104 var import_i18n13 = __toESM(require_i18n(), 1);
6105 var import_media_utils2 = __toESM(require_media_utils(), 1);
6106 var import_notices3 = __toESM(require_notices(), 1);
6107
6108 // node_modules/@react-spring/rafz/dist/react-spring-rafz.esm.js
6109 var updateQueue = makeQueue();
6110 var raf = (fn) => schedule(fn, updateQueue);
6111 var writeQueue = makeQueue();
6112 raf.write = (fn) => schedule(fn, writeQueue);
6113 var onStartQueue = makeQueue();
6114 raf.onStart = (fn) => schedule(fn, onStartQueue);
6115 var onFrameQueue = makeQueue();
6116 raf.onFrame = (fn) => schedule(fn, onFrameQueue);
6117 var onFinishQueue = makeQueue();
6118 raf.onFinish = (fn) => schedule(fn, onFinishQueue);
6119 var timeouts = [];
6120 raf.setTimeout = (handler, ms) => {
6121 let time = raf.now() + ms;
6122 let cancel = () => {
6123 let i3 = timeouts.findIndex((t4) => t4.cancel == cancel);
6124 if (~i3) timeouts.splice(i3, 1);
6125 pendingCount -= ~i3 ? 1 : 0;
6126 };
6127 let timeout = {
6128 time,
6129 handler,
6130 cancel
6131 };
6132 timeouts.splice(findTimeout(time), 0, timeout);
6133 pendingCount += 1;
6134 start();
6135 return timeout;
6136 };
6137 var findTimeout = (time) => ~(~timeouts.findIndex((t4) => t4.time > time) || ~timeouts.length);
6138 raf.cancel = (fn) => {
6139 onStartQueue.delete(fn);
6140 onFrameQueue.delete(fn);
6141 onFinishQueue.delete(fn);
6142 updateQueue.delete(fn);
6143 writeQueue.delete(fn);
6144 };
6145 raf.sync = (fn) => {
6146 sync = true;
6147 raf.batchedUpdates(fn);
6148 sync = false;
6149 };
6150 raf.throttle = (fn) => {
6151 let lastArgs;
6152 function queuedFn() {
6153 try {
6154 fn(...lastArgs);
6155 } finally {
6156 lastArgs = null;
6157 }
6158 }
6159 function throttled(...args) {
6160 lastArgs = args;
6161 raf.onStart(queuedFn);
6162 }
6163 throttled.handler = fn;
6164 throttled.cancel = () => {
6165 onStartQueue.delete(queuedFn);
6166 lastArgs = null;
6167 };
6168 return throttled;
6169 };
6170 var nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : () => {
6171 };
6172 raf.use = (impl) => nativeRaf = impl;
6173 raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now;
6174 raf.batchedUpdates = (fn) => fn();
6175 raf.catch = console.error;
6176 raf.frameLoop = "always";
6177 raf.advance = () => {
6178 if (raf.frameLoop !== "demand") {
6179 console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand");
6180 } else {
6181 update();
6182 }
6183 };
6184 var ts = -1;
6185 var pendingCount = 0;
6186 var sync = false;
6187 function schedule(fn, queue) {
6188 if (sync) {
6189 queue.delete(fn);
6190 fn(0);
6191 } else {
6192 queue.add(fn);
6193 start();
6194 }
6195 }
6196 function start() {
6197 if (ts < 0) {
6198 ts = 0;
6199 if (raf.frameLoop !== "demand") {
6200 nativeRaf(loop);
6201 }
6202 }
6203 }
6204 function stop() {
6205 ts = -1;
6206 }
6207 function loop() {
6208 if (~ts) {
6209 nativeRaf(loop);
6210 raf.batchedUpdates(update);
6211 }
6212 }
6213 function update() {
6214 let prevTs = ts;
6215 ts = raf.now();
6216 let count = findTimeout(ts);
6217 if (count) {
6218 eachSafely(timeouts.splice(0, count), (t4) => t4.handler());
6219 pendingCount -= count;
6220 }
6221 if (!pendingCount) {
6222 stop();
6223 return;
6224 }
6225 onStartQueue.flush();
6226 updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
6227 onFrameQueue.flush();
6228 writeQueue.flush();
6229 onFinishQueue.flush();
6230 }
6231 function makeQueue() {
6232 let next = /* @__PURE__ */ new Set();
6233 let current = next;
6234 return {
6235 add(fn) {
6236 pendingCount += current == next && !next.has(fn) ? 1 : 0;
6237 next.add(fn);
6238 },
6239 delete(fn) {
6240 pendingCount -= current == next && next.has(fn) ? 1 : 0;
6241 return next.delete(fn);
6242 },
6243 flush(arg) {
6244 if (current.size) {
6245 next = /* @__PURE__ */ new Set();
6246 pendingCount -= current.size;
6247 eachSafely(current, (fn) => fn(arg) && next.add(fn));
6248 pendingCount += next.size;
6249 current = next;
6250 }
6251 }
6252 };
6253 }
6254 function eachSafely(values, each2) {
6255 values.forEach((value) => {
6256 try {
6257 each2(value);
6258 } catch (e3) {
6259 raf.catch(e3);
6260 }
6261 });
6262 }
6263
6264 // node_modules/@react-spring/shared/dist/react-spring-shared.esm.js
6265 var import_react = __toESM(require_react());
6266 function noop2() {
6267 }
6268 var defineHidden = (obj, key, value) => Object.defineProperty(obj, key, {
6269 value,
6270 writable: true,
6271 configurable: true
6272 });
6273 var is = {
6274 arr: Array.isArray,
6275 obj: (a3) => !!a3 && a3.constructor.name === "Object",
6276 fun: (a3) => typeof a3 === "function",
6277 str: (a3) => typeof a3 === "string",
6278 num: (a3) => typeof a3 === "number",
6279 und: (a3) => a3 === void 0
6280 };
6281 function isEqual(a3, b3) {
6282 if (is.arr(a3)) {
6283 if (!is.arr(b3) || a3.length !== b3.length) return false;
6284 for (let i3 = 0; i3 < a3.length; i3++) {
6285 if (a3[i3] !== b3[i3]) return false;
6286 }
6287 return true;
6288 }
6289 return a3 === b3;
6290 }
6291 var each = (obj, fn) => obj.forEach(fn);
6292 function eachProp(obj, fn, ctx2) {
6293 if (is.arr(obj)) {
6294 for (let i3 = 0; i3 < obj.length; i3++) {
6295 fn.call(ctx2, obj[i3], `${i3}`);
6296 }
6297 return;
6298 }
6299 for (const key in obj) {
6300 if (obj.hasOwnProperty(key)) {
6301 fn.call(ctx2, obj[key], key);
6302 }
6303 }
6304 }
6305 var toArray = (a3) => is.und(a3) ? [] : is.arr(a3) ? a3 : [a3];
6306 function flush(queue, iterator) {
6307 if (queue.size) {
6308 const items = Array.from(queue);
6309 queue.clear();
6310 each(items, iterator);
6311 }
6312 }
6313 var flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args));
6314 var isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
6315 var createStringInterpolator$1;
6316 var to;
6317 var colors$1 = null;
6318 var skipAnimation = false;
6319 var willAdvance = noop2;
6320 var assign = (globals2) => {
6321 if (globals2.to) to = globals2.to;
6322 if (globals2.now) raf.now = globals2.now;
6323 if (globals2.colors !== void 0) colors$1 = globals2.colors;
6324 if (globals2.skipAnimation != null) skipAnimation = globals2.skipAnimation;
6325 if (globals2.createStringInterpolator) createStringInterpolator$1 = globals2.createStringInterpolator;
6326 if (globals2.requestAnimationFrame) raf.use(globals2.requestAnimationFrame);
6327 if (globals2.batchedUpdates) raf.batchedUpdates = globals2.batchedUpdates;
6328 if (globals2.willAdvance) willAdvance = globals2.willAdvance;
6329 if (globals2.frameLoop) raf.frameLoop = globals2.frameLoop;
6330 };
6331 var globals = /* @__PURE__ */ Object.freeze({
6332 __proto__: null,
6333 get createStringInterpolator() {
6334 return createStringInterpolator$1;
6335 },
6336 get to() {
6337 return to;
6338 },
6339 get colors() {
6340 return colors$1;
6341 },
6342 get skipAnimation() {
6343 return skipAnimation;
6344 },
6345 get willAdvance() {
6346 return willAdvance;
6347 },
6348 assign
6349 });
6350 var startQueue = /* @__PURE__ */ new Set();
6351 var currentFrame = [];
6352 var prevFrame = [];
6353 var priority = 0;
6354 var frameLoop = {
6355 get idle() {
6356 return !startQueue.size && !currentFrame.length;
6357 },
6358 start(animation) {
6359 if (priority > animation.priority) {
6360 startQueue.add(animation);
6361 raf.onStart(flushStartQueue);
6362 } else {
6363 startSafely(animation);
6364 raf(advance);
6365 }
6366 },
6367 advance,
6368 sort(animation) {
6369 if (priority) {
6370 raf.onFrame(() => frameLoop.sort(animation));
6371 } else {
6372 const prevIndex = currentFrame.indexOf(animation);
6373 if (~prevIndex) {
6374 currentFrame.splice(prevIndex, 1);
6375 startUnsafely(animation);
6376 }
6377 }
6378 },
6379 clear() {
6380 currentFrame = [];
6381 startQueue.clear();
6382 }
6383 };
6384 function flushStartQueue() {
6385 startQueue.forEach(startSafely);
6386 startQueue.clear();
6387 raf(advance);
6388 }
6389 function startSafely(animation) {
6390 if (!currentFrame.includes(animation)) startUnsafely(animation);
6391 }
6392 function startUnsafely(animation) {
6393 currentFrame.splice(findIndex(currentFrame, (other) => other.priority > animation.priority), 0, animation);
6394 }
6395 function advance(dt) {
6396 const nextFrame = prevFrame;
6397 for (let i3 = 0; i3 < currentFrame.length; i3++) {
6398 const animation = currentFrame[i3];
6399 priority = animation.priority;
6400 if (!animation.idle) {
6401 willAdvance(animation);
6402 animation.advance(dt);
6403 if (!animation.idle) {
6404 nextFrame.push(animation);
6405 }
6406 }
6407 }
6408 priority = 0;
6409 prevFrame = currentFrame;
6410 prevFrame.length = 0;
6411 currentFrame = nextFrame;
6412 return currentFrame.length > 0;
6413 }
6414 function findIndex(arr, test) {
6415 const index2 = arr.findIndex(test);
6416 return index2 < 0 ? arr.length : index2;
6417 }
6418 var colors = {
6419 transparent: 0,
6420 aliceblue: 4042850303,
6421 antiquewhite: 4209760255,
6422 aqua: 16777215,
6423 aquamarine: 2147472639,
6424 azure: 4043309055,
6425 beige: 4126530815,
6426 bisque: 4293182719,
6427 black: 255,
6428 blanchedalmond: 4293643775,
6429 blue: 65535,
6430 blueviolet: 2318131967,
6431 brown: 2771004159,
6432 burlywood: 3736635391,
6433 burntsienna: 3934150143,
6434 cadetblue: 1604231423,
6435 chartreuse: 2147418367,
6436 chocolate: 3530104575,
6437 coral: 4286533887,
6438 cornflowerblue: 1687547391,
6439 cornsilk: 4294499583,
6440 crimson: 3692313855,
6441 cyan: 16777215,
6442 darkblue: 35839,
6443 darkcyan: 9145343,
6444 darkgoldenrod: 3095792639,
6445 darkgray: 2846468607,
6446 darkgreen: 6553855,
6447 darkgrey: 2846468607,
6448 darkkhaki: 3182914559,
6449 darkmagenta: 2332068863,
6450 darkolivegreen: 1433087999,
6451 darkorange: 4287365375,
6452 darkorchid: 2570243327,
6453 darkred: 2332033279,
6454 darksalmon: 3918953215,
6455 darkseagreen: 2411499519,
6456 darkslateblue: 1211993087,
6457 darkslategray: 793726975,
6458 darkslategrey: 793726975,
6459 darkturquoise: 13554175,
6460 darkviolet: 2483082239,
6461 deeppink: 4279538687,
6462 deepskyblue: 12582911,
6463 dimgray: 1768516095,
6464 dimgrey: 1768516095,
6465 dodgerblue: 512819199,
6466 firebrick: 2988581631,
6467 floralwhite: 4294635775,
6468 forestgreen: 579543807,
6469 fuchsia: 4278255615,
6470 gainsboro: 3705462015,
6471 ghostwhite: 4177068031,
6472 gold: 4292280575,
6473 goldenrod: 3668254975,
6474 gray: 2155905279,
6475 green: 8388863,
6476 greenyellow: 2919182335,
6477 grey: 2155905279,
6478 honeydew: 4043305215,
6479 hotpink: 4285117695,
6480 indianred: 3445382399,
6481 indigo: 1258324735,
6482 ivory: 4294963455,
6483 khaki: 4041641215,
6484 lavender: 3873897215,
6485 lavenderblush: 4293981695,
6486 lawngreen: 2096890111,
6487 lemonchiffon: 4294626815,
6488 lightblue: 2916673279,
6489 lightcoral: 4034953471,
6490 lightcyan: 3774873599,
6491 lightgoldenrodyellow: 4210742015,
6492 lightgray: 3553874943,
6493 lightgreen: 2431553791,
6494 lightgrey: 3553874943,
6495 lightpink: 4290167295,
6496 lightsalmon: 4288707327,
6497 lightseagreen: 548580095,
6498 lightskyblue: 2278488831,
6499 lightslategray: 2005441023,
6500 lightslategrey: 2005441023,
6501 lightsteelblue: 2965692159,
6502 lightyellow: 4294959359,
6503 lime: 16711935,
6504 limegreen: 852308735,
6505 linen: 4210091775,
6506 magenta: 4278255615,
6507 maroon: 2147483903,
6508 mediumaquamarine: 1724754687,
6509 mediumblue: 52735,
6510 mediumorchid: 3126187007,
6511 mediumpurple: 2473647103,
6512 mediumseagreen: 1018393087,
6513 mediumslateblue: 2070474495,
6514 mediumspringgreen: 16423679,
6515 mediumturquoise: 1221709055,
6516 mediumvioletred: 3340076543,
6517 midnightblue: 421097727,
6518 mintcream: 4127193855,
6519 mistyrose: 4293190143,
6520 moccasin: 4293178879,
6521 navajowhite: 4292783615,
6522 navy: 33023,
6523 oldlace: 4260751103,
6524 olive: 2155872511,
6525 olivedrab: 1804477439,
6526 orange: 4289003775,
6527 orangered: 4282712319,
6528 orchid: 3664828159,
6529 palegoldenrod: 4008225535,
6530 palegreen: 2566625535,
6531 paleturquoise: 2951671551,
6532 palevioletred: 3681588223,
6533 papayawhip: 4293907967,
6534 peachpuff: 4292524543,
6535 peru: 3448061951,
6536 pink: 4290825215,
6537 plum: 3718307327,
6538 powderblue: 2967529215,
6539 purple: 2147516671,
6540 rebeccapurple: 1714657791,
6541 red: 4278190335,
6542 rosybrown: 3163525119,
6543 royalblue: 1097458175,
6544 saddlebrown: 2336560127,
6545 salmon: 4202722047,
6546 sandybrown: 4104413439,
6547 seagreen: 780883967,
6548 seashell: 4294307583,
6549 sienna: 2689740287,
6550 silver: 3233857791,
6551 skyblue: 2278484991,
6552 slateblue: 1784335871,
6553 slategray: 1887473919,
6554 slategrey: 1887473919,
6555 snow: 4294638335,
6556 springgreen: 16744447,
6557 steelblue: 1182971135,
6558 tan: 3535047935,
6559 teal: 8421631,
6560 thistle: 3636451583,
6561 tomato: 4284696575,
6562 turquoise: 1088475391,
6563 violet: 4001558271,
6564 wheat: 4125012991,
6565 white: 4294967295,
6566 whitesmoke: 4126537215,
6567 yellow: 4294902015,
6568 yellowgreen: 2597139199
6569 };
6570 var NUMBER = "[-+]?\\d*\\.?\\d+";
6571 var PERCENTAGE = NUMBER + "%";
6572 function call(...parts) {
6573 return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)";
6574 }
6575 var rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER));
6576 var rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER));
6577 var hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE));
6578 var hsla = new RegExp("hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
6579 var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
6580 var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
6581 var hex6 = /^#([0-9a-fA-F]{6})$/;
6582 var hex8 = /^#([0-9a-fA-F]{8})$/;
6583 function normalizeColor(color) {
6584 let match3;
6585 if (typeof color === "number") {
6586 return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null;
6587 }
6588 if (match3 = hex6.exec(color)) return parseInt(match3[1] + "ff", 16) >>> 0;
6589 if (colors$1 && colors$1[color] !== void 0) {
6590 return colors$1[color];
6591 }
6592 if (match3 = rgb.exec(color)) {
6593 return (parse255(match3[1]) << 24 | parse255(match3[2]) << 16 | parse255(match3[3]) << 8 | 255) >>> 0;
6594 }
6595 if (match3 = rgba.exec(color)) {
6596 return (parse255(match3[1]) << 24 | parse255(match3[2]) << 16 | parse255(match3[3]) << 8 | parse1(match3[4])) >>> 0;
6597 }
6598 if (match3 = hex3.exec(color)) {
6599 return parseInt(match3[1] + match3[1] + match3[2] + match3[2] + match3[3] + match3[3] + "ff", 16) >>> 0;
6600 }
6601 if (match3 = hex8.exec(color)) return parseInt(match3[1], 16) >>> 0;
6602 if (match3 = hex4.exec(color)) {
6603 return parseInt(match3[1] + match3[1] + match3[2] + match3[2] + match3[3] + match3[3] + match3[4] + match3[4], 16) >>> 0;
6604 }
6605 if (match3 = hsl.exec(color)) {
6606 return (hslToRgb(parse360(match3[1]), parsePercentage(match3[2]), parsePercentage(match3[3])) | 255) >>> 0;
6607 }
6608 if (match3 = hsla.exec(color)) {
6609 return (hslToRgb(parse360(match3[1]), parsePercentage(match3[2]), parsePercentage(match3[3])) | parse1(match3[4])) >>> 0;
6610 }
6611 return null;
6612 }
6613 function hue2rgb(p4, q, t4) {
6614 if (t4 < 0) t4 += 1;
6615 if (t4 > 1) t4 -= 1;
6616 if (t4 < 1 / 6) return p4 + (q - p4) * 6 * t4;
6617 if (t4 < 1 / 2) return q;
6618 if (t4 < 2 / 3) return p4 + (q - p4) * (2 / 3 - t4) * 6;
6619 return p4;
6620 }
6621 function hslToRgb(h3, s3, l3) {
6622 const q = l3 < 0.5 ? l3 * (1 + s3) : l3 + s3 - l3 * s3;
6623 const p4 = 2 * l3 - q;
6624 const r4 = hue2rgb(p4, q, h3 + 1 / 3);
6625 const g3 = hue2rgb(p4, q, h3);
6626 const b3 = hue2rgb(p4, q, h3 - 1 / 3);
6627 return Math.round(r4 * 255) << 24 | Math.round(g3 * 255) << 16 | Math.round(b3 * 255) << 8;
6628 }
6629 function parse255(str) {
6630 const int = parseInt(str, 10);
6631 if (int < 0) return 0;
6632 if (int > 255) return 255;
6633 return int;
6634 }
6635 function parse360(str) {
6636 const int = parseFloat(str);
6637 return (int % 360 + 360) % 360 / 360;
6638 }
6639 function parse1(str) {
6640 const num = parseFloat(str);
6641 if (num < 0) return 0;
6642 if (num > 1) return 255;
6643 return Math.round(num * 255);
6644 }
6645 function parsePercentage(str) {
6646 const int = parseFloat(str);
6647 if (int < 0) return 0;
6648 if (int > 100) return 1;
6649 return int / 100;
6650 }
6651 function colorToRgba(input) {
6652 let int32Color = normalizeColor(input);
6653 if (int32Color === null) return input;
6654 int32Color = int32Color || 0;
6655 let r4 = (int32Color & 4278190080) >>> 24;
6656 let g3 = (int32Color & 16711680) >>> 16;
6657 let b3 = (int32Color & 65280) >>> 8;
6658 let a3 = (int32Color & 255) / 255;
6659 return `rgba(${r4}, ${g3}, ${b3}, ${a3})`;
6660 }
6661 var createInterpolator = (range, output, extrapolate) => {
6662 if (is.fun(range)) {
6663 return range;
6664 }
6665 if (is.arr(range)) {
6666 return createInterpolator({
6667 range,
6668 output,
6669 extrapolate
6670 });
6671 }
6672 if (is.str(range.output[0])) {
6673 return createStringInterpolator$1(range);
6674 }
6675 const config2 = range;
6676 const outputRange = config2.output;
6677 const inputRange = config2.range || [0, 1];
6678 const extrapolateLeft = config2.extrapolateLeft || config2.extrapolate || "extend";
6679 const extrapolateRight = config2.extrapolateRight || config2.extrapolate || "extend";
6680 const easing = config2.easing || ((t4) => t4);
6681 return (input) => {
6682 const range2 = findRange(input, inputRange);
6683 return interpolate(input, inputRange[range2], inputRange[range2 + 1], outputRange[range2], outputRange[range2 + 1], easing, extrapolateLeft, extrapolateRight, config2.map);
6684 };
6685 };
6686 function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
6687 let result = map ? map(input) : input;
6688 if (result < inputMin) {
6689 if (extrapolateLeft === "identity") return result;
6690 else if (extrapolateLeft === "clamp") result = inputMin;
6691 }
6692 if (result > inputMax) {
6693 if (extrapolateRight === "identity") return result;
6694 else if (extrapolateRight === "clamp") result = inputMax;
6695 }
6696 if (outputMin === outputMax) return outputMin;
6697 if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax;
6698 if (inputMin === -Infinity) result = -result;
6699 else if (inputMax === Infinity) result = result - inputMin;
6700 else result = (result - inputMin) / (inputMax - inputMin);
6701 result = easing(result);
6702 if (outputMin === -Infinity) result = -result;
6703 else if (outputMax === Infinity) result = result + outputMin;
6704 else result = result * (outputMax - outputMin) + outputMin;
6705 return result;
6706 }
6707 function findRange(input, inputRange) {
6708 for (var i3 = 1; i3 < inputRange.length - 1; ++i3) if (inputRange[i3] >= input) break;
6709 return i3 - 1;
6710 }
6711 function _extends() {
6712 _extends = Object.assign ? Object.assign.bind() : function(target) {
6713 for (var i3 = 1; i3 < arguments.length; i3++) {
6714 var source = arguments[i3];
6715 for (var key in source) {
6716 if (Object.prototype.hasOwnProperty.call(source, key)) {
6717 target[key] = source[key];
6718 }
6719 }
6720 }
6721 return target;
6722 };
6723 return _extends.apply(this, arguments);
6724 }
6725 var $get = /* @__PURE__ */ Symbol.for("FluidValue.get");
6726 var $observers = /* @__PURE__ */ Symbol.for("FluidValue.observers");
6727 var hasFluidValue = (arg) => Boolean(arg && arg[$get]);
6728 var getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg;
6729 var getFluidObservers = (target) => target[$observers] || null;
6730 function callFluidObserver(observer, event) {
6731 if (observer.eventObserved) {
6732 observer.eventObserved(event);
6733 } else {
6734 observer(event);
6735 }
6736 }
6737 function callFluidObservers(target, event) {
6738 let observers = target[$observers];
6739 if (observers) {
6740 observers.forEach((observer) => {
6741 callFluidObserver(observer, event);
6742 });
6743 }
6744 }
6745 var FluidValue = class {
6746 constructor(get) {
6747 this[$get] = void 0;
6748 this[$observers] = void 0;
6749 if (!get && !(get = this.get)) {
6750 throw Error("Unknown getter");
6751 }
6752 setFluidGetter(this, get);
6753 }
6754 };
6755 var setFluidGetter = (target, get) => setHidden(target, $get, get);
6756 function addFluidObserver(target, observer) {
6757 if (target[$get]) {
6758 let observers = target[$observers];
6759 if (!observers) {
6760 setHidden(target, $observers, observers = /* @__PURE__ */ new Set());
6761 }
6762 if (!observers.has(observer)) {
6763 observers.add(observer);
6764 if (target.observerAdded) {
6765 target.observerAdded(observers.size, observer);
6766 }
6767 }
6768 }
6769 return observer;
6770 }
6771 function removeFluidObserver(target, observer) {
6772 let observers = target[$observers];
6773 if (observers && observers.has(observer)) {
6774 const count = observers.size - 1;
6775 if (count) {
6776 observers.delete(observer);
6777 } else {
6778 target[$observers] = null;
6779 }
6780 if (target.observerRemoved) {
6781 target.observerRemoved(count, observer);
6782 }
6783 }
6784 }
6785 var setHidden = (target, key, value) => Object.defineProperty(target, key, {
6786 value,
6787 writable: true,
6788 configurable: true
6789 });
6790 var numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
6791 var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
6792 var unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, "i");
6793 var rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
6794 var cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
6795 var variableToRgba = (input) => {
6796 const [token, fallback] = parseCSSVariable(input);
6797 if (!token || isSSR()) {
6798 return input;
6799 }
6800 const value = window.getComputedStyle(document.documentElement).getPropertyValue(token);
6801 if (value) {
6802 return value.trim();
6803 } else if (fallback && fallback.startsWith("--")) {
6804 const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback);
6805 if (_value) {
6806 return _value;
6807 } else {
6808 return input;
6809 }
6810 } else if (fallback && cssVariableRegex.test(fallback)) {
6811 return variableToRgba(fallback);
6812 } else if (fallback) {
6813 return fallback;
6814 }
6815 return input;
6816 };
6817 var parseCSSVariable = (current) => {
6818 const match3 = cssVariableRegex.exec(current);
6819 if (!match3) return [,];
6820 const [, token, fallback] = match3;
6821 return [token, fallback];
6822 };
6823 var namedColorRegex;
6824 var rgbaRound = (_, p1, p22, p32, p4) => `rgba(${Math.round(p1)}, ${Math.round(p22)}, ${Math.round(p32)}, ${p4})`;
6825 var createStringInterpolator = (config2) => {
6826 if (!namedColorRegex) namedColorRegex = colors$1 ? new RegExp(`(${Object.keys(colors$1).join("|")})(?!\\w)`, "g") : /^\b$/;
6827 const output = config2.output.map((value) => {
6828 return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba);
6829 });
6830 const keyframes = output.map((value) => value.match(numberRegex).map(Number));
6831 const outputRanges = keyframes[0].map((_, i3) => keyframes.map((values) => {
6832 if (!(i3 in values)) {
6833 throw Error('The arity of each "output" value must be equal');
6834 }
6835 return values[i3];
6836 }));
6837 const interpolators = outputRanges.map((output2) => createInterpolator(_extends({}, config2, {
6838 output: output2
6839 })));
6840 return (input) => {
6841 var _output$find;
6842 const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find((value) => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, ""));
6843 let i3 = 0;
6844 return output[0].replace(numberRegex, () => `${interpolators[i3++](input)}${missingUnit || ""}`).replace(rgbaRegex, rgbaRound);
6845 };
6846 };
6847 var prefix = "react-spring: ";
6848 var once = (fn) => {
6849 const func = fn;
6850 let called = false;
6851 if (typeof func != "function") {
6852 throw new TypeError(`${prefix}once requires a function parameter`);
6853 }
6854 return (...args) => {
6855 if (!called) {
6856 func(...args);
6857 called = true;
6858 }
6859 };
6860 };
6861 var warnInterpolate = once(console.warn);
6862 function deprecateInterpolate() {
6863 warnInterpolate(`${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`);
6864 }
6865 var warnDirectCall = once(console.warn);
6866 function isAnimatedString(value) {
6867 return is.str(value) && (value[0] == "#" || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {}));
6868 }
6869 var useIsomorphicLayoutEffect = isSSR() ? import_react.useEffect : import_react.useLayoutEffect;
6870 var useIsMounted = () => {
6871 const isMounted = (0, import_react.useRef)(false);
6872 useIsomorphicLayoutEffect(() => {
6873 isMounted.current = true;
6874 return () => {
6875 isMounted.current = false;
6876 };
6877 }, []);
6878 return isMounted;
6879 };
6880 function useForceUpdate() {
6881 const update4 = (0, import_react.useState)()[1];
6882 const isMounted = useIsMounted();
6883 return () => {
6884 if (isMounted.current) {
6885 update4(Math.random());
6886 }
6887 };
6888 }
6889 function useMemoOne(getResult, inputs) {
6890 const [initial] = (0, import_react.useState)(() => ({
6891 inputs,
6892 result: getResult()
6893 }));
6894 const committed = (0, import_react.useRef)();
6895 const prevCache = committed.current;
6896 let cache = prevCache;
6897 if (cache) {
6898 const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs));
6899 if (!useCache) {
6900 cache = {
6901 inputs,
6902 result: getResult()
6903 };
6904 }
6905 } else {
6906 cache = initial;
6907 }
6908 (0, import_react.useEffect)(() => {
6909 committed.current = cache;
6910 if (prevCache == initial) {
6911 initial.inputs = initial.result = void 0;
6912 }
6913 }, [cache]);
6914 return cache.result;
6915 }
6916 function areInputsEqual(next, prev) {
6917 if (next.length !== prev.length) {
6918 return false;
6919 }
6920 for (let i3 = 0; i3 < next.length; i3++) {
6921 if (next[i3] !== prev[i3]) {
6922 return false;
6923 }
6924 }
6925 return true;
6926 }
6927 var useOnce = (effect) => (0, import_react.useEffect)(effect, emptyDeps);
6928 var emptyDeps = [];
6929
6930 // node_modules/@react-spring/core/dist/react-spring-core.esm.js
6931 var React2 = __toESM(require_react());
6932 var import_react3 = __toESM(require_react());
6933
6934 // node_modules/@react-spring/animated/dist/react-spring-animated.esm.js
6935 var React = __toESM(require_react());
6936 var import_react2 = __toESM(require_react());
6937 var $node = /* @__PURE__ */ Symbol.for("Animated:node");
6938 var isAnimated = (value) => !!value && value[$node] === value;
6939 var getAnimated = (owner) => owner && owner[$node];
6940 var setAnimated = (owner, node) => defineHidden(owner, $node, node);
6941 var getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload();
6942 var Animated = class {
6943 constructor() {
6944 this.payload = void 0;
6945 setAnimated(this, this);
6946 }
6947 getPayload() {
6948 return this.payload || [];
6949 }
6950 };
6951 var AnimatedValue = class _AnimatedValue extends Animated {
6952 constructor(_value) {
6953 super();
6954 this.done = true;
6955 this.elapsedTime = void 0;
6956 this.lastPosition = void 0;
6957 this.lastVelocity = void 0;
6958 this.v0 = void 0;
6959 this.durationProgress = 0;
6960 this._value = _value;
6961 if (is.num(this._value)) {
6962 this.lastPosition = this._value;
6963 }
6964 }
6965 static create(value) {
6966 return new _AnimatedValue(value);
6967 }
6968 getPayload() {
6969 return [this];
6970 }
6971 getValue() {
6972 return this._value;
6973 }
6974 setValue(value, step) {
6975 if (is.num(value)) {
6976 this.lastPosition = value;
6977 if (step) {
6978 value = Math.round(value / step) * step;
6979 if (this.done) {
6980 this.lastPosition = value;
6981 }
6982 }
6983 }
6984 if (this._value === value) {
6985 return false;
6986 }
6987 this._value = value;
6988 return true;
6989 }
6990 reset() {
6991 const {
6992 done
6993 } = this;
6994 this.done = false;
6995 if (is.num(this._value)) {
6996 this.elapsedTime = 0;
6997 this.durationProgress = 0;
6998 this.lastPosition = this._value;
6999 if (done) this.lastVelocity = null;
7000 this.v0 = null;
7001 }
7002 }
7003 };
7004 var AnimatedString = class _AnimatedString extends AnimatedValue {
7005 constructor(value) {
7006 super(0);
7007 this._string = null;
7008 this._toString = void 0;
7009 this._toString = createInterpolator({
7010 output: [value, value]
7011 });
7012 }
7013 static create(value) {
7014 return new _AnimatedString(value);
7015 }
7016 getValue() {
7017 let value = this._string;
7018 return value == null ? this._string = this._toString(this._value) : value;
7019 }
7020 setValue(value) {
7021 if (is.str(value)) {
7022 if (value == this._string) {
7023 return false;
7024 }
7025 this._string = value;
7026 this._value = 1;
7027 } else if (super.setValue(value)) {
7028 this._string = null;
7029 } else {
7030 return false;
7031 }
7032 return true;
7033 }
7034 reset(goal) {
7035 if (goal) {
7036 this._toString = createInterpolator({
7037 output: [this.getValue(), goal]
7038 });
7039 }
7040 this._value = 0;
7041 super.reset();
7042 }
7043 };
7044 var TreeContext = {
7045 dependencies: null
7046 };
7047 var AnimatedObject = class extends Animated {
7048 constructor(source) {
7049 super();
7050 this.source = source;
7051 this.setValue(source);
7052 }
7053 getValue(animated2) {
7054 const values = {};
7055 eachProp(this.source, (source, key) => {
7056 if (isAnimated(source)) {
7057 values[key] = source.getValue(animated2);
7058 } else if (hasFluidValue(source)) {
7059 values[key] = getFluidValue(source);
7060 } else if (!animated2) {
7061 values[key] = source;
7062 }
7063 });
7064 return values;
7065 }
7066 setValue(source) {
7067 this.source = source;
7068 this.payload = this._makePayload(source);
7069 }
7070 reset() {
7071 if (this.payload) {
7072 each(this.payload, (node) => node.reset());
7073 }
7074 }
7075 _makePayload(source) {
7076 if (source) {
7077 const payload = /* @__PURE__ */ new Set();
7078 eachProp(source, this._addToPayload, payload);
7079 return Array.from(payload);
7080 }
7081 }
7082 _addToPayload(source) {
7083 if (TreeContext.dependencies && hasFluidValue(source)) {
7084 TreeContext.dependencies.add(source);
7085 }
7086 const payload = getPayload(source);
7087 if (payload) {
7088 each(payload, (node) => this.add(node));
7089 }
7090 }
7091 };
7092 var AnimatedArray = class _AnimatedArray extends AnimatedObject {
7093 constructor(source) {
7094 super(source);
7095 }
7096 static create(source) {
7097 return new _AnimatedArray(source);
7098 }
7099 getValue() {
7100 return this.source.map((node) => node.getValue());
7101 }
7102 setValue(source) {
7103 const payload = this.getPayload();
7104 if (source.length == payload.length) {
7105 return payload.map((node, i3) => node.setValue(source[i3])).some(Boolean);
7106 }
7107 super.setValue(source.map(makeAnimated));
7108 return true;
7109 }
7110 };
7111 function makeAnimated(value) {
7112 const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
7113 return nodeType.create(value);
7114 }
7115 function getAnimatedType(value) {
7116 const parentNode = getAnimated(value);
7117 return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
7118 }
7119 function _extends2() {
7120 _extends2 = Object.assign ? Object.assign.bind() : function(target) {
7121 for (var i3 = 1; i3 < arguments.length; i3++) {
7122 var source = arguments[i3];
7123 for (var key in source) {
7124 if (Object.prototype.hasOwnProperty.call(source, key)) {
7125 target[key] = source[key];
7126 }
7127 }
7128 }
7129 return target;
7130 };
7131 return _extends2.apply(this, arguments);
7132 }
7133 var withAnimated = (Component6, host2) => {
7134 const hasInstance = !is.fun(Component6) || Component6.prototype && Component6.prototype.isReactComponent;
7135 return (0, import_react2.forwardRef)((givenProps, givenRef) => {
7136 const instanceRef = (0, import_react2.useRef)(null);
7137 const ref = hasInstance && (0, import_react2.useCallback)((value) => {
7138 instanceRef.current = updateRef(givenRef, value);
7139 }, [givenRef]);
7140 const [props, deps] = getAnimatedState(givenProps, host2);
7141 const forceUpdate = useForceUpdate();
7142 const callback = () => {
7143 const instance = instanceRef.current;
7144 if (hasInstance && !instance) {
7145 return;
7146 }
7147 const didUpdate = instance ? host2.applyAnimatedValues(instance, props.getValue(true)) : false;
7148 if (didUpdate === false) {
7149 forceUpdate();
7150 }
7151 };
7152 const observer = new PropsObserver(callback, deps);
7153 const observerRef = (0, import_react2.useRef)();
7154 useIsomorphicLayoutEffect(() => {
7155 observerRef.current = observer;
7156 each(deps, (dep) => addFluidObserver(dep, observer));
7157 return () => {
7158 if (observerRef.current) {
7159 each(observerRef.current.deps, (dep) => removeFluidObserver(dep, observerRef.current));
7160 raf.cancel(observerRef.current.update);
7161 }
7162 };
7163 });
7164 (0, import_react2.useEffect)(callback, []);
7165 useOnce(() => () => {
7166 const observer2 = observerRef.current;
7167 each(observer2.deps, (dep) => removeFluidObserver(dep, observer2));
7168 });
7169 const usedProps = host2.getComponentProps(props.getValue());
7170 return React.createElement(Component6, _extends2({}, usedProps, {
7171 ref
7172 }));
7173 });
7174 };
7175 var PropsObserver = class {
7176 constructor(update4, deps) {
7177 this.update = update4;
7178 this.deps = deps;
7179 }
7180 eventObserved(event) {
7181 if (event.type == "change") {
7182 raf.write(this.update);
7183 }
7184 }
7185 };
7186 function getAnimatedState(props, host2) {
7187 const dependencies = /* @__PURE__ */ new Set();
7188 TreeContext.dependencies = dependencies;
7189 if (props.style) props = _extends2({}, props, {
7190 style: host2.createAnimatedStyle(props.style)
7191 });
7192 props = new AnimatedObject(props);
7193 TreeContext.dependencies = null;
7194 return [props, dependencies];
7195 }
7196 function updateRef(ref, value) {
7197 if (ref) {
7198 if (is.fun(ref)) ref(value);
7199 else ref.current = value;
7200 }
7201 return value;
7202 }
7203 var cacheKey = /* @__PURE__ */ Symbol.for("AnimatedComponent");
7204 var createHost = (components, {
7205 applyAnimatedValues: _applyAnimatedValues = () => false,
7206 createAnimatedStyle: _createAnimatedStyle = (style) => new AnimatedObject(style),
7207 getComponentProps: _getComponentProps = (props) => props
7208 } = {}) => {
7209 const hostConfig = {
7210 applyAnimatedValues: _applyAnimatedValues,
7211 createAnimatedStyle: _createAnimatedStyle,
7212 getComponentProps: _getComponentProps
7213 };
7214 const animated2 = (Component6) => {
7215 const displayName = getDisplayName(Component6) || "Anonymous";
7216 if (is.str(Component6)) {
7217 Component6 = animated2[Component6] || (animated2[Component6] = withAnimated(Component6, hostConfig));
7218 } else {
7219 Component6 = Component6[cacheKey] || (Component6[cacheKey] = withAnimated(Component6, hostConfig));
7220 }
7221 Component6.displayName = `Animated(${displayName})`;
7222 return Component6;
7223 };
7224 eachProp(components, (Component6, key) => {
7225 if (is.arr(components)) {
7226 key = getDisplayName(Component6);
7227 }
7228 animated2[key] = animated2(Component6);
7229 });
7230 return {
7231 animated: animated2
7232 };
7233 };
7234 var getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null;
7235
7236 // node_modules/@react-spring/core/dist/react-spring-core.esm.js
7237 function _extends3() {
7238 _extends3 = Object.assign ? Object.assign.bind() : function(target) {
7239 for (var i3 = 1; i3 < arguments.length; i3++) {
7240 var source = arguments[i3];
7241 for (var key in source) {
7242 if (Object.prototype.hasOwnProperty.call(source, key)) {
7243 target[key] = source[key];
7244 }
7245 }
7246 }
7247 return target;
7248 };
7249 return _extends3.apply(this, arguments);
7250 }
7251 function callProp(value, ...args) {
7252 return is.fun(value) ? value(...args) : value;
7253 }
7254 var matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key)));
7255 var resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop;
7256 var getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
7257 var noopTransform = (value) => value;
7258 var getDefaultProps = (props, transform = noopTransform) => {
7259 let keys = DEFAULT_PROPS;
7260 if (props.default && props.default !== true) {
7261 props = props.default;
7262 keys = Object.keys(props);
7263 }
7264 const defaults2 = {};
7265 for (const key of keys) {
7266 const value = transform(props[key], key);
7267 if (!is.und(value)) {
7268 defaults2[key] = value;
7269 }
7270 }
7271 return defaults2;
7272 };
7273 var DEFAULT_PROPS = ["config", "onProps", "onStart", "onChange", "onPause", "onResume", "onRest"];
7274 var RESERVED_PROPS = {
7275 config: 1,
7276 from: 1,
7277 to: 1,
7278 ref: 1,
7279 loop: 1,
7280 reset: 1,
7281 pause: 1,
7282 cancel: 1,
7283 reverse: 1,
7284 immediate: 1,
7285 default: 1,
7286 delay: 1,
7287 onProps: 1,
7288 onStart: 1,
7289 onChange: 1,
7290 onPause: 1,
7291 onResume: 1,
7292 onRest: 1,
7293 onResolve: 1,
7294 items: 1,
7295 trail: 1,
7296 sort: 1,
7297 expires: 1,
7298 initial: 1,
7299 enter: 1,
7300 update: 1,
7301 leave: 1,
7302 children: 1,
7303 onDestroyed: 1,
7304 keys: 1,
7305 callId: 1,
7306 parentId: 1
7307 };
7308 function getForwardProps(props) {
7309 const forward = {};
7310 let count = 0;
7311 eachProp(props, (value, prop) => {
7312 if (!RESERVED_PROPS[prop]) {
7313 forward[prop] = value;
7314 count++;
7315 }
7316 });
7317 if (count) {
7318 return forward;
7319 }
7320 }
7321 function inferTo(props) {
7322 const to2 = getForwardProps(props);
7323 if (to2) {
7324 const out = {
7325 to: to2
7326 };
7327 eachProp(props, (val, key) => key in to2 || (out[key] = val));
7328 return out;
7329 }
7330 return _extends3({}, props);
7331 }
7332 function computeGoal(value) {
7333 value = getFluidValue(value);
7334 return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({
7335 range: [0, 1],
7336 output: [value, value]
7337 })(1) : value;
7338 }
7339 function isAsyncTo(to2) {
7340 return is.fun(to2) || is.arr(to2) && is.obj(to2[0]);
7341 }
7342 var config = {
7343 default: {
7344 tension: 170,
7345 friction: 26
7346 },
7347 gentle: {
7348 tension: 120,
7349 friction: 14
7350 },
7351 wobbly: {
7352 tension: 180,
7353 friction: 12
7354 },
7355 stiff: {
7356 tension: 210,
7357 friction: 20
7358 },
7359 slow: {
7360 tension: 280,
7361 friction: 60
7362 },
7363 molasses: {
7364 tension: 280,
7365 friction: 120
7366 }
7367 };
7368 var c1 = 1.70158;
7369 var c2 = c1 * 1.525;
7370 var c3 = c1 + 1;
7371 var c4 = 2 * Math.PI / 3;
7372 var c5 = 2 * Math.PI / 4.5;
7373 var bounceOut = (x2) => {
7374 const n1 = 7.5625;
7375 const d1 = 2.75;
7376 if (x2 < 1 / d1) {
7377 return n1 * x2 * x2;
7378 } else if (x2 < 2 / d1) {
7379 return n1 * (x2 -= 1.5 / d1) * x2 + 0.75;
7380 } else if (x2 < 2.5 / d1) {
7381 return n1 * (x2 -= 2.25 / d1) * x2 + 0.9375;
7382 } else {
7383 return n1 * (x2 -= 2.625 / d1) * x2 + 0.984375;
7384 }
7385 };
7386 var easings = {
7387 linear: (x2) => x2,
7388 easeInQuad: (x2) => x2 * x2,
7389 easeOutQuad: (x2) => 1 - (1 - x2) * (1 - x2),
7390 easeInOutQuad: (x2) => x2 < 0.5 ? 2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 2) / 2,
7391 easeInCubic: (x2) => x2 * x2 * x2,
7392 easeOutCubic: (x2) => 1 - Math.pow(1 - x2, 3),
7393 easeInOutCubic: (x2) => x2 < 0.5 ? 4 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 3) / 2,
7394 easeInQuart: (x2) => x2 * x2 * x2 * x2,
7395 easeOutQuart: (x2) => 1 - Math.pow(1 - x2, 4),
7396 easeInOutQuart: (x2) => x2 < 0.5 ? 8 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 4) / 2,
7397 easeInQuint: (x2) => x2 * x2 * x2 * x2 * x2,
7398 easeOutQuint: (x2) => 1 - Math.pow(1 - x2, 5),
7399 easeInOutQuint: (x2) => x2 < 0.5 ? 16 * x2 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 5) / 2,
7400 easeInSine: (x2) => 1 - Math.cos(x2 * Math.PI / 2),
7401 easeOutSine: (x2) => Math.sin(x2 * Math.PI / 2),
7402 easeInOutSine: (x2) => -(Math.cos(Math.PI * x2) - 1) / 2,
7403 easeInExpo: (x2) => x2 === 0 ? 0 : Math.pow(2, 10 * x2 - 10),
7404 easeOutExpo: (x2) => x2 === 1 ? 1 : 1 - Math.pow(2, -10 * x2),
7405 easeInOutExpo: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : x2 < 0.5 ? Math.pow(2, 20 * x2 - 10) / 2 : (2 - Math.pow(2, -20 * x2 + 10)) / 2,
7406 easeInCirc: (x2) => 1 - Math.sqrt(1 - Math.pow(x2, 2)),
7407 easeOutCirc: (x2) => Math.sqrt(1 - Math.pow(x2 - 1, 2)),
7408 easeInOutCirc: (x2) => x2 < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x2, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x2 + 2, 2)) + 1) / 2,
7409 easeInBack: (x2) => c3 * x2 * x2 * x2 - c1 * x2 * x2,
7410 easeOutBack: (x2) => 1 + c3 * Math.pow(x2 - 1, 3) + c1 * Math.pow(x2 - 1, 2),
7411 easeInOutBack: (x2) => x2 < 0.5 ? Math.pow(2 * x2, 2) * ((c2 + 1) * 2 * x2 - c2) / 2 : (Math.pow(2 * x2 - 2, 2) * ((c2 + 1) * (x2 * 2 - 2) + c2) + 2) / 2,
7412 easeInElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : -Math.pow(2, 10 * x2 - 10) * Math.sin((x2 * 10 - 10.75) * c4),
7413 easeOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : Math.pow(2, -10 * x2) * Math.sin((x2 * 10 - 0.75) * c4) + 1,
7414 easeInOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : x2 < 0.5 ? -(Math.pow(2, 20 * x2 - 10) * Math.sin((20 * x2 - 11.125) * c5)) / 2 : Math.pow(2, -20 * x2 + 10) * Math.sin((20 * x2 - 11.125) * c5) / 2 + 1,
7415 easeInBounce: (x2) => 1 - bounceOut(1 - x2),
7416 easeOutBounce: bounceOut,
7417 easeInOutBounce: (x2) => x2 < 0.5 ? (1 - bounceOut(1 - 2 * x2)) / 2 : (1 + bounceOut(2 * x2 - 1)) / 2
7418 };
7419 var defaults = _extends3({}, config.default, {
7420 mass: 1,
7421 damping: 1,
7422 easing: easings.linear,
7423 clamp: false
7424 });
7425 var AnimationConfig = class {
7426 constructor() {
7427 this.tension = void 0;
7428 this.friction = void 0;
7429 this.frequency = void 0;
7430 this.damping = void 0;
7431 this.mass = void 0;
7432 this.velocity = 0;
7433 this.restVelocity = void 0;
7434 this.precision = void 0;
7435 this.progress = void 0;
7436 this.duration = void 0;
7437 this.easing = void 0;
7438 this.clamp = void 0;
7439 this.bounce = void 0;
7440 this.decay = void 0;
7441 this.round = void 0;
7442 Object.assign(this, defaults);
7443 }
7444 };
7445 function mergeConfig(config2, newConfig, defaultConfig) {
7446 if (defaultConfig) {
7447 defaultConfig = _extends3({}, defaultConfig);
7448 sanitizeConfig(defaultConfig, newConfig);
7449 newConfig = _extends3({}, defaultConfig, newConfig);
7450 }
7451 sanitizeConfig(config2, newConfig);
7452 Object.assign(config2, newConfig);
7453 for (const key in defaults) {
7454 if (config2[key] == null) {
7455 config2[key] = defaults[key];
7456 }
7457 }
7458 let {
7459 mass,
7460 frequency,
7461 damping
7462 } = config2;
7463 if (!is.und(frequency)) {
7464 if (frequency < 0.01) frequency = 0.01;
7465 if (damping < 0) damping = 0;
7466 config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
7467 config2.friction = 4 * Math.PI * damping * mass / frequency;
7468 }
7469 return config2;
7470 }
7471 function sanitizeConfig(config2, props) {
7472 if (!is.und(props.decay)) {
7473 config2.duration = void 0;
7474 } else {
7475 const isTensionConfig = !is.und(props.tension) || !is.und(props.friction);
7476 if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) {
7477 config2.duration = void 0;
7478 config2.decay = void 0;
7479 }
7480 if (isTensionConfig) {
7481 config2.frequency = void 0;
7482 }
7483 }
7484 }
7485 var emptyArray = [];
7486 var Animation = class {
7487 constructor() {
7488 this.changed = false;
7489 this.values = emptyArray;
7490 this.toValues = null;
7491 this.fromValues = emptyArray;
7492 this.to = void 0;
7493 this.from = void 0;
7494 this.config = new AnimationConfig();
7495 this.immediate = false;
7496 }
7497 };
7498 function scheduleProps(callId, {
7499 key,
7500 props,
7501 defaultProps,
7502 state,
7503 actions: actions2
7504 }) {
7505 return new Promise((resolve, reject) => {
7506 var _props$cancel;
7507 let delay;
7508 let timeout;
7509 let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps == null ? void 0 : defaultProps.cancel, key);
7510 if (cancel) {
7511 onStart();
7512 } else {
7513 if (!is.und(props.pause)) {
7514 state.paused = matchProp(props.pause, key);
7515 }
7516 let pause = defaultProps == null ? void 0 : defaultProps.pause;
7517 if (pause !== true) {
7518 pause = state.paused || matchProp(pause, key);
7519 }
7520 delay = callProp(props.delay || 0, key);
7521 if (pause) {
7522 state.resumeQueue.add(onResume);
7523 actions2.pause();
7524 } else {
7525 actions2.resume();
7526 onResume();
7527 }
7528 }
7529 function onPause() {
7530 state.resumeQueue.add(onResume);
7531 state.timeouts.delete(timeout);
7532 timeout.cancel();
7533 delay = timeout.time - raf.now();
7534 }
7535 function onResume() {
7536 if (delay > 0 && !globals.skipAnimation) {
7537 state.delayed = true;
7538 timeout = raf.setTimeout(onStart, delay);
7539 state.pauseQueue.add(onPause);
7540 state.timeouts.add(timeout);
7541 } else {
7542 onStart();
7543 }
7544 }
7545 function onStart() {
7546 if (state.delayed) {
7547 state.delayed = false;
7548 }
7549 state.pauseQueue.delete(onPause);
7550 state.timeouts.delete(timeout);
7551 if (callId <= (state.cancelId || 0)) {
7552 cancel = true;
7553 }
7554 try {
7555 actions2.start(_extends3({}, props, {
7556 callId,
7557 cancel
7558 }), resolve);
7559 } catch (err) {
7560 reject(err);
7561 }
7562 }
7563 });
7564 }
7565 var getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some((result) => result.cancelled) ? getCancelledResult(target.get()) : results.every((result) => result.noop) ? getNoopResult(target.get()) : getFinishedResult(target.get(), results.every((result) => result.finished));
7566 var getNoopResult = (value) => ({
7567 value,
7568 noop: true,
7569 finished: true,
7570 cancelled: false
7571 });
7572 var getFinishedResult = (value, finished, cancelled = false) => ({
7573 value,
7574 finished,
7575 cancelled
7576 });
7577 var getCancelledResult = (value) => ({
7578 value,
7579 cancelled: true,
7580 finished: false
7581 });
7582 function runAsync(to2, props, state, target) {
7583 const {
7584 callId,
7585 parentId,
7586 onRest
7587 } = props;
7588 const {
7589 asyncTo: prevTo,
7590 promise: prevPromise
7591 } = state;
7592 if (!parentId && to2 === prevTo && !props.reset) {
7593 return prevPromise;
7594 }
7595 return state.promise = (async () => {
7596 state.asyncId = callId;
7597 state.asyncTo = to2;
7598 const defaultProps = getDefaultProps(props, (value, key) => key === "onRest" ? void 0 : value);
7599 let preventBail;
7600 let bail;
7601 const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject));
7602 const bailIfEnded = (bailSignal) => {
7603 const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false);
7604 if (bailResult) {
7605 bailSignal.result = bailResult;
7606 bail(bailSignal);
7607 throw bailSignal;
7608 }
7609 };
7610 const animate = (arg1, arg2) => {
7611 const bailSignal = new BailSignal();
7612 const skipAnimationSignal = new SkipAniamtionSignal();
7613 return (async () => {
7614 if (globals.skipAnimation) {
7615 stopAsync(state);
7616 skipAnimationSignal.result = getFinishedResult(target, false);
7617 bail(skipAnimationSignal);
7618 throw skipAnimationSignal;
7619 }
7620 bailIfEnded(bailSignal);
7621 const props2 = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, {
7622 to: arg1
7623 });
7624 props2.parentId = callId;
7625 eachProp(defaultProps, (value, key) => {
7626 if (is.und(props2[key])) {
7627 props2[key] = value;
7628 }
7629 });
7630 const result2 = await target.start(props2);
7631 bailIfEnded(bailSignal);
7632 if (state.paused) {
7633 await new Promise((resume) => {
7634 state.resumeQueue.add(resume);
7635 });
7636 }
7637 return result2;
7638 })();
7639 };
7640 let result;
7641 if (globals.skipAnimation) {
7642 stopAsync(state);
7643 return getFinishedResult(target, false);
7644 }
7645 try {
7646 let animating;
7647 if (is.arr(to2)) {
7648 animating = (async (queue) => {
7649 for (const props2 of queue) {
7650 await animate(props2);
7651 }
7652 })(to2);
7653 } else {
7654 animating = Promise.resolve(to2(animate, target.stop.bind(target)));
7655 }
7656 await Promise.all([animating.then(preventBail), bailPromise]);
7657 result = getFinishedResult(target.get(), true, false);
7658 } catch (err) {
7659 if (err instanceof BailSignal) {
7660 result = err.result;
7661 } else if (err instanceof SkipAniamtionSignal) {
7662 result = err.result;
7663 } else {
7664 throw err;
7665 }
7666 } finally {
7667 if (callId == state.asyncId) {
7668 state.asyncId = parentId;
7669 state.asyncTo = parentId ? prevTo : void 0;
7670 state.promise = parentId ? prevPromise : void 0;
7671 }
7672 }
7673 if (is.fun(onRest)) {
7674 raf.batchedUpdates(() => {
7675 onRest(result, target, target.item);
7676 });
7677 }
7678 return result;
7679 })();
7680 }
7681 function stopAsync(state, cancelId) {
7682 flush(state.timeouts, (t4) => t4.cancel());
7683 state.pauseQueue.clear();
7684 state.resumeQueue.clear();
7685 state.asyncId = state.asyncTo = state.promise = void 0;
7686 if (cancelId) state.cancelId = cancelId;
7687 }
7688 var BailSignal = class extends Error {
7689 constructor() {
7690 super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise.");
7691 this.result = void 0;
7692 }
7693 };
7694 var SkipAniamtionSignal = class extends Error {
7695 constructor() {
7696 super("SkipAnimationSignal");
7697 this.result = void 0;
7698 }
7699 };
7700 var isFrameValue = (value) => value instanceof FrameValue;
7701 var nextId$1 = 1;
7702 var FrameValue = class extends FluidValue {
7703 constructor(...args) {
7704 super(...args);
7705 this.id = nextId$1++;
7706 this.key = void 0;
7707 this._priority = 0;
7708 }
7709 get priority() {
7710 return this._priority;
7711 }
7712 set priority(priority2) {
7713 if (this._priority != priority2) {
7714 this._priority = priority2;
7715 this._onPriorityChange(priority2);
7716 }
7717 }
7718 get() {
7719 const node = getAnimated(this);
7720 return node && node.getValue();
7721 }
7722 to(...args) {
7723 return globals.to(this, args);
7724 }
7725 interpolate(...args) {
7726 deprecateInterpolate();
7727 return globals.to(this, args);
7728 }
7729 toJSON() {
7730 return this.get();
7731 }
7732 observerAdded(count) {
7733 if (count == 1) this._attach();
7734 }
7735 observerRemoved(count) {
7736 if (count == 0) this._detach();
7737 }
7738 _attach() {
7739 }
7740 _detach() {
7741 }
7742 _onChange(value, idle = false) {
7743 callFluidObservers(this, {
7744 type: "change",
7745 parent: this,
7746 value,
7747 idle
7748 });
7749 }
7750 _onPriorityChange(priority2) {
7751 if (!this.idle) {
7752 frameLoop.sort(this);
7753 }
7754 callFluidObservers(this, {
7755 type: "priority",
7756 parent: this,
7757 priority: priority2
7758 });
7759 }
7760 };
7761 var $P = /* @__PURE__ */ Symbol.for("SpringPhase");
7762 var HAS_ANIMATED = 1;
7763 var IS_ANIMATING = 2;
7764 var IS_PAUSED = 4;
7765 var hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0;
7766 var isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0;
7767 var isPaused = (target) => (target[$P] & IS_PAUSED) > 0;
7768 var setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING;
7769 var setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED;
7770 var SpringValue = class extends FrameValue {
7771 constructor(arg1, arg2) {
7772 super();
7773 this.key = void 0;
7774 this.animation = new Animation();
7775 this.queue = void 0;
7776 this.defaultProps = {};
7777 this._state = {
7778 paused: false,
7779 delayed: false,
7780 pauseQueue: /* @__PURE__ */ new Set(),
7781 resumeQueue: /* @__PURE__ */ new Set(),
7782 timeouts: /* @__PURE__ */ new Set()
7783 };
7784 this._pendingCalls = /* @__PURE__ */ new Set();
7785 this._lastCallId = 0;
7786 this._lastToId = 0;
7787 this._memoizedDuration = 0;
7788 if (!is.und(arg1) || !is.und(arg2)) {
7789 const props = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, {
7790 from: arg1
7791 });
7792 if (is.und(props.default)) {
7793 props.default = true;
7794 }
7795 this.start(props);
7796 }
7797 }
7798 get idle() {
7799 return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
7800 }
7801 get goal() {
7802 return getFluidValue(this.animation.to);
7803 }
7804 get velocity() {
7805 const node = getAnimated(this);
7806 return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0);
7807 }
7808 get hasAnimated() {
7809 return hasAnimated(this);
7810 }
7811 get isAnimating() {
7812 return isAnimating(this);
7813 }
7814 get isPaused() {
7815 return isPaused(this);
7816 }
7817 get isDelayed() {
7818 return this._state.delayed;
7819 }
7820 advance(dt) {
7821 let idle = true;
7822 let changed = false;
7823 const anim = this.animation;
7824 let {
7825 config: config2,
7826 toValues
7827 } = anim;
7828 const payload = getPayload(anim.to);
7829 if (!payload && hasFluidValue(anim.to)) {
7830 toValues = toArray(getFluidValue(anim.to));
7831 }
7832 anim.values.forEach((node2, i3) => {
7833 if (node2.done) return;
7834 const to2 = node2.constructor == AnimatedString ? 1 : payload ? payload[i3].lastPosition : toValues[i3];
7835 let finished = anim.immediate;
7836 let position = to2;
7837 if (!finished) {
7838 position = node2.lastPosition;
7839 if (config2.tension <= 0) {
7840 node2.done = true;
7841 return;
7842 }
7843 let elapsed = node2.elapsedTime += dt;
7844 const from = anim.fromValues[i3];
7845 const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i3] : config2.velocity;
7846 let velocity;
7847 const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3));
7848 if (!is.und(config2.duration)) {
7849 let p4 = 1;
7850 if (config2.duration > 0) {
7851 if (this._memoizedDuration !== config2.duration) {
7852 this._memoizedDuration = config2.duration;
7853 if (node2.durationProgress > 0) {
7854 node2.elapsedTime = config2.duration * node2.durationProgress;
7855 elapsed = node2.elapsedTime += dt;
7856 }
7857 }
7858 p4 = (config2.progress || 0) + elapsed / this._memoizedDuration;
7859 p4 = p4 > 1 ? 1 : p4 < 0 ? 0 : p4;
7860 node2.durationProgress = p4;
7861 }
7862 position = from + config2.easing(p4) * (to2 - from);
7863 velocity = (position - node2.lastPosition) / dt;
7864 finished = p4 == 1;
7865 } else if (config2.decay) {
7866 const decay = config2.decay === true ? 0.998 : config2.decay;
7867 const e3 = Math.exp(-(1 - decay) * elapsed);
7868 position = from + v0 / (1 - decay) * (1 - e3);
7869 finished = Math.abs(node2.lastPosition - position) <= precision;
7870 velocity = v0 * e3;
7871 } else {
7872 velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity;
7873 const restVelocity = config2.restVelocity || precision / 10;
7874 const bounceFactor = config2.clamp ? 0 : config2.bounce;
7875 const canBounce = !is.und(bounceFactor);
7876 const isGrowing = from == to2 ? node2.v0 > 0 : from < to2;
7877 let isMoving;
7878 let isBouncing = false;
7879 const step = 1;
7880 const numSteps = Math.ceil(dt / step);
7881 for (let n3 = 0; n3 < numSteps; ++n3) {
7882 isMoving = Math.abs(velocity) > restVelocity;
7883 if (!isMoving) {
7884 finished = Math.abs(to2 - position) <= precision;
7885 if (finished) {
7886 break;
7887 }
7888 }
7889 if (canBounce) {
7890 isBouncing = position == to2 || position > to2 == isGrowing;
7891 if (isBouncing) {
7892 velocity = -velocity * bounceFactor;
7893 position = to2;
7894 }
7895 }
7896 const springForce = -config2.tension * 1e-6 * (position - to2);
7897 const dampingForce = -config2.friction * 1e-3 * velocity;
7898 const acceleration = (springForce + dampingForce) / config2.mass;
7899 velocity = velocity + acceleration * step;
7900 position = position + velocity * step;
7901 }
7902 }
7903 node2.lastVelocity = velocity;
7904 if (Number.isNaN(position)) {
7905 console.warn(`Got NaN while animating:`, this);
7906 finished = true;
7907 }
7908 }
7909 if (payload && !payload[i3].done) {
7910 finished = false;
7911 }
7912 if (finished) {
7913 node2.done = true;
7914 } else {
7915 idle = false;
7916 }
7917 if (node2.setValue(position, config2.round)) {
7918 changed = true;
7919 }
7920 });
7921 const node = getAnimated(this);
7922 const currVal = node.getValue();
7923 if (idle) {
7924 const finalVal = getFluidValue(anim.to);
7925 if ((currVal !== finalVal || changed) && !config2.decay) {
7926 node.setValue(finalVal);
7927 this._onChange(finalVal);
7928 } else if (changed && config2.decay) {
7929 this._onChange(currVal);
7930 }
7931 this._stop();
7932 } else if (changed) {
7933 this._onChange(currVal);
7934 }
7935 }
7936 set(value) {
7937 raf.batchedUpdates(() => {
7938 this._stop();
7939 this._focus(value);
7940 this._set(value);
7941 });
7942 return this;
7943 }
7944 pause() {
7945 this._update({
7946 pause: true
7947 });
7948 }
7949 resume() {
7950 this._update({
7951 pause: false
7952 });
7953 }
7954 finish() {
7955 if (isAnimating(this)) {
7956 const {
7957 to: to2,
7958 config: config2
7959 } = this.animation;
7960 raf.batchedUpdates(() => {
7961 this._onStart();
7962 if (!config2.decay) {
7963 this._set(to2, false);
7964 }
7965 this._stop();
7966 });
7967 }
7968 return this;
7969 }
7970 update(props) {
7971 const queue = this.queue || (this.queue = []);
7972 queue.push(props);
7973 return this;
7974 }
7975 start(to2, arg2) {
7976 let queue;
7977 if (!is.und(to2)) {
7978 queue = [is.obj(to2) ? to2 : _extends3({}, arg2, {
7979 to: to2
7980 })];
7981 } else {
7982 queue = this.queue || [];
7983 this.queue = [];
7984 }
7985 return Promise.all(queue.map((props) => {
7986 const up = this._update(props);
7987 return up;
7988 })).then((results) => getCombinedResult(this, results));
7989 }
7990 stop(cancel) {
7991 const {
7992 to: to2
7993 } = this.animation;
7994 this._focus(this.get());
7995 stopAsync(this._state, cancel && this._lastCallId);
7996 raf.batchedUpdates(() => this._stop(to2, cancel));
7997 return this;
7998 }
7999 reset() {
8000 this._update({
8001 reset: true
8002 });
8003 }
8004 eventObserved(event) {
8005 if (event.type == "change") {
8006 this._start();
8007 } else if (event.type == "priority") {
8008 this.priority = event.priority + 1;
8009 }
8010 }
8011 _prepareNode(props) {
8012 const key = this.key || "";
8013 let {
8014 to: to2,
8015 from
8016 } = props;
8017 to2 = is.obj(to2) ? to2[key] : to2;
8018 if (to2 == null || isAsyncTo(to2)) {
8019 to2 = void 0;
8020 }
8021 from = is.obj(from) ? from[key] : from;
8022 if (from == null) {
8023 from = void 0;
8024 }
8025 const range = {
8026 to: to2,
8027 from
8028 };
8029 if (!hasAnimated(this)) {
8030 if (props.reverse) [to2, from] = [from, to2];
8031 from = getFluidValue(from);
8032 if (!is.und(from)) {
8033 this._set(from);
8034 } else if (!getAnimated(this)) {
8035 this._set(to2);
8036 }
8037 }
8038 return range;
8039 }
8040 _update(_ref, isLoop) {
8041 let props = _extends3({}, _ref);
8042 const {
8043 key,
8044 defaultProps
8045 } = this;
8046 if (props.default) Object.assign(defaultProps, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value));
8047 mergeActiveFn(this, props, "onProps");
8048 sendEvent(this, "onProps", props, this);
8049 const range = this._prepareNode(props);
8050 if (Object.isFrozen(this)) {
8051 throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");
8052 }
8053 const state = this._state;
8054 return scheduleProps(++this._lastCallId, {
8055 key,
8056 props,
8057 defaultProps,
8058 state,
8059 actions: {
8060 pause: () => {
8061 if (!isPaused(this)) {
8062 setPausedBit(this, true);
8063 flushCalls(state.pauseQueue);
8064 sendEvent(this, "onPause", getFinishedResult(this, checkFinished(this, this.animation.to)), this);
8065 }
8066 },
8067 resume: () => {
8068 if (isPaused(this)) {
8069 setPausedBit(this, false);
8070 if (isAnimating(this)) {
8071 this._resume();
8072 }
8073 flushCalls(state.resumeQueue);
8074 sendEvent(this, "onResume", getFinishedResult(this, checkFinished(this, this.animation.to)), this);
8075 }
8076 },
8077 start: this._merge.bind(this, range)
8078 }
8079 }).then((result) => {
8080 if (props.loop && result.finished && !(isLoop && result.noop)) {
8081 const nextProps = createLoopUpdate(props);
8082 if (nextProps) {
8083 return this._update(nextProps, true);
8084 }
8085 }
8086 return result;
8087 });
8088 }
8089 _merge(range, props, resolve) {
8090 if (props.cancel) {
8091 this.stop(true);
8092 return resolve(getCancelledResult(this));
8093 }
8094 const hasToProp = !is.und(range.to);
8095 const hasFromProp = !is.und(range.from);
8096 if (hasToProp || hasFromProp) {
8097 if (props.callId > this._lastToId) {
8098 this._lastToId = props.callId;
8099 } else {
8100 return resolve(getCancelledResult(this));
8101 }
8102 }
8103 const {
8104 key,
8105 defaultProps,
8106 animation: anim
8107 } = this;
8108 const {
8109 to: prevTo,
8110 from: prevFrom
8111 } = anim;
8112 let {
8113 to: to2 = prevTo,
8114 from = prevFrom
8115 } = range;
8116 if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) {
8117 to2 = from;
8118 }
8119 if (props.reverse) [to2, from] = [from, to2];
8120 const hasFromChanged = !isEqual(from, prevFrom);
8121 if (hasFromChanged) {
8122 anim.from = from;
8123 }
8124 from = getFluidValue(from);
8125 const hasToChanged = !isEqual(to2, prevTo);
8126 if (hasToChanged) {
8127 this._focus(to2);
8128 }
8129 const hasAsyncTo = isAsyncTo(props.to);
8130 const {
8131 config: config2
8132 } = anim;
8133 const {
8134 decay,
8135 velocity
8136 } = config2;
8137 if (hasToProp || hasFromProp) {
8138 config2.velocity = 0;
8139 }
8140 if (props.config && !hasAsyncTo) {
8141 mergeConfig(config2, callProp(props.config, key), props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0);
8142 }
8143 let node = getAnimated(this);
8144 if (!node || is.und(to2)) {
8145 return resolve(getFinishedResult(this, true));
8146 }
8147 const reset = is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key);
8148 const value = reset ? from : this.get();
8149 const goal = computeGoal(to2);
8150 const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal);
8151 const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key));
8152 if (hasToChanged) {
8153 const nodeType = getAnimatedType(to2);
8154 if (nodeType !== node.constructor) {
8155 if (immediate) {
8156 node = this._set(goal);
8157 } else throw Error(`Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`);
8158 }
8159 }
8160 const goalType = node.constructor;
8161 let started = hasFluidValue(to2);
8162 let finished = false;
8163 if (!started) {
8164 const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
8165 if (hasToChanged || hasValueChanged) {
8166 finished = isEqual(computeGoal(value), goal);
8167 started = !finished;
8168 }
8169 if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) {
8170 started = true;
8171 }
8172 }
8173 if (finished && isAnimating(this)) {
8174 if (anim.changed && !reset) {
8175 started = true;
8176 } else if (!started) {
8177 this._stop(prevTo);
8178 }
8179 }
8180 if (!hasAsyncTo) {
8181 if (started || hasFluidValue(prevTo)) {
8182 anim.values = node.getPayload();
8183 anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal);
8184 }
8185 if (anim.immediate != immediate) {
8186 anim.immediate = immediate;
8187 if (!immediate && !reset) {
8188 this._set(prevTo);
8189 }
8190 }
8191 if (started) {
8192 const {
8193 onRest
8194 } = anim;
8195 each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type));
8196 const result = getFinishedResult(this, checkFinished(this, prevTo));
8197 flushCalls(this._pendingCalls, result);
8198 this._pendingCalls.add(resolve);
8199 if (anim.changed) raf.batchedUpdates(() => {
8200 anim.changed = !reset;
8201 onRest == null ? void 0 : onRest(result, this);
8202 if (reset) {
8203 callProp(defaultProps.onRest, result);
8204 } else {
8205 anim.onStart == null ? void 0 : anim.onStart(result, this);
8206 }
8207 });
8208 }
8209 }
8210 if (reset) {
8211 this._set(value);
8212 }
8213 if (hasAsyncTo) {
8214 resolve(runAsync(props.to, props, this._state, this));
8215 } else if (started) {
8216 this._start();
8217 } else if (isAnimating(this) && !hasToChanged) {
8218 this._pendingCalls.add(resolve);
8219 } else {
8220 resolve(getNoopResult(value));
8221 }
8222 }
8223 _focus(value) {
8224 const anim = this.animation;
8225 if (value !== anim.to) {
8226 if (getFluidObservers(this)) {
8227 this._detach();
8228 }
8229 anim.to = value;
8230 if (getFluidObservers(this)) {
8231 this._attach();
8232 }
8233 }
8234 }
8235 _attach() {
8236 let priority2 = 0;
8237 const {
8238 to: to2
8239 } = this.animation;
8240 if (hasFluidValue(to2)) {
8241 addFluidObserver(to2, this);
8242 if (isFrameValue(to2)) {
8243 priority2 = to2.priority + 1;
8244 }
8245 }
8246 this.priority = priority2;
8247 }
8248 _detach() {
8249 const {
8250 to: to2
8251 } = this.animation;
8252 if (hasFluidValue(to2)) {
8253 removeFluidObserver(to2, this);
8254 }
8255 }
8256 _set(arg, idle = true) {
8257 const value = getFluidValue(arg);
8258 if (!is.und(value)) {
8259 const oldNode = getAnimated(this);
8260 if (!oldNode || !isEqual(value, oldNode.getValue())) {
8261 const nodeType = getAnimatedType(value);
8262 if (!oldNode || oldNode.constructor != nodeType) {
8263 setAnimated(this, nodeType.create(value));
8264 } else {
8265 oldNode.setValue(value);
8266 }
8267 if (oldNode) {
8268 raf.batchedUpdates(() => {
8269 this._onChange(value, idle);
8270 });
8271 }
8272 }
8273 }
8274 return getAnimated(this);
8275 }
8276 _onStart() {
8277 const anim = this.animation;
8278 if (!anim.changed) {
8279 anim.changed = true;
8280 sendEvent(this, "onStart", getFinishedResult(this, checkFinished(this, anim.to)), this);
8281 }
8282 }
8283 _onChange(value, idle) {
8284 if (!idle) {
8285 this._onStart();
8286 callProp(this.animation.onChange, value, this);
8287 }
8288 callProp(this.defaultProps.onChange, value, this);
8289 super._onChange(value, idle);
8290 }
8291 _start() {
8292 const anim = this.animation;
8293 getAnimated(this).reset(getFluidValue(anim.to));
8294 if (!anim.immediate) {
8295 anim.fromValues = anim.values.map((node) => node.lastPosition);
8296 }
8297 if (!isAnimating(this)) {
8298 setActiveBit(this, true);
8299 if (!isPaused(this)) {
8300 this._resume();
8301 }
8302 }
8303 }
8304 _resume() {
8305 if (globals.skipAnimation) {
8306 this.finish();
8307 } else {
8308 frameLoop.start(this);
8309 }
8310 }
8311 _stop(goal, cancel) {
8312 if (isAnimating(this)) {
8313 setActiveBit(this, false);
8314 const anim = this.animation;
8315 each(anim.values, (node) => {
8316 node.done = true;
8317 });
8318 if (anim.toValues) {
8319 anim.onChange = anim.onPause = anim.onResume = void 0;
8320 }
8321 callFluidObservers(this, {
8322 type: "idle",
8323 parent: this
8324 });
8325 const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to));
8326 flushCalls(this._pendingCalls, result);
8327 if (anim.changed) {
8328 anim.changed = false;
8329 sendEvent(this, "onRest", result, this);
8330 }
8331 }
8332 }
8333 };
8334 function checkFinished(target, to2) {
8335 const goal = computeGoal(to2);
8336 const value = computeGoal(target.get());
8337 return isEqual(value, goal);
8338 }
8339 function createLoopUpdate(props, loop2 = props.loop, to2 = props.to) {
8340 let loopRet = callProp(loop2);
8341 if (loopRet) {
8342 const overrides = loopRet !== true && inferTo(loopRet);
8343 const reverse = (overrides || props).reverse;
8344 const reset = !overrides || overrides.reset;
8345 return createUpdate(_extends3({}, props, {
8346 loop: loop2,
8347 default: false,
8348 pause: void 0,
8349 to: !reverse || isAsyncTo(to2) ? to2 : void 0,
8350 from: reset ? props.from : void 0,
8351 reset
8352 }, overrides));
8353 }
8354 }
8355 function createUpdate(props) {
8356 const {
8357 to: to2,
8358 from
8359 } = props = inferTo(props);
8360 const keys = /* @__PURE__ */ new Set();
8361 if (is.obj(to2)) findDefined(to2, keys);
8362 if (is.obj(from)) findDefined(from, keys);
8363 props.keys = keys.size ? Array.from(keys) : null;
8364 return props;
8365 }
8366 function findDefined(values, keys) {
8367 eachProp(values, (value, key) => value != null && keys.add(key));
8368 }
8369 var ACTIVE_EVENTS = ["onStart", "onRest", "onChange", "onPause", "onResume"];
8370 function mergeActiveFn(target, props, type) {
8371 target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0;
8372 }
8373 function sendEvent(target, type, ...args) {
8374 var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps;
8375 (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args);
8376 (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args);
8377 }
8378 var BATCHED_EVENTS = ["onStart", "onChange", "onRest"];
8379 var nextId = 1;
8380 var Controller = class {
8381 constructor(props, flush2) {
8382 this.id = nextId++;
8383 this.springs = {};
8384 this.queue = [];
8385 this.ref = void 0;
8386 this._flush = void 0;
8387 this._initialProps = void 0;
8388 this._lastAsyncId = 0;
8389 this._active = /* @__PURE__ */ new Set();
8390 this._changed = /* @__PURE__ */ new Set();
8391 this._started = false;
8392 this._item = void 0;
8393 this._state = {
8394 paused: false,
8395 pauseQueue: /* @__PURE__ */ new Set(),
8396 resumeQueue: /* @__PURE__ */ new Set(),
8397 timeouts: /* @__PURE__ */ new Set()
8398 };
8399 this._events = {
8400 onStart: /* @__PURE__ */ new Map(),
8401 onChange: /* @__PURE__ */ new Map(),
8402 onRest: /* @__PURE__ */ new Map()
8403 };
8404 this._onFrame = this._onFrame.bind(this);
8405 if (flush2) {
8406 this._flush = flush2;
8407 }
8408 if (props) {
8409 this.start(_extends3({
8410 default: true
8411 }, props));
8412 }
8413 }
8414 get idle() {
8415 return !this._state.asyncTo && Object.values(this.springs).every((spring) => {
8416 return spring.idle && !spring.isDelayed && !spring.isPaused;
8417 });
8418 }
8419 get item() {
8420 return this._item;
8421 }
8422 set item(item) {
8423 this._item = item;
8424 }
8425 get() {
8426 const values = {};
8427 this.each((spring, key) => values[key] = spring.get());
8428 return values;
8429 }
8430 set(values) {
8431 for (const key in values) {
8432 const value = values[key];
8433 if (!is.und(value)) {
8434 this.springs[key].set(value);
8435 }
8436 }
8437 }
8438 update(props) {
8439 if (props) {
8440 this.queue.push(createUpdate(props));
8441 }
8442 return this;
8443 }
8444 start(props) {
8445 let {
8446 queue
8447 } = this;
8448 if (props) {
8449 queue = toArray(props).map(createUpdate);
8450 } else {
8451 this.queue = [];
8452 }
8453 if (this._flush) {
8454 return this._flush(this, queue);
8455 }
8456 prepareKeys(this, queue);
8457 return flushUpdateQueue(this, queue);
8458 }
8459 stop(arg, keys) {
8460 if (arg !== !!arg) {
8461 keys = arg;
8462 }
8463 if (keys) {
8464 const springs = this.springs;
8465 each(toArray(keys), (key) => springs[key].stop(!!arg));
8466 } else {
8467 stopAsync(this._state, this._lastAsyncId);
8468 this.each((spring) => spring.stop(!!arg));
8469 }
8470 return this;
8471 }
8472 pause(keys) {
8473 if (is.und(keys)) {
8474 this.start({
8475 pause: true
8476 });
8477 } else {
8478 const springs = this.springs;
8479 each(toArray(keys), (key) => springs[key].pause());
8480 }
8481 return this;
8482 }
8483 resume(keys) {
8484 if (is.und(keys)) {
8485 this.start({
8486 pause: false
8487 });
8488 } else {
8489 const springs = this.springs;
8490 each(toArray(keys), (key) => springs[key].resume());
8491 }
8492 return this;
8493 }
8494 each(iterator) {
8495 eachProp(this.springs, iterator);
8496 }
8497 _onFrame() {
8498 const {
8499 onStart,
8500 onChange,
8501 onRest
8502 } = this._events;
8503 const active = this._active.size > 0;
8504 const changed = this._changed.size > 0;
8505 if (active && !this._started || changed && !this._started) {
8506 this._started = true;
8507 flush(onStart, ([onStart2, result]) => {
8508 result.value = this.get();
8509 onStart2(result, this, this._item);
8510 });
8511 }
8512 const idle = !active && this._started;
8513 const values = changed || idle && onRest.size ? this.get() : null;
8514 if (changed && onChange.size) {
8515 flush(onChange, ([onChange2, result]) => {
8516 result.value = values;
8517 onChange2(result, this, this._item);
8518 });
8519 }
8520 if (idle) {
8521 this._started = false;
8522 flush(onRest, ([onRest2, result]) => {
8523 result.value = values;
8524 onRest2(result, this, this._item);
8525 });
8526 }
8527 }
8528 eventObserved(event) {
8529 if (event.type == "change") {
8530 this._changed.add(event.parent);
8531 if (!event.idle) {
8532 this._active.add(event.parent);
8533 }
8534 } else if (event.type == "idle") {
8535 this._active.delete(event.parent);
8536 } else return;
8537 raf.onFrame(this._onFrame);
8538 }
8539 };
8540 function flushUpdateQueue(ctrl, queue) {
8541 return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then((results) => getCombinedResult(ctrl, results));
8542 }
8543 async function flushUpdate(ctrl, props, isLoop) {
8544 const {
8545 keys,
8546 to: to2,
8547 from,
8548 loop: loop2,
8549 onRest,
8550 onResolve
8551 } = props;
8552 const defaults2 = is.obj(props.default) && props.default;
8553 if (loop2) {
8554 props.loop = false;
8555 }
8556 if (to2 === false) props.to = null;
8557 if (from === false) props.from = null;
8558 const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0;
8559 if (asyncTo) {
8560 props.to = void 0;
8561 props.onRest = void 0;
8562 if (defaults2) {
8563 defaults2.onRest = void 0;
8564 }
8565 } else {
8566 each(BATCHED_EVENTS, (key) => {
8567 const handler = props[key];
8568 if (is.fun(handler)) {
8569 const queue = ctrl["_events"][key];
8570 props[key] = ({
8571 finished,
8572 cancelled
8573 }) => {
8574 const result2 = queue.get(handler);
8575 if (result2) {
8576 if (!finished) result2.finished = false;
8577 if (cancelled) result2.cancelled = true;
8578 } else {
8579 queue.set(handler, {
8580 value: null,
8581 finished: finished || false,
8582 cancelled: cancelled || false
8583 });
8584 }
8585 };
8586 if (defaults2) {
8587 defaults2[key] = props[key];
8588 }
8589 }
8590 });
8591 }
8592 const state = ctrl["_state"];
8593 if (props.pause === !state.paused) {
8594 state.paused = props.pause;
8595 flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
8596 } else if (state.paused) {
8597 props.pause = true;
8598 }
8599 const promises = (keys || Object.keys(ctrl.springs)).map((key) => ctrl.springs[key].start(props));
8600 const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true;
8601 if (asyncTo || cancel && state.asyncId) {
8602 promises.push(scheduleProps(++ctrl["_lastAsyncId"], {
8603 props,
8604 state,
8605 actions: {
8606 pause: noop2,
8607 resume: noop2,
8608 start(props2, resolve) {
8609 if (cancel) {
8610 stopAsync(state, ctrl["_lastAsyncId"]);
8611 resolve(getCancelledResult(ctrl));
8612 } else {
8613 props2.onRest = onRest;
8614 resolve(runAsync(asyncTo, props2, state, ctrl));
8615 }
8616 }
8617 }
8618 }));
8619 }
8620 if (state.paused) {
8621 await new Promise((resume) => {
8622 state.resumeQueue.add(resume);
8623 });
8624 }
8625 const result = getCombinedResult(ctrl, await Promise.all(promises));
8626 if (loop2 && result.finished && !(isLoop && result.noop)) {
8627 const nextProps = createLoopUpdate(props, loop2, to2);
8628 if (nextProps) {
8629 prepareKeys(ctrl, [nextProps]);
8630 return flushUpdate(ctrl, nextProps, true);
8631 }
8632 }
8633 if (onResolve) {
8634 raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
8635 }
8636 return result;
8637 }
8638 function createSpring(key, observer) {
8639 const spring = new SpringValue();
8640 spring.key = key;
8641 if (observer) {
8642 addFluidObserver(spring, observer);
8643 }
8644 return spring;
8645 }
8646 function prepareSprings(springs, props, create4) {
8647 if (props.keys) {
8648 each(props.keys, (key) => {
8649 const spring = springs[key] || (springs[key] = create4(key));
8650 spring["_prepareNode"](props);
8651 });
8652 }
8653 }
8654 function prepareKeys(ctrl, queue) {
8655 each(queue, (props) => {
8656 prepareSprings(ctrl.springs, props, (key) => {
8657 return createSpring(key, ctrl);
8658 });
8659 });
8660 }
8661 function _objectWithoutPropertiesLoose(source, excluded) {
8662 if (source == null) return {};
8663 var target = {};
8664 var sourceKeys = Object.keys(source);
8665 var key, i3;
8666 for (i3 = 0; i3 < sourceKeys.length; i3++) {
8667 key = sourceKeys[i3];
8668 if (excluded.indexOf(key) >= 0) continue;
8669 target[key] = source[key];
8670 }
8671 return target;
8672 }
8673 var _excluded$3 = ["children"];
8674 var SpringContext = (_ref) => {
8675 let {
8676 children
8677 } = _ref, props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
8678 const inherited = (0, import_react3.useContext)(ctx);
8679 const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate;
8680 props = useMemoOne(() => ({
8681 pause,
8682 immediate
8683 }), [pause, immediate]);
8684 const {
8685 Provider
8686 } = ctx;
8687 return React2.createElement(Provider, {
8688 value: props
8689 }, children);
8690 };
8691 var ctx = makeContext(SpringContext, {});
8692 SpringContext.Provider = ctx.Provider;
8693 SpringContext.Consumer = ctx.Consumer;
8694 function makeContext(target, init) {
8695 Object.assign(target, React2.createContext(init));
8696 target.Provider._context = target;
8697 target.Consumer._context = target;
8698 return target;
8699 }
8700 var TransitionPhase;
8701 (function(TransitionPhase2) {
8702 TransitionPhase2["MOUNT"] = "mount";
8703 TransitionPhase2["ENTER"] = "enter";
8704 TransitionPhase2["UPDATE"] = "update";
8705 TransitionPhase2["LEAVE"] = "leave";
8706 })(TransitionPhase || (TransitionPhase = {}));
8707 var Interpolation = class extends FrameValue {
8708 constructor(source, args) {
8709 super();
8710 this.key = void 0;
8711 this.idle = true;
8712 this.calc = void 0;
8713 this._active = /* @__PURE__ */ new Set();
8714 this.source = source;
8715 this.calc = createInterpolator(...args);
8716 const value = this._get();
8717 const nodeType = getAnimatedType(value);
8718 setAnimated(this, nodeType.create(value));
8719 }
8720 advance(_dt) {
8721 const value = this._get();
8722 const oldValue = this.get();
8723 if (!isEqual(value, oldValue)) {
8724 getAnimated(this).setValue(value);
8725 this._onChange(value, this.idle);
8726 }
8727 if (!this.idle && checkIdle(this._active)) {
8728 becomeIdle(this);
8729 }
8730 }
8731 _get() {
8732 const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source));
8733 return this.calc(...inputs);
8734 }
8735 _start() {
8736 if (this.idle && !checkIdle(this._active)) {
8737 this.idle = false;
8738 each(getPayload(this), (node) => {
8739 node.done = false;
8740 });
8741 if (globals.skipAnimation) {
8742 raf.batchedUpdates(() => this.advance());
8743 becomeIdle(this);
8744 } else {
8745 frameLoop.start(this);
8746 }
8747 }
8748 }
8749 _attach() {
8750 let priority2 = 1;
8751 each(toArray(this.source), (source) => {
8752 if (hasFluidValue(source)) {
8753 addFluidObserver(source, this);
8754 }
8755 if (isFrameValue(source)) {
8756 if (!source.idle) {
8757 this._active.add(source);
8758 }
8759 priority2 = Math.max(priority2, source.priority + 1);
8760 }
8761 });
8762 this.priority = priority2;
8763 this._start();
8764 }
8765 _detach() {
8766 each(toArray(this.source), (source) => {
8767 if (hasFluidValue(source)) {
8768 removeFluidObserver(source, this);
8769 }
8770 });
8771 this._active.clear();
8772 becomeIdle(this);
8773 }
8774 eventObserved(event) {
8775 if (event.type == "change") {
8776 if (event.idle) {
8777 this.advance();
8778 } else {
8779 this._active.add(event.parent);
8780 this._start();
8781 }
8782 } else if (event.type == "idle") {
8783 this._active.delete(event.parent);
8784 } else if (event.type == "priority") {
8785 this.priority = toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0);
8786 }
8787 }
8788 };
8789 function isIdle(source) {
8790 return source.idle !== false;
8791 }
8792 function checkIdle(active) {
8793 return !active.size || Array.from(active).every(isIdle);
8794 }
8795 function becomeIdle(self) {
8796 if (!self.idle) {
8797 self.idle = true;
8798 each(getPayload(self), (node) => {
8799 node.done = true;
8800 });
8801 callFluidObservers(self, {
8802 type: "idle",
8803 parent: self
8804 });
8805 }
8806 }
8807 globals.assign({
8808 createStringInterpolator,
8809 to: (source, args) => new Interpolation(source, args)
8810 });
8811 var update2 = frameLoop.advance;
8812
8813 // node_modules/@react-spring/web/dist/react-spring-web.esm.js
8814 var import_react_dom = __toESM(require_react_dom());
8815 function _objectWithoutPropertiesLoose2(source, excluded) {
8816 if (source == null) return {};
8817 var target = {};
8818 var sourceKeys = Object.keys(source);
8819 var key, i3;
8820 for (i3 = 0; i3 < sourceKeys.length; i3++) {
8821 key = sourceKeys[i3];
8822 if (excluded.indexOf(key) >= 0) continue;
8823 target[key] = source[key];
8824 }
8825 return target;
8826 }
8827 var _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"];
8828 var isCustomPropRE = /^--/;
8829 function dangerousStyleValue(name2, value) {
8830 if (value == null || typeof value === "boolean" || value === "") return "";
8831 if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name2) && !(isUnitlessNumber.hasOwnProperty(name2) && isUnitlessNumber[name2])) return value + "px";
8832 return ("" + value).trim();
8833 }
8834 var attributeCache = {};
8835 function applyAnimatedValues(instance, props) {
8836 if (!instance.nodeType || !instance.setAttribute) {
8837 return false;
8838 }
8839 const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter";
8840 const _ref = props, {
8841 style,
8842 children,
8843 scrollTop,
8844 scrollLeft
8845 } = _ref, attributes = _objectWithoutPropertiesLoose2(_ref, _excluded$2);
8846 const values = Object.values(attributes);
8847 const names = Object.keys(attributes).map((name2) => isFilterElement || instance.hasAttribute(name2) ? name2 : attributeCache[name2] || (attributeCache[name2] = name2.replace(/([A-Z])/g, (n3) => "-" + n3.toLowerCase())));
8848 if (children !== void 0) {
8849 instance.textContent = children;
8850 }
8851 for (let name2 in style) {
8852 if (style.hasOwnProperty(name2)) {
8853 const value = dangerousStyleValue(name2, style[name2]);
8854 if (isCustomPropRE.test(name2)) {
8855 instance.style.setProperty(name2, value);
8856 } else {
8857 instance.style[name2] = value;
8858 }
8859 }
8860 }
8861 names.forEach((name2, i3) => {
8862 instance.setAttribute(name2, values[i3]);
8863 });
8864 if (scrollTop !== void 0) {
8865 instance.scrollTop = scrollTop;
8866 }
8867 if (scrollLeft !== void 0) {
8868 instance.scrollLeft = scrollLeft;
8869 }
8870 }
8871 var isUnitlessNumber = {
8872 animationIterationCount: true,
8873 borderImageOutset: true,
8874 borderImageSlice: true,
8875 borderImageWidth: true,
8876 boxFlex: true,
8877 boxFlexGroup: true,
8878 boxOrdinalGroup: true,
8879 columnCount: true,
8880 columns: true,
8881 flex: true,
8882 flexGrow: true,
8883 flexPositive: true,
8884 flexShrink: true,
8885 flexNegative: true,
8886 flexOrder: true,
8887 gridRow: true,
8888 gridRowEnd: true,
8889 gridRowSpan: true,
8890 gridRowStart: true,
8891 gridColumn: true,
8892 gridColumnEnd: true,
8893 gridColumnSpan: true,
8894 gridColumnStart: true,
8895 fontWeight: true,
8896 lineClamp: true,
8897 lineHeight: true,
8898 opacity: true,
8899 order: true,
8900 orphans: true,
8901 tabSize: true,
8902 widows: true,
8903 zIndex: true,
8904 zoom: true,
8905 fillOpacity: true,
8906 floodOpacity: true,
8907 stopOpacity: true,
8908 strokeDasharray: true,
8909 strokeDashoffset: true,
8910 strokeMiterlimit: true,
8911 strokeOpacity: true,
8912 strokeWidth: true
8913 };
8914 var prefixKey = (prefix2, key) => prefix2 + key.charAt(0).toUpperCase() + key.substring(1);
8915 var prefixes = ["Webkit", "Ms", "Moz", "O"];
8916 isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
8917 prefixes.forEach((prefix2) => acc[prefixKey(prefix2, prop)] = acc[prop]);
8918 return acc;
8919 }, isUnitlessNumber);
8920 var _excluded$1 = ["x", "y", "z"];
8921 var domTransforms = /^(matrix|translate|scale|rotate|skew)/;
8922 var pxTransforms = /^(translate)/;
8923 var degTransforms = /^(rotate|skew)/;
8924 var addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value;
8925 var isValueIdentity = (value, id) => is.arr(value) ? value.every((v3) => isValueIdentity(v3, id)) : is.num(value) ? value === id : parseFloat(value) === id;
8926 var AnimatedStyle = class extends AnimatedObject {
8927 constructor(_ref) {
8928 let {
8929 x: x2,
8930 y: y3,
8931 z
8932 } = _ref, style = _objectWithoutPropertiesLoose2(_ref, _excluded$1);
8933 const inputs = [];
8934 const transforms = [];
8935 if (x2 || y3 || z) {
8936 inputs.push([x2 || 0, y3 || 0, z || 0]);
8937 transforms.push((xyz) => [`translate3d(${xyz.map((v3) => addUnit(v3, "px")).join(",")})`, isValueIdentity(xyz, 0)]);
8938 }
8939 eachProp(style, (value, key) => {
8940 if (key === "transform") {
8941 inputs.push([value || ""]);
8942 transforms.push((transform) => [transform, transform === ""]);
8943 } else if (domTransforms.test(key)) {
8944 delete style[key];
8945 if (is.und(value)) return;
8946 const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : "";
8947 inputs.push(toArray(value));
8948 transforms.push(key === "rotate3d" ? ([x3, y4, z2, deg]) => [`rotate3d(${x3},${y4},${z2},${addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : (input) => [`${key}(${input.map((v3) => addUnit(v3, unit)).join(",")})`, isValueIdentity(input, key.startsWith("scale") ? 1 : 0)]);
8949 }
8950 });
8951 if (inputs.length) {
8952 style.transform = new FluidTransform(inputs, transforms);
8953 }
8954 super(style);
8955 }
8956 };
8957 var FluidTransform = class extends FluidValue {
8958 constructor(inputs, transforms) {
8959 super();
8960 this._value = null;
8961 this.inputs = inputs;
8962 this.transforms = transforms;
8963 }
8964 get() {
8965 return this._value || (this._value = this._get());
8966 }
8967 _get() {
8968 let transform = "";
8969 let identity3 = true;
8970 each(this.inputs, (input, i3) => {
8971 const arg1 = getFluidValue(input[0]);
8972 const [t4, id] = this.transforms[i3](is.arr(arg1) ? arg1 : input.map(getFluidValue));
8973 transform += " " + t4;
8974 identity3 = identity3 && id;
8975 });
8976 return identity3 ? "none" : transform;
8977 }
8978 observerAdded(count) {
8979 if (count == 1) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && addFluidObserver(value, this)));
8980 }
8981 observerRemoved(count) {
8982 if (count == 0) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && removeFluidObserver(value, this)));
8983 }
8984 eventObserved(event) {
8985 if (event.type == "change") {
8986 this._value = null;
8987 }
8988 callFluidObservers(this, event);
8989 }
8990 };
8991 var primitives = ["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", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"];
8992 var _excluded = ["scrollTop", "scrollLeft"];
8993 globals.assign({
8994 batchedUpdates: import_react_dom.unstable_batchedUpdates,
8995 createStringInterpolator,
8996 colors
8997 });
8998 var host = createHost(primitives, {
8999 applyAnimatedValues,
9000 createAnimatedStyle: (style) => new AnimatedStyle(style),
9001 getComponentProps: (_ref) => {
9002 let props = _objectWithoutPropertiesLoose2(_ref, _excluded);
9003 return props;
9004 }
9005 });
9006 var animated = host.animated;
9007
9008 // packages/fields/build-module/components/media-edit/use-moving-animation.mjs
9009 var import_element5 = __toESM(require_element(), 1);
9010 function getAbsolutePosition(element) {
9011 return {
9012 top: element.offsetTop,
9013 left: element.offsetLeft
9014 };
9015 }
9016 function useMovingAnimation(triggerAnimationOnChange) {
9017 const ref = (0, import_element5.useRef)(null);
9018 const previousRef = (0, import_element5.useRef)(void 0);
9019 if (ref.current) {
9020 previousRef.current = getAbsolutePosition(ref.current);
9021 }
9022 (0, import_element5.useLayoutEffect)(() => {
9023 const previous = previousRef.current;
9024 if (!previous || !ref.current) {
9025 return;
9026 }
9027 if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
9028 return;
9029 }
9030 const controller = new Controller({
9031 x: 0,
9032 y: 0,
9033 config: { mass: 5, tension: 2e3, friction: 200 },
9034 onChange({ value }) {
9035 if (!ref.current) {
9036 return;
9037 }
9038 let { x: x22, y: y22 } = value;
9039 x22 = Math.round(x22);
9040 y22 = Math.round(y22);
9041 const finishedMoving = x22 === 0 && y22 === 0;
9042 ref.current.style.transform = finishedMoving ? "" : `translate3d(${x22}px,${y22}px,0)`;
9043 }
9044 });
9045 ref.current.style.transform = "";
9046 const destination = getAbsolutePosition(ref.current);
9047 const x2 = Math.round(previous.left - destination.left);
9048 const y3 = Math.round(previous.top - destination.top);
9049 controller.start({ x: 0, y: 0, from: { x: x2, y: y3 } });
9050 return () => {
9051 controller.stop();
9052 controller.set({ x: 0, y: 0 });
9053 };
9054 }, [triggerAnimationOnChange]);
9055 return ref;
9056 }
9057
9058 // packages/fields/build-module/components/media-edit/index.mjs
9059 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
9060 var { MediaUploadModal } = unlock2(import_media_utils2.privateApis);
9061 function AnimatedMediaItem({
9062 children,
9063 index: index2,
9064 className
9065 }) {
9066 const ref = useMovingAnimation(index2);
9067 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { ref, className, children });
9068 }
9069 function normalizeValue(value) {
9070 if (Array.isArray(value)) {
9071 return value;
9072 }
9073 return value ? [value] : [];
9074 }
9075 function ConditionalMediaUpload({ render: render4, multiple, ...props }) {
9076 const [isModalOpen, setIsModalOpen] = (0, import_element6.useState)(false);
9077 if (window.__experimentalDataViewsMediaModal) {
9078 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
9079 render4 && render4({ open: () => setIsModalOpen(true) }),
9080 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9081 MediaUploadModal,
9082 {
9083 ...props,
9084 multiple,
9085 isOpen: isModalOpen,
9086 onClose: () => {
9087 setIsModalOpen(false);
9088 props.onClose?.();
9089 },
9090 onSelect: (media) => {
9091 setIsModalOpen(false);
9092 props.onSelect?.(media);
9093 }
9094 }
9095 )
9096 ] });
9097 }
9098 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9099 import_media_utils2.MediaUpload,
9100 {
9101 ...props,
9102 render: render4,
9103 multiple: multiple ? "add" : void 0
9104 }
9105 );
9106 }
9107 function MediaPickerButton({
9108 open,
9109 children,
9110 label,
9111 showTooltip = false,
9112 onFilesDrop,
9113 attachment,
9114 isUploading = false
9115 }) {
9116 const isBlob = attachment && (0, import_blob.isBlobURL)(attachment.source_url);
9117 const mediaPickerButton = /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
9118 "div",
9119 {
9120 className: clsx_default("fields__media-edit-picker-button", {
9121 "has-attachment": attachment
9122 }),
9123 role: "button",
9124 tabIndex: 0,
9125 onClick: () => {
9126 if (!isUploading) {
9127 open();
9128 }
9129 },
9130 onKeyDown: (event) => {
9131 if (isUploading) {
9132 return;
9133 }
9134 if (event.key === "Enter" || event.key === " ") {
9135 event.preventDefault();
9136 open();
9137 }
9138 },
9139 "aria-label": label,
9140 "aria-disabled": isUploading,
9141 children: [
9142 children,
9143 isBlob && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "fields__media-edit-picker-button-spinner", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.Spinner, {}) }),
9144 !isUploading && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9145 import_components5.DropZone,
9146 {
9147 onFilesDrop: (files) => onFilesDrop(files, attachment?.id)
9148 }
9149 )
9150 ]
9151 }
9152 );
9153 if (!showTooltip) {
9154 return mediaPickerButton;
9155 }
9156 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.Tooltip, { text: label, placement: "top", children: mediaPickerButton });
9157 }
9158 var archiveMimeTypes = [
9159 "application/zip",
9160 "application/x-zip-compressed",
9161 "application/x-rar-compressed",
9162 "application/x-7z-compressed",
9163 "application/x-tar",
9164 "application/x-gzip"
9165 ];
9166 function MediaTitle({ attachment }) {
9167 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.__experimentalTruncate, { className: "fields__media-edit-filename", children: attachment.title.rendered });
9168 }
9169 function MediaEditPlaceholder(props) {
9170 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(MediaPickerButton, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "fields__media-edit-placeholder", children: props.label }) });
9171 }
9172 function MoveButtons({
9173 itemId,
9174 index: index2,
9175 totalItems,
9176 isUploading,
9177 moveItem,
9178 orientation = "vertical"
9179 }) {
9180 const isHorizontal = orientation === "horizontal";
9181 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
9182 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9183 import_components5.Button,
9184 {
9185 __next40pxDefaultSize: true,
9186 icon: isHorizontal ? chevron_left_default : chevron_up_default,
9187 label: isHorizontal ? (0, import_i18n13.__)("Move left") : (0, import_i18n13.__)("Move up"),
9188 size: "small",
9189 disabled: isUploading || index2 === 0,
9190 accessibleWhenDisabled: true,
9191 tooltipPosition: "top",
9192 onClick: (event) => {
9193 event.stopPropagation();
9194 moveItem(itemId, "up");
9195 }
9196 }
9197 ),
9198 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9199 import_components5.Button,
9200 {
9201 __next40pxDefaultSize: true,
9202 icon: isHorizontal ? chevron_right_default : chevron_down_default,
9203 label: isHorizontal ? (0, import_i18n13.__)("Move right") : (0, import_i18n13.__)("Move down"),
9204 size: "small",
9205 disabled: isUploading || index2 === totalItems - 1,
9206 accessibleWhenDisabled: true,
9207 tooltipPosition: "top",
9208 onClick: (event) => {
9209 event.stopPropagation();
9210 moveItem(itemId, "down");
9211 }
9212 }
9213 )
9214 ] });
9215 }
9216 function MediaPreview({ attachment }) {
9217 const url = attachment.source_url;
9218 const mimeType = attachment.mime_type || "";
9219 if (mimeType.startsWith("image")) {
9220 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9221 "img",
9222 {
9223 className: "fields__media-edit-thumbnail",
9224 alt: attachment.alt_text || "",
9225 src: url
9226 }
9227 );
9228 } else if (mimeType.startsWith("audio")) {
9229 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.Icon, { icon: audio_default });
9230 } else if (mimeType.startsWith("video")) {
9231 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.Icon, { icon: video_default });
9232 } else if (archiveMimeTypes.includes(mimeType)) {
9233 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.Icon, { icon: archive_default });
9234 }
9235 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.Icon, { icon: file_default });
9236 }
9237 function ExpandedMediaEditAttachments({
9238 allItems,
9239 addButtonLabel,
9240 multiple,
9241 removeItem,
9242 moveItem,
9243 open,
9244 onFilesDrop,
9245 isUploading,
9246 setTargetItemId
9247 }) {
9248 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
9249 "div",
9250 {
9251 className: clsx_default("fields__media-edit-expanded", {
9252 "is-multiple": multiple,
9253 "is-single": !multiple,
9254 "is-empty": !allItems?.length
9255 }),
9256 children: [
9257 allItems?.map((attachment, index2) => {
9258 const hasPreviewImage = attachment.mime_type?.startsWith("image");
9259 const isBlob = (0, import_blob.isBlobURL)(attachment.source_url);
9260 const attachmentNumericId = attachment.id;
9261 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
9262 AnimatedMediaItem,
9263 {
9264 index: index2,
9265 className: clsx_default("fields__media-edit-expanded-item", {
9266 "has-preview-image": hasPreviewImage
9267 }),
9268 children: [
9269 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9270 MediaPickerButton,
9271 {
9272 open: () => {
9273 setTargetItemId(attachmentNumericId);
9274 open();
9275 },
9276 label: !isBlob ? (0, import_i18n13.sprintf)(
9277 /* translators: %s: The title of the media item. */
9278 (0, import_i18n13.__)("Replace %s"),
9279 attachment.title.rendered
9280 ) : (0, import_i18n13.__)("Replace"),
9281 showTooltip: true,
9282 onFilesDrop,
9283 attachment,
9284 isUploading,
9285 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "fields__media-edit-expanded-preview", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9286 import_components5.__experimentalVStack,
9287 {
9288 spacing: 0,
9289 alignment: "center",
9290 justify: "center",
9291 className: "fields__media-edit-expanded-preview-stack",
9292 children: (!isBlob || hasPreviewImage) && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9293 MediaPreview,
9294 {
9295 attachment
9296 }
9297 )
9298 }
9299 ) })
9300 }
9301 ),
9302 !isBlob && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "fields__media-edit-expanded-overlay", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
9303 import_components5.__experimentalHStack,
9304 {
9305 className: "fields__media-edit-expanded-actions",
9306 spacing: 0,
9307 alignment: "flex-end",
9308 expanded: false,
9309 children: [
9310 multiple && allItems.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9311 MoveButtons,
9312 {
9313 itemId: attachmentNumericId,
9314 index: index2,
9315 totalItems: allItems.length,
9316 isUploading,
9317 moveItem,
9318 orientation: "horizontal"
9319 }
9320 ),
9321 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9322 import_components5.Button,
9323 {
9324 __next40pxDefaultSize: true,
9325 icon: close_small_default,
9326 label: (0, import_i18n13.__)("Remove"),
9327 size: "small",
9328 disabled: isUploading,
9329 accessibleWhenDisabled: true,
9330 tooltipPosition: "top",
9331 onClick: (event) => {
9332 event.stopPropagation();
9333 removeItem(attachmentNumericId);
9334 }
9335 }
9336 )
9337 ]
9338 }
9339 ) })
9340 ]
9341 },
9342 attachment.id
9343 );
9344 }),
9345 (multiple || !allItems?.length) && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9346 MediaEditPlaceholder,
9347 {
9348 open: () => {
9349 setTargetItemId(void 0);
9350 open();
9351 },
9352 label: addButtonLabel,
9353 onFilesDrop,
9354 isUploading
9355 }
9356 )
9357 ]
9358 }
9359 );
9360 }
9361 function CompactMediaEditAttachments({
9362 allItems,
9363 addButtonLabel,
9364 multiple,
9365 removeItem,
9366 moveItem,
9367 open,
9368 onFilesDrop,
9369 isUploading,
9370 setTargetItemId
9371 }) {
9372 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
9373 !!allItems?.length && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9374 "div",
9375 {
9376 className: clsx_default("fields__media-edit-compact-group", {
9377 "is-single": allItems.length === 1
9378 }),
9379 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.__experimentalVStack, { spacing: 0, children: allItems.map((attachment, index2) => {
9380 const isBlob = (0, import_blob.isBlobURL)(attachment.source_url);
9381 const showMoveButtons = multiple && allItems.length > 1;
9382 const attachmentNumericId = attachment.id;
9383 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
9384 AnimatedMediaItem,
9385 {
9386 index: index2,
9387 className: "fields__media-edit-compact",
9388 children: [
9389 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9390 MediaPickerButton,
9391 {
9392 open: () => {
9393 setTargetItemId(
9394 attachmentNumericId
9395 );
9396 open();
9397 },
9398 label: (0, import_i18n13.__)("Replace"),
9399 showTooltip: true,
9400 onFilesDrop,
9401 attachment,
9402 isUploading,
9403 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
9404 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9405 MediaPreview,
9406 {
9407 attachment
9408 }
9409 ),
9410 !isBlob && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9411 MediaTitle,
9412 {
9413 attachment
9414 }
9415 )
9416 ] })
9417 }
9418 ),
9419 !isBlob && /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
9420 import_components5.__experimentalHStack,
9421 {
9422 className: "fields__media-edit-compact-movers",
9423 spacing: 0,
9424 alignment: "flex-end",
9425 expanded: false,
9426 children: [
9427 showMoveButtons && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9428 MoveButtons,
9429 {
9430 itemId: attachmentNumericId,
9431 index: index2,
9432 totalItems: allItems.length,
9433 isUploading,
9434 moveItem,
9435 orientation: "vertical"
9436 }
9437 ),
9438 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9439 import_components5.Button,
9440 {
9441 __next40pxDefaultSize: true,
9442 icon: close_small_default,
9443 label: (0, import_i18n13.__)("Remove"),
9444 size: "small",
9445 disabled: isUploading,
9446 accessibleWhenDisabled: true,
9447 tooltipPosition: "top",
9448 onClick: (event) => {
9449 event.stopPropagation();
9450 removeItem(
9451 attachmentNumericId
9452 );
9453 }
9454 }
9455 )
9456 ]
9457 }
9458 )
9459 ]
9460 },
9461 attachment.id
9462 );
9463 }) })
9464 }
9465 ),
9466 (multiple || !allItems?.length) && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9467 MediaEditPlaceholder,
9468 {
9469 open: () => {
9470 setTargetItemId(void 0);
9471 open();
9472 },
9473 label: addButtonLabel,
9474 onFilesDrop,
9475 isUploading
9476 }
9477 )
9478 ] });
9479 }
9480 function MediaEdit({
9481 data,
9482 field,
9483 onChange,
9484 hideLabelFromVision,
9485 allowedTypes = ["image"],
9486 multiple,
9487 isExpanded,
9488 validity
9489 }) {
9490 const value = field.getValue({ item: data });
9491 const [isTouched, setIsTouched] = (0, import_element6.useState)(false);
9492 const validityTargetRef = (0, import_element6.useRef)(null);
9493 const [customValidity, setCustomValidity] = (0, import_element6.useState)(void 0);
9494 (0, import_element6.useEffect)(() => {
9495 const validityTarget = validityTargetRef.current;
9496 const handler = () => {
9497 setIsTouched(true);
9498 };
9499 validityTarget?.addEventListener("invalid", handler);
9500 return () => validityTarget?.removeEventListener("invalid", handler);
9501 }, []);
9502 const attachments = (0, import_data8.useSelect)(
9503 (select6) => {
9504 if (!value) {
9505 return null;
9506 }
9507 const normalizedValue = normalizeValue(value);
9508 const sortedIds = [...normalizedValue].sort((a3, b3) => a3 - b3);
9509 const { getEntityRecords } = select6(import_core_data6.store);
9510 return getEntityRecords("postType", "attachment", {
9511 include: sortedIds
9512 });
9513 },
9514 [value]
9515 );
9516 const stableAttachmentsRef = (0, import_element6.useRef)(
9517 null
9518 );
9519 if (attachments !== null) {
9520 stableAttachmentsRef.current = attachments;
9521 }
9522 let stableAttachments = attachments;
9523 if (attachments === null && stableAttachmentsRef.current && value) {
9524 const stableIds = new Set(
9525 stableAttachmentsRef.current.map((a3) => a3.id)
9526 );
9527 if (normalizeValue(value).every((id) => stableIds.has(id))) {
9528 stableAttachments = stableAttachmentsRef.current;
9529 }
9530 }
9531 const orderedAttachments = (0, import_element6.useMemo)(() => {
9532 if (!stableAttachments) {
9533 return null;
9534 }
9535 const normalizedValue = normalizeValue(value);
9536 const attachmentMap = new Map(
9537 stableAttachments.map((a3) => [a3.id, a3])
9538 );
9539 return normalizedValue.map((id) => attachmentMap.get(id)).filter((a3) => a3 !== void 0);
9540 }, [stableAttachments, value]);
9541 const { createErrorNotice } = (0, import_data8.useDispatch)(import_notices3.store);
9542 const { receiveEntityRecords } = (0, import_data8.useDispatch)(import_core_data6.store);
9543 const [targetItemId, setTargetItemId] = (0, import_element6.useState)();
9544 const openModalRef = (0, import_element6.useRef)(void 0);
9545 const [pendingOpen, setPendingOpen] = (0, import_element6.useState)(false);
9546 const [blobs, setBlobs] = (0, import_element6.useState)([]);
9547 (0, import_element6.useEffect)(() => {
9548 if (pendingOpen) {
9549 setPendingOpen(false);
9550 openModalRef.current?.();
9551 }
9552 }, [pendingOpen]);
9553 const onChangeControl = (0, import_element6.useCallback)(
9554 (newValue) => onChange(field.setValue({ item: data, value: newValue })),
9555 [data, field, onChange]
9556 );
9557 const removeItem = (0, import_element6.useCallback)(
9558 (itemId) => {
9559 const currentIds = normalizeValue(value);
9560 const newIds = currentIds.filter((id) => id !== itemId);
9561 setIsTouched(true);
9562 onChangeControl(newIds.length ? newIds : void 0);
9563 },
9564 [value, onChangeControl]
9565 );
9566 const moveItem = (0, import_element6.useCallback)(
9567 (itemId, direction) => {
9568 if (!orderedAttachments) {
9569 return;
9570 }
9571 const currentIds = orderedAttachments.map((a3) => a3.id);
9572 const index2 = currentIds.indexOf(itemId);
9573 const newIndex = direction === "up" ? index2 - 1 : index2 + 1;
9574 [currentIds[index2], currentIds[newIndex]] = [
9575 currentIds[newIndex],
9576 currentIds[index2]
9577 ];
9578 onChangeControl(currentIds);
9579 },
9580 [orderedAttachments, onChangeControl]
9581 );
9582 const onFilesDrop = (0, import_element6.useCallback)(
9583 (files, _targetItemId) => {
9584 setTargetItemId(_targetItemId);
9585 (0, import_media_utils2.uploadMedia)({
9586 allowedTypes: allowedTypes?.length ? allowedTypes : void 0,
9587 filesList: files,
9588 onFileChange(uploadedMedia) {
9589 const blobUrls = uploadedMedia.filter((item) => (0, import_blob.isBlobURL)(item.url)).map((item) => item.url);
9590 setBlobs(blobUrls);
9591 if (!!blobUrls.length) {
9592 return;
9593 }
9594 receiveEntityRecords(
9595 "postType",
9596 "attachment",
9597 [],
9598 void 0,
9599 true
9600 );
9601 const uploadedIds = uploadedMedia.map(
9602 (item) => item.id
9603 );
9604 if (!multiple) {
9605 onChangeControl(uploadedIds[0]);
9606 setTargetItemId(void 0);
9607 return;
9608 }
9609 const currentValue = normalizeValue(value);
9610 if (_targetItemId === void 0) {
9611 onChangeControl([...currentValue, ...uploadedIds]);
9612 } else {
9613 const newValue = [...currentValue];
9614 newValue.splice(
9615 currentValue.indexOf(_targetItemId),
9616 1,
9617 ...uploadedIds
9618 );
9619 onChangeControl(newValue);
9620 }
9621 setTargetItemId(void 0);
9622 },
9623 onError(error) {
9624 setTargetItemId(void 0);
9625 setBlobs([]);
9626 createErrorNotice(error.message, { type: "snackbar" });
9627 },
9628 multiple: !!multiple
9629 });
9630 },
9631 [
9632 allowedTypes,
9633 value,
9634 multiple,
9635 createErrorNotice,
9636 onChangeControl,
9637 receiveEntityRecords
9638 ]
9639 );
9640 const addButtonLabel = field.placeholder || (multiple ? (0, import_i18n13.__)("Choose files") : (0, import_i18n13.__)("Choose file"));
9641 const allItems = (0, import_element6.useMemo)(() => {
9642 if (!blobs.length) {
9643 return orderedAttachments;
9644 }
9645 const items = [
9646 ...orderedAttachments || []
9647 ];
9648 const blobItems = blobs.map((url) => ({
9649 id: url,
9650 source_url: url,
9651 mime_type: (0, import_blob.getBlobTypeByURL)(url)
9652 }));
9653 if (targetItemId !== void 0) {
9654 const targetIndex = items.findIndex(
9655 (a3) => a3.id === targetItemId
9656 );
9657 items.splice(targetIndex, 1, ...blobItems);
9658 } else {
9659 items.push(...blobItems);
9660 }
9661 return items;
9662 }, [orderedAttachments, targetItemId, blobs]);
9663 (0, import_element6.useEffect)(() => {
9664 if (!isTouched) {
9665 return;
9666 }
9667 const input = validityTargetRef.current;
9668 if (!input) {
9669 return;
9670 }
9671 if (validity) {
9672 const customValidityResult = validity?.custom;
9673 setCustomValidity(customValidityResult);
9674 if (customValidityResult?.type === "invalid") {
9675 input.setCustomValidity(
9676 customValidityResult.message || (0, import_i18n13.__)("Invalid")
9677 );
9678 } else {
9679 input.setCustomValidity("");
9680 }
9681 } else {
9682 input.setCustomValidity("");
9683 setCustomValidity(void 0);
9684 }
9685 }, [isTouched, field.isValid, validity]);
9686 const onBlur = (0, import_element6.useCallback)(
9687 (event) => {
9688 if (isTouched) {
9689 return;
9690 }
9691 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
9692 setIsTouched(true);
9693 }
9694 },
9695 [isTouched]
9696 );
9697 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { onBlur, children: [
9698 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("fieldset", { className: "fields__media-edit", "data-field-id": field.id, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9699 ConditionalMediaUpload,
9700 {
9701 onSelect: (selectedMedia) => {
9702 if (!multiple) {
9703 onChangeControl(selectedMedia.id);
9704 setTargetItemId(void 0);
9705 return;
9706 }
9707 const newIds = Array.isArray(selectedMedia) ? selectedMedia.map((m2) => m2.id) : [selectedMedia.id];
9708 const currentValue = normalizeValue(value);
9709 if (!currentValue.length) {
9710 onChangeControl(newIds);
9711 } else if (targetItemId === void 0) {
9712 const existingItems = currentValue.filter(
9713 (id) => newIds.includes(id)
9714 );
9715 const newItems = newIds.filter(
9716 (id) => !currentValue.includes(id)
9717 );
9718 onChangeControl([
9719 ...existingItems,
9720 ...newItems
9721 ]);
9722 } else if (selectedMedia.id !== targetItemId) {
9723 const filtered = currentValue.filter(
9724 (id) => id !== selectedMedia.id
9725 );
9726 onChangeControl(
9727 filtered.map(
9728 (id) => id === targetItemId ? selectedMedia.id : id
9729 )
9730 );
9731 }
9732 setTargetItemId(void 0);
9733 },
9734 onClose: () => setTargetItemId(void 0),
9735 allowedTypes,
9736 value: targetItemId !== void 0 ? targetItemId : value,
9737 multiple: multiple && targetItemId === void 0,
9738 title: field.label,
9739 render: ({ open }) => {
9740 openModalRef.current = open;
9741 const AttachmentsComponent = isExpanded ? ExpandedMediaEditAttachments : CompactMediaEditAttachments;
9742 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_components5.__experimentalVStack, { spacing: 2, children: [
9743 field.label && (hideLabelFromVision ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.VisuallyHidden, { as: "legend", children: field.label }) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9744 import_components5.BaseControl.VisualLabel,
9745 {
9746 as: "legend",
9747 style: { marginBottom: 0 },
9748 children: field.label
9749 }
9750 )),
9751 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9752 AttachmentsComponent,
9753 {
9754 allItems,
9755 addButtonLabel,
9756 multiple,
9757 removeItem,
9758 moveItem,
9759 open: () => setPendingOpen(true),
9760 onFilesDrop,
9761 isUploading: !!blobs.length,
9762 setTargetItemId
9763 }
9764 ),
9765 field.description && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.__experimentalText, { variant: "muted", children: field.description })
9766 ] });
9767 }
9768 }
9769 ) }),
9770 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components5.VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9771 "input",
9772 {
9773 type: "text",
9774 ref: validityTargetRef,
9775 value: value ?? "",
9776 tabIndex: -1,
9777 "aria-hidden": "true",
9778 onChange: () => {
9779 }
9780 }
9781 ) }),
9782 customValidity && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { "aria-live": "polite", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
9783 "p",
9784 {
9785 className: clsx_default(
9786 "components-validated-control__indicator",
9787 {
9788 "is-invalid": customValidity.type === "invalid",
9789 "is-valid": customValidity.type === "valid"
9790 }
9791 ),
9792 children: [
9793 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9794 import_components5.Icon,
9795 {
9796 className: "components-validated-control__indicator-icon",
9797 icon: error_default,
9798 size: 16,
9799 fill: "currentColor"
9800 }
9801 ),
9802 customValidity.message
9803 ]
9804 }
9805 ) })
9806 ] });
9807 }
9808
9809 // packages/fields/build-module/fields/featured-image/featured-image-view.mjs
9810 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
9811 var FeaturedImageView = ({
9812 item,
9813 config: config2
9814 }) => {
9815 const media = item?._embedded?.["wp:featuredmedia"]?.[0];
9816 const url = media?.source_url;
9817 if (url) {
9818 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9819 "img",
9820 {
9821 className: "fields-controls__featured-image-image",
9822 src: url,
9823 alt: "",
9824 srcSet: media?.media_details?.sizes ? Object.values(media.media_details.sizes).map(
9825 (size3) => `${size3.source_url} ${size3.width}w`
9826 ).join(", ") : void 0,
9827 sizes: config2?.sizes || "100vw"
9828 }
9829 );
9830 }
9831 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "fields-controls__featured-image-placeholder" });
9832 };
9833
9834 // packages/fields/build-module/fields/featured-image/index.mjs
9835 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
9836 var featuredImageField = {
9837 id: "featured_media",
9838 type: "media",
9839 label: (0, import_i18n14.__)("Featured Image"),
9840 Edit: (props) => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(MediaEdit, { ...props, isExpanded: true }),
9841 render: FeaturedImageView,
9842 setValue: ({ value }) => ({
9843 featured_media: value ?? 0
9844 }),
9845 enableSorting: false,
9846 filterBy: false
9847 };
9848 var featured_image_default = featuredImageField;
9849
9850 // packages/fields/build-module/fields/template/index.mjs
9851 var import_i18n16 = __toESM(require_i18n(), 1);
9852
9853 // packages/fields/build-module/fields/template/template-edit.mjs
9854 var import_element7 = __toESM(require_element(), 1);
9855 var import_core_data8 = __toESM(require_core_data(), 1);
9856 var import_components6 = __toESM(require_components(), 1);
9857 var import_data10 = __toESM(require_data(), 1);
9858 var import_i18n15 = __toESM(require_i18n(), 1);
9859
9860 // packages/fields/build-module/fields/template/hooks.mjs
9861 var import_data9 = __toESM(require_data(), 1);
9862 var import_core_data7 = __toESM(require_core_data(), 1);
9863 function getTemplateSlugToCheck(postType2, slug) {
9864 if (slug) {
9865 return postType2 === "page" ? `${postType2}-${slug}` : `single-${postType2}-${slug}`;
9866 }
9867 return postType2 === "page" ? "page" : `single-${postType2}`;
9868 }
9869 var NAME_NOT_FOUND = "";
9870 function useDefaultTemplateLabel(postType2, postId2, slug) {
9871 return (0, import_data9.useSelect)(
9872 (select6) => {
9873 if (!postType2 || !postId2) {
9874 return NAME_NOT_FOUND;
9875 }
9876 const postIdStr = String(postId2);
9877 const homePage = unlock2(select6(import_core_data7.store)).getHomePage();
9878 if (postType2 === "page" && homePage?.postType === "page" && homePage?.postId === postIdStr) {
9879 const templates = select6(
9880 import_core_data7.store
9881 ).getEntityRecords("postType", "wp_template", {
9882 per_page: -1
9883 });
9884 const frontPage = templates?.find(
9885 (t4) => t4.slug === "front-page"
9886 );
9887 if (frontPage) {
9888 return getItemTitle(frontPage);
9889 }
9890 }
9891 const postsPageId = unlock2(select6(import_core_data7.store)).getPostsPageId();
9892 if (postType2 === "page" && postsPageId === postIdStr) {
9893 const templateId22 = select6(import_core_data7.store).getDefaultTemplateId({
9894 slug: "home"
9895 });
9896 if (!templateId22) {
9897 return NAME_NOT_FOUND;
9898 }
9899 const template22 = select6(
9900 import_core_data7.store
9901 ).getEntityRecord(
9902 "postType",
9903 "wp_template",
9904 templateId22
9905 );
9906 return template22 ? getItemTitle(template22) : NAME_NOT_FOUND;
9907 }
9908 const slugToCheck = getTemplateSlugToCheck(postType2, slug);
9909 const templateId2 = select6(import_core_data7.store).getDefaultTemplateId({
9910 slug: slugToCheck
9911 });
9912 if (!templateId2) {
9913 return NAME_NOT_FOUND;
9914 }
9915 const template2 = select6(import_core_data7.store).getEntityRecord(
9916 "postType",
9917 "wp_template",
9918 templateId2
9919 );
9920 return template2 ? getItemTitle(template2) : NAME_NOT_FOUND;
9921 },
9922 [postType2, postId2, slug]
9923 );
9924 }
9925
9926 // packages/fields/build-module/fields/template/template-edit.mjs
9927 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
9928 var EMPTY_ARRAY2 = [];
9929 var TemplateEdit = ({
9930 data,
9931 field,
9932 onChange
9933 }) => {
9934 const { id } = field;
9935 const postType2 = data.type;
9936 const postId2 = typeof data.id === "number" ? data.id : parseInt(data.id, 10);
9937 const slug = data.slug;
9938 const { templates, canSwitchTemplate } = (0, import_data10.useSelect)(
9939 (select6) => {
9940 const allTemplates = select6(import_core_data8.store).getEntityRecords(
9941 "postType",
9942 "wp_template",
9943 {
9944 per_page: -1,
9945 post_type: postType2
9946 }
9947 ) ?? EMPTY_ARRAY2;
9948 const { getHomePage, getPostsPageId } = unlock2(
9949 select6(import_core_data8.store)
9950 );
9951 const singlePostId = String(postId2);
9952 const isPostsPage = singlePostId !== void 0 && getPostsPageId() === singlePostId;
9953 const isFrontPage = singlePostId !== void 0 && postType2 === "page" && getHomePage()?.postId === singlePostId;
9954 return {
9955 templates: allTemplates,
9956 canSwitchTemplate: !isPostsPage && !isFrontPage
9957 };
9958 },
9959 [postId2, postType2]
9960 );
9961 const defaultTemplateLabel = useDefaultTemplateLabel(
9962 postType2,
9963 postId2,
9964 slug
9965 );
9966 const value = field.getValue({ item: data });
9967 const onChangeControl = (0, import_element7.useCallback)(
9968 (newValue) => onChange({
9969 [id]: newValue
9970 }),
9971 [id, onChange]
9972 );
9973 const options = (0, import_element7.useMemo)(() => {
9974 const templateOptions = templates.map((template2) => ({
9975 label: getItemTitle(template2),
9976 value: template2.slug
9977 }));
9978 return [
9979 { label: defaultTemplateLabel, value: "" },
9980 ...templateOptions
9981 ];
9982 }, [templates, defaultTemplateLabel]);
9983 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
9984 import_components6.SelectControl,
9985 {
9986 __next40pxDefaultSize: true,
9987 label: (0, import_i18n15.__)("Template"),
9988 hideLabelFromVision: true,
9989 value,
9990 options,
9991 onChange: onChangeControl,
9992 disabled: !canSwitchTemplate
9993 }
9994 );
9995 };
9996
9997 // packages/fields/build-module/fields/template/template-view.mjs
9998 var import_data11 = __toESM(require_data(), 1);
9999 var import_core_data9 = __toESM(require_core_data(), 1);
10000 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
10001 var TemplateView = ({
10002 item,
10003 field
10004 }) => {
10005 const postType2 = item.type;
10006 const slug = item.slug;
10007 const postId2 = item.id;
10008 const templateSlug = field.getValue({ item });
10009 const defaultTemplateLabel = useDefaultTemplateLabel(
10010 postType2,
10011 postId2,
10012 slug
10013 );
10014 const templateLabel = (0, import_data11.useSelect)(
10015 (select6) => {
10016 if (!templateSlug) {
10017 return;
10018 }
10019 const allTemplates = select6(
10020 import_core_data9.store
10021 ).getEntityRecords("postType", "wp_template", {
10022 per_page: -1,
10023 post_type: postType2
10024 });
10025 const match3 = allTemplates?.find(
10026 (t4) => t4.slug === templateSlug
10027 );
10028 return match3 ? getItemTitle(match3) : void 0;
10029 },
10030 [postType2, templateSlug]
10031 );
10032 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_jsx_runtime85.Fragment, { children: templateLabel ?? defaultTemplateLabel });
10033 };
10034
10035 // packages/fields/build-module/fields/template/index.mjs
10036 var templateField = {
10037 id: "template",
10038 type: "text",
10039 label: (0, import_i18n16.__)("Template"),
10040 Edit: TemplateEdit,
10041 render: TemplateView,
10042 enableSorting: false,
10043 filterBy: false
10044 };
10045 var template_default = templateField;
10046
10047 // packages/fields/build-module/fields/parent/index.mjs
10048 var import_i18n20 = __toESM(require_i18n(), 1);
10049
10050 // packages/fields/build-module/fields/parent/parent-edit.mjs
10051 var import_remove_accents = __toESM(require_remove_accents(), 1);
10052 var import_components7 = __toESM(require_components(), 1);
10053 var import_data12 = __toESM(require_data(), 1);
10054 var import_element8 = __toESM(require_element(), 1);
10055 var import_core_data10 = __toESM(require_core_data(), 1);
10056 var import_compose2 = __toESM(require_compose(), 1);
10057 var import_html_entities3 = __toESM(require_html_entities(), 1);
10058 var import_i18n18 = __toESM(require_i18n(), 1);
10059 var import_url6 = __toESM(require_url(), 1);
10060
10061 // packages/fields/build-module/fields/parent/utils.mjs
10062 var import_html_entities2 = __toESM(require_html_entities(), 1);
10063 var import_i18n17 = __toESM(require_i18n(), 1);
10064 function getTitleWithFallbackName(post2) {
10065 return typeof post2.title === "object" && "rendered" in post2.title && post2.title.rendered ? (0, import_html_entities2.decodeEntities)(post2.title.rendered) : `#${post2?.id} (${(0, import_i18n17.__)("no title")})`;
10066 }
10067
10068 // packages/fields/build-module/fields/parent/parent-edit.mjs
10069 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
10070 function buildTermsTree(flatTerms) {
10071 const flatTermsWithParentAndChildren = flatTerms.map((term) => {
10072 return {
10073 children: [],
10074 ...term
10075 };
10076 });
10077 if (flatTermsWithParentAndChildren.some(
10078 ({ parent }) => parent === null || parent === void 0
10079 )) {
10080 return flatTermsWithParentAndChildren;
10081 }
10082 const termsByParent = flatTermsWithParentAndChildren.reduce(
10083 (acc, term) => {
10084 const { parent } = term;
10085 if (!acc[parent]) {
10086 acc[parent] = [];
10087 }
10088 acc[parent].push(term);
10089 return acc;
10090 },
10091 {}
10092 );
10093 const fillWithChildren = (terms) => {
10094 return terms.map((term) => {
10095 const children = termsByParent[term.id];
10096 return {
10097 ...term,
10098 children: children && children.length ? fillWithChildren(children) : []
10099 };
10100 });
10101 };
10102 return fillWithChildren(termsByParent["0"] || []);
10103 }
10104 var getItemPriority = (name2, searchValue) => {
10105 const normalizedName = (0, import_remove_accents.default)(name2 || "").toLowerCase();
10106 const normalizedSearch = (0, import_remove_accents.default)(searchValue || "").toLowerCase();
10107 if (normalizedName === normalizedSearch) {
10108 return 0;
10109 }
10110 if (normalizedName.startsWith(normalizedSearch)) {
10111 return normalizedName.length;
10112 }
10113 return Infinity;
10114 };
10115 function PageAttributesParent({
10116 data,
10117 onChangeControl
10118 }) {
10119 const [fieldValue, setFieldValue] = (0, import_element8.useState)(null);
10120 const pageId = data.parent;
10121 const postId2 = data.id;
10122 const postTypeSlug = data.type;
10123 const { parentPostTitle, pageItems, isHierarchical } = (0, import_data12.useSelect)(
10124 (select6) => {
10125 const { getEntityRecord, getEntityRecords, getPostType } = select6(import_core_data10.store);
10126 const postTypeInfo = getPostType(postTypeSlug);
10127 const postIsHierarchical = postTypeInfo?.hierarchical && postTypeInfo.viewable;
10128 const parentPost = pageId ? getEntityRecord(
10129 "postType",
10130 postTypeSlug,
10131 pageId
10132 ) : null;
10133 const query = {
10134 per_page: 100,
10135 exclude: postId2,
10136 parent_exclude: postId2,
10137 orderby: "menu_order",
10138 order: "asc",
10139 _fields: "id,title,parent",
10140 ...fieldValue !== null && {
10141 // Perform a search by relevance when the field is changed.
10142 search: fieldValue,
10143 orderby: "relevance"
10144 }
10145 };
10146 return {
10147 isHierarchical: postIsHierarchical,
10148 parentPostTitle: parentPost ? getTitleWithFallbackName(parentPost) : "",
10149 pageItems: postIsHierarchical ? getEntityRecords(
10150 "postType",
10151 postTypeSlug,
10152 query
10153 ) : null
10154 };
10155 },
10156 [fieldValue, pageId, postId2, postTypeSlug]
10157 );
10158 const parentOptions = (0, import_element8.useMemo)(() => {
10159 const getOptionsFromTree = (tree2, level = 0) => {
10160 const mappedNodes = tree2.map((treeNode) => [
10161 {
10162 value: treeNode.id,
10163 label: "\u2014 ".repeat(level) + (0, import_html_entities3.decodeEntities)(treeNode.name),
10164 rawName: treeNode.name
10165 },
10166 ...getOptionsFromTree(treeNode.children || [], level + 1)
10167 ]);
10168 const sortedNodes = mappedNodes.sort(([a3], [b3]) => {
10169 const priorityA = getItemPriority(
10170 a3.rawName,
10171 fieldValue ?? ""
10172 );
10173 const priorityB = getItemPriority(
10174 b3.rawName,
10175 fieldValue ?? ""
10176 );
10177 return priorityA >= priorityB ? 1 : -1;
10178 });
10179 return sortedNodes.flat();
10180 };
10181 if (!pageItems) {
10182 return [];
10183 }
10184 let tree = pageItems.map((item) => ({
10185 id: item.id,
10186 parent: item.parent ?? null,
10187 name: getTitleWithFallbackName(item)
10188 }));
10189 if (!fieldValue) {
10190 tree = buildTermsTree(tree);
10191 }
10192 const opts = getOptionsFromTree(tree);
10193 const optsHasParent = opts.find((item) => item.value === pageId);
10194 if (pageId && parentPostTitle && !optsHasParent) {
10195 opts.unshift({
10196 value: pageId,
10197 label: parentPostTitle,
10198 rawName: ""
10199 });
10200 }
10201 return opts.map((option) => ({
10202 ...option,
10203 value: option.value.toString()
10204 }));
10205 }, [pageItems, fieldValue, parentPostTitle, pageId]);
10206 if (!isHierarchical) {
10207 return null;
10208 }
10209 const handleKeydown = (inputValue) => {
10210 setFieldValue(inputValue);
10211 };
10212 const handleChange = (selectedPostId) => {
10213 if (selectedPostId) {
10214 return onChangeControl(parseInt(selectedPostId, 10) ?? 0);
10215 }
10216 onChangeControl(0);
10217 };
10218 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
10219 import_components7.ComboboxControl,
10220 {
10221 __next40pxDefaultSize: true,
10222 label: (0, import_i18n18.__)("Parent"),
10223 help: (0, import_i18n18.__)("Choose a parent page."),
10224 value: pageId?.toString(),
10225 options: parentOptions,
10226 onFilterValueChange: (0, import_compose2.debounce)(
10227 (value) => handleKeydown(value),
10228 300
10229 ),
10230 onChange: handleChange,
10231 hideLabelFromVision: true
10232 }
10233 );
10234 }
10235 var ParentEdit = ({
10236 data,
10237 field,
10238 onChange
10239 }) => {
10240 const { id } = field;
10241 const homeUrl = (0, import_data12.useSelect)((select6) => {
10242 return select6(import_core_data10.store).getEntityRecord("root", "__unstableBase")?.home;
10243 }, []);
10244 const onChangeControl = (0, import_element8.useCallback)(
10245 (newValue) => onChange({
10246 [id]: newValue
10247 }),
10248 [id, onChange]
10249 );
10250 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("fieldset", { className: "fields-controls__parent", children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { children: [
10251 (0, import_element8.createInterpolateElement)(
10252 (0, import_i18n18.sprintf)(
10253 /* translators: %1$s The home URL of the WordPress installation without the scheme. */
10254 (0, import_i18n18.__)(
10255 'Child pages inherit characteristics from their parent, such as URL structure. For instance, if "Pricing" is a child of "Services", its URL would be %1$s<wbr />/services<wbr />/pricing.'
10256 ),
10257 (0, import_url6.filterURLForDisplay)(homeUrl).replace(
10258 /([/.])/g,
10259 "<wbr />$1"
10260 )
10261 ),
10262 {
10263 wbr: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("wbr", {})
10264 }
10265 ),
10266 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("p", { children: (0, import_element8.createInterpolateElement)(
10267 (0, import_i18n18.__)(
10268 "They also show up as sub-items in the default navigation menu. <a>Learn more.</a>"
10269 ),
10270 {
10271 a: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
10272 import_components7.ExternalLink,
10273 {
10274 href: (0, import_i18n18.__)(
10275 "https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes"
10276 ),
10277 children: void 0
10278 }
10279 )
10280 }
10281 ) }),
10282 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
10283 PageAttributesParent,
10284 {
10285 data,
10286 onChangeControl
10287 }
10288 )
10289 ] }) });
10290 };
10291
10292 // packages/fields/build-module/fields/parent/parent-view.mjs
10293 var import_data13 = __toESM(require_data(), 1);
10294 var import_core_data11 = __toESM(require_core_data(), 1);
10295 var import_i18n19 = __toESM(require_i18n(), 1);
10296 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
10297 var ParentView = ({
10298 item
10299 }) => {
10300 const parent = (0, import_data13.useSelect)(
10301 (select6) => {
10302 const { getEntityRecord } = select6(import_core_data11.store);
10303 return item?.parent ? getEntityRecord("postType", item.type, item.parent) : null;
10304 },
10305 [item.parent, item.type]
10306 );
10307 if (parent) {
10308 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_jsx_runtime87.Fragment, { children: getTitleWithFallbackName(parent) });
10309 }
10310 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_jsx_runtime87.Fragment, { children: (0, import_i18n19.__)("None") });
10311 };
10312
10313 // packages/fields/build-module/fields/parent/index.mjs
10314 var parentField = {
10315 id: "parent",
10316 type: "text",
10317 label: (0, import_i18n20.__)("Parent"),
10318 Edit: ParentEdit,
10319 render: ParentView,
10320 enableSorting: true,
10321 filterBy: false
10322 };
10323 var parent_default = parentField;
10324
10325 // packages/fields/build-module/fields/password/index.mjs
10326 var import_i18n22 = __toESM(require_i18n(), 1);
10327
10328 // packages/fields/build-module/fields/password/edit.mjs
10329 var import_components8 = __toESM(require_components(), 1);
10330 var import_element9 = __toESM(require_element(), 1);
10331 var import_i18n21 = __toESM(require_i18n(), 1);
10332 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
10333 function PasswordEdit({
10334 data,
10335 onChange,
10336 field
10337 }) {
10338 const [showPassword, setShowPassword] = (0, import_element9.useState)(
10339 !!field.getValue({ item: data })
10340 );
10341 const handleTogglePassword = (value) => {
10342 setShowPassword(value);
10343 if (!value) {
10344 onChange({ password: "" });
10345 }
10346 };
10347 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
10348 import_components8.__experimentalVStack,
10349 {
10350 as: "fieldset",
10351 spacing: 4,
10352 className: "fields-controls__password",
10353 children: [
10354 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
10355 import_components8.CheckboxControl,
10356 {
10357 label: (0, import_i18n21.__)("Password protected"),
10358 help: (0, import_i18n21.__)("Only visible to those who know the password"),
10359 checked: showPassword,
10360 onChange: handleTogglePassword
10361 }
10362 ),
10363 showPassword && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "fields-controls__password-input", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
10364 import_components8.TextControl,
10365 {
10366 label: (0, import_i18n21.__)("Password"),
10367 onChange: (value) => onChange({
10368 password: value
10369 }),
10370 value: field.getValue({ item: data }) || "",
10371 placeholder: (0, import_i18n21.__)("Use a secure password"),
10372 type: "text",
10373 __next40pxDefaultSize: true,
10374 maxLength: 255
10375 }
10376 ) })
10377 ]
10378 }
10379 );
10380 }
10381 var edit_default = PasswordEdit;
10382
10383 // packages/fields/build-module/fields/password/index.mjs
10384 var passwordField = {
10385 id: "password",
10386 type: "text",
10387 label: (0, import_i18n22.__)("Password"),
10388 Edit: edit_default,
10389 enableSorting: false,
10390 enableHiding: false,
10391 isVisible: (item) => item.status !== "private",
10392 filterBy: false
10393 };
10394 var password_default = passwordField;
10395
10396 // packages/fields/build-module/fields/status/index.mjs
10397 var import_i18n24 = __toESM(require_i18n(), 1);
10398
10399 // packages/fields/build-module/fields/status/status-view.mjs
10400 var import_components9 = __toESM(require_components(), 1);
10401
10402 // packages/fields/build-module/fields/status/status-elements.mjs
10403 var import_i18n23 = __toESM(require_i18n(), 1);
10404 var STATUSES = [
10405 {
10406 value: "draft",
10407 label: (0, import_i18n23.__)("Draft"),
10408 icon: drafts_default,
10409 description: (0, import_i18n23.__)("Not ready to publish.")
10410 },
10411 {
10412 value: "future",
10413 label: (0, import_i18n23.__)("Scheduled"),
10414 icon: scheduled_default,
10415 description: (0, import_i18n23.__)("Publish automatically on a chosen date.")
10416 },
10417 {
10418 value: "pending",
10419 label: (0, import_i18n23.__)("Pending Review"),
10420 icon: pending_default,
10421 description: (0, import_i18n23.__)("Waiting for review before publishing.")
10422 },
10423 {
10424 value: "private",
10425 label: (0, import_i18n23.__)("Private"),
10426 icon: not_allowed_default,
10427 description: (0, import_i18n23.__)("Only visible to site admins and editors.")
10428 },
10429 {
10430 value: "publish",
10431 label: (0, import_i18n23.__)("Published"),
10432 icon: published_default,
10433 description: (0, import_i18n23.__)("Visible to everyone.")
10434 },
10435 { value: "trash", label: (0, import_i18n23.__)("Trash"), icon: trash_default }
10436 ];
10437 var status_elements_default = STATUSES;
10438
10439 // packages/fields/build-module/fields/status/status-view.mjs
10440 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
10441 function StatusView({ item }) {
10442 const status = status_elements_default.find(({ value }) => value === item.status);
10443 const label = status?.label || item.status;
10444 const icon = status?.icon;
10445 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(import_components9.__experimentalHStack, { alignment: "left", spacing: 0, children: [
10446 icon && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "edit-site-post-list__status-icon", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components9.Icon, { icon }) }),
10447 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { children: label })
10448 ] });
10449 }
10450 var status_view_default = StatusView;
10451
10452 // packages/fields/build-module/fields/status/index.mjs
10453 var OPERATOR_IS_ANY = "isAny";
10454 var statusField = {
10455 label: (0, import_i18n24.__)("Status"),
10456 id: "status",
10457 type: "text",
10458 elements: status_elements_default,
10459 render: status_view_default,
10460 Edit: "radio",
10461 enableSorting: false,
10462 filterBy: {
10463 operators: [OPERATOR_IS_ANY]
10464 }
10465 };
10466 var status_default = statusField;
10467
10468 // packages/fields/build-module/fields/comment-status/index.mjs
10469 var import_i18n25 = __toESM(require_i18n(), 1);
10470 var commentStatusField = {
10471 id: "comment_status",
10472 label: (0, import_i18n25.__)("Comments"),
10473 type: "text",
10474 Edit: "radio",
10475 enableSorting: false,
10476 enableHiding: false,
10477 filterBy: false,
10478 elements: [
10479 {
10480 value: "open",
10481 label: (0, import_i18n25.__)("Open"),
10482 description: (0, import_i18n25.__)("Visitors can add new comments and replies.")
10483 },
10484 {
10485 value: "closed",
10486 label: (0, import_i18n25.__)("Closed"),
10487 description: (0, import_i18n25.__)(
10488 "Visitors cannot add new comments or replies. Existing comments remain visible."
10489 )
10490 }
10491 ]
10492 };
10493 var comment_status_default = commentStatusField;
10494
10495 // packages/fields/build-module/fields/ping-status/index.mjs
10496 var import_i18n26 = __toESM(require_i18n(), 1);
10497 var import_components10 = __toESM(require_components(), 1);
10498 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
10499 function PingStatusEdit({
10500 data,
10501 onChange
10502 }) {
10503 const pingStatus = data?.ping_status ?? "open";
10504 const onTogglePingback = (checked) => {
10505 onChange({
10506 ...data,
10507 ping_status: checked ? "open" : "closed"
10508 });
10509 };
10510 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
10511 import_components10.CheckboxControl,
10512 {
10513 label: (0, import_i18n26.__)("Enable pingbacks & trackbacks"),
10514 checked: pingStatus === "open",
10515 onChange: onTogglePingback,
10516 help: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
10517 import_components10.ExternalLink,
10518 {
10519 href: (0, import_i18n26.__)(
10520 "https://wordpress.org/documentation/article/trackbacks-and-pingbacks/"
10521 ),
10522 children: (0, import_i18n26.__)("Learn more about pingbacks & trackbacks")
10523 }
10524 )
10525 }
10526 );
10527 }
10528 var pingStatusField = {
10529 id: "ping_status",
10530 label: (0, import_i18n26.__)("Trackbacks & Pingbacks"),
10531 type: "text",
10532 Edit: PingStatusEdit,
10533 enableSorting: false,
10534 enableHiding: false,
10535 filterBy: false,
10536 elements: [
10537 {
10538 value: "open",
10539 label: (0, import_i18n26.__)("Allow"),
10540 description: (0, import_i18n26.__)(
10541 "Allow link notifications from other blogs (pingbacks and trackbacks) on new articles."
10542 )
10543 },
10544 {
10545 value: "closed",
10546 label: (0, import_i18n26.__)("Don't allow"),
10547 description: (0, import_i18n26.__)(
10548 "Don't allow link notifications from other blogs (pingbacks and trackbacks) on new articles."
10549 )
10550 }
10551 ]
10552 };
10553 var ping_status_default = pingStatusField;
10554
10555 // packages/fields/build-module/fields/discussion/index.mjs
10556 var import_i18n27 = __toESM(require_i18n(), 1);
10557 var discussionField = {
10558 id: "discussion",
10559 label: (0, import_i18n27.__)("Discussion"),
10560 type: "text",
10561 render: ({ item }) => {
10562 const commentsOpen = item.comment_status === "open";
10563 const pingsOpen = item.ping_status === "open";
10564 if (commentsOpen && pingsOpen) {
10565 return (0, import_i18n27.__)("Open");
10566 }
10567 if (commentsOpen && !pingsOpen) {
10568 return (0, import_i18n27.__)("Comments only");
10569 }
10570 if (!commentsOpen && pingsOpen) {
10571 return (0, import_i18n27.__)("Pings only");
10572 }
10573 return (0, import_i18n27.__)("Closed");
10574 },
10575 filterBy: false
10576 };
10577 var discussion_default = discussionField;
10578
10579 // packages/fields/build-module/fields/date/index.mjs
10580 var import_i18n29 = __toESM(require_i18n(), 1);
10581
10582 // packages/fields/build-module/fields/date/date-view.mjs
10583 var import_i18n28 = __toESM(require_i18n(), 1);
10584 var import_element10 = __toESM(require_element(), 1);
10585 var import_date2 = __toESM(require_date(), 1);
10586 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
10587 var getFormattedDate = (dateToDisplay) => (0, import_date2.dateI18n)(
10588 (0, import_date2.getSettings)().formats.datetimeAbbreviated,
10589 (0, import_date2.getDate)(dateToDisplay)
10590 );
10591 var DateView = ({ item }) => {
10592 const isDraftOrPrivate = ["draft", "private"].includes(
10593 item.status ?? ""
10594 );
10595 if (isDraftOrPrivate) {
10596 return (0, import_element10.createInterpolateElement)(
10597 (0, import_i18n28.sprintf)(
10598 /* translators: %s: page creation or modification date. */
10599 (0, import_i18n28.__)("<span>Modified: <time>%s</time></span>"),
10600 getFormattedDate(item.date ?? null)
10601 ),
10602 {
10603 span: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", {}),
10604 time: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("time", {})
10605 }
10606 );
10607 }
10608 const isScheduled = item.status === "future";
10609 if (isScheduled) {
10610 return (0, import_element10.createInterpolateElement)(
10611 (0, import_i18n28.sprintf)(
10612 /* translators: %s: page creation date */
10613 (0, import_i18n28.__)("<span>Scheduled: <time>%s</time></span>"),
10614 getFormattedDate(item.date ?? null)
10615 ),
10616 {
10617 span: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", {}),
10618 time: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("time", {})
10619 }
10620 );
10621 }
10622 const isPublished = item.status === "publish";
10623 if (isPublished) {
10624 return (0, import_element10.createInterpolateElement)(
10625 (0, import_i18n28.sprintf)(
10626 /* translators: %s: page creation time */
10627 (0, import_i18n28.__)("<span>Published: <time>%s</time></span>"),
10628 getFormattedDate(item.date ?? null)
10629 ),
10630 {
10631 span: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", {}),
10632 time: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("time", {})
10633 }
10634 );
10635 }
10636 const dateToDisplay = (0, import_date2.getDate)(item.modified ?? null) > (0, import_date2.getDate)(item.date ?? null) ? item.modified : item.date;
10637 const isPending = item.status === "pending";
10638 if (isPending) {
10639 return (0, import_element10.createInterpolateElement)(
10640 (0, import_i18n28.sprintf)(
10641 /* translators: %s: page creation or modification date. */
10642 (0, import_i18n28.__)("<span>Modified: <time>%s</time></span>"),
10643 getFormattedDate(dateToDisplay ?? null)
10644 ),
10645 {
10646 span: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", {}),
10647 time: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("time", {})
10648 }
10649 );
10650 }
10651 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("time", { children: getFormattedDate(item.date ?? null) });
10652 };
10653 var date_view_default = DateView;
10654
10655 // packages/fields/build-module/fields/date/index.mjs
10656 var dateField = {
10657 id: "date",
10658 type: "datetime",
10659 label: (0, import_i18n29.__)("Date"),
10660 render: date_view_default,
10661 filterBy: {
10662 operators: ["before", "after"]
10663 }
10664 };
10665 var date_default = dateField;
10666
10667 // packages/fields/build-module/fields/author/index.mjs
10668 var import_i18n31 = __toESM(require_i18n(), 1);
10669 var import_data15 = __toESM(require_data(), 1);
10670 var import_core_data13 = __toESM(require_core_data(), 1);
10671
10672 // packages/fields/build-module/fields/author/author-view.mjs
10673 var import_i18n30 = __toESM(require_i18n(), 1);
10674 var import_element11 = __toESM(require_element(), 1);
10675 var import_components11 = __toESM(require_components(), 1);
10676 var import_data14 = __toESM(require_data(), 1);
10677 var import_core_data12 = __toESM(require_core_data(), 1);
10678 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
10679 function AuthorView({ item }) {
10680 const authorId = item?.author;
10681 const embeddedAuthorId = item?._embedded?.author?.[0]?.id;
10682 const shouldFetch = Boolean(
10683 authorId && embeddedAuthorId && authorId !== embeddedAuthorId
10684 );
10685 const author = (0, import_data14.useSelect)(
10686 (select6) => {
10687 if (!shouldFetch) {
10688 return null;
10689 }
10690 const { getEntityRecord } = select6(import_core_data12.store);
10691 return authorId ? getEntityRecord("root", "user", authorId) : null;
10692 },
10693 [authorId, shouldFetch]
10694 );
10695 const text = author?.name || item?._embedded?.author?.[0]?.name;
10696 const imageUrl = author?.avatar_urls?.[48] || item?._embedded?.author?.[0]?.avatar_urls?.[48];
10697 const [isImageLoaded, setIsImageLoaded] = (0, import_element11.useState)(false);
10698 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_components11.__experimentalHStack, { alignment: "left", spacing: 0, children: [
10699 !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
10700 "div",
10701 {
10702 className: clsx_default("page-templates-author-field__avatar", {
10703 "is-loaded": isImageLoaded
10704 }),
10705 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
10706 "img",
10707 {
10708 onLoad: () => setIsImageLoaded(true),
10709 alt: (0, import_i18n30.__)("Author avatar"),
10710 src: imageUrl
10711 }
10712 )
10713 }
10714 ),
10715 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className: "page-templates-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components11.Icon, { icon: comment_author_avatar_default }) }),
10716 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { className: "page-templates-author-field__name", children: text })
10717 ] });
10718 }
10719 var author_view_default = AuthorView;
10720
10721 // packages/fields/build-module/fields/author/index.mjs
10722 var authorField = {
10723 label: (0, import_i18n31.__)("Author"),
10724 id: "author",
10725 type: "integer",
10726 getElements: async () => {
10727 const authors = await (0, import_data15.resolveSelect)(import_core_data13.store).getEntityRecords(
10728 "root",
10729 "user",
10730 {
10731 per_page: -1,
10732 who: "authors",
10733 _fields: "id,name",
10734 context: "view"
10735 }
10736 ) ?? [];
10737 return authors.map(({ id, name: name2 }) => ({
10738 value: id,
10739 label: name2
10740 }));
10741 },
10742 setValue: ({ value }) => ({ author: Number(value) }),
10743 render: author_view_default,
10744 sort: (a3, b3, direction) => {
10745 const nameA = a3._embedded?.author?.[0]?.name || "";
10746 const nameB = b3._embedded?.author?.[0]?.name || "";
10747 return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
10748 },
10749 filterBy: {
10750 operators: ["isAny", "isNone"]
10751 }
10752 };
10753 var author_default = authorField;
10754
10755 // packages/fields/build-module/fields/notes/index.mjs
10756 var import_i18n32 = __toESM(require_i18n(), 1);
10757 var notesField = {
10758 id: "notesCount",
10759 label: (0, import_i18n32.__)("Notes"),
10760 type: "integer",
10761 enableSorting: false,
10762 filterBy: false
10763 };
10764 var notes_default = notesField;
10765
10766 // packages/fields/build-module/actions/view-post.mjs
10767 var import_i18n33 = __toESM(require_i18n(), 1);
10768 var viewPost = {
10769 id: "view-post",
10770 label: (0, import_i18n33._x)("View", "verb"),
10771 isPrimary: true,
10772 icon: external_default,
10773 isEligible(post2) {
10774 return post2.status !== "trash";
10775 },
10776 callback(posts, { onActionPerformed }) {
10777 const post2 = posts[0];
10778 window.open(post2?.link, "_blank");
10779 if (onActionPerformed) {
10780 onActionPerformed(posts);
10781 }
10782 }
10783 };
10784 var view_post_default = viewPost;
10785
10786 // packages/fields/build-module/actions/reorder-page.mjs
10787 var import_data16 = __toESM(require_data(), 1);
10788 var import_core_data14 = __toESM(require_core_data(), 1);
10789 var import_i18n34 = __toESM(require_i18n(), 1);
10790 var import_notices4 = __toESM(require_notices(), 1);
10791 var import_element12 = __toESM(require_element(), 1);
10792 var import_components12 = __toESM(require_components(), 1);
10793 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
10794 function isItemValid(item) {
10795 return typeof item.menu_order === "number" && Number.isInteger(item.menu_order);
10796 }
10797 function ReorderModal({
10798 items,
10799 closeModal: closeModal2,
10800 onActionPerformed
10801 }) {
10802 const [item, setItem] = (0, import_element12.useState)(items[0]);
10803 const { editEntityRecord, saveEditedEntityRecord } = (0, import_data16.useDispatch)(import_core_data14.store);
10804 const { createSuccessNotice, createErrorNotice } = (0, import_data16.useDispatch)(import_notices4.store);
10805 const isValid2 = isItemValid(item);
10806 async function onOrder(event) {
10807 event.preventDefault();
10808 if (!isValid2) {
10809 return;
10810 }
10811 try {
10812 await editEntityRecord("postType", item.type, item.id, {
10813 menu_order: item.menu_order
10814 });
10815 closeModal2?.();
10816 await saveEditedEntityRecord("postType", item.type, item.id, {
10817 throwOnError: true
10818 });
10819 createSuccessNotice((0, import_i18n34.__)("Order updated."), {
10820 type: "snackbar"
10821 });
10822 onActionPerformed?.(items);
10823 } catch (error) {
10824 const typedError = error;
10825 const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n34.__)("An error occurred while updating the order");
10826 createErrorNotice(errorMessage, {
10827 type: "snackbar"
10828 });
10829 }
10830 }
10831 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("form", { onSubmit: onOrder, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_components12.__experimentalVStack, { spacing: "5", children: [
10832 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { children: (0, import_i18n34.__)(
10833 "Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported."
10834 ) }),
10835 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
10836 import_components12.__experimentalInputControl,
10837 {
10838 __next40pxDefaultSize: true,
10839 label: (0, import_i18n34.__)("Order"),
10840 type: "number",
10841 value: typeof item.menu_order === "number" && Number.isInteger(item.menu_order) ? String(item.menu_order) : "",
10842 onChange: (value) => {
10843 const parsed = parseInt(value, 10);
10844 setItem({
10845 ...item,
10846 menu_order: isNaN(parsed) ? void 0 : parsed
10847 });
10848 }
10849 }
10850 ),
10851 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_components12.__experimentalHStack, { justify: "right", children: [
10852 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
10853 import_components12.Button,
10854 {
10855 __next40pxDefaultSize: true,
10856 variant: "tertiary",
10857 onClick: () => {
10858 closeModal2?.();
10859 },
10860 children: (0, import_i18n34.__)("Cancel")
10861 }
10862 ),
10863 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
10864 import_components12.Button,
10865 {
10866 __next40pxDefaultSize: true,
10867 variant: "primary",
10868 type: "submit",
10869 accessibleWhenDisabled: true,
10870 disabled: !isValid2,
10871 children: (0, import_i18n34.__)("Save")
10872 }
10873 )
10874 ] })
10875 ] }) });
10876 }
10877 var reorderPage = {
10878 id: "order-pages",
10879 label: (0, import_i18n34.__)("Order"),
10880 isEligible({ status }) {
10881 return status !== "trash";
10882 },
10883 modalFocusOnMount: "firstContentElement",
10884 RenderModal: ReorderModal
10885 };
10886 var reorder_page_default = reorderPage;
10887
10888 // packages/fields/build-module/actions/duplicate-post.mjs
10889 var import_data17 = __toESM(require_data(), 1);
10890 var import_core_data15 = __toESM(require_core_data(), 1);
10891 var import_i18n35 = __toESM(require_i18n(), 1);
10892 var import_notices5 = __toESM(require_notices(), 1);
10893 var import_element13 = __toESM(require_element(), 1);
10894 var import_components13 = __toESM(require_components(), 1);
10895 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
10896 var duplicatePost = {
10897 id: "duplicate-post",
10898 label: (0, import_i18n35._x)("Duplicate", "action label"),
10899 isEligible({ status }) {
10900 return status !== "trash";
10901 },
10902 modalFocusOnMount: "firstContentElement",
10903 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
10904 const [item, setItem] = (0, import_element13.useState)({
10905 ...items[0],
10906 title: (0, import_i18n35.sprintf)(
10907 /* translators: %s: Existing post title */
10908 (0, import_i18n35._x)("%s (Copy)", "post"),
10909 getItemTitle(items[0])
10910 )
10911 });
10912 const [isCreatingPage, setIsCreatingPage] = (0, import_element13.useState)(false);
10913 const { saveEntityRecord } = (0, import_data17.useDispatch)(import_core_data15.store);
10914 const { createSuccessNotice, createErrorNotice } = (0, import_data17.useDispatch)(import_notices5.store);
10915 async function createPage(event) {
10916 event.preventDefault();
10917 if (isCreatingPage) {
10918 return;
10919 }
10920 const isTemplate2 = item.type === "wp_template";
10921 const newItemObject = {
10922 status: isTemplate2 ? "publish" : "draft",
10923 title: item.title,
10924 slug: isTemplate2 ? item.slug : item.title || (0, import_i18n35.__)("No title"),
10925 comment_status: item.comment_status,
10926 content: typeof item.content === "string" ? item.content : item.content.raw,
10927 excerpt: typeof item.excerpt === "string" ? item.excerpt : item.excerpt?.raw,
10928 meta: item.meta,
10929 parent: item.parent,
10930 password: item.password,
10931 template: item.template,
10932 format: item.format,
10933 featured_media: item.featured_media,
10934 menu_order: item.menu_order,
10935 ping_status: item.ping_status
10936 };
10937 const assignablePropertiesPrefix = "wp:action-assign-";
10938 const assignableProperties = Object.keys(item?._links || {}).filter(
10939 (property) => property.startsWith(assignablePropertiesPrefix)
10940 ).map(
10941 (property) => property.slice(assignablePropertiesPrefix.length)
10942 );
10943 assignableProperties.forEach((property) => {
10944 if (item.hasOwnProperty(property)) {
10945 newItemObject[property] = item[property];
10946 }
10947 });
10948 setIsCreatingPage(true);
10949 try {
10950 const newItem = await saveEntityRecord(
10951 "postType",
10952 item.type,
10953 newItemObject,
10954 { throwOnError: true }
10955 );
10956 createSuccessNotice(
10957 (0, import_i18n35.sprintf)(
10958 // translators: %s: Title of the created post, e.g: "Hello world".
10959 (0, import_i18n35.__)('"%s" successfully created.'),
10960 getItemTitle(newItem)
10961 ),
10962 {
10963 id: "duplicate-post-action",
10964 type: "snackbar"
10965 }
10966 );
10967 if (onActionPerformed) {
10968 onActionPerformed([newItem]);
10969 }
10970 } catch (error) {
10971 const typedError = error;
10972 const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n35.__)("An error occurred while duplicating the page.");
10973 createErrorNotice(errorMessage, {
10974 type: "snackbar"
10975 });
10976 } finally {
10977 setIsCreatingPage(false);
10978 closeModal2?.();
10979 }
10980 }
10981 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("form", { onSubmit: createPage, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(import_components13.__experimentalVStack, { spacing: 3, children: [
10982 typeof item.id === "string" && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { children: (0, import_i18n35.__)(
10983 "You are about to duplicate a bundled template. Changes will not be live until you activate the new template."
10984 ) }),
10985 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
10986 import_components13.__experimentalInputControl,
10987 {
10988 __next40pxDefaultSize: true,
10989 label: (0, import_i18n35.__)("Title"),
10990 placeholder: (0, import_i18n35.__)("No title"),
10991 value: getItemTitle(item),
10992 onChange: (value) => setItem((prev) => ({
10993 ...prev,
10994 title: value || (0, import_i18n35.__)("No title")
10995 }))
10996 }
10997 ),
10998 /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(import_components13.__experimentalHStack, { spacing: 2, justify: "end", children: [
10999 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
11000 import_components13.Button,
11001 {
11002 variant: "tertiary",
11003 onClick: closeModal2,
11004 __next40pxDefaultSize: true,
11005 children: (0, import_i18n35.__)("Cancel")
11006 }
11007 ),
11008 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
11009 import_components13.Button,
11010 {
11011 variant: "primary",
11012 type: "submit",
11013 isBusy: isCreatingPage,
11014 "aria-disabled": isCreatingPage,
11015 __next40pxDefaultSize: true,
11016 children: (0, import_i18n35._x)("Duplicate", "action label")
11017 }
11018 )
11019 ] })
11020 ] }) });
11021 }
11022 };
11023 var duplicate_post_default = duplicatePost;
11024
11025 // packages/fields/build-module/actions/rename-post.mjs
11026 var import_data18 = __toESM(require_data(), 1);
11027 var import_core_data16 = __toESM(require_core_data(), 1);
11028 var import_i18n36 = __toESM(require_i18n(), 1);
11029 var import_element14 = __toESM(require_element(), 1);
11030 var import_patterns2 = __toESM(require_patterns(), 1);
11031 var import_components14 = __toESM(require_components(), 1);
11032 var import_notices6 = __toESM(require_notices(), 1);
11033 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
11034 var { PATTERN_TYPES: PATTERN_TYPES2 } = unlock2(import_patterns2.privateApis);
11035 var renamePost = {
11036 id: "rename-post",
11037 label: (0, import_i18n36.__)("Rename"),
11038 modalFocusOnMount: "firstContentElement",
11039 isEligible(post2) {
11040 if (post2.status === "trash") {
11041 return false;
11042 }
11043 if (post2.type === "wp_template" && typeof post2.id === "string" && window?.__experimentalTemplateActivate) {
11044 return false;
11045 }
11046 const specialChecks = ["wp_template", "wp_template_part"];
11047 if (!window?.__experimentalTemplateActivate) {
11048 specialChecks.push("wp_template");
11049 }
11050 if (!specialChecks.includes(post2.type)) {
11051 return post2.permissions?.update;
11052 }
11053 if (isTemplate(post2) && !window?.__experimentalTemplateActivate) {
11054 return isTemplateRemovable(post2) && post2.is_custom && post2.permissions?.update;
11055 }
11056 if (isTemplatePart(post2)) {
11057 return post2.source === "custom" && !post2?.has_theme_file && post2.permissions?.update;
11058 }
11059 return post2.type === PATTERN_TYPES2.user && post2.permissions?.update;
11060 },
11061 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
11062 const [item] = items;
11063 const [title, setTitle] = (0, import_element14.useState)(() => getItemTitle(item, ""));
11064 const { editEntityRecord, saveEditedEntityRecord } = (0, import_data18.useDispatch)(import_core_data16.store);
11065 const { createSuccessNotice, createErrorNotice } = (0, import_data18.useDispatch)(import_notices6.store);
11066 async function onRename(event) {
11067 event.preventDefault();
11068 try {
11069 await editEntityRecord("postType", item.type, item.id, {
11070 title
11071 });
11072 setTitle("");
11073 closeModal2?.();
11074 await saveEditedEntityRecord("postType", item.type, item.id, {
11075 throwOnError: true
11076 });
11077 createSuccessNotice((0, import_i18n36.__)("Name updated"), {
11078 type: "snackbar"
11079 });
11080 onActionPerformed?.(items);
11081 } catch (error) {
11082 const typedError = error;
11083 const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : (0, import_i18n36.__)("An error occurred while updating the name");
11084 createErrorNotice(errorMessage, { type: "snackbar" });
11085 }
11086 }
11087 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("form", { onSubmit: onRename, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_components14.__experimentalVStack, { spacing: "5", children: [
11088 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
11089 import_components14.TextControl,
11090 {
11091 __next40pxDefaultSize: true,
11092 label: (0, import_i18n36.__)("Name"),
11093 value: title,
11094 onChange: setTitle,
11095 required: true
11096 }
11097 ),
11098 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_components14.__experimentalHStack, { justify: "right", children: [
11099 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
11100 import_components14.Button,
11101 {
11102 __next40pxDefaultSize: true,
11103 variant: "tertiary",
11104 onClick: () => {
11105 closeModal2?.();
11106 },
11107 children: (0, import_i18n36.__)("Cancel")
11108 }
11109 ),
11110 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
11111 import_components14.Button,
11112 {
11113 __next40pxDefaultSize: true,
11114 variant: "primary",
11115 type: "submit",
11116 children: (0, import_i18n36.__)("Save")
11117 }
11118 )
11119 ] })
11120 ] }) });
11121 }
11122 };
11123 var rename_post_default = renamePost;
11124
11125 // packages/fields/build-module/actions/reset-post.mjs
11126 var import_data19 = __toESM(require_data(), 1);
11127 var import_core_data17 = __toESM(require_core_data(), 1);
11128 var import_i18n37 = __toESM(require_i18n(), 1);
11129 var import_notices7 = __toESM(require_notices(), 1);
11130 var import_element15 = __toESM(require_element(), 1);
11131 var import_blocks3 = __toESM(require_blocks(), 1);
11132 var import_components15 = __toESM(require_components(), 1);
11133 var import_url7 = __toESM(require_url(), 1);
11134 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
11135 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
11136 var isTemplateRevertable2 = (templateOrTemplatePart) => {
11137 if (!templateOrTemplatePart) {
11138 return false;
11139 }
11140 return templateOrTemplatePart.source === "custom" && (Boolean(templateOrTemplatePart?.plugin) || templateOrTemplatePart?.has_theme_file);
11141 };
11142 var revertTemplate = async (template2, { allowUndo = true } = {}) => {
11143 const noticeId = "edit-site-template-reverted";
11144 (0, import_data19.dispatch)(import_notices7.store).removeNotice(noticeId);
11145 if (!isTemplateRevertable2(template2)) {
11146 (0, import_data19.dispatch)(import_notices7.store).createErrorNotice(
11147 (0, import_i18n37.__)("This template is not revertable."),
11148 {
11149 type: "snackbar"
11150 }
11151 );
11152 return;
11153 }
11154 try {
11155 const templateEntityConfig = (0, import_data19.select)(import_core_data17.store).getEntityConfig(
11156 "postType",
11157 template2.type
11158 );
11159 if (!templateEntityConfig) {
11160 (0, import_data19.dispatch)(import_notices7.store).createErrorNotice(
11161 (0, import_i18n37.__)(
11162 "The editor has encountered an unexpected error. Please reload."
11163 ),
11164 { type: "snackbar" }
11165 );
11166 return;
11167 }
11168 const fileTemplatePath = (0, import_url7.addQueryArgs)(
11169 `${templateEntityConfig.baseURL}/${template2.id}`,
11170 { context: "edit", source: template2.origin }
11171 );
11172 const fileTemplate = await (0, import_api_fetch2.default)({
11173 path: fileTemplatePath
11174 });
11175 if (!fileTemplate) {
11176 (0, import_data19.dispatch)(import_notices7.store).createErrorNotice(
11177 (0, import_i18n37.__)(
11178 "The editor has encountered an unexpected error. Please reload."
11179 ),
11180 { type: "snackbar" }
11181 );
11182 return;
11183 }
11184 const serializeBlocks = ({ blocks: blocksForSerialization = [] }) => (0, import_blocks3.__unstableSerializeAndClean)(blocksForSerialization);
11185 const edited = (0, import_data19.select)(import_core_data17.store).getEditedEntityRecord(
11186 "postType",
11187 template2.type,
11188 template2.id
11189 );
11190 (0, import_data19.dispatch)(import_core_data17.store).editEntityRecord(
11191 "postType",
11192 template2.type,
11193 template2.id,
11194 {
11195 content: serializeBlocks,
11196 // Required to make the `undo` behave correctly.
11197 blocks: edited.blocks,
11198 // Required to revert the blocks in the editor.
11199 source: "custom"
11200 // required to avoid turning the editor into a dirty state
11201 },
11202 {
11203 undoIgnore: true
11204 // Required to merge this edit with the last undo level.
11205 }
11206 );
11207 const blocks = (0, import_blocks3.parse)(fileTemplate?.content?.raw);
11208 (0, import_data19.dispatch)(import_core_data17.store).editEntityRecord(
11209 "postType",
11210 template2.type,
11211 fileTemplate.id,
11212 {
11213 content: serializeBlocks,
11214 blocks,
11215 source: "theme"
11216 }
11217 );
11218 if (allowUndo) {
11219 const undoRevert = () => {
11220 (0, import_data19.dispatch)(import_core_data17.store).editEntityRecord(
11221 "postType",
11222 template2.type,
11223 edited.id,
11224 {
11225 content: serializeBlocks,
11226 blocks: edited.blocks,
11227 source: "custom"
11228 }
11229 );
11230 };
11231 (0, import_data19.dispatch)(import_notices7.store).createSuccessNotice(
11232 (0, import_i18n37.__)("Template reset."),
11233 {
11234 type: "snackbar",
11235 id: noticeId,
11236 actions: [
11237 {
11238 label: (0, import_i18n37.__)("Undo"),
11239 onClick: undoRevert
11240 }
11241 ]
11242 }
11243 );
11244 }
11245 } catch (error) {
11246 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n37.__)("Template revert failed. Please reload.");
11247 (0, import_data19.dispatch)(import_notices7.store).createErrorNotice(errorMessage, {
11248 type: "snackbar"
11249 });
11250 }
11251 };
11252 var resetPostAction = {
11253 id: "reset-post",
11254 label: (0, import_i18n37.__)("Reset"),
11255 isEligible: (item) => {
11256 if (window?.__experimentalTemplateActivate) {
11257 return item.type === "wp_template_part" && item?.source === "custom" && item?.has_theme_file;
11258 }
11259 return isTemplateOrTemplatePart(item) && item?.source === "custom" && (Boolean(item.type === "wp_template" && item?.plugin) || item?.has_theme_file);
11260 },
11261 icon: backup_default,
11262 supportsBulk: true,
11263 hideModalHeader: true,
11264 modalFocusOnMount: "firstContentElement",
11265 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
11266 const [isBusy, setIsBusy] = (0, import_element15.useState)(false);
11267 const { saveEditedEntityRecord } = (0, import_data19.useDispatch)(import_core_data17.store);
11268 const { createSuccessNotice, createErrorNotice } = (0, import_data19.useDispatch)(import_notices7.store);
11269 const onConfirm = async () => {
11270 try {
11271 for (const template2 of items) {
11272 await revertTemplate(template2, {
11273 allowUndo: false
11274 });
11275 await saveEditedEntityRecord(
11276 "postType",
11277 template2.type,
11278 template2.id
11279 );
11280 }
11281 createSuccessNotice(
11282 items.length > 1 ? (0, import_i18n37.sprintf)(
11283 /* translators: %d: The number of items. */
11284 (0, import_i18n37.__)("%d items reset."),
11285 items.length
11286 ) : (0, import_i18n37.sprintf)(
11287 /* translators: %s: The template/part's name. */
11288 (0, import_i18n37.__)('"%s" reset.'),
11289 getItemTitle(items[0])
11290 ),
11291 {
11292 type: "snackbar",
11293 id: "revert-template-action"
11294 }
11295 );
11296 } catch (error) {
11297 let fallbackErrorMessage;
11298 if (items[0].type === "wp_template") {
11299 fallbackErrorMessage = items.length === 1 ? (0, import_i18n37.__)(
11300 "An error occurred while reverting the template."
11301 ) : (0, import_i18n37.__)(
11302 "An error occurred while reverting the templates."
11303 );
11304 } else {
11305 fallbackErrorMessage = items.length === 1 ? (0, import_i18n37.__)(
11306 "An error occurred while reverting the template part."
11307 ) : (0, import_i18n37.__)(
11308 "An error occurred while reverting the template parts."
11309 );
11310 }
11311 const typedError = error;
11312 const errorMessage = typedError.message && typedError.code !== "unknown_error" ? typedError.message : fallbackErrorMessage;
11313 createErrorNotice(errorMessage, { type: "snackbar" });
11314 }
11315 };
11316 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_components15.__experimentalVStack, { spacing: "5", children: [
11317 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components15.__experimentalText, { children: (0, import_i18n37.__)("Reset to default and clear all customizations?") }),
11318 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_components15.__experimentalHStack, { justify: "right", children: [
11319 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
11320 import_components15.Button,
11321 {
11322 __next40pxDefaultSize: true,
11323 variant: "tertiary",
11324 onClick: closeModal2,
11325 disabled: isBusy,
11326 accessibleWhenDisabled: true,
11327 children: (0, import_i18n37.__)("Cancel")
11328 }
11329 ),
11330 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
11331 import_components15.Button,
11332 {
11333 __next40pxDefaultSize: true,
11334 variant: "primary",
11335 onClick: async () => {
11336 setIsBusy(true);
11337 await onConfirm();
11338 onActionPerformed?.(items);
11339 setIsBusy(false);
11340 closeModal2?.();
11341 },
11342 isBusy,
11343 disabled: isBusy,
11344 accessibleWhenDisabled: true,
11345 children: (0, import_i18n37.__)("Reset")
11346 }
11347 )
11348 ] })
11349 ] });
11350 }
11351 };
11352 var reset_post_default = resetPostAction;
11353
11354 // packages/fields/build-module/actions/duplicate-pattern.mjs
11355 var import_i18n38 = __toESM(require_i18n(), 1);
11356 var import_patterns3 = __toESM(require_patterns(), 1);
11357 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
11358 var { CreatePatternModalContents, useDuplicatePatternProps } = unlock2(import_patterns3.privateApis);
11359 var duplicatePattern = {
11360 id: "duplicate-pattern",
11361 label: (0, import_i18n38._x)("Duplicate", "action label"),
11362 isEligible: (item) => item.type !== "wp_template_part",
11363 modalHeader: (0, import_i18n38._x)("Duplicate pattern", "action label"),
11364 modalFocusOnMount: "firstContentElement",
11365 RenderModal: ({ items, closeModal: closeModal2 }) => {
11366 const [item] = items;
11367 const duplicatedProps = useDuplicatePatternProps({
11368 pattern: item,
11369 onSuccess: () => closeModal2?.()
11370 });
11371 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
11372 CreatePatternModalContents,
11373 {
11374 onClose: closeModal2,
11375 confirmLabel: (0, import_i18n38._x)("Duplicate", "action label"),
11376 ...duplicatedProps
11377 }
11378 );
11379 }
11380 };
11381 var duplicate_pattern_default = duplicatePattern;
11382
11383 // node_modules/tslib/tslib.es6.mjs
11384 var __assign = function() {
11385 __assign = Object.assign || function __assign2(t4) {
11386 for (var s3, i3 = 1, n3 = arguments.length; i3 < n3; i3++) {
11387 s3 = arguments[i3];
11388 for (var p4 in s3) if (Object.prototype.hasOwnProperty.call(s3, p4)) t4[p4] = s3[p4];
11389 }
11390 return t4;
11391 };
11392 return __assign.apply(this, arguments);
11393 };
11394
11395 // node_modules/lower-case/dist.es2015/index.js
11396 function lowerCase(str) {
11397 return str.toLowerCase();
11398 }
11399
11400 // node_modules/no-case/dist.es2015/index.js
11401 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
11402 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
11403 function noCase(input, options) {
11404 if (options === void 0) {
11405 options = {};
11406 }
11407 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
11408 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
11409 var start2 = 0;
11410 var end = result.length;
11411 while (result.charAt(start2) === "\0")
11412 start2++;
11413 while (result.charAt(end - 1) === "\0")
11414 end--;
11415 return result.slice(start2, end).split("\0").map(transform).join(delimiter);
11416 }
11417 function replace(input, re, value) {
11418 if (re instanceof RegExp)
11419 return input.replace(re, value);
11420 return re.reduce(function(input2, re2) {
11421 return input2.replace(re2, value);
11422 }, input);
11423 }
11424
11425 // node_modules/dot-case/dist.es2015/index.js
11426 function dotCase(input, options) {
11427 if (options === void 0) {
11428 options = {};
11429 }
11430 return noCase(input, __assign({ delimiter: "." }, options));
11431 }
11432
11433 // node_modules/param-case/dist.es2015/index.js
11434 function paramCase(input, options) {
11435 if (options === void 0) {
11436 options = {};
11437 }
11438 return dotCase(input, __assign({ delimiter: "-" }, options));
11439 }
11440
11441 // node_modules/client-zip/index.js
11442 "stream" in Blob.prototype || Object.defineProperty(Blob.prototype, "stream", { value() {
11443 return new Response(this).body;
11444 } }), "setBigUint64" in DataView.prototype || Object.defineProperty(DataView.prototype, "setBigUint64", { value(e3, n3, t4) {
11445 const i3 = Number(0xffffffffn & n3), r4 = Number(n3 >> 32n);
11446 this.setUint32(e3 + (t4 ? 0 : 4), i3, t4), this.setUint32(e3 + (t4 ? 4 : 0), r4, t4);
11447 } });
11448 var e = (e3) => new DataView(new ArrayBuffer(e3));
11449 var n = (e3) => new Uint8Array(e3.buffer || e3);
11450 var t = (e3) => new TextEncoder().encode(String(e3));
11451 var i = (e3) => Math.min(4294967295, Number(e3));
11452 var r2 = (e3) => Math.min(65535, Number(e3));
11453 function f(e3, i3) {
11454 if (void 0 === i3 || i3 instanceof Date || (i3 = new Date(i3)), e3 instanceof File) return { isFile: 1, t: i3 || new Date(e3.lastModified), i: e3.stream() };
11455 if (e3 instanceof Response) return { isFile: 1, t: i3 || new Date(e3.headers.get("Last-Modified") || Date.now()), i: e3.body };
11456 if (void 0 === i3) i3 = /* @__PURE__ */ new Date();
11457 else if (isNaN(i3)) throw new Error("Invalid modification date.");
11458 if (void 0 === e3) return { isFile: 0, t: i3 };
11459 if ("string" == typeof e3) return { isFile: 1, t: i3, i: t(e3) };
11460 if (e3 instanceof Blob) return { isFile: 1, t: i3, i: e3.stream() };
11461 if (e3 instanceof Uint8Array || e3 instanceof ReadableStream) return { isFile: 1, t: i3, i: e3 };
11462 if (e3 instanceof ArrayBuffer || ArrayBuffer.isView(e3)) return { isFile: 1, t: i3, i: n(e3) };
11463 if (Symbol.asyncIterator in e3) return { isFile: 1, t: i3, i: o(e3[Symbol.asyncIterator]()) };
11464 throw new TypeError("Unsupported input format.");
11465 }
11466 function o(e3, n3 = e3) {
11467 return new ReadableStream({ async pull(n4) {
11468 let t4 = 0;
11469 for (; n4.desiredSize > t4; ) {
11470 const i3 = await e3.next();
11471 if (!i3.value) {
11472 n4.close();
11473 break;
11474 }
11475 {
11476 const e4 = a(i3.value);
11477 n4.enqueue(e4), t4 += e4.byteLength;
11478 }
11479 }
11480 }, cancel(e4) {
11481 n3.throw?.(e4);
11482 } });
11483 }
11484 function a(e3) {
11485 return "string" == typeof e3 ? t(e3) : e3 instanceof Uint8Array ? e3 : n(e3);
11486 }
11487 function s(e3, i3, r4) {
11488 let [f3, o4] = (function(e4) {
11489 return e4 ? e4 instanceof Uint8Array ? [e4, 1] : ArrayBuffer.isView(e4) || e4 instanceof ArrayBuffer ? [n(e4), 1] : [t(e4), 0] : [void 0, 0];
11490 })(i3);
11491 if (e3 instanceof File) return { o: d(f3 || t(e3.name)), u: BigInt(e3.size), l: o4 };
11492 if (e3 instanceof Response) {
11493 const n3 = e3.headers.get("content-disposition"), i4 = n3 && n3.match(/;\s*filename\*?=["']?(.*?)["']?$/i), a3 = i4 && i4[1] || e3.url && new URL(e3.url).pathname.split("/").findLast(Boolean), s3 = a3 && decodeURIComponent(a3), u3 = r4 || +e3.headers.get("content-length");
11494 return { o: d(f3 || t(s3)), u: BigInt(u3), l: o4 };
11495 }
11496 return f3 = d(f3, void 0 !== e3 || void 0 !== r4), "string" == typeof e3 ? { o: f3, u: BigInt(t(e3).length), l: o4 } : e3 instanceof Blob ? { o: f3, u: BigInt(e3.size), l: o4 } : e3 instanceof ArrayBuffer || ArrayBuffer.isView(e3) ? { o: f3, u: BigInt(e3.byteLength), l: o4 } : { o: f3, u: u(e3, r4), l: o4 };
11497 }
11498 function u(e3, n3) {
11499 return n3 > -1 ? BigInt(n3) : e3 ? void 0 : 0n;
11500 }
11501 function d(e3, n3 = 1) {
11502 if (!e3 || e3.every(((c6) => 47 === c6))) throw new Error("The file must have a name.");
11503 if (n3) for (; 47 === e3[e3.length - 1]; ) e3 = e3.subarray(0, -1);
11504 else 47 !== e3[e3.length - 1] && (e3 = new Uint8Array([...e3, 47]));
11505 return e3;
11506 }
11507 var l = new Uint32Array(256);
11508 for (let e3 = 0; e3 < 256; ++e3) {
11509 let n3 = e3;
11510 for (let e4 = 0; e4 < 8; ++e4) n3 = n3 >>> 1 ^ (1 & n3 && 3988292384);
11511 l[e3] = n3;
11512 }
11513 function y(e3, n3 = 0) {
11514 n3 ^= -1;
11515 for (var t4 = 0, i3 = e3.length; t4 < i3; t4++) n3 = n3 >>> 8 ^ l[255 & n3 ^ e3[t4]];
11516 return (-1 ^ n3) >>> 0;
11517 }
11518 function w(e3, n3, t4 = 0) {
11519 const i3 = e3.getSeconds() >> 1 | e3.getMinutes() << 5 | e3.getHours() << 11, r4 = e3.getDate() | e3.getMonth() + 1 << 5 | e3.getFullYear() - 1980 << 9;
11520 n3.setUint16(t4, i3, 1), n3.setUint16(t4 + 2, r4, 1);
11521 }
11522 function B({ o: e3, l: n3 }, t4) {
11523 return 8 * (!n3 || (t4 ?? (function(e4) {
11524 try {
11525 b.decode(e4);
11526 } catch {
11527 return 0;
11528 }
11529 return 1;
11530 })(e3)));
11531 }
11532 var b = new TextDecoder("utf8", { fatal: 1 });
11533 function p2(t4, i3 = 0) {
11534 const r4 = e(30);
11535 return r4.setUint32(0, 1347093252), r4.setUint32(4, 754976768 | i3), w(t4.t, r4, 10), r4.setUint16(26, t4.o.length, 1), n(r4);
11536 }
11537 async function* g(e3) {
11538 let { i: n3 } = e3;
11539 if ("then" in n3 && (n3 = await n3), n3 instanceof Uint8Array) yield n3, e3.m = y(n3, 0), e3.u = BigInt(n3.length);
11540 else {
11541 e3.u = 0n;
11542 const t4 = n3.getReader();
11543 for (; ; ) {
11544 const { value: n4, done: i3 } = await t4.read();
11545 if (i3) break;
11546 e3.m = y(n4, e3.m), e3.u += BigInt(n4.length), yield n4;
11547 }
11548 }
11549 }
11550 function I(t4, r4) {
11551 const f3 = e(16 + (r4 ? 8 : 0));
11552 return f3.setUint32(0, 1347094280), f3.setUint32(4, t4.isFile ? t4.m : 0, 1), r4 ? (f3.setBigUint64(8, t4.u, 1), f3.setBigUint64(16, t4.u, 1)) : (f3.setUint32(8, i(t4.u), 1), f3.setUint32(12, i(t4.u), 1)), n(f3);
11553 }
11554 function v(t4, r4, f3 = 0, o4 = 0) {
11555 const a3 = e(46);
11556 return a3.setUint32(0, 1347092738), a3.setUint32(4, 755182848), a3.setUint16(8, 2048 | f3), w(t4.t, a3, 12), a3.setUint32(16, t4.isFile ? t4.m : 0, 1), a3.setUint32(20, i(t4.u), 1), a3.setUint32(24, i(t4.u), 1), a3.setUint16(28, t4.o.length, 1), a3.setUint16(30, o4, 1), a3.setUint16(40, t4.isFile ? 33204 : 16893, 1), a3.setUint32(42, i(r4), 1), n(a3);
11557 }
11558 function h(t4, i3, r4) {
11559 const f3 = e(r4);
11560 return f3.setUint16(0, 1, 1), f3.setUint16(2, r4 - 4, 1), 16 & r4 && (f3.setBigUint64(4, t4.u, 1), f3.setBigUint64(12, t4.u, 1)), f3.setBigUint64(r4 - 8, i3, 1), n(f3);
11561 }
11562 function D(e3) {
11563 return e3 instanceof File || e3 instanceof Response ? [[e3], [e3]] : [[e3.input, e3.name, e3.size], [e3.input, e3.lastModified]];
11564 }
11565 var S = (e3) => (function(e4) {
11566 let n3 = BigInt(22), t4 = 0n, i3 = 0;
11567 for (const r4 of e4) {
11568 if (!r4.o) throw new Error("Every file must have a non-empty name.");
11569 if (void 0 === r4.u) throw new Error(`Missing size for file "${new TextDecoder().decode(r4.o)}".`);
11570 const e5 = r4.u >= 0xffffffffn, f3 = t4 >= 0xffffffffn;
11571 t4 += BigInt(46 + r4.o.length + (e5 && 8)) + r4.u, n3 += BigInt(r4.o.length + 46 + (12 * f3 | 28 * e5)), i3 || (i3 = e5);
11572 }
11573 return (i3 || t4 >= 0xffffffffn) && (n3 += BigInt(76)), n3 + t4;
11574 })((function* (e4) {
11575 for (const n3 of e4) yield s(...D(n3)[0]);
11576 })(e3));
11577 function A(e3, n3 = {}) {
11578 const t4 = { "Content-Type": "application/zip", "Content-Disposition": "attachment" };
11579 return ("bigint" == typeof n3.length || Number.isInteger(n3.length)) && n3.length > 0 && (t4["Content-Length"] = String(n3.length)), n3.metadata && (t4["Content-Length"] = String(S(n3.metadata))), new Response(N(e3, n3), { headers: t4 });
11580 }
11581 function N(t4, a3 = {}) {
11582 const u3 = (function(e3) {
11583 const n3 = e3[Symbol.iterator in e3 ? Symbol.iterator : Symbol.asyncIterator]();
11584 return { async next() {
11585 const e4 = await n3.next();
11586 if (e4.done) return e4;
11587 const [t5, i3] = D(e4.value);
11588 return { done: 0, value: Object.assign(f(...i3), s(...t5)) };
11589 }, throw: n3.throw?.bind(n3), [Symbol.asyncIterator]() {
11590 return this;
11591 } };
11592 })(t4);
11593 return o((async function* (t5, f3) {
11594 const o4 = [];
11595 let a4 = 0n, s3 = 0n, u4 = 0;
11596 for await (const e3 of t5) {
11597 const n3 = B(e3, f3.buffersAreUTF8);
11598 yield p2(e3, n3), yield new Uint8Array(e3.o), e3.isFile && (yield* g(e3));
11599 const t6 = e3.u >= 0xffffffffn, i3 = 12 * (a4 >= 0xffffffffn) | 28 * t6;
11600 yield I(e3, t6), o4.push(v(e3, a4, n3, i3)), o4.push(e3.o), i3 && o4.push(h(e3, a4, i3)), t6 && (a4 += 8n), s3++, a4 += BigInt(46 + e3.o.length) + e3.u, u4 || (u4 = t6);
11601 }
11602 let d3 = 0n;
11603 for (const e3 of o4) yield e3, d3 += BigInt(e3.length);
11604 if (u4 || a4 >= 0xffffffffn) {
11605 const t6 = e(76);
11606 t6.setUint32(0, 1347094022), t6.setBigUint64(4, BigInt(44), 1), t6.setUint32(12, 755182848), t6.setBigUint64(24, s3, 1), t6.setBigUint64(32, s3, 1), t6.setBigUint64(40, d3, 1), t6.setBigUint64(48, a4, 1), t6.setUint32(56, 1347094023), t6.setBigUint64(64, a4 + d3, 1), t6.setUint32(72, 1, 1), yield n(t6);
11607 }
11608 const l3 = e(22);
11609 l3.setUint32(0, 1347093766), l3.setUint16(8, r2(s3), 1), l3.setUint16(10, r2(s3), 1), l3.setUint32(12, i(d3), 1), l3.setUint32(16, i(a4), 1), yield n(l3);
11610 })(u3, a3), u3);
11611 }
11612
11613 // packages/fields/build-module/actions/export-pattern.mjs
11614 var import_blob2 = __toESM(require_blob(), 1);
11615 var import_i18n39 = __toESM(require_i18n(), 1);
11616 function getJsonFromItem(item) {
11617 return JSON.stringify(
11618 {
11619 __file: item.type,
11620 title: getItemTitle(item),
11621 content: typeof item.content === "string" ? item.content : item.content?.raw,
11622 syncStatus: item.wp_pattern_sync_status
11623 },
11624 null,
11625 2
11626 );
11627 }
11628 var exportPattern = {
11629 id: "export-pattern",
11630 label: (0, import_i18n39.__)("Export as JSON"),
11631 icon: download_default,
11632 supportsBulk: true,
11633 isEligible: (item) => item.type === "wp_block",
11634 callback: async (items) => {
11635 if (items.length === 1) {
11636 return (0, import_blob2.downloadBlob)(
11637 `${paramCase(
11638 getItemTitle(items[0]) || items[0].slug
11639 )}.json`,
11640 getJsonFromItem(items[0]),
11641 "application/json"
11642 );
11643 }
11644 const nameCount = {};
11645 const filesToZip = items.map((item) => {
11646 const name2 = paramCase(getItemTitle(item) || item.slug);
11647 nameCount[name2] = (nameCount[name2] || 0) + 1;
11648 return {
11649 name: `${name2 + (nameCount[name2] > 1 ? "-" + (nameCount[name2] - 1) : "")}.json`,
11650 lastModified: /* @__PURE__ */ new Date(),
11651 input: getJsonFromItem(item)
11652 };
11653 });
11654 return (0, import_blob2.downloadBlob)(
11655 (0, import_i18n39.__)("patterns-export") + ".zip",
11656 await A(filesToZip).blob(),
11657 "application/zip"
11658 );
11659 }
11660 };
11661 var export_pattern_default = exportPattern;
11662
11663 // packages/fields/build-module/actions/view-post-revisions.mjs
11664 var import_url8 = __toESM(require_url(), 1);
11665 var import_i18n40 = __toESM(require_i18n(), 1);
11666 var viewPostRevisions = {
11667 id: "view-post-revisions",
11668 context: "list",
11669 label(items) {
11670 const revisionsCount = items[0]._links?.["version-history"]?.[0]?.count ?? 0;
11671 return (0, import_i18n40.sprintf)(
11672 /* translators: %d: number of revisions. */
11673 (0, import_i18n40.__)("View revisions (%d)"),
11674 revisionsCount
11675 );
11676 },
11677 isEligible(post2) {
11678 if (post2.status === "trash") {
11679 return false;
11680 }
11681 const lastRevisionId = post2?._links?.["predecessor-version"]?.[0]?.id ?? null;
11682 const revisionsCount = post2?._links?.["version-history"]?.[0]?.count ?? 0;
11683 return !!lastRevisionId && revisionsCount > 1;
11684 },
11685 callback(posts, { onActionPerformed }) {
11686 const post2 = posts[0];
11687 const href = (0, import_url8.addQueryArgs)("revision.php", {
11688 revision: post2?._links?.["predecessor-version"]?.[0]?.id
11689 });
11690 document.location.href = href;
11691 if (onActionPerformed) {
11692 onActionPerformed(posts);
11693 }
11694 }
11695 };
11696 var view_post_revisions_default = viewPostRevisions;
11697
11698 // packages/fields/build-module/actions/permanently-delete-post.mjs
11699 var import_core_data18 = __toESM(require_core_data(), 1);
11700 var import_i18n41 = __toESM(require_i18n(), 1);
11701 var import_notices8 = __toESM(require_notices(), 1);
11702 var import_element16 = __toESM(require_element(), 1);
11703 var import_data20 = __toESM(require_data(), 1);
11704 var import_components16 = __toESM(require_components(), 1);
11705 var import_html_entities4 = __toESM(require_html_entities(), 1);
11706 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
11707 var permanentlyDeletePost = {
11708 id: "permanently-delete",
11709 label: (0, import_i18n41.__)("Permanently delete"),
11710 supportsBulk: true,
11711 icon: trash_default,
11712 isEligible(item) {
11713 if (isTemplateOrTemplatePart(item) || item.type === "wp_block") {
11714 return false;
11715 }
11716 const { status, permissions } = item;
11717 return status === "trash" && permissions?.delete;
11718 },
11719 hideModalHeader: true,
11720 modalFocusOnMount: "firstContentElement",
11721 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
11722 const [isBusy, setIsBusy] = (0, import_element16.useState)(false);
11723 const { createSuccessNotice, createErrorNotice } = (0, import_data20.useDispatch)(import_notices8.store);
11724 const { deleteEntityRecord } = (0, import_data20.useDispatch)(import_core_data18.store);
11725 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_components16.__experimentalVStack, { spacing: "5", children: [
11726 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components16.__experimentalText, { children: items.length > 1 ? (0, import_i18n41.sprintf)(
11727 // translators: %d: number of items to delete.
11728 (0, import_i18n41._n)(
11729 "Are you sure you want to permanently delete %d item?",
11730 "Are you sure you want to permanently delete %d items?",
11731 items.length
11732 ),
11733 items.length
11734 ) : (0, import_i18n41.sprintf)(
11735 // translators: %s: The post's title
11736 (0, import_i18n41.__)(
11737 'Are you sure you want to permanently delete "%s"?'
11738 ),
11739 (0, import_html_entities4.decodeEntities)(getItemTitle(items[0]))
11740 ) }),
11741 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_components16.__experimentalHStack, { justify: "right", children: [
11742 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
11743 import_components16.Button,
11744 {
11745 variant: "tertiary",
11746 onClick: closeModal2,
11747 disabled: isBusy,
11748 accessibleWhenDisabled: true,
11749 __next40pxDefaultSize: true,
11750 children: (0, import_i18n41.__)("Cancel")
11751 }
11752 ),
11753 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
11754 import_components16.Button,
11755 {
11756 variant: "primary",
11757 onClick: async () => {
11758 setIsBusy(true);
11759 const promiseResult = await Promise.allSettled(
11760 items.map(
11761 (post2) => deleteEntityRecord(
11762 "postType",
11763 post2.type,
11764 post2.id,
11765 { force: true },
11766 { throwOnError: true }
11767 )
11768 )
11769 );
11770 if (promiseResult.every(
11771 ({ status }) => status === "fulfilled"
11772 )) {
11773 let successMessage;
11774 if (promiseResult.length === 1) {
11775 successMessage = (0, import_i18n41.sprintf)(
11776 /* translators: %s: The posts's title. */
11777 (0, import_i18n41.__)('"%s" permanently deleted.'),
11778 getItemTitle(items[0])
11779 );
11780 } else {
11781 successMessage = (0, import_i18n41.__)(
11782 "The items were permanently deleted."
11783 );
11784 }
11785 createSuccessNotice(successMessage, {
11786 type: "snackbar",
11787 id: "permanently-delete-post-action"
11788 });
11789 onActionPerformed?.(items);
11790 } else {
11791 let errorMessage;
11792 if (promiseResult.length === 1) {
11793 const typedError = promiseResult[0];
11794 if (typedError.reason?.message) {
11795 errorMessage = typedError.reason.message;
11796 } else {
11797 errorMessage = (0, import_i18n41.__)(
11798 "An error occurred while permanently deleting the item."
11799 );
11800 }
11801 } else {
11802 const errorMessages = /* @__PURE__ */ new Set();
11803 const failedPromises = promiseResult.filter(
11804 ({ status }) => status === "rejected"
11805 );
11806 for (const failedPromise of failedPromises) {
11807 const typedError = failedPromise;
11808 if (typedError.reason?.message) {
11809 errorMessages.add(
11810 typedError.reason.message
11811 );
11812 }
11813 }
11814 if (errorMessages.size === 0) {
11815 errorMessage = (0, import_i18n41.__)(
11816 "An error occurred while permanently deleting the items."
11817 );
11818 } else if (errorMessages.size === 1) {
11819 errorMessage = (0, import_i18n41.sprintf)(
11820 /* translators: %s: an error message */
11821 (0, import_i18n41.__)(
11822 "An error occurred while permanently deleting the items: %s"
11823 ),
11824 [...errorMessages][0]
11825 );
11826 } else {
11827 errorMessage = (0, import_i18n41.sprintf)(
11828 /* translators: %s: a list of comma separated error messages */
11829 (0, import_i18n41.__)(
11830 "Some errors occurred while permanently deleting the items: %s"
11831 ),
11832 [...errorMessages].join(",")
11833 );
11834 }
11835 }
11836 createErrorNotice(errorMessage, {
11837 type: "snackbar"
11838 });
11839 }
11840 setIsBusy(false);
11841 closeModal2?.();
11842 },
11843 isBusy,
11844 disabled: isBusy,
11845 accessibleWhenDisabled: true,
11846 __next40pxDefaultSize: true,
11847 children: (0, import_i18n41.__)("Delete permanently")
11848 }
11849 )
11850 ] })
11851 ] });
11852 }
11853 };
11854 var permanently_delete_post_default = permanentlyDeletePost;
11855
11856 // packages/fields/build-module/actions/restore-post.mjs
11857 var import_core_data19 = __toESM(require_core_data(), 1);
11858 var import_i18n42 = __toESM(require_i18n(), 1);
11859 var import_notices9 = __toESM(require_notices(), 1);
11860 var restorePost = {
11861 id: "restore",
11862 label: (0, import_i18n42.__)("Restore"),
11863 isPrimary: true,
11864 icon: backup_default,
11865 supportsBulk: true,
11866 isEligible(item) {
11867 return !isTemplateOrTemplatePart(item) && item.type !== "wp_block" && item.status === "trash" && item.permissions?.update;
11868 },
11869 async callback(posts, { registry, onActionPerformed }) {
11870 const { createSuccessNotice, createErrorNotice } = registry.dispatch(import_notices9.store);
11871 const { editEntityRecord, saveEditedEntityRecord } = registry.dispatch(import_core_data19.store);
11872 await Promise.allSettled(
11873 posts.map((post2) => {
11874 return editEntityRecord("postType", post2.type, post2.id, {
11875 status: "draft"
11876 });
11877 })
11878 );
11879 const promiseResult = await Promise.allSettled(
11880 posts.map((post2) => {
11881 return saveEditedEntityRecord("postType", post2.type, post2.id, {
11882 throwOnError: true
11883 });
11884 })
11885 );
11886 if (promiseResult.every(({ status }) => status === "fulfilled")) {
11887 let successMessage;
11888 if (posts.length === 1) {
11889 successMessage = (0, import_i18n42.sprintf)(
11890 /* translators: %s: The number of posts. */
11891 (0, import_i18n42.__)('"%s" has been restored.'),
11892 getItemTitle(posts[0])
11893 );
11894 } else if (posts[0].type === "page") {
11895 successMessage = (0, import_i18n42.sprintf)(
11896 /* translators: %d: The number of posts. */
11897 (0, import_i18n42.__)("%d pages have been restored."),
11898 posts.length
11899 );
11900 } else {
11901 successMessage = (0, import_i18n42.sprintf)(
11902 /* translators: %d: The number of posts. */
11903 (0, import_i18n42.__)("%d posts have been restored."),
11904 posts.length
11905 );
11906 }
11907 createSuccessNotice(successMessage, {
11908 type: "snackbar",
11909 id: "restore-post-action"
11910 });
11911 if (onActionPerformed) {
11912 onActionPerformed(posts);
11913 }
11914 } else {
11915 let errorMessage;
11916 if (promiseResult.length === 1) {
11917 const typedError = promiseResult[0];
11918 if (typedError.reason?.message) {
11919 errorMessage = typedError.reason.message;
11920 } else {
11921 errorMessage = (0, import_i18n42.__)(
11922 "An error occurred while restoring the post."
11923 );
11924 }
11925 } else {
11926 const errorMessages = /* @__PURE__ */ new Set();
11927 const failedPromises = promiseResult.filter(
11928 ({ status }) => status === "rejected"
11929 );
11930 for (const failedPromise of failedPromises) {
11931 const typedError = failedPromise;
11932 if (typedError.reason?.message) {
11933 errorMessages.add(typedError.reason.message);
11934 }
11935 }
11936 if (errorMessages.size === 0) {
11937 errorMessage = (0, import_i18n42.__)(
11938 "An error occurred while restoring the posts."
11939 );
11940 } else if (errorMessages.size === 1) {
11941 errorMessage = (0, import_i18n42.sprintf)(
11942 /* translators: %s: an error message */
11943 (0, import_i18n42.__)("An error occurred while restoring the posts: %s"),
11944 [...errorMessages][0]
11945 );
11946 } else {
11947 errorMessage = (0, import_i18n42.sprintf)(
11948 /* translators: %s: a list of comma separated error messages */
11949 (0, import_i18n42.__)(
11950 "Some errors occurred while restoring the posts: %s"
11951 ),
11952 [...errorMessages].join(",")
11953 );
11954 }
11955 }
11956 createErrorNotice(errorMessage, {
11957 type: "snackbar"
11958 });
11959 }
11960 }
11961 };
11962 var restore_post_default = restorePost;
11963
11964 // packages/fields/build-module/actions/trash-post.mjs
11965 var import_data21 = __toESM(require_data(), 1);
11966 var import_core_data20 = __toESM(require_core_data(), 1);
11967 var import_i18n43 = __toESM(require_i18n(), 1);
11968 var import_notices10 = __toESM(require_notices(), 1);
11969 var import_element17 = __toESM(require_element(), 1);
11970 var import_components17 = __toESM(require_components(), 1);
11971 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
11972 var trashPost2 = {
11973 id: "move-to-trash",
11974 label: (0, import_i18n43._x)("Trash", "verb"),
11975 isPrimary: true,
11976 icon: trash_default,
11977 isEligible(item) {
11978 if (item.type === "wp_template_part" || item.type === "wp_block") {
11979 return false;
11980 }
11981 if (item.type === "wp_template" && typeof item.id === "string") {
11982 return false;
11983 }
11984 return !!item.status && !["auto-draft", "trash"].includes(item.status) && item.permissions?.delete;
11985 },
11986 supportsBulk: true,
11987 hideModalHeader: true,
11988 modalFocusOnMount: "firstContentElement",
11989 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
11990 const [isBusy, setIsBusy] = (0, import_element17.useState)(false);
11991 const { createSuccessNotice, createErrorNotice } = (0, import_data21.useDispatch)(import_notices10.store);
11992 const { deleteEntityRecord } = (0, import_data21.useDispatch)(import_core_data20.store);
11993 return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(import_components17.__experimentalVStack, { spacing: "5", children: [
11994 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components17.__experimentalText, { children: items.length === 1 ? (0, import_i18n43.sprintf)(
11995 // translators: %s: The item's title.
11996 (0, import_i18n43.__)(
11997 'Are you sure you want to move "%s" to the trash?'
11998 ),
11999 getItemTitle(items[0])
12000 ) : (0, import_i18n43.sprintf)(
12001 // translators: %d: The number of items (2 or more).
12002 (0, import_i18n43._n)(
12003 "Are you sure you want to move %d item to the trash ?",
12004 "Are you sure you want to move %d items to the trash ?",
12005 items.length
12006 ),
12007 items.length
12008 ) }),
12009 /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(import_components17.__experimentalHStack, { justify: "right", children: [
12010 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
12011 import_components17.Button,
12012 {
12013 __next40pxDefaultSize: true,
12014 variant: "tertiary",
12015 onClick: closeModal2,
12016 disabled: isBusy,
12017 accessibleWhenDisabled: true,
12018 children: (0, import_i18n43.__)("Cancel")
12019 }
12020 ),
12021 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
12022 import_components17.Button,
12023 {
12024 __next40pxDefaultSize: true,
12025 variant: "primary",
12026 onClick: async () => {
12027 setIsBusy(true);
12028 const promiseResult = await Promise.allSettled(
12029 items.map(
12030 (item) => deleteEntityRecord(
12031 "postType",
12032 item.type,
12033 item.id.toString(),
12034 {},
12035 { throwOnError: true }
12036 )
12037 )
12038 );
12039 if (promiseResult.every(
12040 ({ status }) => status === "fulfilled"
12041 )) {
12042 let successMessage;
12043 if (promiseResult.length === 1) {
12044 successMessage = (0, import_i18n43.sprintf)(
12045 /* translators: %s: The item's title. */
12046 (0, import_i18n43.__)('"%s" moved to the trash.'),
12047 getItemTitle(items[0])
12048 );
12049 } else {
12050 successMessage = (0, import_i18n43.sprintf)(
12051 /* translators: %d: The number of items. */
12052 (0, import_i18n43._n)(
12053 "%d item moved to the trash.",
12054 "%d items moved to the trash.",
12055 items.length
12056 ),
12057 items.length
12058 );
12059 }
12060 createSuccessNotice(successMessage, {
12061 type: "snackbar",
12062 id: "move-to-trash-action"
12063 });
12064 } else {
12065 let errorMessage;
12066 if (promiseResult.length === 1) {
12067 const typedError = promiseResult[0];
12068 if (typedError.reason?.message) {
12069 errorMessage = typedError.reason.message;
12070 } else {
12071 errorMessage = (0, import_i18n43.__)(
12072 "An error occurred while moving the item to the trash."
12073 );
12074 }
12075 } else {
12076 const errorMessages = /* @__PURE__ */ new Set();
12077 const failedPromises = promiseResult.filter(
12078 ({ status }) => status === "rejected"
12079 );
12080 for (const failedPromise of failedPromises) {
12081 const typedError = failedPromise;
12082 if (typedError.reason?.message) {
12083 errorMessages.add(
12084 typedError.reason.message
12085 );
12086 }
12087 }
12088 if (errorMessages.size === 0) {
12089 errorMessage = (0, import_i18n43.__)(
12090 "An error occurred while moving the items to the trash."
12091 );
12092 } else if (errorMessages.size === 1) {
12093 errorMessage = (0, import_i18n43.sprintf)(
12094 /* translators: %s: an error message */
12095 (0, import_i18n43.__)(
12096 "An error occurred while moving the item to the trash: %s"
12097 ),
12098 [...errorMessages][0]
12099 );
12100 } else {
12101 errorMessage = (0, import_i18n43.sprintf)(
12102 /* translators: %s: a list of comma separated error messages */
12103 (0, import_i18n43.__)(
12104 "Some errors occurred while moving the items to the trash: %s"
12105 ),
12106 [...errorMessages].join(",")
12107 );
12108 }
12109 }
12110 createErrorNotice(errorMessage, {
12111 type: "snackbar"
12112 });
12113 }
12114 if (onActionPerformed) {
12115 onActionPerformed(items);
12116 }
12117 setIsBusy(false);
12118 closeModal2?.();
12119 },
12120 isBusy,
12121 disabled: isBusy,
12122 accessibleWhenDisabled: true,
12123 children: (0, import_i18n43._x)("Trash", "verb")
12124 }
12125 )
12126 ] })
12127 ] });
12128 }
12129 };
12130 var trash_post_default = trashPost2;
12131
12132 // packages/fields/build-module/actions/delete-post.mjs
12133 var import_i18n44 = __toESM(require_i18n(), 1);
12134 var import_element18 = __toESM(require_element(), 1);
12135 var import_components18 = __toESM(require_components(), 1);
12136 var import_patterns4 = __toESM(require_patterns(), 1);
12137 var import_html_entities5 = __toESM(require_html_entities(), 1);
12138
12139 // packages/fields/build-module/mutation/index.mjs
12140 var import_notices11 = __toESM(require_notices(), 1);
12141 var import_core_data21 = __toESM(require_core_data(), 1);
12142 var import_data22 = __toESM(require_data(), 1);
12143 function getErrorMessagesFromPromises(allSettledResults) {
12144 const errorMessages = /* @__PURE__ */ new Set();
12145 if (allSettledResults.length === 1) {
12146 const typedError = allSettledResults[0];
12147 if (typedError.reason?.message) {
12148 errorMessages.add(typedError.reason.message);
12149 }
12150 } else {
12151 const failedPromises = allSettledResults.filter(
12152 ({ status }) => status === "rejected"
12153 );
12154 for (const failedPromise of failedPromises) {
12155 const typedError = failedPromise;
12156 if (typedError.reason?.message) {
12157 errorMessages.add(typedError.reason.message);
12158 }
12159 }
12160 }
12161 return errorMessages;
12162 }
12163 var deletePostWithNotices = async (posts, notice, callbacks) => {
12164 const { createSuccessNotice, createErrorNotice } = (0, import_data22.dispatch)(import_notices11.store);
12165 const { deleteEntityRecord } = (0, import_data22.dispatch)(import_core_data21.store);
12166 const allSettledResults = await Promise.allSettled(
12167 posts.map((post2) => {
12168 return deleteEntityRecord(
12169 "postType",
12170 post2.type,
12171 post2.id,
12172 { force: true },
12173 { throwOnError: true }
12174 );
12175 })
12176 );
12177 if (allSettledResults.every(({ status }) => status === "fulfilled")) {
12178 let successMessage;
12179 if (allSettledResults.length === 1) {
12180 successMessage = notice.success.messages.getMessage(posts[0]);
12181 } else {
12182 successMessage = notice.success.messages.getBatchMessage(posts);
12183 }
12184 createSuccessNotice(successMessage, {
12185 type: notice.success.type ?? "snackbar",
12186 id: notice.success.id
12187 });
12188 callbacks.onActionPerformed?.(posts);
12189 } else {
12190 const errorMessages = getErrorMessagesFromPromises(allSettledResults);
12191 let errorMessage = "";
12192 if (allSettledResults.length === 1) {
12193 errorMessage = notice.error.messages.getMessage(errorMessages);
12194 } else {
12195 errorMessage = notice.error.messages.getBatchMessage(errorMessages);
12196 }
12197 createErrorNotice(errorMessage, {
12198 type: notice.error.type ?? "snackbar",
12199 id: notice.error.id
12200 });
12201 callbacks.onActionError?.();
12202 }
12203 };
12204
12205 // packages/fields/build-module/actions/delete-post.mjs
12206 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
12207 var { PATTERN_TYPES: PATTERN_TYPES3 } = unlock2(import_patterns4.privateApis);
12208 var deletePostAction = {
12209 id: "delete-post",
12210 label: (0, import_i18n44.__)("Delete"),
12211 isPrimary: true,
12212 icon: trash_default,
12213 isEligible(post2) {
12214 if (isTemplateOrTemplatePart(post2)) {
12215 return isTemplateRemovable(post2);
12216 }
12217 return post2.type === PATTERN_TYPES3.user;
12218 },
12219 supportsBulk: true,
12220 hideModalHeader: true,
12221 modalFocusOnMount: "firstContentElement",
12222 RenderModal: ({ items, closeModal: closeModal2, onActionPerformed }) => {
12223 const [isBusy, setIsBusy] = (0, import_element18.useState)(false);
12224 const isResetting = items.every(
12225 (item) => isTemplateOrTemplatePart(item) && item?.has_theme_file
12226 );
12227 return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(import_components18.__experimentalVStack, { spacing: "5", children: [
12228 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components18.__experimentalText, { children: items.length > 1 ? (0, import_i18n44.sprintf)(
12229 // translators: %d: number of items to delete.
12230 (0, import_i18n44._n)(
12231 "Delete %d item?",
12232 "Delete %d items?",
12233 items.length
12234 ),
12235 items.length
12236 ) : (0, import_i18n44.sprintf)(
12237 // translators: %s: The template or template part's title
12238 (0, import_i18n44._x)('Delete "%s"?', "template part"),
12239 getItemTitle(items[0])
12240 ) }),
12241 /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(import_components18.__experimentalHStack, { justify: "right", children: [
12242 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
12243 import_components18.Button,
12244 {
12245 variant: "tertiary",
12246 onClick: closeModal2,
12247 disabled: isBusy,
12248 accessibleWhenDisabled: true,
12249 __next40pxDefaultSize: true,
12250 children: (0, import_i18n44.__)("Cancel")
12251 }
12252 ),
12253 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
12254 import_components18.Button,
12255 {
12256 variant: "primary",
12257 onClick: async () => {
12258 setIsBusy(true);
12259 const notice = {
12260 success: {
12261 messages: {
12262 getMessage: (item) => {
12263 return isResetting ? (0, import_i18n44.sprintf)(
12264 /* translators: %s: The template/part's name. */
12265 (0, import_i18n44.__)('"%s" reset.'),
12266 (0, import_html_entities5.decodeEntities)(
12267 getItemTitle(item)
12268 )
12269 ) : (0, import_i18n44.sprintf)(
12270 /* translators: %s: The template/part's name. */
12271 (0, import_i18n44._x)(
12272 '"%s" deleted.',
12273 "template part"
12274 ),
12275 (0, import_html_entities5.decodeEntities)(
12276 getItemTitle(item)
12277 )
12278 );
12279 },
12280 getBatchMessage: () => {
12281 return isResetting ? (0, import_i18n44.__)("Items reset.") : (0, import_i18n44.__)("Items deleted.");
12282 }
12283 }
12284 },
12285 error: {
12286 messages: {
12287 getMessage: (error) => {
12288 if (error.size === 1) {
12289 return [...error][0];
12290 }
12291 return isResetting ? (0, import_i18n44.__)(
12292 "An error occurred while reverting the item."
12293 ) : (0, import_i18n44.__)(
12294 "An error occurred while deleting the item."
12295 );
12296 },
12297 getBatchMessage: (errors) => {
12298 if (errors.size === 0) {
12299 return isResetting ? (0, import_i18n44.__)(
12300 "An error occurred while reverting the items."
12301 ) : (0, import_i18n44.__)(
12302 "An error occurred while deleting the items."
12303 );
12304 }
12305 if (errors.size === 1) {
12306 return isResetting ? (0, import_i18n44.sprintf)(
12307 /* translators: %s: an error message */
12308 (0, import_i18n44.__)(
12309 "An error occurred while reverting the items: %s"
12310 ),
12311 [...errors][0]
12312 ) : (0, import_i18n44.sprintf)(
12313 /* translators: %s: an error message */
12314 (0, import_i18n44.__)(
12315 "An error occurred while deleting the items: %s"
12316 ),
12317 [...errors][0]
12318 );
12319 }
12320 return isResetting ? (0, import_i18n44.sprintf)(
12321 /* translators: %s: a list of comma separated error messages */
12322 (0, import_i18n44.__)(
12323 "Some errors occurred while reverting the items: %s"
12324 ),
12325 [...errors].join(
12326 ","
12327 )
12328 ) : (0, import_i18n44.sprintf)(
12329 /* translators: %s: a list of comma separated error messages */
12330 (0, import_i18n44.__)(
12331 "Some errors occurred while deleting the items: %s"
12332 ),
12333 [...errors].join(
12334 ","
12335 )
12336 );
12337 }
12338 }
12339 }
12340 };
12341 await deletePostWithNotices(items, notice, {
12342 onActionPerformed
12343 });
12344 setIsBusy(false);
12345 closeModal2?.();
12346 },
12347 isBusy,
12348 disabled: isBusy,
12349 accessibleWhenDisabled: true,
12350 __next40pxDefaultSize: true,
12351 children: (0, import_i18n44.__)("Delete")
12352 }
12353 )
12354 ] })
12355 ] });
12356 }
12357 };
12358 var delete_post_default = deletePostAction;
12359
12360 // packages/fields/build-module/actions/duplicate-template-part.mjs
12361 var import_data25 = __toESM(require_data(), 1);
12362 var import_i18n46 = __toESM(require_i18n(), 1);
12363 var import_notices13 = __toESM(require_notices(), 1);
12364 var import_element20 = __toESM(require_element(), 1);
12365 var import_blocks5 = __toESM(require_blocks(), 1);
12366
12367 // packages/fields/build-module/components/create-template-part-modal/index.mjs
12368 var import_components19 = __toESM(require_components(), 1);
12369 var import_compose3 = __toESM(require_compose(), 1);
12370 var import_core_data23 = __toESM(require_core_data(), 1);
12371 var import_data24 = __toESM(require_data(), 1);
12372 var import_element19 = __toESM(require_element(), 1);
12373 var import_i18n45 = __toESM(require_i18n(), 1);
12374 var import_notices12 = __toESM(require_notices(), 1);
12375 var import_blocks4 = __toESM(require_blocks(), 1);
12376
12377 // packages/fields/build-module/components/create-template-part-modal/utils.mjs
12378 var import_data23 = __toESM(require_data(), 1);
12379 var import_core_data22 = __toESM(require_core_data(), 1);
12380 var useExistingTemplateParts = () => {
12381 return (0, import_data23.useSelect)(
12382 (select6) => select6(import_core_data22.store).getEntityRecords(
12383 "postType",
12384 "wp_template_part",
12385 {
12386 per_page: -1
12387 }
12388 ),
12389 []
12390 ) ?? [];
12391 };
12392 var getUniqueTemplatePartTitle = (title, templateParts) => {
12393 const lowercaseTitle = title.toLowerCase();
12394 const existingTitles = templateParts.map(
12395 (templatePart) => templatePart.title.rendered.toLowerCase()
12396 );
12397 if (!existingTitles.includes(lowercaseTitle)) {
12398 return title;
12399 }
12400 let suffix = 2;
12401 while (existingTitles.includes(`${lowercaseTitle} ${suffix}`)) {
12402 suffix++;
12403 }
12404 return `${title} ${suffix}`;
12405 };
12406 var getCleanTemplatePartSlug = (title) => {
12407 return paramCase(title).replace(/[^\w-]+/g, "") || "wp-custom-part";
12408 };
12409
12410 // packages/fields/build-module/components/create-template-part-modal/index.mjs
12411 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
12412 function getAreaRadioId(value, instanceId) {
12413 return `fields-create-template-part-modal__area-option-${value}-${instanceId}`;
12414 }
12415 function getAreaRadioDescriptionId(value, instanceId) {
12416 return `fields-create-template-part-modal__area-option-description-${value}-${instanceId}`;
12417 }
12418 function CreateTemplatePartModal({
12419 modalTitle,
12420 ...restProps
12421 }) {
12422 const defaultModalTitle = (0, import_data24.useSelect)(
12423 (select6) => select6(import_core_data23.store).getPostType("wp_template_part")?.labels?.add_new_item,
12424 []
12425 );
12426 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
12427 import_components19.Modal,
12428 {
12429 title: modalTitle || defaultModalTitle,
12430 onRequestClose: restProps.closeModal,
12431 overlayClassName: "fields-create-template-part-modal",
12432 focusOnMount: "firstContentElement",
12433 size: "medium",
12434 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(CreateTemplatePartModalContents, { ...restProps })
12435 }
12436 );
12437 }
12438 var getTemplatePartIcon2 = (areaOrIconName) => {
12439 if ("header" === areaOrIconName) {
12440 return header_default;
12441 } else if ("footer" === areaOrIconName) {
12442 return footer_default;
12443 } else if ("sidebar" === areaOrIconName) {
12444 return sidebar_default;
12445 } else if ("navigation-overlay" === areaOrIconName) {
12446 return navigation_overlay_default;
12447 }
12448 return symbol_filled_default;
12449 };
12450 function CreateTemplatePartModalContents({
12451 defaultArea = "uncategorized",
12452 blocks = [],
12453 confirmLabel = (0, import_i18n45.__)("Add"),
12454 closeModal: closeModal2,
12455 onCreate,
12456 onError,
12457 defaultTitle = ""
12458 }) {
12459 const { createErrorNotice } = (0, import_data24.useDispatch)(import_notices12.store);
12460 const { saveEntityRecord } = (0, import_data24.useDispatch)(import_core_data23.store);
12461 const existingTemplateParts = useExistingTemplateParts();
12462 const [title, setTitle] = (0, import_element19.useState)(defaultTitle);
12463 const [area, setArea] = (0, import_element19.useState)(defaultArea);
12464 const [isSubmitting, setIsSubmitting] = (0, import_element19.useState)(false);
12465 const instanceId = (0, import_compose3.useInstanceId)(CreateTemplatePartModal);
12466 const defaultTemplatePartAreas = (0, import_data24.useSelect)(
12467 (select6) => select6(import_core_data23.store).getCurrentTheme()?.default_template_part_areas,
12468 []
12469 );
12470 async function createTemplatePart() {
12471 if (!title || isSubmitting) {
12472 return;
12473 }
12474 try {
12475 setIsSubmitting(true);
12476 const uniqueTitle = getUniqueTemplatePartTitle(
12477 title,
12478 existingTemplateParts
12479 );
12480 const cleanSlug = getCleanTemplatePartSlug(uniqueTitle);
12481 const templatePart = await saveEntityRecord(
12482 "postType",
12483 "wp_template_part",
12484 {
12485 slug: cleanSlug,
12486 title: uniqueTitle,
12487 content: (0, import_blocks4.serialize)(blocks),
12488 area
12489 },
12490 { throwOnError: true }
12491 );
12492 await onCreate(templatePart);
12493 } catch (error) {
12494 const errorMessage = error instanceof Error && "code" in error && error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n45.__)(
12495 "An error occurred while creating the template part."
12496 );
12497 createErrorNotice(errorMessage, { type: "snackbar" });
12498 onError?.();
12499 } finally {
12500 setIsSubmitting(false);
12501 }
12502 }
12503 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
12504 "form",
12505 {
12506 onSubmit: async (event) => {
12507 event.preventDefault();
12508 await createTemplatePart();
12509 },
12510 children: /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_components19.__experimentalVStack, { spacing: "4", children: [
12511 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
12512 import_components19.TextControl,
12513 {
12514 __next40pxDefaultSize: true,
12515 label: (0, import_i18n45.__)("Name"),
12516 value: title,
12517 onChange: setTitle,
12518 required: true
12519 }
12520 ),
12521 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("fieldset", { className: "fields-create-template-part-modal__area-fieldset", children: [
12522 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components19.BaseControl.VisualLabel, { as: "legend", children: (0, import_i18n45.__)("Area") }),
12523 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "fields-create-template-part-modal__area-radio-group", children: (defaultTemplatePartAreas ?? []).map(
12524 (item) => {
12525 const icon = getTemplatePartIcon2(item.icon);
12526 return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
12527 "div",
12528 {
12529 className: "fields-create-template-part-modal__area-radio-wrapper",
12530 children: [
12531 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
12532 "input",
12533 {
12534 type: "radio",
12535 id: getAreaRadioId(
12536 item.area,
12537 instanceId
12538 ),
12539 name: `fields-create-template-part-modal__area-${instanceId}`,
12540 value: item.area,
12541 checked: area === item.area,
12542 onChange: () => {
12543 setArea(item.area);
12544 },
12545 "aria-describedby": getAreaRadioDescriptionId(
12546 item.area,
12547 instanceId
12548 )
12549 }
12550 ),
12551 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
12552 import_components19.Icon,
12553 {
12554 icon,
12555 className: "fields-create-template-part-modal__area-radio-icon"
12556 }
12557 ),
12558 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
12559 "label",
12560 {
12561 htmlFor: getAreaRadioId(
12562 item.area,
12563 instanceId
12564 ),
12565 className: "fields-create-template-part-modal__area-radio-label",
12566 children: item.label
12567 }
12568 ),
12569 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
12570 import_components19.Icon,
12571 {
12572 icon: check_default,
12573 className: "fields-create-template-part-modal__area-radio-checkmark"
12574 }
12575 ),
12576 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
12577 "p",
12578 {
12579 className: "fields-create-template-part-modal__area-radio-description",
12580 id: getAreaRadioDescriptionId(
12581 item.area,
12582 instanceId
12583 ),
12584 children: item.description
12585 }
12586 )
12587 ]
12588 },
12589 item.area
12590 );
12591 }
12592 ) })
12593 ] }),
12594 /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_components19.__experimentalHStack, { justify: "right", children: [
12595 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
12596 import_components19.Button,
12597 {
12598 __next40pxDefaultSize: true,
12599 variant: "tertiary",
12600 onClick: () => {
12601 closeModal2();
12602 },
12603 children: (0, import_i18n45.__)("Cancel")
12604 }
12605 ),
12606 /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
12607 import_components19.Button,
12608 {
12609 __next40pxDefaultSize: true,
12610 variant: "primary",
12611 type: "submit",
12612 "aria-disabled": !title || isSubmitting,
12613 isBusy: isSubmitting,
12614 children: confirmLabel
12615 }
12616 )
12617 ] })
12618 ] })
12619 }
12620 );
12621 }
12622
12623 // packages/fields/build-module/actions/duplicate-template-part.mjs
12624 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
12625 var duplicateTemplatePart = {
12626 id: "duplicate-template-part",
12627 label: (0, import_i18n46._x)("Duplicate", "action label"),
12628 isEligible: (item) => item.type === "wp_template_part",
12629 modalHeader: (0, import_i18n46._x)("Duplicate template part", "action label"),
12630 modalFocusOnMount: "firstContentElement",
12631 RenderModal: ({ items, closeModal: closeModal2 }) => {
12632 const [item] = items;
12633 const blocks = (0, import_element20.useMemo)(() => {
12634 return item.blocks ?? (0, import_blocks5.parse)(
12635 typeof item.content === "string" ? item.content : item.content.raw,
12636 {
12637 __unstableSkipMigrationLogs: true
12638 }
12639 );
12640 }, [item.content, item.blocks]);
12641 const { createSuccessNotice } = (0, import_data25.useDispatch)(import_notices13.store);
12642 function onTemplatePartSuccess(templatePart) {
12643 createSuccessNotice(
12644 (0, import_i18n46.sprintf)(
12645 // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
12646 (0, import_i18n46._x)('"%s" duplicated.', "template part"),
12647 getItemTitle(templatePart)
12648 ),
12649 { type: "snackbar", id: "edit-site-patterns-success" }
12650 );
12651 closeModal2?.();
12652 }
12653 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
12654 CreateTemplatePartModalContents,
12655 {
12656 blocks,
12657 defaultArea: item.area,
12658 defaultTitle: (0, import_i18n46.sprintf)(
12659 /* translators: %s: Existing template part title */
12660 (0, import_i18n46._x)("%s (Copy)", "template part"),
12661 getItemTitle(item)
12662 ),
12663 onCreate: onTemplatePartSuccess,
12664 onError: closeModal2,
12665 confirmLabel: (0, import_i18n46._x)("Duplicate", "action label"),
12666 closeModal: closeModal2 ?? (() => {
12667 })
12668 }
12669 );
12670 }
12671 };
12672 var duplicate_template_part_default = duplicateTemplatePart;
12673
12674 // packages/media-fields/build-module/alt_text/index.mjs
12675 var import_i18n47 = __toESM(require_i18n(), 1);
12676 var import_components20 = __toESM(require_components(), 1);
12677 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
12678 var altTextField = {
12679 id: "alt_text",
12680 type: "text",
12681 label: (0, import_i18n47.__)("Alt text"),
12682 isVisible: (item) => item?.media_type === "image",
12683 render: ({ item }) => item?.alt_text || "-",
12684 Edit: ({ field, onChange, data }) => {
12685 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
12686 import_components20.TextareaControl,
12687 {
12688 label: field.label,
12689 value: data.alt_text || "",
12690 onChange: (value) => onChange({ alt_text: value }),
12691 rows: 2
12692 }
12693 );
12694 },
12695 enableSorting: false,
12696 filterBy: false
12697 };
12698 var alt_text_default = altTextField;
12699
12700 // packages/media-fields/build-module/attached_to/index.mjs
12701 var import_i18n50 = __toESM(require_i18n(), 1);
12702
12703 // packages/media-fields/build-module/attached_to/view.mjs
12704 var import_element21 = __toESM(require_element(), 1);
12705 var import_i18n48 = __toESM(require_i18n(), 1);
12706
12707 // packages/media-fields/build-module/utils/get-rendered-content.mjs
12708 function getRenderedContent(content) {
12709 if (!content) {
12710 return "";
12711 }
12712 if (typeof content === "string") {
12713 return content;
12714 }
12715 if (typeof content === "object") {
12716 return content.rendered || content.raw || "";
12717 }
12718 return "";
12719 }
12720
12721 // packages/media-fields/build-module/attached_to/view.mjs
12722 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
12723 function MediaAttachedToView({
12724 item
12725 }) {
12726 const [attachedPostTitle, setAttachedPostTitle] = (0, import_element21.useState)(null);
12727 const parentId = item.post;
12728 const embeddedPostId = item._embedded?.["wp:attached-to"]?.[0]?.id;
12729 const embeddedPostTitle = item._embedded?.["wp:attached-to"]?.[0]?.title;
12730 (0, import_element21.useEffect)(() => {
12731 if (!!parentId && parentId === embeddedPostId) {
12732 setAttachedPostTitle(
12733 getRenderedContent(embeddedPostTitle) || embeddedPostId?.toString() || ""
12734 );
12735 }
12736 if (!parentId) {
12737 setAttachedPostTitle((0, import_i18n48.__)("(Unattached)"));
12738 }
12739 }, [parentId, embeddedPostId, embeddedPostTitle]);
12740 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_jsx_runtime104.Fragment, { children: attachedPostTitle });
12741 }
12742
12743 // packages/media-fields/build-module/attached_to/edit.mjs
12744 var import_core_data24 = __toESM(require_core_data(), 1);
12745 var import_components21 = __toESM(require_components(), 1);
12746 var import_i18n49 = __toESM(require_i18n(), 1);
12747 var import_element22 = __toESM(require_element(), 1);
12748 var import_compose4 = __toESM(require_compose(), 1);
12749 var import_data26 = __toESM(require_data(), 1);
12750 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
12751 function MediaAttachedToEdit({
12752 data,
12753 onChange
12754 }) {
12755 const defaultPost = !!data.post && !!data?._embedded?.["wp:attached-to"]?.[0] ? [
12756 {
12757 label: getRenderedContent(
12758 data._embedded?.["wp:attached-to"]?.[0]?.title
12759 ),
12760 value: data.post.toString()
12761 }
12762 ] : [];
12763 const [options, setOptions] = (0, import_element22.useState)(defaultPost);
12764 const [searchResults, setSearchResults] = (0, import_element22.useState)(
12765 []
12766 );
12767 const [isLoading, setIsLoading] = (0, import_element22.useState)(false);
12768 const [value, setValue] = (0, import_element22.useState)(
12769 data?.post?.toString() ?? null
12770 );
12771 const postTypes = (0, import_data26.useSelect)(
12772 (select6) => select6(import_core_data24.store).getPostTypes(),
12773 []
12774 );
12775 const handleDetach = () => {
12776 onChange({
12777 post: 0,
12778 _embedded: { ...data?._embedded, "wp:attached-to": void 0 }
12779 });
12780 setOptions([]);
12781 };
12782 const onValueChange = async (filterValue) => {
12783 setIsLoading(true);
12784 const results = await (0, import_core_data24.__experimentalFetchLinkSuggestions)(
12785 filterValue,
12786 /*
12787 * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.
12788 * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.
12789 */
12790 { type: "post", isInitialSuggestions: true },
12791 {}
12792 );
12793 setSearchResults(results);
12794 const mappedSuggestions = results.map((result) => {
12795 return {
12796 label: result.title,
12797 value: result.id.toString()
12798 };
12799 });
12800 setOptions(mappedSuggestions);
12801 setIsLoading(false);
12802 };
12803 const handleSelectOption = (selectedPostId) => {
12804 if (!selectedPostId) {
12805 handleDetach();
12806 return;
12807 }
12808 setValue(selectedPostId);
12809 if (selectedPostId) {
12810 const selectedPost = searchResults.find(
12811 (result) => result.id === Number(selectedPostId)
12812 );
12813 if (selectedPost && postTypes) {
12814 const postType2 = postTypes.find(
12815 (_postType) => _postType.slug === selectedPost?.type
12816 );
12817 const attachedTo = {
12818 ...postType2 && { type: postType2.slug },
12819 id: Number(selectedPostId),
12820 title: {
12821 raw: selectedPost.title,
12822 rendered: selectedPost.title
12823 }
12824 };
12825 onChange({
12826 post: Number(selectedPostId),
12827 _embedded: {
12828 ...data?._embedded,
12829 "wp:attached-to": [attachedTo]
12830 }
12831 });
12832 }
12833 }
12834 };
12835 const help = !!data.post ? (0, import_element22.createInterpolateElement)(
12836 (0, import_i18n49.__)(
12837 "Search for a post or page to attach this media to or <button>detach current</button>."
12838 ),
12839 {
12840 button: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
12841 import_components21.Button,
12842 {
12843 __next40pxDefaultSize: true,
12844 onClick: handleDetach,
12845 variant: "link",
12846 accessibleWhenDisabled: true
12847 }
12848 )
12849 }
12850 ) : (0, import_i18n49.__)("Search for a post or page to attach this media to.");
12851 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
12852 import_components21.ComboboxControl,
12853 {
12854 className: "dataviews-media-field__attached-to",
12855 __next40pxDefaultSize: true,
12856 isLoading,
12857 label: (0, import_i18n49.__)("Attached to"),
12858 help,
12859 value,
12860 options,
12861 onFilterValueChange: (0, import_compose4.debounce)(
12862 (filterValue) => onValueChange(filterValue),
12863 300
12864 ),
12865 onChange: handleSelectOption,
12866 hideLabelFromVision: true
12867 }
12868 );
12869 }
12870
12871 // packages/media-fields/build-module/attached_to/index.mjs
12872 var attachedToField = {
12873 id: "attached_to",
12874 type: "text",
12875 label: (0, import_i18n50.__)("Attached to"),
12876 Edit: MediaAttachedToEdit,
12877 render: MediaAttachedToView,
12878 enableSorting: false,
12879 filterBy: false
12880 };
12881 var attached_to_default = attachedToField;
12882
12883 // packages/media-fields/build-module/author/index.mjs
12884 var import_i18n52 = __toESM(require_i18n(), 1);
12885 var import_data27 = __toESM(require_data(), 1);
12886 var import_core_data25 = __toESM(require_core_data(), 1);
12887
12888 // packages/media-fields/build-module/author/view.mjs
12889 var import_i18n51 = __toESM(require_i18n(), 1);
12890 var import_element23 = __toESM(require_element(), 1);
12891 var import_components22 = __toESM(require_components(), 1);
12892 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
12893 function AuthorView2({
12894 item
12895 }) {
12896 const author = item?._embedded?.author?.[0];
12897 const text = author?.name;
12898 const imageUrl = author?.avatar_urls?.[48];
12899 const [loadingState, setLoadingState] = (0, import_element23.useState)("loading");
12900 (0, import_element23.useEffect)(() => {
12901 setLoadingState("loading");
12902 }, [imageUrl]);
12903 const imgRef = (0, import_element23.useCallback)((img) => {
12904 if (img?.complete) {
12905 setLoadingState("instant");
12906 }
12907 }, []);
12908 const handleLoad = () => {
12909 if (loadingState === "loading") {
12910 setLoadingState("loaded");
12911 }
12912 };
12913 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(import_components22.__experimentalHStack, { alignment: "left", spacing: 0, children: [
12914 !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
12915 "div",
12916 {
12917 className: clsx_default("media-author-field__avatar", {
12918 "is-loading": loadingState === "loading",
12919 "is-loaded": loadingState === "loaded"
12920 }),
12921 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
12922 "img",
12923 {
12924 ref: imgRef,
12925 onLoad: handleLoad,
12926 alt: (0, import_i18n51.__)("Author avatar"),
12927 src: imageUrl
12928 }
12929 )
12930 }
12931 ),
12932 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "media-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components22.Icon, { icon: comment_author_avatar_default }) }),
12933 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("span", { className: "media-author-field__name", children: text })
12934 ] });
12935 }
12936
12937 // packages/media-fields/build-module/author/index.mjs
12938 var authorField2 = {
12939 label: (0, import_i18n52.__)("Author"),
12940 id: "author",
12941 type: "integer",
12942 getElements: async () => {
12943 const authors = await (0, import_data27.resolveSelect)(import_core_data25.store).getEntityRecords(
12944 "root",
12945 "user",
12946 {
12947 per_page: -1,
12948 who: "authors",
12949 _fields: "id,name",
12950 context: "view"
12951 }
12952 ) ?? [];
12953 return authors.map(({ id, name: name2 }) => ({
12954 value: id,
12955 label: name2
12956 }));
12957 },
12958 render: AuthorView2,
12959 sort: (a3, b3, direction) => {
12960 const nameA = a3._embedded?.author?.[0]?.name || "";
12961 const nameB = b3._embedded?.author?.[0]?.name || "";
12962 return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
12963 },
12964 filterBy: {
12965 operators: ["isAny", "isNone"]
12966 },
12967 readOnly: true
12968 };
12969 var author_default2 = authorField2;
12970
12971 // packages/media-fields/build-module/caption/index.mjs
12972 var import_i18n53 = __toESM(require_i18n(), 1);
12973 var import_components23 = __toESM(require_components(), 1);
12974
12975 // packages/media-fields/build-module/utils/get-raw-content.mjs
12976 function getRawContent(content) {
12977 if (!content) {
12978 return "";
12979 }
12980 if (typeof content === "string") {
12981 return content;
12982 }
12983 if (typeof content === "object" && "raw" in content) {
12984 return content.raw || "";
12985 }
12986 return "";
12987 }
12988
12989 // packages/media-fields/build-module/caption/index.mjs
12990 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
12991 var captionField = {
12992 id: "caption",
12993 type: "text",
12994 label: (0, import_i18n53.__)("Caption"),
12995 getValue: ({ item }) => getRawContent(item?.caption),
12996 render: ({ item }) => getRawContent(item?.caption) || "-",
12997 Edit: ({ field, onChange, data }) => {
12998 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
12999 import_components23.TextareaControl,
13000 {
13001 label: field.label,
13002 value: getRawContent(data.caption) || "",
13003 onChange: (value) => onChange({ caption: value }),
13004 rows: 2
13005 }
13006 );
13007 },
13008 enableSorting: false,
13009 filterBy: false
13010 };
13011 var caption_default = captionField;
13012
13013 // packages/media-fields/build-module/date_added/index.mjs
13014 var import_i18n54 = __toESM(require_i18n(), 1);
13015 var import_date4 = __toESM(require_date(), 1);
13016 var dateAddedField = {
13017 id: "date",
13018 type: "datetime",
13019 label: (0, import_i18n54.__)("Date added"),
13020 filterBy: {
13021 operators: ["before", "after"]
13022 },
13023 format: {
13024 datetime: (0, import_date4.getSettings)().formats.datetimeAbbreviated
13025 },
13026 readOnly: true
13027 };
13028 var date_added_default = dateAddedField;
13029
13030 // packages/media-fields/build-module/description/index.mjs
13031 var import_i18n55 = __toESM(require_i18n(), 1);
13032 var import_components24 = __toESM(require_components(), 1);
13033 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
13034 var descriptionField = {
13035 id: "description",
13036 type: "text",
13037 label: (0, import_i18n55.__)("Description"),
13038 getValue: ({ item }) => getRawContent(item?.description),
13039 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { children: getRawContent(item?.description) || "-" }),
13040 Edit: ({ field, onChange, data }) => {
13041 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
13042 import_components24.TextareaControl,
13043 {
13044 label: field.label,
13045 value: getRawContent(data.description) || "",
13046 onChange: (value) => onChange({ description: value }),
13047 rows: 5
13048 }
13049 );
13050 },
13051 enableSorting: false,
13052 filterBy: false
13053 };
13054 var description_default = descriptionField;
13055
13056 // packages/media-fields/build-module/filename/index.mjs
13057 var import_i18n56 = __toESM(require_i18n(), 1);
13058 var import_url10 = __toESM(require_url(), 1);
13059
13060 // packages/media-fields/build-module/filename/view.mjs
13061 var import_components25 = __toESM(require_components(), 1);
13062 var import_element24 = __toESM(require_element(), 1);
13063 var import_url9 = __toESM(require_url(), 1);
13064 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
13065 var TRUNCATE_LENGTH = 15;
13066 function FileNameView({
13067 item
13068 }) {
13069 const fileName = (0, import_element24.useMemo)(
13070 () => item?.source_url ? (0, import_url9.getFilename)(item.source_url) : null,
13071 [item?.source_url]
13072 );
13073 if (!fileName) {
13074 return "";
13075 }
13076 return fileName.length > TRUNCATE_LENGTH ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components25.Tooltip, { text: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components25.__experimentalTruncate, { limit: TRUNCATE_LENGTH, ellipsizeMode: "tail", children: fileName }) }) : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_jsx_runtime109.Fragment, { children: fileName });
13077 }
13078
13079 // packages/media-fields/build-module/filename/index.mjs
13080 var filenameField = {
13081 id: "filename",
13082 type: "text",
13083 label: (0, import_i18n56.__)("File name"),
13084 getValue: ({ item }) => (0, import_url10.getFilename)(item?.source_url || ""),
13085 render: FileNameView,
13086 enableSorting: false,
13087 filterBy: false,
13088 readOnly: true
13089 };
13090 var filename_default = filenameField;
13091
13092 // packages/media-fields/build-module/filesize/index.mjs
13093 var import_i18n57 = __toESM(require_i18n(), 1);
13094 var KB_IN_BYTES = 1024;
13095 var MB_IN_BYTES = 1024 * KB_IN_BYTES;
13096 var GB_IN_BYTES = 1024 * MB_IN_BYTES;
13097 var TB_IN_BYTES = 1024 * GB_IN_BYTES;
13098 var PB_IN_BYTES = 1024 * TB_IN_BYTES;
13099 var EB_IN_BYTES = 1024 * PB_IN_BYTES;
13100 var ZB_IN_BYTES = 1024 * EB_IN_BYTES;
13101 var YB_IN_BYTES = 1024 * ZB_IN_BYTES;
13102 function getBytesString(bytes, unitSymbol, decimals = 2) {
13103 return (0, import_i18n57.sprintf)(
13104 // translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).
13105 (0, import_i18n57._x)("%1$s %2$s", "file size"),
13106 bytes.toLocaleString(void 0, {
13107 minimumFractionDigits: 0,
13108 maximumFractionDigits: decimals
13109 }),
13110 unitSymbol
13111 );
13112 }
13113 function formatFileSize(bytes, decimals = 2) {
13114 if (bytes === 0) {
13115 return getBytesString(0, (0, import_i18n57._x)("B", "unit symbol"), decimals);
13116 }
13117 const quant = {
13118 /* translators: Unit symbol for yottabyte. */
13119 [(0, import_i18n57._x)("YB", "unit symbol")]: YB_IN_BYTES,
13120 /* translators: Unit symbol for zettabyte. */
13121 [(0, import_i18n57._x)("ZB", "unit symbol")]: ZB_IN_BYTES,
13122 /* translators: Unit symbol for exabyte. */
13123 [(0, import_i18n57._x)("EB", "unit symbol")]: EB_IN_BYTES,
13124 /* translators: Unit symbol for petabyte. */
13125 [(0, import_i18n57._x)("PB", "unit symbol")]: PB_IN_BYTES,
13126 /* translators: Unit symbol for terabyte. */
13127 [(0, import_i18n57._x)("TB", "unit symbol")]: TB_IN_BYTES,
13128 /* translators: Unit symbol for gigabyte. */
13129 [(0, import_i18n57._x)("GB", "unit symbol")]: GB_IN_BYTES,
13130 /* translators: Unit symbol for megabyte. */
13131 [(0, import_i18n57._x)("MB", "unit symbol")]: MB_IN_BYTES,
13132 /* translators: Unit symbol for kilobyte. */
13133 [(0, import_i18n57._x)("KB", "unit symbol")]: KB_IN_BYTES,
13134 /* translators: Unit symbol for byte. */
13135 [(0, import_i18n57._x)("B", "unit symbol")]: 1
13136 };
13137 for (const [unit, mag] of Object.entries(quant)) {
13138 if (bytes >= mag) {
13139 return getBytesString(bytes / mag, unit, decimals);
13140 }
13141 }
13142 return "";
13143 }
13144 var filesizeField = {
13145 id: "filesize",
13146 type: "text",
13147 label: (0, import_i18n57.__)("File size"),
13148 getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "",
13149 isVisible: (item) => {
13150 return !!item?.media_details?.filesize;
13151 },
13152 enableSorting: false,
13153 filterBy: false,
13154 readOnly: true
13155 };
13156 var filesize_default = filesizeField;
13157
13158 // packages/media-fields/build-module/media_dimensions/index.mjs
13159 var import_i18n58 = __toESM(require_i18n(), 1);
13160 var mediaDimensionsField = {
13161 id: "media_dimensions",
13162 type: "text",
13163 label: (0, import_i18n58.__)("Dimensions"),
13164 getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, import_i18n58.sprintf)(
13165 // translators: 1: Width. 2: Height.
13166 (0, import_i18n58._x)("%1$s \xD7 %2$s", "image dimensions"),
13167 item?.media_details?.width?.toString(),
13168 item?.media_details?.height?.toString()
13169 ) : "",
13170 isVisible: (item) => {
13171 return !!(item?.media_details?.width && item?.media_details?.height);
13172 },
13173 enableSorting: false,
13174 filterBy: false,
13175 readOnly: true
13176 };
13177 var media_dimensions_default = mediaDimensionsField;
13178
13179 // packages/media-fields/build-module/mime_type/index.mjs
13180 var import_i18n59 = __toESM(require_i18n(), 1);
13181 var mimeTypeField = {
13182 id: "mime_type",
13183 type: "text",
13184 label: (0, import_i18n59.__)("File type"),
13185 getValue: ({ item }) => item?.mime_type || "",
13186 render: ({ item }) => item?.mime_type || "-",
13187 // Disable sorting until REST API support for ordering my `mime_type` is added.
13188 // See: https://core.trac.wordpress.org/ticket/64073
13189 enableSorting: false,
13190 filterBy: false,
13191 readOnly: true
13192 };
13193 var mime_type_default = mimeTypeField;
13194
13195 // packages/editor/build-module/dataviews/fields/content-preview/index.mjs
13196 var import_i18n121 = __toESM(require_i18n(), 1);
13197
13198 // packages/editor/build-module/dataviews/fields/content-preview/content-preview-view.mjs
13199 var import_i18n120 = __toESM(require_i18n(), 1);
13200 var import_block_editor34 = __toESM(require_block_editor(), 1);
13201 var import_data71 = __toESM(require_data(), 1);
13202 var import_core_data51 = __toESM(require_core_data(), 1);
13203
13204 // packages/editor/build-module/components/provider/index.mjs
13205 var import_element47 = __toESM(require_element(), 1);
13206 var import_data55 = __toESM(require_data(), 1);
13207 var import_i18n74 = __toESM(require_i18n(), 1);
13208 var import_core_data37 = __toESM(require_core_data(), 1);
13209 var import_block_editor18 = __toESM(require_block_editor(), 1);
13210 var import_notices16 = __toESM(require_notices(), 1);
13211 var import_patterns7 = __toESM(require_patterns(), 1);
13212 var import_blocks14 = __toESM(require_blocks(), 1);
13213
13214 // packages/editor/build-module/components/provider/with-registry-provider.mjs
13215 var import_element25 = __toESM(require_element(), 1);
13216 var import_data28 = __toESM(require_data(), 1);
13217 var import_compose5 = __toESM(require_compose(), 1);
13218 var import_block_editor5 = __toESM(require_block_editor(), 1);
13219 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
13220 function getSubRegistry(subRegistries, registry, useSubRegistry) {
13221 if (!useSubRegistry) {
13222 return registry;
13223 }
13224 let subRegistry = subRegistries.get(registry);
13225 if (!subRegistry) {
13226 subRegistry = (0, import_data28.createRegistry)(
13227 {
13228 "core/block-editor": import_block_editor5.storeConfig
13229 },
13230 registry
13231 );
13232 subRegistry.registerStore("core/editor", storeConfig);
13233 subRegistries.set(registry, subRegistry);
13234 }
13235 return subRegistry;
13236 }
13237 var withRegistryProvider = (0, import_compose5.createHigherOrderComponent)(
13238 (WrappedComponent) => ({ useSubRegistry = true, ...props }) => {
13239 const registry = (0, import_data28.useRegistry)();
13240 const [subRegistries] = (0, import_element25.useState)(() => /* @__PURE__ */ new WeakMap());
13241 const subRegistry = getSubRegistry(
13242 subRegistries,
13243 registry,
13244 useSubRegistry
13245 );
13246 if (subRegistry === registry) {
13247 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(WrappedComponent, { registry, ...props });
13248 }
13249 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_data28.RegistryProvider, { value: subRegistry, children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(WrappedComponent, { registry: subRegistry, ...props }) });
13250 },
13251 "withRegistryProvider"
13252 );
13253 var with_registry_provider_default = withRegistryProvider;
13254
13255 // packages/editor/build-module/components/provider/use-block-editor-settings.mjs
13256 var import_element27 = __toESM(require_element(), 1);
13257 var import_data33 = __toESM(require_data(), 1);
13258 var import_core_data29 = __toESM(require_core_data(), 1);
13259 var import_i18n62 = __toESM(require_i18n(), 1);
13260 var import_preferences4 = __toESM(require_preferences(), 1);
13261 var import_compose6 = __toESM(require_compose(), 1);
13262 var import_blocks8 = __toESM(require_blocks(), 1);
13263 var import_block_editor7 = __toESM(require_block_editor(), 1);
13264
13265 // packages/editor/build-module/components/media-categories/index.mjs
13266 var import_i18n60 = __toESM(require_i18n(), 1);
13267 var import_data29 = __toESM(require_data(), 1);
13268 var import_html_entities6 = __toESM(require_html_entities(), 1);
13269 var import_core_data26 = __toESM(require_core_data(), 1);
13270 var getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`;
13271 var getExternalLinkAttributes = (url) => `href="${url}" target="_blank" rel="noreferrer noopener"`;
13272 var getOpenverseLicense = (license, licenseVersion) => {
13273 let licenseName = license.trim();
13274 if (license !== "pdm") {
13275 licenseName = license.toUpperCase().replace("SAMPLING", "Sampling");
13276 }
13277 if (licenseVersion) {
13278 licenseName += ` ${licenseVersion}`;
13279 }
13280 if (!["pdm", "cc0"].includes(license)) {
13281 licenseName = `CC ${licenseName}`;
13282 }
13283 return licenseName;
13284 };
13285 var getOpenverseCaption = (item) => {
13286 const {
13287 title,
13288 foreign_landing_url: foreignLandingUrl,
13289 creator,
13290 creator_url: creatorUrl,
13291 license,
13292 license_version: licenseVersion,
13293 license_url: licenseUrl
13294 } = item;
13295 const fullLicense = getOpenverseLicense(license, licenseVersion);
13296 const _creator = (0, import_html_entities6.decodeEntities)(creator);
13297 let _caption;
13298 if (_creator) {
13299 _caption = title ? (0, import_i18n60.sprintf)(
13300 // translators: %1s: Title of a media work from Openverse; %2$s: Name of the work's creator; %3s: Work's licence e.g: "CC0 1.0".
13301 (0, import_i18n60._x)('"%1$s" by %2$s/ %3$s', "caption"),
13302 getExternalLink(
13303 foreignLandingUrl,
13304 (0, import_html_entities6.decodeEntities)(title)
13305 ),
13306 creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator,
13307 licenseUrl ? getExternalLink(
13308 `${licenseUrl}?ref=openverse`,
13309 fullLicense
13310 ) : fullLicense
13311 ) : (0, import_i18n60.sprintf)(
13312 // translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: "CC0 1.0".
13313 (0, import_i18n60._x)("<a %1$s>Work</a> by %2$s/ %3$s", "caption"),
13314 getExternalLinkAttributes(foreignLandingUrl),
13315 creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator,
13316 licenseUrl ? getExternalLink(
13317 `${licenseUrl}?ref=openverse`,
13318 fullLicense
13319 ) : fullLicense
13320 );
13321 } else {
13322 _caption = title ? (0, import_i18n60.sprintf)(
13323 // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
13324 (0, import_i18n60._x)('"%1$s"/ %2$s', "caption"),
13325 getExternalLink(
13326 foreignLandingUrl,
13327 (0, import_html_entities6.decodeEntities)(title)
13328 ),
13329 licenseUrl ? getExternalLink(
13330 `${licenseUrl}?ref=openverse`,
13331 fullLicense
13332 ) : fullLicense
13333 ) : (0, import_i18n60.sprintf)(
13334 // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
13335 (0, import_i18n60._x)("<a %1$s>Work</a>/ %2$s", "caption"),
13336 getExternalLinkAttributes(foreignLandingUrl),
13337 licenseUrl ? getExternalLink(
13338 `${licenseUrl}?ref=openverse`,
13339 fullLicense
13340 ) : fullLicense
13341 );
13342 }
13343 return _caption.replace(/\s{2}/g, " ");
13344 };
13345 var coreMediaFetch = async (query = {}) => {
13346 const mediaItems = await (0, import_data29.resolveSelect)(import_core_data26.store).getEntityRecords(
13347 "postType",
13348 "attachment",
13349 {
13350 ...query,
13351 orderBy: !!query?.search ? "relevance" : "date"
13352 }
13353 );
13354 return mediaItems.map((mediaItem) => ({
13355 ...mediaItem,
13356 alt: mediaItem.alt_text,
13357 url: mediaItem.source_url,
13358 previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
13359 caption: mediaItem.caption?.raw
13360 }));
13361 };
13362 var inserterMediaCategories = [
13363 {
13364 name: "images",
13365 labels: {
13366 name: (0, import_i18n60.__)("Images"),
13367 search_items: (0, import_i18n60.__)("Search images")
13368 },
13369 mediaType: "image",
13370 async fetch(query = {}) {
13371 return coreMediaFetch({ ...query, media_type: "image" });
13372 }
13373 },
13374 {
13375 name: "videos",
13376 labels: {
13377 name: (0, import_i18n60.__)("Videos"),
13378 search_items: (0, import_i18n60.__)("Search videos")
13379 },
13380 mediaType: "video",
13381 async fetch(query = {}) {
13382 return coreMediaFetch({ ...query, media_type: "video" });
13383 }
13384 },
13385 {
13386 name: "audio",
13387 labels: {
13388 name: (0, import_i18n60.__)("Audio"),
13389 search_items: (0, import_i18n60.__)("Search audio")
13390 },
13391 mediaType: "audio",
13392 async fetch(query = {}) {
13393 return coreMediaFetch({ ...query, media_type: "audio" });
13394 }
13395 },
13396 {
13397 name: "openverse",
13398 labels: {
13399 name: (0, import_i18n60.__)("Openverse"),
13400 search_items: (0, import_i18n60.__)("Search Openverse")
13401 },
13402 mediaType: "image",
13403 async fetch(query = {}) {
13404 const defaultArgs = {
13405 mature: false,
13406 excluded_source: "flickr,inaturalist,wikimedia",
13407 license: "pdm,cc0"
13408 };
13409 const finalQuery = { ...query, ...defaultArgs };
13410 const mapFromInserterMediaRequest = {
13411 per_page: "page_size",
13412 search: "q"
13413 };
13414 const url = new URL("https://api.openverse.org/v1/images/");
13415 Object.entries(finalQuery).forEach(([key, value]) => {
13416 const queryKey = mapFromInserterMediaRequest[key] || key;
13417 url.searchParams.set(queryKey, value);
13418 });
13419 const response = await window.fetch(url, {
13420 headers: {
13421 "User-Agent": "WordPress/inserter-media-fetch"
13422 }
13423 });
13424 const jsonResponse = await response.json();
13425 const results = jsonResponse.results;
13426 return results.map((result) => ({
13427 ...result,
13428 // This is a temp solution for better titles, until Openverse API
13429 // completes the cleaning up of some titles of their upstream data.
13430 title: result.title?.toLowerCase().startsWith("file:") ? result.title.slice(5) : result.title,
13431 sourceId: result.id,
13432 id: void 0,
13433 caption: getOpenverseCaption(result),
13434 previewUrl: result.thumbnail
13435 }));
13436 },
13437 getReportUrl: ({ sourceId }) => `https://wordpress.org/openverse/image/${sourceId}/report/`,
13438 isExternalResource: true
13439 }
13440 ];
13441 var media_categories_default = inserterMediaCategories;
13442
13443 // packages/editor/build-module/utils/media-upload/on-success.mjs
13444 var import_data30 = __toESM(require_data(), 1);
13445 var import_core_data27 = __toESM(require_core_data(), 1);
13446 function mediaUploadOnSuccess(attachments) {
13447 const { invalidateResolution } = (0, import_data30.dispatch)(import_core_data27.store);
13448 for (const attachment of attachments) {
13449 if (attachment.id) {
13450 invalidateResolution("getEntityRecord", [
13451 "postType",
13452 "attachment",
13453 attachment.id,
13454 { context: "view" }
13455 ]);
13456 invalidateResolution("getEntityRecord", [
13457 "postType",
13458 "attachment",
13459 attachment.id
13460 ]);
13461 }
13462 }
13463 }
13464
13465 // packages/editor/build-module/utils/media-sideload/index.mjs
13466 var import_media_utils3 = __toESM(require_media_utils(), 1);
13467 var { sideloadMedia: mediaSideload } = unlock(import_media_utils3.privateApis);
13468 var media_sideload_default = mediaSideload;
13469
13470 // packages/editor/build-module/utils/media-finalize/index.mjs
13471 var import_api_fetch3 = __toESM(require_api_fetch(), 1);
13472 async function mediaFinalize(id) {
13473 await (0, import_api_fetch3.default)({
13474 path: `/wp/v2/media/${id}/finalize`,
13475 method: "POST"
13476 });
13477 }
13478
13479 // packages/editor/build-module/components/global-styles-provider/index.mjs
13480 var import_block_editor6 = __toESM(require_block_editor(), 1);
13481 var import_core_data28 = __toESM(require_core_data(), 1);
13482 var import_data32 = __toESM(require_data(), 1);
13483 var import_element26 = __toESM(require_element(), 1);
13484
13485 // packages/global-styles-engine/build-module/utils/object.mjs
13486 function setImmutably(object, path, value) {
13487 path = Array.isArray(path) ? [...path] : [path];
13488 object = Array.isArray(object) ? [...object] : { ...object };
13489 const leaf = path.pop();
13490 let prev = object;
13491 for (const key of path) {
13492 const lvl = prev[key];
13493 prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl };
13494 }
13495 prev[leaf] = value;
13496 return object;
13497 }
13498 var getValueFromObjectPath = (object, path, defaultValue) => {
13499 const arrayPath = Array.isArray(path) ? path : path.split(".");
13500 let value = object;
13501 arrayPath.forEach((fieldName) => {
13502 value = value?.[fieldName];
13503 });
13504 return value ?? defaultValue;
13505 };
13506
13507 // packages/global-styles-engine/build-module/settings/get-setting.mjs
13508 var VALID_SETTINGS = [
13509 "appearanceTools",
13510 "useRootPaddingAwareAlignments",
13511 "background.backgroundImage",
13512 "background.backgroundRepeat",
13513 "background.backgroundSize",
13514 "background.backgroundPosition",
13515 "border.color",
13516 "border.radius",
13517 "border.radiusSizes",
13518 "border.style",
13519 "border.width",
13520 "shadow.presets",
13521 "shadow.defaultPresets",
13522 "color.background",
13523 "color.button",
13524 "color.caption",
13525 "color.custom",
13526 "color.customDuotone",
13527 "color.customGradient",
13528 "color.defaultDuotone",
13529 "color.defaultGradients",
13530 "color.defaultPalette",
13531 "color.duotone",
13532 "color.gradients",
13533 "color.heading",
13534 "color.link",
13535 "color.palette",
13536 "color.text",
13537 "custom",
13538 "dimensions.aspectRatio",
13539 "dimensions.height",
13540 "dimensions.minHeight",
13541 "dimensions.width",
13542 "dimensions.dimensionSizes",
13543 "layout.contentSize",
13544 "layout.definitions",
13545 "layout.wideSize",
13546 "lightbox.enabled",
13547 "lightbox.allowEditing",
13548 "position.fixed",
13549 "position.sticky",
13550 "spacing.customSpacingSize",
13551 "spacing.defaultSpacingSizes",
13552 "spacing.spacingSizes",
13553 "spacing.spacingScale",
13554 "spacing.blockGap",
13555 "spacing.margin",
13556 "spacing.padding",
13557 "spacing.units",
13558 "typography.fluid",
13559 "typography.customFontSize",
13560 "typography.defaultFontSizes",
13561 "typography.dropCap",
13562 "typography.fontFamilies",
13563 "typography.fontSizes",
13564 "typography.fontStyle",
13565 "typography.fontWeight",
13566 "typography.letterSpacing",
13567 "typography.lineHeight",
13568 "typography.textAlign",
13569 "typography.textColumns",
13570 "typography.textDecoration",
13571 "typography.textIndent",
13572 "typography.textTransform",
13573 "typography.writingMode"
13574 ];
13575 function getSetting(globalStyles, path, blockName) {
13576 const appendedBlockPath = blockName ? ".blocks." + blockName : "";
13577 const appendedPropertyPath = path ? "." + path : "";
13578 const contextualPath = `settings${appendedBlockPath}${appendedPropertyPath}`;
13579 const globalPath = `settings${appendedPropertyPath}`;
13580 if (path) {
13581 return getValueFromObjectPath(globalStyles, contextualPath) ?? getValueFromObjectPath(globalStyles, globalPath);
13582 }
13583 let result = {};
13584 VALID_SETTINGS.forEach((setting) => {
13585 const value = getValueFromObjectPath(
13586 globalStyles,
13587 `settings${appendedBlockPath}.${setting}`
13588 ) ?? getValueFromObjectPath(globalStyles, `settings.${setting}`);
13589 if (value !== void 0) {
13590 result = setImmutably(result, setting.split("."), value);
13591 }
13592 });
13593 return result;
13594 }
13595
13596 // packages/global-styles-engine/build-module/settings/set-setting.mjs
13597 function setSetting(globalStyles, path, newValue, blockName) {
13598 const appendedBlockPath = blockName ? ".blocks." + blockName : "";
13599 const appendedPropertyPath = path ? "." + path : "";
13600 const finalPath = `settings${appendedBlockPath}${appendedPropertyPath}`;
13601 return setImmutably(
13602 globalStyles,
13603 finalPath.split("."),
13604 newValue
13605 );
13606 }
13607
13608 // packages/global-styles-engine/build-module/utils/common.mjs
13609 var import_style_engine = __toESM(require_style_engine(), 1);
13610
13611 // packages/global-styles-engine/build-module/utils/fluid.mjs
13612 var DEFAULT_MAXIMUM_VIEWPORT_WIDTH = "1600px";
13613 var DEFAULT_MINIMUM_VIEWPORT_WIDTH = "320px";
13614 var DEFAULT_SCALE_FACTOR = 1;
13615 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;
13616 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;
13617 var DEFAULT_MINIMUM_FONT_SIZE_LIMIT = "14px";
13618 function getComputedFluidTypographyValue({
13619 minimumFontSize,
13620 maximumFontSize,
13621 fontSize,
13622 minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
13623 maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
13624 scaleFactor = DEFAULT_SCALE_FACTOR,
13625 minimumFontSizeLimit
13626 }) {
13627 minimumFontSizeLimit = !!getTypographyValueAndUnit(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT;
13628 if (fontSize) {
13629 const fontSizeParsed = getTypographyValueAndUnit(fontSize);
13630 if (!fontSizeParsed?.unit || !fontSizeParsed?.value) {
13631 return null;
13632 }
13633 const minimumFontSizeLimitParsed = getTypographyValueAndUnit(
13634 minimumFontSizeLimit,
13635 {
13636 coerceTo: fontSizeParsed.unit
13637 }
13638 );
13639 if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) {
13640 if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) {
13641 return null;
13642 }
13643 }
13644 if (!maximumFontSize) {
13645 maximumFontSize = `${fontSizeParsed.value}${fontSizeParsed.unit}`;
13646 }
13647 if (!minimumFontSize) {
13648 const fontSizeValueInPx = fontSizeParsed.unit === "px" ? fontSizeParsed.value : fontSizeParsed.value * 16;
13649 const minimumFontSizeFactor = Math.min(
13650 Math.max(
13651 1 - 0.075 * Math.log2(fontSizeValueInPx),
13652 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN
13653 ),
13654 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX
13655 );
13656 const calculatedMinimumFontSize = roundToPrecision(
13657 fontSizeParsed.value * minimumFontSizeFactor,
13658 3
13659 );
13660 if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) {
13661 minimumFontSize = `${minimumFontSizeLimitParsed.value}${minimumFontSizeLimitParsed.unit}`;
13662 } else {
13663 minimumFontSize = `${calculatedMinimumFontSize}${fontSizeParsed.unit}`;
13664 }
13665 }
13666 }
13667 const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize);
13668 const fontSizeUnit = minimumFontSizeParsed?.unit || "rem";
13669 const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, {
13670 coerceTo: fontSizeUnit
13671 });
13672 if (!minimumFontSizeParsed || !maximumFontSizeParsed) {
13673 return null;
13674 }
13675 const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, {
13676 coerceTo: "rem"
13677 });
13678 const maximumViewportWidthParsed = getTypographyValueAndUnit(
13679 maximumViewportWidth,
13680 { coerceTo: fontSizeUnit }
13681 );
13682 const minimumViewportWidthParsed = getTypographyValueAndUnit(
13683 minimumViewportWidth,
13684 { coerceTo: fontSizeUnit }
13685 );
13686 if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) {
13687 return null;
13688 }
13689 const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value;
13690 if (!linearDenominator) {
13691 return null;
13692 }
13693 const minViewportWidthOffsetValue = roundToPrecision(
13694 minimumViewportWidthParsed.value / 100,
13695 3
13696 );
13697 const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit;
13698 const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator);
13699 const linearFactorScaled = roundToPrecision(
13700 (linearFactor || 1) * scaleFactor,
13701 3
13702 );
13703 const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewportWidthOffset}) * ${linearFactorScaled})`;
13704 return `clamp(${minimumFontSize}, ${fluidTargetFontSize}, ${maximumFontSize})`;
13705 }
13706 function getTypographyValueAndUnit(rawValue, options = {}) {
13707 if (typeof rawValue !== "string" && typeof rawValue !== "number") {
13708 return null;
13709 }
13710 if (isFinite(rawValue)) {
13711 rawValue = `${rawValue}px`;
13712 }
13713 const { coerceTo, rootSizeValue, acceptableUnits } = {
13714 coerceTo: "",
13715 // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`.
13716 rootSizeValue: 16,
13717 acceptableUnits: ["rem", "px", "em"],
13718 ...options
13719 };
13720 const acceptableUnitsGroup = acceptableUnits?.join("|");
13721 const regexUnits = new RegExp(
13722 `^(\\d*\\.?\\d+)(${acceptableUnitsGroup}){1,1}$`
13723 );
13724 const matches = rawValue.toString().match(regexUnits);
13725 if (!matches || matches.length < 3) {
13726 return null;
13727 }
13728 let [, value, unit] = matches;
13729 let returnValue = parseFloat(value);
13730 if ("px" === coerceTo && ("em" === unit || "rem" === unit)) {
13731 returnValue = returnValue * rootSizeValue;
13732 unit = coerceTo;
13733 }
13734 if ("px" === unit && ("em" === coerceTo || "rem" === coerceTo)) {
13735 returnValue = returnValue / rootSizeValue;
13736 unit = coerceTo;
13737 }
13738 if (("em" === coerceTo || "rem" === coerceTo) && ("em" === unit || "rem" === unit)) {
13739 unit = coerceTo;
13740 }
13741 if (!unit) {
13742 return null;
13743 }
13744 return {
13745 value: roundToPrecision(returnValue, 3),
13746 unit
13747 };
13748 }
13749 function roundToPrecision(value, digits = 3) {
13750 const base = Math.pow(10, digits);
13751 return Math.round(value * base) / base;
13752 }
13753
13754 // packages/global-styles-engine/build-module/utils/typography.mjs
13755 function isFluidTypographyEnabled(typographySettings) {
13756 const fluidSettings = typographySettings?.fluid;
13757 return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0;
13758 }
13759 function getFluidTypographyOptionsFromSettings(settings) {
13760 const typographySettings = settings?.typography ?? {};
13761 const layoutSettings = settings?.layout;
13762 const defaultMaxViewportWidth = getTypographyValueAndUnit(
13763 layoutSettings?.wideSize
13764 ) ? layoutSettings?.wideSize : null;
13765 return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? {
13766 fluid: {
13767 maxViewportWidth: defaultMaxViewportWidth,
13768 ...typeof typographySettings.fluid === "object" ? typographySettings.fluid : {}
13769 }
13770 } : {
13771 fluid: typographySettings?.fluid
13772 };
13773 }
13774 function getTypographyFontSizeValue(preset, settings) {
13775 const { size: defaultSize } = preset;
13776 if (!defaultSize || "0" === defaultSize || false === preset?.fluid) {
13777 return defaultSize;
13778 }
13779 if (!isFluidTypographyEnabled(settings?.typography) && !isFluidTypographyEnabled(preset)) {
13780 return defaultSize;
13781 }
13782 const fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings)?.fluid ?? {};
13783 const fluidFontSizeValue = getComputedFluidTypographyValue({
13784 minimumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.min,
13785 maximumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.max,
13786 fontSize: defaultSize,
13787 minimumFontSizeLimit: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minFontSize : void 0,
13788 maximumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.maxViewportWidth : void 0,
13789 minimumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minViewportWidth : void 0
13790 });
13791 if (!!fluidFontSizeValue) {
13792 return fluidFontSizeValue;
13793 }
13794 return defaultSize;
13795 }
13796
13797 // packages/global-styles-engine/build-module/utils/common.mjs
13798 var ROOT_BLOCK_SELECTOR = "body";
13799 var ROOT_CSS_PROPERTIES_SELECTOR = ":root";
13800 var PRESET_METADATA = [
13801 {
13802 path: ["color", "palette"],
13803 valueKey: "color",
13804 cssVarInfix: "color",
13805 classes: [
13806 { classSuffix: "color", propertyName: "color" },
13807 {
13808 classSuffix: "background-color",
13809 propertyName: "background-color"
13810 },
13811 {
13812 classSuffix: "border-color",
13813 propertyName: "border-color"
13814 }
13815 ]
13816 },
13817 {
13818 path: ["color", "gradients"],
13819 valueKey: "gradient",
13820 cssVarInfix: "gradient",
13821 classes: [
13822 {
13823 classSuffix: "gradient-background",
13824 propertyName: "background"
13825 }
13826 ]
13827 },
13828 {
13829 path: ["color", "duotone"],
13830 valueKey: "colors",
13831 cssVarInfix: "duotone",
13832 valueFunc: ({ slug }) => `url( '#wp-duotone-${slug}' )`,
13833 classes: []
13834 },
13835 {
13836 path: ["shadow", "presets"],
13837 valueKey: "shadow",
13838 cssVarInfix: "shadow",
13839 classes: []
13840 },
13841 {
13842 path: ["typography", "fontSizes"],
13843 valueFunc: (preset, settings) => getTypographyFontSizeValue(preset, settings),
13844 valueKey: "size",
13845 cssVarInfix: "font-size",
13846 classes: [{ classSuffix: "font-size", propertyName: "font-size" }]
13847 },
13848 {
13849 path: ["typography", "fontFamilies"],
13850 valueKey: "fontFamily",
13851 cssVarInfix: "font-family",
13852 classes: [
13853 { classSuffix: "font-family", propertyName: "font-family" }
13854 ]
13855 },
13856 {
13857 path: ["spacing", "spacingSizes"],
13858 valueKey: "size",
13859 cssVarInfix: "spacing",
13860 valueFunc: ({ size: size3 }) => size3,
13861 classes: []
13862 },
13863 {
13864 path: ["border", "radiusSizes"],
13865 valueKey: "size",
13866 cssVarInfix: "border-radius",
13867 classes: []
13868 },
13869 {
13870 path: ["dimensions", "dimensionSizes"],
13871 valueKey: "size",
13872 cssVarInfix: "dimension",
13873 classes: []
13874 }
13875 ];
13876 function scopeSelector(scope, selector) {
13877 if (!scope || !selector) {
13878 return selector;
13879 }
13880 const scopes = scope.split(",");
13881 const selectors = selector.split(",");
13882 const selectorsScoped = [];
13883 scopes.forEach((outer) => {
13884 selectors.forEach((inner) => {
13885 selectorsScoped.push(`${outer.trim()} ${inner.trim()}`);
13886 });
13887 });
13888 return selectorsScoped.join(", ");
13889 }
13890 function scopeFeatureSelectors(scope, selectors) {
13891 if (!scope || !selectors) {
13892 return;
13893 }
13894 const featureSelectors = {};
13895 Object.entries(selectors).forEach(([feature, selector]) => {
13896 if (typeof selector === "string") {
13897 featureSelectors[feature] = scopeSelector(scope, selector);
13898 }
13899 if (typeof selector === "object") {
13900 featureSelectors[feature] = {};
13901 Object.entries(selector).forEach(
13902 ([subfeature, subfeatureSelector]) => {
13903 featureSelectors[feature][subfeature] = scopeSelector(
13904 scope,
13905 subfeatureSelector
13906 );
13907 }
13908 );
13909 }
13910 });
13911 return featureSelectors;
13912 }
13913 function appendToSelector(selector, toAppend) {
13914 if (!selector.includes(",")) {
13915 return selector + toAppend;
13916 }
13917 const selectors = selector.split(",");
13918 const newSelectors = selectors.map((sel) => sel + toAppend);
13919 return newSelectors.join(",");
13920 }
13921 function getBlockStyleVariationSelector(variation, blockSelector) {
13922 const variationClass = `.is-style-${variation}`;
13923 if (!blockSelector) {
13924 return variationClass;
13925 }
13926 const ancestorRegex = /((?::\([^)]+\))?\s*)([^\s:]+)/;
13927 const addVariationClass = (_match, group1, group2) => {
13928 return group1 + group2 + variationClass;
13929 };
13930 const result = blockSelector.split(",").map((part) => part.replace(ancestorRegex, addVariationClass));
13931 return result.join(",");
13932 }
13933 function getResolvedRefValue(ruleValue, tree) {
13934 if (!ruleValue || !tree) {
13935 return ruleValue;
13936 }
13937 if (typeof ruleValue === "object" && "ref" in ruleValue && ruleValue?.ref) {
13938 const resolvedRuleValue = (0, import_style_engine.getCSSValueFromRawStyle)(
13939 getValueFromObjectPath(tree, ruleValue.ref)
13940 );
13941 if (typeof resolvedRuleValue === "object" && resolvedRuleValue !== null && "ref" in resolvedRuleValue && resolvedRuleValue?.ref) {
13942 return void 0;
13943 }
13944 if (resolvedRuleValue === void 0) {
13945 return ruleValue;
13946 }
13947 return resolvedRuleValue;
13948 }
13949 return ruleValue;
13950 }
13951 function getResolvedThemeFilePath(file, themeFileURIs) {
13952 if (!file || !themeFileURIs || !Array.isArray(themeFileURIs)) {
13953 return file;
13954 }
13955 const uri = themeFileURIs.find(
13956 (themeFileUri) => themeFileUri?.name === file
13957 );
13958 if (!uri?.href) {
13959 return file;
13960 }
13961 return uri?.href;
13962 }
13963 function getResolvedValue(ruleValue, tree) {
13964 if (!ruleValue || !tree) {
13965 return ruleValue;
13966 }
13967 const resolvedValue = getResolvedRefValue(ruleValue, tree);
13968 if (typeof resolvedValue === "object" && resolvedValue !== null && "url" in resolvedValue && resolvedValue?.url) {
13969 resolvedValue.url = getResolvedThemeFilePath(
13970 resolvedValue.url,
13971 tree?._links?.["wp:theme-file"]
13972 );
13973 }
13974 return resolvedValue;
13975 }
13976 function findInPresetsBy(settings, blockName, presetPath = [], presetProperty = "slug", presetValueValue) {
13977 const orderedPresetsByOrigin = [
13978 blockName ? getValueFromObjectPath(settings, [
13979 "blocks",
13980 blockName,
13981 ...presetPath
13982 ]) : void 0,
13983 getValueFromObjectPath(settings, presetPath)
13984 ].filter(Boolean);
13985 for (const presetByOrigin of orderedPresetsByOrigin) {
13986 if (presetByOrigin) {
13987 const origins = ["custom", "theme", "default"];
13988 for (const origin of origins) {
13989 const presets = presetByOrigin[origin];
13990 if (presets) {
13991 const presetObject = presets.find(
13992 (preset) => preset[presetProperty] === presetValueValue
13993 );
13994 if (presetObject) {
13995 if (presetProperty === "slug") {
13996 return presetObject;
13997 }
13998 const highestPresetObjectWithSameSlug = findInPresetsBy(
13999 settings,
14000 blockName,
14001 presetPath,
14002 "slug",
14003 presetObject.slug
14004 );
14005 if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) {
14006 return presetObject;
14007 }
14008 return void 0;
14009 }
14010 }
14011 }
14012 }
14013 }
14014 }
14015 function getValueFromPresetVariable(features, blockName, variable, [presetType, slug] = []) {
14016 const metadata = PRESET_METADATA.find(
14017 (data) => data.cssVarInfix === presetType
14018 );
14019 if (!metadata || !features.settings) {
14020 return variable;
14021 }
14022 const presetObject = findInPresetsBy(
14023 features.settings,
14024 blockName,
14025 metadata.path,
14026 "slug",
14027 slug
14028 );
14029 if (presetObject) {
14030 const { valueKey } = metadata;
14031 const result = presetObject[valueKey];
14032 return getValueFromVariable(features, blockName, result);
14033 }
14034 return variable;
14035 }
14036 function getValueFromCustomVariable(features, blockName, variable, path = []) {
14037 const result = (blockName ? getValueFromObjectPath(features?.settings ?? {}, [
14038 "blocks",
14039 blockName,
14040 "custom",
14041 ...path
14042 ]) : void 0) ?? getValueFromObjectPath(features?.settings ?? {}, [
14043 "custom",
14044 ...path
14045 ]);
14046 if (!result) {
14047 return variable;
14048 }
14049 return getValueFromVariable(features, blockName, result);
14050 }
14051 function getValueFromVariable(features, blockName, variable) {
14052 if (!variable || typeof variable !== "string") {
14053 if (typeof variable === "object" && variable !== null && "ref" in variable && typeof variable.ref === "string") {
14054 const resolvedVariable = getValueFromObjectPath(
14055 features,
14056 variable.ref
14057 );
14058 if (!resolvedVariable || typeof resolvedVariable === "object" && "ref" in resolvedVariable) {
14059 return resolvedVariable;
14060 }
14061 variable = resolvedVariable;
14062 } else {
14063 return variable;
14064 }
14065 }
14066 const USER_VALUE_PREFIX = "var:";
14067 const THEME_VALUE_PREFIX = "var(--wp--";
14068 const THEME_VALUE_SUFFIX = ")";
14069 let parsedVar;
14070 if (variable.startsWith(USER_VALUE_PREFIX)) {
14071 parsedVar = variable.slice(USER_VALUE_PREFIX.length).split("|");
14072 } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) {
14073 parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split("--");
14074 } else {
14075 return variable;
14076 }
14077 const [type, ...path] = parsedVar;
14078 if (type === "preset") {
14079 return getValueFromPresetVariable(
14080 features,
14081 blockName,
14082 variable,
14083 path
14084 );
14085 }
14086 if (type === "custom") {
14087 return getValueFromCustomVariable(
14088 features,
14089 blockName,
14090 variable,
14091 path
14092 );
14093 }
14094 return variable;
14095 }
14096
14097 // packages/global-styles-engine/build-module/settings/get-style.mjs
14098 function getStyle(globalStyles, path, blockName, shouldDecodeEncode = true) {
14099 const appendedPath = path ? "." + path : "";
14100 const finalPath = !blockName ? `styles${appendedPath}` : `styles.blocks.${blockName}${appendedPath}`;
14101 if (!globalStyles) {
14102 return void 0;
14103 }
14104 const rawResult = getValueFromObjectPath(globalStyles, finalPath);
14105 const result = shouldDecodeEncode ? getValueFromVariable(globalStyles, blockName, rawResult) : rawResult;
14106 return result;
14107 }
14108
14109 // packages/global-styles-engine/build-module/settings/set-style.mjs
14110 function setStyle(globalStyles, path, newValue, blockName) {
14111 const appendedPath = path ? "." + path : "";
14112 const finalPath = !blockName ? `styles${appendedPath}` : `styles.blocks.${blockName}${appendedPath}`;
14113 return setImmutably(
14114 globalStyles,
14115 finalPath.split("."),
14116 newValue
14117 );
14118 }
14119
14120 // packages/global-styles-engine/build-module/core/equal.mjs
14121 var import_es6 = __toESM(require_es6(), 1);
14122 function areGlobalStylesEqual(original, variation) {
14123 if (typeof original !== "object" || typeof variation !== "object") {
14124 return original === variation;
14125 }
14126 return (0, import_es6.default)(original?.styles, variation?.styles) && (0, import_es6.default)(original?.settings, variation?.settings);
14127 }
14128
14129 // packages/global-styles-engine/build-module/core/merge.mjs
14130 var import_deepmerge = __toESM(require_cjs(), 1);
14131
14132 // node_modules/is-plain-object/dist/is-plain-object.mjs
14133 function isObject(o4) {
14134 return Object.prototype.toString.call(o4) === "[object Object]";
14135 }
14136 function isPlainObject(o4) {
14137 var ctor, prot;
14138 if (isObject(o4) === false) return false;
14139 ctor = o4.constructor;
14140 if (ctor === void 0) return true;
14141 prot = ctor.prototype;
14142 if (isObject(prot) === false) return false;
14143 if (prot.hasOwnProperty("isPrototypeOf") === false) {
14144 return false;
14145 }
14146 return true;
14147 }
14148
14149 // packages/global-styles-engine/build-module/core/merge.mjs
14150 function mergeGlobalStyles(base, user) {
14151 return (0, import_deepmerge.default)(base, user, {
14152 /*
14153 * We only pass as arrays the presets,
14154 * in which case we want the new array of values
14155 * to override the old array (no merging).
14156 */
14157 isMergeableObject: isPlainObject,
14158 /*
14159 * Exceptions to the above rule.
14160 * Background images should be replaced, not merged,
14161 * as they themselves are specific object definitions for the style.
14162 */
14163 customMerge: (key) => {
14164 if (key === "backgroundImage") {
14165 return (baseConfig, userConfig) => userConfig ?? baseConfig;
14166 }
14167 return void 0;
14168 }
14169 });
14170 }
14171
14172 // node_modules/memize/dist/index.js
14173 function memize(fn, options) {
14174 var size3 = 0;
14175 var head2;
14176 var tail;
14177 options = options || {};
14178 function memoized() {
14179 var node = head2, len = arguments.length, args, i3;
14180 searchCache: while (node) {
14181 if (node.args.length !== arguments.length) {
14182 node = node.next;
14183 continue;
14184 }
14185 for (i3 = 0; i3 < len; i3++) {
14186 if (node.args[i3] !== arguments[i3]) {
14187 node = node.next;
14188 continue searchCache;
14189 }
14190 }
14191 if (node !== head2) {
14192 if (node === tail) {
14193 tail = node.prev;
14194 }
14195 node.prev.next = node.next;
14196 if (node.next) {
14197 node.next.prev = node.prev;
14198 }
14199 node.next = head2;
14200 node.prev = null;
14201 head2.prev = node;
14202 head2 = node;
14203 }
14204 return node.val;
14205 }
14206 args = new Array(len);
14207 for (i3 = 0; i3 < len; i3++) {
14208 args[i3] = arguments[i3];
14209 }
14210 node = {
14211 args,
14212 // Generate the result from original function
14213 val: fn.apply(null, args)
14214 };
14215 if (head2) {
14216 head2.prev = node;
14217 node.next = head2;
14218 } else {
14219 tail = node;
14220 }
14221 if (size3 === /** @type {MemizeOptions} */
14222 options.maxSize) {
14223 tail = /** @type {MemizeCacheNode} */
14224 tail.prev;
14225 tail.next = null;
14226 } else {
14227 size3++;
14228 }
14229 head2 = node;
14230 return node.val;
14231 }
14232 memoized.clear = function() {
14233 head2 = null;
14234 tail = null;
14235 size3 = 0;
14236 };
14237 return memoized;
14238 }
14239
14240 // packages/global-styles-engine/build-module/utils/get-global-styles-changes.mjs
14241 var import_i18n61 = __toESM(require_i18n(), 1);
14242 var import_blocks6 = __toESM(require_blocks(), 1);
14243 var globalStylesChangesCache = /* @__PURE__ */ new Map();
14244 var EMPTY_ARRAY3 = [];
14245 var translationMap = {
14246 caption: (0, import_i18n61.__)("Caption"),
14247 link: (0, import_i18n61.__)("Link"),
14248 button: (0, import_i18n61.__)("Button"),
14249 heading: (0, import_i18n61.__)("Heading"),
14250 h1: (0, import_i18n61.__)("H1"),
14251 h2: (0, import_i18n61.__)("H2"),
14252 h3: (0, import_i18n61.__)("H3"),
14253 h4: (0, import_i18n61.__)("H4"),
14254 h5: (0, import_i18n61.__)("H5"),
14255 h6: (0, import_i18n61.__)("H6"),
14256 "settings.color": (0, import_i18n61.__)("Color"),
14257 "settings.typography": (0, import_i18n61.__)("Typography"),
14258 "settings.shadow": (0, import_i18n61.__)("Shadow"),
14259 "settings.layout": (0, import_i18n61.__)("Layout"),
14260 "styles.color": (0, import_i18n61.__)("Colors"),
14261 "styles.spacing": (0, import_i18n61.__)("Spacing"),
14262 "styles.background": (0, import_i18n61.__)("Background"),
14263 "styles.typography": (0, import_i18n61.__)("Typography")
14264 };
14265 var getBlockNames = memize(
14266 () => (0, import_blocks6.getBlockTypes)().reduce(
14267 (accumulator, {
14268 name: name2,
14269 title
14270 }) => {
14271 accumulator[name2] = title;
14272 return accumulator;
14273 },
14274 {}
14275 )
14276 );
14277 var isObject2 = (obj) => obj !== null && typeof obj === "object";
14278 function getTranslation(key) {
14279 if (translationMap[key]) {
14280 return translationMap[key];
14281 }
14282 const keyArray = key.split(".");
14283 if (keyArray?.[0] === "blocks") {
14284 const blockName = getBlockNames()?.[keyArray[1]];
14285 return blockName || keyArray[1];
14286 }
14287 if (keyArray?.[0] === "elements") {
14288 return translationMap[keyArray[1]] || keyArray[1];
14289 }
14290 return void 0;
14291 }
14292 function deepCompare(changedObject, originalObject, parentPath = "") {
14293 if (!isObject2(changedObject) && !isObject2(originalObject)) {
14294 return changedObject !== originalObject ? parentPath.split(".").slice(0, 2).join(".") : void 0;
14295 }
14296 changedObject = isObject2(changedObject) ? changedObject : {};
14297 originalObject = isObject2(originalObject) ? originalObject : {};
14298 const allKeys = /* @__PURE__ */ new Set([
14299 ...Object.keys(changedObject),
14300 ...Object.keys(originalObject)
14301 ]);
14302 let diffs = [];
14303 for (const key of allKeys) {
14304 const path = parentPath ? parentPath + "." + key : key;
14305 const changedPath = deepCompare(
14306 changedObject[key],
14307 originalObject[key],
14308 path
14309 );
14310 if (changedPath) {
14311 diffs = diffs.concat(changedPath);
14312 }
14313 }
14314 return diffs;
14315 }
14316 function getGlobalStylesChangelist(next, previous) {
14317 const cacheKey2 = JSON.stringify({ next, previous });
14318 if (globalStylesChangesCache.has(cacheKey2)) {
14319 return globalStylesChangesCache.get(cacheKey2);
14320 }
14321 const changedValueTree = deepCompare(
14322 {
14323 styles: {
14324 background: next?.styles?.background,
14325 color: next?.styles?.color,
14326 typography: next?.styles?.typography,
14327 spacing: next?.styles?.spacing
14328 },
14329 blocks: next?.styles?.blocks,
14330 elements: next?.styles?.elements,
14331 settings: next?.settings
14332 },
14333 {
14334 styles: {
14335 background: previous?.styles?.background,
14336 color: previous?.styles?.color,
14337 typography: previous?.styles?.typography,
14338 spacing: previous?.styles?.spacing
14339 },
14340 blocks: previous?.styles?.blocks,
14341 elements: previous?.styles?.elements,
14342 settings: previous?.settings
14343 }
14344 );
14345 if (!changedValueTree || Array.isArray(changedValueTree) && !changedValueTree.length) {
14346 globalStylesChangesCache.set(cacheKey2, []);
14347 return [];
14348 }
14349 const changedValueArray = Array.isArray(changedValueTree) ? changedValueTree : [changedValueTree];
14350 const result = [...new Set(changedValueArray)].reduce((acc, curr) => {
14351 const translation = getTranslation(curr);
14352 if (translation) {
14353 acc.push([curr.split(".")[0], translation]);
14354 }
14355 return acc;
14356 }, []);
14357 globalStylesChangesCache.set(cacheKey2, result);
14358 return result;
14359 }
14360 function getGlobalStylesChanges(next, previous, options = {}) {
14361 let changeList = getGlobalStylesChangelist(next, previous);
14362 const changesLength = changeList.length;
14363 const { maxResults } = options;
14364 if (changesLength) {
14365 if (!!maxResults && changesLength > maxResults) {
14366 changeList = changeList.slice(0, maxResults);
14367 }
14368 return Object.entries(
14369 changeList.reduce((acc, curr) => {
14370 const group = acc[curr[0]] || [];
14371 if (!group.includes(curr[1])) {
14372 acc[curr[0]] = [...group, curr[1]];
14373 }
14374 return acc;
14375 }, {})
14376 ).map(([key, changeValues]) => {
14377 const changeValuesLength = changeValues.length;
14378 const joinedChangesValue = changeValues.join(
14379 /* translators: Used between list items, there is a space after the comma. */
14380 (0, import_i18n61.__)(", ")
14381 // eslint-disable-line @wordpress/i18n-no-flanking-whitespace
14382 );
14383 switch (key) {
14384 case "blocks": {
14385 return (0, import_i18n61.sprintf)(
14386 // translators: %s: a list of block names separated by a comma.
14387 (0, import_i18n61._n)("%s block.", "%s blocks.", changeValuesLength),
14388 joinedChangesValue
14389 );
14390 }
14391 case "elements": {
14392 return (0, import_i18n61.sprintf)(
14393 // translators: %s: a list of element names separated by a comma.
14394 (0, import_i18n61._n)("%s element.", "%s elements.", changeValuesLength),
14395 joinedChangesValue
14396 );
14397 }
14398 case "settings": {
14399 return (0, import_i18n61.sprintf)(
14400 // translators: %s: a list of theme.json setting labels separated by a comma.
14401 (0, import_i18n61.__)("%s settings."),
14402 joinedChangesValue
14403 );
14404 }
14405 case "styles": {
14406 return (0, import_i18n61.sprintf)(
14407 // translators: %s: a list of theme.json top-level styles labels separated by a comma.
14408 (0, import_i18n61.__)("%s styles."),
14409 joinedChangesValue
14410 );
14411 }
14412 default: {
14413 return (0, import_i18n61.sprintf)(
14414 // translators: %s: a list of global styles changes separated by a comma.
14415 (0, import_i18n61.__)("%s."),
14416 joinedChangesValue
14417 );
14418 }
14419 }
14420 });
14421 }
14422 return EMPTY_ARRAY3;
14423 }
14424
14425 // packages/global-styles-engine/build-module/core/render.mjs
14426 var import_blocks7 = __toESM(require_blocks(), 1);
14427 var import_style_engine2 = __toESM(require_style_engine(), 1);
14428 var import_data31 = __toESM(require_data(), 1);
14429
14430 // packages/global-styles-engine/build-module/core/selectors.mjs
14431 function getBlockSelector(blockType, target = "root", options = {}) {
14432 if (!target) {
14433 return null;
14434 }
14435 const { fallback = false } = options;
14436 const { name: name2, selectors, supports } = blockType;
14437 const hasSelectors = selectors && Object.keys(selectors).length > 0;
14438 const path = Array.isArray(target) ? target.join(".") : target;
14439 let rootSelector = null;
14440 if (hasSelectors && selectors.root) {
14441 rootSelector = selectors?.root;
14442 } else if (supports?.__experimentalSelector) {
14443 rootSelector = supports.__experimentalSelector;
14444 } else {
14445 rootSelector = ".wp-block-" + name2.replace("core/", "").replace("/", "-");
14446 }
14447 if (path === "root") {
14448 return rootSelector;
14449 }
14450 const pathArray = Array.isArray(target) ? target : target.split(".");
14451 if (pathArray.length === 1) {
14452 const fallbackSelector = fallback ? rootSelector : null;
14453 if (hasSelectors) {
14454 const featureSelector2 = getValueFromObjectPath(
14455 selectors,
14456 `${path}.root`,
14457 null
14458 ) || getValueFromObjectPath(selectors, path, null);
14459 return featureSelector2 || fallbackSelector;
14460 }
14461 const featureSelector = supports ? getValueFromObjectPath(
14462 supports,
14463 `${path}.__experimentalSelector`,
14464 null
14465 ) : void 0;
14466 if (!featureSelector) {
14467 return fallbackSelector;
14468 }
14469 return scopeSelector(rootSelector, featureSelector);
14470 }
14471 let subfeatureSelector;
14472 if (hasSelectors) {
14473 subfeatureSelector = getValueFromObjectPath(selectors, path, null);
14474 }
14475 if (subfeatureSelector) {
14476 return subfeatureSelector;
14477 }
14478 if (fallback) {
14479 return getBlockSelector(blockType, pathArray[0], options);
14480 }
14481 return null;
14482 }
14483
14484 // node_modules/colord/index.mjs
14485 var r3 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
14486 var t2 = function(r4) {
14487 return "string" == typeof r4 ? r4.length > 0 : "number" == typeof r4;
14488 };
14489 var n2 = function(r4, t4, n3) {
14490 return void 0 === t4 && (t4 = 0), void 0 === n3 && (n3 = Math.pow(10, t4)), Math.round(n3 * r4) / n3 + 0;
14491 };
14492 var e2 = function(r4, t4, n3) {
14493 return void 0 === t4 && (t4 = 0), void 0 === n3 && (n3 = 1), r4 > n3 ? n3 : r4 > t4 ? r4 : t4;
14494 };
14495 var u2 = function(r4) {
14496 return (r4 = isFinite(r4) ? r4 % 360 : 0) > 0 ? r4 : r4 + 360;
14497 };
14498 var a2 = function(r4) {
14499 return { r: e2(r4.r, 0, 255), g: e2(r4.g, 0, 255), b: e2(r4.b, 0, 255), a: e2(r4.a) };
14500 };
14501 var o2 = function(r4) {
14502 return { r: n2(r4.r), g: n2(r4.g), b: n2(r4.b), a: n2(r4.a, 3) };
14503 };
14504 var i2 = /^#([0-9a-f]{3,8})$/i;
14505 var s2 = function(r4) {
14506 var t4 = r4.toString(16);
14507 return t4.length < 2 ? "0" + t4 : t4;
14508 };
14509 var h2 = function(r4) {
14510 var t4 = r4.r, n3 = r4.g, e3 = r4.b, u3 = r4.a, a3 = Math.max(t4, n3, e3), o4 = a3 - Math.min(t4, n3, e3), i3 = o4 ? a3 === t4 ? (n3 - e3) / o4 : a3 === n3 ? 2 + (e3 - t4) / o4 : 4 + (t4 - n3) / o4 : 0;
14511 return { h: 60 * (i3 < 0 ? i3 + 6 : i3), s: a3 ? o4 / a3 * 100 : 0, v: a3 / 255 * 100, a: u3 };
14512 };
14513 var b2 = function(r4) {
14514 var t4 = r4.h, n3 = r4.s, e3 = r4.v, u3 = r4.a;
14515 t4 = t4 / 360 * 6, n3 /= 100, e3 /= 100;
14516 var a3 = Math.floor(t4), o4 = e3 * (1 - n3), i3 = e3 * (1 - (t4 - a3) * n3), s3 = e3 * (1 - (1 - t4 + a3) * n3), h3 = a3 % 6;
14517 return { r: 255 * [e3, i3, o4, o4, s3, e3][h3], g: 255 * [s3, e3, e3, i3, o4, o4][h3], b: 255 * [o4, o4, s3, e3, e3, i3][h3], a: u3 };
14518 };
14519 var g2 = function(r4) {
14520 return { h: u2(r4.h), s: e2(r4.s, 0, 100), l: e2(r4.l, 0, 100), a: e2(r4.a) };
14521 };
14522 var d2 = function(r4) {
14523 return { h: n2(r4.h), s: n2(r4.s), l: n2(r4.l), a: n2(r4.a, 3) };
14524 };
14525 var f2 = function(r4) {
14526 return b2((n3 = (t4 = r4).s, { h: t4.h, s: (n3 *= ((e3 = t4.l) < 50 ? e3 : 100 - e3) / 100) > 0 ? 2 * n3 / (e3 + n3) * 100 : 0, v: e3 + n3, a: t4.a }));
14527 var t4, n3, e3;
14528 };
14529 var c = function(r4) {
14530 return { h: (t4 = h2(r4)).h, s: (u3 = (200 - (n3 = t4.s)) * (e3 = t4.v) / 100) > 0 && u3 < 200 ? n3 * e3 / 100 / (u3 <= 100 ? u3 : 200 - u3) * 100 : 0, l: u3 / 2, a: t4.a };
14531 var t4, n3, e3, u3;
14532 };
14533 var l2 = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
14534 var p3 = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
14535 var v2 = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
14536 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
14537 var y2 = { string: [[function(r4) {
14538 var t4 = i2.exec(r4);
14539 return t4 ? (r4 = t4[1]).length <= 4 ? { r: parseInt(r4[0] + r4[0], 16), g: parseInt(r4[1] + r4[1], 16), b: parseInt(r4[2] + r4[2], 16), a: 4 === r4.length ? n2(parseInt(r4[3] + r4[3], 16) / 255, 2) : 1 } : 6 === r4.length || 8 === r4.length ? { r: parseInt(r4.substr(0, 2), 16), g: parseInt(r4.substr(2, 2), 16), b: parseInt(r4.substr(4, 2), 16), a: 8 === r4.length ? n2(parseInt(r4.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
14540 }, "hex"], [function(r4) {
14541 var t4 = v2.exec(r4) || m.exec(r4);
14542 return t4 ? t4[2] !== t4[4] || t4[4] !== t4[6] ? null : a2({ r: Number(t4[1]) / (t4[2] ? 100 / 255 : 1), g: Number(t4[3]) / (t4[4] ? 100 / 255 : 1), b: Number(t4[5]) / (t4[6] ? 100 / 255 : 1), a: void 0 === t4[7] ? 1 : Number(t4[7]) / (t4[8] ? 100 : 1) }) : null;
14543 }, "rgb"], [function(t4) {
14544 var n3 = l2.exec(t4) || p3.exec(t4);
14545 if (!n3) return null;
14546 var e3, u3, a3 = g2({ h: (e3 = n3[1], u3 = n3[2], void 0 === u3 && (u3 = "deg"), Number(e3) * (r3[u3] || 1)), s: Number(n3[3]), l: Number(n3[4]), a: void 0 === n3[5] ? 1 : Number(n3[5]) / (n3[6] ? 100 : 1) });
14547 return f2(a3);
14548 }, "hsl"]], object: [[function(r4) {
14549 var n3 = r4.r, e3 = r4.g, u3 = r4.b, o4 = r4.a, i3 = void 0 === o4 ? 1 : o4;
14550 return t2(n3) && t2(e3) && t2(u3) ? a2({ r: Number(n3), g: Number(e3), b: Number(u3), a: Number(i3) }) : null;
14551 }, "rgb"], [function(r4) {
14552 var n3 = r4.h, e3 = r4.s, u3 = r4.l, a3 = r4.a, o4 = void 0 === a3 ? 1 : a3;
14553 if (!t2(n3) || !t2(e3) || !t2(u3)) return null;
14554 var i3 = g2({ h: Number(n3), s: Number(e3), l: Number(u3), a: Number(o4) });
14555 return f2(i3);
14556 }, "hsl"], [function(r4) {
14557 var n3 = r4.h, a3 = r4.s, o4 = r4.v, i3 = r4.a, s3 = void 0 === i3 ? 1 : i3;
14558 if (!t2(n3) || !t2(a3) || !t2(o4)) return null;
14559 var h3 = (function(r5) {
14560 return { h: u2(r5.h), s: e2(r5.s, 0, 100), v: e2(r5.v, 0, 100), a: e2(r5.a) };
14561 })({ h: Number(n3), s: Number(a3), v: Number(o4), a: Number(s3) });
14562 return b2(h3);
14563 }, "hsv"]] };
14564 var N2 = function(r4, t4) {
14565 for (var n3 = 0; n3 < t4.length; n3++) {
14566 var e3 = t4[n3][0](r4);
14567 if (e3) return [e3, t4[n3][1]];
14568 }
14569 return [null, void 0];
14570 };
14571 var x = function(r4) {
14572 return "string" == typeof r4 ? N2(r4.trim(), y2.string) : "object" == typeof r4 && null !== r4 ? N2(r4, y2.object) : [null, void 0];
14573 };
14574 var M = function(r4, t4) {
14575 var n3 = c(r4);
14576 return { h: n3.h, s: e2(n3.s + 100 * t4, 0, 100), l: n3.l, a: n3.a };
14577 };
14578 var H = function(r4) {
14579 return (299 * r4.r + 587 * r4.g + 114 * r4.b) / 1e3 / 255;
14580 };
14581 var $ = function(r4, t4) {
14582 var n3 = c(r4);
14583 return { h: n3.h, s: n3.s, l: e2(n3.l + 100 * t4, 0, 100), a: n3.a };
14584 };
14585 var j = (function() {
14586 function r4(r5) {
14587 this.parsed = x(r5)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
14588 }
14589 return r4.prototype.isValid = function() {
14590 return null !== this.parsed;
14591 }, r4.prototype.brightness = function() {
14592 return n2(H(this.rgba), 2);
14593 }, r4.prototype.isDark = function() {
14594 return H(this.rgba) < 0.5;
14595 }, r4.prototype.isLight = function() {
14596 return H(this.rgba) >= 0.5;
14597 }, r4.prototype.toHex = function() {
14598 return r5 = o2(this.rgba), t4 = r5.r, e3 = r5.g, u3 = r5.b, i3 = (a3 = r5.a) < 1 ? s2(n2(255 * a3)) : "", "#" + s2(t4) + s2(e3) + s2(u3) + i3;
14599 var r5, t4, e3, u3, a3, i3;
14600 }, r4.prototype.toRgb = function() {
14601 return o2(this.rgba);
14602 }, r4.prototype.toRgbString = function() {
14603 return r5 = o2(this.rgba), t4 = r5.r, n3 = r5.g, e3 = r5.b, (u3 = r5.a) < 1 ? "rgba(" + t4 + ", " + n3 + ", " + e3 + ", " + u3 + ")" : "rgb(" + t4 + ", " + n3 + ", " + e3 + ")";
14604 var r5, t4, n3, e3, u3;
14605 }, r4.prototype.toHsl = function() {
14606 return d2(c(this.rgba));
14607 }, r4.prototype.toHslString = function() {
14608 return r5 = d2(c(this.rgba)), t4 = r5.h, n3 = r5.s, e3 = r5.l, (u3 = r5.a) < 1 ? "hsla(" + t4 + ", " + n3 + "%, " + e3 + "%, " + u3 + ")" : "hsl(" + t4 + ", " + n3 + "%, " + e3 + "%)";
14609 var r5, t4, n3, e3, u3;
14610 }, r4.prototype.toHsv = function() {
14611 return r5 = h2(this.rgba), { h: n2(r5.h), s: n2(r5.s), v: n2(r5.v), a: n2(r5.a, 3) };
14612 var r5;
14613 }, r4.prototype.invert = function() {
14614 return w2({ r: 255 - (r5 = this.rgba).r, g: 255 - r5.g, b: 255 - r5.b, a: r5.a });
14615 var r5;
14616 }, r4.prototype.saturate = function(r5) {
14617 return void 0 === r5 && (r5 = 0.1), w2(M(this.rgba, r5));
14618 }, r4.prototype.desaturate = function(r5) {
14619 return void 0 === r5 && (r5 = 0.1), w2(M(this.rgba, -r5));
14620 }, r4.prototype.grayscale = function() {
14621 return w2(M(this.rgba, -1));
14622 }, r4.prototype.lighten = function(r5) {
14623 return void 0 === r5 && (r5 = 0.1), w2($(this.rgba, r5));
14624 }, r4.prototype.darken = function(r5) {
14625 return void 0 === r5 && (r5 = 0.1), w2($(this.rgba, -r5));
14626 }, r4.prototype.rotate = function(r5) {
14627 return void 0 === r5 && (r5 = 15), this.hue(this.hue() + r5);
14628 }, r4.prototype.alpha = function(r5) {
14629 return "number" == typeof r5 ? w2({ r: (t4 = this.rgba).r, g: t4.g, b: t4.b, a: r5 }) : n2(this.rgba.a, 3);
14630 var t4;
14631 }, r4.prototype.hue = function(r5) {
14632 var t4 = c(this.rgba);
14633 return "number" == typeof r5 ? w2({ h: r5, s: t4.s, l: t4.l, a: t4.a }) : n2(t4.h);
14634 }, r4.prototype.isEqual = function(r5) {
14635 return this.toHex() === w2(r5).toHex();
14636 }, r4;
14637 })();
14638 var w2 = function(r4) {
14639 return r4 instanceof j ? r4 : new j(r4);
14640 };
14641 var S2 = [];
14642 var k = function(r4) {
14643 r4.forEach(function(r5) {
14644 S2.indexOf(r5) < 0 && (r5(j, y2), S2.push(r5));
14645 });
14646 };
14647
14648 // packages/global-styles-engine/build-module/utils/duotone.mjs
14649 function getValuesFromColors(colors2 = []) {
14650 const values = {
14651 r: [],
14652 g: [],
14653 b: [],
14654 a: []
14655 };
14656 colors2.forEach((color) => {
14657 const rgbColor = w2(color).toRgb();
14658 values.r.push(rgbColor.r / 255);
14659 values.g.push(rgbColor.g / 255);
14660 values.b.push(rgbColor.b / 255);
14661 values.a.push(rgbColor.a);
14662 });
14663 return values;
14664 }
14665 function getDuotoneFilter(id, colors2) {
14666 const values = getValuesFromColors(colors2);
14667 return `
14668<svg
14669 xmlns:xlink="http://www.w3.org/1999/xlink"
14670 viewBox="0 0 0 0"
14671 width="0"
14672 height="0"
14673 focusable="false"
14674 role="none"
14675 aria-hidden="true"
14676 style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
14677>
14678 <defs>
14679 <filter id="${id}">
14680 <!--
14681 Use sRGB instead of linearRGB so transparency looks correct.
14682 Use perceptual brightness to convert to grayscale.
14683 -->
14684 <feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
14685 <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
14686 <feComponentTransfer color-interpolation-filters="sRGB">
14687 <feFuncR type="table" tableValues="${values.r.join(" ")}"></feFuncR>
14688 <feFuncG type="table" tableValues="${values.g.join(" ")}"></feFuncG>
14689 <feFuncB type="table" tableValues="${values.b.join(" ")}"></feFuncB>
14690 <feFuncA type="table" tableValues="${values.a.join(" ")}"></feFuncA>
14691 </feComponentTransfer>
14692 <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
14693 <feComposite in2="SourceGraphic" operator="in"></feComposite>
14694 </filter>
14695 </defs>
14696</svg>`;
14697 }
14698
14699 // packages/global-styles-engine/build-module/utils/string.mjs
14700 function kebabCase(str) {
14701 return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([0-9])([a-zA-Z])/g, "$1-$2").replace(/([a-zA-Z])([0-9])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
14702 }
14703
14704 // packages/global-styles-engine/build-module/utils/spacing.mjs
14705 function getSpacingPresetCssVar(value) {
14706 if (!value) {
14707 return;
14708 }
14709 const slug = value.match(/var:preset\|spacing\|(.+)/);
14710 if (!slug) {
14711 return value;
14712 }
14713 return `var(--wp--preset--spacing--${slug[1]})`;
14714 }
14715
14716 // packages/global-styles-engine/build-module/utils/gap.mjs
14717 function getGapBoxControlValueFromStyle(blockGapValue) {
14718 if (!blockGapValue) {
14719 return null;
14720 }
14721 const isValueString = typeof blockGapValue === "string";
14722 return {
14723 top: isValueString ? blockGapValue : blockGapValue?.top,
14724 left: isValueString ? blockGapValue : blockGapValue?.left
14725 };
14726 }
14727 function getGapCSSValue(blockGapValue, defaultValue = "0") {
14728 const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue);
14729 if (!blockGapBoxControlValue) {
14730 return null;
14731 }
14732 const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue;
14733 const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue;
14734 return row === column ? row : `${row} ${column}`;
14735 }
14736
14737 // packages/global-styles-engine/build-module/utils/background.mjs
14738 var BACKGROUND_BLOCK_DEFAULT_VALUES = {
14739 backgroundSize: "cover",
14740 backgroundPosition: "50% 50%"
14741 // used only when backgroundSize is 'contain'.
14742 };
14743 function setBackgroundStyleDefaults(backgroundStyle) {
14744 if (!backgroundStyle || // @ts-expect-error
14745 !backgroundStyle?.backgroundImage?.url) {
14746 return;
14747 }
14748 let backgroundStylesWithDefaults;
14749 if (!backgroundStyle?.backgroundSize) {
14750 backgroundStylesWithDefaults = {
14751 backgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize
14752 };
14753 }
14754 if ("contain" === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) {
14755 backgroundStylesWithDefaults = {
14756 backgroundPosition: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition
14757 };
14758 }
14759 return backgroundStylesWithDefaults;
14760 }
14761
14762 // packages/global-styles-engine/build-module/utils/layout.mjs
14763 var LAYOUT_DEFINITIONS = {
14764 default: {
14765 name: "default",
14766 slug: "flow",
14767 className: "is-layout-flow",
14768 baseStyles: [
14769 {
14770 selector: " > .alignleft",
14771 rules: {
14772 float: "left",
14773 "margin-inline-start": "0",
14774 "margin-inline-end": "2em"
14775 }
14776 },
14777 {
14778 selector: " > .alignright",
14779 rules: {
14780 float: "right",
14781 "margin-inline-start": "2em",
14782 "margin-inline-end": "0"
14783 }
14784 },
14785 {
14786 selector: " > .aligncenter",
14787 rules: {
14788 "margin-left": "auto !important",
14789 "margin-right": "auto !important"
14790 }
14791 }
14792 ],
14793 spacingStyles: [
14794 {
14795 selector: " > :first-child",
14796 rules: {
14797 "margin-block-start": "0"
14798 }
14799 },
14800 {
14801 selector: " > :last-child",
14802 rules: {
14803 "margin-block-end": "0"
14804 }
14805 },
14806 {
14807 selector: " > *",
14808 rules: {
14809 "margin-block-start": null,
14810 "margin-block-end": "0"
14811 }
14812 }
14813 ]
14814 },
14815 constrained: {
14816 name: "constrained",
14817 slug: "constrained",
14818 className: "is-layout-constrained",
14819 baseStyles: [
14820 {
14821 selector: " > .alignleft",
14822 rules: {
14823 float: "left",
14824 "margin-inline-start": "0",
14825 "margin-inline-end": "2em"
14826 }
14827 },
14828 {
14829 selector: " > .alignright",
14830 rules: {
14831 float: "right",
14832 "margin-inline-start": "2em",
14833 "margin-inline-end": "0"
14834 }
14835 },
14836 {
14837 selector: " > .aligncenter",
14838 rules: {
14839 "margin-left": "auto !important",
14840 "margin-right": "auto !important"
14841 }
14842 },
14843 {
14844 selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))",
14845 rules: {
14846 "max-width": "var(--wp--style--global--content-size)",
14847 "margin-left": "auto !important",
14848 "margin-right": "auto !important"
14849 }
14850 },
14851 {
14852 selector: " > .alignwide",
14853 rules: {
14854 "max-width": "var(--wp--style--global--wide-size)"
14855 }
14856 }
14857 ],
14858 spacingStyles: [
14859 {
14860 selector: " > :first-child",
14861 rules: {
14862 "margin-block-start": "0"
14863 }
14864 },
14865 {
14866 selector: " > :last-child",
14867 rules: {
14868 "margin-block-end": "0"
14869 }
14870 },
14871 {
14872 selector: " > *",
14873 rules: {
14874 "margin-block-start": null,
14875 "margin-block-end": "0"
14876 }
14877 }
14878 ]
14879 },
14880 flex: {
14881 name: "flex",
14882 slug: "flex",
14883 className: "is-layout-flex",
14884 displayMode: "flex",
14885 baseStyles: [
14886 {
14887 selector: "",
14888 rules: {
14889 "flex-wrap": "wrap",
14890 "align-items": "center"
14891 }
14892 },
14893 {
14894 selector: " > :is(*, div)",
14895 // :is(*, div) instead of just * increases the specificity by 001.
14896 rules: {
14897 margin: "0"
14898 }
14899 }
14900 ],
14901 spacingStyles: [
14902 {
14903 selector: "",
14904 rules: {
14905 gap: null
14906 }
14907 }
14908 ]
14909 },
14910 grid: {
14911 name: "grid",
14912 slug: "grid",
14913 className: "is-layout-grid",
14914 displayMode: "grid",
14915 baseStyles: [
14916 {
14917 selector: " > :is(*, div)",
14918 // :is(*, div) instead of just * increases the specificity by 001.
14919 rules: {
14920 margin: "0"
14921 }
14922 }
14923 ],
14924 spacingStyles: [
14925 {
14926 selector: "",
14927 rules: {
14928 gap: null
14929 }
14930 }
14931 ]
14932 }
14933 };
14934
14935 // packages/global-styles-engine/build-module/core/render.mjs
14936 var ELEMENT_CLASS_NAMES = {
14937 button: "wp-element-button",
14938 caption: "wp-element-caption"
14939 };
14940 var BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
14941 __experimentalBorder: "border",
14942 color: "color",
14943 dimensions: "dimensions",
14944 spacing: "spacing",
14945 typography: "typography"
14946 };
14947 function getPresetsDeclarations(blockPresets = {}, mergedSettings) {
14948 return PRESET_METADATA.reduce(
14949 (declarations, { path, valueKey, valueFunc, cssVarInfix }) => {
14950 const presetByOrigin = getValueFromObjectPath(
14951 blockPresets,
14952 path,
14953 []
14954 );
14955 ["default", "theme", "custom"].forEach((origin) => {
14956 if (presetByOrigin[origin]) {
14957 presetByOrigin[origin].forEach((value) => {
14958 if (valueKey && !valueFunc) {
14959 declarations.push(
14960 `--wp--preset--${cssVarInfix}--${kebabCase(
14961 value.slug
14962 )}: ${value[valueKey]}`
14963 );
14964 } else if (valueFunc && typeof valueFunc === "function") {
14965 declarations.push(
14966 `--wp--preset--${cssVarInfix}--${kebabCase(
14967 value.slug
14968 )}: ${valueFunc(value, mergedSettings)}`
14969 );
14970 }
14971 });
14972 }
14973 });
14974 return declarations;
14975 },
14976 []
14977 );
14978 }
14979 function getPresetsClasses(blockSelector = "*", blockPresets = {}) {
14980 return PRESET_METADATA.reduce(
14981 (declarations, { path, cssVarInfix, classes }) => {
14982 if (!classes) {
14983 return declarations;
14984 }
14985 const presetByOrigin = getValueFromObjectPath(
14986 blockPresets,
14987 path,
14988 []
14989 );
14990 ["default", "theme", "custom"].forEach((origin) => {
14991 if (presetByOrigin[origin]) {
14992 presetByOrigin[origin].forEach(
14993 ({ slug }) => {
14994 classes.forEach(
14995 ({
14996 classSuffix,
14997 propertyName
14998 }) => {
14999 const classSelectorToUse = `.has-${kebabCase(
15000 slug
15001 )}-${classSuffix}`;
15002 const selectorToUse = blockSelector.split(",").map(
15003 (selector) => `${selector}${classSelectorToUse}`
15004 ).join(",");
15005 const value = `var(--wp--preset--${cssVarInfix}--${kebabCase(
15006 slug
15007 )})`;
15008 declarations += `${selectorToUse}{${propertyName}: ${value} !important;}`;
15009 }
15010 );
15011 }
15012 );
15013 }
15014 });
15015 return declarations;
15016 },
15017 ""
15018 );
15019 }
15020 function getPresetsSvgFilters(blockPresets = {}) {
15021 return PRESET_METADATA.filter(
15022 // Duotone are the only type of filters for now.
15023 (metadata) => metadata.path.at(-1) === "duotone"
15024 ).flatMap((metadata) => {
15025 const presetByOrigin = getValueFromObjectPath(
15026 blockPresets,
15027 metadata.path,
15028 {}
15029 );
15030 return ["default", "theme"].filter((origin) => presetByOrigin[origin]).flatMap(
15031 (origin) => presetByOrigin[origin].map(
15032 (preset) => getDuotoneFilter(
15033 `wp-duotone-${preset.slug}`,
15034 preset.colors
15035 )
15036 )
15037 ).join("");
15038 });
15039 }
15040 function flattenTree(input = {}, prefix2, token) {
15041 let result = [];
15042 Object.keys(input).forEach((key) => {
15043 const newKey = prefix2 + kebabCase(key.replace("/", "-"));
15044 const newLeaf = input[key];
15045 if (newLeaf instanceof Object) {
15046 const newPrefix = newKey + token;
15047 result = [...result, ...flattenTree(newLeaf, newPrefix, token)];
15048 } else {
15049 result.push(`${newKey}: ${newLeaf}`);
15050 }
15051 });
15052 return result;
15053 }
15054 function concatFeatureVariationSelectorString(featureSelector, styleVariationSelector) {
15055 const featureSelectors = featureSelector.split(",");
15056 const combinedSelectors = [];
15057 featureSelectors.forEach((selector) => {
15058 combinedSelectors.push(
15059 `${styleVariationSelector.trim()}${selector.trim()}`
15060 );
15061 });
15062 return combinedSelectors.join(", ");
15063 }
15064 var updateParagraphTextIndentSelector = (featureDeclarations, settings, blockName) => {
15065 if (blockName !== "core/paragraph") {
15066 return featureDeclarations;
15067 }
15068 const blockSettings = settings?.blocks?.["core/paragraph"];
15069 const textIndentSetting = blockSettings?.typography?.textIndent ?? settings?.typography?.textIndent ?? "subsequent";
15070 if (textIndentSetting !== "all") {
15071 return featureDeclarations;
15072 }
15073 const oldSelector = ".wp-block-paragraph + .wp-block-paragraph";
15074 const newSelector = ".wp-block-paragraph";
15075 if (oldSelector in featureDeclarations) {
15076 const declarations = featureDeclarations[oldSelector];
15077 const updated = { ...featureDeclarations };
15078 delete updated[oldSelector];
15079 updated[newSelector] = declarations;
15080 return updated;
15081 }
15082 return featureDeclarations;
15083 };
15084 var getFeatureDeclarations = (selectors, styles) => {
15085 const declarations = {};
15086 Object.entries(selectors).forEach(([feature, selector]) => {
15087 if (feature === "root" || !styles?.[feature]) {
15088 return;
15089 }
15090 const isShorthand = typeof selector === "string";
15091 if (!isShorthand && typeof selector === "object" && selector !== null) {
15092 Object.entries(selector).forEach(
15093 ([subfeature, subfeatureSelector]) => {
15094 if (subfeature === "root" || !styles?.[feature][subfeature]) {
15095 return;
15096 }
15097 const subfeatureStyles = {
15098 [feature]: {
15099 [subfeature]: styles[feature][subfeature]
15100 }
15101 };
15102 const newDeclarations = getStylesDeclarations(subfeatureStyles);
15103 declarations[subfeatureSelector] = [
15104 ...declarations[subfeatureSelector] || [],
15105 ...newDeclarations
15106 ];
15107 delete styles[feature][subfeature];
15108 }
15109 );
15110 }
15111 if (isShorthand || typeof selector === "object" && selector !== null && "root" in selector) {
15112 const featureSelector = isShorthand ? selector : selector.root;
15113 const featureStyles = { [feature]: styles[feature] };
15114 const newDeclarations = getStylesDeclarations(featureStyles);
15115 declarations[featureSelector] = [
15116 ...declarations[featureSelector] || [],
15117 ...newDeclarations
15118 ];
15119 delete styles[feature];
15120 }
15121 });
15122 return declarations;
15123 };
15124 function getStylesDeclarations(blockStyles = {}, selector = "", useRootPaddingAlign, tree = {}, disableRootPadding = false) {
15125 const isRoot = ROOT_BLOCK_SELECTOR === selector;
15126 const output = Object.entries(
15127 import_blocks7.__EXPERIMENTAL_STYLE_PROPERTY
15128 ).reduce(
15129 (declarations, [key, { value, properties, useEngine, rootOnly }]) => {
15130 if (rootOnly && !isRoot) {
15131 return declarations;
15132 }
15133 const pathToValue = value;
15134 if (pathToValue[0] === "elements" || useEngine) {
15135 return declarations;
15136 }
15137 const styleValue = getValueFromObjectPath(
15138 blockStyles,
15139 pathToValue
15140 );
15141 if (key === "--wp--style--root--padding" && (typeof styleValue === "string" || !useRootPaddingAlign)) {
15142 return declarations;
15143 }
15144 if (properties && typeof styleValue !== "string") {
15145 Object.entries(properties).forEach((entry) => {
15146 const [name2, prop] = entry;
15147 if (!getValueFromObjectPath(styleValue, [prop], false)) {
15148 return;
15149 }
15150 const cssProperty = name2.startsWith("--") ? name2 : kebabCase(name2);
15151 declarations.push(
15152 `${cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)(
15153 getValueFromObjectPath(styleValue, [prop])
15154 )}`
15155 );
15156 });
15157 } else if (getValueFromObjectPath(blockStyles, pathToValue, false)) {
15158 const cssProperty = key.startsWith("--") ? key : kebabCase(key);
15159 declarations.push(
15160 `${cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)(
15161 getValueFromObjectPath(blockStyles, pathToValue)
15162 )}`
15163 );
15164 }
15165 return declarations;
15166 },
15167 []
15168 );
15169 if (!!blockStyles.background) {
15170 if (blockStyles.background?.backgroundImage) {
15171 blockStyles.background.backgroundImage = getResolvedValue(
15172 blockStyles.background.backgroundImage,
15173 tree
15174 );
15175 }
15176 if (!isRoot && !!blockStyles.background?.backgroundImage?.id) {
15177 blockStyles = {
15178 ...blockStyles,
15179 background: {
15180 ...blockStyles.background,
15181 ...setBackgroundStyleDefaults(blockStyles.background)
15182 }
15183 };
15184 }
15185 }
15186 const extraRules = (0, import_style_engine2.getCSSRules)(blockStyles);
15187 extraRules.forEach((rule) => {
15188 if (isRoot && (useRootPaddingAlign || disableRootPadding) && rule.key.startsWith("padding")) {
15189 return;
15190 }
15191 const cssProperty = rule.key.startsWith("--") ? rule.key : kebabCase(rule.key);
15192 let ruleValue = getResolvedValue(rule.value, tree);
15193 if (cssProperty === "font-size") {
15194 ruleValue = getTypographyFontSizeValue(
15195 { name: "", slug: "", size: ruleValue },
15196 tree?.settings
15197 );
15198 }
15199 if (cssProperty === "aspect-ratio") {
15200 output.push("min-height: unset");
15201 }
15202 output.push(`${cssProperty}: ${ruleValue}`);
15203 });
15204 return output;
15205 }
15206 function getLayoutStyles({
15207 layoutDefinitions = LAYOUT_DEFINITIONS,
15208 style,
15209 selector,
15210 hasBlockGapSupport,
15211 hasFallbackGapSupport,
15212 fallbackGapValue
15213 }) {
15214 let ruleset = "";
15215 let gapValue = hasBlockGapSupport ? getGapCSSValue(style?.spacing?.blockGap) : "";
15216 if (hasFallbackGapSupport) {
15217 if (selector === ROOT_BLOCK_SELECTOR) {
15218 gapValue = !gapValue ? "0.5em" : gapValue;
15219 } else if (!hasBlockGapSupport && fallbackGapValue) {
15220 gapValue = fallbackGapValue;
15221 }
15222 }
15223 if (gapValue && layoutDefinitions) {
15224 Object.values(layoutDefinitions).forEach(
15225 ({ className, name: name2, spacingStyles }) => {
15226 if (!hasBlockGapSupport && "flex" !== name2 && "grid" !== name2) {
15227 return;
15228 }
15229 if (spacingStyles?.length) {
15230 spacingStyles.forEach((spacingStyle) => {
15231 const declarations = [];
15232 if (spacingStyle.rules) {
15233 Object.entries(spacingStyle.rules).forEach(
15234 ([cssProperty, cssValue]) => {
15235 declarations.push(
15236 `${cssProperty}: ${cssValue ? cssValue : gapValue}`
15237 );
15238 }
15239 );
15240 }
15241 if (declarations.length) {
15242 let combinedSelector = "";
15243 if (!hasBlockGapSupport) {
15244 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(.${className}${spacingStyle?.selector || ""})` : `:where(${selector}.${className}${spacingStyle?.selector || ""})`;
15245 } else {
15246 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:root :where(.${className})${spacingStyle?.selector || ""}` : `:root :where(${selector}-${className})${spacingStyle?.selector || ""}`;
15247 }
15248 ruleset += `${combinedSelector} { ${declarations.join(
15249 "; "
15250 )}; }`;
15251 }
15252 });
15253 }
15254 }
15255 );
15256 if (selector === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) {
15257 ruleset += `${ROOT_CSS_PROPERTIES_SELECTOR} { --wp--style--block-gap: ${gapValue}; }`;
15258 }
15259 }
15260 if (selector === ROOT_BLOCK_SELECTOR && layoutDefinitions) {
15261 const validDisplayModes = ["block", "flex", "grid"];
15262 Object.values(layoutDefinitions).forEach(
15263 ({ className, displayMode, baseStyles }) => {
15264 if (displayMode && validDisplayModes.includes(displayMode)) {
15265 ruleset += `${selector} .${className} { display:${displayMode}; }`;
15266 }
15267 if (baseStyles?.length) {
15268 baseStyles.forEach((baseStyle) => {
15269 const declarations = [];
15270 if (baseStyle.rules) {
15271 Object.entries(baseStyle.rules).forEach(
15272 ([cssProperty, cssValue]) => {
15273 declarations.push(
15274 `${cssProperty}: ${cssValue}`
15275 );
15276 }
15277 );
15278 }
15279 if (declarations.length) {
15280 const combinedSelector = `.${className}${baseStyle?.selector || ""}`;
15281 ruleset += `${combinedSelector} { ${declarations.join(
15282 "; "
15283 )}; }`;
15284 }
15285 });
15286 }
15287 }
15288 );
15289 }
15290 return ruleset;
15291 }
15292 var STYLE_KEYS = [
15293 "border",
15294 "color",
15295 "dimensions",
15296 "spacing",
15297 "typography",
15298 "filter",
15299 "outline",
15300 "shadow",
15301 "background"
15302 ];
15303 function pickStyleKeys(treeToPickFrom) {
15304 if (!treeToPickFrom) {
15305 return {};
15306 }
15307 const entries = Object.entries(treeToPickFrom);
15308 const pickedEntries = entries.filter(
15309 ([key]) => STYLE_KEYS.includes(key)
15310 );
15311 const clonedEntries = pickedEntries.map(([key, style]) => [
15312 key,
15313 JSON.parse(JSON.stringify(style))
15314 ]);
15315 return Object.fromEntries(clonedEntries);
15316 }
15317 var getNodesWithStyles = (tree, blockSelectors) => {
15318 const nodes = [];
15319 if (!tree?.styles) {
15320 return nodes;
15321 }
15322 const styles = pickStyleKeys(tree.styles);
15323 if (styles) {
15324 nodes.push({
15325 styles,
15326 selector: ROOT_BLOCK_SELECTOR,
15327 // Root selector (body) styles should not be wrapped in `:root where()` to keep
15328 // specificity at (0,0,1) and maintain backwards compatibility.
15329 skipSelectorWrapper: true
15330 });
15331 }
15332 Object.entries(import_blocks7.__EXPERIMENTAL_ELEMENTS).forEach(([name2, selector]) => {
15333 if (tree.styles?.elements?.[name2]) {
15334 nodes.push({
15335 styles: tree.styles?.elements?.[name2] ?? {},
15336 selector,
15337 // Top level elements that don't use a class name should not receive the
15338 // `:root :where()` wrapper to maintain backwards compatibility.
15339 skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name2]
15340 });
15341 }
15342 });
15343 Object.entries(tree.styles?.blocks ?? {}).forEach(
15344 ([blockName, node]) => {
15345 const blockStyles = pickStyleKeys(node);
15346 const typedNode = node;
15347 const variationNodesToAdd = [];
15348 if (typedNode?.variations) {
15349 const variations = {};
15350 Object.entries(typedNode.variations).forEach(
15351 ([variationName, variation]) => {
15352 const typedVariation = variation;
15353 variations[variationName] = pickStyleKeys(typedVariation);
15354 if (typedVariation?.css) {
15355 variations[variationName].css = typedVariation.css;
15356 }
15357 const variationSelector = typeof blockSelectors !== "string" ? blockSelectors[blockName]?.styleVariationSelectors?.[variationName] : void 0;
15358 Object.entries(
15359 typedVariation?.elements ?? {}
15360 ).forEach(([element, elementStyles]) => {
15361 if (elementStyles && import_blocks7.__EXPERIMENTAL_ELEMENTS[element]) {
15362 variationNodesToAdd.push({
15363 styles: elementStyles,
15364 selector: scopeSelector(
15365 variationSelector,
15366 import_blocks7.__EXPERIMENTAL_ELEMENTS[element]
15367 )
15368 });
15369 }
15370 });
15371 Object.entries(typedVariation?.blocks ?? {}).forEach(
15372 ([
15373 variationBlockName,
15374 variationBlockStyles
15375 ]) => {
15376 const variationBlockSelector = typeof blockSelectors !== "string" ? scopeSelector(
15377 variationSelector,
15378 blockSelectors[variationBlockName]?.selector
15379 ) : void 0;
15380 const variationDuotoneSelector = typeof blockSelectors !== "string" ? scopeSelector(
15381 variationSelector,
15382 blockSelectors[variationBlockName]?.duotoneSelector
15383 ) : void 0;
15384 const variationFeatureSelectors = typeof blockSelectors !== "string" ? scopeFeatureSelectors(
15385 variationSelector,
15386 blockSelectors[variationBlockName]?.featureSelectors ?? {}
15387 ) : void 0;
15388 const variationBlockStyleNodes = pickStyleKeys(variationBlockStyles);
15389 if (variationBlockStyles?.css) {
15390 variationBlockStyleNodes.css = variationBlockStyles.css;
15391 }
15392 if (!variationBlockSelector || typeof blockSelectors === "string") {
15393 return;
15394 }
15395 variationNodesToAdd.push({
15396 selector: variationBlockSelector,
15397 duotoneSelector: variationDuotoneSelector,
15398 featureSelectors: variationFeatureSelectors,
15399 fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue,
15400 hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport,
15401 styles: variationBlockStyleNodes
15402 });
15403 Object.entries(
15404 variationBlockStyles.elements ?? {}
15405 ).forEach(
15406 ([
15407 variationBlockElement,
15408 variationBlockElementStyles
15409 ]) => {
15410 if (variationBlockElementStyles && import_blocks7.__EXPERIMENTAL_ELEMENTS[variationBlockElement]) {
15411 variationNodesToAdd.push({
15412 styles: variationBlockElementStyles,
15413 selector: scopeSelector(
15414 variationBlockSelector,
15415 import_blocks7.__EXPERIMENTAL_ELEMENTS[variationBlockElement]
15416 )
15417 });
15418 }
15419 }
15420 );
15421 }
15422 );
15423 }
15424 );
15425 blockStyles.variations = variations;
15426 }
15427 if (typeof blockSelectors !== "string" && blockSelectors?.[blockName]?.selector) {
15428 nodes.push({
15429 duotoneSelector: blockSelectors[blockName].duotoneSelector,
15430 fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
15431 hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
15432 selector: blockSelectors[blockName].selector,
15433 styles: blockStyles,
15434 featureSelectors: blockSelectors[blockName].featureSelectors,
15435 styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors,
15436 name: blockName
15437 });
15438 }
15439 Object.entries(typedNode?.elements ?? {}).forEach(
15440 ([elementName, value]) => {
15441 if (typeof blockSelectors !== "string" && value && blockSelectors?.[blockName] && import_blocks7.__EXPERIMENTAL_ELEMENTS[elementName]) {
15442 nodes.push({
15443 styles: value,
15444 selector: blockSelectors[blockName]?.selector.split(",").map((sel) => {
15445 const elementSelectors = import_blocks7.__EXPERIMENTAL_ELEMENTS[elementName].split(",");
15446 return elementSelectors.map(
15447 (elementSelector) => sel + " " + elementSelector
15448 );
15449 }).join(",")
15450 });
15451 }
15452 }
15453 );
15454 nodes.push(...variationNodesToAdd);
15455 }
15456 );
15457 return nodes;
15458 };
15459 var getNodesWithSettings = (tree, blockSelectors) => {
15460 const nodes = [];
15461 if (!tree?.settings) {
15462 return nodes;
15463 }
15464 const pickPresets = (treeToPickFrom) => {
15465 let presets2 = {};
15466 PRESET_METADATA.forEach(({ path }) => {
15467 const value = getValueFromObjectPath(treeToPickFrom, path, false);
15468 if (value !== false) {
15469 presets2 = setImmutably(presets2, path, value);
15470 }
15471 });
15472 return presets2;
15473 };
15474 const presets = pickPresets(tree.settings);
15475 const custom = tree.settings?.custom;
15476 if (Object.keys(presets).length > 0 || custom) {
15477 nodes.push({
15478 presets,
15479 custom,
15480 selector: ROOT_CSS_PROPERTIES_SELECTOR
15481 });
15482 }
15483 Object.entries(tree.settings?.blocks ?? {}).forEach(
15484 ([blockName, node]) => {
15485 const blockCustom = node.custom;
15486 if (typeof blockSelectors === "string" || !blockSelectors[blockName]) {
15487 return;
15488 }
15489 const blockPresets = pickPresets(node);
15490 if (Object.keys(blockPresets).length > 0 || blockCustom) {
15491 nodes.push({
15492 presets: blockPresets,
15493 custom: blockCustom,
15494 selector: blockSelectors[blockName]?.selector
15495 });
15496 }
15497 }
15498 );
15499 return nodes;
15500 };
15501 var generateCustomProperties = (tree, blockSelectors) => {
15502 const settings = getNodesWithSettings(tree, blockSelectors);
15503 let ruleset = "";
15504 settings.forEach(({ presets, custom, selector }) => {
15505 const declarations = tree?.settings ? getPresetsDeclarations(presets, tree?.settings) : [];
15506 const customProps = flattenTree(custom, "--wp--custom--", "--");
15507 if (customProps.length > 0) {
15508 declarations.push(...customProps);
15509 }
15510 if (declarations.length > 0) {
15511 ruleset += `${selector}{${declarations.join(";")};}`;
15512 }
15513 });
15514 return ruleset;
15515 };
15516 var transformToStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles = false, disableRootPadding = false, styleOptions = {}) => {
15517 const options = {
15518 blockGap: true,
15519 blockStyles: true,
15520 layoutStyles: true,
15521 marginReset: true,
15522 presets: true,
15523 rootPadding: true,
15524 variationStyles: false,
15525 ...styleOptions
15526 };
15527 const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
15528 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
15529 const useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments;
15530 const { contentSize, wideSize } = tree?.settings?.layout || {};
15531 const hasBodyStyles = options.marginReset || options.rootPadding || options.layoutStyles;
15532 let ruleset = "";
15533 if (options.presets && (contentSize || wideSize)) {
15534 ruleset += `${ROOT_CSS_PROPERTIES_SELECTOR} {`;
15535 ruleset = contentSize ? ruleset + ` --wp--style--global--content-size: ${contentSize};` : ruleset;
15536 ruleset = wideSize ? ruleset + ` --wp--style--global--wide-size: ${wideSize};` : ruleset;
15537 ruleset += "}";
15538 }
15539 if (hasBodyStyles) {
15540 ruleset += ":where(body) {margin: 0;";
15541 if (options.rootPadding && useRootPaddingAlign) {
15542 ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
15543 .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
15544 .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
15545 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; }
15546 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0;
15547 `;
15548 }
15549 ruleset += "}";
15550 }
15551 if (options.blockStyles) {
15552 nodesWithStyles.forEach(
15553 ({
15554 selector,
15555 duotoneSelector,
15556 styles,
15557 fallbackGapValue,
15558 hasLayoutSupport,
15559 featureSelectors,
15560 styleVariationSelectors,
15561 skipSelectorWrapper,
15562 name: name2
15563 }) => {
15564 if (featureSelectors) {
15565 let featureDeclarations = getFeatureDeclarations(
15566 featureSelectors,
15567 styles
15568 );
15569 featureDeclarations = updateParagraphTextIndentSelector(
15570 featureDeclarations,
15571 tree.settings,
15572 name2
15573 );
15574 Object.entries(featureDeclarations).forEach(
15575 ([cssSelector, declarations]) => {
15576 if (declarations.length) {
15577 const rules = declarations.join(";");
15578 ruleset += `:root :where(${cssSelector}){${rules};}`;
15579 }
15580 }
15581 );
15582 }
15583 if (duotoneSelector) {
15584 const duotoneStyles = {};
15585 if (styles?.filter) {
15586 duotoneStyles.filter = styles.filter;
15587 delete styles.filter;
15588 }
15589 const duotoneDeclarations = getStylesDeclarations(duotoneStyles);
15590 if (duotoneDeclarations.length) {
15591 ruleset += `${duotoneSelector}{${duotoneDeclarations.join(
15592 ";"
15593 )};}`;
15594 }
15595 }
15596 if (!disableLayoutStyles && (ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport)) {
15597 ruleset += getLayoutStyles({
15598 style: styles,
15599 selector,
15600 hasBlockGapSupport,
15601 hasFallbackGapSupport,
15602 fallbackGapValue
15603 });
15604 }
15605 const styleDeclarations = getStylesDeclarations(
15606 styles,
15607 selector,
15608 useRootPaddingAlign,
15609 tree,
15610 disableRootPadding
15611 );
15612 if (styleDeclarations?.length) {
15613 const generalSelector = skipSelectorWrapper ? selector : `:root :where(${selector})`;
15614 ruleset += `${generalSelector}{${styleDeclarations.join(
15615 ";"
15616 )};}`;
15617 }
15618 if (styles?.css) {
15619 ruleset += processCSSNesting(
15620 styles.css,
15621 `:root :where(${selector})`
15622 );
15623 }
15624 if (options.variationStyles && styleVariationSelectors) {
15625 Object.entries(styleVariationSelectors).forEach(
15626 ([styleVariationName, styleVariationSelector]) => {
15627 const styleVariations = styles?.variations?.[styleVariationName];
15628 if (styleVariations) {
15629 if (featureSelectors) {
15630 let featureDeclarations = getFeatureDeclarations(
15631 featureSelectors,
15632 styleVariations
15633 );
15634 featureDeclarations = updateParagraphTextIndentSelector(
15635 featureDeclarations,
15636 tree.settings,
15637 name2
15638 );
15639 Object.entries(
15640 featureDeclarations
15641 ).forEach(
15642 ([baseSelector, declarations]) => {
15643 if (declarations.length) {
15644 const cssSelector = concatFeatureVariationSelectorString(
15645 baseSelector,
15646 styleVariationSelector
15647 );
15648 const rules = declarations.join(";");
15649 ruleset += `:root :where(${cssSelector}){${rules};}`;
15650 }
15651 }
15652 );
15653 }
15654 const styleVariationDeclarations = getStylesDeclarations(
15655 styleVariations,
15656 styleVariationSelector,
15657 useRootPaddingAlign,
15658 tree
15659 );
15660 if (styleVariationDeclarations.length) {
15661 ruleset += `:root :where(${styleVariationSelector}){${styleVariationDeclarations.join(
15662 ";"
15663 )};}`;
15664 }
15665 if (styleVariations?.css) {
15666 ruleset += processCSSNesting(
15667 styleVariations.css,
15668 `:root :where(${styleVariationSelector})`
15669 );
15670 }
15671 if (hasLayoutSupport && styleVariations?.spacing?.blockGap) {
15672 const variationSelectorWithBlock = styleVariationSelector + selector;
15673 ruleset += getLayoutStyles({
15674 style: styleVariations,
15675 selector: variationSelectorWithBlock,
15676 hasBlockGapSupport: true,
15677 hasFallbackGapSupport,
15678 fallbackGapValue
15679 });
15680 }
15681 }
15682 }
15683 );
15684 }
15685 const pseudoSelectorStyles = Object.entries(styles).filter(
15686 ([key]) => key.startsWith(":")
15687 );
15688 if (pseudoSelectorStyles?.length) {
15689 pseudoSelectorStyles.forEach(
15690 ([pseudoKey, pseudoStyle]) => {
15691 const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
15692 if (!pseudoDeclarations?.length) {
15693 return;
15694 }
15695 const _selector = selector.split(",").map((sel) => sel + pseudoKey).join(",");
15696 const pseudoRule = `:root :where(${_selector}){${pseudoDeclarations.join(
15697 ";"
15698 )};}`;
15699 ruleset += pseudoRule;
15700 }
15701 );
15702 }
15703 }
15704 );
15705 }
15706 if (options.layoutStyles) {
15707 ruleset = ruleset + ".wp-site-blocks > .alignleft { float: left; margin-right: 2em; }";
15708 ruleset = ruleset + ".wp-site-blocks > .alignright { float: right; margin-left: 2em; }";
15709 ruleset = ruleset + ".wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }";
15710 }
15711 if (options.blockGap && hasBlockGapSupport) {
15712 const gapValue = getGapCSSValue(tree?.styles?.spacing?.blockGap) || "0.5em";
15713 ruleset = ruleset + `:root :where(.wp-site-blocks) > * { margin-block-start: ${gapValue}; margin-block-end: 0; }`;
15714 ruleset = ruleset + ":root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }";
15715 ruleset = ruleset + ":root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }";
15716 }
15717 if (options.presets) {
15718 nodesWithSettings.forEach(({ selector, presets }) => {
15719 if (ROOT_BLOCK_SELECTOR === selector || ROOT_CSS_PROPERTIES_SELECTOR === selector) {
15720 selector = "";
15721 }
15722 const classes = getPresetsClasses(selector, presets);
15723 if (classes.length > 0) {
15724 ruleset += classes;
15725 }
15726 });
15727 }
15728 return ruleset;
15729 };
15730 function generateSvgFilters(tree, blockSelectors) {
15731 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
15732 return nodesWithSettings.flatMap(({ presets }) => {
15733 return getPresetsSvgFilters(presets);
15734 });
15735 }
15736 var getSelectorsConfig = (blockType, rootSelector) => {
15737 if (blockType?.selectors && Object.keys(blockType.selectors).length > 0) {
15738 return blockType.selectors;
15739 }
15740 const config2 = {
15741 root: rootSelector
15742 };
15743 Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(
15744 ([featureKey, featureName]) => {
15745 const featureSelector = getBlockSelector(blockType, featureKey);
15746 if (featureSelector) {
15747 config2[featureName] = featureSelector;
15748 }
15749 }
15750 );
15751 return config2;
15752 };
15753 var getBlockSelectors = (blockTypes, variationInstanceId) => {
15754 const { getBlockStyles } = (0, import_data31.select)(import_blocks7.store);
15755 const result = {};
15756 blockTypes.forEach((blockType) => {
15757 const name2 = blockType.name;
15758 const selector = getBlockSelector(blockType);
15759 if (!selector) {
15760 return;
15761 }
15762 let duotoneSelector = getBlockSelector(blockType, "filter.duotone");
15763 if (!duotoneSelector) {
15764 const rootSelector = getBlockSelector(blockType);
15765 const duotoneSupport = (0, import_blocks7.getBlockSupport)(
15766 blockType,
15767 "color.__experimentalDuotone",
15768 false
15769 );
15770 duotoneSelector = duotoneSupport && rootSelector && scopeSelector(rootSelector, duotoneSupport);
15771 }
15772 const hasLayoutSupport = !!blockType?.supports?.layout || !!blockType?.supports?.__experimentalLayout;
15773 const fallbackGapValue = (
15774 // @ts-expect-error
15775 blockType?.supports?.spacing?.blockGap?.__experimentalDefault
15776 );
15777 const blockStyleVariations = getBlockStyles(name2);
15778 const styleVariationSelectors = {};
15779 blockStyleVariations?.forEach((variation) => {
15780 const variationSuffix = variationInstanceId ? `-${variationInstanceId}` : "";
15781 const variationName = `${variation.name}${variationSuffix}`;
15782 const styleVariationSelector = getBlockStyleVariationSelector(
15783 variationName,
15784 selector
15785 );
15786 styleVariationSelectors[variationName] = styleVariationSelector;
15787 });
15788 const featureSelectors = getSelectorsConfig(blockType, selector);
15789 result[name2] = {
15790 duotoneSelector: duotoneSelector ?? void 0,
15791 fallbackGapValue,
15792 featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : void 0,
15793 hasLayoutSupport,
15794 name: name2,
15795 selector,
15796 styleVariationSelectors: blockStyleVariations?.length ? styleVariationSelectors : void 0
15797 };
15798 });
15799 return result;
15800 };
15801 function updateConfigWithSeparator(config2) {
15802 const blocks = config2.styles?.blocks;
15803 const separatorBlock = blocks?.["core/separator"];
15804 const needsSeparatorStyleUpdate = separatorBlock && separatorBlock.color?.background && !separatorBlock.color?.text && !separatorBlock.border?.color;
15805 if (needsSeparatorStyleUpdate) {
15806 return {
15807 ...config2,
15808 styles: {
15809 ...config2.styles,
15810 blocks: {
15811 ...blocks,
15812 "core/separator": {
15813 ...separatorBlock,
15814 color: {
15815 ...separatorBlock.color,
15816 text: separatorBlock.color?.background
15817 }
15818 }
15819 }
15820 }
15821 };
15822 }
15823 return config2;
15824 }
15825 function processCSSNesting(css, blockSelector) {
15826 let processedCSS = "";
15827 if (!css || css.trim() === "") {
15828 return processedCSS;
15829 }
15830 const parts = css.split("&");
15831 parts.forEach((part) => {
15832 if (!part || part.trim() === "") {
15833 return;
15834 }
15835 const isRootCss = !part.includes("{");
15836 if (isRootCss) {
15837 processedCSS += `:root :where(${blockSelector}){${part.trim()}}`;
15838 } else {
15839 const splitPart = part.replace("}", "").split("{");
15840 if (splitPart.length !== 2) {
15841 return;
15842 }
15843 const [nestedSelector, cssValue] = splitPart;
15844 const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/);
15845 const pseudoPart = matches ? matches[1] : "";
15846 const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, "").trim() : nestedSelector.trim();
15847 let combinedSelector;
15848 if (withoutPseudoElement === "") {
15849 combinedSelector = blockSelector;
15850 } else {
15851 combinedSelector = nestedSelector.startsWith(" ") ? scopeSelector(blockSelector, withoutPseudoElement) : appendToSelector(blockSelector, withoutPseudoElement);
15852 }
15853 processedCSS += `:root :where(${combinedSelector})${pseudoPart}{${cssValue.trim()}}`;
15854 }
15855 });
15856 return processedCSS;
15857 }
15858 function generateGlobalStyles(config2 = {}, blockTypes = [], options = {}) {
15859 const {
15860 hasBlockGapSupport: hasBlockGapSupportOption,
15861 hasFallbackGapSupport: hasFallbackGapSupportOption,
15862 disableLayoutStyles = false,
15863 disableRootPadding = false,
15864 styleOptions = {}
15865 } = options;
15866 const blocks = blockTypes.length > 0 ? blockTypes : (0, import_blocks7.getBlockTypes)();
15867 const blockGap = getSetting(config2, "spacing.blockGap");
15868 const hasBlockGapSupport = hasBlockGapSupportOption ?? blockGap !== null;
15869 const hasFallbackGapSupport = hasFallbackGapSupportOption ?? !hasBlockGapSupport;
15870 if (!config2?.styles || !config2?.settings) {
15871 return [[], {}];
15872 }
15873 const updatedConfig = updateConfigWithSeparator(config2);
15874 const blockSelectors = getBlockSelectors(blocks);
15875 const customProperties = generateCustomProperties(
15876 updatedConfig,
15877 blockSelectors
15878 );
15879 const globalStyles = transformToStyles(
15880 updatedConfig,
15881 blockSelectors,
15882 hasBlockGapSupport,
15883 hasFallbackGapSupport,
15884 disableLayoutStyles,
15885 disableRootPadding,
15886 styleOptions
15887 );
15888 const svgs = generateSvgFilters(updatedConfig, blockSelectors);
15889 const styles = [
15890 {
15891 css: customProperties,
15892 isGlobalStyles: true
15893 },
15894 {
15895 css: globalStyles,
15896 isGlobalStyles: true
15897 },
15898 // Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.
15899 {
15900 css: updatedConfig?.styles?.css ?? "",
15901 isGlobalStyles: true
15902 },
15903 {
15904 assets: svgs,
15905 __unstableType: "svg",
15906 isGlobalStyles: true
15907 }
15908 ];
15909 blocks.forEach((blockType) => {
15910 const blockStyles = updatedConfig?.styles?.blocks?.[blockType.name];
15911 if (blockStyles?.css) {
15912 const selector = blockSelectors[blockType.name].selector;
15913 styles.push({
15914 css: processCSSNesting(blockStyles.css, selector),
15915 isGlobalStyles: true
15916 });
15917 }
15918 });
15919 return [styles, updatedConfig.settings];
15920 }
15921
15922 // packages/editor/build-module/components/global-styles-provider/index.mjs
15923 var { cleanEmptyObject } = unlock(import_block_editor6.privateApis);
15924 function useGlobalStylesUserConfig() {
15925 const { globalStylesId, isReady: isReady2, settings, styles, _links } = (0, import_data32.useSelect)(
15926 (select6) => {
15927 const {
15928 getEntityRecord,
15929 getEditedEntityRecord: getEditedEntityRecord2,
15930 hasFinishedResolution,
15931 canUser
15932 } = select6(import_core_data28.store);
15933 const _globalStylesId = select6(import_core_data28.store).__experimentalGetCurrentGlobalStylesId();
15934 let record;
15935 const userCanEditGlobalStyles = _globalStylesId ? canUser("update", {
15936 kind: "root",
15937 name: "globalStyles",
15938 id: _globalStylesId
15939 }) : null;
15940 if (_globalStylesId && /*
15941 * Test that the OPTIONS request for user capabilities is complete
15942 * before fetching the global styles entity record.
15943 * This is to avoid fetching the global styles entity unnecessarily.
15944 */
15945 typeof userCanEditGlobalStyles === "boolean") {
15946 if (userCanEditGlobalStyles) {
15947 record = getEditedEntityRecord2(
15948 "root",
15949 "globalStyles",
15950 _globalStylesId
15951 );
15952 } else {
15953 record = getEntityRecord(
15954 "root",
15955 "globalStyles",
15956 _globalStylesId,
15957 { context: "view" }
15958 );
15959 }
15960 }
15961 let hasResolved = false;
15962 if (hasFinishedResolution(
15963 "__experimentalGetCurrentGlobalStylesId"
15964 )) {
15965 if (_globalStylesId) {
15966 hasResolved = userCanEditGlobalStyles ? hasFinishedResolution("getEditedEntityRecord", [
15967 "root",
15968 "globalStyles",
15969 _globalStylesId
15970 ]) : hasFinishedResolution("getEntityRecord", [
15971 "root",
15972 "globalStyles",
15973 _globalStylesId,
15974 { context: "view" }
15975 ]);
15976 } else {
15977 hasResolved = true;
15978 }
15979 }
15980 return {
15981 globalStylesId: _globalStylesId,
15982 isReady: hasResolved,
15983 settings: record?.settings,
15984 styles: record?.styles,
15985 _links: record?._links
15986 };
15987 },
15988 []
15989 );
15990 const { getEditedEntityRecord } = (0, import_data32.useSelect)(import_core_data28.store);
15991 const { editEntityRecord } = (0, import_data32.useDispatch)(import_core_data28.store);
15992 const config2 = (0, import_element26.useMemo)(() => {
15993 return {
15994 settings: settings ?? {},
15995 styles: styles ?? {},
15996 _links: _links ?? {}
15997 };
15998 }, [settings, styles, _links]);
15999 const setConfig = (0, import_element26.useCallback)(
16000 /**
16001 * Set the global styles config.
16002 * @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values.
16003 * Otherwise, overwrite the current config with the incoming object.
16004 * @param {Object} options Options for editEntityRecord Core selector.
16005 */
16006 (callbackOrObject, options = {}) => {
16007 const record = getEditedEntityRecord(
16008 "root",
16009 "globalStyles",
16010 globalStylesId
16011 );
16012 const currentConfig = {
16013 styles: record?.styles ?? {},
16014 settings: record?.settings ?? {},
16015 _links: record?._links ?? {}
16016 };
16017 const updatedConfig = typeof callbackOrObject === "function" ? callbackOrObject(currentConfig) : callbackOrObject;
16018 editEntityRecord(
16019 "root",
16020 "globalStyles",
16021 globalStylesId,
16022 {
16023 styles: cleanEmptyObject(updatedConfig.styles) || {},
16024 settings: cleanEmptyObject(updatedConfig.settings) || {},
16025 _links: cleanEmptyObject(updatedConfig._links) || {}
16026 },
16027 options
16028 );
16029 },
16030 [globalStylesId, editEntityRecord, getEditedEntityRecord]
16031 );
16032 return [isReady2, config2, setConfig];
16033 }
16034 function useGlobalStylesBaseConfig() {
16035 const baseConfig = (0, import_data32.useSelect)(
16036 (select6) => select6(import_core_data28.store).__experimentalGetCurrentThemeBaseGlobalStyles(),
16037 []
16038 );
16039 return [!!baseConfig, baseConfig];
16040 }
16041 function useGlobalStylesContext() {
16042 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig();
16043 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig();
16044 const mergedConfig = (0, import_element26.useMemo)(() => {
16045 if (!baseConfig || !userConfig) {
16046 return {};
16047 }
16048 return mergeGlobalStyles(baseConfig, userConfig);
16049 }, [userConfig, baseConfig]);
16050 const context = (0, import_element26.useMemo)(() => {
16051 return {
16052 isReady: isUserConfigReady && isBaseConfigReady,
16053 user: userConfig,
16054 base: baseConfig,
16055 merged: mergedConfig,
16056 setUserConfig
16057 };
16058 }, [
16059 mergedConfig,
16060 userConfig,
16061 baseConfig,
16062 setUserConfig,
16063 isUserConfigReady,
16064 isBaseConfigReady
16065 ]);
16066 return context;
16067 }
16068
16069 // packages/editor/build-module/components/provider/use-block-editor-settings.mjs
16070 var EMPTY_OBJECT3 = {};
16071 function __experimentalReusableBlocksSelect(select6) {
16072 const { RECEIVE_INTERMEDIATE_RESULTS: RECEIVE_INTERMEDIATE_RESULTS2 } = unlock(import_core_data29.privateApis);
16073 const { getEntityRecords } = select6(import_core_data29.store);
16074 return getEntityRecords("postType", "wp_block", {
16075 per_page: -1,
16076 [RECEIVE_INTERMEDIATE_RESULTS2]: true
16077 });
16078 }
16079 var BLOCK_EDITOR_SETTINGS = [
16080 "__experimentalBlockBindingsSupportedAttributes",
16081 "__experimentalBlockDirectory",
16082 "__experimentalDiscussionSettings",
16083 "__experimentalFeatures",
16084 "__experimentalGlobalStylesBaseStyles",
16085 "allImageSizes",
16086 "alignWide",
16087 "blockInspectorTabs",
16088 "maxUploadFileSize",
16089 "allowedMimeTypes",
16090 "bodyPlaceholder",
16091 "canEditCSS",
16092 "canLockBlocks",
16093 "canUpdateBlockBindings",
16094 "capabilities",
16095 "clearBlockSelection",
16096 "codeEditingEnabled",
16097 "colors",
16098 "disableContentOnlyForUnsyncedPatterns",
16099 "disableCustomColors",
16100 "disableCustomFontSizes",
16101 "disableCustomSpacingSizes",
16102 "disableCustomGradients",
16103 "disableLayoutStyles",
16104 "enableCustomLineHeight",
16105 "enableCustomSpacing",
16106 "enableCustomUnits",
16107 "enableOpenverseMediaCategory",
16108 "fontSizes",
16109 "gradients",
16110 "generateAnchors",
16111 "onNavigateToEntityRecord",
16112 "imageDefaultSize",
16113 "imageDimensions",
16114 "imageEditing",
16115 "imageSizes",
16116 "isPreviewMode",
16117 "isRTL",
16118 "locale",
16119 "maxWidth",
16120 "postContentAttributes",
16121 "postsPerPage",
16122 "readOnly",
16123 "styles",
16124 "titlePlaceholder",
16125 "supportsLayout",
16126 "widgetTypesToHideFromLegacyWidgetBlock",
16127 "__unstableHasCustomAppender",
16128 "__unstableResolvedAssets",
16129 "__unstableIsBlockBasedTheme"
16130 ];
16131 var {
16132 globalStylesDataKey,
16133 globalStylesLinksDataKey,
16134 selectBlockPatternsKey,
16135 reusableBlocksSelectKey,
16136 sectionRootClientIdKey,
16137 mediaEditKey,
16138 getMediaSelectKey,
16139 isIsolatedEditorKey,
16140 deviceTypeKey,
16141 isNavigationOverlayContextKey,
16142 mediaUploadOnSuccessKey
16143 } = unlock(import_block_editor7.privateApis);
16144 function useBlockEditorSettings(settings, postType2, postId2, renderingMode2) {
16145 const isLargeViewport = (0, import_compose6.useViewportMatch)("medium");
16146 const {
16147 allImageSizes,
16148 bigImageSizeThreshold,
16149 allowRightClickOverrides,
16150 blockTypes,
16151 focusMode,
16152 hasFixedToolbar,
16153 isDistractionFree,
16154 keepCaretInsideBlock,
16155 hasUploadPermissions,
16156 hiddenBlockTypes,
16157 canUseUnfilteredHTML,
16158 userCanCreatePages,
16159 pageOnFront,
16160 pageForPosts,
16161 userPatternCategories,
16162 restBlockPatternCategories,
16163 sectionRootClientId,
16164 deviceType: deviceType2,
16165 isNavigationOverlayContext,
16166 isRevisionsMode: isRevisionsMode2
16167 } = (0, import_data33.useSelect)(
16168 (select6) => {
16169 const {
16170 canUser,
16171 getRawEntityRecord,
16172 getEntityRecord,
16173 getUserPatternCategories,
16174 getBlockPatternCategories
16175 } = select6(import_core_data29.store);
16176 const { get } = select6(import_preferences4.store);
16177 const { getBlockTypes: getBlockTypes6 } = select6(import_blocks8.store);
16178 const { getDeviceType: getDeviceType2, isRevisionsMode: _isRevisionsMode } = unlock(
16179 select6(store)
16180 );
16181 const { getBlocksByName, getBlockAttributes: getBlockAttributes2 } = select6(import_block_editor7.store);
16182 const siteSettings = canUser("read", {
16183 kind: "root",
16184 name: "site"
16185 }) ? getEntityRecord("root", "site") : void 0;
16186 const baseData = getEntityRecord("root", "__unstableBase");
16187 function getSectionRootBlock() {
16188 if (renderingMode2 === "template-locked") {
16189 return getBlocksByName("core/post-content")?.[0] ?? "";
16190 }
16191 return getBlocksByName("core/group").find(
16192 (clientId) => getBlockAttributes2(clientId)?.tagName === "main"
16193 ) ?? "";
16194 }
16195 return {
16196 allImageSizes: baseData?.image_sizes,
16197 bigImageSizeThreshold: baseData?.image_size_threshold,
16198 allowRightClickOverrides: get(
16199 "core",
16200 "allowRightClickOverrides"
16201 ),
16202 blockTypes: getBlockTypes6(),
16203 canUseUnfilteredHTML: getRawEntityRecord(
16204 "postType",
16205 postType2,
16206 postId2
16207 )?._links?.hasOwnProperty("wp:action-unfiltered-html"),
16208 focusMode: get("core", "focusMode"),
16209 hasFixedToolbar: get("core", "fixedToolbar") || !isLargeViewport,
16210 hiddenBlockTypes: get("core", "hiddenBlockTypes"),
16211 isDistractionFree: get("core", "distractionFree"),
16212 keepCaretInsideBlock: get("core", "keepCaretInsideBlock"),
16213 hasUploadPermissions: canUser("create", {
16214 kind: "postType",
16215 name: "attachment"
16216 }) ?? true,
16217 userCanCreatePages: canUser("create", {
16218 kind: "postType",
16219 name: "page"
16220 }),
16221 pageOnFront: siteSettings?.page_on_front,
16222 pageForPosts: siteSettings?.page_for_posts,
16223 userPatternCategories: getUserPatternCategories(),
16224 restBlockPatternCategories: getBlockPatternCategories(),
16225 sectionRootClientId: getSectionRootBlock(),
16226 deviceType: getDeviceType2(),
16227 isNavigationOverlayContext: postType2 === "wp_template_part" && postId2 ? getEntityRecord(
16228 "postType",
16229 "wp_template_part",
16230 postId2
16231 )?.area === "navigation-overlay" : false,
16232 isRevisionsMode: _isRevisionsMode()
16233 };
16234 },
16235 [postType2, postId2, isLargeViewport, renderingMode2]
16236 );
16237 const { merged: mergedGlobalStyles } = useGlobalStylesContext();
16238 const globalStylesData = mergedGlobalStyles.styles ?? EMPTY_OBJECT3;
16239 const globalStylesLinksData = mergedGlobalStyles._links ?? EMPTY_OBJECT3;
16240 const settingsBlockPatterns = settings.__experimentalAdditionalBlockPatterns ?? // WP 6.0
16241 settings.__experimentalBlockPatterns;
16242 const settingsBlockPatternCategories = settings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0
16243 settings.__experimentalBlockPatternCategories;
16244 const blockPatterns = (0, import_element27.useMemo)(
16245 () => [...settingsBlockPatterns || []].filter(
16246 ({ postTypes }) => {
16247 return !postTypes || Array.isArray(postTypes) && postTypes.includes(postType2);
16248 }
16249 ),
16250 [settingsBlockPatterns, postType2]
16251 );
16252 const blockPatternCategories = (0, import_element27.useMemo)(
16253 () => [
16254 ...settingsBlockPatternCategories || [],
16255 ...restBlockPatternCategories || []
16256 ].filter(
16257 (x2, index2, arr) => index2 === arr.findIndex((y3) => x2.name === y3.name)
16258 ),
16259 [settingsBlockPatternCategories, restBlockPatternCategories]
16260 );
16261 const { undo: undo2, setIsInserterOpened: setIsInserterOpened2 } = (0, import_data33.useDispatch)(store);
16262 const { editMediaEntity } = unlock((0, import_data33.useDispatch)(import_core_data29.store));
16263 const { saveEntityRecord } = (0, import_data33.useDispatch)(import_core_data29.store);
16264 const createPageEntity = (0, import_element27.useCallback)(
16265 (options) => {
16266 if (!userCanCreatePages) {
16267 return Promise.reject({
16268 message: (0, import_i18n62.__)(
16269 "You do not have permission to create Pages."
16270 )
16271 });
16272 }
16273 return saveEntityRecord("postType", "page", options);
16274 },
16275 [saveEntityRecord, userCanCreatePages]
16276 );
16277 const allowedBlockTypes = (0, import_element27.useMemo)(() => {
16278 if (hiddenBlockTypes && hiddenBlockTypes.length > 0) {
16279 const defaultAllowedBlockTypes = true === settings.allowedBlockTypes ? blockTypes.map(({ name: name2 }) => name2) : settings.allowedBlockTypes || [];
16280 return defaultAllowedBlockTypes.filter(
16281 (type) => !hiddenBlockTypes.includes(type)
16282 );
16283 }
16284 return settings.allowedBlockTypes;
16285 }, [settings.allowedBlockTypes, hiddenBlockTypes, blockTypes]);
16286 const forceDisableFocusMode = settings.focusMode === false;
16287 return (0, import_element27.useMemo)(() => {
16288 const blockEditorSettings = {
16289 ...Object.fromEntries(
16290 Object.entries(settings).filter(
16291 ([key]) => BLOCK_EDITOR_SETTINGS.includes(key)
16292 ).filter(([key]) => key !== "onNavigateToEntityRecord")
16293 ),
16294 [globalStylesDataKey]: globalStylesData,
16295 [globalStylesLinksDataKey]: globalStylesLinksData,
16296 allImageSizes,
16297 bigImageSizeThreshold,
16298 allowedBlockTypes,
16299 allowRightClickOverrides,
16300 focusMode: focusMode && !forceDisableFocusMode,
16301 hasFixedToolbar,
16302 isDistractionFree,
16303 keepCaretInsideBlock,
16304 onNavigateToEntityRecord: settings.onNavigateToEntityRecord,
16305 [getMediaSelectKey]: (select6, attachmentId) => {
16306 return select6(import_core_data29.store).getEntityRecord(
16307 "postType",
16308 "attachment",
16309 attachmentId
16310 );
16311 },
16312 [mediaEditKey]: hasUploadPermissions ? editMediaEntity : void 0,
16313 mediaUpload: hasUploadPermissions ? mediaUpload : void 0,
16314 [mediaUploadOnSuccessKey]: hasUploadPermissions ? mediaUploadOnSuccess : void 0,
16315 mediaSideload: hasUploadPermissions ? media_sideload_default : void 0,
16316 mediaFinalize: hasUploadPermissions ? mediaFinalize : void 0,
16317 __experimentalBlockPatterns: blockPatterns,
16318 [selectBlockPatternsKey]: (select6) => {
16319 const { hasFinishedResolution, getBlockPatternsForPostType } = unlock(select6(import_core_data29.store));
16320 const patterns2 = getBlockPatternsForPostType(postType2);
16321 return hasFinishedResolution("getBlockPatterns") ? patterns2 : void 0;
16322 },
16323 [reusableBlocksSelectKey]: __experimentalReusableBlocksSelect,
16324 __experimentalBlockPatternCategories: blockPatternCategories,
16325 __experimentalUserPatternCategories: userPatternCategories,
16326 __experimentalFetchLinkSuggestions: (search, searchOptions) => (0, import_core_data29.__experimentalFetchLinkSuggestions)(search, searchOptions, settings),
16327 inserterMediaCategories: media_categories_default,
16328 __experimentalFetchRichUrlData: import_core_data29.__experimentalFetchUrlData,
16329 // Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.
16330 // This might be better as a generic "canUser" selector.
16331 __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
16332 //Todo: this is only needed for native and should probably be removed.
16333 __experimentalUndo: undo2,
16334 // Check whether we want all site editor frames to have outlines
16335 // including the navigation / pattern / parts editors.
16336 outlineMode: !isDistractionFree && postType2 === "wp_template",
16337 // Check these two properties: they were not present in the site editor.
16338 __experimentalCreatePageEntity: createPageEntity,
16339 __experimentalUserCanCreatePages: userCanCreatePages,
16340 pageOnFront,
16341 pageForPosts,
16342 __experimentalPreferPatternsOnRoot: postType2 === "wp_template",
16343 templateLock: postType2 === "wp_navigation" ? "insert" : settings.templateLock,
16344 template: postType2 === "wp_navigation" ? [["core/navigation", {}, []]] : settings.template,
16345 __experimentalSetIsInserterOpened: setIsInserterOpened2,
16346 [sectionRootClientIdKey]: sectionRootClientId,
16347 editorTool: renderingMode2 === "post-only" && postType2 !== "wp_template" ? "edit" : void 0,
16348 // When editing template parts, patterns, or navigation directly,
16349 // we're in an isolated editing context (focused on that entity alone).
16350 [isIsolatedEditorKey]: [
16351 "wp_template_part",
16352 "wp_block",
16353 "wp_navigation"
16354 ].includes(postType2),
16355 // When in template-locked mode (e.g., "Show Template" in the post editor),
16356 // don't treat template parts as contentOnly sections.
16357 disableContentOnlyForTemplateParts: renderingMode2 === "template-locked",
16358 ...deviceType2 ? { [deviceTypeKey]: deviceType2 } : {},
16359 [isNavigationOverlayContextKey]: isNavigationOverlayContext
16360 };
16361 if (isRevisionsMode2) {
16362 blockEditorSettings.isPreviewMode = true;
16363 }
16364 return blockEditorSettings;
16365 }, [
16366 isRevisionsMode2,
16367 allowedBlockTypes,
16368 allowRightClickOverrides,
16369 focusMode,
16370 forceDisableFocusMode,
16371 hasFixedToolbar,
16372 isDistractionFree,
16373 keepCaretInsideBlock,
16374 settings,
16375 hasUploadPermissions,
16376 userPatternCategories,
16377 blockPatterns,
16378 blockPatternCategories,
16379 canUseUnfilteredHTML,
16380 undo2,
16381 createPageEntity,
16382 userCanCreatePages,
16383 pageOnFront,
16384 pageForPosts,
16385 postType2,
16386 setIsInserterOpened2,
16387 sectionRootClientId,
16388 globalStylesData,
16389 globalStylesLinksData,
16390 renderingMode2,
16391 editMediaEntity,
16392 settings.onNavigateToEntityRecord,
16393 deviceType2,
16394 allImageSizes,
16395 bigImageSizeThreshold,
16396 isNavigationOverlayContext
16397 ]);
16398 }
16399 var use_block_editor_settings_default = useBlockEditorSettings;
16400
16401 // packages/editor/build-module/components/provider/disable-non-page-content-blocks.mjs
16402 var import_data34 = __toESM(require_data(), 1);
16403 var import_block_editor8 = __toESM(require_block_editor(), 1);
16404 var import_element29 = __toESM(require_element(), 1);
16405
16406 // packages/editor/build-module/components/provider/use-post-content-block-types.mjs
16407 var import_element28 = __toESM(require_element(), 1);
16408 var import_hooks4 = __toESM(require_hooks(), 1);
16409 var POST_CONTENT_BLOCK_TYPES = [
16410 "core/post-title",
16411 "core/post-featured-image",
16412 "core/post-content"
16413 ];
16414 function usePostContentBlockTypes() {
16415 return (0, import_element28.useMemo)(
16416 () => [
16417 ...(0, import_hooks4.applyFilters)(
16418 "editor.postContentBlockTypes",
16419 POST_CONTENT_BLOCK_TYPES
16420 )
16421 ],
16422 []
16423 );
16424 }
16425
16426 // packages/editor/build-module/components/provider/disable-non-page-content-blocks.mjs
16427 function DisableNonPageContentBlocks() {
16428 const postContentBlockTypes = usePostContentBlockTypes();
16429 const { contentOnlyIds, templateParts } = (0, import_data34.useSelect)(
16430 (select6) => {
16431 const { getPostBlocksByName: getPostBlocksByName2 } = unlock(select6(store));
16432 const { getBlocksByName } = select6(import_block_editor8.store);
16433 return {
16434 contentOnlyIds: getPostBlocksByName2(postContentBlockTypes),
16435 templateParts: getBlocksByName("core/template-part")
16436 };
16437 },
16438 [postContentBlockTypes]
16439 );
16440 const templatePartChildren = (0, import_data34.useSelect)(
16441 (select6) => {
16442 const { getBlockOrder: getBlockOrder2 } = select6(import_block_editor8.store);
16443 return templateParts.flatMap(
16444 (clientId) => getBlockOrder2(clientId)
16445 );
16446 },
16447 [templateParts]
16448 );
16449 const registry = (0, import_data34.useRegistry)();
16450 (0, import_element29.useEffect)(() => {
16451 const {
16452 setBlockEditingMode,
16453 unsetBlockEditingMode,
16454 __unstableMarkNextChangeAsNotPersistent
16455 } = registry.dispatch(import_block_editor8.store);
16456 __unstableMarkNextChangeAsNotPersistent();
16457 setBlockEditingMode("", "disabled");
16458 return () => {
16459 __unstableMarkNextChangeAsNotPersistent();
16460 unsetBlockEditingMode("");
16461 };
16462 }, [registry]);
16463 (0, import_element29.useEffect)(() => {
16464 const {
16465 setBlockEditingMode,
16466 unsetBlockEditingMode,
16467 __unstableMarkNextChangeAsNotPersistent
16468 } = registry.dispatch(import_block_editor8.store);
16469 registry.batch(() => {
16470 for (const clientId of templateParts) {
16471 __unstableMarkNextChangeAsNotPersistent();
16472 setBlockEditingMode(clientId, "contentOnly");
16473 }
16474 });
16475 return () => {
16476 registry.batch(() => {
16477 for (const clientId of templateParts) {
16478 __unstableMarkNextChangeAsNotPersistent();
16479 unsetBlockEditingMode(clientId);
16480 }
16481 });
16482 };
16483 }, [templateParts, registry]);
16484 (0, import_element29.useEffect)(() => {
16485 const {
16486 setBlockEditingMode,
16487 unsetBlockEditingMode,
16488 __unstableMarkNextChangeAsNotPersistent
16489 } = registry.dispatch(import_block_editor8.store);
16490 const contentOnlySet = new Set(contentOnlyIds);
16491 registry.batch(() => {
16492 for (const clientId of contentOnlyIds) {
16493 __unstableMarkNextChangeAsNotPersistent();
16494 setBlockEditingMode(clientId, "contentOnly");
16495 }
16496 for (const clientId of templatePartChildren) {
16497 if (!contentOnlySet.has(clientId)) {
16498 __unstableMarkNextChangeAsNotPersistent();
16499 setBlockEditingMode(clientId, "disabled");
16500 }
16501 }
16502 });
16503 return () => {
16504 registry.batch(() => {
16505 for (const clientId of contentOnlyIds) {
16506 __unstableMarkNextChangeAsNotPersistent();
16507 unsetBlockEditingMode(clientId);
16508 }
16509 for (const clientId of templatePartChildren) {
16510 if (!contentOnlySet.has(clientId)) {
16511 __unstableMarkNextChangeAsNotPersistent();
16512 unsetBlockEditingMode(clientId);
16513 }
16514 }
16515 });
16516 };
16517 }, [contentOnlyIds, templatePartChildren, registry]);
16518 return null;
16519 }
16520
16521 // packages/editor/build-module/components/provider/navigation-block-editing-mode.mjs
16522 var import_element30 = __toESM(require_element(), 1);
16523 var import_data35 = __toESM(require_data(), 1);
16524 var import_block_editor9 = __toESM(require_block_editor(), 1);
16525 function NavigationBlockEditingMode() {
16526 const registry = (0, import_data35.useRegistry)();
16527 const blockClientId = (0, import_data35.useSelect)(
16528 (select6) => select6(import_block_editor9.store).getBlockOrder()?.[0],
16529 []
16530 );
16531 (0, import_element30.useEffect)(() => {
16532 if (!blockClientId) {
16533 return;
16534 }
16535 const {
16536 setBlockEditingMode,
16537 unsetBlockEditingMode,
16538 __unstableMarkNextChangeAsNotPersistent
16539 } = registry.dispatch(import_block_editor9.store);
16540 __unstableMarkNextChangeAsNotPersistent();
16541 setBlockEditingMode(blockClientId, "contentOnly");
16542 return () => {
16543 __unstableMarkNextChangeAsNotPersistent();
16544 unsetBlockEditingMode(blockClientId);
16545 };
16546 }, [registry, blockClientId]);
16547 }
16548
16549 // packages/editor/build-module/components/provider/use-hide-blocks-from-inserter.mjs
16550 var import_element31 = __toESM(require_element(), 1);
16551 var import_hooks5 = __toESM(require_hooks(), 1);
16552 var POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = [
16553 "wp_block",
16554 "wp_template",
16555 "wp_template_part"
16556 ];
16557 function useHideBlocksFromInserter(postType2, mode) {
16558 (0, import_element31.useEffect)(() => {
16559 (0, import_hooks5.addFilter)(
16560 "blockEditor.__unstableCanInsertBlockType",
16561 "removeTemplatePartsFromInserter",
16562 (canInsert, blockType) => {
16563 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(
16564 postType2
16565 ) && blockType.name === "core/template-part" && mode === "post-only") {
16566 return false;
16567 }
16568 return canInsert;
16569 }
16570 );
16571 (0, import_hooks5.addFilter)(
16572 "blockEditor.__unstableCanInsertBlockType",
16573 "removePostContentFromInserter",
16574 (canInsert, blockType, rootClientId, { getBlockParentsByBlockName }) => {
16575 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(
16576 postType2
16577 ) && blockType.name === "core/post-content") {
16578 return getBlockParentsByBlockName(rootClientId, "core/query").length > 0;
16579 }
16580 return canInsert;
16581 }
16582 );
16583 return () => {
16584 (0, import_hooks5.removeFilter)(
16585 "blockEditor.__unstableCanInsertBlockType",
16586 "removeTemplatePartsFromInserter"
16587 );
16588 (0, import_hooks5.removeFilter)(
16589 "blockEditor.__unstableCanInsertBlockType",
16590 "removePostContentFromInserter"
16591 );
16592 };
16593 }, [postType2, mode]);
16594 }
16595
16596 // packages/editor/build-module/components/provider/use-revision-blocks.mjs
16597 var import_data36 = __toESM(require_data(), 1);
16598 var import_element32 = __toESM(require_element(), 1);
16599 var import_blocks10 = __toESM(require_blocks(), 1);
16600
16601 // packages/editor/build-module/components/post-revisions-preview/block-diff.mjs
16602 var import_array = __toESM(require_array(), 1);
16603 var import_word = __toESM(require_word(), 1);
16604 var import_block_serialization_default_parser = __toESM(require_block_serialization_default_parser(), 1);
16605 var import_blocks9 = __toESM(require_blocks(), 1);
16606 var import_rich_text = __toESM(require_rich_text(), 1);
16607 var import_i18n63 = __toESM(require_i18n(), 1);
16608 var { parseRawBlock } = unlock(import_blocks9.privateApis);
16609 function stringifyValue(value) {
16610 if (value === null || value === void 0) {
16611 return "";
16612 }
16613 if (typeof value === "object") {
16614 return JSON.stringify(value, null, 2);
16615 }
16616 return String(value);
16617 }
16618 function textSimilarity(text1, text2) {
16619 if (!text1 && !text2) {
16620 return 1;
16621 }
16622 if (!text1 || !text2) {
16623 return 0;
16624 }
16625 const segmenter = new Intl.Segmenter(void 0, {
16626 granularity: "word"
16627 });
16628 const wordLikeRegex = /[\p{L}\p{N}]/u;
16629 const getWords = (text) => {
16630 const words = [];
16631 for (const { segment, isWordLike } of segmenter.segment(text)) {
16632 if (isWordLike || wordLikeRegex.test(segment)) {
16633 words.push(segment);
16634 }
16635 }
16636 return words;
16637 };
16638 const words1 = getWords(text1);
16639 const words2 = getWords(text2);
16640 if (words1.length === 0 && words2.length === 0) {
16641 return 1;
16642 }
16643 const set1 = new Set(words1);
16644 let intersection = 0;
16645 for (const word of words2) {
16646 if (set1.has(word)) {
16647 intersection++;
16648 }
16649 }
16650 const total = Math.max(words1.length, words2.length);
16651 return total > 0 ? intersection / total : 0;
16652 }
16653 function pairSimilarBlocks(blocks) {
16654 const removed = [];
16655 const added = [];
16656 blocks.forEach((block, index2) => {
16657 const status = block.__revisionDiffStatus?.status;
16658 if (status === "removed") {
16659 removed.push({ block, index: index2 });
16660 } else if (status === "added") {
16661 added.push({ block, index: index2 });
16662 }
16663 });
16664 if (removed.length === 0 || added.length === 0) {
16665 return blocks;
16666 }
16667 const pairedRemoved = /* @__PURE__ */ new Set();
16668 const pairedAdded = /* @__PURE__ */ new Set();
16669 const modifications = /* @__PURE__ */ new Map();
16670 const SIMILARITY_THRESHOLD = 0.5;
16671 const addedByName = /* @__PURE__ */ new Map();
16672 for (const add of added) {
16673 const name2 = add.block.blockName;
16674 if (!addedByName.has(name2)) {
16675 addedByName.set(name2, []);
16676 }
16677 addedByName.get(name2).push(add);
16678 }
16679 const removedByName = /* @__PURE__ */ new Map();
16680 for (const rem of removed) {
16681 const name2 = rem.block.blockName;
16682 if (!removedByName.has(name2)) {
16683 removedByName.set(name2, []);
16684 }
16685 removedByName.get(name2).push(rem);
16686 }
16687 let maxPairedAddedIndex = -1;
16688 for (const rem of removed) {
16689 const candidates = addedByName.get(rem.block.blockName) || [];
16690 const sameNameRemoved = removedByName.get(rem.block.blockName) || [];
16691 const unpaired = candidates.filter(
16692 (add) => !modifications.has(add.index) && add.index > maxPairedAddedIndex
16693 );
16694 if (unpaired.length === 0) {
16695 continue;
16696 }
16697 let bestMatch = null;
16698 if (sameNameRemoved.length === 1 && unpaired.length === 1) {
16699 const add = unpaired[0];
16700 const attrsMatch = JSON.stringify(rem.block.attrs) === JSON.stringify(add.block.attrs);
16701 const contentMatch = (rem.block.innerHTML || "") === (add.block.innerHTML || "");
16702 if (!contentMatch || !attrsMatch) {
16703 bestMatch = add;
16704 }
16705 } else {
16706 let bestScore = 0;
16707 for (const add of unpaired) {
16708 const score = textSimilarity(
16709 rem.block.innerHTML || "",
16710 add.block.innerHTML || ""
16711 );
16712 const attrsMatch = JSON.stringify(rem.block.attrs) === JSON.stringify(add.block.attrs);
16713 if (score > bestScore && score > SIMILARITY_THRESHOLD && (score < 1 || !attrsMatch)) {
16714 bestScore = score;
16715 bestMatch = add;
16716 }
16717 }
16718 }
16719 if (bestMatch) {
16720 maxPairedAddedIndex = bestMatch.index;
16721 const modifiedBlock = {
16722 ...bestMatch.block,
16723 __revisionDiffStatus: { status: "modified" },
16724 __previousRawBlock: rem.block
16725 };
16726 const lo = Math.min(rem.index, bestMatch.index);
16727 const hi = Math.max(rem.index, bestMatch.index);
16728 let hasAddedBetween = false;
16729 for (let i3 = lo + 1; i3 < hi; i3++) {
16730 if (blocks[i3].__revisionDiffStatus?.status === "added" && !pairedAdded.has(i3)) {
16731 hasAddedBetween = true;
16732 break;
16733 }
16734 }
16735 if (hasAddedBetween) {
16736 modifications.set(bestMatch.index, modifiedBlock);
16737 pairedRemoved.add(rem.index);
16738 } else {
16739 modifications.set(rem.index, modifiedBlock);
16740 pairedAdded.add(bestMatch.index);
16741 }
16742 }
16743 }
16744 return blocks.map((block, index2) => {
16745 if (pairedRemoved.has(index2) || pairedAdded.has(index2)) {
16746 return null;
16747 }
16748 if (modifications.has(index2)) {
16749 return modifications.get(index2);
16750 }
16751 return block;
16752 }).filter(Boolean);
16753 }
16754 function diffRawBlocks(currentRaw, previousRaw) {
16755 const createBlockSignature = (rawBlock) => JSON.stringify({
16756 name: rawBlock.blockName,
16757 attrs: rawBlock.attrs,
16758 // Use innerContent filtered to non-null and non-whitespace-only strings.
16759 // This excludes whitespace between inner blocks which changes based on count.
16760 html: (rawBlock.innerContent || []).filter(
16761 (c6) => c6 !== null && c6.trim() !== ""
16762 )
16763 });
16764 const currentSigs = currentRaw.map(createBlockSignature);
16765 const previousSigs = previousRaw.map(createBlockSignature);
16766 const diff = (0, import_array.diffArrays)(previousSigs, currentSigs);
16767 const result = [];
16768 let currIdx = 0;
16769 let prevIdx = 0;
16770 for (const part of diff) {
16771 if (part.added) {
16772 for (let i3 = 0; i3 < part.count; i3++) {
16773 result.push({
16774 ...currentRaw[currIdx++],
16775 __revisionDiffStatus: { status: "added" }
16776 });
16777 }
16778 } else if (part.removed) {
16779 for (let i3 = 0; i3 < part.count; i3++) {
16780 result.push({
16781 ...previousRaw[prevIdx++],
16782 __revisionDiffStatus: { status: "removed" }
16783 });
16784 }
16785 } else {
16786 for (let i3 = 0; i3 < part.count; i3++) {
16787 const currBlock = currentRaw[currIdx++];
16788 const prevBlock = previousRaw[prevIdx++];
16789 const diffedInnerBlocks = diffRawBlocks(
16790 currBlock.innerBlocks || [],
16791 prevBlock.innerBlocks || []
16792 );
16793 result.push({
16794 ...currBlock,
16795 innerBlocks: diffedInnerBlocks
16796 });
16797 }
16798 }
16799 }
16800 return pairSimilarBlocks(result);
16801 }
16802 function hasFormatChangedAtIndex(currentFormats, previousFormats, currentIndex, previousIndex) {
16803 const currFmts = currentFormats[currentIndex] || [];
16804 const prevFmts = previousFormats[previousIndex] || [];
16805 if (currFmts.length !== prevFmts.length) {
16806 return true;
16807 }
16808 for (const fmt of currFmts) {
16809 const match3 = prevFmts.find(
16810 (pf) => pf.type === fmt.type && JSON.stringify(pf.attributes) === JSON.stringify(fmt.attributes)
16811 );
16812 if (!match3) {
16813 return true;
16814 }
16815 }
16816 return false;
16817 }
16818 function describeFormatChange(currentFormats, previousFormats, currIdx, prevIdx) {
16819 const currFmts = currentFormats[currIdx] || [];
16820 const prevFmts = previousFormats[prevIdx] || [];
16821 let addedCount = 0;
16822 let removedCount = 0;
16823 let changedCount = 0;
16824 for (const fmt of currFmts) {
16825 const match3 = prevFmts.find((pf) => pf.type === fmt.type);
16826 if (!match3) {
16827 addedCount++;
16828 } else if (JSON.stringify(fmt.attributes) !== JSON.stringify(match3.attributes)) {
16829 changedCount++;
16830 }
16831 }
16832 for (const fmt of prevFmts) {
16833 const match3 = currFmts.find((cf) => cf.type === fmt.type);
16834 if (!match3) {
16835 removedCount++;
16836 }
16837 }
16838 if (addedCount > 0 && removedCount === 0 && changedCount === 0) {
16839 return {
16840 type: "added",
16841 description: (0, import_i18n63.sprintf)(
16842 /* translators: %d: number of formats added */
16843 (0, import_i18n63._n)("%d format added", "%d formats added", addedCount),
16844 addedCount
16845 )
16846 };
16847 }
16848 if (removedCount > 0 && addedCount === 0 && changedCount === 0) {
16849 return {
16850 type: "removed",
16851 description: (0, import_i18n63.sprintf)(
16852 /* translators: %d: number of formats removed */
16853 (0, import_i18n63._n)("%d format removed", "%d formats removed", removedCount),
16854 removedCount
16855 )
16856 };
16857 }
16858 const parts = [];
16859 if (addedCount > 0) {
16860 parts.push(
16861 (0, import_i18n63.sprintf)(
16862 /* translators: %d: number of formats added */
16863 (0, import_i18n63._n)("%d format added", "%d formats added", addedCount),
16864 addedCount
16865 )
16866 );
16867 }
16868 if (removedCount > 0) {
16869 parts.push(
16870 (0, import_i18n63.sprintf)(
16871 /* translators: %d: number of formats removed */
16872 (0, import_i18n63._n)("%d format removed", "%d formats removed", removedCount),
16873 removedCount
16874 )
16875 );
16876 }
16877 if (changedCount > 0) {
16878 parts.push(
16879 (0, import_i18n63.sprintf)(
16880 /* translators: %d: number of formats changed */
16881 (0, import_i18n63._n)("%d format changed", "%d formats changed", changedCount),
16882 changedCount
16883 )
16884 );
16885 }
16886 return {
16887 type: "changed",
16888 description: parts.join(", ") || (0, import_i18n63.__)("Formatting changed")
16889 };
16890 }
16891 function applyRichTextDiff(currentRichText, previousRichText) {
16892 const currentText = currentRichText.toPlainText();
16893 const previousText = previousRichText.toPlainText();
16894 const textDiff = (0, import_word.diffWords)(previousText, currentText);
16895 let result = (0, import_rich_text.create)({ text: "" });
16896 let currentIdx = 0;
16897 let previousIdx = 0;
16898 for (const part of textDiff) {
16899 if (part.removed) {
16900 const removedSlice = (0, import_rich_text.slice)(
16901 previousRichText,
16902 previousIdx,
16903 previousIdx + part.value.length
16904 );
16905 const formatted = (0, import_rich_text.applyFormat)(
16906 removedSlice,
16907 {
16908 type: "revision/diff-removed",
16909 attributes: { title: (0, import_i18n63.__)("Removed") }
16910 },
16911 0,
16912 part.value.length
16913 );
16914 result = (0, import_rich_text.concat)(result, formatted);
16915 previousIdx += part.value.length;
16916 } else if (part.added) {
16917 const addedSlice = (0, import_rich_text.slice)(
16918 currentRichText,
16919 currentIdx,
16920 currentIdx + part.value.length
16921 );
16922 const formatted = (0, import_rich_text.applyFormat)(
16923 addedSlice,
16924 {
16925 type: "revision/diff-added",
16926 attributes: { title: (0, import_i18n63.__)("Added") }
16927 },
16928 0,
16929 part.value.length
16930 );
16931 result = (0, import_rich_text.concat)(result, formatted);
16932 currentIdx += part.value.length;
16933 } else {
16934 const currentFormats = currentRichText.formats || [];
16935 const previousFormats = previousRichText.formats || [];
16936 const len = part.value.length;
16937 const checkFormatChanged = (offset3) => hasFormatChangedAtIndex(
16938 currentFormats,
16939 previousFormats,
16940 currentIdx + offset3,
16941 previousIdx + offset3
16942 );
16943 let rangeStart = 0;
16944 let rangeFormatChanged = checkFormatChanged(0);
16945 for (let i3 = 1; i3 <= len; i3++) {
16946 const formatChanged = i3 < len && checkFormatChanged(i3);
16947 if (i3 === len || formatChanged !== rangeFormatChanged) {
16948 const rangeSlice = (0, import_rich_text.slice)(
16949 currentRichText,
16950 currentIdx + rangeStart,
16951 currentIdx + i3
16952 );
16953 if (rangeFormatChanged) {
16954 const { type, description } = describeFormatChange(
16955 currentFormats,
16956 previousFormats,
16957 currentIdx + rangeStart,
16958 previousIdx + rangeStart
16959 );
16960 const formatType = {
16961 added: "revision/diff-format-added",
16962 removed: "revision/diff-format-removed",
16963 changed: "revision/diff-format-changed"
16964 }[type];
16965 const marked = (0, import_rich_text.applyFormat)(
16966 rangeSlice,
16967 {
16968 type: formatType,
16969 attributes: { title: description }
16970 },
16971 0,
16972 i3 - rangeStart
16973 );
16974 result = (0, import_rich_text.concat)(result, marked);
16975 } else {
16976 result = (0, import_rich_text.concat)(result, rangeSlice);
16977 }
16978 rangeStart = i3;
16979 rangeFormatChanged = formatChanged;
16980 }
16981 }
16982 currentIdx += part.value.length;
16983 previousIdx += part.value.length;
16984 }
16985 }
16986 return new import_rich_text.RichTextData(result);
16987 }
16988 function applyDiffToBlock(currentBlock, previousBlock, diffStatus) {
16989 const blockType = (0, import_blocks9.getBlockType)(currentBlock.name);
16990 if (!blockType) {
16991 return;
16992 }
16993 const changedAttributes = {};
16994 for (const [attrName, attrDef] of Object.entries(
16995 blockType.attributes
16996 )) {
16997 if (attrDef.source === "rich-text") {
16998 const currentRichText = currentBlock.attributes[attrName];
16999 const previousRichText = previousBlock.attributes[attrName];
17000 if (currentRichText instanceof import_rich_text.RichTextData && previousRichText instanceof import_rich_text.RichTextData) {
17001 currentBlock.attributes[attrName] = applyRichTextDiff(
17002 currentRichText,
17003 previousRichText
17004 );
17005 }
17006 } else {
17007 const currStr = stringifyValue(
17008 currentBlock.attributes[attrName]
17009 );
17010 const prevStr = stringifyValue(
17011 previousBlock.attributes[attrName]
17012 );
17013 if (currStr !== prevStr) {
17014 changedAttributes[attrName] = (0, import_word.diffWords)(prevStr, currStr);
17015 }
17016 }
17017 }
17018 if (Object.keys(changedAttributes).length > 0) {
17019 diffStatus.changedAttributes = changedAttributes;
17020 }
17021 }
17022 function applyDiffRecursively(parsedBlock, rawBlock) {
17023 if (rawBlock.__revisionDiffStatus) {
17024 if (rawBlock.__revisionDiffStatus.status === "modified" && rawBlock.__previousRawBlock) {
17025 const previousParsed = parseRawBlock(rawBlock.__previousRawBlock);
17026 if (previousParsed) {
17027 applyDiffToBlock(
17028 parsedBlock,
17029 previousParsed,
17030 rawBlock.__revisionDiffStatus
17031 );
17032 }
17033 }
17034 parsedBlock.__revisionDiffStatus = rawBlock.__revisionDiffStatus;
17035 parsedBlock.attributes.__revisionDiffStatus = rawBlock.__revisionDiffStatus;
17036 }
17037 if (parsedBlock.innerBlocks && rawBlock.innerBlocks) {
17038 for (let i3 = 0; i3 < parsedBlock.innerBlocks.length; i3++) {
17039 const parsedInner = parsedBlock.innerBlocks[i3];
17040 const rawInner = rawBlock.innerBlocks[i3];
17041 if (parsedInner && rawInner) {
17042 applyDiffRecursively(parsedInner, rawInner);
17043 }
17044 }
17045 }
17046 }
17047 function diffRevisionContent(currentContent, previousContent) {
17048 const currentRaw = (0, import_block_serialization_default_parser.parse)(currentContent || "");
17049 const previousRaw = (0, import_block_serialization_default_parser.parse)(previousContent || "");
17050 const mergedRaw = diffRawBlocks(currentRaw, previousRaw);
17051 return mergedRaw.map((rawBlock) => {
17052 const parsed = parseRawBlock(rawBlock);
17053 if (parsed) {
17054 applyDiffRecursively(parsed, rawBlock);
17055 }
17056 return parsed;
17057 }).filter(Boolean);
17058 }
17059
17060 // packages/editor/build-module/components/post-revisions-preview/preserve-client-ids.mjs
17061 var import_array2 = __toESM(require_array(), 1);
17062 function preserveClientIds(newBlocks, prevBlocks) {
17063 if (!prevBlocks?.length || !newBlocks?.length) {
17064 return newBlocks;
17065 }
17066 const newSigs = newBlocks.map((block) => block.name);
17067 const prevSigs = prevBlocks.map((block) => block.name);
17068 const diffResult = (0, import_array2.diffArrays)(prevSigs, newSigs);
17069 let newIndex = 0;
17070 let prevIndex = 0;
17071 const result = [];
17072 for (const chunk of diffResult) {
17073 if (chunk.removed) {
17074 prevIndex += chunk.count;
17075 } else if (chunk.added) {
17076 for (let i3 = 0; i3 < chunk.count; i3++) {
17077 result.push(newBlocks[newIndex++]);
17078 }
17079 } else {
17080 for (let i3 = 0; i3 < chunk.count; i3++) {
17081 const newBlock = newBlocks[newIndex++];
17082 const prevBlock = prevBlocks[prevIndex++];
17083 result.push({
17084 ...newBlock,
17085 clientId: prevBlock.clientId,
17086 innerBlocks: preserveClientIds(
17087 newBlock.innerBlocks,
17088 prevBlock.innerBlocks
17089 )
17090 });
17091 }
17092 }
17093 }
17094 return result;
17095 }
17096
17097 // packages/editor/build-module/components/provider/use-revision-blocks.mjs
17098 function useRevisionBlocks() {
17099 const {
17100 isInRevisionsMode,
17101 showDiff,
17102 revision,
17103 previousRevision,
17104 postType: postType2
17105 } = (0, import_data36.useSelect)((select6) => {
17106 const {
17107 isRevisionsMode: isRevisionsMode2,
17108 isShowingRevisionDiff: isShowingRevisionDiff2,
17109 getCurrentRevision: getCurrentRevision2,
17110 getPreviousRevision: getPreviousRevision2
17111 } = unlock(select6(store));
17112 const { getCurrentPostType: getCurrentPostType2 } = select6(store);
17113 const inRevisions = isRevisionsMode2();
17114 return {
17115 isInRevisionsMode: inRevisions,
17116 showDiff: isShowingRevisionDiff2(),
17117 revision: inRevisions ? getCurrentRevision2() : void 0,
17118 previousRevision: inRevisions ? getPreviousRevision2() : void 0,
17119 postType: getCurrentPostType2()
17120 };
17121 }, []);
17122 const previousBlocksRef = (0, import_element32.useRef)([]);
17123 const blocks = (0, import_element32.useMemo)(() => {
17124 if (!isInRevisionsMode) {
17125 previousBlocksRef.current = [];
17126 return null;
17127 }
17128 if (!revision) {
17129 return [];
17130 }
17131 const currentContent = revision?.content?.raw ?? "";
17132 let parsedBlocks;
17133 if (showDiff) {
17134 const previousContent = previousRevision?.content?.raw || "";
17135 parsedBlocks = diffRevisionContent(
17136 currentContent,
17137 previousContent
17138 );
17139 } else {
17140 parsedBlocks = (0, import_blocks10.parse)(currentContent);
17141 }
17142 if (postType2 === "wp_navigation") {
17143 parsedBlocks = [
17144 (0, import_blocks10.createBlock)(
17145 "core/navigation",
17146 { templateLock: false },
17147 parsedBlocks
17148 )
17149 ];
17150 }
17151 const blocksWithStableIds = preserveClientIds(
17152 parsedBlocks,
17153 previousBlocksRef.current
17154 );
17155 previousBlocksRef.current = blocksWithStableIds;
17156 return blocksWithStableIds;
17157 }, [
17158 isInRevisionsMode,
17159 revision,
17160 revision?.content?.raw,
17161 previousRevision?.content?.raw,
17162 postType2,
17163 showDiff
17164 ]);
17165 return blocks;
17166 }
17167
17168 // packages/editor/build-module/components/commands/index.mjs
17169 var import_data44 = __toESM(require_data(), 1);
17170 var import_i18n66 = __toESM(require_i18n(), 1);
17171 var import_commands = __toESM(require_commands(), 1);
17172 var import_preferences8 = __toESM(require_preferences(), 1);
17173 var import_notices14 = __toESM(require_notices(), 1);
17174 var import_block_editor10 = __toESM(require_block_editor(), 1);
17175 var import_core_data32 = __toESM(require_core_data(), 1);
17176
17177 // packages/interface/build-module/index.mjs
17178 var build_module_exports = {};
17179 __export(build_module_exports, {
17180 ActionItem: () => action_item_default,
17181 ComplementaryArea: () => complementary_area_default,
17182 ComplementaryAreaMoreMenuItem: () => ComplementaryAreaMoreMenuItem,
17183 FullscreenMode: () => fullscreen_mode_default,
17184 InterfaceSkeleton: () => interface_skeleton_default,
17185 PinnedItems: () => pinned_items_default,
17186 store: () => store2
17187 });
17188
17189 // packages/interface/build-module/components/complementary-area/index.mjs
17190 var import_components30 = __toESM(require_components(), 1);
17191 var import_data41 = __toESM(require_data(), 1);
17192 var import_i18n64 = __toESM(require_i18n(), 1);
17193 var import_element34 = __toESM(require_element(), 1);
17194 var import_viewport = __toESM(require_viewport(), 1);
17195 var import_preferences7 = __toESM(require_preferences(), 1);
17196 var import_compose7 = __toESM(require_compose(), 1);
17197 var import_plugins2 = __toESM(require_plugins(), 1);
17198
17199 // packages/interface/build-module/components/complementary-area-toggle/index.mjs
17200 var import_components26 = __toESM(require_components(), 1);
17201 var import_data40 = __toESM(require_data(), 1);
17202 var import_plugins = __toESM(require_plugins(), 1);
17203
17204 // packages/interface/build-module/store/index.mjs
17205 var import_data39 = __toESM(require_data(), 1);
17206
17207 // packages/interface/build-module/store/actions.mjs
17208 var actions_exports2 = {};
17209 __export(actions_exports2, {
17210 closeModal: () => closeModal,
17211 disableComplementaryArea: () => disableComplementaryArea,
17212 enableComplementaryArea: () => enableComplementaryArea,
17213 openModal: () => openModal,
17214 pinItem: () => pinItem,
17215 setDefaultComplementaryArea: () => setDefaultComplementaryArea,
17216 setFeatureDefaults: () => setFeatureDefaults,
17217 setFeatureValue: () => setFeatureValue,
17218 toggleFeature: () => toggleFeature,
17219 unpinItem: () => unpinItem
17220 });
17221 var import_deprecated5 = __toESM(require_deprecated(), 1);
17222 var import_preferences5 = __toESM(require_preferences(), 1);
17223
17224 // packages/interface/build-module/store/deprecated.mjs
17225 var import_deprecated4 = __toESM(require_deprecated(), 1);
17226 function normalizeComplementaryAreaScope(scope) {
17227 if (["core/edit-post", "core/edit-site"].includes(scope)) {
17228 (0, import_deprecated4.default)(`${scope} interface scope`, {
17229 alternative: "core interface scope",
17230 hint: "core/edit-post and core/edit-site are merging.",
17231 version: "6.6"
17232 });
17233 return "core";
17234 }
17235 return scope;
17236 }
17237 function normalizeComplementaryAreaName(scope, name2) {
17238 if (scope === "core" && name2 === "edit-site/template") {
17239 (0, import_deprecated4.default)(`edit-site/template sidebar`, {
17240 alternative: "edit-post/document",
17241 version: "6.6"
17242 });
17243 return "edit-post/document";
17244 }
17245 if (scope === "core" && name2 === "edit-site/block-inspector") {
17246 (0, import_deprecated4.default)(`edit-site/block-inspector sidebar`, {
17247 alternative: "edit-post/block",
17248 version: "6.6"
17249 });
17250 return "edit-post/block";
17251 }
17252 return name2;
17253 }
17254
17255 // packages/interface/build-module/store/actions.mjs
17256 var setDefaultComplementaryArea = (scope, area) => {
17257 scope = normalizeComplementaryAreaScope(scope);
17258 area = normalizeComplementaryAreaName(scope, area);
17259 return {
17260 type: "SET_DEFAULT_COMPLEMENTARY_AREA",
17261 scope,
17262 area
17263 };
17264 };
17265 var enableComplementaryArea = (scope, area) => ({ registry, dispatch: dispatch7 }) => {
17266 if (!area) {
17267 return;
17268 }
17269 scope = normalizeComplementaryAreaScope(scope);
17270 area = normalizeComplementaryAreaName(scope, area);
17271 const isComplementaryAreaVisible = registry.select(import_preferences5.store).get(scope, "isComplementaryAreaVisible");
17272 if (!isComplementaryAreaVisible) {
17273 registry.dispatch(import_preferences5.store).set(scope, "isComplementaryAreaVisible", true);
17274 }
17275 dispatch7({
17276 type: "ENABLE_COMPLEMENTARY_AREA",
17277 scope,
17278 area
17279 });
17280 };
17281 var disableComplementaryArea = (scope) => ({ registry }) => {
17282 scope = normalizeComplementaryAreaScope(scope);
17283 const isComplementaryAreaVisible = registry.select(import_preferences5.store).get(scope, "isComplementaryAreaVisible");
17284 if (isComplementaryAreaVisible) {
17285 registry.dispatch(import_preferences5.store).set(scope, "isComplementaryAreaVisible", false);
17286 }
17287 };
17288 var pinItem = (scope, item) => ({ registry }) => {
17289 if (!item) {
17290 return;
17291 }
17292 scope = normalizeComplementaryAreaScope(scope);
17293 item = normalizeComplementaryAreaName(scope, item);
17294 const pinnedItems = registry.select(import_preferences5.store).get(scope, "pinnedItems");
17295 if (pinnedItems?.[item] === true) {
17296 return;
17297 }
17298 registry.dispatch(import_preferences5.store).set(scope, "pinnedItems", {
17299 ...pinnedItems,
17300 [item]: true
17301 });
17302 };
17303 var unpinItem = (scope, item) => ({ registry }) => {
17304 if (!item) {
17305 return;
17306 }
17307 scope = normalizeComplementaryAreaScope(scope);
17308 item = normalizeComplementaryAreaName(scope, item);
17309 const pinnedItems = registry.select(import_preferences5.store).get(scope, "pinnedItems");
17310 registry.dispatch(import_preferences5.store).set(scope, "pinnedItems", {
17311 ...pinnedItems,
17312 [item]: false
17313 });
17314 };
17315 function toggleFeature(scope, featureName) {
17316 return function({ registry }) {
17317 (0, import_deprecated5.default)(`dispatch( 'core/interface' ).toggleFeature`, {
17318 since: "6.0",
17319 alternative: `dispatch( 'core/preferences' ).toggle`
17320 });
17321 registry.dispatch(import_preferences5.store).toggle(scope, featureName);
17322 };
17323 }
17324 function setFeatureValue(scope, featureName, value) {
17325 return function({ registry }) {
17326 (0, import_deprecated5.default)(`dispatch( 'core/interface' ).setFeatureValue`, {
17327 since: "6.0",
17328 alternative: `dispatch( 'core/preferences' ).set`
17329 });
17330 registry.dispatch(import_preferences5.store).set(scope, featureName, !!value);
17331 };
17332 }
17333 function setFeatureDefaults(scope, defaults2) {
17334 return function({ registry }) {
17335 (0, import_deprecated5.default)(`dispatch( 'core/interface' ).setFeatureDefaults`, {
17336 since: "6.0",
17337 alternative: `dispatch( 'core/preferences' ).setDefaults`
17338 });
17339 registry.dispatch(import_preferences5.store).setDefaults(scope, defaults2);
17340 };
17341 }
17342 function openModal(name2) {
17343 return {
17344 type: "OPEN_MODAL",
17345 name: name2
17346 };
17347 }
17348 function closeModal() {
17349 return {
17350 type: "CLOSE_MODAL"
17351 };
17352 }
17353
17354 // packages/interface/build-module/store/selectors.mjs
17355 var selectors_exports2 = {};
17356 __export(selectors_exports2, {
17357 getActiveComplementaryArea: () => getActiveComplementaryArea,
17358 isComplementaryAreaLoading: () => isComplementaryAreaLoading,
17359 isFeatureActive: () => isFeatureActive,
17360 isItemPinned: () => isItemPinned,
17361 isModalActive: () => isModalActive
17362 });
17363 var import_data37 = __toESM(require_data(), 1);
17364 var import_deprecated7 = __toESM(require_deprecated(), 1);
17365 var import_preferences6 = __toESM(require_preferences(), 1);
17366 var getActiveComplementaryArea = (0, import_data37.createRegistrySelector)(
17367 (select6) => (state, scope) => {
17368 scope = normalizeComplementaryAreaScope(scope);
17369 const isComplementaryAreaVisible = select6(import_preferences6.store).get(
17370 scope,
17371 "isComplementaryAreaVisible"
17372 );
17373 if (isComplementaryAreaVisible === void 0) {
17374 return void 0;
17375 }
17376 if (isComplementaryAreaVisible === false) {
17377 return null;
17378 }
17379 return state?.complementaryAreas?.[scope];
17380 }
17381 );
17382 var isComplementaryAreaLoading = (0, import_data37.createRegistrySelector)(
17383 (select6) => (state, scope) => {
17384 scope = normalizeComplementaryAreaScope(scope);
17385 const isVisible = select6(import_preferences6.store).get(
17386 scope,
17387 "isComplementaryAreaVisible"
17388 );
17389 const identifier = state?.complementaryAreas?.[scope];
17390 return isVisible && identifier === void 0;
17391 }
17392 );
17393 var isItemPinned = (0, import_data37.createRegistrySelector)(
17394 (select6) => (state, scope, item) => {
17395 scope = normalizeComplementaryAreaScope(scope);
17396 item = normalizeComplementaryAreaName(scope, item);
17397 const pinnedItems = select6(import_preferences6.store).get(
17398 scope,
17399 "pinnedItems"
17400 );
17401 return pinnedItems?.[item] ?? true;
17402 }
17403 );
17404 var isFeatureActive = (0, import_data37.createRegistrySelector)(
17405 (select6) => (state, scope, featureName) => {
17406 (0, import_deprecated7.default)(
17407 `select( 'core/interface' ).isFeatureActive( scope, featureName )`,
17408 {
17409 since: "6.0",
17410 alternative: `select( 'core/preferences' ).get( scope, featureName )`
17411 }
17412 );
17413 return !!select6(import_preferences6.store).get(scope, featureName);
17414 }
17415 );
17416 function isModalActive(state, modalName3) {
17417 return state.activeModal === modalName3;
17418 }
17419
17420 // packages/interface/build-module/store/reducer.mjs
17421 var import_data38 = __toESM(require_data(), 1);
17422 function complementaryAreas(state = {}, action) {
17423 switch (action.type) {
17424 case "SET_DEFAULT_COMPLEMENTARY_AREA": {
17425 const { scope, area } = action;
17426 if (state[scope]) {
17427 return state;
17428 }
17429 return {
17430 ...state,
17431 [scope]: area
17432 };
17433 }
17434 case "ENABLE_COMPLEMENTARY_AREA": {
17435 const { scope, area } = action;
17436 return {
17437 ...state,
17438 [scope]: area
17439 };
17440 }
17441 }
17442 return state;
17443 }
17444 function activeModal(state = null, action) {
17445 switch (action.type) {
17446 case "OPEN_MODAL":
17447 return action.name;
17448 case "CLOSE_MODAL":
17449 return null;
17450 }
17451 return state;
17452 }
17453 var reducer_default3 = (0, import_data38.combineReducers)({
17454 complementaryAreas,
17455 activeModal
17456 });
17457
17458 // packages/interface/build-module/store/constants.mjs
17459 var STORE_NAME2 = "core/interface";
17460
17461 // packages/interface/build-module/store/index.mjs
17462 var store2 = (0, import_data39.createReduxStore)(STORE_NAME2, {
17463 reducer: reducer_default3,
17464 actions: actions_exports2,
17465 selectors: selectors_exports2
17466 });
17467 (0, import_data39.register)(store2);
17468
17469 // packages/interface/build-module/components/complementary-area-toggle/index.mjs
17470 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
17471 function roleSupportsCheckedState(role) {
17472 return [
17473 "checkbox",
17474 "option",
17475 "radio",
17476 "switch",
17477 "menuitemcheckbox",
17478 "menuitemradio",
17479 "treeitem"
17480 ].includes(role);
17481 }
17482 function ComplementaryAreaToggle({
17483 as = import_components26.Button,
17484 scope,
17485 identifier: identifierProp,
17486 icon: iconProp,
17487 selectedIcon,
17488 name: name2,
17489 shortcut,
17490 ...props
17491 }) {
17492 const ComponentToUse = as;
17493 const context = (0, import_plugins.usePluginContext)();
17494 const icon = iconProp || context.icon;
17495 const identifier = identifierProp || `${context.name}/${name2}`;
17496 const isSelected = (0, import_data40.useSelect)(
17497 (select6) => select6(store2).getActiveComplementaryArea(scope) === identifier,
17498 [identifier, scope]
17499 );
17500 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data40.useDispatch)(store2);
17501 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
17502 ComponentToUse,
17503 {
17504 icon: selectedIcon && isSelected ? selectedIcon : icon,
17505 "aria-controls": identifier.replace("/", ":"),
17506 "aria-checked": roleSupportsCheckedState(props.role) ? isSelected : void 0,
17507 onClick: () => {
17508 if (isSelected) {
17509 disableComplementaryArea2(scope);
17510 } else {
17511 enableComplementaryArea2(scope, identifier);
17512 }
17513 },
17514 shortcut,
17515 ...props
17516 }
17517 );
17518 }
17519
17520 // packages/interface/build-module/components/complementary-area-header/index.mjs
17521 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
17522 var ComplementaryAreaHeader = ({
17523 children,
17524 className,
17525 toggleButtonProps
17526 }) => {
17527 const toggleButton = /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(ComplementaryAreaToggle, { icon: close_small_default, ...toggleButtonProps });
17528 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
17529 "div",
17530 {
17531 className: clsx_default(
17532 "components-panel__header",
17533 "interface-complementary-area-header",
17534 className
17535 ),
17536 tabIndex: -1,
17537 children: [
17538 children,
17539 toggleButton
17540 ]
17541 }
17542 );
17543 };
17544 var complementary_area_header_default = ComplementaryAreaHeader;
17545
17546 // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs
17547 var import_components28 = __toESM(require_components(), 1);
17548
17549 // packages/interface/build-module/components/action-item/index.mjs
17550 var import_components27 = __toESM(require_components(), 1);
17551 var import_element33 = __toESM(require_element(), 1);
17552 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
17553 var noop3 = () => {
17554 };
17555 function ActionItemSlot({
17556 name: name2,
17557 as: Component6 = import_components27.MenuGroup,
17558 fillProps = {},
17559 bubblesVirtually,
17560 ...props
17561 }) {
17562 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
17563 import_components27.Slot,
17564 {
17565 name: name2,
17566 bubblesVirtually,
17567 fillProps,
17568 children: (fills) => {
17569 if (!import_element33.Children.toArray(fills).length) {
17570 return null;
17571 }
17572 const initializedByPlugins = [];
17573 import_element33.Children.forEach(
17574 fills,
17575 ({
17576 props: { __unstableExplicitMenuItem, __unstableTarget }
17577 }) => {
17578 if (__unstableTarget && __unstableExplicitMenuItem) {
17579 initializedByPlugins.push(__unstableTarget);
17580 }
17581 }
17582 );
17583 const children = import_element33.Children.map(fills, (child) => {
17584 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(
17585 child.props.__unstableTarget
17586 )) {
17587 return null;
17588 }
17589 return child;
17590 });
17591 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(Component6, { ...props, children });
17592 }
17593 }
17594 );
17595 }
17596 function ActionItem({ name: name2, as: Component6 = import_components27.Button, onClick, ...props }) {
17597 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components27.Fill, { name: name2, children: ({ onClick: fpOnClick }) => {
17598 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
17599 Component6,
17600 {
17601 onClick: onClick || fpOnClick ? (...args) => {
17602 (onClick || noop3)(...args);
17603 (fpOnClick || noop3)(...args);
17604 } : void 0,
17605 ...props
17606 }
17607 );
17608 } });
17609 }
17610 ActionItem.Slot = ActionItemSlot;
17611 var action_item_default = ActionItem;
17612
17613 // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs
17614 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
17615 var PluginsMenuItem = ({
17616 // Menu item is marked with unstable prop for backward compatibility.
17617 // They are removed so they don't leak to DOM elements.
17618 // @see https://github.com/WordPress/gutenberg/issues/14457
17619 __unstableExplicitMenuItem,
17620 __unstableTarget,
17621 ...restProps
17622 }) => /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components28.MenuItem, { ...restProps });
17623 function ComplementaryAreaMoreMenuItem({
17624 scope,
17625 target,
17626 __unstableExplicitMenuItem,
17627 ...props
17628 }) {
17629 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
17630 ComplementaryAreaToggle,
17631 {
17632 as: (toggleProps) => {
17633 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
17634 action_item_default,
17635 {
17636 __unstableExplicitMenuItem,
17637 __unstableTarget: `${scope}/${target}`,
17638 as: PluginsMenuItem,
17639 name: `${scope}/plugin-more-menu`,
17640 ...toggleProps
17641 }
17642 );
17643 },
17644 role: "menuitemcheckbox",
17645 selectedIcon: check_default,
17646 name: target,
17647 scope,
17648 ...props
17649 }
17650 );
17651 }
17652
17653 // packages/interface/build-module/components/pinned-items/index.mjs
17654 var import_components29 = __toESM(require_components(), 1);
17655 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
17656 function PinnedItems({ scope, ...props }) {
17657 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components29.Fill, { name: `PinnedItems/${scope}`, ...props });
17658 }
17659 function PinnedItemsSlot({ scope, className, ...props }) {
17660 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components29.Slot, { name: `PinnedItems/${scope}`, ...props, children: (fills) => fills?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
17661 "div",
17662 {
17663 className: clsx_default(
17664 className,
17665 "interface-pinned-items"
17666 ),
17667 children: fills
17668 }
17669 ) });
17670 }
17671 PinnedItems.Slot = PinnedItemsSlot;
17672 var pinned_items_default = PinnedItems;
17673
17674 // packages/interface/build-module/components/complementary-area/index.mjs
17675 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
17676 var ANIMATION_DURATION = 0.3;
17677 function ComplementaryAreaSlot({ scope, ...props }) {
17678 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components30.Slot, { name: `ComplementaryArea/${scope}`, ...props });
17679 }
17680 var SIDEBAR_WIDTH = 280;
17681 var variants = {
17682 open: { width: SIDEBAR_WIDTH },
17683 closed: { width: 0 },
17684 mobileOpen: { width: "100vw" }
17685 };
17686 function ComplementaryAreaFill({
17687 activeArea,
17688 isActive,
17689 scope,
17690 children,
17691 className,
17692 id
17693 }) {
17694 const disableMotion = (0, import_compose7.useReducedMotion)();
17695 const isMobileViewport = (0, import_compose7.useViewportMatch)("medium", "<");
17696 const previousActiveArea = (0, import_compose7.usePrevious)(activeArea);
17697 const previousIsActive = (0, import_compose7.usePrevious)(isActive);
17698 const [, setState] = (0, import_element34.useState)({});
17699 (0, import_element34.useEffect)(() => {
17700 setState({});
17701 }, [isActive]);
17702 const transition = {
17703 type: "tween",
17704 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION,
17705 ease: [0.6, 0, 0.4, 1]
17706 };
17707 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components30.Fill, { name: `ComplementaryArea/${scope}`, children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components30.__unstableAnimatePresence, { initial: false, children: (previousIsActive || isActive) && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
17708 import_components30.__unstableMotion.div,
17709 {
17710 variants,
17711 initial: "closed",
17712 animate: isMobileViewport ? "mobileOpen" : "open",
17713 exit: "closed",
17714 transition,
17715 className: "interface-complementary-area__fill",
17716 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
17717 "div",
17718 {
17719 id,
17720 className,
17721 style: {
17722 width: isMobileViewport ? "100vw" : SIDEBAR_WIDTH
17723 },
17724 children
17725 }
17726 )
17727 }
17728 ) }) });
17729 }
17730 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
17731 const previousIsSmallRef = (0, import_element34.useRef)(false);
17732 const shouldOpenWhenNotSmallRef = (0, import_element34.useRef)(false);
17733 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data41.useDispatch)(store2);
17734 (0, import_element34.useEffect)(() => {
17735 if (isActive && isSmall && !previousIsSmallRef.current) {
17736 disableComplementaryArea2(scope);
17737 shouldOpenWhenNotSmallRef.current = true;
17738 } else if (
17739 // If there is a flag indicating the complementary area should be
17740 // enabled when we go from small to big window size and we are going
17741 // from a small to big window size.
17742 shouldOpenWhenNotSmallRef.current && !isSmall && previousIsSmallRef.current
17743 ) {
17744 shouldOpenWhenNotSmallRef.current = false;
17745 enableComplementaryArea2(scope, identifier);
17746 } else if (
17747 // If the flag is indicating the current complementary should be
17748 // reopened but another complementary area becomes active, remove
17749 // the flag.
17750 shouldOpenWhenNotSmallRef.current && activeArea && activeArea !== identifier
17751 ) {
17752 shouldOpenWhenNotSmallRef.current = false;
17753 }
17754 if (isSmall !== previousIsSmallRef.current) {
17755 previousIsSmallRef.current = isSmall;
17756 }
17757 }, [
17758 isActive,
17759 isSmall,
17760 scope,
17761 identifier,
17762 activeArea,
17763 disableComplementaryArea2,
17764 enableComplementaryArea2
17765 ]);
17766 }
17767 function ComplementaryArea({
17768 children,
17769 className,
17770 closeLabel = (0, import_i18n64.__)("Close plugin"),
17771 identifier: identifierProp,
17772 header,
17773 headerClassName,
17774 icon: iconProp,
17775 isPinnable = true,
17776 panelClassName,
17777 scope,
17778 name: name2,
17779 title,
17780 toggleShortcut,
17781 isActiveByDefault
17782 }) {
17783 const context = (0, import_plugins2.usePluginContext)();
17784 const icon = iconProp || context.icon;
17785 const identifier = identifierProp || `${context.name}/${name2}`;
17786 const [isReady2, setIsReady2] = (0, import_element34.useState)(false);
17787 const {
17788 isLoading,
17789 isActive,
17790 isPinned,
17791 activeArea,
17792 isSmall,
17793 isLarge,
17794 showIconLabels
17795 } = (0, import_data41.useSelect)(
17796 (select6) => {
17797 const {
17798 getActiveComplementaryArea: getActiveComplementaryArea2,
17799 isComplementaryAreaLoading: isComplementaryAreaLoading2,
17800 isItemPinned: isItemPinned2
17801 } = select6(store2);
17802 const { get } = select6(import_preferences7.store);
17803 const _activeArea = getActiveComplementaryArea2(scope);
17804 return {
17805 isLoading: isComplementaryAreaLoading2(scope),
17806 isActive: _activeArea === identifier,
17807 isPinned: isItemPinned2(scope, identifier),
17808 activeArea: _activeArea,
17809 isSmall: select6(import_viewport.store).isViewportMatch("< medium"),
17810 isLarge: select6(import_viewport.store).isViewportMatch("large"),
17811 showIconLabels: get("core", "showIconLabels")
17812 };
17813 },
17814 [identifier, scope]
17815 );
17816 const isMobileViewport = (0, import_compose7.useViewportMatch)("medium", "<");
17817 useAdjustComplementaryListener(
17818 scope,
17819 identifier,
17820 activeArea,
17821 isActive,
17822 isSmall
17823 );
17824 const {
17825 enableComplementaryArea: enableComplementaryArea2,
17826 disableComplementaryArea: disableComplementaryArea2,
17827 pinItem: pinItem2,
17828 unpinItem: unpinItem2
17829 } = (0, import_data41.useDispatch)(store2);
17830 (0, import_element34.useEffect)(() => {
17831 if (isActiveByDefault && activeArea === void 0 && !isSmall) {
17832 enableComplementaryArea2(scope, identifier);
17833 } else if (activeArea === void 0 && isSmall) {
17834 disableComplementaryArea2(scope, identifier);
17835 }
17836 setIsReady2(true);
17837 }, [
17838 activeArea,
17839 isActiveByDefault,
17840 scope,
17841 identifier,
17842 isSmall,
17843 enableComplementaryArea2,
17844 disableComplementaryArea2
17845 ]);
17846 if (!isReady2) {
17847 return;
17848 }
17849 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(import_jsx_runtime116.Fragment, { children: [
17850 isPinnable && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(pinned_items_default, { scope, children: isPinned && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
17851 ComplementaryAreaToggle,
17852 {
17853 scope,
17854 identifier,
17855 isPressed: isActive && (!showIconLabels || isLarge),
17856 "aria-expanded": isActive,
17857 "aria-disabled": isLoading,
17858 label: title,
17859 icon: showIconLabels ? check_default : icon,
17860 showTooltip: !showIconLabels,
17861 variant: showIconLabels ? "tertiary" : void 0,
17862 size: "compact",
17863 shortcut: toggleShortcut
17864 }
17865 ) }),
17866 name2 && isPinnable && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
17867 ComplementaryAreaMoreMenuItem,
17868 {
17869 target: name2,
17870 scope,
17871 icon,
17872 identifier,
17873 children: title
17874 }
17875 ),
17876 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
17877 ComplementaryAreaFill,
17878 {
17879 activeArea,
17880 isActive,
17881 className: clsx_default("interface-complementary-area", className),
17882 scope,
17883 id: identifier.replace("/", ":"),
17884 children: [
17885 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
17886 complementary_area_header_default,
17887 {
17888 className: headerClassName,
17889 closeLabel,
17890 onClose: () => disableComplementaryArea2(scope),
17891 toggleButtonProps: {
17892 label: closeLabel,
17893 size: "compact",
17894 shortcut: toggleShortcut,
17895 scope,
17896 identifier
17897 },
17898 children: header || /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(import_jsx_runtime116.Fragment, { children: [
17899 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("h2", { className: "interface-complementary-area-header__title", children: title }),
17900 isPinnable && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
17901 import_components30.Button,
17902 {
17903 className: "interface-complementary-area__pin-unpin-item",
17904 icon: isPinned ? star_filled_default : star_empty_default,
17905 label: isPinned ? (0, import_i18n64.__)("Unpin from toolbar") : (0, import_i18n64.__)("Pin to toolbar"),
17906 onClick: () => (isPinned ? unpinItem2 : pinItem2)(
17907 scope,
17908 identifier
17909 ),
17910 isPressed: isPinned,
17911 "aria-expanded": isPinned,
17912 size: "compact"
17913 }
17914 )
17915 ] })
17916 }
17917 ),
17918 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components30.Panel, { className: panelClassName, children })
17919 ]
17920 }
17921 )
17922 ] });
17923 }
17924 ComplementaryArea.Slot = ComplementaryAreaSlot;
17925 var complementary_area_default = ComplementaryArea;
17926
17927 // packages/interface/build-module/components/fullscreen-mode/index.mjs
17928 var import_element35 = __toESM(require_element(), 1);
17929 var FullscreenMode = ({ isActive }) => {
17930 (0, import_element35.useEffect)(() => {
17931 let isSticky = false;
17932 if (document.body.classList.contains("sticky-menu")) {
17933 isSticky = true;
17934 document.body.classList.remove("sticky-menu");
17935 }
17936 return () => {
17937 if (isSticky) {
17938 document.body.classList.add("sticky-menu");
17939 }
17940 };
17941 }, []);
17942 (0, import_element35.useEffect)(() => {
17943 if (isActive) {
17944 document.body.classList.add("is-fullscreen-mode");
17945 } else {
17946 document.body.classList.remove("is-fullscreen-mode");
17947 }
17948 return () => {
17949 if (isActive) {
17950 document.body.classList.remove("is-fullscreen-mode");
17951 }
17952 };
17953 }, [isActive]);
17954 return null;
17955 };
17956 var fullscreen_mode_default = FullscreenMode;
17957
17958 // packages/admin-ui/build-module/navigable-region/index.mjs
17959 var import_element36 = __toESM(require_element(), 1);
17960 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
17961 var NavigableRegion = (0, import_element36.forwardRef)(
17962 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
17963 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
17964 Tag,
17965 {
17966 ref,
17967 className: clsx_default("admin-ui-navigable-region", className),
17968 "aria-label": ariaLabel,
17969 role: "region",
17970 tabIndex: "-1",
17971 ...props,
17972 children
17973 }
17974 );
17975 }
17976 );
17977 NavigableRegion.displayName = "NavigableRegion";
17978 var navigable_region_default = NavigableRegion;
17979
17980 // node_modules/@base-ui/utils/esm/useRefWithInit.js
17981 var React3 = __toESM(require_react(), 1);
17982 var UNINITIALIZED = {};
17983 function useRefWithInit(init, initArg) {
17984 const ref = React3.useRef(UNINITIALIZED);
17985 if (ref.current === UNINITIALIZED) {
17986 ref.current = init(initArg);
17987 }
17988 return ref;
17989 }
17990
17991 // node_modules/@base-ui/react/esm/utils/useRenderElement.js
17992 var React6 = __toESM(require_react(), 1);
17993
17994 // node_modules/@base-ui/utils/esm/useMergedRefs.js
17995 function useMergedRefs(a3, b3, c6, d3) {
17996 const forkRef = useRefWithInit(createForkRef).current;
17997 if (didChange(forkRef, a3, b3, c6, d3)) {
17998 update3(forkRef, [a3, b3, c6, d3]);
17999 }
18000 return forkRef.callback;
18001 }
18002 function useMergedRefsN(refs) {
18003 const forkRef = useRefWithInit(createForkRef).current;
18004 if (didChangeN(forkRef, refs)) {
18005 update3(forkRef, refs);
18006 }
18007 return forkRef.callback;
18008 }
18009 function createForkRef() {
18010 return {
18011 callback: null,
18012 cleanup: null,
18013 refs: []
18014 };
18015 }
18016 function didChange(forkRef, a3, b3, c6, d3) {
18017 return forkRef.refs[0] !== a3 || forkRef.refs[1] !== b3 || forkRef.refs[2] !== c6 || forkRef.refs[3] !== d3;
18018 }
18019 function didChangeN(forkRef, newRefs) {
18020 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
18021 }
18022 function update3(forkRef, refs) {
18023 forkRef.refs = refs;
18024 if (refs.every((ref) => ref == null)) {
18025 forkRef.callback = null;
18026 return;
18027 }
18028 forkRef.callback = (instance) => {
18029 if (forkRef.cleanup) {
18030 forkRef.cleanup();
18031 forkRef.cleanup = null;
18032 }
18033 if (instance != null) {
18034 const cleanupCallbacks = Array(refs.length).fill(null);
18035 for (let i3 = 0; i3 < refs.length; i3 += 1) {
18036 const ref = refs[i3];
18037 if (ref == null) {
18038 continue;
18039 }
18040 switch (typeof ref) {
18041 case "function": {
18042 const refCleanup = ref(instance);
18043 if (typeof refCleanup === "function") {
18044 cleanupCallbacks[i3] = refCleanup;
18045 }
18046 break;
18047 }
18048 case "object": {
18049 ref.current = instance;
18050 break;
18051 }
18052 default:
18053 }
18054 }
18055 forkRef.cleanup = () => {
18056 for (let i3 = 0; i3 < refs.length; i3 += 1) {
18057 const ref = refs[i3];
18058 if (ref == null) {
18059 continue;
18060 }
18061 switch (typeof ref) {
18062 case "function": {
18063 const cleanupCallback = cleanupCallbacks[i3];
18064 if (typeof cleanupCallback === "function") {
18065 cleanupCallback();
18066 } else {
18067 ref(null);
18068 }
18069 break;
18070 }
18071 case "object": {
18072 ref.current = null;
18073 break;
18074 }
18075 default:
18076 }
18077 }
18078 };
18079 }
18080 };
18081 }
18082
18083 // node_modules/@base-ui/utils/esm/getReactElementRef.js
18084 var React5 = __toESM(require_react(), 1);
18085
18086 // node_modules/@base-ui/utils/esm/reactVersion.js
18087 var React4 = __toESM(require_react(), 1);
18088 var majorVersion = parseInt(React4.version, 10);
18089 function isReactVersionAtLeast(reactVersionToCheck) {
18090 return majorVersion >= reactVersionToCheck;
18091 }
18092
18093 // node_modules/@base-ui/utils/esm/getReactElementRef.js
18094 function getReactElementRef(element) {
18095 if (!/* @__PURE__ */ React5.isValidElement(element)) {
18096 return null;
18097 }
18098 const reactElement = element;
18099 const propsWithRef = reactElement.props;
18100 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
18101 }
18102
18103 // node_modules/@base-ui/utils/esm/mergeObjects.js
18104 function mergeObjects(a3, b3) {
18105 if (a3 && !b3) {
18106 return a3;
18107 }
18108 if (!a3 && b3) {
18109 return b3;
18110 }
18111 if (a3 || b3) {
18112 return {
18113 ...a3,
18114 ...b3
18115 };
18116 }
18117 return void 0;
18118 }
18119
18120 // node_modules/@base-ui/react/esm/utils/getStateAttributesProps.js
18121 function getStateAttributesProps(state, customMapping) {
18122 const props = {};
18123 for (const key in state) {
18124 const value = state[key];
18125 if (customMapping?.hasOwnProperty(key)) {
18126 const customProps = customMapping[key](value);
18127 if (customProps != null) {
18128 Object.assign(props, customProps);
18129 }
18130 continue;
18131 }
18132 if (value === true) {
18133 props[`data-${key.toLowerCase()}`] = "";
18134 } else if (value) {
18135 props[`data-${key.toLowerCase()}`] = value.toString();
18136 }
18137 }
18138 return props;
18139 }
18140
18141 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
18142 function resolveClassName(className, state) {
18143 return typeof className === "function" ? className(state) : className;
18144 }
18145
18146 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
18147 function resolveStyle(style, state) {
18148 return typeof style === "function" ? style(state) : style;
18149 }
18150
18151 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
18152 var EMPTY_PROPS = {};
18153 function mergeProps(a3, b3, c6, d3, e3) {
18154 let merged = {
18155 ...resolvePropsGetter(a3, EMPTY_PROPS)
18156 };
18157 if (b3) {
18158 merged = mergeOne(merged, b3);
18159 }
18160 if (c6) {
18161 merged = mergeOne(merged, c6);
18162 }
18163 if (d3) {
18164 merged = mergeOne(merged, d3);
18165 }
18166 if (e3) {
18167 merged = mergeOne(merged, e3);
18168 }
18169 return merged;
18170 }
18171 function mergePropsN(props) {
18172 if (props.length === 0) {
18173 return EMPTY_PROPS;
18174 }
18175 if (props.length === 1) {
18176 return resolvePropsGetter(props[0], EMPTY_PROPS);
18177 }
18178 let merged = {
18179 ...resolvePropsGetter(props[0], EMPTY_PROPS)
18180 };
18181 for (let i3 = 1; i3 < props.length; i3 += 1) {
18182 merged = mergeOne(merged, props[i3]);
18183 }
18184 return merged;
18185 }
18186 function mergeOne(merged, inputProps) {
18187 if (isPropsGetter(inputProps)) {
18188 return inputProps(merged);
18189 }
18190 return mutablyMergeInto(merged, inputProps);
18191 }
18192 function mutablyMergeInto(mergedProps, externalProps) {
18193 if (!externalProps) {
18194 return mergedProps;
18195 }
18196 for (const propName in externalProps) {
18197 const externalPropValue = externalProps[propName];
18198 switch (propName) {
18199 case "style": {
18200 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
18201 break;
18202 }
18203 case "className": {
18204 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
18205 break;
18206 }
18207 default: {
18208 if (isEventHandler(propName, externalPropValue)) {
18209 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
18210 } else {
18211 mergedProps[propName] = externalPropValue;
18212 }
18213 }
18214 }
18215 }
18216 return mergedProps;
18217 }
18218 function isEventHandler(key, value) {
18219 const code0 = key.charCodeAt(0);
18220 const code1 = key.charCodeAt(1);
18221 const code2 = key.charCodeAt(2);
18222 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
18223 }
18224 function isPropsGetter(inputProps) {
18225 return typeof inputProps === "function";
18226 }
18227 function resolvePropsGetter(inputProps, previousProps) {
18228 if (isPropsGetter(inputProps)) {
18229 return inputProps(previousProps);
18230 }
18231 return inputProps ?? EMPTY_PROPS;
18232 }
18233 function mergeEventHandlers(ourHandler, theirHandler) {
18234 if (!theirHandler) {
18235 return ourHandler;
18236 }
18237 if (!ourHandler) {
18238 return theirHandler;
18239 }
18240 return (event) => {
18241 if (isSyntheticEvent(event)) {
18242 const baseUIEvent = event;
18243 makeEventPreventable(baseUIEvent);
18244 const result2 = theirHandler(baseUIEvent);
18245 if (!baseUIEvent.baseUIHandlerPrevented) {
18246 ourHandler?.(baseUIEvent);
18247 }
18248 return result2;
18249 }
18250 const result = theirHandler(event);
18251 ourHandler?.(event);
18252 return result;
18253 };
18254 }
18255 function makeEventPreventable(event) {
18256 event.preventBaseUIHandler = () => {
18257 event.baseUIHandlerPrevented = true;
18258 };
18259 return event;
18260 }
18261 function mergeClassNames(ourClassName, theirClassName) {
18262 if (theirClassName) {
18263 if (ourClassName) {
18264 return theirClassName + " " + ourClassName;
18265 }
18266 return theirClassName;
18267 }
18268 return ourClassName;
18269 }
18270 function isSyntheticEvent(event) {
18271 return event != null && typeof event === "object" && "nativeEvent" in event;
18272 }
18273
18274 // node_modules/@base-ui/utils/esm/empty.js
18275 var EMPTY_ARRAY4 = Object.freeze([]);
18276 var EMPTY_OBJECT4 = Object.freeze({});
18277
18278 // node_modules/@base-ui/react/esm/utils/useRenderElement.js
18279 var import_react4 = __toESM(require_react(), 1);
18280 function useRenderElement(element, componentProps, params = {}) {
18281 const renderProp = componentProps.render;
18282 const outProps = useRenderElementProps(componentProps, params);
18283 if (params.enabled === false) {
18284 return null;
18285 }
18286 const state = params.state ?? EMPTY_OBJECT4;
18287 return evaluateRenderProp(element, renderProp, outProps, state);
18288 }
18289 function useRenderElementProps(componentProps, params = {}) {
18290 const {
18291 className: classNameProp,
18292 style: styleProp,
18293 render: renderProp
18294 } = componentProps;
18295 const {
18296 state = EMPTY_OBJECT4,
18297 ref,
18298 props,
18299 stateAttributesMapping,
18300 enabled = true
18301 } = params;
18302 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
18303 const style = enabled ? resolveStyle(styleProp, state) : void 0;
18304 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT4;
18305 const outProps = enabled ? mergeObjects(stateProps, Array.isArray(props) ? mergePropsN(props) : props) ?? EMPTY_OBJECT4 : EMPTY_OBJECT4;
18306 if (typeof document !== "undefined") {
18307 if (!enabled) {
18308 useMergedRefs(null, null);
18309 } else if (Array.isArray(ref)) {
18310 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
18311 } else {
18312 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
18313 }
18314 }
18315 if (!enabled) {
18316 return EMPTY_OBJECT4;
18317 }
18318 if (className !== void 0) {
18319 outProps.className = mergeClassNames(outProps.className, className);
18320 }
18321 if (style !== void 0) {
18322 outProps.style = mergeObjects(outProps.style, style);
18323 }
18324 return outProps;
18325 }
18326 function evaluateRenderProp(element, render4, props, state) {
18327 if (render4) {
18328 if (typeof render4 === "function") {
18329 return render4(props, state);
18330 }
18331 const mergedProps = mergeProps(props, render4.props);
18332 mergedProps.ref = props.ref;
18333 return /* @__PURE__ */ React6.cloneElement(render4, mergedProps);
18334 }
18335 if (element) {
18336 if (typeof element === "string") {
18337 return renderTag(element, props);
18338 }
18339 }
18340 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage(8));
18341 }
18342 function renderTag(Tag, props) {
18343 if (Tag === "button") {
18344 return /* @__PURE__ */ (0, import_react4.createElement)("button", {
18345 type: "button",
18346 ...props,
18347 key: props.key
18348 });
18349 }
18350 if (Tag === "img") {
18351 return /* @__PURE__ */ (0, import_react4.createElement)("img", {
18352 alt: "",
18353 ...props,
18354 key: props.key
18355 });
18356 }
18357 return /* @__PURE__ */ React6.createElement(Tag, props);
18358 }
18359
18360 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
18361 function hasWindow() {
18362 return typeof window !== "undefined";
18363 }
18364 function getNodeName(node) {
18365 if (isNode(node)) {
18366 return (node.nodeName || "").toLowerCase();
18367 }
18368 return "#document";
18369 }
18370 function getWindow(node) {
18371 var _node$ownerDocument;
18372 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
18373 }
18374 function getDocumentElement(node) {
18375 var _ref;
18376 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
18377 }
18378 function isNode(value) {
18379 if (!hasWindow()) {
18380 return false;
18381 }
18382 return value instanceof Node || value instanceof getWindow(value).Node;
18383 }
18384 function isElement(value) {
18385 if (!hasWindow()) {
18386 return false;
18387 }
18388 return value instanceof Element || value instanceof getWindow(value).Element;
18389 }
18390 function isHTMLElement(value) {
18391 if (!hasWindow()) {
18392 return false;
18393 }
18394 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
18395 }
18396 function isShadowRoot(value) {
18397 if (!hasWindow() || typeof ShadowRoot === "undefined") {
18398 return false;
18399 }
18400 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
18401 }
18402 var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
18403 function isOverflowElement(element) {
18404 const {
18405 overflow,
18406 overflowX,
18407 overflowY,
18408 display
18409 } = getComputedStyle2(element);
18410 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
18411 }
18412 var tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
18413 function isTableElement(element) {
18414 return tableElements.has(getNodeName(element));
18415 }
18416 var topLayerSelectors = [":popover-open", ":modal"];
18417 function isTopLayer(element) {
18418 return topLayerSelectors.some((selector) => {
18419 try {
18420 return element.matches(selector);
18421 } catch (_e) {
18422 return false;
18423 }
18424 });
18425 }
18426 var transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
18427 var willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
18428 var containValues = ["paint", "layout", "strict", "content"];
18429 function isContainingBlock(elementOrCss) {
18430 const webkit = isWebKit();
18431 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
18432 return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value));
18433 }
18434 function getContainingBlock(element) {
18435 let currentNode = getParentNode(element);
18436 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
18437 if (isContainingBlock(currentNode)) {
18438 return currentNode;
18439 } else if (isTopLayer(currentNode)) {
18440 return null;
18441 }
18442 currentNode = getParentNode(currentNode);
18443 }
18444 return null;
18445 }
18446 function isWebKit() {
18447 if (typeof CSS === "undefined" || !CSS.supports) return false;
18448 return CSS.supports("-webkit-backdrop-filter", "none");
18449 }
18450 var lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
18451 function isLastTraversableNode(node) {
18452 return lastTraversableNodeNames.has(getNodeName(node));
18453 }
18454 function getComputedStyle2(element) {
18455 return getWindow(element).getComputedStyle(element);
18456 }
18457 function getNodeScroll(element) {
18458 if (isElement(element)) {
18459 return {
18460 scrollLeft: element.scrollLeft,
18461 scrollTop: element.scrollTop
18462 };
18463 }
18464 return {
18465 scrollLeft: element.scrollX,
18466 scrollTop: element.scrollY
18467 };
18468 }
18469 function getParentNode(node) {
18470 if (getNodeName(node) === "html") {
18471 return node;
18472 }
18473 const result = (
18474 // Step into the shadow DOM of the parent of a slotted node.
18475 node.assignedSlot || // DOM Element detected.
18476 node.parentNode || // ShadowRoot detected.
18477 isShadowRoot(node) && node.host || // Fallback.
18478 getDocumentElement(node)
18479 );
18480 return isShadowRoot(result) ? result.host : result;
18481 }
18482 function getNearestOverflowAncestor(node) {
18483 const parentNode = getParentNode(node);
18484 if (isLastTraversableNode(parentNode)) {
18485 return node.ownerDocument ? node.ownerDocument.body : node.body;
18486 }
18487 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
18488 return parentNode;
18489 }
18490 return getNearestOverflowAncestor(parentNode);
18491 }
18492 function getOverflowAncestors(node, list, traverseIframes) {
18493 var _node$ownerDocument2;
18494 if (list === void 0) {
18495 list = [];
18496 }
18497 if (traverseIframes === void 0) {
18498 traverseIframes = true;
18499 }
18500 const scrollableAncestor = getNearestOverflowAncestor(node);
18501 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
18502 const win = getWindow(scrollableAncestor);
18503 if (isBody) {
18504 const frameElement = getFrameElement(win);
18505 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
18506 }
18507 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
18508 }
18509 function getFrameElement(win) {
18510 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
18511 }
18512
18513 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
18514 var min = Math.min;
18515 var max = Math.max;
18516 var round = Math.round;
18517 var floor = Math.floor;
18518 var createCoords = (v3) => ({
18519 x: v3,
18520 y: v3
18521 });
18522 function evaluate(value, param) {
18523 return typeof value === "function" ? value(param) : value;
18524 }
18525 function getSide(placement) {
18526 return placement.split("-")[0];
18527 }
18528 function getAlignment(placement) {
18529 return placement.split("-")[1];
18530 }
18531 function getOppositeAxis(axis) {
18532 return axis === "x" ? "y" : "x";
18533 }
18534 function getAxisLength(axis) {
18535 return axis === "y" ? "height" : "width";
18536 }
18537 var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
18538 function getSideAxis(placement) {
18539 return yAxisSides.has(getSide(placement)) ? "y" : "x";
18540 }
18541 function getAlignmentAxis(placement) {
18542 return getOppositeAxis(getSideAxis(placement));
18543 }
18544 function rectToClientRect(rect) {
18545 const {
18546 x: x2,
18547 y: y3,
18548 width,
18549 height
18550 } = rect;
18551 return {
18552 width,
18553 height,
18554 top: y3,
18555 left: x2,
18556 right: x2 + width,
18557 bottom: y3 + height,
18558 x: x2,
18559 y: y3
18560 };
18561 }
18562
18563 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
18564 function computeCoordsFromPlacement(_ref, placement, rtl) {
18565 let {
18566 reference,
18567 floating
18568 } = _ref;
18569 const sideAxis = getSideAxis(placement);
18570 const alignmentAxis = getAlignmentAxis(placement);
18571 const alignLength = getAxisLength(alignmentAxis);
18572 const side = getSide(placement);
18573 const isVertical = sideAxis === "y";
18574 const commonX = reference.x + reference.width / 2 - floating.width / 2;
18575 const commonY = reference.y + reference.height / 2 - floating.height / 2;
18576 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
18577 let coords;
18578 switch (side) {
18579 case "top":
18580 coords = {
18581 x: commonX,
18582 y: reference.y - floating.height
18583 };
18584 break;
18585 case "bottom":
18586 coords = {
18587 x: commonX,
18588 y: reference.y + reference.height
18589 };
18590 break;
18591 case "right":
18592 coords = {
18593 x: reference.x + reference.width,
18594 y: commonY
18595 };
18596 break;
18597 case "left":
18598 coords = {
18599 x: reference.x - floating.width,
18600 y: commonY
18601 };
18602 break;
18603 default:
18604 coords = {
18605 x: reference.x,
18606 y: reference.y
18607 };
18608 }
18609 switch (getAlignment(placement)) {
18610 case "start":
18611 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
18612 break;
18613 case "end":
18614 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
18615 break;
18616 }
18617 return coords;
18618 }
18619 var computePosition = async (reference, floating, config2) => {
18620 const {
18621 placement = "bottom",
18622 strategy = "absolute",
18623 middleware = [],
18624 platform: platform2
18625 } = config2;
18626 const validMiddleware = middleware.filter(Boolean);
18627 const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
18628 let rects = await platform2.getElementRects({
18629 reference,
18630 floating,
18631 strategy
18632 });
18633 let {
18634 x: x2,
18635 y: y3
18636 } = computeCoordsFromPlacement(rects, placement, rtl);
18637 let statefulPlacement = placement;
18638 let middlewareData = {};
18639 let resetCount = 0;
18640 for (let i3 = 0; i3 < validMiddleware.length; i3++) {
18641 const {
18642 name: name2,
18643 fn
18644 } = validMiddleware[i3];
18645 const {
18646 x: nextX,
18647 y: nextY,
18648 data,
18649 reset
18650 } = await fn({
18651 x: x2,
18652 y: y3,
18653 initialPlacement: placement,
18654 placement: statefulPlacement,
18655 strategy,
18656 middlewareData,
18657 rects,
18658 platform: platform2,
18659 elements: {
18660 reference,
18661 floating
18662 }
18663 });
18664 x2 = nextX != null ? nextX : x2;
18665 y3 = nextY != null ? nextY : y3;
18666 middlewareData = {
18667 ...middlewareData,
18668 [name2]: {
18669 ...middlewareData[name2],
18670 ...data
18671 }
18672 };
18673 if (reset && resetCount <= 50) {
18674 resetCount++;
18675 if (typeof reset === "object") {
18676 if (reset.placement) {
18677 statefulPlacement = reset.placement;
18678 }
18679 if (reset.rects) {
18680 rects = reset.rects === true ? await platform2.getElementRects({
18681 reference,
18682 floating,
18683 strategy
18684 }) : reset.rects;
18685 }
18686 ({
18687 x: x2,
18688 y: y3
18689 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
18690 }
18691 i3 = -1;
18692 }
18693 }
18694 return {
18695 x: x2,
18696 y: y3,
18697 placement: statefulPlacement,
18698 strategy,
18699 middlewareData
18700 };
18701 };
18702 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
18703 async function convertValueToCoords(state, options) {
18704 const {
18705 placement,
18706 platform: platform2,
18707 elements: elements2
18708 } = state;
18709 const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements2.floating));
18710 const side = getSide(placement);
18711 const alignment = getAlignment(placement);
18712 const isVertical = getSideAxis(placement) === "y";
18713 const mainAxisMulti = originSides.has(side) ? -1 : 1;
18714 const crossAxisMulti = rtl && isVertical ? -1 : 1;
18715 const rawValue = evaluate(options, state);
18716 let {
18717 mainAxis,
18718 crossAxis,
18719 alignmentAxis
18720 } = typeof rawValue === "number" ? {
18721 mainAxis: rawValue,
18722 crossAxis: 0,
18723 alignmentAxis: null
18724 } : {
18725 mainAxis: rawValue.mainAxis || 0,
18726 crossAxis: rawValue.crossAxis || 0,
18727 alignmentAxis: rawValue.alignmentAxis
18728 };
18729 if (alignment && typeof alignmentAxis === "number") {
18730 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
18731 }
18732 return isVertical ? {
18733 x: crossAxis * crossAxisMulti,
18734 y: mainAxis * mainAxisMulti
18735 } : {
18736 x: mainAxis * mainAxisMulti,
18737 y: crossAxis * crossAxisMulti
18738 };
18739 }
18740 var offset = function(options) {
18741 if (options === void 0) {
18742 options = 0;
18743 }
18744 return {
18745 name: "offset",
18746 options,
18747 async fn(state) {
18748 var _middlewareData$offse, _middlewareData$arrow;
18749 const {
18750 x: x2,
18751 y: y3,
18752 placement,
18753 middlewareData
18754 } = state;
18755 const diffCoords = await convertValueToCoords(state, options);
18756 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
18757 return {};
18758 }
18759 return {
18760 x: x2 + diffCoords.x,
18761 y: y3 + diffCoords.y,
18762 data: {
18763 ...diffCoords,
18764 placement
18765 }
18766 };
18767 }
18768 };
18769 };
18770
18771 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
18772 function getCssDimensions(element) {
18773 const css = getComputedStyle2(element);
18774 let width = parseFloat(css.width) || 0;
18775 let height = parseFloat(css.height) || 0;
18776 const hasOffset = isHTMLElement(element);
18777 const offsetWidth = hasOffset ? element.offsetWidth : width;
18778 const offsetHeight = hasOffset ? element.offsetHeight : height;
18779 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
18780 if (shouldFallback) {
18781 width = offsetWidth;
18782 height = offsetHeight;
18783 }
18784 return {
18785 width,
18786 height,
18787 $: shouldFallback
18788 };
18789 }
18790 function unwrapElement(element) {
18791 return !isElement(element) ? element.contextElement : element;
18792 }
18793 function getScale(element) {
18794 const domElement = unwrapElement(element);
18795 if (!isHTMLElement(domElement)) {
18796 return createCoords(1);
18797 }
18798 const rect = domElement.getBoundingClientRect();
18799 const {
18800 width,
18801 height,
18802 $: $2
18803 } = getCssDimensions(domElement);
18804 let x2 = ($2 ? round(rect.width) : rect.width) / width;
18805 let y3 = ($2 ? round(rect.height) : rect.height) / height;
18806 if (!x2 || !Number.isFinite(x2)) {
18807 x2 = 1;
18808 }
18809 if (!y3 || !Number.isFinite(y3)) {
18810 y3 = 1;
18811 }
18812 return {
18813 x: x2,
18814 y: y3
18815 };
18816 }
18817 var noOffsets = /* @__PURE__ */ createCoords(0);
18818 function getVisualOffsets(element) {
18819 const win = getWindow(element);
18820 if (!isWebKit() || !win.visualViewport) {
18821 return noOffsets;
18822 }
18823 return {
18824 x: win.visualViewport.offsetLeft,
18825 y: win.visualViewport.offsetTop
18826 };
18827 }
18828 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
18829 if (isFixed === void 0) {
18830 isFixed = false;
18831 }
18832 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
18833 return false;
18834 }
18835 return isFixed;
18836 }
18837 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
18838 if (includeScale === void 0) {
18839 includeScale = false;
18840 }
18841 if (isFixedStrategy === void 0) {
18842 isFixedStrategy = false;
18843 }
18844 const clientRect = element.getBoundingClientRect();
18845 const domElement = unwrapElement(element);
18846 let scale = createCoords(1);
18847 if (includeScale) {
18848 if (offsetParent) {
18849 if (isElement(offsetParent)) {
18850 scale = getScale(offsetParent);
18851 }
18852 } else {
18853 scale = getScale(element);
18854 }
18855 }
18856 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
18857 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
18858 let y3 = (clientRect.top + visualOffsets.y) / scale.y;
18859 let width = clientRect.width / scale.x;
18860 let height = clientRect.height / scale.y;
18861 if (domElement) {
18862 const win = getWindow(domElement);
18863 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
18864 let currentWin = win;
18865 let currentIFrame = getFrameElement(currentWin);
18866 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
18867 const iframeScale = getScale(currentIFrame);
18868 const iframeRect = currentIFrame.getBoundingClientRect();
18869 const css = getComputedStyle2(currentIFrame);
18870 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
18871 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
18872 x2 *= iframeScale.x;
18873 y3 *= iframeScale.y;
18874 width *= iframeScale.x;
18875 height *= iframeScale.y;
18876 x2 += left;
18877 y3 += top;
18878 currentWin = getWindow(currentIFrame);
18879 currentIFrame = getFrameElement(currentWin);
18880 }
18881 }
18882 return rectToClientRect({
18883 width,
18884 height,
18885 x: x2,
18886 y: y3
18887 });
18888 }
18889 function getWindowScrollBarX(element, rect) {
18890 const leftScroll = getNodeScroll(element).scrollLeft;
18891 if (!rect) {
18892 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
18893 }
18894 return rect.left + leftScroll;
18895 }
18896 function getHTMLOffset(documentElement, scroll) {
18897 const htmlRect = documentElement.getBoundingClientRect();
18898 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
18899 const y3 = htmlRect.top + scroll.scrollTop;
18900 return {
18901 x: x2,
18902 y: y3
18903 };
18904 }
18905 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
18906 let {
18907 elements: elements2,
18908 rect,
18909 offsetParent,
18910 strategy
18911 } = _ref;
18912 const isFixed = strategy === "fixed";
18913 const documentElement = getDocumentElement(offsetParent);
18914 const topLayer = elements2 ? isTopLayer(elements2.floating) : false;
18915 if (offsetParent === documentElement || topLayer && isFixed) {
18916 return rect;
18917 }
18918 let scroll = {
18919 scrollLeft: 0,
18920 scrollTop: 0
18921 };
18922 let scale = createCoords(1);
18923 const offsets = createCoords(0);
18924 const isOffsetParentAnElement = isHTMLElement(offsetParent);
18925 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
18926 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
18927 scroll = getNodeScroll(offsetParent);
18928 }
18929 if (isHTMLElement(offsetParent)) {
18930 const offsetRect = getBoundingClientRect(offsetParent);
18931 scale = getScale(offsetParent);
18932 offsets.x = offsetRect.x + offsetParent.clientLeft;
18933 offsets.y = offsetRect.y + offsetParent.clientTop;
18934 }
18935 }
18936 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
18937 return {
18938 width: rect.width * scale.x,
18939 height: rect.height * scale.y,
18940 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
18941 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
18942 };
18943 }
18944 function getClientRects(element) {
18945 return Array.from(element.getClientRects());
18946 }
18947 function getDocumentRect(element) {
18948 const html = getDocumentElement(element);
18949 const scroll = getNodeScroll(element);
18950 const body = element.ownerDocument.body;
18951 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
18952 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
18953 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
18954 const y3 = -scroll.scrollTop;
18955 if (getComputedStyle2(body).direction === "rtl") {
18956 x2 += max(html.clientWidth, body.clientWidth) - width;
18957 }
18958 return {
18959 width,
18960 height,
18961 x: x2,
18962 y: y3
18963 };
18964 }
18965 var SCROLLBAR_MAX = 25;
18966 function getViewportRect(element, strategy) {
18967 const win = getWindow(element);
18968 const html = getDocumentElement(element);
18969 const visualViewport = win.visualViewport;
18970 let width = html.clientWidth;
18971 let height = html.clientHeight;
18972 let x2 = 0;
18973 let y3 = 0;
18974 if (visualViewport) {
18975 width = visualViewport.width;
18976 height = visualViewport.height;
18977 const visualViewportBased = isWebKit();
18978 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
18979 x2 = visualViewport.offsetLeft;
18980 y3 = visualViewport.offsetTop;
18981 }
18982 }
18983 const windowScrollbarX = getWindowScrollBarX(html);
18984 if (windowScrollbarX <= 0) {
18985 const doc = html.ownerDocument;
18986 const body = doc.body;
18987 const bodyStyles = getComputedStyle(body);
18988 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
18989 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
18990 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
18991 width -= clippingStableScrollbarWidth;
18992 }
18993 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
18994 width += windowScrollbarX;
18995 }
18996 return {
18997 width,
18998 height,
18999 x: x2,
19000 y: y3
19001 };
19002 }
19003 var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
19004 function getInnerBoundingClientRect(element, strategy) {
19005 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
19006 const top = clientRect.top + element.clientTop;
19007 const left = clientRect.left + element.clientLeft;
19008 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
19009 const width = element.clientWidth * scale.x;
19010 const height = element.clientHeight * scale.y;
19011 const x2 = left * scale.x;
19012 const y3 = top * scale.y;
19013 return {
19014 width,
19015 height,
19016 x: x2,
19017 y: y3
19018 };
19019 }
19020 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
19021 let rect;
19022 if (clippingAncestor === "viewport") {
19023 rect = getViewportRect(element, strategy);
19024 } else if (clippingAncestor === "document") {
19025 rect = getDocumentRect(getDocumentElement(element));
19026 } else if (isElement(clippingAncestor)) {
19027 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
19028 } else {
19029 const visualOffsets = getVisualOffsets(element);
19030 rect = {
19031 x: clippingAncestor.x - visualOffsets.x,
19032 y: clippingAncestor.y - visualOffsets.y,
19033 width: clippingAncestor.width,
19034 height: clippingAncestor.height
19035 };
19036 }
19037 return rectToClientRect(rect);
19038 }
19039 function hasFixedPositionAncestor(element, stopNode) {
19040 const parentNode = getParentNode(element);
19041 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
19042 return false;
19043 }
19044 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
19045 }
19046 function getClippingElementAncestors(element, cache) {
19047 const cachedResult = cache.get(element);
19048 if (cachedResult) {
19049 return cachedResult;
19050 }
19051 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
19052 let currentContainingBlockComputedStyle = null;
19053 const elementIsFixed = getComputedStyle2(element).position === "fixed";
19054 let currentNode = elementIsFixed ? getParentNode(element) : element;
19055 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
19056 const computedStyle = getComputedStyle2(currentNode);
19057 const currentNodeIsContaining = isContainingBlock(currentNode);
19058 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
19059 currentContainingBlockComputedStyle = null;
19060 }
19061 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
19062 if (shouldDropCurrentNode) {
19063 result = result.filter((ancestor) => ancestor !== currentNode);
19064 } else {
19065 currentContainingBlockComputedStyle = computedStyle;
19066 }
19067 currentNode = getParentNode(currentNode);
19068 }
19069 cache.set(element, result);
19070 return result;
19071 }
19072 function getClippingRect(_ref) {
19073 let {
19074 element,
19075 boundary,
19076 rootBoundary,
19077 strategy
19078 } = _ref;
19079 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
19080 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
19081 const firstClippingAncestor = clippingAncestors[0];
19082 const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
19083 const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
19084 accRect.top = max(rect.top, accRect.top);
19085 accRect.right = min(rect.right, accRect.right);
19086 accRect.bottom = min(rect.bottom, accRect.bottom);
19087 accRect.left = max(rect.left, accRect.left);
19088 return accRect;
19089 }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
19090 return {
19091 width: clippingRect.right - clippingRect.left,
19092 height: clippingRect.bottom - clippingRect.top,
19093 x: clippingRect.left,
19094 y: clippingRect.top
19095 };
19096 }
19097 function getDimensions(element) {
19098 const {
19099 width,
19100 height
19101 } = getCssDimensions(element);
19102 return {
19103 width,
19104 height
19105 };
19106 }
19107 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
19108 const isOffsetParentAnElement = isHTMLElement(offsetParent);
19109 const documentElement = getDocumentElement(offsetParent);
19110 const isFixed = strategy === "fixed";
19111 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
19112 let scroll = {
19113 scrollLeft: 0,
19114 scrollTop: 0
19115 };
19116 const offsets = createCoords(0);
19117 function setLeftRTLScrollbarOffset() {
19118 offsets.x = getWindowScrollBarX(documentElement);
19119 }
19120 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
19121 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
19122 scroll = getNodeScroll(offsetParent);
19123 }
19124 if (isOffsetParentAnElement) {
19125 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
19126 offsets.x = offsetRect.x + offsetParent.clientLeft;
19127 offsets.y = offsetRect.y + offsetParent.clientTop;
19128 } else if (documentElement) {
19129 setLeftRTLScrollbarOffset();
19130 }
19131 }
19132 if (isFixed && !isOffsetParentAnElement && documentElement) {
19133 setLeftRTLScrollbarOffset();
19134 }
19135 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
19136 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
19137 const y3 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
19138 return {
19139 x: x2,
19140 y: y3,
19141 width: rect.width,
19142 height: rect.height
19143 };
19144 }
19145 function isStaticPositioned(element) {
19146 return getComputedStyle2(element).position === "static";
19147 }
19148 function getTrueOffsetParent(element, polyfill) {
19149 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
19150 return null;
19151 }
19152 if (polyfill) {
19153 return polyfill(element);
19154 }
19155 let rawOffsetParent = element.offsetParent;
19156 if (getDocumentElement(element) === rawOffsetParent) {
19157 rawOffsetParent = rawOffsetParent.ownerDocument.body;
19158 }
19159 return rawOffsetParent;
19160 }
19161 function getOffsetParent(element, polyfill) {
19162 const win = getWindow(element);
19163 if (isTopLayer(element)) {
19164 return win;
19165 }
19166 if (!isHTMLElement(element)) {
19167 let svgOffsetParent = getParentNode(element);
19168 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
19169 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
19170 return svgOffsetParent;
19171 }
19172 svgOffsetParent = getParentNode(svgOffsetParent);
19173 }
19174 return win;
19175 }
19176 let offsetParent = getTrueOffsetParent(element, polyfill);
19177 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
19178 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
19179 }
19180 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
19181 return win;
19182 }
19183 return offsetParent || getContainingBlock(element) || win;
19184 }
19185 var getElementRects = async function(data) {
19186 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
19187 const getDimensionsFn = this.getDimensions;
19188 const floatingDimensions = await getDimensionsFn(data.floating);
19189 return {
19190 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
19191 floating: {
19192 x: 0,
19193 y: 0,
19194 width: floatingDimensions.width,
19195 height: floatingDimensions.height
19196 }
19197 };
19198 };
19199 function isRTL(element) {
19200 return getComputedStyle2(element).direction === "rtl";
19201 }
19202 var platform = {
19203 convertOffsetParentRelativeRectToViewportRelativeRect,
19204 getDocumentElement,
19205 getClippingRect,
19206 getOffsetParent,
19207 getElementRects,
19208 getClientRects,
19209 getDimensions,
19210 getScale,
19211 isElement,
19212 isRTL
19213 };
19214 function rectsAreEqual(a3, b3) {
19215 return a3.x === b3.x && a3.y === b3.y && a3.width === b3.width && a3.height === b3.height;
19216 }
19217 function observeMove(element, onMove) {
19218 let io = null;
19219 let timeoutId;
19220 const root = getDocumentElement(element);
19221 function cleanup() {
19222 var _io;
19223 clearTimeout(timeoutId);
19224 (_io = io) == null || _io.disconnect();
19225 io = null;
19226 }
19227 function refresh(skip, threshold) {
19228 if (skip === void 0) {
19229 skip = false;
19230 }
19231 if (threshold === void 0) {
19232 threshold = 1;
19233 }
19234 cleanup();
19235 const elementRectForRootMargin = element.getBoundingClientRect();
19236 const {
19237 left,
19238 top,
19239 width,
19240 height
19241 } = elementRectForRootMargin;
19242 if (!skip) {
19243 onMove();
19244 }
19245 if (!width || !height) {
19246 return;
19247 }
19248 const insetTop = floor(top);
19249 const insetRight = floor(root.clientWidth - (left + width));
19250 const insetBottom = floor(root.clientHeight - (top + height));
19251 const insetLeft = floor(left);
19252 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
19253 const options = {
19254 rootMargin,
19255 threshold: max(0, min(1, threshold)) || 1
19256 };
19257 let isFirstUpdate = true;
19258 function handleObserve(entries) {
19259 const ratio = entries[0].intersectionRatio;
19260 if (ratio !== threshold) {
19261 if (!isFirstUpdate) {
19262 return refresh();
19263 }
19264 if (!ratio) {
19265 timeoutId = setTimeout(() => {
19266 refresh(false, 1e-7);
19267 }, 1e3);
19268 } else {
19269 refresh(false, ratio);
19270 }
19271 }
19272 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
19273 refresh();
19274 }
19275 isFirstUpdate = false;
19276 }
19277 try {
19278 io = new IntersectionObserver(handleObserve, {
19279 ...options,
19280 // Handle <iframe>s
19281 root: root.ownerDocument
19282 });
19283 } catch (_e) {
19284 io = new IntersectionObserver(handleObserve, options);
19285 }
19286 io.observe(element);
19287 }
19288 refresh(true);
19289 return cleanup;
19290 }
19291 function autoUpdate(reference, floating, update4, options) {
19292 if (options === void 0) {
19293 options = {};
19294 }
19295 const {
19296 ancestorScroll = true,
19297 ancestorResize = true,
19298 elementResize = typeof ResizeObserver === "function",
19299 layoutShift = typeof IntersectionObserver === "function",
19300 animationFrame = false
19301 } = options;
19302 const referenceEl = unwrapElement(reference);
19303 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
19304 ancestors.forEach((ancestor) => {
19305 ancestorScroll && ancestor.addEventListener("scroll", update4, {
19306 passive: true
19307 });
19308 ancestorResize && ancestor.addEventListener("resize", update4);
19309 });
19310 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update4) : null;
19311 let reobserveFrame = -1;
19312 let resizeObserver = null;
19313 if (elementResize) {
19314 resizeObserver = new ResizeObserver((_ref) => {
19315 let [firstEntry] = _ref;
19316 if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
19317 resizeObserver.unobserve(floating);
19318 cancelAnimationFrame(reobserveFrame);
19319 reobserveFrame = requestAnimationFrame(() => {
19320 var _resizeObserver;
19321 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
19322 });
19323 }
19324 update4();
19325 });
19326 if (referenceEl && !animationFrame) {
19327 resizeObserver.observe(referenceEl);
19328 }
19329 resizeObserver.observe(floating);
19330 }
19331 let frameId;
19332 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
19333 if (animationFrame) {
19334 frameLoop2();
19335 }
19336 function frameLoop2() {
19337 const nextRefRect = getBoundingClientRect(reference);
19338 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
19339 update4();
19340 }
19341 prevRefRect = nextRefRect;
19342 frameId = requestAnimationFrame(frameLoop2);
19343 }
19344 update4();
19345 return () => {
19346 var _resizeObserver2;
19347 ancestors.forEach((ancestor) => {
19348 ancestorScroll && ancestor.removeEventListener("scroll", update4);
19349 ancestorResize && ancestor.removeEventListener("resize", update4);
19350 });
19351 cleanupIo == null || cleanupIo();
19352 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
19353 resizeObserver = null;
19354 if (animationFrame) {
19355 cancelAnimationFrame(frameId);
19356 }
19357 };
19358 }
19359 var offset2 = offset;
19360 var computePosition2 = (reference, floating, options) => {
19361 const cache = /* @__PURE__ */ new Map();
19362 const mergedOptions = {
19363 platform,
19364 ...options
19365 };
19366 const platformWithCache = {
19367 ...mergedOptions.platform,
19368 _c: cache
19369 };
19370 return computePosition(reference, floating, {
19371 ...mergedOptions,
19372 platform: platformWithCache
19373 });
19374 };
19375
19376 // node_modules/@base-ui/react/esm/use-render/useRender.js
19377 function useRender(params) {
19378 return useRenderElement(params.defaultTagName ?? "div", params, params);
19379 }
19380
19381 // packages/ui/build-module/badge/badge.mjs
19382 var import_element37 = __toESM(require_element(), 1);
19383 if (typeof document !== "undefined" && !document.head.querySelector("style[data-wp-hash='244b5c59c0']")) {
19384 const style = document.createElement("style");
19385 style.setAttribute("data-wp-hash", "244b5c59c0");
19386 style.appendChild(document.createTextNode('@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);font-family:var(--wpds-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-font-size-sm,12px);font-weight:var(--wpds-font-weight-regular,400);line-height:var(--wpds-font-line-height-xs,16px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-bg-surface-error,#f6e6e3);color:var(--wpds-color-fg-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-bg-surface-warning,#fde6bd);color:var(--wpds-color-fg-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-bg-surface-caution,#fee994);color:var(--wpds-color-fg-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-bg-surface-success,#c5f7cc);color:var(--wpds-color-fg-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-bg-surface-info,#deebfa);color:var(--wpds-color-fg-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-bg-surface-neutral-weak,#f0f0f0);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-bg-surface-neutral,#f8f8f8);color:var(--wpds-color-fg-content-neutral-weak,#6d6d6d)}}'));
19387 document.head.appendChild(style);
19388 }
19389 var style_default = { "badge": "_96e6251aad1a6136__badge", "is-high-intent": "_99f7158cb520f750__is-high-intent", "is-medium-intent": "c20ebef2365bc8b7__is-medium-intent", "is-low-intent": "_365e1626c6202e52__is-low-intent", "is-stable-intent": "_33f8198127ddf4ef__is-stable-intent", "is-informational-intent": "_04c1aca8fc449412__is-informational-intent", "is-draft-intent": "_90726e69d495ec19__is-draft-intent", "is-none-intent": "_898f4a544993bd39__is-none-intent" };
19390 var Badge2 = (0, import_element37.forwardRef)(function Badge22({ children, intent = "none", render: render4, className, ...props }, ref) {
19391 const element = useRender({
19392 render: render4,
19393 defaultTagName: "span",
19394 ref,
19395 props: mergeProps(props, {
19396 className: clsx_default(
19397 style_default.badge,
19398 style_default[`is-${intent}-intent`],
19399 className
19400 ),
19401 children
19402 })
19403 });
19404 return element;
19405 });
19406
19407 // packages/ui/build-module/stack/stack.mjs
19408 var import_element38 = __toESM(require_element(), 1);
19409 if (typeof document !== "undefined" && !document.head.querySelector("style[data-wp-hash='71d20935c2']")) {
19410 const style = document.createElement("style");
19411 style.setAttribute("data-wp-hash", "71d20935c2");
19412 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}"));
19413 document.head.appendChild(style);
19414 }
19415 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
19416 var gapTokens = {
19417 xs: "var(--wpds-dimension-gap-xs, 4px)",
19418 sm: "var(--wpds-dimension-gap-sm, 8px)",
19419 md: "var(--wpds-dimension-gap-md, 12px)",
19420 lg: "var(--wpds-dimension-gap-lg, 16px)",
19421 xl: "var(--wpds-dimension-gap-xl, 24px)",
19422 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
19423 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
19424 };
19425 var Stack = (0, import_element38.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
19426 const style = {
19427 gap: gap && gapTokens[gap],
19428 alignItems: align,
19429 justifyContent: justify,
19430 flexDirection: direction,
19431 flexWrap: wrap
19432 };
19433 const element = useRender({
19434 render: render4,
19435 ref,
19436 props: mergeProps(props, { style, className: style_default2.stack })
19437 });
19438 return element;
19439 });
19440
19441 // packages/interface/build-module/components/interface-skeleton/index.mjs
19442 var import_element39 = __toESM(require_element(), 1);
19443 var import_components31 = __toESM(require_components(), 1);
19444 var import_i18n65 = __toESM(require_i18n(), 1);
19445 var import_compose8 = __toESM(require_compose(), 1);
19446 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
19447 var ANIMATION_DURATION2 = 0.25;
19448 var commonTransition = {
19449 type: "tween",
19450 duration: ANIMATION_DURATION2,
19451 ease: [0.6, 0, 0.4, 1]
19452 };
19453 function useHTMLClass(className) {
19454 (0, import_element39.useEffect)(() => {
19455 const element = document && document.querySelector(`html:not(.${className})`);
19456 if (!element) {
19457 return;
19458 }
19459 element.classList.toggle(className);
19460 return () => {
19461 element.classList.toggle(className);
19462 };
19463 }, [className]);
19464 }
19465 var headerVariants = {
19466 hidden: { opacity: 1, marginTop: -60 },
19467 visible: { opacity: 1, marginTop: 0 },
19468 distractionFreeHover: {
19469 opacity: 1,
19470 marginTop: 0,
19471 transition: {
19472 ...commonTransition,
19473 delay: 0.2,
19474 delayChildren: 0.2
19475 }
19476 },
19477 distractionFreeHidden: {
19478 opacity: 0,
19479 marginTop: -60
19480 },
19481 distractionFreeDisabled: {
19482 opacity: 0,
19483 marginTop: 0,
19484 transition: {
19485 ...commonTransition,
19486 delay: 0.8,
19487 delayChildren: 0.8
19488 }
19489 }
19490 };
19491 function InterfaceSkeleton({
19492 isDistractionFree,
19493 footer,
19494 header,
19495 editorNotices,
19496 sidebar,
19497 secondarySidebar,
19498 content,
19499 actions: actions2,
19500 labels,
19501 className
19502 }, ref) {
19503 const [secondarySidebarResizeListener, secondarySidebarSize] = (0, import_compose8.useResizeObserver)();
19504 const isMobileViewport = (0, import_compose8.useViewportMatch)("medium", "<");
19505 const disableMotion = (0, import_compose8.useReducedMotion)();
19506 const defaultTransition = {
19507 type: "tween",
19508 duration: disableMotion ? 0 : ANIMATION_DURATION2,
19509 ease: [0.6, 0, 0.4, 1]
19510 };
19511 useHTMLClass("interface-interface-skeleton__html-container");
19512 const defaultLabels = {
19513 /* translators: accessibility text for the top bar landmark region. */
19514 header: (0, import_i18n65._x)("Header", "header landmark area"),
19515 /* translators: accessibility text for the content landmark region. */
19516 body: (0, import_i18n65.__)("Content"),
19517 /* translators: accessibility text for the secondary sidebar landmark region. */
19518 secondarySidebar: (0, import_i18n65.__)("Block Library"),
19519 /* translators: accessibility text for the settings landmark region. */
19520 sidebar: (0, import_i18n65._x)("Settings", "settings landmark area"),
19521 /* translators: accessibility text for the publish landmark region. */
19522 actions: (0, import_i18n65.__)("Publish"),
19523 /* translators: accessibility text for the footer landmark region. */
19524 footer: (0, import_i18n65.__)("Footer")
19525 };
19526 const mergedLabels = { ...defaultLabels, ...labels };
19527 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
19528 "div",
19529 {
19530 ref,
19531 className: clsx_default(
19532 className,
19533 "interface-interface-skeleton",
19534 !!footer && "has-footer"
19535 ),
19536 children: [
19537 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { className: "interface-interface-skeleton__editor", children: [
19538 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components31.__unstableAnimatePresence, { initial: false, children: !!header && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
19539 navigable_region_default,
19540 {
19541 as: import_components31.__unstableMotion.div,
19542 className: "interface-interface-skeleton__header",
19543 "aria-label": mergedLabels.header,
19544 initial: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden",
19545 whileHover: isDistractionFree && !isMobileViewport ? "distractionFreeHover" : "visible",
19546 animate: isDistractionFree && !isMobileViewport ? "distractionFreeDisabled" : "visible",
19547 exit: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden",
19548 variants: headerVariants,
19549 transition: defaultTransition,
19550 children: header
19551 }
19552 ) }),
19553 isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "interface-interface-skeleton__header", children: editorNotices }),
19554 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { className: "interface-interface-skeleton__body", children: [
19555 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components31.__unstableAnimatePresence, { initial: false, children: !!secondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
19556 navigable_region_default,
19557 {
19558 className: "interface-interface-skeleton__secondary-sidebar",
19559 ariaLabel: mergedLabels.secondarySidebar,
19560 as: import_components31.__unstableMotion.div,
19561 initial: "closed",
19562 animate: "open",
19563 exit: "closed",
19564 variants: {
19565 open: { width: secondarySidebarSize.width },
19566 closed: { width: 0 }
19567 },
19568 transition: defaultTransition,
19569 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
19570 import_components31.__unstableMotion.div,
19571 {
19572 style: {
19573 position: "absolute",
19574 width: isMobileViewport ? "100vw" : "fit-content",
19575 height: "100%",
19576 left: 0
19577 },
19578 variants: {
19579 open: { x: 0 },
19580 closed: { x: "-100%" }
19581 },
19582 transition: defaultTransition,
19583 children: [
19584 secondarySidebarResizeListener,
19585 secondarySidebar
19586 ]
19587 }
19588 )
19589 }
19590 ) }),
19591 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
19592 navigable_region_default,
19593 {
19594 className: "interface-interface-skeleton__content",
19595 ariaLabel: mergedLabels.body,
19596 children: content
19597 }
19598 ),
19599 !!sidebar && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
19600 navigable_region_default,
19601 {
19602 className: "interface-interface-skeleton__sidebar",
19603 ariaLabel: mergedLabels.sidebar,
19604 children: sidebar
19605 }
19606 ),
19607 !!actions2 && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
19608 navigable_region_default,
19609 {
19610 className: "interface-interface-skeleton__actions",
19611 ariaLabel: mergedLabels.actions,
19612 children: actions2
19613 }
19614 )
19615 ] })
19616 ] }),
19617 !!footer && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
19618 navigable_region_default,
19619 {
19620 className: "interface-interface-skeleton__footer",
19621 ariaLabel: mergedLabels.footer,
19622 children: footer
19623 }
19624 )
19625 ]
19626 }
19627 );
19628 }
19629 var interface_skeleton_default = (0, import_element39.forwardRef)(InterfaceSkeleton);
19630
19631 // packages/editor/build-module/components/commands/index.mjs
19632 var import_html_entities7 = __toESM(require_html_entities(), 1);
19633
19634 // packages/editor/build-module/components/pattern-rename-modal/index.mjs
19635 var import_data42 = __toESM(require_data(), 1);
19636 var import_patterns5 = __toESM(require_patterns(), 1);
19637 var import_core_data30 = __toESM(require_core_data(), 1);
19638 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
19639 var { RenamePatternModal } = unlock(import_patterns5.privateApis);
19640 var modalName = "editor/pattern-rename";
19641 function PatternRenameModal() {
19642 const isActive = (0, import_data42.useSelect)(
19643 (select6) => select6(store2).isModalActive(modalName)
19644 );
19645 const { record, postType: postType2 } = (0, import_data42.useSelect)(
19646 (select6) => {
19647 if (!isActive) {
19648 return {};
19649 }
19650 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select6(store);
19651 const { getEditedEntityRecord } = select6(import_core_data30.store);
19652 const _postType = getCurrentPostType2();
19653 return {
19654 record: getEditedEntityRecord(
19655 "postType",
19656 _postType,
19657 getCurrentPostId2()
19658 ),
19659 postType: _postType
19660 };
19661 },
19662 [isActive]
19663 );
19664 const { closeModal: closeModal2 } = (0, import_data42.useDispatch)(store2);
19665 if (!isActive || postType2 !== PATTERN_POST_TYPE) {
19666 return null;
19667 }
19668 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(RenamePatternModal, { onClose: closeModal2, pattern: record });
19669 }
19670
19671 // packages/editor/build-module/components/pattern-duplicate-modal/index.mjs
19672 var import_data43 = __toESM(require_data(), 1);
19673 var import_patterns6 = __toESM(require_patterns(), 1);
19674 var import_core_data31 = __toESM(require_core_data(), 1);
19675 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
19676 var { DuplicatePatternModal } = unlock(import_patterns6.privateApis);
19677 var modalName2 = "editor/pattern-duplicate";
19678 function PatternDuplicateModal() {
19679 const isActive = (0, import_data43.useSelect)(
19680 (select6) => select6(store2).isModalActive(modalName2)
19681 );
19682 const { record, postType: postType2 } = (0, import_data43.useSelect)(
19683 (select6) => {
19684 if (!isActive) {
19685 return {};
19686 }
19687 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select6(store);
19688 const { getEditedEntityRecord } = select6(import_core_data31.store);
19689 const _postType = getCurrentPostType2();
19690 return {
19691 record: getEditedEntityRecord(
19692 "postType",
19693 _postType,
19694 getCurrentPostId2()
19695 ),
19696 postType: _postType
19697 };
19698 },
19699 [isActive]
19700 );
19701 const { closeModal: closeModal2 } = (0, import_data43.useDispatch)(store2);
19702 if (!isActive || postType2 !== PATTERN_POST_TYPE) {
19703 return null;
19704 }
19705 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
19706 DuplicatePatternModal,
19707 {
19708 onClose: closeModal2,
19709 onSuccess: () => closeModal2(),
19710 pattern: record
19711 }
19712 );
19713 }
19714
19715 // packages/editor/build-module/components/commands/index.mjs
19716 var getEditorCommandLoader = () => function useEditorCommandLoader() {
19717 const {
19718 editorMode,
19719 isListViewOpen,
19720 showBlockBreadcrumbs,
19721 isDistractionFree,
19722 isFocusMode,
19723 isPreviewMode,
19724 isViewable,
19725 isCodeEditingEnabled,
19726 isRichEditingEnabled,
19727 isPublishSidebarEnabled: isPublishSidebarEnabled2
19728 } = (0, import_data44.useSelect)((select6) => {
19729 const { get } = select6(import_preferences8.store);
19730 const { isListViewOpened: isListViewOpened2, getCurrentPostType: getCurrentPostType2, getEditorSettings: getEditorSettings2 } = select6(store);
19731 const { getSettings: getSettings10 } = select6(import_block_editor10.store);
19732 const { getPostType } = select6(import_core_data32.store);
19733 return {
19734 editorMode: get("core", "editorMode") ?? "visual",
19735 isListViewOpen: isListViewOpened2(),
19736 showBlockBreadcrumbs: get("core", "showBlockBreadcrumbs"),
19737 isDistractionFree: get("core", "distractionFree"),
19738 isFocusMode: get("core", "focusMode"),
19739 isPreviewMode: getSettings10().isPreviewMode,
19740 isViewable: getPostType(getCurrentPostType2())?.viewable ?? false,
19741 isCodeEditingEnabled: getEditorSettings2().codeEditingEnabled,
19742 isRichEditingEnabled: getEditorSettings2().richEditingEnabled,
19743 isPublishSidebarEnabled: select6(store).isPublishSidebarEnabled()
19744 };
19745 }, []);
19746 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data44.useSelect)(store2);
19747 const { toggle } = (0, import_data44.useDispatch)(import_preferences8.store);
19748 const { createInfoNotice } = (0, import_data44.useDispatch)(import_notices14.store);
19749 const {
19750 __unstableSaveForPreview: __unstableSaveForPreview2,
19751 setIsListViewOpened: setIsListViewOpened2,
19752 switchEditorMode: switchEditorMode2,
19753 toggleDistractionFree: toggleDistractionFree2,
19754 toggleSpotlightMode: toggleSpotlightMode2,
19755 toggleTopToolbar: toggleTopToolbar2
19756 } = (0, import_data44.useDispatch)(store);
19757 const { openModal: openModal2, enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data44.useDispatch)(store2);
19758 const { getCurrentPostId: getCurrentPostId2 } = (0, import_data44.useSelect)(store);
19759 const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
19760 if (isPreviewMode) {
19761 return { commands: [], isLoading: false };
19762 }
19763 const commands = [];
19764 commands.push({
19765 name: "core/open-shortcut-help",
19766 label: (0, import_i18n66.__)("Keyboard shortcuts"),
19767 icon: keyboard_default,
19768 category: "view",
19769 callback: ({ close }) => {
19770 close();
19771 openModal2("editor/keyboard-shortcut-help");
19772 }
19773 });
19774 commands.push({
19775 name: "core/toggle-distraction-free",
19776 label: isDistractionFree ? (0, import_i18n66.__)("Exit Distraction free") : (0, import_i18n66.__)("Enter Distraction free"),
19777 category: "command",
19778 callback: ({ close }) => {
19779 toggleDistractionFree2();
19780 close();
19781 }
19782 });
19783 commands.push({
19784 name: "core/open-preferences",
19785 label: (0, import_i18n66.__)("Editor preferences"),
19786 category: "view",
19787 callback: ({ close }) => {
19788 close();
19789 openModal2("editor/preferences");
19790 }
19791 });
19792 commands.push({
19793 name: "core/toggle-spotlight-mode",
19794 label: isFocusMode ? (0, import_i18n66.__)("Exit Spotlight mode") : (0, import_i18n66.__)("Enter Spotlight mode"),
19795 category: "command",
19796 callback: ({ close }) => {
19797 toggleSpotlightMode2();
19798 close();
19799 }
19800 });
19801 commands.push({
19802 name: "core/toggle-list-view",
19803 label: isListViewOpen ? (0, import_i18n66.__)("Close List View") : (0, import_i18n66.__)("Open List View"),
19804 icon: list_view_default,
19805 category: "command",
19806 callback: ({ close }) => {
19807 setIsListViewOpened2(!isListViewOpen);
19808 close();
19809 createInfoNotice(
19810 isListViewOpen ? (0, import_i18n66.__)("List View off.") : (0, import_i18n66.__)("List View on."),
19811 {
19812 id: "core/editor/toggle-list-view/notice",
19813 type: "snackbar"
19814 }
19815 );
19816 }
19817 });
19818 commands.push({
19819 name: "core/toggle-top-toolbar",
19820 label: (0, import_i18n66.__)("Top toolbar"),
19821 category: "command",
19822 callback: ({ close }) => {
19823 toggleTopToolbar2();
19824 close();
19825 }
19826 });
19827 if (allowSwitchEditorMode) {
19828 commands.push({
19829 name: "core/toggle-code-editor",
19830 label: editorMode === "visual" ? (0, import_i18n66.__)("Open code editor") : (0, import_i18n66.__)("Exit code editor"),
19831 icon: code_default,
19832 category: "command",
19833 callback: ({ close }) => {
19834 switchEditorMode2(
19835 editorMode === "visual" ? "text" : "visual"
19836 );
19837 close();
19838 }
19839 });
19840 }
19841 commands.push({
19842 name: "core/toggle-breadcrumbs",
19843 label: showBlockBreadcrumbs ? (0, import_i18n66.__)("Hide block breadcrumbs") : (0, import_i18n66.__)("Show block breadcrumbs"),
19844 category: "command",
19845 callback: ({ close }) => {
19846 toggle("core", "showBlockBreadcrumbs");
19847 close();
19848 createInfoNotice(
19849 showBlockBreadcrumbs ? (0, import_i18n66.__)("Breadcrumbs hidden.") : (0, import_i18n66.__)("Breadcrumbs visible."),
19850 {
19851 id: "core/editor/toggle-breadcrumbs/notice",
19852 type: "snackbar"
19853 }
19854 );
19855 }
19856 });
19857 commands.push({
19858 name: "core/open-settings-sidebar",
19859 label: (0, import_i18n66.__)("Show or hide the Settings panel"),
19860 icon: (0, import_i18n66.isRTL)() ? drawer_left_default : drawer_right_default,
19861 category: "command",
19862 callback: ({ close }) => {
19863 const activeSidebar = getActiveComplementaryArea2("core");
19864 close();
19865 if (activeSidebar === "edit-post/document") {
19866 disableComplementaryArea2("core");
19867 } else {
19868 enableComplementaryArea2("core", "edit-post/document");
19869 }
19870 }
19871 });
19872 commands.push({
19873 name: "core/open-block-inspector",
19874 label: (0, import_i18n66.__)("Show or hide the Block settings panel"),
19875 icon: block_default_default,
19876 category: "command",
19877 callback: ({ close }) => {
19878 const activeSidebar = getActiveComplementaryArea2("core");
19879 close();
19880 if (activeSidebar === "edit-post/block") {
19881 disableComplementaryArea2("core");
19882 } else {
19883 enableComplementaryArea2("core", "edit-post/block");
19884 }
19885 }
19886 });
19887 commands.push({
19888 name: "core/toggle-publish-sidebar",
19889 label: isPublishSidebarEnabled2 ? (0, import_i18n66.__)("Disable pre-publish checks") : (0, import_i18n66.__)("Enable pre-publish checks"),
19890 icon: format_list_bullets_default,
19891 category: "command",
19892 callback: ({ close }) => {
19893 close();
19894 toggle("core", "isPublishSidebarEnabled");
19895 createInfoNotice(
19896 isPublishSidebarEnabled2 ? (0, import_i18n66.__)("Pre-publish checks disabled.") : (0, import_i18n66.__)("Pre-publish checks enabled."),
19897 {
19898 id: "core/editor/publish-sidebar/notice",
19899 type: "snackbar"
19900 }
19901 );
19902 }
19903 });
19904 if (isViewable) {
19905 commands.push({
19906 name: "core/preview-link",
19907 label: (0, import_i18n66.__)("Preview in a new tab"),
19908 icon: external_default,
19909 category: "view",
19910 callback: async ({ close }) => {
19911 close();
19912 const postId2 = getCurrentPostId2();
19913 const link = await __unstableSaveForPreview2();
19914 window.open(link, `wp-preview-${postId2}`);
19915 }
19916 });
19917 }
19918 return {
19919 commands,
19920 isLoading: false
19921 };
19922 };
19923 var getEditedEntityContextualCommands = () => function useEditedEntityContextualCommands() {
19924 const { postType: postType2 } = (0, import_data44.useSelect)((select6) => {
19925 const { getCurrentPostType: getCurrentPostType2 } = select6(store);
19926 return {
19927 postType: getCurrentPostType2()
19928 };
19929 }, []);
19930 const { openModal: openModal2 } = (0, import_data44.useDispatch)(store2);
19931 const commands = [];
19932 if (postType2 === PATTERN_POST_TYPE) {
19933 commands.push({
19934 name: "core/rename-pattern",
19935 label: (0, import_i18n66.__)("Rename pattern"),
19936 icon: pencil_default,
19937 category: "edit",
19938 callback: ({ close }) => {
19939 openModal2(modalName);
19940 close();
19941 }
19942 });
19943 commands.push({
19944 name: "core/duplicate-pattern",
19945 label: (0, import_i18n66.__)("Duplicate pattern"),
19946 icon: symbol_default,
19947 category: "command",
19948 callback: ({ close }) => {
19949 openModal2(modalName2);
19950 close();
19951 }
19952 });
19953 }
19954 return { isLoading: false, commands };
19955 };
19956 var getPageContentFocusCommands = () => function usePageContentFocusCommands() {
19957 const {
19958 onNavigateToEntityRecord,
19959 goBack,
19960 templateId: templateId2,
19961 isPreviewMode,
19962 canEditTemplate
19963 } = (0, import_data44.useSelect)((select6) => {
19964 const {
19965 getRenderingMode: getRenderingMode2,
19966 getEditorSettings: _getEditorSettings,
19967 getCurrentTemplateId: getCurrentTemplateId2
19968 } = unlock(select6(store));
19969 const editorSettings2 = _getEditorSettings();
19970 const _templateId = getCurrentTemplateId2();
19971 return {
19972 isTemplateHidden: getRenderingMode2() === "post-only",
19973 onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord,
19974 getEditorSettings: _getEditorSettings,
19975 goBack: editorSettings2.onNavigateToPreviousEntityRecord,
19976 templateId: _templateId,
19977 isPreviewMode: editorSettings2.isPreviewMode,
19978 canEditTemplate: !!_templateId && select6(import_core_data32.store).canUser("update", {
19979 kind: "postType",
19980 name: "wp_template",
19981 id: _templateId
19982 })
19983 };
19984 }, []);
19985 const { editedRecord: template2, hasResolved } = (0, import_core_data32.useEntityRecord)(
19986 "postType",
19987 "wp_template",
19988 templateId2
19989 );
19990 if (isPreviewMode) {
19991 return { isLoading: false, commands: [] };
19992 }
19993 const commands = [];
19994 if (templateId2 && hasResolved && canEditTemplate) {
19995 commands.push({
19996 name: "core/switch-to-template-focus",
19997 label: (0, import_i18n66.sprintf)(
19998 /* translators: %s: template title */
19999 (0, import_i18n66.__)("Edit template: %s"),
20000 (0, import_html_entities7.decodeEntities)(template2.title)
20001 ),
20002 icon: layout_default,
20003 category: "edit",
20004 callback: ({ close }) => {
20005 onNavigateToEntityRecord({
20006 postId: templateId2,
20007 postType: "wp_template"
20008 });
20009 close();
20010 }
20011 });
20012 }
20013 if (!!goBack) {
20014 commands.push({
20015 name: "core/switch-to-previous-entity",
20016 label: (0, import_i18n66.__)("Go back"),
20017 icon: page_default,
20018 category: "view",
20019 callback: ({ close }) => {
20020 goBack();
20021 close();
20022 }
20023 });
20024 }
20025 return { isLoading: false, commands };
20026 };
20027 var getManipulateDocumentCommands = () => function useManipulateDocumentCommands() {
20028 const { postType: postType2, postId: postId2 } = (0, import_data44.useSelect)((select6) => {
20029 const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select6(store);
20030 return {
20031 postType: getCurrentPostType2(),
20032 postId: getCurrentPostId2()
20033 };
20034 }, []);
20035 const { editedRecord: template2, hasResolved } = (0, import_core_data32.useEntityRecord)(
20036 "postType",
20037 postType2,
20038 postId2
20039 );
20040 const { revertTemplate: revertTemplate3 } = unlock((0, import_data44.useDispatch)(store));
20041 if (!hasResolved || ![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(
20042 postType2
20043 )) {
20044 return { isLoading: true, commands: [] };
20045 }
20046 const commands = [];
20047 if (isTemplateRevertable(template2)) {
20048 const label = template2.type === TEMPLATE_POST_TYPE ? (0, import_i18n66.sprintf)(
20049 /* translators: %s: template title */
20050 (0, import_i18n66.__)("Reset template: %s"),
20051 (0, import_html_entities7.decodeEntities)(template2.title)
20052 ) : (0, import_i18n66.sprintf)(
20053 /* translators: %s: template part title */
20054 (0, import_i18n66.__)("Reset template part: %s"),
20055 (0, import_html_entities7.decodeEntities)(template2.title)
20056 );
20057 commands.push({
20058 name: "core/reset-template",
20059 label,
20060 icon: (0, import_i18n66.isRTL)() ? rotate_right_default : rotate_left_default,
20061 category: "command",
20062 callback: ({ close }) => {
20063 revertTemplate3(template2);
20064 close();
20065 }
20066 });
20067 }
20068 return {
20069 isLoading: !hasResolved,
20070 commands
20071 };
20072 };
20073 function useCommands() {
20074 (0, import_commands.useCommandLoader)({
20075 name: "core/editor/edit-ui",
20076 hook: getEditorCommandLoader()
20077 });
20078 (0, import_commands.useCommandLoader)({
20079 name: "core/editor/contextual-commands",
20080 hook: getEditedEntityContextualCommands(),
20081 context: "entity-edit"
20082 });
20083 (0, import_commands.useCommandLoader)({
20084 name: "core/editor/page-content-focus",
20085 hook: getPageContentFocusCommands(),
20086 context: "entity-edit"
20087 });
20088 (0, import_commands.useCommandLoader)({
20089 name: "core/edit-site/manipulate-document",
20090 hook: getManipulateDocumentCommands()
20091 });
20092 }
20093
20094 // packages/editor/build-module/components/provider/use-upload-save-lock.mjs
20095 var import_data45 = __toESM(require_data(), 1);
20096 var import_element40 = __toESM(require_element(), 1);
20097 var import_upload_media = __toESM(require_upload_media(), 1);
20098 var LOCK_NAME = "upload-in-progress";
20099 function useUploadSaveLock() {
20100 const isClientSideMediaProcessingEnabled = window.__clientSideMediaProcessing;
20101 const isUploading = (0, import_data45.useSelect)(
20102 (select6) => {
20103 if (!isClientSideMediaProcessingEnabled) {
20104 return false;
20105 }
20106 return select6(import_upload_media.store).isUploading();
20107 },
20108 [isClientSideMediaProcessingEnabled]
20109 );
20110 const {
20111 lockPostSaving: lockPostSaving2,
20112 unlockPostSaving: unlockPostSaving2,
20113 lockPostAutosaving: lockPostAutosaving2,
20114 unlockPostAutosaving: unlockPostAutosaving2
20115 } = (0, import_data45.useDispatch)(store);
20116 (0, import_element40.useEffect)(() => {
20117 if (!isClientSideMediaProcessingEnabled) {
20118 return;
20119 }
20120 if (isUploading) {
20121 lockPostSaving2(LOCK_NAME);
20122 lockPostAutosaving2(LOCK_NAME);
20123 } else {
20124 unlockPostSaving2(LOCK_NAME);
20125 unlockPostAutosaving2(LOCK_NAME);
20126 }
20127 return () => {
20128 unlockPostSaving2(LOCK_NAME);
20129 unlockPostAutosaving2(LOCK_NAME);
20130 };
20131 }, [
20132 isClientSideMediaProcessingEnabled,
20133 isUploading,
20134 lockPostSaving2,
20135 unlockPostSaving2,
20136 lockPostAutosaving2,
20137 unlockPostAutosaving2
20138 ]);
20139 }
20140
20141 // packages/editor/build-module/components/block-removal-warnings/index.mjs
20142 var import_i18n67 = __toESM(require_i18n(), 1);
20143 var import_block_editor11 = __toESM(require_block_editor(), 1);
20144 var import_data46 = __toESM(require_data(), 1);
20145 var import_element41 = __toESM(require_element(), 1);
20146 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
20147 var { BlockRemovalWarningModal } = unlock(import_block_editor11.privateApis);
20148 var TEMPLATE_BLOCKS = [
20149 "core/post-content",
20150 "core/post-template",
20151 "core/query"
20152 ];
20153 var BLOCK_REMOVAL_RULES = [
20154 {
20155 // Template blocks.
20156 // The warning is only shown when a user manipulates templates or template parts.
20157 postTypes: ["wp_template", "wp_template_part"],
20158 callback(removedBlocks) {
20159 const removedPostContentBlocks = removedBlocks.filter(
20160 ({ name: name2 }) => name2 === "core/post-content"
20161 );
20162 if (removedPostContentBlocks.length) {
20163 return {
20164 description: (0, import_i18n67.__)(
20165 "This block displays the content of posts and pages using this template."
20166 ),
20167 warning: (0, import_i18n67.__)(
20168 "If you delete it, posts or pages using this template will not display any content."
20169 ),
20170 subtext: (0, import_i18n67.__)("Visitors will see blank pages."),
20171 requireConfirmation: true
20172 };
20173 }
20174 const removedTemplateBlocks = removedBlocks.filter(
20175 ({ name: name2 }) => TEMPLATE_BLOCKS.includes(name2)
20176 );
20177 if (removedTemplateBlocks.length) {
20178 return (0, import_i18n67._n)(
20179 "Deleting this block will stop your post or page content from displaying on this template. It is not recommended.",
20180 "Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.",
20181 removedBlocks.length
20182 );
20183 }
20184 }
20185 },
20186 {
20187 // Pattern overrides.
20188 // The warning is only shown when the user edits a pattern.
20189 postTypes: ["wp_block"],
20190 callback(removedBlocks) {
20191 const removedBlocksWithOverrides = removedBlocks.filter(
20192 ({ attributes }) => attributes?.metadata?.bindings && Object.values(attributes.metadata.bindings).some(
20193 (binding) => binding.source === "core/pattern-overrides"
20194 )
20195 );
20196 if (removedBlocksWithOverrides.length) {
20197 return (0, import_i18n67._n)(
20198 "The deleted block allows instance overrides. Removing it may result in content not displaying where this pattern is used. Are you sure you want to proceed?",
20199 "Some of the deleted blocks allow instance overrides. Removing them may result in content not displaying where this pattern is used. Are you sure you want to proceed?",
20200 removedBlocks.length
20201 );
20202 }
20203 }
20204 }
20205 ];
20206 function BlockRemovalWarnings() {
20207 const currentPostType = (0, import_data46.useSelect)(
20208 (select6) => select6(store).getCurrentPostType(),
20209 []
20210 );
20211 const removalRulesForPostType = (0, import_element41.useMemo)(
20212 () => BLOCK_REMOVAL_RULES.filter(
20213 (rule) => rule.postTypes.includes(currentPostType)
20214 ),
20215 [currentPostType]
20216 );
20217 if (!BlockRemovalWarningModal) {
20218 return null;
20219 }
20220 if (!removalRulesForPostType) {
20221 return null;
20222 }
20223 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(BlockRemovalWarningModal, { rules: removalRulesForPostType });
20224 }
20225
20226 // packages/editor/build-module/components/start-page-options/index.mjs
20227 var import_components32 = __toESM(require_components(), 1);
20228 var import_i18n68 = __toESM(require_i18n(), 1);
20229 var import_element42 = __toESM(require_element(), 1);
20230 var import_block_editor12 = __toESM(require_block_editor(), 1);
20231 var import_data47 = __toESM(require_data(), 1);
20232 var import_core_data33 = __toESM(require_core_data(), 1);
20233 var import_blocks11 = __toESM(require_blocks(), 1);
20234 var import_preferences9 = __toESM(require_preferences(), 1);
20235 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
20236 function useStartPatterns() {
20237 const { blockPatternsWithPostContentBlockType, postType: postType2 } = (0, import_data47.useSelect)(
20238 (select6) => {
20239 const { getPatternsByBlockTypes, getBlocksByName } = select6(import_block_editor12.store);
20240 const { getCurrentPostType: getCurrentPostType2, getRenderingMode: getRenderingMode2 } = select6(store);
20241 const rootClientId = getRenderingMode2() === "post-only" ? "" : getBlocksByName("core/post-content")?.[0];
20242 return {
20243 blockPatternsWithPostContentBlockType: getPatternsByBlockTypes(
20244 "core/post-content",
20245 rootClientId
20246 ),
20247 postType: getCurrentPostType2()
20248 };
20249 },
20250 []
20251 );
20252 return (0, import_element42.useMemo)(() => {
20253 if (!blockPatternsWithPostContentBlockType?.length) {
20254 return [];
20255 }
20256 return blockPatternsWithPostContentBlockType.filter((pattern) => {
20257 return postType2 === "page" && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType2);
20258 });
20259 }, [postType2, blockPatternsWithPostContentBlockType]);
20260 }
20261 function PatternSelection({ blockPatterns, onChoosePattern }) {
20262 const { editEntityRecord } = (0, import_data47.useDispatch)(import_core_data33.store);
20263 const { postType: postType2, postId: postId2 } = (0, import_data47.useSelect)((select6) => {
20264 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select6(store);
20265 return {
20266 postType: getCurrentPostType2(),
20267 postId: getCurrentPostId2()
20268 };
20269 }, []);
20270 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
20271 import_block_editor12.__experimentalBlockPatternsList,
20272 {
20273 blockPatterns,
20274 onClickPattern: (_pattern, blocks) => {
20275 editEntityRecord("postType", postType2, postId2, {
20276 blocks,
20277 content: ({ blocks: blocksForSerialization = [] }) => (0, import_blocks11.__unstableSerializeAndClean)(blocksForSerialization)
20278 });
20279 onChoosePattern();
20280 }
20281 }
20282 );
20283 }
20284 function StartPageOptionsModal({ onClose }) {
20285 const [showStartPatterns, setShowStartPatterns] = (0, import_element42.useState)(true);
20286 const { set: setPreference } = (0, import_data47.useDispatch)(import_preferences9.store);
20287 const startPatterns = useStartPatterns();
20288 const hasStartPattern = startPatterns.length > 0;
20289 if (!hasStartPattern) {
20290 return null;
20291 }
20292 function handleClose() {
20293 onClose();
20294 setPreference("core", "enableChoosePatternModal", showStartPatterns);
20295 }
20296 return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
20297 import_components32.Modal,
20298 {
20299 className: "editor-start-page-options__modal",
20300 title: (0, import_i18n68.__)("Choose a pattern"),
20301 isFullScreen: true,
20302 onRequestClose: handleClose,
20303 children: [
20304 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: "editor-start-page-options__modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
20305 PatternSelection,
20306 {
20307 blockPatterns: startPatterns,
20308 onChoosePattern: handleClose
20309 }
20310 ) }),
20311 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
20312 import_components32.Flex,
20313 {
20314 className: "editor-start-page-options__modal__actions",
20315 justify: "flex-start",
20316 expanded: false,
20317 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components32.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
20318 import_components32.CheckboxControl,
20319 {
20320 checked: showStartPatterns,
20321 label: (0, import_i18n68.__)(
20322 "Always show starter patterns for new pages"
20323 ),
20324 onChange: (newValue) => {
20325 setShowStartPatterns(newValue);
20326 }
20327 }
20328 ) })
20329 }
20330 )
20331 ]
20332 }
20333 );
20334 }
20335 function StartPageOptions() {
20336 const [isOpen, setIsOpen] = (0, import_element42.useState)(false);
20337 const { isEditedPostDirty: isEditedPostDirty2, isEditedPostEmpty: isEditedPostEmpty2 } = (0, import_data47.useSelect)(store);
20338 const { isModalActive: isModalActive2 } = (0, import_data47.useSelect)(store2);
20339 const { enabled, postId: postId2 } = (0, import_data47.useSelect)((select6) => {
20340 const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select6(store);
20341 const choosePatternModalEnabled = select6(import_preferences9.store).get(
20342 "core",
20343 "enableChoosePatternModal"
20344 );
20345 const currentPostType = getCurrentPostType2();
20346 return {
20347 postId: getCurrentPostId2(),
20348 enabled: choosePatternModalEnabled && ATTACHMENT_POST_TYPE !== currentPostType && TEMPLATE_POST_TYPE !== currentPostType && TEMPLATE_PART_POST_TYPE !== currentPostType
20349 };
20350 }, []);
20351 (0, import_element42.useEffect)(() => {
20352 const isFreshPage = !isEditedPostDirty2() && isEditedPostEmpty2();
20353 const isPreferencesModalActive = isModalActive2("editor/preferences");
20354 if (!enabled || !isFreshPage || isPreferencesModalActive) {
20355 return;
20356 }
20357 setIsOpen(true);
20358 }, [
20359 enabled,
20360 postId2,
20361 isEditedPostDirty2,
20362 isEditedPostEmpty2,
20363 isModalActive2
20364 ]);
20365 if (!isOpen) {
20366 return null;
20367 }
20368 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(StartPageOptionsModal, { onClose: () => setIsOpen(false) });
20369 }
20370
20371 // packages/editor/build-module/components/keyboard-shortcut-help-modal/index.mjs
20372 var import_components33 = __toESM(require_components(), 1);
20373 var import_i18n70 = __toESM(require_i18n(), 1);
20374 var import_keyboard_shortcuts2 = __toESM(require_keyboard_shortcuts(), 1);
20375 var import_data49 = __toESM(require_data(), 1);
20376
20377 // packages/editor/build-module/components/keyboard-shortcut-help-modal/config.mjs
20378 var import_i18n69 = __toESM(require_i18n(), 1);
20379 var textFormattingShortcuts = [
20380 {
20381 keyCombination: { modifier: "primary", character: "b" },
20382 description: (0, import_i18n69.__)("Make the selected text bold.")
20383 },
20384 {
20385 keyCombination: { modifier: "primary", character: "i" },
20386 description: (0, import_i18n69.__)("Make the selected text italic.")
20387 },
20388 {
20389 keyCombination: { modifier: "primary", character: "k" },
20390 description: (0, import_i18n69.__)("Convert the selected text into a link.")
20391 },
20392 {
20393 keyCombination: { modifier: "primaryShift", character: "k" },
20394 description: (0, import_i18n69.__)("Remove a link.")
20395 },
20396 {
20397 keyCombination: { character: "[[" },
20398 description: (0, import_i18n69.__)("Insert a link to a post or page.")
20399 },
20400 {
20401 keyCombination: { modifier: "primary", character: "u" },
20402 description: (0, import_i18n69.__)("Underline the selected text.")
20403 },
20404 {
20405 keyCombination: { modifier: "access", character: "d" },
20406 description: (0, import_i18n69.__)("Strikethrough the selected text.")
20407 },
20408 {
20409 keyCombination: { modifier: "access", character: "x" },
20410 description: (0, import_i18n69.__)("Make the selected text inline code.")
20411 },
20412 {
20413 keyCombination: {
20414 modifier: "access",
20415 character: "0"
20416 },
20417 aliases: [
20418 {
20419 modifier: "access",
20420 character: "7"
20421 }
20422 ],
20423 description: (0, import_i18n69.__)("Convert the current heading to a paragraph.")
20424 },
20425 {
20426 keyCombination: { modifier: "access", character: "1-6" },
20427 description: (0, import_i18n69.__)(
20428 "Convert the current paragraph or heading to a heading of level 1 to 6."
20429 )
20430 },
20431 {
20432 keyCombination: { modifier: "primaryShift", character: "SPACE" },
20433 description: (0, import_i18n69.__)("Add non breaking space.")
20434 }
20435 ];
20436
20437 // packages/editor/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs
20438 var import_element43 = __toESM(require_element(), 1);
20439 var import_keycodes = __toESM(require_keycodes(), 1);
20440 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
20441 function KeyCombination({ keyCombination, forceAriaLabel }) {
20442 const shortcut = keyCombination.modifier ? import_keycodes.displayShortcutList[keyCombination.modifier](
20443 keyCombination.character
20444 ) : keyCombination.character;
20445 const ariaLabel = keyCombination.modifier ? import_keycodes.shortcutAriaLabel[keyCombination.modifier](
20446 keyCombination.character
20447 ) : keyCombination.character;
20448 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
20449 "kbd",
20450 {
20451 className: "editor-keyboard-shortcut-help-modal__shortcut-key-combination",
20452 "aria-label": forceAriaLabel || ariaLabel,
20453 children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map(
20454 (character, index2) => {
20455 if (character === "+") {
20456 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_element43.Fragment, { children: character }, index2);
20457 }
20458 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
20459 "kbd",
20460 {
20461 className: "editor-keyboard-shortcut-help-modal__shortcut-key",
20462 children: character
20463 },
20464 index2
20465 );
20466 }
20467 )
20468 }
20469 );
20470 }
20471 function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) {
20472 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_jsx_runtime123.Fragment, { children: [
20473 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("div", { className: "editor-keyboard-shortcut-help-modal__shortcut-description", children: description }),
20474 /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: "editor-keyboard-shortcut-help-modal__shortcut-term", children: [
20475 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
20476 KeyCombination,
20477 {
20478 keyCombination,
20479 forceAriaLabel: ariaLabel
20480 }
20481 ),
20482 aliases.map((alias, index2) => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
20483 KeyCombination,
20484 {
20485 keyCombination: alias,
20486 forceAriaLabel: ariaLabel
20487 },
20488 index2
20489 ))
20490 ] })
20491 ] });
20492 }
20493 var shortcut_default = Shortcut;
20494
20495 // packages/editor/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs
20496 var import_data48 = __toESM(require_data(), 1);
20497 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1);
20498 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
20499 function DynamicShortcut({ name: name2 }) {
20500 const { keyCombination, description, aliases } = (0, import_data48.useSelect)(
20501 (select6) => {
20502 const {
20503 getShortcutKeyCombination,
20504 getShortcutDescription,
20505 getShortcutAliases
20506 } = select6(import_keyboard_shortcuts.store);
20507 return {
20508 keyCombination: getShortcutKeyCombination(name2),
20509 aliases: getShortcutAliases(name2),
20510 description: getShortcutDescription(name2)
20511 };
20512 },
20513 [name2]
20514 );
20515 if (!keyCombination) {
20516 return null;
20517 }
20518 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
20519 shortcut_default,
20520 {
20521 keyCombination,
20522 description,
20523 aliases
20524 }
20525 );
20526 }
20527 var dynamic_shortcut_default = DynamicShortcut;
20528
20529 // packages/editor/build-module/components/keyboard-shortcut-help-modal/index.mjs
20530 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
20531 var KEYBOARD_SHORTCUT_HELP_MODAL_NAME = "editor/keyboard-shortcut-help";
20532 var ShortcutList = ({ shortcuts }) => (
20533 /*
20534 * Disable reason: The `list` ARIA role is redundant but
20535 * Safari+VoiceOver won't announce the list otherwise.
20536 */
20537 /* eslint-disable jsx-a11y/no-redundant-roles */
20538 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
20539 "ul",
20540 {
20541 className: "editor-keyboard-shortcut-help-modal__shortcut-list",
20542 role: "list",
20543 children: shortcuts.map((shortcut, index2) => /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
20544 "li",
20545 {
20546 className: "editor-keyboard-shortcut-help-modal__shortcut",
20547 children: typeof shortcut === "string" ? /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(dynamic_shortcut_default, { name: shortcut }) : /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(shortcut_default, { ...shortcut })
20548 },
20549 index2
20550 ))
20551 }
20552 )
20553 );
20554 var ShortcutSection = ({ title, shortcuts, className }) => /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(
20555 "section",
20556 {
20557 className: clsx_default(
20558 "editor-keyboard-shortcut-help-modal__section",
20559 className
20560 ),
20561 children: [
20562 !!title && /* @__PURE__ */ (0, import_jsx_runtime125.jsx)("h2", { className: "editor-keyboard-shortcut-help-modal__section-title", children: title }),
20563 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(ShortcutList, { shortcuts })
20564 ]
20565 }
20566 );
20567 var ShortcutCategorySection = ({
20568 title,
20569 categoryName,
20570 additionalShortcuts = []
20571 }) => {
20572 const categoryShortcuts = (0, import_data49.useSelect)(
20573 (select6) => {
20574 return select6(import_keyboard_shortcuts2.store).getCategoryShortcuts(
20575 categoryName
20576 );
20577 },
20578 [categoryName]
20579 );
20580 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
20581 ShortcutSection,
20582 {
20583 title,
20584 shortcuts: categoryShortcuts.concat(additionalShortcuts)
20585 }
20586 );
20587 };
20588 function KeyboardShortcutHelpModal() {
20589 const isModalActive2 = (0, import_data49.useSelect)(
20590 (select6) => select6(store2).isModalActive(
20591 KEYBOARD_SHORTCUT_HELP_MODAL_NAME
20592 ),
20593 []
20594 );
20595 const { openModal: openModal2, closeModal: closeModal2 } = (0, import_data49.useDispatch)(store2);
20596 const toggleModal = () => {
20597 if (isModalActive2) {
20598 closeModal2();
20599 } else {
20600 openModal2(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
20601 }
20602 };
20603 (0, import_keyboard_shortcuts2.useShortcut)("core/editor/keyboard-shortcuts", toggleModal);
20604 if (!isModalActive2) {
20605 return null;
20606 }
20607 return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(
20608 import_components33.Modal,
20609 {
20610 className: "editor-keyboard-shortcut-help-modal",
20611 title: (0, import_i18n70.__)("Keyboard shortcuts"),
20612 closeButtonLabel: (0, import_i18n70.__)("Close"),
20613 onRequestClose: toggleModal,
20614 children: [
20615 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
20616 ShortcutSection,
20617 {
20618 className: "editor-keyboard-shortcut-help-modal__main-shortcuts",
20619 shortcuts: ["core/editor/keyboard-shortcuts"]
20620 }
20621 ),
20622 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
20623 ShortcutCategorySection,
20624 {
20625 title: (0, import_i18n70.__)("Global shortcuts"),
20626 categoryName: "global"
20627 }
20628 ),
20629 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
20630 ShortcutCategorySection,
20631 {
20632 title: (0, import_i18n70.__)("Selection shortcuts"),
20633 categoryName: "selection"
20634 }
20635 ),
20636 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
20637 ShortcutCategorySection,
20638 {
20639 title: (0, import_i18n70.__)("Block shortcuts"),
20640 categoryName: "block",
20641 additionalShortcuts: [
20642 {
20643 keyCombination: { character: "/" },
20644 description: (0, import_i18n70.__)(
20645 "Change the block type after adding a new paragraph."
20646 ),
20647 /* translators: The forward-slash character. e.g. '/'. */
20648 ariaLabel: (0, import_i18n70.__)("Forward-slash")
20649 }
20650 ]
20651 }
20652 ),
20653 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
20654 ShortcutSection,
20655 {
20656 title: (0, import_i18n70.__)("Text formatting"),
20657 shortcuts: textFormattingShortcuts
20658 }
20659 ),
20660 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
20661 ShortcutCategorySection,
20662 {
20663 title: (0, import_i18n70.__)("List View shortcuts"),
20664 categoryName: "list-view"
20665 }
20666 )
20667 ]
20668 }
20669 );
20670 }
20671 var keyboard_shortcut_help_modal_default = KeyboardShortcutHelpModal;
20672
20673 // packages/editor/build-module/components/start-template-options/index.mjs
20674 var import_components34 = __toESM(require_components(), 1);
20675 var import_i18n71 = __toESM(require_i18n(), 1);
20676 var import_element44 = __toESM(require_element(), 1);
20677 var import_block_editor13 = __toESM(require_block_editor(), 1);
20678 var import_data50 = __toESM(require_data(), 1);
20679 var import_blocks12 = __toESM(require_blocks(), 1);
20680 var import_core_data34 = __toESM(require_core_data(), 1);
20681 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
20682 function useFallbackTemplateContent(slug, isCustom = false) {
20683 return (0, import_data50.useSelect)(
20684 (select6) => {
20685 const { getEntityRecord, getDefaultTemplateId } = select6(import_core_data34.store);
20686 const templateId2 = getDefaultTemplateId({
20687 slug,
20688 is_custom: isCustom,
20689 ignore_empty: true
20690 });
20691 return templateId2 ? getEntityRecord("postType", TEMPLATE_POST_TYPE, templateId2)?.content?.raw : void 0;
20692 },
20693 [slug, isCustom]
20694 );
20695 }
20696 function useStartPatterns2(fallbackContent) {
20697 const { slug, patterns: patterns2 } = (0, import_data50.useSelect)((select6) => {
20698 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select6(store);
20699 const { getEntityRecord, getBlockPatterns } = select6(import_core_data34.store);
20700 const postId2 = getCurrentPostId2();
20701 const postType2 = getCurrentPostType2();
20702 const record = getEntityRecord("postType", postType2, postId2);
20703 return {
20704 slug: record.slug,
20705 patterns: getBlockPatterns()
20706 };
20707 }, []);
20708 const currentThemeStylesheet = (0, import_data50.useSelect)(
20709 (select6) => select6(import_core_data34.store).getCurrentTheme().stylesheet
20710 );
20711 function injectThemeAttributeInBlockTemplateContent2(block) {
20712 if (block.innerBlocks.find(
20713 (innerBlock) => innerBlock.name === "core/template-part"
20714 )) {
20715 block.innerBlocks = block.innerBlocks.map((innerBlock) => {
20716 if (innerBlock.name === "core/template-part" && innerBlock.attributes.theme === void 0) {
20717 innerBlock.attributes.theme = currentThemeStylesheet;
20718 }
20719 return innerBlock;
20720 });
20721 }
20722 if (block.name === "core/template-part" && block.attributes.theme === void 0) {
20723 block.attributes.theme = currentThemeStylesheet;
20724 }
20725 return block;
20726 }
20727 return (0, import_element44.useMemo)(() => {
20728 return [
20729 {
20730 name: "fallback",
20731 blocks: (0, import_blocks12.parse)(fallbackContent),
20732 title: (0, import_i18n71.__)("Fallback content")
20733 },
20734 ...patterns2.filter((pattern) => {
20735 return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some(
20736 (templateType) => slug.startsWith(templateType)
20737 );
20738 }).map((pattern) => {
20739 return {
20740 ...pattern,
20741 blocks: (0, import_blocks12.parse)(pattern.content).map(
20742 (block) => injectThemeAttributeInBlockTemplateContent2(block)
20743 )
20744 };
20745 })
20746 ];
20747 }, [fallbackContent, slug, patterns2]);
20748 }
20749 function PatternSelection2({ fallbackContent, onChoosePattern, postType: postType2 }) {
20750 const [, , onChange] = (0, import_core_data34.useEntityBlockEditor)("postType", postType2);
20751 const blockPatterns = useStartPatterns2(fallbackContent);
20752 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
20753 import_block_editor13.__experimentalBlockPatternsList,
20754 {
20755 blockPatterns,
20756 onClickPattern: (pattern, blocks) => {
20757 onChange(blocks, { selection: void 0 });
20758 onChoosePattern();
20759 }
20760 }
20761 );
20762 }
20763 function StartModal({ slug, isCustom, onClose, postType: postType2 }) {
20764 const fallbackContent = useFallbackTemplateContent(slug, isCustom);
20765 if (!fallbackContent) {
20766 return null;
20767 }
20768 return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(
20769 import_components34.Modal,
20770 {
20771 className: "editor-start-template-options__modal",
20772 title: (0, import_i18n71.__)("Choose a pattern"),
20773 closeLabel: (0, import_i18n71.__)("Cancel"),
20774 focusOnMount: "firstElement",
20775 onRequestClose: onClose,
20776 isFullScreen: true,
20777 children: [
20778 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("div", { className: "editor-start-template-options__modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
20779 PatternSelection2,
20780 {
20781 fallbackContent,
20782 slug,
20783 isCustom,
20784 postType: postType2,
20785 onChoosePattern: () => {
20786 onClose();
20787 }
20788 }
20789 ) }),
20790 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
20791 import_components34.Flex,
20792 {
20793 className: "editor-start-template-options__modal__actions",
20794 justify: "flex-end",
20795 expanded: false,
20796 children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(import_components34.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
20797 import_components34.Button,
20798 {
20799 __next40pxDefaultSize: true,
20800 variant: "tertiary",
20801 onClick: onClose,
20802 children: (0, import_i18n71.__)("Skip")
20803 }
20804 ) })
20805 }
20806 )
20807 ]
20808 }
20809 );
20810 }
20811 function StartTemplateOptions() {
20812 const [isClosed, setIsClosed] = (0, import_element44.useState)(false);
20813 const { shouldOpenModal, slug, isCustom, postType: postType2, postId: postId2 } = (0, import_data50.useSelect)(
20814 (select6) => {
20815 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select6(store);
20816 const _postType = getCurrentPostType2();
20817 const _postId = getCurrentPostId2();
20818 const { getEditedEntityRecord, hasEditsForEntityRecord } = select6(import_core_data34.store);
20819 const templateRecord = getEditedEntityRecord(
20820 "postType",
20821 _postType,
20822 _postId
20823 );
20824 const hasEdits = hasEditsForEntityRecord(
20825 "postType",
20826 _postType,
20827 _postId
20828 );
20829 return {
20830 shouldOpenModal: !hasEdits && "" === templateRecord.content && TEMPLATE_POST_TYPE === _postType,
20831 slug: templateRecord.slug,
20832 isCustom: templateRecord.is_custom,
20833 postType: _postType,
20834 postId: _postId
20835 };
20836 },
20837 []
20838 );
20839 (0, import_element44.useEffect)(() => {
20840 setIsClosed(false);
20841 }, [postType2, postId2]);
20842 if (!shouldOpenModal || isClosed) {
20843 return null;
20844 }
20845 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
20846 StartModal,
20847 {
20848 slug,
20849 isCustom,
20850 postType: postType2,
20851 onClose: () => setIsClosed(true)
20852 }
20853 );
20854 }
20855
20856 // packages/editor/build-module/components/global-keyboard-shortcuts/index.mjs
20857 var import_keyboard_shortcuts3 = __toESM(require_keyboard_shortcuts(), 1);
20858 var import_data51 = __toESM(require_data(), 1);
20859 var import_block_editor14 = __toESM(require_block_editor(), 1);
20860 function EditorKeyboardShortcuts() {
20861 const isModeToggleDisabled = (0, import_data51.useSelect)((select6) => {
20862 const { richEditingEnabled, codeEditingEnabled } = select6(store).getEditorSettings();
20863 return !richEditingEnabled || !codeEditingEnabled;
20864 }, []);
20865 const { getBlockSelectionStart: getBlockSelectionStart2 } = (0, import_data51.useSelect)(import_block_editor14.store);
20866 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data51.useSelect)(store2);
20867 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data51.useDispatch)(store2);
20868 const {
20869 redo: redo2,
20870 undo: undo2,
20871 savePost: savePost2,
20872 setIsListViewOpened: setIsListViewOpened2,
20873 switchEditorMode: switchEditorMode2,
20874 toggleDistractionFree: toggleDistractionFree2
20875 } = (0, import_data51.useDispatch)(store);
20876 const {
20877 isEditedPostDirty: isEditedPostDirty2,
20878 isPostSavingLocked: isPostSavingLocked2,
20879 isListViewOpened: isListViewOpened2,
20880 getEditorMode: getEditorMode2
20881 } = (0, import_data51.useSelect)(store);
20882 (0, import_keyboard_shortcuts3.useShortcut)(
20883 "core/editor/toggle-mode",
20884 () => {
20885 switchEditorMode2(
20886 getEditorMode2() === "visual" ? "text" : "visual"
20887 );
20888 },
20889 {
20890 isDisabled: isModeToggleDisabled
20891 }
20892 );
20893 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/toggle-distraction-free", () => {
20894 toggleDistractionFree2();
20895 });
20896 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/undo", (event) => {
20897 undo2();
20898 event.preventDefault();
20899 });
20900 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/redo", (event) => {
20901 redo2();
20902 event.preventDefault();
20903 });
20904 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/save", (event) => {
20905 event.preventDefault();
20906 if (isPostSavingLocked2()) {
20907 return;
20908 }
20909 if (!isEditedPostDirty2()) {
20910 return;
20911 }
20912 savePost2();
20913 });
20914 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/toggle-list-view", (event) => {
20915 if (!isListViewOpened2()) {
20916 event.preventDefault();
20917 setIsListViewOpened2(true);
20918 }
20919 });
20920 (0, import_keyboard_shortcuts3.useShortcut)("core/editor/toggle-sidebar", (event) => {
20921 event.preventDefault();
20922 const isEditorSidebarOpened = [
20923 "edit-post/document",
20924 "edit-post/block"
20925 ].includes(getActiveComplementaryArea2("core"));
20926 if (isEditorSidebarOpened) {
20927 disableComplementaryArea2("core");
20928 } else {
20929 const sidebarToOpen = getBlockSelectionStart2() ? "edit-post/block" : "edit-post/document";
20930 enableComplementaryArea2("core", sidebarToOpen);
20931 }
20932 });
20933 return null;
20934 }
20935
20936 // packages/editor/build-module/components/template-part-menu-items/index.mjs
20937 var import_data54 = __toESM(require_data(), 1);
20938 var import_block_editor17 = __toESM(require_block_editor(), 1);
20939
20940 // packages/editor/build-module/components/template-part-menu-items/convert-to-regular.mjs
20941 var import_data52 = __toESM(require_data(), 1);
20942 var import_block_editor15 = __toESM(require_block_editor(), 1);
20943 var import_core_data35 = __toESM(require_core_data(), 1);
20944 var import_components35 = __toESM(require_components(), 1);
20945 var import_i18n72 = __toESM(require_i18n(), 1);
20946 var import_html_entities8 = __toESM(require_html_entities(), 1);
20947 var import_element45 = __toESM(require_element(), 1);
20948 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
20949 function ConvertToRegularBlocks({ clientId, onClose }) {
20950 const [showConfirmDialog, setShowConfirmDialog] = (0, import_element45.useState)(false);
20951 const { getBlocks: getBlocks2 } = (0, import_data52.useSelect)(import_block_editor15.store);
20952 const { replaceBlocks: replaceBlocks2 } = (0, import_data52.useDispatch)(import_block_editor15.store);
20953 const { canRemove, templatePartTitle } = (0, import_data52.useSelect)(
20954 (select6) => {
20955 const { canRemoveBlock, getBlock: getBlock2 } = select6(import_block_editor15.store);
20956 const { getEntityRecord, getCurrentTheme } = select6(import_core_data35.store);
20957 const block = getBlock2(clientId);
20958 const { slug, theme } = block?.attributes ?? {};
20959 const themeSlug = theme || getCurrentTheme()?.stylesheet;
20960 const templatePartId = themeSlug && slug ? `${themeSlug}//${slug}` : null;
20961 const entity = templatePartId ? getEntityRecord(
20962 "postType",
20963 "wp_template_part",
20964 templatePartId
20965 ) : null;
20966 return {
20967 canRemove: canRemoveBlock(clientId),
20968 templatePartTitle: entity?.title?.rendered ? (0, import_html_entities8.decodeEntities)(entity.title.rendered) : null
20969 };
20970 },
20971 [clientId]
20972 );
20973 if (!canRemove) {
20974 return null;
20975 }
20976 const title = templatePartTitle ? (0, import_i18n72.sprintf)(
20977 /* translators: %s: template part title, e.g. "Header" */
20978 (0, import_i18n72.__)("Detach %s?"),
20979 templatePartTitle
20980 ) : (0, import_i18n72.__)("Detach template part?");
20981 const message2 = templatePartTitle ? (0, import_i18n72.sprintf)(
20982 /* translators: %s: template part title, e.g. "Header" */
20983 (0, import_i18n72.__)(
20984 "The blocks will be separated from the original template part and will be fully editable. Future changes to the %s template part will not apply here."
20985 ),
20986 templatePartTitle
20987 ) : (0, import_i18n72.__)(
20988 "The blocks will be separated from the original template part and will be fully editable. Future changes to the template part will not apply here."
20989 );
20990 return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(import_jsx_runtime127.Fragment, { children: [
20991 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(import_components35.MenuItem, { onClick: () => setShowConfirmDialog(true), children: (0, import_i18n72.__)("Detach") }),
20992 /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(
20993 import_components35.__experimentalConfirmDialog,
20994 {
20995 isOpen: showConfirmDialog,
20996 onConfirm: () => {
20997 replaceBlocks2(clientId, getBlocks2(clientId));
20998 onClose();
20999 },
21000 onCancel: () => setShowConfirmDialog(false),
21001 confirmButtonText: (0, import_i18n72.__)("Detach"),
21002 size: "medium",
21003 title,
21004 __experimentalHideHeader: false,
21005 children: message2
21006 }
21007 )
21008 ] });
21009 }
21010
21011 // packages/editor/build-module/components/template-part-menu-items/convert-to-template-part.mjs
21012 var import_data53 = __toESM(require_data(), 1);
21013 var import_block_editor16 = __toESM(require_block_editor(), 1);
21014 var import_components36 = __toESM(require_components(), 1);
21015 var import_blocks13 = __toESM(require_blocks(), 1);
21016 var import_i18n73 = __toESM(require_i18n(), 1);
21017 var import_element46 = __toESM(require_element(), 1);
21018 var import_notices15 = __toESM(require_notices(), 1);
21019 var import_core_data36 = __toESM(require_core_data(), 1);
21020 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
21021 function ConvertToTemplatePart({ clientIds, blocks }) {
21022 const [isModalOpen, setIsModalOpen] = (0, import_element46.useState)(false);
21023 const { replaceBlocks: replaceBlocks2 } = (0, import_data53.useDispatch)(import_block_editor16.store);
21024 const { createSuccessNotice } = (0, import_data53.useDispatch)(import_notices15.store);
21025 const { isBlockBasedTheme, canCreate } = (0, import_data53.useSelect)((select6) => {
21026 return {
21027 isBlockBasedTheme: select6(import_core_data36.store).getCurrentTheme()?.is_block_theme,
21028 canCreate: select6(import_block_editor16.store).canInsertBlockType(
21029 "core/template-part"
21030 )
21031 };
21032 }, []);
21033 if (!isBlockBasedTheme || !canCreate) {
21034 return null;
21035 }
21036 const onConvert = async (templatePart) => {
21037 replaceBlocks2(
21038 clientIds,
21039 (0, import_blocks13.createBlock)("core/template-part", {
21040 slug: templatePart.slug,
21041 theme: templatePart.theme
21042 })
21043 );
21044 createSuccessNotice((0, import_i18n73.__)("Template part created."), {
21045 type: "snackbar"
21046 });
21047 };
21048 return /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(import_jsx_runtime128.Fragment, { children: [
21049 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
21050 import_components36.MenuItem,
21051 {
21052 icon: symbol_filled_default,
21053 onClick: () => {
21054 setIsModalOpen(true);
21055 },
21056 "aria-expanded": isModalOpen,
21057 "aria-haspopup": "dialog",
21058 children: (0, import_i18n73.__)("Create template part")
21059 }
21060 ),
21061 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(
21062 CreateTemplatePartModal,
21063 {
21064 closeModal: () => {
21065 setIsModalOpen(false);
21066 },
21067 blocks,
21068 onCreate: onConvert
21069 }
21070 )
21071 ] });
21072 }
21073
21074 // packages/editor/build-module/components/template-part-menu-items/index.mjs
21075 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
21076 function TemplatePartMenuItems() {
21077 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_block_editor17.BlockSettingsMenuControls, { children: ({ selectedClientIds, onClose }) => /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
21078 TemplatePartConverterMenuItem,
21079 {
21080 clientIds: selectedClientIds,
21081 onClose
21082 }
21083 ) });
21084 }
21085 function TemplatePartConverterMenuItem({ clientIds, onClose }) {
21086 const { blocks } = (0, import_data54.useSelect)(
21087 (select6) => {
21088 const { getBlocksByClientId: getBlocksByClientId2 } = select6(import_block_editor17.store);
21089 return {
21090 blocks: getBlocksByClientId2(clientIds)
21091 };
21092 },
21093 [clientIds]
21094 );
21095 if (blocks.length === 1 && blocks[0]?.name === "core/template-part") {
21096 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
21097 ConvertToRegularBlocks,
21098 {
21099 clientId: clientIds[0],
21100 onClose
21101 }
21102 );
21103 }
21104 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(ConvertToTemplatePart, { clientIds, blocks });
21105 }
21106
21107 // packages/editor/build-module/components/provider/index.mjs
21108 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
21109 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor18.privateApis);
21110 var { PatternsMenuItems } = unlock(import_patterns7.privateApis);
21111 var noop4 = () => {
21112 };
21113 var NON_CONTEXTUAL_POST_TYPES = [
21114 "wp_block",
21115 "wp_navigation",
21116 "wp_template_part"
21117 ];
21118 function useBlockEditorProps(post2, template2, mode) {
21119 const revisionBlocks = useRevisionBlocks();
21120 const rootLevelPost = mode === "template-locked" ? "template" : "post";
21121 const [postBlocks, onInput, onChange] = (0, import_core_data37.useEntityBlockEditor)(
21122 "postType",
21123 post2.type,
21124 { id: post2.id }
21125 );
21126 const [templateBlocks, onInputTemplate, onChangeTemplate] = (0, import_core_data37.useEntityBlockEditor)("postType", template2?.type, {
21127 id: template2?.id
21128 });
21129 const maybeNavigationBlocks = (0, import_element47.useMemo)(() => {
21130 if (post2.type === "wp_navigation") {
21131 return [
21132 (0, import_blocks14.createBlock)("core/navigation", {
21133 ref: post2.id,
21134 // As the parent editor is locked with `templateLock`, the template locking
21135 // must be explicitly "unset" on the block itself to allow the user to modify
21136 // the block's content.
21137 templateLock: false
21138 })
21139 ];
21140 }
21141 }, [post2.type, post2.id]);
21142 const blocks = (0, import_element47.useMemo)(() => {
21143 if (maybeNavigationBlocks) {
21144 return maybeNavigationBlocks;
21145 }
21146 if (rootLevelPost === "template") {
21147 return templateBlocks;
21148 }
21149 return postBlocks;
21150 }, [maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks]);
21151 if (revisionBlocks !== null) {
21152 return [revisionBlocks, noop4, noop4];
21153 }
21154 const disableRootLevelChanges = !!template2 && mode === "template-locked" || post2.type === "wp_navigation";
21155 if (disableRootLevelChanges) {
21156 return [blocks, noop4, noop4];
21157 }
21158 return [
21159 blocks,
21160 rootLevelPost === "post" ? onInput : onInputTemplate,
21161 rootLevelPost === "post" ? onChange : onChangeTemplate
21162 ];
21163 }
21164 var ExperimentalEditorProvider = with_registry_provider_default(
21165 ({
21166 post: post2,
21167 settings,
21168 recovery,
21169 initialEdits,
21170 children,
21171 BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
21172 __unstableTemplate: template2
21173 }) => {
21174 const hasTemplate = !!template2;
21175 const {
21176 editorSettings: editorSettings2,
21177 selection,
21178 isReady: isReady2,
21179 mode,
21180 defaultMode,
21181 postTypeEntities,
21182 isInRevisionsMode,
21183 currentRevisionId
21184 } = (0, import_data55.useSelect)(
21185 (select6) => {
21186 const {
21187 getEditorSettings: getEditorSettings2,
21188 getRenderingMode: getRenderingMode2,
21189 __unstableIsEditorReady: __unstableIsEditorReady2,
21190 getDefaultRenderingMode: getDefaultRenderingMode2,
21191 isRevisionsMode: _isRevisionsMode,
21192 getCurrentRevisionId: _getCurrentRevisionId
21193 } = unlock(select6(store));
21194 const { getEntitiesConfig, getEntityRecordEdits } = select6(import_core_data37.store);
21195 const _mode = getRenderingMode2();
21196 const _defaultMode = getDefaultRenderingMode2(post2.type);
21197 const hasResolvedDefaultMode = _defaultMode === "template-locked" ? hasTemplate : _defaultMode !== void 0;
21198 const isRenderingModeReady = _defaultMode !== void 0;
21199 const entityEdits = getEntityRecordEdits(
21200 "postType",
21201 post2.type,
21202 post2.id
21203 );
21204 return {
21205 editorSettings: getEditorSettings2(),
21206 isReady: __unstableIsEditorReady2(),
21207 mode: isRenderingModeReady ? _mode : void 0,
21208 defaultMode: hasResolvedDefaultMode ? _defaultMode : void 0,
21209 selection: entityEdits?.selection,
21210 postTypeEntities: post2.type === "wp_template" ? getEntitiesConfig("postType") : null,
21211 isInRevisionsMode: _isRevisionsMode(),
21212 currentRevisionId: _getCurrentRevisionId()
21213 };
21214 },
21215 [post2.type, post2.id, hasTemplate]
21216 );
21217 const shouldRenderTemplate = hasTemplate && mode !== "post-only";
21218 const rootLevelPost = shouldRenderTemplate ? template2 : post2;
21219 const defaultBlockContext = (0, import_element47.useMemo)(() => {
21220 const postContext = {};
21221 if (post2.type === "wp_template") {
21222 if (post2.slug === "page") {
21223 postContext.postType = "page";
21224 } else if (post2.slug === "single") {
21225 postContext.postType = "post";
21226 } else if (post2.slug.split("-")[0] === "single") {
21227 const postTypeNames = postTypeEntities?.map((entity) => entity.name) || [];
21228 const match3 = post2.slug.match(
21229 `^single-(${postTypeNames.join("|")})(?:-.+)?$`
21230 );
21231 if (match3) {
21232 postContext.postType = match3[1];
21233 }
21234 }
21235 } else if (!NON_CONTEXTUAL_POST_TYPES.includes(rootLevelPost.type) || shouldRenderTemplate) {
21236 postContext.postId = post2.id;
21237 postContext.postType = post2.type;
21238 }
21239 return {
21240 ...postContext,
21241 templateSlug: rootLevelPost.type === "wp_template" ? rootLevelPost.slug : void 0
21242 };
21243 }, [
21244 shouldRenderTemplate,
21245 post2.id,
21246 post2.type,
21247 post2.slug,
21248 rootLevelPost.type,
21249 rootLevelPost.slug,
21250 postTypeEntities
21251 ]);
21252 const { id, type } = rootLevelPost;
21253 const blockEditorSettings = use_block_editor_settings_default(
21254 editorSettings2,
21255 type,
21256 id,
21257 mode
21258 );
21259 const [blocks, onInput, onChange] = useBlockEditorProps(
21260 post2,
21261 template2,
21262 mode
21263 );
21264 const {
21265 updatePostLock: updatePostLock2,
21266 setupEditor: setupEditor2,
21267 updateEditorSettings: updateEditorSettings2,
21268 setCurrentTemplateId: setCurrentTemplateId2,
21269 setEditedPost: setEditedPost2,
21270 setRenderingMode: setRenderingMode2
21271 } = unlock((0, import_data55.useDispatch)(store));
21272 const { editEntityRecord } = (0, import_data55.useDispatch)(import_core_data37.store);
21273 const onChangeSelection = (0, import_element47.useCallback)(
21274 (newSelection) => {
21275 editEntityRecord(
21276 "postType",
21277 post2.type,
21278 post2.id,
21279 { selection: newSelection },
21280 { undoIgnore: true }
21281 );
21282 },
21283 [editEntityRecord, post2.type, post2.id]
21284 );
21285 const { createWarningNotice, removeNotice } = (0, import_data55.useDispatch)(import_notices16.store);
21286 (0, import_element47.useLayoutEffect)(() => {
21287 if (recovery) {
21288 return;
21289 }
21290 updatePostLock2(settings.postLock);
21291 setupEditor2(post2, initialEdits, settings.template);
21292 if (settings.autosave) {
21293 createWarningNotice(
21294 (0, import_i18n74.__)(
21295 "There is an autosave of this post that is more recent than the version below."
21296 ),
21297 {
21298 id: "autosave-exists",
21299 actions: [
21300 {
21301 label: (0, import_i18n74.__)("View the autosave"),
21302 url: settings.autosave.editLink
21303 }
21304 ]
21305 }
21306 );
21307 }
21308 }, []);
21309 (0, import_element47.useEffect)(() => {
21310 setEditedPost2(post2.type, post2.id);
21311 if (typeof window !== "undefined" && window.__experimentalTemplateActivate) {
21312 removeNotice("template-activate-notice");
21313 }
21314 return () => setEditedPost2(null, null);
21315 }, [post2.type, post2.id, setEditedPost2, removeNotice]);
21316 (0, import_element47.useEffect)(() => {
21317 updateEditorSettings2(settings);
21318 }, [settings, updateEditorSettings2]);
21319 (0, import_element47.useEffect)(() => {
21320 setCurrentTemplateId2(template2?.id);
21321 }, [template2?.id, setCurrentTemplateId2]);
21322 (0, import_element47.useEffect)(() => {
21323 if (defaultMode) {
21324 setRenderingMode2(defaultMode);
21325 }
21326 }, [defaultMode, setRenderingMode2]);
21327 useHideBlocksFromInserter(post2.type, mode);
21328 useCommands();
21329 useUploadSaveLock();
21330 if (!isReady2 || !mode) {
21331 return null;
21332 }
21333 const isAttachment = post2.type === ATTACHMENT_POST_TYPE && window?.__experimentalMediaEditor;
21334 if (isAttachment) {
21335 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_core_data37.EntityProvider, { kind: "root", type: "site", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
21336 import_core_data37.EntityProvider,
21337 {
21338 kind: "postType",
21339 type: post2.type,
21340 id: post2.id,
21341 children: [
21342 children,
21343 !settings.isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [
21344 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(EditorKeyboardShortcuts, {}),
21345 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(keyboard_shortcut_help_modal_default, {})
21346 ] })
21347 ]
21348 }
21349 ) });
21350 }
21351 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_core_data37.EntityProvider, { kind: "root", type: "site", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
21352 import_core_data37.EntityProvider,
21353 {
21354 kind: "postType",
21355 type: post2.type,
21356 id: post2.id,
21357 revisionId: currentRevisionId ?? void 0,
21358 children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_block_editor18.BlockContextProvider, { value: defaultBlockContext, children: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
21359 BlockEditorProviderComponent,
21360 {
21361 value: blocks,
21362 onChange,
21363 onInput,
21364 selection: isInRevisionsMode ? void 0 : selection,
21365 onChangeSelection: isInRevisionsMode ? noop4 : onChangeSelection,
21366 settings: blockEditorSettings,
21367 useSubRegistry: false,
21368 children: [
21369 children,
21370 !settings.isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [
21371 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(PatternsMenuItems, {}),
21372 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(TemplatePartMenuItems, {}),
21373 mode === "template-locked" && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(DisableNonPageContentBlocks, {}),
21374 type === "wp_navigation" && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(NavigationBlockEditingMode, {}),
21375 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(EditorKeyboardShortcuts, {}),
21376 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(keyboard_shortcut_help_modal_default, {}),
21377 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(BlockRemovalWarnings, {}),
21378 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(StartPageOptions, {}),
21379 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(StartTemplateOptions, {}),
21380 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(PatternRenameModal, {}),
21381 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(PatternDuplicateModal, {})
21382 ] })
21383 ]
21384 }
21385 ) })
21386 }
21387 ) });
21388 }
21389 );
21390 function EditorProvider(props) {
21391 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
21392 ExperimentalEditorProvider,
21393 {
21394 ...props,
21395 BlockEditorProviderComponent: import_block_editor18.BlockEditorProvider,
21396 children: props.children
21397 }
21398 );
21399 }
21400 var provider_default = EditorProvider;
21401
21402 // packages/editor/build-module/components/global-styles/index.mjs
21403 var import_core_data50 = __toESM(require_core_data(), 1);
21404 var import_data70 = __toESM(require_data(), 1);
21405 var import_element81 = __toESM(require_element(), 1);
21406
21407 // packages/global-styles-ui/build-module/global-styles-ui.mjs
21408 var import_components96 = __toESM(require_components(), 1);
21409 var import_blocks19 = __toESM(require_blocks(), 1);
21410 var import_data67 = __toESM(require_data(), 1);
21411 var import_block_editor31 = __toESM(require_block_editor(), 1);
21412 var import_element78 = __toESM(require_element(), 1);
21413 var import_compose14 = __toESM(require_compose(), 1);
21414
21415 // packages/global-styles-ui/build-module/provider.mjs
21416 var import_element49 = __toESM(require_element(), 1);
21417
21418 // packages/global-styles-ui/build-module/context.mjs
21419 var import_element48 = __toESM(require_element(), 1);
21420 var GlobalStylesContext = (0, import_element48.createContext)({
21421 user: { styles: {}, settings: {} },
21422 base: { styles: {}, settings: {} },
21423 merged: { styles: {}, settings: {} },
21424 onChange: () => {
21425 },
21426 fontLibraryEnabled: false
21427 });
21428
21429 // packages/global-styles-ui/build-module/provider.mjs
21430 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
21431 function GlobalStylesProvider({
21432 children,
21433 value,
21434 baseValue,
21435 onChange,
21436 fontLibraryEnabled
21437 }) {
21438 const merged = (0, import_element49.useMemo)(() => {
21439 return mergeGlobalStyles(baseValue, value);
21440 }, [baseValue, value]);
21441 const contextValue = (0, import_element49.useMemo)(
21442 () => ({
21443 user: value,
21444 base: baseValue,
21445 merged,
21446 onChange,
21447 fontLibraryEnabled
21448 }),
21449 [value, baseValue, merged, onChange, fontLibraryEnabled]
21450 );
21451 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(GlobalStylesContext.Provider, { value: contextValue, children });
21452 }
21453
21454 // packages/global-styles-ui/build-module/screen-root.mjs
21455 var import_components43 = __toESM(require_components(), 1);
21456 var import_i18n78 = __toESM(require_i18n(), 1);
21457 var import_data57 = __toESM(require_data(), 1);
21458 var import_core_data39 = __toESM(require_core_data(), 1);
21459
21460 // packages/global-styles-ui/build-module/icon-with-current-color.mjs
21461 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
21462 function IconWithCurrentColor({
21463 className,
21464 ...props
21465 }) {
21466 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
21467 icon_default,
21468 {
21469 className: clsx_default(
21470 className,
21471 "global-styles-ui-icon-with-current-color"
21472 ),
21473 ...props
21474 }
21475 );
21476 }
21477
21478 // packages/global-styles-ui/build-module/navigation-button.mjs
21479 var import_components37 = __toESM(require_components(), 1);
21480 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
21481 function GenericNavigationButton({
21482 icon,
21483 children,
21484 ...props
21485 }) {
21486 return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(import_components37.__experimentalItem, { ...props, children: [
21487 icon && /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(import_components37.__experimentalHStack, { justify: "flex-start", children: [
21488 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(IconWithCurrentColor, { icon, size: 24 }),
21489 /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_components37.FlexItem, { children })
21490 ] }),
21491 !icon && children
21492 ] });
21493 }
21494 function NavigationButtonAsItem(props) {
21495 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_components37.Navigator.Button, { as: GenericNavigationButton, ...props });
21496 }
21497
21498 // packages/global-styles-ui/build-module/root-menu.mjs
21499 var import_components38 = __toESM(require_components(), 1);
21500 var import_i18n76 = __toESM(require_i18n(), 1);
21501 var import_block_editor19 = __toESM(require_block_editor(), 1);
21502
21503 // node_modules/colord/plugins/a11y.mjs
21504 var o3 = function(o4) {
21505 var t4 = o4 / 255;
21506 return t4 < 0.04045 ? t4 / 12.92 : Math.pow((t4 + 0.055) / 1.055, 2.4);
21507 };
21508 var t3 = function(t4) {
21509 return 0.2126 * o3(t4.r) + 0.7152 * o3(t4.g) + 0.0722 * o3(t4.b);
21510 };
21511 function a11y_default(o4) {
21512 o4.prototype.luminance = function() {
21513 return o5 = t3(this.rgba), void 0 === (r4 = 2) && (r4 = 0), void 0 === n3 && (n3 = Math.pow(10, r4)), Math.round(n3 * o5) / n3 + 0;
21514 var o5, r4, n3;
21515 }, o4.prototype.contrast = function(r4) {
21516 void 0 === r4 && (r4 = "#FFF");
21517 var n3, a3, i3, e3, v3, u3, d3, c6 = r4 instanceof o4 ? r4 : new o4(r4);
21518 return e3 = this.rgba, v3 = c6.toRgb(), u3 = t3(e3), d3 = t3(v3), n3 = u3 > d3 ? (u3 + 0.05) / (d3 + 0.05) : (d3 + 0.05) / (u3 + 0.05), void 0 === (a3 = 2) && (a3 = 0), void 0 === i3 && (i3 = Math.pow(10, a3)), Math.floor(i3 * n3) / i3 + 0;
21519 }, o4.prototype.isReadable = function(o5, t4) {
21520 return void 0 === o5 && (o5 = "#FFF"), void 0 === t4 && (t4 = {}), this.contrast(o5) >= (e3 = void 0 === (i3 = (r4 = t4).size) ? "normal" : i3, "AAA" === (a3 = void 0 === (n3 = r4.level) ? "AA" : n3) && "normal" === e3 ? 7 : "AA" === a3 && "large" === e3 ? 3 : 4.5);
21521 var r4, n3, a3, i3, e3;
21522 };
21523 }
21524
21525 // packages/global-styles-ui/build-module/hooks.mjs
21526 var import_element50 = __toESM(require_element(), 1);
21527 var import_data56 = __toESM(require_data(), 1);
21528 var import_core_data38 = __toESM(require_core_data(), 1);
21529 var import_i18n75 = __toESM(require_i18n(), 1);
21530
21531 // packages/global-styles-ui/build-module/utils.mjs
21532 function removePropertiesFromObject(object, properties) {
21533 if (!properties?.length) {
21534 return object;
21535 }
21536 if (typeof object !== "object" || !object || !Object.keys(object).length) {
21537 return object;
21538 }
21539 for (const key in object) {
21540 if (properties.includes(key)) {
21541 delete object[key];
21542 } else if (typeof object[key] === "object") {
21543 removePropertiesFromObject(object[key], properties);
21544 }
21545 }
21546 return object;
21547 }
21548 var filterObjectByProperties = (object, properties) => {
21549 if (!object || !properties?.length) {
21550 return {};
21551 }
21552 const newObject = {};
21553 Object.keys(object).forEach((key) => {
21554 if (properties.includes(key)) {
21555 newObject[key] = object[key];
21556 } else if (typeof object[key] === "object") {
21557 const newFilter = filterObjectByProperties(
21558 object[key],
21559 properties
21560 );
21561 if (Object.keys(newFilter).length) {
21562 newObject[key] = newFilter;
21563 }
21564 }
21565 });
21566 return newObject;
21567 };
21568 function isVariationWithProperties(variation, properties) {
21569 const variationWithProperties = filterObjectByProperties(
21570 structuredClone(variation),
21571 properties
21572 );
21573 return areGlobalStylesEqual(variationWithProperties, variation);
21574 }
21575 function getFontFamilyFromSetting(fontFamilies, setting) {
21576 if (!Array.isArray(fontFamilies) || !setting) {
21577 return null;
21578 }
21579 const fontFamilyVariable = setting.replace("var(", "").replace(")", "");
21580 const fontFamilySlug = fontFamilyVariable?.split("--").slice(-1)[0];
21581 return fontFamilies.find(
21582 (fontFamily) => fontFamily.slug === fontFamilySlug
21583 );
21584 }
21585 function getFontFamilies(themeJson) {
21586 const themeFontFamilies = themeJson?.settings?.typography?.fontFamilies?.theme;
21587 const customFontFamilies = themeJson?.settings?.typography?.fontFamilies?.custom;
21588 let fontFamilies = [];
21589 if (themeFontFamilies && customFontFamilies) {
21590 fontFamilies = [...themeFontFamilies, ...customFontFamilies];
21591 } else if (themeFontFamilies) {
21592 fontFamilies = themeFontFamilies;
21593 } else if (customFontFamilies) {
21594 fontFamilies = customFontFamilies;
21595 }
21596 const bodyFontFamilySetting = themeJson?.styles?.typography?.fontFamily;
21597 const bodyFontFamily = getFontFamilyFromSetting(
21598 fontFamilies,
21599 bodyFontFamilySetting
21600 );
21601 const headingFontFamilySetting = themeJson?.styles?.elements?.heading?.typography?.fontFamily;
21602 let headingFontFamily;
21603 if (!headingFontFamilySetting) {
21604 headingFontFamily = bodyFontFamily;
21605 } else {
21606 headingFontFamily = getFontFamilyFromSetting(
21607 fontFamilies,
21608 themeJson?.styles?.elements?.heading?.typography?.fontFamily
21609 );
21610 }
21611 return [bodyFontFamily, headingFontFamily];
21612 }
21613 function getVariationClassName(variation) {
21614 if (!variation) {
21615 return "";
21616 }
21617 return `is-style-${variation}`;
21618 }
21619 function getNewIndexFromPresets(presets, slugPrefix) {
21620 const nameRegex = new RegExp(`^${slugPrefix}([\\d]+)$`);
21621 const highestPresetValue = presets.reduce((currentHighest, preset) => {
21622 if (typeof preset?.slug === "string") {
21623 const matches = preset?.slug.match(nameRegex);
21624 if (matches) {
21625 const id = parseInt(matches[1], 10);
21626 if (id > currentHighest) {
21627 return id;
21628 }
21629 }
21630 }
21631 return currentHighest;
21632 }, 0);
21633 return highestPresetValue + 1;
21634 }
21635
21636 // packages/global-styles-ui/build-module/hooks.mjs
21637 k([a11y_default]);
21638 function useStyle(path, blockName, readFrom = "merged", shouldDecodeEncode = true) {
21639 const { user, base, merged, onChange } = (0, import_element50.useContext)(GlobalStylesContext);
21640 let sourceValue = merged;
21641 if (readFrom === "base") {
21642 sourceValue = base;
21643 } else if (readFrom === "user") {
21644 sourceValue = user;
21645 }
21646 const styleValue = (0, import_element50.useMemo)(
21647 () => getStyle(sourceValue, path, blockName, shouldDecodeEncode),
21648 [sourceValue, path, blockName, shouldDecodeEncode]
21649 );
21650 const setStyleValue = (0, import_element50.useCallback)(
21651 (newValue) => {
21652 const newGlobalStyles = setStyle(
21653 user,
21654 path,
21655 newValue,
21656 blockName
21657 );
21658 onChange(newGlobalStyles);
21659 },
21660 [user, onChange, path, blockName]
21661 );
21662 return [styleValue, setStyleValue];
21663 }
21664 function useSetting(path, blockName, readFrom = "merged") {
21665 const { user, base, merged, onChange } = (0, import_element50.useContext)(GlobalStylesContext);
21666 let sourceValue = merged;
21667 if (readFrom === "base") {
21668 sourceValue = base;
21669 } else if (readFrom === "user") {
21670 sourceValue = user;
21671 }
21672 const settingValue = (0, import_element50.useMemo)(
21673 () => getSetting(sourceValue, path, blockName),
21674 [sourceValue, path, blockName]
21675 );
21676 const setSettingValue = (0, import_element50.useCallback)(
21677 (newValue) => {
21678 const newGlobalStyles = setSetting(
21679 user,
21680 path,
21681 newValue,
21682 blockName
21683 );
21684 onChange(newGlobalStyles);
21685 },
21686 [user, onChange, path, blockName]
21687 );
21688 return [settingValue, setSettingValue];
21689 }
21690 var EMPTY_ARRAY5 = [];
21691 function hasThemeVariation({
21692 title,
21693 settings,
21694 styles
21695 }) {
21696 return title === (0, import_i18n75.__)("Default") || Object.keys(settings || {}).length > 0 || Object.keys(styles || {}).length > 0;
21697 }
21698 function useCurrentMergeThemeStyleVariationsWithUserConfig(properties = []) {
21699 const { variationsFromTheme } = (0, import_data56.useSelect)((select6) => {
21700 const _variationsFromTheme = select6(
21701 import_core_data38.store
21702 ).__experimentalGetCurrentThemeGlobalStylesVariations?.();
21703 return {
21704 variationsFromTheme: _variationsFromTheme || EMPTY_ARRAY5
21705 };
21706 }, []);
21707 const { user: userVariation } = (0, import_element50.useContext)(GlobalStylesContext);
21708 return (0, import_element50.useMemo)(() => {
21709 const clonedUserVariation = structuredClone(userVariation);
21710 const userVariationWithoutProperties = removePropertiesFromObject(
21711 clonedUserVariation,
21712 properties
21713 );
21714 userVariationWithoutProperties.title = (0, import_i18n75.__)("Default");
21715 const variationsWithPropertiesAndBase = variationsFromTheme.filter((variation) => {
21716 return isVariationWithProperties(variation, properties);
21717 }).map((variation) => {
21718 return mergeGlobalStyles(
21719 userVariationWithoutProperties,
21720 variation
21721 );
21722 });
21723 const variationsByProperties = [
21724 userVariationWithoutProperties,
21725 ...variationsWithPropertiesAndBase
21726 ];
21727 return variationsByProperties?.length ? variationsByProperties.filter(hasThemeVariation) : [];
21728 }, [properties, userVariation, variationsFromTheme]);
21729 }
21730 function useColorRandomizer(blockName) {
21731 const [themeColors, setThemeColors] = useSetting(
21732 "color.palette.theme",
21733 blockName
21734 );
21735 const randomizeColors = (0, import_element50.useCallback)(() => {
21736 if (!themeColors || !themeColors.length) {
21737 return;
21738 }
21739 const randomRotationValue = Math.floor(Math.random() * 225);
21740 const newColors = themeColors.map((colorObject) => {
21741 const { color } = colorObject;
21742 const newColor = w2(color).rotate(randomRotationValue).toHex();
21743 return {
21744 ...colorObject,
21745 color: newColor
21746 };
21747 });
21748 setThemeColors(newColors);
21749 }, [themeColors, setThemeColors]);
21750 return window.__experimentalEnableColorRandomizer ? [randomizeColors] : [];
21751 }
21752
21753 // packages/global-styles-ui/build-module/lock-unlock.mjs
21754 var import_private_apis3 = __toESM(require_private_apis(), 1);
21755 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
21756 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
21757 "@wordpress/global-styles-ui"
21758 );
21759
21760 // packages/global-styles-ui/build-module/root-menu.mjs
21761 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
21762 var {
21763 useHasDimensionsPanel,
21764 useHasTypographyPanel,
21765 useHasColorPanel,
21766 useSettingsForBlockElement,
21767 useHasBackgroundPanel
21768 } = unlock3(import_block_editor19.privateApis);
21769 function RootMenu() {
21770 const [rawSettings] = useSetting("");
21771 const settings = useSettingsForBlockElement(rawSettings);
21772 const hasBackgroundPanel = useHasBackgroundPanel(rawSettings);
21773 const hasTypographyPanel = useHasTypographyPanel(settings);
21774 const hasColorPanel = useHasColorPanel(settings);
21775 const hasShadowPanel = true;
21776 const hasDimensionsPanel = useHasDimensionsPanel(settings);
21777 const hasLayoutPanel = hasDimensionsPanel;
21778 return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_jsx_runtime134.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(import_components38.__experimentalItemGroup, { children: [
21779 hasTypographyPanel && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
21780 NavigationButtonAsItem,
21781 {
21782 icon: typography_default,
21783 path: "/typography",
21784 children: (0, import_i18n76.__)("Typography")
21785 }
21786 ),
21787 hasColorPanel && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(NavigationButtonAsItem, { icon: color_default, path: "/colors", children: (0, import_i18n76.__)("Colors") }),
21788 hasBackgroundPanel && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
21789 NavigationButtonAsItem,
21790 {
21791 icon: background_default,
21792 path: "/background",
21793 "aria-label": (0, import_i18n76.__)("Background styles"),
21794 children: (0, import_i18n76.__)("Background")
21795 }
21796 ),
21797 hasShadowPanel && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(NavigationButtonAsItem, { icon: shadow_default, path: "/shadows", children: (0, import_i18n76.__)("Shadows") }),
21798 hasLayoutPanel && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(NavigationButtonAsItem, { icon: layout_default, path: "/layout", children: (0, import_i18n76.__)("Layout") })
21799 ] }) });
21800 }
21801 var root_menu_default = RootMenu;
21802
21803 // packages/global-styles-ui/build-module/preview-styles.mjs
21804 var import_components42 = __toESM(require_components(), 1);
21805
21806 // packages/global-styles-ui/build-module/preview-hooks.mjs
21807 function useStylesPreviewColors() {
21808 const [textColor = "black"] = useStyle("color.text");
21809 const [backgroundColor = "white"] = useStyle("color.background");
21810 const [headingColor = textColor] = useStyle(
21811 "elements.h1.color.text"
21812 );
21813 const [linkColor = headingColor] = useStyle(
21814 "elements.link.color.text"
21815 );
21816 const [buttonBackgroundColor = linkColor] = useStyle(
21817 "elements.button.color.background"
21818 );
21819 const [coreColors] = useSetting("color.palette.core") || [];
21820 const [themeColors] = useSetting("color.palette.theme") || [];
21821 const [customColors] = useSetting("color.palette.custom") || [];
21822 const paletteColors = (themeColors ?? []).concat(customColors ?? []).concat(coreColors ?? []);
21823 const textColorObject = paletteColors.filter(
21824 ({ color }) => color === textColor
21825 );
21826 const buttonBackgroundColorObject = paletteColors.filter(
21827 ({ color }) => color === buttonBackgroundColor
21828 );
21829 const highlightedColors = textColorObject.concat(buttonBackgroundColorObject).concat(paletteColors).filter(
21830 // we exclude these background color because it is already visible in the preview.
21831 ({ color }) => color !== backgroundColor
21832 ).slice(0, 2);
21833 return {
21834 paletteColors,
21835 highlightedColors
21836 };
21837 }
21838
21839 // packages/global-styles-ui/build-module/typography-example.mjs
21840 var import_element51 = __toESM(require_element(), 1);
21841 var import_components39 = __toESM(require_components(), 1);
21842 var import_i18n77 = __toESM(require_i18n(), 1);
21843
21844 // packages/global-styles-ui/build-module/font-library/utils/preview-styles.mjs
21845 function findNearest(input, numbers) {
21846 if (numbers.length === 0) {
21847 return null;
21848 }
21849 numbers.sort((a3, b3) => Math.abs(input - a3) - Math.abs(input - b3));
21850 return numbers[0];
21851 }
21852 function extractFontWeights(fontFaces) {
21853 const result = [];
21854 fontFaces.forEach((face) => {
21855 const weights = String(face.fontWeight).split(" ");
21856 if (weights.length === 2) {
21857 const start2 = parseInt(weights[0]);
21858 const end = parseInt(weights[1]);
21859 for (let i3 = start2; i3 <= end; i3 += 100) {
21860 result.push(i3);
21861 }
21862 } else if (weights.length === 1) {
21863 result.push(parseInt(weights[0]));
21864 }
21865 });
21866 return result;
21867 }
21868 function formatFontFamily(input) {
21869 const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/;
21870 const output = input.trim();
21871 const formatItem = (item) => {
21872 item = item.trim();
21873 if (item.match(regex)) {
21874 item = item.replace(/^["']|["']$/g, "");
21875 return `"${item}"`;
21876 }
21877 return item;
21878 };
21879 if (output.includes(",")) {
21880 return output.split(",").map(formatItem).filter((item) => item !== "").join(", ");
21881 }
21882 return formatItem(output);
21883 }
21884 function formatFontFaceName(input) {
21885 if (!input) {
21886 return "";
21887 }
21888 let output = input.trim();
21889 if (output.includes(",")) {
21890 output = (output.split(",").find((item) => item.trim() !== "") ?? "").trim();
21891 }
21892 output = output.replace(/^["']|["']$/g, "");
21893 if (window.navigator.userAgent.toLowerCase().includes("firefox")) {
21894 output = `"${output}"`;
21895 }
21896 return output;
21897 }
21898 function getFamilyPreviewStyle(family) {
21899 const style = {
21900 fontFamily: formatFontFamily(family.fontFamily)
21901 };
21902 if (!("fontFace" in family) || !Array.isArray(family.fontFace)) {
21903 style.fontWeight = "400";
21904 style.fontStyle = "normal";
21905 return style;
21906 }
21907 if (family.fontFace) {
21908 const normalFaces = family.fontFace.filter(
21909 (face) => face?.fontStyle && face.fontStyle.toLowerCase() === "normal"
21910 );
21911 if (normalFaces.length > 0) {
21912 style.fontStyle = "normal";
21913 const normalWeights = extractFontWeights(normalFaces);
21914 const nearestWeight = findNearest(400, normalWeights);
21915 style.fontWeight = String(nearestWeight) || "400";
21916 } else {
21917 style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || "normal";
21918 style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || "400";
21919 }
21920 }
21921 return style;
21922 }
21923 function getFacePreviewStyle(face) {
21924 return {
21925 fontFamily: formatFontFamily(face.fontFamily),
21926 fontStyle: face.fontStyle || "normal",
21927 fontWeight: face.fontWeight || "400"
21928 };
21929 }
21930
21931 // packages/global-styles-ui/build-module/typography-example.mjs
21932 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
21933 function PreviewTypography({
21934 fontSize,
21935 variation
21936 }) {
21937 const { base } = (0, import_element51.useContext)(GlobalStylesContext);
21938 let config2 = base;
21939 if (variation) {
21940 config2 = { ...base, ...variation };
21941 }
21942 const [textColor] = useStyle("color.text");
21943 const [bodyFontFamilies, headingFontFamilies] = getFontFamilies(config2);
21944 const bodyPreviewStyle = bodyFontFamilies ? getFamilyPreviewStyle(bodyFontFamilies) : {};
21945 const headingPreviewStyle = headingFontFamilies ? getFamilyPreviewStyle(headingFontFamilies) : {};
21946 if (textColor) {
21947 bodyPreviewStyle.color = textColor;
21948 headingPreviewStyle.color = textColor;
21949 }
21950 if (fontSize) {
21951 bodyPreviewStyle.fontSize = fontSize;
21952 headingPreviewStyle.fontSize = fontSize;
21953 }
21954 return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
21955 import_components39.__unstableMotion.div,
21956 {
21957 animate: {
21958 scale: 1,
21959 opacity: 1
21960 },
21961 initial: {
21962 scale: 0.1,
21963 opacity: 0
21964 },
21965 transition: {
21966 delay: 0.3,
21967 type: "tween"
21968 },
21969 style: {
21970 textAlign: "center",
21971 lineHeight: 1
21972 },
21973 children: [
21974 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("span", { style: headingPreviewStyle, children: (0, import_i18n77._x)("A", "Uppercase letter A") }),
21975 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)("span", { style: bodyPreviewStyle, children: (0, import_i18n77._x)("a", "Lowercase letter A") })
21976 ]
21977 }
21978 );
21979 }
21980
21981 // packages/global-styles-ui/build-module/highlighted-colors.mjs
21982 var import_components40 = __toESM(require_components(), 1);
21983 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
21984 function HighlightedColors({
21985 normalizedColorSwatchSize,
21986 ratio
21987 }) {
21988 const { highlightedColors } = useStylesPreviewColors();
21989 const scaledSwatchSize = normalizedColorSwatchSize * ratio;
21990 return highlightedColors.map(({ slug, color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
21991 import_components40.__unstableMotion.div,
21992 {
21993 style: {
21994 height: scaledSwatchSize,
21995 width: scaledSwatchSize,
21996 background: color,
21997 borderRadius: scaledSwatchSize / 2
21998 },
21999 animate: {
22000 scale: 1,
22001 opacity: 1
22002 },
22003 initial: {
22004 scale: 0.1,
22005 opacity: 0
22006 },
22007 transition: {
22008 delay: index2 === 1 ? 0.2 : 0.1
22009 }
22010 },
22011 `${slug}-${index2}`
22012 ));
22013 }
22014
22015 // packages/global-styles-ui/build-module/preview-wrapper.mjs
22016 var import_components41 = __toESM(require_components(), 1);
22017 var import_compose9 = __toESM(require_compose(), 1);
22018 var import_element52 = __toESM(require_element(), 1);
22019 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
22020 var normalizedWidth = 248;
22021 var normalizedHeight = 152;
22022 var THROTTLE_OPTIONS = {
22023 leading: true,
22024 trailing: true
22025 };
22026 function PreviewWrapper({
22027 children,
22028 label,
22029 isFocused,
22030 withHoverView
22031 }) {
22032 const [backgroundColor = "white"] = useStyle("color.background");
22033 const [gradientValue] = useStyle("color.gradient");
22034 const disableMotion = (0, import_compose9.useReducedMotion)();
22035 const [isHovered, setIsHovered] = (0, import_element52.useState)(false);
22036 const [containerResizeListener, { width }] = (0, import_compose9.useResizeObserver)();
22037 const [throttledWidth, setThrottledWidthState] = (0, import_element52.useState)(width);
22038 const [ratioState, setRatioState] = (0, import_element52.useState)();
22039 const setThrottledWidth = (0, import_compose9.useThrottle)(
22040 setThrottledWidthState,
22041 250,
22042 THROTTLE_OPTIONS
22043 );
22044 (0, import_element52.useLayoutEffect)(() => {
22045 if (width) {
22046 setThrottledWidth(width);
22047 }
22048 }, [width, setThrottledWidth]);
22049 (0, import_element52.useLayoutEffect)(() => {
22050 const newRatio = throttledWidth ? throttledWidth / normalizedWidth : 1;
22051 const ratioDiff = newRatio - (ratioState || 0);
22052 const isRatioDiffBigEnough = Math.abs(ratioDiff) > 0.1;
22053 if (isRatioDiffBigEnough || !ratioState) {
22054 setRatioState(newRatio);
22055 }
22056 }, [throttledWidth, ratioState]);
22057 const fallbackRatio = width ? width / normalizedWidth : 1;
22058 const ratio = ratioState ? ratioState : fallbackRatio;
22059 const isReady2 = !!width;
22060 return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)(import_jsx_runtime137.Fragment, { children: [
22061 /* @__PURE__ */ (0, import_jsx_runtime137.jsx)("div", { style: { position: "relative" }, children: containerResizeListener }),
22062 isReady2 && /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
22063 "div",
22064 {
22065 className: "global-styles-ui-preview__wrapper",
22066 style: {
22067 height: normalizedHeight * ratio
22068 },
22069 onMouseEnter: () => setIsHovered(true),
22070 onMouseLeave: () => setIsHovered(false),
22071 tabIndex: -1,
22072 children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
22073 import_components41.__unstableMotion.div,
22074 {
22075 style: {
22076 height: normalizedHeight * ratio,
22077 width: "100%",
22078 background: gradientValue ?? backgroundColor,
22079 cursor: withHoverView ? "pointer" : void 0
22080 },
22081 initial: "start",
22082 animate: (isHovered || isFocused) && !disableMotion && label ? "hover" : "start",
22083 children: [].concat(children).map(
22084 (child, key) => child({ ratio, key })
22085 )
22086 }
22087 )
22088 }
22089 )
22090 ] });
22091 }
22092 var preview_wrapper_default = PreviewWrapper;
22093
22094 // packages/global-styles-ui/build-module/preview-styles.mjs
22095 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
22096 var firstFrameVariants = {
22097 start: {
22098 scale: 1,
22099 opacity: 1
22100 },
22101 hover: {
22102 scale: 0,
22103 opacity: 0
22104 }
22105 };
22106 var midFrameVariants = {
22107 hover: {
22108 opacity: 1
22109 },
22110 start: {
22111 opacity: 0.5
22112 }
22113 };
22114 var secondFrameVariants = {
22115 hover: {
22116 scale: 1,
22117 opacity: 1
22118 },
22119 start: {
22120 scale: 0,
22121 opacity: 0
22122 }
22123 };
22124 function PreviewStyles({
22125 label,
22126 isFocused,
22127 withHoverView,
22128 variation
22129 }) {
22130 const [fontWeight] = useStyle("typography.fontWeight");
22131 const [fontFamily = "serif"] = useStyle(
22132 "typography.fontFamily"
22133 );
22134 const [headingFontFamily = fontFamily] = useStyle(
22135 "elements.h1.typography.fontFamily"
22136 );
22137 const [headingFontWeight = fontWeight] = useStyle(
22138 "elements.h1.typography.fontWeight"
22139 );
22140 const [textColor = "black"] = useStyle("color.text");
22141 const [headingColor = textColor] = useStyle(
22142 "elements.h1.color.text"
22143 );
22144 const { paletteColors } = useStylesPreviewColors();
22145 return /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(
22146 preview_wrapper_default,
22147 {
22148 label,
22149 isFocused,
22150 withHoverView,
22151 children: [
22152 ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
22153 import_components42.__unstableMotion.div,
22154 {
22155 variants: firstFrameVariants,
22156 style: {
22157 height: "100%",
22158 overflow: "hidden"
22159 },
22160 children: /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(
22161 import_components42.__experimentalHStack,
22162 {
22163 spacing: 10 * ratio,
22164 justify: "center",
22165 style: {
22166 height: "100%",
22167 overflow: "hidden"
22168 },
22169 children: [
22170 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
22171 PreviewTypography,
22172 {
22173 fontSize: 65 * ratio,
22174 variation
22175 }
22176 ),
22177 /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(import_components42.__experimentalVStack, { spacing: 4 * ratio, children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
22178 HighlightedColors,
22179 {
22180 normalizedColorSwatchSize: 32,
22181 ratio
22182 }
22183 ) })
22184 ]
22185 }
22186 )
22187 },
22188 key
22189 ),
22190 ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
22191 import_components42.__unstableMotion.div,
22192 {
22193 variants: withHoverView ? midFrameVariants : void 0,
22194 style: {
22195 height: "100%",
22196 width: "100%",
22197 position: "absolute",
22198 top: 0,
22199 overflow: "hidden",
22200 filter: "blur(60px)",
22201 opacity: 0.1
22202 },
22203 children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
22204 import_components42.__experimentalHStack,
22205 {
22206 spacing: 0,
22207 justify: "flex-start",
22208 style: {
22209 height: "100%",
22210 overflow: "hidden"
22211 },
22212 children: paletteColors.slice(0, 4).map(({ color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
22213 "div",
22214 {
22215 style: {
22216 height: "100%",
22217 background: color,
22218 flexGrow: 1
22219 }
22220 },
22221 index2
22222 ))
22223 }
22224 )
22225 },
22226 key
22227 ),
22228 ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
22229 import_components42.__unstableMotion.div,
22230 {
22231 variants: secondFrameVariants,
22232 style: {
22233 height: "100%",
22234 width: "100%",
22235 overflow: "hidden",
22236 position: "absolute",
22237 top: 0
22238 },
22239 children: /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
22240 import_components42.__experimentalVStack,
22241 {
22242 spacing: 3 * ratio,
22243 justify: "center",
22244 style: {
22245 height: "100%",
22246 overflow: "hidden",
22247 padding: 10 * ratio,
22248 boxSizing: "border-box"
22249 },
22250 children: label && /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(
22251 "div",
22252 {
22253 style: {
22254 fontSize: 40 * ratio,
22255 fontFamily: headingFontFamily,
22256 color: headingColor,
22257 fontWeight: headingFontWeight,
22258 lineHeight: "1em",
22259 textAlign: "center"
22260 },
22261 children: label
22262 }
22263 )
22264 }
22265 )
22266 },
22267 key
22268 )
22269 ]
22270 }
22271 );
22272 }
22273 var preview_styles_default = PreviewStyles;
22274
22275 // packages/global-styles-ui/build-module/screen-root.mjs
22276 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
22277 function ScreenRoot() {
22278 const hasVariations = (0, import_data57.useSelect)((select6) => {
22279 const { __experimentalGetCurrentThemeGlobalStylesVariations } = select6(import_core_data39.store);
22280 return !!__experimentalGetCurrentThemeGlobalStylesVariations()?.length;
22281 }, []);
22282 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(
22283 import_components43.Card,
22284 {
22285 size: "small",
22286 isBorderless: true,
22287 className: "global-styles-ui-screen-root",
22288 isRounded: false,
22289 children: [
22290 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components43.CardBody, { children: /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components43.__experimentalVStack, { spacing: 4, children: [
22291 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components43.Card, { className: "global-styles-ui-screen-root__active-style-tile", children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components43.CardMedia, { className: "global-styles-ui-screen-root__active-style-tile-preview", children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(preview_styles_default, {}) }) }),
22292 hasVariations && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components43.__experimentalItemGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(NavigationButtonAsItem, { path: "/variations", children: /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components43.__experimentalHStack, { justify: "space-between", children: [
22293 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components43.FlexItem, { children: (0, import_i18n78.__)("Browse styles") }),
22294 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
22295 IconWithCurrentColor,
22296 {
22297 icon: (0, import_i18n78.isRTL)() ? chevron_left_default : chevron_right_default
22298 }
22299 )
22300 ] }) }) }),
22301 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(root_menu_default, {})
22302 ] }) }),
22303 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components43.CardDivider, {}),
22304 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components43.CardBody, { children: [
22305 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
22306 import_components43.__experimentalSpacer,
22307 {
22308 as: "p",
22309 paddingTop: 2,
22310 paddingX: "13px",
22311 marginBottom: 4,
22312 children: (0, import_i18n78.__)(
22313 "Customize the appearance of specific blocks for the whole site."
22314 )
22315 }
22316 ),
22317 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components43.__experimentalItemGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(NavigationButtonAsItem, { path: "/blocks", children: /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)(import_components43.__experimentalHStack, { justify: "space-between", children: [
22318 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(import_components43.FlexItem, { children: (0, import_i18n78.__)("Blocks") }),
22319 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
22320 IconWithCurrentColor,
22321 {
22322 icon: (0, import_i18n78.isRTL)() ? chevron_left_default : chevron_right_default
22323 }
22324 )
22325 ] }) }) })
22326 ] })
22327 ]
22328 }
22329 );
22330 }
22331 var screen_root_default = ScreenRoot;
22332
22333 // packages/global-styles-ui/build-module/screen-block-list.mjs
22334 var import_blocks16 = __toESM(require_blocks(), 1);
22335 var import_i18n80 = __toESM(require_i18n(), 1);
22336 var import_components46 = __toESM(require_components(), 1);
22337 var import_data59 = __toESM(require_data(), 1);
22338 var import_element53 = __toESM(require_element(), 1);
22339 var import_block_editor20 = __toESM(require_block_editor(), 1);
22340 var import_compose10 = __toESM(require_compose(), 1);
22341 var import_a11y3 = __toESM(require_a11y(), 1);
22342
22343 // packages/global-styles-ui/build-module/variations/variations-panel.mjs
22344 var import_blocks15 = __toESM(require_blocks(), 1);
22345 var import_data58 = __toESM(require_data(), 1);
22346 var import_components44 = __toESM(require_components(), 1);
22347 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
22348 function getFilteredBlockStyles(blockStyles, variations) {
22349 return blockStyles?.filter(
22350 (style) => style.source === "block" || variations.includes(style.name)
22351 ) || [];
22352 }
22353 function useBlockVariations(name2) {
22354 const blockStyles = (0, import_data58.useSelect)(
22355 (select6) => {
22356 const { getBlockStyles } = select6(import_blocks15.store);
22357 return getBlockStyles(name2);
22358 },
22359 [name2]
22360 );
22361 const [variations] = useStyle("variations", name2);
22362 const variationNames = Object.keys(variations ?? {});
22363 return getFilteredBlockStyles(blockStyles, variationNames);
22364 }
22365 function VariationsPanel({ name: name2 }) {
22366 const coreBlockStyles = useBlockVariations(name2);
22367 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_components44.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: coreBlockStyles.map((style, index2) => {
22368 if (style?.isDefault) {
22369 return null;
22370 }
22371 return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
22372 NavigationButtonAsItem,
22373 {
22374 path: "/blocks/" + encodeURIComponent(name2) + "/variations/" + encodeURIComponent(style.name),
22375 children: style.label
22376 },
22377 index2
22378 );
22379 }) });
22380 }
22381
22382 // packages/global-styles-ui/build-module/screen-header.mjs
22383 var import_components45 = __toESM(require_components(), 1);
22384 var import_i18n79 = __toESM(require_i18n(), 1);
22385 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
22386 function ScreenHeader({
22387 title,
22388 description,
22389 onBack
22390 }) {
22391 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components45.__experimentalVStack, { spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components45.__experimentalView, { children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components45.__experimentalSpacer, { marginBottom: 0, paddingX: 4, paddingY: 3, children: /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(import_components45.__experimentalVStack, { spacing: 2, children: [
22392 /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(import_components45.__experimentalHStack, { spacing: 2, children: [
22393 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
22394 import_components45.Navigator.BackButton,
22395 {
22396 icon: (0, import_i18n79.isRTL)() ? chevron_right_default : chevron_left_default,
22397 size: "small",
22398 label: (0, import_i18n79.__)("Back"),
22399 onClick: onBack
22400 }
22401 ),
22402 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components45.__experimentalSpacer, { children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
22403 import_components45.__experimentalHeading,
22404 {
22405 className: "global-styles-ui-header",
22406 level: 2,
22407 size: 13,
22408 children: title
22409 }
22410 ) })
22411 ] }),
22412 description && /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(import_components45.__experimentalText, { className: "global-styles-ui-header__description", children: description })
22413 ] }) }) }) });
22414 }
22415
22416 // packages/global-styles-ui/build-module/screen-block-list.mjs
22417 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
22418 var {
22419 useHasDimensionsPanel: useHasDimensionsPanel2,
22420 useHasTypographyPanel: useHasTypographyPanel2,
22421 useHasBorderPanel,
22422 useSettingsForBlockElement: useSettingsForBlockElement2,
22423 useHasColorPanel: useHasColorPanel2
22424 } = unlock3(import_block_editor20.privateApis);
22425 function useSortedBlockTypes() {
22426 const blockItems = (0, import_data59.useSelect)(
22427 (select6) => select6(import_blocks16.store).getBlockTypes(),
22428 []
22429 );
22430 const groupByType = (blocks, block) => {
22431 const { core, noncore } = blocks;
22432 const type = block.name.startsWith("core/") ? core : noncore;
22433 type.push(block);
22434 return blocks;
22435 };
22436 const { core: coreItems, noncore: nonCoreItems } = blockItems.reduce(
22437 groupByType,
22438 { core: [], noncore: [] }
22439 );
22440 return [...coreItems, ...nonCoreItems];
22441 }
22442 function useBlockHasGlobalStyles(blockName) {
22443 const [rawSettings] = useSetting("", blockName);
22444 const settings = useSettingsForBlockElement2(rawSettings, blockName);
22445 const hasTypographyPanel = useHasTypographyPanel2(settings);
22446 const hasColorPanel = useHasColorPanel2(settings);
22447 const hasBorderPanel = useHasBorderPanel(settings);
22448 const hasDimensionsPanel = useHasDimensionsPanel2(settings);
22449 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
22450 const hasVariationsPanel = !!useBlockVariations(blockName)?.length;
22451 const hasGlobalStyles = hasTypographyPanel || hasColorPanel || hasLayoutPanel || hasVariationsPanel;
22452 return hasGlobalStyles;
22453 }
22454 function BlockMenuItem({ block }) {
22455 const hasBlockMenuItem = useBlockHasGlobalStyles(block.name);
22456 if (!hasBlockMenuItem) {
22457 return null;
22458 }
22459 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
22460 NavigationButtonAsItem,
22461 {
22462 path: "/blocks/" + encodeURIComponent(block.name),
22463 children: /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(import_components46.__experimentalHStack, { justify: "flex-start", children: [
22464 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_block_editor20.BlockIcon, { icon: block.icon }),
22465 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components46.FlexItem, { children: block.title })
22466 ] })
22467 }
22468 );
22469 }
22470 function BlockList({ filterValue }) {
22471 const sortedBlockTypes = useSortedBlockTypes();
22472 const debouncedSpeak = (0, import_compose10.useDebounce)(import_a11y3.speak, 500);
22473 const { isMatchingSearchTerm } = (0, import_data59.useSelect)(import_blocks16.store);
22474 const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter(
22475 (blockType) => isMatchingSearchTerm(blockType, filterValue)
22476 );
22477 const blockTypesListRef = (0, import_element53.useRef)(null);
22478 (0, import_element53.useEffect)(() => {
22479 if (!filterValue) {
22480 return;
22481 }
22482 const count = blockTypesListRef.current?.childElementCount || 0;
22483 const resultsFoundMessage = (0, import_i18n80.sprintf)(
22484 /* translators: %d: number of results. */
22485 (0, import_i18n80._n)("%d result found.", "%d results found.", count),
22486 count
22487 );
22488 debouncedSpeak(resultsFoundMessage, "polite");
22489 }, [filterValue, debouncedSpeak]);
22490 return /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
22491 "div",
22492 {
22493 ref: blockTypesListRef,
22494 className: "global-styles-ui-block-types-item-list",
22495 role: "list",
22496 children: filteredBlockTypes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(import_components46.__experimentalText, { align: "center", as: "p", children: (0, import_i18n80.__)("No blocks found.") }) : filteredBlockTypes.map((block) => /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
22497 BlockMenuItem,
22498 {
22499 block
22500 },
22501 "menu-itemblock-" + block.name
22502 ))
22503 }
22504 );
22505 }
22506 var MemoizedBlockList = (0, import_element53.memo)(BlockList);
22507 function ScreenBlockList() {
22508 const [filterValue, setFilterValue] = (0, import_element53.useState)("");
22509 const deferredFilterValue = (0, import_element53.useDeferredValue)(filterValue);
22510 return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(import_jsx_runtime142.Fragment, { children: [
22511 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
22512 ScreenHeader,
22513 {
22514 title: (0, import_i18n80.__)("Blocks"),
22515 description: (0, import_i18n80.__)(
22516 "Customize the appearance of specific blocks and for the whole site."
22517 )
22518 }
22519 ),
22520 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
22521 import_components46.SearchControl,
22522 {
22523 className: "global-styles-ui-block-types-search",
22524 onChange: setFilterValue,
22525 value: filterValue,
22526 label: (0, import_i18n80.__)("Search"),
22527 placeholder: (0, import_i18n80.__)("Search")
22528 }
22529 ),
22530 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(MemoizedBlockList, { filterValue: deferredFilterValue })
22531 ] });
22532 }
22533 var screen_block_list_default = ScreenBlockList;
22534
22535 // packages/global-styles-ui/build-module/screen-block.mjs
22536 var import_blocks18 = __toESM(require_blocks(), 1);
22537 var import_block_editor22 = __toESM(require_block_editor(), 1);
22538 var import_element55 = __toESM(require_element(), 1);
22539 var import_data60 = __toESM(require_data(), 1);
22540 var import_core_data40 = __toESM(require_core_data(), 1);
22541 var import_components49 = __toESM(require_components(), 1);
22542 var import_i18n81 = __toESM(require_i18n(), 1);
22543
22544 // packages/global-styles-ui/build-module/block-preview-panel.mjs
22545 var import_block_editor21 = __toESM(require_block_editor(), 1);
22546 var import_blocks17 = __toESM(require_blocks(), 1);
22547 var import_components47 = __toESM(require_components(), 1);
22548 var import_element54 = __toESM(require_element(), 1);
22549 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
22550 var BlockPreviewPanel = ({
22551 name: name2,
22552 variation = ""
22553 }) => {
22554 const blockExample = (0, import_blocks17.getBlockType)(name2)?.example;
22555 const blocks = (0, import_element54.useMemo)(() => {
22556 if (!blockExample) {
22557 return null;
22558 }
22559 const example = {
22560 ...blockExample,
22561 attributes: {
22562 ...blockExample.attributes,
22563 style: void 0,
22564 className: variation ? getVariationClassName(variation) : blockExample.attributes?.className
22565 }
22566 };
22567 return (0, import_blocks17.getBlockFromExample)(name2, example);
22568 }, [name2, blockExample, variation]);
22569 const viewportWidth = blockExample?.viewportWidth ?? 500;
22570 const previewHeight = 144;
22571 const sidebarWidth = 235;
22572 const scale = sidebarWidth / viewportWidth;
22573 const minHeight = scale !== 0 && scale < 1 && previewHeight ? previewHeight / scale : previewHeight;
22574 if (!blockExample) {
22575 return null;
22576 }
22577 return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_components47.__experimentalSpacer, { marginX: 4, marginBottom: 4, children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
22578 "div",
22579 {
22580 className: "global-styles-ui__block-preview-panel",
22581 style: { maxHeight: previewHeight, boxSizing: "initial" },
22582 children: /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(
22583 import_block_editor21.BlockPreview,
22584 {
22585 blocks,
22586 viewportWidth,
22587 minHeight: previewHeight,
22588 additionalStyles: (
22589 //We want this CSS to be in sync with the one in InserterPreviewPanel.
22590 [
22591 {
22592 css: `
22593 body{
22594 padding: 24px;
22595 min-height:${Math.round(minHeight)}px;
22596 display:flex;
22597 align-items:center;
22598 }
22599 .is-root-container { width: 100%; }
22600 `
22601 }
22602 ]
22603 )
22604 }
22605 )
22606 }
22607 ) });
22608 };
22609 var block_preview_panel_default = BlockPreviewPanel;
22610
22611 // packages/global-styles-ui/build-module/subtitle.mjs
22612 var import_components48 = __toESM(require_components(), 1);
22613 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
22614 function Subtitle({ children, level = 2 }) {
22615 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_components48.__experimentalHeading, { className: "global-styles-ui-subtitle", level, children });
22616 }
22617
22618 // packages/global-styles-ui/build-module/screen-block.mjs
22619 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1);
22620 var BACKGROUND_BLOCK_DEFAULT_VALUES2 = {
22621 backgroundSize: "cover",
22622 backgroundPosition: "50% 50%"
22623 // used only when backgroundSize is 'contain'.
22624 };
22625 function applyFallbackStyle(border) {
22626 if (!border) {
22627 return border;
22628 }
22629 const hasColorOrWidth = border.color || border.width;
22630 if (!border.style && hasColorOrWidth) {
22631 return { ...border, style: "solid" };
22632 }
22633 if (border.style && !hasColorOrWidth) {
22634 return void 0;
22635 }
22636 return border;
22637 }
22638 function applyAllFallbackStyles(border) {
22639 if (!border) {
22640 return border;
22641 }
22642 if ((0, import_components49.__experimentalHasSplitBorders)(border)) {
22643 return {
22644 top: applyFallbackStyle(border.top),
22645 right: applyFallbackStyle(border.right),
22646 bottom: applyFallbackStyle(border.bottom),
22647 left: applyFallbackStyle(border.left)
22648 };
22649 }
22650 return applyFallbackStyle(border);
22651 }
22652 var {
22653 useHasDimensionsPanel: useHasDimensionsPanel3,
22654 useHasTypographyPanel: useHasTypographyPanel3,
22655 useHasBorderPanel: useHasBorderPanel2,
22656 useSettingsForBlockElement: useSettingsForBlockElement3,
22657 useHasColorPanel: useHasColorPanel3,
22658 useHasFiltersPanel,
22659 useHasImageSettingsPanel,
22660 useHasBackgroundPanel: useHasBackgroundPanel2,
22661 BackgroundPanel: StylesBackgroundPanel,
22662 BorderPanel: StylesBorderPanel,
22663 ColorPanel: StylesColorPanel,
22664 TypographyPanel: StylesTypographyPanel,
22665 DimensionsPanel: StylesDimensionsPanel,
22666 FiltersPanel: StylesFiltersPanel,
22667 ImageSettingsPanel,
22668 AdvancedPanel: StylesAdvancedPanel
22669 } = unlock3(import_block_editor22.privateApis);
22670 function ScreenBlock({ name: name2, variation }) {
22671 const { user: userConfig, onChange: onChangeGlobalStyles } = (0, import_element55.useContext)(GlobalStylesContext);
22672 let prefixParts = [];
22673 if (variation) {
22674 prefixParts = ["variations", variation].concat(prefixParts);
22675 }
22676 const prefix2 = prefixParts.join(".");
22677 const [style] = useStyle(prefix2, name2, "user", false);
22678 const [inheritedStyle, setStyle2] = useStyle(
22679 prefix2,
22680 name2,
22681 "merged",
22682 false
22683 );
22684 const [userSettings] = useSetting("", name2, "user");
22685 const [rawSettings, setSettings] = useSetting("", name2);
22686 const settingsForBlockElement = useSettingsForBlockElement3(
22687 rawSettings,
22688 name2
22689 );
22690 const blockType = (0, import_blocks18.getBlockType)(name2);
22691 let disableBlockGap = false;
22692 if (settingsForBlockElement?.spacing?.blockGap && blockType?.supports?.spacing?.blockGap && (blockType?.supports?.spacing?.__experimentalSkipSerialization === true || blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(
22693 (spacingType) => spacingType === "blockGap"
22694 ))) {
22695 disableBlockGap = true;
22696 }
22697 let disableAspectRatio = false;
22698 if (settingsForBlockElement?.dimensions?.aspectRatio && name2 === "core/group") {
22699 disableAspectRatio = true;
22700 }
22701 const settings = (0, import_element55.useMemo)(() => {
22702 const updatedSettings = structuredClone(settingsForBlockElement);
22703 if (disableBlockGap) {
22704 updatedSettings.spacing.blockGap = false;
22705 }
22706 if (disableAspectRatio) {
22707 updatedSettings.dimensions.aspectRatio = false;
22708 }
22709 return updatedSettings;
22710 }, [settingsForBlockElement, disableBlockGap, disableAspectRatio]);
22711 const blockVariations = useBlockVariations(name2);
22712 const hasBackgroundPanel = useHasBackgroundPanel2(settings);
22713 const hasTypographyPanel = useHasTypographyPanel3(settings);
22714 const hasColorPanel = useHasColorPanel3(settings);
22715 const hasBorderPanel = useHasBorderPanel2(settings);
22716 const hasDimensionsPanel = useHasDimensionsPanel3(settings);
22717 const hasFiltersPanel = useHasFiltersPanel(settings);
22718 const hasImageSettingsPanel = useHasImageSettingsPanel(
22719 name2,
22720 userSettings,
22721 settings
22722 );
22723 const hasVariationsPanel = !!blockVariations?.length && !variation;
22724 const { canEditCSS } = (0, import_data60.useSelect)((select6) => {
22725 const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select6(import_core_data40.store);
22726 const globalStylesId = __experimentalGetCurrentGlobalStylesId();
22727 const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0;
22728 return {
22729 canEditCSS: !!globalStyles?._links?.["wp:action-edit-css"]
22730 };
22731 }, []);
22732 const currentBlockStyle = variation ? blockVariations.find((s3) => s3.name === variation) : null;
22733 const inheritedStyleWithLayout = (0, import_element55.useMemo)(() => {
22734 return {
22735 ...inheritedStyle,
22736 layout: settings.layout
22737 };
22738 }, [inheritedStyle, settings.layout]);
22739 const styleWithLayout = (0, import_element55.useMemo)(() => {
22740 return {
22741 ...style,
22742 layout: userSettings.layout
22743 };
22744 }, [style, userSettings.layout]);
22745 const onChangeDimensions = (newStyle) => {
22746 const updatedStyle = { ...newStyle };
22747 delete updatedStyle.layout;
22748 setStyle2(updatedStyle);
22749 if (newStyle.layout !== userSettings.layout) {
22750 setSettings({
22751 ...userSettings,
22752 layout: newStyle.layout
22753 });
22754 }
22755 };
22756 const onChangeLightbox = (newSetting) => {
22757 if (newSetting === void 0) {
22758 setSettings({
22759 ...rawSettings,
22760 lightbox: void 0
22761 });
22762 } else {
22763 setSettings({
22764 ...rawSettings,
22765 lightbox: {
22766 ...rawSettings.lightbox,
22767 ...newSetting
22768 }
22769 });
22770 }
22771 };
22772 const onChangeTypography = (newStyle) => {
22773 const { settings: newSettings, ...styleWithoutSettings } = newStyle;
22774 if (newSettings?.typography) {
22775 let updatedConfig = setStyle(
22776 userConfig,
22777 prefix2,
22778 styleWithoutSettings,
22779 name2
22780 );
22781 updatedConfig = setSetting(
22782 updatedConfig,
22783 "typography",
22784 {
22785 ...userSettings.typography,
22786 ...newSettings.typography
22787 },
22788 name2
22789 );
22790 onChangeGlobalStyles(updatedConfig);
22791 } else {
22792 setStyle2(styleWithoutSettings);
22793 }
22794 };
22795 const onChangeBorders = (newStyle) => {
22796 if (!newStyle?.border) {
22797 setStyle2(newStyle);
22798 return;
22799 }
22800 const { radius, ...newBorder } = newStyle.border;
22801 const border = applyAllFallbackStyles(newBorder);
22802 const updatedBorder = !(0, import_components49.__experimentalHasSplitBorders)(border) ? {
22803 top: border,
22804 right: border,
22805 bottom: border,
22806 left: border
22807 } : {
22808 color: null,
22809 style: null,
22810 width: null,
22811 ...border
22812 };
22813 setStyle2({ ...newStyle, border: { ...updatedBorder, radius } });
22814 };
22815 return /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_jsx_runtime145.Fragment, { children: [
22816 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
22817 ScreenHeader,
22818 {
22819 title: variation ? currentBlockStyle?.label : blockType?.title
22820 }
22821 ),
22822 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(block_preview_panel_default, { name: name2, variation }),
22823 hasVariationsPanel && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("div", { className: "global-styles-ui-screen-variations", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_components49.__experimentalVStack, { spacing: 3, children: [
22824 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Subtitle, { children: (0, import_i18n81.__)("Style Variations") }),
22825 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(VariationsPanel, { name: name2 })
22826 ] }) }),
22827 hasColorPanel && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
22828 StylesColorPanel,
22829 {
22830 inheritedValue: inheritedStyle,
22831 value: style,
22832 onChange: setStyle2,
22833 settings
22834 }
22835 ),
22836 hasBackgroundPanel && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
22837 StylesBackgroundPanel,
22838 {
22839 inheritedValue: inheritedStyle,
22840 value: style,
22841 onChange: setStyle2,
22842 settings,
22843 defaultValues: BACKGROUND_BLOCK_DEFAULT_VALUES2
22844 }
22845 ),
22846 hasTypographyPanel && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
22847 StylesTypographyPanel,
22848 {
22849 inheritedValue: inheritedStyle,
22850 value: style,
22851 onChange: onChangeTypography,
22852 settings,
22853 isGlobalStyles: true
22854 }
22855 ),
22856 hasDimensionsPanel && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
22857 StylesDimensionsPanel,
22858 {
22859 inheritedValue: inheritedStyleWithLayout,
22860 value: styleWithLayout,
22861 onChange: onChangeDimensions,
22862 settings,
22863 includeLayoutControls: true
22864 }
22865 ),
22866 hasBorderPanel && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
22867 StylesBorderPanel,
22868 {
22869 inheritedValue: inheritedStyle,
22870 value: style,
22871 onChange: onChangeBorders,
22872 settings
22873 }
22874 ),
22875 hasFiltersPanel && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
22876 StylesFiltersPanel,
22877 {
22878 inheritedValue: inheritedStyleWithLayout,
22879 value: styleWithLayout,
22880 onChange: setStyle2,
22881 settings,
22882 includeLayoutControls: true
22883 }
22884 ),
22885 hasImageSettingsPanel && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
22886 ImageSettingsPanel,
22887 {
22888 onChange: onChangeLightbox,
22889 value: userSettings,
22890 inheritedValue: settings
22891 }
22892 ),
22893 canEditCSS && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_components49.PanelBody, { title: (0, import_i18n81.__)("Advanced"), initialOpen: false, children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
22894 StylesAdvancedPanel,
22895 {
22896 value: style,
22897 onChange: setStyle2,
22898 inheritedValue: inheritedStyle,
22899 help: (0, import_i18n81.sprintf)(
22900 // translators: %s: is the name of a block e.g., 'Image' or 'Table'.
22901 (0, import_i18n81.__)(
22902 "Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value."
22903 ),
22904 blockType?.title
22905 )
22906 }
22907 ) })
22908 ] });
22909 }
22910 var screen_block_default = ScreenBlock;
22911
22912 // packages/global-styles-ui/build-module/screen-typography.mjs
22913 var import_i18n95 = __toESM(require_i18n(), 1);
22914 var import_components69 = __toESM(require_components(), 1);
22915 var import_element66 = __toESM(require_element(), 1);
22916
22917 // packages/global-styles-ui/build-module/screen-body.mjs
22918 var import_components50 = __toESM(require_components(), 1);
22919 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1);
22920 function ScreenBody({ children, className }) {
22921 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
22922 import_components50.__experimentalSpacer,
22923 {
22924 className: clsx_default("global-styles-ui-screen-body", className),
22925 padding: 4,
22926 children
22927 }
22928 );
22929 }
22930
22931 // packages/global-styles-ui/build-module/typography-elements.mjs
22932 var import_i18n82 = __toESM(require_i18n(), 1);
22933 var import_components51 = __toESM(require_components(), 1);
22934 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1);
22935 function ElementItem({ parentMenu, element, label }) {
22936 const prefix2 = element === "text" || !element ? "" : `elements.${element}.`;
22937 const extraStyles = element === "link" ? {
22938 textDecoration: "underline"
22939 } : {};
22940 const [fontFamily] = useStyle(
22941 prefix2 + "typography.fontFamily"
22942 );
22943 const [fontStyle] = useStyle(prefix2 + "typography.fontStyle");
22944 const [fontWeight] = useStyle(
22945 prefix2 + "typography.fontWeight"
22946 );
22947 const [backgroundColor] = useStyle(
22948 prefix2 + "color.background"
22949 );
22950 const [fallbackBackgroundColor] = useStyle("color.background");
22951 const [gradientValue] = useStyle(prefix2 + "color.gradient");
22952 const [color] = useStyle(prefix2 + "color.text");
22953 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(NavigationButtonAsItem, { path: parentMenu + "/typography/" + element, children: /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_components51.__experimentalHStack, { justify: "flex-start", children: [
22954 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
22955 import_components51.FlexItem,
22956 {
22957 className: "global-styles-ui-screen-typography__indicator",
22958 "aria-hidden": "true",
22959 style: {
22960 fontFamily: fontFamily ?? "serif",
22961 background: gradientValue ?? backgroundColor ?? fallbackBackgroundColor,
22962 color,
22963 fontStyle,
22964 fontWeight,
22965 ...extraStyles
22966 },
22967 children: (0, import_i18n82.__)("Aa")
22968 }
22969 ),
22970 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_components51.FlexItem, { children: label })
22971 ] }) });
22972 }
22973 function TypographyElements() {
22974 const parentMenu = "";
22975 return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_components51.__experimentalVStack, { spacing: 3, children: [
22976 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(Subtitle, { level: 3, children: (0, import_i18n82.__)("Elements") }),
22977 /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_components51.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: [
22978 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
22979 ElementItem,
22980 {
22981 parentMenu,
22982 element: "text",
22983 label: (0, import_i18n82.__)("Text")
22984 }
22985 ),
22986 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
22987 ElementItem,
22988 {
22989 parentMenu,
22990 element: "link",
22991 label: (0, import_i18n82.__)("Links")
22992 }
22993 ),
22994 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
22995 ElementItem,
22996 {
22997 parentMenu,
22998 element: "heading",
22999 label: (0, import_i18n82.__)("Headings")
23000 }
23001 ),
23002 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
23003 ElementItem,
23004 {
23005 parentMenu,
23006 element: "caption",
23007 label: (0, import_i18n82.__)("Captions")
23008 }
23009 ),
23010 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
23011 ElementItem,
23012 {
23013 parentMenu,
23014 element: "button",
23015 label: (0, import_i18n82.__)("Buttons")
23016 }
23017 )
23018 ] })
23019 ] });
23020 }
23021 var typography_elements_default = TypographyElements;
23022
23023 // packages/global-styles-ui/build-module/variations/variations-typography.mjs
23024 var import_components54 = __toESM(require_components(), 1);
23025
23026 // packages/global-styles-ui/build-module/preview-typography.mjs
23027 var import_components52 = __toESM(require_components(), 1);
23028 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1);
23029 var StylesPreviewTypography = ({
23030 variation,
23031 isFocused,
23032 withHoverView
23033 }) => {
23034 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
23035 preview_wrapper_default,
23036 {
23037 label: variation.title,
23038 isFocused,
23039 withHoverView,
23040 children: ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
23041 import_components52.__experimentalHStack,
23042 {
23043 spacing: 10 * ratio,
23044 justify: "center",
23045 style: {
23046 height: "100%",
23047 overflow: "hidden"
23048 },
23049 children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
23050 PreviewTypography,
23051 {
23052 variation,
23053 fontSize: 85 * ratio
23054 }
23055 )
23056 },
23057 key
23058 )
23059 }
23060 );
23061 };
23062 var preview_typography_default = StylesPreviewTypography;
23063
23064 // packages/global-styles-ui/build-module/variations/variation.mjs
23065 var import_components53 = __toESM(require_components(), 1);
23066 var import_element56 = __toESM(require_element(), 1);
23067 var import_keycodes2 = __toESM(require_keycodes(), 1);
23068 var import_i18n83 = __toESM(require_i18n(), 1);
23069 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1);
23070 function Variation({
23071 variation,
23072 children,
23073 isPill = false,
23074 properties,
23075 showTooltip = false
23076 }) {
23077 const [isFocused, setIsFocused] = (0, import_element56.useState)(false);
23078 const {
23079 base,
23080 user,
23081 onChange: setUserConfig
23082 } = (0, import_element56.useContext)(GlobalStylesContext);
23083 const context = (0, import_element56.useMemo)(() => {
23084 let merged = mergeGlobalStyles(base, variation);
23085 if (properties) {
23086 merged = filterObjectByProperties(merged, properties);
23087 }
23088 return {
23089 user: variation,
23090 base,
23091 merged,
23092 onChange: () => {
23093 }
23094 };
23095 }, [variation, base, properties]);
23096 const selectVariation = () => setUserConfig(variation);
23097 const selectOnEnter = (event) => {
23098 if (event.keyCode === import_keycodes2.ENTER) {
23099 event.preventDefault();
23100 selectVariation();
23101 }
23102 };
23103 const isActive = (0, import_element56.useMemo)(
23104 () => areGlobalStylesEqual(user, variation),
23105 [user, variation]
23106 );
23107 let label = variation?.title;
23108 if (variation?.description) {
23109 label = (0, import_i18n83.sprintf)(
23110 /* translators: 1: variation title. 2: variation description. */
23111 (0, import_i18n83._x)("%1$s (%2$s)", "variation label"),
23112 variation?.title,
23113 variation?.description
23114 );
23115 }
23116 const content = /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
23117 "div",
23118 {
23119 className: clsx_default("global-styles-ui-variations_item", {
23120 "is-active": isActive
23121 }),
23122 role: "button",
23123 onClick: selectVariation,
23124 onKeyDown: selectOnEnter,
23125 tabIndex: 0,
23126 "aria-label": label,
23127 "aria-current": isActive,
23128 onFocus: () => setIsFocused(true),
23129 onBlur: () => setIsFocused(false),
23130 children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
23131 "div",
23132 {
23133 className: clsx_default("global-styles-ui-variations_item-preview", {
23134 "is-pill": isPill
23135 }),
23136 children: children(isFocused)
23137 }
23138 )
23139 }
23140 );
23141 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(GlobalStylesContext.Provider, { value: context, children: showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_components53.Tooltip, { text: variation?.title, children: content }) : content });
23142 }
23143
23144 // packages/global-styles-ui/build-module/variations/variations-typography.mjs
23145 var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1);
23146 var propertiesToFilter = ["typography"];
23147 function TypographyVariations({
23148 title,
23149 gap = 2
23150 }) {
23151 const typographyVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter);
23152 if (typographyVariations?.length <= 1) {
23153 return null;
23154 }
23155 return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(import_components54.__experimentalVStack, { spacing: 3, children: [
23156 title && /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Subtitle, { level: 3, children: title }),
23157 /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
23158 import_components54.__experimentalGrid,
23159 {
23160 columns: 3,
23161 gap,
23162 className: "global-styles-ui-style-variations-container",
23163 children: typographyVariations.map(
23164 (variation, index2) => {
23165 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
23166 Variation,
23167 {
23168 variation,
23169 properties: propertiesToFilter,
23170 showTooltip: true,
23171 children: () => /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
23172 preview_typography_default,
23173 {
23174 variation
23175 }
23176 )
23177 },
23178 index2
23179 );
23180 }
23181 )
23182 }
23183 )
23184 ] });
23185 }
23186
23187 // packages/global-styles-ui/build-module/font-families.mjs
23188 var import_i18n93 = __toESM(require_i18n(), 1);
23189 var import_components67 = __toESM(require_components(), 1);
23190 var import_element65 = __toESM(require_element(), 1);
23191
23192 // packages/global-styles-ui/build-module/font-library/context.mjs
23193 var import_element57 = __toESM(require_element(), 1);
23194 var import_data61 = __toESM(require_data(), 1);
23195 var import_core_data42 = __toESM(require_core_data(), 1);
23196 var import_i18n85 = __toESM(require_i18n(), 1);
23197
23198 // packages/global-styles-ui/build-module/font-library/api.mjs
23199 var import_api_fetch4 = __toESM(require_api_fetch(), 1);
23200 var import_core_data41 = __toESM(require_core_data(), 1);
23201 var FONT_FAMILIES_URL = "/wp/v2/font-families";
23202 function invalidateFontFamilyCache(registry) {
23203 const { receiveEntityRecords } = registry.dispatch(import_core_data41.store);
23204 receiveEntityRecords(
23205 "postType",
23206 "wp_font_family",
23207 [],
23208 void 0,
23209 true
23210 // invalidateCache
23211 );
23212 }
23213 async function fetchInstallFontFamily(data, registry) {
23214 const config2 = {
23215 path: FONT_FAMILIES_URL,
23216 method: "POST",
23217 body: data
23218 };
23219 const response = await (0, import_api_fetch4.default)(config2);
23220 invalidateFontFamilyCache(registry);
23221 return {
23222 id: response.id,
23223 ...response.font_family_settings,
23224 fontFace: []
23225 };
23226 }
23227 async function fetchInstallFontFace(fontFamilyId, data, registry) {
23228 const config2 = {
23229 path: `${FONT_FAMILIES_URL}/${fontFamilyId}/font-faces`,
23230 method: "POST",
23231 body: data
23232 };
23233 const response = await (0, import_api_fetch4.default)(config2);
23234 invalidateFontFamilyCache(registry);
23235 return {
23236 id: response.id,
23237 ...response.font_face_settings
23238 };
23239 }
23240
23241 // packages/global-styles-ui/build-module/font-library/utils/index.mjs
23242 var import_components55 = __toESM(require_components(), 1);
23243
23244 // packages/global-styles-ui/build-module/font-library/utils/constants.mjs
23245 var import_i18n84 = __toESM(require_i18n(), 1);
23246 var ALLOWED_FILE_EXTENSIONS = ["otf", "ttf", "woff", "woff2"];
23247 var FONT_WEIGHTS = {
23248 100: (0, import_i18n84._x)("Thin", "font weight"),
23249 200: (0, import_i18n84._x)("Extra-light", "font weight"),
23250 300: (0, import_i18n84._x)("Light", "font weight"),
23251 400: (0, import_i18n84._x)("Normal", "font weight"),
23252 500: (0, import_i18n84._x)("Medium", "font weight"),
23253 600: (0, import_i18n84._x)("Semi-bold", "font weight"),
23254 700: (0, import_i18n84._x)("Bold", "font weight"),
23255 800: (0, import_i18n84._x)("Extra-bold", "font weight"),
23256 900: (0, import_i18n84._x)("Black", "font weight")
23257 };
23258 var FONT_STYLES = {
23259 normal: (0, import_i18n84._x)("Normal", "font style"),
23260 italic: (0, import_i18n84._x)("Italic", "font style")
23261 };
23262
23263 // packages/global-styles-ui/build-module/font-library/utils/index.mjs
23264 var { File: File2 } = window;
23265 var { kebabCase: kebabCase2 } = unlock3(import_components55.privateApis);
23266 function setUIValuesNeeded(font2, extraValues = {}) {
23267 if (!font2.name && (font2.fontFamily || font2.slug)) {
23268 font2.name = font2.fontFamily || font2.slug;
23269 }
23270 return {
23271 ...font2,
23272 ...extraValues
23273 };
23274 }
23275 function isUrlEncoded(url) {
23276 if (typeof url !== "string") {
23277 return false;
23278 }
23279 return url !== decodeURIComponent(url);
23280 }
23281 function getFontFaceVariantName(face) {
23282 const weightName = FONT_WEIGHTS[face.fontWeight ?? ""] || face.fontWeight;
23283 const styleName = face.fontStyle === "normal" ? "" : FONT_STYLES[face.fontStyle ?? ""] || face.fontStyle;
23284 return `${weightName} ${styleName}`;
23285 }
23286 function mergeFontFaces(existing = [], incoming = []) {
23287 const map = /* @__PURE__ */ new Map();
23288 for (const face of existing) {
23289 map.set(`${face.fontWeight}${face.fontStyle}`, face);
23290 }
23291 for (const face of incoming) {
23292 map.set(`${face.fontWeight}${face.fontStyle}`, face);
23293 }
23294 return Array.from(map.values());
23295 }
23296 function mergeFontFamilies(existing = [], incoming = []) {
23297 const map = /* @__PURE__ */ new Map();
23298 for (const font2 of existing) {
23299 map.set(font2.slug, { ...font2 });
23300 }
23301 for (const font2 of incoming) {
23302 if (map.has(font2.slug)) {
23303 const { fontFace: incomingFontFaces, ...restIncoming } = font2;
23304 const existingFont = map.get(font2.slug);
23305 const mergedFontFaces = mergeFontFaces(
23306 existingFont.fontFace,
23307 incomingFontFaces
23308 );
23309 map.set(font2.slug, {
23310 ...restIncoming,
23311 fontFace: mergedFontFaces
23312 });
23313 } else {
23314 map.set(font2.slug, { ...font2 });
23315 }
23316 }
23317 return Array.from(map.values());
23318 }
23319 async function loadFontFaceInBrowser(fontFace, source, addTo = "all") {
23320 let dataSource;
23321 if (typeof source === "string") {
23322 dataSource = `url(${source})`;
23323 } else if (source instanceof File2) {
23324 dataSource = await source.arrayBuffer();
23325 } else {
23326 return;
23327 }
23328 const newFont = new window.FontFace(
23329 formatFontFaceName(fontFace.fontFamily),
23330 dataSource,
23331 {
23332 style: fontFace.fontStyle,
23333 weight: String(fontFace.fontWeight)
23334 }
23335 );
23336 const loadedFace = await newFont.load();
23337 if (addTo === "document" || addTo === "all") {
23338 document.fonts.add(loadedFace);
23339 }
23340 if (addTo === "iframe" || addTo === "all") {
23341 const iframe = document.querySelector(
23342 'iframe[name="editor-canvas"]'
23343 );
23344 if (iframe?.contentDocument) {
23345 iframe.contentDocument.fonts.add(loadedFace);
23346 }
23347 }
23348 }
23349 function unloadFontFaceInBrowser(fontFace, removeFrom = "all") {
23350 const unloadFontFace = (fonts) => {
23351 fonts.forEach((f3) => {
23352 if (f3.family === formatFontFaceName(fontFace?.fontFamily) && f3.weight === fontFace?.fontWeight && f3.style === fontFace?.fontStyle) {
23353 fonts.delete(f3);
23354 }
23355 });
23356 };
23357 if (removeFrom === "document" || removeFrom === "all") {
23358 unloadFontFace(document.fonts);
23359 }
23360 if (removeFrom === "iframe" || removeFrom === "all") {
23361 const iframe = document.querySelector(
23362 'iframe[name="editor-canvas"]'
23363 );
23364 if (iframe?.contentDocument) {
23365 unloadFontFace(iframe.contentDocument.fonts);
23366 }
23367 }
23368 }
23369 function getDisplaySrcFromFontFace(input) {
23370 if (!input) {
23371 return;
23372 }
23373 let src;
23374 if (Array.isArray(input)) {
23375 src = input[0];
23376 } else {
23377 src = input;
23378 }
23379 if (src.startsWith("file:.")) {
23380 return;
23381 }
23382 if (!isUrlEncoded(src)) {
23383 src = encodeURI(src);
23384 }
23385 return src;
23386 }
23387 function makeFontFamilyFormData(fontFamily) {
23388 const formData = new FormData();
23389 const { fontFace, category, ...familyWithValidParameters } = fontFamily;
23390 const fontFamilySettings = {
23391 ...familyWithValidParameters,
23392 slug: kebabCase2(fontFamily.slug)
23393 };
23394 formData.append(
23395 "font_family_settings",
23396 JSON.stringify(fontFamilySettings)
23397 );
23398 return formData;
23399 }
23400 function makeFontFacesFormData(font2) {
23401 const fontFacesFormData = (font2?.fontFace ?? []).map(
23402 (item, faceIndex) => {
23403 const face = { ...item };
23404 const formData = new FormData();
23405 if (face.file) {
23406 const files = Array.isArray(face.file) ? face.file : [face.file];
23407 const src = [];
23408 files.forEach((file, key) => {
23409 const fileId = `file-${faceIndex}-${key}`;
23410 formData.append(fileId, file, file.name);
23411 src.push(fileId);
23412 });
23413 face.src = src.length === 1 ? src[0] : src;
23414 delete face.file;
23415 formData.append("font_face_settings", JSON.stringify(face));
23416 } else {
23417 formData.append("font_face_settings", JSON.stringify(face));
23418 }
23419 return formData;
23420 }
23421 );
23422 return fontFacesFormData;
23423 }
23424 async function batchInstallFontFaces(fontFamilyId, fontFacesData, registry) {
23425 const responses = [];
23426 for (const faceData of fontFacesData) {
23427 try {
23428 const response = await fetchInstallFontFace(
23429 fontFamilyId,
23430 faceData,
23431 registry
23432 );
23433 responses.push({ status: "fulfilled", value: response });
23434 } catch (error) {
23435 responses.push({ status: "rejected", reason: error });
23436 }
23437 }
23438 const results = {
23439 errors: [],
23440 successes: []
23441 };
23442 responses.forEach((result, index2) => {
23443 if (result.status === "fulfilled" && result.value) {
23444 const response = result.value;
23445 results.successes.push(response);
23446 } else if (result.reason) {
23447 results.errors.push({
23448 data: fontFacesData[index2],
23449 message: result.reason.message
23450 });
23451 }
23452 });
23453 return results;
23454 }
23455 async function downloadFontFaceAssets(src) {
23456 src = Array.isArray(src) ? src : [src];
23457 const files = await Promise.all(
23458 src.map(async (url) => {
23459 return fetch(new Request(url)).then((response) => {
23460 if (!response.ok) {
23461 throw new Error(
23462 `Error downloading font face asset from ${url}. Server responded with status: ${response.status}`
23463 );
23464 }
23465 return response.blob();
23466 }).then((blob) => {
23467 const filename = url.split("/").pop();
23468 const file = new File2([blob], filename, {
23469 type: blob.type
23470 });
23471 return file;
23472 });
23473 })
23474 );
23475 return files.length === 1 ? files[0] : files;
23476 }
23477 function checkFontFaceInstalled(fontFace, collection) {
23478 return -1 !== collection.findIndex((collectionFontFace) => {
23479 return collectionFontFace.fontWeight === fontFace.fontWeight && collectionFontFace.fontStyle === fontFace.fontStyle;
23480 });
23481 }
23482
23483 // packages/global-styles-ui/build-module/font-library/utils/set-immutably.mjs
23484 function setImmutably2(object, path, value) {
23485 path = Array.isArray(path) ? [...path] : [path];
23486 object = Array.isArray(object) ? [...object] : { ...object };
23487 const leaf = path.pop();
23488 let prev = object;
23489 for (const key of path) {
23490 const lvl = prev[key];
23491 prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl };
23492 }
23493 prev[leaf] = value;
23494 return object;
23495 }
23496
23497 // packages/global-styles-ui/build-module/font-library/utils/toggleFont.mjs
23498 function toggleFont(font2, face, initialfonts = []) {
23499 const isFontActivated = (f3) => f3.slug === font2.slug;
23500 const getActivatedFont = (fonts) => fonts.find(isFontActivated);
23501 const toggleEntireFontFamily = (activatedFont2) => {
23502 if (!activatedFont2) {
23503 return [...initialfonts, font2];
23504 }
23505 return initialfonts.filter(
23506 (f3) => !isFontActivated(f3)
23507 );
23508 };
23509 const toggleFontVariant = (activatedFont2) => {
23510 const isFaceActivated = (f3) => f3.fontWeight === face.fontWeight && f3.fontStyle === face.fontStyle;
23511 if (!activatedFont2) {
23512 return [...initialfonts, { ...font2, fontFace: [face] }];
23513 }
23514 let newFontFaces = activatedFont2.fontFace || [];
23515 if (newFontFaces.find(isFaceActivated)) {
23516 newFontFaces = newFontFaces.filter(
23517 (f3) => !isFaceActivated(f3)
23518 );
23519 } else {
23520 newFontFaces = [...newFontFaces, face];
23521 }
23522 if (newFontFaces.length === 0) {
23523 return initialfonts.filter(
23524 (f3) => !isFontActivated(f3)
23525 );
23526 }
23527 return initialfonts.map(
23528 (f3) => isFontActivated(f3) ? { ...f3, fontFace: newFontFaces } : f3
23529 );
23530 };
23531 const activatedFont = getActivatedFont(initialfonts);
23532 if (!face) {
23533 return toggleEntireFontFamily(activatedFont);
23534 }
23535 return toggleFontVariant(activatedFont);
23536 }
23537
23538 // packages/global-styles-ui/build-module/font-library/context.mjs
23539 var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1);
23540 var FontLibraryContext = (0, import_element57.createContext)(
23541 {}
23542 );
23543 FontLibraryContext.displayName = "FontLibraryContext";
23544 function FontLibraryProvider({ children }) {
23545 const registry = (0, import_data61.useRegistry)();
23546 const { saveEntityRecord, deleteEntityRecord } = (0, import_data61.useDispatch)(import_core_data42.store);
23547 const { globalStylesId } = (0, import_data61.useSelect)((select6) => {
23548 const { __experimentalGetCurrentGlobalStylesId } = select6(import_core_data42.store);
23549 return { globalStylesId: __experimentalGetCurrentGlobalStylesId() };
23550 }, []);
23551 const globalStyles = (0, import_core_data42.useEntityRecord)(
23552 "root",
23553 "globalStyles",
23554 globalStylesId
23555 );
23556 const [isInstalling, setIsInstalling] = (0, import_element57.useState)(false);
23557 const { records: libraryPosts = [], isResolving: isResolvingLibrary } = (0, import_core_data42.useEntityRecords)(
23558 "postType",
23559 "wp_font_family",
23560 {
23561 _embed: true
23562 }
23563 );
23564 const libraryFonts = (libraryPosts || []).map((fontFamilyPost) => {
23565 return {
23566 id: fontFamilyPost.id,
23567 ...fontFamilyPost.font_family_settings || {},
23568 fontFace: fontFamilyPost?._embedded?.font_faces?.map(
23569 (face) => face.font_face_settings
23570 ) || []
23571 };
23572 }) || [];
23573 const [fontFamilies, setFontFamilies] = useSetting("typography.fontFamilies");
23574 const saveFontFamilies = async (fonts) => {
23575 if (!globalStyles.record) {
23576 return;
23577 }
23578 const updatedGlobalStyles = globalStyles.record;
23579 const finalGlobalStyles = setImmutably2(
23580 updatedGlobalStyles ?? {},
23581 ["settings", "typography", "fontFamilies"],
23582 fonts
23583 );
23584 await saveEntityRecord("root", "globalStyles", finalGlobalStyles);
23585 };
23586 const [modalTabOpen, setModalTabOpen] = (0, import_element57.useState)("");
23587 const [libraryFontSelected, setLibraryFontSelected] = (0, import_element57.useState)(void 0);
23588 const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map((f3) => setUIValuesNeeded(f3, { source: "theme" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : [];
23589 const customFonts = fontFamilies?.custom ? fontFamilies.custom.map((f3) => setUIValuesNeeded(f3, { source: "custom" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : [];
23590 const baseCustomFonts = libraryFonts ? libraryFonts.map((f3) => setUIValuesNeeded(f3, { source: "custom" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : [];
23591 (0, import_element57.useEffect)(() => {
23592 if (!modalTabOpen) {
23593 setLibraryFontSelected(void 0);
23594 }
23595 }, [modalTabOpen]);
23596 const handleSetLibraryFontSelected = (font2) => {
23597 if (!font2) {
23598 setLibraryFontSelected(void 0);
23599 return;
23600 }
23601 const fonts = font2.source === "theme" ? themeFonts : baseCustomFonts;
23602 const fontSelected = fonts.find((f3) => f3.slug === font2.slug);
23603 setLibraryFontSelected({
23604 ...fontSelected || font2,
23605 source: font2.source
23606 });
23607 };
23608 const [loadedFontUrls] = (0, import_element57.useState)(/* @__PURE__ */ new Set());
23609 const getAvailableFontsOutline = (availableFontFamilies) => {
23610 const outline = availableFontFamilies.reduce(
23611 (acc, font2) => {
23612 const availableFontFaces = font2?.fontFace && font2.fontFace?.length > 0 ? font2?.fontFace.map(
23613 (face) => `${face.fontStyle ?? ""}${face.fontWeight ?? ""}`
23614 ) : ["normal400"];
23615 acc[font2.slug] = availableFontFaces;
23616 return acc;
23617 },
23618 {}
23619 );
23620 return outline;
23621 };
23622 const getActivatedFontsOutline = (source) => {
23623 switch (source) {
23624 case "theme":
23625 return getAvailableFontsOutline(themeFonts);
23626 case "custom":
23627 default:
23628 return getAvailableFontsOutline(customFonts);
23629 }
23630 };
23631 const isFontActivated = (slug, style, weight, source) => {
23632 if (!style && !weight) {
23633 return !!getActivatedFontsOutline(source)[slug];
23634 }
23635 return !!getActivatedFontsOutline(source)[slug]?.includes(
23636 (style ?? "") + (weight ?? "")
23637 );
23638 };
23639 const getFontFacesActivated = (slug, source) => {
23640 return getActivatedFontsOutline(source)[slug] || [];
23641 };
23642 async function installFonts(fontFamiliesToInstall) {
23643 setIsInstalling(true);
23644 try {
23645 const fontFamiliesToActivate = [];
23646 let installationErrors = [];
23647 for (const fontFamilyToInstall of fontFamiliesToInstall) {
23648 let isANewFontFamily = false;
23649 const fontFamilyRecords = await (0, import_data61.resolveSelect)(
23650 import_core_data42.store
23651 ).getEntityRecords(
23652 "postType",
23653 "wp_font_family",
23654 {
23655 slug: fontFamilyToInstall.slug,
23656 per_page: 1,
23657 _embed: true
23658 }
23659 );
23660 const fontFamilyPost = fontFamilyRecords && fontFamilyRecords.length > 0 ? fontFamilyRecords[0] : null;
23661 let installedFontFamily = fontFamilyPost ? {
23662 id: fontFamilyPost.id,
23663 ...fontFamilyPost.font_family_settings,
23664 fontFace: (fontFamilyPost?._embedded?.font_faces ?? []).map(
23665 (face) => face.font_face_settings
23666 ) || []
23667 } : null;
23668 if (!installedFontFamily) {
23669 isANewFontFamily = true;
23670 installedFontFamily = await fetchInstallFontFamily(
23671 makeFontFamilyFormData(fontFamilyToInstall),
23672 registry
23673 );
23674 }
23675 const alreadyInstalledFontFaces = installedFontFamily.fontFace && fontFamilyToInstall.fontFace ? installedFontFamily.fontFace.filter(
23676 (fontFaceToInstall) => fontFaceToInstall && fontFamilyToInstall.fontFace && checkFontFaceInstalled(
23677 fontFaceToInstall,
23678 fontFamilyToInstall.fontFace
23679 )
23680 ) : [];
23681 if (installedFontFamily.fontFace && fontFamilyToInstall.fontFace) {
23682 fontFamilyToInstall.fontFace = fontFamilyToInstall.fontFace.filter(
23683 (fontFaceToInstall) => !checkFontFaceInstalled(
23684 fontFaceToInstall,
23685 installedFontFamily.fontFace
23686 )
23687 );
23688 }
23689 let successfullyInstalledFontFaces = [];
23690 let unsuccessfullyInstalledFontFaces = [];
23691 if (fontFamilyToInstall?.fontFace?.length ?? 0 > 0) {
23692 const response = await batchInstallFontFaces(
23693 // @ts-expect-error - Type mismatch: WpFontFamily.id can be number | string, but batchInstallFontFaces expects only string.
23694 installedFontFamily.id,
23695 makeFontFacesFormData(
23696 fontFamilyToInstall
23697 ),
23698 registry
23699 );
23700 successfullyInstalledFontFaces = response?.successes;
23701 unsuccessfullyInstalledFontFaces = response?.errors;
23702 }
23703 if (successfullyInstalledFontFaces?.length > 0 || alreadyInstalledFontFaces?.length > 0) {
23704 installedFontFamily.fontFace = [
23705 ...successfullyInstalledFontFaces
23706 ];
23707 fontFamiliesToActivate.push(installedFontFamily);
23708 }
23709 if (installedFontFamily && !fontFamilyToInstall?.fontFace?.length) {
23710 fontFamiliesToActivate.push(installedFontFamily);
23711 }
23712 if (isANewFontFamily && (fontFamilyToInstall?.fontFace?.length ?? 0) > 0 && successfullyInstalledFontFaces?.length === 0) {
23713 await deleteEntityRecord(
23714 "postType",
23715 "wp_font_family",
23716 installedFontFamily.id,
23717 { force: true }
23718 );
23719 }
23720 installationErrors = installationErrors.concat(
23721 unsuccessfullyInstalledFontFaces
23722 );
23723 }
23724 const installationErrorMessages = installationErrors.reduce(
23725 (unique, item) => unique.includes(item.message) ? unique : [...unique, item.message],
23726 []
23727 );
23728 if (fontFamiliesToActivate.length > 0) {
23729 const activeFonts = activateCustomFontFamilies(
23730 // @ts-expect-error - Type mismatch: items may have id as number | string, but FontFamily.id should be string | undefined.
23731 fontFamiliesToActivate
23732 );
23733 await saveFontFamilies(activeFonts);
23734 }
23735 if (installationErrorMessages.length > 0) {
23736 const installError = new Error((0, import_i18n85.__)("There was an error installing fonts."));
23737 installError.installationErrors = installationErrorMessages;
23738 throw installError;
23739 }
23740 } finally {
23741 setIsInstalling(false);
23742 }
23743 }
23744 async function uninstallFontFamily(fontFamilyToUninstall) {
23745 if (!fontFamilyToUninstall?.id) {
23746 throw new Error((0, import_i18n85.__)("Font family to uninstall is not defined."));
23747 }
23748 try {
23749 await deleteEntityRecord(
23750 "postType",
23751 "wp_font_family",
23752 fontFamilyToUninstall.id,
23753 { force: true }
23754 );
23755 const activeFonts = deactivateFontFamily(fontFamilyToUninstall);
23756 await saveFontFamilies(activeFonts);
23757 return { deleted: true };
23758 } catch (error) {
23759 console.error(
23760 `There was an error uninstalling the font family:`,
23761 error
23762 );
23763 throw error;
23764 }
23765 }
23766 const deactivateFontFamily = (font2) => {
23767 const initialCustomFonts = fontFamilies?.[font2.source ?? ""] ?? [];
23768 const newCustomFonts = initialCustomFonts.filter(
23769 (f3) => f3.slug !== font2.slug
23770 );
23771 const activeFonts = {
23772 ...fontFamilies,
23773 [font2.source ?? ""]: newCustomFonts
23774 };
23775 setFontFamilies(activeFonts);
23776 if (font2.fontFace) {
23777 font2.fontFace.forEach((face) => {
23778 unloadFontFaceInBrowser(face, "all");
23779 });
23780 }
23781 return activeFonts;
23782 };
23783 const activateCustomFontFamilies = (fontsToAdd) => {
23784 const fontsToActivate = cleanFontsForSave(fontsToAdd);
23785 const activeFonts = {
23786 ...fontFamilies,
23787 // Merge the existing custom fonts with the new fonts.
23788 custom: mergeFontFamilies(fontFamilies?.custom, fontsToActivate)
23789 };
23790 setFontFamilies(activeFonts);
23791 loadFontsInBrowser(fontsToActivate);
23792 return activeFonts;
23793 };
23794 const cleanFontsForSave = (fonts) => {
23795 return fonts.map(({ id: _familyDbId, fontFace, ...font2 }) => ({
23796 ...font2,
23797 ...fontFace && fontFace.length > 0 ? {
23798 fontFace: fontFace.map(
23799 ({ id: _faceDbId, ...face }) => face
23800 )
23801 } : {}
23802 }));
23803 };
23804 const loadFontsInBrowser = (fonts) => {
23805 fonts.forEach((font2) => {
23806 if (font2.fontFace) {
23807 font2.fontFace.forEach((face) => {
23808 const displaySrc = getDisplaySrcFromFontFace(
23809 face?.src ?? ""
23810 );
23811 if (displaySrc) {
23812 loadFontFaceInBrowser(face, displaySrc, "all");
23813 }
23814 });
23815 }
23816 });
23817 };
23818 const toggleActivateFont = (font2, face) => {
23819 const initialFonts = fontFamilies?.[font2.source ?? ""] ?? [];
23820 const newFonts = toggleFont(font2, face, initialFonts);
23821 setFontFamilies({
23822 ...fontFamilies,
23823 [font2.source ?? ""]: newFonts
23824 });
23825 const isFaceActivated = isFontActivated(
23826 font2.slug,
23827 face?.fontStyle ?? "",
23828 face?.fontWeight ?? "",
23829 font2.source ?? "custom"
23830 );
23831 if (face && isFaceActivated) {
23832 unloadFontFaceInBrowser(face, "all");
23833 } else {
23834 const displaySrc = getDisplaySrcFromFontFace(face?.src ?? "");
23835 if (face && displaySrc) {
23836 loadFontFaceInBrowser(face, displaySrc, "all");
23837 }
23838 }
23839 };
23840 const loadFontFaceAsset = async (fontFace) => {
23841 if (!fontFace.src) {
23842 return;
23843 }
23844 const src = getDisplaySrcFromFontFace(fontFace.src);
23845 if (!src || loadedFontUrls.has(src)) {
23846 return;
23847 }
23848 loadFontFaceInBrowser(fontFace, src, "document");
23849 loadedFontUrls.add(src);
23850 };
23851 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
23852 FontLibraryContext.Provider,
23853 {
23854 value: {
23855 libraryFontSelected,
23856 handleSetLibraryFontSelected,
23857 fontFamilies: fontFamilies ?? {},
23858 baseCustomFonts,
23859 isFontActivated,
23860 getFontFacesActivated,
23861 loadFontFaceAsset,
23862 installFonts,
23863 uninstallFontFamily,
23864 toggleActivateFont,
23865 getAvailableFontsOutline,
23866 modalTabOpen,
23867 setModalTabOpen,
23868 saveFontFamilies,
23869 isResolvingLibrary,
23870 isInstalling
23871 },
23872 children
23873 }
23874 );
23875 }
23876 var context_default = FontLibraryProvider;
23877
23878 // packages/global-styles-ui/build-module/font-library/modal.mjs
23879 var import_i18n91 = __toESM(require_i18n(), 1);
23880 var import_components65 = __toESM(require_components(), 1);
23881 var import_core_data45 = __toESM(require_core_data(), 1);
23882 var import_data63 = __toESM(require_data(), 1);
23883
23884 // packages/global-styles-ui/build-module/font-library/installed-fonts.mjs
23885 var import_components59 = __toESM(require_components(), 1);
23886 var import_core_data43 = __toESM(require_core_data(), 1);
23887 var import_data62 = __toESM(require_data(), 1);
23888 var import_element60 = __toESM(require_element(), 1);
23889 var import_i18n87 = __toESM(require_i18n(), 1);
23890
23891 // packages/global-styles-ui/build-module/font-library/font-card.mjs
23892 var import_i18n86 = __toESM(require_i18n(), 1);
23893 var import_components57 = __toESM(require_components(), 1);
23894
23895 // packages/global-styles-ui/build-module/font-library/font-demo.mjs
23896 var import_components56 = __toESM(require_components(), 1);
23897 var import_element58 = __toESM(require_element(), 1);
23898 var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1);
23899 function getPreviewUrl(fontFace) {
23900 if (fontFace.preview) {
23901 return fontFace.preview;
23902 }
23903 if (fontFace.src) {
23904 return Array.isArray(fontFace.src) ? fontFace.src[0] : fontFace.src;
23905 }
23906 return void 0;
23907 }
23908 function getDisplayFontFace(font2) {
23909 if ("fontStyle" in font2 && font2.fontStyle || "fontWeight" in font2 && font2.fontWeight) {
23910 return font2;
23911 }
23912 if ("fontFace" in font2 && font2.fontFace && font2.fontFace.length) {
23913 return font2.fontFace.find(
23914 (face) => face.fontStyle === "normal" && face.fontWeight === "400"
23915 ) || font2.fontFace[0];
23916 }
23917 return {
23918 fontStyle: "normal",
23919 fontWeight: "400",
23920 fontFamily: font2.fontFamily
23921 };
23922 }
23923 function FontDemo({ font: font2, text }) {
23924 const ref = (0, import_element58.useRef)(null);
23925 const fontFace = getDisplayFontFace(font2);
23926 const style = getFamilyPreviewStyle(font2);
23927 text = text || ("name" in font2 ? font2.name : "");
23928 const customPreviewUrl = font2.preview;
23929 const [isIntersecting, setIsIntersecting] = (0, import_element58.useState)(false);
23930 const [isAssetLoaded, setIsAssetLoaded] = (0, import_element58.useState)(false);
23931 const { loadFontFaceAsset } = (0, import_element58.useContext)(FontLibraryContext);
23932 const previewUrl = customPreviewUrl ?? getPreviewUrl(fontFace);
23933 const isPreviewImage = previewUrl && previewUrl.match(/\.(png|jpg|jpeg|gif|svg)$/i);
23934 const faceStyles = getFacePreviewStyle(fontFace);
23935 const textDemoStyle = {
23936 fontSize: "18px",
23937 lineHeight: 1,
23938 opacity: isAssetLoaded ? "1" : "0",
23939 ...style,
23940 ...faceStyles
23941 };
23942 (0, import_element58.useEffect)(() => {
23943 const observer = new window.IntersectionObserver(([entry]) => {
23944 setIsIntersecting(entry.isIntersecting);
23945 }, {});
23946 if (ref.current) {
23947 observer.observe(ref.current);
23948 }
23949 return () => observer.disconnect();
23950 }, [ref]);
23951 (0, import_element58.useEffect)(() => {
23952 const loadAsset = async () => {
23953 if (isIntersecting) {
23954 if (!isPreviewImage && fontFace.src) {
23955 await loadFontFaceAsset(fontFace);
23956 }
23957 setIsAssetLoaded(true);
23958 }
23959 };
23960 loadAsset();
23961 }, [fontFace, isIntersecting, loadFontFaceAsset, isPreviewImage]);
23962 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("div", { ref, children: isPreviewImage ? /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
23963 "img",
23964 {
23965 src: previewUrl,
23966 loading: "lazy",
23967 alt: text,
23968 className: "font-library__font-variant_demo-image"
23969 }
23970 ) : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
23971 import_components56.__experimentalText,
23972 {
23973 style: textDemoStyle,
23974 className: "font-library__font-variant_demo-text",
23975 children: text
23976 }
23977 ) });
23978 }
23979 var font_demo_default = FontDemo;
23980
23981 // packages/global-styles-ui/build-module/font-library/font-card.mjs
23982 var import_jsx_runtime153 = __toESM(require_jsx_runtime(), 1);
23983 function FontCard({
23984 font: font2,
23985 onClick,
23986 variantsText,
23987 navigatorPath
23988 }) {
23989 const variantsCount = font2.fontFace?.length || 1;
23990 const style = {
23991 cursor: !!onClick ? "pointer" : "default"
23992 };
23993 const navigator = (0, import_components57.useNavigator)();
23994 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
23995 import_components57.Button,
23996 {
23997 __next40pxDefaultSize: true,
23998 onClick: () => {
23999 onClick();
24000 if (navigatorPath) {
24001 navigator.goTo(navigatorPath);
24002 }
24003 },
24004 style,
24005 className: "font-library__font-card",
24006 children: /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(import_components57.Flex, { justify: "space-between", wrap: false, children: [
24007 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(font_demo_default, { font: font2 }),
24008 /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(import_components57.Flex, { justify: "flex-end", children: [
24009 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_components57.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_components57.__experimentalText, { className: "font-library__font-card__count", children: variantsText || (0, import_i18n86.sprintf)(
24010 /* translators: %d: Number of font variants. */
24011 (0, import_i18n86._n)(
24012 "%d variant",
24013 "%d variants",
24014 variantsCount
24015 ),
24016 variantsCount
24017 ) }) }),
24018 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_components57.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(icon_default, { icon: (0, import_i18n86.isRTL)() ? chevron_left_default : chevron_right_default }) })
24019 ] })
24020 ] })
24021 }
24022 );
24023 }
24024 var font_card_default = FontCard;
24025
24026 // packages/global-styles-ui/build-module/font-library/library-font-variant.mjs
24027 var import_element59 = __toESM(require_element(), 1);
24028 var import_components58 = __toESM(require_components(), 1);
24029 var import_jsx_runtime154 = __toESM(require_jsx_runtime(), 1);
24030 function LibraryFontVariant({
24031 face,
24032 font: font2
24033 }) {
24034 const { isFontActivated, toggleActivateFont } = (0, import_element59.useContext)(FontLibraryContext);
24035 const isInstalled = (font2?.fontFace?.length ?? 0) > 0 ? isFontActivated(
24036 font2.slug,
24037 face.fontStyle,
24038 face.fontWeight,
24039 font2.source
24040 ) : isFontActivated(font2.slug, void 0, void 0, font2.source);
24041 const handleToggleActivation = () => {
24042 if ((font2?.fontFace?.length ?? 0) > 0) {
24043 toggleActivateFont(font2, face);
24044 return;
24045 }
24046 toggleActivateFont(font2);
24047 };
24048 const displayName = font2.name + " " + getFontFaceVariantName(face);
24049 const checkboxId = (0, import_element59.useId)();
24050 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("div", { className: "font-library__font-card", children: /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_components58.Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [
24051 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
24052 import_components58.CheckboxControl,
24053 {
24054 checked: isInstalled,
24055 onChange: handleToggleActivation,
24056 id: checkboxId
24057 }
24058 ),
24059 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("label", { htmlFor: checkboxId, children: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
24060 font_demo_default,
24061 {
24062 font: face,
24063 text: displayName,
24064 onClick: handleToggleActivation
24065 }
24066 ) })
24067 ] }) });
24068 }
24069 var library_font_variant_default = LibraryFontVariant;
24070
24071 // packages/global-styles-ui/build-module/font-library/utils/sort-font-faces.mjs
24072 function getNumericFontWeight(value) {
24073 switch (value) {
24074 case "normal":
24075 return 400;
24076 case "bold":
24077 return 700;
24078 case "bolder":
24079 return 500;
24080 case "lighter":
24081 return 300;
24082 default:
24083 return parseInt(value, 10);
24084 }
24085 }
24086 function sortFontFaces(faces) {
24087 return faces.sort((a3, b3) => {
24088 if (a3.fontStyle === "normal" && b3.fontStyle !== "normal") {
24089 return -1;
24090 }
24091 if (b3.fontStyle === "normal" && a3.fontStyle !== "normal") {
24092 return 1;
24093 }
24094 if (a3.fontStyle === b3.fontStyle) {
24095 return getNumericFontWeight(a3.fontWeight?.toString() ?? "normal") - getNumericFontWeight(b3.fontWeight?.toString() ?? "normal");
24096 }
24097 if (!a3.fontStyle || !b3.fontStyle) {
24098 return !a3.fontStyle ? 1 : -1;
24099 }
24100 return a3.fontStyle.localeCompare(b3.fontStyle);
24101 });
24102 }
24103
24104 // packages/global-styles-ui/build-module/font-library/installed-fonts.mjs
24105 var import_jsx_runtime155 = __toESM(require_jsx_runtime(), 1);
24106 function InstalledFonts() {
24107 const {
24108 baseCustomFonts,
24109 libraryFontSelected,
24110 handleSetLibraryFontSelected,
24111 uninstallFontFamily,
24112 isResolvingLibrary,
24113 isInstalling,
24114 saveFontFamilies,
24115 getFontFacesActivated
24116 } = (0, import_element60.useContext)(FontLibraryContext);
24117 const [fontFamilies, setFontFamilies] = useSetting("typography.fontFamilies");
24118 const [isConfirmDeleteOpen, setIsConfirmDeleteOpen] = (0, import_element60.useState)(false);
24119 const [notice, setNotice] = (0, import_element60.useState)(null);
24120 const [baseFontFamilies] = useSetting("typography.fontFamilies", void 0, "base");
24121 const globalStylesId = (0, import_data62.useSelect)((select6) => {
24122 const { __experimentalGetCurrentGlobalStylesId } = select6(import_core_data43.store);
24123 return __experimentalGetCurrentGlobalStylesId();
24124 }, []);
24125 const globalStyles = (0, import_core_data43.useEntityRecord)(
24126 "root",
24127 "globalStyles",
24128 globalStylesId
24129 );
24130 const fontFamiliesHasChanges = !!globalStyles?.edits?.settings?.typography?.fontFamilies;
24131 const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map((f3) => setUIValuesNeeded(f3, { source: "theme" })).sort((a3, b3) => a3.name.localeCompare(b3.name)) : [];
24132 const themeFontsSlugs = new Set(themeFonts.map((f3) => f3.slug));
24133 const baseThemeFonts = baseFontFamilies?.theme ? themeFonts.concat(
24134 baseFontFamilies.theme.filter((f3) => !themeFontsSlugs.has(f3.slug)).map((f3) => setUIValuesNeeded(f3, { source: "theme" })).sort((a3, b3) => a3.name.localeCompare(b3.name))
24135 ) : [];
24136 const customFontFamilyId = libraryFontSelected?.source === "custom" && libraryFontSelected?.id;
24137 const canUserDelete = (0, import_data62.useSelect)(
24138 (select6) => {
24139 const { canUser } = select6(import_core_data43.store);
24140 return customFontFamilyId && canUser("delete", {
24141 kind: "postType",
24142 name: "wp_font_family",
24143 id: customFontFamilyId
24144 });
24145 },
24146 [customFontFamilyId]
24147 );
24148 const shouldDisplayDeleteButton = !!libraryFontSelected && libraryFontSelected?.source !== "theme" && canUserDelete;
24149 const handleUninstallClick = () => {
24150 setIsConfirmDeleteOpen(true);
24151 };
24152 const handleUpdate = async () => {
24153 setNotice(null);
24154 try {
24155 await saveFontFamilies(fontFamilies);
24156 setNotice({
24157 type: "success",
24158 message: (0, import_i18n87.__)("Font family updated successfully.")
24159 });
24160 } catch (error) {
24161 setNotice({
24162 type: "error",
24163 message: (0, import_i18n87.sprintf)(
24164 /* translators: %s: error message */
24165 (0, import_i18n87.__)("There was an error updating the font family. %s"),
24166 error.message
24167 )
24168 });
24169 }
24170 };
24171 const getFontFacesToDisplay = (font2) => {
24172 if (!font2) {
24173 return [];
24174 }
24175 if (!font2.fontFace || !font2.fontFace.length) {
24176 return [
24177 {
24178 fontFamily: font2.fontFamily,
24179 fontStyle: "normal",
24180 fontWeight: "400"
24181 }
24182 ];
24183 }
24184 return sortFontFaces(font2.fontFace);
24185 };
24186 const getFontCardVariantsText = (font2) => {
24187 const variantsInstalled = font2?.fontFace && (font2?.fontFace?.length ?? 0) > 0 ? font2.fontFace.length : 1;
24188 const variantsActive = getFontFacesActivated(
24189 font2.slug,
24190 font2.source
24191 ).length;
24192 return (0, import_i18n87.sprintf)(
24193 /* translators: 1: Active font variants, 2: Total font variants. */
24194 (0, import_i18n87.__)("%1$d/%2$d variants active"),
24195 variantsActive,
24196 variantsInstalled
24197 );
24198 };
24199 (0, import_element60.useEffect)(() => {
24200 handleSetLibraryFontSelected(libraryFontSelected);
24201 }, []);
24202 const activeFontsCount = libraryFontSelected ? getFontFacesActivated(
24203 libraryFontSelected.slug,
24204 libraryFontSelected.source
24205 ).length : 0;
24206 const selectedFontsCount = libraryFontSelected?.fontFace?.length ?? (libraryFontSelected?.fontFamily ? 1 : 0);
24207 const isIndeterminate = activeFontsCount > 0 && activeFontsCount !== selectedFontsCount;
24208 const isSelectAllChecked = activeFontsCount === selectedFontsCount;
24209 const toggleSelectAll = () => {
24210 if (!libraryFontSelected || !libraryFontSelected?.source) {
24211 return;
24212 }
24213 const initialFonts = fontFamilies?.[libraryFontSelected.source]?.filter(
24214 (f3) => f3.slug !== libraryFontSelected.slug
24215 ) ?? [];
24216 const newFonts = isSelectAllChecked ? initialFonts : [...initialFonts, libraryFontSelected];
24217 setFontFamilies({
24218 ...fontFamilies,
24219 [libraryFontSelected.source]: newFonts
24220 });
24221 if (libraryFontSelected.fontFace) {
24222 libraryFontSelected.fontFace.forEach((face) => {
24223 if (isSelectAllChecked) {
24224 unloadFontFaceInBrowser(face, "all");
24225 } else {
24226 const displaySrc = getDisplaySrcFromFontFace(
24227 face?.src ?? ""
24228 );
24229 if (displaySrc) {
24230 loadFontFaceInBrowser(face, displaySrc, "all");
24231 }
24232 }
24233 });
24234 }
24235 };
24236 const hasFonts = baseThemeFonts.length > 0 || baseCustomFonts.length > 0;
24237 return /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
24238 isResolvingLibrary && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)("div", { className: "font-library__loading", children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components59.ProgressBar, {}) }),
24239 !isResolvingLibrary && /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_jsx_runtime155.Fragment, { children: [
24240 /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(
24241 import_components59.Navigator,
24242 {
24243 initialPath: libraryFontSelected ? "/fontFamily" : "/",
24244 children: [
24245 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components59.Navigator.Screen, { path: "/", children: /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_components59.__experimentalVStack, { spacing: "8", children: [
24246 notice && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24247 import_components59.Notice,
24248 {
24249 status: notice.type,
24250 onRemove: () => setNotice(null),
24251 children: notice.message
24252 }
24253 ),
24254 !hasFonts && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components59.__experimentalText, { as: "p", children: (0, import_i18n87.__)("No fonts installed.") }),
24255 baseThemeFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_components59.__experimentalVStack, { children: [
24256 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)("h2", {
24257 className: "font-library__fonts-title",
24258 /* translators: Heading for a list of fonts provided by the theme. */
24259 children: (0, import_i18n87._x)("Theme", "font source")
24260 }),
24261 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24262 "ul",
24263 {
24264 role: "list",
24265 className: "font-library__fonts-list",
24266 children: baseThemeFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24267 "li",
24268 {
24269 className: "font-library__fonts-list-item",
24270 children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24271 font_card_default,
24272 {
24273 font: font2,
24274 navigatorPath: "/fontFamily",
24275 variantsText: getFontCardVariantsText(
24276 font2
24277 ),
24278 onClick: () => {
24279 setNotice(null);
24280 handleSetLibraryFontSelected(
24281 font2
24282 );
24283 }
24284 }
24285 )
24286 },
24287 font2.slug
24288 ))
24289 }
24290 )
24291 ] }),
24292 baseCustomFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_components59.__experimentalVStack, { children: [
24293 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)("h2", {
24294 className: "font-library__fonts-title",
24295 /* translators: Heading for a list of fonts installed by the user. */
24296 children: (0, import_i18n87._x)("Custom", "font source")
24297 }),
24298 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24299 "ul",
24300 {
24301 role: "list",
24302 className: "font-library__fonts-list",
24303 children: baseCustomFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24304 "li",
24305 {
24306 className: "font-library__fonts-list-item",
24307 children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24308 font_card_default,
24309 {
24310 font: font2,
24311 navigatorPath: "/fontFamily",
24312 variantsText: getFontCardVariantsText(
24313 font2
24314 ),
24315 onClick: () => {
24316 setNotice(null);
24317 handleSetLibraryFontSelected(
24318 font2
24319 );
24320 }
24321 }
24322 )
24323 },
24324 font2.slug
24325 ))
24326 }
24327 )
24328 ] })
24329 ] }) }),
24330 /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_components59.Navigator.Screen, { path: "/fontFamily", children: [
24331 libraryFontSelected && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24332 ConfirmDeleteDialog,
24333 {
24334 font: libraryFontSelected,
24335 isOpen: isConfirmDeleteOpen,
24336 setIsOpen: setIsConfirmDeleteOpen,
24337 setNotice,
24338 uninstallFontFamily,
24339 handleSetLibraryFontSelected
24340 }
24341 ),
24342 /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_components59.Flex, { justify: "flex-start", children: [
24343 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24344 import_components59.Navigator.BackButton,
24345 {
24346 icon: (0, import_i18n87.isRTL)() ? chevron_right_default : chevron_left_default,
24347 size: "small",
24348 onClick: () => {
24349 handleSetLibraryFontSelected(
24350 void 0
24351 );
24352 setNotice(null);
24353 },
24354 label: (0, import_i18n87.__)("Back")
24355 }
24356 ),
24357 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24358 import_components59.__experimentalHeading,
24359 {
24360 level: 2,
24361 size: 13,
24362 className: "global-styles-ui-header",
24363 children: libraryFontSelected?.name
24364 }
24365 )
24366 ] }),
24367 notice && /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_jsx_runtime155.Fragment, { children: [
24368 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components59.__experimentalSpacer, { margin: 1 }),
24369 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24370 import_components59.Notice,
24371 {
24372 status: notice.type,
24373 onRemove: () => setNotice(null),
24374 children: notice.message
24375 }
24376 ),
24377 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components59.__experimentalSpacer, { margin: 1 })
24378 ] }),
24379 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components59.__experimentalSpacer, { margin: 4 }),
24380 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components59.__experimentalText, { children: (0, import_i18n87.__)(
24381 "Choose font variants. Keep in mind that too many variants could make your site slower."
24382 ) }),
24383 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components59.__experimentalSpacer, { margin: 4 }),
24384 /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_components59.__experimentalVStack, { spacing: 0, children: [
24385 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24386 import_components59.CheckboxControl,
24387 {
24388 className: "font-library__select-all",
24389 label: (0, import_i18n87.__)("Select all"),
24390 checked: isSelectAllChecked,
24391 onChange: toggleSelectAll,
24392 indeterminate: isIndeterminate
24393 }
24394 ),
24395 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components59.__experimentalSpacer, { margin: 8 }),
24396 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24397 "ul",
24398 {
24399 role: "list",
24400 className: "font-library__fonts-list",
24401 children: libraryFontSelected && getFontFacesToDisplay(
24402 libraryFontSelected
24403 ).map((face, i3) => /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24404 "li",
24405 {
24406 className: "font-library__fonts-list-item",
24407 children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24408 library_font_variant_default,
24409 {
24410 font: libraryFontSelected,
24411 face
24412 },
24413 `face${i3}`
24414 )
24415 },
24416 `face${i3}`
24417 ))
24418 }
24419 )
24420 ] })
24421 ] })
24422 ]
24423 }
24424 ),
24425 /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_components59.__experimentalHStack, { justify: "flex-end", className: "font-library__footer", children: [
24426 isInstalling && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components59.ProgressBar, {}),
24427 shouldDisplayDeleteButton && /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24428 import_components59.Button,
24429 {
24430 __next40pxDefaultSize: true,
24431 isDestructive: true,
24432 variant: "tertiary",
24433 onClick: handleUninstallClick,
24434 children: (0, import_i18n87.__)("Delete")
24435 }
24436 ),
24437 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24438 import_components59.Button,
24439 {
24440 __next40pxDefaultSize: true,
24441 variant: "primary",
24442 onClick: handleUpdate,
24443 disabled: !fontFamiliesHasChanges,
24444 accessibleWhenDisabled: true,
24445 children: (0, import_i18n87.__)("Update")
24446 }
24447 )
24448 ] })
24449 ] })
24450 ] });
24451 }
24452 function ConfirmDeleteDialog({
24453 font: font2,
24454 isOpen,
24455 setIsOpen,
24456 setNotice,
24457 uninstallFontFamily,
24458 handleSetLibraryFontSelected
24459 }) {
24460 const navigator = (0, import_components59.useNavigator)();
24461 const handleConfirmUninstall = async () => {
24462 setNotice(null);
24463 setIsOpen(false);
24464 try {
24465 await uninstallFontFamily(font2);
24466 navigator.goBack();
24467 handleSetLibraryFontSelected(void 0);
24468 setNotice({
24469 type: "success",
24470 message: (0, import_i18n87.__)("Font family uninstalled successfully.")
24471 });
24472 } catch (error) {
24473 setNotice({
24474 type: "error",
24475 message: (0, import_i18n87.__)("There was an error uninstalling the font family.") + error.message
24476 });
24477 }
24478 };
24479 const handleCancelUninstall = () => {
24480 setIsOpen(false);
24481 };
24482 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
24483 import_components59.__experimentalConfirmDialog,
24484 {
24485 isOpen,
24486 cancelButtonText: (0, import_i18n87.__)("Cancel"),
24487 confirmButtonText: (0, import_i18n87.__)("Delete"),
24488 onCancel: handleCancelUninstall,
24489 onConfirm: handleConfirmUninstall,
24490 size: "medium",
24491 children: font2 && (0, import_i18n87.sprintf)(
24492 /* translators: %s: Name of the font. */
24493 (0, import_i18n87.__)(
24494 'Are you sure you want to delete "%s" font and all its variants and assets?'
24495 ),
24496 font2.name
24497 )
24498 }
24499 );
24500 }
24501 var installed_fonts_default = InstalledFonts;
24502
24503 // packages/global-styles-ui/build-module/font-library/font-collection.mjs
24504 var import_element62 = __toESM(require_element(), 1);
24505 var import_components62 = __toESM(require_components(), 1);
24506 var import_compose11 = __toESM(require_compose(), 1);
24507 var import_i18n89 = __toESM(require_i18n(), 1);
24508 var import_core_data44 = __toESM(require_core_data(), 1);
24509
24510 // packages/global-styles-ui/build-module/font-library/utils/filter-fonts.mjs
24511 function filterFonts(fonts, filters) {
24512 const { category, search } = filters;
24513 let filteredFonts = fonts || [];
24514 if (category && category !== "all") {
24515 filteredFonts = filteredFonts.filter(
24516 (font2) => font2.categories && font2.categories.indexOf(category) !== -1
24517 );
24518 }
24519 if (search) {
24520 filteredFonts = filteredFonts.filter(
24521 (font2) => font2.font_family_settings && font2.font_family_settings.name.toLowerCase().includes(search.toLowerCase())
24522 );
24523 }
24524 return filteredFonts;
24525 }
24526
24527 // packages/global-styles-ui/build-module/font-library/utils/fonts-outline.mjs
24528 function getFontsOutline(fonts) {
24529 return fonts.reduce(
24530 (acc, font2) => ({
24531 ...acc,
24532 [font2.slug]: (font2?.fontFace || []).reduce(
24533 (faces, face) => ({
24534 ...faces,
24535 [`${face.fontStyle}-${face.fontWeight}`]: true
24536 }),
24537 {}
24538 )
24539 }),
24540 {}
24541 );
24542 }
24543 function isFontFontFaceInOutline(slug, face, outline) {
24544 if (!face) {
24545 return !!outline[slug];
24546 }
24547 return !!outline[slug]?.[`${face.fontStyle}-${face.fontWeight}`];
24548 }
24549
24550 // packages/global-styles-ui/build-module/font-library/google-fonts-confirm-dialog.mjs
24551 var import_i18n88 = __toESM(require_i18n(), 1);
24552 var import_components60 = __toESM(require_components(), 1);
24553 var import_jsx_runtime156 = __toESM(require_jsx_runtime(), 1);
24554 function GoogleFontsConfirmDialog() {
24555 const handleConfirm = () => {
24556 window.localStorage.setItem(
24557 "wp-font-library-google-fonts-permission",
24558 "true"
24559 );
24560 window.dispatchEvent(new Event("storage"));
24561 };
24562 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { className: "font-library__google-fonts-confirm", children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components60.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(import_components60.CardBody, { children: [
24563 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components60.__experimentalHeading, { level: 2, children: (0, import_i18n88.__)("Connect to Google Fonts") }),
24564 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components60.__experimentalSpacer, { margin: 6 }),
24565 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components60.__experimentalText, { as: "p", children: (0, import_i18n88.__)(
24566 "To install fonts from Google you must give permission to connect directly to Google servers. The fonts you install will be downloaded from Google and stored on your site. Your site will then use these locally-hosted fonts."
24567 ) }),
24568 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components60.__experimentalSpacer, { margin: 3 }),
24569 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components60.__experimentalText, { as: "p", children: (0, import_i18n88.__)(
24570 "You can alternatively upload files directly on the Upload tab."
24571 ) }),
24572 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(import_components60.__experimentalSpacer, { margin: 6 }),
24573 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
24574 import_components60.Button,
24575 {
24576 __next40pxDefaultSize: true,
24577 variant: "primary",
24578 onClick: handleConfirm,
24579 children: (0, import_i18n88.__)("Allow access to Google Fonts")
24580 }
24581 )
24582 ] }) }) });
24583 }
24584 var google_fonts_confirm_dialog_default = GoogleFontsConfirmDialog;
24585
24586 // packages/global-styles-ui/build-module/font-library/collection-font-variant.mjs
24587 var import_element61 = __toESM(require_element(), 1);
24588 var import_components61 = __toESM(require_components(), 1);
24589 var import_jsx_runtime157 = __toESM(require_jsx_runtime(), 1);
24590 function CollectionFontVariant({
24591 face,
24592 font: font2,
24593 handleToggleVariant,
24594 selected
24595 }) {
24596 const handleToggleActivation = () => {
24597 if (font2?.fontFace) {
24598 handleToggleVariant(font2, face);
24599 return;
24600 }
24601 handleToggleVariant(font2);
24602 };
24603 const displayName = font2.name + " " + getFontFaceVariantName(face);
24604 const checkboxId = (0, import_element61.useId)();
24605 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("div", { className: "font-library__font-card", children: /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(import_components61.Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [
24606 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
24607 import_components61.CheckboxControl,
24608 {
24609 checked: selected,
24610 onChange: handleToggleActivation,
24611 id: checkboxId
24612 }
24613 ),
24614 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("label", { htmlFor: checkboxId, children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
24615 font_demo_default,
24616 {
24617 font: face,
24618 text: displayName,
24619 onClick: handleToggleActivation
24620 }
24621 ) })
24622 ] }) });
24623 }
24624 var collection_font_variant_default = CollectionFontVariant;
24625
24626 // packages/global-styles-ui/build-module/font-library/font-collection.mjs
24627 var import_jsx_runtime158 = __toESM(require_jsx_runtime(), 1);
24628 var DEFAULT_CATEGORY = {
24629 slug: "all",
24630 name: (0, import_i18n89._x)("All", "font categories")
24631 };
24632 var LOCAL_STORAGE_ITEM = "wp-font-library-google-fonts-permission";
24633 var MIN_WINDOW_HEIGHT = 500;
24634 function FontCollection({ slug }) {
24635 const requiresPermission = slug === "google-fonts";
24636 const getGoogleFontsPermissionFromStorage = () => {
24637 return window.localStorage.getItem(LOCAL_STORAGE_ITEM) === "true";
24638 };
24639 const [selectedFont, setSelectedFont] = (0, import_element62.useState)(
24640 null
24641 );
24642 const [notice, setNotice] = (0, import_element62.useState)(null);
24643 const [fontsToInstall, setFontsToInstall] = (0, import_element62.useState)(
24644 []
24645 );
24646 const [page, setPage] = (0, import_element62.useState)(1);
24647 const [filters, setFilters] = (0, import_element62.useState)({});
24648 const [renderConfirmDialog, setRenderConfirmDialog] = (0, import_element62.useState)(
24649 requiresPermission && !getGoogleFontsPermissionFromStorage()
24650 );
24651 const { installFonts, isInstalling } = (0, import_element62.useContext)(FontLibraryContext);
24652 const { record: selectedCollection, isResolving: isLoading } = (0, import_core_data44.useEntityRecord)("root", "fontCollection", slug);
24653 (0, import_element62.useEffect)(() => {
24654 const handleStorage = () => {
24655 setRenderConfirmDialog(
24656 requiresPermission && !getGoogleFontsPermissionFromStorage()
24657 );
24658 };
24659 handleStorage();
24660 window.addEventListener("storage", handleStorage);
24661 return () => window.removeEventListener("storage", handleStorage);
24662 }, [slug, requiresPermission]);
24663 const revokeAccess = () => {
24664 window.localStorage.setItem(LOCAL_STORAGE_ITEM, "false");
24665 window.dispatchEvent(new Event("storage"));
24666 };
24667 (0, import_element62.useEffect)(() => {
24668 setSelectedFont(null);
24669 }, [slug]);
24670 (0, import_element62.useEffect)(() => {
24671 setFontsToInstall([]);
24672 }, [selectedFont]);
24673 const collectionFonts = (0, import_element62.useMemo)(
24674 () => selectedCollection?.font_families ?? [],
24675 [selectedCollection]
24676 );
24677 const collectionCategories = selectedCollection?.categories ?? [];
24678 const categories = [DEFAULT_CATEGORY, ...collectionCategories];
24679 const fonts = (0, import_element62.useMemo)(
24680 () => filterFonts(collectionFonts, filters),
24681 [collectionFonts, filters]
24682 );
24683 const windowHeight = Math.max(window.innerHeight, MIN_WINDOW_HEIGHT);
24684 const pageSize = Math.floor((windowHeight - 417) / 61);
24685 const totalPages = Math.ceil(fonts.length / pageSize);
24686 const itemsStart = (page - 1) * pageSize;
24687 const itemsLimit = page * pageSize;
24688 const items = fonts.slice(itemsStart, itemsLimit);
24689 const handleCategoryFilter = (category) => {
24690 setFilters({ ...filters, category });
24691 setPage(1);
24692 };
24693 const handleUpdateSearchInput = (value) => {
24694 setFilters({ ...filters, search: value });
24695 setPage(1);
24696 };
24697 const debouncedUpdateSearchInput = (0, import_compose11.debounce)(handleUpdateSearchInput, 300);
24698 const handleToggleVariant = (font2, face) => {
24699 const newFontsToInstall = toggleFont(font2, face, fontsToInstall);
24700 setFontsToInstall(newFontsToInstall);
24701 };
24702 const fontToInstallOutline = getFontsOutline(fontsToInstall);
24703 const resetFontsToInstall = () => {
24704 setFontsToInstall([]);
24705 };
24706 const selectFontCount = fontsToInstall.length > 0 ? fontsToInstall[0]?.fontFace?.length ?? 0 : 0;
24707 const isIndeterminate = selectFontCount > 0 && selectFontCount !== selectedFont?.fontFace?.length;
24708 const isSelectAllChecked = selectFontCount === selectedFont?.fontFace?.length;
24709 const toggleSelectAll = () => {
24710 const newFonts = [];
24711 if (!isSelectAllChecked && selectedFont) {
24712 newFonts.push(selectedFont);
24713 }
24714 setFontsToInstall(newFonts);
24715 };
24716 const handleInstall = async () => {
24717 setNotice(null);
24718 const fontFamily = fontsToInstall[0];
24719 try {
24720 if (fontFamily?.fontFace) {
24721 await Promise.all(
24722 fontFamily.fontFace.map(async (fontFace) => {
24723 if (fontFace.src) {
24724 fontFace.file = await downloadFontFaceAssets(
24725 fontFace.src
24726 );
24727 }
24728 })
24729 );
24730 }
24731 } catch (error) {
24732 setNotice({
24733 type: "error",
24734 message: (0, import_i18n89.__)(
24735 "Error installing the fonts, could not be downloaded."
24736 )
24737 });
24738 return;
24739 }
24740 try {
24741 await installFonts([fontFamily]);
24742 setNotice({
24743 type: "success",
24744 message: (0, import_i18n89.__)("Fonts were installed successfully.")
24745 });
24746 } catch (error) {
24747 setNotice({
24748 type: "error",
24749 message: error.message
24750 });
24751 }
24752 resetFontsToInstall();
24753 };
24754 const getSortedFontFaces = (fontFamily) => {
24755 if (!fontFamily) {
24756 return [];
24757 }
24758 if (!fontFamily.fontFace || !fontFamily.fontFace.length) {
24759 return [
24760 {
24761 fontFamily: fontFamily.fontFamily,
24762 fontStyle: "normal",
24763 fontWeight: "400"
24764 }
24765 ];
24766 }
24767 return sortFontFaces(fontFamily.fontFace);
24768 };
24769 if (renderConfirmDialog) {
24770 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(google_fonts_confirm_dialog_default, {});
24771 }
24772 const ActionsComponent = () => {
24773 if (slug !== "google-fonts" || renderConfirmDialog || selectedFont) {
24774 return null;
24775 }
24776 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24777 import_components62.DropdownMenu,
24778 {
24779 icon: more_vertical_default,
24780 label: (0, import_i18n89.__)("Actions"),
24781 popoverProps: {
24782 position: "bottom left"
24783 },
24784 controls: [
24785 {
24786 title: (0, import_i18n89.__)("Revoke access to Google Fonts"),
24787 onClick: revokeAccess
24788 }
24789 ]
24790 }
24791 );
24792 };
24793 return /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
24794 isLoading && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className: "font-library__loading", children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.ProgressBar, {}) }),
24795 !isLoading && selectedCollection && /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_jsx_runtime158.Fragment, { children: [
24796 /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
24797 import_components62.Navigator,
24798 {
24799 initialPath: "/",
24800 className: "font-library__tabpanel-layout",
24801 children: [
24802 /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_components62.Navigator.Screen, { path: "/", children: [
24803 /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_components62.__experimentalHStack, { justify: "space-between", children: [
24804 /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_components62.__experimentalVStack, { children: [
24805 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalHeading, { level: 2, size: 13, children: selectedCollection.name }),
24806 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalText, { children: selectedCollection.description })
24807 ] }),
24808 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(ActionsComponent, {})
24809 ] }),
24810 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalSpacer, { margin: 4 }),
24811 /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_components62.__experimentalHStack, { spacing: 4, justify: "space-between", children: [
24812 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24813 import_components62.SearchControl,
24814 {
24815 value: filters.search,
24816 placeholder: (0, import_i18n89.__)("Font name\u2026"),
24817 label: (0, import_i18n89.__)("Search"),
24818 onChange: debouncedUpdateSearchInput,
24819 hideLabelFromVision: false
24820 }
24821 ),
24822 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24823 import_components62.SelectControl,
24824 {
24825 __next40pxDefaultSize: true,
24826 label: (0, import_i18n89.__)("Category"),
24827 value: filters.category,
24828 onChange: handleCategoryFilter,
24829 children: categories && categories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24830 "option",
24831 {
24832 value: category.slug,
24833 children: category.name
24834 },
24835 category.slug
24836 ))
24837 }
24838 )
24839 ] }),
24840 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalSpacer, { margin: 4 }),
24841 !!selectedCollection?.font_families?.length && !fonts.length && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalText, { children: (0, import_i18n89.__)(
24842 "No fonts found. Try with a different search term."
24843 ) }),
24844 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className: "font-library__fonts-grid__main", children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24845 "ul",
24846 {
24847 role: "list",
24848 className: "font-library__fonts-list",
24849 children: items.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24850 "li",
24851 {
24852 className: "font-library__fonts-list-item",
24853 children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24854 font_card_default,
24855 {
24856 font: font2.font_family_settings,
24857 navigatorPath: "/fontFamily",
24858 onClick: () => {
24859 setSelectedFont(
24860 font2.font_family_settings
24861 );
24862 }
24863 }
24864 )
24865 },
24866 font2.font_family_settings.slug
24867 ))
24868 }
24869 ) })
24870 ] }),
24871 /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_components62.Navigator.Screen, { path: "/fontFamily", children: [
24872 /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_components62.Flex, { justify: "flex-start", children: [
24873 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24874 import_components62.Navigator.BackButton,
24875 {
24876 icon: (0, import_i18n89.isRTL)() ? chevron_right_default : chevron_left_default,
24877 size: "small",
24878 onClick: () => {
24879 setSelectedFont(null);
24880 setNotice(null);
24881 },
24882 label: (0, import_i18n89.__)("Back")
24883 }
24884 ),
24885 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24886 import_components62.__experimentalHeading,
24887 {
24888 level: 2,
24889 size: 13,
24890 className: "global-styles-ui-header",
24891 children: selectedFont?.name
24892 }
24893 )
24894 ] }),
24895 notice && /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_jsx_runtime158.Fragment, { children: [
24896 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalSpacer, { margin: 1 }),
24897 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24898 import_components62.Notice,
24899 {
24900 status: notice.type,
24901 onRemove: () => setNotice(null),
24902 children: notice.message
24903 }
24904 ),
24905 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalSpacer, { margin: 1 })
24906 ] }),
24907 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalSpacer, { margin: 4 }),
24908 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalText, { children: (0, import_i18n89.__)("Select font variants to install.") }),
24909 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalSpacer, { margin: 4 }),
24910 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24911 import_components62.CheckboxControl,
24912 {
24913 className: "font-library__select-all",
24914 label: (0, import_i18n89.__)("Select all"),
24915 checked: isSelectAllChecked,
24916 onChange: toggleSelectAll,
24917 indeterminate: isIndeterminate
24918 }
24919 ),
24920 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalVStack, { spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24921 "ul",
24922 {
24923 role: "list",
24924 className: "font-library__fonts-list",
24925 children: selectedFont && getSortedFontFaces(selectedFont).map(
24926 (face, i3) => /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24927 "li",
24928 {
24929 className: "font-library__fonts-list-item",
24930 children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24931 collection_font_variant_default,
24932 {
24933 font: selectedFont,
24934 face,
24935 handleToggleVariant,
24936 selected: isFontFontFaceInOutline(
24937 selectedFont.slug,
24938 selectedFont.fontFace ? face : null,
24939 // If the font has no fontFace, we want to check if the font is in the outline
24940 fontToInstallOutline
24941 )
24942 }
24943 )
24944 },
24945 `face${i3}`
24946 )
24947 )
24948 }
24949 ) }),
24950 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(import_components62.__experimentalSpacer, { margin: 16 })
24951 ] })
24952 ]
24953 }
24954 ),
24955 selectedFont && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24956 import_components62.Flex,
24957 {
24958 justify: "flex-end",
24959 className: "font-library__footer",
24960 children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24961 import_components62.Button,
24962 {
24963 __next40pxDefaultSize: true,
24964 variant: "primary",
24965 onClick: handleInstall,
24966 isBusy: isInstalling,
24967 disabled: fontsToInstall.length === 0 || isInstalling,
24968 accessibleWhenDisabled: true,
24969 children: (0, import_i18n89.__)("Install")
24970 }
24971 )
24972 }
24973 ),
24974 !selectedFont && /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
24975 import_components62.__experimentalHStack,
24976 {
24977 expanded: false,
24978 className: "font-library__footer",
24979 justify: "end",
24980 spacing: 6,
24981 children: [
24982 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
24983 import_components62.__experimentalHStack,
24984 {
24985 justify: "flex-start",
24986 expanded: false,
24987 spacing: 1,
24988 className: "font-library__page-selection",
24989 children: (0, import_element62.createInterpolateElement)(
24990 (0, import_i18n89.sprintf)(
24991 // translators: 1: Current page number, 2: Total number of pages.
24992 (0, import_i18n89._x)(
24993 "<div>Page</div>%1$s<div>of %2$d</div>",
24994 "paging"
24995 ),
24996 "<CurrentPage />",
24997 totalPages
24998 ),
24999 {
25000 div: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { "aria-hidden": true }),
25001 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
25002 import_components62.SelectControl,
25003 {
25004 "aria-label": (0, import_i18n89.__)(
25005 "Current page"
25006 ),
25007 value: page.toString(),
25008 options: [
25009 ...Array(totalPages)
25010 ].map((e3, i3) => {
25011 return {
25012 label: (i3 + 1).toString(),
25013 value: (i3 + 1).toString()
25014 };
25015 }),
25016 onChange: (newPage) => setPage(
25017 parseInt(newPage)
25018 ),
25019 size: "small",
25020 variant: "minimal"
25021 }
25022 )
25023 }
25024 )
25025 }
25026 ),
25027 /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_components62.__experimentalHStack, { expanded: false, spacing: 1, children: [
25028 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
25029 import_components62.Button,
25030 {
25031 onClick: () => setPage(page - 1),
25032 disabled: page === 1,
25033 accessibleWhenDisabled: true,
25034 label: (0, import_i18n89.__)("Previous page"),
25035 icon: (0, import_i18n89.isRTL)() ? next_default : previous_default,
25036 showTooltip: true,
25037 size: "compact",
25038 tooltipPosition: "top"
25039 }
25040 ),
25041 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
25042 import_components62.Button,
25043 {
25044 onClick: () => setPage(page + 1),
25045 disabled: page === totalPages,
25046 accessibleWhenDisabled: true,
25047 label: (0, import_i18n89.__)("Next page"),
25048 icon: (0, import_i18n89.isRTL)() ? previous_default : next_default,
25049 showTooltip: true,
25050 size: "compact",
25051 tooltipPosition: "top"
25052 }
25053 )
25054 ] })
25055 ]
25056 }
25057 )
25058 ] })
25059 ] });
25060 }
25061 var font_collection_default = FontCollection;
25062
25063 // packages/global-styles-ui/build-module/font-library/upload-fonts.mjs
25064 var import_i18n90 = __toESM(require_i18n(), 1);
25065 var import_components64 = __toESM(require_components(), 1);
25066 var import_element63 = __toESM(require_element(), 1);
25067
25068 // packages/global-styles-ui/build-module/font-library/lib/unbrotli.mjs
25069 var __require2 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, {
25070 get: (a3, b3) => (typeof __require !== "undefined" ? __require : a3)[b3]
25071 }) : x2)(function(x2) {
25072 if (typeof __require !== "undefined") return __require.apply(this, arguments);
25073 throw Error('Dynamic require of "' + x2 + '" is not supported');
25074 });
25075 var unbrotli_default = (function() {
25076 var define2, module, exports;
25077 return (/* @__PURE__ */ (function() {
25078 function r4(e3, n3, t4) {
25079 function o4(i22, f3) {
25080 if (!n3[i22]) {
25081 if (!e3[i22]) {
25082 var c6 = "function" == typeof __require2 && __require2;
25083 if (!f3 && c6) return c6(i22, true);
25084 if (u3) return u3(i22, true);
25085 var a3 = new Error("Cannot find module '" + i22 + "'");
25086 throw a3.code = "MODULE_NOT_FOUND", a3;
25087 }
25088 var p4 = n3[i22] = { exports: {} };
25089 e3[i22][0].call(
25090 p4.exports,
25091 function(r22) {
25092 var n22 = e3[i22][1][r22];
25093 return o4(n22 || r22);
25094 },
25095 p4,
25096 p4.exports,
25097 r4,
25098 e3,
25099 n3,
25100 t4
25101 );
25102 }
25103 return n3[i22].exports;
25104 }
25105 for (var u3 = "function" == typeof __require2 && __require2, i3 = 0; i3 < t4.length; i3++)
25106 o4(t4[i3]);
25107 return o4;
25108 }
25109 return r4;
25110 })())(
25111 {
25112 1: [
25113 function(require2, module2, exports2) {
25114 var BROTLI_READ_SIZE = 4096;
25115 var BROTLI_IBUF_SIZE = 2 * BROTLI_READ_SIZE + 32;
25116 var BROTLI_IBUF_MASK = 2 * BROTLI_READ_SIZE - 1;
25117 var kBitMask = new Uint32Array([
25118 0,
25119 1,
25120 3,
25121 7,
25122 15,
25123 31,
25124 63,
25125 127,
25126 255,
25127 511,
25128 1023,
25129 2047,
25130 4095,
25131 8191,
25132 16383,
25133 32767,
25134 65535,
25135 131071,
25136 262143,
25137 524287,
25138 1048575,
25139 2097151,
25140 4194303,
25141 8388607,
25142 16777215
25143 ]);
25144 function BrotliBitReader(input) {
25145 this.buf_ = new Uint8Array(BROTLI_IBUF_SIZE);
25146 this.input_ = input;
25147 this.reset();
25148 }
25149 BrotliBitReader.READ_SIZE = BROTLI_READ_SIZE;
25150 BrotliBitReader.IBUF_MASK = BROTLI_IBUF_MASK;
25151 BrotliBitReader.prototype.reset = function() {
25152 this.buf_ptr_ = 0;
25153 this.val_ = 0;
25154 this.pos_ = 0;
25155 this.bit_pos_ = 0;
25156 this.bit_end_pos_ = 0;
25157 this.eos_ = 0;
25158 this.readMoreInput();
25159 for (var i3 = 0; i3 < 4; i3++) {
25160 this.val_ |= this.buf_[this.pos_] << 8 * i3;
25161 ++this.pos_;
25162 }
25163 return this.bit_end_pos_ > 0;
25164 };
25165 BrotliBitReader.prototype.readMoreInput = function() {
25166 if (this.bit_end_pos_ > 256) {
25167 return;
25168 } else if (this.eos_) {
25169 if (this.bit_pos_ > this.bit_end_pos_)
25170 throw new Error(
25171 "Unexpected end of input " + this.bit_pos_ + " " + this.bit_end_pos_
25172 );
25173 } else {
25174 var dst = this.buf_ptr_;
25175 var bytes_read = this.input_.read(
25176 this.buf_,
25177 dst,
25178 BROTLI_READ_SIZE
25179 );
25180 if (bytes_read < 0) {
25181 throw new Error("Unexpected end of input");
25182 }
25183 if (bytes_read < BROTLI_READ_SIZE) {
25184 this.eos_ = 1;
25185 for (var p4 = 0; p4 < 32; p4++)
25186 this.buf_[dst + bytes_read + p4] = 0;
25187 }
25188 if (dst === 0) {
25189 for (var p4 = 0; p4 < 32; p4++)
25190 this.buf_[(BROTLI_READ_SIZE << 1) + p4] = this.buf_[p4];
25191 this.buf_ptr_ = BROTLI_READ_SIZE;
25192 } else {
25193 this.buf_ptr_ = 0;
25194 }
25195 this.bit_end_pos_ += bytes_read << 3;
25196 }
25197 };
25198 BrotliBitReader.prototype.fillBitWindow = function() {
25199 while (this.bit_pos_ >= 8) {
25200 this.val_ >>>= 8;
25201 this.val_ |= this.buf_[this.pos_ & BROTLI_IBUF_MASK] << 24;
25202 ++this.pos_;
25203 this.bit_pos_ = this.bit_pos_ - 8 >>> 0;
25204 this.bit_end_pos_ = this.bit_end_pos_ - 8 >>> 0;
25205 }
25206 };
25207 BrotliBitReader.prototype.readBits = function(n_bits) {
25208 if (32 - this.bit_pos_ < n_bits) {
25209 this.fillBitWindow();
25210 }
25211 var val = this.val_ >>> this.bit_pos_ & kBitMask[n_bits];
25212 this.bit_pos_ += n_bits;
25213 return val;
25214 };
25215 module2.exports = BrotliBitReader;
25216 },
25217 {}
25218 ],
25219 2: [
25220 function(require2, module2, exports2) {
25221 var CONTEXT_LSB6 = 0;
25222 var CONTEXT_MSB6 = 1;
25223 var CONTEXT_UTF8 = 2;
25224 var CONTEXT_SIGNED = 3;
25225 exports2.lookup = new Uint8Array([
25226 /* CONTEXT_UTF8, last byte. */
25227 /* ASCII range. */
25228 0,
25229 0,
25230 0,
25231 0,
25232 0,
25233 0,
25234 0,
25235 0,
25236 0,
25237 4,
25238 4,
25239 0,
25240 0,
25241 4,
25242 0,
25243 0,
25244 0,
25245 0,
25246 0,
25247 0,
25248 0,
25249 0,
25250 0,
25251 0,
25252 0,
25253 0,
25254 0,
25255 0,
25256 0,
25257 0,
25258 0,
25259 0,
25260 8,
25261 12,
25262 16,
25263 12,
25264 12,
25265 20,
25266 12,
25267 16,
25268 24,
25269 28,
25270 12,
25271 12,
25272 32,
25273 12,
25274 36,
25275 12,
25276 44,
25277 44,
25278 44,
25279 44,
25280 44,
25281 44,
25282 44,
25283 44,
25284 44,
25285 44,
25286 32,
25287 32,
25288 24,
25289 40,
25290 28,
25291 12,
25292 12,
25293 48,
25294 52,
25295 52,
25296 52,
25297 48,
25298 52,
25299 52,
25300 52,
25301 48,
25302 52,
25303 52,
25304 52,
25305 52,
25306 52,
25307 48,
25308 52,
25309 52,
25310 52,
25311 52,
25312 52,
25313 48,
25314 52,
25315 52,
25316 52,
25317 52,
25318 52,
25319 24,
25320 12,
25321 28,
25322 12,
25323 12,
25324 12,
25325 56,
25326 60,
25327 60,
25328 60,
25329 56,
25330 60,
25331 60,
25332 60,
25333 56,
25334 60,
25335 60,
25336 60,
25337 60,
25338 60,
25339 56,
25340 60,
25341 60,
25342 60,
25343 60,
25344 60,
25345 56,
25346 60,
25347 60,
25348 60,
25349 60,
25350 60,
25351 24,
25352 12,
25353 28,
25354 12,
25355 0,
25356 /* UTF8 continuation byte range. */
25357 0,
25358 1,
25359 0,
25360 1,
25361 0,
25362 1,
25363 0,
25364 1,
25365 0,
25366 1,
25367 0,
25368 1,
25369 0,
25370 1,
25371 0,
25372 1,
25373 0,
25374 1,
25375 0,
25376 1,
25377 0,
25378 1,
25379 0,
25380 1,
25381 0,
25382 1,
25383 0,
25384 1,
25385 0,
25386 1,
25387 0,
25388 1,
25389 0,
25390 1,
25391 0,
25392 1,
25393 0,
25394 1,
25395 0,
25396 1,
25397 0,
25398 1,
25399 0,
25400 1,
25401 0,
25402 1,
25403 0,
25404 1,
25405 0,
25406 1,
25407 0,
25408 1,
25409 0,
25410 1,
25411 0,
25412 1,
25413 0,
25414 1,
25415 0,
25416 1,
25417 0,
25418 1,
25419 0,
25420 1,
25421 2,
25422 3,
25423 2,
25424 3,
25425 2,
25426 3,
25427 2,
25428 3,
25429 2,
25430 3,
25431 2,
25432 3,
25433 2,
25434 3,
25435 2,
25436 3,
25437 2,
25438 3,
25439 2,
25440 3,
25441 2,
25442 3,
25443 2,
25444 3,
25445 2,
25446 3,
25447 2,
25448 3,
25449 2,
25450 3,
25451 2,
25452 3,
25453 2,
25454 3,
25455 2,
25456 3,
25457 2,
25458 3,
25459 2,
25460 3,
25461 2,
25462 3,
25463 2,
25464 3,
25465 2,
25466 3,
25467 2,
25468 3,
25469 2,
25470 3,
25471 2,
25472 3,
25473 2,
25474 3,
25475 2,
25476 3,
25477 2,
25478 3,
25479 2,
25480 3,
25481 2,
25482 3,
25483 2,
25484 3,
25485 /* ASCII range. */
25486 0,
25487 0,
25488 0,
25489 0,
25490 0,
25491 0,
25492 0,
25493 0,
25494 0,
25495 0,
25496 0,
25497 0,
25498 0,
25499 0,
25500 0,
25501 0,
25502 0,
25503 0,
25504 0,
25505 0,
25506 0,
25507 0,
25508 0,
25509 0,
25510 0,
25511 0,
25512 0,
25513 0,
25514 0,
25515 0,
25516 0,
25517 0,
25518 0,
25519 1,
25520 1,
25521 1,
25522 1,
25523 1,
25524 1,
25525 1,
25526 1,
25527 1,
25528 1,
25529 1,
25530 1,
25531 1,
25532 1,
25533 1,
25534 2,
25535 2,
25536 2,
25537 2,
25538 2,
25539 2,
25540 2,
25541 2,
25542 2,
25543 2,
25544 1,
25545 1,
25546 1,
25547 1,
25548 1,
25549 1,
25550 1,
25551 2,
25552 2,
25553 2,
25554 2,
25555 2,
25556 2,
25557 2,
25558 2,
25559 2,
25560 2,
25561 2,
25562 2,
25563 2,
25564 2,
25565 2,
25566 2,
25567 2,
25568 2,
25569 2,
25570 2,
25571 2,
25572 2,
25573 2,
25574 2,
25575 2,
25576 2,
25577 1,
25578 1,
25579 1,
25580 1,
25581 1,
25582 1,
25583 3,
25584 3,
25585 3,
25586 3,
25587 3,
25588 3,
25589 3,
25590 3,
25591 3,
25592 3,
25593 3,
25594 3,
25595 3,
25596 3,
25597 3,
25598 3,
25599 3,
25600 3,
25601 3,
25602 3,
25603 3,
25604 3,
25605 3,
25606 3,
25607 3,
25608 3,
25609 1,
25610 1,
25611 1,
25612 1,
25613 0,
25614 /* UTF8 continuation byte range. */
25615 0,
25616 0,
25617 0,
25618 0,
25619 0,
25620 0,
25621 0,
25622 0,
25623 0,
25624 0,
25625 0,
25626 0,
25627 0,
25628 0,
25629 0,
25630 0,
25631 0,
25632 0,
25633 0,
25634 0,
25635 0,
25636 0,
25637 0,
25638 0,
25639 0,
25640 0,
25641 0,
25642 0,
25643 0,
25644 0,
25645 0,
25646 0,
25647 0,
25648 0,
25649 0,
25650 0,
25651 0,
25652 0,
25653 0,
25654 0,
25655 0,
25656 0,
25657 0,
25658 0,
25659 0,
25660 0,
25661 0,
25662 0,
25663 0,
25664 0,
25665 0,
25666 0,
25667 0,
25668 0,
25669 0,
25670 0,
25671 0,
25672 0,
25673 0,
25674 0,
25675 0,
25676 0,
25677 0,
25678 0,
25679 0,
25680 0,
25681 0,
25682 0,
25683 0,
25684 0,
25685 0,
25686 0,
25687 0,
25688 0,
25689 0,
25690 0,
25691 0,
25692 0,
25693 0,
25694 0,
25695 0,
25696 0,
25697 0,
25698 0,
25699 0,
25700 0,
25701 0,
25702 0,
25703 0,
25704 0,
25705 0,
25706 0,
25707 0,
25708 0,
25709 0,
25710 0,
25711 2,
25712 2,
25713 2,
25714 2,
25715 2,
25716 2,
25717 2,
25718 2,
25719 2,
25720 2,
25721 2,
25722 2,
25723 2,
25724 2,
25725 2,
25726 2,
25727 2,
25728 2,
25729 2,
25730 2,
25731 2,
25732 2,
25733 2,
25734 2,
25735 2,
25736 2,
25737 2,
25738 2,
25739 2,
25740 2,
25741 2,
25742 2,
25743 0,
25744 1,
25745 1,
25746 1,
25747 1,
25748 1,
25749 1,
25750 1,
25751 1,
25752 1,
25753 1,
25754 1,
25755 1,
25756 1,
25757 1,
25758 1,
25759 2,
25760 2,
25761 2,
25762 2,
25763 2,
25764 2,
25765 2,
25766 2,
25767 2,
25768 2,
25769 2,
25770 2,
25771 2,
25772 2,
25773 2,
25774 2,
25775 2,
25776 2,
25777 2,
25778 2,
25779 2,
25780 2,
25781 2,
25782 2,
25783 2,
25784 2,
25785 2,
25786 2,
25787 2,
25788 2,
25789 2,
25790 2,
25791 2,
25792 2,
25793 2,
25794 2,
25795 2,
25796 2,
25797 2,
25798 2,
25799 2,
25800 2,
25801 2,
25802 2,
25803 2,
25804 2,
25805 2,
25806 2,
25807 3,
25808 3,
25809 3,
25810 3,
25811 3,
25812 3,
25813 3,
25814 3,
25815 3,
25816 3,
25817 3,
25818 3,
25819 3,
25820 3,
25821 3,
25822 3,
25823 3,
25824 3,
25825 3,
25826 3,
25827 3,
25828 3,
25829 3,
25830 3,
25831 3,
25832 3,
25833 3,
25834 3,
25835 3,
25836 3,
25837 3,
25838 3,
25839 3,
25840 3,
25841 3,
25842 3,
25843 3,
25844 3,
25845 3,
25846 3,
25847 3,
25848 3,
25849 3,
25850 3,
25851 3,
25852 3,
25853 3,
25854 3,
25855 3,
25856 3,
25857 3,
25858 3,
25859 3,
25860 3,
25861 3,
25862 3,
25863 3,
25864 3,
25865 3,
25866 3,
25867 3,
25868 3,
25869 3,
25870 3,
25871 4,
25872 4,
25873 4,
25874 4,
25875 4,
25876 4,
25877 4,
25878 4,
25879 4,
25880 4,
25881 4,
25882 4,
25883 4,
25884 4,
25885 4,
25886 4,
25887 4,
25888 4,
25889 4,
25890 4,
25891 4,
25892 4,
25893 4,
25894 4,
25895 4,
25896 4,
25897 4,
25898 4,
25899 4,
25900 4,
25901 4,
25902 4,
25903 4,
25904 4,
25905 4,
25906 4,
25907 4,
25908 4,
25909 4,
25910 4,
25911 4,
25912 4,
25913 4,
25914 4,
25915 4,
25916 4,
25917 4,
25918 4,
25919 4,
25920 4,
25921 4,
25922 4,
25923 4,
25924 4,
25925 4,
25926 4,
25927 4,
25928 4,
25929 4,
25930 4,
25931 4,
25932 4,
25933 4,
25934 4,
25935 5,
25936 5,
25937 5,
25938 5,
25939 5,
25940 5,
25941 5,
25942 5,
25943 5,
25944 5,
25945 5,
25946 5,
25947 5,
25948 5,
25949 5,
25950 5,
25951 5,
25952 5,
25953 5,
25954 5,
25955 5,
25956 5,
25957 5,
25958 5,
25959 5,
25960 5,
25961 5,
25962 5,
25963 5,
25964 5,
25965 5,
25966 5,
25967 5,
25968 5,
25969 5,
25970 5,
25971 5,
25972 5,
25973 5,
25974 5,
25975 5,
25976 5,
25977 5,
25978 5,
25979 5,
25980 5,
25981 5,
25982 5,
25983 6,
25984 6,
25985 6,
25986 6,
25987 6,
25988 6,
25989 6,
25990 6,
25991 6,
25992 6,
25993 6,
25994 6,
25995 6,
25996 6,
25997 6,
25998 7,
25999 /* CONTEXT_SIGNED, last byte, same as the above values shifted by 3 bits. */
26000 0,
26001 8,
26002 8,
26003 8,
26004 8,
26005 8,
26006 8,
26007 8,
26008 8,
26009 8,
26010 8,
26011 8,
26012 8,
26013 8,
26014 8,
26015 8,
26016 16,
26017 16,
26018 16,
26019 16,
26020 16,
26021 16,
26022 16,
26023 16,
26024 16,
26025 16,
26026 16,
26027 16,
26028 16,
26029 16,
26030 16,
26031 16,
26032 16,
26033 16,
26034 16,
26035 16,
26036 16,
26037 16,
26038 16,
26039 16,
26040 16,
26041 16,
26042 16,
26043 16,
26044 16,
26045 16,
26046 16,
26047 16,
26048 16,
26049 16,
26050 16,
26051 16,
26052 16,
26053 16,
26054 16,
26055 16,
26056 16,
26057 16,
26058 16,
26059 16,
26060 16,
26061 16,
26062 16,
26063 16,
26064 24,
26065 24,
26066 24,
26067 24,
26068 24,
26069 24,
26070 24,
26071 24,
26072 24,
26073 24,
26074 24,
26075 24,
26076 24,
26077 24,
26078 24,
26079 24,
26080 24,
26081 24,
26082 24,
26083 24,
26084 24,
26085 24,
26086 24,
26087 24,
26088 24,
26089 24,
26090 24,
26091 24,
26092 24,
26093 24,
26094 24,
26095 24,
26096 24,
26097 24,
26098 24,
26099 24,
26100 24,
26101 24,
26102 24,
26103 24,
26104 24,
26105 24,
26106 24,
26107 24,
26108 24,
26109 24,
26110 24,
26111 24,
26112 24,
26113 24,
26114 24,
26115 24,
26116 24,
26117 24,
26118 24,
26119 24,
26120 24,
26121 24,
26122 24,
26123 24,
26124 24,
26125 24,
26126 24,
26127 24,
26128 32,
26129 32,
26130 32,
26131 32,
26132 32,
26133 32,
26134 32,
26135 32,
26136 32,
26137 32,
26138 32,
26139 32,
26140 32,
26141 32,
26142 32,
26143 32,
26144 32,
26145 32,
26146 32,
26147 32,
26148 32,
26149 32,
26150 32,
26151 32,
26152 32,
26153 32,
26154 32,
26155 32,
26156 32,
26157 32,
26158 32,
26159 32,
26160 32,
26161 32,
26162 32,
26163 32,
26164 32,
26165 32,
26166 32,
26167 32,
26168 32,
26169 32,
26170 32,
26171 32,
26172 32,
26173 32,
26174 32,
26175 32,
26176 32,
26177 32,
26178 32,
26179 32,
26180 32,
26181 32,
26182 32,
26183 32,
26184 32,
26185 32,
26186 32,
26187 32,
26188 32,
26189 32,
26190 32,
26191 32,
26192 40,
26193 40,
26194 40,
26195 40,
26196 40,
26197 40,
26198 40,
26199 40,
26200 40,
26201 40,
26202 40,
26203 40,
26204 40,
26205 40,
26206 40,
26207 40,
26208 40,
26209 40,
26210 40,
26211 40,
26212 40,
26213 40,
26214 40,
26215 40,
26216 40,
26217 40,
26218 40,
26219 40,
26220 40,
26221 40,
26222 40,
26223 40,
26224 40,
26225 40,
26226 40,
26227 40,
26228 40,
26229 40,
26230 40,
26231 40,
26232 40,
26233 40,
26234 40,
26235 40,
26236 40,
26237 40,
26238 40,
26239 40,
26240 48,
26241 48,
26242 48,
26243 48,
26244 48,
26245 48,
26246 48,
26247 48,
26248 48,
26249 48,
26250 48,
26251 48,
26252 48,
26253 48,
26254 48,
26255 56,
26256 /* CONTEXT_LSB6, last byte. */
26257 0,
26258 1,
26259 2,
26260 3,
26261 4,
26262 5,
26263 6,
26264 7,
26265 8,
26266 9,
26267 10,
26268 11,
26269 12,
26270 13,
26271 14,
26272 15,
26273 16,
26274 17,
26275 18,
26276 19,
26277 20,
26278 21,
26279 22,
26280 23,
26281 24,
26282 25,
26283 26,
26284 27,
26285 28,
26286 29,
26287 30,
26288 31,
26289 32,
26290 33,
26291 34,
26292 35,
26293 36,
26294 37,
26295 38,
26296 39,
26297 40,
26298 41,
26299 42,
26300 43,
26301 44,
26302 45,
26303 46,
26304 47,
26305 48,
26306 49,
26307 50,
26308 51,
26309 52,
26310 53,
26311 54,
26312 55,
26313 56,
26314 57,
26315 58,
26316 59,
26317 60,
26318 61,
26319 62,
26320 63,
26321 0,
26322 1,
26323 2,
26324 3,
26325 4,
26326 5,
26327 6,
26328 7,
26329 8,
26330 9,
26331 10,
26332 11,
26333 12,
26334 13,
26335 14,
26336 15,
26337 16,
26338 17,
26339 18,
26340 19,
26341 20,
26342 21,
26343 22,
26344 23,
26345 24,
26346 25,
26347 26,
26348 27,
26349 28,
26350 29,
26351 30,
26352 31,
26353 32,
26354 33,
26355 34,
26356 35,
26357 36,
26358 37,
26359 38,
26360 39,
26361 40,
26362 41,
26363 42,
26364 43,
26365 44,
26366 45,
26367 46,
26368 47,
26369 48,
26370 49,
26371 50,
26372 51,
26373 52,
26374 53,
26375 54,
26376 55,
26377 56,
26378 57,
26379 58,
26380 59,
26381 60,
26382 61,
26383 62,
26384 63,
26385 0,
26386 1,
26387 2,
26388 3,
26389 4,
26390 5,
26391 6,
26392 7,
26393 8,
26394 9,
26395 10,
26396 11,
26397 12,
26398 13,
26399 14,
26400 15,
26401 16,
26402 17,
26403 18,
26404 19,
26405 20,
26406 21,
26407 22,
26408 23,
26409 24,
26410 25,
26411 26,
26412 27,
26413 28,
26414 29,
26415 30,
26416 31,
26417 32,
26418 33,
26419 34,
26420 35,
26421 36,
26422 37,
26423 38,
26424 39,
26425 40,
26426 41,
26427 42,
26428 43,
26429 44,
26430 45,
26431 46,
26432 47,
26433 48,
26434 49,
26435 50,
26436 51,
26437 52,
26438 53,
26439 54,
26440 55,
26441 56,
26442 57,
26443 58,
26444 59,
26445 60,
26446 61,
26447 62,
26448 63,
26449 0,
26450 1,
26451 2,
26452 3,
26453 4,
26454 5,
26455 6,
26456 7,
26457 8,
26458 9,
26459 10,
26460 11,
26461 12,
26462 13,
26463 14,
26464 15,
26465 16,
26466 17,
26467 18,
26468 19,
26469 20,
26470 21,
26471 22,
26472 23,
26473 24,
26474 25,
26475 26,
26476 27,
26477 28,
26478 29,
26479 30,
26480 31,
26481 32,
26482 33,
26483 34,
26484 35,
26485 36,
26486 37,
26487 38,
26488 39,
26489 40,
26490 41,
26491 42,
26492 43,
26493 44,
26494 45,
26495 46,
26496 47,
26497 48,
26498 49,
26499 50,
26500 51,
26501 52,
26502 53,
26503 54,
26504 55,
26505 56,
26506 57,
26507 58,
26508 59,
26509 60,
26510 61,
26511 62,
26512 63,
26513 /* CONTEXT_MSB6, last byte. */
26514 0,
26515 0,
26516 0,
26517 0,
26518 1,
26519 1,
26520 1,
26521 1,
26522 2,
26523 2,
26524 2,
26525 2,
26526 3,
26527 3,
26528 3,
26529 3,
26530 4,
26531 4,
26532 4,
26533 4,
26534 5,
26535 5,
26536 5,
26537 5,
26538 6,
26539 6,
26540 6,
26541 6,
26542 7,
26543 7,
26544 7,
26545 7,
26546 8,
26547 8,
26548 8,
26549 8,
26550 9,
26551 9,
26552 9,
26553 9,
26554 10,
26555 10,
26556 10,
26557 10,
26558 11,
26559 11,
26560 11,
26561 11,
26562 12,
26563 12,
26564 12,
26565 12,
26566 13,
26567 13,
26568 13,
26569 13,
26570 14,
26571 14,
26572 14,
26573 14,
26574 15,
26575 15,
26576 15,
26577 15,
26578 16,
26579 16,
26580 16,
26581 16,
26582 17,
26583 17,
26584 17,
26585 17,
26586 18,
26587 18,
26588 18,
26589 18,
26590 19,
26591 19,
26592 19,
26593 19,
26594 20,
26595 20,
26596 20,
26597 20,
26598 21,
26599 21,
26600 21,
26601 21,
26602 22,
26603 22,
26604 22,
26605 22,
26606 23,
26607 23,
26608 23,
26609 23,
26610 24,
26611 24,
26612 24,
26613 24,
26614 25,
26615 25,
26616 25,
26617 25,
26618 26,
26619 26,
26620 26,
26621 26,
26622 27,
26623 27,
26624 27,
26625 27,
26626 28,
26627 28,
26628 28,
26629 28,
26630 29,
26631 29,
26632 29,
26633 29,
26634 30,
26635 30,
26636 30,
26637 30,
26638 31,
26639 31,
26640 31,
26641 31,
26642 32,
26643 32,
26644 32,
26645 32,
26646 33,
26647 33,
26648 33,
26649 33,
26650 34,
26651 34,
26652 34,
26653 34,
26654 35,
26655 35,
26656 35,
26657 35,
26658 36,
26659 36,
26660 36,
26661 36,
26662 37,
26663 37,
26664 37,
26665 37,
26666 38,
26667 38,
26668 38,
26669 38,
26670 39,
26671 39,
26672 39,
26673 39,
26674 40,
26675 40,
26676 40,
26677 40,
26678 41,
26679 41,
26680 41,
26681 41,
26682 42,
26683 42,
26684 42,
26685 42,
26686 43,
26687 43,
26688 43,
26689 43,
26690 44,
26691 44,
26692 44,
26693 44,
26694 45,
26695 45,
26696 45,
26697 45,
26698 46,
26699 46,
26700 46,
26701 46,
26702 47,
26703 47,
26704 47,
26705 47,
26706 48,
26707 48,
26708 48,
26709 48,
26710 49,
26711 49,
26712 49,
26713 49,
26714 50,
26715 50,
26716 50,
26717 50,
26718 51,
26719 51,
26720 51,
26721 51,
26722 52,
26723 52,
26724 52,
26725 52,
26726 53,
26727 53,
26728 53,
26729 53,
26730 54,
26731 54,
26732 54,
26733 54,
26734 55,
26735 55,
26736 55,
26737 55,
26738 56,
26739 56,
26740 56,
26741 56,
26742 57,
26743 57,
26744 57,
26745 57,
26746 58,
26747 58,
26748 58,
26749 58,
26750 59,
26751 59,
26752 59,
26753 59,
26754 60,
26755 60,
26756 60,
26757 60,
26758 61,
26759 61,
26760 61,
26761 61,
26762 62,
26763 62,
26764 62,
26765 62,
26766 63,
26767 63,
26768 63,
26769 63,
26770 /* CONTEXT_{M,L}SB6, second last byte, */
26771 0,
26772 0,
26773 0,
26774 0,
26775 0,
26776 0,
26777 0,
26778 0,
26779 0,
26780 0,
26781 0,
26782 0,
26783 0,
26784 0,
26785 0,
26786 0,
26787 0,
26788 0,
26789 0,
26790 0,
26791 0,
26792 0,
26793 0,
26794 0,
26795 0,
26796 0,
26797 0,
26798 0,
26799 0,
26800 0,
26801 0,
26802 0,
26803 0,
26804 0,
26805 0,
26806 0,
26807 0,
26808 0,
26809 0,
26810 0,
26811 0,
26812 0,
26813 0,
26814 0,
26815 0,
26816 0,
26817 0,
26818 0,
26819 0,
26820 0,
26821 0,
26822 0,
26823 0,
26824 0,
26825 0,
26826 0,
26827 0,
26828 0,
26829 0,
26830 0,
26831 0,
26832 0,
26833 0,
26834 0,
26835 0,
26836 0,
26837 0,
26838 0,
26839 0,
26840 0,
26841 0,
26842 0,
26843 0,
26844 0,
26845 0,
26846 0,
26847 0,
26848 0,
26849 0,
26850 0,
26851 0,
26852 0,
26853 0,
26854 0,
26855 0,
26856 0,
26857 0,
26858 0,
26859 0,
26860 0,
26861 0,
26862 0,
26863 0,
26864 0,
26865 0,
26866 0,
26867 0,
26868 0,
26869 0,
26870 0,
26871 0,
26872 0,
26873 0,
26874 0,
26875 0,
26876 0,
26877 0,
26878 0,
26879 0,
26880 0,
26881 0,
26882 0,
26883 0,
26884 0,
26885 0,
26886 0,
26887 0,
26888 0,
26889 0,
26890 0,
26891 0,
26892 0,
26893 0,
26894 0,
26895 0,
26896 0,
26897 0,
26898 0,
26899 0,
26900 0,
26901 0,
26902 0,
26903 0,
26904 0,
26905 0,
26906 0,
26907 0,
26908 0,
26909 0,
26910 0,
26911 0,
26912 0,
26913 0,
26914 0,
26915 0,
26916 0,
26917 0,
26918 0,
26919 0,
26920 0,
26921 0,
26922 0,
26923 0,
26924 0,
26925 0,
26926 0,
26927 0,
26928 0,
26929 0,
26930 0,
26931 0,
26932 0,
26933 0,
26934 0,
26935 0,
26936 0,
26937 0,
26938 0,
26939 0,
26940 0,
26941 0,
26942 0,
26943 0,
26944 0,
26945 0,
26946 0,
26947 0,
26948 0,
26949 0,
26950 0,
26951 0,
26952 0,
26953 0,
26954 0,
26955 0,
26956 0,
26957 0,
26958 0,
26959 0,
26960 0,
26961 0,
26962 0,
26963 0,
26964 0,
26965 0,
26966 0,
26967 0,
26968 0,
26969 0,
26970 0,
26971 0,
26972 0,
26973 0,
26974 0,
26975 0,
26976 0,
26977 0,
26978 0,
26979 0,
26980 0,
26981 0,
26982 0,
26983 0,
26984 0,
26985 0,
26986 0,
26987 0,
26988 0,
26989 0,
26990 0,
26991 0,
26992 0,
26993 0,
26994 0,
26995 0,
26996 0,
26997 0,
26998 0,
26999 0,
27000 0,
27001 0,
27002 0,
27003 0,
27004 0,
27005 0,
27006 0,
27007 0,
27008 0,
27009 0,
27010 0,
27011 0,
27012 0,
27013 0,
27014 0,
27015 0,
27016 0,
27017 0,
27018 0,
27019 0,
27020 0,
27021 0,
27022 0,
27023 0,
27024 0,
27025 0,
27026 0
27027 ]);
27028 exports2.lookupOffsets = new Uint16Array([
27029 /* CONTEXT_LSB6 */
27030 1024,
27031 1536,
27032 1280,
27033 1536,
27034 0,
27035 256,
27036 768,
27037 512
27038 ]);
27039 },
27040 {}
27041 ],
27042 3: [
27043 function(require2, module2, exports2) {
27044 var BrotliInput = require2("./streams").BrotliInput;
27045 var BrotliOutput = require2("./streams").BrotliOutput;
27046 var BrotliBitReader = require2("./bit_reader");
27047 var BrotliDictionary = require2("./dictionary");
27048 var HuffmanCode = require2("./huffman").HuffmanCode;
27049 var BrotliBuildHuffmanTable = require2("./huffman").BrotliBuildHuffmanTable;
27050 var Context = require2("./context");
27051 var Prefix = require2("./prefix");
27052 var Transform = require2("./transform");
27053 var kDefaultCodeLength = 8;
27054 var kCodeLengthRepeatCode = 16;
27055 var kNumLiteralCodes = 256;
27056 var kNumInsertAndCopyCodes = 704;
27057 var kNumBlockLengthCodes = 26;
27058 var kLiteralContextBits = 6;
27059 var kDistanceContextBits = 2;
27060 var HUFFMAN_TABLE_BITS = 8;
27061 var HUFFMAN_TABLE_MASK = 255;
27062 var HUFFMAN_MAX_TABLE_SIZE = 1080;
27063 var CODE_LENGTH_CODES = 18;
27064 var kCodeLengthCodeOrder = new Uint8Array([
27065 1,
27066 2,
27067 3,
27068 4,
27069 0,
27070 5,
27071 17,
27072 6,
27073 16,
27074 7,
27075 8,
27076 9,
27077 10,
27078 11,
27079 12,
27080 13,
27081 14,
27082 15
27083 ]);
27084 var NUM_DISTANCE_SHORT_CODES = 16;
27085 var kDistanceShortCodeIndexOffset = new Uint8Array([
27086 3,
27087 2,
27088 1,
27089 0,
27090 3,
27091 3,
27092 3,
27093 3,
27094 3,
27095 3,
27096 2,
27097 2,
27098 2,
27099 2,
27100 2,
27101 2
27102 ]);
27103 var kDistanceShortCodeValueOffset = new Int8Array([
27104 0,
27105 0,
27106 0,
27107 0,
27108 -1,
27109 1,
27110 -2,
27111 2,
27112 -3,
27113 3,
27114 -1,
27115 1,
27116 -2,
27117 2,
27118 -3,
27119 3
27120 ]);
27121 var kMaxHuffmanTableSize = new Uint16Array([
27122 256,
27123 402,
27124 436,
27125 468,
27126 500,
27127 534,
27128 566,
27129 598,
27130 630,
27131 662,
27132 694,
27133 726,
27134 758,
27135 790,
27136 822,
27137 854,
27138 886,
27139 920,
27140 952,
27141 984,
27142 1016,
27143 1048,
27144 1080
27145 ]);
27146 function DecodeWindowBits(br) {
27147 var n3;
27148 if (br.readBits(1) === 0) {
27149 return 16;
27150 }
27151 n3 = br.readBits(3);
27152 if (n3 > 0) {
27153 return 17 + n3;
27154 }
27155 n3 = br.readBits(3);
27156 if (n3 > 0) {
27157 return 8 + n3;
27158 }
27159 return 17;
27160 }
27161 function DecodeVarLenUint8(br) {
27162 if (br.readBits(1)) {
27163 var nbits = br.readBits(3);
27164 if (nbits === 0) {
27165 return 1;
27166 } else {
27167 return br.readBits(nbits) + (1 << nbits);
27168 }
27169 }
27170 return 0;
27171 }
27172 function MetaBlockLength() {
27173 this.meta_block_length = 0;
27174 this.input_end = 0;
27175 this.is_uncompressed = 0;
27176 this.is_metadata = false;
27177 }
27178 function DecodeMetaBlockLength(br) {
27179 var out = new MetaBlockLength();
27180 var size_nibbles;
27181 var size_bytes;
27182 var i3;
27183 out.input_end = br.readBits(1);
27184 if (out.input_end && br.readBits(1)) {
27185 return out;
27186 }
27187 size_nibbles = br.readBits(2) + 4;
27188 if (size_nibbles === 7) {
27189 out.is_metadata = true;
27190 if (br.readBits(1) !== 0)
27191 throw new Error("Invalid reserved bit");
27192 size_bytes = br.readBits(2);
27193 if (size_bytes === 0) return out;
27194 for (i3 = 0; i3 < size_bytes; i3++) {
27195 var next_byte = br.readBits(8);
27196 if (i3 + 1 === size_bytes && size_bytes > 1 && next_byte === 0)
27197 throw new Error("Invalid size byte");
27198 out.meta_block_length |= next_byte << i3 * 8;
27199 }
27200 } else {
27201 for (i3 = 0; i3 < size_nibbles; ++i3) {
27202 var next_nibble = br.readBits(4);
27203 if (i3 + 1 === size_nibbles && size_nibbles > 4 && next_nibble === 0)
27204 throw new Error("Invalid size nibble");
27205 out.meta_block_length |= next_nibble << i3 * 4;
27206 }
27207 }
27208 ++out.meta_block_length;
27209 if (!out.input_end && !out.is_metadata) {
27210 out.is_uncompressed = br.readBits(1);
27211 }
27212 return out;
27213 }
27214 function ReadSymbol(table, index2, br) {
27215 var start_index = index2;
27216 var nbits;
27217 br.fillBitWindow();
27218 index2 += br.val_ >>> br.bit_pos_ & HUFFMAN_TABLE_MASK;
27219 nbits = table[index2].bits - HUFFMAN_TABLE_BITS;
27220 if (nbits > 0) {
27221 br.bit_pos_ += HUFFMAN_TABLE_BITS;
27222 index2 += table[index2].value;
27223 index2 += br.val_ >>> br.bit_pos_ & (1 << nbits) - 1;
27224 }
27225 br.bit_pos_ += table[index2].bits;
27226 return table[index2].value;
27227 }
27228 function ReadHuffmanCodeLengths(code_length_code_lengths, num_symbols, code_lengths, br) {
27229 var symbol = 0;
27230 var prev_code_len = kDefaultCodeLength;
27231 var repeat = 0;
27232 var repeat_code_len = 0;
27233 var space = 32768;
27234 var table = [];
27235 for (var i3 = 0; i3 < 32; i3++)
27236 table.push(new HuffmanCode(0, 0));
27237 BrotliBuildHuffmanTable(
27238 table,
27239 0,
27240 5,
27241 code_length_code_lengths,
27242 CODE_LENGTH_CODES
27243 );
27244 while (symbol < num_symbols && space > 0) {
27245 var p4 = 0;
27246 var code_len;
27247 br.readMoreInput();
27248 br.fillBitWindow();
27249 p4 += br.val_ >>> br.bit_pos_ & 31;
27250 br.bit_pos_ += table[p4].bits;
27251 code_len = table[p4].value & 255;
27252 if (code_len < kCodeLengthRepeatCode) {
27253 repeat = 0;
27254 code_lengths[symbol++] = code_len;
27255 if (code_len !== 0) {
27256 prev_code_len = code_len;
27257 space -= 32768 >> code_len;
27258 }
27259 } else {
27260 var extra_bits = code_len - 14;
27261 var old_repeat;
27262 var repeat_delta;
27263 var new_len = 0;
27264 if (code_len === kCodeLengthRepeatCode) {
27265 new_len = prev_code_len;
27266 }
27267 if (repeat_code_len !== new_len) {
27268 repeat = 0;
27269 repeat_code_len = new_len;
27270 }
27271 old_repeat = repeat;
27272 if (repeat > 0) {
27273 repeat -= 2;
27274 repeat <<= extra_bits;
27275 }
27276 repeat += br.readBits(extra_bits) + 3;
27277 repeat_delta = repeat - old_repeat;
27278 if (symbol + repeat_delta > num_symbols) {
27279 throw new Error(
27280 "[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols"
27281 );
27282 }
27283 for (var x2 = 0; x2 < repeat_delta; x2++)
27284 code_lengths[symbol + x2] = repeat_code_len;
27285 symbol += repeat_delta;
27286 if (repeat_code_len !== 0) {
27287 space -= repeat_delta << 15 - repeat_code_len;
27288 }
27289 }
27290 }
27291 if (space !== 0) {
27292 throw new Error(
27293 "[ReadHuffmanCodeLengths] space = " + space
27294 );
27295 }
27296 for (; symbol < num_symbols; symbol++)
27297 code_lengths[symbol] = 0;
27298 }
27299 function ReadHuffmanCode(alphabet_size, tables, table, br) {
27300 var table_size = 0;
27301 var simple_code_or_skip;
27302 var code_lengths = new Uint8Array(alphabet_size);
27303 br.readMoreInput();
27304 simple_code_or_skip = br.readBits(2);
27305 if (simple_code_or_skip === 1) {
27306 var i3;
27307 var max_bits_counter = alphabet_size - 1;
27308 var max_bits = 0;
27309 var symbols = new Int32Array(4);
27310 var num_symbols = br.readBits(2) + 1;
27311 while (max_bits_counter) {
27312 max_bits_counter >>= 1;
27313 ++max_bits;
27314 }
27315 for (i3 = 0; i3 < num_symbols; ++i3) {
27316 symbols[i3] = br.readBits(max_bits) % alphabet_size;
27317 code_lengths[symbols[i3]] = 2;
27318 }
27319 code_lengths[symbols[0]] = 1;
27320 switch (num_symbols) {
27321 case 1:
27322 break;
27323 case 3:
27324 if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[1] === symbols[2]) {
27325 throw new Error(
27326 "[ReadHuffmanCode] invalid symbols"
27327 );
27328 }
27329 break;
27330 case 2:
27331 if (symbols[0] === symbols[1]) {
27332 throw new Error(
27333 "[ReadHuffmanCode] invalid symbols"
27334 );
27335 }
27336 code_lengths[symbols[1]] = 1;
27337 break;
27338 case 4:
27339 if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[0] === symbols[3] || symbols[1] === symbols[2] || symbols[1] === symbols[3] || symbols[2] === symbols[3]) {
27340 throw new Error(
27341 "[ReadHuffmanCode] invalid symbols"
27342 );
27343 }
27344 if (br.readBits(1)) {
27345 code_lengths[symbols[2]] = 3;
27346 code_lengths[symbols[3]] = 3;
27347 } else {
27348 code_lengths[symbols[0]] = 2;
27349 }
27350 break;
27351 }
27352 } else {
27353 var i3;
27354 var code_length_code_lengths = new Uint8Array(
27355 CODE_LENGTH_CODES
27356 );
27357 var space = 32;
27358 var num_codes = 0;
27359 var huff = [
27360 new HuffmanCode(2, 0),
27361 new HuffmanCode(2, 4),
27362 new HuffmanCode(2, 3),
27363 new HuffmanCode(3, 2),
27364 new HuffmanCode(2, 0),
27365 new HuffmanCode(2, 4),
27366 new HuffmanCode(2, 3),
27367 new HuffmanCode(4, 1),
27368 new HuffmanCode(2, 0),
27369 new HuffmanCode(2, 4),
27370 new HuffmanCode(2, 3),
27371 new HuffmanCode(3, 2),
27372 new HuffmanCode(2, 0),
27373 new HuffmanCode(2, 4),
27374 new HuffmanCode(2, 3),
27375 new HuffmanCode(4, 5)
27376 ];
27377 for (i3 = simple_code_or_skip; i3 < CODE_LENGTH_CODES && space > 0; ++i3) {
27378 var code_len_idx = kCodeLengthCodeOrder[i3];
27379 var p4 = 0;
27380 var v3;
27381 br.fillBitWindow();
27382 p4 += br.val_ >>> br.bit_pos_ & 15;
27383 br.bit_pos_ += huff[p4].bits;
27384 v3 = huff[p4].value;
27385 code_length_code_lengths[code_len_idx] = v3;
27386 if (v3 !== 0) {
27387 space -= 32 >> v3;
27388 ++num_codes;
27389 }
27390 }
27391 if (!(num_codes === 1 || space === 0))
27392 throw new Error(
27393 "[ReadHuffmanCode] invalid num_codes or space"
27394 );
27395 ReadHuffmanCodeLengths(
27396 code_length_code_lengths,
27397 alphabet_size,
27398 code_lengths,
27399 br
27400 );
27401 }
27402 table_size = BrotliBuildHuffmanTable(
27403 tables,
27404 table,
27405 HUFFMAN_TABLE_BITS,
27406 code_lengths,
27407 alphabet_size
27408 );
27409 if (table_size === 0) {
27410 throw new Error(
27411 "[ReadHuffmanCode] BuildHuffmanTable failed: "
27412 );
27413 }
27414 return table_size;
27415 }
27416 function ReadBlockLength(table, index2, br) {
27417 var code;
27418 var nbits;
27419 code = ReadSymbol(table, index2, br);
27420 nbits = Prefix.kBlockLengthPrefixCode[code].nbits;
27421 return Prefix.kBlockLengthPrefixCode[code].offset + br.readBits(nbits);
27422 }
27423 function TranslateShortCodes(code, ringbuffer, index2) {
27424 var val;
27425 if (code < NUM_DISTANCE_SHORT_CODES) {
27426 index2 += kDistanceShortCodeIndexOffset[code];
27427 index2 &= 3;
27428 val = ringbuffer[index2] + kDistanceShortCodeValueOffset[code];
27429 } else {
27430 val = code - NUM_DISTANCE_SHORT_CODES + 1;
27431 }
27432 return val;
27433 }
27434 function MoveToFront(v3, index2) {
27435 var value = v3[index2];
27436 var i3 = index2;
27437 for (; i3; --i3) v3[i3] = v3[i3 - 1];
27438 v3[0] = value;
27439 }
27440 function InverseMoveToFrontTransform(v3, v_len) {
27441 var mtf = new Uint8Array(256);
27442 var i3;
27443 for (i3 = 0; i3 < 256; ++i3) {
27444 mtf[i3] = i3;
27445 }
27446 for (i3 = 0; i3 < v_len; ++i3) {
27447 var index2 = v3[i3];
27448 v3[i3] = mtf[index2];
27449 if (index2) MoveToFront(mtf, index2);
27450 }
27451 }
27452 function HuffmanTreeGroup(alphabet_size, num_htrees) {
27453 this.alphabet_size = alphabet_size;
27454 this.num_htrees = num_htrees;
27455 this.codes = new Array(
27456 num_htrees + num_htrees * kMaxHuffmanTableSize[alphabet_size + 31 >>> 5]
27457 );
27458 this.htrees = new Uint32Array(num_htrees);
27459 }
27460 HuffmanTreeGroup.prototype.decode = function(br) {
27461 var i3;
27462 var table_size;
27463 var next = 0;
27464 for (i3 = 0; i3 < this.num_htrees; ++i3) {
27465 this.htrees[i3] = next;
27466 table_size = ReadHuffmanCode(
27467 this.alphabet_size,
27468 this.codes,
27469 next,
27470 br
27471 );
27472 next += table_size;
27473 }
27474 };
27475 function DecodeContextMap(context_map_size, br) {
27476 var out = { num_htrees: null, context_map: null };
27477 var use_rle_for_zeros;
27478 var max_run_length_prefix = 0;
27479 var table;
27480 var i3;
27481 br.readMoreInput();
27482 var num_htrees = out.num_htrees = DecodeVarLenUint8(br) + 1;
27483 var context_map = out.context_map = new Uint8Array(
27484 context_map_size
27485 );
27486 if (num_htrees <= 1) {
27487 return out;
27488 }
27489 use_rle_for_zeros = br.readBits(1);
27490 if (use_rle_for_zeros) {
27491 max_run_length_prefix = br.readBits(4) + 1;
27492 }
27493 table = [];
27494 for (i3 = 0; i3 < HUFFMAN_MAX_TABLE_SIZE; i3++) {
27495 table[i3] = new HuffmanCode(0, 0);
27496 }
27497 ReadHuffmanCode(
27498 num_htrees + max_run_length_prefix,
27499 table,
27500 0,
27501 br
27502 );
27503 for (i3 = 0; i3 < context_map_size; ) {
27504 var code;
27505 br.readMoreInput();
27506 code = ReadSymbol(table, 0, br);
27507 if (code === 0) {
27508 context_map[i3] = 0;
27509 ++i3;
27510 } else if (code <= max_run_length_prefix) {
27511 var reps = 1 + (1 << code) + br.readBits(code);
27512 while (--reps) {
27513 if (i3 >= context_map_size) {
27514 throw new Error(
27515 "[DecodeContextMap] i >= context_map_size"
27516 );
27517 }
27518 context_map[i3] = 0;
27519 ++i3;
27520 }
27521 } else {
27522 context_map[i3] = code - max_run_length_prefix;
27523 ++i3;
27524 }
27525 }
27526 if (br.readBits(1)) {
27527 InverseMoveToFrontTransform(
27528 context_map,
27529 context_map_size
27530 );
27531 }
27532 return out;
27533 }
27534 function DecodeBlockType(max_block_type, trees, tree_type, block_types, ringbuffers, indexes, br) {
27535 var ringbuffer = tree_type * 2;
27536 var index2 = tree_type;
27537 var type_code = ReadSymbol(
27538 trees,
27539 tree_type * HUFFMAN_MAX_TABLE_SIZE,
27540 br
27541 );
27542 var block_type;
27543 if (type_code === 0) {
27544 block_type = ringbuffers[ringbuffer + (indexes[index2] & 1)];
27545 } else if (type_code === 1) {
27546 block_type = ringbuffers[ringbuffer + (indexes[index2] - 1 & 1)] + 1;
27547 } else {
27548 block_type = type_code - 2;
27549 }
27550 if (block_type >= max_block_type) {
27551 block_type -= max_block_type;
27552 }
27553 block_types[tree_type] = block_type;
27554 ringbuffers[ringbuffer + (indexes[index2] & 1)] = block_type;
27555 ++indexes[index2];
27556 }
27557 function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_mask, br) {
27558 var rb_size = ringbuffer_mask + 1;
27559 var rb_pos = pos & ringbuffer_mask;
27560 var br_pos = br.pos_ & BrotliBitReader.IBUF_MASK;
27561 var nbytes;
27562 if (len < 8 || br.bit_pos_ + (len << 3) < br.bit_end_pos_) {
27563 while (len-- > 0) {
27564 br.readMoreInput();
27565 ringbuffer[rb_pos++] = br.readBits(8);
27566 if (rb_pos === rb_size) {
27567 output.write(ringbuffer, rb_size);
27568 rb_pos = 0;
27569 }
27570 }
27571 return;
27572 }
27573 if (br.bit_end_pos_ < 32) {
27574 throw new Error(
27575 "[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32"
27576 );
27577 }
27578 while (br.bit_pos_ < 32) {
27579 ringbuffer[rb_pos] = br.val_ >>> br.bit_pos_;
27580 br.bit_pos_ += 8;
27581 ++rb_pos;
27582 --len;
27583 }
27584 nbytes = br.bit_end_pos_ - br.bit_pos_ >> 3;
27585 if (br_pos + nbytes > BrotliBitReader.IBUF_MASK) {
27586 var tail = BrotliBitReader.IBUF_MASK + 1 - br_pos;
27587 for (var x2 = 0; x2 < tail; x2++)
27588 ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2];
27589 nbytes -= tail;
27590 rb_pos += tail;
27591 len -= tail;
27592 br_pos = 0;
27593 }
27594 for (var x2 = 0; x2 < nbytes; x2++)
27595 ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2];
27596 rb_pos += nbytes;
27597 len -= nbytes;
27598 if (rb_pos >= rb_size) {
27599 output.write(ringbuffer, rb_size);
27600 rb_pos -= rb_size;
27601 for (var x2 = 0; x2 < rb_pos; x2++)
27602 ringbuffer[x2] = ringbuffer[rb_size + x2];
27603 }
27604 while (rb_pos + len >= rb_size) {
27605 nbytes = rb_size - rb_pos;
27606 if (br.input_.read(ringbuffer, rb_pos, nbytes) < nbytes) {
27607 throw new Error(
27608 "[CopyUncompressedBlockToOutput] not enough bytes"
27609 );
27610 }
27611 output.write(ringbuffer, rb_size);
27612 len -= nbytes;
27613 rb_pos = 0;
27614 }
27615 if (br.input_.read(ringbuffer, rb_pos, len) < len) {
27616 throw new Error(
27617 "[CopyUncompressedBlockToOutput] not enough bytes"
27618 );
27619 }
27620 br.reset();
27621 }
27622 function JumpToByteBoundary(br) {
27623 var new_bit_pos = br.bit_pos_ + 7 & ~7;
27624 var pad_bits = br.readBits(new_bit_pos - br.bit_pos_);
27625 return pad_bits == 0;
27626 }
27627 function BrotliDecompressedSize(buffer) {
27628 var input = new BrotliInput(buffer);
27629 var br = new BrotliBitReader(input);
27630 DecodeWindowBits(br);
27631 var out = DecodeMetaBlockLength(br);
27632 return out.meta_block_length;
27633 }
27634 exports2.BrotliDecompressedSize = BrotliDecompressedSize;
27635 function BrotliDecompressBuffer(buffer, output_size) {
27636 var input = new BrotliInput(buffer);
27637 if (output_size == null) {
27638 output_size = BrotliDecompressedSize(buffer);
27639 }
27640 var output_buffer = new Uint8Array(output_size);
27641 var output = new BrotliOutput(output_buffer);
27642 BrotliDecompress(input, output);
27643 if (output.pos < output.buffer.length) {
27644 output.buffer = output.buffer.subarray(
27645 0,
27646 output.pos
27647 );
27648 }
27649 return output.buffer;
27650 }
27651 exports2.BrotliDecompressBuffer = BrotliDecompressBuffer;
27652 function BrotliDecompress(input, output) {
27653 var i3;
27654 var pos = 0;
27655 var input_end = 0;
27656 var window_bits = 0;
27657 var max_backward_distance;
27658 var max_distance = 0;
27659 var ringbuffer_size;
27660 var ringbuffer_mask;
27661 var ringbuffer;
27662 var ringbuffer_end;
27663 var dist_rb = [16, 15, 11, 4];
27664 var dist_rb_idx = 0;
27665 var prev_byte1 = 0;
27666 var prev_byte2 = 0;
27667 var hgroup = [
27668 new HuffmanTreeGroup(0, 0),
27669 new HuffmanTreeGroup(0, 0),
27670 new HuffmanTreeGroup(0, 0)
27671 ];
27672 var block_type_trees;
27673 var block_len_trees;
27674 var br;
27675 var kRingBufferWriteAheadSlack = 128 + BrotliBitReader.READ_SIZE;
27676 br = new BrotliBitReader(input);
27677 window_bits = DecodeWindowBits(br);
27678 max_backward_distance = (1 << window_bits) - 16;
27679 ringbuffer_size = 1 << window_bits;
27680 ringbuffer_mask = ringbuffer_size - 1;
27681 ringbuffer = new Uint8Array(
27682 ringbuffer_size + kRingBufferWriteAheadSlack + BrotliDictionary.maxDictionaryWordLength
27683 );
27684 ringbuffer_end = ringbuffer_size;
27685 block_type_trees = [];
27686 block_len_trees = [];
27687 for (var x2 = 0; x2 < 3 * HUFFMAN_MAX_TABLE_SIZE; x2++) {
27688 block_type_trees[x2] = new HuffmanCode(0, 0);
27689 block_len_trees[x2] = new HuffmanCode(0, 0);
27690 }
27691 while (!input_end) {
27692 var meta_block_remaining_len = 0;
27693 var is_uncompressed;
27694 var block_length = [1 << 28, 1 << 28, 1 << 28];
27695 var block_type = [0];
27696 var num_block_types = [1, 1, 1];
27697 var block_type_rb = [0, 1, 0, 1, 0, 1];
27698 var block_type_rb_index = [0];
27699 var distance_postfix_bits;
27700 var num_direct_distance_codes;
27701 var distance_postfix_mask;
27702 var num_distance_codes;
27703 var context_map = null;
27704 var context_modes = null;
27705 var num_literal_htrees;
27706 var dist_context_map = null;
27707 var num_dist_htrees;
27708 var context_offset = 0;
27709 var context_map_slice = null;
27710 var literal_htree_index = 0;
27711 var dist_context_offset = 0;
27712 var dist_context_map_slice = null;
27713 var dist_htree_index = 0;
27714 var context_lookup_offset1 = 0;
27715 var context_lookup_offset2 = 0;
27716 var context_mode;
27717 var htree_command;
27718 for (i3 = 0; i3 < 3; ++i3) {
27719 hgroup[i3].codes = null;
27720 hgroup[i3].htrees = null;
27721 }
27722 br.readMoreInput();
27723 var _out = DecodeMetaBlockLength(br);
27724 meta_block_remaining_len = _out.meta_block_length;
27725 if (pos + meta_block_remaining_len > output.buffer.length) {
27726 var tmp = new Uint8Array(
27727 pos + meta_block_remaining_len
27728 );
27729 tmp.set(output.buffer);
27730 output.buffer = tmp;
27731 }
27732 input_end = _out.input_end;
27733 is_uncompressed = _out.is_uncompressed;
27734 if (_out.is_metadata) {
27735 JumpToByteBoundary(br);
27736 for (; meta_block_remaining_len > 0; --meta_block_remaining_len) {
27737 br.readMoreInput();
27738 br.readBits(8);
27739 }
27740 continue;
27741 }
27742 if (meta_block_remaining_len === 0) {
27743 continue;
27744 }
27745 if (is_uncompressed) {
27746 br.bit_pos_ = br.bit_pos_ + 7 & ~7;
27747 CopyUncompressedBlockToOutput(
27748 output,
27749 meta_block_remaining_len,
27750 pos,
27751 ringbuffer,
27752 ringbuffer_mask,
27753 br
27754 );
27755 pos += meta_block_remaining_len;
27756 continue;
27757 }
27758 for (i3 = 0; i3 < 3; ++i3) {
27759 num_block_types[i3] = DecodeVarLenUint8(br) + 1;
27760 if (num_block_types[i3] >= 2) {
27761 ReadHuffmanCode(
27762 num_block_types[i3] + 2,
27763 block_type_trees,
27764 i3 * HUFFMAN_MAX_TABLE_SIZE,
27765 br
27766 );
27767 ReadHuffmanCode(
27768 kNumBlockLengthCodes,
27769 block_len_trees,
27770 i3 * HUFFMAN_MAX_TABLE_SIZE,
27771 br
27772 );
27773 block_length[i3] = ReadBlockLength(
27774 block_len_trees,
27775 i3 * HUFFMAN_MAX_TABLE_SIZE,
27776 br
27777 );
27778 block_type_rb_index[i3] = 1;
27779 }
27780 }
27781 br.readMoreInput();
27782 distance_postfix_bits = br.readBits(2);
27783 num_direct_distance_codes = NUM_DISTANCE_SHORT_CODES + (br.readBits(4) << distance_postfix_bits);
27784 distance_postfix_mask = (1 << distance_postfix_bits) - 1;
27785 num_distance_codes = num_direct_distance_codes + (48 << distance_postfix_bits);
27786 context_modes = new Uint8Array(
27787 num_block_types[0]
27788 );
27789 for (i3 = 0; i3 < num_block_types[0]; ++i3) {
27790 br.readMoreInput();
27791 context_modes[i3] = br.readBits(2) << 1;
27792 }
27793 var _o1 = DecodeContextMap(
27794 num_block_types[0] << kLiteralContextBits,
27795 br
27796 );
27797 num_literal_htrees = _o1.num_htrees;
27798 context_map = _o1.context_map;
27799 var _o2 = DecodeContextMap(
27800 num_block_types[2] << kDistanceContextBits,
27801 br
27802 );
27803 num_dist_htrees = _o2.num_htrees;
27804 dist_context_map = _o2.context_map;
27805 hgroup[0] = new HuffmanTreeGroup(
27806 kNumLiteralCodes,
27807 num_literal_htrees
27808 );
27809 hgroup[1] = new HuffmanTreeGroup(
27810 kNumInsertAndCopyCodes,
27811 num_block_types[1]
27812 );
27813 hgroup[2] = new HuffmanTreeGroup(
27814 num_distance_codes,
27815 num_dist_htrees
27816 );
27817 for (i3 = 0; i3 < 3; ++i3) {
27818 hgroup[i3].decode(br);
27819 }
27820 context_map_slice = 0;
27821 dist_context_map_slice = 0;
27822 context_mode = context_modes[block_type[0]];
27823 context_lookup_offset1 = Context.lookupOffsets[context_mode];
27824 context_lookup_offset2 = Context.lookupOffsets[context_mode + 1];
27825 htree_command = hgroup[1].htrees[0];
27826 while (meta_block_remaining_len > 0) {
27827 var cmd_code;
27828 var range_idx;
27829 var insert_code;
27830 var copy_code;
27831 var insert_length;
27832 var copy_length;
27833 var distance_code;
27834 var distance;
27835 var context;
27836 var j2;
27837 var copy_dst;
27838 br.readMoreInput();
27839 if (block_length[1] === 0) {
27840 DecodeBlockType(
27841 num_block_types[1],
27842 block_type_trees,
27843 1,
27844 block_type,
27845 block_type_rb,
27846 block_type_rb_index,
27847 br
27848 );
27849 block_length[1] = ReadBlockLength(
27850 block_len_trees,
27851 HUFFMAN_MAX_TABLE_SIZE,
27852 br
27853 );
27854 htree_command = hgroup[1].htrees[block_type[1]];
27855 }
27856 --block_length[1];
27857 cmd_code = ReadSymbol(
27858 hgroup[1].codes,
27859 htree_command,
27860 br
27861 );
27862 range_idx = cmd_code >> 6;
27863 if (range_idx >= 2) {
27864 range_idx -= 2;
27865 distance_code = -1;
27866 } else {
27867 distance_code = 0;
27868 }
27869 insert_code = Prefix.kInsertRangeLut[range_idx] + (cmd_code >> 3 & 7);
27870 copy_code = Prefix.kCopyRangeLut[range_idx] + (cmd_code & 7);
27871 insert_length = Prefix.kInsertLengthPrefixCode[insert_code].offset + br.readBits(
27872 Prefix.kInsertLengthPrefixCode[insert_code].nbits
27873 );
27874 copy_length = Prefix.kCopyLengthPrefixCode[copy_code].offset + br.readBits(
27875 Prefix.kCopyLengthPrefixCode[copy_code].nbits
27876 );
27877 prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask];
27878 prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask];
27879 for (j2 = 0; j2 < insert_length; ++j2) {
27880 br.readMoreInput();
27881 if (block_length[0] === 0) {
27882 DecodeBlockType(
27883 num_block_types[0],
27884 block_type_trees,
27885 0,
27886 block_type,
27887 block_type_rb,
27888 block_type_rb_index,
27889 br
27890 );
27891 block_length[0] = ReadBlockLength(
27892 block_len_trees,
27893 0,
27894 br
27895 );
27896 context_offset = block_type[0] << kLiteralContextBits;
27897 context_map_slice = context_offset;
27898 context_mode = context_modes[block_type[0]];
27899 context_lookup_offset1 = Context.lookupOffsets[context_mode];
27900 context_lookup_offset2 = Context.lookupOffsets[context_mode + 1];
27901 }
27902 context = Context.lookup[context_lookup_offset1 + prev_byte1] | Context.lookup[context_lookup_offset2 + prev_byte2];
27903 literal_htree_index = context_map[context_map_slice + context];
27904 --block_length[0];
27905 prev_byte2 = prev_byte1;
27906 prev_byte1 = ReadSymbol(
27907 hgroup[0].codes,
27908 hgroup[0].htrees[literal_htree_index],
27909 br
27910 );
27911 ringbuffer[pos & ringbuffer_mask] = prev_byte1;
27912 if ((pos & ringbuffer_mask) === ringbuffer_mask) {
27913 output.write(
27914 ringbuffer,
27915 ringbuffer_size
27916 );
27917 }
27918 ++pos;
27919 }
27920 meta_block_remaining_len -= insert_length;
27921 if (meta_block_remaining_len <= 0) break;
27922 if (distance_code < 0) {
27923 var context;
27924 br.readMoreInput();
27925 if (block_length[2] === 0) {
27926 DecodeBlockType(
27927 num_block_types[2],
27928 block_type_trees,
27929 2,
27930 block_type,
27931 block_type_rb,
27932 block_type_rb_index,
27933 br
27934 );
27935 block_length[2] = ReadBlockLength(
27936 block_len_trees,
27937 2 * HUFFMAN_MAX_TABLE_SIZE,
27938 br
27939 );
27940 dist_context_offset = block_type[2] << kDistanceContextBits;
27941 dist_context_map_slice = dist_context_offset;
27942 }
27943 --block_length[2];
27944 context = (copy_length > 4 ? 3 : copy_length - 2) & 255;
27945 dist_htree_index = dist_context_map[dist_context_map_slice + context];
27946 distance_code = ReadSymbol(
27947 hgroup[2].codes,
27948 hgroup[2].htrees[dist_htree_index],
27949 br
27950 );
27951 if (distance_code >= num_direct_distance_codes) {
27952 var nbits;
27953 var postfix;
27954 var offset3;
27955 distance_code -= num_direct_distance_codes;
27956 postfix = distance_code & distance_postfix_mask;
27957 distance_code >>= distance_postfix_bits;
27958 nbits = (distance_code >> 1) + 1;
27959 offset3 = (2 + (distance_code & 1) << nbits) - 4;
27960 distance_code = num_direct_distance_codes + (offset3 + br.readBits(nbits) << distance_postfix_bits) + postfix;
27961 }
27962 }
27963 distance = TranslateShortCodes(
27964 distance_code,
27965 dist_rb,
27966 dist_rb_idx
27967 );
27968 if (distance < 0) {
27969 throw new Error(
27970 "[BrotliDecompress] invalid distance"
27971 );
27972 }
27973 if (pos < max_backward_distance && max_distance !== max_backward_distance) {
27974 max_distance = pos;
27975 } else {
27976 max_distance = max_backward_distance;
27977 }
27978 copy_dst = pos & ringbuffer_mask;
27979 if (distance > max_distance) {
27980 if (copy_length >= BrotliDictionary.minDictionaryWordLength && copy_length <= BrotliDictionary.maxDictionaryWordLength) {
27981 var offset3 = BrotliDictionary.offsetsByLength[copy_length];
27982 var word_id = distance - max_distance - 1;
27983 var shift3 = BrotliDictionary.sizeBitsByLength[copy_length];
27984 var mask = (1 << shift3) - 1;
27985 var word_idx = word_id & mask;
27986 var transform_idx = word_id >> shift3;
27987 offset3 += word_idx * copy_length;
27988 if (transform_idx < Transform.kNumTransforms) {
27989 var len = Transform.transformDictionaryWord(
27990 ringbuffer,
27991 copy_dst,
27992 offset3,
27993 copy_length,
27994 transform_idx
27995 );
27996 copy_dst += len;
27997 pos += len;
27998 meta_block_remaining_len -= len;
27999 if (copy_dst >= ringbuffer_end) {
28000 output.write(
28001 ringbuffer,
28002 ringbuffer_size
28003 );
28004 for (var _x44 = 0; _x44 < copy_dst - ringbuffer_end; _x44++)
28005 ringbuffer[_x44] = ringbuffer[ringbuffer_end + _x44];
28006 }
28007 } else {
28008 throw new Error(
28009 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
28010 );
28011 }
28012 } else {
28013 throw new Error(
28014 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
28015 );
28016 }
28017 } else {
28018 if (distance_code > 0) {
28019 dist_rb[dist_rb_idx & 3] = distance;
28020 ++dist_rb_idx;
28021 }
28022 if (copy_length > meta_block_remaining_len) {
28023 throw new Error(
28024 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
28025 );
28026 }
28027 for (j2 = 0; j2 < copy_length; ++j2) {
28028 ringbuffer[pos & ringbuffer_mask] = ringbuffer[pos - distance & ringbuffer_mask];
28029 if ((pos & ringbuffer_mask) === ringbuffer_mask) {
28030 output.write(
28031 ringbuffer,
28032 ringbuffer_size
28033 );
28034 }
28035 ++pos;
28036 --meta_block_remaining_len;
28037 }
28038 }
28039 prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask];
28040 prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask];
28041 }
28042 pos &= 1073741823;
28043 }
28044 output.write(ringbuffer, pos & ringbuffer_mask);
28045 }
28046 exports2.BrotliDecompress = BrotliDecompress;
28047 BrotliDictionary.init();
28048 },
28049 {
28050 "./bit_reader": 1,
28051 "./context": 2,
28052 "./dictionary": 6,
28053 "./huffman": 7,
28054 "./prefix": 9,
28055 "./streams": 10,
28056 "./transform": 11
28057 }
28058 ],
28059 4: [
28060 function(require2, module2, exports2) {
28061 var base64 = require2("base64-js");
28062 exports2.init = function() {
28063 var BrotliDecompressBuffer = require2("./decode").BrotliDecompressBuffer;
28064 var compressed = base64.toByteArray(
28065 require2("./dictionary.bin.js")
28066 );
28067 return BrotliDecompressBuffer(compressed);
28068 };
28069 },
28070 { "./decode": 3, "./dictionary.bin.js": 5, "base64-js": 8 }
28071 ],
28072 5: [
28073 function(require2, module2, exports2) {
28074 module2.exports = "W5/fcQLn5gKf2XUbAiQ1XULX+TZz6ADToDsgqk6qVfeC0e4m6OO2wcQ1J76ZBVRV1fRkEsdu//62zQsFEZWSTCnMhcsQKlS2qOhuVYYMGCkV0fXWEoMFbESXrKEZ9wdUEsyw9g4bJlEt1Y6oVMxMRTEVbCIwZzJzboK5j8m4YH02qgXYhv1V+PM435sLVxyHJihaJREEhZGqL03txGFQLm76caGO/ovxKvzCby/3vMTtX/459f0igi7WutnKiMQ6wODSoRh/8Lx1V3Q99MvKtwB6bHdERYRY0hStJoMjNeTsNX7bn+Y7e4EQ3bf8xBc7L0BsyfFPK43dGSXpL6clYC/I328h54/VYrQ5i0648FgbGtl837svJ35L3Mot/+nPlNpWgKx1gGXQYqX6n+bbZ7wuyCHKcUok12Xjqub7NXZGzqBx0SD+uziNf87t7ve42jxSKQoW3nyxVrWIGlFShhCKxjpZZ5MeGna0+lBkk+kaN8F9qFBAFgEogyMBdcX/T1W/WnMOi/7ycWUQloEBKGeC48MkiwqJkJO+12eQiOFHMmck6q/IjWW3RZlany23TBm+cNr/84/oi5GGmGBZWrZ6j+zykVozz5fT/QH/Da6WTbZYYPynVNO7kxzuNN2kxKKWche5WveitPKAecB8YcAHz/+zXLjcLzkdDSktNIDwZE9J9X+tto43oJy65wApM3mDzYtCwX9lM+N5VR3kXYo0Z3t0TtXfgBFg7gU8oN0Dgl7fZlUbhNll+0uuohRVKjrEd8egrSndy5/Tgd2gqjA4CAVuC7ESUmL3DZoGnfhQV8uwnpi8EGvAVVsowNRxPudck7+oqAUDkwZopWqFnW1riss0t1z6iCISVKreYGNvQcXv+1L9+jbP8cd/dPUiqBso2q+7ZyFBvENCkkVr44iyPbtOoOoCecWsiuqMSML5lv+vN5MzUr+Dnh73G7Q1YnRYJVYXHRJaNAOByiaK6CusgFdBPE40r0rvqXV7tksKO2DrHYXBTv8P5ysqxEx8VDXUDDqkPH6NNOV/a2WH8zlkXRELSa8P+heNyJBBP7PgsG1EtWtNef6/i+lcayzQwQCsduidpbKfhWUDgAEmyhGu/zVTacI6RS0zTABrOYueemnVa19u9fT23N/Ta6RvTpof5DWygqreCqrDAgM4LID1+1T/taU6yTFVLqXOv+/MuQOFnaF8vLMKD7tKWDoBdALgxF33zQccCcdHx8fKIVdW69O7qHtXpeGr9jbbpFA+qRMWr5hp0s67FPc7HAiLV0g0/peZlW7hJPYEhZyhpSwahnf93/tZgfqZWXFdmdXBzqxGHLrQKxoAY6fRoBhgCRPmmGueYZ5JexTVDKUIXzkG/fqp/0U3hAgQdJ9zumutK6nqWbaqvm1pgu03IYR+G+8s0jDBBz8cApZFSBeuWasyqo2OMDKAZCozS+GWSvL/HsE9rHxooe17U3s/lTE+VZAk4j3dp6uIGaC0JMiqR5CUsabPyM0dOYDR7Ea7ip4USZlya38YfPtvrX/tBlhHilj55nZ1nfN24AOAi9BVtz/Mbn8AEDJCqJgsVUa6nQnSxv2Fs7l/NlCzpfYEjmPrNyib/+t0ei2eEMjvNhLkHCZlci4WhBe7ePZTmzYqlY9+1pxtS4GB+5lM1BHT9tS270EWUDYFq1I0yY/fNiAk4bk9yBgmef/f2k6AlYQZHsNFnW8wBQxCd68iWv7/35bXfz3JZmfGligWAKRjIs3IpzxQ27vAglHSiOzCYzJ9L9A1CdiyFvyR66ucA4jKifu5ehwER26yV7HjKqn5Mfozo7Coxxt8LWWPT47BeMxX8p0Pjb7hZn+6bw7z3Lw+7653j5sI8CLu5kThpMlj1m4c2ch3jGcP1FsT13vuK3qjecKTZk2kHcOZY40UX+qdaxstZqsqQqgXz+QGF99ZJLqr3VYu4aecl1Ab5GmqS8k/GV5b95zxQ5d4EfXUJ6kTS/CXF/aiqKDOT1T7Jz5z0PwDUcwr9clLN1OJGCiKfqvah+h3XzrBOiLOW8wvn8gW6qE8vPxi+Efv+UH55T7PQFVMh6cZ1pZQlzJpKZ7P7uWvwPGJ6DTlR6wbyj3Iv2HyefnRo/dv7dNx+qaa0N38iBsR++Uil7Wd4afwDNsrzDAK4fXZwvEY/jdKuIKXlfrQd2C39dW7ntnRbIp9OtGy9pPBn/V2ASoi/2UJZfS+xuGLH8bnLuPlzdTNS6zdyk8Dt/h6sfOW5myxh1f+zf3zZ3MX/mO9cQPp5pOx967ZA6/pqHvclNfnUFF+rq+Vd7alKr6KWPcIDhpn6v2K6NlUu6LrKo8b/pYpU/Gazfvtwhn7tEOUuXht5rUJdSf6sLjYf0VTYDgwJ81yaqKTUYej/tbHckSRb/HZicwGJqh1mAHB/IuNs9dc9yuvF3D5Xocm3elWFdq5oEy70dYFit79yaLiNjPj5UUcVmZUVhQEhW5V2Z6Cm4HVH/R8qlamRYwBileuh07CbEce3TXa2JmXWBf+ozt319psboobeZhVnwhMZzOeQJzhpTDbP71Tv8HuZxxUI/+ma3XW6DFDDs4+qmpERwHGBd2edxwUKlODRdUWZ/g0GOezrbzOZauFMai4QU6GVHV6aPNBiBndHSsV4IzpvUiiYyg6OyyrL4Dj5q/Lw3N5kAwftEVl9rNd7Jk5PDij2hTH6wIXnsyXkKePxbmHYgC8A6an5Fob/KH5GtC0l4eFso+VpxedtJHdHpNm+Bvy4C79yVOkrZsLrQ3OHCeB0Ra+kBIRldUGlDCEmq2RwXnfyh6Dz+alk6eftI2n6sastRrGwbwszBeDRS/Fa/KwRJkCzTsLr/JCs5hOPE/MPLYdZ1F1fv7D+VmysX6NpOC8aU9F4Qs6HvDyUy9PvFGDKZ/P5101TYHFl8pjj6wm/qyS75etZhhfg0UEL4OYmHk6m6dO192AzoIyPSV9QedDA4Ml23rRbqxMPMxf7FJnDc5FTElVS/PyqgePzmwVZ26NWhRDQ+oaT7ly7ell4s3DypS1s0g+tOr7XHrrkZj9+x/mJBttrLx98lFIaRZzHz4aC7r52/JQ4VjHahY2/YVXZn/QC2ztQb/sY3uRlyc5vQS8nLPGT/n27495i8HPA152z7Fh5aFpyn1GPJKHuPL8Iw94DuW3KjkURAWZXn4EQy89xiKEHN1mk/tkM4gYDBxwNoYvRfE6LFqsxWJtPrDGbsnLMap3Ka3MUoytW0cvieozOmdERmhcqzG+3HmZv2yZeiIeQTKGdRT4HHNxekm1tY+/n06rGmFleqLscSERzctTKM6G9P0Pc1RmVvrascIxaO1CQCiYPE15bD7c3xSeW7gXxYjgxcrUlcbIvO0r+Yplhx0kTt3qafDOmFyMjgGxXu73rddMHpV1wMubyAGcf/v5dLr5P72Ta9lBF+fzMJrMycwv+9vnU3ANIl1cH9tfW7af8u0/HG0vV47jNFXzFTtaha1xvze/s8KMtCYucXc1nzfd/MQydUXn/b72RBt5wO/3jRcMH9BdhC/yctKBIveRYPrNpDWqBsO8VMmP+WvRaOcA4zRMR1PvSoO92rS7pYEv+fZfEfTMzEdM+6X5tLlyxExhqLRkms5EuLovLfx66de5fL2/yX02H52FPVwahrPqmN/E0oVXnsCKhbi/yRxX83nRbUKWhzYceXOntfuXn51NszJ6MO73pQf5Pl4in3ec4JU8hF7ppV34+mm9r1LY0ee/i1O1wpd8+zfLztE0cqBxggiBi5Bu95v9l3r9r/U5hweLn+TbfxowrWDqdJauKd8+q/dH8sbPkc9ttuyO94f7/XK/nHX46MPFLEb5qQlNPvhJ50/59t9ft3LXu7uVaWaO2bDrDCnRSzZyWvFKxO1+vT8MwwunR3bX0CkfPjqb4K9O19tn5X50PvmYpEwHtiW9WtzuV/s76B1zvLLNkViNd8ySxIl/3orfqP90TyTGaf7/rx8jQzeHJXdmh/N6YDvbvmTBwCdxfEQ1NcL6wNMdSIXNq7b1EUzRy1/Axsyk5p22GMG1b+GxFgbHErZh92wuvco0AuOLXct9hvw2nw/LqIcDRRmJmmZzcgUa7JpM/WV/S9IUfbF56TL2orzqwebdRD8nIYNJ41D/hz37Fo11p2Y21wzPcn713qVGhqtevStYfGH4n69OEJtPvbbLYWvscDqc3Hgnu166+tAyLnxrX0Y5zoYjV++1sI7t5kMr02KT/+uwtkc+rZLOf/qn/s3nYCf13Dg8/sB2diJgjGqjQ+TLhxbzyue2Ob7X6/9lUwW7a+lbznHzOYy8LKW1C/uRPbQY3KW/0gO9LXunHLvPL97afba9bFtc9hmz7GAttjVYlCvQAiOwAk/gC5+hkLEs6tr3AZKxLJtOEwk2dLxTYWsIB/j/ToWtIWzo906FrSG8iaqqqqqqiIiIiAgzMzMzNz+AyK+01/zi8n8S+Y1MjoRaQ80WU/G8MBlO+53VPXANrWm4wzGUVZUjjBJZVdhpcfkjsmcWaO+UEldXi1e+zq+HOsCpknYshuh8pOLISJun7TN0EIGW2xTnlOImeecnoGW4raxe2G1T3HEvfYUYMhG+gAFOAwh5nK8mZhwJMmN7r224QVsNFvZ87Z0qatvknklyPDK3Hy45PgVKXji52Wen4d4PlFVVYGnNap+fSpFbK90rYnhUc6n91Q3AY9E0tJOFrcfZtm/491XbcG/jsViUPPX76qmeuiz+qY1Hk7/1VPM405zWVuoheLUimpWYdVzCmUdKHebMdzgrYrb8mL2eeLSnRWHdonfZa8RsOU9F37w+591l5FLYHiOqWeHtE/lWrBHcRKp3uhtr8yXm8LU/5ms+NM6ZKsqu90cFZ4o58+k4rdrtB97NADFbwmEG7lXqvirhOTOqU14xuUF2myIjURcPHrPOQ4lmM3PeMg7bUuk0nnZi67bXsU6H8lhqIo8TaOrEafCO1ARK9PjC0QOoq2BxmMdgYB9G/lIb9++fqNJ2s7BHGFyBNmZAR8J3KCo012ikaSP8BCrf6VI0X5xdnbhHIO+B5rbOyB54zXkzfObyJ4ecwxfqBJMLFc7m59rNcw7hoHnFZ0b00zee+gTqvjm61Pb4xn0kcDX4jvHM0rBXZypG3DCKnD/Waa/ZtHmtFPgO5eETx+k7RrVg3aSwm2YoNXnCs3XPQDhNn+Fia6IlOOuIG6VJH7TP6ava26ehKHQa2T4N0tcZ9dPCGo3ZdnNltsHQbeYt5vPnJezV/cAeNypdml1vCHI8M81nSRP5Qi2+mI8v/sxiZru9187nRtp3f/42NemcONa+4eVC3PCZzc88aZh851CqSsshe70uPxeN/dmYwlwb3trwMrN1Gq8jbnApcVDx/yDPeYs5/7r62tsQ6lLg+DiFXTEhzR9dHqv0iT4tgj825W+H3XiRUNUZT2kR9Ri0+lp+UM3iQtS8uOE23Ly4KYtvqH13jghUntJRAewuzNLDXp8RxdcaA3cMY6TO2IeSFRXezeWIjCqyhsUdMYuCgYTZSKpBype1zRfq8FshvfBPc6BAQWl7/QxIDp3VGo1J3vn42OEs3qznws+YLRXbymyB19a9XBx6n/owcyxlEYyFWCi+kG9F+EyD/4yn80+agaZ9P7ay2Dny99aK2o91FkfEOY8hBwyfi5uwx2y5SaHmG+oq/zl1FX/8irOf8Y3vAcX/6uLP6A6nvMO24edSGPjQc827Rw2atX+z2bKq0CmW9mOtYnr5/AfDa1ZfPaXnKtlWborup7QYx+Or2uWb+N3N//2+yDcXMqIJdf55xl7/vsj4WoPPlxLxtVrkJ4w/tTe3mLdATOOYwxcq52w5Wxz5MbPdVs5O8/lhfE7dPj0bIiPQ3QV0iqm4m3YX8hRfc6jQ3fWepevMqUDJd86Z4vwM40CWHnn+WphsGHfieF02D3tmZvpWD+kBpNCFcLnZhcmmrhpGzzbdA+sQ1ar18OJD87IOKOFoRNznaHPNHUfUNhvY1iU+uhvEvpKHaUn3qK3exVVyX4joipp3um7FmYJWmA+WbIDshRpbVRx5/nqstCgy87FGbfVB8yDGCqS+2qCsnRwnSAN6zgzxfdB2nBT/vZ4/6uxb6oH8b4VBRxiIB93wLa47hG3w2SL/2Z27yOXJFwZpSJaBYyvajA7vRRYNKqljXKpt/CFD/tSMr18DKKbwB0xggBePatl1nki0yvqW5zchlyZmJ0OTxJ3D+fsYJs/mxYN5+Le5oagtcl+YsVvy8kSjI2YGvGjvmpkRS9W2dtXqWnVuxUhURm1lKtou/hdEq19VBp9OjGvHEQSmrpuf2R24mXGheil8KeiANY8fW1VERUfBImb64j12caBZmRViZHbeVMjCrPDg9A90IXrtnsYCuZtRQ0PyrKDjBNOsPfKsg1pA02gHlVr0OXiFhtp6nJqXVzcbfM0KnzC3ggOENPE9VBdmHKN6LYaijb4wXxJn5A0FSDF5j+h1ooZx885Jt3ZKzO5n7Z5WfNEOtyyPqQEnn7WLv5Fis3PdgMshjF1FRydbNyeBbyKI1oN1TRVrVK7kgsb/zjX4NDPIRMctVeaxVB38Vh1x5KbeJbU138AM5KzmZu3uny0ErygxiJF7GVXUrPzFxrlx1uFdAaZFDN9cvIb74qD9tzBMo7L7WIEYK+sla1DVMHpF0F7b3+Y6S+zjvLeDMCpapmJo1weBWuxKF3rOocih1gun4BoJh1kWnV/Jmiq6uOhK3VfKxEHEkafjLgK3oujaPzY6SXg8phhL4TNR1xvJd1Wa0aYFfPUMLrNBDCh4AuGRTbtKMc6Z1Udj8evY/ZpCuMAUefdo69DZUngoqE1P9A3PJfOf7WixCEj+Y6t7fYeHbbxUAoFV3M89cCKfma3fc1+jKRe7MFWEbQqEfyzO2x/wrO2VYH7iYdQ9BkPyI8/3kXBpLaCpU7eC0Yv/am/tEDu7HZpqg0EvHo0nf/R/gRzUWy33/HXMJQeu1GylKmOkXzlCfGFruAcPPhaGqZOtu19zsJ1SO2Jz4Ztth5cBX6mRQwWmDwryG9FUMlZzNckMdK+IoMJv1rOWnBamS2w2KHiaPMPLC15hCZm4KTpoZyj4E2TqC/P6r7/EhnDMhKicZZ1ZwxuC7DPzDGs53q8gXaI9kFTK+2LTq7bhwsTbrMV8Rsfua5lMS0FwbTitUVnVa1yTb5IX51mmYnUcP9wPr8Ji1tiYJeJV9GZTrQhF7vvdU2OTU42ogJ9FDwhmycI2LIg++03C6scYhUyUuMV5tkw6kGUoL+mjNC38+wMdWNljn6tGPpRES7veqrSn5TRuv+dh6JVL/iDHU1db4c9WK3++OrH3PqziF916UMUKn8G67nN60GfWiHrXYhUG3yVWmyYak59NHj8t1smG4UDiWz2rPHNrKnN4Zo1LBbr2/eF9YZ0n0blx2nG4X+EKFxvS3W28JESD+FWk61VCD3z/URGHiJl++7TdBwkCj6tGOH3qDb0QqcOF9Kzpj0HUb/KyFW3Yhj2VMKJqGZleFBH7vqvf7WqLC3XMuHV8q8a4sTFuxUtkD/6JIBvKaVjv96ndgruKZ1k/BHzqf2K9fLk7HGXANyLDd1vxkK/i055pnzl+zw6zLnwXlVYVtfmacJgEpRP1hbGgrYPVN6v2lG+idQNGmwcKXu/8xEj/P6qe/sB2WmwNp6pp8jaISMkwdleFXYK55NHWLTTbutSUqjBfDGWo/Yg918qQ+8BRZSAHZbfuNZz2O0sov1Ue4CWlVg3rFhM3Kljj9ksGd/NUhk4nH+a5UN2+1i8+NM3vRNp7uQ6sqexSCukEVlVZriHNqFi5rLm9TMWa4qm3idJqppQACol2l4VSuvWLfta4JcXy3bROPNbXOgdOhG47LC0CwW/dMlSx4Jf17aEU3yA1x9p+Yc0jupXgcMuYNku64iYOkGToVDuJvlbEKlJqsmiHbvNrIVZEH+yFdF8DbleZ6iNiWwMqvtMp/mSpwx5KxRrT9p3MAPTHGtMbfvdFhyj9vhaKcn3At8Lc16Ai+vBcSp1ztXi7rCJZx/ql7TXcclq6Q76UeKWDy9boS0WHIjUuWhPG8LBmW5y2rhuTpM5vsLt+HOLh1Yf0DqXa9tsfC+kaKt2htA0ai/L2i7RKoNjEwztkmRU0GfgW1TxUvPFhg0V7DdfWJk5gfrccpYv+MA9M0dkGTLECeYwUixRzjRFdmjG7zdZIl3XKB9YliNKI31lfa7i2JG5C8Ss+rHe0D7Z696/V3DEAOWHnQ9yNahMUl5kENWS6pHKKp2D1BaSrrHdE1w2qNxIztpXgUIrF0bm15YML4b6V1k+GpNysTahKMVrrS85lTVo9OGJ96I47eAy5rYWpRf/mIzeoYU1DKaQCTUVwrhHeyNoDqHel+lLxr9WKzhSYw7vrR6+V5q0pfi2k3L1zqkubY6rrd9ZLvSuWNf0uqnkY+FpTvFzSW9Fp0b9l8JA7THV9eCi/PY/SCZIUYx3BU2alj7Cm3VV6eYpios4b6WuNOJdYXUK3zTqj5CVG2FqYM4Z7CuIU0qO05XR0d71FHM0YhZmJmTRfLlXEumN82BGtzdX0S19t1e+bUieK8zRmqpa4Qc5TSjifmaQsY2ETLjhI36gMR1+7qpjdXXHiceUekfBaucHShAOiFXmv3sNmGQyU5iVgnoocuonQXEPTFwslHtS8R+A47StI9wj0iSrtbi5rMysczFiImsQ+bdFClnFjjpXXwMy6O7qfjOr8Fb0a7ODItisjnn3EQO16+ypd1cwyaAW5Yzxz5QknfMO7643fXW/I9y3U2xH27Oapqr56Z/tEzglj6IbT6HEHjopiXqeRbe5mQQvxtcbDOVverN0ZgMdzqRYRjaXtMRd56Q4cZSmdPvZJdSrhJ1D9zNXPqAEqPIavPdfubt5oke2kmv0dztIszSv2VYuoyf1UuopbsYb+uX9h6WpwjpgtZ6fNNawNJ4q8O3CFoSbioAaOSZMx2GYaPYB+rEb6qjQiNRFQ76TvwNFVKD+BhH9VhcKGsXzmMI7BptU/CNWolM7YzROvpFAntsiWJp6eR2d3GarcYShVYSUqhmYOWj5E96NK2WvmYNTeY7Zs4RUEdv9h9QT4EseKt6LzLrqEOs3hxAY1MaNWpSa6zZx8F3YOVeCYMS88W+CYHDuWe4yoc6YK+djDuEOrBR5lvh0r+Q9uM88lrjx9x9AtgpQVNE8r+3O6Gvw59D+kBF/UMXyhliYUtPjmvXGY6Dk3x+kEOW+GtdMVC4EZTqoS/jmR0P0LS75DOc/w2vnri97M4SdbZ8qeU7gg8DVbERkU5geaMQO3mYrSYyAngeUQqrN0C0/vsFmcgWNXNeidsTAj7/4MncJR0caaBUpbLK1yBCBNRjEv6KvuVSdpPnEMJdsRRtqJ+U8tN1gXA4ePHc6ZT0eviI73UOJF0fEZ8YaneAQqQdGphNvwM4nIqPnXxV0xA0fnCT+oAhJuyw/q8jO0y8CjSteZExwBpIN6SvNp6A5G/abi6egeND/1GTguhuNjaUbbnSbGd4L8937Ezm34Eyi6n1maeOBxh3PI0jzJDf5mh/BsLD7F2GOKvlA/5gtvxI3/eV4sLfKW5Wy+oio+es/u6T8UU+nsofy57Icb/JlZHPFtCgd/x+bwt3ZT+xXTtTtTrGAb4QehC6X9G+8YT+ozcLxDsdCjsuOqwPFnrdLYaFc92Ui0m4fr39lYmlCaqTit7G6O/3kWDkgtXjNH4BiEm/+jegQnihOtfffn33WxsFjhfMd48HT+f6o6X65j7XR8WLSHMFkxbvOYsrRsF1bowDuSQ18Mkxk4qz2zoGPL5fu9h2Hqmt1asl3Q3Yu3szOc+spiCmX4AETBM3pLoTYSp3sVxahyhL8eC4mPN9k2x3o0xkiixIzM3CZFzf5oR4mecQ5+ax2wCah3/crmnHoqR0+KMaOPxRif1oEFRFOO/kTPPmtww+NfMXxEK6gn6iU32U6fFruIz8Q4WgljtnaCVTBgWx7diUdshC9ZEa5yKpRBBeW12r/iNc/+EgNqmhswNB8SBoihHXeDF7rrWDLcmt3V8GYYN7pXRy4DZjj4DJuUBL5iC3DQAaoo4vkftqVTYRGLS3mHZ7gdmdTTqbgNN/PTdTCOTgXolc88MhXAEUMdX0iy1JMuk5wLsgeu0QUYlz2S4skTWwJz6pOm/8ihrmgGfFgri+ZWUK2gAPHgbWa8jaocdSuM4FJYoKicYX/ZSENkg9Q1ZzJfwScfVnR2DegOGwCvmogaWJCLQepv9WNlU6QgsmOwICquU28Mlk3d9W5E81lU/5Ez0LcX6lwKMWDNluNKfBDUy/phJgBcMnfkh9iRxrdOzgs08JdPB85Lwo+GUSb4t3nC+0byqMZtO2fQJ4U2zGIr49t/28qmmGv2RanDD7a3FEcdtutkW8twwwlUSpb8QalodddbBfNHKDQ828BdE7OBgFdiKYohLawFYqpybQoxATZrheLhdI7+0Zlu9Q1myRcd15r9UIm8K2LGJxqTegntqNVMKnf1a8zQiyUR1rxoqjiFxeHxqFcYUTHfDu7rhbWng6qOxOsI+5A1p9mRyEPdVkTlE24vY54W7bWc6jMgZvNXdfC9/9q7408KDsbdL7Utz7QFSDetz2picArzrdpL8OaCHC9V26RroemtDZ5yNM/KGkWMyTmfnInEvwtSD23UcFcjhaE3VKzkoaEMKGBft4XbIO6forTY1lmGQwVmKicBCiArDzE+1oIxE08fWeviIOD5TznqH+OoHadvoOP20drMPe5Irg3XBQziW2XDuHYzjqQQ4wySssjXUs5H+t3FWYMHppUnBHMx/nYIT5d7OmjDbgD9F6na3m4l7KdkeSO3kTEPXafiWinogag7b52taiZhL1TSvBFmEZafFq2H8khQaZXuitCewT5FBgVtPK0j4xUHPfUz3Q28eac1Z139DAP23dgki94EC8vbDPTQC97HPPSWjUNG5tWKMsaxAEMKC0665Xvo1Ntd07wCLNf8Q56mrEPVpCxlIMVlQlWRxM3oAfpgIc+8KC3rEXUog5g06vt7zgXY8grH7hhwVSaeuvC06YYRAwpbyk/Unzj9hLEZNs2oxPQB9yc+GnL6zTgq7rI++KDJwX2SP8Sd6YzTuw5lV/kU6eQxRD12omfQAW6caTR4LikYkBB1CMOrvgRr/VY75+NSB40Cni6bADAtaK+vyxVWpf9NeKJxN2KYQ8Q2xPB3K1s7fuhvWbr2XpgW044VD6DRs0qXoqKf1NFsaGvKJc47leUV3pppP/5VTKFhaGuol4Esfjf5zyCyUHmHthChcYh4hYLQF+AFWsuq4t0wJyWgdwQVOZiV0efRHPoK5+E1vjz9wTJmVkITC9oEstAsyZSgE/dbicwKr89YUxKZI+owD205Tm5lnnmDRuP/JnzxX3gMtlrcX0UesZdxyQqYQuEW4R51vmQ5xOZteUd8SJruMlTUzhtVw/Nq7eUBcqN2/HVotgfngif60yKEtoUx3WYOZlVJuJOh8u59fzSDPFYtQgqDUAGyGhQOAvKroXMcOYY0qjnStJR/G3aP+Jt1sLVlGV8POwr/6OGsqetnyF3TmTqZjENfnXh51oxe9qVUw2M78EzAJ+IM8lZ1MBPQ9ZWSVc4J3mWSrLKrMHReA5qdGoz0ODRsaA+vwxXA2cAM4qlfzBJA6581m4hzxItQw5dxrrBL3Y6kCbUcFxo1S8jyV44q//+7ASNNudZ6xeaNOSIUffqMn4A9lIjFctYn2gpEPAb3f7p3iIBN8H14FUGQ9ct2hPsL+cEsTgUrR47uJVN4n4wt/wgfwwHuOnLd4yobkofy8JvxSQTA7rMpDIc608SlZFJfZYcmbT0tAHpPE8MrtQ42siTUNWxqvWZOmvu9f0JPoQmg+6l7sZWwyfi6PXkxJnwBraUG0MYG4zYHQz3igy/XsFkx5tNQxw43qvI9dU3f0DdhOUlHKjmi1VAr2Kiy0HZwD8VeEbhh0OiDdMYspolQsYdSwjCcjeowIXNZVUPmL2wwIkYhmXKhGozdCJ4lRKbsf4NBh/XnQoS92NJEWOVOFs2YhN8c5QZFeK0pRdAG40hqvLbmoSA8xQmzOOEc7wLcme9JOsjPCEgpCwUs9E2DohMHRhUeyGIN6TFvrbny8nDuilsDpzrH5mS76APoIEJmItS67sQJ+nfwddzmjPxcBEBBCw0kWDwd0EZCkNeOD7NNQhtBm7KHL9mRxj6U1yWU2puzlIDtpYxdH4ZPeXBJkTGAJfUr/oTCz/iypY6uXaR2V1doPxJYlrw2ghH0D5gbrhFcIxzYwi4a/4hqVdf2DdxBp6vGYDjavxMAAoy+1+3aiO6S3W/QAKNVXagDtvsNtx7Ks+HKgo6U21B+QSZgIogV5Bt+BnXisdVfy9VyXV+2P5fMuvdpAjM1o/K9Z+XnE4EOCrue+kcdYHqAQ0/Y/OmNlQ6OI33jH/uD1RalPaHpJAm2av0/xtpqdXVKNDrc9F2izo23Wu7firgbURFDNX9eGGeYBhiypyXZft2j3hTvzE6PMWKsod//rEILDkzBXfi7xh0eFkfb3/1zzPK/PI5Nk3FbZyTl4mq5BfBoVoqiPHO4Q4QKZAlrQ3MdNfi3oxIjvsM3kAFv3fdufurqYR3PSwX/mpGy/GFI/B2MNPiNdOppWVbs/gjF3YH+QA9jMhlAbhvasAHstB0IJew09iAkmXHl1/TEj+jvHOpOGrPRQXbPADM+Ig2/OEcUcpgPTItMtW4DdqgfYVI/+4hAFWYjUGpOP/UwNuB7+BbKOcALbjobdgzeBQfjgNSp2GOpxzGLj70Vvq5cw2AoYENwKLUtJUX8sGRox4dVa/TN4xKwaKcl9XawQR/uNus700Hf17pyNnezrUgaY9e4MADhEDBpsJT6y1gDJs1q6wlwGhuUzGR7C8kgpjPyHWwsvrf3yn1zJEIRa5eSxoLAZOCR9xbuztxFRJW9ZmMYfCFJ0evm9F2fVnuje92Rc4Pl6A8bluN8MZyyJGZ0+sNSb//DvAFxC2BqlEsFwccWeAl6CyBcQV1bx4mQMBP1Jxqk1EUADNLeieS2dUFbQ/c/kvwItbZ7tx0st16viqd53WsRmPTKv2AD8CUnhtPWg5aUegNpsYgasaw2+EVooeNKmrW3MFtj76bYHJm5K9gpAXZXsE5U8DM8XmVOSJ1F1WnLy6nQup+jx52bAb+rCq6y9WXl2B2oZDhfDkW7H3oYfT/4xx5VncBuxMXP2lNfhUVQjSSzSRbuZFE4vFawlzveXxaYKVs8LpvAb8IRYF3ZHiRnm0ADeNPWocwxSzNseG7NrSEVZoHdKWqaGEBz1N8Pt7kFbqh3LYmAbm9i1IChIpLpM5AS6mr6OAPHMwwznVy61YpBYX8xZDN/a+lt7n+x5j4bNOVteZ8lj3hpAHSx1VR8vZHec4AHO9XFCdjZ9eRkSV65ljMmZVzaej2qFn/qt1lvWzNZEfHxK3qOJrHL6crr0CRzMox5f2e8ALBB4UGFZKA3tN6F6IXd32GTJXGQ7DTi9j/dNcLF9jCbDcWGKxoKTYblIwbLDReL00LRcDPMcQuXLMh5YzgtfjkFK1DP1iDzzYYVZz5M/kWYRlRpig1htVRjVCknm+h1M5LiEDXOyHREhvzCGpFZjHS0RsK27o2avgdilrJkalWqPW3D9gmwV37HKmfM3F8YZj2ar+vHFvf3B8CRoH4kDHIK9mrAg+owiEwNjjd9V+FsQKYR8czJrUkf7Qoi2YaW6EVDZp5zYlqiYtuXOTHk4fAcZ7qBbdLDiJq0WNV1l2+Hntk1mMWvxrYmc8kIx8G3rW36J6Ra4lLrTOCgiOihmow+YnzUT19jbV2B3RWqSHyxkhmgsBqMYWvOcUom1jDQ436+fcbu3xf2bbeqU/ca+C4DOKE+e3qvmeMqW3AxejfzBRFVcwVYPq4L0APSWWoJu+5UYX4qg5U6YTioqQGPG9XrnuZ/BkxuYpe6Li87+18EskyQW/uA+uk2rpHpr6hut2TlVbKgWkFpx+AZffweiw2+VittkEyf/ifinS/0ItRL2Jq3tQOcxPaWO2xrG68GdFoUpZgFXaP2wYVtRc6xYCfI1CaBqyWpg4bx8OHBQwsV4XWMibZZ0LYjWEy2IxQ1mZrf1/UNbYCJplWu3nZ4WpodIGVA05d+RWSS+ET9tH3RfGGmNI1cIY7evZZq7o+a0bjjygpmR3mVfalkT/SZGT27Q8QGalwGlDOS9VHCyFAIL0a1Q7JiW3saz9gqY8lqKynFrPCzxkU4SIfLc9VfCI5edgRhDXs0edO992nhTKHriREP1NJC6SROMgQ0xO5kNNZOhMOIT99AUElbxqeZF8A3xrfDJsWtDnUenAHdYWSwAbYjFqQZ+D5gi3hNK8CSxU9i6f6ClL9IGlj1OPMQAsr84YG6ijsJpCaGWj75c3yOZKBB9mNpQNPUKkK0D6wgLH8MGoyRxTX6Y05Q4AnYNXMZwXM4eij/9WpsM/9CoRnFQXGR6MEaY+FXvXEO3RO0JaStk6OXuHVATHJE+1W+TU3bSZ2ksMtqjO0zfSJCdBv7y2d8DMx6TfVme3q0ZpTKMMu4YL/t7ciTNtdDkwPogh3Cnjx7qk08SHwf+dksZ7M2vCOlfsF0hQ6J4ehPCaHTNrM/zBSOqD83dBEBCW/F/LEmeh0nOHd7oVl3/Qo/9GUDkkbj7yz+9cvvu+dDAtx8NzCDTP4iKdZvk9MWiizvtILLepysflSvTLFBZ37RLwiriqyRxYv/zrgFd/9XVHh/OmzBvDX4mitMR/lUavs2Vx6cR94lzAkplm3IRNy4TFfu47tuYs9EQPIPVta4P64tV+sZ7n3ued3cgEx2YK+QL5+xms6osk8qQbTyuKVGdaX9FQqk6qfDnT5ykxk0VK7KZ62b6DNDUfQlqGHxSMKv1P0XN5BqMeKG1P4Wp5QfZDUCEldppoX0U6ss2jIko2XpURKCIhfaOqLPfShdtS37ZrT+jFRSH2xYVV1rmT/MBtRQhxiO4MQ3iAGlaZi+9PWBEIXOVnu9jN1f921lWLZky9bqbM3J2MAAI9jmuAx3gyoEUa6P2ivs0EeNv/OR+AX6q5SW6l5HaoFuS6jr6yg9limu+P0KYKzfMXWcQSfTXzpOzKEKpwI3YGXZpSSy2LTlMgfmFA3CF6R5c9xWEtRuCg2ZPUQ2Nb6dRFTNd4TfGHrnEWSKHPuRyiJSDAZ+KX0VxmSHjGPbQTLVpqixia2uyhQ394gBMt7C3ZAmxn/DJS+l1fBsAo2Eir/C0jG9csd4+/tp12pPc/BVJGaK9mfvr7M/CeztrmCO5qY06Edi4xAGtiEhnWAbzLy2VEyazE1J5nPmgU4RpW4Sa0TnOT6w5lgt3/tMpROigHHmexBGAMY0mdcDbDxWIz41NgdD6oxgHsJRgr5RnT6wZAkTOcStU4NMOQNemSO7gxGahdEsC+NRVGxMUhQmmM0llWRbbmFGHzEqLM4Iw0H7577Kyo+Zf+2cUFIOw93gEY171vQaM0HLwpjpdRR6Jz7V0ckE7XzYJ0TmY9znLdzkva0vNrAGGT5SUZ5uaHDkcGvI0ySpwkasEgZPMseYcu85w8HPdSNi+4T6A83iAwDbxgeFcB1ZM2iGXzFcEOUlYVrEckaOyodfvaYSQ7GuB4ISE0nYJc15X/1ciDTPbPCgYJK55VkEor4LvzL9S2WDy4xj+6FOqVyTAC2ZNowheeeSI5hA/02l8UYkv4nk9iaVn+kCVEUstgk5Hyq+gJm6R9vG3rhuM904he/hFmNQaUIATB1y3vw+OmxP4X5Yi6A5I5jJufHCjF9+AGNwnEllZjUco6XhsO5T5+R3yxz5yLVOnAn0zuS+6zdj0nTJbEZCbXJdtpfYZfCeCOqJHoE2vPPFS6eRLjIJlG69X93nfR0mxSFXzp1Zc0lt/VafDaImhUMtbnqWVb9M4nGNQLN68BHP7AR8Il9dkcxzmBv8PCZlw9guY0lurbBsmNYlwJZsA/B15/HfkbjbwPddaVecls/elmDHNW2r4crAx43feNkfRwsaNq/yyJ0d/p5hZ6AZajz7DBfUok0ZU62gCzz7x8eVfJTKA8IWn45vINLSM1q+HF9CV9qF3zP6Ml21kPPL3CXzkuYUlnSqT+Ij4tI/od5KwIs+tDajDs64owN7tOAd6eucGz+KfO26iNcBFpbWA5732bBNWO4kHNpr9D955L61bvHCF/mwSrz6eQaDjfDEANqGMkFc+NGxpKZzCD2sj/JrHd+zlPQ8Iz7Q+2JVIiVCuCKoK/hlAEHzvk/Piq3mRL1rT/fEh9hoT5GJmeYswg1otiKydizJ/fS2SeKHVu6Z3JEHjiW8NaTQgP5xdBli8nC57XiN9hrquBu99hn9zqwo92+PM2JXtpeVZS0PdqR5mDyDreMMtEws+CpwaRyyzoYtfcvt9PJIW0fJVNNi/FFyRsea7peLvJrL+5b4GOXJ8tAr+ATk9f8KmiIsRhqRy0vFzwRV3Z5dZ3QqIU8JQ/uQpkJbjMUMFj2F9sCFeaBjI4+fL/oN3+LQgjI4zuAfQ+3IPIPFQBccf0clJpsfpnBxD84atwtupkGqKvrH7cGNl/QcWcSi6wcVDML6ljOgYbo+2BOAWNNjlUBPiyitUAwbnhFvLbnqw42kR3Yp2kv2dMeDdcGOX5kT4S6M44KHEB/SpCfl7xgsUvs+JNY9G3O2X/6FEt9FyAn57lrbiu+tl83sCymSvq9eZbe9mchL7MTf/Ta78e80zSf0hYY5eUU7+ff14jv7Xy8qjzfzzzvaJnrIdvFb5BLWKcWGy5/w7+vV2cvIfwHqdTB+RuJK5oj9mbt0Hy94AmjMjjwYNZlNS6uiyxNnwNyt3gdreLb64p/3+08nXkb92LTkkRgFOwk1oGEVllcOj5lv1hfAZywDows0944U8vUFw+A/nuVq/UCygsrmWIBnHyU01d0XJPwriEOvx/ISK6Pk4y2w0gmojZs7lU8TtakBAdne4v/aNxmMpK4VcGMp7si0yqsiolXRuOi1Z1P7SqD3Zmp0CWcyK4Ubmp2SXiXuI5nGLCieFHKHNRIlcY3Pys2dwMTYCaqlyWSITwr2oGXvyU3h1Pf8eQ3w1bnD7ilocVjYDkcXR3Oo1BXgMLTUjNw2xMVwjtp99NhSVc5aIWrDQT5DHPKtCtheBP4zHcw4dz2eRdTMamhlHhtfgqJJHI7NGDUw1XL8vsSeSHyKqDtqoAmrQqsYwvwi7HW3ojWyhIa5oz5xJTaq14NAzFLjVLR12rRNUQ6xohDnrWFb5bG9yf8aCD8d5phoackcNJp+Dw3Due3RM+5Rid7EuIgsnwgpX0rUWh/nqPtByMhMZZ69NpgvRTKZ62ViZ+Q7Dp5r4K0d7EfJuiy06KuIYauRh5Ecrhdt2QpTS1k1AscEHvapNbU3HL1F2TFyR33Wxb5MvH5iZsrn3SDcsxlnnshO8PLwmdGN+paWnQuORtZGX37uhFT64SeuPsx8UOokY6ON85WdQ1dki5zErsJGazcBOddWJEKqNPiJpsMD1GrVLrVY+AOdPWQneTyyP1hRX/lMM4ZogGGOhYuAdr7F/DOiAoc++cn5vlf0zkMUJ40Z1rlgv9BelPqVOpxKeOpzKdF8maK+1Vv23MO9k/8+qpLoxrIGH2EDQlnGmH8CD31G8QqlyQIcpmR5bwmSVw9/Ns6IHgulCRehvZ/+VrM60Cu/r3AontFfrljew74skYe2uyn7JKQtFQBQRJ9ryGic/zQOsbS4scUBctA8cPToQ3x6ZBQu6DPu5m1bnCtP8TllLYA0UTQNVqza5nfew3Mopy1GPUwG5jsl0OVXniPmAcmLqO5HG8Hv3nSLecE9oOjPDXcsTxoCBxYyzBdj4wmnyEV4kvFDunipS8SSkvdaMnTBN9brHUR8xdmmEAp/Pdqk9uextp1t+JrtXwpN/MG2w/qhRMpSNxQ1uhg/kKO30eQ/FyHUDkWHT8V6gGRU4DhDMxZu7xXij9Ui6jlpWmQCqJg3FkOTq3WKneCRYZxBXMNAVLQgHXSCGSqNdjebY94oyIpVjMYehAiFx/tqzBXFHZaL5PeeD74rW5OysFoUXY8sebUZleFTUa/+zBKVTFDopTReXNuZq47QjkWnxjirCommO4L/GrFtVV21EpMyw8wyThL5Y59d88xtlx1g1ttSICDwnof6lt/6zliPzgVUL8jWBjC0o2D6Kg+jNuThkAlaDJsq/AG2aKA//A76avw2KNqtv223P+Wq3StRDDNKFFgtsFukYt1GFDWooFVXitaNhb3RCyJi4cMeNjROiPEDb4k+G3+hD8tsg+5hhmSc/8t2JTSwYoCzAI75doq8QTHe+E/Tw0RQSUDlU+6uBeNN3h6jJGX/mH8oj0i3caCNsjvTnoh73BtyZpsflHLq6AfwJNCDX4S98h4+pCOhGKDhV3rtkKHMa3EG4J9y8zFWI4UsfNzC/Rl5midNn7gwoN9j23HGCQQ+OAZpTTPMdiVow740gIyuEtd0qVxMyNXhHcnuXRKdw5wDUSL358ktjMXmAkvIB73BLa1vfF9BAUZInPYJiwxqFWQQBVk7gQH4ojfUQ/KEjn+A/WR6EEe4CtbpoLe1mzHkajgTIoE0SLDHVauKhrq12zrAXBGbPPWKCt4DGedq3JyGRbmPFW32bE7T20+73BatV/qQhhBWfWBFHfhYWXjALts38FemnoT+9bn1jDBMcUMmYgSc0e7GQjv2MUBwLU8ionCpgV+Qrhg7iUIfUY6JFxR0Y+ZTCPM+rVuq0GNLyJXX6nrUTt8HzFBRY1E/FIm2EeVA9NcXrj7S6YYIChVQCWr/m2fYUjC4j0XLkzZ8GCSLfmkW3PB/xq+nlXsKVBOj7vTvqKCOMq7Ztqr3cQ+N8gBnPaAps+oGwWOkbuxnRYj/x/WjiDclVrs22xMK4qArE1Ztk1456kiJriw6abkNeRHogaPRBgbgF9Z8i/tbzWELN4CvbqtrqV9TtGSnmPS2F9kqOIBaazHYaJ9bi3AoDBvlZasMluxt0BDXfhp02Jn411aVt6S4TUB8ZgFDkI6TP6gwPY85w+oUQSsjIeXVminrwIdK2ZAawb8Se6XOJbOaliQxHSrnAeONDLuCnFejIbp4YDtBcQCwMsYiRZfHefuEJqJcwKTTJ8sx5hjHmJI1sPFHOr6W9AhZ2NAod38mnLQk1gOz2LCAohoQbgMbUK9RMEA3LkiF7Sr9tLZp6lkciIGhE2V546w3Mam53VtVkGbB9w0Yk2XiRnCmbpxmHr2k4eSC0RuNbjNsUfDIfc8DZvRvgUDe1IlKdZTzcT4ZGEb53dp8VtsoZlyXzLHOdAbsp1LPTVaHvLA0GYDFMbAW/WUBfUAdHwqLFAV+3uHvYWrCfhUOR2i89qvCBoOb48usAGdcF2M4aKn79k/43WzBZ+xR1L0uZfia70XP9soQReeuhZiUnXFDG1T8/OXNmssTSnYO+3kVLAgeiY719uDwL9FQycgLPessNihMZbAKG7qwPZyG11G1+ZA3jAX2yddpYfmaKBlmfcK/V0mwIRUDC0nJSOPUl2KB8h13F4dlVZiRhdGY5farwN+f9hEb1cRi41ZcGDn6Xe9MMSTOY81ULJyXIHSWFIQHstVYLiJEiUjktlHiGjntN5/btB8Fu+vp28zl2fZXN+dJDyN6EXhS+0yzqpl/LSJNEUVxmu7BsNdjAY0jVsAhkNuuY0E1G48ej25mSt+00yPbQ4SRCVkIwb6ISvYtmJRPz9Zt5dk76blf+lJwAPH5KDF+vHAmACLoCdG2Adii6dOHnNJnTmZtoOGO8Q1jy1veMw6gbLFToQmfJa7nT7Al89mRbRkZZQxJTKgK5Kc9INzmTJFp0tpAPzNmyL/F08bX3nhCumM/cR/2RPn9emZ3VljokttZD1zVWXlUIqEU7SLk5I0lFRU0AcENXBYazNaVzsVHA/sD3o9hm42wbHIRb/BBQTKzAi8s3+bMtpOOZgLdQzCYPfX3UUxKd1WYVkGH7lh/RBBgMZZwXzU9+GYxdBqlGs0LP+DZ5g2BWNh6FAcR944B+K/JTWI3t9YyVyRhlP4CCoUk/mmF7+r2pilVBjxXBHFaBfBtr9hbVn2zDuI0kEOG3kBx8CGdPOjX1ph1POOZJUO1JEGG0jzUy2tK4X0CgVNYhmkqqQysRNtKuPdCJqK3WW57kaV17vXgiyPrl4KEEWgiGF1euI4QkSFHFf0TDroQiLNKJiLbdhH0YBhriRNCHPxSqJmNNoketaioohqMglh6wLtEGWSM1EZbQg72h0UJAIPVFCAJOThpQGGdKfFovcwEeiBuZHN2Ob4uVM7+gwZLz1D9E7ta4RmMZ24OBBAg7Eh6dLXGofZ4U2TFOCQMKjwhVckjrydRS+YaqCw1kYt6UexuzbNEDyYLTZnrY1PzsHZJT4U+awO2xlqTSYu6n/U29O2wPXgGOEKDMSq+zTUtyc8+6iLp0ivav4FKx+xxVy4FxhIF/pucVDqpsVe2jFOfdZhTzLz2QjtzvsTCvDPU7bzDH2eXVKUV9TZ+qFtaSSxnYgYdXKwVreIgvWhT9eGDB2OvnWyPLfIIIfNnfIxU8nW7MbcH05nhlsYtaW9EZRsxWcKdEqInq1DiZPKCz7iGmAU9/ccnnQud2pNgIGFYOTAWjhIrd63aPDgfj8/sdlD4l+UTlcxTI9jbaMqqN0gQxSHs60IAcW3cH4p3V1aSciTKB29L1tz2eUQhRiTgTvmqc+sGtBNh4ky0mQJGsdycBREP+fAaSs1EREDVo5gvgi5+aCN7NECw30owbCc1mSpjiahyNVwJd1jiGgzSwfTpzf2c5XJvG/g1n0fH88KHNnf+u7ZiRMlXueSIsloJBUtW9ezvsx9grfsX/FNxnbxU1Lvg0hLxixypHKGFAaPu0xCD8oDTeFSyfRT6s8109GMUZL8m2xXp8X2dpPCWWdX84iga4BrTlOfqox4shqEgh/Ht4qRst52cA1xOIUuOxgfUivp6v5f8IVyaryEdpVk72ERAwdT4aoY1usBgmP+0m06Q216H/nubtNYxHaOIYjcach3A8Ez/zc0KcShhel0HCYjFsA0FjYqyJ5ZUH1aZw3+zWC0hLpM6GDfcAdn9fq2orPmZbW6XXrf+Krc9RtvII5jeD3dFoT1KwZJwxfUMvc5KLfn8rROW23Jw89sJ2a5dpB3qWDUBWF2iX8OCuKprHosJ2mflBR+Wqs86VvgI/XMnsqb97+VlKdPVysczPj8Jhzf+WCvGBHijAqYlavbF60soMWlHbvKT+ScvhprgeTln51xX0sF+Eadc/l2s2a5BgkVbHYyz0E85p0LstqH+gEGiR84nBRRFIn8hLSZrGwqjZ3E29cuGi+5Z5bp7EM8MWFa9ssS/vy4VrDfECSv7DSU84DaP0sXI3Ap4lWznQ65nQoTKRWU30gd7Nn8ZowUvGIx4aqyXGwmA/PB4qN8msJUODezUHEl0VP9uo+cZ8vPFodSIB4C7lQYjEFj8yu49C2KIV3qxMFYTevG8KqAr0TPlkbzHHnTpDpvpzziAiNFh8xiT7C/TiyH0EguUw4vxAgpnE27WIypV+uFN2zW7xniF/n75trs9IJ5amB1zXXZ1LFkJ6GbS/dFokzl4cc2mamVwhL4XU0Av5gDWAl+aEWhAP7t2VIwU+EpvfOPDcLASX7H7lZpXA2XQfbSlD4qU18NffNPoAKMNSccBfO9YVVgmlW4RydBqfHAV7+hrZ84WJGho6bNT0YMhxxLdOx/dwGj0oyak9aAkNJ8lRJzUuA8sR+fPyiyTgUHio5+Pp+YaKlHrhR41jY5NESPS3x+zTMe0S2HnLOKCOQPpdxKyviBvdHrCDRqO+l96HhhNBLXWv4yEMuEUYo8kXnYJM8oIgVM4XJ+xXOev4YbWeqsvgq0lmw4/PiYr9sYLt+W5EAuYSFnJEan8CwJwbtASBfLBBpJZiRPor/aCJBZsM+MhvS7ZepyHvU8m5WSmaZnxuLts8ojl6KkS8oSAHkq5GWlCB/NgJ5W3rO2Cj1MK7ahxsCrbTT3a0V/QQH+sErxV4XUWDHx0kkFy25bPmBMBQ6BU3HoHhhYcJB9JhP6NXUWKxnE0raXHB6U9KHpWdQCQI72qevp5fMzcm+AvC85rsynVQhruDA9fp9COe7N56cg1UKGSas89vrN+WlGLYTwi5W+0xYdKEGtGCeNJwXKDU0XqU5uQYnWsMwTENLGtbQMvoGjIFIEMzCRal4rnBAg7D/CSn8MsCvS+FDJJAzoiioJEhZJgAp9n2+1Yznr7H+6eT4YkJ9Mpj60ImcW4i4iHDLn9RydB8dx3QYm3rsX6n4VRrZDsYK6DCGwkwd5n3/INFEpk16fYpP6JtMQpqEMzcOfQGAHXBTEGzuLJ03GYQL9bmV2/7ExDlRf+Uvf1sM2frRtCWmal12pMgtonvSCtR4n1CLUZRdTHDHP1Otwqd+rcdlavnKjUB/OYXQHUJzpNyFoKpQK+2OgrEKpGyIgIBgn2y9QHnTJihZOpEvOKIoHAMGAXHmj21Lym39Mbiow4IF+77xNuewziNVBxr6KD5e+9HzZSBIlUa/AmsDFJFXeyrQakR3FwowTGcADJHcEfhGkXYNGSYo4dh4bxwLM+28xjiqkdn0/3R4UEkvcBrBfn/SzBc1XhKM2VPlJgKSorjDac96V2UnQYXl1/yZPT4DVelgO+soMjexXwYO58VLl5xInQUZI8jc3H2CPnCNb9X05nOxIy4MlecasTqGK6s2az4RjpF2cQP2G28R+7wDPsZDZC/kWtjdoHC7SpdPmqQrUAhMwKVuxCmYTiD9q/O7GHtZvPSN0CAUQN/rymXZNniYLlJDE70bsk6Xxsh4kDOdxe7A2wo7P9F5YvqqRDI6brf79yPCSp4I0jVoO4YnLYtX5nzspR5WB4AKOYtR1ujXbOQpPyYDvfRE3FN5zw0i7reehdi7yV0YDRKRllGCGRk5Yz+Uv1fYl2ZwrnGsqsjgAVo0xEUba8ohjaNMJNwTwZA/wBDWFSCpg1eUH8MYL2zdioxRTqgGQrDZxQyNzyBJPXZF0+oxITJAbj7oNC5JwgDMUJaM5GqlGCWc//KCIrI+aclEe4IA0uzv7cuj6GCdaJONpi13O544vbtIHBF+A+JeDFUQNy61Gki3rtyQ4aUywn6ru314/dkGiP8Iwjo0J/2Txs49ZkwEl4mx+iYUUO55I6pJzU4P+7RRs+DXZkyKUYZqVWrPF4I94m4Wx1tXeE74o9GuX977yvJ/jkdak8+AmoHVjI15V+WwBdARFV2IPirJgVMdsg1Pez2VNHqa7EHWdTkl3XTcyjG9BiueWFvQfXI8aWSkuuRmqi/HUuzqyvLJfNfs0txMqldYYflWB1BS31WkuPJGGwXUCpjiQSktkuBMWwHjSkQxeehqw1Kgz0Trzm7QbtgxiEPDVmWCNCAeCfROTphd1ZNOhzLy6XfJyG6Xgd5MCAZw4xie0Sj5AnY1/akDgNS9YFl3Y06vd6FAsg2gVQJtzG7LVq1OH2frbXNHWH/NY89NNZ4QUSJqL2yEcGADbT38X0bGdukqYlSoliKOcsSTuqhcaemUeYLLoI8+MZor2RxXTRThF1LrHfqf/5LcLAjdl4EERgUysYS2geE+yFdasU91UgUDsc2cSQ1ZoT9+uLOwdgAmifwQqF028INc2IQEDfTmUw3eZxvz7Ud1z3xc1PQfeCvfKsB9jOhRj7rFyb9XcDWLcYj0bByosychMezMLVkFiYcdBBQtvI6K0KRuOZQH2kBsYHJaXTkup8F0eIhO1/GcIwWKpr2mouB7g5TUDJNvORXPXa/mU8bh27TAZYBe2sKx4NSv5OjnHIWD2RuysCzBlUfeNXhDd2jxnHoUlheJ3jBApzURy0fwm2FwwsSU0caQGl0Kv8hopRQE211NnvtLRsmCNrhhpEDoNiZEzD2QdJWKbRRWnaFedXHAELSN0t0bfsCsMf0ktfBoXBoNA+nZN9+pSlmuzspFevmsqqcMllzzvkyXrzoA+Ryo1ePXpdGOoJvhyru+EBRsmOp7MXZ0vNUMUqHLUoKglg1p73sWeZmPc+KAw0pE2zIsFFE5H4192KwDvDxdxEYoDBDNZjbg2bmADTeUKK57IPD4fTYF4c6EnXx/teYMORBDtIhPJneiZny7Nv/zG+YmekIKCoxr6kauE2bZtBLufetNG0BtBY7f+/ImUypMBvdWu/Q7vTMRzw5aQGZWuc1V0HEsItFYMIBnoKGZ0xcarba/TYZq50kCaflFysYjA4EDKHqGdpYWdKYmm+a7TADmW35yfnOYpZYrkpVEtiqF0EujI00aeplNs2k+qyFZNeE3CDPL9P6b4PQ/kataHkVpLSEVGK7EX6rAa7IVNrvZtFvOA6okKvBgMtFDAGZOx88MeBcJ8AR3AgUUeIznAN6tjCUipGDZONm1FjWJp4A3QIzSaIOmZ7DvF/ysYYbM/fFDOV0jntAjRdapxJxL0eThpEhKOjCDDq2ks+3GrwxqIFKLe1WdOzII8XIOPGnwy6LKXVfpSDOTEfaRsGujhpS4hBIsMOqHbl16PJxc4EkaVu9wpEYlF/84NSv5Zum4drMfp9yXbzzAOJqqS4YkI4cBrFrC7bMPiCfgI3nNZAqkk3QOZqR+yyqx+nDQKBBBZ7QKrfGMCL+XpqFaBJU0wpkBdAhbR4hJsmT5aynlvkouoxm/NjD5oe6BzVIO9uktM+/5dEC5P7vZvarmuO/lKXz4sBabVPIATuKTrwbJP8XUkdM6uEctHKXICUJGjaZIWRbZp8czquQYfY6ynBUCfIU+gG6wqSIBmYIm9pZpXdaL121V7q0VjDjmQnXvMe7ysoEZnZL15B0SpxS1jjd83uNIOKZwu5MPzg2NhOx3xMOPYwEn2CUzbSrwAs5OAtrz3GAaUkJOU74XwjaYUmGJdZBS1NJVkGYrToINLKDjxcuIlyfVsKQSG/G4DyiO2SlQvJ0d0Ot1uOG5IFSAkq+PRVMgVMDvOIJMdqjeCFKUGRWBW9wigYvcbU7CQL/7meF2KZAaWl+4y9uhowAX7elogAvItAAxo2+SFxGRsHGEW9BnhlTuWigYxRcnVUBRQHV41LV+Fr5CJYV7sHfeywswx4XMtUx6EkBhR+q8AXXUA8uPJ73Pb49i9KG9fOljvXeyFj9ixgbo6CcbAJ7WHWqKHy/h+YjBwp6VcN7M89FGzQ04qbrQtgrOFybg3gQRTYG5xn73ArkfQWjCJROwy3J38Dx/D7jOa6BBNsitEw1wGq780EEioOeD+ZGp2J66ADiVGMayiHYucMk8nTK2zzT9CnEraAk95kQjy4k0GRElLL5YAKLQErJ5rp1eay9O4Fb6yJGm9U4FaMwPGxtKD6odIIHKoWnhKo1U8KIpFC+MVn59ZXmc7ZTBZfsg6FQ8W10YfTr4u0nYrpHZbZ1jXiLmooF0cOm0+mPnJBXQtepc7n0BqOipNCqI6yyloTeRShNKH04FIo0gcMk0H/xThyN4pPAWjDDkEp3lNNPRNVfpMI44CWRlRgViP64eK0JSRp0WUvCWYumlW/c58Vcz/yMwVcW5oYb9+26TEhwvbxiNg48hl1VI1UXTU//Eta+BMKnGUivctfL5wINDD0giQL1ipt6U7C9cd4+lgqY2lMUZ02Uv6Prs+ZEZer7ZfWBXVghlfOOrClwsoOFKzWEfz6RZu1eCs+K8fLvkts5+BX0gyrFYve0C3qHrn5U/Oh6D/CihmWIrY7HUZRhJaxde+tldu6adYJ+LeXupQw0XExC36RETdNFxcq9glMu4cNQSX9cqR/GQYp+IxUkIcNGWVU7ZtGa6P3XAyodRt0XeS3Tp01AnCh0ZbUh4VrSZeV9RWfSoWyxnY3hzcZ30G/InDq4wxRrEejreBxnhIQbkxenxkaxl+k7eLUQkUR6vKJ2iDFNGX3WmVA1yaOH+mvhBd+sE6vacQzFobwY5BqEAFmejwW5ne7HtVNolOUgJc8CsUxmc/LBi8N5mu9VsIA5HyErnS6zeCz7VLI9+n/hbT6hTokMXTVyXJRKSG2hd2labXTbtmK4fNH3IZBPreSA4FMeVouVN3zG5x9CiGpLw/3pceo4qGqp+rVp+z+7yQ98oEf+nyH4F3+J9IheDBa94Wi63zJbLBCIZm7P0asHGpIJt3PzE3m0S4YIWyXBCVXGikj8MudDPB/6Nm2v4IxJ5gU0ii0guy5SUHqGUYzTP0jIJU5E82RHUXtX4lDdrihBLdP1YaG1AGUC12rQKuIaGvCpMjZC9bWSCYnjDlvpWbkdXMTNeBHLKiuoozMGIvkczmP0aRJSJ8PYnLCVNhKHXBNckH79e8Z8Kc2wUej4sQZoH8qDRGkg86maW/ZQWGNnLcXmq3FlXM6ssR/3P6E/bHMvm6HLrv1yRixit25JsH3/IOr2UV4BWJhxXW5BJ6Xdr07n9kF3ZNAk6/Xpc5MSFmYJ2R7bdL8Kk7q1OU9Elg/tCxJ8giT27wSTySF0GOxg4PbYJdi/Nyia9Nn89CGDulfJemm1aiEr/eleGSN+5MRrVJ4K6lgyTTIW3i9cQ0dAi6FHt0YMbH3wDSAtGLSAccezzxHitt1QdhW36CQgPcA8vIIBh3/JNjf/Obmc2yzpk8edSlS4lVdwgW5vzbYEyFoF4GCBBby1keVNueHAH+evi+H7oOVfS3XuPQSNTXOONAbzJeSb5stwdQHl1ZjrGoE49I8+A9j3t+ahhQj74FCSWpZrj7wRSFJJnnwi1T9HL5qrCFW/JZq6P62XkMWTb+u4lGpKfmmwiJWx178GOG7KbrZGqyWwmuyKWPkNswkZ1q8uptUlviIi+AXh2bOOTOLsrtNkfqbQJeh24reebkINLkjut5r4d9GR/r8CBa9SU0UQhsnZp5cP+RqWCixRm7i4YRFbtZ4EAkhtNa6jHb6gPYQv7MKqkPLRmX3dFsK8XsRLVZ6IEVrCbmNDc8o5mqsogjAQfoC9Bc7R6gfw03m+lQpv6kTfhxscDIX6s0w+fBxtkhjXAXr10UouWCx3C/p/FYwJRS/AXRKkjOb5CLmK4XRe0+xeDDwVkJPZau52bzLEDHCqV0f44pPgKOkYKgTZJ33fmk3Tu8SdxJ02SHM8Fem5SMsWqRyi2F1ynfRJszcFKykdWlNqgDA/L9lKYBmc7Zu/q9ii1FPF47VJkqhirUob53zoiJtVVRVwMR34gV9iqcBaHbRu9kkvqk3yMpfRFG49pKKjIiq7h/VpRwPGTHoY4cg05X5028iHsLvUW/uz+kjPyIEhhcKUwCkJAwbR9pIEGOn8z6svAO8i89sJ3dL5qDWFYbS+HGPRMxYwJItFQN86YESeJQhn2urGiLRffQeLptDl8dAgb+Tp47UQPxWOw17OeChLN1WnzlkPL1T5O+O3Menpn4C3IY5LEepHpnPeZHbvuWfeVtPlkH4LZjPbBrkJT3NoRJzBt86CO0Xq59oQ+8dsm0ymRcmQyn8w71mhmcuEI5byuF+C88VPYly2sEzjlzAQ3vdn/1+Hzguw6qFNNbqenhZGbdiG6RwZaTG7jTA2X9RdXjDN9yj1uQpyO4Lx8KRAcZcbZMafp4wPOd5MdXoFY52V1A8M9hi3sso93+uprE0qYNMjkE22CvK4HuUxqN7oIz5pWuETq1lQAjqlSlqdD2Rnr/ggp/TVkQYjn9lMfYelk2sH5HPdopYo7MHwlV1or9Bxf+QCyLzm92vzG2wjiIjC/ZHEJzeroJl6bdFPTpZho5MV2U86fLQqxNlGIMqCGy+9WYhJ8ob1r0+Whxde9L2PdysETv97O+xVw+VNN1TZSQN5I6l9m5Ip6pLIqLm4a1B1ffH6gHyqT9p82NOjntRWGIofO3bJz5GhkvSWbsXueTAMaJDou99kGLqDlhwBZNEQ4mKPuDvVwSK4WmLluHyhA97pZiVe8g+JxmnJF8IkV/tCs4Jq/HgOoAEGR9tCDsDbDmi3OviUQpG5D8XmKcSAUaFLRXb2lmJTNYdhtYyfjBYZQmN5qT5CNuaD3BVnlkCk7bsMW3AtXkNMMTuW4HjUERSJnVQ0vsBGa1wo3Qh7115XGeTF3NTz8w0440AgU7c3bSXO/KMINaIWXd0oLpoq/0/QJxCQSJ9XnYy1W7TYLBJpHsVWD1ahsA7FjNvRd6mxCiHsm8g6Z0pnzqIpF1dHUtP2ITU5Z1hZHbu+L3BEEStBbL9XYvGfEakv1bmf+bOZGnoiuHEdlBnaChxYKNzB23b8sw8YyT7Ajxfk49eJIAvdbVkdFCe2J0gMefhQ0bIZxhx3fzMIysQNiN8PgOUKxOMur10LduigREDRMZyP4oGWrP1GFY4t6groASsZ421os48wAdnrbovNhLt7ScNULkwZ5AIZJTrbaKYTLjA1oJ3sIuN/aYocm/9uoQHEIlacF1s/TM1fLcPTL38O9fOsjMEIwoPKfvt7opuI9G2Hf/PR4aCLDQ7wNmIdEuXJ/QNL72k5q4NejAldPfe3UVVqzkys8YZ/jYOGOp6c+YzRCrCuq0M11y7TiN6qk7YXRMn/gukxrEimbMQjr3jwRM6dKVZ4RUfWQr8noPXLJq6yh5R3EH1IVOHESst/LItbG2D2vRsZRkAObzvQAAD3mb3/G4NzopI0FAiHfbpq0X72adg6SRj+8OHMShtFxxLZlf/nLgRLbClwl5WmaYSs+yEjkq48tY7Z2bE0N91mJwt+ua0NlRJIDh0HikF4UvSVorFj2YVu9YeS5tfvlVjPSoNu/Zu6dEUfBOT555hahBdN3Sa5Xuj2Rvau1lQNIaC944y0RWj9UiNDskAK1WoL+EfXcC6IbBXFRyVfX/WKXxPAwUyIAGW8ggZ08hcijKTt1YKnUO6QPvcrmDVAb0FCLIXn5id4fD/Jx4tw/gbXs7WF9b2RgXtPhLBG9vF5FEkdHAKrQHZAJC/HWvk7nvzzDzIXZlfFTJoC3JpGgLPBY7SQTjGlUvG577yNutZ1hTfs9/1nkSXK9zzKLRZ3VODeKUovJe0WCq1zVMYxCJMenmNzPIU2S8TA4E7wWmbNkxq9rI2dd6v0VpcAPVMxnDsvWTWFayyqvKZO7Z08a62i/oH2/jxf8rpmfO64in3FLiL1GX8IGtVE9M23yGsIqJbxDTy+LtaMWDaPqkymb5VrQdzOvqldeU0SUi6IirG8UZ3jcpRbwHa1C0Dww9G/SFX3gPvTJQE+kyz+g1BeMILKKO+olcHzctOWgzxYHnOD7dpCRtuZEXACjgqesZMasoPgnuDC4nUviAAxDc5pngjoAITIkvhKwg5d608pdrZcA+qn5TMT6Uo/QzBaOxBCLTJX3Mgk85rMfsnWx86oLxf7p2PX5ONqieTa/qM3tPw4ZXvlAp83NSD8F7+ZgctK1TpoYwtiU2h02HCGioH5tkVCqNVTMH5p00sRy2JU1qyDBP2CII/Dg4WDsIl+zgeX7589srx6YORRQMBfKbodbB743Tl4WLKOEnwWUVBsm94SOlCracU72MSyj068wdpYjyz1FwC2bjQnxnB6Mp/pZ+yyZXtguEaYB+kqhjQ6UUmwSFazOb+rhYjLaoiM+aN9/8KKn0zaCTFpN9eKwWy7/u4EHzO46TdFSNjMfn2iPSJwDPCFHc0I1+vjdAZw5ZjqR/uzi9Zn20oAa5JnLEk/EA3VRWE7J/XrupfFJPtCUuqHPpnlL7ISJtRpSVcB8qsZCm2QEkWoROtCKKxUh3yEcMbWYJwk6DlEBG0bZP6eg06FL3v6RPb7odGuwm7FN8fG4woqtB8e7M5klPpo97GoObNwt+ludTAmxyC5hmcFx+dIvEZKI6igFKHqLH01iY1o7903VzG9QGetyVx5RNmBYUU+zIuSva/yIcECUi4pRmE3VkF2avqulQEUY4yZ/wmNboBzPmAPey3+dSYtBZUjeWWT0pPwCz4Vozxp9xeClIU60qvEFMQCaPvPaA70WlOP9f/ey39macvpGCVa+zfa8gO44wbxpJUlC8GN/pRMTQtzY8Z8/hiNrU+Zq64ZfFGIkdj7m7abcK1EBtws1X4J/hnqvasPvvDSDYWN+QcQVGMqXalkDtTad5rYY0TIR1Eqox3czwPMjKPvF5sFv17Thujr1IZ1Ytl4VX1J0vjXKmLY4lmXipRAro0qVGEcXxEVMMEl54jQMd4J7RjgomU0j1ptjyxY+cLiSyXPfiEcIS2lWDK3ISAy6UZ3Hb5vnPncA94411jcy75ay6B6DSTzK6UTCZR9uDANtPBrvIDgjsfarMiwoax2OlLxaSoYn4iRgkpEGqEkwox5tyI8aKkLlfZ12lO11TxsqRMY89j5JaO55XfPJPDL1LGSnC88Re9Ai+Nu5bZjtwRrvFITUFHPR4ZmxGslQMecgbZO7nHk32qHxYkdvWpup07ojcMCaVrpFAyFZJJbNvBpZfdf39Hdo2kPtT7v0/f8R/B5Nz4f1t9/3zNM/7n6SUHfcWk5dfQFJvcJMgPolGCpOFb/WC0FGWU2asuQyT+rm88ZKZ78Cei/CAh939CH0JYbpZIPtxc2ufXqjS3pHH9lnWK4iJ7OjR/EESpCo2R3MYKyE7rHfhTvWho4cL1QdN4jFTyR6syMwFm124TVDDRXMNveI1Dp/ntwdz8k8kxw7iFSx6+Yx6O+1LzMVrN0BBzziZi9kneZSzgollBnVwBh6oSOPHXrglrOj+QmR/AESrhDpKrWT+8/AiMDxS/5wwRNuGQPLlJ9ovomhJWn8sMLVItQ8N/7IXvtD8kdOoHaw+vBSbFImQsv/OCAIui99E+YSIOMlMvBXkAt+NAZK8wB9Jf8CPtB+TOUOR+z71d/AFXpPBT6+A5FLjxMjLIEoJzrQfquvxEIi+WoUzGR1IzQFNvbYOnxb2PyQ0kGdyXKzW2axQL8lNAXPk6NEjqrRD1oZtKLlFoofrXw0dCNWASHzy+7PSzOUJ3XtaPZsxLDjr+o41fKuKWNmjiZtfkOzItvlV2MDGSheGF0ma04qE3TUEfqJMrXFm7DpK+27DSvCUVf7rbNoljPhha5W7KBqVq0ShUSTbRmuqPtQreVWH4JET5yMhuqMoSd4r/N8sDmeQiQQvi1tcZv7Moc7dT5X5AtCD6kNEGZOzVcNYlpX4AbTsLgSYYliiPyVoniuYYySxsBy5cgb3pD+EK0Gpb0wJg031dPgaL8JZt6sIvzNPEHfVPOjXmaXj4bd4voXzpZ5GApMhILgMbCEWZ2zwgdeQgjNHLbPIt+KqxRwWPLTN6HwZ0Ouijj4UF+Sg0Au8XuIKW0WxlexdrFrDcZJ8Shauat3X0XmHygqgL1nAu2hrJFb4wZXkcS+i36KMyU1yFvYv23bQUJi/3yQpqr/naUOoiEWOxckyq/gq43dFou1DVDaYMZK9tho7+IXXokBCs5GRfOcBK7g3A+jXQ39K4YA8PBRW4m5+yR0ZAxWJncjRVbITvIAPHYRt1EJ3YLiUbqIvoKHtzHKtUy1ddRUQ0AUO41vonZDUOW+mrszw+SW/6Q/IUgNpcXFjkM7F4CSSQ2ExZg85otsMs7kqsQD4OxYeBNDcSpifjMoLb7GEbGWTwasVObmB/bfPcUlq0wYhXCYEDWRW02TP5bBrYsKTGWjnWDDJ1F7zWai0zW/2XsCuvBQjPFcTYaQX3tSXRSm8hsAoDdjArK/OFp6vcWYOE7lizP0Yc+8p16i7/NiXIiiQTp7c7Xus925VEtlKAjUdFhyaiLT7VxDagprMFwix4wZ05u0qj7cDWFd0W9OYHIu3JbJKMXRJ1aYNovugg+QqRN7fNHSi26VSgBpn+JfMuPo3aeqPWik/wI5Rz3BWarPQX4i5+dM0npwVOsX+KsOhC7vDg+OJsz4Q5zlnIeflUWL6QYMbf9WDfLmosLF4Qev3mJiOuHjoor/dMeBpA9iKDkMjYBNbRo414HCxjsHrB4EXNbHzNMDHCLuNBG6Sf+J4MZ/ElVsDSLxjIiGsTPhw8BPjxbfQtskj+dyNMKOOcUYIRBEIqbazz3lmjlRQhplxq673VklMMY6597vu+d89ec/zq7Mi4gQvh87ehYbpOuZEXj5g/Q7S7BFDAAB9DzG35SC853xtWVcnZQoH54jeOqYLR9NDuwxsVthTV7V99n/B7HSbAytbEyVTz/5NhJ8gGIjG0E5j3griULUd5Rg7tQR+90hJgNQKQH2btbSfPcaTOfIexc1db1BxUOhM1vWCpLaYuKr3FdNTt/T3PWCpEUWDKEtzYrjpzlL/wri3MITKsFvtF8QVV/NhVo97aKIBgdliNc10dWdXVDpVtsNn+2UIolrgqdWA4EY8so0YvB4a+aLzMXiMAuOHQrXY0tr+CL10JbvZzgjJJuB1cRkdT7DUqTvnswVUp5kkUSFVtIIFYK05+tQxT6992HHNWVhWxUsD1PkceIrlXuUVRogwmfdhyrf6zzaL8+c0L7GXMZOteAhAVQVwdJh+7nrX7x4LaIIfz2F2v7Dg/uDfz2Fa+4gFm2zHAor8UqimJG3VTJtZEoFXhnDYXvxMJFc6ku2bhbCxzij2z5UNuK0jmp1mnvkVNUfR+SEmj1Lr94Lym75PO7Fs0MIr3GdsWXRXSfgLTVY0FLqba97u1In8NAcY7IC6TjWLigwKEIm43NxTdaVTv9mcKkzuzBkKd8x/xt1p/9BbP7Wyb4bpo1K1gnOpbLvKz58pWl3B55RJ/Z5mRDLPtNQg14jdOEs9+h/V5UVpwrAI8kGbX8KPVPDIMfIqKDjJD9UyDOPhjZ3vFAyecwyq4akUE9mDOtJEK1hpDyi6Ae87sWAClXGTiwPwN7PXWwjxaR79ArHRIPeYKTunVW24sPr/3HPz2IwH8oKH4OlWEmt4BLM6W5g4kMcYbLwj2usodD1088stZA7VOsUSpEVl4w7NMb1EUHMRxAxLF0CIV+0L3iZb+ekB1vSDSFjAZ3hfLJf7gFaXrOKn+mhR+rWw/eTXIcAgl4HvFuBg1LOmOAwJH3eoVEjjwheKA4icbrQCmvAtpQ0mXG0agYp5mj4Rb6mdQ+RV4QBPbxMqh9C7o8nP0Wko2ocnCHeRGhN1XVyT2b9ACsL+6ylUy+yC3QEnaKRIJK91YtaoSrcWZMMwxuM0E9J68Z+YyjA0g8p1PfHAAIROy6Sa04VXOuT6A351FOWhKfTGsFJ3RTJGWYPoLk5FVK4OaYR9hkJvezwF9vQN1126r6isMGXWTqFW+3HL3I/jurlIdDWIVvYY+s6yq7lrFSPAGRdnU7PVwY/SvWbZGpXzy3BQ2LmAJlrONUsZs4oGkly0V267xbD5KMY8woNNsmWG1VVgLCra8aQBBcI4DP2BlNwxhiCtHlaz6OWFoCW0vMR3ErrG7JyMjTSCnvRcsEHgmPnwA6iNpJ2DrFb4gLlhKJyZGaWkA97H6FFdwEcLT6DRQQL++fOkVC4cYGW1TG/3iK5dShRSuiBulmihqgjR45Vi03o2RbQbP3sxt90VxQ6vzdlGfkXmmKmjOi080JSHkLntjvsBJnv7gKscOaTOkEaRQqAnCA4HWtB4XnMtOhpRmH2FH8tTXrIjAGNWEmudQLCkcVlGTQ965Kh0H6ixXbgImQP6b42B49sO5C8pc7iRlgyvSYvcnH9FgQ3azLbQG2cUW96SDojTQStxkOJyOuDGTHAnnWkz29aEwN9FT8EJ4yhXOg+jLTrCPKeEoJ9a7lDXOjEr8AgX4BmnMQ668oW0zYPyQiVMPxKRHtpfnEEyaKhdzNVThlxxDQNdrHeZiUFb6NoY2KwvSb7BnRcpJy+/g/zAYx3fYSN5QEaVD2Y1VsNWxB0BSO12MRsRY8JLfAezRMz5lURuLUnG1ToKk6Q30FughqWN6gBNcFxP/nY/iv+iaUQOa+2Nuym46wtI/DvSfzSp1jEi4SdYBE7YhTiVV5cX9gwboVDMVgZp5YBQlHOQvaDNfcCoCJuYhf5kz5kwiIKPjzgpcRJHPbOhJajeoeRL53cuMahhV8Z7IRr6M4hW0JzT7mzaMUzQpm866zwM7Cs07fJYXuWvjAMkbe5O6V4bu71sOG6JQ4oL8zIeXHheFVavzxmlIyBkgc9IZlEDplMPr8xlcyss4pVUdwK1e7CK2kTsSdq7g5SHRAl3pYUB9Ko4fsh4qleOyJv1z3KFSTSvwEcRO/Ew8ozEDYZSqpfoVW9uhJfYrNAXR0Z3VmeoAD+rVWtwP/13sE/3ICX3HhDG3CMc476dEEC0K3umSAD4j+ZQLVdFOsWL2C1TH5+4KiSWH+lMibo+B55hR3Gq40G1n25sGcN0mEcoU2wN9FCVyQLBhYOu9aHVLWjEKx2JIUZi5ySoHUAI9b8hGzaLMxCZDMLhv8MkcpTqEwz9KFDpCpqQhVmsGQN8m24wyB82FAKNmjgfKRsXRmsSESovAwXjBIoMKSG51p6Um8b3i7GISs7kjTq/PZoioCfJzfKdJTN0Q45kQEQuh9H88M3yEs3DbtRTKALraM0YC8laiMiOOe6ADmTcCiREeAWZelBaEXRaSuj2lx0xHaRYqF65O0Lo5OCFU18A8cMDE4MLYm9w2QSr9NgQAIcRxZsNpA7UJR0e71JL+VU+ISWFk5I97lra8uGg7GlQYhGd4Gc6rxsLFRiIeGO4abP4S4ekQ1fiqDCy87GZHd52fn5aaDGuvOmIofrzpVwMvtbreZ/855OaXTRcNiNE0wzGZSxbjg26v8ko8L537v/XCCWP2MFaArJpvnkep0pA+O86MWjRAZPQRfznZiSIaTppy6m3p6HrNSsY7fDtz7Cl4V/DJAjQDoyiL2uwf1UHVd2AIrzBUSlJaTj4k6NL97a/GqhWKU9RUmjnYKpm2r+JYUcrkCuZKvcYvrg8pDoUKQywY9GDWg03DUFSirlUXBS5SWn/KAntnf0IdHGL/7mwXqDG+LZYjbEdQmqUqq4y54TNmWUP7IgcAw5816YBzwiNIJiE9M4lPCzeI/FGBeYy3p6IAmH4AjXXmvQ4Iy0Y82NTobcAggT2Cdqz6Mx4TdGoq9fn2etrWKUNFyatAHydQTVUQ2S5OWVUlugcNvoUrlA8cJJz9MqOa/W3iVno4zDHfE7zhoY5f5lRTVZDhrQbR8LS4eRLz8iPMyBL6o4PiLlp89FjdokQLaSBmKHUwWp0na5fE3v9zny2YcDXG/jfI9sctulHRbdkI5a4GOPJx4oAJQzVZ/yYAado8KNZUdEFs9ZPiBsausotXMNebEgr0dyopuqfScFJ3ODNPHgclACPdccwv0YJGQdsN2lhoV4HVGBxcEUeUX/alr4nqpcc1CCR3vR7g40zteQg/JvWmFlUE4mAiTpHlYGrB7w+U2KdSwQz2QJKBe/5eiixWipmfP15AFWrK8Sh1GBBYLgzki1wTMhGQmagXqJ2+FuqJ8f0XzXCVJFHQdMAw8xco11HhM347alrAu+wmX3pDFABOvkC+WPX0Uhg1Z5MVHKNROxaR84YV3s12UcM+70cJ460SzEaKLyh472vOMD3XnaK7zxZcXlWqenEvcjmgGNR2OKbI1s8U+iwiW+HotHalp3e1MGDy6BMVIvajnAzkFHbeVsgjmJUkrP9OAwnEHYXVBqYx3q7LvXjoVR0mY8h+ZaOnh053pdsGkmbqhyryN01eVHySr+CkDYkSMeZ1xjPNVM+gVLTDKu2VGsMUJqWO4TwPDP0VOg2/8ITbAUaMGb4LjL7L+Pi11lEVMXTYIlAZ/QHmTENjyx3kDkBdfcvvQt6tKk6jYFM4EG5UXDTaF5+1ZjRz6W7MdJPC+wTkbDUim4p5QQH3b9kGk2Bkilyeur8Bc20wm5uJSBO95GfYDI1EZipoRaH7uVveneqz43tlTZGRQ4a7CNmMHgXyOQQOL6WQkgMUTQDT8vh21aSdz7ERiZT1jK9F+v6wgFvuEmGngSvIUR2CJkc5tx1QygfZnAruONobB1idCLB1FCfO7N1ZdRocT8/Wye+EnDiO9pzqIpnLDl4bkaRKW+ekBVwHn46Shw1X0tclt/0ROijuUB4kIInrVJU4buWf4YITJtjOJ6iKdr1u+flgQeFH70GxKjhdgt/MrwfB4K/sXczQ+9zYcrD4dhY6qZhZ010rrxggWA8JaZyg2pYij8ieYEg1aZJkZK9O1Re7sB0iouf60rK0Gd+AYlp7soqCBCDGwfKeUQhCBn0E0o0GS6PdmjLi0TtCYZeqazqwN+yNINIA8Lk3iPDnWUiIPLGNcHmZDxfeK0iAdxm/T7LnN+gemRL61hHIc0NCAZaiYJR+OHnLWSe8sLrK905B5eEJHNlWq4RmEXIaFTmo49f8w61+NwfEUyuJAwVqZCLFcyHBKAcIVj3sNzfEOXzVKIndxHw+AR93owhbCxUZf6Gs8cz6/1VdrFEPrv330+9s6BtMVPJ3zl/Uf9rUi0Z/opexfdL3ykF76e999GPfVv8fJv/Y/+/5hEMon1tqNFyVRevV9y9/uIvsG3dbB8GRRrgaEXfhx+2xeOFt+cEn3RZanNxdEe2+B6MHpNbrRE53PlDifPvFcp4kO78ILR0T4xyW/WGPyBsqGdoA7zJJCu1TKbGfhnqgnRbxbB2B3UZoeQ2bz2sTVnUwokTcTU21RxN1PYPS3Sar7T0eRIsyCNowr9amwoMU/od9s2APtiKNL6ENOlyKADstAEWKA+sdKDhrJ6BOhRJmZ+QJbAaZ3/5Fq0/lumCgEzGEbu3yi0Y4I4EgVAjqxh4HbuQn0GrRhOWyAfsglQJAVL1y/6yezS2k8RE2MstJLh92NOB3GCYgFXznF4d25qiP4ZCyI4RYGesut6FXK6GwPpKK8WHEkhYui0AyEmr5Ml3uBFtPFdnioI8RiCooa7Z1G1WuyIi3nSNglutc+xY8BkeW3JJXPK6jd2VIMpaSxpVtFq+R+ySK9J6WG5Qvt+C+QH1hyYUOVK7857nFmyDBYgZ/o+AnibzNVqyYCJQvyDXDTK+iXdkA71bY7TL3bvuLxLBQ8kbTvTEY9aqkQ3+MiLWbEgjLzOH+lXgco1ERgzd80rDCymlpaRQbOYnKG/ODoFl46lzT0cjM5FYVvv0qLUbD5lyJtMUaC1pFlTkNONx6lliaX9o0i/1vws5bNKn5OuENQEKmLlcP4o2ZmJjD4zzd3Fk32uQ4uRWkPSUqb4LBe3EXHdORNB2BWsws5daRnMfNVX7isPSb1hMQdAJi1/qmDMfRUlCU74pmnzjbXfL8PVG8NsW6IQM2Ne23iCPIpryJjYbVnm5hCvKpMa7HLViNiNc+xTfDIaKm3jctViD8A1M9YPJNk003VVr4Zo2MuGW8vil8SLaGpPXqG7I4DLdtl8a4Rbx1Lt4w5Huqaa1XzZBtj208EJVGcmKYEuaeN27zT9EE6a09JerXdEbpaNgNqYJdhP1NdqiPKsbDRUi86XvvNC7rME5mrSQtrzAZVndtSjCMqd8BmaeGR4l4YFULGRBeXIV9Y4yxLFdyoUNpiy2IhePSWzBofYPP0eIa2q5JP4j9G8at/AqoSsLAUuRXtvgsqX/zYwsE+of6oSDbUOo4RMJw+DOUTJq+hnqwKim9Yy/napyZNTc2rCq6V9jHtJbxGPDwlzWj/Sk3zF/BHOlT/fSjSq7FqlPI1q6J+ru8Aku008SFINXZfOfnZNOvGPMtEmn2gLPt+H4QLA+/SYe4j398auzhKIp2Pok3mPC5q1IN1HgR+mnEfc4NeeHYwd2/kpszR3cBn7ni9NbIqhtSWFW8xbUJuUPVOeeXu3j0IGZmFNiwaNZ6rH4/zQ2ODz6tFxRLsUYZu1bfd1uIvfQDt4YD/efKYv8VF8bHGDgK22w2Wqwpi43vNCOXFJZCGMqWiPbL8mil6tsmOTXAWCyMCw73e2rADZj2IK6rqksM3EXF2cbLb4vjB14wa/yXK5vwU+05MzERJ5nXsXsW21o7M+gO0js2OyKciP5uF2iXyb2DiptwQeHeqygkrNsqVCSlldxBMpwHi1vfc8RKpP/4L3Lmpq6DZcvhDDfxTCE3splacTcOtXdK2g303dIWBVe2wD/Gvja1cClFQ67gw0t1ZUttsUgQ1Veky8oOpS6ksYEc4bqseCbZy766SvL3FodmnahlWJRgVCNjPxhL/fk2wyvlKhITH/VQCipOI0dNcRa5B1M5HmOBjTLeZQJy237e2mobwmDyJNHePhdDmiknvLKaDbShL+Is1XTCJuLQd2wmdJL7+mKvs294whXQD+vtd88KKk0DXP8B1Xu9J+xo69VOuFgexgTrcvI6SyltuLix9OPuE6/iRJYoBMEXxU4shQMf4Fjqwf1PtnJ/wWSZd29rhZjRmTGgiGTAUQqRz+nCdjeMfYhsBD5Lv60KILWEvNEHfmsDs2L0A252351eUoYxAysVaCJVLdH9QFWAmqJDCODUcdoo12+gd6bW2boY0pBVHWL6LQDK5bYWh1V8vFvi0cRpfwv7cJiMX3AZNJuTddHehTIdU0YQ/sQ1dLoF2xQPcCuHKiuCWOY30DHe1OwcClLAhqAKyqlnIbH/8u9ScJpcS4kgp6HKDUdiOgRaRGSiUCRBjzI5gSksMZKqy7Sd51aeg0tgJ+x0TH9YH2Mgsap9N7ENZdEB0bey2DMTrBA1hn56SErNHf3tKtqyL9b6yXEP97/rc+jgD2N1LNUH6RM9AzP3kSipr06RkKOolR7HO768jjWiH1X92jA7dkg7gcNcjqsZCgfqWw0tPXdLg20cF6vnQypg7gLtkazrHAodyYfENPQZsdfnjMZiNu4nJO97D1/sQE+3vNFzrSDOKw+keLECYf7RJwVHeP/j79833oZ0egonYB2FlFE5qj02B/LVOMJQlsB8uNg3Leg4qtZwntsOSNidR0abbZmAK4sCzvt8Yiuz2yrNCJoH5O8XvX/vLeR/BBYTWj0sOPYM/jyxRd5+/JziKAABaPcw/34UA3aj/gLZxZgRCWN6m4m3demanNgsx0P237/Q+Ew5VYnJPkyCY0cIVHoFn2Ay/e7U4P19APbPFXEHX94N6KhEMPG7iwB3+I+O1jd5n6VSgHegxgaSawO6iQCYFgDsPSMsNOcUj4q3sF6KzGaH/0u5PQoAj/8zq6Uc9MoNrGqhYeb2jQo0WlGlXjxtanZLS24/OIN5Gx/2g684BPDQpwlqnkFcxpmP/osnOXrFuu4PqifouQH0eF5qCkvITQbJw/Zvy5mAHWC9oU+cTiYhJmSfKsCyt1cGVxisKu+NymEQIAyaCgud/V09qT3nk/9s/SWsYtha7yNpzBIMM40rCSGaJ9u6lEkl00vXBiEt7p9P5IBCiavynEOv7FgLqPdeqxRiCwuFVMolSIUBcoyfUC2e2FJSAUgYdVGFf0b0Kn2EZlK97yyxrT2MVgvtRikfdaAW8RwEEfN+B7/eK8bBdp7URpbqn1xcrC6d2UjdsKbzCjBFqkKkoZt7Mrhg6YagE7spkqj0jOrWM+UGQ0MUlG2evP1uE1p2xSv4dMK0dna6ENcNUF+xkaJ7B764NdxLCpuvhblltVRAf7vK5qPttJ/9RYFUUSGcLdibnz6mf7WkPO3MkUUhR2mAOuGv8IWw5XG1ZvoVMnjSAZe6T7WYA99GENxoHkMiKxHlCuK5Gd0INrISImHQrQmv6F4mqU/TTQ8nHMDzCRivKySQ8dqkpQgnUMnwIkaAuc6/FGq1hw3b2Sba398BhUwUZSAIO8XZvnuLdY2n6hOXws+gq9BHUKcKFA6kz6FDnpxLPICa3qGhnc97bo1FT/XJk48LrkHJ2CAtBv0RtN97N21plfpXHvZ8gMJb7Zc4cfI6MbPwsW7AilCSXMFIEUEmir8XLEklA0ztYbGpTTGqttp5hpFTTIqUyaAIqvMT9A/x+Ji5ejA4Bhxb/cl1pUdOD6epd3yilIdO6j297xInoiBPuEDW2/UfslDyhGkQs7Wy253bVnlT+SWg89zYIK/9KXFl5fe+jow2rd5FXv8zDPrmfMXiUPt9QBO/iK4QGbX5j/7Rx1c1vzsY8ONbP3lVIaPrhL4+1QrECTN3nyKavGG0gBBtHvTKhGoBHgMXHStFowN+HKrPriYu+OZ05Frn8okQrPaaxoKP1ULCS/cmKFN3gcH7HQlVjraCeQmtjg1pSQxeuqXiSKgLpxc/1OiZsU4+n4lz4hpahGyWBURLi4642n1gn9qz9bIsaCeEPJ0uJmenMWp2tJmIwLQ6VSgDYErOeBCfSj9P4G/vI7oIF+l/n5fp956QgxGvur77ynawAu3G9MdFbJbu49NZnWnnFcQHjxRuhUYvg1U/e84N4JTecciDAKb/KYIFXzloyuE1eYXf54MmhjTq7B/yBToDzzpx3tJCTo3HCmVPYfmtBRe3mPYEE/6RlTIxbf4fSOcaKFGk4gbaUWe44hVk9SZzhW80yfW5QWBHxmtUzvMhfVQli4gZTktIOZd9mjJ5hsbmzttaHQB29Am3dZkmx3g/qvYocyhZ2PXAWsNQiIaf+Q8W/MWPIK7/TjvCx5q2XRp4lVWydMc2wIQkhadDB0xsnw/kSEyGjLKjI4coVIwtubTF3E7MJ6LS6UOsJKj82XVAVPJJcepfewbzE91ivXZvOvYfsmMevwtPpfMzGmC7WJlyW2j0jh7AF1JLmwEJSKYwIvu6DHc3YnyLH9ZdIBnQ+nOVDRiP+REpqv++typYHIvoJyICGA40d8bR7HR2k7do6UQTHF4oriYeIQbxKe4Th6+/l1BjUtS9hqORh3MbgvYrStXTfSwaBOmAVQZzpYNqsAmQyjY56MUqty3c/xH6GuhNvNaG9vGbG6cPtBM8UA3e8r51D0AR9kozKuGGSMgLz3nAHxDNnc7GTwpLj7/6HeWp1iksDeTjwCLpxejuMtpMnGJgsiku1sOACwQ9ukzESiDRN77YNESxR5LphOlcASXA5uIts1LnBIcn1J7BLWs49DMALSnuz95gdOrTZr0u1SeYHinno/pE58xYoXbVO/S+FEMMs5qyWkMnp8Q3ClyTlZP52Y9nq7b8fITPuVXUk9ohG5EFHw4gAEcjFxfKb3xuAsEjx2z1wxNbSZMcgS9GKyW3R6KwJONgtA64LTyxWm8Bvudp0M1FdJPEGopM4Fvg7G/hsptkhCfHFegv4ENwxPeXmYhxwZy7js+BeM27t9ODBMynVCLJ7RWcBMteZJtvjOYHb5lOnCLYWNEMKC59BA7covu1cANa2PXL05iGdufOzkgFqqHBOrgQVUmLEc+Mkz4Rq8O6WkNr7atNkH4M8d+SD1t/tSzt3oFql+neVs+AwEI5JaBJaxARtY2Z4mKoUqxds4UpZ0sv3zIbNoo0J4fihldQTX3XNcuNcZmcrB5LTWMdzeRuAtBk3cZHYQF6gTi3PNuDJ0nmR+4LPLoHvxQIxRgJ9iNNXqf2SYJhcvCtJiVWo85TsyFOuq7EyBPJrAdhEgE0cTq16FQXhYPJFqSfiVn0IQnPOy0LbU4BeG94QjdYNB0CiQ3QaxQqD2ebSMiNjaVaw8WaM4Z5WnzcVDsr4eGweSLa2DE3BWViaxhZFIcSTjgxNCAfelg+hznVOYoe5VqTYs1g7WtfTm3e4/WduC6p+qqAM8H4ZyrJCGpewThTDPe6H7CzX/zQ8Tm+r65HeZn+MsmxUciEWPlAVaK/VBaQBWfoG/aRL/jSZIQfep/89GjasWmbaWzeEZ2R1FOjvyJT37O9B8046SRSKVEnXWlBqbkb5XCS3qFeuE9xb9+frEknxWB5h1D/hruz2iVDEAS7+qkEz5Ot5agHJc7WCdY94Ws61sURcX5nG8UELGBAHZ3i+3VulAyT0nKNNz4K2LBHBWJcTBX1wzf+//u/j/9+//v87+9/l9Lbh/L/uyNYiTsWV2LwsjaA6MxTuzFMqmxW8Jw/+IppdX8t/Clgi1rI1SN0UC/r6tX/4lUc2VV1OQReSeCsjUpKZchw4XUcjHfw6ryCV3R8s6VXm67vp4n+lcPV9gJwmbKQEsmrJi9c2vkwrm8HFbVYNTaRGq8D91t9n5+U+aD/hNtN3HjC/nC/vUoGFSCkXP+NlRcmLUqLbiUBl4LYf1U/CCvwtd3ryCH8gUmGITAxiH1O5rnGTz7y1LuFjmnFGQ1UWuM7HwfXtWl2fPFKklYwNUpF2IL/TmaRETjQiM5SJacI+3Gv5MBU8lP5Io6gWkawpyzNEVGqOdx4YlO1dCvjbWFZWbCmeiFKPSlMKtKcMFLs/KQxtgAHi7NZNCQ32bBAW2mbHflVZ8wXKi1JKVHkW20bnYnl3dKWJeWJOiX3oKPBD6Zbi0ZvSIuWktUHB8qDR8DMMh1ZfkBL9FS9x5r0hBGLJ8pUCJv3NYH+Ae8p40mZWd5m5fhobFjQeQvqTT4VKWIYfRL0tfaXKiVl75hHReuTJEcqVlug+eOIIc4bdIydtn2K0iNZPsYWQvQio2qbO3OqAlPHDDOB7DfjGEfVF51FqqNacd6QmgFKJpMfLp5DHTv4wXlONKVXF9zTJpDV4m1sYZqJPhotcsliZM8yksKkCkzpiXt+EcRQvSQqmBS9WdWkxMTJXPSw94jqI3varCjQxTazjlMH8jTS8ilaW8014/vwA/LNa+YiFoyyx3s/KswP3O8QW1jtq45yTM/DX9a8M4voTVaO2ebvw1EooDw/yg6Y1faY+WwrdVs5Yt0hQ5EwRfYXSFxray1YvSM+kYmlpLG2/9mm1MfmbKHXr44Ih8nVKb1M537ZANUkCtdsPZ80JVKVKabVHCadaLXg+IV8i5GSwpZti0h6diTaKs9sdpUKEpd7jDUpYmHtiX33SKiO3tuydkaxA7pEc9XIQEOfWJlszj5YpL5bKeQyT7aZSBOamvSHl8xsWvgo26IP/bqk+0EJUz+gkkcvlUlyPp2kdKFtt7y5aCdks9ZJJcFp5ZWeaWKgtnXMN3ORwGLBE0PtkEIek5FY2aVssUZHtsWIvnljMVJtuVIjpZup/5VL1yPOHWWHkOMc6YySWMckczD5jUj2mlLVquFaMU8leGVaqeXis+aRRL8zm4WuBk6cyWfGMxgtr8useQEx7k/PvRoZyd9nde1GUCV84gMX8Ogu/BWezYPSR27llzQnA97oo0pYyxobYUJfsj+ysTm9zJ+S4pk0TGo9VTG0KjqYhTmALfoDZVKla2b5yhv241PxFaLJs3i05K0AAIdcGxCJZmT3ZdT7CliR7q+kur7WdQjygYtOWRL9B8E4s4LI8KpAj7bE0dg7DLOaX+MGeAi0hMMSSWZEz+RudXbZCsGYS0QqiXjH9XQbd8sCB+nIVTq7/T/FDS+zWY9q7Z2fdq1tdLb6v3hKKVDAw5gjj6o9r1wHFROdHc18MJp4SJ2Ucvu+iQ9EgkekW8VCM+psM6y+/2SBy8tNN4a3L1MzP+OLsyvESo5gS7IQOnIqMmviJBVc6zbVG1n8eXiA3j46kmvvtJlewwNDrxk4SbJOtP/TV/lIVK9ueShNbbMHfwnLTLLhbZuO79ec5XvfgRwLFK+w1r5ZWW15rVFZrE+wKqNRv5KqsLNfpGgnoUU6Y71NxEmN7MyqwqAQqoIULOw/LbuUB2+uE75gJt+kq1qY4LoxV+qR/zalupea3D5+WMeaRIn0sAI6DDWDh158fqUb4YhAxhREbUN0qyyJYkBU4V2KARXDT65gW3gRsiv7xSPYEKLwzgriWcWgPr0sbZnv7m1XHNFW6xPdGNZUdxFiUYlmXNjDVWuu7LCkX/nVkrXaJhiYktBISC2xgBXQnNEP+cptWl1eG62a7CPXrnrkTQ5BQASbEqUZWMDiZUisKyHDeLFOaJILUo5f6iDt4ZO8MlqaKLto0AmTHVVbkGuyPa1R/ywZsWRoRDoRdNMMHwYTsklMVnlAd2S0282bgMI8fiJpDh69OSL6K3qbo20KfpNMurnYGQSr/stFqZ7hYsxKlLnKAKhsmB8AIpEQ4bd/NrTLTXefsE6ChRmKWjXKVgpGoPs8GAicgKVw4K0qgDgy1A6hFq1WRat3fHF+FkU+b6H4NWpOU3KXTxrIb2qSHAb+qhm8hiSROi/9ofapjxhyKxxntPpge6KL5Z4+WBMYkAcE6+0Hd3Yh2zBsK2MV3iW0Y6cvOCroXlRb2MMJtdWx+3dkFzGh2Pe3DZ9QpSqpaR/rE1ImOrHqYYyccpiLC22amJIjRWVAherTfpQLmo6/K2pna85GrDuQPlH1Tsar8isAJbXLafSwOof4gg9RkAGm/oYpBQQiPUoyDk2BCQ1k+KILq48ErFo4WSRhHLq/y7mgw3+L85PpP6xWr6cgp9sOjYjKagOrxF148uhuaWtjet953fh1IQiEzgC+d2IgBCcUZqgTAICm2bR8oCjDLBsmg+ThyhfD+zBalsKBY1Ce54Y/t9cwfbLu9SFwEgphfopNA3yNxgyDafUM3mYTovZNgPGdd4ZFFOj1vtfFW3u7N+iHEN1HkeesDMXKPyoCDCGVMo4GCCD6PBhQ3dRZIHy0Y/3MaE5zU9mTCrwwnZojtE+qNpMSkJSpmGe0EzLyFelMJqhfFQ7a50uXxZ8pCc2wxtAKWgHoeamR2O7R+bq7IbPYItO0esdRgoTaY38hZLJ5y02oIVwoPokGIzxAMDuanQ1vn2WDQ00Rh6o5QOaCRu99fwDbQcN0XAuqkFpxT/cfz3slGRVokrNU0iqiMAJFEbKScZdmSkTUznC0U+MfwFOGdLgsewRyPKwBZYSmy6U325iUhBQNxbAC3FLKDV9VSOuQpOOukJ/GAmu/tyEbX9DgEp6dv1zoU0IqzpG6gssSjIYRVPGgU1QAQYRgIT8gEV0EXr1sqeh2I6rXjtmoCYyEDCe/PkFEi/Q48FuT29p557iN+LCwk5CK/CZ2WdAdfQZh2Z9QGrzPLSNRj5igUWzl9Vi0rCqH8G1Kp4QMLkuwMCAypdviDXyOIk0AHTM8HBYKh3b0/F+DxoNj4ZdoZfCpQVdnZarqoMaHWnMLNVcyevytGsrXQEoIbubqWYNo7NRHzdc0zvT21fWVirj7g36iy6pxogfvgHp1xH1Turbz8QyyHnXeBJicpYUctbzApwzZ1HT+FPEXMAgUZetgeGMwt4G+DHiDT2Lu+PT21fjJCAfV16a/Wu1PqOkUHSTKYhWW6PhhHUlNtWzFnA7MbY+r64vkwdpfNB2JfWgWXAvkzd42K4lN9x7Wrg4kIKgXCb4mcW595MCPJ/cTfPAMQMFWwnqwde4w8HZYJFpQwcSMhjVz4B8p6ncSCN1X4klxoIH4BN2J6taBMj6lHkAOs8JJAmXq5xsQtrPIPIIp/HG6i21xMGcFgqDXSRF0xQg14d2uy6HgKE13LSvQe52oShF5Jx1R6avyL4thhXQZHfC94oZzuPUBKFYf1VvDaxIrtV6dNGSx7DO0i1p6CzBkuAmEqyWceQY7F9+U0ObYDzoa1iKao/cOD/v6Q9gHrrr1uCeOk8fST9MG23Ul0KmM3r+Wn6Hi6WAcL7gEeaykicvgjzkjSwFsAXIR81Zx4QJ6oosVyJkCcT+4xAldCcihqvTf94HHUPXYp3REIaR4dhpQF6+FK1H0i9i7Pvh8owu3lO4PT1iuqu+DkL2Bj9+kdfGAg2TXw03iNHyobxofLE2ibjsYDPgeEQlRMR7afXbSGQcnPjI2D+sdtmuQ771dbASUsDndU7t58jrrNGRzISvwioAlHs5FA+cBE5Ccznkd8NMV6BR6ksnKLPZnMUawRDU1MZ/ib3xCdkTblHKu4blNiylH5n213yM0zubEie0o4JhzcfAy3H5qh2l17uLooBNLaO+gzonTH2uF8PQu9EyH+pjGsACTMy4cHzsPdymUSXYJOMP3yTkXqvO/lpvt0cX5ekDEu9PUfBeZODkFuAjXCaGdi6ew4qxJ8PmFfwmPpkgQjQlWqomFY6UkjmcnAtJG75EVR+NpzGpP1Ef5qUUbfowrC3zcSLX3BxgWEgEx/v9cP8H8u1Mvt9/rMDYf6sjwU1xSOPBgzFEeJLMRVFtKo5QHsUYT8ZRLCah27599EuqoC9PYjYO6aoAMHB8X1OHwEAYouHfHB3nyb2B+SnZxM/vw/bCtORjLMSy5aZoEpvgdGvlJfNPFUu/p7Z4VVK1hiI0/UTuB3ZPq4ohEbm7Mntgc1evEtknaosgZSwnDC2BdMmibpeg48X8Ixl+/8+xXdbshQXUPPvx8jT3fkELivHSmqbhblfNFShWAyQnJ3WBU6SMYSIpTDmHjdLVAdlADdz9gCplZw6mTiHqDwIsxbm9ErGusiVpg2w8Q3khKV/R9Oj8PFeF43hmW/nSd99nZzhyjCX3QOZkkB6BsH4H866WGyv9E0hVAzPYah2tkRfQZMmP2rinfOeQalge0ovhduBjJs9a1GBwReerceify49ctOh5/65ATYuMsAkVltmvTLBk4oHpdl6i+p8DoNj4Fb2vhdFYer2JSEilEwPd5n5zNoGBXEjreg/wh2NFnNRaIUHSOXa4eJRwygZoX6vnWnqVdCRT1ARxeFrNBJ+tsdooMwqnYhE7zIxnD8pZH+P0Nu1wWxCPTADfNWmqx626IBJJq6NeapcGeOmbtXvl0TeWG0Y7OGGV4+EHTtNBIT5Wd0Bujl7inXgZgfXTM5efD3qDTJ54O9v3Bkv+tdIRlq1kXcVD0BEMirmFxglNPt5pedb1AnxuCYMChUykwsTIWqT23XDpvTiKEru1cTcEMeniB+HQDehxPXNmkotFdwUPnilB/u4Nx5Xc6l8J9jH1EgKZUUt8t8cyoZleDBEt8oibDmJRAoMKJ5Oe9CSWS5ZMEJvacsGVdXDWjp/Ype5x0p9PXB2PAwt2LRD3d+ftNgpuyvxlP8pB84oB1i73vAVpwyrmXW72hfW6Dzn9Jkj4++0VQ4d0KSx1AsDA4OtXXDo63/w+GD+zC7w5SJaxsmnlYRQ4dgdjA7tTl2KNLnpJ+mvkoDxtt1a4oPaX3EVqj96o9sRKBQqU7ZOiupeAIyLMD+Y3YwHx30XWHB5CQiw7q3mj1EDlP2eBsZbz79ayUMbyHQ7s8gu4Lgip1LiGJj7NQj905/+rgUYKAA5qdrlHKIknWmqfuR+PB8RdBkDg/NgnlT89G72h2NvySnj7UyBwD+mi/IWs1xWbxuVwUIVXun5cMqBtFbrccI+DILjsVQg6eeq0itiRfedn89CvyFtpkxaauEvSANuZmB1p8FGPbU94J9medwsZ9HkUYjmI7OH5HuxendLbxTaYrPuIfE2ffXFKhoNBUp33HsFAXmCV/Vxpq5AYgFoRr5Ay93ZLRlgaIPjhZjXZZChT+aE5iWAXMX0oSFQEtwjiuhQQItTQX5IYrKfKB+queTNplR1Hoflo5/I6aPPmACwQCE2jTOYo5Dz1cs7Sod0KTG/3kEDGk3kUaUCON19xSJCab3kNpWZhSWkO8l+SpW70Wn3g0ciOIJO5JXma6dbos6jyisuxXwUUhj2+1uGhcvuliKtWwsUTw4gi1c/diEEpZHoKoxTBeMDmhPhKTx7TXWRakV8imJR355DcIHkR9IREHxohP4TbyR5LtFU24umRPRmEYHbpe1LghyxPx7YgUHjNbbQFRQhh4KeU1EabXx8FS3JAxp2rwRDoeWkJgWRUSKw6gGP5U2PuO9V4ZuiKXGGzFQuRuf+tkSSsbBtRJKhCi3ENuLlXhPbjTKD4djXVnfXFds6Zb+1XiUrRfyayGxJq1+SYBEfbKlgjiSmk0orgTqzSS+DZ5rTqsJbttiNtp+KMqGE2AHGFw6jQqM5vD6vMptmXV9OAjq49Uf/Lx9Opam+Hn5O9p8qoBBAQixzQZ4eNVkO9sPzJAMyR1y4/RCQQ1s0pV5KAU5sKLw3tkcFbI/JqrjCsK4Mw+W8aod4lioYuawUiCyVWBE/qPaFi5bnkgpfu/ae47174rI1fqQoTbW0HrU6FAejq7ByM0V4zkZTg02/YJK2N7hUQRCeZ4BIgSEqgD8XsjzG6LIsSbuHoIdz/LhFzbNn1clci1NHWJ0/6/O8HJMdIpEZbqi1RrrFfoo/rI/7ufm2MPG5lUI0IYJ4MAiHRTSOFJ2oTverFHYXThkYFIoyFx6rMYFgaOKM4xNWdlOnIcKb/suptptgTOTdVIf4YgdaAjJnIAm4qNNHNQqqAzvi53GkyRCEoseUBrHohZsjUbkR8gfKtc/+Oa72lwxJ8Mq6HDfDATbfbJhzeIuFQJSiw1uZprHlzUf90WgqG76zO0eCB1WdPv1IT6sNxxh91GEL2YpgC97ikFHyoaH92ndwduqZ6IYjkg20DX33MWdoZk7QkcKUCgisIYslOaaLyvIIqRKWQj16jE1DlQWJJaPopWTJjXfixEjRJJo8g4++wuQjbq+WVYjsqCuNIQW3YjnxKe2M5ZKEqq+cX7ZVgnkbsU3RWIyXA1rxv4kGersYJjD//auldXGmcEbcfTeF16Y1708FB1HIfmWv6dSFi6oD4E+RIjCsEZ+kY7dKnwReJJw3xCjKvi3kGN42rvyhUlIz0Bp+fNSV5xwFiuBzG296e5s/oHoFtUyUplmPulIPl+e1CQIQVtjlzLzzzbV+D/OVQtYzo5ixtMi5BmHuG4N/uKfJk5UIREp7+12oZlKtPBomXSzAY0KgtbPzzZoHQxujnREUgBU+O/jKKhgxVhRPtbqyHiUaRwRpHv7pgRPyUrnE7fYkVblGmfTY28tFCvlILC04Tz3ivkNWVazA+OsYrxvRM/hiNn8Fc4bQBeUZABGx5S/xFf9Lbbmk298X7iFg2yeimvsQqqJ+hYbt6uq+Zf9jC+Jcwiccd61NKQtFvGWrgJiHB5lwi6fR8KzYS7EaEHf/ka9EC7H8D+WEa3TEACHBkNSj/cXxFeq4RllC+fUFm2xtstYLL2nos1DfzsC9vqDDdRVcPA3Ho95aEQHvExVThXPqym65llkKlfRXbPTRiDepdylHjmV9YTWAEjlD9DdQnCem7Aj/ml58On366392214B5zrmQz/9ySG2mFqEwjq5sFl5tYJPw5hNz8lyZPUTsr5E0F2C9VMPnZckWP7+mbwp/BiN7f4kf7vtGnZF2JGvjK/sDX1RtcFY5oPQnE4lIAYV49U3C9SP0LCY/9i/WIFK9ORjzM9kG/KGrAuwFmgdEpdLaiqQNpCTGZVuAO65afkY1h33hrqyLjZy92JK3/twdj9pafFcwfXONmPQWldPlMe7jlP24Js0v9m8bIJ9TgS2IuRvE9ZVRaCwSJYOtAfL5H/YS4FfzKWKbek+GFulheyKtDNlBtrdmr+KU+ibHTdalzFUmMfxw3f36x+3cQbJLItSilW9cuvZEMjKw987jykZRlsH/UI+HlKfo2tLwemBEeBFtmxF2xmItA/dAIfQ+rXnm88dqvXa+GapOYVt/2waFimXFx3TC2MUiOi5/Ml+3rj/YU6Ihx2hXgiDXFsUeQkRAD6wF3SCPi2flk7XwKAA4zboqynuELD312EJ88lmDEVOMa1W/K/a8tGylZRMrMoILyoMQzzbDJHNZrhH77L9qSC42HVmKiZ5S0016UTp83gOhCwz9XItK9fgXfK3F5d7nZCBUekoLxrutQaPHa16Rjsa0gTrzyjqTnmcIcrxg6X6dkKiucudc0DD5W4pJPf0vuDW8r5/uw24YfMuxFRpD2ovT2mFX79xH6Jf+MVdv2TYqR6/955QgVPe3JCD/WjAYcLA9tpXgFiEjge2J5ljeI/iUzg91KQuHkII4mmHZxC3XQORLAC6G7uFn5LOmlnXkjFdoO976moNTxElS8HdxWoPAkjjocDR136m2l+f5t6xaaNgdodOvTu0rievnhNAB79WNrVs6EsPgkgfahF9gSFzzAd+rJSraw5Mllit7vUP5YxA843lUpu6/5jAR0RvH4rRXkSg3nE+O5GFyfe+L0s5r3k05FyghSFnKo4TTgs07qj4nTLqOYj6qaW9knJTDkF5OFMYbmCP+8H16Ty482OjvERV6OFyw043L9w3hoJi408sR+SGo1WviXUu8d7qS+ehKjpKwxeCthsm2LBFSFeetx0x4AaKPxtp3CxdWqCsLrB1s/j5TAhc1jNZsXWl6tjo/WDoewxzg8T8NnhZ1niUwL/nhfygLanCnRwaFGDyLw+sfZhyZ1UtYTp8TYB6dE7R3VsKKH95CUxJ8u8N+9u2/9HUNKHW3x3w5GQrfOPafk2w5qZq8MaHT0ebeY3wIsp3rN9lrpIsW9c1ws3VNV+JwNz0Lo9+V7zZr6GD56We6gWVIvtmam5GPPkVAbr74r6SwhuL+TRXtW/0pgyX16VNl4/EAD50TnUPuwrW6OcUO2VlWXS0inq872kk7GUlW6o/ozFKq+Sip6LcTtSDfDrPTcCHhx75H8BeRon+KG2wRwzfDgWhALmiWOMO6h3pm1UCZEPEjScyk7tdLx6WrdA2N1QTPENvNnhCQjW6kl057/qv7IwRryHrZBCwVSbLLnFRiHdTwk8mlYixFt1slEcPD7FVht13HyqVeyD55HOXrh2ElAxJyinGeoFzwKA91zfrdLvDxJSjzmImfvTisreI25EDcVfGsmxLVbfU8PGe/7NmWWKjXcdTJ11jAlVIY/Bv/mcxg/Q10vCHwKG1GW/XbJq5nxDhyLqiorn7Wd7VEVL8UgVzpHMjQ+Z8DUgSukiVwWAKkeTlVVeZ7t1DGnCgJVIdBPZAEK5f8CDyDNo7tK4/5DBjdD5MPV86TaEhGsLVFPQSI68KlBYy84FievdU9gWh6XZrugvtCZmi9vfd6db6V7FmoEcRHnG36VZH8N4aZaldq9zZawt1uBFgxYYx+Gs/qW1jwANeFy+LCoymyM6zgG7j8bGzUyLhvrbJkTYAEdICEb4kMKusKT9V3eIwMLsjdUdgijMc+7iKrr+TxrVWG0U+W95SGrxnxGrE4eaJFfgvAjUM4SAy8UaRwE9j6ZQH5qYAWGtXByvDiLSDfOD0yFA3UCMKSyQ30fyy1mIRg4ZcgZHLNHWl+c9SeijOvbOJxoQy7lTN2r3Y8p6ovxvUY74aOYbuVezryqXA6U+fcp6wSV9X5/OZKP18tB56Ua0gMyxJI7XyNT7IrqN8GsB9rL/kP5KMrjXxgqKLDa+V5OCH6a5hmOWemMUsea9vQl9t5Oce76PrTyTv50ExOqngE3PHPfSL//AItPdB7kGnyTRhVUUFNdJJ2z7RtktZwgmQzhBG/G7QsjZmJfCE7k75EmdIKH7xlnmDrNM/XbTT6FzldcH/rcRGxlPrv4qDScqE7JSmQABJWqRT/TUcJSwoQM+1jvDigvrjjH8oeK2in1S+/yO1j8xAws/T5u0VnIvAPqaE1atNuN0cuRliLcH2j0nTL4JpcR7w9Qya0JoaHgsOiALLCCzRkl1UUESz+ze/gIXHGtDwgYrK6pCFKJ1webSDog4zTlPkgXZqxlQDiYMjhDpwTtBW2WxthWbov9dt2X9XFLFmcF+eEc1UaQ74gqZiZsdj63pH1qcv3Vy8JYciogIVKsJ8Yy3J9w/GhjWVSQAmrS0BPOWK+RKV+0lWqXgYMnIFwpcZVD7zPSp547i9HlflB8gVnSTGmmq1ClO081OW/UH11pEQMfkEdDFzjLC1Cdo/BdL3s7cXb8J++Hzz1rhOUVZFIPehRiZ8VYu6+7Er7j5PSZu9g/GBdmNzJmyCD9wiswj9BZw+T3iBrg81re36ihMLjoVLoWc+62a1U/7qVX5CpvTVF7rocSAKwv4cBVqZm7lLDS/qoXs4fMs/VQi6BtVbNA3uSzKpQfjH1o3x4LrvkOn40zhm6hjduDglzJUwA0POabgdXIndp9fzhOo23Pe+Rk9GSLX0d71Poqry8NQDTzNlsa+JTNG9+UrEf+ngxCjGEsDCc0bz+udVRyHQI1jmEO3S+IOQycEq7XwB6z3wfMfa73m8PVRp+iOgtZfeSBl01xn03vMaQJkyj7vnhGCklsCWVRUl4y+5oNUzQ63B2dbjDF3vikd/3RUMifPYnX5Glfuk2FsV/7RqjI9yKTbE8wJY+74p7qXO8+dIYgjtLD/N8TJtRh04N9tXJA4H59IkMmLElgvr0Q5OCeVfdAt+5hkh4pQgfRMHpL74XatLQpPiOyHRs/OdmHtBf8nOZcxVKzdGclIN16lE7kJ+pVMjspOI+5+TqLRO6m0ZpNXJoZRv9MPDRcAfJUtNZHyig/s2wwReakFgPPJwCQmu1I30/tcBbji+Na53i1W1N+BqoY7Zxo+U/M9XyJ4Ok2SSkBtoOrwuhAY3a03Eu6l8wFdIG1cN+e8hopTkiKF093KuH/BcB39rMiGDLn6XVhGKEaaT/vqb/lufuAdpGExevF1+J9itkFhCfymWr9vGb3BTK4j598zRH7+e+MU9maruZqb0pkGxRDRE1CD4Z8LV4vhgPidk5w2Bq816g3nHw1//j3JStz7NR9HIWELO8TMn3QrP/zZp//+Dv9p429/ogv+GATR+n/UdF+ns9xNkXZQJXY4t9jMkJNUFygAtzndXwjss+yWH9HAnLQQfhAskdZS2l01HLWv7L7us5uTH409pqitvfSOQg/c+Zt7k879P3K9+WV68n7+3cZfuRd/dDPP/03rn+d+/nBvWfgDlt8+LzjqJ/vx3CnNOwiXhho778C96iD+1TBvRZYeP+EH81LE0vVwOOrmCLB3iKzI1x+vJEsrPH4uF0UB4TJ4X3uDfOCo3PYpYe0MF4bouh0DQ/l43fxUF7Y+dpWuvTSffB0yO2UQUETI/LwCZE3BvnevJ7c9zUlY3H58xzke6DNFDQG8n0WtDN4LAYN4nogKav1ezOfK/z+t6tsCTp+dhx4ymjWuCJk1dEUifDP+HyS4iP/Vg9B2jTo9L4NbiBuDS4nuuHW6H+JDQn2JtqRKGkEQPEYE7uzazXIkcxIAqUq1esasZBETlEZY7y7Jo+RoV/IsjY9eIMkUvr42Hc0xqtsavZvhz1OLwSxMOTuqzlhb0WbdOwBH9EYiyBjatz40bUxTHbiWxqJ0uma19qhPruvcWJlbiSSH48OLDDpaHPszvyct41ZfTu10+vjox6kOqK6v0K/gEPphEvMl/vwSv+A4Hhm36JSP9IXTyCZDm4kKsqD5ay8b1Sad/vaiyO5N/sDfEV6Z4q95E+yfjxpqBoBETW2C7xl4pIO2bDODDFurUPwE7EWC2Uplq+AHmBHvir2PSgkR12/Ry65O0aZtQPeXi9mTlF/Wj5GQ+vFkYyhXsLTjrBSP9hwk4GPqDP5rBn5/l8b0mLRAvRSzXHc293bs3s8EsdE3m2exxidWVB4joHR+S+dz5/W+v00K3TqN14CDBth8eWcsTbiwXPsygHdGid0PEdy6HHm2v/IUuV5RVapYmzGsX90mpnIdNGcOOq64Dbc5GUbYpD9M7S+6cLY//QmjxFLP5cuTFRm3vA5rkFZroFnO3bjHF35uU3s8mvL7Tp9nyTc4mymTJ5sLIp7umSnGkO23faehtz3mmTS7fbVx5rP7x3HXIjRNeq/A3xCs9JNB08c9S9BF2O3bOur0ItslFxXgRPdaapBIi4dRpKGxVz7ir69t/bc9qTxjvtOyGOfiLGDhR4fYywHv1WdOplxIV87TpLBy3Wc0QP0P9s4G7FBNOdITS/tep3o3h1TEa5XDDii7fWtqRzUEReP2fbxz7bHWWJdbIOxOUJZtItNZpTFRfj6vm9sYjRxQVO+WTdiOhdPeTJ+8YirPvoeL88l5iLYOHd3b/Imkq+1ZN1El3UikhftuteEYxf1Wujof8Pr4ICTu5ezZyZ4tHQMxlzUHLYO2VMOoNMGL/20S5i2o2obfk+8qqdR7xzbRDbgU0lnuIgz4LelQ5XS7xbLuSQtNS95v3ZUOdaUx/Qd8qxCt6xf2E62yb/HukLO6RyorV8KgYl5YNc75y+KvefrxY+lc/64y9kvWP0a0bDz/rojq+RWjO06WeruWqNFU7r3HPIcLWRql8ICZsz2Ls/qOm/CLn6++X+Qf7mGspYCrZod/lpl6Rw4xN/yuq8gqV4B6aHk1hVE1SfILxWu5gvXqbfARYQpspcxKp1F/c8XOPzkZvmoSw+vEqBLdrq1fr3wAPv5NnM9i8F+jdAuxkP5Z71c6uhK3enlnGymr7UsWZKC12qgUiG8XXGQ9mxnqz4GSIlybF9eXmbqj2sHX+a1jf0gRoONHRdRSrIq03Ty89eQ1GbV/Bk+du4+V15zls+vvERvZ4E7ZbnxWTVjDjb4o/k8jlw44pTIrUGxxuJvBeO+heuhOjpFsO6lVJ/aXnJDa/bM0Ql1cLbXE/Pbv3EZ3vj3iVrB5irjupZTzlnv677NrI9UNYNqbPgp/HZXS+lJmk87wec+7YOxTDo2aw2l3NfDr34VNlvqWJBknuK7oSlZ6/T10zuOoPZOeoIk81N+sL843WJ2Q4Z0fZ3scsqC/JV2fuhWi1jGURSKZV637lf53Xnnx16/vKEXY89aVJ0fv91jGdfG+G4+sniwHes4hS+udOr4RfhFhG/F5gUG35QaU+McuLmclb5ZWmR+sG5V6nf+PxYzlrnFGxpZaK8eqqVo0NfmAWoGfXDiT/FnUbWvzGDOTr8aktOZWg4BYvz5YH12ZbfCcGtNk+dDAZNGWvHov+PIOnY9Prjg8h/wLRrT69suaMVZ5bNuK00lSVpnqSX1NON/81FoP92rYndionwgOiA8WMf4vc8l15KqEEG4yAm2+WAN5Brfu1sq9suWYqgoajgOYt/JCk1gC8wPkK+XKCtRX6TAtgvrnuBgNRmn6I8lVDipOVB9kX6Oxkp4ZKyd1M6Gj8/v2U7k+YQBL95Kb9PQENucJb0JlW3b5tObN7m/Z1j1ev388d7o15zgXsI9CikAGAViR6lkJv7nb4Ak40M2G8TJ447kN+pvfHiOFjSUSP6PM+QfbAywKJCBaxSVxpizHseZUyUBhq59vFwrkyGoRiHbo0apweEZeSLuNiQ+HAekOnarFg00dZNXaPeoHPTRR0FmEyqYExOVaaaO8c0uFUh7U4e/UxdBmthlBDgg257Q33j1hA7HTxSeTTSuVnPZbgW1nodwmG16aKBDKxEetv7D9OjO0JhrbJTnoe+kcGoDJazFSO8/fUN9Jy/g4XK5PUkw2dgPDGpJqBfhe7GA+cjzfE/EGsMM+FV9nj9IAhrSfT/J3QE5TEIYyk5UjsI6ZZcCPr6A8FZUF4g9nnpVmjX90MLSQysIPD0nFzqwCcSJmIb5mYv2Cmk+C1MDFkZQyCBq4c/Yai9LJ6xYkGS/x2s5/frIW2vmG2Wrv0APpCdgCA9snFvfpe8uc0OwdRs4G9973PGEBnQB5qKrCQ6m6X/H7NInZ7y/1674/ZXOVp7OeuCRk8JFS516VHrnH1HkIUIlTIljjHaQtEtkJtosYul77cVwjk3gW1Ajaa6zWeyHGLlpk3VHE2VFzT2yI/EvlGUSz2H9zYE1s4nsKMtMqNyKNtL/59CpFJki5Fou6VXGm8vWATEPwrUVOLvoA8jLuwOzVBCgHB2Cr5V6OwEWtJEKokJkfc87h+sNHTvMb0KVTp5284QTPupoWvQVUwUeogZR3kBMESYo0mfukewRVPKh5+rzLQb7HKjFFIgWhj1w3yN/qCNoPI8XFiUgBNT1hCHBsAz8L7Oyt8wQWUFj92ONn/APyJFg8hzueqoJdNj57ROrFbffuS/XxrSXLTRgj5uxZjpgQYceeMc2wJrahReSKpm3QjHfqExTLAB2ipVumE8pqcZv8LYXQiPHHsgb5BMW8zM5pvQit+mQx8XGaVDcfVbLyMTlY8xcfmm/RSAT/H09UQol5gIz7rESDmnrQ4bURIB4iRXMDQwxgex1GgtDxKp2HayIkR+E/aDmCttNm2C6lytWdfOVzD6X2SpDWjQDlMRvAp1symWv4my1bPCD+E1EmGnMGWhNwmycJnDV2WrQNxO45ukEb08AAffizYKVULp15I4vbNK5DzWwCSUADfmKhfGSUqii1L2UsE8rB7mLuHuUJZOx4+WiizHBJ/hwboaBzhpNOVvgFTf5cJsHef7L1HCI9dOUUbb+YxUJWn6dYOLz+THi91kzY5dtO5c+grX7v0jEbsuoOGnoIreDIg/sFMyG+TyCLIcAWd1IZ1UNFxE8Uie13ucm40U2fcxC0u3WLvLOxwu+F7MWUsHsdtFQZ7W+nlfCASiAKyh8rnP3EyDByvtJb6Kax6/HkLzT9SyEyTMVM1zPtM0MJY14DmsWh4MgD15Ea9Hd00AdkTZ0EiG5NAGuIBzQJJ0JR0na+OB7lQA6UKxMfihIQ7GCCnVz694QvykWXTxpS2soDu+smru1UdIxSvAszBFD1c8c6ZOobA8bJiJIvuycgIXBQIXWwhyTgZDQxJTRXgEwRNAawGSXO0a1DKjdihLVNp/taE/xYhsgwe+VpKEEB4LlraQyE84gEihxCnbfoyOuJIEXy2FIYw+JjRusybKlU2g/vhTSGTydvCvXhYBdtAXtS2v7LkHtmXh/8fly1do8FI/D0f8UbzVb5h+KRhMGSAmR2mhi0YG/uj7wgxcfzCrMvdjitUIpXDX8ae2JcF/36qUWIMwN6JsjaRGNj+jEteGDcFyTUb8X/NHSucKMJp7pduxtD6KuxVlyxxwaeiC1FbGBESO84lbyrAugYxdl+2N8/6AgWpo/IeoAOcsG35IA/b3AuSyoa55L7llBLlaWlEWvuCFd8f8NfcTUgzJv6CbB+6ohWwodlk9nGWFpBAOaz5uEW5xBvmjnHFeDsb0mXwayj3mdYq5gxxNf3H3/tnCgHwjSrpSgVxLmiTtuszdRUFIsn6LiMPjL808vL1uQhDbM7aA43mISXReqjSskynIRcHCJ9qeFopJfx9tqyUoGbSwJex/0aDE3plBPGtNBYgWbdLom3+Q/bjdizR2/AS/c/dH/d3G7pyl1qDXgtOFtEqidwLqxPYtrNEveasWq3vPUUtqTeu8gpov4bdOQRI2kneFvRNMrShyVeEupK1PoLDPMSfWMIJcs267mGB8X9CehQCF0gIyhpP10mbyM7lwW1e6TGvHBV1sg/UyTghHPGRqMyaebC6pbB1WKNCQtlai1GGvmq9zUKaUzLaXsXEBYtHxmFbEZ2kJhR164LhWW2Tlp1dhsGE7ZgIWRBOx3Zcu2DxgH+G83WTPceKG0TgQKKiiNNOlWgvqNEbnrk6fVD+AqRam2OguZb0YWSTX88N+i/ELSxbaUUpPx4vJUzYg/WonSeA8xUK6u7DPHgpqWpEe6D4cXg5uK9FIYVba47V/nb+wyOtk+zG8RrS4EA0ouwa04iByRLSvoJA2FzaobbZtXnq8GdbfqEp5I2dpfpj59TCVif6+E75p665faiX8gS213RqBxTZqfHP46nF6NSenOneuT+vgbLUbdTH2/t0REFXZJOEB6DHvx6N6g9956CYrY/AYcm9gELJXYkrSi+0F0geKDZgOCIYkLU/+GOW5aGj8mvLFgtFH5+XC8hvAE3CvHRfl4ofM/Qwk4x2A+R+nyc9gNu/9Tem7XW4XRnyRymf52z09cTOdr+PG6+P/Vb4QiXlwauc5WB1z3o+IJjlbxI8MyWtSzT+k4sKVbhF3xa+vDts3NxXa87iiu+xRH9cAprnOL2h6vV54iQRXuOAj1s8nLFK8gZ70ThIQcWdF19/2xaJmT0efrkNDkWbpAQPdo92Z8+Hn/aLjbOzB9AI/k12fPs9HhUNDJ1u6ax2VxD3R6PywN7BrLJ26z6s3QoMp76qzzwetrDABKSGkfW5PwS1GvYNUbK6uRqxfyVGNyFB0E+OugMM8kKwmJmupuRWO8XkXXXQECyRVw9UyIrtCtcc4oNqXqr7AURBmKn6Khz3eBN96LwIJrAGP9mr/59uTOSx631suyT+QujDd4beUFpZ0kJEEnjlP+X/Kr2kCKhnENTg4BsMTOmMqlj2WMFLRUlVG0fzdCBgUta9odrJfpVdFomTi6ak0tFjXTcdqqvWBAzjY6hVrH9sbt3Z9gn+AVDpTcQImefbB4edirjzrsNievve4ZT4EUZWV3TxEsIW+9MT/RJoKfZZYSRGfC1CwPG/9rdMOM8qR/LUYvw5f/emUSoD7YSFuOoqchdUg2UePd1eCtFSKgxLSZ764oy4lvRCIH6bowPxZWwxNFctksLeil47pfevcBipkkBIc4ngZG+kxGZ71a72KQ7VaZ6MZOZkQJZXM6kb/Ac0/XkJx8dvyfJcWbI3zONEaEPIW8GbkYjsZcwy+eMoKrYjDmvEEixHzkCSCRPRzhOfJZuLdcbx19EL23MA8rnjTZZ787FGMnkqnpuzB5/90w1gtUSRaWcb0eta8198VEeZMUSfIhyuc4/nywFQ9uqn7jdqXh+5wwv+RK9XouNPbYdoEelNGo34KyySwigsrfCe0v/PlWPvQvQg8R0KgHO18mTVThhQrlbEQ0Kp/JxPdjHyR7E1QPw/ut0r+HDDG7BwZFm9IqEUZRpv2WpzlMkOemeLcAt5CsrzskLGaVOAxyySzZV/D2EY7ydNZMf8e8VhHcKGHAWNszf1EOq8fNstijMY4JXyATwTdncFFqcNDfDo+mWFvxJJpc4sEZtjXyBdoFcxbUmniCoKq5jydUHNjYJxMqN1KzYV62MugcELVhS3Bnd+TLLOh7dws/zSXWzxEb4Nj4aFun5x4kDWLK5TUF/yCXB/cZYvI9kPgVsG2jShtXkxfgT+xzjJofXqPEnIXIQ1lnIdmVzBOM90EXvJUW6a0nZ/7XjJGl8ToO3H/fdxnxmTNKBZxnkpXLVgLXCZywGT3YyS75w/PAH5I/jMuRspej8xZObU9kREbRA+kqjmKRFaKGWAmFQspC+QLbKPf0RaK3OXvBSWqo46p70ws/eZpu6jCtZUgQy6r4tHMPUdAgWGGUYNbuv/1a6K+MVFsd3T183+T8capSo6m0+Sh57fEeG/95dykGJBQMj09DSW2bY0mUonDy9a8trLnnL5B5LW3Nl8rJZNysO8Zb+80zXxqUGFpud3Qzwb7bf+8mq6x0TAnJU9pDQR9YQmZhlna2xuxJt0aCO/f1SU8gblOrbIyMsxTlVUW69VJPzYU2HlRXcqE2lLLxnObZuz2tT9CivfTAUYfmzJlt/lOPgsR6VN64/xQd4Jlk/RV7UKVv2Gx/AWsmTAuCWKhdwC+4HmKEKYZh2Xis4KsUR1BeObs1c13wqFRnocdmuheaTV30gvVXZcouzHKK5zwrN52jXJEuX6dGx3BCpV/++4f3hyaW/cQJLFKqasjsMuO3B3WlMq2gyYfdK1e7L2pO/tRye2mwzwZPfdUMrl5wdLqdd2Kv/wVtnpyWYhd49L6rsOV+8HXPrWH2Kup89l2tz6bf80iYSd+V4LROSOHeamvexR524q4r43rTmtFzQvArpvWfLYFZrbFspBsXNUqqenjxNNsFXatZvlIhk7teUPfK+YL32F8McTnjv0BZNppb+vshoCrtLXjIWq3EJXpVXIlG6ZNL0dh6qEm2WMwDjD3LfOfkGh1/czYc/0qhiD2ozNnH4882MVVt3JbVFkbwowNCO3KL5IoYW5wlVeGCViOuv1svZx7FbzxKzA4zGqBlRRaRWCobXaVq4yYCWbZf8eiJwt3OY+MFiSJengcFP2t0JMfzOiJ7cECvpx7neg1Rc5x+7myPJOXt2FohVRyXtD+/rDoTOyGYInJelZMjolecVHUhUNqvdZWg2J2t0jPmiLFeRD/8fOT4o+NGILb+TufCo9ceBBm3JLVn+MO2675n7qiEX/6W+188cYg3Zn5NSTjgOKfWFSAANa6raCxSoVU851oJLY11WIoYK0du0ec5E4tCnAPoKh71riTsjVIp3gKvBbEYQiNYrmH22oLQWA2AdwMnID6PX9b58dR2QKo4qag1D1Z+L/FwEKTR7osOZPWECPJIHQqPUsM5i/CH5YupVPfFA5pHUBcsesh8eO5YhyWnaVRPZn/BmdXVumZWPxMP5e28zm2uqHgFoT9CymHYNNrzrrjlXZM06HnzDxYNlI5b/QosxLmmrqDFqmogQdqk0WLkUceoAvQxHgkIyvWU69BPFr24VB6+lx75Rna6dGtrmOxDnvBojvi1/4dHjVeg8owofPe1cOnxU1ioh016s/Vudv9mhV9f35At+Sh28h1bpp8xhr09+vf47Elx3Ms6hyp6QvB3t0vnLbOhwo660cp7K0vvepabK7YJfxEWWfrC2YzJfYOjygPwfwd/1amTqa0hZ5ueebhWYVMubRTwIjj+0Oq0ohU3zfRfuL8gt59XsHdwKtxTQQ4Y2qz6gisxnm2UdlmpEkgOsZz7iEk6QOt8BuPwr+NR01LTqXmJo1C76o1N274twJvl+I069TiLpenK/miRxhyY8jvYV6W1WuSwhH9q7kuwnJMtm7IWcqs7HsnyHSqWXLSpYtZGaR1V3t0gauninFPZGtWskF65rtti48UV9uV9KM8kfDYs0pgB00S+TlzTXV6P8mxq15b9En8sz3jWSszcifZa/NuufPNnNTb031pptt0+sRSH/7UG8pzbsgtt3OG3ut7B9JzDMt2mTZuyRNIV8D54TuTrpNcHtgmMlYJeiY9XS83NYJicjRjtJSf9BZLsQv629QdDsKQhTK5CnXhpk7vMNkHzPhm0ExW/VCGApHfPyBagtZQTQmPHx7g5IXXsrQDPzIVhv2LB6Ih138iSDww1JNHrDvzUxvp73MsQBVhW8EbrReaVUcLB1R3PUXyaYG4HpJUcLVxMgDxcPkVRQpL7VTAGabDzbKcvg12t5P8TSGQkrj/gOrpnbiDHwluA73xbXts/L7u468cRWSWRtgTwlQnA47EKg0OiZDgFxAKQQUcsbGomITgeXUAAyKe03eA7Mp4gnyKQmm0LXJtEk6ddksMJCuxDmmHzmVhO+XaN2A54MIh3niw5CF7PwiXFZrnA8wOdeHLvvhdoqIDG9PDI7UnWWHq526T8y6ixJPhkuVKZnoUruOpUgOOp3iIKBjk+yi1vHo5cItHXb1PIKzGaZlRS0g5d3MV2pD8FQdGYLZ73aae/eEIUePMc4NFz8pIUfLCrrF4jVWH5gQneN3S8vANBmUXrEcKGn6hIUN95y1vpsvLwbGpzV9L0ZKTan6TDXM05236uLJcIEMKVAxKNT0K8WljuwNny3BNQRfzovA85beI9zr1AGNYnYCVkR1aGngWURUrgqR+gRrQhxW81l3CHevjvGEPzPMTxdsIfB9dfGRbZU0cg/1mcubtECX4tvaedmNAvTxCJtc2QaoUalGfENCGK7IS/O8CRpdOVca8EWCRwv2sSWE8CJPW5PCugjCXPd3h6U60cPD+bdhtXZuYB6stcoveE7Sm5MM2yvfUHXFSW7KzLmi7/EeEWL0wqcOH9MOSKjhCHHmw+JGLcYE/7SBZQCRggox0ZZTAxrlzNNXYXL5fNIjkdT4YMqVUz6p8YDt049v4OXGdg3qTrtLBUXOZf7ahPlZAY/O+7Sp0bvGSHdyQ8B1LOsplqMb9Se8VAE7gIdSZvxbRSrfl+Lk5Qaqi5QJceqjitdErcHXg/3MryljPSIAMaaloFm1cVwBJ8DNmkDqoGROSHFetrgjQ5CahuKkdH5pRPigMrgTtlFI8ufJPJSUlGgTjbBSvpRc0zypiUn6U5KZqcRoyrtzhmJ7/caeZkmVRwJQeLOG8LY6vP5ChpKhc8Js0El+n6FXqbx9ItdtLtYP92kKfaTLtCi8StLZdENJa9Ex1nOoz1kQ7qxoiZFKRyLf4O4CHRT0T/0W9F8epNKVoeyxUXhy3sQMMsJjQJEyMOjmOhMFgOmmlscV4eFi1CldU92yjwleirEKPW3bPAuEhRZV7JsKV3Lr5cETAiFuX5Nw5UlF7d2HZ96Bh0sgFIL5KGaKSoVYVlvdKpZJVP5+NZ7xDEkQhmDgsDKciazJCXJ6ZN2B3FY2f6VZyGl/t4aunGIAk/BHaS+i+SpdRfnB/OktOvyjinWNfM9Ksr6WwtCa1hCmeRI6icpFM4o8quCLsikU0tMoZI/9EqXRMpKGaWzofl4nQuVQm17d5fU5qXCQeCDqVaL9XJ9qJ08n3G3EFZS28SHEb3cdRBdtO0YcTzil3QknNKEe/smQ1fTb0XbpyNB5xAeuIlf+5KWlEY0DqJbsnzJlQxJPOVyHiKMx5Xu9FcEv1Fbg6Fhm4t+Jyy5JC1W3YO8dYLsO0PXPbxodBgttTbH3rt9Cp1lJIk2r3O1Zqu94eRbnIz2f50lWolYzuKsj4PMok4abHLO8NAC884hiXx5Fy5pWKO0bWL7uEGXaJCtznhP67SlQ4xjWIfgq6EpZ28QMtuZK7JC0RGbl9nA4XtFLug/NLMoH1pGt9IonAJqcEDLyH6TDROcbsmGPaGIxMo41IUAnQVPMPGByp4mOmh9ZQMkBAcksUK55LsZj7E5z5XuZoyWCKu6nHmDq22xI/9Z8YdxJy4kWpD16jLVrpwGLWfyOD0Wd+cBzFBxVaGv7S5k9qwh/5t/LQEXsRqI3Q9Rm3QIoaZW9GlsDaKOUyykyWuhNOprSEi0s1G4rgoiX1V743EELti+pJu5og6X0g6oTynUqlhH9k6ezyRi05NGZHz0nvp3HOJr7ebrAUFrDjbkFBObEvdQWkkUbL0pEvMU46X58vF9j9F3j6kpyetNUBItrEubW9ZvMPM4qNqLlsSBJqOH3XbNwv/cXDXNxN8iFLzUhteisYY+RlHYOuP29/Cb+L+xv+35Rv7xudnZ6ohK4cMPfCG8KI7dNmjNk/H4e84pOxn/sZHK9psfvj8ncA8qJz7O8xqbxESDivGJOZzF7o5PJLQ7g34qAWoyuA+x3btU98LT6ZyGyceIXjrqob2CAVql4VOTQPUQYvHV/g4zAuCZGvYQBtf0wmd5lilrvuEn1BXLny01B4h4SMDlYsnNpm9d7m9h578ufpef9Z4WplqWQvqo52fyUA7J24eZD5av6SyGIV9kpmHNqyvdfzcpEMw97BvknV2fq+MFHun9BT3Lsf8pbzvisWiIQvYkng+8Vxk1V+dli1u56kY50LRjaPdotvT5BwqtwyF+emo/z9J3yVUVGfKrxQtJMOAQWoQii/4dp9wgybSa5mkucmRLtEQZ/pz0tL/NVcgWAd95nEQ3Tg6tNbuyn3Iepz65L3huMUUBntllWuu4DbtOFSMSbpILV4fy6wlM0SOvi6CpLh81c1LreIvKd61uEWBcDw1lUBUW1I0Z+m/PaRlX+PQ/oxg0Ye6KUiIiTF4ADNk59Ydpt5/rkxmq9tV5Kcp/eQLUVVmBzQNVuytQCP6Ezd0G8eLxWyHpmZWJ3bAzkWTtg4lZlw42SQezEmiUPaJUuR/qklVA/87S4ArFCpALdY3QRdUw3G3XbWUp6aq9z0zUizcPa7351p9JXOZyfdZBFnqt90VzQndXB/mwf8LC9STj5kenVpNuqOQQP3mIRJj7eV21FxG8VAxKrEn3c+XfmZ800EPb9/5lIlijscUbB6da0RQaMook0zug1G0tKi/JBC4rw7/D3m4ARzAkzMcVrDcT2SyFtUdWAsFlsPDFqV3N+EjyXaoEePwroaZCiLqEzb8MW+PNE9TmTC01EzWli51PzZvUqkmyuROU+V6ik+Le/9qT6nwzUzf9tP68tYei0YaDGx6kAd7jn1cKqOCuYbiELH9zYqcc4MnRJjkeGiqaGwLImhyeKs+xKJMBlOJ05ow9gGCKZ1VpnMKoSCTbMS+X+23y042zOb5MtcY/6oBeAo1Vy89OTyhpavFP78jXCcFH0t7Gx24hMEOm2gsEfGabVpQgvFqbQKMsknFRRmuPHcZu0Su/WMFphZvB2r/EGbG72rpGGho3h+Msz0uGzJ7hNK2uqQiE1qmn0zgacKYYZBCqsxV+sjbpoVdSilW/b94n2xNb648VmNIoizqEWhBnsen+d0kbCPmRItfWqSBeOd9Wne3c6bcd6uvXOJ6WdiSsuXq0ndhqrQ4QoWUjCjYtZ0EAhnSOP1m44xkf0O7jXghrzSJWxP4a/t72jU29Vu2rvu4n7HfHkkmQOMGSS+NPeLGO5I73mC2B7+lMiBQQZRM9/9liLIfowupUFAbPBbR+lxDM6M8Ptgh1paJq5Rvs7yEuLQv/7d1oU2woFSb3FMPWQOKMuCuJ7pDDjpIclus5TeEoMBy2YdVB4fxmesaCeMNsEgTHKS5WDSGyNUOoEpcC2OFWtIRf0w27ck34/DjxRTVIcc9+kqZE6iMSiVDsiKdP/Xz5XfEhm/sBhO50p1rvJDlkyyxuJ9SPgs7YeUJBjXdeAkE+P9OQJm6SZnn1svcduI78dYmbkE2mtziPrcjVisXG78spLvbZaSFx/Rks9zP4LKn0Cdz/3JsetkT06A8f/yCgMO6Mb1Hme0JJ7b2wZz1qleqTuKBGokhPVUZ0dVu+tnQYNEY1fmkZSz6+EGZ5EzL7657mreZGR3jUfaEk458PDniBzsSmBKhDRzfXameryJv9/D5m6HIqZ0R+ouCE54Dzp4IJuuD1e4Dc5i+PpSORJfG23uVgqixAMDvchMR0nZdH5brclYwRoJRWv/rlxGRI5ffD5NPGmIDt7vDE1434pYdVZIFh89Bs94HGGJbTwrN8T6lh1HZFTOB4lWzWj6EVqxSMvC0/ljWBQ3F2kc/mO2b6tWonT2JEqEwFts8rz2h+oWNds9ceR2cb7zZvJTDppHaEhK5avWqsseWa2Dt5BBhabdWSktS80oMQrL4TvAM9b5HMmyDnO+OkkbMXfUJG7eXqTIG6lqSOEbqVR+qYdP7uWb57WEJqzyh411GAVsDinPs7KvUeXItlcMdOUWzXBH6zscymV1LLVCtc8IePojzXHF9m5b5zGwBRdzcyUJkiu938ApmAayRdJrX1PmVguWUvt2ThQ62czItTyWJMW2An/hdDfMK7SiFQlGIdAbltHz3ycoh7j9V7GxNWBpbtcSdqm4XxRwTawc3cbZ+xfSv9qQfEkDKfZTwCkqWGI/ur250ItXlMlh6vUNWEYIg9A3GzbgmbqvTN8js2YMo87CU5y6nZ4dbJLDQJj9fc7yM7tZzJDZFtqOcU8+mZjYlq4VmifI23iHb1ZoT9E+kT2dolnP1AfiOkt7PQCSykBiXy5mv637IegWSKj9IKrYZf4Lu9+I7ub+mkRdlvYzehh/jaJ9n7HUH5b2IbgeNdkY7wx1yVzxS7pbvky6+nmVUtRllEFfweUQ0/nG017WoUYSxs+j2B4FV/F62EtHlMWZXYrjGHpthnNb1x66LKZ0Qe92INWHdfR/vqp02wMS8r1G4dJqHok8KmQ7947G13a4YXbsGgHcBvRuVu1eAi4/A5+ZixmdSXM73LupB/LH7O9yxLTVXJTyBbI1S49TIROrfVCOb/czZ9pM4JsZx8kUz8dQGv7gUWKxXvTH7QM/3J2OuXXgciUhqY+cgtaOliQQVOYthBLV3xpESZT3rmfEYNZxmpBbb24CRao86prn+i9TNOh8VxRJGXJfXHATJHs1T5txgc/opYrY8XjlGQQbRcoxIBcnVsMjmU1ymmIUL4dviJXndMAJ0Yet+c7O52/p98ytlmAsGBaTAmMhimAnvp1TWNGM9BpuitGj+t810CU2UhorrjPKGtThVC8WaXw04WFnT5fTjqmPyrQ0tN3CkLsctVy2xr0ZWgiWVZ1OrlFjjxJYsOiZv2cAoOvE+7sY0I/TwWcZqMoyIKNOftwP7w++Rfg67ljfovKYa50if3fzE/8aPYVey/Nq35+nH2sLPh/fP5TsylSKGOZ4k69d2PnH43+kq++sRXHQqGArWdwhx+hpwQC6JgT2uxehYU4Zbw7oNb6/HLikPyJROGK2ouyr+vzseESp9G50T4AyFrSqOQ0rroCYP4sMDFBrHn342EyZTMlSyk47rHSq89Y9/nI3zG5lX16Z5lxphguLOcZUndL8wNcrkyjH82jqg8Bo8OYkynrxZvbFno5lUS3OPr8Ko3mX9NoRPdYOKKjD07bvgFgpZ/RF+YzkWvJ/Hs/tUbfeGzGWLxNAjfDzHHMVSDwB5SabQLsIZHiBp43FjGkaienYoDd18hu2BGwOK7U3o70K/WY/kuuKdmdrykIBUdG2mvE91L1JtTbh20mOLbk1vCAamu7utlXeGU2ooVikbU/actcgmsC1FKk2qmj3GWeIWbj4tGIxE7BLcBWUvvcnd/lYxsMV4F917fWeFB/XbINN3qGvIyTpCalz1lVewdIGqeAS/gB8Mi+sA+BqDiX3VGD2eUunTRbSY+AuDy4E3Qx3hAhwnSXX+B0zuj3eQ1miS8Vux2z/l6/BkWtjKGU72aJkOCWhGcSf3+kFkkB15vGOsQrSdFr6qTj0gBYiOlnBO41170gOWHSUoBVRU2JjwppYdhIFDfu7tIRHccSNM5KZOFDPz0TGMAjzzEpeLwTWp+kn201kU6NjbiMQJx83+LX1e1tZ10kuChJZ/XBUQ1dwaBHjTDJDqOympEk8X2M3VtVw21JksChA8w1tTefO3RJ1FMbqZ01bHHkudDB/OhLfe7P5GOHaI28ZXKTMuqo0hLWQ4HabBsGG7NbP1RiXtETz074er6w/OerJWEqjmkq2y51q1BVI+JUudnVa3ogBpzdhFE7fC7kybrAt2Z6RqDjATAUEYeYK45WMupBKQRtQlU+uNsjnzj6ZmGrezA+ASrWxQ6LMkHRXqXwNq7ftv28dUx/ZSJciDXP2SWJsWaN0FjPX9Yko6LobZ7aYW/IdUktI9apTLyHS8DyWPyuoZyxN1TK/vtfxk3HwWh6JczZC8Ftn0bIJay2g+n5wd7lm9rEsKO+svqVmi+c1j88hSCxbzrg4+HEP0Nt1/B6YW1XVm09T1CpAKjc9n18hjqsaFGdfyva1ZG0Xu3ip6N6JGpyTSqY5h4BOlpLPaOnyw45PdXTN+DtAKg7DLrLFTnWusoSBHk3s0d7YouJHq85/R09Tfc37ENXZF48eAYLnq9GLioNcwDZrC6FW6godB8JnqYUPvn0pWLfQz0lM0Yy8Mybgn84Ds3Q9bDP10bLyOV+qzxa4Rd9Dhu7cju8mMaONXK3UqmBQ9qIg7etIwEqM/kECk/Dzja4Bs1xR+Q/tCbc8IKrSGsTdJJ0vge7IG20W687uVmK6icWQ6cD3lwFzgNMGtFvO5qyJeKflGLAAcQZOrkxVwy3cWvqlGpvjmf9Qe6Ap20MPbV92DPV0OhFM4kz8Yr0ffC2zLWSQ1kqY6QdQrttR3kh1YLtQd1kCEv5hVoPIRWl5ERcUTttBIrWp6Xs5Ehh5OUUwI5aEBvuiDmUoENmnVw1FohCrbRp1A1E+XSlWVOTi7ADW+5Ohb9z1vK4qx5R5lPdGCPBJZ00mC+Ssp8VUbgpGAvXWMuWQQRbCqI6Rr2jtxZxtfP7W/8onz+yz0Gs76LaT5HX9ecyiZCB/ZR/gFtMxPsDwohoeCRtiuLxE1GM1vUEUgBv86+eehL58/P56QFGQ/MqOe/vC76L63jzmeax4exd/OKTUvkXg+fOJUHych9xt/9goJMrapSgvXrj8+8vk/N80f22Sewj6cyGqt1B6mztoeklVHHraouhvHJaG/OuBz6DHKMpFmQULU1bRWlyYE0RPXYYkUycIemN7TLtgNCJX6BqdyxDKkegO7nJK5xQ7OVYDZTMf9bVHidtk6DQX9Et+V9M7esgbsYBdEeUpsB0Xvw2kd9+rI7V+m47u+O/tq7mw7262HU1WlS9uFzsV6JxIHNmUCy0QS9e077JGRFbG65z3/dOKB/Zk+yDdKpUmdXjn/aS3N5nv4fK7bMHHmPlHd4E2+iTbV5rpzScRnxk6KARuDTJ8Q1LpK2mP8gj1EbuJ9RIyY+EWK4hCiIDBAS1Tm2IEXAFfgKPgdL9O6mAa06wjCcUAL6EsxPQWO9VNegBPm/0GgkZbDxCynxujX/92vmGcjZRMAY45puak2sFLCLSwXpEsyy5fnF0jGJBhm+fNSHKKUUfy+276A7/feLOFxxUuHRNJI2Osenxyvf8DAGObT60pfTTlhEg9u/KKkhJqm5U1/+BEcSkpFDA5XeCqxwXmPac1jcuZ3JWQ+p0NdWzb/5v1ZvF8GtMTFFEdQjpLO0bwPb0BHNWnip3liDXI2fXf05jjvfJ0NpjLCUgfTh9CMFYVFKEd4Z/OG/2C+N435mnK+9t1gvCiVcaaH7rK4+PjCvpVNiz+t2QyqH1O8x3JKZVl6Q+Lp/XK8wMjVMslOq9FdSw5FtUs/CptXH9PW+wbWHgrV17R5jTVOtGtKFu3nb80T+E0tv9QkzW3J2dbaw/8ddAKZ0pxIaEqLjlPrji3VgJ3GvdFvlqD8075woxh4fVt0JZE0KVFsAvqhe0dqN9b35jtSpnYMXkU+vZq+IAHad3IHc2s/LYrnD1anfG46IFiMIr9oNbZDWvwthqYNqOigaKd/XlLU4XHfk/PXIjPsLy/9/kAtQ+/wKH+hI/IROWj5FPvTZAT9f7j4ZXQyG4M0TujMAFXYkKvEHv1xhySekgXGGqNxWeWKlf8dDAlLuB1cb/qOD+rk7cmwt+1yKpk9cudqBanTi6zTbXRtV8qylNtjyOVKy1HTz0GW9rjt6sSjAZcT5R+KdtyYb0zyqG9pSLuCw5WBwAn7fjBjKLLoxLXMI+52L9cLwIR2B6OllJZLHJ8vDxmWdtF+QJnmt1rsHPIWY20lftk8fYePkAIg6Hgn532QoIpegMxiWgAOfe5/U44APR8Ac0NeZrVh3gEhs12W+tVSiWiUQekf/YBECUy5fdYbA08dd7VzPAP9aiVcIB9k6tY7WdJ1wNV+bHeydNtmC6G5ICtFC1ZwmJU/j8hf0I8TRVKSiz5oYIa93EpUI78X8GYIAZabx47/n8LDAAJ0nNtP1rpROprqKMBRecShca6qXuTSI3jZBLOB3Vp381B5rCGhjSvh/NSVkYp2qIdP/Bg=";
28075 },
28076 {}
28077 ],
28078 6: [
28079 function(require2, module2, exports2) {
28080 var data = require2("./dictionary-browser");
28081 exports2.init = function() {
28082 exports2.dictionary = data.init();
28083 };
28084 exports2.offsetsByLength = new Uint32Array([
28085 0,
28086 0,
28087 0,
28088 0,
28089 0,
28090 4096,
28091 9216,
28092 21504,
28093 35840,
28094 44032,
28095 53248,
28096 63488,
28097 74752,
28098 87040,
28099 93696,
28100 100864,
28101 104704,
28102 106752,
28103 108928,
28104 113536,
28105 115968,
28106 118528,
28107 119872,
28108 121280,
28109 122016
28110 ]);
28111 exports2.sizeBitsByLength = new Uint8Array([
28112 0,
28113 0,
28114 0,
28115 0,
28116 10,
28117 10,
28118 11,
28119 11,
28120 10,
28121 10,
28122 10,
28123 10,
28124 10,
28125 9,
28126 9,
28127 8,
28128 7,
28129 7,
28130 8,
28131 7,
28132 7,
28133 6,
28134 6,
28135 5,
28136 5
28137 ]);
28138 exports2.minDictionaryWordLength = 4;
28139 exports2.maxDictionaryWordLength = 24;
28140 },
28141 { "./dictionary-browser": 4 }
28142 ],
28143 7: [
28144 function(require2, module2, exports2) {
28145 function HuffmanCode(bits, value) {
28146 this.bits = bits;
28147 this.value = value;
28148 }
28149 exports2.HuffmanCode = HuffmanCode;
28150 var MAX_LENGTH = 15;
28151 function GetNextKey(key, len) {
28152 var step = 1 << len - 1;
28153 while (key & step) {
28154 step >>= 1;
28155 }
28156 return (key & step - 1) + step;
28157 }
28158 function ReplicateValue(table, i3, step, end, code) {
28159 do {
28160 end -= step;
28161 table[i3 + end] = new HuffmanCode(
28162 code.bits,
28163 code.value
28164 );
28165 } while (end > 0);
28166 }
28167 function NextTableBitSize(count, len, root_bits) {
28168 var left = 1 << len - root_bits;
28169 while (len < MAX_LENGTH) {
28170 left -= count[len];
28171 if (left <= 0) break;
28172 ++len;
28173 left <<= 1;
28174 }
28175 return len - root_bits;
28176 }
28177 exports2.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_lengths, code_lengths_size) {
28178 var start_table = table;
28179 var code;
28180 var len;
28181 var symbol;
28182 var key;
28183 var step;
28184 var low;
28185 var mask;
28186 var table_bits;
28187 var table_size;
28188 var total_size;
28189 var sorted;
28190 var count = new Int32Array(
28191 MAX_LENGTH + 1
28192 );
28193 var offset3 = new Int32Array(
28194 MAX_LENGTH + 1
28195 );
28196 sorted = new Int32Array(code_lengths_size);
28197 for (symbol = 0; symbol < code_lengths_size; symbol++) {
28198 count[code_lengths[symbol]]++;
28199 }
28200 offset3[1] = 0;
28201 for (len = 1; len < MAX_LENGTH; len++) {
28202 offset3[len + 1] = offset3[len] + count[len];
28203 }
28204 for (symbol = 0; symbol < code_lengths_size; symbol++) {
28205 if (code_lengths[symbol] !== 0) {
28206 sorted[offset3[code_lengths[symbol]]++] = symbol;
28207 }
28208 }
28209 table_bits = root_bits;
28210 table_size = 1 << table_bits;
28211 total_size = table_size;
28212 if (offset3[MAX_LENGTH] === 1) {
28213 for (key = 0; key < total_size; ++key) {
28214 root_table[table + key] = new HuffmanCode(
28215 0,
28216 sorted[0] & 65535
28217 );
28218 }
28219 return total_size;
28220 }
28221 key = 0;
28222 symbol = 0;
28223 for (len = 1, step = 2; len <= root_bits; ++len, step <<= 1) {
28224 for (; count[len] > 0; --count[len]) {
28225 code = new HuffmanCode(
28226 len & 255,
28227 sorted[symbol++] & 65535
28228 );
28229 ReplicateValue(
28230 root_table,
28231 table + key,
28232 step,
28233 table_size,
28234 code
28235 );
28236 key = GetNextKey(key, len);
28237 }
28238 }
28239 mask = total_size - 1;
28240 low = -1;
28241 for (len = root_bits + 1, step = 2; len <= MAX_LENGTH; ++len, step <<= 1) {
28242 for (; count[len] > 0; --count[len]) {
28243 if ((key & mask) !== low) {
28244 table += table_size;
28245 table_bits = NextTableBitSize(
28246 count,
28247 len,
28248 root_bits
28249 );
28250 table_size = 1 << table_bits;
28251 total_size += table_size;
28252 low = key & mask;
28253 root_table[start_table + low] = new HuffmanCode(
28254 table_bits + root_bits & 255,
28255 table - start_table - low & 65535
28256 );
28257 }
28258 code = new HuffmanCode(
28259 len - root_bits & 255,
28260 sorted[symbol++] & 65535
28261 );
28262 ReplicateValue(
28263 root_table,
28264 table + (key >> root_bits),
28265 step,
28266 table_size,
28267 code
28268 );
28269 key = GetNextKey(key, len);
28270 }
28271 }
28272 return total_size;
28273 };
28274 },
28275 {}
28276 ],
28277 8: [
28278 function(require2, module2, exports2) {
28279 "use strict";
28280 exports2.byteLength = byteLength;
28281 exports2.toByteArray = toByteArray;
28282 exports2.fromByteArray = fromByteArray;
28283 var lookup = [];
28284 var revLookup = [];
28285 var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
28286 var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
28287 for (var i3 = 0, len = code.length; i3 < len; ++i3) {
28288 lookup[i3] = code[i3];
28289 revLookup[code.charCodeAt(i3)] = i3;
28290 }
28291 revLookup["-".charCodeAt(0)] = 62;
28292 revLookup["_".charCodeAt(0)] = 63;
28293 function getLens(b64) {
28294 var len2 = b64.length;
28295 if (len2 % 4 > 0) {
28296 throw new Error(
28297 "Invalid string. Length must be a multiple of 4"
28298 );
28299 }
28300 var validLen = b64.indexOf("=");
28301 if (validLen === -1) validLen = len2;
28302 var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
28303 return [validLen, placeHoldersLen];
28304 }
28305 function byteLength(b64) {
28306 var lens = getLens(b64);
28307 var validLen = lens[0];
28308 var placeHoldersLen = lens[1];
28309 return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
28310 }
28311 function _byteLength(b64, validLen, placeHoldersLen) {
28312 return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
28313 }
28314 function toByteArray(b64) {
28315 var tmp;
28316 var lens = getLens(b64);
28317 var validLen = lens[0];
28318 var placeHoldersLen = lens[1];
28319 var arr = new Arr(
28320 _byteLength(b64, validLen, placeHoldersLen)
28321 );
28322 var curByte = 0;
28323 var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
28324 for (var i22 = 0; i22 < len2; i22 += 4) {
28325 tmp = revLookup[b64.charCodeAt(i22)] << 18 | revLookup[b64.charCodeAt(i22 + 1)] << 12 | revLookup[b64.charCodeAt(i22 + 2)] << 6 | revLookup[b64.charCodeAt(i22 + 3)];
28326 arr[curByte++] = tmp >> 16 & 255;
28327 arr[curByte++] = tmp >> 8 & 255;
28328 arr[curByte++] = tmp & 255;
28329 }
28330 if (placeHoldersLen === 2) {
28331 tmp = revLookup[b64.charCodeAt(i22)] << 2 | revLookup[b64.charCodeAt(i22 + 1)] >> 4;
28332 arr[curByte++] = tmp & 255;
28333 }
28334 if (placeHoldersLen === 1) {
28335 tmp = revLookup[b64.charCodeAt(i22)] << 10 | revLookup[b64.charCodeAt(i22 + 1)] << 4 | revLookup[b64.charCodeAt(i22 + 2)] >> 2;
28336 arr[curByte++] = tmp >> 8 & 255;
28337 arr[curByte++] = tmp & 255;
28338 }
28339 return arr;
28340 }
28341 function tripletToBase64(num) {
28342 return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
28343 }
28344 function encodeChunk(uint8, start2, end) {
28345 var tmp;
28346 var output = [];
28347 for (var i22 = start2; i22 < end; i22 += 3) {
28348 tmp = (uint8[i22] << 16 & 16711680) + (uint8[i22 + 1] << 8 & 65280) + (uint8[i22 + 2] & 255);
28349 output.push(tripletToBase64(tmp));
28350 }
28351 return output.join("");
28352 }
28353 function fromByteArray(uint8) {
28354 var tmp;
28355 var len2 = uint8.length;
28356 var extraBytes = len2 % 3;
28357 var parts = [];
28358 var maxChunkLength = 16383;
28359 for (var i22 = 0, len22 = len2 - extraBytes; i22 < len22; i22 += maxChunkLength) {
28360 parts.push(
28361 encodeChunk(
28362 uint8,
28363 i22,
28364 i22 + maxChunkLength > len22 ? len22 : i22 + maxChunkLength
28365 )
28366 );
28367 }
28368 if (extraBytes === 1) {
28369 tmp = uint8[len2 - 1];
28370 parts.push(
28371 lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
28372 );
28373 } else if (extraBytes === 2) {
28374 tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
28375 parts.push(
28376 lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
28377 );
28378 }
28379 return parts.join("");
28380 }
28381 },
28382 {}
28383 ],
28384 9: [
28385 function(require2, module2, exports2) {
28386 function PrefixCodeRange(offset3, nbits) {
28387 this.offset = offset3;
28388 this.nbits = nbits;
28389 }
28390 exports2.kBlockLengthPrefixCode = [
28391 new PrefixCodeRange(1, 2),
28392 new PrefixCodeRange(5, 2),
28393 new PrefixCodeRange(9, 2),
28394 new PrefixCodeRange(13, 2),
28395 new PrefixCodeRange(17, 3),
28396 new PrefixCodeRange(25, 3),
28397 new PrefixCodeRange(33, 3),
28398 new PrefixCodeRange(41, 3),
28399 new PrefixCodeRange(49, 4),
28400 new PrefixCodeRange(65, 4),
28401 new PrefixCodeRange(81, 4),
28402 new PrefixCodeRange(97, 4),
28403 new PrefixCodeRange(113, 5),
28404 new PrefixCodeRange(145, 5),
28405 new PrefixCodeRange(177, 5),
28406 new PrefixCodeRange(209, 5),
28407 new PrefixCodeRange(241, 6),
28408 new PrefixCodeRange(305, 6),
28409 new PrefixCodeRange(369, 7),
28410 new PrefixCodeRange(497, 8),
28411 new PrefixCodeRange(753, 9),
28412 new PrefixCodeRange(1265, 10),
28413 new PrefixCodeRange(2289, 11),
28414 new PrefixCodeRange(4337, 12),
28415 new PrefixCodeRange(8433, 13),
28416 new PrefixCodeRange(16625, 24)
28417 ];
28418 exports2.kInsertLengthPrefixCode = [
28419 new PrefixCodeRange(0, 0),
28420 new PrefixCodeRange(1, 0),
28421 new PrefixCodeRange(2, 0),
28422 new PrefixCodeRange(3, 0),
28423 new PrefixCodeRange(4, 0),
28424 new PrefixCodeRange(5, 0),
28425 new PrefixCodeRange(6, 1),
28426 new PrefixCodeRange(8, 1),
28427 new PrefixCodeRange(10, 2),
28428 new PrefixCodeRange(14, 2),
28429 new PrefixCodeRange(18, 3),
28430 new PrefixCodeRange(26, 3),
28431 new PrefixCodeRange(34, 4),
28432 new PrefixCodeRange(50, 4),
28433 new PrefixCodeRange(66, 5),
28434 new PrefixCodeRange(98, 5),
28435 new PrefixCodeRange(130, 6),
28436 new PrefixCodeRange(194, 7),
28437 new PrefixCodeRange(322, 8),
28438 new PrefixCodeRange(578, 9),
28439 new PrefixCodeRange(1090, 10),
28440 new PrefixCodeRange(2114, 12),
28441 new PrefixCodeRange(6210, 14),
28442 new PrefixCodeRange(22594, 24)
28443 ];
28444 exports2.kCopyLengthPrefixCode = [
28445 new PrefixCodeRange(2, 0),
28446 new PrefixCodeRange(3, 0),
28447 new PrefixCodeRange(4, 0),
28448 new PrefixCodeRange(5, 0),
28449 new PrefixCodeRange(6, 0),
28450 new PrefixCodeRange(7, 0),
28451 new PrefixCodeRange(8, 0),
28452 new PrefixCodeRange(9, 0),
28453 new PrefixCodeRange(10, 1),
28454 new PrefixCodeRange(12, 1),
28455 new PrefixCodeRange(14, 2),
28456 new PrefixCodeRange(18, 2),
28457 new PrefixCodeRange(22, 3),
28458 new PrefixCodeRange(30, 3),
28459 new PrefixCodeRange(38, 4),
28460 new PrefixCodeRange(54, 4),
28461 new PrefixCodeRange(70, 5),
28462 new PrefixCodeRange(102, 5),
28463 new PrefixCodeRange(134, 6),
28464 new PrefixCodeRange(198, 7),
28465 new PrefixCodeRange(326, 8),
28466 new PrefixCodeRange(582, 9),
28467 new PrefixCodeRange(1094, 10),
28468 new PrefixCodeRange(2118, 24)
28469 ];
28470 exports2.kInsertRangeLut = [0, 0, 8, 8, 0, 16, 8, 16, 16];
28471 exports2.kCopyRangeLut = [0, 8, 0, 8, 16, 0, 16, 8, 16];
28472 },
28473 {}
28474 ],
28475 10: [
28476 function(require2, module2, exports2) {
28477 function BrotliInput(buffer) {
28478 this.buffer = buffer;
28479 this.pos = 0;
28480 }
28481 BrotliInput.prototype.read = function(buf, i3, count) {
28482 if (this.pos + count > this.buffer.length) {
28483 count = this.buffer.length - this.pos;
28484 }
28485 for (var p4 = 0; p4 < count; p4++)
28486 buf[i3 + p4] = this.buffer[this.pos + p4];
28487 this.pos += count;
28488 return count;
28489 };
28490 exports2.BrotliInput = BrotliInput;
28491 function BrotliOutput(buf) {
28492 this.buffer = buf;
28493 this.pos = 0;
28494 }
28495 BrotliOutput.prototype.write = function(buf, count) {
28496 if (this.pos + count > this.buffer.length)
28497 throw new Error(
28498 "Output buffer is not large enough"
28499 );
28500 this.buffer.set(buf.subarray(0, count), this.pos);
28501 this.pos += count;
28502 return count;
28503 };
28504 exports2.BrotliOutput = BrotliOutput;
28505 },
28506 {}
28507 ],
28508 11: [
28509 function(require2, module2, exports2) {
28510 var BrotliDictionary = require2("./dictionary");
28511 var kIdentity = 0;
28512 var kOmitLast1 = 1;
28513 var kOmitLast2 = 2;
28514 var kOmitLast3 = 3;
28515 var kOmitLast4 = 4;
28516 var kOmitLast5 = 5;
28517 var kOmitLast6 = 6;
28518 var kOmitLast7 = 7;
28519 var kOmitLast8 = 8;
28520 var kOmitLast9 = 9;
28521 var kUppercaseFirst = 10;
28522 var kUppercaseAll = 11;
28523 var kOmitFirst1 = 12;
28524 var kOmitFirst2 = 13;
28525 var kOmitFirst3 = 14;
28526 var kOmitFirst4 = 15;
28527 var kOmitFirst5 = 16;
28528 var kOmitFirst6 = 17;
28529 var kOmitFirst7 = 18;
28530 var kOmitFirst8 = 19;
28531 var kOmitFirst9 = 20;
28532 function Transform(prefix2, transform, suffix) {
28533 this.prefix = new Uint8Array(prefix2.length);
28534 this.transform = transform;
28535 this.suffix = new Uint8Array(suffix.length);
28536 for (var i3 = 0; i3 < prefix2.length; i3++)
28537 this.prefix[i3] = prefix2.charCodeAt(i3);
28538 for (var i3 = 0; i3 < suffix.length; i3++)
28539 this.suffix[i3] = suffix.charCodeAt(i3);
28540 }
28541 var kTransforms = [
28542 new Transform("", kIdentity, ""),
28543 new Transform("", kIdentity, " "),
28544 new Transform(" ", kIdentity, " "),
28545 new Transform("", kOmitFirst1, ""),
28546 new Transform("", kUppercaseFirst, " "),
28547 new Transform("", kIdentity, " the "),
28548 new Transform(" ", kIdentity, ""),
28549 new Transform("s ", kIdentity, " "),
28550 new Transform("", kIdentity, " of "),
28551 new Transform("", kUppercaseFirst, ""),
28552 new Transform("", kIdentity, " and "),
28553 new Transform("", kOmitFirst2, ""),
28554 new Transform("", kOmitLast1, ""),
28555 new Transform(", ", kIdentity, " "),
28556 new Transform("", kIdentity, ", "),
28557 new Transform(" ", kUppercaseFirst, " "),
28558 new Transform("", kIdentity, " in "),
28559 new Transform("", kIdentity, " to "),
28560 new Transform("e ", kIdentity, " "),
28561 new Transform("", kIdentity, '"'),
28562 new Transform("", kIdentity, "."),
28563 new Transform("", kIdentity, '">'),
28564 new Transform("", kIdentity, "\n"),
28565 new Transform("", kOmitLast3, ""),
28566 new Transform("", kIdentity, "]"),
28567 new Transform("", kIdentity, " for "),
28568 new Transform("", kOmitFirst3, ""),
28569 new Transform("", kOmitLast2, ""),
28570 new Transform("", kIdentity, " a "),
28571 new Transform("", kIdentity, " that "),
28572 new Transform(" ", kUppercaseFirst, ""),
28573 new Transform("", kIdentity, ". "),
28574 new Transform(".", kIdentity, ""),
28575 new Transform(" ", kIdentity, ", "),
28576 new Transform("", kOmitFirst4, ""),
28577 new Transform("", kIdentity, " with "),
28578 new Transform("", kIdentity, "'"),
28579 new Transform("", kIdentity, " from "),
28580 new Transform("", kIdentity, " by "),
28581 new Transform("", kOmitFirst5, ""),
28582 new Transform("", kOmitFirst6, ""),
28583 new Transform(" the ", kIdentity, ""),
28584 new Transform("", kOmitLast4, ""),
28585 new Transform("", kIdentity, ". The "),
28586 new Transform("", kUppercaseAll, ""),
28587 new Transform("", kIdentity, " on "),
28588 new Transform("", kIdentity, " as "),
28589 new Transform("", kIdentity, " is "),
28590 new Transform("", kOmitLast7, ""),
28591 new Transform("", kOmitLast1, "ing "),
28592 new Transform("", kIdentity, "\n "),
28593 new Transform("", kIdentity, ":"),
28594 new Transform(" ", kIdentity, ". "),
28595 new Transform("", kIdentity, "ed "),
28596 new Transform("", kOmitFirst9, ""),
28597 new Transform("", kOmitFirst7, ""),
28598 new Transform("", kOmitLast6, ""),
28599 new Transform("", kIdentity, "("),
28600 new Transform("", kUppercaseFirst, ", "),
28601 new Transform("", kOmitLast8, ""),
28602 new Transform("", kIdentity, " at "),
28603 new Transform("", kIdentity, "ly "),
28604 new Transform(" the ", kIdentity, " of "),
28605 new Transform("", kOmitLast5, ""),
28606 new Transform("", kOmitLast9, ""),
28607 new Transform(" ", kUppercaseFirst, ", "),
28608 new Transform("", kUppercaseFirst, '"'),
28609 new Transform(".", kIdentity, "("),
28610 new Transform("", kUppercaseAll, " "),
28611 new Transform("", kUppercaseFirst, '">'),
28612 new Transform("", kIdentity, '="'),
28613 new Transform(" ", kIdentity, "."),
28614 new Transform(".com/", kIdentity, ""),
28615 new Transform(" the ", kIdentity, " of the "),
28616 new Transform("", kUppercaseFirst, "'"),
28617 new Transform("", kIdentity, ". This "),
28618 new Transform("", kIdentity, ","),
28619 new Transform(".", kIdentity, " "),
28620 new Transform("", kUppercaseFirst, "("),
28621 new Transform("", kUppercaseFirst, "."),
28622 new Transform("", kIdentity, " not "),
28623 new Transform(" ", kIdentity, '="'),
28624 new Transform("", kIdentity, "er "),
28625 new Transform(" ", kUppercaseAll, " "),
28626 new Transform("", kIdentity, "al "),
28627 new Transform(" ", kUppercaseAll, ""),
28628 new Transform("", kIdentity, "='"),
28629 new Transform("", kUppercaseAll, '"'),
28630 new Transform("", kUppercaseFirst, ". "),
28631 new Transform(" ", kIdentity, "("),
28632 new Transform("", kIdentity, "ful "),
28633 new Transform(" ", kUppercaseFirst, ". "),
28634 new Transform("", kIdentity, "ive "),
28635 new Transform("", kIdentity, "less "),
28636 new Transform("", kUppercaseAll, "'"),
28637 new Transform("", kIdentity, "est "),
28638 new Transform(" ", kUppercaseFirst, "."),
28639 new Transform("", kUppercaseAll, '">'),
28640 new Transform(" ", kIdentity, "='"),
28641 new Transform("", kUppercaseFirst, ","),
28642 new Transform("", kIdentity, "ize "),
28643 new Transform("", kUppercaseAll, "."),
28644 new Transform("\xC2\xA0", kIdentity, ""),
28645 new Transform(" ", kIdentity, ","),
28646 new Transform("", kUppercaseFirst, '="'),
28647 new Transform("", kUppercaseAll, '="'),
28648 new Transform("", kIdentity, "ous "),
28649 new Transform("", kUppercaseAll, ", "),
28650 new Transform("", kUppercaseFirst, "='"),
28651 new Transform(" ", kUppercaseFirst, ","),
28652 new Transform(" ", kUppercaseAll, '="'),
28653 new Transform(" ", kUppercaseAll, ", "),
28654 new Transform("", kUppercaseAll, ","),
28655 new Transform("", kUppercaseAll, "("),
28656 new Transform("", kUppercaseAll, ". "),
28657 new Transform(" ", kUppercaseAll, "."),
28658 new Transform("", kUppercaseAll, "='"),
28659 new Transform(" ", kUppercaseAll, ". "),
28660 new Transform(" ", kUppercaseFirst, '="'),
28661 new Transform(" ", kUppercaseAll, "='"),
28662 new Transform(" ", kUppercaseFirst, "='")
28663 ];
28664 exports2.kTransforms = kTransforms;
28665 exports2.kNumTransforms = kTransforms.length;
28666 function ToUpperCase(p4, i3) {
28667 if (p4[i3] < 192) {
28668 if (p4[i3] >= 97 && p4[i3] <= 122) {
28669 p4[i3] ^= 32;
28670 }
28671 return 1;
28672 }
28673 if (p4[i3] < 224) {
28674 p4[i3 + 1] ^= 32;
28675 return 2;
28676 }
28677 p4[i3 + 2] ^= 5;
28678 return 3;
28679 }
28680 exports2.transformDictionaryWord = function(dst, idx, word, len, transform) {
28681 var prefix2 = kTransforms[transform].prefix;
28682 var suffix = kTransforms[transform].suffix;
28683 var t4 = kTransforms[transform].transform;
28684 var skip = t4 < kOmitFirst1 ? 0 : t4 - (kOmitFirst1 - 1);
28685 var i3 = 0;
28686 var start_idx = idx;
28687 var uppercase;
28688 if (skip > len) {
28689 skip = len;
28690 }
28691 var prefix_pos = 0;
28692 while (prefix_pos < prefix2.length) {
28693 dst[idx++] = prefix2[prefix_pos++];
28694 }
28695 word += skip;
28696 len -= skip;
28697 if (t4 <= kOmitLast9) {
28698 len -= t4;
28699 }
28700 for (i3 = 0; i3 < len; i3++) {
28701 dst[idx++] = BrotliDictionary.dictionary[word + i3];
28702 }
28703 uppercase = idx - len;
28704 if (t4 === kUppercaseFirst) {
28705 ToUpperCase(dst, uppercase);
28706 } else if (t4 === kUppercaseAll) {
28707 while (len > 0) {
28708 var step = ToUpperCase(dst, uppercase);
28709 uppercase += step;
28710 len -= step;
28711 }
28712 }
28713 var suffix_pos = 0;
28714 while (suffix_pos < suffix.length) {
28715 dst[idx++] = suffix[suffix_pos++];
28716 }
28717 return idx - start_idx;
28718 };
28719 },
28720 { "./dictionary": 6 }
28721 ],
28722 12: [
28723 function(require2, module2, exports2) {
28724 module2.exports = require2("./dec/decode").BrotliDecompressBuffer;
28725 },
28726 { "./dec/decode": 3 }
28727 ]
28728 },
28729 {},
28730 [12]
28731 )(12);
28732 })();
28733
28734 // packages/global-styles-ui/build-module/font-library/lib/inflate.mjs
28735 var __require3 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, {
28736 get: (a3, b3) => (typeof __require !== "undefined" ? __require : a3)[b3]
28737 }) : x2)(function(x2) {
28738 if (typeof __require !== "undefined") return __require.apply(this, arguments);
28739 throw Error('Dynamic require of "' + x2 + '" is not supported');
28740 });
28741 var inflate_default = (function() {
28742 var define2, module, exports;
28743 return (/* @__PURE__ */ (function() {
28744 function r4(e3, n3, t4) {
28745 function o4(i22, f3) {
28746 if (!n3[i22]) {
28747 if (!e3[i22]) {
28748 var c6 = "function" == typeof __require3 && __require3;
28749 if (!f3 && c6) return c6(i22, true);
28750 if (u3) return u3(i22, true);
28751 var a3 = new Error("Cannot find module '" + i22 + "'");
28752 throw a3.code = "MODULE_NOT_FOUND", a3;
28753 }
28754 var p4 = n3[i22] = { exports: {} };
28755 e3[i22][0].call(
28756 p4.exports,
28757 function(r22) {
28758 var n22 = e3[i22][1][r22];
28759 return o4(n22 || r22);
28760 },
28761 p4,
28762 p4.exports,
28763 r4,
28764 e3,
28765 n3,
28766 t4
28767 );
28768 }
28769 return n3[i22].exports;
28770 }
28771 for (var u3 = "function" == typeof __require3 && __require3, i3 = 0; i3 < t4.length; i3++)
28772 o4(t4[i3]);
28773 return o4;
28774 }
28775 return r4;
28776 })())(
28777 {
28778 1: [
28779 function(require2, module2, exports2) {
28780 "use strict";
28781 var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined";
28782 function _has(obj, key) {
28783 return Object.prototype.hasOwnProperty.call(obj, key);
28784 }
28785 exports2.assign = function(obj) {
28786 var sources = Array.prototype.slice.call(
28787 arguments,
28788 1
28789 );
28790 while (sources.length) {
28791 var source = sources.shift();
28792 if (!source) {
28793 continue;
28794 }
28795 if (typeof source !== "object") {
28796 throw new TypeError(
28797 source + "must be non-object"
28798 );
28799 }
28800 for (var p4 in source) {
28801 if (_has(source, p4)) {
28802 obj[p4] = source[p4];
28803 }
28804 }
28805 }
28806 return obj;
28807 };
28808 exports2.shrinkBuf = function(buf, size3) {
28809 if (buf.length === size3) {
28810 return buf;
28811 }
28812 if (buf.subarray) {
28813 return buf.subarray(0, size3);
28814 }
28815 buf.length = size3;
28816 return buf;
28817 };
28818 var fnTyped = {
28819 arraySet: function(dest, src, src_offs, len, dest_offs) {
28820 if (src.subarray && dest.subarray) {
28821 dest.set(
28822 src.subarray(src_offs, src_offs + len),
28823 dest_offs
28824 );
28825 return;
28826 }
28827 for (var i3 = 0; i3 < len; i3++) {
28828 dest[dest_offs + i3] = src[src_offs + i3];
28829 }
28830 },
28831 // Join array of chunks to single array.
28832 flattenChunks: function(chunks) {
28833 var i3, l3, len, pos, chunk, result;
28834 len = 0;
28835 for (i3 = 0, l3 = chunks.length; i3 < l3; i3++) {
28836 len += chunks[i3].length;
28837 }
28838 result = new Uint8Array(len);
28839 pos = 0;
28840 for (i3 = 0, l3 = chunks.length; i3 < l3; i3++) {
28841 chunk = chunks[i3];
28842 result.set(chunk, pos);
28843 pos += chunk.length;
28844 }
28845 return result;
28846 }
28847 };
28848 var fnUntyped = {
28849 arraySet: function(dest, src, src_offs, len, dest_offs) {
28850 for (var i3 = 0; i3 < len; i3++) {
28851 dest[dest_offs + i3] = src[src_offs + i3];
28852 }
28853 },
28854 // Join array of chunks to single array.
28855 flattenChunks: function(chunks) {
28856 return [].concat.apply([], chunks);
28857 }
28858 };
28859 exports2.setTyped = function(on) {
28860 if (on) {
28861 exports2.Buf8 = Uint8Array;
28862 exports2.Buf16 = Uint16Array;
28863 exports2.Buf32 = Int32Array;
28864 exports2.assign(exports2, fnTyped);
28865 } else {
28866 exports2.Buf8 = Array;
28867 exports2.Buf16 = Array;
28868 exports2.Buf32 = Array;
28869 exports2.assign(exports2, fnUntyped);
28870 }
28871 };
28872 exports2.setTyped(TYPED_OK);
28873 },
28874 {}
28875 ],
28876 2: [
28877 function(require2, module2, exports2) {
28878 "use strict";
28879 var utils = require2("./common");
28880 var STR_APPLY_OK = true;
28881 var STR_APPLY_UIA_OK = true;
28882 try {
28883 String.fromCharCode.apply(null, [0]);
28884 } catch (__268) {
28885 STR_APPLY_OK = false;
28886 }
28887 try {
28888 String.fromCharCode.apply(null, new Uint8Array(1));
28889 } catch (__268) {
28890 STR_APPLY_UIA_OK = false;
28891 }
28892 var _utf8len = new utils.Buf8(256);
28893 for (var q = 0; q < 256; q++) {
28894 _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;
28895 }
28896 _utf8len[254] = _utf8len[254] = 1;
28897 exports2.string2buf = function(str) {
28898 var buf, c6, c22, m_pos, i3, str_len = str.length, buf_len = 0;
28899 for (m_pos = 0; m_pos < str_len; m_pos++) {
28900 c6 = str.charCodeAt(m_pos);
28901 if ((c6 & 64512) === 55296 && m_pos + 1 < str_len) {
28902 c22 = str.charCodeAt(m_pos + 1);
28903 if ((c22 & 64512) === 56320) {
28904 c6 = 65536 + (c6 - 55296 << 10) + (c22 - 56320);
28905 m_pos++;
28906 }
28907 }
28908 buf_len += c6 < 128 ? 1 : c6 < 2048 ? 2 : c6 < 65536 ? 3 : 4;
28909 }
28910 buf = new utils.Buf8(buf_len);
28911 for (i3 = 0, m_pos = 0; i3 < buf_len; m_pos++) {
28912 c6 = str.charCodeAt(m_pos);
28913 if ((c6 & 64512) === 55296 && m_pos + 1 < str_len) {
28914 c22 = str.charCodeAt(m_pos + 1);
28915 if ((c22 & 64512) === 56320) {
28916 c6 = 65536 + (c6 - 55296 << 10) + (c22 - 56320);
28917 m_pos++;
28918 }
28919 }
28920 if (c6 < 128) {
28921 buf[i3++] = c6;
28922 } else if (c6 < 2048) {
28923 buf[i3++] = 192 | c6 >>> 6;
28924 buf[i3++] = 128 | c6 & 63;
28925 } else if (c6 < 65536) {
28926 buf[i3++] = 224 | c6 >>> 12;
28927 buf[i3++] = 128 | c6 >>> 6 & 63;
28928 buf[i3++] = 128 | c6 & 63;
28929 } else {
28930 buf[i3++] = 240 | c6 >>> 18;
28931 buf[i3++] = 128 | c6 >>> 12 & 63;
28932 buf[i3++] = 128 | c6 >>> 6 & 63;
28933 buf[i3++] = 128 | c6 & 63;
28934 }
28935 }
28936 return buf;
28937 };
28938 function buf2binstring(buf, len) {
28939 if (len < 65534) {
28940 if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) {
28941 return String.fromCharCode.apply(
28942 null,
28943 utils.shrinkBuf(buf, len)
28944 );
28945 }
28946 }
28947 var result = "";
28948 for (var i3 = 0; i3 < len; i3++) {
28949 result += String.fromCharCode(buf[i3]);
28950 }
28951 return result;
28952 }
28953 exports2.buf2binstring = function(buf) {
28954 return buf2binstring(buf, buf.length);
28955 };
28956 exports2.binstring2buf = function(str) {
28957 var buf = new utils.Buf8(str.length);
28958 for (var i3 = 0, len = buf.length; i3 < len; i3++) {
28959 buf[i3] = str.charCodeAt(i3);
28960 }
28961 return buf;
28962 };
28963 exports2.buf2string = function(buf, max2) {
28964 var i3, out, c6, c_len;
28965 var len = max2 || buf.length;
28966 var utf16buf = new Array(len * 2);
28967 for (out = 0, i3 = 0; i3 < len; ) {
28968 c6 = buf[i3++];
28969 if (c6 < 128) {
28970 utf16buf[out++] = c6;
28971 continue;
28972 }
28973 c_len = _utf8len[c6];
28974 if (c_len > 4) {
28975 utf16buf[out++] = 65533;
28976 i3 += c_len - 1;
28977 continue;
28978 }
28979 c6 &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;
28980 while (c_len > 1 && i3 < len) {
28981 c6 = c6 << 6 | buf[i3++] & 63;
28982 c_len--;
28983 }
28984 if (c_len > 1) {
28985 utf16buf[out++] = 65533;
28986 continue;
28987 }
28988 if (c6 < 65536) {
28989 utf16buf[out++] = c6;
28990 } else {
28991 c6 -= 65536;
28992 utf16buf[out++] = 55296 | c6 >> 10 & 1023;
28993 utf16buf[out++] = 56320 | c6 & 1023;
28994 }
28995 }
28996 return buf2binstring(utf16buf, out);
28997 };
28998 exports2.utf8border = function(buf, max2) {
28999 var pos;
29000 max2 = max2 || buf.length;
29001 if (max2 > buf.length) {
29002 max2 = buf.length;
29003 }
29004 pos = max2 - 1;
29005 while (pos >= 0 && (buf[pos] & 192) === 128) {
29006 pos--;
29007 }
29008 if (pos < 0) {
29009 return max2;
29010 }
29011 if (pos === 0) {
29012 return max2;
29013 }
29014 return pos + _utf8len[buf[pos]] > max2 ? pos : max2;
29015 };
29016 },
29017 { "./common": 1 }
29018 ],
29019 3: [
29020 function(require2, module2, exports2) {
29021 "use strict";
29022 function adler32(adler, buf, len, pos) {
29023 var s1 = adler & 65535 | 0, s22 = adler >>> 16 & 65535 | 0, n3 = 0;
29024 while (len !== 0) {
29025 n3 = len > 2e3 ? 2e3 : len;
29026 len -= n3;
29027 do {
29028 s1 = s1 + buf[pos++] | 0;
29029 s22 = s22 + s1 | 0;
29030 } while (--n3);
29031 s1 %= 65521;
29032 s22 %= 65521;
29033 }
29034 return s1 | s22 << 16 | 0;
29035 }
29036 module2.exports = adler32;
29037 },
29038 {}
29039 ],
29040 4: [
29041 function(require2, module2, exports2) {
29042 "use strict";
29043 module2.exports = {
29044 /* Allowed flush values; see deflate() and inflate() below for details */
29045 Z_NO_FLUSH: 0,
29046 Z_PARTIAL_FLUSH: 1,
29047 Z_SYNC_FLUSH: 2,
29048 Z_FULL_FLUSH: 3,
29049 Z_FINISH: 4,
29050 Z_BLOCK: 5,
29051 Z_TREES: 6,
29052 /* Return codes for the compression/decompression functions. Negative values
29053 * are errors, positive values are used for special but normal events.
29054 */
29055 Z_OK: 0,
29056 Z_STREAM_END: 1,
29057 Z_NEED_DICT: 2,
29058 Z_ERRNO: -1,
29059 Z_STREAM_ERROR: -2,
29060 Z_DATA_ERROR: -3,
29061 //Z_MEM_ERROR: -4,
29062 Z_BUF_ERROR: -5,
29063 //Z_VERSION_ERROR: -6,
29064 /* compression levels */
29065 Z_NO_COMPRESSION: 0,
29066 Z_BEST_SPEED: 1,
29067 Z_BEST_COMPRESSION: 9,
29068 Z_DEFAULT_COMPRESSION: -1,
29069 Z_FILTERED: 1,
29070 Z_HUFFMAN_ONLY: 2,
29071 Z_RLE: 3,
29072 Z_FIXED: 4,
29073 Z_DEFAULT_STRATEGY: 0,
29074 /* Possible values of the data_type field (though see inflate()) */
29075 Z_BINARY: 0,
29076 Z_TEXT: 1,
29077 //Z_ASCII: 1, // = Z_TEXT (deprecated)
29078 Z_UNKNOWN: 2,
29079 /* The deflate compression method */
29080 Z_DEFLATED: 8
29081 //Z_NULL: null // Use -1 or null inline, depending on var type
29082 };
29083 },
29084 {}
29085 ],
29086 5: [
29087 function(require2, module2, exports2) {
29088 "use strict";
29089 function makeTable() {
29090 var c6, table = [];
29091 for (var n3 = 0; n3 < 256; n3++) {
29092 c6 = n3;
29093 for (var k2 = 0; k2 < 8; k2++) {
29094 c6 = c6 & 1 ? 3988292384 ^ c6 >>> 1 : c6 >>> 1;
29095 }
29096 table[n3] = c6;
29097 }
29098 return table;
29099 }
29100 var crcTable = makeTable();
29101 function crc32(crc, buf, len, pos) {
29102 var t4 = crcTable, end = pos + len;
29103 crc ^= -1;
29104 for (var i3 = pos; i3 < end; i3++) {
29105 crc = crc >>> 8 ^ t4[(crc ^ buf[i3]) & 255];
29106 }
29107 return crc ^ -1;
29108 }
29109 module2.exports = crc32;
29110 },
29111 {}
29112 ],
29113 6: [
29114 function(require2, module2, exports2) {
29115 "use strict";
29116 function GZheader() {
29117 this.text = 0;
29118 this.time = 0;
29119 this.xflags = 0;
29120 this.os = 0;
29121 this.extra = null;
29122 this.extra_len = 0;
29123 this.name = "";
29124 this.comment = "";
29125 this.hcrc = 0;
29126 this.done = false;
29127 }
29128 module2.exports = GZheader;
29129 },
29130 {}
29131 ],
29132 7: [
29133 function(require2, module2, exports2) {
29134 "use strict";
29135 var BAD = 30;
29136 var TYPE = 12;
29137 module2.exports = function inflate_fast(strm, start2) {
29138 var state;
29139 var _in;
29140 var last;
29141 var _out;
29142 var beg;
29143 var end;
29144 var dmax;
29145 var wsize;
29146 var whave;
29147 var wnext;
29148 var s_window;
29149 var hold;
29150 var bits;
29151 var lcode;
29152 var dcode;
29153 var lmask;
29154 var dmask;
29155 var here;
29156 var op;
29157 var len;
29158 var dist;
29159 var from;
29160 var from_source;
29161 var input, output;
29162 state = strm.state;
29163 _in = strm.next_in;
29164 input = strm.input;
29165 last = _in + (strm.avail_in - 5);
29166 _out = strm.next_out;
29167 output = strm.output;
29168 beg = _out - (start2 - strm.avail_out);
29169 end = _out + (strm.avail_out - 257);
29170 dmax = state.dmax;
29171 wsize = state.wsize;
29172 whave = state.whave;
29173 wnext = state.wnext;
29174 s_window = state.window;
29175 hold = state.hold;
29176 bits = state.bits;
29177 lcode = state.lencode;
29178 dcode = state.distcode;
29179 lmask = (1 << state.lenbits) - 1;
29180 dmask = (1 << state.distbits) - 1;
29181 top: do {
29182 if (bits < 15) {
29183 hold += input[_in++] << bits;
29184 bits += 8;
29185 hold += input[_in++] << bits;
29186 bits += 8;
29187 }
29188 here = lcode[hold & lmask];
29189 dolen: for (; ; ) {
29190 op = here >>> 24;
29191 hold >>>= op;
29192 bits -= op;
29193 op = here >>> 16 & 255;
29194 if (op === 0) {
29195 output[_out++] = here & 65535;
29196 } else if (op & 16) {
29197 len = here & 65535;
29198 op &= 15;
29199 if (op) {
29200 if (bits < op) {
29201 hold += input[_in++] << bits;
29202 bits += 8;
29203 }
29204 len += hold & (1 << op) - 1;
29205 hold >>>= op;
29206 bits -= op;
29207 }
29208 if (bits < 15) {
29209 hold += input[_in++] << bits;
29210 bits += 8;
29211 hold += input[_in++] << bits;
29212 bits += 8;
29213 }
29214 here = dcode[hold & dmask];
29215 dodist: for (; ; ) {
29216 op = here >>> 24;
29217 hold >>>= op;
29218 bits -= op;
29219 op = here >>> 16 & 255;
29220 if (op & 16) {
29221 dist = here & 65535;
29222 op &= 15;
29223 if (bits < op) {
29224 hold += input[_in++] << bits;
29225 bits += 8;
29226 if (bits < op) {
29227 hold += input[_in++] << bits;
29228 bits += 8;
29229 }
29230 }
29231 dist += hold & (1 << op) - 1;
29232 if (dist > dmax) {
29233 strm.msg = "invalid distance too far back";
29234 state.mode = BAD;
29235 break top;
29236 }
29237 hold >>>= op;
29238 bits -= op;
29239 op = _out - beg;
29240 if (dist > op) {
29241 op = dist - op;
29242 if (op > whave) {
29243 if (state.sane) {
29244 strm.msg = "invalid distance too far back";
29245 state.mode = BAD;
29246 break top;
29247 }
29248 }
29249 from = 0;
29250 from_source = s_window;
29251 if (wnext === 0) {
29252 from += wsize - op;
29253 if (op < len) {
29254 len -= op;
29255 do {
29256 output[_out++] = s_window[from++];
29257 } while (--op);
29258 from = _out - dist;
29259 from_source = output;
29260 }
29261 } else if (wnext < op) {
29262 from += wsize + wnext - op;
29263 op -= wnext;
29264 if (op < len) {
29265 len -= op;
29266 do {
29267 output[_out++] = s_window[from++];
29268 } while (--op);
29269 from = 0;
29270 if (wnext < len) {
29271 op = wnext;
29272 len -= op;
29273 do {
29274 output[_out++] = s_window[from++];
29275 } while (--op);
29276 from = _out - dist;
29277 from_source = output;
29278 }
29279 }
29280 } else {
29281 from += wnext - op;
29282 if (op < len) {
29283 len -= op;
29284 do {
29285 output[_out++] = s_window[from++];
29286 } while (--op);
29287 from = _out - dist;
29288 from_source = output;
29289 }
29290 }
29291 while (len > 2) {
29292 output[_out++] = from_source[from++];
29293 output[_out++] = from_source[from++];
29294 output[_out++] = from_source[from++];
29295 len -= 3;
29296 }
29297 if (len) {
29298 output[_out++] = from_source[from++];
29299 if (len > 1) {
29300 output[_out++] = from_source[from++];
29301 }
29302 }
29303 } else {
29304 from = _out - dist;
29305 do {
29306 output[_out++] = output[from++];
29307 output[_out++] = output[from++];
29308 output[_out++] = output[from++];
29309 len -= 3;
29310 } while (len > 2);
29311 if (len) {
29312 output[_out++] = output[from++];
29313 if (len > 1) {
29314 output[_out++] = output[from++];
29315 }
29316 }
29317 }
29318 } else if ((op & 64) === 0) {
29319 here = dcode[(here & 65535) + (hold & (1 << op) - 1)];
29320 continue dodist;
29321 } else {
29322 strm.msg = "invalid distance code";
29323 state.mode = BAD;
29324 break top;
29325 }
29326 break;
29327 }
29328 } else if ((op & 64) === 0) {
29329 here = lcode[(here & 65535) + (hold & (1 << op) - 1)];
29330 continue dolen;
29331 } else if (op & 32) {
29332 state.mode = TYPE;
29333 break top;
29334 } else {
29335 strm.msg = "invalid literal/length code";
29336 state.mode = BAD;
29337 break top;
29338 }
29339 break;
29340 }
29341 } while (_in < last && _out < end);
29342 len = bits >> 3;
29343 _in -= len;
29344 bits -= len << 3;
29345 hold &= (1 << bits) - 1;
29346 strm.next_in = _in;
29347 strm.next_out = _out;
29348 strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);
29349 strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);
29350 state.hold = hold;
29351 state.bits = bits;
29352 return;
29353 };
29354 },
29355 {}
29356 ],
29357 8: [
29358 function(require2, module2, exports2) {
29359 "use strict";
29360 var utils = require2("../utils/common");
29361 var adler32 = require2("./adler32");
29362 var crc32 = require2("./crc32");
29363 var inflate_fast = require2("./inffast");
29364 var inflate_table = require2("./inftrees");
29365 var CODES = 0;
29366 var LENS = 1;
29367 var DISTS = 2;
29368 var Z_FINISH = 4;
29369 var Z_BLOCK = 5;
29370 var Z_TREES = 6;
29371 var Z_OK = 0;
29372 var Z_STREAM_END = 1;
29373 var Z_NEED_DICT = 2;
29374 var Z_STREAM_ERROR = -2;
29375 var Z_DATA_ERROR = -3;
29376 var Z_MEM_ERROR = -4;
29377 var Z_BUF_ERROR = -5;
29378 var Z_DEFLATED = 8;
29379 var HEAD = 1;
29380 var FLAGS = 2;
29381 var TIME = 3;
29382 var OS = 4;
29383 var EXLEN = 5;
29384 var EXTRA = 6;
29385 var NAME = 7;
29386 var COMMENT = 8;
29387 var HCRC = 9;
29388 var DICTID = 10;
29389 var DICT = 11;
29390 var TYPE = 12;
29391 var TYPEDO = 13;
29392 var STORED = 14;
29393 var COPY_ = 15;
29394 var COPY = 16;
29395 var TABLE = 17;
29396 var LENLENS = 18;
29397 var CODELENS = 19;
29398 var LEN_ = 20;
29399 var LEN = 21;
29400 var LENEXT = 22;
29401 var DIST = 23;
29402 var DISTEXT = 24;
29403 var MATCH = 25;
29404 var LIT = 26;
29405 var CHECK = 27;
29406 var LENGTH = 28;
29407 var DONE = 29;
29408 var BAD = 30;
29409 var MEM = 31;
29410 var SYNC = 32;
29411 var ENOUGH_LENS = 852;
29412 var ENOUGH_DISTS = 592;
29413 var MAX_WBITS = 15;
29414 var DEF_WBITS = MAX_WBITS;
29415 function zswap32(q) {
29416 return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);
29417 }
29418 function InflateState() {
29419 this.mode = 0;
29420 this.last = false;
29421 this.wrap = 0;
29422 this.havedict = false;
29423 this.flags = 0;
29424 this.dmax = 0;
29425 this.check = 0;
29426 this.total = 0;
29427 this.head = null;
29428 this.wbits = 0;
29429 this.wsize = 0;
29430 this.whave = 0;
29431 this.wnext = 0;
29432 this.window = null;
29433 this.hold = 0;
29434 this.bits = 0;
29435 this.length = 0;
29436 this.offset = 0;
29437 this.extra = 0;
29438 this.lencode = null;
29439 this.distcode = null;
29440 this.lenbits = 0;
29441 this.distbits = 0;
29442 this.ncode = 0;
29443 this.nlen = 0;
29444 this.ndist = 0;
29445 this.have = 0;
29446 this.next = null;
29447 this.lens = new utils.Buf16(
29448 320
29449 );
29450 this.work = new utils.Buf16(
29451 288
29452 );
29453 this.lendyn = null;
29454 this.distdyn = null;
29455 this.sane = 0;
29456 this.back = 0;
29457 this.was = 0;
29458 }
29459 function inflateResetKeep(strm) {
29460 var state;
29461 if (!strm || !strm.state) {
29462 return Z_STREAM_ERROR;
29463 }
29464 state = strm.state;
29465 strm.total_in = strm.total_out = state.total = 0;
29466 strm.msg = "";
29467 if (state.wrap) {
29468 strm.adler = state.wrap & 1;
29469 }
29470 state.mode = HEAD;
29471 state.last = 0;
29472 state.havedict = 0;
29473 state.dmax = 32768;
29474 state.head = null;
29475 state.hold = 0;
29476 state.bits = 0;
29477 state.lencode = state.lendyn = new utils.Buf32(
29478 ENOUGH_LENS
29479 );
29480 state.distcode = state.distdyn = new utils.Buf32(
29481 ENOUGH_DISTS
29482 );
29483 state.sane = 1;
29484 state.back = -1;
29485 return Z_OK;
29486 }
29487 function inflateReset(strm) {
29488 var state;
29489 if (!strm || !strm.state) {
29490 return Z_STREAM_ERROR;
29491 }
29492 state = strm.state;
29493 state.wsize = 0;
29494 state.whave = 0;
29495 state.wnext = 0;
29496 return inflateResetKeep(strm);
29497 }
29498 function inflateReset2(strm, windowBits) {
29499 var wrap;
29500 var state;
29501 if (!strm || !strm.state) {
29502 return Z_STREAM_ERROR;
29503 }
29504 state = strm.state;
29505 if (windowBits < 0) {
29506 wrap = 0;
29507 windowBits = -windowBits;
29508 } else {
29509 wrap = (windowBits >> 4) + 1;
29510 if (windowBits < 48) {
29511 windowBits &= 15;
29512 }
29513 }
29514 if (windowBits && (windowBits < 8 || windowBits > 15)) {
29515 return Z_STREAM_ERROR;
29516 }
29517 if (state.window !== null && state.wbits !== windowBits) {
29518 state.window = null;
29519 }
29520 state.wrap = wrap;
29521 state.wbits = windowBits;
29522 return inflateReset(strm);
29523 }
29524 function inflateInit2(strm, windowBits) {
29525 var ret;
29526 var state;
29527 if (!strm) {
29528 return Z_STREAM_ERROR;
29529 }
29530 state = new InflateState();
29531 strm.state = state;
29532 state.window = null;
29533 ret = inflateReset2(strm, windowBits);
29534 if (ret !== Z_OK) {
29535 strm.state = null;
29536 }
29537 return ret;
29538 }
29539 function inflateInit(strm) {
29540 return inflateInit2(strm, DEF_WBITS);
29541 }
29542 var virgin = true;
29543 var lenfix, distfix;
29544 function fixedtables(state) {
29545 if (virgin) {
29546 var sym;
29547 lenfix = new utils.Buf32(512);
29548 distfix = new utils.Buf32(32);
29549 sym = 0;
29550 while (sym < 144) {
29551 state.lens[sym++] = 8;
29552 }
29553 while (sym < 256) {
29554 state.lens[sym++] = 9;
29555 }
29556 while (sym < 280) {
29557 state.lens[sym++] = 7;
29558 }
29559 while (sym < 288) {
29560 state.lens[sym++] = 8;
29561 }
29562 inflate_table(
29563 LENS,
29564 state.lens,
29565 0,
29566 288,
29567 lenfix,
29568 0,
29569 state.work,
29570 { bits: 9 }
29571 );
29572 sym = 0;
29573 while (sym < 32) {
29574 state.lens[sym++] = 5;
29575 }
29576 inflate_table(
29577 DISTS,
29578 state.lens,
29579 0,
29580 32,
29581 distfix,
29582 0,
29583 state.work,
29584 { bits: 5 }
29585 );
29586 virgin = false;
29587 }
29588 state.lencode = lenfix;
29589 state.lenbits = 9;
29590 state.distcode = distfix;
29591 state.distbits = 5;
29592 }
29593 function updatewindow(strm, src, end, copy) {
29594 var dist;
29595 var state = strm.state;
29596 if (state.window === null) {
29597 state.wsize = 1 << state.wbits;
29598 state.wnext = 0;
29599 state.whave = 0;
29600 state.window = new utils.Buf8(state.wsize);
29601 }
29602 if (copy >= state.wsize) {
29603 utils.arraySet(
29604 state.window,
29605 src,
29606 end - state.wsize,
29607 state.wsize,
29608 0
29609 );
29610 state.wnext = 0;
29611 state.whave = state.wsize;
29612 } else {
29613 dist = state.wsize - state.wnext;
29614 if (dist > copy) {
29615 dist = copy;
29616 }
29617 utils.arraySet(
29618 state.window,
29619 src,
29620 end - copy,
29621 dist,
29622 state.wnext
29623 );
29624 copy -= dist;
29625 if (copy) {
29626 utils.arraySet(
29627 state.window,
29628 src,
29629 end - copy,
29630 copy,
29631 0
29632 );
29633 state.wnext = copy;
29634 state.whave = state.wsize;
29635 } else {
29636 state.wnext += dist;
29637 if (state.wnext === state.wsize) {
29638 state.wnext = 0;
29639 }
29640 if (state.whave < state.wsize) {
29641 state.whave += dist;
29642 }
29643 }
29644 }
29645 return 0;
29646 }
29647 function inflate(strm, flush2) {
29648 var state;
29649 var input, output;
29650 var next;
29651 var put;
29652 var have, left;
29653 var hold;
29654 var bits;
29655 var _in, _out;
29656 var copy;
29657 var from;
29658 var from_source;
29659 var here = 0;
29660 var here_bits, here_op, here_val;
29661 var last_bits, last_op, last_val;
29662 var len;
29663 var ret;
29664 var hbuf = new utils.Buf8(
29665 4
29666 );
29667 var opts;
29668 var n3;
29669 var order = (
29670 /* permutation of code lengths */
29671 [
29672 16,
29673 17,
29674 18,
29675 0,
29676 8,
29677 7,
29678 9,
29679 6,
29680 10,
29681 5,
29682 11,
29683 4,
29684 12,
29685 3,
29686 13,
29687 2,
29688 14,
29689 1,
29690 15
29691 ]
29692 );
29693 if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
29694 return Z_STREAM_ERROR;
29695 }
29696 state = strm.state;
29697 if (state.mode === TYPE) {
29698 state.mode = TYPEDO;
29699 }
29700 put = strm.next_out;
29701 output = strm.output;
29702 left = strm.avail_out;
29703 next = strm.next_in;
29704 input = strm.input;
29705 have = strm.avail_in;
29706 hold = state.hold;
29707 bits = state.bits;
29708 _in = have;
29709 _out = left;
29710 ret = Z_OK;
29711 inf_leave: for (; ; ) {
29712 switch (state.mode) {
29713 case HEAD:
29714 if (state.wrap === 0) {
29715 state.mode = TYPEDO;
29716 break;
29717 }
29718 while (bits < 16) {
29719 if (have === 0) {
29720 break inf_leave;
29721 }
29722 have--;
29723 hold += input[next++] << bits;
29724 bits += 8;
29725 }
29726 if (state.wrap & 2 && hold === 35615) {
29727 state.check = 0;
29728 hbuf[0] = hold & 255;
29729 hbuf[1] = hold >>> 8 & 255;
29730 state.check = crc32(
29731 state.check,
29732 hbuf,
29733 2,
29734 0
29735 );
29736 hold = 0;
29737 bits = 0;
29738 state.mode = FLAGS;
29739 break;
29740 }
29741 state.flags = 0;
29742 if (state.head) {
29743 state.head.done = false;
29744 }
29745 if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) {
29746 strm.msg = "incorrect header check";
29747 state.mode = BAD;
29748 break;
29749 }
29750 if ((hold & 15) !== Z_DEFLATED) {
29751 strm.msg = "unknown compression method";
29752 state.mode = BAD;
29753 break;
29754 }
29755 hold >>>= 4;
29756 bits -= 4;
29757 len = (hold & 15) + 8;
29758 if (state.wbits === 0) {
29759 state.wbits = len;
29760 } else if (len > state.wbits) {
29761 strm.msg = "invalid window size";
29762 state.mode = BAD;
29763 break;
29764 }
29765 state.dmax = 1 << len;
29766 strm.adler = state.check = 1;
29767 state.mode = hold & 512 ? DICTID : TYPE;
29768 hold = 0;
29769 bits = 0;
29770 break;
29771 case FLAGS:
29772 while (bits < 16) {
29773 if (have === 0) {
29774 break inf_leave;
29775 }
29776 have--;
29777 hold += input[next++] << bits;
29778 bits += 8;
29779 }
29780 state.flags = hold;
29781 if ((state.flags & 255) !== Z_DEFLATED) {
29782 strm.msg = "unknown compression method";
29783 state.mode = BAD;
29784 break;
29785 }
29786 if (state.flags & 57344) {
29787 strm.msg = "unknown header flags set";
29788 state.mode = BAD;
29789 break;
29790 }
29791 if (state.head) {
29792 state.head.text = hold >> 8 & 1;
29793 }
29794 if (state.flags & 512) {
29795 hbuf[0] = hold & 255;
29796 hbuf[1] = hold >>> 8 & 255;
29797 state.check = crc32(
29798 state.check,
29799 hbuf,
29800 2,
29801 0
29802 );
29803 }
29804 hold = 0;
29805 bits = 0;
29806 state.mode = TIME;
29807 /* falls through */
29808 case TIME:
29809 while (bits < 32) {
29810 if (have === 0) {
29811 break inf_leave;
29812 }
29813 have--;
29814 hold += input[next++] << bits;
29815 bits += 8;
29816 }
29817 if (state.head) {
29818 state.head.time = hold;
29819 }
29820 if (state.flags & 512) {
29821 hbuf[0] = hold & 255;
29822 hbuf[1] = hold >>> 8 & 255;
29823 hbuf[2] = hold >>> 16 & 255;
29824 hbuf[3] = hold >>> 24 & 255;
29825 state.check = crc32(
29826 state.check,
29827 hbuf,
29828 4,
29829 0
29830 );
29831 }
29832 hold = 0;
29833 bits = 0;
29834 state.mode = OS;
29835 /* falls through */
29836 case OS:
29837 while (bits < 16) {
29838 if (have === 0) {
29839 break inf_leave;
29840 }
29841 have--;
29842 hold += input[next++] << bits;
29843 bits += 8;
29844 }
29845 if (state.head) {
29846 state.head.xflags = hold & 255;
29847 state.head.os = hold >> 8;
29848 }
29849 if (state.flags & 512) {
29850 hbuf[0] = hold & 255;
29851 hbuf[1] = hold >>> 8 & 255;
29852 state.check = crc32(
29853 state.check,
29854 hbuf,
29855 2,
29856 0
29857 );
29858 }
29859 hold = 0;
29860 bits = 0;
29861 state.mode = EXLEN;
29862 /* falls through */
29863 case EXLEN:
29864 if (state.flags & 1024) {
29865 while (bits < 16) {
29866 if (have === 0) {
29867 break inf_leave;
29868 }
29869 have--;
29870 hold += input[next++] << bits;
29871 bits += 8;
29872 }
29873 state.length = hold;
29874 if (state.head) {
29875 state.head.extra_len = hold;
29876 }
29877 if (state.flags & 512) {
29878 hbuf[0] = hold & 255;
29879 hbuf[1] = hold >>> 8 & 255;
29880 state.check = crc32(
29881 state.check,
29882 hbuf,
29883 2,
29884 0
29885 );
29886 }
29887 hold = 0;
29888 bits = 0;
29889 } else if (state.head) {
29890 state.head.extra = null;
29891 }
29892 state.mode = EXTRA;
29893 /* falls through */
29894 case EXTRA:
29895 if (state.flags & 1024) {
29896 copy = state.length;
29897 if (copy > have) {
29898 copy = have;
29899 }
29900 if (copy) {
29901 if (state.head) {
29902 len = state.head.extra_len - state.length;
29903 if (!state.head.extra) {
29904 state.head.extra = new Array(
29905 state.head.extra_len
29906 );
29907 }
29908 utils.arraySet(
29909 state.head.extra,
29910 input,
29911 next,
29912 // extra field is limited to 65536 bytes
29913 // - no need for additional size check
29914 copy,
29915 /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
29916 len
29917 );
29918 }
29919 if (state.flags & 512) {
29920 state.check = crc32(
29921 state.check,
29922 input,
29923 copy,
29924 next
29925 );
29926 }
29927 have -= copy;
29928 next += copy;
29929 state.length -= copy;
29930 }
29931 if (state.length) {
29932 break inf_leave;
29933 }
29934 }
29935 state.length = 0;
29936 state.mode = NAME;
29937 /* falls through */
29938 case NAME:
29939 if (state.flags & 2048) {
29940 if (have === 0) {
29941 break inf_leave;
29942 }
29943 copy = 0;
29944 do {
29945 len = input[next + copy++];
29946 if (state.head && len && state.length < 65536) {
29947 state.head.name += String.fromCharCode(len);
29948 }
29949 } while (len && copy < have);
29950 if (state.flags & 512) {
29951 state.check = crc32(
29952 state.check,
29953 input,
29954 copy,
29955 next
29956 );
29957 }
29958 have -= copy;
29959 next += copy;
29960 if (len) {
29961 break inf_leave;
29962 }
29963 } else if (state.head) {
29964 state.head.name = null;
29965 }
29966 state.length = 0;
29967 state.mode = COMMENT;
29968 /* falls through */
29969 case COMMENT:
29970 if (state.flags & 4096) {
29971 if (have === 0) {
29972 break inf_leave;
29973 }
29974 copy = 0;
29975 do {
29976 len = input[next + copy++];
29977 if (state.head && len && state.length < 65536) {
29978 state.head.comment += String.fromCharCode(len);
29979 }
29980 } while (len && copy < have);
29981 if (state.flags & 512) {
29982 state.check = crc32(
29983 state.check,
29984 input,
29985 copy,
29986 next
29987 );
29988 }
29989 have -= copy;
29990 next += copy;
29991 if (len) {
29992 break inf_leave;
29993 }
29994 } else if (state.head) {
29995 state.head.comment = null;
29996 }
29997 state.mode = HCRC;
29998 /* falls through */
29999 case HCRC:
30000 if (state.flags & 512) {
30001 while (bits < 16) {
30002 if (have === 0) {
30003 break inf_leave;
30004 }
30005 have--;
30006 hold += input[next++] << bits;
30007 bits += 8;
30008 }
30009 if (hold !== (state.check & 65535)) {
30010 strm.msg = "header crc mismatch";
30011 state.mode = BAD;
30012 break;
30013 }
30014 hold = 0;
30015 bits = 0;
30016 }
30017 if (state.head) {
30018 state.head.hcrc = state.flags >> 9 & 1;
30019 state.head.done = true;
30020 }
30021 strm.adler = state.check = 0;
30022 state.mode = TYPE;
30023 break;
30024 case DICTID:
30025 while (bits < 32) {
30026 if (have === 0) {
30027 break inf_leave;
30028 }
30029 have--;
30030 hold += input[next++] << bits;
30031 bits += 8;
30032 }
30033 strm.adler = state.check = zswap32(hold);
30034 hold = 0;
30035 bits = 0;
30036 state.mode = DICT;
30037 /* falls through */
30038 case DICT:
30039 if (state.havedict === 0) {
30040 strm.next_out = put;
30041 strm.avail_out = left;
30042 strm.next_in = next;
30043 strm.avail_in = have;
30044 state.hold = hold;
30045 state.bits = bits;
30046 return Z_NEED_DICT;
30047 }
30048 strm.adler = state.check = 1;
30049 state.mode = TYPE;
30050 /* falls through */
30051 case TYPE:
30052 if (flush2 === Z_BLOCK || flush2 === Z_TREES) {
30053 break inf_leave;
30054 }
30055 /* falls through */
30056 case TYPEDO:
30057 if (state.last) {
30058 hold >>>= bits & 7;
30059 bits -= bits & 7;
30060 state.mode = CHECK;
30061 break;
30062 }
30063 while (bits < 3) {
30064 if (have === 0) {
30065 break inf_leave;
30066 }
30067 have--;
30068 hold += input[next++] << bits;
30069 bits += 8;
30070 }
30071 state.last = hold & 1;
30072 hold >>>= 1;
30073 bits -= 1;
30074 switch (hold & 3) {
30075 case 0:
30076 state.mode = STORED;
30077 break;
30078 case 1:
30079 fixedtables(state);
30080 state.mode = LEN_;
30081 if (flush2 === Z_TREES) {
30082 hold >>>= 2;
30083 bits -= 2;
30084 break inf_leave;
30085 }
30086 break;
30087 case 2:
30088 state.mode = TABLE;
30089 break;
30090 case 3:
30091 strm.msg = "invalid block type";
30092 state.mode = BAD;
30093 }
30094 hold >>>= 2;
30095 bits -= 2;
30096 break;
30097 case STORED:
30098 hold >>>= bits & 7;
30099 bits -= bits & 7;
30100 while (bits < 32) {
30101 if (have === 0) {
30102 break inf_leave;
30103 }
30104 have--;
30105 hold += input[next++] << bits;
30106 bits += 8;
30107 }
30108 if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {
30109 strm.msg = "invalid stored block lengths";
30110 state.mode = BAD;
30111 break;
30112 }
30113 state.length = hold & 65535;
30114 hold = 0;
30115 bits = 0;
30116 state.mode = COPY_;
30117 if (flush2 === Z_TREES) {
30118 break inf_leave;
30119 }
30120 /* falls through */
30121 case COPY_:
30122 state.mode = COPY;
30123 /* falls through */
30124 case COPY:
30125 copy = state.length;
30126 if (copy) {
30127 if (copy > have) {
30128 copy = have;
30129 }
30130 if (copy > left) {
30131 copy = left;
30132 }
30133 if (copy === 0) {
30134 break inf_leave;
30135 }
30136 utils.arraySet(
30137 output,
30138 input,
30139 next,
30140 copy,
30141 put
30142 );
30143 have -= copy;
30144 next += copy;
30145 left -= copy;
30146 put += copy;
30147 state.length -= copy;
30148 break;
30149 }
30150 state.mode = TYPE;
30151 break;
30152 case TABLE:
30153 while (bits < 14) {
30154 if (have === 0) {
30155 break inf_leave;
30156 }
30157 have--;
30158 hold += input[next++] << bits;
30159 bits += 8;
30160 }
30161 state.nlen = (hold & 31) + 257;
30162 hold >>>= 5;
30163 bits -= 5;
30164 state.ndist = (hold & 31) + 1;
30165 hold >>>= 5;
30166 bits -= 5;
30167 state.ncode = (hold & 15) + 4;
30168 hold >>>= 4;
30169 bits -= 4;
30170 if (state.nlen > 286 || state.ndist > 30) {
30171 strm.msg = "too many length or distance symbols";
30172 state.mode = BAD;
30173 break;
30174 }
30175 state.have = 0;
30176 state.mode = LENLENS;
30177 /* falls through */
30178 case LENLENS:
30179 while (state.have < state.ncode) {
30180 while (bits < 3) {
30181 if (have === 0) {
30182 break inf_leave;
30183 }
30184 have--;
30185 hold += input[next++] << bits;
30186 bits += 8;
30187 }
30188 state.lens[order[state.have++]] = hold & 7;
30189 hold >>>= 3;
30190 bits -= 3;
30191 }
30192 while (state.have < 19) {
30193 state.lens[order[state.have++]] = 0;
30194 }
30195 state.lencode = state.lendyn;
30196 state.lenbits = 7;
30197 opts = { bits: state.lenbits };
30198 ret = inflate_table(
30199 CODES,
30200 state.lens,
30201 0,
30202 19,
30203 state.lencode,
30204 0,
30205 state.work,
30206 opts
30207 );
30208 state.lenbits = opts.bits;
30209 if (ret) {
30210 strm.msg = "invalid code lengths set";
30211 state.mode = BAD;
30212 break;
30213 }
30214 state.have = 0;
30215 state.mode = CODELENS;
30216 /* falls through */
30217 case CODELENS:
30218 while (state.have < state.nlen + state.ndist) {
30219 for (; ; ) {
30220 here = state.lencode[hold & (1 << state.lenbits) - 1];
30221 here_bits = here >>> 24;
30222 here_op = here >>> 16 & 255;
30223 here_val = here & 65535;
30224 if (here_bits <= bits) {
30225 break;
30226 }
30227 if (have === 0) {
30228 break inf_leave;
30229 }
30230 have--;
30231 hold += input[next++] << bits;
30232 bits += 8;
30233 }
30234 if (here_val < 16) {
30235 hold >>>= here_bits;
30236 bits -= here_bits;
30237 state.lens[state.have++] = here_val;
30238 } else {
30239 if (here_val === 16) {
30240 n3 = here_bits + 2;
30241 while (bits < n3) {
30242 if (have === 0) {
30243 break inf_leave;
30244 }
30245 have--;
30246 hold += input[next++] << bits;
30247 bits += 8;
30248 }
30249 hold >>>= here_bits;
30250 bits -= here_bits;
30251 if (state.have === 0) {
30252 strm.msg = "invalid bit length repeat";
30253 state.mode = BAD;
30254 break;
30255 }
30256 len = state.lens[state.have - 1];
30257 copy = 3 + (hold & 3);
30258 hold >>>= 2;
30259 bits -= 2;
30260 } else if (here_val === 17) {
30261 n3 = here_bits + 3;
30262 while (bits < n3) {
30263 if (have === 0) {
30264 break inf_leave;
30265 }
30266 have--;
30267 hold += input[next++] << bits;
30268 bits += 8;
30269 }
30270 hold >>>= here_bits;
30271 bits -= here_bits;
30272 len = 0;
30273 copy = 3 + (hold & 7);
30274 hold >>>= 3;
30275 bits -= 3;
30276 } else {
30277 n3 = here_bits + 7;
30278 while (bits < n3) {
30279 if (have === 0) {
30280 break inf_leave;
30281 }
30282 have--;
30283 hold += input[next++] << bits;
30284 bits += 8;
30285 }
30286 hold >>>= here_bits;
30287 bits -= here_bits;
30288 len = 0;
30289 copy = 11 + (hold & 127);
30290 hold >>>= 7;
30291 bits -= 7;
30292 }
30293 if (state.have + copy > state.nlen + state.ndist) {
30294 strm.msg = "invalid bit length repeat";
30295 state.mode = BAD;
30296 break;
30297 }
30298 while (copy--) {
30299 state.lens[state.have++] = len;
30300 }
30301 }
30302 }
30303 if (state.mode === BAD) {
30304 break;
30305 }
30306 if (state.lens[256] === 0) {
30307 strm.msg = "invalid code -- missing end-of-block";
30308 state.mode = BAD;
30309 break;
30310 }
30311 state.lenbits = 9;
30312 opts = { bits: state.lenbits };
30313 ret = inflate_table(
30314 LENS,
30315 state.lens,
30316 0,
30317 state.nlen,
30318 state.lencode,
30319 0,
30320 state.work,
30321 opts
30322 );
30323 state.lenbits = opts.bits;
30324 if (ret) {
30325 strm.msg = "invalid literal/lengths set";
30326 state.mode = BAD;
30327 break;
30328 }
30329 state.distbits = 6;
30330 state.distcode = state.distdyn;
30331 opts = { bits: state.distbits };
30332 ret = inflate_table(
30333 DISTS,
30334 state.lens,
30335 state.nlen,
30336 state.ndist,
30337 state.distcode,
30338 0,
30339 state.work,
30340 opts
30341 );
30342 state.distbits = opts.bits;
30343 if (ret) {
30344 strm.msg = "invalid distances set";
30345 state.mode = BAD;
30346 break;
30347 }
30348 state.mode = LEN_;
30349 if (flush2 === Z_TREES) {
30350 break inf_leave;
30351 }
30352 /* falls through */
30353 case LEN_:
30354 state.mode = LEN;
30355 /* falls through */
30356 case LEN:
30357 if (have >= 6 && left >= 258) {
30358 strm.next_out = put;
30359 strm.avail_out = left;
30360 strm.next_in = next;
30361 strm.avail_in = have;
30362 state.hold = hold;
30363 state.bits = bits;
30364 inflate_fast(strm, _out);
30365 put = strm.next_out;
30366 output = strm.output;
30367 left = strm.avail_out;
30368 next = strm.next_in;
30369 input = strm.input;
30370 have = strm.avail_in;
30371 hold = state.hold;
30372 bits = state.bits;
30373 if (state.mode === TYPE) {
30374 state.back = -1;
30375 }
30376 break;
30377 }
30378 state.back = 0;
30379 for (; ; ) {
30380 here = state.lencode[hold & (1 << state.lenbits) - 1];
30381 here_bits = here >>> 24;
30382 here_op = here >>> 16 & 255;
30383 here_val = here & 65535;
30384 if (here_bits <= bits) {
30385 break;
30386 }
30387 if (have === 0) {
30388 break inf_leave;
30389 }
30390 have--;
30391 hold += input[next++] << bits;
30392 bits += 8;
30393 }
30394 if (here_op && (here_op & 240) === 0) {
30395 last_bits = here_bits;
30396 last_op = here_op;
30397 last_val = here_val;
30398 for (; ; ) {
30399 here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
30400 here_bits = here >>> 24;
30401 here_op = here >>> 16 & 255;
30402 here_val = here & 65535;
30403 if (last_bits + here_bits <= bits) {
30404 break;
30405 }
30406 if (have === 0) {
30407 break inf_leave;
30408 }
30409 have--;
30410 hold += input[next++] << bits;
30411 bits += 8;
30412 }
30413 hold >>>= last_bits;
30414 bits -= last_bits;
30415 state.back += last_bits;
30416 }
30417 hold >>>= here_bits;
30418 bits -= here_bits;
30419 state.back += here_bits;
30420 state.length = here_val;
30421 if (here_op === 0) {
30422 state.mode = LIT;
30423 break;
30424 }
30425 if (here_op & 32) {
30426 state.back = -1;
30427 state.mode = TYPE;
30428 break;
30429 }
30430 if (here_op & 64) {
30431 strm.msg = "invalid literal/length code";
30432 state.mode = BAD;
30433 break;
30434 }
30435 state.extra = here_op & 15;
30436 state.mode = LENEXT;
30437 /* falls through */
30438 case LENEXT:
30439 if (state.extra) {
30440 n3 = state.extra;
30441 while (bits < n3) {
30442 if (have === 0) {
30443 break inf_leave;
30444 }
30445 have--;
30446 hold += input[next++] << bits;
30447 bits += 8;
30448 }
30449 state.length += hold & (1 << state.extra) - 1;
30450 hold >>>= state.extra;
30451 bits -= state.extra;
30452 state.back += state.extra;
30453 }
30454 state.was = state.length;
30455 state.mode = DIST;
30456 /* falls through */
30457 case DIST:
30458 for (; ; ) {
30459 here = state.distcode[hold & (1 << state.distbits) - 1];
30460 here_bits = here >>> 24;
30461 here_op = here >>> 16 & 255;
30462 here_val = here & 65535;
30463 if (here_bits <= bits) {
30464 break;
30465 }
30466 if (have === 0) {
30467 break inf_leave;
30468 }
30469 have--;
30470 hold += input[next++] << bits;
30471 bits += 8;
30472 }
30473 if ((here_op & 240) === 0) {
30474 last_bits = here_bits;
30475 last_op = here_op;
30476 last_val = here_val;
30477 for (; ; ) {
30478 here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
30479 here_bits = here >>> 24;
30480 here_op = here >>> 16 & 255;
30481 here_val = here & 65535;
30482 if (last_bits + here_bits <= bits) {
30483 break;
30484 }
30485 if (have === 0) {
30486 break inf_leave;
30487 }
30488 have--;
30489 hold += input[next++] << bits;
30490 bits += 8;
30491 }
30492 hold >>>= last_bits;
30493 bits -= last_bits;
30494 state.back += last_bits;
30495 }
30496 hold >>>= here_bits;
30497 bits -= here_bits;
30498 state.back += here_bits;
30499 if (here_op & 64) {
30500 strm.msg = "invalid distance code";
30501 state.mode = BAD;
30502 break;
30503 }
30504 state.offset = here_val;
30505 state.extra = here_op & 15;
30506 state.mode = DISTEXT;
30507 /* falls through */
30508 case DISTEXT:
30509 if (state.extra) {
30510 n3 = state.extra;
30511 while (bits < n3) {
30512 if (have === 0) {
30513 break inf_leave;
30514 }
30515 have--;
30516 hold += input[next++] << bits;
30517 bits += 8;
30518 }
30519 state.offset += hold & (1 << state.extra) - 1;
30520 hold >>>= state.extra;
30521 bits -= state.extra;
30522 state.back += state.extra;
30523 }
30524 if (state.offset > state.dmax) {
30525 strm.msg = "invalid distance too far back";
30526 state.mode = BAD;
30527 break;
30528 }
30529 state.mode = MATCH;
30530 /* falls through */
30531 case MATCH:
30532 if (left === 0) {
30533 break inf_leave;
30534 }
30535 copy = _out - left;
30536 if (state.offset > copy) {
30537 copy = state.offset - copy;
30538 if (copy > state.whave) {
30539 if (state.sane) {
30540 strm.msg = "invalid distance too far back";
30541 state.mode = BAD;
30542 break;
30543 }
30544 }
30545 if (copy > state.wnext) {
30546 copy -= state.wnext;
30547 from = state.wsize - copy;
30548 } else {
30549 from = state.wnext - copy;
30550 }
30551 if (copy > state.length) {
30552 copy = state.length;
30553 }
30554 from_source = state.window;
30555 } else {
30556 from_source = output;
30557 from = put - state.offset;
30558 copy = state.length;
30559 }
30560 if (copy > left) {
30561 copy = left;
30562 }
30563 left -= copy;
30564 state.length -= copy;
30565 do {
30566 output[put++] = from_source[from++];
30567 } while (--copy);
30568 if (state.length === 0) {
30569 state.mode = LEN;
30570 }
30571 break;
30572 case LIT:
30573 if (left === 0) {
30574 break inf_leave;
30575 }
30576 output[put++] = state.length;
30577 left--;
30578 state.mode = LEN;
30579 break;
30580 case CHECK:
30581 if (state.wrap) {
30582 while (bits < 32) {
30583 if (have === 0) {
30584 break inf_leave;
30585 }
30586 have--;
30587 hold |= input[next++] << bits;
30588 bits += 8;
30589 }
30590 _out -= left;
30591 strm.total_out += _out;
30592 state.total += _out;
30593 if (_out) {
30594 strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/
30595 state.flags ? crc32(
30596 state.check,
30597 output,
30598 _out,
30599 put - _out
30600 ) : adler32(
30601 state.check,
30602 output,
30603 _out,
30604 put - _out
30605 );
30606 }
30607 _out = left;
30608 if ((state.flags ? hold : zswap32(hold)) !== state.check) {
30609 strm.msg = "incorrect data check";
30610 state.mode = BAD;
30611 break;
30612 }
30613 hold = 0;
30614 bits = 0;
30615 }
30616 state.mode = LENGTH;
30617 /* falls through */
30618 case LENGTH:
30619 if (state.wrap && state.flags) {
30620 while (bits < 32) {
30621 if (have === 0) {
30622 break inf_leave;
30623 }
30624 have--;
30625 hold += input[next++] << bits;
30626 bits += 8;
30627 }
30628 if (hold !== (state.total & 4294967295)) {
30629 strm.msg = "incorrect length check";
30630 state.mode = BAD;
30631 break;
30632 }
30633 hold = 0;
30634 bits = 0;
30635 }
30636 state.mode = DONE;
30637 /* falls through */
30638 case DONE:
30639 ret = Z_STREAM_END;
30640 break inf_leave;
30641 case BAD:
30642 ret = Z_DATA_ERROR;
30643 break inf_leave;
30644 case MEM:
30645 return Z_MEM_ERROR;
30646 case SYNC:
30647 /* falls through */
30648 default:
30649 return Z_STREAM_ERROR;
30650 }
30651 }
30652 strm.next_out = put;
30653 strm.avail_out = left;
30654 strm.next_in = next;
30655 strm.avail_in = have;
30656 state.hold = hold;
30657 state.bits = bits;
30658 if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush2 !== Z_FINISH)) {
30659 if (updatewindow(
30660 strm,
30661 strm.output,
30662 strm.next_out,
30663 _out - strm.avail_out
30664 )) {
30665 state.mode = MEM;
30666 return Z_MEM_ERROR;
30667 }
30668 }
30669 _in -= strm.avail_in;
30670 _out -= strm.avail_out;
30671 strm.total_in += _in;
30672 strm.total_out += _out;
30673 state.total += _out;
30674 if (state.wrap && _out) {
30675 strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
30676 state.flags ? crc32(
30677 state.check,
30678 output,
30679 _out,
30680 strm.next_out - _out
30681 ) : adler32(
30682 state.check,
30683 output,
30684 _out,
30685 strm.next_out - _out
30686 );
30687 }
30688 strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
30689 if ((_in === 0 && _out === 0 || flush2 === Z_FINISH) && ret === Z_OK) {
30690 ret = Z_BUF_ERROR;
30691 }
30692 return ret;
30693 }
30694 function inflateEnd(strm) {
30695 if (!strm || !strm.state) {
30696 return Z_STREAM_ERROR;
30697 }
30698 var state = strm.state;
30699 if (state.window) {
30700 state.window = null;
30701 }
30702 strm.state = null;
30703 return Z_OK;
30704 }
30705 function inflateGetHeader(strm, head2) {
30706 var state;
30707 if (!strm || !strm.state) {
30708 return Z_STREAM_ERROR;
30709 }
30710 state = strm.state;
30711 if ((state.wrap & 2) === 0) {
30712 return Z_STREAM_ERROR;
30713 }
30714 state.head = head2;
30715 head2.done = false;
30716 return Z_OK;
30717 }
30718 function inflateSetDictionary(strm, dictionary) {
30719 var dictLength = dictionary.length;
30720 var state;
30721 var dictid;
30722 var ret;
30723 if (!strm || !strm.state) {
30724 return Z_STREAM_ERROR;
30725 }
30726 state = strm.state;
30727 if (state.wrap !== 0 && state.mode !== DICT) {
30728 return Z_STREAM_ERROR;
30729 }
30730 if (state.mode === DICT) {
30731 dictid = 1;
30732 dictid = adler32(
30733 dictid,
30734 dictionary,
30735 dictLength,
30736 0
30737 );
30738 if (dictid !== state.check) {
30739 return Z_DATA_ERROR;
30740 }
30741 }
30742 ret = updatewindow(
30743 strm,
30744 dictionary,
30745 dictLength,
30746 dictLength
30747 );
30748 if (ret) {
30749 state.mode = MEM;
30750 return Z_MEM_ERROR;
30751 }
30752 state.havedict = 1;
30753 return Z_OK;
30754 }
30755 exports2.inflateReset = inflateReset;
30756 exports2.inflateReset2 = inflateReset2;
30757 exports2.inflateResetKeep = inflateResetKeep;
30758 exports2.inflateInit = inflateInit;
30759 exports2.inflateInit2 = inflateInit2;
30760 exports2.inflate = inflate;
30761 exports2.inflateEnd = inflateEnd;
30762 exports2.inflateGetHeader = inflateGetHeader;
30763 exports2.inflateSetDictionary = inflateSetDictionary;
30764 exports2.inflateInfo = "pako inflate (from Nodeca project)";
30765 },
30766 {
30767 "../utils/common": 1,
30768 "./adler32": 3,
30769 "./crc32": 5,
30770 "./inffast": 7,
30771 "./inftrees": 9
30772 }
30773 ],
30774 9: [
30775 function(require2, module2, exports2) {
30776 "use strict";
30777 var utils = require2("../utils/common");
30778 var MAXBITS = 15;
30779 var ENOUGH_LENS = 852;
30780 var ENOUGH_DISTS = 592;
30781 var CODES = 0;
30782 var LENS = 1;
30783 var DISTS = 2;
30784 var lbase = [
30785 /* Length codes 257..285 base */
30786 3,
30787 4,
30788 5,
30789 6,
30790 7,
30791 8,
30792 9,
30793 10,
30794 11,
30795 13,
30796 15,
30797 17,
30798 19,
30799 23,
30800 27,
30801 31,
30802 35,
30803 43,
30804 51,
30805 59,
30806 67,
30807 83,
30808 99,
30809 115,
30810 131,
30811 163,
30812 195,
30813 227,
30814 258,
30815 0,
30816 0
30817 ];
30818 var lext = [
30819 /* Length codes 257..285 extra */
30820 16,
30821 16,
30822 16,
30823 16,
30824 16,
30825 16,
30826 16,
30827 16,
30828 17,
30829 17,
30830 17,
30831 17,
30832 18,
30833 18,
30834 18,
30835 18,
30836 19,
30837 19,
30838 19,
30839 19,
30840 20,
30841 20,
30842 20,
30843 20,
30844 21,
30845 21,
30846 21,
30847 21,
30848 16,
30849 72,
30850 78
30851 ];
30852 var dbase = [
30853 /* Distance codes 0..29 base */
30854 1,
30855 2,
30856 3,
30857 4,
30858 5,
30859 7,
30860 9,
30861 13,
30862 17,
30863 25,
30864 33,
30865 49,
30866 65,
30867 97,
30868 129,
30869 193,
30870 257,
30871 385,
30872 513,
30873 769,
30874 1025,
30875 1537,
30876 2049,
30877 3073,
30878 4097,
30879 6145,
30880 8193,
30881 12289,
30882 16385,
30883 24577,
30884 0,
30885 0
30886 ];
30887 var dext = [
30888 /* Distance codes 0..29 extra */
30889 16,
30890 16,
30891 16,
30892 16,
30893 17,
30894 17,
30895 18,
30896 18,
30897 19,
30898 19,
30899 20,
30900 20,
30901 21,
30902 21,
30903 22,
30904 22,
30905 23,
30906 23,
30907 24,
30908 24,
30909 25,
30910 25,
30911 26,
30912 26,
30913 27,
30914 27,
30915 28,
30916 28,
30917 29,
30918 29,
30919 64,
30920 64
30921 ];
30922 module2.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) {
30923 var bits = opts.bits;
30924 var len = 0;
30925 var sym = 0;
30926 var min2 = 0, max2 = 0;
30927 var root = 0;
30928 var curr = 0;
30929 var drop = 0;
30930 var left = 0;
30931 var used = 0;
30932 var huff = 0;
30933 var incr;
30934 var fill;
30935 var low;
30936 var mask;
30937 var next;
30938 var base = null;
30939 var base_index = 0;
30940 var end;
30941 var count = new utils.Buf16(MAXBITS + 1);
30942 var offs = new utils.Buf16(MAXBITS + 1);
30943 var extra = null;
30944 var extra_index = 0;
30945 var here_bits, here_op, here_val;
30946 for (len = 0; len <= MAXBITS; len++) {
30947 count[len] = 0;
30948 }
30949 for (sym = 0; sym < codes; sym++) {
30950 count[lens[lens_index + sym]]++;
30951 }
30952 root = bits;
30953 for (max2 = MAXBITS; max2 >= 1; max2--) {
30954 if (count[max2] !== 0) {
30955 break;
30956 }
30957 }
30958 if (root > max2) {
30959 root = max2;
30960 }
30961 if (max2 === 0) {
30962 table[table_index++] = 1 << 24 | 64 << 16 | 0;
30963 table[table_index++] = 1 << 24 | 64 << 16 | 0;
30964 opts.bits = 1;
30965 return 0;
30966 }
30967 for (min2 = 1; min2 < max2; min2++) {
30968 if (count[min2] !== 0) {
30969 break;
30970 }
30971 }
30972 if (root < min2) {
30973 root = min2;
30974 }
30975 left = 1;
30976 for (len = 1; len <= MAXBITS; len++) {
30977 left <<= 1;
30978 left -= count[len];
30979 if (left < 0) {
30980 return -1;
30981 }
30982 }
30983 if (left > 0 && (type === CODES || max2 !== 1)) {
30984 return -1;
30985 }
30986 offs[1] = 0;
30987 for (len = 1; len < MAXBITS; len++) {
30988 offs[len + 1] = offs[len] + count[len];
30989 }
30990 for (sym = 0; sym < codes; sym++) {
30991 if (lens[lens_index + sym] !== 0) {
30992 work[offs[lens[lens_index + sym]]++] = sym;
30993 }
30994 }
30995 if (type === CODES) {
30996 base = extra = work;
30997 end = 19;
30998 } else if (type === LENS) {
30999 base = lbase;
31000 base_index -= 257;
31001 extra = lext;
31002 extra_index -= 257;
31003 end = 256;
31004 } else {
31005 base = dbase;
31006 extra = dext;
31007 end = -1;
31008 }
31009 huff = 0;
31010 sym = 0;
31011 len = min2;
31012 next = table_index;
31013 curr = root;
31014 drop = 0;
31015 low = -1;
31016 used = 1 << root;
31017 mask = used - 1;
31018 if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
31019 return 1;
31020 }
31021 for (; ; ) {
31022 here_bits = len - drop;
31023 if (work[sym] < end) {
31024 here_op = 0;
31025 here_val = work[sym];
31026 } else if (work[sym] > end) {
31027 here_op = extra[extra_index + work[sym]];
31028 here_val = base[base_index + work[sym]];
31029 } else {
31030 here_op = 32 + 64;
31031 here_val = 0;
31032 }
31033 incr = 1 << len - drop;
31034 fill = 1 << curr;
31035 min2 = fill;
31036 do {
31037 fill -= incr;
31038 table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
31039 } while (fill !== 0);
31040 incr = 1 << len - 1;
31041 while (huff & incr) {
31042 incr >>= 1;
31043 }
31044 if (incr !== 0) {
31045 huff &= incr - 1;
31046 huff += incr;
31047 } else {
31048 huff = 0;
31049 }
31050 sym++;
31051 if (--count[len] === 0) {
31052 if (len === max2) {
31053 break;
31054 }
31055 len = lens[lens_index + work[sym]];
31056 }
31057 if (len > root && (huff & mask) !== low) {
31058 if (drop === 0) {
31059 drop = root;
31060 }
31061 next += min2;
31062 curr = len - drop;
31063 left = 1 << curr;
31064 while (curr + drop < max2) {
31065 left -= count[curr + drop];
31066 if (left <= 0) {
31067 break;
31068 }
31069 curr++;
31070 left <<= 1;
31071 }
31072 used += 1 << curr;
31073 if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
31074 return 1;
31075 }
31076 low = huff & mask;
31077 table[low] = root << 24 | curr << 16 | next - table_index | 0;
31078 }
31079 }
31080 if (huff !== 0) {
31081 table[next + huff] = len - drop << 24 | 64 << 16 | 0;
31082 }
31083 opts.bits = root;
31084 return 0;
31085 };
31086 },
31087 { "../utils/common": 1 }
31088 ],
31089 10: [
31090 function(require2, module2, exports2) {
31091 "use strict";
31092 module2.exports = {
31093 2: "need dictionary",
31094 1: "stream end",
31095 0: "",
31096 "-1": "file error",
31097 "-2": "stream error",
31098 "-3": "data error",
31099 "-4": "insufficient memory",
31100 "-5": "buffer error",
31101 "-6": "incompatible version"
31102 };
31103 },
31104 {}
31105 ],
31106 11: [
31107 function(require2, module2, exports2) {
31108 "use strict";
31109 function ZStream() {
31110 this.input = null;
31111 this.next_in = 0;
31112 this.avail_in = 0;
31113 this.total_in = 0;
31114 this.output = null;
31115 this.next_out = 0;
31116 this.avail_out = 0;
31117 this.total_out = 0;
31118 this.msg = "";
31119 this.state = null;
31120 this.data_type = 2;
31121 this.adler = 0;
31122 }
31123 module2.exports = ZStream;
31124 },
31125 {}
31126 ],
31127 "/lib/inflate.js": [
31128 function(require2, module2, exports2) {
31129 "use strict";
31130 var zlib_inflate = require2("./zlib/inflate");
31131 var utils = require2("./utils/common");
31132 var strings = require2("./utils/strings");
31133 var c6 = require2("./zlib/constants");
31134 var msg = require2("./zlib/messages");
31135 var ZStream = require2("./zlib/zstream");
31136 var GZheader = require2("./zlib/gzheader");
31137 var toString = Object.prototype.toString;
31138 function Inflate(options) {
31139 if (!(this instanceof Inflate))
31140 return new Inflate(options);
31141 this.options = utils.assign(
31142 {
31143 chunkSize: 16384,
31144 windowBits: 0,
31145 to: ""
31146 },
31147 options || {}
31148 );
31149 var opt = this.options;
31150 if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
31151 opt.windowBits = -opt.windowBits;
31152 if (opt.windowBits === 0) {
31153 opt.windowBits = -15;
31154 }
31155 }
31156 if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
31157 opt.windowBits += 32;
31158 }
31159 if (opt.windowBits > 15 && opt.windowBits < 48) {
31160 if ((opt.windowBits & 15) === 0) {
31161 opt.windowBits |= 15;
31162 }
31163 }
31164 this.err = 0;
31165 this.msg = "";
31166 this.ended = false;
31167 this.chunks = [];
31168 this.strm = new ZStream();
31169 this.strm.avail_out = 0;
31170 var status = zlib_inflate.inflateInit2(
31171 this.strm,
31172 opt.windowBits
31173 );
31174 if (status !== c6.Z_OK) {
31175 throw new Error(msg[status]);
31176 }
31177 this.header = new GZheader();
31178 zlib_inflate.inflateGetHeader(this.strm, this.header);
31179 if (opt.dictionary) {
31180 if (typeof opt.dictionary === "string") {
31181 opt.dictionary = strings.string2buf(
31182 opt.dictionary
31183 );
31184 } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {
31185 opt.dictionary = new Uint8Array(
31186 opt.dictionary
31187 );
31188 }
31189 if (opt.raw) {
31190 status = zlib_inflate.inflateSetDictionary(
31191 this.strm,
31192 opt.dictionary
31193 );
31194 if (status !== c6.Z_OK) {
31195 throw new Error(msg[status]);
31196 }
31197 }
31198 }
31199 }
31200 Inflate.prototype.push = function(data, mode) {
31201 var strm = this.strm;
31202 var chunkSize = this.options.chunkSize;
31203 var dictionary = this.options.dictionary;
31204 var status, _mode;
31205 var next_out_utf8, tail, utf8str;
31206 var allowBufError = false;
31207 if (this.ended) {
31208 return false;
31209 }
31210 _mode = mode === ~~mode ? mode : mode === true ? c6.Z_FINISH : c6.Z_NO_FLUSH;
31211 if (typeof data === "string") {
31212 strm.input = strings.binstring2buf(data);
31213 } else if (toString.call(data) === "[object ArrayBuffer]") {
31214 strm.input = new Uint8Array(data);
31215 } else {
31216 strm.input = data;
31217 }
31218 strm.next_in = 0;
31219 strm.avail_in = strm.input.length;
31220 do {
31221 if (strm.avail_out === 0) {
31222 strm.output = new utils.Buf8(chunkSize);
31223 strm.next_out = 0;
31224 strm.avail_out = chunkSize;
31225 }
31226 status = zlib_inflate.inflate(
31227 strm,
31228 c6.Z_NO_FLUSH
31229 );
31230 if (status === c6.Z_NEED_DICT && dictionary) {
31231 status = zlib_inflate.inflateSetDictionary(
31232 this.strm,
31233 dictionary
31234 );
31235 }
31236 if (status === c6.Z_BUF_ERROR && allowBufError === true) {
31237 status = c6.Z_OK;
31238 allowBufError = false;
31239 }
31240 if (status !== c6.Z_STREAM_END && status !== c6.Z_OK) {
31241 this.onEnd(status);
31242 this.ended = true;
31243 return false;
31244 }
31245 if (strm.next_out) {
31246 if (strm.avail_out === 0 || status === c6.Z_STREAM_END || strm.avail_in === 0 && (_mode === c6.Z_FINISH || _mode === c6.Z_SYNC_FLUSH)) {
31247 if (this.options.to === "string") {
31248 next_out_utf8 = strings.utf8border(
31249 strm.output,
31250 strm.next_out
31251 );
31252 tail = strm.next_out - next_out_utf8;
31253 utf8str = strings.buf2string(
31254 strm.output,
31255 next_out_utf8
31256 );
31257 strm.next_out = tail;
31258 strm.avail_out = chunkSize - tail;
31259 if (tail) {
31260 utils.arraySet(
31261 strm.output,
31262 strm.output,
31263 next_out_utf8,
31264 tail,
31265 0
31266 );
31267 }
31268 this.onData(utf8str);
31269 } else {
31270 this.onData(
31271 utils.shrinkBuf(
31272 strm.output,
31273 strm.next_out
31274 )
31275 );
31276 }
31277 }
31278 }
31279 if (strm.avail_in === 0 && strm.avail_out === 0) {
31280 allowBufError = true;
31281 }
31282 } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c6.Z_STREAM_END);
31283 if (status === c6.Z_STREAM_END) {
31284 _mode = c6.Z_FINISH;
31285 }
31286 if (_mode === c6.Z_FINISH) {
31287 status = zlib_inflate.inflateEnd(this.strm);
31288 this.onEnd(status);
31289 this.ended = true;
31290 return status === c6.Z_OK;
31291 }
31292 if (_mode === c6.Z_SYNC_FLUSH) {
31293 this.onEnd(c6.Z_OK);
31294 strm.avail_out = 0;
31295 return true;
31296 }
31297 return true;
31298 };
31299 Inflate.prototype.onData = function(chunk) {
31300 this.chunks.push(chunk);
31301 };
31302 Inflate.prototype.onEnd = function(status) {
31303 if (status === c6.Z_OK) {
31304 if (this.options.to === "string") {
31305 this.result = this.chunks.join("");
31306 } else {
31307 this.result = utils.flattenChunks(
31308 this.chunks
31309 );
31310 }
31311 }
31312 this.chunks = [];
31313 this.err = status;
31314 this.msg = this.strm.msg;
31315 };
31316 function inflate(input, options) {
31317 var inflator = new Inflate(options);
31318 inflator.push(input, true);
31319 if (inflator.err) {
31320 throw inflator.msg || msg[inflator.err];
31321 }
31322 return inflator.result;
31323 }
31324 function inflateRaw(input, options) {
31325 options = options || {};
31326 options.raw = true;
31327 return inflate(input, options);
31328 }
31329 exports2.Inflate = Inflate;
31330 exports2.inflate = inflate;
31331 exports2.inflateRaw = inflateRaw;
31332 exports2.ungzip = inflate;
31333 },
31334 {
31335 "./utils/common": 1,
31336 "./utils/strings": 2,
31337 "./zlib/constants": 4,
31338 "./zlib/gzheader": 6,
31339 "./zlib/inflate": 8,
31340 "./zlib/messages": 10,
31341 "./zlib/zstream": 11
31342 }
31343 ]
31344 },
31345 {},
31346 []
31347 )("/lib/inflate.js");
31348 })();
31349
31350 // packages/global-styles-ui/build-module/font-library/lib/lib-font.browser.mjs
31351 var fetchFunction = globalThis.fetch;
31352 var Event2 = class {
31353 constructor(type, detail = {}, msg) {
31354 this.type = type;
31355 this.detail = detail;
31356 this.msg = msg;
31357 Object.defineProperty(this, `__mayPropagate`, {
31358 enumerable: false,
31359 writable: true
31360 });
31361 this.__mayPropagate = true;
31362 }
31363 preventDefault() {
31364 }
31365 stopPropagation() {
31366 this.__mayPropagate = false;
31367 }
31368 valueOf() {
31369 return this;
31370 }
31371 toString() {
31372 return this.msg ? `[${this.type} event]: ${this.msg}` : `[${this.type} event]`;
31373 }
31374 };
31375 var EventManager = class {
31376 constructor() {
31377 this.listeners = {};
31378 }
31379 addEventListener(type, listener, useCapture) {
31380 let bin = this.listeners[type] || [];
31381 if (useCapture) bin.unshift(listener);
31382 else bin.push(listener);
31383 this.listeners[type] = bin;
31384 }
31385 removeEventListener(type, listener) {
31386 let bin = this.listeners[type] || [];
31387 let pos = bin.findIndex((e3) => e3 === listener);
31388 if (pos > -1) {
31389 bin.splice(pos, 1);
31390 this.listeners[type] = bin;
31391 }
31392 }
31393 dispatch(event) {
31394 let bin = this.listeners[event.type];
31395 if (bin) {
31396 for (let l3 = 0, e3 = bin.length; l3 < e3; l3++) {
31397 if (!event.__mayPropagate) break;
31398 bin[l3](event);
31399 }
31400 }
31401 }
31402 };
31403 var startDate = (/* @__PURE__ */ new Date(`1904-01-01T00:00:00+0000`)).getTime();
31404 function asText(data) {
31405 return Array.from(data).map((v3) => String.fromCharCode(v3)).join(``);
31406 }
31407 var Parser = class {
31408 constructor(dict, dataview, name2) {
31409 this.name = (name2 || dict.tag || ``).trim();
31410 this.length = dict.length;
31411 this.start = dict.offset;
31412 this.offset = 0;
31413 this.data = dataview;
31414 [
31415 `getInt8`,
31416 `getUint8`,
31417 `getInt16`,
31418 `getUint16`,
31419 `getInt32`,
31420 `getUint32`,
31421 `getBigInt64`,
31422 `getBigUint64`
31423 ].forEach((name3) => {
31424 let fn = name3.replace(/get(Big)?/, "").toLowerCase();
31425 let increment = parseInt(name3.replace(/[^\d]/g, "")) / 8;
31426 Object.defineProperty(this, fn, {
31427 get: () => this.getValue(name3, increment)
31428 });
31429 });
31430 }
31431 get currentPosition() {
31432 return this.start + this.offset;
31433 }
31434 set currentPosition(position) {
31435 this.start = position;
31436 this.offset = 0;
31437 }
31438 skip(n3 = 0, bits = 8) {
31439 this.offset += n3 * bits / 8;
31440 }
31441 getValue(type, increment) {
31442 let pos = this.start + this.offset;
31443 this.offset += increment;
31444 try {
31445 return this.data[type](pos);
31446 } catch (e3) {
31447 console.error(`parser`, type, increment, this);
31448 console.error(`parser`, this.start, this.offset);
31449 throw e3;
31450 }
31451 }
31452 flags(n3) {
31453 if (n3 === 8 || n3 === 16 || n3 === 32 || n3 === 64) {
31454 return this[`uint${n3}`].toString(2).padStart(n3, 0).split(``).map((v3) => v3 === "1");
31455 }
31456 console.error(
31457 `Error parsing flags: flag types can only be 1, 2, 4, or 8 bytes long`
31458 );
31459 console.trace();
31460 }
31461 get tag() {
31462 const t4 = this.uint32;
31463 return asText([
31464 t4 >> 24 & 255,
31465 t4 >> 16 & 255,
31466 t4 >> 8 & 255,
31467 t4 & 255
31468 ]);
31469 }
31470 get fixed() {
31471 let major = this.int16;
31472 let minor = Math.round(1e3 * this.uint16 / 65356);
31473 return major + minor / 1e3;
31474 }
31475 get legacyFixed() {
31476 let major = this.uint16;
31477 let minor = this.uint16.toString(16).padStart(4, 0);
31478 return parseFloat(`${major}.${minor}`);
31479 }
31480 get uint24() {
31481 return (this.uint8 << 16) + (this.uint8 << 8) + this.uint8;
31482 }
31483 get uint128() {
31484 let value = 0;
31485 for (let i3 = 0; i3 < 5; i3++) {
31486 let byte = this.uint8;
31487 value = value * 128 + (byte & 127);
31488 if (byte < 128) break;
31489 }
31490 return value;
31491 }
31492 get longdatetime() {
31493 return new Date(startDate + 1e3 * parseInt(this.int64.toString()));
31494 }
31495 get fword() {
31496 return this.int16;
31497 }
31498 get ufword() {
31499 return this.uint16;
31500 }
31501 get Offset16() {
31502 return this.uint16;
31503 }
31504 get Offset32() {
31505 return this.uint32;
31506 }
31507 get F2DOT14() {
31508 const bits = p.uint16;
31509 const integer = [0, 1, -2, -1][bits >> 14];
31510 const fraction = bits & 16383;
31511 return integer + fraction / 16384;
31512 }
31513 verifyLength() {
31514 if (this.offset != this.length) {
31515 console.error(
31516 `unexpected parsed table size (${this.offset}) for "${this.name}" (expected ${this.length})`
31517 );
31518 }
31519 }
31520 readBytes(n3 = 0, position = 0, bits = 8, signed = false) {
31521 n3 = n3 || this.length;
31522 if (n3 === 0) return [];
31523 if (position) this.currentPosition = position;
31524 const fn = `${signed ? `` : `u`}int${bits}`, slice2 = [];
31525 while (n3--) slice2.push(this[fn]);
31526 return slice2;
31527 }
31528 };
31529 var ParsedData = class {
31530 constructor(parser) {
31531 const pGetter = { enumerable: false, get: () => parser };
31532 Object.defineProperty(this, `parser`, pGetter);
31533 const start2 = parser.currentPosition;
31534 const startGetter = { enumerable: false, get: () => start2 };
31535 Object.defineProperty(this, `start`, startGetter);
31536 }
31537 load(struct) {
31538 Object.keys(struct).forEach((p22) => {
31539 let props = Object.getOwnPropertyDescriptor(struct, p22);
31540 if (props.get) {
31541 this[p22] = props.get.bind(this);
31542 } else if (props.value !== void 0) {
31543 this[p22] = props.value;
31544 }
31545 });
31546 if (this.parser.length) {
31547 this.parser.verifyLength();
31548 }
31549 }
31550 };
31551 var SimpleTable = class extends ParsedData {
31552 constructor(dict, dataview, name2) {
31553 const { parser, start: start2 } = super(
31554 new Parser(dict, dataview, name2)
31555 );
31556 const pGetter = { enumerable: false, get: () => parser };
31557 Object.defineProperty(this, `p`, pGetter);
31558 const startGetter = { enumerable: false, get: () => start2 };
31559 Object.defineProperty(this, `tableStart`, startGetter);
31560 }
31561 };
31562 function lazy$1(object, property, getter) {
31563 let val;
31564 Object.defineProperty(object, property, {
31565 get: () => {
31566 if (val) return val;
31567 val = getter();
31568 return val;
31569 },
31570 enumerable: true
31571 });
31572 }
31573 var SFNT = class extends SimpleTable {
31574 constructor(font2, dataview, createTable2) {
31575 const { p: p22 } = super({ offset: 0, length: 12 }, dataview, `sfnt`);
31576 this.version = p22.uint32;
31577 this.numTables = p22.uint16;
31578 this.searchRange = p22.uint16;
31579 this.entrySelector = p22.uint16;
31580 this.rangeShift = p22.uint16;
31581 p22.verifyLength();
31582 this.directory = [...new Array(this.numTables)].map(
31583 (_) => new TableRecord(p22)
31584 );
31585 this.tables = {};
31586 this.directory.forEach((entry) => {
31587 const getter = () => createTable2(
31588 this.tables,
31589 {
31590 tag: entry.tag,
31591 offset: entry.offset,
31592 length: entry.length
31593 },
31594 dataview
31595 );
31596 lazy$1(this.tables, entry.tag.trim(), getter);
31597 });
31598 }
31599 };
31600 var TableRecord = class {
31601 constructor(p22) {
31602 this.tag = p22.tag;
31603 this.checksum = p22.uint32;
31604 this.offset = p22.uint32;
31605 this.length = p22.uint32;
31606 }
31607 };
31608 var gzipDecode = inflate_default.inflate || void 0;
31609 var nativeGzipDecode = void 0;
31610 var WOFF$1 = class extends SimpleTable {
31611 constructor(font2, dataview, createTable2) {
31612 const { p: p22 } = super({ offset: 0, length: 44 }, dataview, `woff`);
31613 this.signature = p22.tag;
31614 this.flavor = p22.uint32;
31615 this.length = p22.uint32;
31616 this.numTables = p22.uint16;
31617 p22.uint16;
31618 this.totalSfntSize = p22.uint32;
31619 this.majorVersion = p22.uint16;
31620 this.minorVersion = p22.uint16;
31621 this.metaOffset = p22.uint32;
31622 this.metaLength = p22.uint32;
31623 this.metaOrigLength = p22.uint32;
31624 this.privOffset = p22.uint32;
31625 this.privLength = p22.uint32;
31626 p22.verifyLength();
31627 this.directory = [...new Array(this.numTables)].map(
31628 (_) => new WoffTableDirectoryEntry(p22)
31629 );
31630 buildWoffLazyLookups(this, dataview, createTable2);
31631 }
31632 };
31633 var WoffTableDirectoryEntry = class {
31634 constructor(p22) {
31635 this.tag = p22.tag;
31636 this.offset = p22.uint32;
31637 this.compLength = p22.uint32;
31638 this.origLength = p22.uint32;
31639 this.origChecksum = p22.uint32;
31640 }
31641 };
31642 function buildWoffLazyLookups(woff, dataview, createTable2) {
31643 woff.tables = {};
31644 woff.directory.forEach((entry) => {
31645 lazy$1(woff.tables, entry.tag.trim(), () => {
31646 let offset3 = 0;
31647 let view = dataview;
31648 if (entry.compLength !== entry.origLength) {
31649 const data = dataview.buffer.slice(
31650 entry.offset,
31651 entry.offset + entry.compLength
31652 );
31653 let unpacked;
31654 if (gzipDecode) {
31655 unpacked = gzipDecode(new Uint8Array(data));
31656 } else if (nativeGzipDecode) {
31657 unpacked = nativeGzipDecode(new Uint8Array(data));
31658 } else {
31659 const msg = `no brotli decoder available to decode WOFF2 font`;
31660 if (font.onerror) font.onerror(msg);
31661 throw new Error(msg);
31662 }
31663 view = new DataView(unpacked.buffer);
31664 } else {
31665 offset3 = entry.offset;
31666 }
31667 return createTable2(
31668 woff.tables,
31669 { tag: entry.tag, offset: offset3, length: entry.origLength },
31670 view
31671 );
31672 });
31673 });
31674 }
31675 var brotliDecode = unbrotli_default;
31676 var nativeBrotliDecode = void 0;
31677 var WOFF2$1 = class extends SimpleTable {
31678 constructor(font2, dataview, createTable2) {
31679 const { p: p22 } = super({ offset: 0, length: 48 }, dataview, `woff2`);
31680 this.signature = p22.tag;
31681 this.flavor = p22.uint32;
31682 this.length = p22.uint32;
31683 this.numTables = p22.uint16;
31684 p22.uint16;
31685 this.totalSfntSize = p22.uint32;
31686 this.totalCompressedSize = p22.uint32;
31687 this.majorVersion = p22.uint16;
31688 this.minorVersion = p22.uint16;
31689 this.metaOffset = p22.uint32;
31690 this.metaLength = p22.uint32;
31691 this.metaOrigLength = p22.uint32;
31692 this.privOffset = p22.uint32;
31693 this.privLength = p22.uint32;
31694 p22.verifyLength();
31695 this.directory = [...new Array(this.numTables)].map(
31696 (_) => new Woff2TableDirectoryEntry(p22)
31697 );
31698 let dictOffset = p22.currentPosition;
31699 this.directory[0].offset = 0;
31700 this.directory.forEach((e3, i3) => {
31701 let next = this.directory[i3 + 1];
31702 if (next) {
31703 next.offset = e3.offset + (e3.transformLength !== void 0 ? e3.transformLength : e3.origLength);
31704 }
31705 });
31706 let decoded;
31707 let buffer = dataview.buffer.slice(dictOffset);
31708 if (brotliDecode) {
31709 decoded = brotliDecode(new Uint8Array(buffer));
31710 } else if (nativeBrotliDecode) {
31711 decoded = new Uint8Array(nativeBrotliDecode(buffer));
31712 } else {
31713 const msg = `no brotli decoder available to decode WOFF2 font`;
31714 if (font2.onerror) font2.onerror(msg);
31715 throw new Error(msg);
31716 }
31717 buildWoff2LazyLookups(this, decoded, createTable2);
31718 }
31719 };
31720 var Woff2TableDirectoryEntry = class {
31721 constructor(p22) {
31722 this.flags = p22.uint8;
31723 const tagNumber = this.tagNumber = this.flags & 63;
31724 if (tagNumber === 63) {
31725 this.tag = p22.tag;
31726 } else {
31727 this.tag = getWOFF2Tag(tagNumber);
31728 }
31729 const transformVersion = this.transformVersion = (this.flags & 192) >> 6;
31730 let hasTransforms = transformVersion !== 0;
31731 if (this.tag === `glyf` || this.tag === `loca`) {
31732 hasTransforms = this.transformVersion !== 3;
31733 }
31734 this.origLength = p22.uint128;
31735 if (hasTransforms) {
31736 this.transformLength = p22.uint128;
31737 }
31738 }
31739 };
31740 function buildWoff2LazyLookups(woff2, decoded, createTable2) {
31741 woff2.tables = {};
31742 woff2.directory.forEach((entry) => {
31743 lazy$1(woff2.tables, entry.tag.trim(), () => {
31744 const start2 = entry.offset;
31745 const end = start2 + (entry.transformLength ? entry.transformLength : entry.origLength);
31746 const data = new DataView(decoded.slice(start2, end).buffer);
31747 try {
31748 return createTable2(
31749 woff2.tables,
31750 { tag: entry.tag, offset: 0, length: entry.origLength },
31751 data
31752 );
31753 } catch (e3) {
31754 console.error(e3);
31755 }
31756 });
31757 });
31758 }
31759 function getWOFF2Tag(flag) {
31760 return [
31761 `cmap`,
31762 `head`,
31763 `hhea`,
31764 `hmtx`,
31765 `maxp`,
31766 `name`,
31767 `OS/2`,
31768 `post`,
31769 `cvt `,
31770 `fpgm`,
31771 `glyf`,
31772 `loca`,
31773 `prep`,
31774 `CFF `,
31775 `VORG`,
31776 `EBDT`,
31777 `EBLC`,
31778 `gasp`,
31779 `hdmx`,
31780 `kern`,
31781 `LTSH`,
31782 `PCLT`,
31783 `VDMX`,
31784 `vhea`,
31785 `vmtx`,
31786 `BASE`,
31787 `GDEF`,
31788 `GPOS`,
31789 `GSUB`,
31790 `EBSC`,
31791 `JSTF`,
31792 `MATH`,
31793 `CBDT`,
31794 `CBLC`,
31795 `COLR`,
31796 `CPAL`,
31797 `SVG `,
31798 `sbix`,
31799 `acnt`,
31800 `avar`,
31801 `bdat`,
31802 `bloc`,
31803 `bsln`,
31804 `cvar`,
31805 `fdsc`,
31806 `feat`,
31807 `fmtx`,
31808 `fvar`,
31809 `gvar`,
31810 `hsty`,
31811 `just`,
31812 `lcar`,
31813 `mort`,
31814 `morx`,
31815 `opbd`,
31816 `prop`,
31817 `trak`,
31818 `Zapf`,
31819 `Silf`,
31820 `Glat`,
31821 `Gloc`,
31822 `Feat`,
31823 `Sill`
31824 ][flag & 63];
31825 }
31826 var tableClasses = {};
31827 var tableClassesLoaded = false;
31828 Promise.all([
31829 Promise.resolve().then(function() {
31830 return cmap$1;
31831 }),
31832 Promise.resolve().then(function() {
31833 return head$1;
31834 }),
31835 Promise.resolve().then(function() {
31836 return hhea$1;
31837 }),
31838 Promise.resolve().then(function() {
31839 return hmtx$1;
31840 }),
31841 Promise.resolve().then(function() {
31842 return maxp$1;
31843 }),
31844 Promise.resolve().then(function() {
31845 return name$1;
31846 }),
31847 Promise.resolve().then(function() {
31848 return OS2$1;
31849 }),
31850 Promise.resolve().then(function() {
31851 return post$1;
31852 }),
31853 Promise.resolve().then(function() {
31854 return BASE$1;
31855 }),
31856 Promise.resolve().then(function() {
31857 return GDEF$1;
31858 }),
31859 Promise.resolve().then(function() {
31860 return GSUB$1;
31861 }),
31862 Promise.resolve().then(function() {
31863 return GPOS$1;
31864 }),
31865 Promise.resolve().then(function() {
31866 return SVG$1;
31867 }),
31868 Promise.resolve().then(function() {
31869 return fvar$1;
31870 }),
31871 Promise.resolve().then(function() {
31872 return cvt$1;
31873 }),
31874 Promise.resolve().then(function() {
31875 return fpgm$1;
31876 }),
31877 Promise.resolve().then(function() {
31878 return gasp$1;
31879 }),
31880 Promise.resolve().then(function() {
31881 return glyf$1;
31882 }),
31883 Promise.resolve().then(function() {
31884 return loca$1;
31885 }),
31886 Promise.resolve().then(function() {
31887 return prep$1;
31888 }),
31889 Promise.resolve().then(function() {
31890 return CFF$1;
31891 }),
31892 Promise.resolve().then(function() {
31893 return CFF2$1;
31894 }),
31895 Promise.resolve().then(function() {
31896 return VORG$1;
31897 }),
31898 Promise.resolve().then(function() {
31899 return EBLC$1;
31900 }),
31901 Promise.resolve().then(function() {
31902 return EBDT$1;
31903 }),
31904 Promise.resolve().then(function() {
31905 return EBSC$1;
31906 }),
31907 Promise.resolve().then(function() {
31908 return CBLC$1;
31909 }),
31910 Promise.resolve().then(function() {
31911 return CBDT$1;
31912 }),
31913 Promise.resolve().then(function() {
31914 return sbix$1;
31915 }),
31916 Promise.resolve().then(function() {
31917 return COLR$1;
31918 }),
31919 Promise.resolve().then(function() {
31920 return CPAL$1;
31921 }),
31922 Promise.resolve().then(function() {
31923 return DSIG$1;
31924 }),
31925 Promise.resolve().then(function() {
31926 return hdmx$1;
31927 }),
31928 Promise.resolve().then(function() {
31929 return kern$1;
31930 }),
31931 Promise.resolve().then(function() {
31932 return LTSH$1;
31933 }),
31934 Promise.resolve().then(function() {
31935 return MERG$1;
31936 }),
31937 Promise.resolve().then(function() {
31938 return meta$1;
31939 }),
31940 Promise.resolve().then(function() {
31941 return PCLT$1;
31942 }),
31943 Promise.resolve().then(function() {
31944 return VDMX$1;
31945 }),
31946 Promise.resolve().then(function() {
31947 return vhea$1;
31948 }),
31949 Promise.resolve().then(function() {
31950 return vmtx$1;
31951 })
31952 ]).then((data) => {
31953 data.forEach((e3) => {
31954 let name2 = Object.keys(e3)[0];
31955 tableClasses[name2] = e3[name2];
31956 });
31957 tableClassesLoaded = true;
31958 });
31959 function createTable(tables, dict, dataview) {
31960 let name2 = dict.tag.replace(/[^\w\d]/g, ``);
31961 let Type = tableClasses[name2];
31962 if (Type) return new Type(dict, dataview, tables);
31963 console.warn(
31964 `lib-font has no definition for ${name2}. The table was skipped.`
31965 );
31966 return {};
31967 }
31968 function loadTableClasses() {
31969 let count = 0;
31970 function checkLoaded(resolve, reject) {
31971 if (!tableClassesLoaded) {
31972 if (count > 10) {
31973 return reject(new Error(`loading took too long`));
31974 }
31975 count++;
31976 return setTimeout(() => checkLoaded(resolve), 250);
31977 }
31978 resolve(createTable);
31979 }
31980 return new Promise((resolve, reject) => checkLoaded(resolve));
31981 }
31982 function getFontCSSFormat(path, errorOnStyle) {
31983 let pos = path.lastIndexOf(`.`);
31984 let ext = (path.substring(pos + 1) || ``).toLowerCase();
31985 let format6 = {
31986 ttf: `truetype`,
31987 otf: `opentype`,
31988 woff: `woff`,
31989 woff2: `woff2`
31990 }[ext];
31991 if (format6) return format6;
31992 let msg = {
31993 eot: `The .eot format is not supported: it died in January 12, 2016, when Microsoft retired all versions of IE that didn't already support WOFF.`,
31994 svg: `The .svg format is not supported: SVG fonts (not to be confused with OpenType with embedded SVG) were so bad we took the entire fonts chapter out of the SVG specification again.`,
31995 fon: `The .fon format is not supported: this is an ancient Windows bitmap font format.`,
31996 ttc: `Based on the current CSS specification, font collections are not (yet?) supported.`
31997 }[ext];
31998 if (!msg) msg = `${path} is not a known webfont format.`;
31999 if (errorOnStyle) {
32000 throw new Error(msg);
32001 } else {
32002 console.warn(`Could not load font: ${msg}`);
32003 }
32004 }
32005 async function setupFontFace(name2, url, options = {}) {
32006 if (!globalThis.document) return;
32007 let format6 = getFontCSSFormat(url, options.errorOnStyle);
32008 if (!format6) return;
32009 let style = document.createElement(`style`);
32010 style.className = `injected-by-Font-js`;
32011 let rules = [];
32012 if (options.styleRules) {
32013 rules = Object.entries(options.styleRules).map(
32014 ([key, value]) => `${key}: ${value};`
32015 );
32016 }
32017 style.textContent = `
32018@font-face {
32019 font-family: "${name2}";
32020 ${rules.join(
32021 `
32022 `
32023 )}
32024 src: url("${url}") format("${format6}");
32025}`;
32026 globalThis.document.head.appendChild(style);
32027 return style;
32028 }
32029 var TTF = [0, 1, 0, 0];
32030 var OTF = [79, 84, 84, 79];
32031 var WOFF = [119, 79, 70, 70];
32032 var WOFF2 = [119, 79, 70, 50];
32033 function match(ar1, ar2) {
32034 if (ar1.length !== ar2.length) return;
32035 for (let i3 = 0; i3 < ar1.length; i3++) {
32036 if (ar1[i3] !== ar2[i3]) return;
32037 }
32038 return true;
32039 }
32040 function validFontFormat(dataview) {
32041 const LEAD_BYTES = [
32042 dataview.getUint8(0),
32043 dataview.getUint8(1),
32044 dataview.getUint8(2),
32045 dataview.getUint8(3)
32046 ];
32047 if (match(LEAD_BYTES, TTF) || match(LEAD_BYTES, OTF)) return `SFNT`;
32048 if (match(LEAD_BYTES, WOFF)) return `WOFF`;
32049 if (match(LEAD_BYTES, WOFF2)) return `WOFF2`;
32050 }
32051 function checkFetchResponseStatus(response) {
32052 if (!response.ok) {
32053 throw new Error(
32054 `HTTP ${response.status} - ${response.statusText}`
32055 );
32056 }
32057 return response;
32058 }
32059 var Font = class extends EventManager {
32060 constructor(name2, options = {}) {
32061 super();
32062 this.name = name2;
32063 this.options = options;
32064 this.metrics = false;
32065 }
32066 get src() {
32067 return this.__src;
32068 }
32069 set src(src) {
32070 this.__src = src;
32071 (async () => {
32072 if (globalThis.document && !this.options.skipStyleSheet) {
32073 await setupFontFace(this.name, src, this.options);
32074 }
32075 this.loadFont(src);
32076 })();
32077 }
32078 async loadFont(url, filename) {
32079 fetch(url).then(
32080 (response) => checkFetchResponseStatus(response) && response.arrayBuffer()
32081 ).then(
32082 (buffer) => this.fromDataBuffer(buffer, filename || url)
32083 ).catch((err) => {
32084 const evt = new Event2(
32085 `error`,
32086 err,
32087 `Failed to load font at ${filename || url}`
32088 );
32089 this.dispatch(evt);
32090 if (this.onerror) this.onerror(evt);
32091 });
32092 }
32093 async fromDataBuffer(buffer, filenameOrUrL) {
32094 this.fontData = new DataView(buffer);
32095 let type = validFontFormat(this.fontData);
32096 if (!type) {
32097 throw new Error(
32098 `${filenameOrUrL} is either an unsupported font format, or not a font at all.`
32099 );
32100 }
32101 await this.parseBasicData(type);
32102 const evt = new Event2("load", { font: this });
32103 this.dispatch(evt);
32104 if (this.onload) this.onload(evt);
32105 }
32106 async parseBasicData(type) {
32107 return loadTableClasses().then((createTable2) => {
32108 if (type === `SFNT`) {
32109 this.opentype = new SFNT(this, this.fontData, createTable2);
32110 }
32111 if (type === `WOFF`) {
32112 this.opentype = new WOFF$1(this, this.fontData, createTable2);
32113 }
32114 if (type === `WOFF2`) {
32115 this.opentype = new WOFF2$1(this, this.fontData, createTable2);
32116 }
32117 return this.opentype;
32118 });
32119 }
32120 getGlyphId(char) {
32121 return this.opentype.tables.cmap.getGlyphId(char);
32122 }
32123 reverse(glyphid) {
32124 return this.opentype.tables.cmap.reverse(glyphid);
32125 }
32126 supports(char) {
32127 return this.getGlyphId(char) !== 0;
32128 }
32129 supportsVariation(variation) {
32130 return this.opentype.tables.cmap.supportsVariation(variation) !== false;
32131 }
32132 measureText(text, size3 = 16) {
32133 if (this.__unloaded)
32134 throw new Error(
32135 "Cannot measure text: font was unloaded. Please reload before calling measureText()"
32136 );
32137 let d3 = document.createElement("div");
32138 d3.textContent = text;
32139 d3.style.fontFamily = this.name;
32140 d3.style.fontSize = `${size3}px`;
32141 d3.style.color = `transparent`;
32142 d3.style.background = `transparent`;
32143 d3.style.top = `0`;
32144 d3.style.left = `0`;
32145 d3.style.position = `absolute`;
32146 document.body.appendChild(d3);
32147 let bbox = d3.getBoundingClientRect();
32148 document.body.removeChild(d3);
32149 const OS22 = this.opentype.tables["OS/2"];
32150 bbox.fontSize = size3;
32151 bbox.ascender = OS22.sTypoAscender;
32152 bbox.descender = OS22.sTypoDescender;
32153 return bbox;
32154 }
32155 unload() {
32156 if (this.styleElement.parentNode) {
32157 this.styleElement.parentNode.removeElement(this.styleElement);
32158 const evt = new Event2("unload", { font: this });
32159 this.dispatch(evt);
32160 if (this.onunload) this.onunload(evt);
32161 }
32162 this._unloaded = true;
32163 }
32164 load() {
32165 if (this.__unloaded) {
32166 delete this.__unloaded;
32167 document.head.appendChild(this.styleElement);
32168 const evt = new Event2("load", { font: this });
32169 this.dispatch(evt);
32170 if (this.onload) this.onload(evt);
32171 }
32172 }
32173 };
32174 globalThis.Font = Font;
32175 var Subtable = class extends ParsedData {
32176 constructor(p22, plaformID, encodingID) {
32177 super(p22);
32178 this.plaformID = plaformID;
32179 this.encodingID = encodingID;
32180 }
32181 };
32182 var Format0 = class extends Subtable {
32183 constructor(p22, platformID, encodingID) {
32184 super(p22, platformID, encodingID);
32185 this.format = 0;
32186 this.length = p22.uint16;
32187 this.language = p22.uint16;
32188 this.glyphIdArray = [...new Array(256)].map((_) => p22.uint8);
32189 }
32190 supports(charCode) {
32191 if (charCode.charCodeAt) {
32192 charCode = -1;
32193 console.warn(
32194 `supports(character) not implemented for cmap subtable format 0. only supports(id) is implemented.`
32195 );
32196 }
32197 return 0 <= charCode && charCode <= 255;
32198 }
32199 reverse(glyphID) {
32200 console.warn(`reverse not implemented for cmap subtable format 0`);
32201 return {};
32202 }
32203 getSupportedCharCodes() {
32204 return [{ start: 1, end: 256 }];
32205 }
32206 };
32207 var Format2 = class extends Subtable {
32208 constructor(p22, platformID, encodingID) {
32209 super(p22, platformID, encodingID);
32210 this.format = 2;
32211 this.length = p22.uint16;
32212 this.language = p22.uint16;
32213 this.subHeaderKeys = [...new Array(256)].map((_) => p22.uint16);
32214 const subHeaderCount = Math.max(...this.subHeaderKeys);
32215 const subHeaderOffset = p22.currentPosition;
32216 lazy$1(this, `subHeaders`, () => {
32217 p22.currentPosition = subHeaderOffset;
32218 return [...new Array(subHeaderCount)].map(
32219 (_) => new SubHeader(p22)
32220 );
32221 });
32222 const glyphIndexOffset = subHeaderOffset + subHeaderCount * 8;
32223 lazy$1(this, `glyphIndexArray`, () => {
32224 p22.currentPosition = glyphIndexOffset;
32225 return [...new Array(subHeaderCount)].map((_) => p22.uint16);
32226 });
32227 }
32228 supports(charCode) {
32229 if (charCode.charCodeAt) {
32230 charCode = -1;
32231 console.warn(
32232 `supports(character) not implemented for cmap subtable format 2. only supports(id) is implemented.`
32233 );
32234 }
32235 const low = charCode && 255;
32236 const high = charCode && 65280;
32237 const subHeaderKey = this.subHeaders[high];
32238 const subheader = this.subHeaders[subHeaderKey];
32239 const first = subheader.firstCode;
32240 const last = first + subheader.entryCount;
32241 return first <= low && low <= last;
32242 }
32243 reverse(glyphID) {
32244 console.warn(`reverse not implemented for cmap subtable format 2`);
32245 return {};
32246 }
32247 getSupportedCharCodes(preservePropNames = false) {
32248 if (preservePropNames) {
32249 return this.subHeaders.map((h3) => ({
32250 firstCode: h3.firstCode,
32251 lastCode: h3.lastCode
32252 }));
32253 }
32254 return this.subHeaders.map((h3) => ({
32255 start: h3.firstCode,
32256 end: h3.lastCode
32257 }));
32258 }
32259 };
32260 var SubHeader = class {
32261 constructor(p22) {
32262 this.firstCode = p22.uint16;
32263 this.entryCount = p22.uint16;
32264 this.lastCode = this.first + this.entryCount;
32265 this.idDelta = p22.int16;
32266 this.idRangeOffset = p22.uint16;
32267 }
32268 };
32269 var Format4 = class extends Subtable {
32270 constructor(p22, platformID, encodingID) {
32271 super(p22, platformID, encodingID);
32272 this.format = 4;
32273 this.length = p22.uint16;
32274 this.language = p22.uint16;
32275 this.segCountX2 = p22.uint16;
32276 this.segCount = this.segCountX2 / 2;
32277 this.searchRange = p22.uint16;
32278 this.entrySelector = p22.uint16;
32279 this.rangeShift = p22.uint16;
32280 const endCodePosition = p22.currentPosition;
32281 lazy$1(
32282 this,
32283 `endCode`,
32284 () => p22.readBytes(this.segCount, endCodePosition, 16)
32285 );
32286 const startCodePosition = endCodePosition + 2 + this.segCountX2;
32287 lazy$1(
32288 this,
32289 `startCode`,
32290 () => p22.readBytes(this.segCount, startCodePosition, 16)
32291 );
32292 const idDeltaPosition = startCodePosition + this.segCountX2;
32293 lazy$1(
32294 this,
32295 `idDelta`,
32296 () => p22.readBytes(this.segCount, idDeltaPosition, 16, true)
32297 );
32298 const idRangePosition = idDeltaPosition + this.segCountX2;
32299 lazy$1(
32300 this,
32301 `idRangeOffset`,
32302 () => p22.readBytes(this.segCount, idRangePosition, 16)
32303 );
32304 const glyphIdArrayPosition = idRangePosition + this.segCountX2;
32305 const glyphIdArrayLength = this.length - (glyphIdArrayPosition - this.tableStart);
32306 lazy$1(
32307 this,
32308 `glyphIdArray`,
32309 () => p22.readBytes(glyphIdArrayLength, glyphIdArrayPosition, 16)
32310 );
32311 lazy$1(
32312 this,
32313 `segments`,
32314 () => this.buildSegments(idRangePosition, glyphIdArrayPosition, p22)
32315 );
32316 }
32317 buildSegments(idRangePosition, glyphIdArrayPosition, p22) {
32318 const build = (_, i3) => {
32319 let startCode = this.startCode[i3], endCode = this.endCode[i3], idDelta = this.idDelta[i3], idRangeOffset = this.idRangeOffset[i3], idRangeOffsetPointer = idRangePosition + 2 * i3, glyphIDs = [];
32320 if (idRangeOffset === 0) {
32321 for (let i22 = startCode + idDelta, e3 = endCode + idDelta; i22 <= e3; i22++) {
32322 glyphIDs.push(i22);
32323 }
32324 } else {
32325 for (let i22 = 0, e3 = endCode - startCode; i22 <= e3; i22++) {
32326 p22.currentPosition = idRangeOffsetPointer + idRangeOffset + i22 * 2;
32327 glyphIDs.push(p22.uint16);
32328 }
32329 }
32330 return {
32331 startCode,
32332 endCode,
32333 idDelta,
32334 idRangeOffset,
32335 glyphIDs
32336 };
32337 };
32338 return [...new Array(this.segCount)].map(build);
32339 }
32340 reverse(glyphID) {
32341 let s3 = this.segments.find((v3) => v3.glyphIDs.includes(glyphID));
32342 if (!s3) return {};
32343 const code = s3.startCode + s3.glyphIDs.indexOf(glyphID);
32344 return { code, unicode: String.fromCodePoint(code) };
32345 }
32346 getGlyphId(charCode) {
32347 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
32348 if (55296 <= charCode && charCode <= 57343) return 0;
32349 if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535)
32350 return 0;
32351 let segment = this.segments.find(
32352 (s3) => s3.startCode <= charCode && charCode <= s3.endCode
32353 );
32354 if (!segment) return 0;
32355 return segment.glyphIDs[charCode - segment.startCode];
32356 }
32357 supports(charCode) {
32358 return this.getGlyphId(charCode) !== 0;
32359 }
32360 getSupportedCharCodes(preservePropNames = false) {
32361 if (preservePropNames) return this.segments;
32362 return this.segments.map((v3) => ({
32363 start: v3.startCode,
32364 end: v3.endCode
32365 }));
32366 }
32367 };
32368 var Format6 = class extends Subtable {
32369 constructor(p22, platformID, encodingID) {
32370 super(p22, platformID, encodingID);
32371 this.format = 6;
32372 this.length = p22.uint16;
32373 this.language = p22.uint16;
32374 this.firstCode = p22.uint16;
32375 this.entryCount = p22.uint16;
32376 this.lastCode = this.firstCode + this.entryCount - 1;
32377 const getter = () => [...new Array(this.entryCount)].map((_) => p22.uint16);
32378 lazy$1(this, `glyphIdArray`, getter);
32379 }
32380 supports(charCode) {
32381 if (charCode.charCodeAt) {
32382 charCode = -1;
32383 console.warn(
32384 `supports(character) not implemented for cmap subtable format 6. only supports(id) is implemented.`
32385 );
32386 }
32387 if (charCode < this.firstCode) return {};
32388 if (charCode > this.firstCode + this.entryCount) return {};
32389 const code = charCode - this.firstCode;
32390 return { code, unicode: String.fromCodePoint(code) };
32391 }
32392 reverse(glyphID) {
32393 let pos = this.glyphIdArray.indexOf(glyphID);
32394 if (pos > -1) return this.firstCode + pos;
32395 }
32396 getSupportedCharCodes(preservePropNames = false) {
32397 if (preservePropNames) {
32398 return [{ firstCode: this.firstCode, lastCode: this.lastCode }];
32399 }
32400 return [{ start: this.firstCode, end: this.lastCode }];
32401 }
32402 };
32403 var Format8 = class extends Subtable {
32404 constructor(p22, platformID, encodingID) {
32405 super(p22, platformID, encodingID);
32406 this.format = 8;
32407 p22.uint16;
32408 this.length = p22.uint32;
32409 this.language = p22.uint32;
32410 this.is32 = [...new Array(8192)].map((_) => p22.uint8);
32411 this.numGroups = p22.uint32;
32412 const getter = () => [...new Array(this.numGroups)].map(
32413 (_) => new SequentialMapGroup$1(p22)
32414 );
32415 lazy$1(this, `groups`, getter);
32416 }
32417 supports(charCode) {
32418 if (charCode.charCodeAt) {
32419 charCode = -1;
32420 console.warn(
32421 `supports(character) not implemented for cmap subtable format 8. only supports(id) is implemented.`
32422 );
32423 }
32424 return this.groups.findIndex(
32425 (s3) => s3.startcharCode <= charCode && charCode <= s3.endcharCode
32426 ) !== -1;
32427 }
32428 reverse(glyphID) {
32429 console.warn(`reverse not implemented for cmap subtable format 8`);
32430 return {};
32431 }
32432 getSupportedCharCodes(preservePropNames = false) {
32433 if (preservePropNames) return this.groups;
32434 return this.groups.map((v3) => ({
32435 start: v3.startcharCode,
32436 end: v3.endcharCode
32437 }));
32438 }
32439 };
32440 var SequentialMapGroup$1 = class {
32441 constructor(p22) {
32442 this.startcharCode = p22.uint32;
32443 this.endcharCode = p22.uint32;
32444 this.startGlyphID = p22.uint32;
32445 }
32446 };
32447 var Format10 = class extends Subtable {
32448 constructor(p22, platformID, encodingID) {
32449 super(p22, platformID, encodingID);
32450 this.format = 10;
32451 p22.uint16;
32452 this.length = p22.uint32;
32453 this.language = p22.uint32;
32454 this.startCharCode = p22.uint32;
32455 this.numChars = p22.uint32;
32456 this.endCharCode = this.startCharCode + this.numChars;
32457 const getter = () => [...new Array(this.numChars)].map((_) => p22.uint16);
32458 lazy$1(this, `glyphs`, getter);
32459 }
32460 supports(charCode) {
32461 if (charCode.charCodeAt) {
32462 charCode = -1;
32463 console.warn(
32464 `supports(character) not implemented for cmap subtable format 10. only supports(id) is implemented.`
32465 );
32466 }
32467 if (charCode < this.startCharCode) return false;
32468 if (charCode > this.startCharCode + this.numChars) return false;
32469 return charCode - this.startCharCode;
32470 }
32471 reverse(glyphID) {
32472 console.warn(`reverse not implemented for cmap subtable format 10`);
32473 return {};
32474 }
32475 getSupportedCharCodes(preservePropNames = false) {
32476 if (preservePropNames) {
32477 return [
32478 {
32479 startCharCode: this.startCharCode,
32480 endCharCode: this.endCharCode
32481 }
32482 ];
32483 }
32484 return [{ start: this.startCharCode, end: this.endCharCode }];
32485 }
32486 };
32487 var Format12 = class extends Subtable {
32488 constructor(p22, platformID, encodingID) {
32489 super(p22, platformID, encodingID);
32490 this.format = 12;
32491 p22.uint16;
32492 this.length = p22.uint32;
32493 this.language = p22.uint32;
32494 this.numGroups = p22.uint32;
32495 const getter = () => [...new Array(this.numGroups)].map(
32496 (_) => new SequentialMapGroup(p22)
32497 );
32498 lazy$1(this, `groups`, getter);
32499 }
32500 supports(charCode) {
32501 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
32502 if (55296 <= charCode && charCode <= 57343) return 0;
32503 if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535)
32504 return 0;
32505 return this.groups.findIndex(
32506 (s3) => s3.startCharCode <= charCode && charCode <= s3.endCharCode
32507 ) !== -1;
32508 }
32509 reverse(glyphID) {
32510 for (let group of this.groups) {
32511 let start2 = group.startGlyphID;
32512 if (start2 > glyphID) continue;
32513 if (start2 === glyphID) return group.startCharCode;
32514 let end = start2 + (group.endCharCode - group.startCharCode);
32515 if (end < glyphID) continue;
32516 const code = group.startCharCode + (glyphID - start2);
32517 return { code, unicode: String.fromCodePoint(code) };
32518 }
32519 return {};
32520 }
32521 getSupportedCharCodes(preservePropNames = false) {
32522 if (preservePropNames) return this.groups;
32523 return this.groups.map((v3) => ({
32524 start: v3.startCharCode,
32525 end: v3.endCharCode
32526 }));
32527 }
32528 };
32529 var SequentialMapGroup = class {
32530 constructor(p22) {
32531 this.startCharCode = p22.uint32;
32532 this.endCharCode = p22.uint32;
32533 this.startGlyphID = p22.uint32;
32534 }
32535 };
32536 var Format13 = class extends Subtable {
32537 constructor(p22, platformID, encodingID) {
32538 super(p22, platformID, encodingID);
32539 this.format = 13;
32540 p22.uint16;
32541 this.length = p22.uint32;
32542 this.language = p22.uint32;
32543 this.numGroups = p22.uint32;
32544 const getter = [...new Array(this.numGroups)].map(
32545 (_) => new ConstantMapGroup(p22)
32546 );
32547 lazy$1(this, `groups`, getter);
32548 }
32549 supports(charCode) {
32550 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
32551 return this.groups.findIndex(
32552 (s3) => s3.startCharCode <= charCode && charCode <= s3.endCharCode
32553 ) !== -1;
32554 }
32555 reverse(glyphID) {
32556 console.warn(`reverse not implemented for cmap subtable format 13`);
32557 return {};
32558 }
32559 getSupportedCharCodes(preservePropNames = false) {
32560 if (preservePropNames) return this.groups;
32561 return this.groups.map((v3) => ({
32562 start: v3.startCharCode,
32563 end: v3.endCharCode
32564 }));
32565 }
32566 };
32567 var ConstantMapGroup = class {
32568 constructor(p22) {
32569 this.startCharCode = p22.uint32;
32570 this.endCharCode = p22.uint32;
32571 this.glyphID = p22.uint32;
32572 }
32573 };
32574 var Format14 = class extends Subtable {
32575 constructor(p22, platformID, encodingID) {
32576 super(p22, platformID, encodingID);
32577 this.subTableStart = p22.currentPosition;
32578 this.format = 14;
32579 this.length = p22.uint32;
32580 this.numVarSelectorRecords = p22.uint32;
32581 lazy$1(
32582 this,
32583 `varSelectors`,
32584 () => [...new Array(this.numVarSelectorRecords)].map(
32585 (_) => new VariationSelector(p22)
32586 )
32587 );
32588 }
32589 supports() {
32590 console.warn(`supports not implemented for cmap subtable format 14`);
32591 return 0;
32592 }
32593 getSupportedCharCodes() {
32594 console.warn(
32595 `getSupportedCharCodes not implemented for cmap subtable format 14`
32596 );
32597 return [];
32598 }
32599 reverse(glyphID) {
32600 console.warn(`reverse not implemented for cmap subtable format 14`);
32601 return {};
32602 }
32603 supportsVariation(variation) {
32604 let v3 = this.varSelector.find(
32605 (uvs) => uvs.varSelector === variation
32606 );
32607 return v3 ? v3 : false;
32608 }
32609 getSupportedVariations() {
32610 return this.varSelectors.map((v3) => v3.varSelector);
32611 }
32612 };
32613 var VariationSelector = class {
32614 constructor(p22) {
32615 this.varSelector = p22.uint24;
32616 this.defaultUVSOffset = p22.Offset32;
32617 this.nonDefaultUVSOffset = p22.Offset32;
32618 }
32619 };
32620 function createSubTable(parser, platformID, encodingID) {
32621 const format6 = parser.uint16;
32622 if (format6 === 0) return new Format0(parser, platformID, encodingID);
32623 if (format6 === 2) return new Format2(parser, platformID, encodingID);
32624 if (format6 === 4) return new Format4(parser, platformID, encodingID);
32625 if (format6 === 6) return new Format6(parser, platformID, encodingID);
32626 if (format6 === 8) return new Format8(parser, platformID, encodingID);
32627 if (format6 === 10) return new Format10(parser, platformID, encodingID);
32628 if (format6 === 12) return new Format12(parser, platformID, encodingID);
32629 if (format6 === 13) return new Format13(parser, platformID, encodingID);
32630 if (format6 === 14) return new Format14(parser, platformID, encodingID);
32631 return {};
32632 }
32633 var cmap = class extends SimpleTable {
32634 constructor(dict, dataview) {
32635 const { p: p22 } = super(dict, dataview);
32636 this.version = p22.uint16;
32637 this.numTables = p22.uint16;
32638 this.encodingRecords = [...new Array(this.numTables)].map(
32639 (_) => new EncodingRecord(p22, this.tableStart)
32640 );
32641 }
32642 getSubTable(tableID) {
32643 return this.encodingRecords[tableID].table;
32644 }
32645 getSupportedEncodings() {
32646 return this.encodingRecords.map((r4) => ({
32647 platformID: r4.platformID,
32648 encodingId: r4.encodingID
32649 }));
32650 }
32651 getSupportedCharCodes(platformID, encodingID) {
32652 const recordID = this.encodingRecords.findIndex(
32653 (r4) => r4.platformID === platformID && r4.encodingID === encodingID
32654 );
32655 if (recordID === -1) return false;
32656 const subtable = this.getSubTable(recordID);
32657 return subtable.getSupportedCharCodes();
32658 }
32659 reverse(glyphid) {
32660 for (let i3 = 0; i3 < this.numTables; i3++) {
32661 let code = this.getSubTable(i3).reverse(glyphid);
32662 if (code) return code;
32663 }
32664 }
32665 getGlyphId(char) {
32666 let last = 0;
32667 this.encodingRecords.some((_, tableID) => {
32668 let t4 = this.getSubTable(tableID);
32669 if (!t4.getGlyphId) return false;
32670 last = t4.getGlyphId(char);
32671 return last !== 0;
32672 });
32673 return last;
32674 }
32675 supports(char) {
32676 return this.encodingRecords.some((_, tableID) => {
32677 const t4 = this.getSubTable(tableID);
32678 return t4.supports && t4.supports(char) !== false;
32679 });
32680 }
32681 supportsVariation(variation) {
32682 return this.encodingRecords.some((_, tableID) => {
32683 const t4 = this.getSubTable(tableID);
32684 return t4.supportsVariation && t4.supportsVariation(variation) !== false;
32685 });
32686 }
32687 };
32688 var EncodingRecord = class {
32689 constructor(p22, tableStart) {
32690 const platformID = this.platformID = p22.uint16;
32691 const encodingID = this.encodingID = p22.uint16;
32692 const offset3 = this.offset = p22.Offset32;
32693 lazy$1(this, `table`, () => {
32694 p22.currentPosition = tableStart + offset3;
32695 return createSubTable(p22, platformID, encodingID);
32696 });
32697 }
32698 };
32699 var cmap$1 = Object.freeze({ __proto__: null, cmap });
32700 var head = class extends SimpleTable {
32701 constructor(dict, dataview) {
32702 const { p: p22 } = super(dict, dataview);
32703 this.load({
32704 majorVersion: p22.uint16,
32705 minorVersion: p22.uint16,
32706 fontRevision: p22.fixed,
32707 checkSumAdjustment: p22.uint32,
32708 magicNumber: p22.uint32,
32709 flags: p22.flags(16),
32710 unitsPerEm: p22.uint16,
32711 created: p22.longdatetime,
32712 modified: p22.longdatetime,
32713 xMin: p22.int16,
32714 yMin: p22.int16,
32715 xMax: p22.int16,
32716 yMax: p22.int16,
32717 macStyle: p22.flags(16),
32718 lowestRecPPEM: p22.uint16,
32719 fontDirectionHint: p22.uint16,
32720 indexToLocFormat: p22.uint16,
32721 glyphDataFormat: p22.uint16
32722 });
32723 }
32724 };
32725 var head$1 = Object.freeze({ __proto__: null, head });
32726 var hhea = class extends SimpleTable {
32727 constructor(dict, dataview) {
32728 const { p: p22 } = super(dict, dataview);
32729 this.majorVersion = p22.uint16;
32730 this.minorVersion = p22.uint16;
32731 this.ascender = p22.fword;
32732 this.descender = p22.fword;
32733 this.lineGap = p22.fword;
32734 this.advanceWidthMax = p22.ufword;
32735 this.minLeftSideBearing = p22.fword;
32736 this.minRightSideBearing = p22.fword;
32737 this.xMaxExtent = p22.fword;
32738 this.caretSlopeRise = p22.int16;
32739 this.caretSlopeRun = p22.int16;
32740 this.caretOffset = p22.int16;
32741 p22.int16;
32742 p22.int16;
32743 p22.int16;
32744 p22.int16;
32745 this.metricDataFormat = p22.int16;
32746 this.numberOfHMetrics = p22.uint16;
32747 p22.verifyLength();
32748 }
32749 };
32750 var hhea$1 = Object.freeze({ __proto__: null, hhea });
32751 var hmtx = class extends SimpleTable {
32752 constructor(dict, dataview, tables) {
32753 const { p: p22 } = super(dict, dataview);
32754 const numberOfHMetrics = tables.hhea.numberOfHMetrics;
32755 const numGlyphs = tables.maxp.numGlyphs;
32756 const metricsStart = p22.currentPosition;
32757 lazy$1(this, `hMetrics`, () => {
32758 p22.currentPosition = metricsStart;
32759 return [...new Array(numberOfHMetrics)].map(
32760 (_) => new LongHorMetric(p22.uint16, p22.int16)
32761 );
32762 });
32763 if (numberOfHMetrics < numGlyphs) {
32764 const lsbStart = metricsStart + numberOfHMetrics * 4;
32765 lazy$1(this, `leftSideBearings`, () => {
32766 p22.currentPosition = lsbStart;
32767 return [...new Array(numGlyphs - numberOfHMetrics)].map(
32768 (_) => p22.int16
32769 );
32770 });
32771 }
32772 }
32773 };
32774 var LongHorMetric = class {
32775 constructor(w3, b3) {
32776 this.advanceWidth = w3;
32777 this.lsb = b3;
32778 }
32779 };
32780 var hmtx$1 = Object.freeze({ __proto__: null, hmtx });
32781 var maxp = class extends SimpleTable {
32782 constructor(dict, dataview) {
32783 const { p: p22 } = super(dict, dataview);
32784 this.version = p22.legacyFixed;
32785 this.numGlyphs = p22.uint16;
32786 if (this.version === 1) {
32787 this.maxPoints = p22.uint16;
32788 this.maxContours = p22.uint16;
32789 this.maxCompositePoints = p22.uint16;
32790 this.maxCompositeContours = p22.uint16;
32791 this.maxZones = p22.uint16;
32792 this.maxTwilightPoints = p22.uint16;
32793 this.maxStorage = p22.uint16;
32794 this.maxFunctionDefs = p22.uint16;
32795 this.maxInstructionDefs = p22.uint16;
32796 this.maxStackElements = p22.uint16;
32797 this.maxSizeOfInstructions = p22.uint16;
32798 this.maxComponentElements = p22.uint16;
32799 this.maxComponentDepth = p22.uint16;
32800 }
32801 p22.verifyLength();
32802 }
32803 };
32804 var maxp$1 = Object.freeze({ __proto__: null, maxp });
32805 var name = class extends SimpleTable {
32806 constructor(dict, dataview) {
32807 const { p: p22 } = super(dict, dataview);
32808 this.format = p22.uint16;
32809 this.count = p22.uint16;
32810 this.stringOffset = p22.Offset16;
32811 this.nameRecords = [...new Array(this.count)].map(
32812 (_) => new NameRecord(p22, this)
32813 );
32814 if (this.format === 1) {
32815 this.langTagCount = p22.uint16;
32816 this.langTagRecords = [...new Array(this.langTagCount)].map(
32817 (_) => new LangTagRecord(p22.uint16, p22.Offset16)
32818 );
32819 }
32820 this.stringStart = this.tableStart + this.stringOffset;
32821 }
32822 get(nameID) {
32823 let record = this.nameRecords.find(
32824 (record2) => record2.nameID === nameID
32825 );
32826 if (record) return record.string;
32827 }
32828 };
32829 var LangTagRecord = class {
32830 constructor(length, offset3) {
32831 this.length = length;
32832 this.offset = offset3;
32833 }
32834 };
32835 var NameRecord = class {
32836 constructor(p22, nameTable) {
32837 this.platformID = p22.uint16;
32838 this.encodingID = p22.uint16;
32839 this.languageID = p22.uint16;
32840 this.nameID = p22.uint16;
32841 this.length = p22.uint16;
32842 this.offset = p22.Offset16;
32843 lazy$1(this, `string`, () => {
32844 p22.currentPosition = nameTable.stringStart + this.offset;
32845 return decodeString(p22, this);
32846 });
32847 }
32848 };
32849 function decodeString(p22, record) {
32850 const { platformID, length } = record;
32851 if (length === 0) return ``;
32852 if (platformID === 0 || platformID === 3) {
32853 const str2 = [];
32854 for (let i3 = 0, e3 = length / 2; i3 < e3; i3++)
32855 str2[i3] = String.fromCharCode(p22.uint16);
32856 return str2.join(``);
32857 }
32858 const bytes = p22.readBytes(length);
32859 const str = [];
32860 bytes.forEach(function(b3, i3) {
32861 str[i3] = String.fromCharCode(b3);
32862 });
32863 return str.join(``);
32864 }
32865 var name$1 = Object.freeze({ __proto__: null, name });
32866 var OS2 = class extends SimpleTable {
32867 constructor(dict, dataview) {
32868 const { p: p22 } = super(dict, dataview);
32869 this.version = p22.uint16;
32870 this.xAvgCharWidth = p22.int16;
32871 this.usWeightClass = p22.uint16;
32872 this.usWidthClass = p22.uint16;
32873 this.fsType = p22.uint16;
32874 this.ySubscriptXSize = p22.int16;
32875 this.ySubscriptYSize = p22.int16;
32876 this.ySubscriptXOffset = p22.int16;
32877 this.ySubscriptYOffset = p22.int16;
32878 this.ySuperscriptXSize = p22.int16;
32879 this.ySuperscriptYSize = p22.int16;
32880 this.ySuperscriptXOffset = p22.int16;
32881 this.ySuperscriptYOffset = p22.int16;
32882 this.yStrikeoutSize = p22.int16;
32883 this.yStrikeoutPosition = p22.int16;
32884 this.sFamilyClass = p22.int16;
32885 this.panose = [...new Array(10)].map((_) => p22.uint8);
32886 this.ulUnicodeRange1 = p22.flags(32);
32887 this.ulUnicodeRange2 = p22.flags(32);
32888 this.ulUnicodeRange3 = p22.flags(32);
32889 this.ulUnicodeRange4 = p22.flags(32);
32890 this.achVendID = p22.tag;
32891 this.fsSelection = p22.uint16;
32892 this.usFirstCharIndex = p22.uint16;
32893 this.usLastCharIndex = p22.uint16;
32894 this.sTypoAscender = p22.int16;
32895 this.sTypoDescender = p22.int16;
32896 this.sTypoLineGap = p22.int16;
32897 this.usWinAscent = p22.uint16;
32898 this.usWinDescent = p22.uint16;
32899 if (this.version === 0) return p22.verifyLength();
32900 this.ulCodePageRange1 = p22.flags(32);
32901 this.ulCodePageRange2 = p22.flags(32);
32902 if (this.version === 1) return p22.verifyLength();
32903 this.sxHeight = p22.int16;
32904 this.sCapHeight = p22.int16;
32905 this.usDefaultChar = p22.uint16;
32906 this.usBreakChar = p22.uint16;
32907 this.usMaxContext = p22.uint16;
32908 if (this.version <= 4) return p22.verifyLength();
32909 this.usLowerOpticalPointSize = p22.uint16;
32910 this.usUpperOpticalPointSize = p22.uint16;
32911 if (this.version === 5) return p22.verifyLength();
32912 }
32913 };
32914 var OS2$1 = Object.freeze({ __proto__: null, OS2 });
32915 var post = class extends SimpleTable {
32916 constructor(dict, dataview) {
32917 const { p: p22 } = super(dict, dataview);
32918 this.version = p22.legacyFixed;
32919 this.italicAngle = p22.fixed;
32920 this.underlinePosition = p22.fword;
32921 this.underlineThickness = p22.fword;
32922 this.isFixedPitch = p22.uint32;
32923 this.minMemType42 = p22.uint32;
32924 this.maxMemType42 = p22.uint32;
32925 this.minMemType1 = p22.uint32;
32926 this.maxMemType1 = p22.uint32;
32927 if (this.version === 1 || this.version === 3) return p22.verifyLength();
32928 this.numGlyphs = p22.uint16;
32929 if (this.version === 2) {
32930 this.glyphNameIndex = [...new Array(this.numGlyphs)].map(
32931 (_) => p22.uint16
32932 );
32933 this.namesOffset = p22.currentPosition;
32934 this.glyphNameOffsets = [1];
32935 for (let i3 = 0; i3 < this.numGlyphs; i3++) {
32936 let index2 = this.glyphNameIndex[i3];
32937 if (index2 < macStrings.length) {
32938 this.glyphNameOffsets.push(this.glyphNameOffsets[i3]);
32939 continue;
32940 }
32941 let bytelength = p22.int8;
32942 p22.skip(bytelength);
32943 this.glyphNameOffsets.push(
32944 this.glyphNameOffsets[i3] + bytelength + 1
32945 );
32946 }
32947 }
32948 if (this.version === 2.5) {
32949 this.offset = [...new Array(this.numGlyphs)].map(
32950 (_) => p22.int8
32951 );
32952 }
32953 }
32954 getGlyphName(glyphid) {
32955 if (this.version !== 2) {
32956 console.warn(
32957 `post table version ${this.version} does not support glyph name lookups`
32958 );
32959 return ``;
32960 }
32961 let index2 = this.glyphNameIndex[glyphid];
32962 if (index2 < 258) return macStrings[index2];
32963 let offset3 = this.glyphNameOffsets[glyphid];
32964 let next = this.glyphNameOffsets[glyphid + 1];
32965 let len = next - offset3 - 1;
32966 if (len === 0) return `.notdef.`;
32967 this.parser.currentPosition = this.namesOffset + offset3;
32968 const data = this.parser.readBytes(
32969 len,
32970 this.namesOffset + offset3,
32971 8,
32972 true
32973 );
32974 return data.map((b3) => String.fromCharCode(b3)).join(``);
32975 }
32976 };
32977 var macStrings = [
32978 `.notdef`,
32979 `.null`,
32980 `nonmarkingreturn`,
32981 `space`,
32982 `exclam`,
32983 `quotedbl`,
32984 `numbersign`,
32985 `dollar`,
32986 `percent`,
32987 `ampersand`,
32988 `quotesingle`,
32989 `parenleft`,
32990 `parenright`,
32991 `asterisk`,
32992 `plus`,
32993 `comma`,
32994 `hyphen`,
32995 `period`,
32996 `slash`,
32997 `zero`,
32998 `one`,
32999 `two`,
33000 `three`,
33001 `four`,
33002 `five`,
33003 `six`,
33004 `seven`,
33005 `eight`,
33006 `nine`,
33007 `colon`,
33008 `semicolon`,
33009 `less`,
33010 `equal`,
33011 `greater`,
33012 `question`,
33013 `at`,
33014 `A`,
33015 `B`,
33016 `C`,
33017 `D`,
33018 `E`,
33019 `F`,
33020 `G`,
33021 `H`,
33022 `I`,
33023 `J`,
33024 `K`,
33025 `L`,
33026 `M`,
33027 `N`,
33028 `O`,
33029 `P`,
33030 `Q`,
33031 `R`,
33032 `S`,
33033 `T`,
33034 `U`,
33035 `V`,
33036 `W`,
33037 `X`,
33038 `Y`,
33039 `Z`,
33040 `bracketleft`,
33041 `backslash`,
33042 `bracketright`,
33043 `asciicircum`,
33044 `underscore`,
33045 `grave`,
33046 `a`,
33047 `b`,
33048 `c`,
33049 `d`,
33050 `e`,
33051 `f`,
33052 `g`,
33053 `h`,
33054 `i`,
33055 `j`,
33056 `k`,
33057 `l`,
33058 `m`,
33059 `n`,
33060 `o`,
33061 `p`,
33062 `q`,
33063 `r`,
33064 `s`,
33065 `t`,
33066 `u`,
33067 `v`,
33068 `w`,
33069 `x`,
33070 `y`,
33071 `z`,
33072 `braceleft`,
33073 `bar`,
33074 `braceright`,
33075 `asciitilde`,
33076 `Adieresis`,
33077 `Aring`,
33078 `Ccedilla`,
33079 `Eacute`,
33080 `Ntilde`,
33081 `Odieresis`,
33082 `Udieresis`,
33083 `aacute`,
33084 `agrave`,
33085 `acircumflex`,
33086 `adieresis`,
33087 `atilde`,
33088 `aring`,
33089 `ccedilla`,
33090 `eacute`,
33091 `egrave`,
33092 `ecircumflex`,
33093 `edieresis`,
33094 `iacute`,
33095 `igrave`,
33096 `icircumflex`,
33097 `idieresis`,
33098 `ntilde`,
33099 `oacute`,
33100 `ograve`,
33101 `ocircumflex`,
33102 `odieresis`,
33103 `otilde`,
33104 `uacute`,
33105 `ugrave`,
33106 `ucircumflex`,
33107 `udieresis`,
33108 `dagger`,
33109 `degree`,
33110 `cent`,
33111 `sterling`,
33112 `section`,
33113 `bullet`,
33114 `paragraph`,
33115 `germandbls`,
33116 `registered`,
33117 `copyright`,
33118 `trademark`,
33119 `acute`,
33120 `dieresis`,
33121 `notequal`,
33122 `AE`,
33123 `Oslash`,
33124 `infinity`,
33125 `plusminus`,
33126 `lessequal`,
33127 `greaterequal`,
33128 `yen`,
33129 `mu`,
33130 `partialdiff`,
33131 `summation`,
33132 `product`,
33133 `pi`,
33134 `integral`,
33135 `ordfeminine`,
33136 `ordmasculine`,
33137 `Omega`,
33138 `ae`,
33139 `oslash`,
33140 `questiondown`,
33141 `exclamdown`,
33142 `logicalnot`,
33143 `radical`,
33144 `florin`,
33145 `approxequal`,
33146 `Delta`,
33147 `guillemotleft`,
33148 `guillemotright`,
33149 `ellipsis`,
33150 `nonbreakingspace`,
33151 `Agrave`,
33152 `Atilde`,
33153 `Otilde`,
33154 `OE`,
33155 `oe`,
33156 `endash`,
33157 `emdash`,
33158 `quotedblleft`,
33159 `quotedblright`,
33160 `quoteleft`,
33161 `quoteright`,
33162 `divide`,
33163 `lozenge`,
33164 `ydieresis`,
33165 `Ydieresis`,
33166 `fraction`,
33167 `currency`,
33168 `guilsinglleft`,
33169 `guilsinglright`,
33170 `fi`,
33171 `fl`,
33172 `daggerdbl`,
33173 `periodcentered`,
33174 `quotesinglbase`,
33175 `quotedblbase`,
33176 `perthousand`,
33177 `Acircumflex`,
33178 `Ecircumflex`,
33179 `Aacute`,
33180 `Edieresis`,
33181 `Egrave`,
33182 `Iacute`,
33183 `Icircumflex`,
33184 `Idieresis`,
33185 `Igrave`,
33186 `Oacute`,
33187 `Ocircumflex`,
33188 `apple`,
33189 `Ograve`,
33190 `Uacute`,
33191 `Ucircumflex`,
33192 `Ugrave`,
33193 `dotlessi`,
33194 `circumflex`,
33195 `tilde`,
33196 `macron`,
33197 `breve`,
33198 `dotaccent`,
33199 `ring`,
33200 `cedilla`,
33201 `hungarumlaut`,
33202 `ogonek`,
33203 `caron`,
33204 `Lslash`,
33205 `lslash`,
33206 `Scaron`,
33207 `scaron`,
33208 `Zcaron`,
33209 `zcaron`,
33210 `brokenbar`,
33211 `Eth`,
33212 `eth`,
33213 `Yacute`,
33214 `yacute`,
33215 `Thorn`,
33216 `thorn`,
33217 `minus`,
33218 `multiply`,
33219 `onesuperior`,
33220 `twosuperior`,
33221 `threesuperior`,
33222 `onehalf`,
33223 `onequarter`,
33224 `threequarters`,
33225 `franc`,
33226 `Gbreve`,
33227 `gbreve`,
33228 `Idotaccent`,
33229 `Scedilla`,
33230 `scedilla`,
33231 `Cacute`,
33232 `cacute`,
33233 `Ccaron`,
33234 `ccaron`,
33235 `dcroat`
33236 ];
33237 var post$1 = Object.freeze({ __proto__: null, post });
33238 var BASE = class extends SimpleTable {
33239 constructor(dict, dataview) {
33240 const { p: p22 } = super(dict, dataview);
33241 this.majorVersion = p22.uint16;
33242 this.minorVersion = p22.uint16;
33243 this.horizAxisOffset = p22.Offset16;
33244 this.vertAxisOffset = p22.Offset16;
33245 lazy$1(
33246 this,
33247 `horizAxis`,
33248 () => new AxisTable(
33249 { offset: dict.offset + this.horizAxisOffset },
33250 dataview
33251 )
33252 );
33253 lazy$1(
33254 this,
33255 `vertAxis`,
33256 () => new AxisTable(
33257 { offset: dict.offset + this.vertAxisOffset },
33258 dataview
33259 )
33260 );
33261 if (this.majorVersion === 1 && this.minorVersion === 1) {
33262 this.itemVarStoreOffset = p22.Offset32;
33263 lazy$1(
33264 this,
33265 `itemVarStore`,
33266 () => new AxisTable(
33267 { offset: dict.offset + this.itemVarStoreOffset },
33268 dataview
33269 )
33270 );
33271 }
33272 }
33273 };
33274 var AxisTable = class extends SimpleTable {
33275 constructor(dict, dataview) {
33276 const { p: p22 } = super(dict, dataview, `AxisTable`);
33277 this.baseTagListOffset = p22.Offset16;
33278 this.baseScriptListOffset = p22.Offset16;
33279 lazy$1(
33280 this,
33281 `baseTagList`,
33282 () => new BaseTagListTable(
33283 { offset: dict.offset + this.baseTagListOffset },
33284 dataview
33285 )
33286 );
33287 lazy$1(
33288 this,
33289 `baseScriptList`,
33290 () => new BaseScriptListTable(
33291 { offset: dict.offset + this.baseScriptListOffset },
33292 dataview
33293 )
33294 );
33295 }
33296 };
33297 var BaseTagListTable = class extends SimpleTable {
33298 constructor(dict, dataview) {
33299 const { p: p22 } = super(dict, dataview, `BaseTagListTable`);
33300 this.baseTagCount = p22.uint16;
33301 this.baselineTags = [...new Array(this.baseTagCount)].map(
33302 (_) => p22.tag
33303 );
33304 }
33305 };
33306 var BaseScriptListTable = class extends SimpleTable {
33307 constructor(dict, dataview) {
33308 const { p: p22 } = super(dict, dataview, `BaseScriptListTable`);
33309 this.baseScriptCount = p22.uint16;
33310 const recordStart = p22.currentPosition;
33311 lazy$1(this, `baseScriptRecords`, () => {
33312 p22.currentPosition = recordStart;
33313 return [...new Array(this.baseScriptCount)].map(
33314 (_) => new BaseScriptRecord(this.start, p22)
33315 );
33316 });
33317 }
33318 };
33319 var BaseScriptRecord = class {
33320 constructor(baseScriptListTableStart, p22) {
33321 this.baseScriptTag = p22.tag;
33322 this.baseScriptOffset = p22.Offset16;
33323 lazy$1(this, `baseScriptTable`, () => {
33324 p22.currentPosition = baseScriptListTableStart + this.baseScriptOffset;
33325 return new BaseScriptTable(p22);
33326 });
33327 }
33328 };
33329 var BaseScriptTable = class {
33330 constructor(p22) {
33331 this.start = p22.currentPosition;
33332 this.baseValuesOffset = p22.Offset16;
33333 this.defaultMinMaxOffset = p22.Offset16;
33334 this.baseLangSysCount = p22.uint16;
33335 this.baseLangSysRecords = [...new Array(this.baseLangSysCount)].map(
33336 (_) => new BaseLangSysRecord(this.start, p22)
33337 );
33338 lazy$1(this, `baseValues`, () => {
33339 p22.currentPosition = this.start + this.baseValuesOffset;
33340 return new BaseValuesTable(p22);
33341 });
33342 lazy$1(this, `defaultMinMax`, () => {
33343 p22.currentPosition = this.start + this.defaultMinMaxOffset;
33344 return new MinMaxTable(p22);
33345 });
33346 }
33347 };
33348 var BaseLangSysRecord = class {
33349 constructor(baseScriptTableStart, p22) {
33350 this.baseLangSysTag = p22.tag;
33351 this.minMaxOffset = p22.Offset16;
33352 lazy$1(this, `minMax`, () => {
33353 p22.currentPosition = baseScriptTableStart + this.minMaxOffset;
33354 return new MinMaxTable(p22);
33355 });
33356 }
33357 };
33358 var BaseValuesTable = class {
33359 constructor(p22) {
33360 this.parser = p22;
33361 this.start = p22.currentPosition;
33362 this.defaultBaselineIndex = p22.uint16;
33363 this.baseCoordCount = p22.uint16;
33364 this.baseCoords = [...new Array(this.baseCoordCount)].map(
33365 (_) => p22.Offset16
33366 );
33367 }
33368 getTable(id) {
33369 this.parser.currentPosition = this.start + this.baseCoords[id];
33370 return new BaseCoordTable(this.parser);
33371 }
33372 };
33373 var MinMaxTable = class {
33374 constructor(p22) {
33375 this.minCoord = p22.Offset16;
33376 this.maxCoord = p22.Offset16;
33377 this.featMinMaxCount = p22.uint16;
33378 const recordStart = p22.currentPosition;
33379 lazy$1(this, `featMinMaxRecords`, () => {
33380 p22.currentPosition = recordStart;
33381 return [...new Array(this.featMinMaxCount)].map(
33382 (_) => new FeatMinMaxRecord(p22)
33383 );
33384 });
33385 }
33386 };
33387 var FeatMinMaxRecord = class {
33388 constructor(p22) {
33389 this.featureTableTag = p22.tag;
33390 this.minCoord = p22.Offset16;
33391 this.maxCoord = p22.Offset16;
33392 }
33393 };
33394 var BaseCoordTable = class {
33395 constructor(p22) {
33396 this.baseCoordFormat = p22.uint16;
33397 this.coordinate = p22.int16;
33398 if (this.baseCoordFormat === 2) {
33399 this.referenceGlyph = p22.uint16;
33400 this.baseCoordPoint = p22.uint16;
33401 }
33402 if (this.baseCoordFormat === 3) {
33403 this.deviceTable = p22.Offset16;
33404 }
33405 }
33406 };
33407 var BASE$1 = Object.freeze({ __proto__: null, BASE });
33408 var ClassDefinition = class {
33409 constructor(p22) {
33410 this.classFormat = p22.uint16;
33411 if (this.classFormat === 1) {
33412 this.startGlyphID = p22.uint16;
33413 this.glyphCount = p22.uint16;
33414 this.classValueArray = [...new Array(this.glyphCount)].map(
33415 (_) => p22.uint16
33416 );
33417 }
33418 if (this.classFormat === 2) {
33419 this.classRangeCount = p22.uint16;
33420 this.classRangeRecords = [
33421 ...new Array(this.classRangeCount)
33422 ].map((_) => new ClassRangeRecord(p22));
33423 }
33424 }
33425 };
33426 var ClassRangeRecord = class {
33427 constructor(p22) {
33428 this.startGlyphID = p22.uint16;
33429 this.endGlyphID = p22.uint16;
33430 this.class = p22.uint16;
33431 }
33432 };
33433 var CoverageTable = class extends ParsedData {
33434 constructor(p22) {
33435 super(p22);
33436 this.coverageFormat = p22.uint16;
33437 if (this.coverageFormat === 1) {
33438 this.glyphCount = p22.uint16;
33439 this.glyphArray = [...new Array(this.glyphCount)].map(
33440 (_) => p22.uint16
33441 );
33442 }
33443 if (this.coverageFormat === 2) {
33444 this.rangeCount = p22.uint16;
33445 this.rangeRecords = [...new Array(this.rangeCount)].map(
33446 (_) => new CoverageRangeRecord(p22)
33447 );
33448 }
33449 }
33450 };
33451 var CoverageRangeRecord = class {
33452 constructor(p22) {
33453 this.startGlyphID = p22.uint16;
33454 this.endGlyphID = p22.uint16;
33455 this.startCoverageIndex = p22.uint16;
33456 }
33457 };
33458 var ItemVariationStoreTable = class {
33459 constructor(table, p22) {
33460 this.table = table;
33461 this.parser = p22;
33462 this.start = p22.currentPosition;
33463 this.format = p22.uint16;
33464 this.variationRegionListOffset = p22.Offset32;
33465 this.itemVariationDataCount = p22.uint16;
33466 this.itemVariationDataOffsets = [
33467 ...new Array(this.itemVariationDataCount)
33468 ].map((_) => p22.Offset32);
33469 }
33470 };
33471 var GDEF = class extends SimpleTable {
33472 constructor(dict, dataview) {
33473 const { p: p22 } = super(dict, dataview);
33474 this.majorVersion = p22.uint16;
33475 this.minorVersion = p22.uint16;
33476 this.glyphClassDefOffset = p22.Offset16;
33477 lazy$1(this, `glyphClassDefs`, () => {
33478 if (this.glyphClassDefOffset === 0) return void 0;
33479 p22.currentPosition = this.tableStart + this.glyphClassDefOffset;
33480 return new ClassDefinition(p22);
33481 });
33482 this.attachListOffset = p22.Offset16;
33483 lazy$1(this, `attachList`, () => {
33484 if (this.attachListOffset === 0) return void 0;
33485 p22.currentPosition = this.tableStart + this.attachListOffset;
33486 return new AttachList(p22);
33487 });
33488 this.ligCaretListOffset = p22.Offset16;
33489 lazy$1(this, `ligCaretList`, () => {
33490 if (this.ligCaretListOffset === 0) return void 0;
33491 p22.currentPosition = this.tableStart + this.ligCaretListOffset;
33492 return new LigCaretList(p22);
33493 });
33494 this.markAttachClassDefOffset = p22.Offset16;
33495 lazy$1(this, `markAttachClassDef`, () => {
33496 if (this.markAttachClassDefOffset === 0) return void 0;
33497 p22.currentPosition = this.tableStart + this.markAttachClassDefOffset;
33498 return new ClassDefinition(p22);
33499 });
33500 if (this.minorVersion >= 2) {
33501 this.markGlyphSetsDefOffset = p22.Offset16;
33502 lazy$1(this, `markGlyphSetsDef`, () => {
33503 if (this.markGlyphSetsDefOffset === 0) return void 0;
33504 p22.currentPosition = this.tableStart + this.markGlyphSetsDefOffset;
33505 return new MarkGlyphSetsTable(p22);
33506 });
33507 }
33508 if (this.minorVersion === 3) {
33509 this.itemVarStoreOffset = p22.Offset32;
33510 lazy$1(this, `itemVarStore`, () => {
33511 if (this.itemVarStoreOffset === 0) return void 0;
33512 p22.currentPosition = this.tableStart + this.itemVarStoreOffset;
33513 return new ItemVariationStoreTable(p22);
33514 });
33515 }
33516 }
33517 };
33518 var AttachList = class extends ParsedData {
33519 constructor(p22) {
33520 super(p22);
33521 this.coverageOffset = p22.Offset16;
33522 this.glyphCount = p22.uint16;
33523 this.attachPointOffsets = [...new Array(this.glyphCount)].map(
33524 (_) => p22.Offset16
33525 );
33526 }
33527 getPoint(pointID) {
33528 this.parser.currentPosition = this.start + this.attachPointOffsets[pointID];
33529 return new AttachPoint(this.parser);
33530 }
33531 };
33532 var AttachPoint = class {
33533 constructor(p22) {
33534 this.pointCount = p22.uint16;
33535 this.pointIndices = [...new Array(this.pointCount)].map(
33536 (_) => p22.uint16
33537 );
33538 }
33539 };
33540 var LigCaretList = class extends ParsedData {
33541 constructor(p22) {
33542 super(p22);
33543 this.coverageOffset = p22.Offset16;
33544 lazy$1(this, `coverage`, () => {
33545 p22.currentPosition = this.start + this.coverageOffset;
33546 return new CoverageTable(p22);
33547 });
33548 this.ligGlyphCount = p22.uint16;
33549 this.ligGlyphOffsets = [...new Array(this.ligGlyphCount)].map(
33550 (_) => p22.Offset16
33551 );
33552 }
33553 getLigGlyph(ligGlyphID) {
33554 this.parser.currentPosition = this.start + this.ligGlyphOffsets[ligGlyphID];
33555 return new LigGlyph(this.parser);
33556 }
33557 };
33558 var LigGlyph = class extends ParsedData {
33559 constructor(p22) {
33560 super(p22);
33561 this.caretCount = p22.uint16;
33562 this.caretValueOffsets = [...new Array(this.caretCount)].map(
33563 (_) => p22.Offset16
33564 );
33565 }
33566 getCaretValue(caretID) {
33567 this.parser.currentPosition = this.start + this.caretValueOffsets[caretID];
33568 return new CaretValue(this.parser);
33569 }
33570 };
33571 var CaretValue = class {
33572 constructor(p22) {
33573 this.caretValueFormat = p22.uint16;
33574 if (this.caretValueFormat === 1) {
33575 this.coordinate = p22.int16;
33576 }
33577 if (this.caretValueFormat === 2) {
33578 this.caretValuePointIndex = p22.uint16;
33579 }
33580 if (this.caretValueFormat === 3) {
33581 this.coordinate = p22.int16;
33582 this.deviceOffset = p22.Offset16;
33583 }
33584 }
33585 };
33586 var MarkGlyphSetsTable = class extends ParsedData {
33587 constructor(p22) {
33588 super(p22);
33589 this.markGlyphSetTableFormat = p22.uint16;
33590 this.markGlyphSetCount = p22.uint16;
33591 this.coverageOffsets = [...new Array(this.markGlyphSetCount)].map(
33592 (_) => p22.Offset32
33593 );
33594 }
33595 getMarkGlyphSet(markGlyphSetID) {
33596 this.parser.currentPosition = this.start + this.coverageOffsets[markGlyphSetID];
33597 return new CoverageTable(this.parser);
33598 }
33599 };
33600 var GDEF$1 = Object.freeze({ __proto__: null, GDEF });
33601 var ScriptList = class extends ParsedData {
33602 static EMPTY = { scriptCount: 0, scriptRecords: [] };
33603 constructor(p22) {
33604 super(p22);
33605 this.scriptCount = p22.uint16;
33606 this.scriptRecords = [...new Array(this.scriptCount)].map(
33607 (_) => new ScriptRecord(p22)
33608 );
33609 }
33610 };
33611 var ScriptRecord = class {
33612 constructor(p22) {
33613 this.scriptTag = p22.tag;
33614 this.scriptOffset = p22.Offset16;
33615 }
33616 };
33617 var ScriptTable = class extends ParsedData {
33618 constructor(p22) {
33619 super(p22);
33620 this.defaultLangSys = p22.Offset16;
33621 this.langSysCount = p22.uint16;
33622 this.langSysRecords = [...new Array(this.langSysCount)].map(
33623 (_) => new LangSysRecord(p22)
33624 );
33625 }
33626 };
33627 var LangSysRecord = class {
33628 constructor(p22) {
33629 this.langSysTag = p22.tag;
33630 this.langSysOffset = p22.Offset16;
33631 }
33632 };
33633 var LangSysTable = class {
33634 constructor(p22) {
33635 this.lookupOrder = p22.Offset16;
33636 this.requiredFeatureIndex = p22.uint16;
33637 this.featureIndexCount = p22.uint16;
33638 this.featureIndices = [...new Array(this.featureIndexCount)].map(
33639 (_) => p22.uint16
33640 );
33641 }
33642 };
33643 var FeatureList = class extends ParsedData {
33644 static EMPTY = { featureCount: 0, featureRecords: [] };
33645 constructor(p22) {
33646 super(p22);
33647 this.featureCount = p22.uint16;
33648 this.featureRecords = [...new Array(this.featureCount)].map(
33649 (_) => new FeatureRecord(p22)
33650 );
33651 }
33652 };
33653 var FeatureRecord = class {
33654 constructor(p22) {
33655 this.featureTag = p22.tag;
33656 this.featureOffset = p22.Offset16;
33657 }
33658 };
33659 var FeatureTable = class extends ParsedData {
33660 constructor(p22) {
33661 super(p22);
33662 this.featureParams = p22.Offset16;
33663 this.lookupIndexCount = p22.uint16;
33664 this.lookupListIndices = [...new Array(this.lookupIndexCount)].map(
33665 (_) => p22.uint16
33666 );
33667 }
33668 getFeatureParams() {
33669 if (this.featureParams > 0) {
33670 const p22 = this.parser;
33671 p22.currentPosition = this.start + this.featureParams;
33672 const tag = this.featureTag;
33673 if (tag === `size`) return new Size(p22);
33674 if (tag.startsWith(`cc`)) return new CharacterVariant(p22);
33675 if (tag.startsWith(`ss`)) return new StylisticSet(p22);
33676 }
33677 }
33678 };
33679 var CharacterVariant = class {
33680 constructor(p22) {
33681 this.format = p22.uint16;
33682 this.featUiLabelNameId = p22.uint16;
33683 this.featUiTooltipTextNameId = p22.uint16;
33684 this.sampleTextNameId = p22.uint16;
33685 this.numNamedParameters = p22.uint16;
33686 this.firstParamUiLabelNameId = p22.uint16;
33687 this.charCount = p22.uint16;
33688 this.character = [...new Array(this.charCount)].map(
33689 (_) => p22.uint24
33690 );
33691 }
33692 };
33693 var Size = class {
33694 constructor(p22) {
33695 this.designSize = p22.uint16;
33696 this.subfamilyIdentifier = p22.uint16;
33697 this.subfamilyNameID = p22.uint16;
33698 this.smallEnd = p22.uint16;
33699 this.largeEnd = p22.uint16;
33700 }
33701 };
33702 var StylisticSet = class {
33703 constructor(p22) {
33704 this.version = p22.uint16;
33705 this.UINameID = p22.uint16;
33706 }
33707 };
33708 function undoCoverageOffsetParsing(instance) {
33709 instance.parser.currentPosition -= 2;
33710 delete instance.coverageOffset;
33711 delete instance.getCoverageTable;
33712 }
33713 var LookupType$1 = class extends ParsedData {
33714 constructor(p22) {
33715 super(p22);
33716 this.substFormat = p22.uint16;
33717 this.coverageOffset = p22.Offset16;
33718 }
33719 getCoverageTable() {
33720 let p22 = this.parser;
33721 p22.currentPosition = this.start + this.coverageOffset;
33722 return new CoverageTable(p22);
33723 }
33724 };
33725 var SubstLookupRecord = class {
33726 constructor(p22) {
33727 this.glyphSequenceIndex = p22.uint16;
33728 this.lookupListIndex = p22.uint16;
33729 }
33730 };
33731 var LookupType1$1 = class extends LookupType$1 {
33732 constructor(p22) {
33733 super(p22);
33734 this.deltaGlyphID = p22.int16;
33735 }
33736 };
33737 var LookupType2$1 = class extends LookupType$1 {
33738 constructor(p22) {
33739 super(p22);
33740 this.sequenceCount = p22.uint16;
33741 this.sequenceOffsets = [...new Array(this.sequenceCount)].map(
33742 (_) => p22.Offset16
33743 );
33744 }
33745 getSequence(index2) {
33746 let p22 = this.parser;
33747 p22.currentPosition = this.start + this.sequenceOffsets[index2];
33748 return new SequenceTable(p22);
33749 }
33750 };
33751 var SequenceTable = class {
33752 constructor(p22) {
33753 this.glyphCount = p22.uint16;
33754 this.substituteGlyphIDs = [...new Array(this.glyphCount)].map(
33755 (_) => p22.uint16
33756 );
33757 }
33758 };
33759 var LookupType3$1 = class extends LookupType$1 {
33760 constructor(p22) {
33761 super(p22);
33762 this.alternateSetCount = p22.uint16;
33763 this.alternateSetOffsets = [
33764 ...new Array(this.alternateSetCount)
33765 ].map((_) => p22.Offset16);
33766 }
33767 getAlternateSet(index2) {
33768 let p22 = this.parser;
33769 p22.currentPosition = this.start + this.alternateSetOffsets[index2];
33770 return new AlternateSetTable(p22);
33771 }
33772 };
33773 var AlternateSetTable = class {
33774 constructor(p22) {
33775 this.glyphCount = p22.uint16;
33776 this.alternateGlyphIDs = [...new Array(this.glyphCount)].map(
33777 (_) => p22.uint16
33778 );
33779 }
33780 };
33781 var LookupType4$1 = class extends LookupType$1 {
33782 constructor(p22) {
33783 super(p22);
33784 this.ligatureSetCount = p22.uint16;
33785 this.ligatureSetOffsets = [...new Array(this.ligatureSetCount)].map(
33786 (_) => p22.Offset16
33787 );
33788 }
33789 getLigatureSet(index2) {
33790 let p22 = this.parser;
33791 p22.currentPosition = this.start + this.ligatureSetOffsets[index2];
33792 return new LigatureSetTable(p22);
33793 }
33794 };
33795 var LigatureSetTable = class extends ParsedData {
33796 constructor(p22) {
33797 super(p22);
33798 this.ligatureCount = p22.uint16;
33799 this.ligatureOffsets = [...new Array(this.ligatureCount)].map(
33800 (_) => p22.Offset16
33801 );
33802 }
33803 getLigature(index2) {
33804 let p22 = this.parser;
33805 p22.currentPosition = this.start + this.ligatureOffsets[index2];
33806 return new LigatureTable(p22);
33807 }
33808 };
33809 var LigatureTable = class {
33810 constructor(p22) {
33811 this.ligatureGlyph = p22.uint16;
33812 this.componentCount = p22.uint16;
33813 this.componentGlyphIDs = [
33814 ...new Array(this.componentCount - 1)
33815 ].map((_) => p22.uint16);
33816 }
33817 };
33818 var LookupType5$1 = class extends LookupType$1 {
33819 constructor(p22) {
33820 super(p22);
33821 if (this.substFormat === 1) {
33822 this.subRuleSetCount = p22.uint16;
33823 this.subRuleSetOffsets = [
33824 ...new Array(this.subRuleSetCount)
33825 ].map((_) => p22.Offset16);
33826 }
33827 if (this.substFormat === 2) {
33828 this.classDefOffset = p22.Offset16;
33829 this.subClassSetCount = p22.uint16;
33830 this.subClassSetOffsets = [
33831 ...new Array(this.subClassSetCount)
33832 ].map((_) => p22.Offset16);
33833 }
33834 if (this.substFormat === 3) {
33835 undoCoverageOffsetParsing(this);
33836 this.glyphCount = p22.uint16;
33837 this.substitutionCount = p22.uint16;
33838 this.coverageOffsets = [...new Array(this.glyphCount)].map(
33839 (_) => p22.Offset16
33840 );
33841 this.substLookupRecords = [
33842 ...new Array(this.substitutionCount)
33843 ].map((_) => new SubstLookupRecord(p22));
33844 }
33845 }
33846 getSubRuleSet(index2) {
33847 if (this.substFormat !== 1)
33848 throw new Error(
33849 `lookup type 5.${this.substFormat} has no subrule sets.`
33850 );
33851 let p22 = this.parser;
33852 p22.currentPosition = this.start + this.subRuleSetOffsets[index2];
33853 return new SubRuleSetTable(p22);
33854 }
33855 getSubClassSet(index2) {
33856 if (this.substFormat !== 2)
33857 throw new Error(
33858 `lookup type 5.${this.substFormat} has no subclass sets.`
33859 );
33860 let p22 = this.parser;
33861 p22.currentPosition = this.start + this.subClassSetOffsets[index2];
33862 return new SubClassSetTable(p22);
33863 }
33864 getCoverageTable(index2) {
33865 if (this.substFormat !== 3 && !index2)
33866 return super.getCoverageTable();
33867 if (!index2)
33868 throw new Error(
33869 `lookup type 5.${this.substFormat} requires an coverage table index.`
33870 );
33871 let p22 = this.parser;
33872 p22.currentPosition = this.start + this.coverageOffsets[index2];
33873 return new CoverageTable(p22);
33874 }
33875 };
33876 var SubRuleSetTable = class extends ParsedData {
33877 constructor(p22) {
33878 super(p22);
33879 this.subRuleCount = p22.uint16;
33880 this.subRuleOffsets = [...new Array(this.subRuleCount)].map(
33881 (_) => p22.Offset16
33882 );
33883 }
33884 getSubRule(index2) {
33885 let p22 = this.parser;
33886 p22.currentPosition = this.start + this.subRuleOffsets[index2];
33887 return new SubRuleTable(p22);
33888 }
33889 };
33890 var SubRuleTable = class {
33891 constructor(p22) {
33892 this.glyphCount = p22.uint16;
33893 this.substitutionCount = p22.uint16;
33894 this.inputSequence = [...new Array(this.glyphCount - 1)].map(
33895 (_) => p22.uint16
33896 );
33897 this.substLookupRecords = [
33898 ...new Array(this.substitutionCount)
33899 ].map((_) => new SubstLookupRecord(p22));
33900 }
33901 };
33902 var SubClassSetTable = class extends ParsedData {
33903 constructor(p22) {
33904 super(p22);
33905 this.subClassRuleCount = p22.uint16;
33906 this.subClassRuleOffsets = [
33907 ...new Array(this.subClassRuleCount)
33908 ].map((_) => p22.Offset16);
33909 }
33910 getSubClass(index2) {
33911 let p22 = this.parser;
33912 p22.currentPosition = this.start + this.subClassRuleOffsets[index2];
33913 return new SubClassRuleTable(p22);
33914 }
33915 };
33916 var SubClassRuleTable = class extends SubRuleTable {
33917 constructor(p22) {
33918 super(p22);
33919 }
33920 };
33921 var LookupType6$1 = class extends LookupType$1 {
33922 constructor(p22) {
33923 super(p22);
33924 if (this.substFormat === 1) {
33925 this.chainSubRuleSetCount = p22.uint16;
33926 this.chainSubRuleSetOffsets = [
33927 ...new Array(this.chainSubRuleSetCount)
33928 ].map((_) => p22.Offset16);
33929 }
33930 if (this.substFormat === 2) {
33931 this.backtrackClassDefOffset = p22.Offset16;
33932 this.inputClassDefOffset = p22.Offset16;
33933 this.lookaheadClassDefOffset = p22.Offset16;
33934 this.chainSubClassSetCount = p22.uint16;
33935 this.chainSubClassSetOffsets = [
33936 ...new Array(this.chainSubClassSetCount)
33937 ].map((_) => p22.Offset16);
33938 }
33939 if (this.substFormat === 3) {
33940 undoCoverageOffsetParsing(this);
33941 this.backtrackGlyphCount = p22.uint16;
33942 this.backtrackCoverageOffsets = [
33943 ...new Array(this.backtrackGlyphCount)
33944 ].map((_) => p22.Offset16);
33945 this.inputGlyphCount = p22.uint16;
33946 this.inputCoverageOffsets = [
33947 ...new Array(this.inputGlyphCount)
33948 ].map((_) => p22.Offset16);
33949 this.lookaheadGlyphCount = p22.uint16;
33950 this.lookaheadCoverageOffsets = [
33951 ...new Array(this.lookaheadGlyphCount)
33952 ].map((_) => p22.Offset16);
33953 this.seqLookupCount = p22.uint16;
33954 this.seqLookupRecords = [
33955 ...new Array(this.substitutionCount)
33956 ].map((_) => new SequenceLookupRecord(p22));
33957 }
33958 }
33959 getChainSubRuleSet(index2) {
33960 if (this.substFormat !== 1)
33961 throw new Error(
33962 `lookup type 6.${this.substFormat} has no chainsubrule sets.`
33963 );
33964 let p22 = this.parser;
33965 p22.currentPosition = this.start + this.chainSubRuleSetOffsets[index2];
33966 return new ChainSubRuleSetTable(p22);
33967 }
33968 getChainSubClassSet(index2) {
33969 if (this.substFormat !== 2)
33970 throw new Error(
33971 `lookup type 6.${this.substFormat} has no chainsubclass sets.`
33972 );
33973 let p22 = this.parser;
33974 p22.currentPosition = this.start + this.chainSubClassSetOffsets[index2];
33975 return new ChainSubClassSetTable(p22);
33976 }
33977 getCoverageFromOffset(offset3) {
33978 if (this.substFormat !== 3)
33979 throw new Error(
33980 `lookup type 6.${this.substFormat} does not use contextual coverage offsets.`
33981 );
33982 let p22 = this.parser;
33983 p22.currentPosition = this.start + offset3;
33984 return new CoverageTable(p22);
33985 }
33986 };
33987 var ChainSubRuleSetTable = class extends ParsedData {
33988 constructor(p22) {
33989 super(p22);
33990 this.chainSubRuleCount = p22.uint16;
33991 this.chainSubRuleOffsets = [
33992 ...new Array(this.chainSubRuleCount)
33993 ].map((_) => p22.Offset16);
33994 }
33995 getSubRule(index2) {
33996 let p22 = this.parser;
33997 p22.currentPosition = this.start + this.chainSubRuleOffsets[index2];
33998 return new ChainSubRuleTable(p22);
33999 }
34000 };
34001 var ChainSubRuleTable = class {
34002 constructor(p22) {
34003 this.backtrackGlyphCount = p22.uint16;
34004 this.backtrackSequence = [
34005 ...new Array(this.backtrackGlyphCount)
34006 ].map((_) => p22.uint16);
34007 this.inputGlyphCount = p22.uint16;
34008 this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map(
34009 (_) => p22.uint16
34010 );
34011 this.lookaheadGlyphCount = p22.uint16;
34012 this.lookAheadSequence = [
34013 ...new Array(this.lookAheadGlyphCount)
34014 ].map((_) => p22.uint16);
34015 this.substitutionCount = p22.uint16;
34016 this.substLookupRecords = [...new Array(this.SubstCount)].map(
34017 (_) => new SubstLookupRecord(p22)
34018 );
34019 }
34020 };
34021 var ChainSubClassSetTable = class extends ParsedData {
34022 constructor(p22) {
34023 super(p22);
34024 this.chainSubClassRuleCount = p22.uint16;
34025 this.chainSubClassRuleOffsets = [
34026 ...new Array(this.chainSubClassRuleCount)
34027 ].map((_) => p22.Offset16);
34028 }
34029 getSubClass(index2) {
34030 let p22 = this.parser;
34031 p22.currentPosition = this.start + this.chainSubRuleOffsets[index2];
34032 return new ChainSubClassRuleTable(p22);
34033 }
34034 };
34035 var ChainSubClassRuleTable = class {
34036 constructor(p22) {
34037 this.backtrackGlyphCount = p22.uint16;
34038 this.backtrackSequence = [
34039 ...new Array(this.backtrackGlyphCount)
34040 ].map((_) => p22.uint16);
34041 this.inputGlyphCount = p22.uint16;
34042 this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map(
34043 (_) => p22.uint16
34044 );
34045 this.lookaheadGlyphCount = p22.uint16;
34046 this.lookAheadSequence = [
34047 ...new Array(this.lookAheadGlyphCount)
34048 ].map((_) => p22.uint16);
34049 this.substitutionCount = p22.uint16;
34050 this.substLookupRecords = [
34051 ...new Array(this.substitutionCount)
34052 ].map((_) => new SequenceLookupRecord(p22));
34053 }
34054 };
34055 var SequenceLookupRecord = class extends ParsedData {
34056 constructor(p22) {
34057 super(p22);
34058 this.sequenceIndex = p22.uint16;
34059 this.lookupListIndex = p22.uint16;
34060 }
34061 };
34062 var LookupType7$1 = class extends ParsedData {
34063 constructor(p22) {
34064 super(p22);
34065 this.substFormat = p22.uint16;
34066 this.extensionLookupType = p22.uint16;
34067 this.extensionOffset = p22.Offset32;
34068 }
34069 };
34070 var LookupType8$1 = class extends LookupType$1 {
34071 constructor(p22) {
34072 super(p22);
34073 this.backtrackGlyphCount = p22.uint16;
34074 this.backtrackCoverageOffsets = [
34075 ...new Array(this.backtrackGlyphCount)
34076 ].map((_) => p22.Offset16);
34077 this.lookaheadGlyphCount = p22.uint16;
34078 this.lookaheadCoverageOffsets = [
34079 new Array(this.lookaheadGlyphCount)
34080 ].map((_) => p22.Offset16);
34081 this.glyphCount = p22.uint16;
34082 this.substituteGlyphIDs = [...new Array(this.glyphCount)].map(
34083 (_) => p22.uint16
34084 );
34085 }
34086 };
34087 var GSUBtables = {
34088 buildSubtable: function(type, p22) {
34089 const subtable = new [
34090 void 0,
34091 LookupType1$1,
34092 LookupType2$1,
34093 LookupType3$1,
34094 LookupType4$1,
34095 LookupType5$1,
34096 LookupType6$1,
34097 LookupType7$1,
34098 LookupType8$1
34099 ][type](p22);
34100 subtable.type = type;
34101 return subtable;
34102 }
34103 };
34104 var LookupType = class extends ParsedData {
34105 constructor(p22) {
34106 super(p22);
34107 }
34108 };
34109 var LookupType1 = class extends LookupType {
34110 constructor(p22) {
34111 super(p22);
34112 console.log(`lookup type 1`);
34113 }
34114 };
34115 var LookupType2 = class extends LookupType {
34116 constructor(p22) {
34117 super(p22);
34118 console.log(`lookup type 2`);
34119 }
34120 };
34121 var LookupType3 = class extends LookupType {
34122 constructor(p22) {
34123 super(p22);
34124 console.log(`lookup type 3`);
34125 }
34126 };
34127 var LookupType4 = class extends LookupType {
34128 constructor(p22) {
34129 super(p22);
34130 console.log(`lookup type 4`);
34131 }
34132 };
34133 var LookupType5 = class extends LookupType {
34134 constructor(p22) {
34135 super(p22);
34136 console.log(`lookup type 5`);
34137 }
34138 };
34139 var LookupType6 = class extends LookupType {
34140 constructor(p22) {
34141 super(p22);
34142 console.log(`lookup type 6`);
34143 }
34144 };
34145 var LookupType7 = class extends LookupType {
34146 constructor(p22) {
34147 super(p22);
34148 console.log(`lookup type 7`);
34149 }
34150 };
34151 var LookupType8 = class extends LookupType {
34152 constructor(p22) {
34153 super(p22);
34154 console.log(`lookup type 8`);
34155 }
34156 };
34157 var LookupType9 = class extends LookupType {
34158 constructor(p22) {
34159 super(p22);
34160 console.log(`lookup type 9`);
34161 }
34162 };
34163 var GPOStables = {
34164 buildSubtable: function(type, p22) {
34165 const subtable = new [
34166 void 0,
34167 LookupType1,
34168 LookupType2,
34169 LookupType3,
34170 LookupType4,
34171 LookupType5,
34172 LookupType6,
34173 LookupType7,
34174 LookupType8,
34175 LookupType9
34176 ][type](p22);
34177 subtable.type = type;
34178 return subtable;
34179 }
34180 };
34181 var LookupList = class extends ParsedData {
34182 static EMPTY = { lookupCount: 0, lookups: [] };
34183 constructor(p22) {
34184 super(p22);
34185 this.lookupCount = p22.uint16;
34186 this.lookups = [...new Array(this.lookupCount)].map(
34187 (_) => p22.Offset16
34188 );
34189 }
34190 };
34191 var LookupTable = class extends ParsedData {
34192 constructor(p22, type) {
34193 super(p22);
34194 this.ctType = type;
34195 this.lookupType = p22.uint16;
34196 this.lookupFlag = p22.uint16;
34197 this.subTableCount = p22.uint16;
34198 this.subtableOffsets = [...new Array(this.subTableCount)].map(
34199 (_) => p22.Offset16
34200 );
34201 this.markFilteringSet = p22.uint16;
34202 }
34203 get rightToLeft() {
34204 return this.lookupFlag & true;
34205 }
34206 get ignoreBaseGlyphs() {
34207 return this.lookupFlag & true;
34208 }
34209 get ignoreLigatures() {
34210 return this.lookupFlag & true;
34211 }
34212 get ignoreMarks() {
34213 return this.lookupFlag & true;
34214 }
34215 get useMarkFilteringSet() {
34216 return this.lookupFlag & true;
34217 }
34218 get markAttachmentType() {
34219 return this.lookupFlag & true;
34220 }
34221 getSubTable(index2) {
34222 const builder = this.ctType === `GSUB` ? GSUBtables : GPOStables;
34223 this.parser.currentPosition = this.start + this.subtableOffsets[index2];
34224 return builder.buildSubtable(this.lookupType, this.parser);
34225 }
34226 };
34227 var CommonLayoutTable = class extends SimpleTable {
34228 constructor(dict, dataview, name2) {
34229 const { p: p22, tableStart } = super(dict, dataview, name2);
34230 this.majorVersion = p22.uint16;
34231 this.minorVersion = p22.uint16;
34232 this.scriptListOffset = p22.Offset16;
34233 this.featureListOffset = p22.Offset16;
34234 this.lookupListOffset = p22.Offset16;
34235 if (this.majorVersion === 1 && this.minorVersion === 1) {
34236 this.featureVariationsOffset = p22.Offset32;
34237 }
34238 const no_content = !(this.scriptListOffset || this.featureListOffset || this.lookupListOffset);
34239 lazy$1(this, `scriptList`, () => {
34240 if (no_content) return ScriptList.EMPTY;
34241 p22.currentPosition = tableStart + this.scriptListOffset;
34242 return new ScriptList(p22);
34243 });
34244 lazy$1(this, `featureList`, () => {
34245 if (no_content) return FeatureList.EMPTY;
34246 p22.currentPosition = tableStart + this.featureListOffset;
34247 return new FeatureList(p22);
34248 });
34249 lazy$1(this, `lookupList`, () => {
34250 if (no_content) return LookupList.EMPTY;
34251 p22.currentPosition = tableStart + this.lookupListOffset;
34252 return new LookupList(p22);
34253 });
34254 if (this.featureVariationsOffset) {
34255 lazy$1(this, `featureVariations`, () => {
34256 if (no_content) return FeatureVariations.EMPTY;
34257 p22.currentPosition = tableStart + this.featureVariationsOffset;
34258 return new FeatureVariations(p22);
34259 });
34260 }
34261 }
34262 getSupportedScripts() {
34263 return this.scriptList.scriptRecords.map((r4) => r4.scriptTag);
34264 }
34265 getScriptTable(scriptTag) {
34266 let record = this.scriptList.scriptRecords.find(
34267 (r4) => r4.scriptTag === scriptTag
34268 );
34269 this.parser.currentPosition = this.scriptList.start + record.scriptOffset;
34270 let table = new ScriptTable(this.parser);
34271 table.scriptTag = scriptTag;
34272 return table;
34273 }
34274 ensureScriptTable(arg) {
34275 if (typeof arg === "string") {
34276 return this.getScriptTable(arg);
34277 }
34278 return arg;
34279 }
34280 getSupportedLangSys(scriptTable) {
34281 scriptTable = this.ensureScriptTable(scriptTable);
34282 const hasDefault = scriptTable.defaultLangSys !== 0;
34283 const supported = scriptTable.langSysRecords.map(
34284 (l3) => l3.langSysTag
34285 );
34286 if (hasDefault) supported.unshift(`dflt`);
34287 return supported;
34288 }
34289 getDefaultLangSysTable(scriptTable) {
34290 scriptTable = this.ensureScriptTable(scriptTable);
34291 let offset3 = scriptTable.defaultLangSys;
34292 if (offset3 !== 0) {
34293 this.parser.currentPosition = scriptTable.start + offset3;
34294 let table = new LangSysTable(this.parser);
34295 table.langSysTag = ``;
34296 table.defaultForScript = scriptTable.scriptTag;
34297 return table;
34298 }
34299 }
34300 getLangSysTable(scriptTable, langSysTag = `dflt`) {
34301 if (langSysTag === `dflt`)
34302 return this.getDefaultLangSysTable(scriptTable);
34303 scriptTable = this.ensureScriptTable(scriptTable);
34304 let record = scriptTable.langSysRecords.find(
34305 (l3) => l3.langSysTag === langSysTag
34306 );
34307 this.parser.currentPosition = scriptTable.start + record.langSysOffset;
34308 let table = new LangSysTable(this.parser);
34309 table.langSysTag = langSysTag;
34310 return table;
34311 }
34312 getFeatures(langSysTable) {
34313 return langSysTable.featureIndices.map(
34314 (index2) => this.getFeature(index2)
34315 );
34316 }
34317 getFeature(indexOrTag) {
34318 let record;
34319 if (parseInt(indexOrTag) == indexOrTag) {
34320 record = this.featureList.featureRecords[indexOrTag];
34321 } else {
34322 record = this.featureList.featureRecords.find(
34323 (f3) => f3.featureTag === indexOrTag
34324 );
34325 }
34326 if (!record) return;
34327 this.parser.currentPosition = this.featureList.start + record.featureOffset;
34328 let table = new FeatureTable(this.parser);
34329 table.featureTag = record.featureTag;
34330 return table;
34331 }
34332 getLookups(featureTable) {
34333 return featureTable.lookupListIndices.map(
34334 (index2) => this.getLookup(index2)
34335 );
34336 }
34337 getLookup(lookupIndex, type) {
34338 let lookupOffset = this.lookupList.lookups[lookupIndex];
34339 this.parser.currentPosition = this.lookupList.start + lookupOffset;
34340 return new LookupTable(this.parser, type);
34341 }
34342 };
34343 var GSUB = class extends CommonLayoutTable {
34344 constructor(dict, dataview) {
34345 super(dict, dataview, `GSUB`);
34346 }
34347 getLookup(lookupIndex) {
34348 return super.getLookup(lookupIndex, `GSUB`);
34349 }
34350 };
34351 var GSUB$1 = Object.freeze({ __proto__: null, GSUB });
34352 var GPOS = class extends CommonLayoutTable {
34353 constructor(dict, dataview) {
34354 super(dict, dataview, `GPOS`);
34355 }
34356 getLookup(lookupIndex) {
34357 return super.getLookup(lookupIndex, `GPOS`);
34358 }
34359 };
34360 var GPOS$1 = Object.freeze({ __proto__: null, GPOS });
34361 var SVG77 = class extends SimpleTable {
34362 constructor(dict, dataview) {
34363 const { p: p22 } = super(dict, dataview);
34364 this.version = p22.uint16;
34365 this.offsetToSVGDocumentList = p22.Offset32;
34366 p22.currentPosition = this.tableStart + this.offsetToSVGDocumentList;
34367 this.documentList = new SVGDocumentList(p22);
34368 }
34369 };
34370 var SVGDocumentList = class extends ParsedData {
34371 constructor(p22) {
34372 super(p22);
34373 this.numEntries = p22.uint16;
34374 this.documentRecords = [...new Array(this.numEntries)].map(
34375 (_) => new SVGDocumentRecord(p22)
34376 );
34377 }
34378 getDocument(documentID) {
34379 let record = this.documentRecords[documentID];
34380 if (!record) return "";
34381 let offset3 = this.start + record.svgDocOffset;
34382 this.parser.currentPosition = offset3;
34383 return this.parser.readBytes(record.svgDocLength);
34384 }
34385 getDocumentForGlyph(glyphID) {
34386 let id = this.documentRecords.findIndex(
34387 (d3) => d3.startGlyphID <= glyphID && glyphID <= d3.endGlyphID
34388 );
34389 if (id === -1) return "";
34390 return this.getDocument(id);
34391 }
34392 };
34393 var SVGDocumentRecord = class {
34394 constructor(p22) {
34395 this.startGlyphID = p22.uint16;
34396 this.endGlyphID = p22.uint16;
34397 this.svgDocOffset = p22.Offset32;
34398 this.svgDocLength = p22.uint32;
34399 }
34400 };
34401 var SVG$1 = Object.freeze({ __proto__: null, SVG: SVG77 });
34402 var fvar = class extends SimpleTable {
34403 constructor(dict, dataview) {
34404 const { p: p22 } = super(dict, dataview);
34405 this.majorVersion = p22.uint16;
34406 this.minorVersion = p22.uint16;
34407 this.axesArrayOffset = p22.Offset16;
34408 p22.uint16;
34409 this.axisCount = p22.uint16;
34410 this.axisSize = p22.uint16;
34411 this.instanceCount = p22.uint16;
34412 this.instanceSize = p22.uint16;
34413 const axisStart = this.tableStart + this.axesArrayOffset;
34414 lazy$1(this, `axes`, () => {
34415 p22.currentPosition = axisStart;
34416 return [...new Array(this.axisCount)].map(
34417 (_) => new VariationAxisRecord(p22)
34418 );
34419 });
34420 const instanceStart = axisStart + this.axisCount * this.axisSize;
34421 lazy$1(this, `instances`, () => {
34422 let instances = [];
34423 for (let i3 = 0; i3 < this.instanceCount; i3++) {
34424 p22.currentPosition = instanceStart + i3 * this.instanceSize;
34425 instances.push(
34426 new InstanceRecord(p22, this.axisCount, this.instanceSize)
34427 );
34428 }
34429 return instances;
34430 });
34431 }
34432 getSupportedAxes() {
34433 return this.axes.map((a3) => a3.tag);
34434 }
34435 getAxis(name2) {
34436 return this.axes.find((a3) => a3.tag === name2);
34437 }
34438 };
34439 var VariationAxisRecord = class {
34440 constructor(p22) {
34441 this.tag = p22.tag;
34442 this.minValue = p22.fixed;
34443 this.defaultValue = p22.fixed;
34444 this.maxValue = p22.fixed;
34445 this.flags = p22.flags(16);
34446 this.axisNameID = p22.uint16;
34447 }
34448 };
34449 var InstanceRecord = class {
34450 constructor(p22, axisCount, size3) {
34451 let start2 = p22.currentPosition;
34452 this.subfamilyNameID = p22.uint16;
34453 p22.uint16;
34454 this.coordinates = [...new Array(axisCount)].map(
34455 (_) => p22.fixed
34456 );
34457 if (p22.currentPosition - start2 < size3) {
34458 this.postScriptNameID = p22.uint16;
34459 }
34460 }
34461 };
34462 var fvar$1 = Object.freeze({ __proto__: null, fvar });
34463 var cvt = class extends SimpleTable {
34464 constructor(dict, dataview) {
34465 const { p: p22 } = super(dict, dataview);
34466 const n3 = dict.length / 2;
34467 lazy$1(
34468 this,
34469 `items`,
34470 () => [...new Array(n3)].map((_) => p22.fword)
34471 );
34472 }
34473 };
34474 var cvt$1 = Object.freeze({ __proto__: null, cvt });
34475 var fpgm = class extends SimpleTable {
34476 constructor(dict, dataview) {
34477 const { p: p22 } = super(dict, dataview);
34478 lazy$1(
34479 this,
34480 `instructions`,
34481 () => [...new Array(dict.length)].map((_) => p22.uint8)
34482 );
34483 }
34484 };
34485 var fpgm$1 = Object.freeze({ __proto__: null, fpgm });
34486 var gasp = class extends SimpleTable {
34487 constructor(dict, dataview) {
34488 const { p: p22 } = super(dict, dataview);
34489 this.version = p22.uint16;
34490 this.numRanges = p22.uint16;
34491 const getter = () => [...new Array(this.numRanges)].map(
34492 (_) => new GASPRange(p22)
34493 );
34494 lazy$1(this, `gaspRanges`, getter);
34495 }
34496 };
34497 var GASPRange = class {
34498 constructor(p22) {
34499 this.rangeMaxPPEM = p22.uint16;
34500 this.rangeGaspBehavior = p22.uint16;
34501 }
34502 };
34503 var gasp$1 = Object.freeze({ __proto__: null, gasp });
34504 var glyf = class extends SimpleTable {
34505 constructor(dict, dataview) {
34506 super(dict, dataview);
34507 }
34508 getGlyphData(offset3, length) {
34509 this.parser.currentPosition = this.tableStart + offset3;
34510 return this.parser.readBytes(length);
34511 }
34512 };
34513 var glyf$1 = Object.freeze({ __proto__: null, glyf });
34514 var loca = class extends SimpleTable {
34515 constructor(dict, dataview, tables) {
34516 const { p: p22 } = super(dict, dataview);
34517 const n3 = tables.maxp.numGlyphs + 1;
34518 if (tables.head.indexToLocFormat === 0) {
34519 this.x2 = true;
34520 lazy$1(
34521 this,
34522 `offsets`,
34523 () => [...new Array(n3)].map((_) => p22.Offset16)
34524 );
34525 } else {
34526 lazy$1(
34527 this,
34528 `offsets`,
34529 () => [...new Array(n3)].map((_) => p22.Offset32)
34530 );
34531 }
34532 }
34533 getGlyphDataOffsetAndLength(glyphID) {
34534 let offset3 = this.offsets[glyphID] * this.x2 ? 2 : 1;
34535 let nextOffset = this.offsets[glyphID + 1] * this.x2 ? 2 : 1;
34536 return { offset: offset3, length: nextOffset - offset3 };
34537 }
34538 };
34539 var loca$1 = Object.freeze({ __proto__: null, loca });
34540 var prep = class extends SimpleTable {
34541 constructor(dict, dataview) {
34542 const { p: p22 } = super(dict, dataview);
34543 lazy$1(
34544 this,
34545 `instructions`,
34546 () => [...new Array(dict.length)].map((_) => p22.uint8)
34547 );
34548 }
34549 };
34550 var prep$1 = Object.freeze({ __proto__: null, prep });
34551 var CFF = class extends SimpleTable {
34552 constructor(dict, dataview) {
34553 const { p: p22 } = super(dict, dataview);
34554 lazy$1(this, `data`, () => p22.readBytes());
34555 }
34556 };
34557 var CFF$1 = Object.freeze({ __proto__: null, CFF });
34558 var CFF2 = class extends SimpleTable {
34559 constructor(dict, dataview) {
34560 const { p: p22 } = super(dict, dataview);
34561 lazy$1(this, `data`, () => p22.readBytes());
34562 }
34563 };
34564 var CFF2$1 = Object.freeze({ __proto__: null, CFF2 });
34565 var VORG = class extends SimpleTable {
34566 constructor(dict, dataview) {
34567 const { p: p22 } = super(dict, dataview);
34568 this.majorVersion = p22.uint16;
34569 this.minorVersion = p22.uint16;
34570 this.defaultVertOriginY = p22.int16;
34571 this.numVertOriginYMetrics = p22.uint16;
34572 lazy$1(
34573 this,
34574 `vertORiginYMetrics`,
34575 () => [...new Array(this.numVertOriginYMetrics)].map(
34576 (_) => new VertOriginYMetric(p22)
34577 )
34578 );
34579 }
34580 };
34581 var VertOriginYMetric = class {
34582 constructor(p22) {
34583 this.glyphIndex = p22.uint16;
34584 this.vertOriginY = p22.int16;
34585 }
34586 };
34587 var VORG$1 = Object.freeze({ __proto__: null, VORG });
34588 var BitmapSize = class {
34589 constructor(p22) {
34590 this.indexSubTableArrayOffset = p22.Offset32;
34591 this.indexTablesSize = p22.uint32;
34592 this.numberofIndexSubTables = p22.uint32;
34593 this.colorRef = p22.uint32;
34594 this.hori = new SbitLineMetrics(p22);
34595 this.vert = new SbitLineMetrics(p22);
34596 this.startGlyphIndex = p22.uint16;
34597 this.endGlyphIndex = p22.uint16;
34598 this.ppemX = p22.uint8;
34599 this.ppemY = p22.uint8;
34600 this.bitDepth = p22.uint8;
34601 this.flags = p22.int8;
34602 }
34603 };
34604 var BitmapScale = class {
34605 constructor(p22) {
34606 this.hori = new SbitLineMetrics(p22);
34607 this.vert = new SbitLineMetrics(p22);
34608 this.ppemX = p22.uint8;
34609 this.ppemY = p22.uint8;
34610 this.substitutePpemX = p22.uint8;
34611 this.substitutePpemY = p22.uint8;
34612 }
34613 };
34614 var SbitLineMetrics = class {
34615 constructor(p22) {
34616 this.ascender = p22.int8;
34617 this.descender = p22.int8;
34618 this.widthMax = p22.uint8;
34619 this.caretSlopeNumerator = p22.int8;
34620 this.caretSlopeDenominator = p22.int8;
34621 this.caretOffset = p22.int8;
34622 this.minOriginSB = p22.int8;
34623 this.minAdvanceSB = p22.int8;
34624 this.maxBeforeBL = p22.int8;
34625 this.minAfterBL = p22.int8;
34626 this.pad1 = p22.int8;
34627 this.pad2 = p22.int8;
34628 }
34629 };
34630 var EBLC = class extends SimpleTable {
34631 constructor(dict, dataview, name2) {
34632 const { p: p22 } = super(dict, dataview, name2);
34633 this.majorVersion = p22.uint16;
34634 this.minorVersion = p22.uint16;
34635 this.numSizes = p22.uint32;
34636 lazy$1(
34637 this,
34638 `bitMapSizes`,
34639 () => [...new Array(this.numSizes)].map(
34640 (_) => new BitmapSize(p22)
34641 )
34642 );
34643 }
34644 };
34645 var EBLC$1 = Object.freeze({ __proto__: null, EBLC });
34646 var EBDT = class extends SimpleTable {
34647 constructor(dict, dataview, name2) {
34648 const { p: p22 } = super(dict, dataview, name2);
34649 this.majorVersion = p22.uint16;
34650 this.minorVersion = p22.uint16;
34651 }
34652 };
34653 var EBDT$1 = Object.freeze({ __proto__: null, EBDT });
34654 var EBSC = class extends SimpleTable {
34655 constructor(dict, dataview) {
34656 const { p: p22 } = super(dict, dataview);
34657 this.majorVersion = p22.uint16;
34658 this.minorVersion = p22.uint16;
34659 this.numSizes = p22.uint32;
34660 lazy$1(
34661 this,
34662 `bitmapScales`,
34663 () => [...new Array(this.numSizes)].map(
34664 (_) => new BitmapScale(p22)
34665 )
34666 );
34667 }
34668 };
34669 var EBSC$1 = Object.freeze({ __proto__: null, EBSC });
34670 var CBLC = class extends EBLC {
34671 constructor(dict, dataview) {
34672 super(dict, dataview, `CBLC`);
34673 }
34674 };
34675 var CBLC$1 = Object.freeze({ __proto__: null, CBLC });
34676 var CBDT = class extends EBDT {
34677 constructor(dict, dataview) {
34678 super(dict, dataview, `CBDT`);
34679 }
34680 };
34681 var CBDT$1 = Object.freeze({ __proto__: null, CBDT });
34682 var sbix = class extends SimpleTable {
34683 constructor(dict, dataview) {
34684 const { p: p22 } = super(dict, dataview);
34685 this.version = p22.uint16;
34686 this.flags = p22.flags(16);
34687 this.numStrikes = p22.uint32;
34688 lazy$1(
34689 this,
34690 `strikeOffsets`,
34691 () => [...new Array(this.numStrikes)].map((_) => p22.Offset32)
34692 );
34693 }
34694 };
34695 var sbix$1 = Object.freeze({ __proto__: null, sbix });
34696 var COLR = class extends SimpleTable {
34697 constructor(dict, dataview) {
34698 const { p: p22 } = super(dict, dataview);
34699 this.version = p22.uint16;
34700 this.numBaseGlyphRecords = p22.uint16;
34701 this.baseGlyphRecordsOffset = p22.Offset32;
34702 this.layerRecordsOffset = p22.Offset32;
34703 this.numLayerRecords = p22.uint16;
34704 }
34705 getBaseGlyphRecord(glyphID) {
34706 let start2 = this.tableStart + this.baseGlyphRecordsOffset;
34707 this.parser.currentPosition = start2;
34708 let first = new BaseGlyphRecord(this.parser);
34709 let firstID = first.gID;
34710 let end = this.tableStart + this.layerRecordsOffset - 6;
34711 this.parser.currentPosition = end;
34712 let last = new BaseGlyphRecord(this.parser);
34713 let lastID = last.gID;
34714 if (firstID === glyphID) return first;
34715 if (lastID === glyphID) return last;
34716 while (true) {
34717 if (start2 === end) break;
34718 let mid = start2 + (end - start2) / 12;
34719 this.parser.currentPosition = mid;
34720 let middle = new BaseGlyphRecord(this.parser);
34721 let midID = middle.gID;
34722 if (midID === glyphID) return middle;
34723 else if (midID > glyphID) {
34724 end = mid;
34725 } else if (midID < glyphID) {
34726 start2 = mid;
34727 }
34728 }
34729 return false;
34730 }
34731 getLayers(glyphID) {
34732 let record = this.getBaseGlyphRecord(glyphID);
34733 this.parser.currentPosition = this.tableStart + this.layerRecordsOffset + 4 * record.firstLayerIndex;
34734 return [...new Array(record.numLayers)].map(
34735 (_) => new LayerRecord(p)
34736 );
34737 }
34738 };
34739 var BaseGlyphRecord = class {
34740 constructor(p22) {
34741 this.gID = p22.uint16;
34742 this.firstLayerIndex = p22.uint16;
34743 this.numLayers = p22.uint16;
34744 }
34745 };
34746 var LayerRecord = class {
34747 constructor(p22) {
34748 this.gID = p22.uint16;
34749 this.paletteIndex = p22.uint16;
34750 }
34751 };
34752 var COLR$1 = Object.freeze({ __proto__: null, COLR });
34753 var CPAL = class extends SimpleTable {
34754 constructor(dict, dataview) {
34755 const { p: p22 } = super(dict, dataview);
34756 this.version = p22.uint16;
34757 this.numPaletteEntries = p22.uint16;
34758 const numPalettes = this.numPalettes = p22.uint16;
34759 this.numColorRecords = p22.uint16;
34760 this.offsetFirstColorRecord = p22.Offset32;
34761 this.colorRecordIndices = [...new Array(this.numPalettes)].map(
34762 (_) => p22.uint16
34763 );
34764 lazy$1(this, `colorRecords`, () => {
34765 p22.currentPosition = this.tableStart + this.offsetFirstColorRecord;
34766 return [...new Array(this.numColorRecords)].map(
34767 (_) => new ColorRecord(p22)
34768 );
34769 });
34770 if (this.version === 1) {
34771 this.offsetPaletteTypeArray = p22.Offset32;
34772 this.offsetPaletteLabelArray = p22.Offset32;
34773 this.offsetPaletteEntryLabelArray = p22.Offset32;
34774 lazy$1(this, `paletteTypeArray`, () => {
34775 p22.currentPosition = this.tableStart + this.offsetPaletteTypeArray;
34776 return new PaletteTypeArray(p22, numPalettes);
34777 });
34778 lazy$1(this, `paletteLabelArray`, () => {
34779 p22.currentPosition = this.tableStart + this.offsetPaletteLabelArray;
34780 return new PaletteLabelsArray(p22, numPalettes);
34781 });
34782 lazy$1(this, `paletteEntryLabelArray`, () => {
34783 p22.currentPosition = this.tableStart + this.offsetPaletteEntryLabelArray;
34784 return new PaletteEntryLabelArray(p22, numPalettes);
34785 });
34786 }
34787 }
34788 };
34789 var ColorRecord = class {
34790 constructor(p22) {
34791 this.blue = p22.uint8;
34792 this.green = p22.uint8;
34793 this.red = p22.uint8;
34794 this.alpha = p22.uint8;
34795 }
34796 };
34797 var PaletteTypeArray = class {
34798 constructor(p22, numPalettes) {
34799 this.paletteTypes = [...new Array(numPalettes)].map(
34800 (_) => p22.uint32
34801 );
34802 }
34803 };
34804 var PaletteLabelsArray = class {
34805 constructor(p22, numPalettes) {
34806 this.paletteLabels = [...new Array(numPalettes)].map(
34807 (_) => p22.uint16
34808 );
34809 }
34810 };
34811 var PaletteEntryLabelArray = class {
34812 constructor(p22, numPalettes) {
34813 this.paletteEntryLabels = [...new Array(numPalettes)].map(
34814 (_) => p22.uint16
34815 );
34816 }
34817 };
34818 var CPAL$1 = Object.freeze({ __proto__: null, CPAL });
34819 var DSIG = class extends SimpleTable {
34820 constructor(dict, dataview) {
34821 const { p: p22 } = super(dict, dataview);
34822 this.version = p22.uint32;
34823 this.numSignatures = p22.uint16;
34824 this.flags = p22.uint16;
34825 this.signatureRecords = [...new Array(this.numSignatures)].map(
34826 (_) => new SignatureRecord(p22)
34827 );
34828 }
34829 getData(signatureID) {
34830 const record = this.signatureRecords[signatureID];
34831 this.parser.currentPosition = this.tableStart + record.offset;
34832 return new SignatureBlockFormat1(this.parser);
34833 }
34834 };
34835 var SignatureRecord = class {
34836 constructor(p22) {
34837 this.format = p22.uint32;
34838 this.length = p22.uint32;
34839 this.offset = p22.Offset32;
34840 }
34841 };
34842 var SignatureBlockFormat1 = class {
34843 constructor(p22) {
34844 p22.uint16;
34845 p22.uint16;
34846 this.signatureLength = p22.uint32;
34847 this.signature = p22.readBytes(this.signatureLength);
34848 }
34849 };
34850 var DSIG$1 = Object.freeze({ __proto__: null, DSIG });
34851 var hdmx = class extends SimpleTable {
34852 constructor(dict, dataview, tables) {
34853 const { p: p22 } = super(dict, dataview);
34854 const numGlyphs = tables.hmtx.numGlyphs;
34855 this.version = p22.uint16;
34856 this.numRecords = p22.int16;
34857 this.sizeDeviceRecord = p22.int32;
34858 this.records = [...new Array(numRecords)].map(
34859 (_) => new DeviceRecord(p22, numGlyphs)
34860 );
34861 }
34862 };
34863 var DeviceRecord = class {
34864 constructor(p22, numGlyphs) {
34865 this.pixelSize = p22.uint8;
34866 this.maxWidth = p22.uint8;
34867 this.widths = p22.readBytes(numGlyphs);
34868 }
34869 };
34870 var hdmx$1 = Object.freeze({ __proto__: null, hdmx });
34871 var kern = class extends SimpleTable {
34872 constructor(dict, dataview) {
34873 const { p: p22 } = super(dict, dataview);
34874 this.version = p22.uint16;
34875 this.nTables = p22.uint16;
34876 lazy$1(this, `tables`, () => {
34877 let offset3 = this.tableStart + 4;
34878 const tables = [];
34879 for (let i3 = 0; i3 < this.nTables; i3++) {
34880 p22.currentPosition = offset3;
34881 let subtable = new KernSubTable(p22);
34882 tables.push(subtable);
34883 offset3 += subtable;
34884 }
34885 return tables;
34886 });
34887 }
34888 };
34889 var KernSubTable = class {
34890 constructor(p22) {
34891 this.version = p22.uint16;
34892 this.length = p22.uint16;
34893 this.coverage = p22.flags(8);
34894 this.format = p22.uint8;
34895 if (this.format === 0) {
34896 this.nPairs = p22.uint16;
34897 this.searchRange = p22.uint16;
34898 this.entrySelector = p22.uint16;
34899 this.rangeShift = p22.uint16;
34900 lazy$1(
34901 this,
34902 `pairs`,
34903 () => [...new Array(this.nPairs)].map((_) => new Pair(p22))
34904 );
34905 }
34906 if (this.format === 2) {
34907 console.warn(
34908 `Kern subtable format 2 is not supported: this parser currently only parses universal table data.`
34909 );
34910 }
34911 }
34912 get horizontal() {
34913 return this.coverage[0];
34914 }
34915 get minimum() {
34916 return this.coverage[1];
34917 }
34918 get crossstream() {
34919 return this.coverage[2];
34920 }
34921 get override() {
34922 return this.coverage[3];
34923 }
34924 };
34925 var Pair = class {
34926 constructor(p22) {
34927 this.left = p22.uint16;
34928 this.right = p22.uint16;
34929 this.value = p22.fword;
34930 }
34931 };
34932 var kern$1 = Object.freeze({ __proto__: null, kern });
34933 var LTSH = class extends SimpleTable {
34934 constructor(dict, dataview) {
34935 const { p: p22 } = super(dict, dataview);
34936 this.version = p22.uint16;
34937 this.numGlyphs = p22.uint16;
34938 this.yPels = p22.readBytes(this.numGlyphs);
34939 }
34940 };
34941 var LTSH$1 = Object.freeze({ __proto__: null, LTSH });
34942 var MERG = class extends SimpleTable {
34943 constructor(dict, dataview) {
34944 const { p: p22 } = super(dict, dataview);
34945 this.version = p22.uint16;
34946 this.mergeClassCount = p22.uint16;
34947 this.mergeDataOffset = p22.Offset16;
34948 this.classDefCount = p22.uint16;
34949 this.offsetToClassDefOffsets = p22.Offset16;
34950 lazy$1(
34951 this,
34952 `mergeEntryMatrix`,
34953 () => [...new Array(this.mergeClassCount)].map(
34954 (_) => p22.readBytes(this.mergeClassCount)
34955 )
34956 );
34957 console.warn(`Full MERG parsing is currently not supported.`);
34958 console.warn(
34959 `If you need this table parsed, please file an issue, or better yet, a PR.`
34960 );
34961 }
34962 };
34963 var MERG$1 = Object.freeze({ __proto__: null, MERG });
34964 var meta = class extends SimpleTable {
34965 constructor(dict, dataview) {
34966 const { p: p22 } = super(dict, dataview);
34967 this.version = p22.uint32;
34968 this.flags = p22.uint32;
34969 p22.uint32;
34970 this.dataMapsCount = p22.uint32;
34971 this.dataMaps = [...new Array(this.dataMapsCount)].map(
34972 (_) => new DataMap(this.tableStart, p22)
34973 );
34974 }
34975 };
34976 var DataMap = class {
34977 constructor(tableStart, p22) {
34978 this.tableStart = tableStart;
34979 this.parser = p22;
34980 this.tag = p22.tag;
34981 this.dataOffset = p22.Offset32;
34982 this.dataLength = p22.uint32;
34983 }
34984 getData() {
34985 this.parser.currentField = this.tableStart + this.dataOffset;
34986 return this.parser.readBytes(this.dataLength);
34987 }
34988 };
34989 var meta$1 = Object.freeze({ __proto__: null, meta });
34990 var PCLT = class extends SimpleTable {
34991 constructor(dict, dataview) {
34992 super(dict, dataview);
34993 console.warn(
34994 `This font uses a PCLT table, which is currently not supported by this parser.`
34995 );
34996 console.warn(
34997 `If you need this table parsed, please file an issue, or better yet, a PR.`
34998 );
34999 }
35000 };
35001 var PCLT$1 = Object.freeze({ __proto__: null, PCLT });
35002 var VDMX = class extends SimpleTable {
35003 constructor(dict, dataview) {
35004 const { p: p22 } = super(dict, dataview);
35005 this.version = p22.uint16;
35006 this.numRecs = p22.uint16;
35007 this.numRatios = p22.uint16;
35008 this.ratRanges = [...new Array(this.numRatios)].map(
35009 (_) => new RatioRange(p22)
35010 );
35011 this.offsets = [...new Array(this.numRatios)].map(
35012 (_) => p22.Offset16
35013 );
35014 this.VDMXGroups = [...new Array(this.numRecs)].map(
35015 (_) => new VDMXGroup(p22)
35016 );
35017 }
35018 };
35019 var RatioRange = class {
35020 constructor(p22) {
35021 this.bCharSet = p22.uint8;
35022 this.xRatio = p22.uint8;
35023 this.yStartRatio = p22.uint8;
35024 this.yEndRatio = p22.uint8;
35025 }
35026 };
35027 var VDMXGroup = class {
35028 constructor(p22) {
35029 this.recs = p22.uint16;
35030 this.startsz = p22.uint8;
35031 this.endsz = p22.uint8;
35032 this.records = [...new Array(this.recs)].map(
35033 (_) => new vTable(p22)
35034 );
35035 }
35036 };
35037 var vTable = class {
35038 constructor(p22) {
35039 this.yPelHeight = p22.uint16;
35040 this.yMax = p22.int16;
35041 this.yMin = p22.int16;
35042 }
35043 };
35044 var VDMX$1 = Object.freeze({ __proto__: null, VDMX });
35045 var vhea = class extends SimpleTable {
35046 constructor(dict, dataview) {
35047 const { p: p22 } = super(dict, dataview);
35048 this.version = p22.fixed;
35049 this.ascent = this.vertTypoAscender = p22.int16;
35050 this.descent = this.vertTypoDescender = p22.int16;
35051 this.lineGap = this.vertTypoLineGap = p22.int16;
35052 this.advanceHeightMax = p22.int16;
35053 this.minTopSideBearing = p22.int16;
35054 this.minBottomSideBearing = p22.int16;
35055 this.yMaxExtent = p22.int16;
35056 this.caretSlopeRise = p22.int16;
35057 this.caretSlopeRun = p22.int16;
35058 this.caretOffset = p22.int16;
35059 this.reserved = p22.int16;
35060 this.reserved = p22.int16;
35061 this.reserved = p22.int16;
35062 this.reserved = p22.int16;
35063 this.metricDataFormat = p22.int16;
35064 this.numOfLongVerMetrics = p22.uint16;
35065 p22.verifyLength();
35066 }
35067 };
35068 var vhea$1 = Object.freeze({ __proto__: null, vhea });
35069 var vmtx = class extends SimpleTable {
35070 constructor(dict, dataview, tables) {
35071 super(dict, dataview);
35072 const numOfLongVerMetrics = tables.vhea.numOfLongVerMetrics;
35073 const numGlyphs = tables.maxp.numGlyphs;
35074 const metricsStart = p.currentPosition;
35075 lazy(this, `vMetrics`, () => {
35076 p.currentPosition = metricsStart;
35077 return [...new Array(numOfLongVerMetrics)].map(
35078 (_) => new LongVertMetric(p.uint16, p.int16)
35079 );
35080 });
35081 if (numOfLongVerMetrics < numGlyphs) {
35082 const tsbStart = metricsStart + numOfLongVerMetrics * 4;
35083 lazy(this, `topSideBearings`, () => {
35084 p.currentPosition = tsbStart;
35085 return [...new Array(numGlyphs - numOfLongVerMetrics)].map(
35086 (_) => p.int16
35087 );
35088 });
35089 }
35090 }
35091 };
35092 var LongVertMetric = class {
35093 constructor(h3, b3) {
35094 this.advanceHeight = h3;
35095 this.topSideBearing = b3;
35096 }
35097 };
35098 var vmtx$1 = Object.freeze({ __proto__: null, vmtx });
35099
35100 // packages/global-styles-ui/build-module/font-library/utils/make-families-from-faces.mjs
35101 var import_components63 = __toESM(require_components(), 1);
35102 var { kebabCase: kebabCase3 } = unlock3(import_components63.privateApis);
35103 function makeFamiliesFromFaces(fontFaces) {
35104 const fontFamiliesObject = fontFaces.reduce(
35105 (acc, item) => {
35106 if (!acc[item.fontFamily]) {
35107 acc[item.fontFamily] = {
35108 name: item.fontFamily,
35109 fontFamily: item.fontFamily,
35110 slug: kebabCase3(item.fontFamily.toLowerCase()),
35111 fontFace: []
35112 };
35113 }
35114 acc[item.fontFamily].fontFace.push(item);
35115 return acc;
35116 },
35117 {}
35118 );
35119 return Object.values(fontFamiliesObject);
35120 }
35121
35122 // packages/global-styles-ui/build-module/font-library/upload-fonts.mjs
35123 var import_jsx_runtime159 = __toESM(require_jsx_runtime(), 1);
35124 function UploadFonts() {
35125 const { installFonts } = (0, import_element63.useContext)(FontLibraryContext);
35126 const [isUploading, setIsUploading] = (0, import_element63.useState)(false);
35127 const [notice, setNotice] = (0, import_element63.useState)(null);
35128 const handleDropZone = (files) => {
35129 handleFilesUpload(files);
35130 };
35131 const onFilesUpload = (event) => {
35132 handleFilesUpload(event.target.files);
35133 };
35134 const handleFilesUpload = async (files) => {
35135 if (!files) {
35136 return;
35137 }
35138 setNotice(null);
35139 setIsUploading(true);
35140 const uniqueFilenames = /* @__PURE__ */ new Set();
35141 const selectedFiles = [...files];
35142 let hasInvalidFiles = false;
35143 const checkFilesPromises = selectedFiles.map(async (file) => {
35144 const isFont = await isFontFile(file);
35145 if (!isFont) {
35146 hasInvalidFiles = true;
35147 return null;
35148 }
35149 if (uniqueFilenames.has(file.name)) {
35150 return null;
35151 }
35152 const fileExtension = (((file.name ?? "").split(".") ?? []).pop() ?? "").toLowerCase();
35153 if (ALLOWED_FILE_EXTENSIONS.includes(fileExtension)) {
35154 uniqueFilenames.add(file.name);
35155 return file;
35156 }
35157 return null;
35158 });
35159 const allowedFiles = (await Promise.all(checkFilesPromises)).filter((file) => null !== file);
35160 if (allowedFiles.length > 0) {
35161 loadFiles(allowedFiles);
35162 } else {
35163 const message2 = hasInvalidFiles ? (0, import_i18n90.__)("Sorry, you are not allowed to upload this file type.") : (0, import_i18n90.__)("No fonts found to install.");
35164 setNotice({
35165 type: "error",
35166 message: message2
35167 });
35168 setIsUploading(false);
35169 }
35170 };
35171 const loadFiles = async (files) => {
35172 const fontFacesLoaded = await Promise.all(
35173 files.map(async (fontFile) => {
35174 const fontFaceData = await getFontFaceMetadata(fontFile);
35175 await loadFontFaceInBrowser(
35176 fontFaceData,
35177 fontFaceData.file,
35178 "all"
35179 );
35180 return fontFaceData;
35181 })
35182 );
35183 handleInstall(fontFacesLoaded);
35184 };
35185 async function isFontFile(file) {
35186 const font2 = new Font("Uploaded Font");
35187 try {
35188 const buffer = await readFileAsArrayBuffer(file);
35189 await font2.fromDataBuffer(buffer, "font");
35190 return true;
35191 } catch (error) {
35192 return false;
35193 }
35194 }
35195 async function readFileAsArrayBuffer(file) {
35196 return new Promise((resolve, reject) => {
35197 const reader = new window.FileReader();
35198 reader.readAsArrayBuffer(file);
35199 reader.onload = () => resolve(reader.result);
35200 reader.onerror = reject;
35201 });
35202 }
35203 const getFontFaceMetadata = async (fontFile) => {
35204 const buffer = await readFileAsArrayBuffer(fontFile);
35205 const fontObj = new Font("Uploaded Font");
35206 fontObj.fromDataBuffer(buffer, fontFile.name);
35207 const onloadEvent = await new Promise(
35208 (resolve) => fontObj.onload = resolve
35209 );
35210 const font2 = onloadEvent.detail.font;
35211 const { name: name2 } = font2.opentype.tables;
35212 const fontName = name2.get(16) || name2.get(1);
35213 const isItalic = name2.get(2).toLowerCase().includes("italic");
35214 const fontWeight = font2.opentype.tables["OS/2"].usWeightClass || "normal";
35215 const isVariable = !!font2.opentype.tables.fvar;
35216 const weightAxis = isVariable && font2.opentype.tables.fvar.axes.find(
35217 ({ tag }) => tag === "wght"
35218 );
35219 const weightRange = weightAxis ? `${weightAxis.minValue} ${weightAxis.maxValue}` : null;
35220 return {
35221 file: fontFile,
35222 fontFamily: fontName,
35223 fontStyle: isItalic ? "italic" : "normal",
35224 fontWeight: weightRange || fontWeight
35225 };
35226 };
35227 const handleInstall = async (fontFaces) => {
35228 const fontFamilies = makeFamiliesFromFaces(fontFaces);
35229 try {
35230 await installFonts(fontFamilies);
35231 setNotice({
35232 type: "success",
35233 message: (0, import_i18n90.__)("Fonts were installed successfully.")
35234 });
35235 } catch (error) {
35236 const typedError = error;
35237 setNotice({
35238 type: "error",
35239 message: typedError.message,
35240 errors: typedError?.installationErrors
35241 });
35242 }
35243 setIsUploading(false);
35244 };
35245 return /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
35246 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_components64.DropZone, { onFilesDrop: handleDropZone }),
35247 /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(import_components64.__experimentalVStack, { className: "font-library__local-fonts", justify: "start", children: [
35248 notice && /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(
35249 import_components64.Notice,
35250 {
35251 status: notice.type,
35252 __unstableHTML: true,
35253 onRemove: () => setNotice(null),
35254 children: [
35255 notice.message,
35256 notice.errors && /* @__PURE__ */ (0, import_jsx_runtime159.jsx)("ul", { children: notice.errors.map((error, index2) => /* @__PURE__ */ (0, import_jsx_runtime159.jsx)("li", { children: error }, index2)) })
35257 ]
35258 }
35259 ),
35260 isUploading && /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_components64.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)("div", { className: "font-library__upload-area", children: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_components64.ProgressBar, {}) }) }),
35261 !isUploading && /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
35262 import_components64.FormFileUpload,
35263 {
35264 accept: ALLOWED_FILE_EXTENSIONS.map(
35265 (ext) => `.${ext}`
35266 ).join(","),
35267 multiple: true,
35268 onChange: onFilesUpload,
35269 render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
35270 import_components64.Button,
35271 {
35272 __next40pxDefaultSize: true,
35273 className: "font-library__upload-area",
35274 onClick: openFileDialog,
35275 children: (0, import_i18n90.__)("Upload font")
35276 }
35277 )
35278 }
35279 ),
35280 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(import_components64.__experimentalText, { className: "font-library__upload-area__text", children: (0, import_i18n90.__)(
35281 "Uploaded fonts appear in your library and can be used in your theme. Supported formats: .ttf, .otf, .woff, and .woff2."
35282 ) })
35283 ] })
35284 ] });
35285 }
35286 var upload_fonts_default = UploadFonts;
35287
35288 // packages/global-styles-ui/build-module/font-library/modal.mjs
35289 var import_jsx_runtime160 = __toESM(require_jsx_runtime(), 1);
35290 var { Tabs } = unlock3(import_components65.privateApis);
35291 var DEFAULT_TAB = {
35292 id: "installed-fonts",
35293 title: (0, import_i18n91._x)("Library", "Font library")
35294 };
35295 var UPLOAD_TAB = {
35296 id: "upload-fonts",
35297 title: (0, import_i18n91._x)("Upload", "noun")
35298 };
35299 var tabsFromCollections = (collections) => collections.map(({ slug, name: name2 }) => ({
35300 id: slug,
35301 title: collections.length === 1 && slug === "google-fonts" ? (0, import_i18n91.__)("Install Fonts") : name2
35302 }));
35303 function FontLibraryModal({
35304 onRequestClose,
35305 defaultTabId = "installed-fonts"
35306 }) {
35307 const { records: collections = [] } = (0, import_core_data45.useEntityRecords)("root", "fontCollection", {
35308 _fields: "slug,name,description"
35309 });
35310 const canUserCreate = (0, import_data63.useSelect)((select6) => {
35311 return select6(import_core_data45.store).canUser("create", {
35312 kind: "postType",
35313 name: "wp_font_family"
35314 });
35315 }, []);
35316 const tabs = [DEFAULT_TAB];
35317 if (canUserCreate) {
35318 tabs.push(UPLOAD_TAB);
35319 tabs.push(...tabsFromCollections(collections || []));
35320 }
35321 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
35322 import_components65.Modal,
35323 {
35324 title: (0, import_i18n91.__)("Fonts"),
35325 onRequestClose,
35326 isFullScreen: true,
35327 className: "font-library-modal",
35328 children: /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)(Tabs, { defaultTabId, children: [
35329 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)("div", { className: "font-library-modal__tablist-container", children: /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(Tabs.TabList, { children: tabs.map(({ id, title }) => /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(Tabs.Tab, { tabId: id, children: title }, id)) }) }),
35330 tabs.map(({ id }) => {
35331 let contents;
35332 switch (id) {
35333 case "upload-fonts":
35334 contents = /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(upload_fonts_default, {});
35335 break;
35336 case "installed-fonts":
35337 contents = /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(installed_fonts_default, {});
35338 break;
35339 default:
35340 contents = /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(font_collection_default, { slug: id });
35341 }
35342 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
35343 Tabs.TabPanel,
35344 {
35345 tabId: id,
35346 focusable: false,
35347 className: "font-library-modal__tab-panel",
35348 children: contents
35349 },
35350 id
35351 );
35352 })
35353 ] })
35354 }
35355 );
35356 }
35357 var modal_default = FontLibraryModal;
35358
35359 // packages/global-styles-ui/build-module/font-family-item.mjs
35360 var import_i18n92 = __toESM(require_i18n(), 1);
35361 var import_components66 = __toESM(require_components(), 1);
35362 var import_element64 = __toESM(require_element(), 1);
35363 var import_jsx_runtime161 = __toESM(require_jsx_runtime(), 1);
35364 function FontFamilyItem({ font: font2 }) {
35365 const { handleSetLibraryFontSelected, setModalTabOpen } = (0, import_element64.useContext)(FontLibraryContext);
35366 const variantsCount = font2?.fontFace?.length || 1;
35367 const handleClick = () => {
35368 handleSetLibraryFontSelected?.(font2);
35369 setModalTabOpen?.("installed-fonts");
35370 };
35371 const previewStyle = getFamilyPreviewStyle(font2);
35372 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_components66.__experimentalItem, { onClick: handleClick, children: /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(import_components66.__experimentalHStack, { justify: "space-between", children: [
35373 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_components66.FlexItem, { style: previewStyle, children: font2.name }),
35374 /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_components66.FlexItem, { className: "global-styles-ui-screen-typography__font-variants-count", children: (0, import_i18n92.sprintf)(
35375 /* translators: %d: Number of font variants. */
35376 (0, import_i18n92._n)("%d variant", "%d variants", variantsCount),
35377 variantsCount
35378 ) })
35379 ] }) });
35380 }
35381 var font_family_item_default = FontFamilyItem;
35382
35383 // packages/global-styles-ui/build-module/font-families.mjs
35384 var import_jsx_runtime162 = __toESM(require_jsx_runtime(), 1);
35385 function mapFontsWithSource(fonts, source) {
35386 return fonts ? fonts.map((f3) => setUIValuesNeeded(f3, { source })) : [];
35387 }
35388 function FontFamiliesInner() {
35389 const { baseCustomFonts, modalTabOpen, setModalTabOpen } = (0, import_element65.useContext)(FontLibraryContext);
35390 const [fontFamilies] = useSetting("typography.fontFamilies");
35391 const [baseFontFamilies] = useSetting(
35392 "typography.fontFamilies",
35393 void 0,
35394 "base"
35395 );
35396 const themeFonts = mapFontsWithSource(fontFamilies?.theme, "theme");
35397 const customFonts = mapFontsWithSource(fontFamilies?.custom, "custom");
35398 const activeFonts = [...themeFonts, ...customFonts].sort(
35399 (a3, b3) => a3.name.localeCompare(b3.name)
35400 );
35401 const hasFonts = 0 < activeFonts.length;
35402 const hasInstalledFonts = hasFonts || baseFontFamilies?.theme?.length > 0 || (baseCustomFonts?.length ?? 0) > 0;
35403 return /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_jsx_runtime162.Fragment, { children: [
35404 !!modalTabOpen && /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
35405 modal_default,
35406 {
35407 onRequestClose: () => setModalTabOpen?.(""),
35408 defaultTabId: modalTabOpen
35409 }
35410 ),
35411 /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_components67.__experimentalVStack, { spacing: 2, children: [
35412 /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_components67.__experimentalHStack, { justify: "space-between", children: [
35413 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Subtitle, { level: 3, children: (0, import_i18n93.__)("Fonts") }),
35414 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
35415 import_components67.Button,
35416 {
35417 onClick: () => setModalTabOpen?.("installed-fonts"),
35418 label: (0, import_i18n93.__)("Manage fonts"),
35419 icon: settings_default,
35420 size: "small"
35421 }
35422 )
35423 ] }),
35424 activeFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_jsx_runtime162.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components67.__experimentalItemGroup, { size: "large", isBordered: true, isSeparated: true, children: activeFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
35425 font_family_item_default,
35426 {
35427 font: font2
35428 },
35429 font2.slug
35430 )) }) }),
35431 !hasFonts && /* @__PURE__ */ (0, import_jsx_runtime162.jsxs)(import_jsx_runtime162.Fragment, { children: [
35432 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_components67.__experimentalText, { as: "p", children: hasInstalledFonts ? (0, import_i18n93.__)("No fonts activated.") : (0, import_i18n93.__)("No fonts installed.") }),
35433 /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(
35434 import_components67.Button,
35435 {
35436 className: "global-styles-ui-font-families__manage-fonts",
35437 variant: "secondary",
35438 __next40pxDefaultSize: true,
35439 onClick: () => {
35440 setModalTabOpen?.(
35441 hasInstalledFonts ? "installed-fonts" : "upload-fonts"
35442 );
35443 },
35444 children: hasInstalledFonts ? (0, import_i18n93.__)("Manage fonts") : (0, import_i18n93.__)("Add fonts")
35445 }
35446 )
35447 ] })
35448 ] })
35449 ] });
35450 }
35451 function FontFamilies({ ...props }) {
35452 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(context_default, { children: /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(FontFamiliesInner, { ...props }) });
35453 }
35454
35455 // packages/global-styles-ui/build-module/font-sizes/font-sizes-count.mjs
35456 var import_i18n94 = __toESM(require_i18n(), 1);
35457 var import_components68 = __toESM(require_components(), 1);
35458 var import_jsx_runtime163 = __toESM(require_jsx_runtime(), 1);
35459 function FontSizes() {
35460 return /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(import_components68.__experimentalVStack, { spacing: 2, children: [
35461 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components68.__experimentalHStack, { justify: "space-between", children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(Subtitle, { level: 3, children: (0, import_i18n94.__)("Font Sizes") }) }),
35462 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components68.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(NavigationButtonAsItem, { path: "/typography/font-sizes", children: /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)(import_components68.__experimentalHStack, { direction: "row", children: [
35463 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components68.FlexItem, { children: (0, import_i18n94.__)("Font size presets") }),
35464 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(icon_default, { icon: (0, import_i18n94.isRTL)() ? chevron_left_default : chevron_right_default })
35465 ] }) }) })
35466 ] });
35467 }
35468 var font_sizes_count_default = FontSizes;
35469
35470 // packages/global-styles-ui/build-module/screen-typography.mjs
35471 var import_jsx_runtime164 = __toESM(require_jsx_runtime(), 1);
35472 function ScreenTypography() {
35473 const { fontLibraryEnabled } = (0, import_element66.useContext)(GlobalStylesContext);
35474 return /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(import_jsx_runtime164.Fragment, { children: [
35475 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
35476 ScreenHeader,
35477 {
35478 title: (0, import_i18n95.__)("Typography"),
35479 description: (0, import_i18n95.__)(
35480 "Available fonts, typographic styles, and the application of those styles."
35481 )
35482 }
35483 ),
35484 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(ScreenBody, { children: /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(import_components69.__experimentalVStack, { spacing: 7, children: [
35485 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(TypographyVariations, { title: (0, import_i18n95.__)("Typesets") }),
35486 fontLibraryEnabled && /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(FontFamilies, {}),
35487 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(typography_elements_default, {}),
35488 /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(font_sizes_count_default, {})
35489 ] }) })
35490 ] });
35491 }
35492 var screen_typography_default = ScreenTypography;
35493
35494 // packages/global-styles-ui/build-module/screen-typography-element.mjs
35495 var import_i18n96 = __toESM(require_i18n(), 1);
35496 var import_components70 = __toESM(require_components(), 1);
35497 var import_element67 = __toESM(require_element(), 1);
35498
35499 // packages/global-styles-ui/build-module/typography-panel.mjs
35500 var import_block_editor23 = __toESM(require_block_editor(), 1);
35501 var import_jsx_runtime165 = __toESM(require_jsx_runtime(), 1);
35502 var { useSettingsForBlockElement: useSettingsForBlockElement4, TypographyPanel: StylesTypographyPanel2 } = unlock3(import_block_editor23.privateApis);
35503 function TypographyPanel({
35504 element,
35505 headingLevel
35506 }) {
35507 let prefixParts = [];
35508 if (element === "heading") {
35509 prefixParts = prefixParts.concat(["elements", headingLevel]);
35510 } else if (element && element !== "text") {
35511 prefixParts = prefixParts.concat(["elements", element]);
35512 }
35513 const prefix2 = prefixParts.join(".");
35514 const [style] = useStyle(prefix2, "", "user", false);
35515 const [inheritedStyle, setStyle2] = useStyle(
35516 prefix2,
35517 "",
35518 "merged",
35519 false
35520 );
35521 const [rawSettings] = useSetting("");
35522 const usedElement = element === "heading" ? headingLevel : element;
35523 const settings = useSettingsForBlockElement4(
35524 rawSettings,
35525 void 0,
35526 usedElement
35527 );
35528 return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
35529 StylesTypographyPanel2,
35530 {
35531 inheritedValue: inheritedStyle,
35532 value: style,
35533 onChange: setStyle2,
35534 settings
35535 }
35536 );
35537 }
35538
35539 // packages/global-styles-ui/build-module/typography-preview.mjs
35540 var import_jsx_runtime166 = __toESM(require_jsx_runtime(), 1);
35541 function TypographyPreview({
35542 name: name2,
35543 element,
35544 headingLevel
35545 }) {
35546 let prefix2 = "";
35547 if (element === "heading") {
35548 prefix2 = `elements.${headingLevel}.`;
35549 } else if (element && element !== "text") {
35550 prefix2 = `elements.${element}.`;
35551 }
35552 const [fontFamily] = useStyle(prefix2 + "typography.fontFamily", name2);
35553 const [gradientValue] = useStyle(prefix2 + "color.gradient", name2);
35554 const [backgroundColor] = useStyle(prefix2 + "color.background", name2);
35555 const [fallbackBackgroundColor] = useStyle("color.background");
35556 const [color] = useStyle(prefix2 + "color.text", name2);
35557 const [fontSize] = useStyle(prefix2 + "typography.fontSize", name2);
35558 const [fontStyle] = useStyle(prefix2 + "typography.fontStyle", name2);
35559 const [fontWeight] = useStyle(prefix2 + "typography.fontWeight", name2);
35560 const [letterSpacing] = useStyle(
35561 prefix2 + "typography.letterSpacing",
35562 name2
35563 );
35564 const extraStyles = element === "link" ? {
35565 textDecoration: "underline"
35566 } : {};
35567 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
35568 "div",
35569 {
35570 className: "global-styles-ui-typography-preview",
35571 style: {
35572 fontFamily: fontFamily ?? "serif",
35573 background: gradientValue ?? backgroundColor ?? fallbackBackgroundColor,
35574 color,
35575 fontSize,
35576 fontStyle,
35577 fontWeight,
35578 letterSpacing,
35579 ...extraStyles
35580 },
35581 children: "Aa"
35582 }
35583 );
35584 }
35585
35586 // packages/global-styles-ui/build-module/screen-typography-element.mjs
35587 var import_jsx_runtime167 = __toESM(require_jsx_runtime(), 1);
35588 var elements = {
35589 text: {
35590 description: (0, import_i18n96.__)("Manage the fonts used on the site."),
35591 title: (0, import_i18n96.__)("Text")
35592 },
35593 link: {
35594 description: (0, import_i18n96.__)("Manage the fonts and typography used on the links."),
35595 title: (0, import_i18n96.__)("Links")
35596 },
35597 heading: {
35598 description: (0, import_i18n96.__)("Manage the fonts and typography used on headings."),
35599 title: (0, import_i18n96.__)("Headings")
35600 },
35601 caption: {
35602 description: (0, import_i18n96.__)("Manage the fonts and typography used on captions."),
35603 title: (0, import_i18n96.__)("Captions")
35604 },
35605 button: {
35606 description: (0, import_i18n96.__)("Manage the fonts and typography used on buttons."),
35607 title: (0, import_i18n96.__)("Buttons")
35608 }
35609 };
35610 function ScreenTypographyElement({ element }) {
35611 const [headingLevel, setHeadingLevel] = (0, import_element67.useState)("heading");
35612 return /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(import_jsx_runtime167.Fragment, { children: [
35613 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
35614 ScreenHeader,
35615 {
35616 title: elements[element].title,
35617 description: elements[element].description
35618 }
35619 ),
35620 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(import_components70.__experimentalSpacer, { marginX: 4, children: /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
35621 TypographyPreview,
35622 {
35623 element,
35624 headingLevel
35625 }
35626 ) }),
35627 element === "heading" && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(import_components70.__experimentalSpacer, { marginX: 4, marginBottom: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(
35628 import_components70.__experimentalToggleGroupControl,
35629 {
35630 label: (0, import_i18n96.__)("Select heading level"),
35631 hideLabelFromVision: true,
35632 value: headingLevel,
35633 onChange: (value) => setHeadingLevel(value),
35634 isBlock: true,
35635 size: "__unstable-large",
35636 children: [
35637 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
35638 import_components70.__experimentalToggleGroupControlOption,
35639 {
35640 value: "heading",
35641 showTooltip: true,
35642 "aria-label": (0, import_i18n96.__)("All headings"),
35643 label: (0, import_i18n96._x)("All", "heading levels")
35644 }
35645 ),
35646 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
35647 import_components70.__experimentalToggleGroupControlOption,
35648 {
35649 value: "h1",
35650 showTooltip: true,
35651 "aria-label": (0, import_i18n96.__)("Heading 1"),
35652 label: (0, import_i18n96.__)("H1")
35653 }
35654 ),
35655 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
35656 import_components70.__experimentalToggleGroupControlOption,
35657 {
35658 value: "h2",
35659 showTooltip: true,
35660 "aria-label": (0, import_i18n96.__)("Heading 2"),
35661 label: (0, import_i18n96.__)("H2")
35662 }
35663 ),
35664 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
35665 import_components70.__experimentalToggleGroupControlOption,
35666 {
35667 value: "h3",
35668 showTooltip: true,
35669 "aria-label": (0, import_i18n96.__)("Heading 3"),
35670 label: (0, import_i18n96.__)("H3")
35671 }
35672 ),
35673 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
35674 import_components70.__experimentalToggleGroupControlOption,
35675 {
35676 value: "h4",
35677 showTooltip: true,
35678 "aria-label": (0, import_i18n96.__)("Heading 4"),
35679 label: (0, import_i18n96.__)("H4")
35680 }
35681 ),
35682 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
35683 import_components70.__experimentalToggleGroupControlOption,
35684 {
35685 value: "h5",
35686 showTooltip: true,
35687 "aria-label": (0, import_i18n96.__)("Heading 5"),
35688 label: (0, import_i18n96.__)("H5")
35689 }
35690 ),
35691 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
35692 import_components70.__experimentalToggleGroupControlOption,
35693 {
35694 value: "h6",
35695 showTooltip: true,
35696 "aria-label": (0, import_i18n96.__)("Heading 6"),
35697 label: (0, import_i18n96.__)("H6")
35698 }
35699 )
35700 ]
35701 }
35702 ) }),
35703 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
35704 TypographyPanel,
35705 {
35706 element,
35707 headingLevel
35708 }
35709 )
35710 ] });
35711 }
35712 var screen_typography_element_default = ScreenTypographyElement;
35713
35714 // packages/global-styles-ui/build-module/screen-colors.mjs
35715 var import_i18n98 = __toESM(require_i18n(), 1);
35716 var import_components73 = __toESM(require_components(), 1);
35717 var import_block_editor24 = __toESM(require_block_editor(), 1);
35718
35719 // packages/global-styles-ui/build-module/palette.mjs
35720 var import_components72 = __toESM(require_components(), 1);
35721 var import_i18n97 = __toESM(require_i18n(), 1);
35722 var import_element68 = __toESM(require_element(), 1);
35723
35724 // packages/global-styles-ui/build-module/color-indicator-wrapper.mjs
35725 var import_components71 = __toESM(require_components(), 1);
35726 var import_jsx_runtime168 = __toESM(require_jsx_runtime(), 1);
35727 function ColorIndicatorWrapper({
35728 className,
35729 children,
35730 ...props
35731 }) {
35732 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(
35733 import_components71.Flex,
35734 {
35735 className: clsx_default(
35736 "global-styles-ui__color-indicator-wrapper",
35737 className
35738 ),
35739 ...props,
35740 children
35741 }
35742 );
35743 }
35744 var color_indicator_wrapper_default = ColorIndicatorWrapper;
35745
35746 // packages/global-styles-ui/build-module/palette.mjs
35747 var import_jsx_runtime169 = __toESM(require_jsx_runtime(), 1);
35748 var EMPTY_COLORS = [];
35749 function Palette({ name: name2 }) {
35750 const [customColors] = useSetting("color.palette.custom");
35751 const [themeColors] = useSetting("color.palette.theme");
35752 const [defaultColors] = useSetting("color.palette.default");
35753 const [defaultPaletteEnabled] = useSetting(
35754 "color.defaultPalette",
35755 name2
35756 );
35757 const safeCustomColors = customColors || EMPTY_COLORS;
35758 const safeThemeColors = themeColors || EMPTY_COLORS;
35759 const safeDefaultColors = defaultColors || EMPTY_COLORS;
35760 const safeDefaultPaletteEnabled = defaultPaletteEnabled ?? true;
35761 const colors2 = (0, import_element68.useMemo)(
35762 () => [
35763 ...safeCustomColors,
35764 ...safeThemeColors,
35765 ...safeDefaultColors && safeDefaultPaletteEnabled ? safeDefaultColors : EMPTY_COLORS
35766 ],
35767 [
35768 safeCustomColors,
35769 safeThemeColors,
35770 safeDefaultColors,
35771 safeDefaultPaletteEnabled
35772 ]
35773 );
35774 const screenPath = !name2 ? "/colors/palette" : "/blocks/" + encodeURIComponent(name2) + "/colors/palette";
35775 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_components72.__experimentalVStack, { spacing: 3, children: [
35776 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(Subtitle, { level: 3, children: (0, import_i18n97.__)("Palette") }),
35777 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(import_components72.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(NavigationButtonAsItem, { path: screenPath, children: /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_components72.__experimentalHStack, { direction: "row", children: [
35778 colors2.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_jsx_runtime169.Fragment, { children: [
35779 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(import_components72.__experimentalZStack, { isLayered: false, offset: -8, children: colors2.slice(0, 5).map(({ color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
35780 color_indicator_wrapper_default,
35781 {
35782 children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
35783 import_components72.ColorIndicator,
35784 {
35785 colorValue: color
35786 }
35787 )
35788 },
35789 `${color}-${index2}`
35790 )) }),
35791 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(import_components72.FlexItem, { isBlock: true, children: (0, import_i18n97.__)("Edit palette") })
35792 ] }) : /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(import_components72.FlexItem, { children: (0, import_i18n97.__)("Add colors") }),
35793 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(icon_default, { icon: (0, import_i18n97.isRTL)() ? chevron_left_default : chevron_right_default })
35794 ] }) }) })
35795 ] });
35796 }
35797 var palette_default = Palette;
35798
35799 // packages/global-styles-ui/build-module/screen-colors.mjs
35800 var import_jsx_runtime170 = __toESM(require_jsx_runtime(), 1);
35801 var { useSettingsForBlockElement: useSettingsForBlockElement5, ColorPanel: StylesColorPanel2 } = unlock3(
35802 import_block_editor24.privateApis
35803 );
35804 function ScreenColors() {
35805 const [style, setStyle2] = useStyle(
35806 "",
35807 void 0,
35808 "user",
35809 false
35810 );
35811 const [inheritedStyle] = useStyle(
35812 "",
35813 void 0,
35814 "merged",
35815 false
35816 );
35817 const [rawSettings] = useSetting("");
35818 const settings = useSettingsForBlockElement5(rawSettings);
35819 return /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(import_jsx_runtime170.Fragment, { children: [
35820 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
35821 ScreenHeader,
35822 {
35823 title: (0, import_i18n98.__)("Colors"),
35824 description: (0, import_i18n98.__)(
35825 "Palette colors and the application of those colors on site elements."
35826 )
35827 }
35828 ),
35829 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(ScreenBody, { children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_components73.__experimentalVStack, { spacing: 7, children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(palette_default, {}) }) }),
35830 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
35831 StylesColorPanel2,
35832 {
35833 inheritedValue: inheritedStyle,
35834 value: style,
35835 onChange: setStyle2,
35836 settings
35837 }
35838 )
35839 ] });
35840 }
35841 var screen_colors_default = ScreenColors;
35842
35843 // packages/global-styles-ui/build-module/screen-color-palette.mjs
35844 var import_i18n101 = __toESM(require_i18n(), 1);
35845 var import_components78 = __toESM(require_components(), 1);
35846
35847 // packages/global-styles-ui/build-module/color-palette-panel.mjs
35848 var import_compose12 = __toESM(require_compose(), 1);
35849 var import_components76 = __toESM(require_components(), 1);
35850 var import_i18n99 = __toESM(require_i18n(), 1);
35851
35852 // packages/global-styles-ui/build-module/variations/variations-color.mjs
35853 var import_components75 = __toESM(require_components(), 1);
35854
35855 // packages/global-styles-ui/build-module/preview-colors.mjs
35856 var import_components74 = __toESM(require_components(), 1);
35857
35858 // packages/global-styles-ui/build-module/preset-colors.mjs
35859 var import_jsx_runtime171 = __toESM(require_jsx_runtime(), 1);
35860 function PresetColors() {
35861 const { paletteColors } = useStylesPreviewColors();
35862 return paletteColors.slice(0, 4).map(({ slug, color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
35863 "div",
35864 {
35865 style: {
35866 flexGrow: 1,
35867 height: "100%",
35868 background: color
35869 }
35870 },
35871 `${slug}-${index2}`
35872 ));
35873 }
35874
35875 // packages/global-styles-ui/build-module/preview-colors.mjs
35876 var import_jsx_runtime172 = __toESM(require_jsx_runtime(), 1);
35877 var firstFrameVariants2 = {
35878 start: {
35879 scale: 1,
35880 opacity: 1
35881 },
35882 hover: {
35883 scale: 0,
35884 opacity: 0
35885 }
35886 };
35887 var StylesPreviewColors = ({
35888 label,
35889 isFocused,
35890 withHoverView
35891 }) => {
35892 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
35893 preview_wrapper_default,
35894 {
35895 label,
35896 isFocused,
35897 withHoverView,
35898 children: ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
35899 import_components74.__unstableMotion.div,
35900 {
35901 variants: firstFrameVariants2,
35902 style: {
35903 height: "100%",
35904 overflow: "hidden"
35905 },
35906 children: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
35907 import_components74.__experimentalHStack,
35908 {
35909 spacing: 0,
35910 justify: "center",
35911 style: {
35912 height: "100%",
35913 overflow: "hidden"
35914 },
35915 children: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(PresetColors, {})
35916 }
35917 )
35918 },
35919 key
35920 )
35921 }
35922 );
35923 };
35924 var preview_colors_default = StylesPreviewColors;
35925
35926 // packages/global-styles-ui/build-module/variations/variations-color.mjs
35927 var import_jsx_runtime173 = __toESM(require_jsx_runtime(), 1);
35928 var propertiesToFilter2 = ["color"];
35929 function ColorVariations({
35930 title,
35931 gap = 2
35932 }) {
35933 const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter2);
35934 if (colorVariations?.length <= 1) {
35935 return null;
35936 }
35937 return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(import_components75.__experimentalVStack, { spacing: 3, children: [
35938 title && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(Subtitle, { level: 3, children: title }),
35939 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(import_components75.__experimentalGrid, { gap, children: colorVariations.map((variation, index2) => /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
35940 Variation,
35941 {
35942 variation,
35943 isPill: true,
35944 properties: propertiesToFilter2,
35945 showTooltip: true,
35946 children: () => /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(preview_colors_default, {})
35947 },
35948 index2
35949 )) })
35950 ] });
35951 }
35952
35953 // packages/global-styles-ui/build-module/color-palette-panel.mjs
35954 var import_jsx_runtime174 = __toESM(require_jsx_runtime(), 1);
35955 var mobilePopoverProps = { placement: "bottom-start", offset: 8 };
35956 function ColorPalettePanel({ name: name2 }) {
35957 const [themeColors, setThemeColors] = useSetting(
35958 "color.palette.theme",
35959 name2
35960 );
35961 const [baseThemeColors] = useSetting(
35962 "color.palette.theme",
35963 name2,
35964 "base"
35965 );
35966 const [defaultColors, setDefaultColors] = useSetting(
35967 "color.palette.default",
35968 name2
35969 );
35970 const [baseDefaultColors] = useSetting(
35971 "color.palette.default",
35972 name2,
35973 "base"
35974 );
35975 const [customColors, setCustomColors] = useSetting(
35976 "color.palette.custom",
35977 name2
35978 );
35979 const [defaultPaletteEnabled] = useSetting(
35980 "color.defaultPalette",
35981 name2
35982 );
35983 const isMobileViewport = (0, import_compose12.useViewportMatch)("small", "<");
35984 const popoverProps = isMobileViewport ? mobilePopoverProps : void 0;
35985 const [randomizeThemeColors] = useColorRandomizer(name2);
35986 return /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_components76.__experimentalVStack, { className: "global-styles-ui-color-palette-panel", spacing: 8, children: [
35987 /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_components76.__experimentalVStack, { spacing: 4, children: [
35988 !!themeColors && !!themeColors.length && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
35989 import_components76.__experimentalPaletteEdit,
35990 {
35991 canReset: themeColors !== baseThemeColors,
35992 canOnlyChangeValues: true,
35993 colors: themeColors,
35994 onChange: setThemeColors,
35995 paletteLabel: (0, import_i18n99.__)("Theme"),
35996 paletteLabelHeadingLevel: 3,
35997 popoverProps
35998 }
35999 ),
36000 window.__experimentalEnableColorRandomizer && themeColors?.length > 0 && randomizeThemeColors && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
36001 import_components76.Button,
36002 {
36003 __next40pxDefaultSize: true,
36004 variant: "secondary",
36005 icon: shuffle_default,
36006 onClick: randomizeThemeColors,
36007 children: (0, import_i18n99.__)("Randomize colors")
36008 }
36009 )
36010 ] }),
36011 !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
36012 import_components76.__experimentalPaletteEdit,
36013 {
36014 canReset: defaultColors !== baseDefaultColors,
36015 canOnlyChangeValues: true,
36016 colors: defaultColors,
36017 onChange: setDefaultColors,
36018 paletteLabel: (0, import_i18n99.__)("Default"),
36019 paletteLabelHeadingLevel: 3,
36020 popoverProps
36021 }
36022 ),
36023 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
36024 import_components76.__experimentalPaletteEdit,
36025 {
36026 colors: customColors,
36027 onChange: setCustomColors,
36028 paletteLabel: (0, import_i18n99.__)("Custom"),
36029 paletteLabelHeadingLevel: 3,
36030 slugPrefix: "custom-",
36031 popoverProps
36032 }
36033 ),
36034 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(ColorVariations, { title: (0, import_i18n99.__)("Palettes") })
36035 ] });
36036 }
36037
36038 // packages/global-styles-ui/build-module/gradients-palette-panel.mjs
36039 var import_compose13 = __toESM(require_compose(), 1);
36040 var import_components77 = __toESM(require_components(), 1);
36041 var import_i18n100 = __toESM(require_i18n(), 1);
36042 var import_jsx_runtime175 = __toESM(require_jsx_runtime(), 1);
36043 var mobilePopoverProps2 = { placement: "bottom-start", offset: 8 };
36044 var noop5 = () => {
36045 };
36046 function GradientPalettePanel({
36047 name: name2
36048 }) {
36049 const [themeGradients, setThemeGradients] = useSetting(
36050 "color.gradients.theme",
36051 name2
36052 );
36053 const [baseThemeGradients] = useSetting(
36054 "color.gradients.theme",
36055 name2,
36056 "base"
36057 );
36058 const [defaultGradients, setDefaultGradients] = useSetting(
36059 "color.gradients.default",
36060 name2
36061 );
36062 const [baseDefaultGradients] = useSetting(
36063 "color.gradients.default",
36064 name2,
36065 "base"
36066 );
36067 const [customGradients, setCustomGradients] = useSetting(
36068 "color.gradients.custom",
36069 name2
36070 );
36071 const [defaultPaletteEnabled] = useSetting(
36072 "color.defaultGradients",
36073 name2
36074 );
36075 const [customDuotone] = useSetting("color.duotone.custom") || [];
36076 const [defaultDuotone] = useSetting("color.duotone.default") || [];
36077 const [themeDuotone] = useSetting("color.duotone.theme") || [];
36078 const [defaultDuotoneEnabled] = useSetting("color.defaultDuotone");
36079 const duotonePalette = [
36080 ...customDuotone || [],
36081 ...themeDuotone || [],
36082 ...defaultDuotone && defaultDuotoneEnabled ? defaultDuotone : []
36083 ];
36084 const isMobileViewport = (0, import_compose13.useViewportMatch)("small", "<");
36085 const popoverProps = isMobileViewport ? mobilePopoverProps2 : void 0;
36086 return /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)(
36087 import_components77.__experimentalVStack,
36088 {
36089 className: "global-styles-ui-gradient-palette-panel",
36090 spacing: 8,
36091 children: [
36092 !!themeGradients && !!themeGradients.length && /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(
36093 import_components77.__experimentalPaletteEdit,
36094 {
36095 canReset: themeGradients !== baseThemeGradients,
36096 canOnlyChangeValues: true,
36097 gradients: themeGradients,
36098 onChange: setThemeGradients,
36099 paletteLabel: (0, import_i18n100.__)("Theme"),
36100 paletteLabelHeadingLevel: 3,
36101 popoverProps
36102 }
36103 ),
36104 !!defaultGradients && !!defaultGradients.length && !!defaultPaletteEnabled && /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(
36105 import_components77.__experimentalPaletteEdit,
36106 {
36107 canReset: defaultGradients !== baseDefaultGradients,
36108 canOnlyChangeValues: true,
36109 gradients: defaultGradients,
36110 onChange: setDefaultGradients,
36111 paletteLabel: (0, import_i18n100.__)("Default"),
36112 paletteLabelHeadingLevel: 3,
36113 popoverProps
36114 }
36115 ),
36116 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(
36117 import_components77.__experimentalPaletteEdit,
36118 {
36119 gradients: customGradients,
36120 onChange: setCustomGradients,
36121 paletteLabel: (0, import_i18n100.__)("Custom"),
36122 paletteLabelHeadingLevel: 3,
36123 slugPrefix: "custom-",
36124 popoverProps
36125 }
36126 ),
36127 !!duotonePalette && !!duotonePalette.length && /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)("div", { children: [
36128 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(Subtitle, { level: 3, children: (0, import_i18n100.__)("Duotone") }),
36129 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_components77.__experimentalSpacer, { margin: 3 }),
36130 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(
36131 import_components77.DuotonePicker,
36132 {
36133 duotonePalette,
36134 disableCustomDuotone: true,
36135 disableCustomColors: true,
36136 clearable: false,
36137 onChange: noop5,
36138 colorPalette: []
36139 }
36140 )
36141 ] })
36142 ]
36143 }
36144 );
36145 }
36146
36147 // packages/global-styles-ui/build-module/screen-color-palette.mjs
36148 var import_jsx_runtime176 = __toESM(require_jsx_runtime(), 1);
36149 var { Tabs: Tabs2 } = unlock3(import_components78.privateApis);
36150 function ScreenColorPalette({ name: name2 }) {
36151 return /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(import_jsx_runtime176.Fragment, { children: [
36152 /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
36153 ScreenHeader,
36154 {
36155 title: (0, import_i18n101.__)("Edit palette"),
36156 description: (0, import_i18n101.__)(
36157 "The combination of colors used across the site and in color pickers."
36158 )
36159 }
36160 ),
36161 /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(Tabs2, { children: [
36162 /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(Tabs2.TabList, { children: [
36163 /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(Tabs2.Tab, { tabId: "color", children: (0, import_i18n101.__)("Color") }),
36164 /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(Tabs2.Tab, { tabId: "gradient", children: (0, import_i18n101.__)("Gradient") })
36165 ] }),
36166 /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(Tabs2.TabPanel, { tabId: "color", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(ColorPalettePanel, { name: name2 }) }),
36167 /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(Tabs2.TabPanel, { tabId: "gradient", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(GradientPalettePanel, { name: name2 }) })
36168 ] })
36169 ] });
36170 }
36171 var screen_color_palette_default = ScreenColorPalette;
36172
36173 // packages/global-styles-ui/build-module/screen-background.mjs
36174 var import_i18n102 = __toESM(require_i18n(), 1);
36175 var import_block_editor26 = __toESM(require_block_editor(), 1);
36176 var import_components79 = __toESM(require_components(), 1);
36177
36178 // packages/global-styles-ui/build-module/background-panel.mjs
36179 var import_block_editor25 = __toESM(require_block_editor(), 1);
36180 var import_jsx_runtime177 = __toESM(require_jsx_runtime(), 1);
36181 var BACKGROUND_DEFAULT_VALUES = {
36182 backgroundSize: "auto"
36183 };
36184 var { BackgroundPanel: StylesBackgroundPanel2 } = unlock3(
36185 import_block_editor25.privateApis
36186 );
36187 function BackgroundPanel() {
36188 const [style] = useStyle("", void 0, "user", false);
36189 const [inheritedStyle, setStyle2] = useStyle(
36190 "",
36191 void 0,
36192 "merged",
36193 false
36194 );
36195 const [settings] = useSetting("");
36196 return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
36197 StylesBackgroundPanel2,
36198 {
36199 inheritedValue: inheritedStyle,
36200 value: style,
36201 onChange: setStyle2,
36202 settings,
36203 defaultValues: BACKGROUND_DEFAULT_VALUES
36204 }
36205 );
36206 }
36207
36208 // packages/global-styles-ui/build-module/screen-background.mjs
36209 var import_jsx_runtime178 = __toESM(require_jsx_runtime(), 1);
36210 var { useHasBackgroundPanel: useHasBackgroundPanel3 } = unlock3(import_block_editor26.privateApis);
36211 function ScreenBackground() {
36212 const [settings] = useSetting("");
36213 const hasBackgroundPanel = useHasBackgroundPanel3(settings);
36214 return /* @__PURE__ */ (0, import_jsx_runtime178.jsxs)(import_jsx_runtime178.Fragment, { children: [
36215 /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
36216 ScreenHeader,
36217 {
36218 title: (0, import_i18n102.__)("Background"),
36219 description: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(import_components79.__experimentalText, { children: (0, import_i18n102.__)("Set styles for the site's background.") })
36220 }
36221 ),
36222 hasBackgroundPanel && /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(BackgroundPanel, {})
36223 ] });
36224 }
36225 var screen_background_default = ScreenBackground;
36226
36227 // packages/global-styles-ui/build-module/shadows-panel.mjs
36228 var import_components81 = __toESM(require_components(), 1);
36229 var import_i18n104 = __toESM(require_i18n(), 1);
36230 var import_element69 = __toESM(require_element(), 1);
36231
36232 // packages/global-styles-ui/build-module/confirm-reset-shadow-dialog.mjs
36233 var import_components80 = __toESM(require_components(), 1);
36234 var import_i18n103 = __toESM(require_i18n(), 1);
36235 var import_jsx_runtime179 = __toESM(require_jsx_runtime(), 1);
36236 function ConfirmResetShadowDialog({
36237 text,
36238 confirmButtonText,
36239 isOpen,
36240 toggleOpen,
36241 onConfirm
36242 }) {
36243 const handleConfirm = async () => {
36244 toggleOpen();
36245 onConfirm();
36246 };
36247 const handleCancel = () => {
36248 toggleOpen();
36249 };
36250 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
36251 import_components80.__experimentalConfirmDialog,
36252 {
36253 isOpen,
36254 cancelButtonText: (0, import_i18n103.__)("Cancel"),
36255 confirmButtonText,
36256 onCancel: handleCancel,
36257 onConfirm: handleConfirm,
36258 size: "medium",
36259 children: text
36260 }
36261 );
36262 }
36263 var confirm_reset_shadow_dialog_default = ConfirmResetShadowDialog;
36264
36265 // packages/global-styles-ui/build-module/shadows-panel.mjs
36266 var import_jsx_runtime180 = __toESM(require_jsx_runtime(), 1);
36267 var { Menu } = unlock3(import_components81.privateApis);
36268 var defaultShadow = "6px 6px 9px rgba(0, 0, 0, 0.2)";
36269 function ShadowsPanel() {
36270 const [defaultShadows] = useSetting("shadow.presets.default");
36271 const [defaultShadowsEnabled] = useSetting("shadow.defaultPresets");
36272 const [themeShadows] = useSetting("shadow.presets.theme");
36273 const [customShadows, setCustomShadows] = useSetting(
36274 "shadow.presets.custom"
36275 );
36276 const onCreateShadow = (shadow) => {
36277 setCustomShadows([...customShadows || [], shadow]);
36278 };
36279 const handleResetShadows = () => {
36280 setCustomShadows([]);
36281 };
36282 const [isResetDialogOpen, setIsResetDialogOpen] = (0, import_element69.useState)(false);
36283 const toggleResetDialog = () => setIsResetDialogOpen(!isResetDialogOpen);
36284 return /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(import_jsx_runtime180.Fragment, { children: [
36285 isResetDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36286 confirm_reset_shadow_dialog_default,
36287 {
36288 text: (0, import_i18n104.__)(
36289 "Are you sure you want to remove all custom shadows?"
36290 ),
36291 confirmButtonText: (0, import_i18n104.__)("Remove"),
36292 isOpen: isResetDialogOpen,
36293 toggleOpen: toggleResetDialog,
36294 onConfirm: handleResetShadows
36295 }
36296 ),
36297 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36298 ScreenHeader,
36299 {
36300 title: (0, import_i18n104.__)("Shadows"),
36301 description: (0, import_i18n104.__)(
36302 "Manage and create shadow styles for use across the site."
36303 )
36304 }
36305 ),
36306 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(ScreenBody, { children: /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(
36307 import_components81.__experimentalVStack,
36308 {
36309 className: "global-styles-ui__shadows-panel",
36310 spacing: 7,
36311 children: [
36312 defaultShadowsEnabled && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36313 ShadowList,
36314 {
36315 label: (0, import_i18n104.__)("Default"),
36316 shadows: defaultShadows || [],
36317 category: "default"
36318 }
36319 ),
36320 themeShadows && themeShadows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36321 ShadowList,
36322 {
36323 label: (0, import_i18n104.__)("Theme"),
36324 shadows: themeShadows || [],
36325 category: "theme"
36326 }
36327 ),
36328 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36329 ShadowList,
36330 {
36331 label: (0, import_i18n104.__)("Custom"),
36332 shadows: customShadows || [],
36333 category: "custom",
36334 canCreate: true,
36335 onCreate: onCreateShadow,
36336 onReset: toggleResetDialog
36337 }
36338 )
36339 ]
36340 }
36341 ) })
36342 ] });
36343 }
36344 function ShadowList({
36345 label,
36346 shadows,
36347 category,
36348 canCreate,
36349 onCreate,
36350 onReset
36351 }) {
36352 const handleAddShadow = () => {
36353 const newIndex = getNewIndexFromPresets(shadows, "shadow-");
36354 onCreate?.({
36355 name: (0, import_i18n104.sprintf)(
36356 /* translators: %d: is an index for a preset */
36357 (0, import_i18n104.__)("Shadow %d"),
36358 newIndex
36359 ),
36360 shadow: defaultShadow,
36361 slug: `shadow-${newIndex}`
36362 });
36363 };
36364 return /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(import_components81.__experimentalVStack, { spacing: 2, children: [
36365 /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(import_components81.__experimentalHStack, { justify: "space-between", children: [
36366 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(Subtitle, { level: 3, children: label }),
36367 /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(import_components81.FlexItem, { className: "global-styles-ui__shadows-panel__options-container", children: [
36368 canCreate && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36369 import_components81.Button,
36370 {
36371 size: "small",
36372 icon: plus_default,
36373 label: (0, import_i18n104.__)("Add shadow"),
36374 onClick: () => {
36375 handleAddShadow();
36376 }
36377 }
36378 ),
36379 !!shadows?.length && category === "custom" && /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(Menu, { children: [
36380 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36381 Menu.TriggerButton,
36382 {
36383 render: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36384 import_components81.Button,
36385 {
36386 size: "small",
36387 icon: more_vertical_default,
36388 label: (0, import_i18n104.__)("Shadow options")
36389 }
36390 )
36391 }
36392 ),
36393 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(Menu.Item, { onClick: onReset, children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(Menu.ItemLabel, { children: (0, import_i18n104.__)("Remove all custom shadows") }) }) })
36394 ] })
36395 ] })
36396 ] }),
36397 shadows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(import_components81.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: shadows.map((shadow) => /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36398 ShadowItem,
36399 {
36400 shadow,
36401 category
36402 },
36403 shadow.slug
36404 )) })
36405 ] });
36406 }
36407 function ShadowItem({ shadow, category }) {
36408 return /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(
36409 NavigationButtonAsItem,
36410 {
36411 path: `/shadows/edit/${category}/${shadow.slug}`,
36412 children: /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(import_components81.__experimentalHStack, { children: [
36413 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(import_components81.FlexItem, { children: shadow.name }),
36414 /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(icon_default, { icon: (0, import_i18n104.isRTL)() ? chevron_left_default : chevron_right_default })
36415 ] })
36416 }
36417 );
36418 }
36419
36420 // packages/global-styles-ui/build-module/shadows-edit-panel.mjs
36421 var import_components82 = __toESM(require_components(), 1);
36422 var import_i18n105 = __toESM(require_i18n(), 1);
36423 var import_element70 = __toESM(require_element(), 1);
36424
36425 // packages/global-styles-ui/build-module/shadow-utils.mjs
36426 function getShadowParts(shadow) {
36427 const shadowValues = shadow.match(/(?:[^,(]|\([^)]*\))+/g) || [];
36428 return shadowValues.map((value) => value.trim());
36429 }
36430 function shadowStringToObject(shadowValue) {
36431 const defaultShadow2 = {
36432 x: "0",
36433 y: "0",
36434 blur: "0",
36435 spread: "0",
36436 color: "#000",
36437 inset: false
36438 };
36439 if (!shadowValue) {
36440 return defaultShadow2;
36441 }
36442 if (shadowValue.includes("none")) {
36443 return defaultShadow2;
36444 }
36445 const lengthsRegex = /((?:^|\s+)(-?\d*\.?\d+(?:px|%|in|cm|mm|em|rem|ex|pt|pc|vh|vw|vmin|vmax|ch|lh)?)(?=\s|$)(?![^(]*\))){1,4}/g;
36446 const matches = shadowValue.match(lengthsRegex) || [];
36447 if (matches.length !== 1) {
36448 return defaultShadow2;
36449 }
36450 const lengths = matches[0].split(" ").map((value) => value.trim()).filter((value) => value);
36451 if (lengths.length < 2) {
36452 return defaultShadow2;
36453 }
36454 const insets = shadowValue.match(/inset/gi) || [];
36455 if (insets.length > 1) {
36456 return defaultShadow2;
36457 }
36458 const hasInset = insets.length === 1;
36459 let colorString = shadowValue.replace(lengthsRegex, "").trim();
36460 if (hasInset) {
36461 colorString = colorString.replace("inset", "").replace("INSET", "").trim();
36462 }
36463 const colorRegex2 = /^#([0-9a-f]{3}){1,2}$|^#([0-9a-f]{4}){1,2}$|^(?:rgb|hsl)a?\(?[\d*\.?\d+%?,?\/?\s]*\)$/gi;
36464 let colorMatches = (colorString.match(colorRegex2) || []).map((value) => value?.trim()).filter((value) => value);
36465 if (colorMatches.length > 1) {
36466 return defaultShadow2;
36467 } else if (colorMatches.length === 0) {
36468 colorMatches = colorString.trim().split(" ").filter((value) => value);
36469 if (colorMatches.length > 1) {
36470 return defaultShadow2;
36471 }
36472 }
36473 const [x2, y3, blur, spread] = lengths;
36474 return {
36475 x: x2,
36476 y: y3,
36477 blur: blur || defaultShadow2.blur,
36478 spread: spread || defaultShadow2.spread,
36479 inset: hasInset,
36480 color: colorString || defaultShadow2.color
36481 };
36482 }
36483 function shadowObjectToString(shadowObj) {
36484 const shadowString = `${shadowObj.x || "0px"} ${shadowObj.y || "0px"} ${shadowObj.blur || "0px"} ${shadowObj.spread || "0px"}`;
36485 return `${shadowObj.inset ? "inset" : ""} ${shadowString} ${shadowObj.color || ""}`.trim();
36486 }
36487
36488 // packages/global-styles-ui/build-module/shadows-edit-panel.mjs
36489 var import_jsx_runtime181 = __toESM(require_jsx_runtime(), 1);
36490 var { Menu: Menu2 } = unlock3(import_components82.privateApis);
36491 var customShadowMenuItems = [
36492 {
36493 label: (0, import_i18n105.__)("Rename"),
36494 action: "rename"
36495 },
36496 {
36497 label: (0, import_i18n105.__)("Delete"),
36498 action: "delete"
36499 }
36500 ];
36501 var presetShadowMenuItems = [
36502 {
36503 label: (0, import_i18n105.__)("Reset"),
36504 action: "reset"
36505 }
36506 ];
36507 function ShadowsEditPanel() {
36508 const { goBack, params } = (0, import_components82.useNavigator)();
36509 const { category, slug } = params;
36510 const [shadows, setShadows] = useSetting(
36511 `shadow.presets.${category}`
36512 );
36513 (0, import_element70.useEffect)(() => {
36514 const hasCurrentShadow = shadows?.some(
36515 (shadow) => shadow.slug === slug
36516 );
36517 if (!!slug && !hasCurrentShadow) {
36518 goBack();
36519 }
36520 }, [shadows, slug, goBack]);
36521 const [baseShadows] = useSetting(
36522 `shadow.presets.${category}`,
36523 void 0,
36524 "base"
36525 );
36526 const [selectedShadow, setSelectedShadow] = (0, import_element70.useState)(
36527 () => (shadows || []).find((shadow) => shadow.slug === slug)
36528 );
36529 const baseSelectedShadow = (0, import_element70.useMemo)(
36530 () => (baseShadows || []).find((b3) => b3.slug === slug),
36531 [baseShadows, slug]
36532 );
36533 const [isConfirmDialogVisible, setIsConfirmDialogVisible] = (0, import_element70.useState)(false);
36534 const [isRenameModalVisible, setIsRenameModalVisible] = (0, import_element70.useState)(false);
36535 const [shadowName, setShadowName] = (0, import_element70.useState)(
36536 selectedShadow?.name
36537 );
36538 if (!category || !slug) {
36539 return null;
36540 }
36541 const onShadowChange = (shadow) => {
36542 setSelectedShadow({ ...selectedShadow, shadow });
36543 const updatedShadows = shadows.map(
36544 (s3) => s3.slug === slug ? { ...selectedShadow, shadow } : s3
36545 );
36546 setShadows(updatedShadows);
36547 };
36548 const onMenuClick = (action) => {
36549 if (action === "reset") {
36550 const updatedShadows = shadows.map(
36551 (s3) => s3.slug === slug ? baseSelectedShadow : s3
36552 );
36553 setSelectedShadow(baseSelectedShadow);
36554 setShadows(updatedShadows);
36555 } else if (action === "delete") {
36556 setIsConfirmDialogVisible(true);
36557 } else if (action === "rename") {
36558 setIsRenameModalVisible(true);
36559 }
36560 };
36561 const handleShadowDelete = () => {
36562 setShadows(shadows.filter((s3) => s3.slug !== slug));
36563 };
36564 const handleShadowRename = (newName) => {
36565 if (!newName) {
36566 return;
36567 }
36568 const updatedShadows = shadows.map(
36569 (s3) => s3.slug === slug ? { ...selectedShadow, name: newName } : s3
36570 );
36571 setSelectedShadow({ ...selectedShadow, name: newName });
36572 setShadows(updatedShadows);
36573 };
36574 return !selectedShadow ? /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(ScreenHeader, { title: "" }) : /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(import_jsx_runtime181.Fragment, { children: [
36575 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(import_components82.__experimentalHStack, { justify: "space-between", children: [
36576 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(ScreenHeader, { title: selectedShadow.name }),
36577 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components82.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components82.__experimentalSpacer, { marginTop: 2, marginBottom: 0, paddingX: 4, children: /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(Menu2, { children: [
36578 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36579 Menu2.TriggerButton,
36580 {
36581 render: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36582 import_components82.Button,
36583 {
36584 size: "small",
36585 icon: more_vertical_default,
36586 label: (0, import_i18n105.__)("Menu")
36587 }
36588 )
36589 }
36590 ),
36591 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(Menu2.Popover, { children: (category === "custom" ? customShadowMenuItems : presetShadowMenuItems).map((item) => /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36592 Menu2.Item,
36593 {
36594 onClick: () => onMenuClick(item.action),
36595 disabled: item.action === "reset" && selectedShadow.shadow === baseSelectedShadow?.shadow,
36596 children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(Menu2.ItemLabel, { children: item.label })
36597 },
36598 item.action
36599 )) })
36600 ] }) }) })
36601 ] }),
36602 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(ScreenBody, { children: [
36603 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(ShadowsPreview, { shadow: selectedShadow.shadow }),
36604 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36605 ShadowEditor,
36606 {
36607 shadow: selectedShadow.shadow,
36608 onChange: onShadowChange
36609 }
36610 )
36611 ] }),
36612 isConfirmDialogVisible && /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36613 import_components82.__experimentalConfirmDialog,
36614 {
36615 isOpen: true,
36616 onConfirm: () => {
36617 handleShadowDelete();
36618 setIsConfirmDialogVisible(false);
36619 },
36620 onCancel: () => {
36621 setIsConfirmDialogVisible(false);
36622 },
36623 confirmButtonText: (0, import_i18n105.__)("Delete"),
36624 size: "medium",
36625 children: (0, import_i18n105.sprintf)(
36626 /* translators: %s: Name of the shadow preset. */
36627 (0, import_i18n105.__)(
36628 'Are you sure you want to delete "%s" shadow preset?'
36629 ),
36630 selectedShadow.name
36631 )
36632 }
36633 ),
36634 isRenameModalVisible && /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36635 import_components82.Modal,
36636 {
36637 title: (0, import_i18n105.__)("Rename"),
36638 onRequestClose: () => setIsRenameModalVisible(false),
36639 size: "small",
36640 children: /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(
36641 "form",
36642 {
36643 onSubmit: (event) => {
36644 event.preventDefault();
36645 handleShadowRename(shadowName);
36646 setIsRenameModalVisible(false);
36647 },
36648 children: [
36649 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36650 import_components82.__experimentalInputControl,
36651 {
36652 __next40pxDefaultSize: true,
36653 autoComplete: "off",
36654 label: (0, import_i18n105.__)("Name"),
36655 placeholder: (0, import_i18n105.__)("Shadow name"),
36656 value: shadowName ?? "",
36657 onChange: setShadowName
36658 }
36659 ),
36660 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components82.__experimentalSpacer, { marginBottom: 6 }),
36661 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(
36662 import_components82.Flex,
36663 {
36664 className: "block-editor-shadow-edit-modal__actions",
36665 justify: "flex-end",
36666 expanded: false,
36667 children: [
36668 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components82.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36669 import_components82.Button,
36670 {
36671 __next40pxDefaultSize: true,
36672 variant: "tertiary",
36673 onClick: () => setIsRenameModalVisible(false),
36674 children: (0, import_i18n105.__)("Cancel")
36675 }
36676 ) }),
36677 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components82.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36678 import_components82.Button,
36679 {
36680 __next40pxDefaultSize: true,
36681 variant: "primary",
36682 type: "submit",
36683 children: (0, import_i18n105.__)("Save")
36684 }
36685 ) })
36686 ]
36687 }
36688 )
36689 ]
36690 }
36691 )
36692 }
36693 )
36694 ] });
36695 }
36696 function ShadowsPreview({ shadow }) {
36697 const shadowStyle = {
36698 boxShadow: shadow
36699 };
36700 return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components82.__experimentalSpacer, { marginBottom: 4, marginTop: -2, children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36701 import_components82.__experimentalHStack,
36702 {
36703 alignment: "center",
36704 justify: "center",
36705 className: "global-styles-ui__shadow-preview-panel",
36706 children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36707 "div",
36708 {
36709 className: "global-styles-ui__shadow-preview-block",
36710 style: shadowStyle
36711 }
36712 )
36713 }
36714 ) });
36715 }
36716 function ShadowEditor({ shadow, onChange }) {
36717 const addShadowButtonRef = (0, import_element70.useRef)(null);
36718 const shadowParts = (0, import_element70.useMemo)(() => getShadowParts(shadow), [shadow]);
36719 const onChangeShadowPart = (index2, part) => {
36720 const newShadowParts = [...shadowParts];
36721 newShadowParts[index2] = part;
36722 onChange(newShadowParts.join(", "));
36723 };
36724 const onAddShadowPart = () => {
36725 onChange([...shadowParts, defaultShadow].join(", "));
36726 };
36727 const onRemoveShadowPart = (index2) => {
36728 onChange(shadowParts.filter((p4, i3) => i3 !== index2).join(", "));
36729 addShadowButtonRef.current?.focus();
36730 };
36731 return /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(import_jsx_runtime181.Fragment, { children: [
36732 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components82.__experimentalVStack, { spacing: 2, children: /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(import_components82.__experimentalHStack, { justify: "space-between", children: [
36733 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(Subtitle, { level: 3, children: (0, import_i18n105.__)("Shadows") }),
36734 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components82.FlexItem, { className: "global-styles-ui__shadows-panel__options-container", children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36735 import_components82.Button,
36736 {
36737 size: "small",
36738 icon: plus_default,
36739 label: (0, import_i18n105.__)("Add shadow"),
36740 onClick: () => {
36741 onAddShadowPart();
36742 },
36743 ref: addShadowButtonRef
36744 }
36745 ) })
36746 ] }) }),
36747 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components82.__experimentalSpacer, {}),
36748 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components82.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: shadowParts.map((part, index2) => /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36749 ShadowItem2,
36750 {
36751 shadow: part,
36752 onChange: (value) => onChangeShadowPart(index2, value),
36753 canRemove: shadowParts.length > 1,
36754 onRemove: () => onRemoveShadowPart(index2)
36755 },
36756 index2
36757 )) })
36758 ] });
36759 }
36760 function ShadowItem2({
36761 shadow,
36762 onChange,
36763 canRemove,
36764 onRemove
36765 }) {
36766 const popoverProps = {
36767 placement: "left-start",
36768 offset: 36,
36769 shift: true
36770 };
36771 const shadowObj = (0, import_element70.useMemo)(
36772 () => shadowStringToObject(shadow),
36773 [shadow]
36774 );
36775 const onShadowChange = (newShadow) => {
36776 onChange(shadowObjectToString(newShadow));
36777 };
36778 return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36779 import_components82.Dropdown,
36780 {
36781 popoverProps,
36782 className: "global-styles-ui__shadow-editor__dropdown",
36783 renderToggle: ({ onToggle, isOpen }) => {
36784 const toggleProps = {
36785 onClick: onToggle,
36786 className: clsx_default(
36787 "global-styles-ui__shadow-editor__dropdown-toggle",
36788 { "is-open": isOpen }
36789 ),
36790 "aria-expanded": isOpen
36791 };
36792 const removeButtonProps = {
36793 onClick: () => {
36794 if (isOpen) {
36795 onToggle();
36796 }
36797 onRemove();
36798 },
36799 className: clsx_default(
36800 "global-styles-ui__shadow-editor__remove-button",
36801 { "is-open": isOpen }
36802 ),
36803 label: (0, import_i18n105.__)("Remove shadow")
36804 };
36805 return /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(import_jsx_runtime181.Fragment, { children: [
36806 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36807 import_components82.Button,
36808 {
36809 __next40pxDefaultSize: true,
36810 icon: shadow_default,
36811 ...toggleProps,
36812 children: shadowObj.inset ? (0, import_i18n105.__)("Inner shadow") : (0, import_i18n105.__)("Drop shadow")
36813 }
36814 ),
36815 canRemove && /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36816 import_components82.Button,
36817 {
36818 size: "small",
36819 icon: reset_default,
36820 ...removeButtonProps
36821 }
36822 )
36823 ] });
36824 },
36825 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36826 import_components82.__experimentalDropdownContentWrapper,
36827 {
36828 paddingSize: "medium",
36829 className: "global-styles-ui__shadow-editor__dropdown-content",
36830 children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36831 ShadowPopover,
36832 {
36833 shadowObj,
36834 onChange: onShadowChange
36835 }
36836 )
36837 }
36838 )
36839 }
36840 );
36841 }
36842 function ShadowPopover({ shadowObj, onChange }) {
36843 const __experimentalIsRenderedInSidebar = true;
36844 const enableAlpha = true;
36845 const onShadowChange = (key, value) => {
36846 const newShadow = {
36847 ...shadowObj,
36848 [key]: value
36849 };
36850 onChange(newShadow);
36851 };
36852 return /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(import_components82.__experimentalVStack, { spacing: 4, className: "global-styles-ui__shadow-editor-panel", children: [
36853 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36854 import_components82.ColorPalette,
36855 {
36856 clearable: false,
36857 enableAlpha,
36858 __experimentalIsRenderedInSidebar,
36859 value: shadowObj.color,
36860 onChange: (value) => onShadowChange("color", value)
36861 }
36862 ),
36863 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(
36864 import_components82.__experimentalToggleGroupControl,
36865 {
36866 label: (0, import_i18n105.__)("Shadow Type"),
36867 value: shadowObj.inset ? "inset" : "outset",
36868 isBlock: true,
36869 onChange: (value) => onShadowChange("inset", value === "inset"),
36870 hideLabelFromVision: true,
36871 __next40pxDefaultSize: true,
36872 children: [
36873 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36874 import_components82.__experimentalToggleGroupControlOption,
36875 {
36876 value: "outset",
36877 label: (0, import_i18n105.__)("Outset")
36878 }
36879 ),
36880 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36881 import_components82.__experimentalToggleGroupControlOption,
36882 {
36883 value: "inset",
36884 label: (0, import_i18n105.__)("Inset")
36885 }
36886 )
36887 ]
36888 }
36889 ),
36890 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(import_components82.__experimentalGrid, { columns: 2, gap: 4, children: [
36891 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36892 ShadowInputControl,
36893 {
36894 label: (0, import_i18n105.__)("X Position"),
36895 value: shadowObj.x,
36896 onChange: (value) => onShadowChange("x", value)
36897 }
36898 ),
36899 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36900 ShadowInputControl,
36901 {
36902 label: (0, import_i18n105.__)("Y Position"),
36903 value: shadowObj.y,
36904 onChange: (value) => onShadowChange("y", value)
36905 }
36906 ),
36907 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36908 ShadowInputControl,
36909 {
36910 label: (0, import_i18n105.__)("Blur"),
36911 value: shadowObj.blur,
36912 onChange: (value) => onShadowChange("blur", value)
36913 }
36914 ),
36915 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36916 ShadowInputControl,
36917 {
36918 label: (0, import_i18n105.__)("Spread"),
36919 value: shadowObj.spread,
36920 onChange: (value) => onShadowChange("spread", value)
36921 }
36922 )
36923 ] })
36924 ] });
36925 }
36926 function ShadowInputControl({
36927 label,
36928 value,
36929 onChange
36930 }) {
36931 const onValueChange = (next) => {
36932 const isNumeric = next !== void 0 && !isNaN(parseFloat(next));
36933 const nextValue = isNumeric ? next : "0px";
36934 onChange(nextValue);
36935 };
36936 return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(
36937 import_components82.__experimentalUnitControl,
36938 {
36939 label,
36940 __next40pxDefaultSize: true,
36941 value,
36942 onChange: onValueChange
36943 }
36944 );
36945 }
36946
36947 // packages/global-styles-ui/build-module/screen-shadows.mjs
36948 var import_jsx_runtime182 = __toESM(require_jsx_runtime(), 1);
36949 function ScreenShadows() {
36950 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(ShadowsPanel, {});
36951 }
36952 function ScreenShadowsEdit() {
36953 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(ShadowsEditPanel, {});
36954 }
36955
36956 // packages/global-styles-ui/build-module/screen-layout.mjs
36957 var import_i18n106 = __toESM(require_i18n(), 1);
36958 var import_block_editor28 = __toESM(require_block_editor(), 1);
36959
36960 // packages/global-styles-ui/build-module/dimensions-panel.mjs
36961 var import_block_editor27 = __toESM(require_block_editor(), 1);
36962 var import_element71 = __toESM(require_element(), 1);
36963 var import_jsx_runtime183 = __toESM(require_jsx_runtime(), 1);
36964 var { useSettingsForBlockElement: useSettingsForBlockElement6, DimensionsPanel: StylesDimensionsPanel2 } = unlock3(import_block_editor27.privateApis);
36965 var DEFAULT_CONTROLS = {
36966 contentSize: true,
36967 wideSize: true,
36968 padding: true,
36969 margin: true,
36970 blockGap: true,
36971 height: true,
36972 minHeight: true,
36973 width: true,
36974 childLayout: false
36975 };
36976 function DimensionsPanel() {
36977 const [style] = useStyle("", void 0, "user", false);
36978 const [inheritedStyle, setStyle2] = useStyle(
36979 "",
36980 void 0,
36981 "merged",
36982 false
36983 );
36984 const [userSettings] = useSetting("", void 0, "user");
36985 const [rawSettings, setSettings] = useSetting("");
36986 const settings = useSettingsForBlockElement6(rawSettings);
36987 const inheritedStyleWithLayout = (0, import_element71.useMemo)(() => {
36988 return {
36989 ...inheritedStyle,
36990 layout: settings.layout
36991 };
36992 }, [inheritedStyle, settings.layout]);
36993 const styleWithLayout = (0, import_element71.useMemo)(() => {
36994 return {
36995 ...style,
36996 layout: userSettings.layout
36997 };
36998 }, [style, userSettings.layout]);
36999 const onChange = (newStyle) => {
37000 const updatedStyle = { ...newStyle };
37001 delete updatedStyle.layout;
37002 setStyle2(updatedStyle);
37003 if (newStyle.layout !== userSettings.layout) {
37004 const updatedSettings = {
37005 ...userSettings,
37006 layout: newStyle.layout
37007 };
37008 if (updatedSettings.layout?.definitions) {
37009 delete updatedSettings.layout.definitions;
37010 }
37011 setSettings(updatedSettings);
37012 }
37013 };
37014 return /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
37015 StylesDimensionsPanel2,
37016 {
37017 inheritedValue: inheritedStyleWithLayout,
37018 value: styleWithLayout,
37019 onChange,
37020 settings,
37021 includeLayoutControls: true,
37022 defaultControls: DEFAULT_CONTROLS
37023 }
37024 );
37025 }
37026
37027 // packages/global-styles-ui/build-module/screen-layout.mjs
37028 var import_jsx_runtime184 = __toESM(require_jsx_runtime(), 1);
37029 var { useHasDimensionsPanel: useHasDimensionsPanel4, useSettingsForBlockElement: useSettingsForBlockElement7 } = unlock3(
37030 import_block_editor28.privateApis
37031 );
37032 function ScreenLayout() {
37033 const [rawSettings] = useSetting("");
37034 const settings = useSettingsForBlockElement7(rawSettings);
37035 const hasDimensionsPanel = useHasDimensionsPanel4(settings);
37036 return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_jsx_runtime184.Fragment, { children: [
37037 /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(ScreenHeader, { title: (0, import_i18n106.__)("Layout") }),
37038 hasDimensionsPanel && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(DimensionsPanel, {})
37039 ] });
37040 }
37041 var screen_layout_default = ScreenLayout;
37042
37043 // packages/global-styles-ui/build-module/screen-style-variations.mjs
37044 var import_components85 = __toESM(require_components(), 1);
37045 var import_i18n109 = __toESM(require_i18n(), 1);
37046
37047 // packages/global-styles-ui/build-module/style-variations-content.mjs
37048 var import_i18n108 = __toESM(require_i18n(), 1);
37049 var import_components84 = __toESM(require_components(), 1);
37050
37051 // packages/global-styles-ui/build-module/style-variations-container.mjs
37052 var import_core_data46 = __toESM(require_core_data(), 1);
37053 var import_data64 = __toESM(require_data(), 1);
37054 var import_element72 = __toESM(require_element(), 1);
37055 var import_components83 = __toESM(require_components(), 1);
37056 var import_i18n107 = __toESM(require_i18n(), 1);
37057 var import_jsx_runtime185 = __toESM(require_jsx_runtime(), 1);
37058 function StyleVariationsContainer({
37059 gap = 2
37060 }) {
37061 const { user } = (0, import_element72.useContext)(GlobalStylesContext);
37062 const userStyles = user?.styles;
37063 const variations = (0, import_data64.useSelect)((select6) => {
37064 const result = select6(
37065 import_core_data46.store
37066 ).__experimentalGetCurrentThemeGlobalStylesVariations();
37067 return Array.isArray(result) ? result : void 0;
37068 }, []);
37069 const fullStyleVariations = variations?.filter(
37070 (variation) => {
37071 return !isVariationWithProperties(variation, ["color"]) && !isVariationWithProperties(variation, [
37072 "typography",
37073 "spacing"
37074 ]);
37075 }
37076 );
37077 const themeVariations = (0, import_element72.useMemo)(() => {
37078 const withEmptyVariation = [
37079 {
37080 title: (0, import_i18n107.__)("Default"),
37081 settings: {},
37082 styles: {}
37083 },
37084 ...fullStyleVariations ?? []
37085 ];
37086 return [
37087 ...withEmptyVariation.map((variation) => {
37088 const blockStyles = variation?.styles?.blocks ? { ...variation.styles.blocks } : {};
37089 if (userStyles?.blocks) {
37090 Object.keys(userStyles.blocks).forEach((blockName) => {
37091 if (userStyles.blocks?.[blockName]?.css) {
37092 const variationBlockStyles = blockStyles[blockName] || {};
37093 const customCSS = {
37094 css: `${blockStyles[blockName]?.css || ""} ${userStyles.blocks?.[blockName]?.css?.trim() || ""}`
37095 };
37096 blockStyles[blockName] = {
37097 ...variationBlockStyles,
37098 ...customCSS
37099 };
37100 }
37101 });
37102 }
37103 const css = userStyles?.css || variation.styles?.css ? {
37104 css: `${variation.styles?.css || ""} ${userStyles?.css || ""}`
37105 } : {};
37106 const blocks = Object.keys(blockStyles).length > 0 ? { blocks: blockStyles } : {};
37107 const styles = {
37108 ...variation.styles,
37109 ...css,
37110 ...blocks
37111 };
37112 return {
37113 ...variation,
37114 settings: variation.settings ?? {},
37115 styles
37116 };
37117 })
37118 ];
37119 }, [fullStyleVariations, userStyles?.blocks, userStyles?.css]);
37120 if (!fullStyleVariations || fullStyleVariations.length < 1) {
37121 return null;
37122 }
37123 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
37124 import_components83.__experimentalGrid,
37125 {
37126 columns: 2,
37127 className: "global-styles-ui-style-variations-container",
37128 gap,
37129 children: themeVariations.map(
37130 (variation, index2) => /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Variation, { variation, children: (isFocused) => /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
37131 preview_styles_default,
37132 {
37133 label: variation?.title,
37134 withHoverView: true,
37135 isFocused,
37136 variation
37137 }
37138 ) }, index2)
37139 )
37140 }
37141 );
37142 }
37143 var style_variations_container_default = StyleVariationsContainer;
37144
37145 // packages/global-styles-ui/build-module/style-variations-content.mjs
37146 var import_jsx_runtime186 = __toESM(require_jsx_runtime(), 1);
37147 function StyleVariationsContent() {
37148 const gap = 3;
37149 return /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(import_components84.__experimentalVStack, { spacing: 10, className: "global-styles-ui-variation-container", children: [
37150 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(style_variations_container_default, { gap }),
37151 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(ColorVariations, { title: (0, import_i18n108.__)("Color Variations"), gap }),
37152 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(TypographyVariations, { title: (0, import_i18n108.__)("Typography"), gap })
37153 ] });
37154 }
37155
37156 // packages/global-styles-ui/build-module/screen-style-variations.mjs
37157 var import_jsx_runtime187 = __toESM(require_jsx_runtime(), 1);
37158 function ScreenStyleVariations() {
37159 return /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(import_jsx_runtime187.Fragment, { children: [
37160 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
37161 ScreenHeader,
37162 {
37163 title: (0, import_i18n109.__)("Browse styles"),
37164 description: (0, import_i18n109.__)(
37165 "Choose a variation to change the look of the site."
37166 )
37167 }
37168 ),
37169 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
37170 import_components85.Card,
37171 {
37172 size: "small",
37173 isBorderless: true,
37174 className: "global-styles-ui-screen-style-variations",
37175 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components85.CardBody, { children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(StyleVariationsContent, {}) })
37176 }
37177 )
37178 ] });
37179 }
37180 var screen_style_variations_default = ScreenStyleVariations;
37181
37182 // packages/global-styles-ui/build-module/screen-css.mjs
37183 var import_i18n110 = __toESM(require_i18n(), 1);
37184 var import_components86 = __toESM(require_components(), 1);
37185 var import_block_editor29 = __toESM(require_block_editor(), 1);
37186 var import_jsx_runtime188 = __toESM(require_jsx_runtime(), 1);
37187 var { AdvancedPanel: StylesAdvancedPanel2 } = unlock3(import_block_editor29.privateApis);
37188 function ScreenCSS() {
37189 const [style] = useStyle("", void 0, "user", false);
37190 const [inheritedStyle, setStyle2] = useStyle(
37191 "",
37192 void 0,
37193 "merged",
37194 false
37195 );
37196 return /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)(import_jsx_runtime188.Fragment, { children: [
37197 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
37198 ScreenHeader,
37199 {
37200 title: (0, import_i18n110.__)("Additional CSS"),
37201 description: /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)(import_jsx_runtime188.Fragment, { children: [
37202 (0, import_i18n110.__)(
37203 "You can add custom CSS to further customize the appearance and layout of your site."
37204 ),
37205 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)("br", {}),
37206 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
37207 import_components86.ExternalLink,
37208 {
37209 href: (0, import_i18n110.__)(
37210 "https://developer.wordpress.org/advanced-administration/wordpress/css/"
37211 ),
37212 className: "global-styles-ui-screen-css-help-link",
37213 children: (0, import_i18n110.__)("Learn more about CSS")
37214 }
37215 )
37216 ] })
37217 }
37218 ),
37219 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)("div", { className: "global-styles-ui-screen-css", children: /* @__PURE__ */ (0, import_jsx_runtime188.jsx)(
37220 StylesAdvancedPanel2,
37221 {
37222 value: style,
37223 onChange: setStyle2,
37224 inheritedValue: inheritedStyle
37225 }
37226 ) })
37227 ] });
37228 }
37229 var screen_css_default = ScreenCSS;
37230
37231 // packages/global-styles-ui/build-module/screen-revisions/index.mjs
37232 var import_i18n113 = __toESM(require_i18n(), 1);
37233 var import_components89 = __toESM(require_components(), 1);
37234 var import_element74 = __toESM(require_element(), 1);
37235
37236 // packages/global-styles-ui/build-module/screen-revisions/use-global-styles-revisions.mjs
37237 var import_data65 = __toESM(require_data(), 1);
37238 var import_core_data47 = __toESM(require_core_data(), 1);
37239 var import_element73 = __toESM(require_element(), 1);
37240 var SITE_EDITOR_AUTHORS_QUERY = {
37241 per_page: -1,
37242 _fields: "id,name,avatar_urls",
37243 context: "view",
37244 capabilities: ["edit_theme_options"]
37245 };
37246 var DEFAULT_QUERY = { per_page: 100, page: 1 };
37247 var EMPTY_ARRAY6 = [];
37248 function useGlobalStylesRevisions({
37249 query
37250 } = {}) {
37251 const { user: userConfig } = (0, import_element73.useContext)(GlobalStylesContext);
37252 const _query = (0, import_element73.useMemo)(
37253 () => ({ ...DEFAULT_QUERY, ...query }),
37254 [query]
37255 );
37256 const {
37257 authors,
37258 currentUser,
37259 isDirty,
37260 revisions,
37261 isLoadingGlobalStylesRevisions,
37262 revisionsCount
37263 } = (0, import_data65.useSelect)(
37264 (select6) => {
37265 const {
37266 __experimentalGetDirtyEntityRecords,
37267 getCurrentUser,
37268 getUsers,
37269 getRevisions,
37270 __experimentalGetCurrentGlobalStylesId,
37271 getEntityRecord,
37272 // @ts-expect-error
37273 isResolving
37274 } = select6(import_core_data47.store);
37275 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords() || [];
37276 const _currentUser = getCurrentUser();
37277 const _isDirty = dirtyEntityRecords.length > 0;
37278 const globalStylesId = __experimentalGetCurrentGlobalStylesId();
37279 const globalStyles = globalStylesId ? getEntityRecord(
37280 "root",
37281 "globalStyles",
37282 globalStylesId
37283 ) : void 0;
37284 const _revisionsCount = (
37285 // @ts-expect-error - _links is not typed in GlobalStylesRevision
37286 globalStyles?._links?.["version-history"]?.[0]?.count ?? 0
37287 );
37288 const globalStylesRevisions = globalStylesId ? getRevisions(
37289 "root",
37290 "globalStyles",
37291 globalStylesId,
37292 _query
37293 ) || EMPTY_ARRAY6 : EMPTY_ARRAY6;
37294 const _authors = getUsers(SITE_EDITOR_AUTHORS_QUERY) || EMPTY_ARRAY6;
37295 const _isResolving = globalStylesId ? isResolving("getRevisions", [
37296 "root",
37297 "globalStyles",
37298 globalStylesId,
37299 _query
37300 ]) : false;
37301 return {
37302 authors: _authors,
37303 currentUser: _currentUser,
37304 isDirty: _isDirty,
37305 revisions: globalStylesRevisions,
37306 isLoadingGlobalStylesRevisions: _isResolving,
37307 revisionsCount: _revisionsCount
37308 };
37309 },
37310 [_query]
37311 );
37312 return (0, import_element73.useMemo)(() => {
37313 if (!authors.length || isLoadingGlobalStylesRevisions) {
37314 return {
37315 revisions: EMPTY_ARRAY6,
37316 hasUnsavedChanges: isDirty,
37317 isLoading: true,
37318 revisionsCount
37319 };
37320 }
37321 const _modifiedRevisions = revisions.map((revision) => {
37322 return {
37323 ...revision,
37324 author: authors.find(
37325 (author) => author.id === revision.author
37326 )
37327 };
37328 });
37329 const fetchedRevisionsCount = revisions.length;
37330 if (fetchedRevisionsCount) {
37331 if (_modifiedRevisions[0].id !== "unsaved" && _query.page === 1) {
37332 _modifiedRevisions[0].isLatest = true;
37333 }
37334 if (isDirty && userConfig && Object.keys(userConfig).length > 0 && currentUser && _query.page === 1) {
37335 const unsavedRevision = {
37336 id: "unsaved",
37337 styles: userConfig?.styles,
37338 settings: userConfig?.settings,
37339 _links: userConfig?._links,
37340 author: {
37341 name: currentUser?.name || "",
37342 // @ts-expect-error - avatar_urls is not typed in User
37343 avatar_urls: currentUser?.avatar_urls || {}
37344 },
37345 modified: /* @__PURE__ */ new Date()
37346 };
37347 _modifiedRevisions.unshift(unsavedRevision);
37348 }
37349 if (_query.per_page && _query.page === Math.ceil(revisionsCount / _query.per_page)) {
37350 _modifiedRevisions.push({
37351 id: "parent",
37352 styles: {},
37353 settings: {}
37354 });
37355 }
37356 }
37357 return {
37358 revisions: _modifiedRevisions,
37359 hasUnsavedChanges: isDirty,
37360 isLoading: false,
37361 revisionsCount
37362 };
37363 }, [
37364 isDirty,
37365 revisions,
37366 currentUser,
37367 authors,
37368 userConfig,
37369 isLoadingGlobalStylesRevisions,
37370 revisionsCount,
37371 _query.page,
37372 _query.per_page
37373 ]);
37374 }
37375
37376 // packages/global-styles-ui/build-module/screen-revisions/revisions-buttons.mjs
37377 var import_i18n111 = __toESM(require_i18n(), 1);
37378 var import_components87 = __toESM(require_components(), 1);
37379 var import_date5 = __toESM(require_date(), 1);
37380 var import_core_data48 = __toESM(require_core_data(), 1);
37381 var import_data66 = __toESM(require_data(), 1);
37382 var import_keycodes3 = __toESM(require_keycodes(), 1);
37383 var import_jsx_runtime189 = __toESM(require_jsx_runtime(), 1);
37384 var DAY_IN_MILLISECONDS = 60 * 60 * 1e3 * 24;
37385 function ChangesSummary({ revision, previousRevision }) {
37386 const changes = getGlobalStylesChanges(
37387 revision,
37388 previousRevision,
37389 {
37390 maxResults: 7
37391 }
37392 );
37393 if (!changes.length) {
37394 return null;
37395 }
37396 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
37397 "ul",
37398 {
37399 "data-testid": "global-styles-revision-changes",
37400 className: "global-styles-ui-screen-revisions__changes",
37401 children: changes.map((change) => /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("li", { children: change }, change))
37402 }
37403 );
37404 }
37405 function getRevisionLabel(id, authorDisplayName, formattedModifiedDate, areStylesEqual) {
37406 if ("parent" === id) {
37407 return (0, import_i18n111.__)("Reset the styles to the theme defaults");
37408 }
37409 if ("unsaved" === id) {
37410 return (0, import_i18n111.sprintf)(
37411 /* translators: %s: author display name */
37412 (0, import_i18n111.__)("Unsaved changes by %s"),
37413 authorDisplayName
37414 );
37415 }
37416 return areStylesEqual ? (0, import_i18n111.sprintf)(
37417 // translators: 1: author display name. 2: revision creation date.
37418 (0, import_i18n111.__)(
37419 "Changes saved by %1$s on %2$s. This revision matches current editor styles."
37420 ),
37421 authorDisplayName,
37422 formattedModifiedDate
37423 ) : (0, import_i18n111.sprintf)(
37424 // translators: 1: author display name. 2: revision creation date.
37425 (0, import_i18n111.__)("Changes saved by %1$s on %2$s"),
37426 authorDisplayName,
37427 formattedModifiedDate
37428 );
37429 }
37430 function RevisionsButtons({
37431 userRevisions,
37432 selectedRevisionId,
37433 onChange,
37434 canApplyRevision,
37435 onApplyRevision
37436 }) {
37437 const { currentThemeName, currentUser } = (0, import_data66.useSelect)((select6) => {
37438 const { getCurrentTheme, getCurrentUser } = select6(import_core_data48.store);
37439 const currentTheme = getCurrentTheme();
37440 return {
37441 currentThemeName: currentTheme?.name?.rendered || currentTheme?.stylesheet,
37442 currentUser: getCurrentUser()
37443 };
37444 }, []);
37445 const dateNowInMs = (0, import_date5.getDate)(null).getTime();
37446 const { datetimeAbbreviated } = (0, import_date5.getSettings)().formats;
37447 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
37448 import_components87.Composite,
37449 {
37450 orientation: "vertical",
37451 className: "global-styles-ui-screen-revisions__revisions-list",
37452 "aria-label": (0, import_i18n111.__)("Global styles revisions list"),
37453 role: "listbox",
37454 children: userRevisions.map((revision, index2) => {
37455 const { id, author, modified } = revision;
37456 const isUnsaved = "unsaved" === id;
37457 const revisionAuthor = isUnsaved ? currentUser : author;
37458 const authorDisplayName = revisionAuthor?.name || (0, import_i18n111.__)("User");
37459 const authorAvatar = revisionAuthor?.avatar_urls?.["48"];
37460 const isFirstItem = index2 === 0;
37461 const isSelected = selectedRevisionId ? selectedRevisionId === id : isFirstItem;
37462 const areStylesEqual = !canApplyRevision && isSelected;
37463 const isReset = "parent" === id;
37464 const modifiedString = modified instanceof Date ? modified.toISOString() : modified;
37465 const modifiedDate = (0, import_date5.getDate)(modifiedString ?? null);
37466 const displayDate = modifiedString && dateNowInMs - modifiedDate.getTime() > DAY_IN_MILLISECONDS ? (0, import_date5.dateI18n)(datetimeAbbreviated, modifiedDate) : (0, import_date5.humanTimeDiff)(
37467 modifiedString ?? modifiedDate,
37468 void 0
37469 );
37470 const revisionLabel = getRevisionLabel(
37471 id,
37472 authorDisplayName,
37473 (0, import_date5.dateI18n)(datetimeAbbreviated, modifiedDate),
37474 areStylesEqual
37475 );
37476 return /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)(
37477 import_components87.Composite.Item,
37478 {
37479 className: "global-styles-ui-screen-revisions__revision-item",
37480 "aria-current": isSelected,
37481 role: "option",
37482 onKeyDown: (event) => {
37483 const { keyCode } = event;
37484 if (keyCode === import_keycodes3.ENTER || keyCode === import_keycodes3.SPACE) {
37485 onChange(revision);
37486 }
37487 },
37488 onClick: (event) => {
37489 event.preventDefault();
37490 onChange(revision);
37491 },
37492 "aria-selected": isSelected,
37493 "aria-label": revisionLabel,
37494 render: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("div", {}),
37495 children: [
37496 /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", { className: "global-styles-ui-screen-revisions__revision-item-wrapper", children: isReset ? /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)("span", { className: "global-styles-ui-screen-revisions__description", children: [
37497 (0, import_i18n111.__)("Default styles"),
37498 /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", { className: "global-styles-ui-screen-revisions__meta", children: currentThemeName })
37499 ] }) : /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)("span", { className: "global-styles-ui-screen-revisions__description", children: [
37500 isUnsaved ? /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", { className: "global-styles-ui-screen-revisions__date", children: (0, import_i18n111.__)("(Unsaved)") }) : /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
37501 "time",
37502 {
37503 className: "global-styles-ui-screen-revisions__date",
37504 dateTime: modifiedString,
37505 children: displayDate
37506 }
37507 ),
37508 /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)("span", { className: "global-styles-ui-screen-revisions__meta", children: [
37509 /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
37510 "img",
37511 {
37512 alt: authorDisplayName,
37513 src: authorAvatar
37514 }
37515 ),
37516 authorDisplayName
37517 ] }),
37518 isSelected && /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
37519 ChangesSummary,
37520 {
37521 revision,
37522 previousRevision: index2 < userRevisions.length ? userRevisions[index2 + 1] : void 0
37523 }
37524 )
37525 ] }) }),
37526 isSelected && (areStylesEqual ? /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("p", { className: "global-styles-ui-screen-revisions__applied-text", children: (0, import_i18n111.__)(
37527 "These styles are already applied to your site."
37528 ) }) : /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
37529 import_components87.Button,
37530 {
37531 size: "compact",
37532 variant: "primary",
37533 className: "global-styles-ui-screen-revisions__apply-button",
37534 onClick: onApplyRevision,
37535 "aria-label": (0, import_i18n111.__)(
37536 "Apply the selected revision to your site."
37537 ),
37538 children: isReset ? (0, import_i18n111.__)("Reset to defaults") : (0, import_i18n111.__)("Apply")
37539 }
37540 ))
37541 ]
37542 },
37543 id
37544 );
37545 })
37546 }
37547 );
37548 }
37549 var revisions_buttons_default = RevisionsButtons;
37550
37551 // packages/global-styles-ui/build-module/pagination/index.mjs
37552 var import_components88 = __toESM(require_components(), 1);
37553 var import_i18n112 = __toESM(require_i18n(), 1);
37554 var import_jsx_runtime190 = __toESM(require_jsx_runtime(), 1);
37555 function Pagination({
37556 currentPage,
37557 numPages,
37558 changePage,
37559 totalItems,
37560 className,
37561 disabled = false,
37562 buttonVariant = "tertiary",
37563 label = (0, import_i18n112.__)("Pagination")
37564 }) {
37565 return /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(
37566 import_components88.__experimentalHStack,
37567 {
37568 expanded: false,
37569 as: "nav",
37570 "aria-label": label,
37571 spacing: 3,
37572 justify: "flex-start",
37573 className: clsx_default("global-styles-ui-pagination", className),
37574 children: [
37575 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
37576 import_components88.__experimentalText,
37577 {
37578 variant: "muted",
37579 className: "global-styles-ui-pagination__total",
37580 children: (0, import_i18n112.sprintf)(
37581 // translators: %d: Total number of patterns.
37582 (0, import_i18n112._n)("%d item", "%d items", totalItems),
37583 totalItems
37584 )
37585 }
37586 ),
37587 /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(import_components88.__experimentalHStack, { expanded: false, spacing: 1, children: [
37588 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
37589 import_components88.Button,
37590 {
37591 variant: buttonVariant,
37592 onClick: () => changePage(1),
37593 accessibleWhenDisabled: true,
37594 disabled: disabled || currentPage === 1,
37595 label: (0, import_i18n112.__)("First page"),
37596 icon: (0, import_i18n112.isRTL)() ? next_default : previous_default,
37597 size: "compact"
37598 }
37599 ),
37600 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
37601 import_components88.Button,
37602 {
37603 variant: buttonVariant,
37604 onClick: () => changePage(currentPage - 1),
37605 accessibleWhenDisabled: true,
37606 disabled: disabled || currentPage === 1,
37607 label: (0, import_i18n112.__)("Previous page"),
37608 icon: (0, import_i18n112.isRTL)() ? chevron_right_default : chevron_left_default,
37609 size: "compact"
37610 }
37611 )
37612 ] }),
37613 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components88.__experimentalText, { variant: "muted", children: (0, import_i18n112.sprintf)(
37614 // translators: 1: Current page number. 2: Total number of pages.
37615 (0, import_i18n112._x)("%1$d of %2$d", "paging"),
37616 currentPage,
37617 numPages
37618 ) }),
37619 /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(import_components88.__experimentalHStack, { expanded: false, spacing: 1, children: [
37620 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
37621 import_components88.Button,
37622 {
37623 variant: buttonVariant,
37624 onClick: () => changePage(currentPage + 1),
37625 accessibleWhenDisabled: true,
37626 disabled: disabled || currentPage === numPages,
37627 label: (0, import_i18n112.__)("Next page"),
37628 icon: (0, import_i18n112.isRTL)() ? chevron_left_default : chevron_right_default,
37629 size: "compact"
37630 }
37631 ),
37632 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
37633 import_components88.Button,
37634 {
37635 variant: buttonVariant,
37636 onClick: () => changePage(numPages),
37637 accessibleWhenDisabled: true,
37638 disabled: disabled || currentPage === numPages,
37639 label: (0, import_i18n112.__)("Last page"),
37640 icon: (0, import_i18n112.isRTL)() ? previous_default : next_default,
37641 size: "compact"
37642 }
37643 )
37644 ] })
37645 ]
37646 }
37647 );
37648 }
37649
37650 // packages/global-styles-ui/build-module/screen-revisions/index.mjs
37651 var import_jsx_runtime191 = __toESM(require_jsx_runtime(), 1);
37652 var PAGE_SIZE = 10;
37653 function ScreenRevisions({ onClose } = {}) {
37654 const { user: currentEditorGlobalStyles, onChange: setUserConfig } = (0, import_element74.useContext)(GlobalStylesContext);
37655 const { params, goTo } = (0, import_components89.useNavigator)();
37656 const { revisionId: revisionId2 } = params;
37657 const [currentPage, setCurrentPage] = (0, import_element74.useState)(1);
37658 const { revisions, isLoading, hasUnsavedChanges, revisionsCount } = useGlobalStylesRevisions({
37659 query: {
37660 per_page: PAGE_SIZE,
37661 page: currentPage
37662 }
37663 });
37664 const numPages = Math.ceil(revisionsCount / PAGE_SIZE);
37665 const [
37666 isLoadingRevisionWithUnsavedChanges,
37667 setIsLoadingRevisionWithUnsavedChanges
37668 ] = (0, import_element74.useState)(false);
37669 const currentlySelectedRevision = (0, import_element74.useMemo)(() => {
37670 if (!revisionId2) {
37671 return currentEditorGlobalStyles;
37672 }
37673 const revision = revisions.find(
37674 (rev) => String(rev.id) === String(revisionId2)
37675 );
37676 return revision || currentEditorGlobalStyles;
37677 }, [revisionId2, revisions, currentEditorGlobalStyles]);
37678 const selectedRevisionMatchesEditorStyles = areGlobalStylesEqual(
37679 currentlySelectedRevision,
37680 currentEditorGlobalStyles
37681 );
37682 const onCloseRevisions = () => {
37683 if (onClose) {
37684 onClose();
37685 }
37686 };
37687 const restoreRevision2 = (revision) => {
37688 setUserConfig(revision);
37689 setIsLoadingRevisionWithUnsavedChanges(false);
37690 onCloseRevisions();
37691 };
37692 const handleRevisionSelect = (revision) => {
37693 goTo(`/revisions/${revision.id}`);
37694 };
37695 const currentlySelectedRevisionId = (
37696 // @ts-expect-error: revision id is not present in the fallback (default object).
37697 currentlySelectedRevision?.id ?? revisions[0]?.id
37698 );
37699 const isLoadButtonEnabled = !!currentlySelectedRevisionId && currentlySelectedRevisionId !== "unsaved" && !selectedRevisionMatchesEditorStyles;
37700 const hasRevisions = !!revisions.length;
37701 return /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)(import_jsx_runtime191.Fragment, { children: [
37702 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
37703 ScreenHeader,
37704 {
37705 title: revisionsCount ? (0, import_i18n113.sprintf)(
37706 // translators: %d: number of revisions.
37707 (0, import_i18n113.__)("Revisions (%d)"),
37708 revisionsCount
37709 ) : (0, import_i18n113.__)("Revisions"),
37710 description: (0, import_i18n113.__)(
37711 `Click on previously saved styles to preview them. To restore a selected version to the editor, hit "Apply." When you're ready, use the Save button to save your changes.`
37712 ),
37713 onBack: onCloseRevisions
37714 }
37715 ),
37716 !hasRevisions && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(import_components89.Spinner, { className: "global-styles-ui-screen-revisions__loading" }),
37717 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
37718 revisions_buttons_default,
37719 {
37720 onChange: handleRevisionSelect,
37721 selectedRevisionId: currentlySelectedRevisionId,
37722 userRevisions: revisions,
37723 canApplyRevision: isLoadButtonEnabled,
37724 onApplyRevision: () => hasUnsavedChanges ? setIsLoadingRevisionWithUnsavedChanges(true) : restoreRevision2(currentlySelectedRevision)
37725 }
37726 ),
37727 numPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("div", { className: "global-styles-ui-screen-revisions__footer", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
37728 Pagination,
37729 {
37730 className: "global-styles-ui-screen-revisions__pagination",
37731 currentPage,
37732 numPages,
37733 changePage: setCurrentPage,
37734 totalItems: revisionsCount,
37735 disabled: isLoading,
37736 label: (0, import_i18n113.__)("Global Styles pagination")
37737 }
37738 ) }),
37739 isLoadingRevisionWithUnsavedChanges && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
37740 import_components89.__experimentalConfirmDialog,
37741 {
37742 isOpen: isLoadingRevisionWithUnsavedChanges,
37743 confirmButtonText: (0, import_i18n113.__)("Apply"),
37744 onConfirm: () => restoreRevision2(currentlySelectedRevision),
37745 onCancel: () => setIsLoadingRevisionWithUnsavedChanges(false),
37746 size: "medium",
37747 children: (0, import_i18n113.__)(
37748 "Are you sure you want to apply this revision? Any unsaved changes will be lost."
37749 )
37750 }
37751 )
37752 ] });
37753 }
37754 var screen_revisions_default = ScreenRevisions;
37755
37756 // packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs
37757 var import_i18n115 = __toESM(require_i18n(), 1);
37758 var import_components91 = __toESM(require_components(), 1);
37759 var import_element75 = __toESM(require_element(), 1);
37760
37761 // packages/global-styles-ui/build-module/font-sizes/confirm-reset-font-sizes-dialog.mjs
37762 var import_components90 = __toESM(require_components(), 1);
37763 var import_i18n114 = __toESM(require_i18n(), 1);
37764 var import_jsx_runtime192 = __toESM(require_jsx_runtime(), 1);
37765 function ConfirmResetFontSizesDialog({
37766 text,
37767 confirmButtonText,
37768 isOpen,
37769 toggleOpen,
37770 onConfirm
37771 }) {
37772 const handleConfirm = async () => {
37773 toggleOpen();
37774 onConfirm();
37775 };
37776 const handleCancel = () => {
37777 toggleOpen();
37778 };
37779 return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(
37780 import_components90.__experimentalConfirmDialog,
37781 {
37782 isOpen,
37783 cancelButtonText: (0, import_i18n114.__)("Cancel"),
37784 confirmButtonText,
37785 onCancel: handleCancel,
37786 onConfirm: handleConfirm,
37787 size: "medium",
37788 children: text
37789 }
37790 );
37791 }
37792 var confirm_reset_font_sizes_dialog_default = ConfirmResetFontSizesDialog;
37793
37794 // packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs
37795 var import_jsx_runtime193 = __toESM(require_jsx_runtime(), 1);
37796 var { Menu: Menu3 } = unlock3(import_components91.privateApis);
37797 function FontSizeGroup({
37798 label,
37799 origin,
37800 sizes,
37801 handleAddFontSize,
37802 handleResetFontSizes
37803 }) {
37804 const [isResetDialogOpen, setIsResetDialogOpen] = (0, import_element75.useState)(false);
37805 const toggleResetDialog = () => setIsResetDialogOpen(!isResetDialogOpen);
37806 const resetDialogText = origin === "custom" ? (0, import_i18n115.__)(
37807 "Are you sure you want to remove all custom font size presets?"
37808 ) : (0, import_i18n115.__)(
37809 "Are you sure you want to reset all font size presets to their default values?"
37810 );
37811 return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_jsx_runtime193.Fragment, { children: [
37812 handleResetFontSizes && isResetDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
37813 confirm_reset_font_sizes_dialog_default,
37814 {
37815 text: resetDialogText,
37816 confirmButtonText: origin === "custom" ? (0, import_i18n115.__)("Remove") : (0, import_i18n115.__)("Reset"),
37817 isOpen: isResetDialogOpen,
37818 toggleOpen: toggleResetDialog,
37819 onConfirm: handleResetFontSizes
37820 }
37821 ),
37822 /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_components91.__experimentalVStack, { spacing: 4, children: [
37823 /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_components91.__experimentalHStack, { children: [
37824 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(Subtitle, { level: 3, children: label }),
37825 /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_components91.FlexItem, { className: "global-styles-ui__typography-panel__options-container", children: [
37826 origin === "custom" && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
37827 import_components91.Button,
37828 {
37829 label: (0, import_i18n115.__)("Add font size"),
37830 icon: plus_default,
37831 size: "small",
37832 onClick: handleAddFontSize
37833 }
37834 ),
37835 !!handleResetFontSizes && /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(Menu3, { children: [
37836 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
37837 Menu3.TriggerButton,
37838 {
37839 render: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
37840 import_components91.Button,
37841 {
37842 size: "small",
37843 icon: more_vertical_default,
37844 label: (0, import_i18n115.__)(
37845 "Font size presets options"
37846 )
37847 }
37848 )
37849 }
37850 ),
37851 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(Menu3.Item, { onClick: toggleResetDialog, children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(Menu3.ItemLabel, { children: origin === "custom" ? (0, import_i18n115.__)(
37852 "Remove font size presets"
37853 ) : (0, import_i18n115.__)(
37854 "Reset font size presets"
37855 ) }) }) })
37856 ] })
37857 ] })
37858 ] }),
37859 !!sizes.length && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components91.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: sizes.map((size3) => /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
37860 NavigationButtonAsItem,
37861 {
37862 path: `/typography/font-sizes/${origin}/${size3.slug}`,
37863 children: /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_components91.__experimentalHStack, { children: [
37864 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components91.FlexItem, { className: "global-styles-ui-font-size__item", children: size3.name }),
37865 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components91.FlexItem, { display: "flex", children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
37866 icon_default,
37867 {
37868 icon: (0, import_i18n115.isRTL)() ? chevron_left_default : chevron_right_default
37869 }
37870 ) })
37871 ] })
37872 },
37873 size3.slug
37874 )) })
37875 ] })
37876 ] });
37877 }
37878 function FontSizes2() {
37879 const [themeFontSizes, setThemeFontSizes] = useSetting(
37880 "typography.fontSizes.theme"
37881 );
37882 const [baseThemeFontSizes] = useSetting(
37883 "typography.fontSizes.theme",
37884 "base"
37885 );
37886 const [defaultFontSizes, setDefaultFontSizes] = useSetting(
37887 "typography.fontSizes.default"
37888 );
37889 const [baseDefaultFontSizes] = useSetting(
37890 "typography.fontSizes.default",
37891 "base"
37892 );
37893 const [customFontSizes = [], setCustomFontSizes] = useSetting(
37894 "typography.fontSizes.custom"
37895 );
37896 const [defaultFontSizesEnabled] = useSetting(
37897 "typography.defaultFontSizes"
37898 );
37899 const handleAddFontSize = () => {
37900 const index2 = getNewIndexFromPresets(customFontSizes, "custom-");
37901 const newFontSize = {
37902 /* translators: %d: font size index */
37903 name: (0, import_i18n115.sprintf)((0, import_i18n115.__)("New Font Size %d"), index2),
37904 size: "16px",
37905 slug: `custom-${index2}`
37906 };
37907 setCustomFontSizes([...customFontSizes, newFontSize]);
37908 };
37909 const hasSameSizeValues = (arr1, arr2) => arr1.map((item) => item.size).join("") === arr2.map((item) => item.size).join("");
37910 return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_components91.__experimentalVStack, { spacing: 2, children: [
37911 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
37912 ScreenHeader,
37913 {
37914 title: (0, import_i18n115.__)("Font size presets"),
37915 description: (0, import_i18n115.__)(
37916 "Create and edit the presets used for font sizes across the site."
37917 )
37918 }
37919 ),
37920 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components91.__experimentalView, { children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components91.__experimentalSpacer, { paddingX: 4, children: /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_components91.__experimentalVStack, { spacing: 8, children: [
37921 !!themeFontSizes?.length && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
37922 FontSizeGroup,
37923 {
37924 label: (0, import_i18n115.__)("Theme"),
37925 origin: "theme",
37926 sizes: themeFontSizes,
37927 handleAddFontSize,
37928 handleResetFontSizes: hasSameSizeValues(
37929 themeFontSizes,
37930 baseThemeFontSizes
37931 ) ? void 0 : () => setThemeFontSizes(
37932 baseThemeFontSizes
37933 )
37934 }
37935 ),
37936 defaultFontSizesEnabled && !!defaultFontSizes?.length && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
37937 FontSizeGroup,
37938 {
37939 label: (0, import_i18n115.__)("Default"),
37940 origin: "default",
37941 sizes: defaultFontSizes,
37942 handleAddFontSize,
37943 handleResetFontSizes: hasSameSizeValues(
37944 defaultFontSizes,
37945 baseDefaultFontSizes
37946 ) ? void 0 : () => setDefaultFontSizes(
37947 baseDefaultFontSizes
37948 )
37949 }
37950 ),
37951 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
37952 FontSizeGroup,
37953 {
37954 label: (0, import_i18n115.__)("Custom"),
37955 origin: "custom",
37956 sizes: customFontSizes,
37957 handleAddFontSize,
37958 handleResetFontSizes: customFontSizes.length > 0 ? () => setCustomFontSizes([]) : void 0
37959 }
37960 )
37961 ] }) }) })
37962 ] });
37963 }
37964 var font_sizes_default = FontSizes2;
37965
37966 // packages/global-styles-ui/build-module/font-sizes/font-size.mjs
37967 var import_i18n119 = __toESM(require_i18n(), 1);
37968 var import_components95 = __toESM(require_components(), 1);
37969 var import_element77 = __toESM(require_element(), 1);
37970
37971 // packages/global-styles-ui/build-module/font-sizes/font-size-preview.mjs
37972 var import_block_editor30 = __toESM(require_block_editor(), 1);
37973 var import_i18n116 = __toESM(require_i18n(), 1);
37974 var import_jsx_runtime194 = __toESM(require_jsx_runtime(), 1);
37975 function FontSizePreview({ fontSize }) {
37976 const [font2] = useStyle("typography");
37977 const input = typeof fontSize?.fluid === "object" && fontSize?.fluid?.min && fontSize?.fluid?.max ? {
37978 minimumFontSize: fontSize.fluid.min,
37979 maximumFontSize: fontSize.fluid.max
37980 } : {
37981 fontSize: fontSize.size
37982 };
37983 const computedFontSize = (0, import_block_editor30.getComputedFluidTypographyValue)(input);
37984 return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
37985 "div",
37986 {
37987 className: "global-styles-ui-typography-preview",
37988 style: {
37989 fontSize: computedFontSize,
37990 fontFamily: font2?.fontFamily ?? "serif"
37991 },
37992 children: (0, import_i18n116.__)("Aa")
37993 }
37994 );
37995 }
37996 var font_size_preview_default = FontSizePreview;
37997
37998 // packages/global-styles-ui/build-module/font-sizes/confirm-delete-font-size-dialog.mjs
37999 var import_components92 = __toESM(require_components(), 1);
38000 var import_i18n117 = __toESM(require_i18n(), 1);
38001 var import_jsx_runtime195 = __toESM(require_jsx_runtime(), 1);
38002 function ConfirmDeleteFontSizeDialog({
38003 fontSize,
38004 isOpen,
38005 toggleOpen,
38006 handleRemoveFontSize
38007 }) {
38008 const handleConfirm = async () => {
38009 toggleOpen();
38010 handleRemoveFontSize(fontSize);
38011 };
38012 const handleCancel = () => {
38013 toggleOpen();
38014 };
38015 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
38016 import_components92.__experimentalConfirmDialog,
38017 {
38018 isOpen,
38019 cancelButtonText: (0, import_i18n117.__)("Cancel"),
38020 confirmButtonText: (0, import_i18n117.__)("Delete"),
38021 onCancel: handleCancel,
38022 onConfirm: handleConfirm,
38023 size: "medium",
38024 children: fontSize && (0, import_i18n117.sprintf)(
38025 /* translators: %s: Name of the font size preset. */
38026 (0, import_i18n117.__)(
38027 'Are you sure you want to delete "%s" font size preset?'
38028 ),
38029 fontSize.name
38030 )
38031 }
38032 );
38033 }
38034 var confirm_delete_font_size_dialog_default = ConfirmDeleteFontSizeDialog;
38035
38036 // packages/global-styles-ui/build-module/font-sizes/rename-font-size-dialog.mjs
38037 var import_components93 = __toESM(require_components(), 1);
38038 var import_i18n118 = __toESM(require_i18n(), 1);
38039 var import_element76 = __toESM(require_element(), 1);
38040 var import_jsx_runtime196 = __toESM(require_jsx_runtime(), 1);
38041 function RenameFontSizeDialog({
38042 fontSize,
38043 toggleOpen,
38044 handleRename
38045 }) {
38046 const [newName, setNewName] = (0, import_element76.useState)(
38047 fontSize.name
38048 );
38049 const handleConfirm = () => {
38050 if (newName && newName.trim()) {
38051 handleRename(newName);
38052 }
38053 toggleOpen();
38054 };
38055 return /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
38056 import_components93.Modal,
38057 {
38058 onRequestClose: toggleOpen,
38059 focusOnMount: "firstContentElement",
38060 title: (0, import_i18n118.__)("Rename"),
38061 size: "small",
38062 children: /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
38063 "form",
38064 {
38065 onSubmit: (event) => {
38066 event.preventDefault();
38067 handleConfirm();
38068 toggleOpen();
38069 },
38070 children: /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)(import_components93.__experimentalVStack, { spacing: "3", children: [
38071 /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
38072 import_components93.__experimentalInputControl,
38073 {
38074 __next40pxDefaultSize: true,
38075 autoComplete: "off",
38076 value: newName,
38077 onChange: setNewName,
38078 label: (0, import_i18n118.__)("Name"),
38079 placeholder: (0, import_i18n118.__)("Font size preset name")
38080 }
38081 ),
38082 /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)(import_components93.__experimentalHStack, { justify: "right", children: [
38083 /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
38084 import_components93.Button,
38085 {
38086 __next40pxDefaultSize: true,
38087 variant: "tertiary",
38088 onClick: toggleOpen,
38089 children: (0, import_i18n118.__)("Cancel")
38090 }
38091 ),
38092 /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
38093 import_components93.Button,
38094 {
38095 __next40pxDefaultSize: true,
38096 variant: "primary",
38097 type: "submit",
38098 children: (0, import_i18n118.__)("Save")
38099 }
38100 )
38101 ] })
38102 ] })
38103 }
38104 )
38105 }
38106 );
38107 }
38108 var rename_font_size_dialog_default = RenameFontSizeDialog;
38109
38110 // packages/global-styles-ui/build-module/size-control/index.mjs
38111 var import_components94 = __toESM(require_components(), 1);
38112 var import_jsx_runtime197 = __toESM(require_jsx_runtime(), 1);
38113 var DEFAULT_UNITS = ["px", "em", "rem", "vw", "vh"];
38114 function SizeControl(props) {
38115 const { baseControlProps } = (0, import_components94.useBaseControlProps)(props);
38116 const { value, onChange, fallbackValue, disabled, label } = props;
38117 const units = (0, import_components94.__experimentalUseCustomUnits)({
38118 availableUnits: DEFAULT_UNITS
38119 });
38120 const [valueQuantity, valueUnit = "px"] = (0, import_components94.__experimentalParseQuantityAndUnitFromRawValue)(value, units);
38121 const isValueUnitRelative = !!valueUnit && ["em", "rem", "vw", "vh"].includes(valueUnit);
38122 const handleUnitControlChange = (newValue) => {
38123 onChange?.(newValue);
38124 };
38125 const handleRangeControlChange = (newValue) => {
38126 if (newValue !== void 0) {
38127 onChange?.(newValue + valueUnit);
38128 } else {
38129 onChange?.(void 0);
38130 }
38131 };
38132 return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(import_components94.BaseControl, { ...baseControlProps, children: /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)(import_components94.Flex, { children: [
38133 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(import_components94.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
38134 import_components94.__experimentalUnitControl,
38135 {
38136 __next40pxDefaultSize: true,
38137 label,
38138 hideLabelFromVision: true,
38139 value,
38140 onChange: handleUnitControlChange,
38141 units,
38142 min: 0,
38143 disabled
38144 }
38145 ) }),
38146 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(import_components94.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(import_components94.__experimentalSpacer, { marginX: 2, marginBottom: 0, children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
38147 import_components94.RangeControl,
38148 {
38149 __next40pxDefaultSize: true,
38150 label,
38151 hideLabelFromVision: true,
38152 value: valueQuantity,
38153 initialPosition: fallbackValue,
38154 withInputField: false,
38155 onChange: handleRangeControlChange,
38156 min: 0,
38157 max: isValueUnitRelative ? 10 : 100,
38158 step: isValueUnitRelative ? 0.1 : 1,
38159 disabled
38160 }
38161 ) }) })
38162 ] }) });
38163 }
38164
38165 // packages/global-styles-ui/build-module/font-sizes/font-size.mjs
38166 var import_jsx_runtime198 = __toESM(require_jsx_runtime(), 1);
38167 var { Menu: Menu4 } = unlock3(import_components95.privateApis);
38168 function FontSize() {
38169 const [isDeleteConfirmOpen, setIsDeleteConfirmOpen] = (0, import_element77.useState)(false);
38170 const [isRenameDialogOpen, setIsRenameDialogOpen] = (0, import_element77.useState)(false);
38171 const {
38172 params: { origin, slug },
38173 goBack
38174 } = (0, import_components95.useNavigator)();
38175 const [fontSizes, setFontSizes] = useSetting("typography.fontSizes");
38176 const [globalFluid] = useSetting("typography.fluid");
38177 const sizes = fontSizes?.[origin] ?? [];
38178 const fontSize = sizes.find(
38179 (size3) => size3.slug === slug
38180 );
38181 (0, import_element77.useEffect)(() => {
38182 if (!!slug && !fontSize) {
38183 goBack();
38184 }
38185 }, [slug, fontSize, goBack]);
38186 if (!origin || !slug || !fontSize) {
38187 return null;
38188 }
38189 const isFluid = fontSize?.fluid !== void 0 ? !!fontSize.fluid : !!globalFluid;
38190 const isCustomFluid = typeof fontSize?.fluid === "object";
38191 const handleNameChange = (value) => {
38192 updateFontSize("name", value);
38193 };
38194 const handleFontSizeChange = (value) => {
38195 updateFontSize("size", value);
38196 };
38197 const handleFluidChange = (value) => {
38198 updateFontSize("fluid", value);
38199 };
38200 const handleCustomFluidValues = (value) => {
38201 if (value) {
38202 updateFontSize("fluid", {
38203 min: fontSize.size,
38204 max: fontSize.size
38205 });
38206 } else {
38207 updateFontSize("fluid", true);
38208 }
38209 };
38210 const handleMinChange = (value) => {
38211 const fluid = typeof fontSize.fluid === "object" ? fontSize.fluid : {};
38212 updateFontSize("fluid", { ...fluid, min: value });
38213 };
38214 const handleMaxChange = (value) => {
38215 const fluid = typeof fontSize.fluid === "object" ? fontSize.fluid : {};
38216 updateFontSize("fluid", { ...fluid, max: value });
38217 };
38218 const updateFontSize = (key, value) => {
38219 const newFontSizes = sizes.map((size3) => {
38220 if (size3.slug === slug) {
38221 return { ...size3, [key]: value };
38222 }
38223 return size3;
38224 });
38225 setFontSizes({
38226 ...fontSizes,
38227 [origin]: newFontSizes
38228 });
38229 };
38230 const handleRemoveFontSize = () => {
38231 const newFontSizes = sizes.filter((size3) => size3.slug !== slug);
38232 setFontSizes({
38233 ...fontSizes,
38234 [origin]: newFontSizes
38235 });
38236 };
38237 const toggleDeleteConfirm = () => {
38238 setIsDeleteConfirmOpen(!isDeleteConfirmOpen);
38239 };
38240 const toggleRenameDialog = () => {
38241 setIsRenameDialogOpen(!isRenameDialogOpen);
38242 };
38243 return /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(import_jsx_runtime198.Fragment, { children: [
38244 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38245 confirm_delete_font_size_dialog_default,
38246 {
38247 fontSize,
38248 isOpen: isDeleteConfirmOpen,
38249 toggleOpen: toggleDeleteConfirm,
38250 handleRemoveFontSize
38251 }
38252 ),
38253 isRenameDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38254 rename_font_size_dialog_default,
38255 {
38256 fontSize,
38257 toggleOpen: toggleRenameDialog,
38258 handleRename: handleNameChange
38259 }
38260 ),
38261 /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(import_components95.__experimentalVStack, { spacing: 4, children: [
38262 /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(import_components95.__experimentalHStack, { justify: "space-between", alignment: "flex-start", children: [
38263 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38264 ScreenHeader,
38265 {
38266 title: fontSize.name,
38267 description: (0, import_i18n119.sprintf)(
38268 /* translators: %s: font size preset name. */
38269 (0, import_i18n119.__)("Manage the font size %s."),
38270 fontSize.name
38271 )
38272 }
38273 ),
38274 origin === "custom" && /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components95.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38275 import_components95.__experimentalSpacer,
38276 {
38277 marginTop: 3,
38278 marginBottom: 0,
38279 paddingX: 4,
38280 children: /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(Menu4, { children: [
38281 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38282 Menu4.TriggerButton,
38283 {
38284 render: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38285 import_components95.Button,
38286 {
38287 size: "small",
38288 icon: more_vertical_default,
38289 label: (0, import_i18n119.__)(
38290 "Font size options"
38291 )
38292 }
38293 )
38294 }
38295 ),
38296 /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(Menu4.Popover, { children: [
38297 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38298 Menu4.Item,
38299 {
38300 onClick: toggleRenameDialog,
38301 children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(Menu4.ItemLabel, { children: (0, import_i18n119.__)("Rename") })
38302 }
38303 ),
38304 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38305 Menu4.Item,
38306 {
38307 onClick: toggleDeleteConfirm,
38308 children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(Menu4.ItemLabel, { children: (0, import_i18n119.__)("Delete") })
38309 }
38310 )
38311 ] })
38312 ] })
38313 }
38314 ) })
38315 ] }),
38316 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components95.__experimentalView, { children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38317 import_components95.__experimentalSpacer,
38318 {
38319 paddingX: 4,
38320 marginBottom: 0,
38321 paddingBottom: 6,
38322 children: /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(import_components95.__experimentalVStack, { spacing: 4, children: [
38323 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components95.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(font_size_preview_default, { fontSize }) }),
38324 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38325 SizeControl,
38326 {
38327 label: (0, import_i18n119.__)("Size"),
38328 value: !isCustomFluid && fontSize.size ? String(fontSize.size) : "",
38329 onChange: handleFontSizeChange,
38330 disabled: isCustomFluid
38331 }
38332 ),
38333 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38334 import_components95.ToggleControl,
38335 {
38336 label: (0, import_i18n119.__)("Fluid typography"),
38337 help: (0, import_i18n119.__)(
38338 "Scale the font size dynamically to fit the screen or viewport."
38339 ),
38340 checked: isFluid,
38341 onChange: handleFluidChange
38342 }
38343 ),
38344 isFluid && /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38345 import_components95.ToggleControl,
38346 {
38347 label: (0, import_i18n119.__)("Custom fluid values"),
38348 help: (0, import_i18n119.__)(
38349 "Set custom min and max values for the fluid font size."
38350 ),
38351 checked: isCustomFluid,
38352 onChange: handleCustomFluidValues
38353 }
38354 ),
38355 isCustomFluid && /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(import_jsx_runtime198.Fragment, { children: [
38356 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38357 SizeControl,
38358 {
38359 label: (0, import_i18n119.__)("Minimum"),
38360 value: typeof fontSize?.fluid === "object" ? fontSize.fluid?.min : void 0,
38361 onChange: handleMinChange
38362 }
38363 ),
38364 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
38365 SizeControl,
38366 {
38367 label: (0, import_i18n119.__)("Maximum"),
38368 value: typeof fontSize?.fluid === "object" ? fontSize.fluid?.max : void 0,
38369 onChange: handleMaxChange
38370 }
38371 )
38372 ] })
38373 ] })
38374 }
38375 ) })
38376 ] })
38377 ] });
38378 }
38379 var font_size_default = FontSize;
38380
38381 // packages/global-styles-ui/build-module/global-styles-ui.mjs
38382 var import_jsx_runtime199 = __toESM(require_jsx_runtime(), 1);
38383 function BlockStylesNavigationScreens({
38384 parentMenu,
38385 blockStyles,
38386 blockName
38387 }) {
38388 return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(import_jsx_runtime199.Fragment, { children: blockStyles.map((style, index2) => /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
38389 import_components96.Navigator.Screen,
38390 {
38391 path: parentMenu + "/variations/" + style.name,
38392 children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_block_default, { name: blockName, variation: style.name })
38393 },
38394 index2
38395 )) });
38396 }
38397 function ContextScreens({ name: name2, parentMenu = "" }) {
38398 const blockStyleVariations = (0, import_data67.useSelect)(
38399 (select6) => {
38400 if (!name2) {
38401 return [];
38402 }
38403 const { getBlockStyles } = select6(import_blocks19.store);
38404 return getBlockStyles(name2);
38405 },
38406 [name2]
38407 );
38408 if (!blockStyleVariations?.length) {
38409 return null;
38410 }
38411 return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
38412 BlockStylesNavigationScreens,
38413 {
38414 parentMenu,
38415 blockStyles: blockStyleVariations,
38416 blockName: name2 || ""
38417 }
38418 );
38419 }
38420 function GlobalStylesUI({
38421 value,
38422 baseValue,
38423 onChange,
38424 path,
38425 onPathChange,
38426 fontLibraryEnabled = false,
38427 serverCSS,
38428 serverSettings
38429 }) {
38430 const blocks = (0, import_blocks19.getBlockTypes)();
38431 const mergedValue = (0, import_element78.useMemo)(() => {
38432 return mergeGlobalStyles(baseValue, value);
38433 }, [baseValue, value]);
38434 const [globalStylesCSS, globalSettings] = generateGlobalStyles(
38435 mergedValue,
38436 [],
38437 {
38438 styleOptions: { variationStyles: true }
38439 }
38440 );
38441 const styles = (0, import_element78.useMemo)(
38442 () => [...serverCSS ?? [], ...globalStylesCSS ?? []],
38443 [serverCSS, globalStylesCSS]
38444 );
38445 const settings = (0, import_element78.useMemo)(() => {
38446 return {
38447 ...serverSettings,
38448 __experimentalFeatures: globalSettings,
38449 styles
38450 };
38451 }, [globalSettings, serverSettings, styles]);
38452 return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
38453 GlobalStylesProvider,
38454 {
38455 value,
38456 baseValue,
38457 onChange,
38458 fontLibraryEnabled,
38459 children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(import_block_editor31.BlockEditorProvider, { settings, children: /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)(
38460 import_components96.Navigator,
38461 {
38462 className: "global-styles-ui-sidebar__navigator-provider",
38463 initialPath: path || "/",
38464 children: [
38465 (path || onPathChange) && /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
38466 PathSynchronizer,
38467 {
38468 path,
38469 onPathChange
38470 }
38471 ),
38472 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_root_default, {}) }),
38473 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/colors", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_colors_default, {}) }),
38474 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/typography", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_typography_default, {}) }),
38475 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/typography/font-sizes", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(font_sizes_default, {}) }),
38476 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/typography/font-sizes/:origin/:slug", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(font_size_default, {}) }),
38477 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/layout", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_layout_default, {}) }),
38478 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/colors/palette", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_color_palette_default, {}) }),
38479 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/variations", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_style_variations_default, {}) }),
38480 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/css", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_css_default, {}) }),
38481 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/revisions/:revisionId?", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_revisions_default, {}) }),
38482 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/shadows", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(ScreenShadows, {}) }),
38483 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/shadows/edit/:category/:slug", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(ScreenShadowsEdit, {}) }),
38484 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/background", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_background_default, {}) }),
38485 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/typography/text", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_typography_element_default, { element: "text" }) }),
38486 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/typography/link", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_typography_element_default, { element: "link" }) }),
38487 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/typography/heading", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_typography_element_default, { element: "heading" }) }),
38488 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/typography/caption", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_typography_element_default, { element: "caption" }) }),
38489 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/typography/button", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_typography_element_default, { element: "button" }) }),
38490 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(GlobalStylesNavigationScreen, { path: "/blocks", children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_block_list_default, {}) }),
38491 blocks.map((block) => /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)(import_element78.Fragment, { children: [
38492 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
38493 GlobalStylesNavigationScreen,
38494 {
38495 path: "/blocks/" + encodeURIComponent(block.name),
38496 children: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(screen_block_default, { name: block.name })
38497 }
38498 ),
38499 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
38500 ContextScreens,
38501 {
38502 name: block.name,
38503 parentMenu: "/blocks/" + encodeURIComponent(block.name)
38504 }
38505 )
38506 ] }, block.name))
38507 ]
38508 }
38509 ) })
38510 }
38511 );
38512 }
38513 function GlobalStylesNavigationScreen({
38514 path,
38515 children
38516 }) {
38517 return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
38518 import_components96.Navigator.Screen,
38519 {
38520 className: "global-styles-ui-sidebar__navigator-screen",
38521 path,
38522 children
38523 }
38524 );
38525 }
38526 function PathSynchronizer({
38527 path,
38528 onPathChange
38529 }) {
38530 const navigator = (0, import_components96.useNavigator)();
38531 const { path: childPath } = navigator.location;
38532 const previousParentPath = (0, import_compose14.usePrevious)(path);
38533 const previousChildPath = (0, import_compose14.usePrevious)(childPath);
38534 (0, import_element78.useEffect)(() => {
38535 if (path && path !== childPath) {
38536 if (path !== previousParentPath) {
38537 navigator.goTo(path);
38538 } else if (childPath !== previousChildPath && onPathChange) {
38539 onPathChange(childPath ?? "/");
38540 }
38541 }
38542 }, [
38543 onPathChange,
38544 path,
38545 previousChildPath,
38546 previousParentPath,
38547 childPath,
38548 navigator
38549 ]);
38550 return null;
38551 }
38552
38553 // packages/global-styles-ui/build-module/with-global-styles-provider.mjs
38554 var import_jsx_runtime200 = __toESM(require_jsx_runtime(), 1);
38555 function withGlobalStylesProvider(Component6) {
38556 return function WrappedComponent({
38557 value,
38558 baseValue,
38559 onChange,
38560 ...props
38561 }) {
38562 return /* @__PURE__ */ (0, import_jsx_runtime200.jsx)(
38563 GlobalStylesProvider,
38564 {
38565 value,
38566 baseValue,
38567 onChange,
38568 children: /* @__PURE__ */ (0, import_jsx_runtime200.jsx)(Component6, { ...props })
38569 }
38570 );
38571 };
38572 }
38573
38574 // packages/global-styles-ui/build-module/style-variations.mjs
38575 var StyleVariations = withGlobalStylesProvider(style_variations_container_default);
38576
38577 // packages/global-styles-ui/build-module/color-variations.mjs
38578 var ColorVariations2 = withGlobalStylesProvider(ColorVariations);
38579
38580 // packages/global-styles-ui/build-module/typography-variations.mjs
38581 var TypographyVariations2 = withGlobalStylesProvider(TypographyVariations);
38582
38583 // packages/global-styles-ui/build-module/font-library/font-library.mjs
38584 var import_jsx_runtime201 = __toESM(require_jsx_runtime(), 1);
38585
38586 // packages/editor/build-module/components/global-styles/index.mjs
38587 var import_media_utils4 = __toESM(require_media_utils(), 1);
38588
38589 // packages/editor/build-module/components/global-styles/block-link.mjs
38590 var import_data68 = __toESM(require_data(), 1);
38591 var import_element79 = __toESM(require_element(), 1);
38592 var import_block_editor32 = __toESM(require_block_editor(), 1);
38593 var import_compose15 = __toESM(require_compose(), 1);
38594 function GlobalStylesBlockLink({ path, onPathChange }) {
38595 const { selectedBlockName, selectedBlockClientId } = (0, import_data68.useSelect)(
38596 (select6) => {
38597 const { getSelectedBlockClientId: getSelectedBlockClientId2, getBlockName: getBlockName2 } = select6(import_block_editor32.store);
38598 const clientId = getSelectedBlockClientId2();
38599 return {
38600 selectedBlockName: getBlockName2(clientId),
38601 selectedBlockClientId: clientId
38602 };
38603 },
38604 []
38605 );
38606 const blockHasGlobalStyles = true;
38607 const previousBlockClientId = (0, import_compose15.usePrevious)(selectedBlockClientId);
38608 (0, import_element79.useEffect)(() => {
38609 if (selectedBlockClientId === previousBlockClientId) {
38610 return;
38611 }
38612 if (!selectedBlockClientId || !blockHasGlobalStyles) {
38613 return;
38614 }
38615 if (!path || path !== "/blocks" && !path.startsWith("/blocks/")) {
38616 return;
38617 }
38618 const newPath = "/blocks/" + encodeURIComponent(selectedBlockName);
38619 if (newPath !== path) {
38620 onPathChange?.(newPath);
38621 }
38622 }, [
38623 selectedBlockClientId,
38624 previousBlockClientId,
38625 selectedBlockName,
38626 blockHasGlobalStyles,
38627 path,
38628 onPathChange
38629 ]);
38630 return null;
38631 }
38632
38633 // packages/editor/build-module/components/global-styles/hooks.mjs
38634 var import_element80 = __toESM(require_element(), 1);
38635 var import_core_data49 = __toESM(require_core_data(), 1);
38636 var import_data69 = __toESM(require_data(), 1);
38637 var import_block_editor33 = __toESM(require_block_editor(), 1);
38638 var { cleanEmptyObject: cleanEmptyObject2 } = unlock(import_block_editor33.privateApis);
38639 function useGlobalStylesUserConfig2() {
38640 const { globalStylesId, isReady: isReady2, settings, styles, _links } = (0, import_data69.useSelect)(
38641 (select6) => {
38642 const {
38643 getEntityRecord,
38644 getEditedEntityRecord: getEditedEntityRecord2,
38645 hasFinishedResolution,
38646 canUser
38647 } = select6(import_core_data49.store);
38648 const _globalStylesId = select6(import_core_data49.store).__experimentalGetCurrentGlobalStylesId();
38649 let record;
38650 const userCanEditGlobalStyles = _globalStylesId ? canUser("update", {
38651 kind: "root",
38652 name: "globalStyles",
38653 id: _globalStylesId
38654 }) : null;
38655 if (_globalStylesId && typeof userCanEditGlobalStyles === "boolean") {
38656 if (userCanEditGlobalStyles) {
38657 record = getEditedEntityRecord2(
38658 "root",
38659 "globalStyles",
38660 _globalStylesId
38661 );
38662 } else {
38663 record = getEntityRecord(
38664 "root",
38665 "globalStyles",
38666 _globalStylesId,
38667 { context: "view" }
38668 );
38669 }
38670 }
38671 let hasResolved = false;
38672 if (hasFinishedResolution(
38673 "__experimentalGetCurrentGlobalStylesId"
38674 )) {
38675 if (_globalStylesId) {
38676 hasResolved = userCanEditGlobalStyles ? hasFinishedResolution("getEditedEntityRecord", [
38677 "root",
38678 "globalStyles",
38679 _globalStylesId
38680 ]) : hasFinishedResolution("getEntityRecord", [
38681 "root",
38682 "globalStyles",
38683 _globalStylesId,
38684 { context: "view" }
38685 ]);
38686 } else {
38687 hasResolved = true;
38688 }
38689 }
38690 return {
38691 globalStylesId: _globalStylesId,
38692 isReady: hasResolved,
38693 settings: record?.settings,
38694 styles: record?.styles,
38695 _links: record?._links
38696 };
38697 },
38698 []
38699 );
38700 const { getEditedEntityRecord } = (0, import_data69.useSelect)(import_core_data49.store);
38701 const { editEntityRecord } = (0, import_data69.useDispatch)(import_core_data49.store);
38702 const config2 = (0, import_element80.useMemo)(() => {
38703 return {
38704 settings: settings ?? {},
38705 styles: styles ?? {},
38706 _links: _links ?? {}
38707 };
38708 }, [settings, styles, _links]);
38709 const setConfig = (0, import_element80.useCallback)(
38710 (callbackOrObject, options = {}) => {
38711 const record = getEditedEntityRecord(
38712 "root",
38713 "globalStyles",
38714 globalStylesId
38715 );
38716 const currentConfig = {
38717 styles: record?.styles ?? {},
38718 settings: record?.settings ?? {},
38719 _links: record?._links ?? {}
38720 };
38721 const updatedConfig = typeof callbackOrObject === "function" ? callbackOrObject(currentConfig) : callbackOrObject;
38722 editEntityRecord(
38723 "root",
38724 "globalStyles",
38725 globalStylesId,
38726 {
38727 styles: cleanEmptyObject2(updatedConfig.styles) || {},
38728 settings: cleanEmptyObject2(updatedConfig.settings) || {},
38729 _links: cleanEmptyObject2(updatedConfig._links) || {}
38730 },
38731 options
38732 );
38733 },
38734 [globalStylesId, editEntityRecord, getEditedEntityRecord]
38735 );
38736 return [isReady2, config2, setConfig];
38737 }
38738 function useGlobalStylesBaseConfig2() {
38739 const baseConfig = (0, import_data69.useSelect)(
38740 (select6) => select6(import_core_data49.store).__experimentalGetCurrentThemeBaseGlobalStyles(),
38741 []
38742 );
38743 return [!!baseConfig, baseConfig];
38744 }
38745 function useGlobalStyles() {
38746 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig2();
38747 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig2();
38748 const merged = (0, import_element80.useMemo)(() => {
38749 if (!isUserConfigReady || !isBaseConfigReady) {
38750 return {};
38751 }
38752 return mergeGlobalStyles(baseConfig || {}, userConfig);
38753 }, [isUserConfigReady, isBaseConfigReady, baseConfig, userConfig]);
38754 return {
38755 merged,
38756 base: baseConfig || {},
38757 user: userConfig,
38758 setUser: setUserConfig,
38759 isReady: isUserConfigReady && isBaseConfigReady
38760 };
38761 }
38762 function useStyle2(path, blockName) {
38763 const { merged } = useGlobalStyles();
38764 return (0, import_element80.useMemo)(
38765 () => getStyle(merged, path, blockName),
38766 [merged, path, blockName]
38767 );
38768 }
38769 function useSetting2(path, blockName) {
38770 const { merged } = useGlobalStyles();
38771 return (0, import_element80.useMemo)(
38772 () => getSetting(merged, path, blockName),
38773 [merged, path, blockName]
38774 );
38775 }
38776
38777 // packages/editor/build-module/components/global-styles/index.mjs
38778 var import_jsx_runtime202 = __toESM(require_jsx_runtime(), 1);
38779 function useServerData() {
38780 const {
38781 styles,
38782 __unstableResolvedAssets,
38783 colors: colors2,
38784 gradients,
38785 __experimentalDiscussionSettings,
38786 mediaUploadHandler,
38787 fontLibraryEnabled
38788 } = (0, import_data70.useSelect)((select6) => {
38789 const { getEditorSettings: getEditorSettings2 } = select6(store);
38790 const { canUser } = select6(import_core_data50.store);
38791 const editorSettings2 = getEditorSettings2();
38792 const canUserUploadMedia = canUser("create", {
38793 kind: "postType",
38794 name: "attachment"
38795 });
38796 return {
38797 styles: editorSettings2?.styles,
38798 __unstableResolvedAssets: editorSettings2?.__unstableResolvedAssets,
38799 colors: editorSettings2?.colors,
38800 gradients: editorSettings2?.gradients,
38801 __experimentalDiscussionSettings: editorSettings2?.__experimentalDiscussionSettings,
38802 mediaUploadHandler: canUserUploadMedia ? import_media_utils4.uploadMedia : void 0,
38803 fontLibraryEnabled: editorSettings2?.fontLibraryEnabled ?? true
38804 };
38805 }, []);
38806 const serverCSS = (0, import_element81.useMemo)(() => {
38807 if (!styles) {
38808 return [];
38809 }
38810 return styles.filter((style) => !style.isGlobalStyles);
38811 }, [styles]);
38812 const serverSettings = (0, import_element81.useMemo)(() => {
38813 return {
38814 __unstableResolvedAssets,
38815 settings: {
38816 color: {
38817 palette: {
38818 theme: colors2 ?? []
38819 },
38820 gradients: {
38821 theme: gradients ?? []
38822 },
38823 duotone: {
38824 theme: []
38825 }
38826 }
38827 },
38828 __experimentalDiscussionSettings,
38829 mediaUpload: mediaUploadHandler
38830 };
38831 }, [
38832 __unstableResolvedAssets,
38833 colors2,
38834 gradients,
38835 __experimentalDiscussionSettings,
38836 mediaUploadHandler
38837 ]);
38838 return { serverCSS, serverSettings, fontLibraryEnabled };
38839 }
38840 function GlobalStylesUIWrapper({ path, onPathChange }) {
38841 const {
38842 user: userConfig,
38843 base: baseConfig,
38844 setUser: setUserConfig,
38845 isReady: isReady2
38846 } = useGlobalStyles();
38847 const { serverCSS, serverSettings, fontLibraryEnabled } = useServerData();
38848 if (!isReady2) {
38849 return null;
38850 }
38851 return /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(import_jsx_runtime202.Fragment, { children: [
38852 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
38853 GlobalStylesUI,
38854 {
38855 value: userConfig,
38856 baseValue: baseConfig || {},
38857 onChange: setUserConfig,
38858 path,
38859 onPathChange,
38860 fontLibraryEnabled,
38861 serverCSS,
38862 serverSettings
38863 }
38864 ),
38865 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
38866 GlobalStylesBlockLink,
38867 {
38868 path,
38869 onPathChange
38870 }
38871 )
38872 ] });
38873 }
38874
38875 // packages/editor/build-module/dataviews/fields/content-preview/content-preview-view.mjs
38876 var import_jsx_runtime203 = __toESM(require_jsx_runtime(), 1);
38877 function PostPreviewContainer({
38878 template: template2,
38879 post: post2
38880 }) {
38881 const [backgroundColor = "white"] = useStyle2("color.background");
38882 const [postBlocks] = (0, import_core_data51.useEntityBlockEditor)("postType", post2.type, {
38883 id: post2.id
38884 });
38885 const [templateBlocks] = (0, import_core_data51.useEntityBlockEditor)(
38886 "postType",
38887 template2?.type,
38888 {
38889 id: template2?.id
38890 }
38891 );
38892 const blocks = template2 && templateBlocks ? templateBlocks : postBlocks;
38893 const isEmpty2 = !blocks?.length;
38894 return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
38895 "div",
38896 {
38897 className: "editor-fields-content-preview",
38898 style: {
38899 backgroundColor
38900 },
38901 children: [
38902 isEmpty2 && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("span", { className: "editor-fields-content-preview__empty", children: (0, import_i18n120.__)("Empty content") }),
38903 !isEmpty2 && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_block_editor34.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_block_editor34.BlockPreview, { blocks }) })
38904 ]
38905 }
38906 );
38907 }
38908 function PostPreviewView({ item }) {
38909 const { settings, template: template2 } = (0, import_data71.useSelect)(
38910 (select6) => {
38911 const { canUser, getPostType, getTemplateId, getEntityRecord } = unlock(select6(import_core_data51.store));
38912 const canViewTemplate = canUser("read", {
38913 kind: "postType",
38914 name: "wp_template"
38915 });
38916 const _settings = select6(store).getEditorSettings();
38917 const supportsTemplateMode = _settings.supportsTemplateMode;
38918 const isViewable = getPostType(item.type)?.viewable ?? false;
38919 const templateId2 = supportsTemplateMode && isViewable && canViewTemplate ? getTemplateId(item.type, item.id) : null;
38920 return {
38921 settings: _settings,
38922 template: templateId2 ? getEntityRecord("postType", "wp_template", templateId2) : void 0
38923 };
38924 },
38925 [item.type, item.id]
38926 );
38927 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
38928 EditorProvider,
38929 {
38930 post: item,
38931 settings,
38932 __unstableTemplate: template2,
38933 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(PostPreviewContainer, { template: template2, post: item })
38934 }
38935 );
38936 }
38937
38938 // packages/editor/build-module/dataviews/fields/content-preview/index.mjs
38939 var postPreviewField = {
38940 type: "media",
38941 id: "content-preview",
38942 label: (0, import_i18n121.__)("Content preview"),
38943 render: PostPreviewView,
38944 enableSorting: false
38945 };
38946 var content_preview_default = postPreviewField;
38947
38948 // packages/editor/build-module/dataviews/store/private-actions.mjs
38949 function hasEditorNotesSupport(supports) {
38950 const editor = supports?.editor;
38951 if (Array.isArray(editor)) {
38952 return !!editor[0]?.notes;
38953 }
38954 return false;
38955 }
38956 function registerEntityAction(kind, name2, config2) {
38957 return {
38958 type: "REGISTER_ENTITY_ACTION",
38959 kind,
38960 name: name2,
38961 config: config2
38962 };
38963 }
38964 function unregisterEntityAction(kind, name2, actionId) {
38965 return {
38966 type: "UNREGISTER_ENTITY_ACTION",
38967 kind,
38968 name: name2,
38969 actionId
38970 };
38971 }
38972 function registerEntityField(kind, name2, config2) {
38973 return {
38974 type: "REGISTER_ENTITY_FIELD",
38975 kind,
38976 name: name2,
38977 config: config2
38978 };
38979 }
38980 function unregisterEntityField(kind, name2, fieldId) {
38981 return {
38982 type: "UNREGISTER_ENTITY_FIELD",
38983 kind,
38984 name: name2,
38985 fieldId
38986 };
38987 }
38988 function setIsReady(kind, name2) {
38989 return {
38990 type: "SET_IS_READY",
38991 kind,
38992 name: name2
38993 };
38994 }
38995 var ORDERED_MEDIA_FIELDS = [
38996 // Metadata in panels (collapsed by default).
38997 date_added_default,
38998 author_default2,
38999 filename_default,
39000 mime_type_default,
39001 filesize_default,
39002 media_dimensions_default,
39003 attached_to_default,
39004 // Regular layout fields (always visible).
39005 title_default,
39006 alt_text_default,
39007 caption_default,
39008 description_default
39009 ];
39010 var registerPostTypeSchema = (postType2) => async ({ registry }) => {
39011 const isReady2 = unlock(registry.select(store)).isEntityReady(
39012 "postType",
39013 postType2
39014 );
39015 if (isReady2) {
39016 return;
39017 }
39018 unlock(registry.dispatch(store)).setIsReady(
39019 "postType",
39020 postType2
39021 );
39022 const postTypeConfig = await registry.resolveSelect(import_core_data52.store).getPostType(postType2);
39023 const canCreate = await registry.resolveSelect(import_core_data52.store).canUser("create", {
39024 kind: "postType",
39025 name: postType2
39026 });
39027 const currentTheme = await registry.resolveSelect(import_core_data52.store).getCurrentTheme();
39028 let canDuplicate = !["wp_block", "wp_template_part"].includes(
39029 postTypeConfig.slug
39030 ) && canCreate && duplicate_post_default;
39031 if (true) {
39032 if ("wp_template" !== postTypeConfig.slug) {
39033 canDuplicate = void 0;
39034 }
39035 }
39036 if (postTypeConfig.slug === "wp_template" && !window?.__experimentalTemplateActivate) {
39037 canDuplicate = void 0;
39038 }
39039 const actions2 = [
39040 postTypeConfig.viewable ? view_post_default : void 0,
39041 !!postTypeConfig.supports?.revisions ? view_post_revisions_default : void 0,
39042 // @ts-ignore
39043 canDuplicate,
39044 postTypeConfig.slug === "wp_template_part" && canCreate && currentTheme?.is_block_theme ? duplicate_template_part_default : void 0,
39045 canCreate && postTypeConfig.slug === "wp_block" ? duplicate_pattern_default : void 0,
39046 postTypeConfig.supports?.title ? rename_post_default : void 0,
39047 postTypeConfig.supports?.["page-attributes"] ? reorder_page_default : void 0,
39048 postTypeConfig.slug === "wp_block" ? export_pattern_default : void 0,
39049 restore_post_default,
39050 reset_post_default,
39051 delete_post_default,
39052 trash_post_default,
39053 permanently_delete_post_default
39054 ].filter(Boolean);
39055 let fields2;
39056 if (postType2 === ATTACHMENT_POST_TYPE) {
39057 fields2 = ORDERED_MEDIA_FIELDS;
39058 } else {
39059 fields2 = [
39060 postTypeConfig.supports?.thumbnail && currentTheme?.theme_supports?.["post-thumbnails"] && featured_image_default,
39061 postTypeConfig.supports?.author && author_default,
39062 status_default,
39063 !DESIGN_POST_TYPES.includes(postTypeConfig.slug) && date_default,
39064 slug_default,
39065 postTypeConfig.supports?.["page-attributes"] && parent_default,
39066 postTypeConfig.supports?.comments && comment_status_default,
39067 postTypeConfig.supports?.trackbacks && ping_status_default,
39068 (postTypeConfig.supports?.comments || postTypeConfig.supports?.trackbacks) && discussion_default,
39069 template_default,
39070 password_default,
39071 postTypeConfig.supports?.editor && postTypeConfig.viewable && content_preview_default,
39072 hasEditorNotesSupport(postTypeConfig.supports) && notes_default
39073 ].filter(Boolean);
39074 if (postTypeConfig.supports?.title) {
39075 let _titleField;
39076 if (postType2 === "page") {
39077 _titleField = page_title_default;
39078 } else if (postType2 === "wp_template") {
39079 _titleField = template_title_default;
39080 } else if (postType2 === "wp_block") {
39081 _titleField = pattern_title_default;
39082 } else {
39083 _titleField = title_default;
39084 }
39085 fields2.push(_titleField);
39086 }
39087 }
39088 registry.batch(() => {
39089 actions2.forEach((action) => {
39090 unlock(registry.dispatch(store)).registerEntityAction(
39091 "postType",
39092 postType2,
39093 action
39094 );
39095 });
39096 fields2.forEach((field) => {
39097 unlock(registry.dispatch(store)).registerEntityField(
39098 "postType",
39099 postType2,
39100 field
39101 );
39102 });
39103 });
39104 (0, import_hooks38.doAction)("core.registerPostTypeSchema", postType2);
39105 };
39106
39107 // packages/editor/build-module/store/private-actions.mjs
39108 function setCurrentTemplateId(id) {
39109 return {
39110 type: "SET_CURRENT_TEMPLATE_ID",
39111 id
39112 };
39113 }
39114 var createTemplate = (template2) => async ({ select: select6, dispatch: dispatch7, registry }) => {
39115 const savedTemplate = await registry.dispatch(import_core_data53.store).saveEntityRecord("postType", "wp_template", template2);
39116 registry.dispatch(import_core_data53.store).editEntityRecord(
39117 "postType",
39118 select6.getCurrentPostType(),
39119 select6.getCurrentPostId(),
39120 {
39121 template: savedTemplate.slug
39122 }
39123 );
39124 registry.dispatch(import_notices17.store).createSuccessNotice(
39125 (0, import_i18n122.__)("Custom template created. You're in template mode now."),
39126 {
39127 type: "snackbar",
39128 actions: [
39129 {
39130 label: (0, import_i18n122.__)("Go back"),
39131 onClick: () => dispatch7.setRenderingMode(
39132 select6.getEditorSettings().defaultRenderingMode
39133 )
39134 }
39135 ]
39136 }
39137 );
39138 return savedTemplate;
39139 };
39140 var showBlockTypes = (blockNames) => ({ registry }) => {
39141 const existingBlockNames = registry.select(import_preferences10.store).get("core", "hiddenBlockTypes") ?? [];
39142 const newBlockNames = existingBlockNames.filter(
39143 (type) => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type)
39144 );
39145 registry.dispatch(import_preferences10.store).set("core", "hiddenBlockTypes", newBlockNames);
39146 };
39147 var hideBlockTypes = (blockNames) => ({ registry }) => {
39148 const existingBlockNames = registry.select(import_preferences10.store).get("core", "hiddenBlockTypes") ?? [];
39149 const mergedBlockNames = /* @__PURE__ */ new Set([
39150 ...existingBlockNames,
39151 ...Array.isArray(blockNames) ? blockNames : [blockNames]
39152 ]);
39153 registry.dispatch(import_preferences10.store).set("core", "hiddenBlockTypes", [...mergedBlockNames]);
39154 };
39155 var saveDirtyEntities = ({
39156 onSave,
39157 dirtyEntityRecords = [],
39158 entitiesToSkip = [],
39159 close,
39160 successNoticeContent
39161 } = {}) => ({ registry }) => {
39162 const PUBLISH_ON_SAVE_ENTITIES = [
39163 { kind: "postType", name: "wp_navigation" }
39164 ];
39165 const saveNoticeId = "site-editor-save-success";
39166 const homeUrl = registry.select(import_core_data53.store).getEntityRecord("root", "__unstableBase")?.home;
39167 registry.dispatch(import_notices17.store).removeNotice(saveNoticeId);
39168 const entitiesToSave = dirtyEntityRecords.filter(
39169 ({ kind, name: name2, key, property }) => {
39170 return !entitiesToSkip.some(
39171 (elt) => elt.kind === kind && elt.name === name2 && elt.key === key && elt.property === property
39172 );
39173 }
39174 );
39175 close?.(entitiesToSave);
39176 const siteItemsToSave = [];
39177 const pendingSavedRecords = [];
39178 entitiesToSave.forEach(({ kind, name: name2, key, property }) => {
39179 if ("root" === kind && "site" === name2) {
39180 siteItemsToSave.push(property);
39181 } else {
39182 if (PUBLISH_ON_SAVE_ENTITIES.some(
39183 (typeToPublish) => typeToPublish.kind === kind && typeToPublish.name === name2
39184 )) {
39185 registry.dispatch(import_core_data53.store).editEntityRecord(kind, name2, key, {
39186 status: "publish"
39187 });
39188 }
39189 pendingSavedRecords.push(
39190 registry.dispatch(import_core_data53.store).saveEditedEntityRecord(kind, name2, key)
39191 );
39192 }
39193 });
39194 if (siteItemsToSave.length) {
39195 pendingSavedRecords.push(
39196 registry.dispatch(import_core_data53.store).__experimentalSaveSpecifiedEntityEdits(
39197 "root",
39198 "site",
39199 void 0,
39200 siteItemsToSave
39201 )
39202 );
39203 }
39204 registry.dispatch(import_block_editor35.store).__unstableMarkLastChangeAsPersistent();
39205 Promise.all(pendingSavedRecords).then((values) => {
39206 return onSave ? onSave(values) : values;
39207 }).then((values) => {
39208 if (values.some((value) => typeof value === "undefined")) {
39209 registry.dispatch(import_notices17.store).createErrorNotice((0, import_i18n122.__)("Saving failed."));
39210 } else {
39211 registry.dispatch(import_notices17.store).createSuccessNotice(
39212 successNoticeContent || (0, import_i18n122.__)("Site updated."),
39213 {
39214 type: "snackbar",
39215 id: saveNoticeId,
39216 actions: [
39217 {
39218 label: (0, import_i18n122.__)("View site"),
39219 url: homeUrl,
39220 openInNewTab: true
39221 }
39222 ]
39223 }
39224 );
39225 }
39226 }).catch(
39227 (error) => registry.dispatch(import_notices17.store).createErrorNotice(
39228 `${(0, import_i18n122.__)("Saving failed.")} ${error}`
39229 )
39230 );
39231 };
39232 var revertTemplate2 = (template2, { allowUndo = true } = {}) => async ({ registry }) => {
39233 const noticeId = "edit-site-template-reverted";
39234 registry.dispatch(import_notices17.store).removeNotice(noticeId);
39235 if (!isTemplateRevertable(template2)) {
39236 registry.dispatch(import_notices17.store).createErrorNotice((0, import_i18n122.__)("This template is not revertable."), {
39237 type: "snackbar"
39238 });
39239 return;
39240 }
39241 try {
39242 const templateEntityConfig = registry.select(import_core_data53.store).getEntityConfig("postType", template2.type);
39243 if (!templateEntityConfig) {
39244 registry.dispatch(import_notices17.store).createErrorNotice(
39245 (0, import_i18n122.__)(
39246 "The editor has encountered an unexpected error. Please reload."
39247 ),
39248 { type: "snackbar" }
39249 );
39250 return;
39251 }
39252 const fileTemplatePath = (0, import_url11.addQueryArgs)(
39253 `${templateEntityConfig.baseURL}/${template2.id}`,
39254 { context: "edit", source: template2.origin }
39255 );
39256 const fileTemplate = await (0, import_api_fetch5.default)({ path: fileTemplatePath });
39257 if (!fileTemplate) {
39258 registry.dispatch(import_notices17.store).createErrorNotice(
39259 (0, import_i18n122.__)(
39260 "The editor has encountered an unexpected error. Please reload."
39261 ),
39262 { type: "snackbar" }
39263 );
39264 return;
39265 }
39266 const serializeBlocks = ({
39267 blocks: blocksForSerialization = []
39268 }) => (0, import_blocks20.__unstableSerializeAndClean)(blocksForSerialization);
39269 const edited = registry.select(import_core_data53.store).getEditedEntityRecord(
39270 "postType",
39271 template2.type,
39272 template2.id
39273 );
39274 registry.dispatch(import_core_data53.store).editEntityRecord(
39275 "postType",
39276 template2.type,
39277 template2.id,
39278 {
39279 content: serializeBlocks,
39280 // Required to make the `undo` behave correctly.
39281 blocks: edited.blocks,
39282 // Required to revert the blocks in the editor.
39283 source: "custom"
39284 // required to avoid turning the editor into a dirty state
39285 },
39286 {
39287 undoIgnore: true
39288 // Required to merge this edit with the last undo level.
39289 }
39290 );
39291 const blocks = (0, import_blocks20.parse)(fileTemplate?.content?.raw);
39292 registry.dispatch(import_core_data53.store).editEntityRecord("postType", template2.type, fileTemplate.id, {
39293 content: serializeBlocks,
39294 blocks,
39295 source: "theme"
39296 });
39297 if (allowUndo) {
39298 const undoRevert = () => {
39299 registry.dispatch(import_core_data53.store).editEntityRecord(
39300 "postType",
39301 template2.type,
39302 edited.id,
39303 {
39304 content: serializeBlocks,
39305 blocks: edited.blocks,
39306 source: "custom"
39307 }
39308 );
39309 };
39310 registry.dispatch(import_notices17.store).createSuccessNotice((0, import_i18n122.__)("Template reset."), {
39311 type: "snackbar",
39312 id: noticeId,
39313 actions: [
39314 {
39315 label: (0, import_i18n122.__)("Undo"),
39316 onClick: undoRevert
39317 }
39318 ]
39319 });
39320 }
39321 } catch (error) {
39322 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n122.__)("Template revert failed. Please reload.");
39323 registry.dispatch(import_notices17.store).createErrorNotice(errorMessage, { type: "snackbar" });
39324 }
39325 };
39326 var removeTemplates = (items) => async ({ registry }) => {
39327 const isResetting = items.every((item) => item?.has_theme_file);
39328 const promiseResult = await Promise.allSettled(
39329 items.map((item) => {
39330 return registry.dispatch(import_core_data53.store).deleteEntityRecord(
39331 "postType",
39332 item.type,
39333 item.id,
39334 { force: true },
39335 { throwOnError: true }
39336 );
39337 })
39338 );
39339 if (promiseResult.every(({ status }) => status === "fulfilled")) {
39340 let successMessage;
39341 if (items.length === 1) {
39342 let title;
39343 if (typeof items[0].title === "string") {
39344 title = items[0].title;
39345 } else if (typeof items[0].title?.rendered === "string") {
39346 title = items[0].title?.rendered;
39347 } else if (typeof items[0].title?.raw === "string") {
39348 title = items[0].title?.raw;
39349 }
39350 successMessage = isResetting ? (0, import_i18n122.sprintf)(
39351 /* translators: %s: The template/part's name. */
39352 (0, import_i18n122.__)('"%s" reset.'),
39353 (0, import_html_entities9.decodeEntities)(title)
39354 ) : (0, import_i18n122.sprintf)(
39355 /* translators: %s: The template/part's name. */
39356 (0, import_i18n122._x)('"%s" deleted.', "template part"),
39357 (0, import_html_entities9.decodeEntities)(title)
39358 );
39359 } else {
39360 successMessage = isResetting ? (0, import_i18n122.__)("Items reset.") : (0, import_i18n122.__)("Items deleted.");
39361 }
39362 registry.dispatch(import_notices17.store).createSuccessNotice(successMessage, {
39363 type: "snackbar",
39364 id: "editor-template-deleted-success"
39365 });
39366 } else {
39367 let errorMessage;
39368 if (promiseResult.length === 1) {
39369 if (promiseResult[0].reason?.message) {
39370 errorMessage = promiseResult[0].reason.message;
39371 } else {
39372 errorMessage = isResetting ? (0, import_i18n122.__)("An error occurred while reverting the item.") : (0, import_i18n122.__)("An error occurred while deleting the item.");
39373 }
39374 } else {
39375 const errorMessages = /* @__PURE__ */ new Set();
39376 const failedPromises = promiseResult.filter(
39377 ({ status }) => status === "rejected"
39378 );
39379 for (const failedPromise of failedPromises) {
39380 if (failedPromise.reason?.message) {
39381 errorMessages.add(failedPromise.reason.message);
39382 }
39383 }
39384 if (errorMessages.size === 0) {
39385 errorMessage = (0, import_i18n122.__)(
39386 "An error occurred while deleting the items."
39387 );
39388 } else if (errorMessages.size === 1) {
39389 errorMessage = isResetting ? (0, import_i18n122.sprintf)(
39390 /* translators: %s: an error message */
39391 (0, import_i18n122.__)(
39392 "An error occurred while reverting the items: %s"
39393 ),
39394 [...errorMessages][0]
39395 ) : (0, import_i18n122.sprintf)(
39396 /* translators: %s: an error message */
39397 (0, import_i18n122.__)(
39398 "An error occurred while deleting the items: %s"
39399 ),
39400 [...errorMessages][0]
39401 );
39402 } else {
39403 errorMessage = isResetting ? (0, import_i18n122.sprintf)(
39404 /* translators: %s: a list of comma separated error messages */
39405 (0, import_i18n122.__)(
39406 "Some errors occurred while reverting the items: %s"
39407 ),
39408 [...errorMessages].join(",")
39409 ) : (0, import_i18n122.sprintf)(
39410 /* translators: %s: a list of comma separated error messages */
39411 (0, import_i18n122.__)(
39412 "Some errors occurred while deleting the items: %s"
39413 ),
39414 [...errorMessages].join(",")
39415 );
39416 }
39417 }
39418 registry.dispatch(import_notices17.store).createErrorNotice(errorMessage, { type: "snackbar" });
39419 }
39420 };
39421 var setDefaultRenderingMode = (mode) => ({ select: select6, registry }) => {
39422 const postType2 = select6.getCurrentPostType();
39423 const theme = registry.select(import_core_data53.store).getCurrentTheme()?.stylesheet;
39424 const renderingModes = registry.select(import_preferences10.store).get("core", "renderingModes")?.[theme] ?? {};
39425 if (renderingModes[postType2] === mode) {
39426 return;
39427 }
39428 const newModes = {
39429 [theme]: {
39430 ...renderingModes,
39431 [postType2]: mode
39432 }
39433 };
39434 registry.dispatch(import_preferences10.store).set("core", "renderingModes", newModes);
39435 };
39436 function setStylesPath(path) {
39437 return {
39438 type: "SET_STYLES_PATH",
39439 path
39440 };
39441 }
39442 function setShowStylebook(show) {
39443 return {
39444 type: "SET_SHOW_STYLEBOOK",
39445 show
39446 };
39447 }
39448 function resetStylesNavigation() {
39449 return {
39450 type: "RESET_STYLES_NAVIGATION"
39451 };
39452 }
39453 function setCanvasMinHeight(minHeight) {
39454 return {
39455 type: "SET_CANVAS_MIN_HEIGHT",
39456 minHeight
39457 };
39458 }
39459 function setCurrentRevisionId(revisionId2) {
39460 return {
39461 type: "SET_CURRENT_REVISION_ID",
39462 revisionId: revisionId2
39463 };
39464 }
39465 var setRevisionPage = (page) => async ({ dispatch: dispatch7, select: select6, registry }) => {
39466 const postType2 = select6.getCurrentPostType();
39467 const postId2 = select6.getCurrentPostId();
39468 const entityConfig = registry.select(import_core_data53.store).getEntityConfig("postType", postType2);
39469 const revisionKey = entityConfig?.revisionKey || "id";
39470 const revisions = await registry.resolveSelect(import_core_data53.store).getRevisions(
39471 "postType",
39472 postType2,
39473 postId2,
39474 buildRevisionsPageQuery(revisionKey, page)
39475 );
39476 registry.batch(() => {
39477 dispatch7({ type: "SET_REVISION_PAGE", page });
39478 if (revisions?.length) {
39479 dispatch7.setCurrentRevisionId(revisions[0][revisionKey]);
39480 }
39481 });
39482 };
39483 function setShowRevisionDiff(showDiff) {
39484 return {
39485 type: "SET_SHOW_REVISION_DIFF",
39486 showDiff
39487 };
39488 }
39489 var restoreRevision = (revisionId2) => async ({ select: select6, dispatch: dispatch7, registry }) => {
39490 const postType2 = select6.getCurrentPostType();
39491 const postId2 = select6.getCurrentPostId();
39492 const entityConfig = registry.select(import_core_data53.store).getEntityConfig("postType", postType2);
39493 const revisionKey = entityConfig?.revisionKey || "id";
39494 const revision = await registry.resolveSelect(import_core_data53.store).getRevision("postType", postType2, postId2, revisionId2, {
39495 context: "edit",
39496 _fields: [
39497 .../* @__PURE__ */ new Set([
39498 "id",
39499 "date",
39500 "modified",
39501 "author",
39502 "meta",
39503 "title.raw",
39504 "excerpt.raw",
39505 "content.raw",
39506 revisionKey
39507 ])
39508 ].join()
39509 });
39510 if (!revision) {
39511 return;
39512 }
39513 const edits = {
39514 blocks: void 0,
39515 content: revision.content.raw
39516 };
39517 if (revision.title?.raw !== void 0) {
39518 edits.title = revision.title.raw;
39519 }
39520 if (revision.excerpt?.raw !== void 0) {
39521 edits.excerpt = revision.excerpt.raw;
39522 }
39523 if (revision.meta !== void 0) {
39524 edits.meta = revision.meta;
39525 }
39526 dispatch7.editPost(edits);
39527 dispatch7.setCurrentRevisionId(null);
39528 await dispatch7.savePost();
39529 registry.dispatch(import_notices17.store).createSuccessNotice(
39530 (0, import_i18n122.sprintf)(
39531 /* translators: %s: Date and time of the revision. */
39532 (0, import_i18n122.__)("Restored to revision from %s."),
39533 (0, import_date6.dateI18n)((0, import_date6.getSettings)().formats.datetime, revision.date)
39534 ),
39535 {
39536 type: "snackbar",
39537 id: "editor-revision-restored"
39538 }
39539 );
39540 };
39541 function selectNote(noteId, options = { focus: false }) {
39542 return {
39543 type: "SELECT_NOTE",
39544 noteId,
39545 options
39546 };
39547 }
39548
39549 // packages/editor/build-module/store/index.mjs
39550 var storeConfig = {
39551 reducer: reducer_default2,
39552 selectors: selectors_exports,
39553 actions: actions_exports
39554 };
39555 var store = (0, import_data72.createReduxStore)(STORE_NAME, {
39556 ...storeConfig
39557 });
39558 (0, import_data72.register)(store);
39559 unlock(store).registerPrivateActions(private_actions_exports);
39560 unlock(store).registerPrivateSelectors(private_selectors_exports);
39561
39562 // packages/editor/build-module/hooks/custom-sources-backwards-compatibility.mjs
39563 var import_jsx_runtime204 = __toESM(require_jsx_runtime(), 1);
39564 var createWithMetaAttributeSource = (metaAttributes) => (0, import_compose16.createHigherOrderComponent)(
39565 (BlockEdit2) => ({ attributes, setAttributes, ...props }) => {
39566 const postType2 = (0, import_data73.useSelect)(
39567 (select6) => select6(store).getCurrentPostType(),
39568 []
39569 );
39570 const [meta2, setMeta] = (0, import_core_data54.useEntityProp)(
39571 "postType",
39572 postType2,
39573 "meta"
39574 );
39575 const mergedAttributes = (0, import_element82.useMemo)(
39576 () => ({
39577 ...attributes,
39578 ...Object.fromEntries(
39579 Object.entries(metaAttributes).map(
39580 ([attributeKey, metaKey]) => [
39581 attributeKey,
39582 meta2[metaKey]
39583 ]
39584 )
39585 )
39586 }),
39587 [attributes, meta2]
39588 );
39589 return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(
39590 BlockEdit2,
39591 {
39592 attributes: mergedAttributes,
39593 setAttributes: (nextAttributes) => {
39594 const nextMeta = Object.fromEntries(
39595 Object.entries(nextAttributes ?? {}).filter(
39596 // Filter to intersection of keys between the updated
39597 // attributes and those with an associated meta key.
39598 ([key]) => key in metaAttributes
39599 ).map(([attributeKey, value]) => [
39600 // Rename the keys to the expected meta key name.
39601 metaAttributes[attributeKey],
39602 value
39603 ])
39604 );
39605 if (Object.entries(nextMeta).length) {
39606 setMeta(nextMeta);
39607 }
39608 setAttributes(nextAttributes);
39609 },
39610 ...props
39611 }
39612 );
39613 },
39614 "withMetaAttributeSource"
39615 );
39616 function shimAttributeSource(settings) {
39617 const metaAttributes = Object.fromEntries(
39618 Object.entries(settings.attributes ?? {}).filter(([, { source }]) => source === "meta").map(([attributeKey, { meta: meta2 }]) => [attributeKey, meta2])
39619 );
39620 if (Object.entries(metaAttributes).length) {
39621 settings.edit = createWithMetaAttributeSource(metaAttributes)(
39622 settings.edit
39623 );
39624 }
39625 return settings;
39626 }
39627 (0, import_hooks39.addFilter)(
39628 "blocks.registerBlockType",
39629 "core/editor/custom-sources-backwards-compatibility/shim-attribute-source",
39630 shimAttributeSource
39631 );
39632
39633 // packages/editor/build-module/hooks/default-autocompleters.mjs
39634 var import_hooks49 = __toESM(require_hooks(), 1);
39635
39636 // packages/editor/build-module/components/autocompleters/user.mjs
39637 var import_element83 = __toESM(require_element(), 1);
39638 var import_data74 = __toESM(require_data(), 1);
39639 var import_core_data55 = __toESM(require_core_data(), 1);
39640 var import_jsx_runtime205 = __toESM(require_jsx_runtime(), 1);
39641 function getUserLabel(user) {
39642 const avatar = user.avatar_urls && user.avatar_urls[24] ? /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(
39643 "img",
39644 {
39645 className: "editor-autocompleters__user-avatar",
39646 alt: "",
39647 src: user.avatar_urls[24]
39648 }
39649 ) : /* @__PURE__ */ (0, import_jsx_runtime205.jsx)("span", { className: "editor-autocompleters__no-avatar" });
39650 return /* @__PURE__ */ (0, import_jsx_runtime205.jsxs)(import_jsx_runtime205.Fragment, { children: [
39651 avatar,
39652 /* @__PURE__ */ (0, import_jsx_runtime205.jsx)("span", { className: "editor-autocompleters__user-name", children: user.name }),
39653 /* @__PURE__ */ (0, import_jsx_runtime205.jsx)("span", { className: "editor-autocompleters__user-slug", children: user.slug })
39654 ] });
39655 }
39656 var user_default = {
39657 name: "users",
39658 className: "editor-autocompleters__user",
39659 triggerPrefix: "@",
39660 useItems(filterValue) {
39661 const users = (0, import_data74.useSelect)(
39662 (select6) => {
39663 const { getUsers } = select6(import_core_data55.store);
39664 return getUsers({
39665 context: "view",
39666 search: encodeURIComponent(filterValue)
39667 });
39668 },
39669 [filterValue]
39670 );
39671 const options = (0, import_element83.useMemo)(
39672 () => users ? users.map((user) => ({
39673 key: `user-${user.slug}`,
39674 value: user,
39675 label: getUserLabel(user)
39676 })) : [],
39677 [users]
39678 );
39679 return [options];
39680 },
39681 getOptionCompletion(user) {
39682 return `@${user.slug}`;
39683 }
39684 };
39685
39686 // packages/editor/build-module/components/autosave-monitor/index.mjs
39687 var import_element84 = __toESM(require_element(), 1);
39688 var import_compose17 = __toESM(require_compose(), 1);
39689 var import_data75 = __toESM(require_data(), 1);
39690 var import_core_data56 = __toESM(require_core_data(), 1);
39691 var AutosaveMonitor = class extends import_element84.Component {
39692 constructor(props) {
39693 super(props);
39694 this.needsAutosave = !!(props.isDirty && props.isAutosaveable);
39695 }
39696 componentDidMount() {
39697 if (!this.props.disableIntervalChecks) {
39698 this.setAutosaveTimer();
39699 }
39700 }
39701 componentDidUpdate(prevProps) {
39702 if (this.props.disableIntervalChecks) {
39703 if (this.props.editsReference !== prevProps.editsReference) {
39704 this.props.autosave();
39705 }
39706 return;
39707 }
39708 if (this.props.interval !== prevProps.interval) {
39709 clearTimeout(this.timerId);
39710 this.setAutosaveTimer();
39711 }
39712 if (!this.props.isDirty) {
39713 this.needsAutosave = false;
39714 return;
39715 }
39716 if (this.props.isAutosaving && !prevProps.isAutosaving) {
39717 this.needsAutosave = false;
39718 return;
39719 }
39720 if (this.props.editsReference !== prevProps.editsReference) {
39721 this.needsAutosave = true;
39722 }
39723 }
39724 componentWillUnmount() {
39725 clearTimeout(this.timerId);
39726 }
39727 setAutosaveTimer(timeout = this.props.interval * 1e3) {
39728 this.timerId = setTimeout(() => {
39729 this.autosaveTimerHandler();
39730 }, timeout);
39731 }
39732 autosaveTimerHandler() {
39733 if (!this.props.isAutosaveable) {
39734 this.setAutosaveTimer(1e3);
39735 return;
39736 }
39737 if (this.needsAutosave) {
39738 this.needsAutosave = false;
39739 this.props.autosave();
39740 }
39741 this.setAutosaveTimer();
39742 }
39743 render() {
39744 return null;
39745 }
39746 };
39747 var autosave_monitor_default = (0, import_compose17.compose)([
39748 (0, import_data75.withSelect)((select6, ownProps) => {
39749 const { getReferenceByDistinctEdits } = select6(import_core_data56.store);
39750 const {
39751 isEditedPostDirty: isEditedPostDirty2,
39752 isEditedPostAutosaveable: isEditedPostAutosaveable2,
39753 isAutosavingPost: isAutosavingPost2,
39754 getEditorSettings: getEditorSettings2
39755 } = select6(store);
39756 const { interval = getEditorSettings2().autosaveInterval } = ownProps;
39757 return {
39758 editsReference: getReferenceByDistinctEdits(),
39759 isDirty: isEditedPostDirty2(),
39760 isAutosaveable: isEditedPostAutosaveable2(),
39761 isAutosaving: isAutosavingPost2(),
39762 interval
39763 };
39764 }),
39765 (0, import_data75.withDispatch)((dispatch7, ownProps) => ({
39766 autosave() {
39767 const { autosave: autosave2 = dispatch7(store).autosave } = ownProps;
39768 autosave2();
39769 }
39770 }))
39771 ])(AutosaveMonitor);
39772
39773 // packages/editor/build-module/components/document-bar/index.mjs
39774 var import_i18n129 = __toESM(require_i18n(), 1);
39775 var import_data83 = __toESM(require_data(), 1);
39776 var import_components104 = __toESM(require_components(), 1);
39777 var import_block_editor40 = __toESM(require_block_editor(), 1);
39778 var import_keycodes7 = __toESM(require_keycodes(), 1);
39779 var import_core_data60 = __toESM(require_core_data(), 1);
39780 var import_commands3 = __toESM(require_commands(), 1);
39781 var import_element91 = __toESM(require_element(), 1);
39782 var import_compose19 = __toESM(require_compose(), 1);
39783 var import_html_entities11 = __toESM(require_html_entities(), 1);
39784 var import_dom2 = __toESM(require_dom(), 1);
39785
39786 // packages/editor/build-module/utils/pageTypeBadge.mjs
39787 var import_i18n123 = __toESM(require_i18n(), 1);
39788 var import_data76 = __toESM(require_data(), 1);
39789 var import_core_data57 = __toESM(require_core_data(), 1);
39790 function usePageTypeBadge(postId2) {
39791 const { isFrontPage, isPostsPage } = (0, import_data76.useSelect)((select6) => {
39792 const { canUser, getEditedEntityRecord } = select6(import_core_data57.store);
39793 const siteSettings = canUser("read", {
39794 kind: "root",
39795 name: "site"
39796 }) ? getEditedEntityRecord("root", "site") : void 0;
39797 const _postId = parseInt(postId2, 10);
39798 return {
39799 isFrontPage: siteSettings?.page_on_front === _postId,
39800 isPostsPage: siteSettings?.page_for_posts === _postId
39801 };
39802 });
39803 if (isFrontPage) {
39804 return (0, import_i18n123.__)("Homepage");
39805 } else if (isPostsPage) {
39806 return (0, import_i18n123.__)("Posts Page");
39807 }
39808 return false;
39809 }
39810
39811 // packages/editor/build-module/components/styles-canvas/index.mjs
39812 var import_components103 = __toESM(require_components(), 1);
39813 var import_keycodes6 = __toESM(require_keycodes(), 1);
39814 var import_i18n128 = __toESM(require_i18n(), 1);
39815 var import_data81 = __toESM(require_data(), 1);
39816 var import_compose18 = __toESM(require_compose(), 1);
39817 var import_preferences11 = __toESM(require_preferences(), 1);
39818
39819 // packages/editor/build-module/components/styles-canvas/style-book.mjs
39820 var import_element88 = __toESM(require_element(), 1);
39821
39822 // packages/editor/build-module/components/style-book/index.mjs
39823 var import_components99 = __toESM(require_components(), 1);
39824 var import_i18n126 = __toESM(require_i18n(), 1);
39825 var import_block_editor37 = __toESM(require_block_editor(), 1);
39826 var import_data79 = __toESM(require_data(), 1);
39827 var import_element87 = __toESM(require_element(), 1);
39828 var import_keycodes4 = __toESM(require_keycodes(), 1);
39829 var import_media_utils5 = __toESM(require_media_utils(), 1);
39830 var import_core_data58 = __toESM(require_core_data(), 1);
39831
39832 // packages/editor/build-module/components/style-book/constants.mjs
39833 var import_i18n124 = __toESM(require_i18n(), 1);
39834 var STYLE_BOOK_COLOR_GROUPS = [
39835 {
39836 slug: "theme-colors",
39837 title: (0, import_i18n124.__)("Theme Colors"),
39838 origin: "theme",
39839 type: "colors"
39840 },
39841 {
39842 slug: "theme-gradients",
39843 title: (0, import_i18n124.__)("Theme Gradients"),
39844 origin: "theme",
39845 type: "gradients"
39846 },
39847 {
39848 slug: "custom-colors",
39849 title: (0, import_i18n124.__)("Custom Colors"),
39850 origin: "custom",
39851 type: "colors"
39852 },
39853 {
39854 slug: "custom-gradients",
39855 title: (0, import_i18n124.__)("Custom Gradients"),
39856 origin: "custom",
39857 // User.
39858 type: "gradients"
39859 },
39860 {
39861 slug: "duotones",
39862 title: (0, import_i18n124.__)("Duotones"),
39863 origin: "theme",
39864 type: "duotones"
39865 },
39866 {
39867 slug: "default-colors",
39868 title: (0, import_i18n124.__)("Default Colors"),
39869 origin: "default",
39870 type: "colors"
39871 },
39872 {
39873 slug: "default-gradients",
39874 title: (0, import_i18n124.__)("Default Gradients"),
39875 origin: "default",
39876 type: "gradients"
39877 }
39878 ];
39879 var STYLE_BOOK_THEME_SUBCATEGORIES = [
39880 {
39881 slug: "site-identity",
39882 title: (0, import_i18n124.__)("Site Identity"),
39883 blocks: ["core/site-logo", "core/site-title", "core/site-tagline"]
39884 },
39885 {
39886 slug: "design",
39887 title: (0, import_i18n124.__)("Design"),
39888 blocks: ["core/navigation", "core/avatar", "core/post-time-to-read"],
39889 exclude: ["core/home-link", "core/navigation-link"]
39890 },
39891 {
39892 slug: "posts",
39893 title: (0, import_i18n124.__)("Posts"),
39894 blocks: [
39895 "core/post-title",
39896 "core/post-excerpt",
39897 "core/post-author",
39898 "core/post-author-name",
39899 "core/post-author-biography",
39900 "core/post-date",
39901 "core/post-terms",
39902 "core/term-description",
39903 "core/query-title",
39904 "core/query-no-results",
39905 "core/query-pagination",
39906 "core/query-numbers"
39907 ]
39908 },
39909 {
39910 slug: "comments",
39911 title: (0, import_i18n124.__)("Comments"),
39912 blocks: [
39913 "core/comments-title",
39914 "core/comments-pagination",
39915 "core/comments-pagination-numbers",
39916 "core/comments",
39917 "core/comments-author-name",
39918 "core/comment-content",
39919 "core/comment-date",
39920 "core/comment-edit-link",
39921 "core/comment-reply-link",
39922 "core/comment-template",
39923 "core/post-comments-count",
39924 "core/post-comments-link"
39925 ]
39926 }
39927 ];
39928 var STYLE_BOOK_CATEGORIES = [
39929 {
39930 slug: "overview",
39931 title: (0, import_i18n124.__)("Overview"),
39932 blocks: []
39933 },
39934 {
39935 slug: "text",
39936 title: (0, import_i18n124.__)("Text"),
39937 blocks: [
39938 "core/post-content",
39939 "core/home-link",
39940 "core/navigation-link"
39941 ]
39942 },
39943 {
39944 slug: "colors",
39945 title: (0, import_i18n124.__)("Colors"),
39946 blocks: []
39947 },
39948 {
39949 slug: "theme",
39950 title: (0, import_i18n124.__)("Theme"),
39951 subcategories: STYLE_BOOK_THEME_SUBCATEGORIES
39952 },
39953 {
39954 slug: "media",
39955 title: (0, import_i18n124.__)("Media"),
39956 blocks: ["core/post-featured-image"]
39957 },
39958 {
39959 slug: "widgets",
39960 title: (0, import_i18n124.__)("Widgets"),
39961 blocks: []
39962 },
39963 {
39964 slug: "embed",
39965 title: (0, import_i18n124.__)("Embeds"),
39966 include: []
39967 }
39968 ];
39969 var STYLE_BOOK_ALL_BLOCKS_SUBCATEGORIES = [
39970 ...STYLE_BOOK_THEME_SUBCATEGORIES,
39971 {
39972 slug: "media",
39973 title: (0, import_i18n124.__)("Media"),
39974 blocks: ["core/post-featured-image"]
39975 },
39976 {
39977 slug: "widgets",
39978 title: (0, import_i18n124.__)("Widgets"),
39979 blocks: []
39980 },
39981 {
39982 slug: "embed",
39983 title: (0, import_i18n124.__)("Embeds"),
39984 include: []
39985 }
39986 ];
39987 var STYLE_BOOK_PREVIEW_CATEGORIES = [
39988 {
39989 slug: "overview",
39990 title: (0, import_i18n124.__)("Overview"),
39991 blocks: []
39992 },
39993 {
39994 slug: "text",
39995 title: (0, import_i18n124.__)("Text"),
39996 blocks: [
39997 "core/post-content",
39998 "core/home-link",
39999 "core/navigation-link"
40000 ]
40001 },
40002 {
40003 slug: "colors",
40004 title: (0, import_i18n124.__)("Colors"),
40005 blocks: []
40006 },
40007 {
40008 slug: "blocks",
40009 title: (0, import_i18n124.__)("All Blocks"),
40010 blocks: [],
40011 subcategories: STYLE_BOOK_ALL_BLOCKS_SUBCATEGORIES
40012 }
40013 ];
40014 var ROOT_CONTAINER = `
40015 .is-root-container {
40016 display: flow-root;
40017 }
40018`;
40019 var STYLE_BOOK_IFRAME_STYLES = `
40020 body {
40021 position: relative;
40022 padding: 32px !important;
40023 }
40024
40025 ${ROOT_CONTAINER}
40026
40027 .editor-style-book__examples {
40028 max-width: 1200px;
40029 margin: 0 auto;
40030 }
40031
40032 .editor-style-book__example {
40033 max-width: 900px;
40034 border-radius: 2px;
40035 cursor: pointer;
40036 display: flex;
40037 flex-direction: column;
40038 gap: 40px;
40039 padding: 16px;
40040 width: 100%;
40041 box-sizing: border-box;
40042 scroll-margin-top: 32px;
40043 scroll-margin-bottom: 32px;
40044 margin: 0 auto 40px auto;
40045 }
40046
40047 .editor-style-book__example.is-selected {
40048 box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
40049 }
40050
40051 .editor-style-book__example.is-disabled-example {
40052 pointer-events: none;
40053 }
40054
40055 .editor-style-book__example:focus:not(:disabled) {
40056 box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
40057 outline: 3px solid transparent;
40058 }
40059
40060 .editor-style-book__duotone-example > div:first-child {
40061 display: flex;
40062 aspect-ratio: 16 / 9;
40063 grid-row: span 1;
40064 grid-column: span 2;
40065 }
40066 .editor-style-book__duotone-example img {
40067 width: 100%;
40068 height: 100%;
40069 object-fit: cover;
40070 }
40071 .editor-style-book__duotone-example > div:not(:first-child) {
40072 height: 20px;
40073 border: 1px solid color-mix( in srgb, currentColor 10%, transparent );
40074 }
40075
40076 .editor-style-book__color-example {
40077 border: 1px solid color-mix( in srgb, currentColor 10%, transparent );
40078 }
40079
40080 .editor-style-book__subcategory-title,
40081 .editor-style-book__example-title {
40082 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
40083 font-size: 13px;
40084 font-weight: normal;
40085 line-height: normal;
40086 margin: 0;
40087 text-align: left;
40088 padding-top: 8px;
40089 border-top: 1px solid color-mix( in srgb, currentColor 10%, transparent );
40090 color: color-mix( in srgb, currentColor 60%, transparent );
40091 }
40092
40093 .editor-style-book__subcategory-title {
40094 font-size: 16px;
40095 margin-bottom: 40px;
40096 padding-bottom: 8px;
40097 }
40098
40099 .editor-style-book__example-preview {
40100 width: 100%;
40101 }
40102
40103 .editor-style-book__example-preview .block-editor-block-list__insertion-point,
40104 .editor-style-book__example-preview .block-list-appender {
40105 display: none;
40106 }
40107 :where(.is-root-container > .wp-block:first-child) {
40108 margin-top: 0;
40109 }
40110 :where(.is-root-container > .wp-block:last-child) {
40111 margin-bottom: 0;
40112 }
40113`;
40114
40115 // packages/editor/build-module/components/style-book/categories.mjs
40116 var import_blocks21 = __toESM(require_blocks(), 1);
40117 function getExamplesByCategory(categoryDefinition, examples) {
40118 if (!categoryDefinition?.slug || !examples?.length) {
40119 return;
40120 }
40121 const categories = categoryDefinition?.subcategories ?? [];
40122 if (categories.length) {
40123 return categories.reduce(
40124 (acc, subcategoryDefinition) => {
40125 const subcategoryExamples = getExamplesByCategory(
40126 subcategoryDefinition,
40127 examples
40128 );
40129 if (subcategoryExamples) {
40130 if (!acc.subcategories) {
40131 acc.subcategories = [];
40132 }
40133 acc.subcategories = [
40134 ...acc.subcategories,
40135 subcategoryExamples
40136 ];
40137 }
40138 return acc;
40139 },
40140 {
40141 title: categoryDefinition.title,
40142 slug: categoryDefinition.slug
40143 }
40144 );
40145 }
40146 const blocksToInclude = categoryDefinition?.blocks || [];
40147 const blocksToExclude = categoryDefinition?.exclude || [];
40148 const categoryExamples = examples.filter((example) => {
40149 return !blocksToExclude.includes(example.name) && (example.category === categoryDefinition.slug || blocksToInclude.includes(example.name));
40150 });
40151 if (!categoryExamples.length) {
40152 return;
40153 }
40154 return {
40155 title: categoryDefinition.title,
40156 slug: categoryDefinition.slug,
40157 examples: categoryExamples
40158 };
40159 }
40160 function getTopLevelStyleBookCategories() {
40161 const reservedCategories = [
40162 ...STYLE_BOOK_THEME_SUBCATEGORIES,
40163 ...STYLE_BOOK_CATEGORIES
40164 ].map(({ slug }) => slug);
40165 const extraCategories = (0, import_blocks21.getCategories)();
40166 const extraCategoriesFiltered = extraCategories.filter(
40167 ({ slug }) => !reservedCategories.includes(slug)
40168 );
40169 return [...STYLE_BOOK_CATEGORIES, ...extraCategoriesFiltered];
40170 }
40171
40172 // packages/editor/build-module/components/style-book/examples.mjs
40173 var import_i18n125 = __toESM(require_i18n(), 1);
40174 var import_blocks22 = __toESM(require_blocks(), 1);
40175
40176 // packages/editor/build-module/components/style-book/color-examples.mjs
40177 var import_components97 = __toESM(require_components(), 1);
40178 var import_block_editor36 = __toESM(require_block_editor(), 1);
40179 var import_jsx_runtime206 = __toESM(require_jsx_runtime(), 1);
40180 var ColorExamples = ({
40181 colors: colors2,
40182 type,
40183 templateColumns = "1fr 1fr",
40184 itemHeight = "52px"
40185 }) => {
40186 if (!colors2) {
40187 return null;
40188 }
40189 return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(import_components97.__experimentalGrid, { templateColumns, rowGap: 8, columnGap: 16, children: colors2.map((color) => {
40190 const className = type === "gradients" ? (0, import_block_editor36.__experimentalGetGradientClass)(color.slug) : (0, import_block_editor36.getColorClassName)("background-color", color.slug);
40191 const classes = clsx_default(
40192 "editor-style-book__color-example",
40193 className
40194 );
40195 return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(
40196 "div",
40197 {
40198 className: classes,
40199 style: { height: itemHeight }
40200 },
40201 color.slug
40202 );
40203 }) });
40204 };
40205 var color_examples_default = ColorExamples;
40206
40207 // packages/editor/build-module/components/style-book/duotone-examples.mjs
40208 var import_components98 = __toESM(require_components(), 1);
40209 var import_jsx_runtime207 = __toESM(require_jsx_runtime(), 1);
40210 var DuotoneExamples = ({ duotones }) => {
40211 if (!duotones) {
40212 return null;
40213 }
40214 return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(import_components98.__experimentalGrid, { columns: 2, rowGap: 16, columnGap: 16, children: duotones.map((duotone) => {
40215 return /* @__PURE__ */ (0, import_jsx_runtime207.jsxs)(
40216 import_components98.__experimentalGrid,
40217 {
40218 className: "editor-style-book__duotone-example",
40219 columns: 2,
40220 rowGap: 8,
40221 columnGap: 8,
40222 children: [
40223 /* @__PURE__ */ (0, import_jsx_runtime207.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
40224 "img",
40225 {
40226 alt: `Duotone example: ${duotone.slug}`,
40227 src: "https://s.w.org/images/core/5.3/MtBlanc1.jpg",
40228 style: {
40229 filter: `url(#wp-duotone-${duotone.slug})`
40230 }
40231 }
40232 ) }),
40233 duotone.colors.map((color) => {
40234 return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(
40235 "div",
40236 {
40237 className: "editor-style-book__color-example",
40238 style: { backgroundColor: color }
40239 },
40240 color
40241 );
40242 })
40243 ]
40244 },
40245 duotone.slug
40246 );
40247 }) });
40248 };
40249 var duotone_examples_default = DuotoneExamples;
40250
40251 // packages/editor/build-module/components/style-book/examples.mjs
40252 var import_jsx_runtime208 = __toESM(require_jsx_runtime(), 1);
40253 function getColorExamples(colors2) {
40254 if (!colors2) {
40255 return [];
40256 }
40257 const examples = [];
40258 STYLE_BOOK_COLOR_GROUPS.forEach((group) => {
40259 const palette = colors2[group.type];
40260 const paletteFiltered = Array.isArray(palette) ? palette.find(
40261 (origin) => origin.slug === group.origin
40262 ) : void 0;
40263 if (paletteFiltered?.[group.type]) {
40264 const example = {
40265 name: group.slug,
40266 title: group.title,
40267 category: "colors"
40268 };
40269 if (group.type === "duotones") {
40270 example.content = /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(
40271 duotone_examples_default,
40272 {
40273 duotones: paletteFiltered[group.type]
40274 }
40275 );
40276 examples.push(example);
40277 } else {
40278 example.content = /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(
40279 color_examples_default,
40280 {
40281 colors: paletteFiltered[group.type],
40282 type: group.type
40283 }
40284 );
40285 examples.push(example);
40286 }
40287 }
40288 });
40289 return examples;
40290 }
40291 function getOverviewBlockExamples(colors2) {
40292 const examples = [];
40293 const themePalette = Array.isArray(colors2?.colors) ? colors2.colors.find(
40294 (origin) => origin.slug === "theme"
40295 ) : void 0;
40296 if (themePalette) {
40297 const themeColorexample = {
40298 name: "theme-colors",
40299 title: (0, import_i18n125.__)("Colors"),
40300 category: "overview",
40301 content: /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(
40302 color_examples_default,
40303 {
40304 colors: themePalette.colors,
40305 type: "colors",
40306 templateColumns: "repeat(auto-fill, minmax( 200px, 1fr ))",
40307 itemHeight: "32px"
40308 }
40309 )
40310 };
40311 examples.push(themeColorexample);
40312 }
40313 const typographyBlockExamples = [];
40314 if ((0, import_blocks22.getBlockType)("core/heading")) {
40315 const headingBlock = (0, import_blocks22.createBlock)("core/heading", {
40316 // translators: Typography example. Your local alphabet, numbers and some common special characters.
40317 content: (0, import_i18n125.__)(
40318 `AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789X{(\u2026)},.-<>?!*&:/A@HELFO\u2122\xA9`
40319 ),
40320 level: 1
40321 });
40322 typographyBlockExamples.push(headingBlock);
40323 }
40324 if ((0, import_blocks22.getBlockType)("core/paragraph")) {
40325 const firstParagraphBlock = (0, import_blocks22.createBlock)("core/paragraph", {
40326 content: (0, import_i18n125.__)(
40327 `A paragraph in a website refers to a distinct block of text that is used to present and organize information. It is a fundamental unit of content in web design and is typically composed of a group of related sentences or thoughts focused on a particular topic or idea. Paragraphs play a crucial role in improving the readability and user experience of a website. They break down the text into smaller, manageable chunks, allowing readers to scan the content more easily.`
40328 )
40329 });
40330 const secondParagraphBlock = (0, import_blocks22.createBlock)("core/paragraph", {
40331 content: (0, import_i18n125.__)(
40332 `Additionally, paragraphs help structure the flow of information and provide logical breaks between different concepts or pieces of information. In terms of formatting, paragraphs in websites are commonly denoted by a vertical gap or indentation between each block of text. This visual separation helps visually distinguish one paragraph from another, creating a clear and organized layout that guides the reader through the content smoothly.`
40333 )
40334 });
40335 if ((0, import_blocks22.getBlockType)("core/group")) {
40336 const groupBlock = (0, import_blocks22.createBlock)(
40337 "core/group",
40338 {
40339 layout: {
40340 type: "grid",
40341 columnCount: 2,
40342 minimumColumnWidth: "12rem"
40343 },
40344 style: {
40345 spacing: {
40346 blockGap: "1.5rem"
40347 }
40348 }
40349 },
40350 [firstParagraphBlock, secondParagraphBlock]
40351 );
40352 typographyBlockExamples.push(groupBlock);
40353 } else {
40354 typographyBlockExamples.push(firstParagraphBlock);
40355 }
40356 }
40357 if (!!typographyBlockExamples.length) {
40358 examples.push({
40359 name: "typography",
40360 title: (0, import_i18n125.__)("Typography"),
40361 category: "overview",
40362 blocks: typographyBlockExamples
40363 });
40364 }
40365 const otherBlockExamples = [
40366 "core/image",
40367 "core/separator",
40368 "core/buttons",
40369 "core/pullquote",
40370 "core/search"
40371 ];
40372 otherBlockExamples.forEach((blockName) => {
40373 const blockType = (0, import_blocks22.getBlockType)(blockName);
40374 if (blockType && blockType.example) {
40375 const blockExample = {
40376 name: blockName,
40377 title: blockType.title,
40378 category: "overview",
40379 /*
40380 * CSS generated from style attributes will take precedence over global styles CSS,
40381 * so remove the style attribute from the example to ensure the example
40382 * demonstrates changes to global styles.
40383 */
40384 blocks: (0, import_blocks22.getBlockFromExample)(blockName, {
40385 ...blockType.example,
40386 attributes: {
40387 ...blockType.example.attributes,
40388 style: void 0
40389 }
40390 })
40391 };
40392 examples.push(blockExample);
40393 }
40394 });
40395 return examples;
40396 }
40397 function getExamples(colors2) {
40398 const nonHeadingBlockExamples = (0, import_blocks22.getBlockTypes)().filter((blockType) => {
40399 const { name: name2, example, supports } = blockType;
40400 return name2 !== "core/heading" && !!example && supports?.inserter !== false;
40401 }).map((blockType) => ({
40402 name: blockType.name,
40403 title: blockType.title,
40404 category: blockType.category,
40405 /*
40406 * CSS generated from style attributes will take precedence over global styles CSS,
40407 * so remove the style attribute from the example to ensure the example
40408 * demonstrates changes to global styles.
40409 */
40410 blocks: (0, import_blocks22.getBlockFromExample)(blockType.name, {
40411 ...blockType.example,
40412 attributes: {
40413 ...blockType.example.attributes,
40414 style: void 0
40415 }
40416 })
40417 }));
40418 const isHeadingBlockRegistered = !!(0, import_blocks22.getBlockType)("core/heading");
40419 if (!isHeadingBlockRegistered) {
40420 return nonHeadingBlockExamples;
40421 }
40422 const headingsExample = {
40423 name: "core/heading",
40424 title: (0, import_i18n125.__)("Headings"),
40425 category: "text",
40426 blocks: [1, 2, 3, 4, 5, 6].map((level) => {
40427 return (0, import_blocks22.createBlock)("core/heading", {
40428 content: (0, import_i18n125.sprintf)(
40429 // translators: %d: heading level e.g: "1", "2", "3"
40430 (0, import_i18n125.__)("Heading %d"),
40431 level
40432 ),
40433 level
40434 });
40435 })
40436 };
40437 const colorExamples = getColorExamples(colors2);
40438 const overviewBlockExamples = getOverviewBlockExamples(colors2);
40439 return [
40440 headingsExample,
40441 ...colorExamples,
40442 ...nonHeadingBlockExamples,
40443 ...overviewBlockExamples
40444 ];
40445 }
40446
40447 // packages/editor/build-module/components/global-styles-renderer/index.mjs
40448 var import_element86 = __toESM(require_element(), 1);
40449 var import_data78 = __toESM(require_data(), 1);
40450
40451 // packages/editor/build-module/hooks/use-global-styles-output.mjs
40452 var import_blocks23 = __toESM(require_blocks(), 1);
40453 var import_data77 = __toESM(require_data(), 1);
40454 var import_element85 = __toESM(require_element(), 1);
40455 function useGlobalStylesOutputWithConfig(mergedConfig = {}, disableRootPadding = false) {
40456 const blockGap = useSetting2("spacing.blockGap");
40457 const hasBlockGapSupport = blockGap !== null;
40458 const hasFallbackGapSupport = !hasBlockGapSupport;
40459 const { disableLayoutStyles, getBlockStyles } = (0, import_data77.useSelect)((select6) => {
40460 const { getEditorSettings: getEditorSettings2 } = select6(store);
40461 const { getBlockStyles: getBlockStylesSelector } = select6(import_blocks23.store);
40462 const settings = getEditorSettings2();
40463 return {
40464 disableLayoutStyles: !!settings?.disableLayoutStyles,
40465 getBlockStyles: getBlockStylesSelector
40466 };
40467 }, []);
40468 return (0, import_element85.useMemo)(() => {
40469 if (!mergedConfig?.styles || !mergedConfig?.settings) {
40470 return [[], {}];
40471 }
40472 const blockTypes = (0, import_blocks23.getBlockTypes)();
40473 return generateGlobalStyles(mergedConfig, blockTypes, {
40474 hasBlockGapSupport,
40475 hasFallbackGapSupport,
40476 disableLayoutStyles,
40477 disableRootPadding,
40478 getBlockStyles
40479 });
40480 }, [
40481 hasBlockGapSupport,
40482 hasFallbackGapSupport,
40483 mergedConfig,
40484 disableLayoutStyles,
40485 disableRootPadding,
40486 getBlockStyles
40487 ]);
40488 }
40489 function useGlobalStylesOutput(disableRootPadding = false) {
40490 const { merged: mergedConfig } = useGlobalStyles();
40491 return useGlobalStylesOutputWithConfig(mergedConfig, disableRootPadding);
40492 }
40493
40494 // packages/editor/build-module/components/global-styles-renderer/index.mjs
40495 function useGlobalStylesRenderer(disableRootPadding) {
40496 const [styles, settings] = useGlobalStylesOutput(disableRootPadding);
40497 const { getEditorSettings: getEditorSettings2 } = (0, import_data78.useSelect)(store);
40498 const { updateEditorSettings: updateEditorSettings2 } = (0, import_data78.useDispatch)(store);
40499 (0, import_element86.useEffect)(() => {
40500 if (!styles || !settings) {
40501 return;
40502 }
40503 const currentStoreSettings = getEditorSettings2();
40504 const nonGlobalStyles = Object.values(
40505 currentStoreSettings.styles ?? []
40506 ).filter((style) => !style.isGlobalStyles);
40507 updateEditorSettings2({
40508 ...currentStoreSettings,
40509 styles: [...nonGlobalStyles, ...styles],
40510 __experimentalFeatures: settings
40511 });
40512 }, [styles, settings, updateEditorSettings2, getEditorSettings2]);
40513 }
40514 function GlobalStylesRenderer({ disableRootPadding }) {
40515 useGlobalStylesRenderer(disableRootPadding);
40516 return null;
40517 }
40518
40519 // packages/editor/build-module/components/style-book/index.mjs
40520 var import_jsx_runtime209 = __toESM(require_jsx_runtime(), 1);
40521 var { ExperimentalBlockEditorProvider: ExperimentalBlockEditorProvider2 } = unlock(import_block_editor37.privateApis);
40522 var { Tabs: Tabs3 } = unlock(import_components99.privateApis);
40523 function isObjectEmpty(object) {
40524 return !object || Object.keys(object).length === 0;
40525 }
40526 var scrollToSection = (anchorId, iframe) => {
40527 if (!anchorId || !iframe || !iframe?.contentDocument) {
40528 return;
40529 }
40530 const element = anchorId === "top" ? iframe.contentDocument.body : iframe.contentDocument.getElementById(anchorId);
40531 if (element) {
40532 element.scrollIntoView({
40533 behavior: "smooth"
40534 });
40535 }
40536 };
40537 var getStyleBookNavigationFromPath = (path) => {
40538 if (path && typeof path === "string") {
40539 if (path === "/" || path.startsWith("/typography") || path.startsWith("/colors") || path.startsWith("/blocks")) {
40540 return {
40541 top: true
40542 };
40543 }
40544 }
40545 return null;
40546 };
40547 function useMultiOriginPalettes() {
40548 const { colors: colors2, gradients } = (0, import_block_editor37.__experimentalUseMultipleOriginColorsAndGradients)();
40549 const [
40550 shouldDisplayDefaultDuotones,
40551 customDuotones,
40552 themeDuotones,
40553 defaultDuotones
40554 ] = (0, import_block_editor37.useSettings)(
40555 "color.defaultDuotone",
40556 "color.duotone.custom",
40557 "color.duotone.theme",
40558 "color.duotone.default"
40559 );
40560 const palettes = (0, import_element87.useMemo)(() => {
40561 const result = { colors: colors2, gradients, duotones: [] };
40562 if (themeDuotones && themeDuotones.length) {
40563 result.duotones.push({
40564 name: (0, import_i18n126._x)(
40565 "Theme",
40566 "Indicates these duotone filters come from the theme."
40567 ),
40568 slug: "theme",
40569 duotones: themeDuotones
40570 });
40571 }
40572 if (shouldDisplayDefaultDuotones && defaultDuotones && defaultDuotones.length) {
40573 result.duotones.push({
40574 name: (0, import_i18n126._x)(
40575 "Default",
40576 "Indicates these duotone filters come from WordPress."
40577 ),
40578 slug: "default",
40579 duotones: defaultDuotones
40580 });
40581 }
40582 if (customDuotones && customDuotones.length) {
40583 result.duotones.push({
40584 name: (0, import_i18n126._x)(
40585 "Custom",
40586 "Indicates these doutone filters are created by the user."
40587 ),
40588 slug: "custom",
40589 duotones: customDuotones
40590 });
40591 }
40592 return result;
40593 }, [
40594 colors2,
40595 gradients,
40596 customDuotones,
40597 themeDuotones,
40598 defaultDuotones,
40599 shouldDisplayDefaultDuotones
40600 ]);
40601 return palettes;
40602 }
40603 function getExamplesForSinglePageUse(examples) {
40604 const examplesForSinglePageUse = [];
40605 const overviewCategoryExamples = getExamplesByCategory(
40606 { slug: "overview" },
40607 examples
40608 );
40609 examplesForSinglePageUse.push(...overviewCategoryExamples.examples);
40610 const otherExamples = examples.filter((example) => {
40611 return example.category !== "overview" && !overviewCategoryExamples.examples.find(
40612 (overviewExample) => overviewExample.name === example.name
40613 );
40614 });
40615 examplesForSinglePageUse.push(...otherExamples);
40616 return examplesForSinglePageUse;
40617 }
40618 function applyBlockVariationsToExamples(examples, variation) {
40619 if (!variation) {
40620 return examples;
40621 }
40622 return examples.map((example) => {
40623 return {
40624 ...example,
40625 variation,
40626 blocks: Array.isArray(example.blocks) ? example.blocks.map((block) => ({
40627 ...block,
40628 attributes: {
40629 ...block.attributes,
40630 style: void 0,
40631 className: `is-style-${variation}`
40632 }
40633 })) : {
40634 ...example.blocks,
40635 attributes: {
40636 ...example.blocks.attributes,
40637 style: void 0,
40638 className: `is-style-${variation}`
40639 }
40640 }
40641 };
40642 });
40643 }
40644 function StyleBook({
40645 isSelected,
40646 onClick,
40647 onSelect,
40648 showTabs = true,
40649 userConfig = {},
40650 path = ""
40651 }, ref) {
40652 const textColor = useStyle2("color.text");
40653 const backgroundColor = useStyle2("color.background");
40654 const colors2 = useMultiOriginPalettes();
40655 const examples = (0, import_element87.useMemo)(() => getExamples(colors2), [colors2]);
40656 const tabs = (0, import_element87.useMemo)(
40657 () => getTopLevelStyleBookCategories().filter(
40658 (category) => examples.some(
40659 (example) => example.category === category.slug
40660 )
40661 ),
40662 [examples]
40663 );
40664 const examplesForSinglePageUse = getExamplesForSinglePageUse(examples);
40665 const { base: baseConfig } = useGlobalStyles();
40666 const goTo = getStyleBookNavigationFromPath(path);
40667 const mergedConfig = (0, import_element87.useMemo)(() => {
40668 if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) {
40669 return mergeGlobalStyles(baseConfig, userConfig);
40670 }
40671 return {};
40672 }, [baseConfig, userConfig]);
40673 const originalSettings = (0, import_data79.useSelect)(
40674 (select6) => select6(import_block_editor37.store).getSettings(),
40675 []
40676 );
40677 const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig);
40678 const settings = (0, import_element87.useMemo)(
40679 () => ({
40680 ...originalSettings,
40681 styles: !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : originalSettings.styles,
40682 isPreviewMode: true
40683 }),
40684 [globalStyles, originalSettings, userConfig]
40685 );
40686 return /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(
40687 "div",
40688 {
40689 ref,
40690 className: clsx_default("editor-style-book", {
40691 "is-button": !!onClick
40692 }),
40693 style: {
40694 color: textColor,
40695 background: backgroundColor
40696 },
40697 children: showTabs ? /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)(Tabs3, { children: [
40698 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { className: "editor-style-book__tablist-container", children: /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(Tabs3.TabList, { children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(Tabs3.Tab, { tabId: tab.slug, children: tab.title }, tab.slug)) }) }),
40699 tabs.map((tab) => {
40700 const categoryDefinition = tab.slug ? getTopLevelStyleBookCategories().find(
40701 (_category) => _category.slug === tab.slug
40702 ) : null;
40703 const filteredExamples = categoryDefinition ? getExamplesByCategory(
40704 categoryDefinition,
40705 examples
40706 ) : { examples };
40707 return /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(
40708 Tabs3.TabPanel,
40709 {
40710 tabId: tab.slug,
40711 focusable: false,
40712 className: "editor-style-book__tabpanel",
40713 children: /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(
40714 StyleBookBody,
40715 {
40716 category: tab.slug,
40717 examples: filteredExamples,
40718 isSelected,
40719 onSelect,
40720 settings,
40721 title: tab.title,
40722 goTo
40723 }
40724 )
40725 },
40726 tab.slug
40727 );
40728 })
40729 ] }) : /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(
40730 StyleBookBody,
40731 {
40732 examples: { examples: examplesForSinglePageUse },
40733 isSelected,
40734 onClick,
40735 onSelect,
40736 settings,
40737 goTo
40738 }
40739 )
40740 }
40741 );
40742 }
40743 var StyleBookPreview = ({
40744 userConfig = {},
40745 isStatic = false,
40746 path,
40747 onPathChange,
40748 settings: settingsProp
40749 }) => {
40750 const editorSettings2 = (0, import_data79.useSelect)(
40751 (select6) => settingsProp ?? select6(store).getEditorSettings(),
40752 [settingsProp]
40753 );
40754 const canUserUploadMedia = (0, import_data79.useSelect)(
40755 (select6) => select6(import_core_data58.store).canUser("create", {
40756 kind: "postType",
40757 name: "attachment"
40758 }),
40759 []
40760 );
40761 (0, import_element87.useEffect)(() => {
40762 (0, import_data79.dispatch)(import_block_editor37.store).updateSettings({
40763 ...editorSettings2,
40764 mediaUpload: canUserUploadMedia ? import_media_utils5.uploadMedia : void 0
40765 });
40766 }, [editorSettings2, canUserUploadMedia]);
40767 const [internalPath, setInternalPath] = (0, import_element87.useState)("/");
40768 const section = path ?? internalPath;
40769 const onChangeSection = onPathChange ?? setInternalPath;
40770 const isSelected = (blockName) => {
40771 return section === `/blocks/${encodeURIComponent(blockName)}` || section.startsWith(
40772 `/blocks/${encodeURIComponent(blockName)}/`
40773 );
40774 };
40775 const onSelect = (blockName, isBlockVariation = false) => {
40776 if (STYLE_BOOK_COLOR_GROUPS.find(
40777 (group) => group.slug === blockName
40778 )) {
40779 onChangeSection("/colors/palette");
40780 return;
40781 }
40782 if (blockName === "typography") {
40783 onChangeSection("/typography");
40784 return;
40785 }
40786 if (isBlockVariation) {
40787 return;
40788 }
40789 onChangeSection(`/blocks/${encodeURIComponent(blockName)}`);
40790 };
40791 const colors2 = useMultiOriginPalettes();
40792 const examples = getExamples(colors2);
40793 const examplesForSinglePageUse = getExamplesForSinglePageUse(examples);
40794 let previewCategory = null;
40795 let blockVariation = null;
40796 if (section.includes("/colors")) {
40797 previewCategory = "colors";
40798 } else if (section.includes("/typography")) {
40799 previewCategory = "text";
40800 } else if (section.includes("/blocks")) {
40801 previewCategory = "blocks";
40802 let blockName = decodeURIComponent(section).split("/blocks/")[1];
40803 if (blockName?.includes("/variations")) {
40804 [blockName, blockVariation] = blockName.split("/variations/");
40805 }
40806 if (blockName && examples.find((example) => example.name === blockName)) {
40807 previewCategory = blockName;
40808 }
40809 } else if (!isStatic) {
40810 previewCategory = "overview";
40811 }
40812 const categoryDefinition = STYLE_BOOK_PREVIEW_CATEGORIES.find(
40813 (category) => category.slug === previewCategory
40814 );
40815 const filteredExamples = (0, import_element87.useMemo)(() => {
40816 if (!categoryDefinition) {
40817 return {
40818 examples: [
40819 examples.find(
40820 (example) => example.name === previewCategory
40821 )
40822 ]
40823 };
40824 }
40825 return getExamplesByCategory(categoryDefinition, examples);
40826 }, [categoryDefinition, examples, previewCategory]);
40827 const displayedExamples = (0, import_element87.useMemo)(() => {
40828 if (!previewCategory) {
40829 return { examples: examplesForSinglePageUse };
40830 }
40831 if (blockVariation) {
40832 return {
40833 examples: applyBlockVariationsToExamples(
40834 filteredExamples.examples,
40835 blockVariation
40836 )
40837 };
40838 }
40839 return filteredExamples;
40840 }, [
40841 previewCategory,
40842 examplesForSinglePageUse,
40843 blockVariation,
40844 filteredExamples
40845 ]);
40846 const { base: baseConfig } = useGlobalStyles();
40847 const goTo = getStyleBookNavigationFromPath(section);
40848 const mergedConfig = (0, import_element87.useMemo)(() => {
40849 if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) {
40850 return mergeGlobalStyles(baseConfig, userConfig);
40851 }
40852 return {};
40853 }, [baseConfig, userConfig]);
40854 const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig);
40855 const settings = (0, import_element87.useMemo)(
40856 () => ({
40857 ...editorSettings2,
40858 styles: !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : editorSettings2.styles,
40859 isPreviewMode: true
40860 }),
40861 [globalStyles, editorSettings2, userConfig]
40862 );
40863 return /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { className: "editor-style-book", children: /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)(import_block_editor37.BlockEditorProvider, { settings, children: [
40864 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(GlobalStylesRenderer, { disableRootPadding: true }),
40865 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(
40866 StyleBookBody,
40867 {
40868 examples: displayedExamples,
40869 settings,
40870 goTo,
40871 isSelected: !isStatic ? isSelected : null,
40872 onSelect: !isStatic ? onSelect : null
40873 }
40874 )
40875 ] }) });
40876 };
40877 var StyleBookBody = ({
40878 examples,
40879 isSelected,
40880 onClick,
40881 onSelect,
40882 settings,
40883 title,
40884 goTo
40885 }) => {
40886 const [isFocused, setIsFocused] = (0, import_element87.useState)(false);
40887 const [hasIframeLoaded, setHasIframeLoaded] = (0, import_element87.useState)(false);
40888 const iframeRef = (0, import_element87.useRef)(null);
40889 const buttonModeProps = {
40890 role: "button",
40891 onFocus: () => setIsFocused(true),
40892 onBlur: () => setIsFocused(false),
40893 onKeyDown: (event) => {
40894 if (event.defaultPrevented) {
40895 return;
40896 }
40897 const { keyCode } = event;
40898 if (onClick && (keyCode === import_keycodes4.ENTER || keyCode === import_keycodes4.SPACE)) {
40899 event.preventDefault();
40900 onClick(event);
40901 }
40902 },
40903 onClick: (event) => {
40904 if (event.defaultPrevented) {
40905 return;
40906 }
40907 if (onClick) {
40908 event.preventDefault();
40909 onClick(event);
40910 }
40911 },
40912 readonly: true
40913 };
40914 const handleLoad = () => setHasIframeLoaded(true);
40915 (0, import_element87.useLayoutEffect)(() => {
40916 if (hasIframeLoaded && iframeRef.current && goTo?.top) {
40917 scrollToSection("top", iframeRef.current);
40918 }
40919 }, [goTo?.top, hasIframeLoaded]);
40920 return /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)(
40921 import_block_editor37.__unstableIframe,
40922 {
40923 onLoad: handleLoad,
40924 ref: iframeRef,
40925 className: clsx_default("editor-style-book__iframe", {
40926 "is-focused": isFocused && !!onClick,
40927 "is-button": !!onClick
40928 }),
40929 name: "style-book-canvas",
40930 tabIndex: 0,
40931 ...onClick ? buttonModeProps : {},
40932 children: [
40933 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(import_block_editor37.__unstableEditorStyles, { styles: settings.styles }),
40934 /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)("style", { children: [
40935 STYLE_BOOK_IFRAME_STYLES,
40936 !!onClick && "body { cursor: pointer; } body * { pointer-events: none; }"
40937 ] }),
40938 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(
40939 Examples,
40940 {
40941 className: "editor-style-book__examples",
40942 filteredExamples: examples,
40943 label: title ? (0, import_i18n126.sprintf)(
40944 // translators: %s: Category of blocks, e.g. Text.
40945 (0, import_i18n126.__)("Examples of blocks in the %s category"),
40946 title
40947 ) : (0, import_i18n126.__)("Examples of blocks"),
40948 isSelected,
40949 onSelect
40950 },
40951 title
40952 )
40953 ]
40954 }
40955 );
40956 };
40957 var Examples = (0, import_element87.memo)(
40958 ({ className, filteredExamples, label, isSelected, onSelect }) => {
40959 return /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)(
40960 import_components99.Composite,
40961 {
40962 orientation: "vertical",
40963 className,
40964 "aria-label": label,
40965 role: "grid",
40966 children: [
40967 !!filteredExamples?.examples?.length && filteredExamples.examples.map((example) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(
40968 Example,
40969 {
40970 id: `example-${example.name}`,
40971 title: example.title,
40972 content: example.content,
40973 blocks: example.blocks,
40974 isSelected: isSelected?.(example.name),
40975 onClick: !!onSelect ? () => onSelect(
40976 example.name,
40977 !!example.variation
40978 ) : null
40979 },
40980 example.name
40981 )),
40982 !!filteredExamples?.subcategories?.length && filteredExamples.subcategories.map((subcategory) => /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)(
40983 import_components99.Composite.Group,
40984 {
40985 className: "editor-style-book__subcategory",
40986 children: [
40987 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(import_components99.Composite.GroupLabel, { children: /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("h2", { className: "editor-style-book__subcategory-title", children: subcategory.title }) }),
40988 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(
40989 Subcategory,
40990 {
40991 examples: subcategory.examples,
40992 isSelected,
40993 onSelect
40994 }
40995 )
40996 ]
40997 },
40998 `subcategory-${subcategory.slug}`
40999 ))
41000 ]
41001 }
41002 );
41003 }
41004 );
41005 var Subcategory = ({ examples, isSelected, onSelect }) => {
41006 return !!examples?.length && examples.map((example) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(
41007 Example,
41008 {
41009 id: `example-${example.name}`,
41010 title: example.title,
41011 content: example.content,
41012 blocks: example.blocks,
41013 isSelected: isSelected?.(example.name),
41014 onClick: !!onSelect ? () => onSelect(example.name) : null
41015 },
41016 example.name
41017 ));
41018 };
41019 var disabledExamples = ["example-duotones"];
41020 var Example = ({ id, title, blocks, isSelected, onClick, content }) => {
41021 const originalSettings = (0, import_data79.useSelect)(
41022 (select6) => select6(import_block_editor37.store).getSettings(),
41023 []
41024 );
41025 const settings = (0, import_element87.useMemo)(
41026 () => ({
41027 ...originalSettings,
41028 focusMode: false,
41029 // Disable "Spotlight mode".
41030 isPreviewMode: true
41031 }),
41032 [originalSettings]
41033 );
41034 const renderedBlocks = (0, import_element87.useMemo)(
41035 () => Array.isArray(blocks) ? blocks : [blocks],
41036 [blocks]
41037 );
41038 const disabledProps = disabledExamples.includes(id) || !onClick ? {
41039 disabled: true,
41040 accessibleWhenDisabled: !!onClick
41041 } : {};
41042 return /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { role: "row", children: /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)(
41043 import_components99.Composite.Item,
41044 {
41045 className: clsx_default("editor-style-book__example", {
41046 "is-selected": isSelected,
41047 "is-disabled-example": !!disabledProps?.disabled
41048 }),
41049 id,
41050 "aria-label": !!onClick ? (0, import_i18n126.sprintf)(
41051 // translators: %s: Title of a block, e.g. Heading.
41052 (0, import_i18n126.__)("Open %s styles in Styles panel"),
41053 title
41054 ) : void 0,
41055 render: /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("div", {}),
41056 role: !!onClick ? "button" : null,
41057 onClick,
41058 ...disabledProps,
41059 children: [
41060 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)("span", { className: "editor-style-book__example-title", children: title }),
41061 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(
41062 "div",
41063 {
41064 className: "editor-style-book__example-preview",
41065 "aria-hidden": true,
41066 children: /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(import_components99.Disabled, { className: "editor-style-book__example-preview__content", children: content ? content : /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)(
41067 ExperimentalBlockEditorProvider2,
41068 {
41069 value: renderedBlocks,
41070 settings,
41071 children: [
41072 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(import_block_editor37.__unstableEditorStyles, {}),
41073 /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(import_block_editor37.BlockList, { renderAppender: false })
41074 ]
41075 }
41076 ) })
41077 }
41078 )
41079 ]
41080 }
41081 ) }) });
41082 };
41083 var style_book_default = (0, import_element87.forwardRef)(StyleBook);
41084
41085 // packages/editor/build-module/components/styles-canvas/style-book.mjs
41086 var import_jsx_runtime210 = __toESM(require_jsx_runtime(), 1);
41087 function StylesCanvasStyleBook({ path, onPathChange }, ref) {
41088 return /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(
41089 style_book_default,
41090 {
41091 ref,
41092 isSelected: (blockName) => (
41093 // Match '/blocks/core%2Fbutton' and
41094 // '/blocks/core%2Fbutton/typography', but not
41095 // '/blocks/core%2Fbuttons'.
41096 path === `/blocks/${encodeURIComponent(blockName)}` || path?.startsWith(
41097 `/blocks/${encodeURIComponent(blockName)}/`
41098 )
41099 ),
41100 onSelect: (blockName) => {
41101 if (STYLE_BOOK_COLOR_GROUPS.find(
41102 (group) => group.slug === blockName
41103 )) {
41104 onPathChange?.("/colors/palette");
41105 return;
41106 }
41107 if (blockName === "typography") {
41108 onPathChange?.("/typography");
41109 return;
41110 }
41111 onPathChange?.("/blocks/" + encodeURIComponent(blockName));
41112 }
41113 }
41114 );
41115 }
41116 var style_book_default2 = (0, import_element88.forwardRef)(StylesCanvasStyleBook);
41117
41118 // packages/editor/build-module/components/styles-canvas/revisions.mjs
41119 var import_components100 = __toESM(require_components(), 1);
41120 var import_block_editor38 = __toESM(require_block_editor(), 1);
41121 var import_data80 = __toESM(require_data(), 1);
41122 var import_element89 = __toESM(require_element(), 1);
41123 var import_jsx_runtime211 = __toESM(require_jsx_runtime(), 1);
41124 var {
41125 ExperimentalBlockEditorProvider: ExperimentalBlockEditorProvider3,
41126 __unstableBlockStyleVariationOverridesWithConfig
41127 } = unlock(import_block_editor38.privateApis);
41128 function isObjectEmpty2(object) {
41129 return !object || Object.keys(object).length === 0;
41130 }
41131 function StylesCanvasRevisions({ path }, ref) {
41132 const blocks = (0, import_data80.useSelect)((select6) => {
41133 return select6(import_block_editor38.store).getBlocks();
41134 }, []);
41135 const { user: userConfig, base: baseConfig } = useGlobalStyles();
41136 const { revisions, isLoading } = useGlobalStylesRevisions();
41137 const revisionId2 = (0, import_element89.useMemo)(() => {
41138 const match3 = path?.match(/^\/revisions\/(.+)$/);
41139 return match3 ? match3[1] : null;
41140 }, [path]);
41141 const selectedRevision = (0, import_element89.useMemo)(() => {
41142 if (!revisionId2 || !revisions.length) {
41143 return null;
41144 }
41145 return revisions.find(
41146 (rev) => String(rev.id) === String(revisionId2)
41147 );
41148 }, [revisionId2, revisions]);
41149 const displayConfig = selectedRevision || userConfig;
41150 const mergedConfig = (0, import_element89.useMemo)(() => {
41151 if (!isObjectEmpty2(displayConfig) && !isObjectEmpty2(baseConfig)) {
41152 return mergeGlobalStyles(baseConfig, displayConfig);
41153 }
41154 return {};
41155 }, [baseConfig, displayConfig]);
41156 const renderedBlocksArray = (0, import_element89.useMemo)(
41157 () => Array.isArray(blocks) ? blocks : [blocks],
41158 [blocks]
41159 );
41160 const originalSettings = (0, import_data80.useSelect)(
41161 (select6) => select6(import_block_editor38.store).getSettings(),
41162 []
41163 );
41164 const settings = (0, import_element89.useMemo)(
41165 () => ({
41166 ...originalSettings,
41167 isPreviewMode: true
41168 }),
41169 [originalSettings]
41170 );
41171 const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig);
41172 const editorStyles = !isObjectEmpty2(globalStyles) && !isObjectEmpty2(displayConfig) ? globalStyles : settings.styles;
41173 if (isLoading) {
41174 return null;
41175 }
41176 return /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(
41177 import_block_editor38.__unstableIframe,
41178 {
41179 ref,
41180 className: "editor-revisions__iframe",
41181 name: "revisions",
41182 tabIndex: 0,
41183 children: [
41184 /* @__PURE__ */ (0, import_jsx_runtime211.jsx)("style", {
41185 // Forming a "block formatting context" to prevent margin collapsing.
41186 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
41187 children: `.is-root-container { display: flow-root; }`
41188 }),
41189 /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(import_components100.Disabled, { className: "editor-revisions__example-preview__content", children: /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(
41190 ExperimentalBlockEditorProvider3,
41191 {
41192 value: renderedBlocksArray,
41193 settings,
41194 children: [
41195 /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(import_block_editor38.BlockList, { renderAppender: false }),
41196 /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(import_block_editor38.__unstableEditorStyles, { styles: editorStyles }),
41197 /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(
41198 __unstableBlockStyleVariationOverridesWithConfig,
41199 {
41200 config: mergedConfig
41201 }
41202 )
41203 ]
41204 }
41205 ) })
41206 ]
41207 }
41208 );
41209 }
41210 var revisions_default = (0, import_element89.forwardRef)(StylesCanvasRevisions);
41211
41212 // packages/editor/build-module/components/resizable-editor/index.mjs
41213 var import_element90 = __toESM(require_element(), 1);
41214 var import_components102 = __toESM(require_components(), 1);
41215
41216 // packages/editor/build-module/components/resizable-editor/resize-handle.mjs
41217 var import_i18n127 = __toESM(require_i18n(), 1);
41218 var import_keycodes5 = __toESM(require_keycodes(), 1);
41219 var import_components101 = __toESM(require_components(), 1);
41220 var import_jsx_runtime212 = __toESM(require_jsx_runtime(), 1);
41221 var DELTA_DISTANCE = 20;
41222 function ResizeHandle({ direction, resizeWidthBy }) {
41223 function handleKeyDown(event) {
41224 const { keyCode } = event;
41225 if (keyCode !== import_keycodes5.LEFT && keyCode !== import_keycodes5.RIGHT) {
41226 return;
41227 }
41228 event.preventDefault();
41229 if (direction === "left" && keyCode === import_keycodes5.LEFT || direction === "right" && keyCode === import_keycodes5.RIGHT) {
41230 resizeWidthBy(DELTA_DISTANCE);
41231 } else if (direction === "left" && keyCode === import_keycodes5.RIGHT || direction === "right" && keyCode === import_keycodes5.LEFT) {
41232 resizeWidthBy(-DELTA_DISTANCE);
41233 }
41234 }
41235 const resizeHandleVariants = {
41236 active: {
41237 opacity: 1,
41238 scaleY: 1.3
41239 }
41240 };
41241 const resizableHandleHelpId = `resizable-editor__resize-help-${direction}`;
41242 return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)(import_jsx_runtime212.Fragment, { children: [
41243 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components101.Tooltip, { text: (0, import_i18n127.__)("Drag to resize"), children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(
41244 import_components101.__unstableMotion.button,
41245 {
41246 className: `editor-resizable-editor__resize-handle is-${direction}`,
41247 "aria-label": (0, import_i18n127.__)("Drag to resize"),
41248 "aria-describedby": resizableHandleHelpId,
41249 onKeyDown: handleKeyDown,
41250 variants: resizeHandleVariants,
41251 whileFocus: "active",
41252 whileHover: "active",
41253 whileTap: "active",
41254 role: "separator",
41255 "aria-orientation": "vertical"
41256 },
41257 "handle"
41258 ) }),
41259 /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(import_components101.VisuallyHidden, { id: resizableHandleHelpId, children: (0, import_i18n127.__)("Use left and right arrow keys to resize the canvas.") })
41260 ] });
41261 }
41262
41263 // packages/editor/build-module/components/resizable-editor/index.mjs
41264 var import_jsx_runtime213 = __toESM(require_jsx_runtime(), 1);
41265 var HANDLE_STYLES_OVERRIDE = {
41266 position: void 0,
41267 userSelect: void 0,
41268 cursor: void 0,
41269 width: void 0,
41270 height: void 0,
41271 top: void 0,
41272 right: void 0,
41273 bottom: void 0,
41274 left: void 0
41275 };
41276 function ResizableEditor({ className, enableResizing, height, children }) {
41277 const [width, setWidth] = (0, import_element90.useState)("100%");
41278 const resizableRef = (0, import_element90.useRef)();
41279 const resizeWidthBy = (0, import_element90.useCallback)((deltaPixels) => {
41280 if (resizableRef.current) {
41281 setWidth(resizableRef.current.offsetWidth + deltaPixels);
41282 }
41283 }, []);
41284 return /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(
41285 import_components102.ResizableBox,
41286 {
41287 className: clsx_default("editor-resizable-editor", className, {
41288 "is-resizable": enableResizing
41289 }),
41290 ref: (api) => {
41291 resizableRef.current = api?.resizable;
41292 },
41293 size: {
41294 width: enableResizing ? width : "100%",
41295 height: enableResizing && height ? height : "100%"
41296 },
41297 onResizeStop: (event, direction, element) => {
41298 setWidth(element.style.width);
41299 },
41300 minWidth: 300,
41301 maxWidth: "100%",
41302 maxHeight: "100%",
41303 enable: {
41304 left: enableResizing,
41305 right: enableResizing
41306 },
41307 showHandle: enableResizing,
41308 resizeRatio: 2,
41309 handleComponent: {
41310 left: /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(
41311 ResizeHandle,
41312 {
41313 direction: "left",
41314 resizeWidthBy
41315 }
41316 ),
41317 right: /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(
41318 ResizeHandle,
41319 {
41320 direction: "right",
41321 resizeWidthBy
41322 }
41323 )
41324 },
41325 handleClasses: void 0,
41326 handleStyles: {
41327 left: HANDLE_STYLES_OVERRIDE,
41328 right: HANDLE_STYLES_OVERRIDE
41329 },
41330 children
41331 }
41332 );
41333 }
41334 var resizable_editor_default = ResizableEditor;
41335
41336 // packages/editor/build-module/components/styles-canvas/index.mjs
41337 var import_jsx_runtime214 = __toESM(require_jsx_runtime(), 1);
41338 function getStylesCanvasTitle(path, showStylebook2) {
41339 if (showStylebook2) {
41340 return (0, import_i18n128.__)("Style Book");
41341 }
41342 if (path?.startsWith("/revisions")) {
41343 return (0, import_i18n128.__)("Style Revisions");
41344 }
41345 return "";
41346 }
41347 function StylesCanvas() {
41348 const { stylesPath: stylesPath2, showStylebook: showStylebook2, showListViewByDefault } = (0, import_data81.useSelect)(
41349 (select6) => {
41350 const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock(
41351 select6(store)
41352 );
41353 const _showListViewByDefault = select6(import_preferences11.store).get(
41354 "core",
41355 "showListViewByDefault"
41356 );
41357 return {
41358 stylesPath: getStylesPath2(),
41359 showStylebook: getShowStylebook2(),
41360 showListViewByDefault: _showListViewByDefault
41361 };
41362 },
41363 []
41364 );
41365 const { resetStylesNavigation: resetStylesNavigation2, setStylesPath: setStylesPath2 } = unlock(
41366 (0, import_data81.useDispatch)(store)
41367 );
41368 const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data81.useDispatch)(store);
41369 const focusOnMountRef = (0, import_compose18.useFocusOnMount)("firstElement");
41370 const sectionFocusReturnRef = (0, import_compose18.useFocusReturn)();
41371 let content = null;
41372 if (showStylebook2) {
41373 content = /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
41374 style_book_default2,
41375 {
41376 path: stylesPath2,
41377 onPathChange: setStylesPath2,
41378 ref: sectionFocusReturnRef
41379 }
41380 );
41381 } else if (stylesPath2?.startsWith("/revisions")) {
41382 content = /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
41383 revisions_default,
41384 {
41385 path: stylesPath2,
41386 ref: sectionFocusReturnRef
41387 }
41388 );
41389 }
41390 const title = getStylesCanvasTitle(stylesPath2, showStylebook2);
41391 const onCloseCanvas = () => {
41392 setIsListViewOpened2(showListViewByDefault);
41393 resetStylesNavigation2();
41394 };
41395 const closeOnEscape = (event) => {
41396 if (event.keyCode === import_keycodes6.ESCAPE && !event.defaultPrevented) {
41397 event.preventDefault();
41398 onCloseCanvas();
41399 }
41400 };
41401 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("div", { className: "editor-styles-canvas", children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(resizable_editor_default, { enableResizing: false, children: /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(
41402 "section",
41403 {
41404 className: "editor-styles-canvas__section",
41405 ref: focusOnMountRef,
41406 onKeyDown: closeOnEscape,
41407 "aria-label": title,
41408 children: [
41409 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
41410 import_components103.Button,
41411 {
41412 size: "compact",
41413 className: "editor-styles-canvas__close-button",
41414 icon: close_small_default,
41415 label: (0, import_i18n128.__)("Close"),
41416 onClick: onCloseCanvas
41417 }
41418 ),
41419 content
41420 ]
41421 }
41422 ) }) });
41423 }
41424
41425 // packages/editor/build-module/components/document-bar/useEditedSectionDetails.mjs
41426 var import_data82 = __toESM(require_data(), 1);
41427 var import_html_entities10 = __toESM(require_html_entities(), 1);
41428 var import_block_editor39 = __toESM(require_block_editor(), 1);
41429 var import_core_data59 = __toESM(require_core_data(), 1);
41430 function useEditedSectionDetails() {
41431 return (0, import_data82.useSelect)((select6) => {
41432 const {
41433 getBlockAttributes: getBlockAttributes2,
41434 getBlockName: getBlockName2,
41435 __experimentalGetParsedPattern
41436 } = select6(import_block_editor39.store);
41437 const { getEditedEntityRecord, getCurrentTheme } = select6(import_core_data59.store);
41438 const { getEditedContentOnlySection } = unlock(
41439 select6(import_block_editor39.store)
41440 );
41441 const editedSectionId = getEditedContentOnlySection();
41442 if (!editedSectionId) {
41443 return null;
41444 }
41445 const attributes = getBlockAttributes2(editedSectionId);
41446 const patternName = attributes?.metadata?.patternName;
41447 if (patternName) {
41448 const pattern = typeof __experimentalGetParsedPattern === "function" ? __experimentalGetParsedPattern(patternName) : null;
41449 return {
41450 patternName,
41451 patternTitle: pattern?.title || attributes?.metadata?.name,
41452 type: "pattern"
41453 };
41454 }
41455 const blockName = getBlockName2(editedSectionId);
41456 if (blockName === "core/block" && !!attributes?.ref) {
41457 const entity = getEditedEntityRecord(
41458 "postType",
41459 "wp_block",
41460 attributes.ref
41461 );
41462 if (entity?.title) {
41463 return {
41464 patternName: attributes.ref,
41465 patternTitle: (0, import_html_entities10.decodeEntities)(entity.title),
41466 type: "synced-pattern"
41467 };
41468 }
41469 }
41470 if (blockName === "core/template-part" && !!attributes?.slug) {
41471 const theme = attributes.theme || getCurrentTheme()?.stylesheet;
41472 const templatePartId = theme ? `${theme}//${attributes.slug}` : null;
41473 if (templatePartId) {
41474 const entity = getEditedEntityRecord(
41475 "postType",
41476 "wp_template_part",
41477 templatePartId
41478 );
41479 if (entity?.title) {
41480 return {
41481 patternName: attributes.slug,
41482 patternTitle: (0, import_html_entities10.decodeEntities)(entity.title),
41483 type: "template-part"
41484 };
41485 }
41486 }
41487 }
41488 return null;
41489 }, []);
41490 }
41491
41492 // packages/editor/build-module/components/document-bar/index.mjs
41493 var import_jsx_runtime215 = __toESM(require_jsx_runtime(), 1);
41494 var MotionButton = import_components104.__unstableMotion.create(import_components104.Button);
41495 function DocumentBar(props) {
41496 const { stopEditingContentOnlySection } = unlock(
41497 (0, import_data83.useDispatch)(import_block_editor40.store)
41498 );
41499 const unlockedPatternInfo = useEditedSectionDetails();
41500 const {
41501 postId: postId2,
41502 postType: postType2,
41503 postTypeLabel,
41504 documentTitle,
41505 isNotFound,
41506 templateTitle,
41507 onNavigateToPreviousEntityRecord,
41508 isTemplatePreview,
41509 stylesCanvasTitle
41510 } = (0, import_data83.useSelect)((select6) => {
41511 const {
41512 getCurrentPostType: getCurrentPostType2,
41513 getCurrentPostId: getCurrentPostId2,
41514 getEditorSettings: getEditorSettings2,
41515 getRenderingMode: getRenderingMode2
41516 } = select6(store);
41517 const {
41518 getEditedEntityRecord,
41519 getPostType,
41520 getCurrentTheme,
41521 isResolving: isResolvingSelector
41522 } = select6(import_core_data60.store);
41523 const _postType = getCurrentPostType2();
41524 const _postId = getCurrentPostId2();
41525 const _document = getEditedEntityRecord(
41526 "postType",
41527 _postType,
41528 _postId
41529 );
41530 const { default_template_types: templateTypes = [] } = getCurrentTheme() ?? {};
41531 const _templateInfo = getTemplateInfo({
41532 templateTypes,
41533 template: _document
41534 });
41535 const _postTypeLabel = getPostType(_postType)?.labels?.singular_name;
41536 const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock(
41537 select6(store)
41538 );
41539 const _stylesPath = getStylesPath2();
41540 const _showStylebook = getShowStylebook2();
41541 const _stylesCanvasTitle = getStylesCanvasTitle(
41542 _stylesPath,
41543 _showStylebook
41544 );
41545 return {
41546 postId: _postId,
41547 postType: _postType,
41548 postTypeLabel: _postTypeLabel,
41549 documentTitle: _document.title,
41550 isNotFound: !_document && !isResolvingSelector(
41551 "getEditedEntityRecord",
41552 "postType",
41553 _postType,
41554 _postId
41555 ),
41556 templateTitle: _templateInfo.title,
41557 onNavigateToPreviousEntityRecord: getEditorSettings2().onNavigateToPreviousEntityRecord,
41558 isTemplatePreview: getRenderingMode2() === "template-locked",
41559 stylesCanvasTitle: _stylesCanvasTitle
41560 };
41561 }, []);
41562 const { open: openCommandCenter } = (0, import_data83.useDispatch)(import_commands3.store);
41563 const isReducedMotion = (0, import_compose19.useReducedMotion)();
41564 const isTemplate2 = TEMPLATE_POST_TYPES.includes(postType2);
41565 const hasBackButton = !!onNavigateToPreviousEntityRecord || !!unlockedPatternInfo;
41566 const entityTitle = isTemplate2 ? templateTitle : documentTitle;
41567 const title = unlockedPatternInfo?.patternTitle || props.title || stylesCanvasTitle || entityTitle;
41568 const icon = props.icon;
41569 const handleBackClick = (event) => {
41570 event.stopPropagation();
41571 if (unlockedPatternInfo) {
41572 stopEditingContentOnlySection();
41573 } else if (onNavigateToPreviousEntityRecord) {
41574 onNavigateToPreviousEntityRecord();
41575 }
41576 };
41577 const pageTypeBadge = usePageTypeBadge(postId2);
41578 const mountedRef = (0, import_element91.useRef)(false);
41579 (0, import_element91.useEffect)(() => {
41580 mountedRef.current = true;
41581 }, []);
41582 return /* @__PURE__ */ (0, import_jsx_runtime215.jsxs)(
41583 "div",
41584 {
41585 className: clsx_default("editor-document-bar", {
41586 "has-back-button": hasBackButton
41587 }),
41588 children: [
41589 /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(import_components104.__unstableAnimatePresence, { children: hasBackButton && /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(
41590 MotionButton,
41591 {
41592 className: "editor-document-bar__back",
41593 icon: (0, import_i18n129.isRTL)() ? chevron_right_small_default : chevron_left_small_default,
41594 onClick: handleBackClick,
41595 size: "compact",
41596 initial: mountedRef.current ? { opacity: 0, transform: "translateX(15%)" } : false,
41597 animate: { opacity: 1, transform: "translateX(0%)" },
41598 exit: { opacity: 0, transform: "translateX(15%)" },
41599 transition: isReducedMotion ? { duration: 0 } : void 0,
41600 children: (0, import_i18n129.__)("Back")
41601 }
41602 ) }),
41603 !isTemplate2 && isTemplatePreview && !hasBackButton && /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(
41604 import_block_editor40.BlockIcon,
41605 {
41606 icon: layout_default,
41607 className: "editor-document-bar__icon-layout"
41608 }
41609 ),
41610 isNotFound ? /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(import_components104.__experimentalText, { children: (0, import_i18n129.__)("Document not found") }) : /* @__PURE__ */ (0, import_jsx_runtime215.jsxs)(
41611 import_components104.Button,
41612 {
41613 className: "editor-document-bar__command",
41614 onClick: () => openCommandCenter(),
41615 size: "compact",
41616 children: [
41617 /* @__PURE__ */ (0, import_jsx_runtime215.jsxs)(
41618 import_components104.__unstableMotion.div,
41619 {
41620 className: "editor-document-bar__title",
41621 initial: mountedRef.current ? {
41622 opacity: 0,
41623 transform: hasBackButton ? "translateX(15%)" : "translateX(-15%)"
41624 } : false,
41625 animate: {
41626 opacity: 1,
41627 transform: "translateX(0%)"
41628 },
41629 transition: isReducedMotion ? { duration: 0 } : void 0,
41630 children: [
41631 icon && /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(import_block_editor40.BlockIcon, { icon }),
41632 /* @__PURE__ */ (0, import_jsx_runtime215.jsxs)(import_components104.__experimentalText, { size: "body", as: "h1", children: [
41633 /* @__PURE__ */ (0, import_jsx_runtime215.jsx)("span", { className: "editor-document-bar__post-title", children: title ? (0, import_dom2.__unstableStripHTML)(title) : (0, import_i18n129.__)("No title") }),
41634 unlockedPatternInfo && /* @__PURE__ */ (0, import_jsx_runtime215.jsx)("span", { className: "editor-document-bar__post-type-label", children: unlockedPatternInfo.type === "template-part" ? `\xB7 ${(0, import_i18n129.__)("Template Part")}` : `\xB7 ${(0, import_i18n129.__)("Pattern")}` }),
41635 !unlockedPatternInfo && pageTypeBadge && /* @__PURE__ */ (0, import_jsx_runtime215.jsx)("span", { className: "editor-document-bar__post-type-label", children: `\xB7 ${pageTypeBadge}` }),
41636 !unlockedPatternInfo && postTypeLabel && !props.title && !pageTypeBadge && /* @__PURE__ */ (0, import_jsx_runtime215.jsx)("span", { className: "editor-document-bar__post-type-label", children: `\xB7 ${(0, import_html_entities11.decodeEntities)(
41637 postTypeLabel
41638 )}` })
41639 ] })
41640 ]
41641 },
41642 hasBackButton
41643 ),
41644 /* @__PURE__ */ (0, import_jsx_runtime215.jsx)("span", { className: "editor-document-bar__shortcut", children: import_keycodes7.displayShortcut.primary("k") })
41645 ]
41646 }
41647 )
41648 ]
41649 }
41650 );
41651 }
41652
41653 // packages/editor/build-module/components/document-outline/index.mjs
41654 var import_i18n130 = __toESM(require_i18n(), 1);
41655 var import_data84 = __toESM(require_data(), 1);
41656 var import_element92 = __toESM(require_element(), 1);
41657 var import_rich_text2 = __toESM(require_rich_text(), 1);
41658 var import_block_editor41 = __toESM(require_block_editor(), 1);
41659 var import_core_data61 = __toESM(require_core_data(), 1);
41660 var import_components105 = __toESM(require_components(), 1);
41661
41662 // packages/editor/build-module/components/document-outline/item.mjs
41663 var import_jsx_runtime216 = __toESM(require_jsx_runtime(), 1);
41664 var TableOfContentsItem = ({
41665 children,
41666 isValid: isValid2,
41667 isDisabled,
41668 level,
41669 href,
41670 onSelect
41671 }) => {
41672 function handleClick(event) {
41673 if (isDisabled) {
41674 event.preventDefault();
41675 return;
41676 }
41677 onSelect();
41678 }
41679 return /* @__PURE__ */ (0, import_jsx_runtime216.jsx)(
41680 "li",
41681 {
41682 className: clsx_default(
41683 "document-outline__item",
41684 `is-${level.toLowerCase()}`,
41685 {
41686 "is-invalid": !isValid2,
41687 "is-disabled": isDisabled
41688 }
41689 ),
41690 children: /* @__PURE__ */ (0, import_jsx_runtime216.jsxs)(
41691 "a",
41692 {
41693 href,
41694 className: "document-outline__button",
41695 "aria-disabled": isDisabled,
41696 onClick: handleClick,
41697 children: [
41698 /* @__PURE__ */ (0, import_jsx_runtime216.jsx)(
41699 "span",
41700 {
41701 className: "document-outline__emdash",
41702 "aria-hidden": "true"
41703 }
41704 ),
41705 /* @__PURE__ */ (0, import_jsx_runtime216.jsx)("strong", { className: "document-outline__level", children: level }),
41706 /* @__PURE__ */ (0, import_jsx_runtime216.jsx)("span", { className: "document-outline__item-content", children })
41707 ]
41708 }
41709 )
41710 }
41711 );
41712 };
41713 var item_default = TableOfContentsItem;
41714
41715 // packages/editor/build-module/components/document-outline/index.mjs
41716 var import_jsx_runtime217 = __toESM(require_jsx_runtime(), 1);
41717 var emptyHeadingContent = /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("em", { children: (0, import_i18n130.__)("(Empty heading)") });
41718 var incorrectLevelContent = [
41719 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("br", {}, "incorrect-break"),
41720 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("em", { children: (0, import_i18n130.__)("(Incorrect heading level)") }, "incorrect-message")
41721 ];
41722 var singleH1Headings = [
41723 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("br", {}, "incorrect-break-h1"),
41724 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("em", { children: (0, import_i18n130.__)("(Your theme may already use a H1 for the post title)") }, "incorrect-message-h1")
41725 ];
41726 var multipleH1Headings = [
41727 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("br", {}, "incorrect-break-multiple-h1"),
41728 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("em", { children: (0, import_i18n130.__)("(Multiple H1 headings are not recommended)") }, "incorrect-message-multiple-h1")
41729 ];
41730 function EmptyOutlineIllustration() {
41731 return /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(
41732 import_components105.SVG,
41733 {
41734 width: "138",
41735 height: "148",
41736 viewBox: "0 0 138 148",
41737 fill: "none",
41738 xmlns: "http://www.w3.org/2000/svg",
41739 children: [
41740 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components105.Rect, { width: "138", height: "148", rx: "4", fill: "#F0F6FC" }),
41741 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components105.Line, { x1: "44", y1: "28", x2: "24", y2: "28", stroke: "#DDDDDD" }),
41742 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components105.Rect, { x: "48", y: "16", width: "27", height: "23", rx: "4", fill: "#DDDDDD" }),
41743 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
41744 import_components105.Path,
41745 {
41746 d: "M54.7585 32V23.2727H56.6037V26.8736H60.3494V23.2727H62.1903V32H60.3494V28.3949H56.6037V32H54.7585ZM67.4574 23.2727V32H65.6122V25.0241H65.5611L63.5625 26.277V24.6406L65.723 23.2727H67.4574Z",
41747 fill: "black"
41748 }
41749 ),
41750 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components105.Line, { x1: "55", y1: "59", x2: "24", y2: "59", stroke: "#DDDDDD" }),
41751 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components105.Rect, { x: "59", y: "47", width: "29", height: "23", rx: "4", fill: "#DDDDDD" }),
41752 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
41753 import_components105.Path,
41754 {
41755 d: "M65.7585 63V54.2727H67.6037V57.8736H71.3494V54.2727H73.1903V63H71.3494V59.3949H67.6037V63H65.7585ZM74.6605 63V61.6705L77.767 58.794C78.0313 58.5384 78.2528 58.3082 78.4318 58.1037C78.6136 57.8991 78.7514 57.6989 78.8452 57.5028C78.9389 57.304 78.9858 57.0895 78.9858 56.8594C78.9858 56.6037 78.9276 56.3835 78.8111 56.1989C78.6946 56.0114 78.5355 55.8679 78.3338 55.7685C78.1321 55.6662 77.9034 55.6151 77.6477 55.6151C77.3807 55.6151 77.1477 55.669 76.9489 55.777C76.75 55.8849 76.5966 56.0398 76.4886 56.2415C76.3807 56.4432 76.3267 56.6832 76.3267 56.9616H74.5753C74.5753 56.3906 74.7045 55.8949 74.9631 55.4744C75.2216 55.054 75.5838 54.7287 76.0497 54.4986C76.5156 54.2685 77.0526 54.1534 77.6605 54.1534C78.2855 54.1534 78.8295 54.2642 79.2926 54.4858C79.7585 54.7045 80.1207 55.0085 80.3793 55.3977C80.6378 55.7869 80.767 56.233 80.767 56.7358C80.767 57.0653 80.7017 57.3906 80.571 57.7116C80.4432 58.0327 80.2145 58.3892 79.8849 58.7812C79.5554 59.1705 79.0909 59.6378 78.4915 60.1832L77.2173 61.4318V61.4915H80.8821V63H74.6605Z",
41756 fill: "black"
41757 }
41758 ),
41759 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components105.Line, { x1: "80", y1: "90", x2: "24", y2: "90", stroke: "#DDDDDD" }),
41760 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components105.Rect, { x: "84", y: "78", width: "30", height: "23", rx: "4", fill: "#F0B849" }),
41761 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
41762 import_components105.Path,
41763 {
41764 d: "M90.7585 94V85.2727H92.6037V88.8736H96.3494V85.2727H98.1903V94H96.3494V90.3949H92.6037V94H90.7585ZM99.5284 92.4659V91.0128L103.172 85.2727H104.425V87.2841H103.683L101.386 90.919V90.9872H106.564V92.4659H99.5284ZM103.717 94V92.0227L103.751 91.3793V85.2727H105.482V94H103.717Z",
41765 fill: "black"
41766 }
41767 ),
41768 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components105.Line, { x1: "66", y1: "121", x2: "24", y2: "121", stroke: "#DDDDDD" }),
41769 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components105.Rect, { x: "70", y: "109", width: "29", height: "23", rx: "4", fill: "#DDDDDD" }),
41770 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
41771 import_components105.Path,
41772 {
41773 d: "M76.7585 125V116.273H78.6037V119.874H82.3494V116.273H84.1903V125H82.3494V121.395H78.6037V125H76.7585ZM88.8864 125.119C88.25 125.119 87.6832 125.01 87.1861 124.791C86.6918 124.57 86.3011 124.266 86.0142 123.879C85.7301 123.49 85.5838 123.041 85.5753 122.533H87.4332C87.4446 122.746 87.5142 122.933 87.642 123.095C87.7727 123.254 87.946 123.378 88.1619 123.466C88.3778 123.554 88.6207 123.598 88.8906 123.598C89.1719 123.598 89.4205 123.548 89.6364 123.449C89.8523 123.349 90.0213 123.212 90.1435 123.036C90.2656 122.859 90.3267 122.656 90.3267 122.426C90.3267 122.193 90.2614 121.987 90.1307 121.808C90.0028 121.626 89.8182 121.484 89.5767 121.382C89.3381 121.28 89.054 121.229 88.7244 121.229H87.9105V119.874H88.7244C89.0028 119.874 89.2486 119.825 89.4616 119.729C89.6776 119.632 89.8452 119.499 89.9645 119.328C90.0838 119.155 90.1435 118.953 90.1435 118.723C90.1435 118.504 90.0909 118.312 89.9858 118.148C89.8835 117.98 89.7386 117.849 89.5511 117.756C89.3665 117.662 89.1506 117.615 88.9034 117.615C88.6534 117.615 88.4247 117.661 88.2173 117.751C88.0099 117.839 87.8438 117.966 87.7188 118.131C87.5938 118.295 87.527 118.489 87.5185 118.71H85.75C85.7585 118.207 85.902 117.764 86.1804 117.381C86.4588 116.997 86.8338 116.697 87.3054 116.482C87.7798 116.263 88.3153 116.153 88.9119 116.153C89.5142 116.153 90.0412 116.263 90.4929 116.482C90.9446 116.7 91.2955 116.996 91.5455 117.368C91.7983 117.737 91.9233 118.152 91.9205 118.612C91.9233 119.101 91.7713 119.509 91.4645 119.835C91.1605 120.162 90.7642 120.369 90.2756 120.457V120.526C90.9176 120.608 91.4063 120.831 91.7415 121.195C92.0795 121.555 92.2472 122.007 92.2443 122.55C92.2472 123.047 92.1037 123.489 91.8139 123.875C91.527 124.261 91.1307 124.565 90.625 124.787C90.1193 125.009 89.5398 125.119 88.8864 125.119Z",
41774 fill: "black"
41775 }
41776 )
41777 ]
41778 }
41779 );
41780 }
41781 var computeOutlineHeadings = (blocks = []) => {
41782 return blocks.filter((block) => block.name === "core/heading").map((block) => ({
41783 ...block,
41784 level: block.attributes.level,
41785 isEmpty: isEmptyHeading(block)
41786 }));
41787 };
41788 var isEmptyHeading = (heading) => !heading.attributes.content || heading.attributes.content.trim().length === 0;
41789 function DocumentOutline({
41790 onSelect,
41791 hasOutlineItemsDisabled
41792 }) {
41793 const { selectBlock: selectBlock2 } = (0, import_data84.useDispatch)(import_block_editor41.store);
41794 const { title, isTitleSupported } = (0, import_data84.useSelect)((select6) => {
41795 const { getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
41796 const { getPostType } = select6(import_core_data61.store);
41797 const postType2 = getPostType(getEditedPostAttribute2("type"));
41798 return {
41799 title: getEditedPostAttribute2("title"),
41800 isTitleSupported: postType2?.supports?.title ?? false
41801 };
41802 });
41803 const blocks = (0, import_data84.useSelect)((select6) => {
41804 const { getClientIdsWithDescendants: getClientIdsWithDescendants2, getBlock: getBlock2 } = select6(import_block_editor41.store);
41805 const clientIds = getClientIdsWithDescendants2();
41806 return clientIds.map((id) => getBlock2(id));
41807 });
41808 const contentBlocks = (0, import_data84.useSelect)((select6) => {
41809 if (select6(store).getRenderingMode() === "post-only") {
41810 return void 0;
41811 }
41812 const { getBlocksByName, getClientIdsOfDescendants: getClientIdsOfDescendants2 } = select6(import_block_editor41.store);
41813 const [postContentClientId] = getBlocksByName("core/post-content");
41814 if (!postContentClientId) {
41815 return void 0;
41816 }
41817 return getClientIdsOfDescendants2(postContentClientId);
41818 }, []);
41819 const prevHeadingLevelRef = (0, import_element92.useRef)(1);
41820 const headings = (0, import_element92.useMemo)(
41821 () => computeOutlineHeadings(blocks),
41822 [blocks]
41823 );
41824 if (headings.length < 1) {
41825 return /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)("div", { className: "editor-document-outline has-no-headings", children: [
41826 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(EmptyOutlineIllustration, {}),
41827 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("p", { children: (0, import_i18n130.__)(
41828 "Navigate the structure of your document and address issues like empty or incorrect heading levels."
41829 ) })
41830 ] });
41831 }
41832 const titleNode = document.querySelector(".editor-post-title__input");
41833 const hasTitle = isTitleSupported && title && titleNode;
41834 const countByLevel = headings.reduce(
41835 (acc, heading) => ({
41836 ...acc,
41837 [heading.level]: (acc[heading.level] || 0) + 1
41838 }),
41839 {}
41840 );
41841 const hasMultipleH1 = countByLevel[1] > 1;
41842 function isContentBlock(clientId) {
41843 return Array.isArray(contentBlocks) ? contentBlocks.includes(clientId) : true;
41844 }
41845 return /* @__PURE__ */ (0, import_jsx_runtime217.jsx)("div", { className: "document-outline", children: /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)("ul", { children: [
41846 hasTitle && /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
41847 item_default,
41848 {
41849 level: (0, import_i18n130.__)("Title"),
41850 isValid: true,
41851 onSelect,
41852 href: `#${titleNode.id}`,
41853 isDisabled: hasOutlineItemsDisabled,
41854 children: title
41855 }
41856 ),
41857 headings.map((item) => {
41858 const isIncorrectLevel = item.level > prevHeadingLevelRef.current + 1;
41859 const isValid2 = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle);
41860 prevHeadingLevelRef.current = item.level;
41861 return /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(
41862 item_default,
41863 {
41864 level: `H${item.level}`,
41865 isValid: isValid2,
41866 isDisabled: hasOutlineItemsDisabled || !isContentBlock(item.clientId),
41867 href: `#block-${item.clientId}`,
41868 onSelect: () => {
41869 selectBlock2(item.clientId);
41870 onSelect?.();
41871 },
41872 children: [
41873 item.isEmpty ? emptyHeadingContent : (0, import_rich_text2.getTextContent)(
41874 (0, import_rich_text2.create)({
41875 html: item.attributes.content
41876 })
41877 ),
41878 isIncorrectLevel && incorrectLevelContent,
41879 item.level === 1 && hasMultipleH1 && multipleH1Headings,
41880 hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings
41881 ]
41882 },
41883 item.clientId
41884 );
41885 })
41886 ] }) });
41887 }
41888
41889 // packages/editor/build-module/components/document-outline/check.mjs
41890 var import_data85 = __toESM(require_data(), 1);
41891 var import_block_editor42 = __toESM(require_block_editor(), 1);
41892 function DocumentOutlineCheck({ children }) {
41893 const hasHeadings = (0, import_data85.useSelect)((select6) => {
41894 const { getGlobalBlockCount: getGlobalBlockCount2 } = select6(import_block_editor42.store);
41895 return getGlobalBlockCount2("core/heading") > 0;
41896 });
41897 if (!hasHeadings) {
41898 return null;
41899 }
41900 return children;
41901 }
41902
41903 // packages/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.mjs
41904 var import_element93 = __toESM(require_element(), 1);
41905 var import_data86 = __toESM(require_data(), 1);
41906 var import_i18n131 = __toESM(require_i18n(), 1);
41907 var import_block_editor43 = __toESM(require_block_editor(), 1);
41908 var import_keyboard_shortcuts4 = __toESM(require_keyboard_shortcuts(), 1);
41909 var import_keycodes8 = __toESM(require_keycodes(), 1);
41910 var import_jsx_runtime218 = __toESM(require_jsx_runtime(), 1);
41911 function EditorKeyboardShortcutsRegister() {
41912 const { registerShortcut } = (0, import_data86.useDispatch)(import_keyboard_shortcuts4.store);
41913 (0, import_element93.useEffect)(() => {
41914 registerShortcut({
41915 name: "core/editor/toggle-mode",
41916 category: "global",
41917 description: (0, import_i18n131.__)("Switch between visual editor and code editor."),
41918 keyCombination: {
41919 modifier: "secondary",
41920 character: "m"
41921 }
41922 });
41923 registerShortcut({
41924 name: "core/editor/save",
41925 category: "global",
41926 description: (0, import_i18n131.__)("Save your changes."),
41927 keyCombination: {
41928 modifier: "primary",
41929 character: "s"
41930 }
41931 });
41932 registerShortcut({
41933 name: "core/editor/undo",
41934 category: "global",
41935 description: (0, import_i18n131.__)("Undo your last changes."),
41936 keyCombination: {
41937 modifier: "primary",
41938 character: "z"
41939 }
41940 });
41941 registerShortcut({
41942 name: "core/editor/redo",
41943 category: "global",
41944 description: (0, import_i18n131.__)("Redo your last undo."),
41945 keyCombination: {
41946 modifier: "primaryShift",
41947 character: "z"
41948 },
41949 // Disable on Apple OS because it conflicts with the browser's
41950 // history shortcut. It's a fine alias for both Windows and Linux.
41951 // Since there's no conflict for Ctrl+Shift+Z on both Windows and
41952 // Linux, we keep it as the default for consistency.
41953 aliases: (0, import_keycodes8.isAppleOS)() ? [] : [
41954 {
41955 modifier: "primary",
41956 character: "y"
41957 }
41958 ]
41959 });
41960 registerShortcut({
41961 name: "core/editor/toggle-list-view",
41962 category: "global",
41963 description: (0, import_i18n131.__)("Show or hide the List View."),
41964 keyCombination: {
41965 modifier: "access",
41966 character: "o"
41967 }
41968 });
41969 registerShortcut({
41970 name: "core/editor/toggle-distraction-free",
41971 category: "global",
41972 description: (0, import_i18n131.__)("Enter or exit distraction free mode."),
41973 keyCombination: {
41974 modifier: "primaryShift",
41975 character: "\\"
41976 }
41977 });
41978 registerShortcut({
41979 name: "core/editor/toggle-sidebar",
41980 category: "global",
41981 description: (0, import_i18n131.__)("Show or hide the Settings panel."),
41982 keyCombination: {
41983 modifier: "primaryShift",
41984 character: ","
41985 }
41986 });
41987 registerShortcut({
41988 name: "core/editor/keyboard-shortcuts",
41989 category: "main",
41990 description: (0, import_i18n131.__)("Display these keyboard shortcuts."),
41991 keyCombination: {
41992 modifier: "access",
41993 character: "h"
41994 }
41995 });
41996 registerShortcut({
41997 name: "core/editor/new-note",
41998 category: "block",
41999 description: (0, import_i18n131.__)("Add a new note."),
42000 keyCombination: {
42001 modifier: "primaryAlt",
42002 character: "m"
42003 }
42004 });
42005 registerShortcut({
42006 name: "core/editor/next-region",
42007 category: "global",
42008 description: (0, import_i18n131.__)("Navigate to the next part of the editor."),
42009 keyCombination: {
42010 modifier: "ctrl",
42011 character: "`"
42012 },
42013 aliases: [
42014 {
42015 modifier: "access",
42016 character: "n"
42017 }
42018 ]
42019 });
42020 registerShortcut({
42021 name: "core/editor/previous-region",
42022 category: "global",
42023 description: (0, import_i18n131.__)("Navigate to the previous part of the editor."),
42024 keyCombination: {
42025 modifier: "ctrlShift",
42026 character: "`"
42027 },
42028 aliases: [
42029 {
42030 modifier: "access",
42031 character: "p"
42032 },
42033 {
42034 modifier: "ctrlShift",
42035 character: "~"
42036 }
42037 ]
42038 });
42039 }, [registerShortcut]);
42040 return /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(import_block_editor43.BlockEditorKeyboardShortcuts.Register, {});
42041 }
42042 var register_shortcuts_default = EditorKeyboardShortcutsRegister;
42043
42044 // packages/editor/build-module/components/editor-history/redo.mjs
42045 var import_i18n132 = __toESM(require_i18n(), 1);
42046 var import_components106 = __toESM(require_components(), 1);
42047 var import_data87 = __toESM(require_data(), 1);
42048 var import_keycodes9 = __toESM(require_keycodes(), 1);
42049 var import_element94 = __toESM(require_element(), 1);
42050 var import_jsx_runtime219 = __toESM(require_jsx_runtime(), 1);
42051 function EditorHistoryRedo(props, ref) {
42052 const shortcut = (0, import_keycodes9.isAppleOS)() ? import_keycodes9.displayShortcut.primaryShift("z") : import_keycodes9.displayShortcut.primary("y");
42053 const hasRedo = (0, import_data87.useSelect)(
42054 (select6) => select6(store).hasEditorRedo(),
42055 []
42056 );
42057 const { redo: redo2 } = (0, import_data87.useDispatch)(store);
42058 return /* @__PURE__ */ (0, import_jsx_runtime219.jsx)(
42059 import_components106.Button,
42060 {
42061 __next40pxDefaultSize: true,
42062 ...props,
42063 ref,
42064 icon: !(0, import_i18n132.isRTL)() ? redo_default : undo_default,
42065 label: (0, import_i18n132.__)("Redo"),
42066 shortcut,
42067 "aria-disabled": !hasRedo,
42068 onClick: hasRedo ? redo2 : void 0,
42069 className: "editor-history__redo"
42070 }
42071 );
42072 }
42073 var redo_default2 = (0, import_element94.forwardRef)(EditorHistoryRedo);
42074
42075 // packages/editor/build-module/components/editor-history/undo.mjs
42076 var import_i18n133 = __toESM(require_i18n(), 1);
42077 var import_components107 = __toESM(require_components(), 1);
42078 var import_data88 = __toESM(require_data(), 1);
42079 var import_keycodes10 = __toESM(require_keycodes(), 1);
42080 var import_element95 = __toESM(require_element(), 1);
42081 var import_jsx_runtime220 = __toESM(require_jsx_runtime(), 1);
42082 function EditorHistoryUndo(props, ref) {
42083 const hasUndo = (0, import_data88.useSelect)(
42084 (select6) => select6(store).hasEditorUndo(),
42085 []
42086 );
42087 const { undo: undo2 } = (0, import_data88.useDispatch)(store);
42088 return /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
42089 import_components107.Button,
42090 {
42091 __next40pxDefaultSize: true,
42092 ...props,
42093 ref,
42094 icon: !(0, import_i18n133.isRTL)() ? undo_default : redo_default,
42095 label: (0, import_i18n133.__)("Undo"),
42096 shortcut: import_keycodes10.displayShortcut.primary("z"),
42097 "aria-disabled": !hasUndo,
42098 onClick: hasUndo ? undo2 : void 0,
42099 className: "editor-history__undo"
42100 }
42101 );
42102 }
42103 var undo_default2 = (0, import_element95.forwardRef)(EditorHistoryUndo);
42104
42105 // packages/editor/build-module/components/editor-notices/index.mjs
42106 var import_deprecated9 = __toESM(require_deprecated(), 1);
42107 var import_notices18 = __toESM(require_notices(), 1);
42108
42109 // packages/editor/build-module/components/template-validation-notice/index.mjs
42110 var import_components108 = __toESM(require_components(), 1);
42111 var import_i18n134 = __toESM(require_i18n(), 1);
42112 var import_data89 = __toESM(require_data(), 1);
42113 var import_element96 = __toESM(require_element(), 1);
42114 var import_block_editor44 = __toESM(require_block_editor(), 1);
42115 var import_jsx_runtime221 = __toESM(require_jsx_runtime(), 1);
42116 function TemplateValidationNotice() {
42117 const [showConfirmDialog, setShowConfirmDialog] = (0, import_element96.useState)(false);
42118 const isValid2 = (0, import_data89.useSelect)((select6) => {
42119 return select6(import_block_editor44.store).isValidTemplate();
42120 }, []);
42121 const { setTemplateValidity: setTemplateValidity2, synchronizeTemplate: synchronizeTemplate2 } = (0, import_data89.useDispatch)(import_block_editor44.store);
42122 if (isValid2) {
42123 return null;
42124 }
42125 return /* @__PURE__ */ (0, import_jsx_runtime221.jsxs)(import_jsx_runtime221.Fragment, { children: [
42126 /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(
42127 import_components108.Notice,
42128 {
42129 className: "editor-template-validation-notice",
42130 isDismissible: false,
42131 status: "warning",
42132 actions: [
42133 {
42134 label: (0, import_i18n134.__)("Keep it as is"),
42135 onClick: () => setTemplateValidity2(true)
42136 },
42137 {
42138 label: (0, import_i18n134.__)("Reset the template"),
42139 onClick: () => setShowConfirmDialog(true)
42140 }
42141 ],
42142 children: (0, import_i18n134.__)(
42143 "The content of your post doesn\u2019t match the template assigned to your post type."
42144 )
42145 }
42146 ),
42147 /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(
42148 import_components108.__experimentalConfirmDialog,
42149 {
42150 isOpen: showConfirmDialog,
42151 confirmButtonText: (0, import_i18n134.__)("Reset"),
42152 onConfirm: () => {
42153 setShowConfirmDialog(false);
42154 synchronizeTemplate2();
42155 },
42156 onCancel: () => setShowConfirmDialog(false),
42157 size: "medium",
42158 children: (0, import_i18n134.__)(
42159 "Resetting the template may result in loss of content, do you want to continue?"
42160 )
42161 }
42162 )
42163 ] });
42164 }
42165
42166 // packages/editor/build-module/components/editor-notices/index.mjs
42167 var import_jsx_runtime222 = __toESM(require_jsx_runtime(), 1);
42168 function EditorNotices() {
42169 (0, import_deprecated9.default)("wp.editor.EditorNotices", {
42170 since: "7.0",
42171 version: "7.2",
42172 alternative: "wp.notices.InlineNotices"
42173 });
42174 return /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(
42175 import_notices18.InlineNotices,
42176 {
42177 pinnedNoticesClassName: "components-editor-notices__pinned",
42178 dismissibleNoticesClassName: "components-editor-notices__dismissible",
42179 children: /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(TemplateValidationNotice, {})
42180 }
42181 );
42182 }
42183 var editor_notices_default = EditorNotices;
42184
42185 // packages/editor/build-module/components/editor-snackbars/index.mjs
42186 var import_deprecated10 = __toESM(require_deprecated(), 1);
42187 var import_notices19 = __toESM(require_notices(), 1);
42188 var import_jsx_runtime223 = __toESM(require_jsx_runtime(), 1);
42189 function EditorSnackbars() {
42190 (0, import_deprecated10.default)("wp.editor.EditorSnackbars", {
42191 since: "7.0",
42192 version: "7.2",
42193 alternative: "wp.notices.SnackbarNotices"
42194 });
42195 return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(import_notices19.SnackbarNotices, { className: "components-editor-notices__snackbar" });
42196 }
42197
42198 // packages/editor/build-module/components/entities-saved-states/index.mjs
42199 var import_components111 = __toESM(require_components(), 1);
42200 var import_i18n137 = __toESM(require_i18n(), 1);
42201 var import_element98 = __toESM(require_element(), 1);
42202 var import_compose20 = __toESM(require_compose(), 1);
42203 var import_data93 = __toESM(require_data(), 1);
42204
42205 // packages/editor/build-module/components/entities-saved-states/entity-type-list.mjs
42206 var import_i18n136 = __toESM(require_i18n(), 1);
42207 var import_data91 = __toESM(require_data(), 1);
42208 var import_components110 = __toESM(require_components(), 1);
42209 var import_core_data63 = __toESM(require_core_data(), 1);
42210
42211 // packages/editor/build-module/components/entities-saved-states/entity-record-item.mjs
42212 var import_components109 = __toESM(require_components(), 1);
42213 var import_i18n135 = __toESM(require_i18n(), 1);
42214 var import_data90 = __toESM(require_data(), 1);
42215 var import_core_data62 = __toESM(require_core_data(), 1);
42216 var import_html_entities12 = __toESM(require_html_entities(), 1);
42217 var import_jsx_runtime224 = __toESM(require_jsx_runtime(), 1);
42218 function EntityRecordItem({ record, checked, onChange }) {
42219 const { name: name2, kind, title, key } = record;
42220 const { entityRecordTitle, hasPostMetaChanges: hasPostMetaChanges2 } = (0, import_data90.useSelect)(
42221 (select6) => {
42222 if ("postType" !== kind || "wp_template" !== name2) {
42223 return {
42224 entityRecordTitle: title,
42225 hasPostMetaChanges: unlock(
42226 select6(store)
42227 ).hasPostMetaChanges(name2, key)
42228 };
42229 }
42230 const template2 = select6(import_core_data62.store).getEditedEntityRecord(
42231 kind,
42232 name2,
42233 key
42234 );
42235 const { default_template_types: templateTypes = [] } = select6(import_core_data62.store).getCurrentTheme() ?? {};
42236 return {
42237 entityRecordTitle: getTemplateInfo({
42238 template: template2,
42239 templateTypes
42240 }).title,
42241 hasPostMetaChanges: unlock(
42242 select6(store)
42243 ).hasPostMetaChanges(name2, key)
42244 };
42245 },
42246 [name2, kind, title, key]
42247 );
42248 return /* @__PURE__ */ (0, import_jsx_runtime224.jsxs)(import_jsx_runtime224.Fragment, { children: [
42249 /* @__PURE__ */ (0, import_jsx_runtime224.jsx)(import_components109.PanelRow, { children: /* @__PURE__ */ (0, import_jsx_runtime224.jsx)(
42250 import_components109.CheckboxControl,
42251 {
42252 label: (0, import_html_entities12.decodeEntities)(entityRecordTitle) || (0, import_i18n135.__)("Untitled"),
42253 checked,
42254 onChange,
42255 className: "entities-saved-states__change-control"
42256 }
42257 ) }),
42258 hasPostMetaChanges2 && /* @__PURE__ */ (0, import_jsx_runtime224.jsx)("ul", { className: "entities-saved-states__changes", children: /* @__PURE__ */ (0, import_jsx_runtime224.jsx)("li", { children: (0, import_i18n135.__)("Post Meta.") }) })
42259 ] });
42260 }
42261
42262 // packages/editor/build-module/components/entities-saved-states/entity-type-list.mjs
42263 var import_jsx_runtime225 = __toESM(require_jsx_runtime(), 1);
42264 function getEntityDescription(entity, count) {
42265 switch (entity) {
42266 case "site":
42267 return 1 === count ? (0, import_i18n136.__)("This change will affect your whole site.") : (0, import_i18n136.__)("These changes will affect your whole site.");
42268 case "wp_template":
42269 return (0, import_i18n136.__)(
42270 "This change will affect other parts of your site that use this template."
42271 );
42272 case "page":
42273 case "post":
42274 return (0, import_i18n136.__)("The following has been modified.");
42275 }
42276 }
42277 function GlobalStylesDescription({ record }) {
42278 const { editedRecord, savedRecord } = (0, import_data91.useSelect)(
42279 (select6) => {
42280 const { getEditedEntityRecord, getEntityRecord } = select6(import_core_data63.store);
42281 return {
42282 editedRecord: getEditedEntityRecord(
42283 record.kind,
42284 record.name,
42285 record.key
42286 ),
42287 savedRecord: getEntityRecord(
42288 record.kind,
42289 record.name,
42290 record.key
42291 )
42292 };
42293 },
42294 [record.kind, record.name, record.key]
42295 );
42296 const globalStylesChanges = getGlobalStylesChanges(
42297 editedRecord,
42298 savedRecord,
42299 {
42300 maxResults: 10
42301 }
42302 );
42303 return globalStylesChanges.length ? /* @__PURE__ */ (0, import_jsx_runtime225.jsx)("ul", { className: "entities-saved-states__changes", children: globalStylesChanges.map((change) => /* @__PURE__ */ (0, import_jsx_runtime225.jsx)("li", { children: change }, change)) }) : null;
42304 }
42305 function EntityDescription({ record, count }) {
42306 if ("globalStyles" === record?.name) {
42307 return null;
42308 }
42309 const description = getEntityDescription(record?.name, count);
42310 return description ? /* @__PURE__ */ (0, import_jsx_runtime225.jsx)(import_components110.PanelRow, { children: description }) : null;
42311 }
42312 function EntityTypeList({
42313 list,
42314 unselectedEntities,
42315 setUnselectedEntities
42316 }) {
42317 const count = list.length;
42318 const firstRecord = list[0];
42319 const entityConfig = (0, import_data91.useSelect)(
42320 (select6) => select6(import_core_data63.store).getEntityConfig(
42321 firstRecord.kind,
42322 firstRecord.name
42323 ),
42324 [firstRecord.kind, firstRecord.name]
42325 );
42326 let entityLabel = entityConfig.label;
42327 if (firstRecord?.name === "wp_template_part") {
42328 entityLabel = 1 === count ? (0, import_i18n136.__)("Template Part") : (0, import_i18n136.__)("Template Parts");
42329 }
42330 return /* @__PURE__ */ (0, import_jsx_runtime225.jsxs)(
42331 import_components110.PanelBody,
42332 {
42333 title: entityLabel,
42334 initialOpen: true,
42335 className: "entities-saved-states__panel-body",
42336 children: [
42337 /* @__PURE__ */ (0, import_jsx_runtime225.jsx)(EntityDescription, { record: firstRecord, count }),
42338 list.map((record) => {
42339 return /* @__PURE__ */ (0, import_jsx_runtime225.jsx)(
42340 EntityRecordItem,
42341 {
42342 record,
42343 checked: !unselectedEntities.some(
42344 (elt) => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property
42345 ),
42346 onChange: (value) => setUnselectedEntities(record, value)
42347 },
42348 record.key || record.property
42349 );
42350 }),
42351 "globalStyles" === firstRecord?.name && /* @__PURE__ */ (0, import_jsx_runtime225.jsx)(GlobalStylesDescription, { record: firstRecord })
42352 ]
42353 }
42354 );
42355 }
42356
42357 // packages/editor/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs
42358 var import_data92 = __toESM(require_data(), 1);
42359 var import_core_data64 = __toESM(require_core_data(), 1);
42360 var import_element97 = __toESM(require_element(), 1);
42361 var useIsDirty = () => {
42362 const { editedEntities, siteEdits, siteEntityConfig } = (0, import_data92.useSelect)(
42363 (select6) => {
42364 const {
42365 __experimentalGetDirtyEntityRecords,
42366 getEntityRecordEdits,
42367 getEntityConfig
42368 } = select6(import_core_data64.store);
42369 return {
42370 editedEntities: __experimentalGetDirtyEntityRecords(),
42371 siteEdits: getEntityRecordEdits("root", "site"),
42372 siteEntityConfig: getEntityConfig("root", "site")
42373 };
42374 },
42375 []
42376 );
42377 const dirtyEntityRecords = (0, import_element97.useMemo)(() => {
42378 const editedEntitiesWithoutSite = editedEntities.filter(
42379 (record) => !(record.kind === "root" && record.name === "site")
42380 );
42381 const siteEntityLabels = siteEntityConfig?.meta?.labels ?? {};
42382 const editedSiteEntities = [];
42383 for (const property in siteEdits) {
42384 editedSiteEntities.push({
42385 kind: "root",
42386 name: "site",
42387 title: siteEntityLabels[property] || property,
42388 property
42389 });
42390 }
42391 return [...editedEntitiesWithoutSite, ...editedSiteEntities];
42392 }, [editedEntities, siteEdits, siteEntityConfig]);
42393 const [unselectedEntities, _setUnselectedEntities] = (0, import_element97.useState)([]);
42394 const setUnselectedEntities = ({ kind, name: name2, key, property }, checked) => {
42395 if (checked) {
42396 _setUnselectedEntities(
42397 unselectedEntities.filter(
42398 (elt) => elt.kind !== kind || elt.name !== name2 || elt.key !== key || elt.property !== property
42399 )
42400 );
42401 } else {
42402 _setUnselectedEntities([
42403 ...unselectedEntities,
42404 { kind, name: name2, key, property }
42405 ]);
42406 }
42407 };
42408 const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
42409 return {
42410 dirtyEntityRecords,
42411 isDirty,
42412 setUnselectedEntities,
42413 unselectedEntities
42414 };
42415 };
42416
42417 // packages/editor/build-module/components/entities-saved-states/index.mjs
42418 var import_jsx_runtime226 = __toESM(require_jsx_runtime(), 1);
42419 function identity(values) {
42420 return values;
42421 }
42422 function EntitiesSavedStates({
42423 close,
42424 renderDialog,
42425 variant
42426 }) {
42427 const isDirtyProps = useIsDirty();
42428 return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(
42429 EntitiesSavedStatesExtensible,
42430 {
42431 close,
42432 renderDialog,
42433 variant,
42434 ...isDirtyProps
42435 }
42436 );
42437 }
42438 function EntitiesSavedStatesExtensible({
42439 additionalPrompt = void 0,
42440 close,
42441 onSave = identity,
42442 saveEnabled: saveEnabledProp = void 0,
42443 saveLabel = (0, import_i18n137.__)("Save"),
42444 renderDialog,
42445 dirtyEntityRecords,
42446 isDirty,
42447 setUnselectedEntities,
42448 unselectedEntities,
42449 variant = "default",
42450 successNoticeContent
42451 }) {
42452 const saveButtonRef = (0, import_element98.useRef)();
42453 const { saveDirtyEntities: saveDirtyEntities2 } = unlock((0, import_data93.useDispatch)(store));
42454 const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
42455 const { name: name2 } = record;
42456 if (!acc[name2]) {
42457 acc[name2] = [];
42458 }
42459 acc[name2].push(record);
42460 return acc;
42461 }, {});
42462 const {
42463 site: siteSavables,
42464 wp_template: templateSavables,
42465 wp_template_part: templatePartSavables,
42466 ...contentSavables
42467 } = partitionedSavables;
42468 const sortedPartitionedSavables = [
42469 siteSavables,
42470 templateSavables,
42471 templatePartSavables,
42472 ...Object.values(contentSavables)
42473 ].filter(Array.isArray);
42474 const saveEnabled = saveEnabledProp ?? isDirty;
42475 const dismissPanel = (0, import_element98.useCallback)(() => close(), [close]);
42476 const [saveDialogRef, saveDialogProps] = (0, import_compose20.__experimentalUseDialog)({
42477 onClose: () => dismissPanel()
42478 });
42479 const dialogLabelId = (0, import_compose20.useInstanceId)(
42480 EntitiesSavedStatesExtensible,
42481 "entities-saved-states__panel-label"
42482 );
42483 const dialogDescriptionId = (0, import_compose20.useInstanceId)(
42484 EntitiesSavedStatesExtensible,
42485 "entities-saved-states__panel-description"
42486 );
42487 const selectItemsToSaveDescription = !!dirtyEntityRecords.length ? (0, import_i18n137.__)("Select the items you want to save.") : void 0;
42488 const isInline = variant === "inline";
42489 const actionButtons = /* @__PURE__ */ (0, import_jsx_runtime226.jsxs)(import_jsx_runtime226.Fragment, { children: [
42490 /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(
42491 import_components111.FlexItem,
42492 {
42493 isBlock: isInline ? false : true,
42494 as: import_components111.Button,
42495 variant: isInline ? "tertiary" : "secondary",
42496 size: isInline ? void 0 : "compact",
42497 onClick: dismissPanel,
42498 children: (0, import_i18n137.__)("Cancel")
42499 }
42500 ),
42501 /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(
42502 import_components111.FlexItem,
42503 {
42504 isBlock: isInline ? false : true,
42505 as: import_components111.Button,
42506 ref: saveButtonRef,
42507 variant: "primary",
42508 size: isInline ? void 0 : "compact",
42509 disabled: !saveEnabled,
42510 accessibleWhenDisabled: true,
42511 onClick: () => saveDirtyEntities2({
42512 onSave,
42513 dirtyEntityRecords,
42514 entitiesToSkip: unselectedEntities,
42515 close,
42516 successNoticeContent
42517 }),
42518 className: "editor-entities-saved-states__save-button",
42519 children: saveLabel
42520 }
42521 )
42522 ] });
42523 return /* @__PURE__ */ (0, import_jsx_runtime226.jsxs)(
42524 "div",
42525 {
42526 ref: renderDialog ? saveDialogRef : void 0,
42527 ...renderDialog && saveDialogProps,
42528 className: clsx_default("entities-saved-states__panel", {
42529 "is-inline": isInline
42530 }),
42531 role: renderDialog ? "dialog" : void 0,
42532 "aria-labelledby": renderDialog ? dialogLabelId : void 0,
42533 "aria-describedby": renderDialog ? dialogDescriptionId : void 0,
42534 children: [
42535 !isInline && /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(import_components111.Flex, { className: "entities-saved-states__panel-header", gap: 2, children: actionButtons }),
42536 /* @__PURE__ */ (0, import_jsx_runtime226.jsxs)("div", { className: "entities-saved-states__text-prompt", children: [
42537 /* @__PURE__ */ (0, import_jsx_runtime226.jsx)("div", { className: "entities-saved-states__text-prompt--header-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(
42538 "strong",
42539 {
42540 id: renderDialog ? dialogLabelId : void 0,
42541 className: "entities-saved-states__text-prompt--header",
42542 children: (0, import_i18n137.__)("Are you ready to save?")
42543 }
42544 ) }),
42545 /* @__PURE__ */ (0, import_jsx_runtime226.jsxs)("div", { id: renderDialog ? dialogDescriptionId : void 0, children: [
42546 additionalPrompt,
42547 /* @__PURE__ */ (0, import_jsx_runtime226.jsx)("p", { className: "entities-saved-states__text-prompt--changes-count", children: isDirty ? (0, import_element98.createInterpolateElement)(
42548 (0, import_i18n137.sprintf)(
42549 /* translators: %d: number of site changes waiting to be saved. */
42550 (0, import_i18n137._n)(
42551 "There is <strong>%d site change</strong> waiting to be saved.",
42552 "There are <strong>%d site changes</strong> waiting to be saved.",
42553 dirtyEntityRecords.length
42554 ),
42555 dirtyEntityRecords.length
42556 ),
42557 { strong: /* @__PURE__ */ (0, import_jsx_runtime226.jsx)("strong", {}) }
42558 ) : selectItemsToSaveDescription })
42559 ] })
42560 ] }),
42561 sortedPartitionedSavables.map((list) => {
42562 return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(
42563 EntityTypeList,
42564 {
42565 list,
42566 unselectedEntities,
42567 setUnselectedEntities
42568 },
42569 list[0].name
42570 );
42571 }),
42572 isInline && /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(
42573 import_components111.Flex,
42574 {
42575 direction: "row",
42576 justify: "flex-end",
42577 className: "entities-saved-states__panel-footer",
42578 children: actionButtons
42579 }
42580 )
42581 ]
42582 }
42583 );
42584 }
42585
42586 // packages/editor/build-module/components/error-boundary/index.mjs
42587 var import_element99 = __toESM(require_element(), 1);
42588 var import_i18n138 = __toESM(require_i18n(), 1);
42589 var import_components112 = __toESM(require_components(), 1);
42590 var import_data94 = __toESM(require_data(), 1);
42591 var import_compose21 = __toESM(require_compose(), 1);
42592 var import_hooks41 = __toESM(require_hooks(), 1);
42593 var import_jsx_runtime227 = __toESM(require_jsx_runtime(), 1);
42594 function getContent() {
42595 try {
42596 return (0, import_data94.select)(store).getEditedPostContent();
42597 } catch (error) {
42598 }
42599 }
42600 function CopyButton({ text, children, variant = "secondary" }) {
42601 const ref = (0, import_compose21.useCopyToClipboard)(text);
42602 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(import_components112.Button, { __next40pxDefaultSize: true, variant, ref, children });
42603 }
42604 var ErrorBoundary = class extends import_element99.Component {
42605 constructor() {
42606 super(...arguments);
42607 this.state = {
42608 error: null
42609 };
42610 }
42611 componentDidCatch(error) {
42612 (0, import_hooks41.doAction)("editor.ErrorBoundary.errorLogged", error);
42613 }
42614 static getDerivedStateFromError(error) {
42615 return { error };
42616 }
42617 render() {
42618 const { error } = this.state;
42619 const { canCopyContent = false } = this.props;
42620 if (!error) {
42621 return this.props.children;
42622 }
42623 return /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(
42624 import_components112.__experimentalHStack,
42625 {
42626 className: "editor-error-boundary",
42627 alignment: "baseline",
42628 spacing: 4,
42629 justify: "space-between",
42630 expanded: false,
42631 wrap: true,
42632 children: [
42633 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(import_components112.__experimentalText, { as: "p", children: (0, import_i18n138.__)("The editor has encountered an unexpected error.") }),
42634 /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(import_components112.__experimentalHStack, { expanded: false, children: [
42635 canCopyContent && /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(CopyButton, { text: getContent, children: (0, import_i18n138.__)("Copy contents") }),
42636 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(CopyButton, { variant: "primary", text: error?.stack, children: (0, import_i18n138.__)("Copy error") })
42637 ] })
42638 ]
42639 }
42640 );
42641 }
42642 };
42643 var error_boundary_default = ErrorBoundary;
42644
42645 // packages/editor/build-module/components/local-autosave-monitor/index.mjs
42646 var import_element100 = __toESM(require_element(), 1);
42647 var import_compose22 = __toESM(require_compose(), 1);
42648 var import_data95 = __toESM(require_data(), 1);
42649 var import_i18n139 = __toESM(require_i18n(), 1);
42650 var import_blocks24 = __toESM(require_blocks(), 1);
42651 var import_notices20 = __toESM(require_notices(), 1);
42652 var import_jsx_runtime228 = __toESM(require_jsx_runtime(), 1);
42653 var requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
42654 var hasStorageSupport;
42655 var hasSessionStorageSupport = () => {
42656 if (hasStorageSupport !== void 0) {
42657 return hasStorageSupport;
42658 }
42659 try {
42660 window.sessionStorage.setItem("__wpEditorTestSessionStorage", "");
42661 window.sessionStorage.removeItem("__wpEditorTestSessionStorage");
42662 hasStorageSupport = true;
42663 } catch {
42664 hasStorageSupport = false;
42665 }
42666 return hasStorageSupport;
42667 };
42668 function useAutosaveNotice() {
42669 const { postId: postId2, isEditedPostNew: isEditedPostNew2, hasRemoteAutosave } = (0, import_data95.useSelect)(
42670 (select6) => ({
42671 postId: select6(store).getCurrentPostId(),
42672 isEditedPostNew: select6(store).isEditedPostNew(),
42673 hasRemoteAutosave: !!select6(store).getEditorSettings().autosave
42674 }),
42675 []
42676 );
42677 const { getEditedPostAttribute: getEditedPostAttribute2 } = (0, import_data95.useSelect)(store);
42678 const { createWarningNotice, removeNotice } = (0, import_data95.useDispatch)(import_notices20.store);
42679 const { editPost: editPost2, resetEditorBlocks: resetEditorBlocks2 } = (0, import_data95.useDispatch)(store);
42680 (0, import_element100.useEffect)(() => {
42681 let localAutosave = localAutosaveGet(postId2, isEditedPostNew2);
42682 if (!localAutosave) {
42683 return;
42684 }
42685 try {
42686 localAutosave = JSON.parse(localAutosave);
42687 } catch {
42688 return;
42689 }
42690 const { post_title: title, content, excerpt } = localAutosave;
42691 const edits = { title, content, excerpt };
42692 {
42693 const hasDifference = Object.keys(edits).some((key) => {
42694 return edits[key] !== getEditedPostAttribute2(key);
42695 });
42696 if (!hasDifference) {
42697 localAutosaveClear(postId2, isEditedPostNew2);
42698 return;
42699 }
42700 }
42701 if (hasRemoteAutosave) {
42702 return;
42703 }
42704 const id = "wpEditorAutosaveRestore";
42705 createWarningNotice(
42706 (0, import_i18n139.__)(
42707 "The backup of this post in your browser is different from the version below."
42708 ),
42709 {
42710 id,
42711 actions: [
42712 {
42713 label: (0, import_i18n139.__)("Restore the backup"),
42714 onClick() {
42715 const {
42716 content: editsContent,
42717 ...editsWithoutContent
42718 } = edits;
42719 editPost2(editsWithoutContent);
42720 resetEditorBlocks2((0, import_blocks24.parse)(edits.content));
42721 removeNotice(id);
42722 }
42723 }
42724 ]
42725 }
42726 );
42727 }, [isEditedPostNew2, postId2]);
42728 }
42729 function useAutosavePurge() {
42730 const { postId: postId2, isEditedPostNew: isEditedPostNew2, isDirty, isAutosaving, didError } = (0, import_data95.useSelect)(
42731 (select6) => ({
42732 postId: select6(store).getCurrentPostId(),
42733 isEditedPostNew: select6(store).isEditedPostNew(),
42734 isDirty: select6(store).isEditedPostDirty(),
42735 isAutosaving: select6(store).isAutosavingPost(),
42736 didError: select6(store).didPostSaveRequestFail()
42737 }),
42738 []
42739 );
42740 const lastIsDirtyRef = (0, import_element100.useRef)(isDirty);
42741 const lastIsAutosavingRef = (0, import_element100.useRef)(isAutosaving);
42742 (0, import_element100.useEffect)(() => {
42743 if (!didError && (lastIsAutosavingRef.current && !isAutosaving || lastIsDirtyRef.current && !isDirty)) {
42744 localAutosaveClear(postId2, isEditedPostNew2);
42745 }
42746 lastIsDirtyRef.current = isDirty;
42747 lastIsAutosavingRef.current = isAutosaving;
42748 }, [isDirty, isAutosaving, didError]);
42749 const wasEditedPostNew = (0, import_compose22.usePrevious)(isEditedPostNew2);
42750 const prevPostId = (0, import_compose22.usePrevious)(postId2);
42751 (0, import_element100.useEffect)(() => {
42752 if (prevPostId === postId2 && wasEditedPostNew && !isEditedPostNew2) {
42753 localAutosaveClear(postId2, true);
42754 }
42755 }, [isEditedPostNew2, postId2]);
42756 }
42757 function LocalAutosaveMonitor() {
42758 const { autosave: autosave2 } = (0, import_data95.useDispatch)(store);
42759 const deferredAutosave = (0, import_element100.useCallback)(() => {
42760 requestIdleCallback(() => autosave2({ local: true }));
42761 }, []);
42762 useAutosaveNotice();
42763 useAutosavePurge();
42764 const localAutosaveInterval = (0, import_data95.useSelect)(
42765 (select6) => select6(store).getEditorSettings().localAutosaveInterval,
42766 []
42767 );
42768 return /* @__PURE__ */ (0, import_jsx_runtime228.jsx)(
42769 autosave_monitor_default,
42770 {
42771 interval: localAutosaveInterval,
42772 autosave: deferredAutosave
42773 }
42774 );
42775 }
42776 var local_autosave_monitor_default = (0, import_compose22.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor);
42777
42778 // packages/editor/build-module/components/page-attributes/check.mjs
42779 var import_data96 = __toESM(require_data(), 1);
42780 var import_core_data65 = __toESM(require_core_data(), 1);
42781 function PageAttributesCheck({ children }) {
42782 const supportsPageAttributes = (0, import_data96.useSelect)((select6) => {
42783 const { getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
42784 const { getPostType } = select6(import_core_data65.store);
42785 const postType2 = getPostType(getEditedPostAttribute2("type"));
42786 return !!postType2?.supports?.["page-attributes"];
42787 }, []);
42788 if (!supportsPageAttributes) {
42789 return null;
42790 }
42791 return children;
42792 }
42793 var check_default2 = PageAttributesCheck;
42794
42795 // packages/editor/build-module/components/page-attributes/order.mjs
42796 var import_i18n140 = __toESM(require_i18n(), 1);
42797 var import_components113 = __toESM(require_components(), 1);
42798 var import_data98 = __toESM(require_data(), 1);
42799 var import_element101 = __toESM(require_element(), 1);
42800
42801 // packages/editor/build-module/components/post-type-support-check/index.mjs
42802 var import_data97 = __toESM(require_data(), 1);
42803 var import_core_data66 = __toESM(require_core_data(), 1);
42804 function checkSupport(supports = {}, key) {
42805 if (supports[key] !== void 0) {
42806 return !!supports[key];
42807 }
42808 const [topKey, subKey] = key.split(".");
42809 const [subProperties] = Array.isArray(supports[topKey]) ? supports[topKey] : [];
42810 return Array.isArray(subProperties) ? subProperties.includes(subKey) : !!subProperties?.[subKey];
42811 }
42812 function PostTypeSupportCheck({ children, supportKeys }) {
42813 const postType2 = (0, import_data97.useSelect)((select6) => {
42814 const { getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
42815 const { getPostType } = select6(import_core_data66.store);
42816 return getPostType(getEditedPostAttribute2("type"));
42817 }, []);
42818 let isSupported = !!postType2;
42819 if (postType2) {
42820 isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some((key) => checkSupport(postType2.supports, key));
42821 }
42822 if (!isSupported) {
42823 return null;
42824 }
42825 return children;
42826 }
42827 var post_type_support_check_default = PostTypeSupportCheck;
42828
42829 // packages/editor/build-module/components/page-attributes/order.mjs
42830 var import_jsx_runtime229 = __toESM(require_jsx_runtime(), 1);
42831 function PageAttributesOrder() {
42832 const order = (0, import_data98.useSelect)(
42833 (select6) => select6(store).getEditedPostAttribute("menu_order") ?? 0,
42834 []
42835 );
42836 const { editPost: editPost2 } = (0, import_data98.useDispatch)(store);
42837 const [orderInput, setOrderInput] = (0, import_element101.useState)(null);
42838 const setUpdatedOrder = (value2) => {
42839 setOrderInput(value2);
42840 const newOrder = Number(value2);
42841 if (Number.isInteger(newOrder) && value2.trim?.() !== "") {
42842 editPost2({ menu_order: newOrder });
42843 }
42844 };
42845 const value = orderInput ?? order;
42846 return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(import_components113.Flex, { children: /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(import_components113.FlexBlock, { children: /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
42847 import_components113.__experimentalNumberControl,
42848 {
42849 __next40pxDefaultSize: true,
42850 label: (0, import_i18n140.__)("Order"),
42851 help: (0, import_i18n140.__)("Set the page order."),
42852 value,
42853 onChange: setUpdatedOrder,
42854 hideLabelFromVision: true,
42855 onBlur: () => {
42856 setOrderInput(null);
42857 }
42858 }
42859 ) }) });
42860 }
42861 function PageAttributesOrderWithChecks() {
42862 return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(post_type_support_check_default, { supportKeys: "page-attributes", children: /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(PageAttributesOrder, {}) });
42863 }
42864
42865 // packages/editor/build-module/components/page-attributes/panel.mjs
42866 var import_data100 = __toESM(require_data(), 1);
42867 var import_core_data68 = __toESM(require_core_data(), 1);
42868
42869 // packages/editor/build-module/components/page-attributes/parent.mjs
42870 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
42871 var import_i18n141 = __toESM(require_i18n(), 1);
42872 var import_components115 = __toESM(require_components(), 1);
42873 var import_compose23 = __toESM(require_compose(), 1);
42874 var import_element103 = __toESM(require_element(), 1);
42875 var import_data99 = __toESM(require_data(), 1);
42876 var import_html_entities14 = __toESM(require_html_entities(), 1);
42877 var import_core_data67 = __toESM(require_core_data(), 1);
42878 var import_block_editor45 = __toESM(require_block_editor(), 1);
42879 var import_url12 = __toESM(require_url(), 1);
42880
42881 // packages/editor/build-module/components/post-panel-row/index.mjs
42882 var import_components114 = __toESM(require_components(), 1);
42883 var import_element102 = __toESM(require_element(), 1);
42884 var import_jsx_runtime230 = __toESM(require_jsx_runtime(), 1);
42885 var PostPanelRow = (0, import_element102.forwardRef)(({ className, label, children }, ref) => {
42886 return /* @__PURE__ */ (0, import_jsx_runtime230.jsxs)(
42887 import_components114.__experimentalHStack,
42888 {
42889 className: clsx_default("editor-post-panel__row", className),
42890 ref,
42891 children: [
42892 label && /* @__PURE__ */ (0, import_jsx_runtime230.jsx)("div", { className: "editor-post-panel__row-label", children: label }),
42893 /* @__PURE__ */ (0, import_jsx_runtime230.jsx)("div", { className: "editor-post-panel__row-control", children })
42894 ]
42895 }
42896 );
42897 });
42898 var post_panel_row_default = PostPanelRow;
42899
42900 // packages/editor/build-module/utils/terms.mjs
42901 var import_html_entities13 = __toESM(require_html_entities(), 1);
42902 function buildTermsTree2(flatTerms) {
42903 const flatTermsWithParentAndChildren = flatTerms.map((term) => {
42904 return {
42905 children: [],
42906 parent: void 0,
42907 ...term
42908 };
42909 });
42910 if (flatTermsWithParentAndChildren.some(
42911 ({ parent }) => parent === void 0
42912 )) {
42913 return flatTermsWithParentAndChildren;
42914 }
42915 const termsByParent = flatTermsWithParentAndChildren.reduce(
42916 (acc, term) => {
42917 const { parent } = term;
42918 if (!acc[parent]) {
42919 acc[parent] = [];
42920 }
42921 acc[parent].push(term);
42922 return acc;
42923 },
42924 {}
42925 );
42926 const fillWithChildren = (terms) => {
42927 return terms.map((term) => {
42928 const children = termsByParent[term.id];
42929 return {
42930 ...term,
42931 children: children && children.length ? fillWithChildren(children) : []
42932 };
42933 });
42934 };
42935 return fillWithChildren(termsByParent["0"] || []);
42936 }
42937 var unescapeString = (arg) => {
42938 return (0, import_html_entities13.decodeEntities)(arg);
42939 };
42940 var unescapeTerm = (term) => {
42941 return {
42942 ...term,
42943 name: unescapeString(term.name)
42944 };
42945 };
42946 var unescapeTerms = (terms) => {
42947 return (terms ?? []).map(unescapeTerm);
42948 };
42949
42950 // packages/editor/build-module/components/page-attributes/parent.mjs
42951 var import_jsx_runtime231 = __toESM(require_jsx_runtime(), 1);
42952 function getTitle(post2) {
42953 return post2?.title?.rendered ? (0, import_html_entities14.decodeEntities)(post2.title.rendered) : `#${post2.id} (${(0, import_i18n141.__)("no title")})`;
42954 }
42955 var getItemPriority2 = (name2, searchValue) => {
42956 const normalizedName = (0, import_remove_accents2.default)(name2 || "").toLowerCase();
42957 const normalizedSearch = (0, import_remove_accents2.default)(searchValue || "").toLowerCase();
42958 if (normalizedName === normalizedSearch) {
42959 return 0;
42960 }
42961 if (normalizedName.startsWith(normalizedSearch)) {
42962 return normalizedName.length;
42963 }
42964 return Infinity;
42965 };
42966 function PageAttributesParent2() {
42967 const { editPost: editPost2 } = (0, import_data99.useDispatch)(store);
42968 const [fieldValue, setFieldValue] = (0, import_element103.useState)(false);
42969 const {
42970 isHierarchical,
42971 parentPostId,
42972 parentPostTitle,
42973 pageItems,
42974 isLoading
42975 } = (0, import_data99.useSelect)(
42976 (select6) => {
42977 const {
42978 getPostType,
42979 getEntityRecords,
42980 getEntityRecord,
42981 isResolving
42982 } = select6(import_core_data67.store);
42983 const { getCurrentPostId: getCurrentPostId2, getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
42984 const postTypeSlug = getEditedPostAttribute2("type");
42985 const pageId = getEditedPostAttribute2("parent");
42986 const pType = getPostType(postTypeSlug);
42987 const postId2 = getCurrentPostId2();
42988 const postIsHierarchical = pType?.hierarchical ?? false;
42989 const query = {
42990 per_page: 100,
42991 exclude: postId2,
42992 parent_exclude: postId2,
42993 orderby: "menu_order",
42994 order: "asc",
42995 _fields: "id,title,parent"
42996 };
42997 if (!!fieldValue) {
42998 query.search = fieldValue;
42999 query.orderby = "relevance";
43000 }
43001 const parentPost = pageId ? getEntityRecord("postType", postTypeSlug, pageId) : null;
43002 return {
43003 isHierarchical: postIsHierarchical,
43004 parentPostId: pageId,
43005 parentPostTitle: parentPost ? getTitle(parentPost) : "",
43006 pageItems: postIsHierarchical ? getEntityRecords("postType", postTypeSlug, query) : null,
43007 isLoading: postIsHierarchical ? isResolving("getEntityRecords", [
43008 "postType",
43009 postTypeSlug,
43010 query
43011 ]) : false
43012 };
43013 },
43014 [fieldValue]
43015 );
43016 const parentOptions = (0, import_element103.useMemo)(() => {
43017 const getOptionsFromTree = (tree2, level = 0) => {
43018 const mappedNodes = tree2.map((treeNode) => [
43019 {
43020 value: treeNode.id,
43021 label: "\u2014 ".repeat(level) + (0, import_html_entities14.decodeEntities)(treeNode.name),
43022 rawName: treeNode.name
43023 },
43024 ...getOptionsFromTree(treeNode.children || [], level + 1)
43025 ]);
43026 const sortedNodes = mappedNodes.sort(([a3], [b3]) => {
43027 const priorityA = getItemPriority2(a3.rawName, fieldValue);
43028 const priorityB = getItemPriority2(b3.rawName, fieldValue);
43029 return priorityA >= priorityB ? 1 : -1;
43030 });
43031 return sortedNodes.flat();
43032 };
43033 if (!pageItems) {
43034 return [];
43035 }
43036 let tree = pageItems.map((item) => ({
43037 id: item.id,
43038 parent: item.parent,
43039 name: getTitle(item)
43040 }));
43041 if (!fieldValue) {
43042 tree = buildTermsTree2(tree);
43043 }
43044 const opts = getOptionsFromTree(tree);
43045 const optsHasParent = opts.find(
43046 (item) => item.value === parentPostId
43047 );
43048 if (parentPostTitle && !optsHasParent) {
43049 opts.unshift({
43050 value: parentPostId,
43051 label: parentPostTitle
43052 });
43053 }
43054 return opts;
43055 }, [pageItems, fieldValue, parentPostTitle, parentPostId]);
43056 if (!isHierarchical) {
43057 return null;
43058 }
43059 const handleKeydown = (inputValue) => {
43060 setFieldValue(inputValue);
43061 };
43062 const handleChange = (selectedPostId) => {
43063 editPost2({ parent: selectedPostId });
43064 };
43065 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
43066 import_components115.ComboboxControl,
43067 {
43068 __next40pxDefaultSize: true,
43069 className: "editor-page-attributes__parent",
43070 label: (0, import_i18n141.__)("Parent"),
43071 help: (0, import_i18n141.__)("Choose a parent page."),
43072 value: parentPostId,
43073 options: parentOptions,
43074 onFilterValueChange: (0, import_compose23.debounce)(handleKeydown, 300),
43075 onChange: handleChange,
43076 hideLabelFromVision: true,
43077 isLoading
43078 }
43079 );
43080 }
43081 function PostParentToggle({ isOpen, onClick }) {
43082 const parentPost = (0, import_data99.useSelect)((select6) => {
43083 const { getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
43084 const parentPostId = getEditedPostAttribute2("parent");
43085 if (!parentPostId) {
43086 return null;
43087 }
43088 const { getEntityRecord } = select6(import_core_data67.store);
43089 const postTypeSlug = getEditedPostAttribute2("type");
43090 return getEntityRecord("postType", postTypeSlug, parentPostId);
43091 }, []);
43092 const parentTitle = (0, import_element103.useMemo)(
43093 () => !parentPost ? (0, import_i18n141.__)("None") : getTitle(parentPost),
43094 [parentPost]
43095 );
43096 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
43097 import_components115.Button,
43098 {
43099 size: "compact",
43100 className: "editor-post-parent__panel-toggle",
43101 variant: "tertiary",
43102 "aria-expanded": isOpen,
43103 "aria-label": (
43104 // translators: %s: Current post parent.
43105 (0, import_i18n141.sprintf)((0, import_i18n141.__)("Change parent: %s"), parentTitle)
43106 ),
43107 onClick,
43108 children: parentTitle
43109 }
43110 );
43111 }
43112 function ParentRow() {
43113 const homeUrl = (0, import_data99.useSelect)((select6) => {
43114 return select6(import_core_data67.store).getEntityRecord("root", "__unstableBase")?.home;
43115 }, []);
43116 const [popoverAnchor, setPopoverAnchor] = (0, import_element103.useState)(null);
43117 const popoverProps = (0, import_element103.useMemo)(
43118 () => ({
43119 // Anchor the popover to the middle of the entire row so that it doesn't
43120 // move around when the label changes.
43121 anchor: popoverAnchor,
43122 placement: "left-start",
43123 offset: 36,
43124 shift: true
43125 }),
43126 [popoverAnchor]
43127 );
43128 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(post_panel_row_default, { label: (0, import_i18n141.__)("Parent"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
43129 import_components115.Dropdown,
43130 {
43131 popoverProps,
43132 className: "editor-post-parent__panel-dropdown",
43133 contentClassName: "editor-post-parent__panel-dialog",
43134 focusOnMount: true,
43135 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(PostParentToggle, { isOpen, onClick: onToggle }),
43136 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)("div", { className: "editor-post-parent", children: [
43137 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
43138 import_block_editor45.__experimentalInspectorPopoverHeader,
43139 {
43140 title: (0, import_i18n141.__)("Parent"),
43141 onClose
43142 }
43143 ),
43144 /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)("div", { children: [
43145 (0, import_element103.createInterpolateElement)(
43146 (0, import_i18n141.sprintf)(
43147 /* translators: %s: The home URL of the WordPress installation without the scheme. */
43148 (0, import_i18n141.__)(
43149 'Child pages inherit characteristics from their parent, such as URL structure. For instance, if "Pricing" is a child of "Services", its URL would be %s<wbr />/services<wbr />/pricing.'
43150 ),
43151 (0, import_url12.filterURLForDisplay)(homeUrl).replace(
43152 /([/.])/g,
43153 "<wbr />$1"
43154 )
43155 ),
43156 {
43157 wbr: /* @__PURE__ */ (0, import_jsx_runtime231.jsx)("wbr", {})
43158 }
43159 ),
43160 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)("p", { children: (0, import_element103.createInterpolateElement)(
43161 (0, import_i18n141.__)(
43162 "They also show up as sub-items in the default navigation menu. <a>Learn more.</a>"
43163 ),
43164 {
43165 a: /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
43166 import_components115.ExternalLink,
43167 {
43168 href: (0, import_i18n141.__)(
43169 "https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes"
43170 )
43171 }
43172 )
43173 }
43174 ) })
43175 ] }),
43176 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(PageAttributesParent2, {})
43177 ] })
43178 }
43179 ) });
43180 }
43181 var parent_default2 = PageAttributesParent2;
43182
43183 // packages/editor/build-module/components/page-attributes/panel.mjs
43184 var import_jsx_runtime232 = __toESM(require_jsx_runtime(), 1);
43185 var PANEL_NAME = "page-attributes";
43186 function AttributesPanel() {
43187 const { isEnabled, postType: postType2 } = (0, import_data100.useSelect)((select6) => {
43188 const { getEditedPostAttribute: getEditedPostAttribute2, isEditorPanelEnabled: isEditorPanelEnabled2 } = select6(store);
43189 const { getPostType } = select6(import_core_data68.store);
43190 return {
43191 isEnabled: isEditorPanelEnabled2(PANEL_NAME),
43192 postType: getPostType(getEditedPostAttribute2("type"))
43193 };
43194 }, []);
43195 if (!isEnabled || !postType2) {
43196 return null;
43197 }
43198 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(ParentRow, {});
43199 }
43200 function PageAttributesPanel() {
43201 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(check_default2, { children: /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(AttributesPanel, {}) });
43202 }
43203
43204 // packages/editor/build-module/components/post-template/classic-theme.mjs
43205 var import_i18n143 = __toESM(require_i18n(), 1);
43206 var import_components117 = __toESM(require_components(), 1);
43207 var import_data103 = __toESM(require_data(), 1);
43208 var import_core_data70 = __toESM(require_core_data(), 1);
43209 var import_block_editor46 = __toESM(require_block_editor(), 1);
43210 var import_element106 = __toESM(require_element(), 1);
43211 var import_notices21 = __toESM(require_notices(), 1);
43212
43213 // packages/editor/build-module/components/post-template/create-new-template-modal.mjs
43214 var import_data101 = __toESM(require_data(), 1);
43215 var import_element104 = __toESM(require_element(), 1);
43216 var import_blocks25 = __toESM(require_blocks(), 1);
43217 var import_components116 = __toESM(require_components(), 1);
43218 var import_i18n142 = __toESM(require_i18n(), 1);
43219 var import_jsx_runtime233 = __toESM(require_jsx_runtime(), 1);
43220 var DEFAULT_TITLE = (0, import_i18n142.__)("Custom Template");
43221 function CreateNewTemplateModal({ onClose }) {
43222 const { defaultBlockTemplate, onNavigateToEntityRecord } = (0, import_data101.useSelect)(
43223 (select6) => {
43224 const { getEditorSettings: getEditorSettings2, getCurrentTemplateId: getCurrentTemplateId2 } = select6(store);
43225 return {
43226 defaultBlockTemplate: getEditorSettings2().defaultBlockTemplate,
43227 onNavigateToEntityRecord: getEditorSettings2().onNavigateToEntityRecord,
43228 getTemplateId: getCurrentTemplateId2
43229 };
43230 }
43231 );
43232 const { createTemplate: createTemplate2 } = unlock((0, import_data101.useDispatch)(store));
43233 const [title, setTitle] = (0, import_element104.useState)("");
43234 const [isBusy, setIsBusy] = (0, import_element104.useState)(false);
43235 const cancel = () => {
43236 setTitle("");
43237 onClose();
43238 };
43239 const submit = async (event) => {
43240 event.preventDefault();
43241 if (isBusy) {
43242 return;
43243 }
43244 setIsBusy(true);
43245 const newTemplateContent = defaultBlockTemplate ?? (0, import_blocks25.serialize)([
43246 (0, import_blocks25.createBlock)(
43247 "core/group",
43248 {
43249 tagName: "header",
43250 layout: { inherit: true }
43251 },
43252 [
43253 (0, import_blocks25.createBlock)("core/site-title"),
43254 (0, import_blocks25.createBlock)("core/site-tagline")
43255 ]
43256 ),
43257 (0, import_blocks25.createBlock)("core/separator"),
43258 (0, import_blocks25.createBlock)(
43259 "core/group",
43260 {
43261 tagName: "main"
43262 },
43263 [
43264 (0, import_blocks25.createBlock)(
43265 "core/group",
43266 {
43267 layout: { inherit: true }
43268 },
43269 [(0, import_blocks25.createBlock)("core/post-title")]
43270 ),
43271 (0, import_blocks25.createBlock)("core/post-content", {
43272 layout: { inherit: true }
43273 })
43274 ]
43275 )
43276 ]);
43277 const newTemplate = await createTemplate2({
43278 slug: paramCase(title || DEFAULT_TITLE) || "wp-custom-template",
43279 content: newTemplateContent,
43280 title: title || DEFAULT_TITLE,
43281 status: "publish"
43282 });
43283 setIsBusy(false);
43284 onNavigateToEntityRecord({
43285 postId: newTemplate.id,
43286 postType: "wp_template"
43287 });
43288 cancel();
43289 };
43290 return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(
43291 import_components116.Modal,
43292 {
43293 title: (0, import_i18n142.__)("Create custom template"),
43294 onRequestClose: cancel,
43295 focusOnMount: "firstContentElement",
43296 size: "small",
43297 overlayClassName: "editor-post-template__create-template-modal",
43298 children: /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(
43299 "form",
43300 {
43301 className: "editor-post-template__create-form",
43302 onSubmit: submit,
43303 children: /* @__PURE__ */ (0, import_jsx_runtime233.jsxs)(import_components116.__experimentalVStack, { spacing: "3", children: [
43304 /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(
43305 import_components116.TextControl,
43306 {
43307 __next40pxDefaultSize: true,
43308 label: (0, import_i18n142.__)("Name"),
43309 value: title,
43310 onChange: setTitle,
43311 placeholder: DEFAULT_TITLE,
43312 disabled: isBusy,
43313 help: (0, import_i18n142.__)(
43314 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
43315 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.'
43316 )
43317 }
43318 ),
43319 /* @__PURE__ */ (0, import_jsx_runtime233.jsxs)(import_components116.__experimentalHStack, { justify: "right", children: [
43320 /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(
43321 import_components116.Button,
43322 {
43323 __next40pxDefaultSize: true,
43324 variant: "tertiary",
43325 onClick: cancel,
43326 children: (0, import_i18n142.__)("Cancel")
43327 }
43328 ),
43329 /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(
43330 import_components116.Button,
43331 {
43332 __next40pxDefaultSize: true,
43333 variant: "primary",
43334 type: "submit",
43335 isBusy,
43336 "aria-disabled": isBusy,
43337 children: (0, import_i18n142.__)("Create")
43338 }
43339 )
43340 ] })
43341 ] })
43342 }
43343 )
43344 }
43345 );
43346 }
43347
43348 // packages/editor/build-module/components/post-template/hooks.mjs
43349 var import_data102 = __toESM(require_data(), 1);
43350 var import_element105 = __toESM(require_element(), 1);
43351 var import_core_data69 = __toESM(require_core_data(), 1);
43352 function useEditedPostContext() {
43353 return (0, import_data102.useSelect)((select6) => {
43354 const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select6(store);
43355 return {
43356 postId: getCurrentPostId2(),
43357 postType: getCurrentPostType2()
43358 };
43359 }, []);
43360 }
43361 function useAllowSwitchingTemplates() {
43362 const { postType: postType2, postId: postId2 } = useEditedPostContext();
43363 return (0, import_data102.useSelect)(
43364 (select6) => {
43365 const { canUser, getEntityRecord, getEntityRecords } = select6(import_core_data69.store);
43366 const siteSettings = canUser("read", {
43367 kind: "root",
43368 name: "site"
43369 }) ? getEntityRecord("root", "site") : void 0;
43370 const isPostsPage = +postId2 === siteSettings?.page_for_posts;
43371 const isFrontPage = postType2 === "page" && +postId2 === siteSettings?.page_on_front;
43372 const templates = isFrontPage ? getEntityRecords("postType", "wp_template", {
43373 per_page: -1
43374 }) : [];
43375 const hasFrontPage = isFrontPage && !!templates?.some(({ slug }) => slug === "front-page");
43376 return !isPostsPage && !hasFrontPage;
43377 },
43378 [postId2, postType2]
43379 );
43380 }
43381 function useTemplates(postType2) {
43382 return (0, import_data102.useSelect)(
43383 (select6) => select6(import_core_data69.store).getEntityRecords("postType", "wp_template", {
43384 per_page: -1,
43385 post_type: postType2
43386 // We look at the combined templates for now (old endpoint)
43387 // because posts only accept slugs for templates, not IDs.
43388 }),
43389 [postType2]
43390 );
43391 }
43392 function useAvailableTemplates(postType2) {
43393 const currentTemplateSlug = useCurrentTemplateSlug();
43394 const allowSwitchingTemplate = useAllowSwitchingTemplates();
43395 const templates = useTemplates(postType2);
43396 return (0, import_element105.useMemo)(
43397 () => allowSwitchingTemplate && templates?.filter(
43398 (template2) => template2.is_custom && template2.slug !== currentTemplateSlug && !!template2.content.raw
43399 // Skip empty templates.
43400 ),
43401 [templates, currentTemplateSlug, allowSwitchingTemplate]
43402 );
43403 }
43404 function useCurrentTemplateSlug() {
43405 const { postType: postType2, postId: postId2 } = useEditedPostContext();
43406 const templates = useTemplates(postType2);
43407 const entityTemplate = (0, import_data102.useSelect)(
43408 (select6) => {
43409 const post2 = select6(import_core_data69.store).getEditedEntityRecord(
43410 "postType",
43411 postType2,
43412 postId2
43413 );
43414 return post2?.template;
43415 },
43416 [postType2, postId2]
43417 );
43418 if (!entityTemplate) {
43419 return;
43420 }
43421 return templates?.find((template2) => template2.slug === entityTemplate)?.slug;
43422 }
43423
43424 // packages/editor/build-module/components/post-template/classic-theme.mjs
43425 var import_jsx_runtime234 = __toESM(require_jsx_runtime(), 1);
43426 function PostTemplateToggle({ isOpen, onClick }) {
43427 const templateTitle = (0, import_data103.useSelect)((select6) => {
43428 const templateSlug = select6(store).getEditedPostAttribute("template");
43429 const { supportsTemplateMode, availableTemplates } = select6(store).getEditorSettings();
43430 if (!supportsTemplateMode && availableTemplates[templateSlug]) {
43431 return availableTemplates[templateSlug];
43432 }
43433 const template2 = select6(import_core_data70.store).canUser("create", {
43434 kind: "postType",
43435 name: "wp_template"
43436 }) && select6(store).getCurrentTemplateId();
43437 return template2?.title || template2?.slug || availableTemplates?.[templateSlug];
43438 }, []);
43439 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
43440 import_components117.Button,
43441 {
43442 __next40pxDefaultSize: true,
43443 variant: "tertiary",
43444 "aria-expanded": isOpen,
43445 "aria-label": (0, import_i18n143.__)("Template options"),
43446 onClick,
43447 children: templateTitle ?? (0, import_i18n143.__)("Default template")
43448 }
43449 );
43450 }
43451 function PostTemplateDropdownContent({ onClose }) {
43452 const allowSwitchingTemplate = useAllowSwitchingTemplates();
43453 const {
43454 availableTemplates,
43455 fetchedTemplates,
43456 selectedTemplateSlug,
43457 canCreate,
43458 canEdit,
43459 currentTemplateId,
43460 onNavigateToEntityRecord,
43461 getEditorSettings: getEditorSettings2
43462 } = (0, import_data103.useSelect)(
43463 (select6) => {
43464 const { canUser, getEntityRecords } = select6(import_core_data70.store);
43465 const editorSettings2 = select6(store).getEditorSettings();
43466 const canCreateTemplates = canUser("create", {
43467 kind: "postType",
43468 name: "wp_template"
43469 });
43470 const _currentTemplateId = select6(store).getCurrentTemplateId();
43471 return {
43472 availableTemplates: editorSettings2.availableTemplates,
43473 fetchedTemplates: canCreateTemplates ? getEntityRecords("postType", "wp_template", {
43474 post_type: select6(store).getCurrentPostType(),
43475 per_page: -1
43476 }) : void 0,
43477 selectedTemplateSlug: select6(store).getEditedPostAttribute("template"),
43478 canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings2.supportsTemplateMode,
43479 canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings2.supportsTemplateMode && !!_currentTemplateId,
43480 currentTemplateId: _currentTemplateId,
43481 onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord,
43482 getEditorSettings: select6(store).getEditorSettings
43483 };
43484 },
43485 [allowSwitchingTemplate]
43486 );
43487 const options = (0, import_element106.useMemo)(
43488 () => Object.entries({
43489 ...availableTemplates,
43490 ...Object.fromEntries(
43491 (fetchedTemplates ?? []).map(({ slug, title }) => [
43492 slug,
43493 title.rendered
43494 ])
43495 )
43496 }).map(([slug, title]) => ({ value: slug, label: title })),
43497 [availableTemplates, fetchedTemplates]
43498 );
43499 const selectedOption = options.find((option) => option.value === selectedTemplateSlug) ?? options.find((option) => !option.value);
43500 const { editPost: editPost2 } = (0, import_data103.useDispatch)(store);
43501 const { createSuccessNotice } = (0, import_data103.useDispatch)(import_notices21.store);
43502 const [isCreateModalOpen, setIsCreateModalOpen] = (0, import_element106.useState)(false);
43503 return /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)("div", { className: "editor-post-template__classic-theme-dropdown", children: [
43504 /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
43505 import_block_editor46.__experimentalInspectorPopoverHeader,
43506 {
43507 title: (0, import_i18n143.__)("Template"),
43508 help: (0, import_i18n143.__)(
43509 "Templates define the way content is displayed when viewing your site."
43510 ),
43511 actions: canCreate ? [
43512 {
43513 icon: add_template_default,
43514 label: (0, import_i18n143.__)("Add template"),
43515 onClick: () => setIsCreateModalOpen(true)
43516 }
43517 ] : [],
43518 onClose
43519 }
43520 ),
43521 !allowSwitchingTemplate ? /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(import_components117.Notice, { status: "warning", isDismissible: false, children: (0, import_i18n143.__)("The posts page template cannot be changed.") }) : /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
43522 import_components117.SelectControl,
43523 {
43524 __next40pxDefaultSize: true,
43525 hideLabelFromVision: true,
43526 label: (0, import_i18n143.__)("Template"),
43527 value: selectedOption?.value ?? "",
43528 options,
43529 onChange: (slug) => editPost2({ template: slug || "" })
43530 }
43531 ),
43532 canEdit && onNavigateToEntityRecord && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
43533 import_components117.Button,
43534 {
43535 __next40pxDefaultSize: true,
43536 variant: "link",
43537 onClick: () => {
43538 onNavigateToEntityRecord({
43539 postId: currentTemplateId,
43540 postType: "wp_template"
43541 });
43542 onClose();
43543 createSuccessNotice(
43544 (0, import_i18n143.__)(
43545 "Editing template. Changes made here affect all posts and pages that use the template."
43546 ),
43547 {
43548 type: "snackbar",
43549 actions: [
43550 {
43551 label: (0, import_i18n143.__)("Go back"),
43552 onClick: () => getEditorSettings2().onNavigateToPreviousEntityRecord()
43553 }
43554 ]
43555 }
43556 );
43557 },
43558 children: (0, import_i18n143.__)("Edit template")
43559 }
43560 ) }),
43561 isCreateModalOpen && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
43562 CreateNewTemplateModal,
43563 {
43564 onClose: () => setIsCreateModalOpen(false)
43565 }
43566 )
43567 ] });
43568 }
43569 function ClassicThemeControl() {
43570 const [popoverAnchor, setPopoverAnchor] = (0, import_element106.useState)(null);
43571 const popoverProps = (0, import_element106.useMemo)(
43572 () => ({
43573 // Anchor the popover to the middle of the entire row so that it doesn't
43574 // move around when the label changes.
43575 anchor: popoverAnchor,
43576 className: "editor-post-template__dropdown",
43577 placement: "left-start",
43578 offset: 36,
43579 shift: true
43580 }),
43581 [popoverAnchor]
43582 );
43583 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(post_panel_row_default, { label: (0, import_i18n143.__)("Template"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
43584 import_components117.Dropdown,
43585 {
43586 popoverProps,
43587 focusOnMount: true,
43588 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(
43589 PostTemplateToggle,
43590 {
43591 isOpen,
43592 onClick: onToggle
43593 }
43594 ),
43595 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(PostTemplateDropdownContent, { onClose })
43596 }
43597 ) });
43598 }
43599 var classic_theme_default = ClassicThemeControl;
43600
43601 // packages/editor/build-module/components/plugin-document-setting-panel/index.mjs
43602 var import_components119 = __toESM(require_components(), 1);
43603 var import_plugins3 = __toESM(require_plugins(), 1);
43604 var import_data105 = __toESM(require_data(), 1);
43605 var import_warning = __toESM(require_warning(), 1);
43606
43607 // packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.mjs
43608 var import_components118 = __toESM(require_components(), 1);
43609
43610 // packages/editor/build-module/components/preferences-modal/enable-panel.mjs
43611 var import_data104 = __toESM(require_data(), 1);
43612 var import_preferences12 = __toESM(require_preferences(), 1);
43613 var import_jsx_runtime235 = __toESM(require_jsx_runtime(), 1);
43614 var { PreferenceBaseOption } = unlock(import_preferences12.privateApis);
43615 function EnablePanelOption(props) {
43616 const { toggleEditorPanelEnabled: toggleEditorPanelEnabled2 } = (0, import_data104.useDispatch)(store);
43617 const { isChecked, isRemoved } = (0, import_data104.useSelect)(
43618 (select6) => {
43619 const { isEditorPanelEnabled: isEditorPanelEnabled2, isEditorPanelRemoved: isEditorPanelRemoved2 } = select6(store);
43620 return {
43621 isChecked: isEditorPanelEnabled2(props.panelName),
43622 isRemoved: isEditorPanelRemoved2(props.panelName)
43623 };
43624 },
43625 [props.panelName]
43626 );
43627 if (isRemoved) {
43628 return null;
43629 }
43630 return /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
43631 PreferenceBaseOption,
43632 {
43633 isChecked,
43634 onChange: () => toggleEditorPanelEnabled2(props.panelName),
43635 ...props
43636 }
43637 );
43638 }
43639
43640 // packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.mjs
43641 var import_jsx_runtime236 = __toESM(require_jsx_runtime(), 1);
43642 var { Fill: Fill4, Slot: Slot4 } = (0, import_components118.createSlotFill)(
43643 "EnablePluginDocumentSettingPanelOption"
43644 );
43645 var EnablePluginDocumentSettingPanelOption = ({ label, panelName }) => /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(Fill4, { children: /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(EnablePanelOption, { label, panelName }) });
43646 EnablePluginDocumentSettingPanelOption.Slot = Slot4;
43647 var enable_plugin_document_setting_panel_default = EnablePluginDocumentSettingPanelOption;
43648
43649 // packages/editor/build-module/components/plugin-document-setting-panel/index.mjs
43650 var import_jsx_runtime237 = __toESM(require_jsx_runtime(), 1);
43651 var { Fill: Fill5, Slot: Slot5 } = (0, import_components119.createSlotFill)("PluginDocumentSettingPanel");
43652 var PluginDocumentSettingPanel = ({
43653 name: name2,
43654 className,
43655 title,
43656 icon,
43657 children
43658 }) => {
43659 const { name: pluginName } = (0, import_plugins3.usePluginContext)();
43660 const panelName = `${pluginName}/${name2}`;
43661 const { opened, isEnabled } = (0, import_data105.useSelect)(
43662 (select6) => {
43663 const { isEditorPanelOpened: isEditorPanelOpened2, isEditorPanelEnabled: isEditorPanelEnabled2 } = select6(store);
43664 return {
43665 opened: isEditorPanelOpened2(panelName),
43666 isEnabled: isEditorPanelEnabled2(panelName)
43667 };
43668 },
43669 [panelName]
43670 );
43671 const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data105.useDispatch)(store);
43672 if (void 0 === name2) {
43673 (0, import_warning.default)("PluginDocumentSettingPanel requires a name property.");
43674 }
43675 return /* @__PURE__ */ (0, import_jsx_runtime237.jsxs)(import_jsx_runtime237.Fragment, { children: [
43676 /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(
43677 enable_plugin_document_setting_panel_default,
43678 {
43679 label: title,
43680 panelName
43681 }
43682 ),
43683 /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(Fill5, { children: isEnabled && /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(
43684 import_components119.PanelBody,
43685 {
43686 className,
43687 title,
43688 icon,
43689 opened,
43690 onToggle: () => toggleEditorPanelOpened2(panelName),
43691 children
43692 }
43693 ) })
43694 ] });
43695 };
43696 PluginDocumentSettingPanel.Slot = Slot5;
43697 var plugin_document_setting_panel_default = PluginDocumentSettingPanel;
43698
43699 // packages/editor/build-module/components/block-settings-menu/plugin-block-settings-menu-item.mjs
43700 var import_block_editor47 = __toESM(require_block_editor(), 1);
43701 var import_components120 = __toESM(require_components(), 1);
43702 var import_compose24 = __toESM(require_compose(), 1);
43703 var import_jsx_runtime238 = __toESM(require_jsx_runtime(), 1);
43704 var isEverySelectedBlockAllowed = (selected, allowed) => selected.filter((id) => !allowed.includes(id)).length === 0;
43705 var shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks);
43706 var PluginBlockSettingsMenuItem = ({
43707 allowedBlocks,
43708 icon,
43709 label,
43710 onClick,
43711 small,
43712 role
43713 }) => /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(import_block_editor47.BlockSettingsMenuControls, { children: ({ selectedBlocks, onClose }) => {
43714 if (!shouldRenderItem(selectedBlocks, allowedBlocks)) {
43715 return null;
43716 }
43717 return /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(
43718 import_components120.MenuItem,
43719 {
43720 onClick: (0, import_compose24.compose)(onClick, onClose),
43721 icon,
43722 label: small ? label : void 0,
43723 role,
43724 children: !small && label
43725 }
43726 );
43727 } });
43728 var plugin_block_settings_menu_item_default = PluginBlockSettingsMenuItem;
43729
43730 // packages/editor/build-module/components/plugin-more-menu-item/index.mjs
43731 var import_components121 = __toESM(require_components(), 1);
43732 var import_plugins4 = __toESM(require_plugins(), 1);
43733 var import_jsx_runtime239 = __toESM(require_jsx_runtime(), 1);
43734 function PluginMoreMenuItem(props) {
43735 const context = (0, import_plugins4.usePluginContext)();
43736 return /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(
43737 action_item_default,
43738 {
43739 name: "core/plugin-more-menu",
43740 as: props.as ?? import_components121.MenuItem,
43741 icon: props.icon || context.icon,
43742 ...props
43743 }
43744 );
43745 }
43746
43747 // packages/editor/build-module/components/plugin-post-publish-panel/index.mjs
43748 var import_plugins5 = __toESM(require_plugins(), 1);
43749 var import_components122 = __toESM(require_components(), 1);
43750 var import_jsx_runtime240 = __toESM(require_jsx_runtime(), 1);
43751 var { Fill: Fill6, Slot: Slot6 } = (0, import_components122.createSlotFill)("PluginPostPublishPanel");
43752 var PluginPostPublishPanel = ({
43753 children,
43754 className,
43755 title,
43756 initialOpen = false,
43757 icon
43758 }) => {
43759 const { icon: pluginIcon } = (0, import_plugins5.usePluginContext)();
43760 return /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(Fill6, { children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(
43761 import_components122.PanelBody,
43762 {
43763 className,
43764 initialOpen: initialOpen || !title,
43765 title,
43766 icon: icon ?? pluginIcon,
43767 children
43768 }
43769 ) });
43770 };
43771 PluginPostPublishPanel.Slot = Slot6;
43772 var plugin_post_publish_panel_default = PluginPostPublishPanel;
43773
43774 // packages/editor/build-module/components/plugin-post-status-info/index.mjs
43775 var import_components123 = __toESM(require_components(), 1);
43776 var import_jsx_runtime241 = __toESM(require_jsx_runtime(), 1);
43777 var { Fill: Fill7, Slot: Slot7 } = (0, import_components123.createSlotFill)("PluginPostStatusInfo");
43778 var PluginPostStatusInfo = ({ children, className }) => /* @__PURE__ */ (0, import_jsx_runtime241.jsx)(Fill7, { children: /* @__PURE__ */ (0, import_jsx_runtime241.jsx)(import_components123.PanelRow, { className, children }) });
43779 PluginPostStatusInfo.Slot = Slot7;
43780 var plugin_post_status_info_default = PluginPostStatusInfo;
43781
43782 // packages/editor/build-module/components/plugin-pre-publish-panel/index.mjs
43783 var import_components124 = __toESM(require_components(), 1);
43784 var import_plugins6 = __toESM(require_plugins(), 1);
43785 var import_jsx_runtime242 = __toESM(require_jsx_runtime(), 1);
43786 var { Fill: Fill8, Slot: Slot8 } = (0, import_components124.createSlotFill)("PluginPrePublishPanel");
43787 var PluginPrePublishPanel = ({
43788 children,
43789 className,
43790 title,
43791 initialOpen = false,
43792 icon
43793 }) => {
43794 const { icon: pluginIcon } = (0, import_plugins6.usePluginContext)();
43795 return /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(Fill8, { children: /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(
43796 import_components124.PanelBody,
43797 {
43798 className,
43799 initialOpen: initialOpen || !title,
43800 title,
43801 icon: icon ?? pluginIcon,
43802 children
43803 }
43804 ) });
43805 };
43806 PluginPrePublishPanel.Slot = Slot8;
43807 var plugin_pre_publish_panel_default = PluginPrePublishPanel;
43808
43809 // packages/editor/build-module/components/plugin-preview-menu-item/index.mjs
43810 var import_components125 = __toESM(require_components(), 1);
43811 var import_plugins7 = __toESM(require_plugins(), 1);
43812 var import_jsx_runtime243 = __toESM(require_jsx_runtime(), 1);
43813 function PluginPreviewMenuItem(props) {
43814 const context = (0, import_plugins7.usePluginContext)();
43815 return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(
43816 action_item_default,
43817 {
43818 name: "core/plugin-preview-menu",
43819 as: props.as ?? import_components125.MenuItem,
43820 icon: props.icon || context.icon,
43821 ...props
43822 }
43823 );
43824 }
43825
43826 // packages/editor/build-module/components/plugin-sidebar/index.mjs
43827 var import_jsx_runtime244 = __toESM(require_jsx_runtime(), 1);
43828 function PluginSidebar({ className, ...props }) {
43829 return /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(
43830 complementary_area_default,
43831 {
43832 panelClassName: className,
43833 className: "editor-sidebar",
43834 scope: "core",
43835 ...props
43836 }
43837 );
43838 }
43839
43840 // packages/editor/build-module/components/plugin-sidebar-more-menu-item/index.mjs
43841 var import_jsx_runtime245 = __toESM(require_jsx_runtime(), 1);
43842 function PluginSidebarMoreMenuItem(props) {
43843 return /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(
43844 ComplementaryAreaMoreMenuItem,
43845 {
43846 __unstableExplicitMenuItem: true,
43847 scope: "core",
43848 ...props
43849 }
43850 );
43851 }
43852
43853 // packages/editor/build-module/components/post-template/panel.mjs
43854 var import_data110 = __toESM(require_data(), 1);
43855 var import_core_data75 = __toESM(require_core_data(), 1);
43856
43857 // packages/editor/build-module/components/post-template/block-theme.mjs
43858 var import_data109 = __toESM(require_data(), 1);
43859 var import_html_entities16 = __toESM(require_html_entities(), 1);
43860 var import_components129 = __toESM(require_components(), 1);
43861 var import_element109 = __toESM(require_element(), 1);
43862 var import_i18n147 = __toESM(require_i18n(), 1);
43863 var import_core_data74 = __toESM(require_core_data(), 1);
43864 var import_notices22 = __toESM(require_notices(), 1);
43865 var import_preferences13 = __toESM(require_preferences(), 1);
43866
43867 // packages/editor/build-module/components/post-template/swap-template-button.mjs
43868 var import_element107 = __toESM(require_element(), 1);
43869 var import_html_entities15 = __toESM(require_html_entities(), 1);
43870 var import_block_editor48 = __toESM(require_block_editor(), 1);
43871 var import_components126 = __toESM(require_components(), 1);
43872 var import_i18n144 = __toESM(require_i18n(), 1);
43873 var import_data106 = __toESM(require_data(), 1);
43874 var import_core_data71 = __toESM(require_core_data(), 1);
43875 var import_blocks26 = __toESM(require_blocks(), 1);
43876
43877 // packages/editor/build-module/utils/search-templates.mjs
43878 var import_remove_accents3 = __toESM(require_remove_accents(), 1);
43879 function normalizeSearchInput(input = "") {
43880 input = (0, import_remove_accents3.default)(input);
43881 input = input.trim().toLowerCase();
43882 return input;
43883 }
43884 function getTemplateSearchRank(template2, searchValue) {
43885 const normalizedSearchValue = normalizeSearchInput(searchValue);
43886 const normalizedTitle = normalizeSearchInput(template2.title);
43887 let rank = 0;
43888 if (normalizedSearchValue === normalizedTitle) {
43889 rank += 30;
43890 } else if (normalizedTitle.startsWith(normalizedSearchValue)) {
43891 rank += 20;
43892 } else {
43893 const searchTerms = normalizedSearchValue.split(" ");
43894 const hasMatchedTerms = searchTerms.every(
43895 (searchTerm) => normalizedTitle.includes(searchTerm)
43896 );
43897 if (hasMatchedTerms) {
43898 rank += 10;
43899 }
43900 }
43901 return rank;
43902 }
43903 function searchTemplates(templates = [], searchValue = "") {
43904 if (!searchValue) {
43905 return templates;
43906 }
43907 const rankedTemplates = templates.map((template2) => {
43908 return [template2, getTemplateSearchRank(template2, searchValue)];
43909 }).filter(([, rank]) => rank > 0);
43910 rankedTemplates.sort(([, rank1], [, rank2]) => rank2 - rank1);
43911 return rankedTemplates.map(([template2]) => template2);
43912 }
43913
43914 // packages/editor/build-module/components/post-template/swap-template-button.mjs
43915 var import_jsx_runtime246 = __toESM(require_jsx_runtime(), 1);
43916 function SwapTemplateButton({ onClick }) {
43917 const [showModal, setShowModal] = (0, import_element107.useState)(false);
43918 const { postType: postType2, postId: postId2 } = useEditedPostContext();
43919 const availableTemplates = useAvailableTemplates(postType2);
43920 const { editEntityRecord } = (0, import_data106.useDispatch)(import_core_data71.store);
43921 const onTemplateSelect = async (template2) => {
43922 editEntityRecord(
43923 "postType",
43924 postType2,
43925 postId2,
43926 { template: template2.name },
43927 { undoIgnore: true }
43928 );
43929 setShowModal(false);
43930 onClick();
43931 };
43932 return /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)(import_jsx_runtime246.Fragment, { children: [
43933 /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
43934 import_components126.MenuItem,
43935 {
43936 disabled: !availableTemplates?.length,
43937 accessibleWhenDisabled: true,
43938 onClick: () => setShowModal(true),
43939 children: (0, import_i18n144.__)("Change template")
43940 }
43941 ),
43942 showModal && /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
43943 import_components126.Modal,
43944 {
43945 title: (0, import_i18n144.__)("Choose a template"),
43946 onRequestClose: () => setShowModal(false),
43947 overlayClassName: "editor-post-template__swap-template-modal",
43948 isFullScreen: true,
43949 children: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)("div", { className: "editor-post-template__swap-template-modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
43950 TemplatesList,
43951 {
43952 postType: postType2,
43953 onSelect: onTemplateSelect
43954 }
43955 ) })
43956 }
43957 )
43958 ] });
43959 }
43960 function TemplatesList({ postType: postType2, onSelect }) {
43961 const [searchValue, setSearchValue] = (0, import_element107.useState)("");
43962 const availableTemplates = useAvailableTemplates(postType2);
43963 const templatesAsPatterns = (0, import_element107.useMemo)(
43964 () => availableTemplates.map((template2) => ({
43965 name: template2.slug,
43966 blocks: (0, import_blocks26.parse)(template2.content.raw),
43967 title: (0, import_html_entities15.decodeEntities)(template2.title.rendered),
43968 id: template2.id
43969 })),
43970 [availableTemplates]
43971 );
43972 const filteredBlockTemplates = (0, import_element107.useMemo)(() => {
43973 return searchTemplates(templatesAsPatterns, searchValue);
43974 }, [templatesAsPatterns, searchValue]);
43975 return /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)(import_jsx_runtime246.Fragment, { children: [
43976 /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
43977 import_components126.SearchControl,
43978 {
43979 onChange: setSearchValue,
43980 value: searchValue,
43981 label: (0, import_i18n144.__)("Search"),
43982 placeholder: (0, import_i18n144.__)("Search"),
43983 className: "editor-post-template__swap-template-search"
43984 }
43985 ),
43986 /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
43987 import_block_editor48.__experimentalBlockPatternsList,
43988 {
43989 label: (0, import_i18n144.__)("Templates"),
43990 blockPatterns: filteredBlockTemplates,
43991 onClickPattern: onSelect
43992 }
43993 )
43994 ] });
43995 }
43996
43997 // packages/editor/build-module/components/post-template/reset-default-template.mjs
43998 var import_components127 = __toESM(require_components(), 1);
43999 var import_i18n145 = __toESM(require_i18n(), 1);
44000 var import_data107 = __toESM(require_data(), 1);
44001 var import_core_data72 = __toESM(require_core_data(), 1);
44002 var import_jsx_runtime247 = __toESM(require_jsx_runtime(), 1);
44003 function ResetDefaultTemplate({ onClick }) {
44004 const currentTemplateSlug = useCurrentTemplateSlug();
44005 const allowSwitchingTemplate = useAllowSwitchingTemplates();
44006 const { postType: postType2, postId: postId2 } = useEditedPostContext();
44007 const { editEntityRecord } = (0, import_data107.useDispatch)(import_core_data72.store);
44008 if (!currentTemplateSlug || !allowSwitchingTemplate) {
44009 return null;
44010 }
44011 return /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
44012 import_components127.MenuItem,
44013 {
44014 onClick: () => {
44015 editEntityRecord(
44016 "postType",
44017 postType2,
44018 postId2,
44019 { template: "" },
44020 { undoIgnore: true }
44021 );
44022 onClick();
44023 },
44024 children: (0, import_i18n145.__)("Use default template")
44025 }
44026 );
44027 }
44028
44029 // packages/editor/build-module/components/post-template/create-new-template.mjs
44030 var import_components128 = __toESM(require_components(), 1);
44031 var import_i18n146 = __toESM(require_i18n(), 1);
44032 var import_data108 = __toESM(require_data(), 1);
44033 var import_core_data73 = __toESM(require_core_data(), 1);
44034 var import_element108 = __toESM(require_element(), 1);
44035 var import_jsx_runtime248 = __toESM(require_jsx_runtime(), 1);
44036 function CreateNewTemplate() {
44037 const { canCreateTemplates } = (0, import_data108.useSelect)((select6) => {
44038 const { canUser } = select6(import_core_data73.store);
44039 return {
44040 canCreateTemplates: canUser("create", {
44041 kind: "postType",
44042 name: "wp_template"
44043 })
44044 };
44045 }, []);
44046 const [isCreateModalOpen, setIsCreateModalOpen] = (0, import_element108.useState)(false);
44047 const allowSwitchingTemplate = useAllowSwitchingTemplates();
44048 if (!canCreateTemplates || !allowSwitchingTemplate) {
44049 return null;
44050 }
44051 return /* @__PURE__ */ (0, import_jsx_runtime248.jsxs)(import_jsx_runtime248.Fragment, { children: [
44052 /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
44053 import_components128.MenuItem,
44054 {
44055 onClick: () => {
44056 setIsCreateModalOpen(true);
44057 },
44058 children: (0, import_i18n146.__)("Create new template")
44059 }
44060 ),
44061 isCreateModalOpen && /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
44062 CreateNewTemplateModal,
44063 {
44064 onClose: () => {
44065 setIsCreateModalOpen(false);
44066 }
44067 }
44068 )
44069 ] });
44070 }
44071
44072 // packages/editor/build-module/components/post-template/block-theme.mjs
44073 var import_jsx_runtime249 = __toESM(require_jsx_runtime(), 1);
44074 function BlockThemeControl({ id }) {
44075 const {
44076 isTemplateHidden,
44077 onNavigateToEntityRecord,
44078 getEditorSettings: getEditorSettings2,
44079 hasGoBack,
44080 hasSpecificTemplate
44081 } = (0, import_data109.useSelect)((select6) => {
44082 const {
44083 getRenderingMode: getRenderingMode2,
44084 getEditorSettings: _getEditorSettings,
44085 getCurrentPost: getCurrentPost2
44086 } = unlock(select6(store));
44087 const editorSettings2 = _getEditorSettings();
44088 const currentPost = getCurrentPost2();
44089 return {
44090 isTemplateHidden: getRenderingMode2() === "post-only",
44091 onNavigateToEntityRecord: editorSettings2.onNavigateToEntityRecord,
44092 getEditorSettings: _getEditorSettings,
44093 hasGoBack: editorSettings2.hasOwnProperty(
44094 "onNavigateToPreviousEntityRecord"
44095 ),
44096 hasSpecificTemplate: !!currentPost.template
44097 };
44098 }, []);
44099 const { get: getPreference } = (0, import_data109.useSelect)(import_preferences13.store);
44100 const { editedRecord: template2, hasResolved } = (0, import_core_data74.useEntityRecord)(
44101 "postType",
44102 "wp_template",
44103 id
44104 );
44105 const { getEntityRecord } = (0, import_data109.useSelect)(import_core_data74.store);
44106 const { editEntityRecord } = (0, import_data109.useDispatch)(import_core_data74.store);
44107 const { createSuccessNotice } = (0, import_data109.useDispatch)(import_notices22.store);
44108 const { setRenderingMode: setRenderingMode2, setDefaultRenderingMode: setDefaultRenderingMode2 } = unlock(
44109 (0, import_data109.useDispatch)(store)
44110 );
44111 const canCreateTemplate = (0, import_data109.useSelect)(
44112 (select6) => !!select6(import_core_data74.store).canUser("create", {
44113 kind: "postType",
44114 name: "wp_template"
44115 }),
44116 []
44117 );
44118 const [popoverAnchor, setPopoverAnchor] = (0, import_element109.useState)(null);
44119 const popoverProps = (0, import_element109.useMemo)(
44120 () => ({
44121 // Anchor the popover to the middle of the entire row so that it doesn't
44122 // move around when the label changes.
44123 anchor: popoverAnchor,
44124 className: "editor-post-template__dropdown",
44125 placement: "left-start",
44126 offset: 36,
44127 shift: true
44128 }),
44129 [popoverAnchor]
44130 );
44131 if (!hasResolved) {
44132 return null;
44133 }
44134 const notificationAction = hasGoBack ? [
44135 {
44136 label: (0, import_i18n147.__)("Go back"),
44137 onClick: () => getEditorSettings2().onNavigateToPreviousEntityRecord()
44138 }
44139 ] : void 0;
44140 const mayShowTemplateEditNotice = () => {
44141 if (!getPreference("core/edit-site", "welcomeGuideTemplate")) {
44142 createSuccessNotice(
44143 (0, import_i18n147.__)(
44144 "Editing template. Changes made here affect all posts and pages that use the template."
44145 ),
44146 { type: "snackbar", actions: notificationAction }
44147 );
44148 }
44149 };
44150 return /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(post_panel_row_default, { label: (0, import_i18n147.__)("Template"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(
44151 import_components129.DropdownMenu,
44152 {
44153 popoverProps,
44154 focusOnMount: true,
44155 toggleProps: {
44156 size: "compact",
44157 variant: "tertiary",
44158 tooltipPosition: "middle left"
44159 },
44160 label: (0, import_i18n147.__)("Template options"),
44161 text: (0, import_html_entities16.decodeEntities)(template2.title),
44162 icon: null,
44163 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime249.jsxs)(import_jsx_runtime249.Fragment, { children: [
44164 /* @__PURE__ */ (0, import_jsx_runtime249.jsxs)(import_components129.MenuGroup, { children: [
44165 canCreateTemplate && /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(
44166 import_components129.MenuItem,
44167 {
44168 onClick: async () => {
44169 onNavigateToEntityRecord({
44170 postId: template2.id,
44171 postType: "wp_template"
44172 });
44173 if (!hasSpecificTemplate && window?.__experimentalTemplateActivate) {
44174 const activeTemplates = await getEntityRecord(
44175 "root",
44176 "site"
44177 ).active_templates;
44178 if (activeTemplates[template2.slug] !== template2.id) {
44179 editEntityRecord(
44180 "root",
44181 "site",
44182 void 0,
44183 {
44184 active_templates: {
44185 ...activeTemplates,
44186 [template2.slug]: template2.id
44187 }
44188 }
44189 );
44190 }
44191 }
44192 onClose();
44193 mayShowTemplateEditNotice();
44194 },
44195 children: (0, import_i18n147.__)("Edit template")
44196 }
44197 ),
44198 /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(SwapTemplateButton, { onClick: onClose }),
44199 /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(ResetDefaultTemplate, { onClick: onClose }),
44200 canCreateTemplate && /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(CreateNewTemplate, {})
44201 ] }),
44202 /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(import_components129.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(
44203 import_components129.MenuItem,
44204 {
44205 icon: !isTemplateHidden ? check_default : void 0,
44206 isSelected: !isTemplateHidden,
44207 role: "menuitemcheckbox",
44208 onClick: () => {
44209 const newRenderingMode = isTemplateHidden ? "template-locked" : "post-only";
44210 setRenderingMode2(newRenderingMode);
44211 setDefaultRenderingMode2(newRenderingMode);
44212 },
44213 children: (0, import_i18n147.__)("Show template")
44214 }
44215 ) })
44216 ] })
44217 }
44218 ) });
44219 }
44220
44221 // packages/editor/build-module/components/post-template/panel.mjs
44222 var import_jsx_runtime250 = __toESM(require_jsx_runtime(), 1);
44223 function PostTemplatePanel() {
44224 const { templateId: templateId2, isBlockTheme } = (0, import_data110.useSelect)((select6) => {
44225 const { getCurrentTemplateId: getCurrentTemplateId2, getEditorSettings: getEditorSettings2 } = select6(store);
44226 return {
44227 templateId: getCurrentTemplateId2(),
44228 isBlockTheme: getEditorSettings2().__unstableIsBlockBasedTheme
44229 };
44230 }, []);
44231 const isVisible = (0, import_data110.useSelect)((select6) => {
44232 const postTypeSlug = select6(store).getCurrentPostType();
44233 const postType2 = select6(import_core_data75.store).getPostType(postTypeSlug);
44234 if (!postType2?.viewable) {
44235 return false;
44236 }
44237 const settings = select6(store).getEditorSettings();
44238 const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
44239 if (hasTemplates) {
44240 return true;
44241 }
44242 if (!settings.supportsTemplateMode) {
44243 return false;
44244 }
44245 const canCreateTemplates = select6(import_core_data75.store).canUser("create", {
44246 kind: "postType",
44247 name: "wp_template"
44248 }) ?? false;
44249 return canCreateTemplates;
44250 }, []);
44251 const canViewTemplates = (0, import_data110.useSelect)(
44252 (select6) => {
44253 return isVisible ? select6(import_core_data75.store).canUser("read", {
44254 kind: "postType",
44255 name: "wp_template"
44256 }) : false;
44257 },
44258 [isVisible]
44259 );
44260 if ((!isBlockTheme || !canViewTemplates) && isVisible) {
44261 return /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(classic_theme_default, {});
44262 }
44263 if (isBlockTheme && !!templateId2) {
44264 return /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(BlockThemeControl, { id: templateId2 });
44265 }
44266 return null;
44267 }
44268
44269 // packages/editor/build-module/components/post-author/index.mjs
44270 var import_data114 = __toESM(require_data(), 1);
44271 var import_core_data77 = __toESM(require_core_data(), 1);
44272
44273 // packages/editor/build-module/components/post-author/combobox.mjs
44274 var import_compose25 = __toESM(require_compose(), 1);
44275 var import_element111 = __toESM(require_element(), 1);
44276 var import_data112 = __toESM(require_data(), 1);
44277 var import_i18n149 = __toESM(require_i18n(), 1);
44278 var import_components130 = __toESM(require_components(), 1);
44279
44280 // packages/editor/build-module/components/post-author/hook.mjs
44281 var import_i18n148 = __toESM(require_i18n(), 1);
44282 var import_element110 = __toESM(require_element(), 1);
44283 var import_data111 = __toESM(require_data(), 1);
44284 var import_html_entities17 = __toESM(require_html_entities(), 1);
44285 var import_core_data76 = __toESM(require_core_data(), 1);
44286
44287 // packages/editor/build-module/components/post-author/constants.mjs
44288 var BASE_QUERY = {
44289 _fields: "id,name",
44290 context: "view"
44291 // Allows non-admins to perform requests.
44292 };
44293 var AUTHORS_QUERY = {
44294 who: "authors",
44295 per_page: 100,
44296 ...BASE_QUERY
44297 };
44298
44299 // packages/editor/build-module/components/post-author/hook.mjs
44300 function useAuthorsQuery(search) {
44301 const { authorId, authors, postAuthor, isLoading } = (0, import_data111.useSelect)(
44302 (select6) => {
44303 const { getUser, getUsers, isResolving } = select6(import_core_data76.store);
44304 const { getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
44305 const _authorId = getEditedPostAttribute2("author");
44306 const query = { ...AUTHORS_QUERY };
44307 if (search) {
44308 query.search = search;
44309 query.search_columns = ["name"];
44310 }
44311 return {
44312 authorId: _authorId,
44313 authors: getUsers(query),
44314 postAuthor: getUser(_authorId, BASE_QUERY),
44315 isLoading: isResolving("getUsers", [query])
44316 };
44317 },
44318 [search]
44319 );
44320 const authorOptions = (0, import_element110.useMemo)(() => {
44321 const fetchedAuthors = (authors ?? []).map((author) => {
44322 return {
44323 value: author.id,
44324 label: (0, import_html_entities17.decodeEntities)(author.name)
44325 };
44326 });
44327 const foundAuthor = fetchedAuthors.findIndex(
44328 ({ value }) => postAuthor?.id === value
44329 );
44330 let currentAuthor = [];
44331 if (foundAuthor < 0 && postAuthor) {
44332 currentAuthor = [
44333 {
44334 value: postAuthor.id,
44335 label: (0, import_html_entities17.decodeEntities)(postAuthor.name)
44336 }
44337 ];
44338 } else if (foundAuthor < 0 && !postAuthor) {
44339 currentAuthor = [
44340 {
44341 value: 0,
44342 label: (0, import_i18n148.__)("(No author)")
44343 }
44344 ];
44345 }
44346 return [...currentAuthor, ...fetchedAuthors];
44347 }, [authors, postAuthor]);
44348 return { authorId, authorOptions, postAuthor, isLoading };
44349 }
44350
44351 // packages/editor/build-module/components/post-author/combobox.mjs
44352 var import_jsx_runtime251 = __toESM(require_jsx_runtime(), 1);
44353 function PostAuthorCombobox() {
44354 const [fieldValue, setFieldValue] = (0, import_element111.useState)();
44355 const { editPost: editPost2 } = (0, import_data112.useDispatch)(store);
44356 const { authorId, authorOptions, isLoading } = useAuthorsQuery(fieldValue);
44357 const handleSelect = (postAuthorId) => {
44358 if (!postAuthorId) {
44359 return;
44360 }
44361 editPost2({ author: postAuthorId });
44362 };
44363 return /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(
44364 import_components130.ComboboxControl,
44365 {
44366 __next40pxDefaultSize: true,
44367 label: (0, import_i18n149.__)("Author"),
44368 options: authorOptions,
44369 value: authorId,
44370 onFilterValueChange: (0, import_compose25.debounce)(setFieldValue, 300),
44371 onChange: handleSelect,
44372 allowReset: false,
44373 hideLabelFromVision: true,
44374 isLoading
44375 }
44376 );
44377 }
44378
44379 // packages/editor/build-module/components/post-author/select.mjs
44380 var import_i18n150 = __toESM(require_i18n(), 1);
44381 var import_data113 = __toESM(require_data(), 1);
44382 var import_components131 = __toESM(require_components(), 1);
44383 var import_jsx_runtime252 = __toESM(require_jsx_runtime(), 1);
44384 function PostAuthorSelect() {
44385 const { editPost: editPost2 } = (0, import_data113.useDispatch)(store);
44386 const { authorId, authorOptions } = useAuthorsQuery();
44387 const setAuthorId = (value) => {
44388 const author = Number(value);
44389 editPost2({ author });
44390 };
44391 return /* @__PURE__ */ (0, import_jsx_runtime252.jsx)(
44392 import_components131.SelectControl,
44393 {
44394 __next40pxDefaultSize: true,
44395 className: "post-author-selector",
44396 label: (0, import_i18n150.__)("Author"),
44397 options: authorOptions,
44398 onChange: setAuthorId,
44399 value: authorId,
44400 hideLabelFromVision: true
44401 }
44402 );
44403 }
44404
44405 // packages/editor/build-module/components/post-author/index.mjs
44406 var import_jsx_runtime253 = __toESM(require_jsx_runtime(), 1);
44407 var minimumUsersForCombobox = 25;
44408 function PostAuthor() {
44409 const showCombobox = (0, import_data114.useSelect)((select6) => {
44410 const authors = select6(import_core_data77.store).getUsers(AUTHORS_QUERY);
44411 return authors?.length >= minimumUsersForCombobox;
44412 }, []);
44413 if (showCombobox) {
44414 return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(PostAuthorCombobox, {});
44415 }
44416 return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(PostAuthorSelect, {});
44417 }
44418 var post_author_default = PostAuthor;
44419
44420 // packages/editor/build-module/components/post-author/check.mjs
44421 var import_data115 = __toESM(require_data(), 1);
44422 var import_jsx_runtime254 = __toESM(require_jsx_runtime(), 1);
44423 function PostAuthorCheck({ children }) {
44424 const { hasAssignAuthorAction } = (0, import_data115.useSelect)((select6) => {
44425 const post2 = select6(store).getCurrentPost();
44426 const canAssignAuthor = post2?._links?.["wp:action-assign-author"] ? true : false;
44427 return {
44428 hasAssignAuthorAction: canAssignAuthor
44429 };
44430 }, []);
44431 if (!hasAssignAuthorAction) {
44432 return null;
44433 }
44434 return /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(post_type_support_check_default, { supportKeys: "author", children });
44435 }
44436
44437 // packages/editor/build-module/components/post-author/panel.mjs
44438 var import_i18n151 = __toESM(require_i18n(), 1);
44439 var import_components132 = __toESM(require_components(), 1);
44440 var import_element112 = __toESM(require_element(), 1);
44441 var import_html_entities18 = __toESM(require_html_entities(), 1);
44442 var import_block_editor49 = __toESM(require_block_editor(), 1);
44443 var import_data116 = __toESM(require_data(), 1);
44444 var import_core_data78 = __toESM(require_core_data(), 1);
44445 var import_jsx_runtime255 = __toESM(require_jsx_runtime(), 1);
44446 function PostAuthorToggle({ isOpen, onClick }) {
44447 const { postAuthor } = (0, import_data116.useSelect)((select6) => {
44448 const id = select6(store).getEditedPostAttribute("author");
44449 return {
44450 postAuthor: select6(import_core_data78.store).getUser(id, BASE_QUERY)
44451 };
44452 }, []);
44453 const authorName = (0, import_html_entities18.decodeEntities)(postAuthor?.name) || (0, import_i18n151.__)("(No author)");
44454 return /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
44455 import_components132.Button,
44456 {
44457 size: "compact",
44458 className: "editor-post-author__panel-toggle",
44459 variant: "tertiary",
44460 "aria-expanded": isOpen,
44461 "aria-label": (
44462 // translators: %s: Author name.
44463 (0, import_i18n151.sprintf)((0, import_i18n151.__)("Change author: %s"), authorName)
44464 ),
44465 onClick,
44466 children: authorName
44467 }
44468 );
44469 }
44470 function PostAuthor2() {
44471 const [popoverAnchor, setPopoverAnchor] = (0, import_element112.useState)(null);
44472 const popoverProps = (0, import_element112.useMemo)(
44473 () => ({
44474 // Anchor the popover to the middle of the entire row so that it doesn't
44475 // move around when the label changes.
44476 anchor: popoverAnchor,
44477 placement: "left-start",
44478 offset: 36,
44479 shift: true
44480 }),
44481 [popoverAnchor]
44482 );
44483 return /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(PostAuthorCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(post_panel_row_default, { label: (0, import_i18n151.__)("Author"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
44484 import_components132.Dropdown,
44485 {
44486 popoverProps,
44487 contentClassName: "editor-post-author__panel-dialog",
44488 focusOnMount: true,
44489 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
44490 PostAuthorToggle,
44491 {
44492 isOpen,
44493 onClick: onToggle
44494 }
44495 ),
44496 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)("div", { className: "editor-post-author", children: [
44497 /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
44498 import_block_editor49.__experimentalInspectorPopoverHeader,
44499 {
44500 title: (0, import_i18n151.__)("Author"),
44501 onClose
44502 }
44503 ),
44504 /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(post_author_default, { onClose })
44505 ] })
44506 }
44507 ) }) });
44508 }
44509 var panel_default = PostAuthor2;
44510
44511 // packages/editor/build-module/components/post-comments/index.mjs
44512 var import_i18n152 = __toESM(require_i18n(), 1);
44513 var import_components133 = __toESM(require_components(), 1);
44514 var import_data117 = __toESM(require_data(), 1);
44515 var import_jsx_runtime256 = __toESM(require_jsx_runtime(), 1);
44516 var COMMENT_OPTIONS = [
44517 {
44518 label: (0, import_i18n152._x)("Open", 'Adjective: e.g. "Comments are open"'),
44519 value: "open",
44520 description: (0, import_i18n152.__)("Visitors can add new comments and replies.")
44521 },
44522 {
44523 label: (0, import_i18n152.__)("Closed"),
44524 value: "closed",
44525 description: [
44526 (0, import_i18n152.__)("Visitors cannot add new comments or replies."),
44527 (0, import_i18n152.__)("Existing comments remain visible.")
44528 ].join(" ")
44529 }
44530 ];
44531 function PostComments() {
44532 const commentStatus = (0, import_data117.useSelect)(
44533 (select6) => select6(store).getEditedPostAttribute("comment_status") ?? "open",
44534 []
44535 );
44536 const { editPost: editPost2 } = (0, import_data117.useDispatch)(store);
44537 const handleStatus = (newCommentStatus) => editPost2({
44538 comment_status: newCommentStatus
44539 });
44540 return /* @__PURE__ */ (0, import_jsx_runtime256.jsx)("form", { children: /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(import_components133.__experimentalVStack, { spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(
44541 import_components133.RadioControl,
44542 {
44543 className: "editor-change-status__options",
44544 hideLabelFromVision: true,
44545 label: (0, import_i18n152.__)("Comment status"),
44546 options: COMMENT_OPTIONS,
44547 onChange: handleStatus,
44548 selected: commentStatus
44549 }
44550 ) }) });
44551 }
44552 var post_comments_default = PostComments;
44553
44554 // packages/editor/build-module/components/post-discussion/panel.mjs
44555 var import_i18n154 = __toESM(require_i18n(), 1);
44556 var import_components135 = __toESM(require_components(), 1);
44557 var import_data119 = __toESM(require_data(), 1);
44558 var import_element113 = __toESM(require_element(), 1);
44559 var import_block_editor50 = __toESM(require_block_editor(), 1);
44560 var import_core_data79 = __toESM(require_core_data(), 1);
44561
44562 // packages/editor/build-module/components/post-pingbacks/index.mjs
44563 var import_i18n153 = __toESM(require_i18n(), 1);
44564 var import_components134 = __toESM(require_components(), 1);
44565 var import_data118 = __toESM(require_data(), 1);
44566 var import_jsx_runtime257 = __toESM(require_jsx_runtime(), 1);
44567 function PostPingbacks() {
44568 const pingStatus = (0, import_data118.useSelect)(
44569 (select6) => select6(store).getEditedPostAttribute("ping_status") ?? "open",
44570 []
44571 );
44572 const { editPost: editPost2 } = (0, import_data118.useDispatch)(store);
44573 const onTogglePingback = () => editPost2({
44574 ping_status: pingStatus === "open" ? "closed" : "open"
44575 });
44576 return /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(
44577 import_components134.CheckboxControl,
44578 {
44579 label: (0, import_i18n153.__)("Enable pingbacks & trackbacks"),
44580 checked: pingStatus === "open",
44581 onChange: onTogglePingback,
44582 help: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(
44583 import_components134.ExternalLink,
44584 {
44585 href: (0, import_i18n153.__)(
44586 "https://wordpress.org/documentation/article/trackbacks-and-pingbacks/"
44587 ),
44588 children: (0, import_i18n153.__)("Learn more about pingbacks & trackbacks")
44589 }
44590 )
44591 }
44592 );
44593 }
44594 var post_pingbacks_default = PostPingbacks;
44595
44596 // packages/editor/build-module/components/post-discussion/panel.mjs
44597 var import_jsx_runtime258 = __toESM(require_jsx_runtime(), 1);
44598 var PANEL_NAME2 = "discussion-panel";
44599 function ModalContents({ onClose }) {
44600 return /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)("div", { className: "editor-post-discussion", children: [
44601 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
44602 import_block_editor50.__experimentalInspectorPopoverHeader,
44603 {
44604 title: (0, import_i18n154.__)("Discussion"),
44605 onClose
44606 }
44607 ),
44608 /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)(import_components135.__experimentalVStack, { spacing: 4, children: [
44609 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(post_type_support_check_default, { supportKeys: "comments", children: /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(post_comments_default, {}) }),
44610 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(post_type_support_check_default, { supportKeys: "trackbacks", children: /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(post_pingbacks_default, {}) })
44611 ] })
44612 ] });
44613 }
44614 function PostDiscussionToggle({ isOpen, onClick }) {
44615 const {
44616 commentStatus,
44617 pingStatus,
44618 commentsSupported,
44619 trackbacksSupported
44620 } = (0, import_data119.useSelect)((select6) => {
44621 const { getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
44622 const { getPostType } = select6(import_core_data79.store);
44623 const postType2 = getPostType(getEditedPostAttribute2("type"));
44624 return {
44625 commentStatus: getEditedPostAttribute2("comment_status") ?? "open",
44626 pingStatus: getEditedPostAttribute2("ping_status") ?? "open",
44627 commentsSupported: !!postType2.supports.comments,
44628 trackbacksSupported: !!postType2.supports.trackbacks
44629 };
44630 }, []);
44631 let label;
44632 if (commentStatus === "open") {
44633 if (pingStatus === "open") {
44634 label = (0, import_i18n154._x)("Open", 'Adjective: e.g. "Comments are open"');
44635 } else {
44636 label = trackbacksSupported ? (0, import_i18n154.__)("Comments only") : (0, import_i18n154._x)("Open", 'Adjective: e.g. "Comments are open"');
44637 }
44638 } else if (pingStatus === "open") {
44639 label = commentsSupported ? (0, import_i18n154.__)("Pings only") : (0, import_i18n154.__)("Pings enabled");
44640 } else {
44641 label = (0, import_i18n154.__)("Closed");
44642 }
44643 return /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
44644 import_components135.Button,
44645 {
44646 size: "compact",
44647 className: "editor-post-discussion__panel-toggle",
44648 variant: "tertiary",
44649 "aria-label": (0, import_i18n154.__)("Change discussion options"),
44650 "aria-expanded": isOpen,
44651 onClick,
44652 children: label
44653 }
44654 );
44655 }
44656 function PostDiscussionPanel() {
44657 const { isEnabled } = (0, import_data119.useSelect)((select6) => {
44658 const { isEditorPanelEnabled: isEditorPanelEnabled2 } = select6(store);
44659 return {
44660 isEnabled: isEditorPanelEnabled2(PANEL_NAME2)
44661 };
44662 }, []);
44663 const [popoverAnchor, setPopoverAnchor] = (0, import_element113.useState)(null);
44664 const popoverProps = (0, import_element113.useMemo)(
44665 () => ({
44666 // Anchor the popover to the middle of the entire row so that it doesn't
44667 // move around when the label changes.
44668 anchor: popoverAnchor,
44669 placement: "left-start",
44670 offset: 36,
44671 shift: true
44672 }),
44673 [popoverAnchor]
44674 );
44675 if (!isEnabled) {
44676 return null;
44677 }
44678 return /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(post_type_support_check_default, { supportKeys: ["comments", "trackbacks"], children: /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(post_panel_row_default, { label: (0, import_i18n154.__)("Discussion"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
44679 import_components135.Dropdown,
44680 {
44681 popoverProps,
44682 className: "editor-post-discussion__panel-dropdown",
44683 contentClassName: "editor-post-discussion__panel-dialog",
44684 focusOnMount: true,
44685 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
44686 PostDiscussionToggle,
44687 {
44688 isOpen,
44689 onClick: onToggle
44690 }
44691 ),
44692 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(ModalContents, { onClose })
44693 }
44694 ) }) });
44695 }
44696
44697 // packages/editor/build-module/components/post-excerpt/index.mjs
44698 var import_i18n155 = __toESM(require_i18n(), 1);
44699 var import_components136 = __toESM(require_components(), 1);
44700 var import_data120 = __toESM(require_data(), 1);
44701 var import_element114 = __toESM(require_element(), 1);
44702 var import_html_entities19 = __toESM(require_html_entities(), 1);
44703 var import_jsx_runtime259 = __toESM(require_jsx_runtime(), 1);
44704 function PostExcerpt({
44705 hideLabelFromVision = false,
44706 updateOnBlur = false
44707 }) {
44708 const { excerpt, shouldUseDescriptionLabel, usedAttribute } = (0, import_data120.useSelect)(
44709 (select6) => {
44710 const { getCurrentPostType: getCurrentPostType2, getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
44711 const postType2 = getCurrentPostType2();
44712 const _usedAttribute = [
44713 "wp_template",
44714 "wp_template_part"
44715 ].includes(postType2) ? "description" : "excerpt";
44716 return {
44717 excerpt: getEditedPostAttribute2(_usedAttribute),
44718 // There are special cases where we want to label the excerpt as a description.
44719 shouldUseDescriptionLabel: [
44720 "wp_template",
44721 "wp_template_part",
44722 "wp_block"
44723 ].includes(postType2),
44724 usedAttribute: _usedAttribute
44725 };
44726 },
44727 []
44728 );
44729 const { editPost: editPost2 } = (0, import_data120.useDispatch)(store);
44730 const [localExcerpt, setLocalExcerpt] = (0, import_element114.useState)(
44731 (0, import_html_entities19.decodeEntities)(excerpt)
44732 );
44733 const updatePost2 = (value) => {
44734 editPost2({ [usedAttribute]: value });
44735 };
44736 const label = shouldUseDescriptionLabel ? (0, import_i18n155.__)("Write a description (optional)") : (0, import_i18n155.__)("Write an excerpt (optional)");
44737 return /* @__PURE__ */ (0, import_jsx_runtime259.jsx)("div", { className: "editor-post-excerpt", children: /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
44738 import_components136.TextareaControl,
44739 {
44740 label,
44741 hideLabelFromVision,
44742 className: "editor-post-excerpt__textarea",
44743 onChange: updateOnBlur ? setLocalExcerpt : updatePost2,
44744 onBlur: updateOnBlur ? () => updatePost2(localExcerpt) : void 0,
44745 value: updateOnBlur ? localExcerpt : excerpt,
44746 help: !shouldUseDescriptionLabel ? /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
44747 import_components136.ExternalLink,
44748 {
44749 href: (0, import_i18n155.__)(
44750 "https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt"
44751 ),
44752 children: (0, import_i18n155.__)("Learn more about manual excerpts")
44753 }
44754 ) : (0, import_i18n155.__)("Write a description")
44755 }
44756 ) });
44757 }
44758
44759 // packages/editor/build-module/components/post-excerpt/check.mjs
44760 var import_jsx_runtime260 = __toESM(require_jsx_runtime(), 1);
44761 function PostExcerptCheck({ children }) {
44762 return /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(post_type_support_check_default, { supportKeys: "excerpt", children });
44763 }
44764 var check_default3 = PostExcerptCheck;
44765
44766 // packages/editor/build-module/components/post-excerpt/panel.mjs
44767 var import_i18n156 = __toESM(require_i18n(), 1);
44768 var import_components138 = __toESM(require_components(), 1);
44769 var import_data121 = __toESM(require_data(), 1);
44770 var import_element115 = __toESM(require_element(), 1);
44771 var import_block_editor51 = __toESM(require_block_editor(), 1);
44772 var import_core_data80 = __toESM(require_core_data(), 1);
44773 var import_html_entities20 = __toESM(require_html_entities(), 1);
44774
44775 // packages/editor/build-module/components/post-excerpt/plugin.mjs
44776 var import_components137 = __toESM(require_components(), 1);
44777 var import_jsx_runtime261 = __toESM(require_jsx_runtime(), 1);
44778 var { Fill: Fill9, Slot: Slot9 } = (0, import_components137.createSlotFill)("PluginPostExcerpt");
44779 var PluginPostExcerpt = ({ children, className }) => {
44780 return /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(Fill9, { children: /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(import_components137.PanelRow, { className, children }) });
44781 };
44782 PluginPostExcerpt.Slot = Slot9;
44783 var plugin_default = PluginPostExcerpt;
44784
44785 // packages/editor/build-module/components/post-excerpt/panel.mjs
44786 var import_jsx_runtime262 = __toESM(require_jsx_runtime(), 1);
44787 var PANEL_NAME3 = "post-excerpt";
44788 function ExcerptPanel() {
44789 const { isOpened, isEnabled, postType: postType2 } = (0, import_data121.useSelect)((select6) => {
44790 const {
44791 isEditorPanelOpened: isEditorPanelOpened2,
44792 isEditorPanelEnabled: isEditorPanelEnabled2,
44793 getCurrentPostType: getCurrentPostType2
44794 } = select6(store);
44795 return {
44796 isOpened: isEditorPanelOpened2(PANEL_NAME3),
44797 isEnabled: isEditorPanelEnabled2(PANEL_NAME3),
44798 postType: getCurrentPostType2()
44799 };
44800 }, []);
44801 const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data121.useDispatch)(store);
44802 const toggleExcerptPanel = () => toggleEditorPanelOpened2(PANEL_NAME3);
44803 if (!isEnabled) {
44804 return null;
44805 }
44806 const shouldUseDescriptionLabel = [
44807 "wp_template",
44808 "wp_template_part",
44809 "wp_block"
44810 ].includes(postType2);
44811 return /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
44812 import_components138.PanelBody,
44813 {
44814 title: shouldUseDescriptionLabel ? (0, import_i18n156.__)("Description") : (0, import_i18n156.__)("Excerpt"),
44815 opened: isOpened,
44816 onToggle: toggleExcerptPanel,
44817 children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(plugin_default.Slot, { children: (fills) => /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_jsx_runtime262.Fragment, { children: [
44818 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(PostExcerpt, {}),
44819 fills
44820 ] }) })
44821 }
44822 );
44823 }
44824 function PostExcerptPanel() {
44825 return /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(check_default3, { children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(ExcerptPanel, {}) });
44826 }
44827 function PrivatePostExcerptPanel() {
44828 return /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(check_default3, { children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(PrivateExcerpt, {}) });
44829 }
44830 function PrivateExcerpt() {
44831 const { shouldRender, excerpt, shouldBeUsedAsDescription, allowEditing } = (0, import_data121.useSelect)((select6) => {
44832 const {
44833 getCurrentPostType: getCurrentPostType2,
44834 getCurrentPostId: getCurrentPostId2,
44835 getEditedPostAttribute: getEditedPostAttribute2,
44836 isEditorPanelEnabled: isEditorPanelEnabled2
44837 } = select6(store);
44838 const postType2 = getCurrentPostType2();
44839 const isTemplateOrTemplatePart2 = [
44840 "wp_template",
44841 "wp_template_part"
44842 ].includes(postType2);
44843 const isPattern = postType2 === "wp_block";
44844 const _shouldBeUsedAsDescription = isTemplateOrTemplatePart2 || isPattern;
44845 const _usedAttribute = isTemplateOrTemplatePart2 ? "description" : "excerpt";
44846 const _excerpt = getEditedPostAttribute2(_usedAttribute);
44847 const template2 = isTemplateOrTemplatePart2 && select6(import_core_data80.store).getEntityRecord(
44848 "postType",
44849 postType2,
44850 getCurrentPostId2()
44851 );
44852 const fallback = !_excerpt && isTemplateOrTemplatePart2 ? getTemplateInfo({
44853 template: template2,
44854 templateTypes: select6(import_core_data80.store).getCurrentTheme()?.default_template_types
44855 })?.description : void 0;
44856 const _shouldRender = isEditorPanelEnabled2(PANEL_NAME3) || _shouldBeUsedAsDescription;
44857 return {
44858 excerpt: _excerpt ?? fallback,
44859 shouldRender: _shouldRender,
44860 shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
44861 // If we should render, allow editing for all post types that are not used as description.
44862 // For the rest allow editing only for user generated entities.
44863 allowEditing: _shouldRender && (!_shouldBeUsedAsDescription || isPattern || template2 && template2.source === TEMPLATE_ORIGINS.custom && !template2.has_theme_file && template2.is_custom)
44864 };
44865 }, []);
44866 const [popoverAnchor, setPopoverAnchor] = (0, import_element115.useState)(null);
44867 const label = shouldBeUsedAsDescription ? (0, import_i18n156.__)("Description") : (0, import_i18n156.__)("Excerpt");
44868 const popoverProps = (0, import_element115.useMemo)(
44869 () => ({
44870 // Anchor the popover to the middle of the entire row so that it doesn't
44871 // move around when the label changes.
44872 anchor: popoverAnchor,
44873 "aria-label": label,
44874 headerTitle: label,
44875 placement: "left-start",
44876 offset: 36,
44877 shift: true
44878 }),
44879 [popoverAnchor, label]
44880 );
44881 if (!shouldRender) {
44882 return false;
44883 }
44884 const excerptText = !!excerpt && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components138.__experimentalText, { align: "left", numberOfLines: 4, truncate: allowEditing, children: (0, import_html_entities20.decodeEntities)(excerpt) });
44885 if (!allowEditing) {
44886 return excerptText;
44887 }
44888 const excerptPlaceholder = shouldBeUsedAsDescription ? (0, import_i18n156.__)("Add a description\u2026") : (0, import_i18n156.__)("Add an excerpt\u2026");
44889 const triggerEditLabel = shouldBeUsedAsDescription ? (0, import_i18n156.__)("Edit description") : (0, import_i18n156.__)("Edit excerpt");
44890 return /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_components138.__experimentalVStack, { children: [
44891 excerptText,
44892 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
44893 import_components138.Dropdown,
44894 {
44895 className: "editor-post-excerpt__dropdown",
44896 contentClassName: "editor-post-excerpt__dropdown__content",
44897 popoverProps,
44898 focusOnMount: true,
44899 ref: setPopoverAnchor,
44900 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
44901 import_components138.Button,
44902 {
44903 __next40pxDefaultSize: true,
44904 onClick: onToggle,
44905 variant: "link",
44906 children: excerptText ? triggerEditLabel : excerptPlaceholder
44907 }
44908 ),
44909 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_jsx_runtime262.Fragment, { children: [
44910 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
44911 import_block_editor51.__experimentalInspectorPopoverHeader,
44912 {
44913 title: label,
44914 onClose
44915 }
44916 ),
44917 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components138.__experimentalVStack, { spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(plugin_default.Slot, { children: (fills) => /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_jsx_runtime262.Fragment, { children: [
44918 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
44919 PostExcerpt,
44920 {
44921 hideLabelFromVision: true,
44922 updateOnBlur: true
44923 }
44924 ),
44925 fills
44926 ] }) }) })
44927 ] })
44928 }
44929 )
44930 ] });
44931 }
44932
44933 // packages/editor/build-module/components/post-featured-image/index.mjs
44934 var import_i18n157 = __toESM(require_i18n(), 1);
44935 var import_hooks46 = __toESM(require_hooks(), 1);
44936 var import_components139 = __toESM(require_components(), 1);
44937 var import_blob3 = __toESM(require_blob(), 1);
44938 var import_element116 = __toESM(require_element(), 1);
44939 var import_compose26 = __toESM(require_compose(), 1);
44940 var import_data123 = __toESM(require_data(), 1);
44941 var import_block_editor52 = __toESM(require_block_editor(), 1);
44942 var import_core_data82 = __toESM(require_core_data(), 1);
44943
44944 // packages/editor/build-module/components/theme-support-check/index.mjs
44945 var import_data122 = __toESM(require_data(), 1);
44946 var import_core_data81 = __toESM(require_core_data(), 1);
44947 function ThemeSupportCheck({ children, supportKeys }) {
44948 const { postType: postType2, themeSupports } = (0, import_data122.useSelect)((select6) => {
44949 return {
44950 postType: select6(store).getEditedPostAttribute("type"),
44951 themeSupports: select6(import_core_data81.store).getThemeSupports()
44952 };
44953 }, []);
44954 const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some((key) => {
44955 const supported = themeSupports?.[key] ?? false;
44956 if ("post-thumbnails" === key && Array.isArray(supported)) {
44957 return supported.includes(postType2);
44958 }
44959 return supported;
44960 });
44961 if (!isSupported) {
44962 return null;
44963 }
44964 return children;
44965 }
44966
44967 // packages/editor/build-module/components/post-featured-image/check.mjs
44968 var import_jsx_runtime263 = __toESM(require_jsx_runtime(), 1);
44969 function PostFeaturedImageCheck({ children }) {
44970 return /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(ThemeSupportCheck, { supportKeys: "post-thumbnails", children: /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(post_type_support_check_default, { supportKeys: "thumbnail", children }) });
44971 }
44972 var check_default4 = PostFeaturedImageCheck;
44973
44974 // packages/editor/build-module/components/post-featured-image/index.mjs
44975 var import_jsx_runtime264 = __toESM(require_jsx_runtime(), 1);
44976 var ALLOWED_MEDIA_TYPES = ["image"];
44977 var DEFAULT_FEATURE_IMAGE_LABEL = (0, import_i18n157.__)("Featured image");
44978 var DEFAULT_SET_FEATURE_IMAGE_LABEL = (0, import_i18n157.__)("Add a featured image");
44979 var instructions = /* @__PURE__ */ (0, import_jsx_runtime264.jsx)("p", { children: (0, import_i18n157.__)(
44980 "To edit the featured image, you need permission to upload media."
44981 ) });
44982 function getMediaDetails(media, postId2) {
44983 if (!media) {
44984 return {};
44985 }
44986 const defaultSize = (0, import_hooks46.applyFilters)(
44987 "editor.PostFeaturedImage.imageSize",
44988 "large",
44989 media.id,
44990 postId2
44991 );
44992 if (defaultSize in (media?.media_details?.sizes ?? {})) {
44993 return {
44994 mediaWidth: media.media_details.sizes[defaultSize].width,
44995 mediaHeight: media.media_details.sizes[defaultSize].height,
44996 mediaSourceUrl: media.media_details.sizes[defaultSize].source_url
44997 };
44998 }
44999 const fallbackSize = (0, import_hooks46.applyFilters)(
45000 "editor.PostFeaturedImage.imageSize",
45001 "thumbnail",
45002 media.id,
45003 postId2
45004 );
45005 if (fallbackSize in (media?.media_details?.sizes ?? {})) {
45006 return {
45007 mediaWidth: media.media_details.sizes[fallbackSize].width,
45008 mediaHeight: media.media_details.sizes[fallbackSize].height,
45009 mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url
45010 };
45011 }
45012 return {
45013 mediaWidth: media.media_details.width,
45014 mediaHeight: media.media_details.height,
45015 mediaSourceUrl: media.source_url
45016 };
45017 }
45018 function PostFeaturedImage({
45019 currentPostId,
45020 featuredImageId,
45021 onUpdateImage,
45022 onRemoveImage,
45023 media,
45024 postType: postType2,
45025 noticeUI,
45026 noticeOperations,
45027 isRequestingFeaturedImageMedia
45028 }) {
45029 const returnsFocusRef = (0, import_element116.useRef)(false);
45030 const [isLoading, setIsLoading] = (0, import_element116.useState)(false);
45031 const { getSettings: getSettings10 } = (0, import_data123.useSelect)(import_block_editor52.store);
45032 const { mediaSourceUrl } = getMediaDetails(media, currentPostId);
45033 function onDropFiles(filesList) {
45034 getSettings10().mediaUpload({
45035 allowedTypes: ALLOWED_MEDIA_TYPES,
45036 filesList,
45037 onFileChange([image]) {
45038 if ((0, import_blob3.isBlobURL)(image?.url)) {
45039 setIsLoading(true);
45040 return;
45041 }
45042 if (image) {
45043 onUpdateImage(image);
45044 }
45045 setIsLoading(false);
45046 },
45047 onError(message2) {
45048 noticeOperations.removeAllNotices();
45049 noticeOperations.createErrorNotice(message2);
45050 },
45051 multiple: false
45052 });
45053 }
45054 function getImageDescription(imageMedia) {
45055 if (imageMedia.alt_text) {
45056 return (0, import_i18n157.sprintf)(
45057 // Translators: %s: The selected image alt text.
45058 (0, import_i18n157.__)("Current image: %s"),
45059 imageMedia.alt_text
45060 );
45061 }
45062 return (0, import_i18n157.sprintf)(
45063 // Translators: %s: The selected image filename.
45064 (0, import_i18n157.__)(
45065 "The current image has no alternative text. The file name is: %s"
45066 ),
45067 imageMedia.media_details.sizes?.full?.file || imageMedia.slug
45068 );
45069 }
45070 function returnFocus(node) {
45071 if (returnsFocusRef.current && node) {
45072 node.focus();
45073 returnsFocusRef.current = false;
45074 }
45075 }
45076 const isMissingMedia = !isRequestingFeaturedImageMedia && !!featuredImageId && !media;
45077 return /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)(check_default4, { children: [
45078 noticeUI,
45079 /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)("div", { className: "editor-post-featured-image", children: [
45080 media && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
45081 "div",
45082 {
45083 id: `editor-post-featured-image-${featuredImageId}-describedby`,
45084 className: "hidden",
45085 children: getImageDescription(media)
45086 }
45087 ),
45088 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_block_editor52.MediaUploadCheck, { fallback: instructions, children: /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
45089 import_block_editor52.MediaUpload,
45090 {
45091 title: postType2?.labels?.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
45092 onSelect: onUpdateImage,
45093 unstableFeaturedImageFlow: true,
45094 allowedTypes: ALLOWED_MEDIA_TYPES,
45095 modalClass: "editor-post-featured-image__media-modal",
45096 render: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)("div", { className: "editor-post-featured-image__container", children: [
45097 isMissingMedia ? /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
45098 import_components139.Notice,
45099 {
45100 status: "warning",
45101 isDismissible: false,
45102 children: (0, import_i18n157.__)(
45103 "Could not retrieve the featured image data."
45104 )
45105 }
45106 ) : /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)(
45107 import_components139.Button,
45108 {
45109 __next40pxDefaultSize: true,
45110 ref: returnFocus,
45111 className: !featuredImageId ? "editor-post-featured-image__toggle" : "editor-post-featured-image__preview",
45112 onClick: open,
45113 "aria-label": !featuredImageId ? null : (0, import_i18n157.__)(
45114 "Edit or replace the featured image"
45115 ),
45116 "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-${featuredImageId}-describedby`,
45117 "aria-haspopup": "dialog",
45118 disabled: isLoading,
45119 accessibleWhenDisabled: true,
45120 children: [
45121 !!featuredImageId && media && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
45122 "img",
45123 {
45124 className: "editor-post-featured-image__preview-image",
45125 src: mediaSourceUrl,
45126 alt: getImageDescription(
45127 media
45128 )
45129 }
45130 ),
45131 (isLoading || isRequestingFeaturedImageMedia) && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_components139.Spinner, {}),
45132 !featuredImageId && !isLoading && (postType2?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)
45133 ]
45134 }
45135 ),
45136 !!featuredImageId && /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)(
45137 import_components139.__experimentalHStack,
45138 {
45139 className: clsx_default(
45140 "editor-post-featured-image__actions",
45141 {
45142 "editor-post-featured-image__actions-missing-image": isMissingMedia,
45143 "editor-post-featured-image__actions-is-requesting-image": isRequestingFeaturedImageMedia
45144 }
45145 ),
45146 children: [
45147 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
45148 import_components139.Button,
45149 {
45150 __next40pxDefaultSize: true,
45151 className: "editor-post-featured-image__action",
45152 onClick: open,
45153 "aria-haspopup": "dialog",
45154 variant: isMissingMedia ? "secondary" : void 0,
45155 children: (0, import_i18n157.__)("Replace")
45156 }
45157 ),
45158 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
45159 import_components139.Button,
45160 {
45161 __next40pxDefaultSize: true,
45162 className: "editor-post-featured-image__action",
45163 onClick: () => {
45164 onRemoveImage();
45165 returnsFocusRef.current = true;
45166 },
45167 variant: isMissingMedia ? "secondary" : void 0,
45168 isDestructive: isMissingMedia,
45169 children: (0, import_i18n157.__)("Remove")
45170 }
45171 )
45172 ]
45173 }
45174 ),
45175 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_components139.DropZone, { onFilesDrop: onDropFiles })
45176 ] }),
45177 value: featuredImageId
45178 }
45179 ) })
45180 ] })
45181 ] });
45182 }
45183 var applyWithSelect = (0, import_data123.withSelect)((select6) => {
45184 const { getEntityRecord, getPostType, hasFinishedResolution } = select6(import_core_data82.store);
45185 const { getCurrentPostId: getCurrentPostId2, getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
45186 const featuredImageId = getEditedPostAttribute2("featured_media");
45187 return {
45188 media: featuredImageId ? getEntityRecord("postType", "attachment", featuredImageId, {
45189 context: "view"
45190 }) : null,
45191 currentPostId: getCurrentPostId2(),
45192 postType: getPostType(getEditedPostAttribute2("type")),
45193 featuredImageId,
45194 isRequestingFeaturedImageMedia: !!featuredImageId && !hasFinishedResolution("getEntityRecord", [
45195 "postType",
45196 "attachment",
45197 featuredImageId,
45198 { context: "view" }
45199 ])
45200 };
45201 });
45202 var applyWithDispatch = (0, import_data123.withDispatch)(
45203 (dispatch7, { noticeOperations }, { select: select6 }) => {
45204 const { editPost: editPost2 } = dispatch7(store);
45205 return {
45206 onUpdateImage(image) {
45207 editPost2({ featured_media: image.id });
45208 },
45209 onDropImage(filesList) {
45210 select6(import_block_editor52.store).getSettings().mediaUpload({
45211 allowedTypes: ["image"],
45212 filesList,
45213 onFileChange([image]) {
45214 editPost2({ featured_media: image.id });
45215 },
45216 onError(message2) {
45217 noticeOperations.removeAllNotices();
45218 noticeOperations.createErrorNotice(message2);
45219 },
45220 multiple: false
45221 });
45222 },
45223 onRemoveImage() {
45224 editPost2({ featured_media: 0 });
45225 }
45226 };
45227 }
45228 );
45229 var post_featured_image_default = (0, import_compose26.compose)(
45230 import_components139.withNotices,
45231 applyWithSelect,
45232 applyWithDispatch,
45233 (0, import_components139.withFilters)("editor.PostFeaturedImage")
45234 )(PostFeaturedImage);
45235
45236 // packages/editor/build-module/components/post-featured-image/panel.mjs
45237 var import_i18n158 = __toESM(require_i18n(), 1);
45238 var import_components140 = __toESM(require_components(), 1);
45239 var import_data124 = __toESM(require_data(), 1);
45240 var import_core_data83 = __toESM(require_core_data(), 1);
45241 var import_jsx_runtime265 = __toESM(require_jsx_runtime(), 1);
45242 var PANEL_NAME4 = "featured-image";
45243 function PostFeaturedImagePanel({ withPanelBody = true }) {
45244 const { postType: postType2, isEnabled, isOpened } = (0, import_data124.useSelect)((select6) => {
45245 const {
45246 getEditedPostAttribute: getEditedPostAttribute2,
45247 isEditorPanelEnabled: isEditorPanelEnabled2,
45248 isEditorPanelOpened: isEditorPanelOpened2
45249 } = select6(store);
45250 const { getPostType } = select6(import_core_data83.store);
45251 return {
45252 postType: getPostType(getEditedPostAttribute2("type")),
45253 isEnabled: isEditorPanelEnabled2(PANEL_NAME4),
45254 isOpened: isEditorPanelOpened2(PANEL_NAME4)
45255 };
45256 }, []);
45257 const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data124.useDispatch)(store);
45258 if (!isEnabled) {
45259 return null;
45260 }
45261 if (!withPanelBody) {
45262 return /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(check_default4, { children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(post_featured_image_default, {}) });
45263 }
45264 return /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(check_default4, { children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
45265 import_components140.PanelBody,
45266 {
45267 title: postType2?.labels?.featured_image ?? (0, import_i18n158.__)("Featured image"),
45268 opened: isOpened,
45269 onToggle: () => toggleEditorPanelOpened2(PANEL_NAME4),
45270 children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(post_featured_image_default, {})
45271 }
45272 ) });
45273 }
45274
45275 // packages/editor/build-module/components/post-format/index.mjs
45276 var import_i18n159 = __toESM(require_i18n(), 1);
45277 var import_components141 = __toESM(require_components(), 1);
45278 var import_data126 = __toESM(require_data(), 1);
45279 var import_compose27 = __toESM(require_compose(), 1);
45280 var import_core_data84 = __toESM(require_core_data(), 1);
45281
45282 // packages/editor/build-module/components/post-format/check.mjs
45283 var import_data125 = __toESM(require_data(), 1);
45284 var import_jsx_runtime266 = __toESM(require_jsx_runtime(), 1);
45285 function PostFormatCheck({ children }) {
45286 const disablePostFormats = (0, import_data125.useSelect)(
45287 (select6) => select6(store).getEditorSettings().disablePostFormats,
45288 []
45289 );
45290 if (disablePostFormats) {
45291 return null;
45292 }
45293 return /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(post_type_support_check_default, { supportKeys: "post-formats", children });
45294 }
45295
45296 // packages/editor/build-module/components/post-format/index.mjs
45297 var import_jsx_runtime267 = __toESM(require_jsx_runtime(), 1);
45298 var POST_FORMATS = [
45299 { id: "aside", caption: (0, import_i18n159.__)("Aside") },
45300 { id: "audio", caption: (0, import_i18n159.__)("Audio") },
45301 { id: "chat", caption: (0, import_i18n159.__)("Chat") },
45302 { id: "gallery", caption: (0, import_i18n159.__)("Gallery") },
45303 { id: "image", caption: (0, import_i18n159.__)("Image") },
45304 { id: "link", caption: (0, import_i18n159.__)("Link") },
45305 { id: "quote", caption: (0, import_i18n159.__)("Quote") },
45306 { id: "standard", caption: (0, import_i18n159.__)("Standard") },
45307 { id: "status", caption: (0, import_i18n159.__)("Status") },
45308 { id: "video", caption: (0, import_i18n159.__)("Video") }
45309 ].sort((a3, b3) => {
45310 const normalizedA = a3.caption.toUpperCase();
45311 const normalizedB = b3.caption.toUpperCase();
45312 if (normalizedA < normalizedB) {
45313 return -1;
45314 }
45315 if (normalizedA > normalizedB) {
45316 return 1;
45317 }
45318 return 0;
45319 });
45320 function PostFormat() {
45321 const instanceId = (0, import_compose27.useInstanceId)(PostFormat);
45322 const postFormatSelectorId = `post-format-selector-${instanceId}`;
45323 const { postFormat, suggestedFormat, supportedFormats } = (0, import_data126.useSelect)(
45324 (select6) => {
45325 const { getEditedPostAttribute: getEditedPostAttribute2, getSuggestedPostFormat: getSuggestedPostFormat2 } = select6(store);
45326 const _postFormat = getEditedPostAttribute2("format");
45327 const themeSupports = select6(import_core_data84.store).getThemeSupports();
45328 return {
45329 postFormat: _postFormat ?? "standard",
45330 suggestedFormat: getSuggestedPostFormat2(),
45331 supportedFormats: themeSupports.formats
45332 };
45333 },
45334 []
45335 );
45336 const formats = POST_FORMATS.filter((format6) => {
45337 return supportedFormats?.includes(format6.id) || postFormat === format6.id;
45338 });
45339 const suggestion = formats.find(
45340 (format6) => format6.id === suggestedFormat
45341 );
45342 const { editPost: editPost2 } = (0, import_data126.useDispatch)(store);
45343 const onUpdatePostFormat = (format6) => editPost2({ format: format6 });
45344 return /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(PostFormatCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime267.jsxs)("div", { className: "editor-post-format", children: [
45345 /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(
45346 import_components141.RadioControl,
45347 {
45348 className: "editor-post-format__options",
45349 label: (0, import_i18n159.__)("Post Format"),
45350 selected: postFormat,
45351 onChange: (format6) => onUpdatePostFormat(format6),
45352 id: postFormatSelectorId,
45353 options: formats.map((format6) => ({
45354 label: format6.caption,
45355 value: format6.id
45356 })),
45357 hideLabelFromVision: true
45358 }
45359 ),
45360 suggestion && suggestion.id !== postFormat && /* @__PURE__ */ (0, import_jsx_runtime267.jsx)("p", { className: "editor-post-format__suggestion", children: /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(
45361 import_components141.Button,
45362 {
45363 __next40pxDefaultSize: true,
45364 variant: "link",
45365 onClick: () => onUpdatePostFormat(suggestion.id),
45366 children: (0, import_i18n159.sprintf)(
45367 /* translators: %s: post format */
45368 (0, import_i18n159.__)("Apply suggested format: %s"),
45369 suggestion.caption
45370 )
45371 }
45372 ) })
45373 ] }) });
45374 }
45375
45376 // packages/editor/build-module/components/post-last-revision/index.mjs
45377 var import_i18n160 = __toESM(require_i18n(), 1);
45378 var import_components142 = __toESM(require_components(), 1);
45379 var import_data128 = __toESM(require_data(), 1);
45380 var import_url13 = __toESM(require_url(), 1);
45381
45382 // packages/editor/build-module/components/post-last-revision/check.mjs
45383 var import_data127 = __toESM(require_data(), 1);
45384 var import_jsx_runtime268 = __toESM(require_jsx_runtime(), 1);
45385 function PostLastRevisionCheck({ children }) {
45386 const { lastRevisionId, revisionsCount } = (0, import_data127.useSelect)((select6) => {
45387 const { getCurrentPostLastRevisionId: getCurrentPostLastRevisionId2, getCurrentPostRevisionsCount: getCurrentPostRevisionsCount2 } = select6(store);
45388 return {
45389 lastRevisionId: getCurrentPostLastRevisionId2(),
45390 revisionsCount: getCurrentPostRevisionsCount2()
45391 };
45392 }, []);
45393 if (!lastRevisionId || revisionsCount < 2) {
45394 return null;
45395 }
45396 return /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(post_type_support_check_default, { supportKeys: "revisions", children });
45397 }
45398 var check_default5 = PostLastRevisionCheck;
45399
45400 // packages/editor/build-module/components/post-last-revision/index.mjs
45401 var import_jsx_runtime269 = __toESM(require_jsx_runtime(), 1);
45402 function usePostLastRevisionInfo() {
45403 return (0, import_data128.useSelect)((select6) => {
45404 const {
45405 getCurrentPostLastRevisionId: getCurrentPostLastRevisionId2,
45406 getCurrentPostRevisionsCount: getCurrentPostRevisionsCount2,
45407 getEditorSettings: getEditorSettings2
45408 } = select6(store);
45409 return {
45410 lastRevisionId: getCurrentPostLastRevisionId2(),
45411 revisionsCount: getCurrentPostRevisionsCount2(),
45412 disableVisualRevisions: !!getEditorSettings2().disableVisualRevisions
45413 };
45414 }, []);
45415 }
45416 function PostLastRevision() {
45417 const { lastRevisionId, revisionsCount, disableVisualRevisions } = usePostLastRevisionInfo();
45418 const { setCurrentRevisionId: setCurrentRevisionId2 } = unlock((0, import_data128.useDispatch)(store));
45419 const buttonProps = disableVisualRevisions ? {
45420 href: (0, import_url13.addQueryArgs)("revision.php", {
45421 revision: lastRevisionId
45422 })
45423 } : { onClick: () => setCurrentRevisionId2(lastRevisionId) };
45424 return /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(check_default5, { children: /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(
45425 import_components142.Button,
45426 {
45427 __next40pxDefaultSize: true,
45428 ...buttonProps,
45429 className: "editor-post-last-revision__title",
45430 icon: backup_default,
45431 iconPosition: "right",
45432 text: (0, import_i18n160.sprintf)(
45433 /* translators: %s: number of revisions. */
45434 (0, import_i18n160.__)("Revisions (%s)"),
45435 revisionsCount
45436 )
45437 }
45438 ) });
45439 }
45440 function PrivatePostLastRevision() {
45441 const { lastRevisionId, revisionsCount, disableVisualRevisions } = usePostLastRevisionInfo();
45442 const { setCurrentRevisionId: setCurrentRevisionId2 } = unlock((0, import_data128.useDispatch)(store));
45443 const buttonProps = disableVisualRevisions ? {
45444 href: (0, import_url13.addQueryArgs)("revision.php", {
45445 revision: lastRevisionId
45446 })
45447 } : { onClick: () => setCurrentRevisionId2(lastRevisionId) };
45448 return /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(check_default5, { children: /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(post_panel_row_default, { label: (0, import_i18n160.__)("Revisions"), children: /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(
45449 import_components142.Button,
45450 {
45451 ...buttonProps,
45452 className: "editor-private-post-last-revision__button",
45453 text: revisionsCount,
45454 "aria-label": (0, import_i18n160.sprintf)(
45455 /* translators: %s: number of revisions. */
45456 (0, import_i18n160.__)("Open revisions screen: %s revisions"),
45457 revisionsCount
45458 ),
45459 variant: "tertiary",
45460 size: "compact"
45461 }
45462 ) }) });
45463 }
45464 var post_last_revision_default = PostLastRevision;
45465
45466 // packages/editor/build-module/components/post-last-revision/panel.mjs
45467 var import_components143 = __toESM(require_components(), 1);
45468 var import_jsx_runtime270 = __toESM(require_jsx_runtime(), 1);
45469 function PostLastRevisionPanel() {
45470 return /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(check_default5, { children: /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(import_components143.PanelBody, { className: "editor-post-last-revision__panel", children: /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(post_last_revision_default, {}) }) });
45471 }
45472 var panel_default2 = PostLastRevisionPanel;
45473
45474 // packages/editor/build-module/components/post-locked-modal/index.mjs
45475 var import_i18n162 = __toESM(require_i18n(), 1);
45476 var import_components144 = __toESM(require_components(), 1);
45477 var import_data129 = __toESM(require_data(), 1);
45478 var import_url14 = __toESM(require_url(), 1);
45479 var import_element117 = __toESM(require_element(), 1);
45480 var import_hooks47 = __toESM(require_hooks(), 1);
45481 var import_compose28 = __toESM(require_compose(), 1);
45482 var import_core_data85 = __toESM(require_core_data(), 1);
45483
45484 // packages/editor/build-module/utils/sync-error-messages.mjs
45485 var import_i18n161 = __toESM(require_i18n(), 1);
45486 var AUTHENTICATION_FAILED = "authentication-failed";
45487 var CONNECTION_EXPIRED = "connection-expired";
45488 var CONNECTION_LIMIT_EXCEEDED = "connection-limit-exceeded";
45489 var DOCUMENT_SIZE_LIMIT_EXCEEDED = "document-size-limit-exceeded";
45490 var UNKNOWN_ERROR = "unknown-error";
45491 var ERROR_MESSAGES = {
45492 [AUTHENTICATION_FAILED]: {
45493 title: (0, import_i18n161.__)("Unable to connect"),
45494 description: (0, import_i18n161.__)(
45495 "Real-time collaboration couldn't verify your permissions. Check that you have access to edit this post or contact your site administrator."
45496 )
45497 },
45498 [CONNECTION_EXPIRED]: {
45499 title: (0, import_i18n161.__)("Connection expired"),
45500 description: (0, import_i18n161.__)(
45501 "Your connection to real-time collaboration has timed out. Editing is paused to prevent conflicts with other editors."
45502 )
45503 },
45504 [CONNECTION_LIMIT_EXCEEDED]: {
45505 title: (0, import_i18n161.__)("Too many editors connected"),
45506 description: (0, import_i18n161.__)(
45507 "Real-time collaboration has reached its connection limit. Try again later or contact your site administrator."
45508 )
45509 },
45510 // DOCUMENT_SIZE_LIMIT_EXCEEDED is not included here because it results in
45511 // collaboration being disabled entirely.
45512 [UNKNOWN_ERROR]: {
45513 title: (0, import_i18n161.__)("Connection lost"),
45514 description: (0, import_i18n161.__)(
45515 "The connection to real-time collaboration was interrupted. Editing is paused to prevent conflicts with other editors."
45516 )
45517 }
45518 };
45519 function getSyncErrorMessages(error) {
45520 if (error?.code && ERROR_MESSAGES[error?.code]) {
45521 return ERROR_MESSAGES[error.code];
45522 }
45523 return ERROR_MESSAGES[UNKNOWN_ERROR];
45524 }
45525
45526 // packages/editor/build-module/components/post-locked-modal/index.mjs
45527 var import_jsx_runtime271 = __toESM(require_jsx_runtime(), 1);
45528 function CollaborationContext() {
45529 const { isCollaborationSupported, syncConnectionStatus } = (0, import_data129.useSelect)(
45530 (select6) => {
45531 const {
45532 isCollaborationSupported: isSupported,
45533 getSyncConnectionStatus
45534 } = unlock(select6(import_core_data85.store));
45535 return {
45536 isCollaborationSupported: isSupported(),
45537 syncConnectionStatus: getSyncConnectionStatus()
45538 };
45539 },
45540 []
45541 );
45542 if (isCollaborationSupported) {
45543 return null;
45544 }
45545 if (DOCUMENT_SIZE_LIMIT_EXCEEDED === syncConnectionStatus?.error?.code) {
45546 return /* @__PURE__ */ (0, import_jsx_runtime271.jsx)("p", { children: (0, import_i18n162.__)(
45547 "Because this post is too large for real-time collaboration, only one person can edit at a time."
45548 ) });
45549 }
45550 return /* @__PURE__ */ (0, import_jsx_runtime271.jsx)("p", { children: (0, import_i18n162.__)(
45551 "Because this post uses plugins that aren\u2019t compatible with real-time collaboration, only one person can edit at a time."
45552 ) });
45553 }
45554 function PostLockedModal() {
45555 const instanceId = (0, import_compose28.useInstanceId)(PostLockedModal);
45556 const hookName = "core/editor/post-locked-modal-" + instanceId;
45557 const { autosave: autosave2, updatePostLock: updatePostLock2 } = (0, import_data129.useDispatch)(store);
45558 const {
45559 isCollaborationEnabled,
45560 isLocked,
45561 isTakeover,
45562 user,
45563 postId: postId2,
45564 postLockUtils,
45565 activePostLock,
45566 postType: postType2,
45567 previewLink
45568 } = (0, import_data129.useSelect)((select6) => {
45569 const {
45570 isPostLocked: isPostLocked2,
45571 isPostLockTakeover: isPostLockTakeover2,
45572 getPostLockUser: getPostLockUser2,
45573 getCurrentPostId: getCurrentPostId2,
45574 getActivePostLock: getActivePostLock2,
45575 getEditedPostAttribute: getEditedPostAttribute2,
45576 getEditedPostPreviewLink: getEditedPostPreviewLink2,
45577 getEditorSettings: getEditorSettings2,
45578 isCollaborationEnabledForCurrentPost: isCollaborationEnabledForCurrentPost2
45579 } = unlock(select6(store));
45580 const { getPostType } = select6(import_core_data85.store);
45581 return {
45582 isCollaborationEnabled: isCollaborationEnabledForCurrentPost2(),
45583 isLocked: isPostLocked2(),
45584 isTakeover: isPostLockTakeover2(),
45585 user: getPostLockUser2(),
45586 postId: getCurrentPostId2(),
45587 postLockUtils: getEditorSettings2().postLockUtils,
45588 activePostLock: getActivePostLock2(),
45589 postType: getPostType(getEditedPostAttribute2("type")),
45590 previewLink: getEditedPostPreviewLink2()
45591 };
45592 }, []);
45593 (0, import_element117.useEffect)(() => {
45594 function sendPostLock(data) {
45595 if (isLocked) {
45596 return;
45597 }
45598 data["wp-refresh-post-lock"] = {
45599 lock: activePostLock,
45600 post_id: postId2
45601 };
45602 }
45603 function receivePostLock(data) {
45604 if (!data["wp-refresh-post-lock"]) {
45605 return;
45606 }
45607 const received = data["wp-refresh-post-lock"];
45608 if (received.lock_error) {
45609 autosave2();
45610 updatePostLock2({
45611 isLocked: true,
45612 isTakeover: true,
45613 user: {
45614 name: received.lock_error.name,
45615 avatar: received.lock_error.avatar_src_2x
45616 }
45617 });
45618 } else if (received.new_lock) {
45619 updatePostLock2({
45620 isLocked: false,
45621 activePostLock: received.new_lock
45622 });
45623 }
45624 }
45625 function releasePostLock() {
45626 if (isLocked || !activePostLock) {
45627 return;
45628 }
45629 const data = new window.FormData();
45630 data.append("action", "wp-remove-post-lock");
45631 data.append("_wpnonce", postLockUtils.unlockNonce);
45632 data.append("post_ID", postId2);
45633 data.append("active_post_lock", activePostLock);
45634 if (window.navigator.sendBeacon) {
45635 window.navigator.sendBeacon(postLockUtils.ajaxUrl, data);
45636 } else {
45637 const xhr = new window.XMLHttpRequest();
45638 xhr.open("POST", postLockUtils.ajaxUrl, false);
45639 xhr.send(data);
45640 }
45641 }
45642 (0, import_hooks47.addAction)("heartbeat.send", hookName, sendPostLock);
45643 (0, import_hooks47.addAction)("heartbeat.tick", hookName, receivePostLock);
45644 window.addEventListener("beforeunload", releasePostLock);
45645 return () => {
45646 (0, import_hooks47.removeAction)("heartbeat.send", hookName);
45647 (0, import_hooks47.removeAction)("heartbeat.tick", hookName);
45648 window.removeEventListener("beforeunload", releasePostLock);
45649 };
45650 }, []);
45651 if (!isLocked) {
45652 return null;
45653 }
45654 if (isCollaborationEnabled) {
45655 return null;
45656 }
45657 const userDisplayName = user.name;
45658 const userAvatar = user.avatar;
45659 const unlockUrl = (0, import_url14.addQueryArgs)("post.php", {
45660 "get-post-lock": "1",
45661 lockKey: true,
45662 post: postId2,
45663 action: "edit",
45664 _wpnonce: postLockUtils.nonce
45665 });
45666 const allPostsUrl = (0, import_url14.addQueryArgs)("edit.php", {
45667 post_type: postType2?.slug
45668 });
45669 const allPostsLabel = (0, import_i18n162.__)("Exit editor");
45670 return /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
45671 import_components144.Modal,
45672 {
45673 title: isTakeover ? (0, import_i18n162.__)("Someone else has taken over this post") : (0, import_i18n162.__)("This post is already being edited"),
45674 focusOnMount: true,
45675 shouldCloseOnClickOutside: false,
45676 shouldCloseOnEsc: false,
45677 isDismissible: false,
45678 className: "editor-post-locked-modal",
45679 size: "medium",
45680 children: /* @__PURE__ */ (0, import_jsx_runtime271.jsxs)(import_components144.__experimentalHStack, { alignment: "top", spacing: 6, children: [
45681 !!userAvatar && /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
45682 "img",
45683 {
45684 src: userAvatar,
45685 alt: (0, import_i18n162.__)("Avatar"),
45686 className: "editor-post-locked-modal__avatar",
45687 width: 64,
45688 height: 64
45689 }
45690 ),
45691 /* @__PURE__ */ (0, import_jsx_runtime271.jsxs)("div", { children: [
45692 !!isTakeover && /* @__PURE__ */ (0, import_jsx_runtime271.jsxs)(import_jsx_runtime271.Fragment, { children: [
45693 /* @__PURE__ */ (0, import_jsx_runtime271.jsx)("p", { children: (0, import_element117.createInterpolateElement)(
45694 userDisplayName ? (0, import_i18n162.sprintf)(
45695 /* translators: %s: user's display name */
45696 (0, import_i18n162.__)(
45697 "<strong>%s</strong> now has editing control of this post (<PreviewLink />). Don\u2019t worry, your changes up to this moment have been saved."
45698 ),
45699 userDisplayName
45700 ) : (0, import_i18n162.__)(
45701 "Another user now has editing control of this post (<PreviewLink />). Don\u2019t worry, your changes up to this moment have been saved."
45702 ),
45703 {
45704 strong: /* @__PURE__ */ (0, import_jsx_runtime271.jsx)("strong", {}),
45705 PreviewLink: /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(import_components144.ExternalLink, { href: previewLink, children: (0, import_i18n162.__)("preview") })
45706 }
45707 ) }),
45708 /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(CollaborationContext, {})
45709 ] }),
45710 !isTakeover && /* @__PURE__ */ (0, import_jsx_runtime271.jsxs)(import_jsx_runtime271.Fragment, { children: [
45711 /* @__PURE__ */ (0, import_jsx_runtime271.jsx)("p", { children: (0, import_element117.createInterpolateElement)(
45712 userDisplayName ? (0, import_i18n162.sprintf)(
45713 /* translators: %s: user's display name */
45714 (0, import_i18n162.__)(
45715 "<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over."
45716 ),
45717 userDisplayName
45718 ) : (0, import_i18n162.__)(
45719 "Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over."
45720 ),
45721 {
45722 strong: /* @__PURE__ */ (0, import_jsx_runtime271.jsx)("strong", {}),
45723 PreviewLink: /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(import_components144.ExternalLink, { href: previewLink, children: (0, import_i18n162.__)("preview") })
45724 }
45725 ) }),
45726 /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(CollaborationContext, {}),
45727 /* @__PURE__ */ (0, import_jsx_runtime271.jsx)("p", { children: (0, import_i18n162.__)(
45728 "If you take over, the other user will lose editing control to the post, but their changes will be saved."
45729 ) })
45730 ] }),
45731 /* @__PURE__ */ (0, import_jsx_runtime271.jsxs)(
45732 import_components144.__experimentalHStack,
45733 {
45734 className: "editor-post-locked-modal__buttons",
45735 justify: "flex-end",
45736 children: [
45737 !isTakeover && /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
45738 import_components144.Button,
45739 {
45740 __next40pxDefaultSize: true,
45741 variant: "tertiary",
45742 href: unlockUrl,
45743 children: (0, import_i18n162.__)("Take over")
45744 }
45745 ),
45746 /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
45747 import_components144.Button,
45748 {
45749 __next40pxDefaultSize: true,
45750 variant: "primary",
45751 href: allPostsUrl,
45752 children: allPostsLabel
45753 }
45754 )
45755 ]
45756 }
45757 )
45758 ] })
45759 ] })
45760 }
45761 );
45762 }
45763 var post_locked_modal_default = false ? (0, import_components144.withFilters)("editor.PostLockedModal")(PostLockedModal) : PostLockedModal;
45764
45765 // packages/editor/build-module/components/post-pending-status/index.mjs
45766 var import_i18n163 = __toESM(require_i18n(), 1);
45767 var import_components145 = __toESM(require_components(), 1);
45768 var import_data131 = __toESM(require_data(), 1);
45769
45770 // packages/editor/build-module/components/post-pending-status/check.mjs
45771 var import_data130 = __toESM(require_data(), 1);
45772 function PostPendingStatusCheck({ children }) {
45773 const { hasPublishAction, isPublished } = (0, import_data130.useSelect)((select6) => {
45774 const { isCurrentPostPublished: isCurrentPostPublished2, getCurrentPost: getCurrentPost2 } = select6(store);
45775 return {
45776 hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false,
45777 isPublished: isCurrentPostPublished2()
45778 };
45779 }, []);
45780 if (isPublished || !hasPublishAction) {
45781 return null;
45782 }
45783 return children;
45784 }
45785 var check_default6 = PostPendingStatusCheck;
45786
45787 // packages/editor/build-module/components/post-pending-status/index.mjs
45788 var import_jsx_runtime272 = __toESM(require_jsx_runtime(), 1);
45789 function PostPendingStatus() {
45790 const status = (0, import_data131.useSelect)(
45791 (select6) => select6(store).getEditedPostAttribute("status"),
45792 []
45793 );
45794 const { editPost: editPost2 } = (0, import_data131.useDispatch)(store);
45795 const togglePendingStatus = () => {
45796 const updatedStatus = status === "pending" ? "draft" : "pending";
45797 editPost2({ status: updatedStatus });
45798 };
45799 return /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(check_default6, { children: /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(
45800 import_components145.CheckboxControl,
45801 {
45802 label: (0, import_i18n163.__)("Pending review"),
45803 checked: status === "pending",
45804 onChange: togglePendingStatus
45805 }
45806 ) });
45807 }
45808 var post_pending_status_default = PostPendingStatus;
45809
45810 // packages/editor/build-module/components/post-preview-button/index.mjs
45811 var import_element118 = __toESM(require_element(), 1);
45812 var import_components146 = __toESM(require_components(), 1);
45813 var import_i18n164 = __toESM(require_i18n(), 1);
45814 var import_data132 = __toESM(require_data(), 1);
45815 var import_hooks48 = __toESM(require_hooks(), 1);
45816 var import_core_data86 = __toESM(require_core_data(), 1);
45817 var import_jsx_runtime273 = __toESM(require_jsx_runtime(), 1);
45818 function writeInterstitialMessage(targetDocument) {
45819 let markup = (0, import_element118.renderToString)(
45820 /* @__PURE__ */ (0, import_jsx_runtime273.jsxs)("div", { className: "editor-post-preview-button__interstitial-message", children: [
45821 /* @__PURE__ */ (0, import_jsx_runtime273.jsxs)(import_components146.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 96 96", children: [
45822 /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
45823 import_components146.Path,
45824 {
45825 className: "outer",
45826 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36",
45827 fill: "none"
45828 }
45829 ),
45830 /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
45831 import_components146.Path,
45832 {
45833 className: "inner",
45834 d: "M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z",
45835 fill: "none"
45836 }
45837 )
45838 ] }),
45839 /* @__PURE__ */ (0, import_jsx_runtime273.jsx)("p", { children: (0, import_i18n164.__)("Generating preview\u2026") })
45840 ] })
45841 );
45842 markup += `
45843 <style>
45844 body {
45845 margin: 0;
45846 }
45847 .editor-post-preview-button__interstitial-message {
45848 display: flex;
45849 flex-direction: column;
45850 align-items: center;
45851 justify-content: center;
45852 height: 100vh;
45853 width: 100vw;
45854 }
45855 @-webkit-keyframes paint {
45856 0% {
45857 stroke-dashoffset: 0;
45858 }
45859 }
45860 @-moz-keyframes paint {
45861 0% {
45862 stroke-dashoffset: 0;
45863 }
45864 }
45865 @-o-keyframes paint {
45866 0% {
45867 stroke-dashoffset: 0;
45868 }
45869 }
45870 @keyframes paint {
45871 0% {
45872 stroke-dashoffset: 0;
45873 }
45874 }
45875 .editor-post-preview-button__interstitial-message svg {
45876 width: 192px;
45877 height: 192px;
45878 stroke: #555d66;
45879 stroke-width: 0.75;
45880 }
45881 .editor-post-preview-button__interstitial-message svg .outer,
45882 .editor-post-preview-button__interstitial-message svg .inner {
45883 stroke-dasharray: 280;
45884 stroke-dashoffset: 280;
45885 -webkit-animation: paint 1.5s ease infinite alternate;
45886 -moz-animation: paint 1.5s ease infinite alternate;
45887 -o-animation: paint 1.5s ease infinite alternate;
45888 animation: paint 1.5s ease infinite alternate;
45889 }
45890 p {
45891 text-align: center;
45892 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
45893 }
45894 </style>
45895 `;
45896 markup = (0, import_hooks48.applyFilters)("editor.PostPreview.interstitialMarkup", markup);
45897 targetDocument.write(markup);
45898 targetDocument.title = (0, import_i18n164.__)("Generating preview\u2026");
45899 targetDocument.close();
45900 }
45901 function PostPreviewButton({
45902 className,
45903 textContent,
45904 forceIsAutosaveable,
45905 role,
45906 onPreview
45907 }) {
45908 const { postId: postId2, currentPostLink, previewLink, isSaveable, isViewable } = (0, import_data132.useSelect)((select6) => {
45909 const editor = select6(store);
45910 const core = select6(import_core_data86.store);
45911 const postType2 = core.getPostType(
45912 editor.getCurrentPostType("type")
45913 );
45914 const canView = postType2?.viewable ?? false;
45915 if (!canView) {
45916 return { isViewable: canView };
45917 }
45918 return {
45919 postId: editor.getCurrentPostId(),
45920 currentPostLink: editor.getCurrentPostAttribute("link"),
45921 previewLink: editor.getEditedPostPreviewLink(),
45922 isSaveable: editor.isEditedPostSaveable(),
45923 isViewable: canView
45924 };
45925 }, []);
45926 const { __unstableSaveForPreview: __unstableSaveForPreview2 } = (0, import_data132.useDispatch)(store);
45927 if (!isViewable) {
45928 return null;
45929 }
45930 const targetId = `wp-preview-${postId2}`;
45931 const openPreviewWindow = async (event) => {
45932 event.preventDefault();
45933 const previewWindow = window.open("", targetId);
45934 previewWindow.focus();
45935 writeInterstitialMessage(previewWindow.document);
45936 const link = await __unstableSaveForPreview2({ forceIsAutosaveable });
45937 previewWindow.location = link;
45938 onPreview?.();
45939 };
45940 const href = previewLink || currentPostLink;
45941 return /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
45942 import_components146.Button,
45943 {
45944 variant: !className ? "tertiary" : void 0,
45945 className: className || "editor-post-preview",
45946 href,
45947 target: targetId,
45948 accessibleWhenDisabled: true,
45949 disabled: !isSaveable,
45950 onClick: openPreviewWindow,
45951 role,
45952 size: "compact",
45953 children: textContent || /* @__PURE__ */ (0, import_jsx_runtime273.jsxs)(import_jsx_runtime273.Fragment, { children: [
45954 (0, import_i18n164._x)("Preview", "imperative verb"),
45955 /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(import_components146.VisuallyHidden, {
45956 as: "span",
45957 /* translators: accessibility text */
45958 children: (0, import_i18n164.__)("(opens in a new tab)")
45959 })
45960 ] })
45961 }
45962 );
45963 }
45964
45965 // packages/editor/build-module/components/post-publish-button/index.mjs
45966 var import_components147 = __toESM(require_components(), 1);
45967 var import_element119 = __toESM(require_element(), 1);
45968 var import_data134 = __toESM(require_data(), 1);
45969 var import_compose30 = __toESM(require_compose(), 1);
45970
45971 // packages/editor/build-module/components/post-publish-button/label.mjs
45972 var import_i18n165 = __toESM(require_i18n(), 1);
45973 var import_data133 = __toESM(require_data(), 1);
45974 var import_compose29 = __toESM(require_compose(), 1);
45975 function PublishButtonLabel() {
45976 const isSmallerThanMediumViewport = (0, import_compose29.useViewportMatch)("medium", "<");
45977 const {
45978 isPublished,
45979 isBeingScheduled,
45980 isSaving,
45981 isPublishing,
45982 hasPublishAction,
45983 isAutosaving,
45984 hasNonPostEntityChanges: hasNonPostEntityChanges2,
45985 postStatusHasChanged,
45986 postStatus,
45987 postType: postType2
45988 } = (0, import_data133.useSelect)((select6) => {
45989 const {
45990 isCurrentPostPublished: isCurrentPostPublished2,
45991 isEditedPostBeingScheduled: isEditedPostBeingScheduled2,
45992 isSavingPost: isSavingPost2,
45993 isPublishingPost: isPublishingPost2,
45994 getCurrentPost: getCurrentPost2,
45995 getCurrentPostType: getCurrentPostType2,
45996 isAutosavingPost: isAutosavingPost2,
45997 getPostEdits: getPostEdits2,
45998 getEditedPostAttribute: getEditedPostAttribute2
45999 } = select6(store);
46000 return {
46001 isPublished: isCurrentPostPublished2(),
46002 isBeingScheduled: isEditedPostBeingScheduled2(),
46003 isSaving: isSavingPost2(),
46004 isPublishing: isPublishingPost2(),
46005 hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false,
46006 postType: getCurrentPostType2(),
46007 isAutosaving: isAutosavingPost2(),
46008 hasNonPostEntityChanges: select6(store).hasNonPostEntityChanges(),
46009 postStatusHasChanged: !!getPostEdits2()?.status,
46010 postStatus: getEditedPostAttribute2("status")
46011 };
46012 }, []);
46013 if (isPublishing) {
46014 return (0, import_i18n165.__)("Publishing\u2026");
46015 } else if ((isPublished || isBeingScheduled) && isSaving && !isAutosaving) {
46016 return (0, import_i18n165.__)("Saving\u2026");
46017 }
46018 if (!hasPublishAction) {
46019 if (postType2 === ATTACHMENT_POST_TYPE && window?.__experimentalMediaEditor) {
46020 return (0, import_i18n165.__)("Save");
46021 }
46022 return isSmallerThanMediumViewport ? (0, import_i18n165.__)("Publish") : (0, import_i18n165.__)("Submit for Review");
46023 }
46024 if (hasNonPostEntityChanges2 || isPublished || postStatusHasChanged && !["future", "publish"].includes(postStatus) || !postStatusHasChanged && postStatus === "future") {
46025 return (0, import_i18n165.__)("Save");
46026 }
46027 if (isBeingScheduled) {
46028 return (0, import_i18n165.__)("Schedule");
46029 }
46030 return (0, import_i18n165.__)("Publish");
46031 }
46032
46033 // packages/editor/build-module/components/post-publish-button/index.mjs
46034 var import_jsx_runtime274 = __toESM(require_jsx_runtime(), 1);
46035 var noop6 = () => {
46036 };
46037 var PostPublishButton = class extends import_element119.Component {
46038 constructor(props) {
46039 super(props);
46040 this.createOnClick = this.createOnClick.bind(this);
46041 this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this);
46042 this.state = {
46043 entitiesSavedStatesCallback: false
46044 };
46045 }
46046 createOnClick(callback) {
46047 return (...args) => {
46048 const { hasNonPostEntityChanges: hasNonPostEntityChanges2, setEntitiesSavedStatesCallback } = this.props;
46049 if (hasNonPostEntityChanges2 && setEntitiesSavedStatesCallback) {
46050 this.setState({
46051 entitiesSavedStatesCallback: () => callback(...args)
46052 });
46053 setEntitiesSavedStatesCallback(
46054 () => this.closeEntitiesSavedStates
46055 );
46056 return noop6;
46057 }
46058 return callback(...args);
46059 };
46060 }
46061 closeEntitiesSavedStates(savedEntities) {
46062 const { postType: postType2, postId: postId2 } = this.props;
46063 const { entitiesSavedStatesCallback } = this.state;
46064 this.setState({ entitiesSavedStatesCallback: false }, () => {
46065 if (savedEntities && savedEntities.some(
46066 (elt) => elt.kind === "postType" && elt.name === postType2 && elt.key === postId2
46067 )) {
46068 entitiesSavedStatesCallback();
46069 }
46070 });
46071 }
46072 render() {
46073 const {
46074 forceIsDirty,
46075 hasPublishAction,
46076 isBeingScheduled,
46077 isOpen,
46078 isPostSavingLocked: isPostSavingLocked2,
46079 isPublishable,
46080 isPublished,
46081 isSaveable,
46082 isSaving,
46083 isAutoSaving,
46084 isToggle,
46085 savePostStatus,
46086 onSubmit = noop6,
46087 onToggle,
46088 visibility,
46089 hasNonPostEntityChanges: hasNonPostEntityChanges2,
46090 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2,
46091 postStatus,
46092 postStatusHasChanged
46093 } = this.props;
46094 const isButtonDisabled = (isSaving || !isSaveable || isPostSavingLocked2 || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges2 || isSavingNonPostEntityChanges2);
46095 const isToggleDisabled = (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges2 || isSavingNonPostEntityChanges2);
46096 let publishStatus = "publish";
46097 if (postStatusHasChanged) {
46098 publishStatus = postStatus;
46099 } else if (!hasPublishAction) {
46100 publishStatus = "pending";
46101 } else if (visibility === "private") {
46102 publishStatus = "private";
46103 } else if (isBeingScheduled) {
46104 publishStatus = "future";
46105 }
46106 const onClickButton = () => {
46107 if (isButtonDisabled) {
46108 return;
46109 }
46110 onSubmit();
46111 savePostStatus(publishStatus);
46112 };
46113 const onClickToggle = () => {
46114 if (isToggleDisabled) {
46115 return;
46116 }
46117 onToggle();
46118 };
46119 const buttonProps = {
46120 "aria-disabled": isButtonDisabled,
46121 className: "editor-post-publish-button",
46122 isBusy: !isAutoSaving && isSaving,
46123 variant: "primary",
46124 onClick: this.createOnClick(onClickButton),
46125 "aria-haspopup": hasNonPostEntityChanges2 ? "dialog" : void 0
46126 };
46127 const toggleProps = {
46128 "aria-disabled": isToggleDisabled,
46129 "aria-expanded": isOpen,
46130 className: "editor-post-publish-panel__toggle",
46131 isBusy: isSaving && isPublished,
46132 variant: "primary",
46133 size: "compact",
46134 onClick: this.createOnClick(onClickToggle),
46135 "aria-haspopup": hasNonPostEntityChanges2 ? "dialog" : void 0
46136 };
46137 const componentProps = isToggle ? toggleProps : buttonProps;
46138 return /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(import_jsx_runtime274.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(
46139 import_components147.Button,
46140 {
46141 ...componentProps,
46142 className: `${componentProps.className} editor-post-publish-button__button`,
46143 size: "compact",
46144 children: /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(PublishButtonLabel, {})
46145 }
46146 ) });
46147 }
46148 };
46149 var post_publish_button_default = (0, import_compose30.compose)([
46150 (0, import_data134.withSelect)((select6) => {
46151 const {
46152 isSavingPost: isSavingPost2,
46153 isAutosavingPost: isAutosavingPost2,
46154 isEditedPostBeingScheduled: isEditedPostBeingScheduled2,
46155 getEditedPostVisibility: getEditedPostVisibility2,
46156 isCurrentPostPublished: isCurrentPostPublished2,
46157 isEditedPostSaveable: isEditedPostSaveable2,
46158 isEditedPostPublishable: isEditedPostPublishable2,
46159 isPostSavingLocked: isPostSavingLocked2,
46160 getCurrentPost: getCurrentPost2,
46161 getCurrentPostType: getCurrentPostType2,
46162 getCurrentPostId: getCurrentPostId2,
46163 hasNonPostEntityChanges: hasNonPostEntityChanges2,
46164 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2,
46165 getEditedPostAttribute: getEditedPostAttribute2,
46166 getPostEdits: getPostEdits2
46167 } = select6(store);
46168 return {
46169 isSaving: isSavingPost2(),
46170 isAutoSaving: isAutosavingPost2(),
46171 isBeingScheduled: isEditedPostBeingScheduled2(),
46172 visibility: getEditedPostVisibility2(),
46173 isSaveable: isEditedPostSaveable2(),
46174 isPostSavingLocked: isPostSavingLocked2(),
46175 isPublishable: isEditedPostPublishable2(),
46176 isPublished: isCurrentPostPublished2(),
46177 hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false,
46178 postType: getCurrentPostType2(),
46179 postId: getCurrentPostId2(),
46180 postStatus: getEditedPostAttribute2("status"),
46181 postStatusHasChanged: getPostEdits2()?.status,
46182 hasNonPostEntityChanges: hasNonPostEntityChanges2(),
46183 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2()
46184 };
46185 }),
46186 (0, import_data134.withDispatch)((dispatch7) => {
46187 const { editPost: editPost2, savePost: savePost2 } = dispatch7(store);
46188 return {
46189 savePostStatus: (status) => {
46190 editPost2({ status }, { undoIgnore: true });
46191 savePost2();
46192 }
46193 };
46194 })
46195 ])(PostPublishButton);
46196
46197 // packages/editor/build-module/components/post-publish-panel/index.mjs
46198 var import_i18n178 = __toESM(require_i18n(), 1);
46199 var import_element128 = __toESM(require_element(), 1);
46200 var import_components158 = __toESM(require_components(), 1);
46201 var import_data148 = __toESM(require_data(), 1);
46202 var import_compose35 = __toESM(require_compose(), 1);
46203 var import_core_data96 = __toESM(require_core_data(), 1);
46204
46205 // packages/editor/build-module/components/post-publish-panel/prepublish.mjs
46206 var import_i18n176 = __toESM(require_i18n(), 1);
46207 var import_components156 = __toESM(require_components(), 1);
46208 var import_data146 = __toESM(require_data(), 1);
46209 var import_url16 = __toESM(require_url(), 1);
46210 var import_core_data94 = __toESM(require_core_data(), 1);
46211 var import_html_entities22 = __toESM(require_html_entities(), 1);
46212
46213 // packages/editor/build-module/components/post-visibility/index.mjs
46214 var import_i18n167 = __toESM(require_i18n(), 1);
46215 var import_element120 = __toESM(require_element(), 1);
46216 var import_components148 = __toESM(require_components(), 1);
46217 var import_compose31 = __toESM(require_compose(), 1);
46218 var import_data135 = __toESM(require_data(), 1);
46219 var import_block_editor53 = __toESM(require_block_editor(), 1);
46220
46221 // packages/editor/build-module/components/post-visibility/utils.mjs
46222 var import_i18n166 = __toESM(require_i18n(), 1);
46223 var VISIBILITY_OPTIONS = [
46224 {
46225 label: (0, import_i18n166.__)("Public"),
46226 value: "public",
46227 description: (0, import_i18n166.__)("Visible to everyone.")
46228 },
46229 {
46230 label: (0, import_i18n166.__)("Private"),
46231 value: "private",
46232 description: (0, import_i18n166.__)("Only visible to site admins and editors.")
46233 },
46234 {
46235 label: (0, import_i18n166.__)("Password protected"),
46236 value: "password",
46237 description: (0, import_i18n166.__)("Only visible to those who know the password.")
46238 }
46239 ];
46240
46241 // packages/editor/build-module/components/post-visibility/index.mjs
46242 var import_jsx_runtime275 = __toESM(require_jsx_runtime(), 1);
46243 function PostVisibility({ onClose }) {
46244 const instanceId = (0, import_compose31.useInstanceId)(PostVisibility);
46245 const { status, visibility, password } = (0, import_data135.useSelect)((select6) => ({
46246 status: select6(store).getEditedPostAttribute("status"),
46247 visibility: select6(store).getEditedPostVisibility(),
46248 password: select6(store).getEditedPostAttribute("password")
46249 }));
46250 const { editPost: editPost2 } = (0, import_data135.useDispatch)(store);
46251 const [hasPassword, setHasPassword] = (0, import_element120.useState)(!!password);
46252 function updateVisibility(value) {
46253 const nextValues = {
46254 public: {
46255 status: visibility === "private" ? "draft" : status,
46256 password: ""
46257 },
46258 private: { status: "private", password: "" },
46259 password: {
46260 status: visibility === "private" ? "draft" : status,
46261 password: password || ""
46262 }
46263 };
46264 editPost2(nextValues[value]);
46265 setHasPassword(value === "password");
46266 }
46267 const updatePassword = (value) => {
46268 editPost2({ password: value });
46269 };
46270 return /* @__PURE__ */ (0, import_jsx_runtime275.jsxs)("div", { className: "editor-post-visibility", children: [
46271 /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(
46272 import_block_editor53.__experimentalInspectorPopoverHeader,
46273 {
46274 title: (0, import_i18n167.__)("Visibility"),
46275 help: (0, import_i18n167.__)("Control how this post is viewed."),
46276 onClose
46277 }
46278 ),
46279 /* @__PURE__ */ (0, import_jsx_runtime275.jsxs)(import_components148.__experimentalVStack, { spacing: 4, children: [
46280 /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(
46281 import_components148.RadioControl,
46282 {
46283 label: (0, import_i18n167.__)("Visibility"),
46284 hideLabelFromVision: true,
46285 options: VISIBILITY_OPTIONS,
46286 selected: hasPassword ? "password" : visibility,
46287 onChange: updateVisibility
46288 }
46289 ),
46290 hasPassword && /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(
46291 import_components148.TextControl,
46292 {
46293 label: (0, import_i18n167.__)("Password"),
46294 onChange: updatePassword,
46295 value: password,
46296 placeholder: (0, import_i18n167.__)("Use a secure password"),
46297 type: "text",
46298 id: `editor-post-visibility__password-input-${instanceId}`,
46299 __next40pxDefaultSize: true,
46300 maxLength: 255
46301 }
46302 )
46303 ] })
46304 ] });
46305 }
46306
46307 // packages/editor/build-module/components/post-visibility/label.mjs
46308 var import_data136 = __toESM(require_data(), 1);
46309 function PostVisibilityLabel() {
46310 return usePostVisibilityLabel();
46311 }
46312 function usePostVisibilityLabel() {
46313 const visibility = (0, import_data136.useSelect)(
46314 (select6) => select6(store).getEditedPostVisibility(),
46315 []
46316 );
46317 return VISIBILITY_OPTIONS.find((option) => option.value === visibility)?.label;
46318 }
46319
46320 // node_modules/date-fns/toDate.mjs
46321 function toDate(argument) {
46322 const argStr = Object.prototype.toString.call(argument);
46323 if (argument instanceof Date || typeof argument === "object" && argStr === "[object Date]") {
46324 return new argument.constructor(+argument);
46325 } else if (typeof argument === "number" || argStr === "[object Number]" || typeof argument === "string" || argStr === "[object String]") {
46326 return new Date(argument);
46327 } else {
46328 return /* @__PURE__ */ new Date(NaN);
46329 }
46330 }
46331
46332 // node_modules/date-fns/constants.mjs
46333 var daysInYear = 365.2425;
46334 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
46335 var minTime = -maxTime;
46336 var millisecondsInMinute = 6e4;
46337 var millisecondsInHour = 36e5;
46338 var secondsInHour = 3600;
46339 var secondsInDay = secondsInHour * 24;
46340 var secondsInWeek = secondsInDay * 7;
46341 var secondsInYear = secondsInDay * daysInYear;
46342 var secondsInMonth = secondsInYear / 12;
46343 var secondsInQuarter = secondsInMonth * 3;
46344
46345 // node_modules/date-fns/endOfMonth.mjs
46346 function endOfMonth(date) {
46347 const _date = toDate(date);
46348 const month = _date.getMonth();
46349 _date.setFullYear(_date.getFullYear(), month + 1, 0);
46350 _date.setHours(23, 59, 59, 999);
46351 return _date;
46352 }
46353
46354 // node_modules/date-fns/startOfMonth.mjs
46355 function startOfMonth(date) {
46356 const _date = toDate(date);
46357 _date.setDate(1);
46358 _date.setHours(0, 0, 0, 0);
46359 return _date;
46360 }
46361
46362 // node_modules/date-fns/parseISO.mjs
46363 function parseISO(argument, options) {
46364 const additionalDigits = options?.additionalDigits ?? 2;
46365 const dateStrings = splitDateString(argument);
46366 let date;
46367 if (dateStrings.date) {
46368 const parseYearResult = parseYear(dateStrings.date, additionalDigits);
46369 date = parseDate(parseYearResult.restDateString, parseYearResult.year);
46370 }
46371 if (!date || isNaN(date.getTime())) {
46372 return /* @__PURE__ */ new Date(NaN);
46373 }
46374 const timestamp = date.getTime();
46375 let time = 0;
46376 let offset3;
46377 if (dateStrings.time) {
46378 time = parseTime(dateStrings.time);
46379 if (isNaN(time)) {
46380 return /* @__PURE__ */ new Date(NaN);
46381 }
46382 }
46383 if (dateStrings.timezone) {
46384 offset3 = parseTimezone(dateStrings.timezone);
46385 if (isNaN(offset3)) {
46386 return /* @__PURE__ */ new Date(NaN);
46387 }
46388 } else {
46389 const dirtyDate = new Date(timestamp + time);
46390 const result = /* @__PURE__ */ new Date(0);
46391 result.setFullYear(
46392 dirtyDate.getUTCFullYear(),
46393 dirtyDate.getUTCMonth(),
46394 dirtyDate.getUTCDate()
46395 );
46396 result.setHours(
46397 dirtyDate.getUTCHours(),
46398 dirtyDate.getUTCMinutes(),
46399 dirtyDate.getUTCSeconds(),
46400 dirtyDate.getUTCMilliseconds()
46401 );
46402 return result;
46403 }
46404 return new Date(timestamp + time + offset3);
46405 }
46406 var patterns = {
46407 dateTimeDelimiter: /[T ]/,
46408 timeZoneDelimiter: /[Z ]/i,
46409 timezone: /([Z+-].*)$/
46410 };
46411 var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
46412 var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
46413 var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
46414 function splitDateString(dateString) {
46415 const dateStrings = {};
46416 const array = dateString.split(patterns.dateTimeDelimiter);
46417 let timeString;
46418 if (array.length > 2) {
46419 return dateStrings;
46420 }
46421 if (/:/.test(array[0])) {
46422 timeString = array[0];
46423 } else {
46424 dateStrings.date = array[0];
46425 timeString = array[1];
46426 if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
46427 dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
46428 timeString = dateString.substr(
46429 dateStrings.date.length,
46430 dateString.length
46431 );
46432 }
46433 }
46434 if (timeString) {
46435 const token = patterns.timezone.exec(timeString);
46436 if (token) {
46437 dateStrings.time = timeString.replace(token[1], "");
46438 dateStrings.timezone = token[1];
46439 } else {
46440 dateStrings.time = timeString;
46441 }
46442 }
46443 return dateStrings;
46444 }
46445 function parseYear(dateString, additionalDigits) {
46446 const regex = new RegExp(
46447 "^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)"
46448 );
46449 const captures = dateString.match(regex);
46450 if (!captures) return { year: NaN, restDateString: "" };
46451 const year = captures[1] ? parseInt(captures[1]) : null;
46452 const century = captures[2] ? parseInt(captures[2]) : null;
46453 return {
46454 year: century === null ? year : century * 100,
46455 restDateString: dateString.slice((captures[1] || captures[2]).length)
46456 };
46457 }
46458 function parseDate(dateString, year) {
46459 if (year === null) return /* @__PURE__ */ new Date(NaN);
46460 const captures = dateString.match(dateRegex);
46461 if (!captures) return /* @__PURE__ */ new Date(NaN);
46462 const isWeekDate = !!captures[4];
46463 const dayOfYear = parseDateUnit(captures[1]);
46464 const month = parseDateUnit(captures[2]) - 1;
46465 const day = parseDateUnit(captures[3]);
46466 const week = parseDateUnit(captures[4]);
46467 const dayOfWeek = parseDateUnit(captures[5]) - 1;
46468 if (isWeekDate) {
46469 if (!validateWeekDate(year, week, dayOfWeek)) {
46470 return /* @__PURE__ */ new Date(NaN);
46471 }
46472 return dayOfISOWeekYear(year, week, dayOfWeek);
46473 } else {
46474 const date = /* @__PURE__ */ new Date(0);
46475 if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
46476 return /* @__PURE__ */ new Date(NaN);
46477 }
46478 date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
46479 return date;
46480 }
46481 }
46482 function parseDateUnit(value) {
46483 return value ? parseInt(value) : 1;
46484 }
46485 function parseTime(timeString) {
46486 const captures = timeString.match(timeRegex);
46487 if (!captures) return NaN;
46488 const hours = parseTimeUnit(captures[1]);
46489 const minutes = parseTimeUnit(captures[2]);
46490 const seconds = parseTimeUnit(captures[3]);
46491 if (!validateTime(hours, minutes, seconds)) {
46492 return NaN;
46493 }
46494 return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
46495 }
46496 function parseTimeUnit(value) {
46497 return value && parseFloat(value.replace(",", ".")) || 0;
46498 }
46499 function parseTimezone(timezoneString) {
46500 if (timezoneString === "Z") return 0;
46501 const captures = timezoneString.match(timezoneRegex);
46502 if (!captures) return 0;
46503 const sign = captures[1] === "+" ? -1 : 1;
46504 const hours = parseInt(captures[2]);
46505 const minutes = captures[3] && parseInt(captures[3]) || 0;
46506 if (!validateTimezone(hours, minutes)) {
46507 return NaN;
46508 }
46509 return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
46510 }
46511 function dayOfISOWeekYear(isoWeekYear, week, day) {
46512 const date = /* @__PURE__ */ new Date(0);
46513 date.setUTCFullYear(isoWeekYear, 0, 4);
46514 const fourthOfJanuaryDay = date.getUTCDay() || 7;
46515 const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
46516 date.setUTCDate(date.getUTCDate() + diff);
46517 return date;
46518 }
46519 var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
46520 function isLeapYearIndex(year) {
46521 return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
46522 }
46523 function validateDate(year, month, date) {
46524 return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
46525 }
46526 function validateDayOfYearDate(year, dayOfYear) {
46527 return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
46528 }
46529 function validateWeekDate(_year, week, day) {
46530 return week >= 1 && week <= 53 && day >= 0 && day <= 6;
46531 }
46532 function validateTime(hours, minutes, seconds) {
46533 if (hours === 24) {
46534 return minutes === 0 && seconds === 0;
46535 }
46536 return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
46537 }
46538 function validateTimezone(_hours, minutes) {
46539 return minutes >= 0 && minutes <= 59;
46540 }
46541
46542 // packages/editor/build-module/components/post-schedule/index.mjs
46543 var import_date7 = __toESM(require_date(), 1);
46544 var import_i18n168 = __toESM(require_i18n(), 1);
46545 var import_data137 = __toESM(require_data(), 1);
46546 var import_block_editor54 = __toESM(require_block_editor(), 1);
46547 var import_element121 = __toESM(require_element(), 1);
46548 var import_core_data87 = __toESM(require_core_data(), 1);
46549 var import_jsx_runtime276 = __toESM(require_jsx_runtime(), 1);
46550 var { PrivatePublishDateTimePicker } = unlock(import_block_editor54.privateApis);
46551 function PostSchedule(props) {
46552 return /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(
46553 PrivatePostSchedule,
46554 {
46555 ...props,
46556 showPopoverHeaderActions: true,
46557 isCompact: false
46558 }
46559 );
46560 }
46561 function PrivatePostSchedule({
46562 onClose,
46563 showPopoverHeaderActions,
46564 isCompact
46565 }) {
46566 const { postDate, postType: postType2 } = (0, import_data137.useSelect)(
46567 (select6) => ({
46568 postDate: select6(store).getEditedPostAttribute("date"),
46569 postType: select6(store).getCurrentPostType()
46570 }),
46571 []
46572 );
46573 const { editPost: editPost2 } = (0, import_data137.useDispatch)(store);
46574 const onUpdateDate = (date) => editPost2({ date });
46575 const [previewedMonth, setPreviewedMonth] = (0, import_element121.useState)(
46576 startOfMonth(new Date(postDate))
46577 );
46578 const eventsByPostType = (0, import_data137.useSelect)(
46579 (select6) => select6(import_core_data87.store).getEntityRecords("postType", postType2, {
46580 status: "publish,future",
46581 after: startOfMonth(previewedMonth).toISOString(),
46582 before: endOfMonth(previewedMonth).toISOString(),
46583 exclude: [select6(store).getCurrentPostId()],
46584 per_page: 100,
46585 _fields: "id,date"
46586 }),
46587 [previewedMonth, postType2]
46588 );
46589 const events = (0, import_element121.useMemo)(
46590 () => (eventsByPostType || []).map(({ date: eventDate }) => ({
46591 date: new Date(eventDate)
46592 })),
46593 [eventsByPostType]
46594 );
46595 const settings = (0, import_date7.getSettings)();
46596 const is12HourTime = /a(?!\\)/i.test(
46597 settings.formats.time.toLowerCase().replace(/\\\\/g, "").split("").reverse().join("")
46598 // Reverse the string and test for "a" not followed by a slash.
46599 );
46600 return /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(
46601 PrivatePublishDateTimePicker,
46602 {
46603 currentDate: postDate,
46604 onChange: onUpdateDate,
46605 is12Hour: is12HourTime,
46606 dateOrder: (
46607 /* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */
46608 (0, import_i18n168._x)("dmy", "date order")
46609 ),
46610 events,
46611 onMonthPreviewed: (date) => setPreviewedMonth(parseISO(date)),
46612 onClose,
46613 isCompact,
46614 showPopoverHeaderActions
46615 }
46616 );
46617 }
46618
46619 // packages/editor/build-module/components/post-schedule/label.mjs
46620 var import_i18n169 = __toESM(require_i18n(), 1);
46621 var import_date8 = __toESM(require_date(), 1);
46622 var import_data138 = __toESM(require_data(), 1);
46623 function PostScheduleLabel(props) {
46624 return usePostScheduleLabel(props);
46625 }
46626 function usePostScheduleLabel({ full = false } = {}) {
46627 const { date, isFloating } = (0, import_data138.useSelect)(
46628 (select6) => ({
46629 date: select6(store).getEditedPostAttribute("date"),
46630 isFloating: select6(store).isEditedPostDateFloating()
46631 }),
46632 []
46633 );
46634 return full ? getFullPostScheduleLabel(date) : getPostScheduleLabel(date, { isFloating });
46635 }
46636 function getFullPostScheduleLabel(dateAttribute) {
46637 const date = (0, import_date8.getDate)(dateAttribute);
46638 const timezoneAbbreviation = getTimezoneAbbreviation();
46639 const formattedDate = (0, import_date8.dateI18n)(
46640 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
46641 (0, import_i18n169._x)("F j, Y g:i\xA0a", "post schedule full date format"),
46642 date
46643 );
46644 return (0, import_i18n169.isRTL)() ? `${timezoneAbbreviation} ${formattedDate}` : `${formattedDate} ${timezoneAbbreviation}`;
46645 }
46646 function getPostScheduleLabel(dateAttribute, { isFloating = false, now = /* @__PURE__ */ new Date() } = {}) {
46647 if (!dateAttribute || isFloating) {
46648 return (0, import_i18n169.__)("Immediately");
46649 }
46650 if (!isTimezoneSameAsSiteTimezone(now)) {
46651 return getFullPostScheduleLabel(dateAttribute);
46652 }
46653 const date = (0, import_date8.getDate)(dateAttribute);
46654 if (isSameDay(date, now)) {
46655 return (0, import_i18n169.sprintf)(
46656 // translators: %s: Time of day the post is scheduled for.
46657 (0, import_i18n169.__)("Today at %s"),
46658 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
46659 (0, import_date8.dateI18n)((0, import_i18n169._x)("g:i\xA0a", "post schedule time format"), date)
46660 );
46661 }
46662 const tomorrow = new Date(now);
46663 tomorrow.setDate(tomorrow.getDate() + 1);
46664 if (isSameDay(date, tomorrow)) {
46665 return (0, import_i18n169.sprintf)(
46666 // translators: %s: Time of day the post is scheduled for.
46667 (0, import_i18n169.__)("Tomorrow at %s"),
46668 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
46669 (0, import_date8.dateI18n)((0, import_i18n169._x)("g:i\xA0a", "post schedule time format"), date)
46670 );
46671 }
46672 if (date.getFullYear() === now.getFullYear()) {
46673 return (0, import_date8.dateI18n)(
46674 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
46675 (0, import_i18n169._x)("F j g:i\xA0a", "post schedule date format without year"),
46676 date
46677 );
46678 }
46679 return (0, import_date8.dateI18n)(
46680 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
46681 (0, import_i18n169._x)("F j, Y g:i\xA0a", "post schedule full date format"),
46682 date
46683 );
46684 }
46685 function getTimezoneAbbreviation() {
46686 const { timezone } = (0, import_date8.getSettings)();
46687 if (timezone.abbr && isNaN(Number(timezone.abbr))) {
46688 return timezone.abbr;
46689 }
46690 const symbol = timezone.offset < 0 ? "" : "+";
46691 return `UTC${symbol}${timezone.offsetFormatted}`;
46692 }
46693 function isTimezoneSameAsSiteTimezone(date) {
46694 const { timezone } = (0, import_date8.getSettings)();
46695 const siteOffset = Number(timezone.offset);
46696 const dateOffset = -1 * (date.getTimezoneOffset() / 60);
46697 return siteOffset === dateOffset;
46698 }
46699 function isSameDay(left, right) {
46700 return left.getDate() === right.getDate() && left.getMonth() === right.getMonth() && left.getFullYear() === right.getFullYear();
46701 }
46702
46703 // packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.mjs
46704 var import_i18n171 = __toESM(require_i18n(), 1);
46705 var import_element123 = __toESM(require_element(), 1);
46706 var import_data141 = __toESM(require_data(), 1);
46707 var import_components151 = __toESM(require_components(), 1);
46708 var import_core_data90 = __toESM(require_core_data(), 1);
46709
46710 // packages/editor/build-module/components/post-taxonomies/flat-term-selector.mjs
46711 var import_i18n170 = __toESM(require_i18n(), 1);
46712 var import_element122 = __toESM(require_element(), 1);
46713 var import_components150 = __toESM(require_components(), 1);
46714 var import_data140 = __toESM(require_data(), 1);
46715 var import_core_data89 = __toESM(require_core_data(), 1);
46716 var import_compose32 = __toESM(require_compose(), 1);
46717 var import_a11y4 = __toESM(require_a11y(), 1);
46718 var import_notices23 = __toESM(require_notices(), 1);
46719
46720 // packages/editor/build-module/components/post-taxonomies/most-used-terms.mjs
46721 var import_components149 = __toESM(require_components(), 1);
46722 var import_data139 = __toESM(require_data(), 1);
46723 var import_core_data88 = __toESM(require_core_data(), 1);
46724 var import_jsx_runtime277 = __toESM(require_jsx_runtime(), 1);
46725 var MIN_MOST_USED_TERMS = 3;
46726 var DEFAULT_QUERY2 = {
46727 per_page: 10,
46728 orderby: "count",
46729 order: "desc",
46730 hide_empty: true,
46731 _fields: "id,name,count",
46732 context: "view"
46733 };
46734 function MostUsedTerms({ onSelect, taxonomy }) {
46735 const { _terms, showTerms } = (0, import_data139.useSelect)(
46736 (select6) => {
46737 const mostUsedTerms = select6(import_core_data88.store).getEntityRecords(
46738 "taxonomy",
46739 taxonomy.slug,
46740 DEFAULT_QUERY2
46741 );
46742 return {
46743 _terms: mostUsedTerms,
46744 showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS
46745 };
46746 },
46747 [taxonomy.slug]
46748 );
46749 if (!showTerms) {
46750 return null;
46751 }
46752 const terms = unescapeTerms(_terms);
46753 return /* @__PURE__ */ (0, import_jsx_runtime277.jsxs)("div", { className: "editor-post-taxonomies__flat-term-most-used", children: [
46754 /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(
46755 import_components149.BaseControl.VisualLabel,
46756 {
46757 as: "h3",
46758 className: "editor-post-taxonomies__flat-term-most-used-label",
46759 children: taxonomy.labels.most_used
46760 }
46761 ),
46762 /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(
46763 "ul",
46764 {
46765 role: "list",
46766 className: "editor-post-taxonomies__flat-term-most-used-list",
46767 children: terms.map((term) => /* @__PURE__ */ (0, import_jsx_runtime277.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(
46768 import_components149.Button,
46769 {
46770 __next40pxDefaultSize: true,
46771 variant: "link",
46772 onClick: () => onSelect(term),
46773 children: term.name
46774 }
46775 ) }, term.id))
46776 }
46777 )
46778 ] });
46779 }
46780
46781 // packages/editor/build-module/components/post-taxonomies/flat-term-selector.mjs
46782 var import_jsx_runtime278 = __toESM(require_jsx_runtime(), 1);
46783 var EMPTY_ARRAY7 = [];
46784 var MAX_TERMS_SUGGESTIONS = 100;
46785 var DEFAULT_QUERY3 = {
46786 per_page: MAX_TERMS_SUGGESTIONS,
46787 _fields: "id,name",
46788 context: "view"
46789 };
46790 var isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
46791 var termNamesToIds = (names, terms) => {
46792 return names.map(
46793 (termName) => terms.find((term) => isSameTermName(term.name, termName))?.id
46794 ).filter((id) => id !== void 0);
46795 };
46796 function FlatTermSelector({ slug }) {
46797 const [values, setValues] = (0, import_element122.useState)([]);
46798 const [search, setSearch] = (0, import_element122.useState)("");
46799 const debouncedSearch = (0, import_compose32.useDebounce)(setSearch, 500);
46800 const {
46801 terms,
46802 termIds,
46803 taxonomy,
46804 hasAssignAction,
46805 hasCreateAction,
46806 hasResolvedTerms
46807 } = (0, import_data140.useSelect)(
46808 (select6) => {
46809 const { getCurrentPost: getCurrentPost2, getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
46810 const { getEntityRecords, getEntityRecord, hasFinishedResolution } = select6(import_core_data89.store);
46811 const post2 = getCurrentPost2();
46812 const _taxonomy = getEntityRecord("root", "taxonomy", slug);
46813 const _termIds = _taxonomy ? getEditedPostAttribute2(_taxonomy.rest_base) : EMPTY_ARRAY7;
46814 const query = {
46815 ...DEFAULT_QUERY3,
46816 include: _termIds?.join(","),
46817 per_page: -1
46818 };
46819 return {
46820 hasCreateAction: _taxonomy ? post2._links?.["wp:action-create-" + _taxonomy.rest_base] ?? false : false,
46821 hasAssignAction: _taxonomy ? post2._links?.["wp:action-assign-" + _taxonomy.rest_base] ?? false : false,
46822 taxonomy: _taxonomy,
46823 termIds: _termIds,
46824 terms: _termIds?.length ? getEntityRecords("taxonomy", slug, query) : EMPTY_ARRAY7,
46825 hasResolvedTerms: hasFinishedResolution("getEntityRecords", [
46826 "taxonomy",
46827 slug,
46828 query
46829 ])
46830 };
46831 },
46832 [slug]
46833 );
46834 const { searchResults } = (0, import_data140.useSelect)(
46835 (select6) => {
46836 const { getEntityRecords } = select6(import_core_data89.store);
46837 return {
46838 searchResults: !!search ? getEntityRecords("taxonomy", slug, {
46839 ...DEFAULT_QUERY3,
46840 search
46841 }) : EMPTY_ARRAY7
46842 };
46843 },
46844 [search, slug]
46845 );
46846 (0, import_element122.useEffect)(() => {
46847 if (hasResolvedTerms) {
46848 const newValues = (terms ?? []).map(
46849 (term) => unescapeString(term.name)
46850 );
46851 setValues(newValues);
46852 }
46853 }, [terms, hasResolvedTerms]);
46854 const suggestions = (0, import_element122.useMemo)(() => {
46855 return (searchResults ?? []).map(
46856 (term) => unescapeString(term.name)
46857 );
46858 }, [searchResults]);
46859 const { editPost: editPost2 } = (0, import_data140.useDispatch)(store);
46860 const { saveEntityRecord } = (0, import_data140.useDispatch)(import_core_data89.store);
46861 const { createErrorNotice } = (0, import_data140.useDispatch)(import_notices23.store);
46862 if (!hasAssignAction) {
46863 return null;
46864 }
46865 async function findOrCreateTerm(term) {
46866 try {
46867 const newTerm = await saveEntityRecord("taxonomy", slug, term, {
46868 throwOnError: true
46869 });
46870 return unescapeTerm(newTerm);
46871 } catch (error) {
46872 if (error.code !== "term_exists") {
46873 throw error;
46874 }
46875 return {
46876 id: error.data.term_id,
46877 name: term.name
46878 };
46879 }
46880 }
46881 function onUpdateTerms(newTermIds) {
46882 editPost2({ [taxonomy.rest_base]: newTermIds });
46883 }
46884 function onChange(termNames) {
46885 const availableTerms = [
46886 ...terms ?? [],
46887 ...searchResults ?? []
46888 ];
46889 const uniqueTerms = termNames.reduce((acc, name2) => {
46890 if (!acc.some((n3) => n3.toLowerCase() === name2.toLowerCase())) {
46891 acc.push(name2);
46892 }
46893 return acc;
46894 }, []);
46895 const newTermNames = uniqueTerms.filter(
46896 (termName) => !availableTerms.find(
46897 (term) => isSameTermName(term.name, termName)
46898 )
46899 );
46900 setValues(uniqueTerms);
46901 if (newTermNames.length === 0) {
46902 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
46903 return;
46904 }
46905 if (!hasCreateAction) {
46906 return;
46907 }
46908 Promise.all(
46909 newTermNames.map(
46910 (termName) => findOrCreateTerm({ name: termName })
46911 )
46912 ).then((newTerms) => {
46913 const newAvailableTerms = availableTerms.concat(newTerms);
46914 onUpdateTerms(
46915 termNamesToIds(uniqueTerms, newAvailableTerms)
46916 );
46917 }).catch((error) => {
46918 createErrorNotice(error.message, {
46919 type: "snackbar"
46920 });
46921 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
46922 });
46923 }
46924 function appendTerm(newTerm) {
46925 if (termIds.includes(newTerm.id)) {
46926 return;
46927 }
46928 const newTermIds = [...termIds, newTerm.id];
46929 const defaultName = slug === "post_tag" ? (0, import_i18n170.__)("Tag") : (0, import_i18n170.__)("Term");
46930 const termAddedMessage = (0, import_i18n170.sprintf)(
46931 /* translators: %s: term name. */
46932 (0, import_i18n170._x)("%s added", "term"),
46933 taxonomy?.labels?.singular_name ?? defaultName
46934 );
46935 (0, import_a11y4.speak)(termAddedMessage, "assertive");
46936 onUpdateTerms(newTermIds);
46937 }
46938 const newTermLabel = taxonomy?.labels?.add_new_item ?? (slug === "post_tag" ? (0, import_i18n170.__)("Add Tag") : (0, import_i18n170.__)("Add Term"));
46939 const singularName = taxonomy?.labels?.singular_name ?? (slug === "post_tag" ? (0, import_i18n170.__)("Tag") : (0, import_i18n170.__)("Term"));
46940 const termAddedLabel = (0, import_i18n170.sprintf)(
46941 /* translators: %s: term name. */
46942 (0, import_i18n170._x)("%s added", "term"),
46943 singularName
46944 );
46945 const termRemovedLabel = (0, import_i18n170.sprintf)(
46946 /* translators: %s: term name. */
46947 (0, import_i18n170._x)("%s removed", "term"),
46948 singularName
46949 );
46950 const removeTermLabel = (0, import_i18n170.sprintf)(
46951 /* translators: %s: term name. */
46952 (0, import_i18n170._x)("Remove %s", "term"),
46953 singularName
46954 );
46955 return /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_components150.__experimentalVStack, { spacing: 4, children: [
46956 /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
46957 import_components150.FormTokenField,
46958 {
46959 __next40pxDefaultSize: true,
46960 value: values,
46961 suggestions,
46962 onChange,
46963 onInputChange: debouncedSearch,
46964 maxSuggestions: MAX_TERMS_SUGGESTIONS,
46965 label: newTermLabel,
46966 messages: {
46967 added: termAddedLabel,
46968 removed: termRemovedLabel,
46969 remove: removeTermLabel
46970 }
46971 }
46972 ),
46973 /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(MostUsedTerms, { taxonomy, onSelect: appendTerm })
46974 ] });
46975 }
46976 var flat_term_selector_default = (0, import_components150.withFilters)("editor.PostTaxonomyType")(FlatTermSelector);
46977
46978 // packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.mjs
46979 var import_jsx_runtime279 = __toESM(require_jsx_runtime(), 1);
46980 var TagsPanel = () => {
46981 const tagLabels = (0, import_data141.useSelect)((select6) => {
46982 const taxonomy = select6(import_core_data90.store).getTaxonomy("post_tag");
46983 return taxonomy?.labels;
46984 }, []);
46985 const addNewItem = tagLabels?.add_new_item ?? (0, import_i18n171.__)("Add tag");
46986 const tagLabel = tagLabels?.name ?? (0, import_i18n171.__)("Tags");
46987 const panelBodyTitle = [
46988 (0, import_i18n171.__)("Suggestion:"),
46989 /* @__PURE__ */ (0, import_jsx_runtime279.jsx)("span", { className: "editor-post-publish-panel__link", children: addNewItem }, "label")
46990 ];
46991 return /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(import_components151.PanelBody, { initialOpen: false, title: panelBodyTitle, children: [
46992 /* @__PURE__ */ (0, import_jsx_runtime279.jsx)("p", { children: (0, import_i18n171.sprintf)(
46993 // translators: %s is the taxonomy name (e.g., "Tags").
46994 (0, import_i18n171.__)(
46995 "%s help users and search engines navigate your site and find your content. Add a few keywords to describe your post."
46996 ),
46997 tagLabel
46998 ) }),
46999 /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(flat_term_selector_default, { slug: "post_tag" })
47000 ] });
47001 };
47002 var MaybeTagsPanel = () => {
47003 const { postHasTags, siteHasTags, isPostTypeSupported } = (0, import_data141.useSelect)(
47004 (select6) => {
47005 const postType2 = select6(store).getCurrentPostType();
47006 const tagsTaxonomy = select6(import_core_data90.store).getEntityRecord(
47007 "root",
47008 "taxonomy",
47009 "post_tag"
47010 );
47011 const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType2);
47012 const areTagsFetched = tagsTaxonomy !== void 0;
47013 const tags = tagsTaxonomy && select6(store).getEditedPostAttribute(
47014 tagsTaxonomy.rest_base
47015 );
47016 const siteTags = _isPostTypeSupported ? !!select6(import_core_data90.store).getEntityRecords(
47017 "taxonomy",
47018 "post_tag",
47019 { per_page: 1 }
47020 )?.length : false;
47021 return {
47022 postHasTags: !!tags?.length,
47023 siteHasTags: siteTags,
47024 isPostTypeSupported: areTagsFetched && _isPostTypeSupported
47025 };
47026 },
47027 []
47028 );
47029 const [hadTagsWhenOpeningThePanel] = (0, import_element123.useState)(postHasTags);
47030 if (!isPostTypeSupported || !siteHasTags) {
47031 return null;
47032 }
47033 if (!hadTagsWhenOpeningThePanel) {
47034 return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(TagsPanel, {});
47035 }
47036 return null;
47037 };
47038 var maybe_tags_panel_default = MaybeTagsPanel;
47039
47040 // packages/editor/build-module/components/post-publish-panel/maybe-post-format-panel.mjs
47041 var import_components152 = __toESM(require_components(), 1);
47042 var import_data142 = __toESM(require_data(), 1);
47043 var import_i18n172 = __toESM(require_i18n(), 1);
47044 var import_core_data91 = __toESM(require_core_data(), 1);
47045 var import_jsx_runtime280 = __toESM(require_jsx_runtime(), 1);
47046 var getSuggestion = (supportedFormats, suggestedPostFormat) => {
47047 const formats = POST_FORMATS.filter(
47048 (format6) => supportedFormats?.includes(format6.id)
47049 );
47050 return formats.find((format6) => format6.id === suggestedPostFormat);
47051 };
47052 var PostFormatSuggestion = ({
47053 suggestedPostFormat,
47054 suggestionText,
47055 onUpdatePostFormat
47056 }) => /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
47057 import_components152.Button,
47058 {
47059 __next40pxDefaultSize: true,
47060 variant: "link",
47061 onClick: () => onUpdatePostFormat(suggestedPostFormat),
47062 children: suggestionText
47063 }
47064 );
47065 function PostFormatPanel() {
47066 const { currentPostFormat, suggestion } = (0, import_data142.useSelect)((select6) => {
47067 const { getEditedPostAttribute: getEditedPostAttribute2, getSuggestedPostFormat: getSuggestedPostFormat2 } = select6(store);
47068 const supportedFormats = select6(import_core_data91.store).getThemeSupports().formats ?? [];
47069 return {
47070 currentPostFormat: getEditedPostAttribute2("format"),
47071 suggestion: getSuggestion(
47072 supportedFormats,
47073 getSuggestedPostFormat2()
47074 )
47075 };
47076 }, []);
47077 const { editPost: editPost2 } = (0, import_data142.useDispatch)(store);
47078 const onUpdatePostFormat = (format6) => editPost2({ format: format6 });
47079 const panelBodyTitle = [
47080 (0, import_i18n172.__)("Suggestion:"),
47081 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("span", { className: "editor-post-publish-panel__link", children: (0, import_i18n172.__)("Use a post format") }, "label")
47082 ];
47083 if (!suggestion || suggestion.id === currentPostFormat) {
47084 return null;
47085 }
47086 return /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(import_components152.PanelBody, { initialOpen: false, title: panelBodyTitle, children: [
47087 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("p", { children: (0, import_i18n172.__)(
47088 "Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling."
47089 ) }),
47090 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
47091 PostFormatSuggestion,
47092 {
47093 onUpdatePostFormat,
47094 suggestedPostFormat: suggestion.id,
47095 suggestionText: (0, import_i18n172.sprintf)(
47096 /* translators: %1s: post format */
47097 (0, import_i18n172.__)('Apply the "%1$s" format.'),
47098 suggestion.caption
47099 )
47100 }
47101 ) })
47102 ] });
47103 }
47104
47105 // packages/editor/build-module/components/post-publish-panel/maybe-category-panel.mjs
47106 var import_i18n174 = __toESM(require_i18n(), 1);
47107 var import_data144 = __toESM(require_data(), 1);
47108 var import_components154 = __toESM(require_components(), 1);
47109 var import_core_data93 = __toESM(require_core_data(), 1);
47110 var import_element125 = __toESM(require_element(), 1);
47111
47112 // packages/editor/build-module/components/post-taxonomies/hierarchical-term-selector.mjs
47113 var import_i18n173 = __toESM(require_i18n(), 1);
47114 var import_element124 = __toESM(require_element(), 1);
47115 var import_notices24 = __toESM(require_notices(), 1);
47116 var import_components153 = __toESM(require_components(), 1);
47117 var import_data143 = __toESM(require_data(), 1);
47118 var import_compose33 = __toESM(require_compose(), 1);
47119 var import_core_data92 = __toESM(require_core_data(), 1);
47120 var import_a11y5 = __toESM(require_a11y(), 1);
47121 var import_html_entities21 = __toESM(require_html_entities(), 1);
47122 var import_jsx_runtime281 = __toESM(require_jsx_runtime(), 1);
47123 var { normalizeTextString } = unlock(import_components153.privateApis);
47124 var { RECEIVE_INTERMEDIATE_RESULTS } = unlock(import_core_data92.privateApis);
47125 var DEFAULT_QUERY4 = {
47126 per_page: -1,
47127 orderby: "name",
47128 order: "asc",
47129 _fields: "id,name,parent",
47130 context: "view",
47131 [RECEIVE_INTERMEDIATE_RESULTS]: true
47132 };
47133 var MIN_TERMS_COUNT_FOR_FILTER = 8;
47134 var EMPTY_ARRAY8 = [];
47135 function sortBySelected(termsTree, terms) {
47136 const treeHasSelection = (termTree) => {
47137 if (terms.indexOf(termTree.id) !== -1) {
47138 return true;
47139 }
47140 if (void 0 === termTree.children) {
47141 return false;
47142 }
47143 return termTree.children.map(treeHasSelection).filter((child) => child).length > 0;
47144 };
47145 const termOrChildIsSelected = (termA, termB) => {
47146 const termASelected = treeHasSelection(termA);
47147 const termBSelected = treeHasSelection(termB);
47148 if (termASelected === termBSelected) {
47149 return 0;
47150 }
47151 if (termASelected && !termBSelected) {
47152 return -1;
47153 }
47154 if (!termASelected && termBSelected) {
47155 return 1;
47156 }
47157 return 0;
47158 };
47159 const newTermTree = [...termsTree];
47160 newTermTree.sort(termOrChildIsSelected);
47161 return newTermTree;
47162 }
47163 function findTerm(terms, parent, name2) {
47164 return terms.find((term) => {
47165 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name2.toLowerCase();
47166 });
47167 }
47168 function getFilterMatcher(filterValue) {
47169 const matchTermsForFilter = (originalTerm) => {
47170 if ("" === filterValue) {
47171 return originalTerm;
47172 }
47173 const term = { ...originalTerm };
47174 if (term.children.length > 0) {
47175 term.children = term.children.map(matchTermsForFilter).filter((child) => child);
47176 }
47177 if (-1 !== normalizeTextString(term.name).indexOf(
47178 normalizeTextString(filterValue)
47179 ) || term.children.length > 0) {
47180 return term;
47181 }
47182 return false;
47183 };
47184 return matchTermsForFilter;
47185 }
47186 function HierarchicalTermSelector({ slug }) {
47187 const [adding, setAdding] = (0, import_element124.useState)(false);
47188 const [formName, setFormName] = (0, import_element124.useState)("");
47189 const [formParent, setFormParent] = (0, import_element124.useState)("");
47190 const [showForm, setShowForm] = (0, import_element124.useState)(false);
47191 const [filterValue, setFilterValue] = (0, import_element124.useState)("");
47192 const [filteredTermsTree, setFilteredTermsTree] = (0, import_element124.useState)([]);
47193 const debouncedSpeak = (0, import_compose33.useDebounce)(import_a11y5.speak, 500);
47194 const {
47195 hasCreateAction,
47196 hasAssignAction,
47197 terms,
47198 loading,
47199 availableTerms,
47200 taxonomy
47201 } = (0, import_data143.useSelect)(
47202 (select6) => {
47203 const { getCurrentPost: getCurrentPost2, getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
47204 const { getEntityRecord, getEntityRecords, isResolving } = select6(import_core_data92.store);
47205 const _taxonomy = getEntityRecord("root", "taxonomy", slug);
47206 const post2 = getCurrentPost2();
47207 return {
47208 hasCreateAction: _taxonomy ? !!post2._links?.["wp:action-create-" + _taxonomy.rest_base] : false,
47209 hasAssignAction: _taxonomy ? !!post2._links?.["wp:action-assign-" + _taxonomy.rest_base] : false,
47210 terms: _taxonomy ? getEditedPostAttribute2(_taxonomy.rest_base) : EMPTY_ARRAY8,
47211 loading: isResolving("getEntityRecords", [
47212 "taxonomy",
47213 slug,
47214 DEFAULT_QUERY4
47215 ]),
47216 availableTerms: getEntityRecords("taxonomy", slug, DEFAULT_QUERY4) || EMPTY_ARRAY8,
47217 taxonomy: _taxonomy
47218 };
47219 },
47220 [slug]
47221 );
47222 const { editPost: editPost2 } = (0, import_data143.useDispatch)(store);
47223 const { saveEntityRecord } = (0, import_data143.useDispatch)(import_core_data92.store);
47224 const availableTermsTree = (0, import_element124.useMemo)(
47225 () => sortBySelected(buildTermsTree2(availableTerms), terms),
47226 // Remove `terms` from the dependency list to avoid reordering every time
47227 // checking or unchecking a term.
47228 [availableTerms]
47229 );
47230 const { createErrorNotice } = (0, import_data143.useDispatch)(import_notices24.store);
47231 if (!hasAssignAction) {
47232 return null;
47233 }
47234 const addTerm = (term) => {
47235 return saveEntityRecord("taxonomy", slug, term, {
47236 throwOnError: true
47237 });
47238 };
47239 const onUpdateTerms = (termIds) => {
47240 editPost2({ [taxonomy.rest_base]: termIds });
47241 };
47242 const onChange = (termId) => {
47243 const hasTerm = terms.includes(termId);
47244 const newTerms = hasTerm ? terms.filter((id) => id !== termId) : [...terms, termId];
47245 onUpdateTerms(newTerms);
47246 };
47247 const onChangeFormName = (value) => {
47248 setFormName(value);
47249 };
47250 const onChangeFormParent = (parentId) => {
47251 setFormParent(parentId);
47252 };
47253 const onToggleForm = () => {
47254 setShowForm(!showForm);
47255 };
47256 const onAddTerm = async (event) => {
47257 event.preventDefault();
47258 if (formName === "" || adding) {
47259 return;
47260 }
47261 const existingTerm = findTerm(availableTerms, formParent, formName);
47262 if (existingTerm) {
47263 if (!terms.some((term) => term === existingTerm.id)) {
47264 onUpdateTerms([...terms, existingTerm.id]);
47265 }
47266 setFormName("");
47267 setFormParent("");
47268 return;
47269 }
47270 setAdding(true);
47271 let newTerm;
47272 try {
47273 newTerm = await addTerm({
47274 name: formName,
47275 parent: formParent ? formParent : void 0
47276 });
47277 } catch (error) {
47278 createErrorNotice(error.message, {
47279 type: "snackbar"
47280 });
47281 return;
47282 }
47283 const defaultName = slug === "category" ? (0, import_i18n173.__)("Category") : (0, import_i18n173.__)("Term");
47284 const termAddedMessage = (0, import_i18n173.sprintf)(
47285 /* translators: %s: term name. */
47286 (0, import_i18n173._x)("%s added", "term"),
47287 taxonomy?.labels?.singular_name ?? defaultName
47288 );
47289 (0, import_a11y5.speak)(termAddedMessage, "assertive");
47290 setAdding(false);
47291 setFormName("");
47292 setFormParent("");
47293 onUpdateTerms([...terms, newTerm.id]);
47294 };
47295 const setFilter = (value) => {
47296 const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter((term) => term);
47297 const getResultCount = (termsTree) => {
47298 let count = 0;
47299 for (let i3 = 0; i3 < termsTree.length; i3++) {
47300 count++;
47301 if (void 0 !== termsTree[i3].children) {
47302 count += getResultCount(termsTree[i3].children);
47303 }
47304 }
47305 return count;
47306 };
47307 setFilterValue(value);
47308 setFilteredTermsTree(newFilteredTermsTree);
47309 const resultCount = getResultCount(newFilteredTermsTree);
47310 const resultsFoundMessage = (0, import_i18n173.sprintf)(
47311 /* translators: %d: number of results. */
47312 (0, import_i18n173._n)("%d result found.", "%d results found.", resultCount),
47313 resultCount
47314 );
47315 debouncedSpeak(resultsFoundMessage, "assertive");
47316 };
47317 const renderTerms = (renderedTerms) => {
47318 return renderedTerms.map((term) => {
47319 return /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(
47320 "div",
47321 {
47322 className: "editor-post-taxonomies__hierarchical-terms-choice",
47323 children: [
47324 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
47325 import_components153.CheckboxControl,
47326 {
47327 checked: terms.indexOf(term.id) !== -1,
47328 onChange: () => {
47329 const termId = parseInt(term.id, 10);
47330 onChange(termId);
47331 },
47332 label: (0, import_html_entities21.decodeEntities)(term.name)
47333 }
47334 ),
47335 !!term.children.length && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)("div", { className: "editor-post-taxonomies__hierarchical-terms-subchoices", children: renderTerms(term.children) })
47336 ]
47337 },
47338 term.id
47339 );
47340 });
47341 };
47342 const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => taxonomy?.labels?.[labelProperty] ?? (slug === "category" ? fallbackIsCategory : fallbackIsNotCategory);
47343 const newTermButtonLabel = labelWithFallback(
47344 "add_new_item",
47345 (0, import_i18n173.__)("Add Category"),
47346 (0, import_i18n173.__)("Add Term")
47347 );
47348 const newTermLabel = labelWithFallback(
47349 "new_item_name",
47350 (0, import_i18n173.__)("Add Category"),
47351 (0, import_i18n173.__)("Add Term")
47352 );
47353 const parentSelectLabel = labelWithFallback(
47354 "parent_item",
47355 (0, import_i18n173.__)("Parent Category"),
47356 (0, import_i18n173.__)("Parent Term")
47357 );
47358 const noParentOption = `\u2014 ${parentSelectLabel} \u2014`;
47359 const newTermSubmitLabel = newTermButtonLabel;
47360 const filterLabel = taxonomy?.labels?.search_items ?? (0, import_i18n173.__)("Search Terms");
47361 const groupLabel = taxonomy?.name ?? (0, import_i18n173.__)("Terms");
47362 const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
47363 return /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_components153.Flex, { direction: "column", gap: "4", children: [
47364 showFilter && !loading && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
47365 import_components153.SearchControl,
47366 {
47367 __next40pxDefaultSize: true,
47368 label: filterLabel,
47369 placeholder: filterLabel,
47370 value: filterValue,
47371 onChange: setFilter
47372 }
47373 ),
47374 loading && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
47375 import_components153.Flex,
47376 {
47377 justify: "center",
47378 style: {
47379 // Match SearchControl height to prevent layout shift.
47380 height: "40px"
47381 },
47382 children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components153.Spinner, {})
47383 }
47384 ),
47385 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
47386 "div",
47387 {
47388 className: "editor-post-taxonomies__hierarchical-terms-list",
47389 tabIndex: "0",
47390 role: "group",
47391 "aria-label": groupLabel,
47392 children: renderTerms(
47393 "" !== filterValue ? filteredTermsTree : availableTermsTree
47394 )
47395 }
47396 ),
47397 !loading && hasCreateAction && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components153.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
47398 import_components153.Button,
47399 {
47400 __next40pxDefaultSize: true,
47401 onClick: onToggleForm,
47402 className: "editor-post-taxonomies__hierarchical-terms-add",
47403 "aria-expanded": showForm,
47404 variant: "link",
47405 children: newTermButtonLabel
47406 }
47407 ) }),
47408 showForm && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)("form", { onSubmit: onAddTerm, children: /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_components153.Flex, { direction: "column", gap: "4", children: [
47409 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
47410 import_components153.TextControl,
47411 {
47412 __next40pxDefaultSize: true,
47413 className: "editor-post-taxonomies__hierarchical-terms-input",
47414 label: newTermLabel,
47415 value: formName,
47416 onChange: onChangeFormName,
47417 required: true
47418 }
47419 ),
47420 !!availableTerms.length && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
47421 import_components153.TreeSelect,
47422 {
47423 __next40pxDefaultSize: true,
47424 label: parentSelectLabel,
47425 noOptionLabel: noParentOption,
47426 onChange: onChangeFormParent,
47427 selectedId: formParent,
47428 tree: availableTermsTree
47429 }
47430 ),
47431 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(import_components153.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
47432 import_components153.Button,
47433 {
47434 __next40pxDefaultSize: true,
47435 variant: "secondary",
47436 type: "submit",
47437 className: "editor-post-taxonomies__hierarchical-terms-submit",
47438 children: newTermSubmitLabel
47439 }
47440 ) })
47441 ] }) })
47442 ] });
47443 }
47444 var hierarchical_term_selector_default = (0, import_components153.withFilters)("editor.PostTaxonomyType")(
47445 HierarchicalTermSelector
47446 );
47447
47448 // packages/editor/build-module/components/post-publish-panel/maybe-category-panel.mjs
47449 var import_jsx_runtime282 = __toESM(require_jsx_runtime(), 1);
47450 function MaybeCategoryPanel() {
47451 const { hasNoCategory, hasSiteCategories } = (0, import_data144.useSelect)((select6) => {
47452 const postType2 = select6(store).getCurrentPostType();
47453 const { canUser, getEntityRecord } = select6(import_core_data93.store);
47454 const categoriesTaxonomy = getEntityRecord(
47455 "root",
47456 "taxonomy",
47457 "category"
47458 );
47459 const defaultCategoryId = canUser("read", {
47460 kind: "root",
47461 name: "site"
47462 }) ? getEntityRecord("root", "site")?.default_category : void 0;
47463 const defaultCategory = defaultCategoryId ? getEntityRecord("taxonomy", "category", defaultCategoryId) : void 0;
47464 const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some((type) => type === postType2);
47465 const categories = categoriesTaxonomy && select6(store).getEditedPostAttribute(
47466 categoriesTaxonomy.rest_base
47467 );
47468 const siteCategories = postTypeSupportsCategories ? !!select6(import_core_data93.store).getEntityRecords("taxonomy", "category", {
47469 exclude: [defaultCategoryId],
47470 per_page: 1
47471 })?.length : false;
47472 const noCategory = !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]);
47473 return {
47474 hasNoCategory: noCategory,
47475 hasSiteCategories: siteCategories
47476 };
47477 }, []);
47478 const [shouldShowPanel, setShouldShowPanel] = (0, import_element125.useState)(false);
47479 (0, import_element125.useEffect)(() => {
47480 if (hasNoCategory) {
47481 setShouldShowPanel(true);
47482 }
47483 }, [hasNoCategory]);
47484 if (!shouldShowPanel || !hasSiteCategories) {
47485 return null;
47486 }
47487 const panelBodyTitle = [
47488 (0, import_i18n174.__)("Suggestion:"),
47489 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)("span", { className: "editor-post-publish-panel__link", children: (0, import_i18n174.__)("Assign a category") }, "label")
47490 ];
47491 return /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)(import_components154.PanelBody, { initialOpen: false, title: panelBodyTitle, children: [
47492 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)("p", { children: (0, import_i18n174.__)(
47493 "Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about."
47494 ) }),
47495 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(hierarchical_term_selector_default, { slug: "category" })
47496 ] });
47497 }
47498 var maybe_category_panel_default = MaybeCategoryPanel;
47499
47500 // packages/editor/build-module/components/post-publish-panel/maybe-upload-media.mjs
47501 var import_components155 = __toESM(require_components(), 1);
47502 var import_data145 = __toESM(require_data(), 1);
47503 var import_i18n175 = __toESM(require_i18n(), 1);
47504 var import_block_editor55 = __toESM(require_block_editor(), 1);
47505 var import_element126 = __toESM(require_element(), 1);
47506 var import_blob4 = __toESM(require_blob(), 1);
47507
47508 // packages/editor/build-module/components/post-publish-panel/media-util.mjs
47509 var import_url15 = __toESM(require_url(), 1);
47510 function generateUniqueBasenames(urls) {
47511 const basenames = /* @__PURE__ */ new Set();
47512 return Object.fromEntries(
47513 urls.map((url) => {
47514 const filename = (0, import_url15.getFilename)(url);
47515 let basename = "";
47516 if (filename) {
47517 const parts = filename.split(".");
47518 if (parts.length > 1) {
47519 parts.pop();
47520 }
47521 basename = parts.join(".");
47522 }
47523 if (!basename) {
47524 basename = v4_default();
47525 }
47526 if (basenames.has(basename)) {
47527 basename = `${basename}-${v4_default()}`;
47528 }
47529 basenames.add(basename);
47530 return [url, basename];
47531 })
47532 );
47533 }
47534 function fetchMedia(urls) {
47535 return Object.fromEntries(
47536 Object.entries(generateUniqueBasenames(urls)).map(
47537 ([url, basename]) => {
47538 const filePromise = window.fetch(url.includes("?") ? url : url + "?").then((response) => response.blob()).then((blob) => {
47539 return new File([blob], `${basename}.png`, {
47540 type: blob.type
47541 });
47542 });
47543 return [url, filePromise];
47544 }
47545 )
47546 );
47547 }
47548
47549 // packages/editor/build-module/components/post-publish-panel/maybe-upload-media.mjs
47550 var import_jsx_runtime283 = __toESM(require_jsx_runtime(), 1);
47551 function flattenBlocks(blocks) {
47552 const result = [];
47553 blocks.forEach((block) => {
47554 result.push(block);
47555 result.push(...flattenBlocks(block.innerBlocks));
47556 });
47557 return result;
47558 }
47559 function hasExternalMedia(block) {
47560 if (block.name === "core/image" || block.name === "core/cover") {
47561 return block.attributes.url && !block.attributes.id;
47562 }
47563 if (block.name === "core/media-text") {
47564 return block.attributes.mediaUrl && !block.attributes.mediaId;
47565 }
47566 return void 0;
47567 }
47568 function getMediaInfo(block) {
47569 if (block.name === "core/image" || block.name === "core/cover") {
47570 const { url, alt, id } = block.attributes;
47571 return { url, alt, id };
47572 }
47573 if (block.name === "core/media-text") {
47574 const { mediaUrl: url, mediaAlt: alt, mediaId: id } = block.attributes;
47575 return { url, alt, id };
47576 }
47577 return {};
47578 }
47579 function Image({ clientId, alt, url }) {
47580 const { selectBlock: selectBlock2 } = (0, import_data145.useDispatch)(import_block_editor55.store);
47581 return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
47582 import_components155.__unstableMotion.img,
47583 {
47584 tabIndex: 0,
47585 role: "button",
47586 "aria-label": (0, import_i18n175.__)("Select image block."),
47587 onClick: () => {
47588 selectBlock2(clientId);
47589 },
47590 onKeyDown: (event) => {
47591 if (event.key === "Enter" || event.key === " ") {
47592 selectBlock2(clientId);
47593 event.preventDefault();
47594 }
47595 },
47596 alt,
47597 src: url,
47598 animate: { opacity: 1 },
47599 exit: { opacity: 0, scale: 0 },
47600 style: {
47601 width: "32px",
47602 height: "32px",
47603 objectFit: "cover",
47604 borderRadius: "2px",
47605 cursor: "pointer"
47606 },
47607 whileHover: { scale: 1.08 }
47608 },
47609 clientId
47610 );
47611 }
47612 function MaybeUploadMediaPanel() {
47613 const [isUploading, setIsUploading] = (0, import_element126.useState)(false);
47614 const [isAnimating2, setIsAnimating] = (0, import_element126.useState)(false);
47615 const [hadUploadError, setHadUploadError] = (0, import_element126.useState)(false);
47616 const { editorBlocks, mediaUpload: mediaUpload2 } = (0, import_data145.useSelect)(
47617 (select6) => ({
47618 editorBlocks: select6(import_block_editor55.store).getBlocks(),
47619 mediaUpload: select6(import_block_editor55.store).getSettings().mediaUpload
47620 }),
47621 []
47622 );
47623 const blocksWithExternalMedia = flattenBlocks(editorBlocks).filter(
47624 (block) => hasExternalMedia(block)
47625 );
47626 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data145.useDispatch)(import_block_editor55.store);
47627 if (!mediaUpload2 || !blocksWithExternalMedia.length) {
47628 return null;
47629 }
47630 const panelBodyTitle = [
47631 (0, import_i18n175.__)("Suggestion:"),
47632 /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("span", { className: "editor-post-publish-panel__link", children: (0, import_i18n175.__)("External media") }, "label")
47633 ];
47634 function updateBlockWithUploadedMedia(block, media) {
47635 if (block.name === "core/image" || block.name === "core/cover") {
47636 updateBlockAttributes2(block.clientId, {
47637 id: media.id,
47638 url: media.url
47639 });
47640 }
47641 if (block.name === "core/media-text") {
47642 updateBlockAttributes2(block.clientId, {
47643 mediaId: media.id,
47644 mediaUrl: media.url
47645 });
47646 }
47647 }
47648 function uploadImages() {
47649 setIsUploading(true);
47650 setHadUploadError(false);
47651 const mediaUrls = new Set(
47652 blocksWithExternalMedia.map((block) => {
47653 const { url } = getMediaInfo(block);
47654 return url;
47655 })
47656 );
47657 const uploadPromises = Object.fromEntries(
47658 Object.entries(fetchMedia([...mediaUrls])).map(
47659 ([url, filePromise]) => {
47660 const uploadPromise = filePromise.then(
47661 (blob) => new Promise((resolve, reject) => {
47662 mediaUpload2({
47663 filesList: [blob],
47664 onFileChange: ([media]) => {
47665 if ((0, import_blob4.isBlobURL)(media.url)) {
47666 return;
47667 }
47668 resolve(media);
47669 },
47670 onError() {
47671 reject();
47672 }
47673 });
47674 })
47675 );
47676 return [url, uploadPromise];
47677 }
47678 )
47679 );
47680 Promise.allSettled(
47681 blocksWithExternalMedia.map((block) => {
47682 const { url } = getMediaInfo(block);
47683 return uploadPromises[url].then(
47684 (media) => updateBlockWithUploadedMedia(block, media)
47685 ).then(() => setIsAnimating(true)).catch(() => setHadUploadError(true));
47686 })
47687 ).finally(() => {
47688 setIsUploading(false);
47689 });
47690 }
47691 return /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)(import_components155.PanelBody, { initialOpen: true, title: panelBodyTitle, children: [
47692 /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("p", { children: (0, import_i18n175.__)(
47693 "Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly."
47694 ) }),
47695 /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)(
47696 "div",
47697 {
47698 style: {
47699 display: "inline-flex",
47700 flexWrap: "wrap",
47701 gap: "8px"
47702 },
47703 children: [
47704 /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
47705 import_components155.__unstableAnimatePresence,
47706 {
47707 onExitComplete: () => setIsAnimating(false),
47708 children: blocksWithExternalMedia.map((block) => {
47709 const { url, alt } = getMediaInfo(block);
47710 return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
47711 Image,
47712 {
47713 clientId: block.clientId,
47714 url,
47715 alt
47716 },
47717 block.clientId
47718 );
47719 })
47720 }
47721 ),
47722 isUploading || isAnimating2 ? /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(import_components155.Spinner, {}) : /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
47723 import_components155.Button,
47724 {
47725 size: "compact",
47726 variant: "primary",
47727 onClick: uploadImages,
47728 children: (0, import_i18n175._x)("Upload", "verb")
47729 }
47730 )
47731 ]
47732 }
47733 ),
47734 hadUploadError && /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("p", { children: (0, import_i18n175.__)("Upload failed, try again.") })
47735 ] });
47736 }
47737
47738 // packages/editor/build-module/components/post-publish-panel/prepublish.mjs
47739 var import_jsx_runtime284 = __toESM(require_jsx_runtime(), 1);
47740 function PostPublishPanelPrepublish({ children }) {
47741 const {
47742 isBeingScheduled,
47743 isRequestingSiteIcon,
47744 hasPublishAction,
47745 siteIconUrl,
47746 siteTitle,
47747 siteHome
47748 } = (0, import_data146.useSelect)((select6) => {
47749 const { getCurrentPost: getCurrentPost2, isEditedPostBeingScheduled: isEditedPostBeingScheduled2 } = select6(store);
47750 const { getEntityRecord, isResolving } = select6(import_core_data94.store);
47751 const siteData = getEntityRecord("root", "__unstableBase", void 0) || {};
47752 return {
47753 hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false,
47754 isBeingScheduled: isEditedPostBeingScheduled2(),
47755 isRequestingSiteIcon: isResolving("getEntityRecord", [
47756 "root",
47757 "__unstableBase",
47758 void 0
47759 ]),
47760 siteIconUrl: siteData.site_icon_url,
47761 siteTitle: siteData.name,
47762 siteHome: siteData.home && (0, import_url16.filterURLForDisplay)(siteData.home)
47763 };
47764 }, []);
47765 let siteIcon = /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(import_components156.Icon, { className: "components-site-icon", size: "36px", icon: wordpress_default });
47766 if (siteIconUrl) {
47767 siteIcon = /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
47768 "img",
47769 {
47770 alt: (0, import_i18n176.__)("Site Icon"),
47771 className: "components-site-icon",
47772 src: siteIconUrl
47773 }
47774 );
47775 }
47776 if (isRequestingSiteIcon) {
47777 siteIcon = null;
47778 }
47779 let prePublishTitle, prePublishBodyText;
47780 if (!hasPublishAction) {
47781 prePublishTitle = (0, import_i18n176.__)("Are you ready to submit for review?");
47782 prePublishBodyText = (0, import_i18n176.__)(
47783 "Your work will be reviewed and then approved."
47784 );
47785 } else if (isBeingScheduled) {
47786 prePublishTitle = (0, import_i18n176.__)("Are you ready to schedule?");
47787 prePublishBodyText = (0, import_i18n176.__)(
47788 "Your work will be published at the specified date and time."
47789 );
47790 } else {
47791 prePublishTitle = (0, import_i18n176.__)("Are you ready to publish?");
47792 prePublishBodyText = (0, import_i18n176.__)(
47793 "Double-check your settings before publishing."
47794 );
47795 }
47796 return /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)("div", { className: "editor-post-publish-panel__prepublish", children: [
47797 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("strong", { children: prePublishTitle }) }),
47798 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("p", { children: prePublishBodyText }),
47799 /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)("div", { className: "components-site-card", children: [
47800 siteIcon,
47801 /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)("div", { className: "components-site-info", children: [
47802 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("span", { className: "components-site-name", children: (0, import_html_entities22.decodeEntities)(siteTitle) || (0, import_i18n176.__)("(Untitled)") }),
47803 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("span", { className: "components-site-home", children: siteHome })
47804 ] })
47805 ] }),
47806 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(MaybeUploadMediaPanel, {}),
47807 hasPublishAction && /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(import_jsx_runtime284.Fragment, { children: [
47808 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
47809 import_components156.PanelBody,
47810 {
47811 initialOpen: false,
47812 title: [
47813 (0, import_i18n176.__)("Visibility:"),
47814 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
47815 "span",
47816 {
47817 className: "editor-post-publish-panel__link",
47818 children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(PostVisibilityLabel, {})
47819 },
47820 "label"
47821 )
47822 ],
47823 children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(PostVisibility, {})
47824 }
47825 ),
47826 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
47827 import_components156.PanelBody,
47828 {
47829 initialOpen: false,
47830 title: [
47831 (0, import_i18n176.__)("Publish:"),
47832 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
47833 "span",
47834 {
47835 className: "editor-post-publish-panel__link",
47836 children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(PostScheduleLabel, {})
47837 },
47838 "label"
47839 )
47840 ],
47841 children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(PostSchedule, {})
47842 }
47843 )
47844 ] }),
47845 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(PostFormatPanel, {}),
47846 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(maybe_tags_panel_default, {}),
47847 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(maybe_category_panel_default, {}),
47848 children
47849 ] });
47850 }
47851 var prepublish_default = PostPublishPanelPrepublish;
47852
47853 // packages/editor/build-module/components/post-publish-panel/postpublish.mjs
47854 var import_components157 = __toESM(require_components(), 1);
47855 var import_i18n177 = __toESM(require_i18n(), 1);
47856 var import_element127 = __toESM(require_element(), 1);
47857 var import_data147 = __toESM(require_data(), 1);
47858 var import_url17 = __toESM(require_url(), 1);
47859 var import_html_entities23 = __toESM(require_html_entities(), 1);
47860 var import_compose34 = __toESM(require_compose(), 1);
47861 var import_core_data95 = __toESM(require_core_data(), 1);
47862 var import_jsx_runtime285 = __toESM(require_jsx_runtime(), 1);
47863 var POSTNAME = "%postname%";
47864 var PAGENAME = "%pagename%";
47865 var getFuturePostUrl = (post2) => {
47866 const { slug } = post2;
47867 if (post2.permalink_template.includes(POSTNAME)) {
47868 return post2.permalink_template.replace(POSTNAME, slug);
47869 }
47870 if (post2.permalink_template.includes(PAGENAME)) {
47871 return post2.permalink_template.replace(PAGENAME, slug);
47872 }
47873 return post2.permalink_template;
47874 };
47875 function CopyButton2({ text }) {
47876 const [showCopyConfirmation, setShowCopyConfirmation] = (0, import_element127.useState)(false);
47877 const timeoutIdRef = (0, import_element127.useRef)();
47878 const ref = (0, import_compose34.useCopyToClipboard)(text, () => {
47879 setShowCopyConfirmation(true);
47880 if (timeoutIdRef.current) {
47881 clearTimeout(timeoutIdRef.current);
47882 }
47883 timeoutIdRef.current = setTimeout(() => {
47884 setShowCopyConfirmation(false);
47885 }, 4e3);
47886 });
47887 (0, import_element127.useEffect)(() => {
47888 return () => {
47889 if (timeoutIdRef.current) {
47890 clearTimeout(timeoutIdRef.current);
47891 }
47892 };
47893 }, []);
47894 return /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(import_components157.Button, { __next40pxDefaultSize: true, variant: "secondary", ref, children: showCopyConfirmation ? (0, import_i18n177.__)("Copied!") : (0, import_i18n177.__)("Copy") });
47895 }
47896 function PostPublishPanelPostpublish({
47897 focusOnMount,
47898 children
47899 }) {
47900 const { post: post2, postType: postType2, isScheduled } = (0, import_data147.useSelect)((select6) => {
47901 const {
47902 getEditedPostAttribute: getEditedPostAttribute2,
47903 getCurrentPost: getCurrentPost2,
47904 isCurrentPostScheduled: isCurrentPostScheduled2
47905 } = select6(store);
47906 const { getPostType } = select6(import_core_data95.store);
47907 return {
47908 post: getCurrentPost2(),
47909 postType: getPostType(getEditedPostAttribute2("type")),
47910 isScheduled: isCurrentPostScheduled2()
47911 };
47912 }, []);
47913 const postLabel = postType2?.labels?.singular_name;
47914 const viewPostLabel = postType2?.labels?.view_item;
47915 const addNewPostLabel = postType2?.labels?.add_new_item;
47916 const link = post2.status === "future" ? getFuturePostUrl(post2) : post2.link;
47917 const addLink = (0, import_url17.addQueryArgs)("post-new.php", {
47918 post_type: post2.type
47919 });
47920 const postLinkRef = (0, import_element127.useCallback)(
47921 (node) => {
47922 if (focusOnMount && node) {
47923 node.focus();
47924 }
47925 },
47926 [focusOnMount]
47927 );
47928 const postPublishNonLinkHeader = isScheduled ? /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(import_jsx_runtime285.Fragment, { children: [
47929 (0, import_i18n177.__)("is now scheduled. It will go live on"),
47930 " ",
47931 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(PostScheduleLabel, {}),
47932 "."
47933 ] }) : (0, import_i18n177.__)("is now live.");
47934 return /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)("div", { className: "post-publish-panel__postpublish", children: [
47935 /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(import_components157.PanelBody, { className: "post-publish-panel__postpublish-header", children: [
47936 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(import_components157.ExternalLink, { ref: postLinkRef, href: link, children: (0, import_html_entities23.decodeEntities)(post2.title) || (0, import_i18n177.__)("(no title)") }),
47937 " ",
47938 postPublishNonLinkHeader
47939 ] }),
47940 /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(import_components157.PanelBody, { children: [
47941 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)("p", { className: "post-publish-panel__postpublish-subheader", children: /* @__PURE__ */ (0, import_jsx_runtime285.jsx)("strong", { children: (0, import_i18n177.__)("What\u2019s next?") }) }),
47942 /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)("div", { className: "post-publish-panel__postpublish-post-address-container", children: [
47943 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
47944 import_components157.TextControl,
47945 {
47946 __next40pxDefaultSize: true,
47947 className: "post-publish-panel__postpublish-post-address",
47948 readOnly: true,
47949 label: (0, import_i18n177.sprintf)(
47950 /* translators: %s: post type singular name */
47951 (0, import_i18n177.__)("%s address"),
47952 postLabel
47953 ),
47954 value: (0, import_url17.safeDecodeURIComponent)(link),
47955 onFocus: (event) => event.target.select()
47956 }
47957 ),
47958 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)("div", { className: "post-publish-panel__postpublish-post-address__copy-button-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(CopyButton2, { text: link }) })
47959 ] }),
47960 /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)("div", { className: "post-publish-panel__postpublish-buttons", children: [
47961 !isScheduled && /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(
47962 import_components157.Button,
47963 {
47964 variant: "primary",
47965 href: link,
47966 __next40pxDefaultSize: true,
47967 icon: external_default,
47968 iconPosition: "right",
47969 target: "_blank",
47970 children: [
47971 viewPostLabel,
47972 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(import_components157.VisuallyHidden, {
47973 as: "span",
47974 /* translators: accessibility text */
47975 children: (0, import_i18n177.__)("(opens in a new tab)")
47976 })
47977 ]
47978 }
47979 ),
47980 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
47981 import_components157.Button,
47982 {
47983 variant: isScheduled ? "primary" : "secondary",
47984 __next40pxDefaultSize: true,
47985 href: addLink,
47986 children: addNewPostLabel
47987 }
47988 )
47989 ] })
47990 ] }),
47991 children
47992 ] });
47993 }
47994
47995 // packages/editor/build-module/components/post-publish-panel/index.mjs
47996 var import_jsx_runtime286 = __toESM(require_jsx_runtime(), 1);
47997 var PostPublishPanel = class extends import_element128.Component {
47998 constructor() {
47999 super(...arguments);
48000 this.onSubmit = this.onSubmit.bind(this);
48001 this.cancelButtonNode = (0, import_element128.createRef)();
48002 }
48003 componentDidMount() {
48004 this.timeoutID = setTimeout(() => {
48005 this.cancelButtonNode.current.focus();
48006 }, 0);
48007 }
48008 componentWillUnmount() {
48009 clearTimeout(this.timeoutID);
48010 }
48011 componentDidUpdate(prevProps) {
48012 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty || this.props.currentPostId !== prevProps.currentPostId) {
48013 this.props.onClose();
48014 }
48015 }
48016 onSubmit() {
48017 const { onClose, hasPublishAction, isPostTypeViewable } = this.props;
48018 if (!hasPublishAction || !isPostTypeViewable) {
48019 onClose();
48020 }
48021 }
48022 render() {
48023 const {
48024 forceIsDirty,
48025 isBeingScheduled,
48026 isPublished,
48027 isPublishSidebarEnabled: isPublishSidebarEnabled2,
48028 isScheduled,
48029 isSaving,
48030 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2,
48031 onClose,
48032 onTogglePublishSidebar,
48033 PostPublishExtension,
48034 PrePublishExtension,
48035 currentPostId,
48036 ...additionalProps
48037 } = this.props;
48038 const {
48039 hasPublishAction,
48040 isDirty,
48041 isPostTypeViewable,
48042 ...propsForPanel
48043 } = additionalProps;
48044 const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled;
48045 const isPrePublish = !isPublishedOrScheduled && !isSaving;
48046 const isPostPublish = isPublishedOrScheduled && !isSaving;
48047 return /* @__PURE__ */ (0, import_jsx_runtime286.jsxs)("div", { className: "editor-post-publish-panel", ...propsForPanel, children: [
48048 /* @__PURE__ */ (0, import_jsx_runtime286.jsx)("div", { className: "editor-post-publish-panel__header", children: isPostPublish ? /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(
48049 import_components158.Button,
48050 {
48051 size: "compact",
48052 onClick: onClose,
48053 icon: close_small_default,
48054 label: (0, import_i18n178.__)("Close panel")
48055 }
48056 ) : /* @__PURE__ */ (0, import_jsx_runtime286.jsxs)(import_jsx_runtime286.Fragment, { children: [
48057 /* @__PURE__ */ (0, import_jsx_runtime286.jsx)("div", { className: "editor-post-publish-panel__header-cancel-button", children: /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(
48058 import_components158.Button,
48059 {
48060 ref: this.cancelButtonNode,
48061 accessibleWhenDisabled: true,
48062 disabled: isSavingNonPostEntityChanges2,
48063 onClick: onClose,
48064 variant: "secondary",
48065 size: "compact",
48066 children: (0, import_i18n178.__)("Cancel")
48067 }
48068 ) }),
48069 /* @__PURE__ */ (0, import_jsx_runtime286.jsx)("div", { className: "editor-post-publish-panel__header-publish-button", children: /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(
48070 post_publish_button_default,
48071 {
48072 onSubmit: this.onSubmit,
48073 forceIsDirty
48074 }
48075 ) })
48076 ] }) }),
48077 /* @__PURE__ */ (0, import_jsx_runtime286.jsxs)("div", { className: "editor-post-publish-panel__content", children: [
48078 isPrePublish && /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(prepublish_default, { children: PrePublishExtension && /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(PrePublishExtension, {}) }),
48079 isPostPublish && /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(PostPublishPanelPostpublish, { focusOnMount: true, children: PostPublishExtension && /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(PostPublishExtension, {}) }),
48080 isSaving && /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(import_components158.Spinner, {})
48081 ] }),
48082 /* @__PURE__ */ (0, import_jsx_runtime286.jsx)("div", { className: "editor-post-publish-panel__footer", children: /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(
48083 import_components158.CheckboxControl,
48084 {
48085 label: (0, import_i18n178.__)("Always show pre-publish checks."),
48086 checked: isPublishSidebarEnabled2,
48087 onChange: onTogglePublishSidebar
48088 }
48089 ) })
48090 ] });
48091 }
48092 };
48093 var post_publish_panel_default = (0, import_compose35.compose)([
48094 (0, import_data148.withSelect)((select6) => {
48095 const { getPostType } = select6(import_core_data96.store);
48096 const {
48097 getCurrentPost: getCurrentPost2,
48098 getCurrentPostId: getCurrentPostId2,
48099 getEditedPostAttribute: getEditedPostAttribute2,
48100 isCurrentPostPublished: isCurrentPostPublished2,
48101 isCurrentPostScheduled: isCurrentPostScheduled2,
48102 isEditedPostBeingScheduled: isEditedPostBeingScheduled2,
48103 isEditedPostDirty: isEditedPostDirty2,
48104 isAutosavingPost: isAutosavingPost2,
48105 isSavingPost: isSavingPost2,
48106 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2
48107 } = select6(store);
48108 const { isPublishSidebarEnabled: isPublishSidebarEnabled2 } = select6(store);
48109 const postType2 = getPostType(getEditedPostAttribute2("type"));
48110 return {
48111 hasPublishAction: getCurrentPost2()._links?.["wp:action-publish"] ?? false,
48112 isPostTypeViewable: postType2?.viewable,
48113 isBeingScheduled: isEditedPostBeingScheduled2(),
48114 isDirty: isEditedPostDirty2(),
48115 isPublished: isCurrentPostPublished2(),
48116 isPublishSidebarEnabled: isPublishSidebarEnabled2(),
48117 isSaving: isSavingPost2() && !isAutosavingPost2(),
48118 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges2(),
48119 isScheduled: isCurrentPostScheduled2(),
48120 currentPostId: getCurrentPostId2()
48121 };
48122 }),
48123 (0, import_data148.withDispatch)((dispatch7, { isPublishSidebarEnabled: isPublishSidebarEnabled2 }) => {
48124 const { disablePublishSidebar: disablePublishSidebar2, enablePublishSidebar: enablePublishSidebar2 } = dispatch7(store);
48125 return {
48126 onTogglePublishSidebar: () => {
48127 if (isPublishSidebarEnabled2) {
48128 disablePublishSidebar2();
48129 } else {
48130 enablePublishSidebar2();
48131 }
48132 }
48133 };
48134 }),
48135 import_components158.withFocusReturn,
48136 import_components158.withConstrainedTabbing
48137 ])(PostPublishPanel);
48138
48139 // packages/editor/build-module/components/post-saved-state/index.mjs
48140 var import_components161 = __toESM(require_components(), 1);
48141 var import_compose37 = __toESM(require_compose(), 1);
48142 var import_data152 = __toESM(require_data(), 1);
48143 var import_element130 = __toESM(require_element(), 1);
48144 var import_i18n181 = __toESM(require_i18n(), 1);
48145 var import_keycodes11 = __toESM(require_keycodes(), 1);
48146 var import_preferences14 = __toESM(require_preferences(), 1);
48147
48148 // packages/editor/build-module/components/post-status/index.mjs
48149 var import_components160 = __toESM(require_components(), 1);
48150 var import_i18n180 = __toESM(require_i18n(), 1);
48151 var import_data151 = __toESM(require_data(), 1);
48152 var import_element129 = __toESM(require_element(), 1);
48153 var import_core_data97 = __toESM(require_core_data(), 1);
48154 var import_block_editor56 = __toESM(require_block_editor(), 1);
48155 var import_compose36 = __toESM(require_compose(), 1);
48156
48157 // packages/editor/build-module/components/post-sticky/index.mjs
48158 var import_i18n179 = __toESM(require_i18n(), 1);
48159 var import_components159 = __toESM(require_components(), 1);
48160 var import_data150 = __toESM(require_data(), 1);
48161
48162 // packages/editor/build-module/components/post-sticky/check.mjs
48163 var import_data149 = __toESM(require_data(), 1);
48164 function PostStickyCheck({ children }) {
48165 const { hasStickyAction, postType: postType2 } = (0, import_data149.useSelect)((select6) => {
48166 const post2 = select6(store).getCurrentPost();
48167 return {
48168 hasStickyAction: post2._links?.["wp:action-sticky"] ?? false,
48169 postType: select6(store).getCurrentPostType()
48170 };
48171 }, []);
48172 if (postType2 !== "post" || !hasStickyAction) {
48173 return null;
48174 }
48175 return children;
48176 }
48177
48178 // packages/editor/build-module/components/post-sticky/index.mjs
48179 var import_jsx_runtime287 = __toESM(require_jsx_runtime(), 1);
48180 function PostSticky() {
48181 const postSticky = (0, import_data150.useSelect)((select6) => {
48182 return select6(store).getEditedPostAttribute("sticky") ?? false;
48183 }, []);
48184 const { editPost: editPost2 } = (0, import_data150.useDispatch)(store);
48185 return /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(PostStickyCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
48186 import_components159.CheckboxControl,
48187 {
48188 className: "editor-post-sticky__checkbox-control",
48189 label: (0, import_i18n179.__)("Sticky"),
48190 help: (0, import_i18n179.__)("Pin this post to the top of the blog."),
48191 checked: postSticky,
48192 onChange: () => editPost2({ sticky: !postSticky })
48193 }
48194 ) });
48195 }
48196
48197 // packages/editor/build-module/components/post-status/index.mjs
48198 var import_jsx_runtime288 = __toESM(require_jsx_runtime(), 1);
48199 var postStatusesInfo = {
48200 "auto-draft": { label: (0, import_i18n180.__)("Draft"), icon: drafts_default },
48201 draft: { label: (0, import_i18n180.__)("Draft"), icon: drafts_default },
48202 pending: { label: (0, import_i18n180.__)("Pending"), icon: pending_default },
48203 private: { label: (0, import_i18n180.__)("Private"), icon: not_allowed_default },
48204 future: { label: (0, import_i18n180.__)("Scheduled"), icon: scheduled_default },
48205 publish: { label: (0, import_i18n180.__)("Published"), icon: published_default }
48206 };
48207 var STATUS_OPTIONS = [
48208 {
48209 label: (0, import_i18n180.__)("Draft"),
48210 value: "draft",
48211 description: (0, import_i18n180.__)("Not ready to publish.")
48212 },
48213 {
48214 label: (0, import_i18n180.__)("Pending"),
48215 value: "pending",
48216 description: (0, import_i18n180.__)("Waiting for review before publishing.")
48217 },
48218 {
48219 label: (0, import_i18n180.__)("Private"),
48220 value: "private",
48221 description: (0, import_i18n180.__)("Only visible to site admins and editors.")
48222 },
48223 {
48224 label: (0, import_i18n180.__)("Scheduled"),
48225 value: "future",
48226 description: (0, import_i18n180.__)("Publish automatically on a chosen date.")
48227 },
48228 {
48229 label: (0, import_i18n180.__)("Published"),
48230 value: "publish",
48231 description: (0, import_i18n180.__)("Visible to everyone.")
48232 }
48233 ];
48234 function PostStatus() {
48235 const { status, date, password, postId: postId2, postType: postType2, canEdit } = (0, import_data151.useSelect)(
48236 (select6) => {
48237 const {
48238 getEditedPostAttribute: getEditedPostAttribute2,
48239 getCurrentPostId: getCurrentPostId2,
48240 getCurrentPostType: getCurrentPostType2,
48241 getCurrentPost: getCurrentPost2
48242 } = select6(store);
48243 return {
48244 status: getEditedPostAttribute2("status"),
48245 date: getEditedPostAttribute2("date"),
48246 password: getEditedPostAttribute2("password"),
48247 postId: getCurrentPostId2(),
48248 postType: getCurrentPostType2(),
48249 canEdit: getCurrentPost2()._links?.["wp:action-publish"] ?? false
48250 };
48251 },
48252 []
48253 );
48254 const [showPassword, setShowPassword] = (0, import_element129.useState)(!!password);
48255 const passwordInputId = (0, import_compose36.useInstanceId)(
48256 PostStatus,
48257 "editor-change-status__password-input"
48258 );
48259 const { editEntityRecord } = (0, import_data151.useDispatch)(import_core_data97.store);
48260 const [popoverAnchor, setPopoverAnchor] = (0, import_element129.useState)(null);
48261 const popoverProps = (0, import_element129.useMemo)(
48262 () => ({
48263 // Anchor the popover to the middle of the entire row so that it doesn't
48264 // move around when the label changes.
48265 anchor: popoverAnchor,
48266 "aria-label": (0, import_i18n180.__)("Status & visibility"),
48267 headerTitle: (0, import_i18n180.__)("Status & visibility"),
48268 placement: "left-start",
48269 offset: 36,
48270 shift: true
48271 }),
48272 [popoverAnchor]
48273 );
48274 if (DESIGN_POST_TYPES.includes(postType2)) {
48275 return null;
48276 }
48277 const updatePost2 = ({
48278 status: newStatus = status,
48279 password: newPassword = password,
48280 date: newDate = date
48281 }) => {
48282 editEntityRecord("postType", postType2, postId2, {
48283 status: newStatus,
48284 date: newDate,
48285 password: newPassword
48286 });
48287 };
48288 const handleTogglePassword = (value) => {
48289 setShowPassword(value);
48290 if (!value) {
48291 updatePost2({ password: "" });
48292 }
48293 };
48294 const handleStatus = (value) => {
48295 let newDate = date;
48296 let newPassword = password;
48297 if (status === "future" && new Date(date) > /* @__PURE__ */ new Date()) {
48298 newDate = null;
48299 }
48300 if (value === "private" && password) {
48301 newPassword = "";
48302 }
48303 updatePost2({
48304 status: value,
48305 date: newDate,
48306 password: newPassword
48307 });
48308 };
48309 return /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(post_panel_row_default, { label: (0, import_i18n180.__)("Status"), ref: setPopoverAnchor, children: canEdit ? /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
48310 import_components160.Dropdown,
48311 {
48312 className: "editor-post-status",
48313 contentClassName: "editor-change-status__content",
48314 popoverProps,
48315 focusOnMount: true,
48316 renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
48317 import_components160.Button,
48318 {
48319 className: "editor-post-status__toggle",
48320 variant: "tertiary",
48321 size: "compact",
48322 onClick: onToggle,
48323 icon: postStatusesInfo[status]?.icon,
48324 "aria-label": (0, import_i18n180.sprintf)(
48325 // translators: %s: Current post status.
48326 (0, import_i18n180.__)("Change status: %s"),
48327 postStatusesInfo[status]?.label
48328 ),
48329 "aria-expanded": isOpen,
48330 children: postStatusesInfo[status]?.label
48331 }
48332 ),
48333 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime288.jsxs)(import_jsx_runtime288.Fragment, { children: [
48334 /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
48335 import_block_editor56.__experimentalInspectorPopoverHeader,
48336 {
48337 title: (0, import_i18n180.__)("Status & visibility"),
48338 onClose
48339 }
48340 ),
48341 /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
48342 "form",
48343 {
48344 onSubmit: (event) => {
48345 event.preventDefault();
48346 onClose();
48347 },
48348 children: /* @__PURE__ */ (0, import_jsx_runtime288.jsxs)(import_components160.__experimentalVStack, { spacing: 4, children: [
48349 /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
48350 import_components160.RadioControl,
48351 {
48352 className: "editor-change-status__options",
48353 hideLabelFromVision: true,
48354 label: (0, import_i18n180.__)("Status"),
48355 options: STATUS_OPTIONS,
48356 onChange: handleStatus,
48357 selected: status === "auto-draft" ? "draft" : status
48358 }
48359 ),
48360 status === "future" && /* @__PURE__ */ (0, import_jsx_runtime288.jsx)("div", { className: "editor-change-status__publish-date-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
48361 PrivatePostSchedule,
48362 {
48363 showPopoverHeaderActions: false,
48364 isCompact: true
48365 }
48366 ) }),
48367 status !== "private" && /* @__PURE__ */ (0, import_jsx_runtime288.jsxs)(
48368 import_components160.__experimentalVStack,
48369 {
48370 as: "fieldset",
48371 spacing: 4,
48372 className: "editor-change-status__password-fieldset",
48373 children: [
48374 /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
48375 import_components160.CheckboxControl,
48376 {
48377 label: (0, import_i18n180.__)(
48378 "Password protected"
48379 ),
48380 help: (0, import_i18n180.__)(
48381 "Only visible to those who know the password."
48382 ),
48383 checked: showPassword,
48384 onChange: handleTogglePassword
48385 }
48386 ),
48387 showPassword && /* @__PURE__ */ (0, import_jsx_runtime288.jsx)("div", { className: "editor-change-status__password-input", children: /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
48388 import_components160.TextControl,
48389 {
48390 label: (0, import_i18n180.__)(
48391 "Password"
48392 ),
48393 onChange: (value) => updatePost2({
48394 password: value
48395 }),
48396 value: password,
48397 placeholder: (0, import_i18n180.__)(
48398 "Use a secure password"
48399 ),
48400 type: "text",
48401 id: passwordInputId,
48402 __next40pxDefaultSize: true,
48403 maxLength: 255
48404 }
48405 ) })
48406 ]
48407 }
48408 ),
48409 /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(PostSticky, {})
48410 ] })
48411 }
48412 )
48413 ] })
48414 }
48415 ) : /* @__PURE__ */ (0, import_jsx_runtime288.jsx)("div", { className: "editor-post-status is-read-only", children: postStatusesInfo[status]?.label }) });
48416 }
48417
48418 // packages/editor/build-module/components/post-saved-state/index.mjs
48419 var import_jsx_runtime289 = __toESM(require_jsx_runtime(), 1);
48420 function PostSavedState({ forceIsDirty }) {
48421 const [forceSavedMessage, setForceSavedMessage] = (0, import_element130.useState)(false);
48422 const isLargeViewport = (0, import_compose37.useViewportMatch)("small");
48423 const {
48424 isAutosaving,
48425 isDirty,
48426 isNew,
48427 isPublished,
48428 isSaveable,
48429 isSaving,
48430 isScheduled,
48431 hasPublishAction,
48432 showIconLabels,
48433 postStatus,
48434 postStatusHasChanged,
48435 postType: postType2
48436 } = (0, import_data152.useSelect)(
48437 (select6) => {
48438 const {
48439 isEditedPostNew: isEditedPostNew2,
48440 isCurrentPostPublished: isCurrentPostPublished2,
48441 isCurrentPostScheduled: isCurrentPostScheduled2,
48442 isEditedPostDirty: isEditedPostDirty2,
48443 isSavingPost: isSavingPost2,
48444 isEditedPostSaveable: isEditedPostSaveable2,
48445 getCurrentPost: getCurrentPost2,
48446 isAutosavingPost: isAutosavingPost2,
48447 getEditedPostAttribute: getEditedPostAttribute2,
48448 getPostEdits: getPostEdits2
48449 } = select6(store);
48450 const { get } = select6(import_preferences14.store);
48451 return {
48452 isAutosaving: isAutosavingPost2(),
48453 isDirty: forceIsDirty || isEditedPostDirty2(),
48454 isNew: isEditedPostNew2(),
48455 isPublished: isCurrentPostPublished2(),
48456 isSaving: isSavingPost2(),
48457 isSaveable: isEditedPostSaveable2(),
48458 isScheduled: isCurrentPostScheduled2(),
48459 hasPublishAction: getCurrentPost2()?._links?.["wp:action-publish"] ?? false,
48460 showIconLabels: get("core", "showIconLabels"),
48461 postStatus: getEditedPostAttribute2("status"),
48462 postStatusHasChanged: !!getPostEdits2()?.status,
48463 postType: select6(store).getCurrentPostType()
48464 };
48465 },
48466 [forceIsDirty]
48467 );
48468 const isPending = postStatus === "pending";
48469 const { savePost: savePost2 } = (0, import_data152.useDispatch)(store);
48470 const wasSaving = (0, import_compose37.usePrevious)(isSaving);
48471 (0, import_element130.useEffect)(() => {
48472 let timeoutId;
48473 if (wasSaving && !isSaving) {
48474 setForceSavedMessage(true);
48475 timeoutId = setTimeout(() => {
48476 setForceSavedMessage(false);
48477 }, 1e3);
48478 }
48479 return () => clearTimeout(timeoutId);
48480 }, [isSaving]);
48481 if (postType2 === ATTACHMENT_POST_TYPE) {
48482 return null;
48483 }
48484 if (!hasPublishAction && isPending) {
48485 return null;
48486 }
48487 const isIneligibleStatus = !["pending", "draft", "auto-draft"].includes(postStatus) && STATUS_OPTIONS.map(({ value }) => value).includes(postStatus);
48488 if (isPublished || isScheduled || isIneligibleStatus || postStatusHasChanged && ["pending", "draft"].includes(postStatus)) {
48489 return null;
48490 }
48491 const label = isPending ? (0, import_i18n181.__)("Save as pending") : (0, import_i18n181.__)("Save draft");
48492 const shortLabel = (0, import_i18n181.__)("Save");
48493 const isSaved = forceSavedMessage || !isNew && !isDirty;
48494 const isSavedState = isSaving || isSaved;
48495 const isDisabled = isSaving || isSaved || !isSaveable;
48496 let text;
48497 if (isSaving) {
48498 text = isAutosaving ? (0, import_i18n181.__)("Autosaving") : (0, import_i18n181.__)("Saving");
48499 } else if (isSaved) {
48500 text = (0, import_i18n181.__)("Saved");
48501 } else if (isLargeViewport) {
48502 text = label;
48503 } else if (showIconLabels) {
48504 text = shortLabel;
48505 }
48506 return /* @__PURE__ */ (0, import_jsx_runtime289.jsxs)(
48507 import_components161.Button,
48508 {
48509 className: isSaveable || isSaving ? clsx_default({
48510 "editor-post-save-draft": !isSavedState,
48511 "editor-post-saved-state": isSavedState,
48512 "is-saving": isSaving,
48513 "is-autosaving": isAutosaving,
48514 "is-saved": isSaved,
48515 [(0, import_components161.__unstableGetAnimateClassName)({
48516 type: "loading"
48517 })]: isSaving
48518 }) : void 0,
48519 onClick: isDisabled ? void 0 : () => savePost2(),
48520 shortcut: isDisabled ? void 0 : import_keycodes11.displayShortcut.primary("s"),
48521 variant: "tertiary",
48522 size: "compact",
48523 icon: isLargeViewport ? void 0 : cloud_upload_default,
48524 label: text || label,
48525 "aria-disabled": isDisabled,
48526 children: [
48527 isSavedState && /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(icon_default, { icon: isSaved ? check_default : cloud_default }),
48528 text
48529 ]
48530 }
48531 );
48532 }
48533
48534 // packages/editor/build-module/components/post-schedule/check.mjs
48535 var import_data153 = __toESM(require_data(), 1);
48536 function PostScheduleCheck({ children }) {
48537 const hasPublishAction = (0, import_data153.useSelect)((select6) => {
48538 return select6(store).getCurrentPost()._links?.["wp:action-publish"] ?? false;
48539 }, []);
48540 if (!hasPublishAction) {
48541 return null;
48542 }
48543 return children;
48544 }
48545
48546 // packages/editor/build-module/components/post-schedule/panel.mjs
48547 var import_components162 = __toESM(require_components(), 1);
48548 var import_i18n182 = __toESM(require_i18n(), 1);
48549 var import_element131 = __toESM(require_element(), 1);
48550 var import_data154 = __toESM(require_data(), 1);
48551 var import_jsx_runtime290 = __toESM(require_jsx_runtime(), 1);
48552 function PostSchedulePanel() {
48553 const [popoverAnchor, setPopoverAnchor] = (0, import_element131.useState)(null);
48554 const postType2 = (0, import_data154.useSelect)(
48555 (select6) => select6(store).getCurrentPostType(),
48556 []
48557 );
48558 const popoverProps = (0, import_element131.useMemo)(
48559 () => ({
48560 // Anchor the popover to the middle of the entire row so that it doesn't
48561 // move around when the label changes.
48562 anchor: popoverAnchor,
48563 "aria-label": (0, import_i18n182.__)("Change publish date"),
48564 placement: "left-start",
48565 offset: 36,
48566 shift: true
48567 }),
48568 [popoverAnchor]
48569 );
48570 const label = usePostScheduleLabel();
48571 const fullLabel = usePostScheduleLabel({ full: true });
48572 if (DESIGN_POST_TYPES.includes(postType2)) {
48573 return null;
48574 }
48575 return /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(PostScheduleCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(post_panel_row_default, { label: (0, import_i18n182.__)("Publish"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
48576 import_components162.Dropdown,
48577 {
48578 popoverProps,
48579 focusOnMount: true,
48580 className: "editor-post-schedule__panel-dropdown",
48581 contentClassName: "editor-post-schedule__dialog",
48582 renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(
48583 import_components162.Button,
48584 {
48585 size: "compact",
48586 className: "editor-post-schedule__dialog-toggle",
48587 variant: "tertiary",
48588 tooltipPosition: "middle left",
48589 onClick: onToggle,
48590 "aria-label": (0, import_i18n182.sprintf)(
48591 // translators: %s: Current post date.
48592 (0, import_i18n182.__)("Change date: %s"),
48593 label
48594 ),
48595 label: fullLabel,
48596 showTooltip: label !== fullLabel,
48597 "aria-expanded": isOpen,
48598 children: label
48599 }
48600 ),
48601 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(PostSchedule, { onClose })
48602 }
48603 ) }) });
48604 }
48605
48606 // packages/editor/build-module/components/post-switch-to-draft-button/index.mjs
48607 var import_components163 = __toESM(require_components(), 1);
48608 var import_i18n183 = __toESM(require_i18n(), 1);
48609 var import_data155 = __toESM(require_data(), 1);
48610 var import_element132 = __toESM(require_element(), 1);
48611 var import_deprecated11 = __toESM(require_deprecated(), 1);
48612 var import_jsx_runtime291 = __toESM(require_jsx_runtime(), 1);
48613 function PostSwitchToDraftButton() {
48614 (0, import_deprecated11.default)("wp.editor.PostSwitchToDraftButton", {
48615 since: "6.7",
48616 version: "6.9"
48617 });
48618 const [showConfirmDialog, setShowConfirmDialog] = (0, import_element132.useState)(false);
48619 const { editPost: editPost2, savePost: savePost2 } = (0, import_data155.useDispatch)(store);
48620 const { isSaving, isPublished, isScheduled } = (0, import_data155.useSelect)((select6) => {
48621 const { isSavingPost: isSavingPost2, isCurrentPostPublished: isCurrentPostPublished2, isCurrentPostScheduled: isCurrentPostScheduled2 } = select6(store);
48622 return {
48623 isSaving: isSavingPost2(),
48624 isPublished: isCurrentPostPublished2(),
48625 isScheduled: isCurrentPostScheduled2()
48626 };
48627 }, []);
48628 const isDisabled = isSaving || !isPublished && !isScheduled;
48629 let alertMessage;
48630 let confirmButtonText;
48631 if (isPublished) {
48632 alertMessage = (0, import_i18n183.__)("Are you sure you want to unpublish this post?");
48633 confirmButtonText = (0, import_i18n183.__)("Unpublish");
48634 } else if (isScheduled) {
48635 alertMessage = (0, import_i18n183.__)("Are you sure you want to unschedule this post?");
48636 confirmButtonText = (0, import_i18n183.__)("Unschedule");
48637 }
48638 const handleConfirm = () => {
48639 setShowConfirmDialog(false);
48640 editPost2({ status: "draft" });
48641 savePost2();
48642 };
48643 return /* @__PURE__ */ (0, import_jsx_runtime291.jsxs)(import_jsx_runtime291.Fragment, { children: [
48644 /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(
48645 import_components163.Button,
48646 {
48647 __next40pxDefaultSize: true,
48648 className: "editor-post-switch-to-draft",
48649 onClick: () => {
48650 if (!isDisabled) {
48651 setShowConfirmDialog(true);
48652 }
48653 },
48654 "aria-disabled": isDisabled,
48655 variant: "secondary",
48656 style: { flexGrow: "1", justifyContent: "center" },
48657 children: (0, import_i18n183.__)("Switch to draft")
48658 }
48659 ),
48660 /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(
48661 import_components163.__experimentalConfirmDialog,
48662 {
48663 isOpen: showConfirmDialog,
48664 onConfirm: handleConfirm,
48665 onCancel: () => setShowConfirmDialog(false),
48666 confirmButtonText,
48667 children: alertMessage
48668 }
48669 )
48670 ] });
48671 }
48672
48673 // packages/editor/build-module/components/post-sync-status/index.mjs
48674 var import_data156 = __toESM(require_data(), 1);
48675 var import_i18n184 = __toESM(require_i18n(), 1);
48676 var import_jsx_runtime292 = __toESM(require_jsx_runtime(), 1);
48677 function PostSyncStatus() {
48678 const { syncStatus, postType: postType2 } = (0, import_data156.useSelect)((select6) => {
48679 const { getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
48680 const meta2 = getEditedPostAttribute2("meta");
48681 const currentSyncStatus = meta2?.wp_pattern_sync_status === "unsynced" ? "unsynced" : getEditedPostAttribute2("wp_pattern_sync_status");
48682 return {
48683 syncStatus: currentSyncStatus,
48684 postType: getEditedPostAttribute2("type")
48685 };
48686 });
48687 if (postType2 !== "wp_block") {
48688 return null;
48689 }
48690 return /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(post_panel_row_default, { label: (0, import_i18n184.__)("Sync status"), children: /* @__PURE__ */ (0, import_jsx_runtime292.jsx)("div", { className: "editor-post-sync-status__value", children: syncStatus === "unsynced" ? (0, import_i18n184._x)("Not synced", "pattern (singular)") : (0, import_i18n184._x)("Synced", "pattern (singular)") }) });
48691 }
48692
48693 // packages/editor/build-module/components/post-taxonomies/index.mjs
48694 var import_element133 = __toESM(require_element(), 1);
48695 var import_data157 = __toESM(require_data(), 1);
48696 var import_core_data98 = __toESM(require_core_data(), 1);
48697 var import_jsx_runtime293 = __toESM(require_jsx_runtime(), 1);
48698 var identity2 = (x2) => x2;
48699 function PostTaxonomies({ taxonomyWrapper = identity2 }) {
48700 const { postType: postType2, taxonomies } = (0, import_data157.useSelect)((select6) => {
48701 return {
48702 postType: select6(store).getCurrentPostType(),
48703 taxonomies: select6(import_core_data98.store).getEntityRecords(
48704 "root",
48705 "taxonomy",
48706 { per_page: -1 }
48707 )
48708 };
48709 }, []);
48710 const visibleTaxonomies = (taxonomies ?? []).filter(
48711 (taxonomy) => (
48712 // In some circumstances .visibility can end up as undefined so optional chaining operator required.
48713 // https://github.com/WordPress/gutenberg/issues/40326
48714 taxonomy.types.includes(postType2) && taxonomy.visibility?.show_ui
48715 )
48716 );
48717 return visibleTaxonomies.map((taxonomy) => {
48718 const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector_default : flat_term_selector_default;
48719 return /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(import_element133.Fragment, { children: taxonomyWrapper(
48720 /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(TaxonomyComponent, { slug: taxonomy.slug }),
48721 taxonomy
48722 ) }, `taxonomy-${taxonomy.slug}`);
48723 });
48724 }
48725 var post_taxonomies_default = PostTaxonomies;
48726
48727 // packages/editor/build-module/components/post-taxonomies/check.mjs
48728 var import_data158 = __toESM(require_data(), 1);
48729 var import_core_data99 = __toESM(require_core_data(), 1);
48730 function PostTaxonomiesCheck({ children }) {
48731 const hasTaxonomies = (0, import_data158.useSelect)((select6) => {
48732 const postType2 = select6(store).getCurrentPostType();
48733 const taxonomies = select6(import_core_data99.store).getEntityRecords(
48734 "root",
48735 "taxonomy",
48736 { per_page: -1 }
48737 );
48738 return taxonomies?.some(
48739 (taxonomy) => taxonomy.types.includes(postType2)
48740 );
48741 }, []);
48742 if (!hasTaxonomies) {
48743 return null;
48744 }
48745 return children;
48746 }
48747
48748 // packages/editor/build-module/components/post-taxonomies/panel.mjs
48749 var import_components164 = __toESM(require_components(), 1);
48750 var import_data159 = __toESM(require_data(), 1);
48751 var import_jsx_runtime294 = __toESM(require_jsx_runtime(), 1);
48752 function TaxonomyPanel({ taxonomy, children }) {
48753 const slug = taxonomy?.slug;
48754 const panelName = slug ? `taxonomy-panel-${slug}` : "";
48755 const { isEnabled, isOpened } = (0, import_data159.useSelect)(
48756 (select6) => {
48757 const { isEditorPanelEnabled: isEditorPanelEnabled2, isEditorPanelOpened: isEditorPanelOpened2 } = select6(store);
48758 return {
48759 isEnabled: slug ? isEditorPanelEnabled2(panelName) : false,
48760 isOpened: slug ? isEditorPanelOpened2(panelName) : false
48761 };
48762 },
48763 [panelName, slug]
48764 );
48765 const { toggleEditorPanelOpened: toggleEditorPanelOpened2 } = (0, import_data159.useDispatch)(store);
48766 if (!isEnabled) {
48767 return null;
48768 }
48769 const taxonomyMenuName = taxonomy?.labels?.menu_name;
48770 if (!taxonomyMenuName) {
48771 return null;
48772 }
48773 return /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(
48774 import_components164.PanelBody,
48775 {
48776 title: taxonomyMenuName,
48777 opened: isOpened,
48778 onToggle: () => toggleEditorPanelOpened2(panelName),
48779 children
48780 }
48781 );
48782 }
48783 function PostTaxonomies2() {
48784 return /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(PostTaxonomiesCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(
48785 post_taxonomies_default,
48786 {
48787 taxonomyWrapper: (content, taxonomy) => {
48788 return /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(TaxonomyPanel, { taxonomy, children: content });
48789 }
48790 }
48791 ) });
48792 }
48793
48794 // packages/editor/build-module/components/post-text-editor/index.mjs
48795 var import_react_autosize_textarea = __toESM(require_lib(), 1);
48796 var import_i18n185 = __toESM(require_i18n(), 1);
48797 var import_core_data100 = __toESM(require_core_data(), 1);
48798 var import_element134 = __toESM(require_element(), 1);
48799 var import_blocks27 = __toESM(require_blocks(), 1);
48800 var import_data160 = __toESM(require_data(), 1);
48801 var import_compose38 = __toESM(require_compose(), 1);
48802 var import_components165 = __toESM(require_components(), 1);
48803 var import_jsx_runtime295 = __toESM(require_jsx_runtime(), 1);
48804 function PostTextEditor() {
48805 const instanceId = (0, import_compose38.useInstanceId)(PostTextEditor);
48806 const { content, blocks, type, id } = (0, import_data160.useSelect)((select6) => {
48807 const { getEditedEntityRecord } = select6(import_core_data100.store);
48808 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select6(store);
48809 const _type = getCurrentPostType2();
48810 const _id = getCurrentPostId2();
48811 const editedRecord = getEditedEntityRecord("postType", _type, _id);
48812 return {
48813 content: editedRecord?.content,
48814 blocks: editedRecord?.blocks,
48815 type: _type,
48816 id: _id
48817 };
48818 }, []);
48819 const { editEntityRecord } = (0, import_data160.useDispatch)(import_core_data100.store);
48820 const value = (0, import_element134.useMemo)(() => {
48821 if (content instanceof Function) {
48822 return content({ blocks });
48823 } else if (blocks) {
48824 return (0, import_blocks27.__unstableSerializeAndClean)(blocks);
48825 }
48826 return content;
48827 }, [content, blocks]);
48828 return /* @__PURE__ */ (0, import_jsx_runtime295.jsxs)(import_jsx_runtime295.Fragment, { children: [
48829 /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(
48830 import_components165.VisuallyHidden,
48831 {
48832 as: "label",
48833 htmlFor: `post-content-${instanceId}`,
48834 children: (0, import_i18n185.__)("Type text or HTML")
48835 }
48836 ),
48837 /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(
48838 import_react_autosize_textarea.default,
48839 {
48840 autoComplete: "off",
48841 dir: "auto",
48842 value,
48843 onChange: (event) => {
48844 editEntityRecord("postType", type, id, {
48845 content: event.target.value,
48846 blocks: void 0,
48847 selection: void 0
48848 });
48849 },
48850 className: "editor-post-text-editor",
48851 id: `post-content-${instanceId}`,
48852 placeholder: (0, import_i18n185.__)("Start writing with text or HTML")
48853 }
48854 )
48855 ] });
48856 }
48857
48858 // packages/editor/build-module/components/post-title/index.mjs
48859 var import_i18n186 = __toESM(require_i18n(), 1);
48860 var import_element136 = __toESM(require_element(), 1);
48861 var import_html_entities24 = __toESM(require_html_entities(), 1);
48862 var import_data163 = __toESM(require_data(), 1);
48863 var import_block_editor57 = __toESM(require_block_editor(), 1);
48864 var import_keycodes12 = __toESM(require_keycodes(), 1);
48865 var import_blocks28 = __toESM(require_blocks(), 1);
48866 var import_rich_text3 = __toESM(require_rich_text(), 1);
48867 var import_compose39 = __toESM(require_compose(), 1);
48868 var import_dom3 = __toESM(require_dom(), 1);
48869
48870 // packages/editor/build-module/components/post-title/constants.mjs
48871 var DEFAULT_CLASSNAMES = "wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text";
48872 var REGEXP_NEWLINES = /[\r\n]+/g;
48873
48874 // packages/editor/build-module/components/post-title/use-post-title-focus.mjs
48875 var import_element135 = __toESM(require_element(), 1);
48876 var import_data161 = __toESM(require_data(), 1);
48877 function usePostTitleFocus(forwardedRef) {
48878 const ref = (0, import_element135.useRef)();
48879 const { isCleanNewPost: isCleanNewPost2 } = (0, import_data161.useSelect)((select6) => {
48880 const { isCleanNewPost: _isCleanNewPost } = select6(store);
48881 return {
48882 isCleanNewPost: _isCleanNewPost()
48883 };
48884 }, []);
48885 (0, import_element135.useImperativeHandle)(forwardedRef, () => ({
48886 focus: () => {
48887 ref?.current?.focus();
48888 }
48889 }));
48890 (0, import_element135.useEffect)(() => {
48891 if (!ref.current) {
48892 return;
48893 }
48894 const { defaultView } = ref.current.ownerDocument;
48895 const { name: name2, parent } = defaultView;
48896 const ownerDocument = name2 === "editor-canvas" ? parent.document : defaultView.document;
48897 const { activeElement, body } = ownerDocument;
48898 if (isCleanNewPost2 && (!activeElement || body === activeElement)) {
48899 ref.current.focus();
48900 }
48901 }, [isCleanNewPost2]);
48902 return { ref };
48903 }
48904
48905 // packages/editor/build-module/components/post-title/use-post-title.mjs
48906 var import_data162 = __toESM(require_data(), 1);
48907 function usePostTitle() {
48908 const { editPost: editPost2 } = (0, import_data162.useDispatch)(store);
48909 const { title } = (0, import_data162.useSelect)((select6) => {
48910 const { getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
48911 return {
48912 title: getEditedPostAttribute2("title")
48913 };
48914 }, []);
48915 function updateTitle(newTitle) {
48916 editPost2({ title: newTitle });
48917 }
48918 return { title, setTitle: updateTitle };
48919 }
48920
48921 // packages/editor/build-module/components/post-title/index.mjs
48922 var import_jsx_runtime296 = __toESM(require_jsx_runtime(), 1);
48923 var { useRichText } = unlock(import_rich_text3.privateApis);
48924 var PostTitle = (0, import_element136.forwardRef)((_, forwardedRef) => {
48925 const { placeholder, isEditingContentOnlySection, isPreview } = (0, import_data163.useSelect)(
48926 (select6) => {
48927 const { getSettings: getSettings10, getEditedContentOnlySection } = unlock(
48928 select6(import_block_editor57.store)
48929 );
48930 const { titlePlaceholder, isPreviewMode } = getSettings10();
48931 return {
48932 placeholder: titlePlaceholder,
48933 isEditingContentOnlySection: !!getEditedContentOnlySection(),
48934 isPreview: isPreviewMode
48935 };
48936 },
48937 []
48938 );
48939 const [isSelected, setIsSelected] = (0, import_element136.useState)(false);
48940 const { ref: focusRef } = usePostTitleFocus(forwardedRef);
48941 const { title, setTitle: onUpdate } = usePostTitle();
48942 const [selection, setSelection] = (0, import_element136.useState)({});
48943 const { clearSelectedBlock: clearSelectedBlock2, insertBlocks: insertBlocks2, insertDefaultBlock: insertDefaultBlock2 } = (0, import_data163.useDispatch)(import_block_editor57.store);
48944 const decodedPlaceholder = (0, import_html_entities24.decodeEntities)(placeholder) || (0, import_i18n186.__)("Add title");
48945 const {
48946 value,
48947 onChange,
48948 ref: richTextRef
48949 } = useRichText({
48950 value: title,
48951 onChange(newValue) {
48952 onUpdate(newValue.replace(REGEXP_NEWLINES, " "));
48953 },
48954 placeholder: decodedPlaceholder,
48955 selectionStart: selection.start,
48956 selectionEnd: selection.end,
48957 onSelectionChange(newStart, newEnd) {
48958 setSelection((sel) => {
48959 const { start: start2, end } = sel;
48960 if (start2 === newStart && end === newEnd) {
48961 return sel;
48962 }
48963 return {
48964 start: newStart,
48965 end: newEnd
48966 };
48967 });
48968 },
48969 __unstableDisableFormats: false
48970 });
48971 function onInsertBlockAfter(blocks) {
48972 insertBlocks2(blocks, 0);
48973 }
48974 function onSelect() {
48975 setIsSelected(true);
48976 clearSelectedBlock2();
48977 }
48978 function onUnselect() {
48979 setIsSelected(false);
48980 setSelection({});
48981 }
48982 function onEnterPress() {
48983 insertDefaultBlock2(void 0, void 0, 0);
48984 }
48985 function onKeyDown(event) {
48986 if (event.keyCode === import_keycodes12.ENTER) {
48987 event.preventDefault();
48988 onEnterPress();
48989 }
48990 }
48991 function onPaste(event) {
48992 const clipboardData = event.clipboardData;
48993 let plainText = "";
48994 let html = "";
48995 try {
48996 plainText = clipboardData.getData("text/plain");
48997 html = clipboardData.getData("text/html");
48998 } catch (error) {
48999 return;
49000 }
49001 const content = (0, import_blocks28.pasteHandler)({
49002 HTML: html,
49003 plainText
49004 });
49005 event.preventDefault();
49006 if (!content.length) {
49007 return;
49008 }
49009 if (typeof content !== "string") {
49010 const [firstBlock] = content;
49011 if (!title && (firstBlock.name === "core/heading" || firstBlock.name === "core/paragraph")) {
49012 const contentNoHTML = (0, import_dom3.__unstableStripHTML)(
49013 firstBlock.attributes.content
49014 );
49015 onUpdate(contentNoHTML);
49016 onInsertBlockAfter(content.slice(1));
49017 } else {
49018 onInsertBlockAfter(content);
49019 }
49020 } else {
49021 const contentNoHTML = (0, import_dom3.__unstableStripHTML)(content);
49022 onChange((0, import_rich_text3.insert)(value, (0, import_rich_text3.create)({ html: contentNoHTML })));
49023 }
49024 }
49025 const className = clsx_default(DEFAULT_CLASSNAMES, {
49026 "is-selected": isSelected
49027 });
49028 const style = isEditingContentOnlySection ? { opacity: 0.2 } : void 0;
49029 return (
49030 /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
49031 /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(
49032 "h1",
49033 {
49034 ref: (0, import_compose39.useMergeRefs)([richTextRef, focusRef]),
49035 contentEditable: !isEditingContentOnlySection && !isPreview,
49036 className,
49037 "aria-label": decodedPlaceholder,
49038 role: "textbox",
49039 "aria-multiline": "true",
49040 onFocus: onSelect,
49041 onBlur: onUnselect,
49042 onKeyDown,
49043 onPaste,
49044 style
49045 }
49046 )
49047 );
49048 });
49049 var post_title_default = (0, import_element136.forwardRef)((_, forwardedRef) => /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(post_type_support_check_default, { supportKeys: "title", children: /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(PostTitle, { ref: forwardedRef }) }));
49050
49051 // packages/editor/build-module/components/post-title/post-title-raw.mjs
49052 var import_components166 = __toESM(require_components(), 1);
49053 var import_i18n187 = __toESM(require_i18n(), 1);
49054 var import_html_entities25 = __toESM(require_html_entities(), 1);
49055 var import_data164 = __toESM(require_data(), 1);
49056 var import_block_editor58 = __toESM(require_block_editor(), 1);
49057 var import_element137 = __toESM(require_element(), 1);
49058 var import_jsx_runtime297 = __toESM(require_jsx_runtime(), 1);
49059 function PostTitleRaw(_, forwardedRef) {
49060 const { placeholder } = (0, import_data164.useSelect)((select6) => {
49061 const { getSettings: getSettings10 } = select6(import_block_editor58.store);
49062 const { titlePlaceholder } = getSettings10();
49063 return {
49064 placeholder: titlePlaceholder
49065 };
49066 }, []);
49067 const [isSelected, setIsSelected] = (0, import_element137.useState)(false);
49068 const { title, setTitle: onUpdate } = usePostTitle();
49069 const { ref: focusRef } = usePostTitleFocus(forwardedRef);
49070 function onChange(value) {
49071 onUpdate(value.replace(REGEXP_NEWLINES, " "));
49072 }
49073 function onSelect() {
49074 setIsSelected(true);
49075 }
49076 function onUnselect() {
49077 setIsSelected(false);
49078 }
49079 const className = clsx_default(DEFAULT_CLASSNAMES, {
49080 "is-selected": isSelected,
49081 "is-raw-text": true
49082 });
49083 const decodedPlaceholder = (0, import_html_entities25.decodeEntities)(placeholder) || (0, import_i18n187.__)("Add title");
49084 return /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(
49085 import_components166.TextareaControl,
49086 {
49087 ref: focusRef,
49088 value: title,
49089 onChange,
49090 onFocus: onSelect,
49091 onBlur: onUnselect,
49092 label: placeholder,
49093 className,
49094 placeholder: decodedPlaceholder,
49095 hideLabelFromVision: true,
49096 autoComplete: "off",
49097 dir: "auto",
49098 rows: 1
49099 }
49100 );
49101 }
49102 var post_title_raw_default = (0, import_element137.forwardRef)(PostTitleRaw);
49103
49104 // packages/editor/build-module/components/post-trash/index.mjs
49105 var import_i18n188 = __toESM(require_i18n(), 1);
49106 var import_components167 = __toESM(require_components(), 1);
49107 var import_data166 = __toESM(require_data(), 1);
49108 var import_element138 = __toESM(require_element(), 1);
49109
49110 // packages/editor/build-module/components/post-trash/check.mjs
49111 var import_data165 = __toESM(require_data(), 1);
49112 var import_core_data101 = __toESM(require_core_data(), 1);
49113 function PostTrashCheck({ children }) {
49114 const { canTrashPost } = (0, import_data165.useSelect)((select6) => {
49115 const { isEditedPostNew: isEditedPostNew2, getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = select6(store);
49116 const { canUser } = select6(import_core_data101.store);
49117 const postType2 = getCurrentPostType2();
49118 const postId2 = getCurrentPostId2();
49119 const isNew = isEditedPostNew2();
49120 const canUserDelete = !!postId2 ? canUser("delete", {
49121 kind: "postType",
49122 name: postType2,
49123 id: postId2
49124 }) : false;
49125 return {
49126 canTrashPost: (!isNew || postId2) && canUserDelete && !GLOBAL_POST_TYPES.includes(postType2)
49127 };
49128 }, []);
49129 if (!canTrashPost) {
49130 return null;
49131 }
49132 return children;
49133 }
49134
49135 // packages/editor/build-module/components/post-trash/index.mjs
49136 var import_jsx_runtime298 = __toESM(require_jsx_runtime(), 1);
49137 function PostTrash({ onActionPerformed }) {
49138 const registry = (0, import_data166.useRegistry)();
49139 const { isNew, isDeleting, postId: postId2, title } = (0, import_data166.useSelect)((select6) => {
49140 const store3 = select6(store);
49141 return {
49142 isNew: store3.isEditedPostNew(),
49143 isDeleting: store3.isDeletingPost(),
49144 postId: store3.getCurrentPostId(),
49145 title: store3.getCurrentPostAttribute("title")
49146 };
49147 }, []);
49148 const { trashPost: trashPost3 } = (0, import_data166.useDispatch)(store);
49149 const [showConfirmDialog, setShowConfirmDialog] = (0, import_element138.useState)(false);
49150 if (isNew || !postId2) {
49151 return null;
49152 }
49153 const handleConfirm = async () => {
49154 setShowConfirmDialog(false);
49155 await trashPost3();
49156 const item = await registry.resolveSelect(store).getCurrentPost();
49157 onActionPerformed?.("move-to-trash", [item]);
49158 };
49159 return /* @__PURE__ */ (0, import_jsx_runtime298.jsxs)(PostTrashCheck, { children: [
49160 /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(
49161 import_components167.Button,
49162 {
49163 __next40pxDefaultSize: true,
49164 className: "editor-post-trash",
49165 isDestructive: true,
49166 variant: "secondary",
49167 isBusy: isDeleting,
49168 "aria-disabled": isDeleting,
49169 onClick: isDeleting ? void 0 : () => setShowConfirmDialog(true),
49170 children: (0, import_i18n188.__)("Move to trash")
49171 }
49172 ),
49173 /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(
49174 import_components167.__experimentalConfirmDialog,
49175 {
49176 isOpen: showConfirmDialog,
49177 onConfirm: handleConfirm,
49178 onCancel: () => setShowConfirmDialog(false),
49179 confirmButtonText: (0, import_i18n188.__)("Move to trash"),
49180 size: "small",
49181 children: (0, import_i18n188.sprintf)(
49182 // translators: %s: The item's title.
49183 (0, import_i18n188.__)('Are you sure you want to move "%s" to the trash?'),
49184 title
49185 )
49186 }
49187 )
49188 ] });
49189 }
49190
49191 // packages/editor/build-module/components/post-url/index.mjs
49192 var import_data167 = __toESM(require_data(), 1);
49193 var import_url18 = __toESM(require_url(), 1);
49194 var import_element139 = __toESM(require_element(), 1);
49195 var import_block_editor59 = __toESM(require_block_editor(), 1);
49196 var import_i18n189 = __toESM(require_i18n(), 1);
49197 var import_components168 = __toESM(require_components(), 1);
49198 var import_notices25 = __toESM(require_notices(), 1);
49199 var import_core_data102 = __toESM(require_core_data(), 1);
49200 var import_compose40 = __toESM(require_compose(), 1);
49201 var import_jsx_runtime299 = __toESM(require_jsx_runtime(), 1);
49202 function PostURL({ onClose }) {
49203 const {
49204 isEditable,
49205 postSlug,
49206 postLink,
49207 permalinkPrefix,
49208 permalinkSuffix,
49209 permalink
49210 } = (0, import_data167.useSelect)((select6) => {
49211 const post2 = select6(store).getCurrentPost();
49212 const postTypeSlug = select6(store).getCurrentPostType();
49213 const postType2 = select6(import_core_data102.store).getPostType(postTypeSlug);
49214 const permalinkParts = select6(store).getPermalinkParts();
49215 const hasPublishAction = post2?._links?.["wp:action-publish"] ?? false;
49216 return {
49217 isEditable: select6(store).isPermalinkEditable() && hasPublishAction,
49218 postSlug: (0, import_url18.safeDecodeURIComponent)(
49219 select6(store).getEditedPostSlug()
49220 ),
49221 viewPostLabel: postType2?.labels.view_item,
49222 postLink: post2.link,
49223 permalinkPrefix: permalinkParts?.prefix,
49224 permalinkSuffix: permalinkParts?.suffix,
49225 permalink: (0, import_url18.safeDecodeURIComponent)(
49226 select6(store).getPermalink()
49227 )
49228 };
49229 }, []);
49230 const { editPost: editPost2 } = (0, import_data167.useDispatch)(store);
49231 const { createNotice } = (0, import_data167.useDispatch)(import_notices25.store);
49232 const [forceEmptyField, setForceEmptyField] = (0, import_element139.useState)(false);
49233 const copyButtonRef = (0, import_compose40.useCopyToClipboard)(permalink, () => {
49234 createNotice("info", (0, import_i18n189.__)("Copied Permalink to clipboard."), {
49235 isDismissible: true,
49236 type: "snackbar"
49237 });
49238 });
49239 const postUrlSlugDescriptionId = "editor-post-url__slug-description-" + (0, import_compose40.useInstanceId)(PostURL);
49240 return /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)("div", { className: "editor-post-url", children: [
49241 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(
49242 import_block_editor59.__experimentalInspectorPopoverHeader,
49243 {
49244 title: (0, import_i18n189.__)("Slug"),
49245 onClose
49246 }
49247 ),
49248 /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)(import_components168.__experimentalVStack, { spacing: 3, children: [
49249 isEditable && /* @__PURE__ */ (0, import_jsx_runtime299.jsx)("p", { className: "editor-post-url__intro", children: (0, import_element139.createInterpolateElement)(
49250 (0, import_i18n189.__)(
49251 "<span>Customize the last part of the Permalink.</span> <a>Learn more.</a>"
49252 ),
49253 {
49254 span: /* @__PURE__ */ (0, import_jsx_runtime299.jsx)("span", { id: postUrlSlugDescriptionId }),
49255 a: /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(
49256 import_components168.ExternalLink,
49257 {
49258 href: (0, import_i18n189.__)(
49259 "https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink"
49260 )
49261 }
49262 )
49263 }
49264 ) }),
49265 /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)("div", { children: [
49266 isEditable && /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)(import_jsx_runtime299.Fragment, { children: [
49267 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(
49268 import_components168.__experimentalInputControl,
49269 {
49270 __next40pxDefaultSize: true,
49271 prefix: /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(import_components168.__experimentalInputControlPrefixWrapper, { children: "/" }),
49272 suffix: /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(import_components168.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(
49273 import_components168.Button,
49274 {
49275 icon: copy_small_default,
49276 ref: copyButtonRef,
49277 size: "small",
49278 label: "Copy"
49279 }
49280 ) }),
49281 label: (0, import_i18n189.__)("Slug"),
49282 hideLabelFromVision: true,
49283 value: forceEmptyField ? "" : postSlug,
49284 autoComplete: "off",
49285 spellCheck: "false",
49286 type: "text",
49287 className: "editor-post-url__input",
49288 onChange: (newValue) => {
49289 editPost2({ slug: newValue });
49290 if (!newValue) {
49291 if (!forceEmptyField) {
49292 setForceEmptyField(true);
49293 }
49294 return;
49295 }
49296 if (forceEmptyField) {
49297 setForceEmptyField(false);
49298 }
49299 },
49300 onBlur: (event) => {
49301 editPost2({
49302 slug: (0, import_url18.cleanForSlug)(
49303 event.target.value
49304 )
49305 });
49306 if (forceEmptyField) {
49307 setForceEmptyField(false);
49308 }
49309 },
49310 "aria-describedby": postUrlSlugDescriptionId
49311 }
49312 ),
49313 /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)("p", { className: "editor-post-url__permalink", children: [
49314 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)("span", { className: "editor-post-url__permalink-visual-label", children: (0, import_i18n189.__)("Permalink:") }),
49315 /* @__PURE__ */ (0, import_jsx_runtime299.jsxs)(
49316 import_components168.ExternalLink,
49317 {
49318 className: "editor-post-url__link",
49319 href: postLink,
49320 target: "_blank",
49321 children: [
49322 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)("span", { className: "editor-post-url__link-prefix", children: permalinkPrefix }),
49323 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)("span", { className: "editor-post-url__link-slug", children: postSlug }),
49324 /* @__PURE__ */ (0, import_jsx_runtime299.jsx)("span", { className: "editor-post-url__link-suffix", children: permalinkSuffix })
49325 ]
49326 }
49327 )
49328 ] })
49329 ] }),
49330 !isEditable && /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(
49331 import_components168.ExternalLink,
49332 {
49333 className: "editor-post-url__link",
49334 href: postLink,
49335 target: "_blank",
49336 children: postLink
49337 }
49338 )
49339 ] })
49340 ] })
49341 ] });
49342 }
49343
49344 // packages/editor/build-module/components/post-url/check.mjs
49345 var import_data168 = __toESM(require_data(), 1);
49346 var import_core_data103 = __toESM(require_core_data(), 1);
49347 function PostURLCheck({ children }) {
49348 const isVisible = (0, import_data168.useSelect)((select6) => {
49349 const postTypeSlug = select6(store).getCurrentPostType();
49350 const postType2 = select6(import_core_data103.store).getPostType(postTypeSlug);
49351 if (!postType2?.viewable) {
49352 return false;
49353 }
49354 const post2 = select6(store).getCurrentPost();
49355 if (!post2.link) {
49356 return false;
49357 }
49358 const permalinkParts = select6(store).getPermalinkParts();
49359 if (!permalinkParts) {
49360 return false;
49361 }
49362 return true;
49363 }, []);
49364 if (!isVisible) {
49365 return null;
49366 }
49367 return children;
49368 }
49369
49370 // packages/editor/build-module/components/post-url/label.mjs
49371 var import_data169 = __toESM(require_data(), 1);
49372 var import_url19 = __toESM(require_url(), 1);
49373 function PostURLLabel() {
49374 return usePostURLLabel();
49375 }
49376 function usePostURLLabel() {
49377 const postLink = (0, import_data169.useSelect)(
49378 (select6) => select6(store).getPermalink(),
49379 []
49380 );
49381 return (0, import_url19.filterURLForDisplay)((0, import_url19.safeDecodeURIComponent)(postLink));
49382 }
49383
49384 // packages/editor/build-module/components/post-url/panel.mjs
49385 var import_element140 = __toESM(require_element(), 1);
49386 var import_data170 = __toESM(require_data(), 1);
49387 var import_components169 = __toESM(require_components(), 1);
49388 var import_i18n190 = __toESM(require_i18n(), 1);
49389 var import_url20 = __toESM(require_url(), 1);
49390 var import_core_data104 = __toESM(require_core_data(), 1);
49391 var import_jsx_runtime300 = __toESM(require_jsx_runtime(), 1);
49392 function PostURLPanel() {
49393 const { isFrontPage } = (0, import_data170.useSelect)((select6) => {
49394 const { getCurrentPostId: getCurrentPostId2 } = select6(store);
49395 const { getEditedEntityRecord, canUser } = select6(import_core_data104.store);
49396 const siteSettings = canUser("read", {
49397 kind: "root",
49398 name: "site"
49399 }) ? getEditedEntityRecord("root", "site") : void 0;
49400 const _id = getCurrentPostId2();
49401 return {
49402 isFrontPage: siteSettings?.page_on_front === _id
49403 };
49404 }, []);
49405 const [popoverAnchor, setPopoverAnchor] = (0, import_element140.useState)(null);
49406 const popoverProps = (0, import_element140.useMemo)(
49407 () => ({
49408 // Anchor the popover to the middle of the entire row so that it doesn't
49409 // move around when the label changes.
49410 anchor: popoverAnchor,
49411 placement: "left-start",
49412 offset: 36,
49413 shift: true
49414 }),
49415 [popoverAnchor]
49416 );
49417 const label = isFrontPage ? (0, import_i18n190.__)("Link") : (0, import_i18n190.__)("Slug");
49418 return /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(PostURLCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime300.jsxs)(post_panel_row_default, { label, ref: setPopoverAnchor, children: [
49419 !isFrontPage && /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(
49420 import_components169.Dropdown,
49421 {
49422 popoverProps,
49423 className: "editor-post-url__panel-dropdown",
49424 contentClassName: "editor-post-url__panel-dialog",
49425 focusOnMount: true,
49426 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(
49427 PostURLToggle,
49428 {
49429 isOpen,
49430 onClick: onToggle
49431 }
49432 ),
49433 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(PostURL, { onClose })
49434 }
49435 ),
49436 isFrontPage && /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(FrontPageLink, {})
49437 ] }) });
49438 }
49439 function PostURLToggle({ isOpen, onClick }) {
49440 const { slug } = (0, import_data170.useSelect)((select6) => {
49441 return {
49442 slug: select6(store).getEditedPostSlug()
49443 };
49444 }, []);
49445 const decodedSlug = (0, import_url20.safeDecodeURIComponent)(slug);
49446 return /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(
49447 import_components169.Button,
49448 {
49449 size: "compact",
49450 className: "editor-post-url__panel-toggle",
49451 variant: "tertiary",
49452 "aria-expanded": isOpen,
49453 "aria-label": (
49454 // translators: %s: Current post link.
49455 (0, import_i18n190.sprintf)((0, import_i18n190.__)("Change link: %s"), decodedSlug)
49456 ),
49457 onClick,
49458 children: /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(import_jsx_runtime300.Fragment, { children: decodedSlug })
49459 }
49460 );
49461 }
49462 function FrontPageLink() {
49463 const { postLink } = (0, import_data170.useSelect)((select6) => {
49464 const { getCurrentPost: getCurrentPost2 } = select6(store);
49465 return {
49466 postLink: getCurrentPost2()?.link
49467 };
49468 }, []);
49469 return /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(
49470 import_components169.ExternalLink,
49471 {
49472 className: "editor-post-url__front-page-link",
49473 href: postLink,
49474 target: "_blank",
49475 children: postLink
49476 }
49477 );
49478 }
49479
49480 // packages/editor/build-module/components/post-visibility/check.mjs
49481 var import_data171 = __toESM(require_data(), 1);
49482 function PostVisibilityCheck({ render: render4 }) {
49483 const canEdit = (0, import_data171.useSelect)((select6) => {
49484 return select6(store).getCurrentPost()._links?.["wp:action-publish"] ?? false;
49485 });
49486 return render4({ canEdit });
49487 }
49488
49489 // packages/editor/build-module/components/table-of-contents/index.mjs
49490 var import_i18n194 = __toESM(require_i18n(), 1);
49491 var import_components170 = __toESM(require_components(), 1);
49492 var import_data176 = __toESM(require_data(), 1);
49493 var import_element142 = __toESM(require_element(), 1);
49494 var import_block_editor61 = __toESM(require_block_editor(), 1);
49495
49496 // packages/editor/build-module/components/table-of-contents/panel.mjs
49497 var import_i18n193 = __toESM(require_i18n(), 1);
49498 var import_data175 = __toESM(require_data(), 1);
49499 var import_block_editor60 = __toESM(require_block_editor(), 1);
49500
49501 // packages/editor/build-module/components/word-count/index.mjs
49502 var import_data172 = __toESM(require_data(), 1);
49503 var import_i18n191 = __toESM(require_i18n(), 1);
49504 var import_wordcount = __toESM(require_wordcount(), 1);
49505 var import_jsx_runtime301 = __toESM(require_jsx_runtime(), 1);
49506 function WordCount() {
49507 const content = (0, import_data172.useSelect)(
49508 (select6) => select6(store).getEditedPostAttribute("content"),
49509 []
49510 );
49511 const wordCountType = (0, import_i18n191._x)("words", "Word count type. Do not translate!");
49512 return /* @__PURE__ */ (0, import_jsx_runtime301.jsx)("span", { className: "word-count", children: (0, import_wordcount.count)(content, wordCountType) });
49513 }
49514
49515 // packages/editor/build-module/components/time-to-read/index.mjs
49516 var import_data173 = __toESM(require_data(), 1);
49517 var import_i18n192 = __toESM(require_i18n(), 1);
49518 var import_wordcount2 = __toESM(require_wordcount(), 1);
49519 var import_element141 = __toESM(require_element(), 1);
49520 var import_jsx_runtime302 = __toESM(require_jsx_runtime(), 1);
49521 var AVERAGE_READING_RATE = 189;
49522 function TimeToRead() {
49523 const content = (0, import_data173.useSelect)(
49524 (select6) => select6(store).getEditedPostAttribute("content"),
49525 []
49526 );
49527 const wordCountType = (0, import_i18n192._x)("words", "Word count type. Do not translate!");
49528 const minutesToRead = Math.round(
49529 (0, import_wordcount2.count)(content, wordCountType) / AVERAGE_READING_RATE
49530 );
49531 const minutesToReadString = minutesToRead === 0 ? (0, import_element141.createInterpolateElement)((0, import_i18n192.__)("<span>< 1</span> minute"), {
49532 span: /* @__PURE__ */ (0, import_jsx_runtime302.jsx)("span", {})
49533 }) : (0, import_element141.createInterpolateElement)(
49534 (0, import_i18n192.sprintf)(
49535 /* translators: %s: the number of minutes to read the post. */
49536 (0, import_i18n192._n)(
49537 "<span>%s</span> minute",
49538 "<span>%s</span> minutes",
49539 minutesToRead
49540 ),
49541 minutesToRead
49542 ),
49543 {
49544 span: /* @__PURE__ */ (0, import_jsx_runtime302.jsx)("span", {})
49545 }
49546 );
49547 return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)("span", { className: "time-to-read", children: minutesToReadString });
49548 }
49549
49550 // packages/editor/build-module/components/character-count/index.mjs
49551 var import_data174 = __toESM(require_data(), 1);
49552 var import_wordcount3 = __toESM(require_wordcount(), 1);
49553 function CharacterCount() {
49554 const content = (0, import_data174.useSelect)(
49555 (select6) => select6(store).getEditedPostAttribute("content"),
49556 []
49557 );
49558 return (0, import_wordcount3.count)(content, "characters_including_spaces");
49559 }
49560
49561 // packages/editor/build-module/components/table-of-contents/panel.mjs
49562 var import_jsx_runtime303 = __toESM(require_jsx_runtime(), 1);
49563 function TableOfContentsPanel({ hasOutlineItemsDisabled, onRequestClose }) {
49564 const { headingCount, paragraphCount, numberOfBlocks } = (0, import_data175.useSelect)(
49565 (select6) => {
49566 const { getGlobalBlockCount: getGlobalBlockCount2 } = select6(import_block_editor60.store);
49567 return {
49568 headingCount: getGlobalBlockCount2("core/heading"),
49569 paragraphCount: getGlobalBlockCount2("core/paragraph"),
49570 numberOfBlocks: getGlobalBlockCount2()
49571 };
49572 },
49573 []
49574 );
49575 return (
49576 /*
49577 * Disable reason: The `list` ARIA role is redundant but
49578 * Safari+VoiceOver won't announce the list otherwise.
49579 */
49580 /* eslint-disable jsx-a11y/no-redundant-roles */
49581 /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(import_jsx_runtime303.Fragment, { children: [
49582 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
49583 "div",
49584 {
49585 className: "table-of-contents__wrapper",
49586 role: "note",
49587 "aria-label": (0, import_i18n193.__)("Document Statistics"),
49588 tabIndex: "0",
49589 children: /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)("ul", { role: "list", className: "table-of-contents__counts", children: [
49590 /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)("li", { className: "table-of-contents__count", children: [
49591 (0, import_i18n193.__)("Words"),
49592 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(WordCount, {})
49593 ] }),
49594 /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)("li", { className: "table-of-contents__count", children: [
49595 (0, import_i18n193.__)("Characters"),
49596 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)("span", { className: "table-of-contents__number", children: /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(CharacterCount, {}) })
49597 ] }),
49598 /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)("li", { className: "table-of-contents__count", children: [
49599 (0, import_i18n193.__)("Time to read"),
49600 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(TimeToRead, {})
49601 ] }),
49602 /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)("li", { className: "table-of-contents__count", children: [
49603 (0, import_i18n193.__)("Headings"),
49604 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)("span", { className: "table-of-contents__number", children: headingCount })
49605 ] }),
49606 /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)("li", { className: "table-of-contents__count", children: [
49607 (0, import_i18n193.__)("Paragraphs"),
49608 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)("span", { className: "table-of-contents__number", children: paragraphCount })
49609 ] }),
49610 /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)("li", { className: "table-of-contents__count", children: [
49611 (0, import_i18n193.__)("Blocks"),
49612 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)("span", { className: "table-of-contents__number", children: numberOfBlocks })
49613 ] })
49614 ] })
49615 }
49616 ),
49617 headingCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(import_jsx_runtime303.Fragment, { children: [
49618 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)("hr", {}),
49619 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)("h2", { className: "table-of-contents__title", children: (0, import_i18n193.__)("Document Outline") }),
49620 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(
49621 DocumentOutline,
49622 {
49623 onSelect: onRequestClose,
49624 hasOutlineItemsDisabled
49625 }
49626 )
49627 ] })
49628 ] })
49629 );
49630 }
49631 var panel_default3 = TableOfContentsPanel;
49632
49633 // packages/editor/build-module/components/table-of-contents/index.mjs
49634 var import_jsx_runtime304 = __toESM(require_jsx_runtime(), 1);
49635 function TableOfContents({ hasOutlineItemsDisabled, repositionDropdown, ...props }, ref) {
49636 const hasBlocks = (0, import_data176.useSelect)(
49637 (select6) => !!select6(import_block_editor61.store).getBlockCount(),
49638 []
49639 );
49640 return /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
49641 import_components170.Dropdown,
49642 {
49643 popoverProps: {
49644 placement: repositionDropdown ? "right" : "bottom"
49645 },
49646 className: "table-of-contents",
49647 contentClassName: "table-of-contents__popover",
49648 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
49649 import_components170.Button,
49650 {
49651 __next40pxDefaultSize: true,
49652 ...props,
49653 ref,
49654 onClick: hasBlocks ? onToggle : void 0,
49655 icon: info_default,
49656 "aria-expanded": isOpen,
49657 "aria-haspopup": "true",
49658 label: (0, import_i18n194.__)("Details"),
49659 tooltipPosition: "bottom",
49660 "aria-disabled": !hasBlocks
49661 }
49662 ),
49663 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
49664 panel_default3,
49665 {
49666 onRequestClose: onClose,
49667 hasOutlineItemsDisabled
49668 }
49669 )
49670 }
49671 );
49672 }
49673 var table_of_contents_default = (0, import_element142.forwardRef)(TableOfContents);
49674
49675 // packages/editor/build-module/components/unsaved-changes-warning/index.mjs
49676 var import_i18n195 = __toESM(require_i18n(), 1);
49677 var import_element143 = __toESM(require_element(), 1);
49678 var import_data177 = __toESM(require_data(), 1);
49679 var import_core_data105 = __toESM(require_core_data(), 1);
49680 function UnsavedChangesWarning() {
49681 const { __experimentalGetDirtyEntityRecords } = (0, import_data177.useSelect)(import_core_data105.store);
49682 (0, import_element143.useEffect)(() => {
49683 const warnIfUnsavedChanges = (event) => {
49684 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
49685 if (dirtyEntityRecords.length > 0) {
49686 event.returnValue = (0, import_i18n195.__)(
49687 "You have unsaved changes. If you proceed, they will be lost."
49688 );
49689 return event.returnValue;
49690 }
49691 };
49692 window.addEventListener("beforeunload", warnIfUnsavedChanges);
49693 return () => {
49694 window.removeEventListener("beforeunload", warnIfUnsavedChanges);
49695 };
49696 }, [__experimentalGetDirtyEntityRecords]);
49697 return null;
49698 }
49699
49700 // packages/editor/build-module/components/deprecated.mjs
49701 var import_deprecated12 = __toESM(require_deprecated(), 1);
49702 var import_element144 = __toESM(require_element(), 1);
49703 var import_block_editor62 = __toESM(require_block_editor(), 1);
49704 var import_server_side_render = __toESM(require_server_side_render(), 1);
49705 var import_jsx_runtime305 = __toESM(require_jsx_runtime(), 1);
49706 function deprecateComponent(name2, Wrapped, staticsToHoist = []) {
49707 const Component6 = (0, import_element144.forwardRef)((props, ref) => {
49708 (0, import_deprecated12.default)("wp.editor." + name2, {
49709 since: "5.3",
49710 alternative: "wp.blockEditor." + name2,
49711 version: "6.2"
49712 });
49713 return /* @__PURE__ */ (0, import_jsx_runtime305.jsx)(Wrapped, { ref, ...props });
49714 });
49715 staticsToHoist.forEach((staticName) => {
49716 Component6[staticName] = deprecateComponent(
49717 name2 + "." + staticName,
49718 Wrapped[staticName]
49719 );
49720 });
49721 return Component6;
49722 }
49723 function deprecateFunction(name2, func) {
49724 return (...args) => {
49725 (0, import_deprecated12.default)("wp.editor." + name2, {
49726 since: "5.3",
49727 alternative: "wp.blockEditor." + name2,
49728 version: "6.2"
49729 });
49730 return func(...args);
49731 };
49732 }
49733 var RichText = deprecateComponent("RichText", import_block_editor62.RichText, ["Content"]);
49734 RichText.isEmpty = deprecateFunction(
49735 "RichText.isEmpty",
49736 import_block_editor62.RichText.isEmpty
49737 );
49738 var Autocomplete = deprecateComponent(
49739 "Autocomplete",
49740 import_block_editor62.Autocomplete
49741 );
49742 var AlignmentToolbar = deprecateComponent(
49743 "AlignmentToolbar",
49744 import_block_editor62.AlignmentToolbar
49745 );
49746 var BlockAlignmentToolbar = deprecateComponent(
49747 "BlockAlignmentToolbar",
49748 import_block_editor62.BlockAlignmentToolbar
49749 );
49750 var BlockControls = deprecateComponent(
49751 "BlockControls",
49752 import_block_editor62.BlockControls,
49753 ["Slot"]
49754 );
49755 var BlockEdit = deprecateComponent("BlockEdit", import_block_editor62.BlockEdit);
49756 var BlockEditorKeyboardShortcuts2 = deprecateComponent(
49757 "BlockEditorKeyboardShortcuts",
49758 import_block_editor62.BlockEditorKeyboardShortcuts
49759 );
49760 var BlockFormatControls = deprecateComponent(
49761 "BlockFormatControls",
49762 import_block_editor62.BlockFormatControls,
49763 ["Slot"]
49764 );
49765 var BlockIcon3 = deprecateComponent("BlockIcon", import_block_editor62.BlockIcon);
49766 var BlockInspector = deprecateComponent(
49767 "BlockInspector",
49768 import_block_editor62.BlockInspector
49769 );
49770 var BlockList4 = deprecateComponent("BlockList", import_block_editor62.BlockList);
49771 var BlockMover = deprecateComponent("BlockMover", import_block_editor62.BlockMover);
49772 var BlockNavigationDropdown = deprecateComponent(
49773 "BlockNavigationDropdown",
49774 import_block_editor62.BlockNavigationDropdown
49775 );
49776 var BlockSelectionClearer = deprecateComponent(
49777 "BlockSelectionClearer",
49778 import_block_editor62.BlockSelectionClearer
49779 );
49780 var BlockSettingsMenu = deprecateComponent(
49781 "BlockSettingsMenu",
49782 import_block_editor62.BlockSettingsMenu
49783 );
49784 var BlockTitle = deprecateComponent("BlockTitle", import_block_editor62.BlockTitle);
49785 var BlockToolbar = deprecateComponent(
49786 "BlockToolbar",
49787 import_block_editor62.BlockToolbar
49788 );
49789 var ColorPalette2 = deprecateComponent(
49790 "ColorPalette",
49791 import_block_editor62.ColorPalette
49792 );
49793 var ContrastChecker = deprecateComponent(
49794 "ContrastChecker",
49795 import_block_editor62.ContrastChecker
49796 );
49797 var CopyHandler = deprecateComponent("CopyHandler", import_block_editor62.CopyHandler);
49798 var DefaultBlockAppender = deprecateComponent(
49799 "DefaultBlockAppender",
49800 import_block_editor62.DefaultBlockAppender
49801 );
49802 var FontSizePicker = deprecateComponent(
49803 "FontSizePicker",
49804 import_block_editor62.FontSizePicker
49805 );
49806 var Inserter = deprecateComponent("Inserter", import_block_editor62.Inserter);
49807 var InnerBlocks = deprecateComponent("InnerBlocks", import_block_editor62.InnerBlocks, [
49808 "ButtonBlockAppender",
49809 "DefaultBlockAppender",
49810 "Content"
49811 ]);
49812 var InspectorAdvancedControls = deprecateComponent(
49813 "InspectorAdvancedControls",
49814 import_block_editor62.InspectorAdvancedControls,
49815 ["Slot"]
49816 );
49817 var InspectorControls = deprecateComponent(
49818 "InspectorControls",
49819 import_block_editor62.InspectorControls,
49820 ["Slot"]
49821 );
49822 var PanelColorSettings = deprecateComponent(
49823 "PanelColorSettings",
49824 import_block_editor62.PanelColorSettings
49825 );
49826 var PlainText = deprecateComponent("PlainText", import_block_editor62.PlainText);
49827 var RichTextShortcut = deprecateComponent(
49828 "RichTextShortcut",
49829 import_block_editor62.RichTextShortcut
49830 );
49831 var RichTextToolbarButton = deprecateComponent(
49832 "RichTextToolbarButton",
49833 import_block_editor62.RichTextToolbarButton
49834 );
49835 var __unstableRichTextInputEvent = deprecateComponent(
49836 "__unstableRichTextInputEvent",
49837 import_block_editor62.__unstableRichTextInputEvent
49838 );
49839 var MediaPlaceholder = deprecateComponent(
49840 "MediaPlaceholder",
49841 import_block_editor62.MediaPlaceholder
49842 );
49843 var MediaUpload3 = deprecateComponent("MediaUpload", import_block_editor62.MediaUpload);
49844 var MediaUploadCheck2 = deprecateComponent(
49845 "MediaUploadCheck",
49846 import_block_editor62.MediaUploadCheck
49847 );
49848 var MultiSelectScrollIntoView = deprecateComponent(
49849 "MultiSelectScrollIntoView",
49850 import_block_editor62.MultiSelectScrollIntoView
49851 );
49852 var NavigableToolbar = deprecateComponent(
49853 "NavigableToolbar",
49854 import_block_editor62.NavigableToolbar
49855 );
49856 var ObserveTyping = deprecateComponent(
49857 "ObserveTyping",
49858 import_block_editor62.ObserveTyping
49859 );
49860 var SkipToSelectedBlock = deprecateComponent(
49861 "SkipToSelectedBlock",
49862 import_block_editor62.SkipToSelectedBlock
49863 );
49864 var URLInput = deprecateComponent("URLInput", import_block_editor62.URLInput);
49865 var URLInputButton = deprecateComponent(
49866 "URLInputButton",
49867 import_block_editor62.URLInputButton
49868 );
49869 var URLPopover = deprecateComponent("URLPopover", import_block_editor62.URLPopover);
49870 var Warning = deprecateComponent("Warning", import_block_editor62.Warning);
49871 var WritingFlow = deprecateComponent("WritingFlow", import_block_editor62.WritingFlow);
49872 var createCustomColorsHOC = deprecateFunction(
49873 "createCustomColorsHOC",
49874 import_block_editor62.createCustomColorsHOC
49875 );
49876 var getColorClassName2 = deprecateFunction(
49877 "getColorClassName",
49878 import_block_editor62.getColorClassName
49879 );
49880 var getColorObjectByAttributeValues = deprecateFunction(
49881 "getColorObjectByAttributeValues",
49882 import_block_editor62.getColorObjectByAttributeValues
49883 );
49884 var getColorObjectByColorValue = deprecateFunction(
49885 "getColorObjectByColorValue",
49886 import_block_editor62.getColorObjectByColorValue
49887 );
49888 var getFontSize = deprecateFunction("getFontSize", import_block_editor62.getFontSize);
49889 var getFontSizeClass = deprecateFunction(
49890 "getFontSizeClass",
49891 import_block_editor62.getFontSizeClass
49892 );
49893 var withColorContext = deprecateFunction(
49894 "withColorContext",
49895 import_block_editor62.withColorContext
49896 );
49897 var withColors = deprecateFunction("withColors", import_block_editor62.withColors);
49898 var withFontSizes = deprecateFunction(
49899 "withFontSizes",
49900 import_block_editor62.withFontSizes
49901 );
49902
49903 // packages/editor/build-module/components/index.mjs
49904 var VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
49905 var TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
49906
49907 // packages/editor/build-module/hooks/default-autocompleters.mjs
49908 function setDefaultCompleters(completers = []) {
49909 completers.push({ ...user_default });
49910 return completers;
49911 }
49912 (0, import_hooks49.addFilter)(
49913 "editor.Autocomplete.completers",
49914 "editor/autocompleters/set-default-completers",
49915 setDefaultCompleters
49916 );
49917
49918 // packages/editor/build-module/hooks/media-upload.mjs
49919 var import_element145 = __toESM(require_element(), 1);
49920 var import_hooks50 = __toESM(require_hooks(), 1);
49921 var import_deprecated13 = __toESM(require_deprecated(), 1);
49922 var import_media_utils6 = __toESM(require_media_utils(), 1);
49923 var import_jsx_runtime306 = __toESM(require_jsx_runtime(), 1);
49924 var { MediaUploadModal: MediaUploadModalComponent } = unlock(
49925 import_media_utils6.privateApis
49926 );
49927 var MediaUploadModalWrapper = class extends import_element145.Component {
49928 constructor(props) {
49929 super(props);
49930 this.state = {
49931 isOpen: false
49932 };
49933 this.openModal = this.openModal.bind(this);
49934 this.closeModal = this.closeModal.bind(this);
49935 }
49936 openModal() {
49937 this.setState({ isOpen: true });
49938 }
49939 closeModal() {
49940 this.setState({ isOpen: false });
49941 this.props.onClose?.();
49942 }
49943 render() {
49944 const {
49945 allowedTypes,
49946 multiple,
49947 value,
49948 onSelect,
49949 title,
49950 modalClass,
49951 render: render4
49952 } = this.props;
49953 const { isOpen } = this.state;
49954 return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)(import_jsx_runtime306.Fragment, { children: [
49955 render4({ open: this.openModal }),
49956 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(
49957 MediaUploadModalComponent,
49958 {
49959 allowedTypes,
49960 multiple,
49961 value,
49962 onSelect: (media) => {
49963 onSelect(media);
49964 this.closeModal();
49965 },
49966 onClose: this.closeModal,
49967 title,
49968 isOpen,
49969 modalClass
49970 }
49971 )
49972 ] });
49973 }
49974 };
49975 if (window.__experimentalDataViewsMediaModal) {
49976 (0, import_hooks50.addFilter)(
49977 "editor.MediaUpload",
49978 "core/editor/components/media-upload",
49979 () => {
49980 (0, import_deprecated13.default)("Extending MediaUpload as a class component", {
49981 since: "7.0",
49982 version: "7.2",
49983 hint: "MediaUpload will become a function component in WordPress 7.2 Please update any custom implementations to use function components instead."
49984 });
49985 return MediaUploadModalWrapper;
49986 }
49987 );
49988 } else {
49989 (0, import_hooks50.addFilter)(
49990 "editor.MediaUpload",
49991 "core/editor/components/media-upload",
49992 () => {
49993 return import_media_utils6.MediaUpload;
49994 }
49995 );
49996 }
49997
49998 // packages/editor/build-module/hooks/pattern-overrides.mjs
49999 var import_hooks51 = __toESM(require_hooks(), 1);
50000 var import_patterns8 = __toESM(require_patterns(), 1);
50001 var import_compose41 = __toESM(require_compose(), 1);
50002 var import_block_editor63 = __toESM(require_block_editor(), 1);
50003 var import_data178 = __toESM(require_data(), 1);
50004 var import_blocks29 = __toESM(require_blocks(), 1);
50005 var import_jsx_runtime307 = __toESM(require_jsx_runtime(), 1);
50006 var {
50007 PatternOverridesControls,
50008 ResetOverridesControl,
50009 PATTERN_TYPES: PATTERN_TYPES4,
50010 PATTERN_SYNC_TYPES
50011 } = unlock(import_patterns8.privateApis);
50012 var withPatternOverrideControls = (0, import_compose41.createHigherOrderComponent)(
50013 (BlockEdit2) => (props) => {
50014 const isSupportedBlock = (0, import_data178.useSelect)(
50015 (select6) => {
50016 const { __experimentalBlockBindingsSupportedAttributes } = select6(import_block_editor63.store).getSettings();
50017 return !!__experimentalBlockBindingsSupportedAttributes?.[props.name];
50018 },
50019 [props.name]
50020 );
50021 return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)(import_jsx_runtime307.Fragment, { children: [
50022 /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(BlockEdit2, { ...props }, "edit"),
50023 props.isSelected && isSupportedBlock && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(ControlsWithStoreSubscription, { ...props })
50024 ] });
50025 },
50026 "withPatternOverrideControls"
50027 );
50028 function ControlsWithStoreSubscription(props) {
50029 const blockEditingMode = (0, import_block_editor63.useBlockEditingMode)();
50030 const { hasPatternOverridesSource, isEditingSyncedPattern } = (0, import_data178.useSelect)(
50031 (select6) => {
50032 const { getCurrentPostType: getCurrentPostType2, getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
50033 return {
50034 // For editing link to the site editor if the theme and user permissions support it.
50035 hasPatternOverridesSource: !!(0, import_blocks29.getBlockBindingsSource)(
50036 "core/pattern-overrides"
50037 ),
50038 isEditingSyncedPattern: getCurrentPostType2() === PATTERN_TYPES4.user && getEditedPostAttribute2("meta")?.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced && getEditedPostAttribute2("wp_pattern_sync_status") !== PATTERN_SYNC_TYPES.unsynced
50039 };
50040 },
50041 []
50042 );
50043 const bindings = props.attributes.metadata?.bindings;
50044 const hasPatternBindings = !!bindings && Object.values(bindings).some(
50045 (binding) => binding.source === "core/pattern-overrides"
50046 );
50047 const shouldShowPatternOverridesControls = isEditingSyncedPattern && blockEditingMode === "default";
50048 const shouldShowResetOverridesControl = !isEditingSyncedPattern && !!props.attributes.metadata?.name && blockEditingMode !== "disabled" && hasPatternBindings;
50049 if (!hasPatternOverridesSource) {
50050 return null;
50051 }
50052 return /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)(import_jsx_runtime307.Fragment, { children: [
50053 shouldShowPatternOverridesControls && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(PatternOverridesControls, { ...props }),
50054 shouldShowResetOverridesControl && /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(ResetOverridesControl, { ...props })
50055 ] });
50056 }
50057 (0, import_hooks51.addFilter)(
50058 "editor.BlockEdit",
50059 "core/editor/with-pattern-override-controls",
50060 withPatternOverrideControls
50061 );
50062
50063 // packages/editor/build-module/hooks/navigation-link-view-button.mjs
50064 var import_hooks52 = __toESM(require_hooks(), 1);
50065 var import_compose42 = __toESM(require_compose(), 1);
50066 var import_element146 = __toESM(require_element(), 1);
50067 var import_i18n196 = __toESM(require_i18n(), 1);
50068 var import_block_editor64 = __toESM(require_block_editor(), 1);
50069 var import_components172 = __toESM(require_components(), 1);
50070 var import_data179 = __toESM(require_data(), 1);
50071 var import_jsx_runtime308 = __toESM(require_jsx_runtime(), 1);
50072 var SUPPORTED_BLOCKS = ["core/navigation-link", "core/navigation-submenu"];
50073 function NavigationViewButton({ attributes }) {
50074 const { kind, id, type } = attributes;
50075 const blockEditingMode = (0, import_block_editor64.useBlockEditingMode)();
50076 const onNavigateToEntityRecord = (0, import_data179.useSelect)(
50077 (select6) => select6(import_block_editor64.store).getSettings().onNavigateToEntityRecord,
50078 []
50079 );
50080 const onViewPage = (0, import_element146.useCallback)(() => {
50081 if (kind === "post-type" && type === "page" && id && onNavigateToEntityRecord) {
50082 onNavigateToEntityRecord({
50083 postId: id,
50084 postType: type
50085 });
50086 }
50087 }, [kind, id, type, onNavigateToEntityRecord]);
50088 if (kind !== "post-type" || type !== "page" || !id || !onNavigateToEntityRecord || blockEditingMode !== "contentOnly") {
50089 return null;
50090 }
50091 return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(import_block_editor64.__unstableBlockToolbarLastItem, { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(import_components172.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(
50092 import_components172.ToolbarButton,
50093 {
50094 name: "view",
50095 title: (0, import_i18n196.__)("View"),
50096 onClick: onViewPage,
50097 children: (0, import_i18n196.__)("View")
50098 }
50099 ) }) });
50100 }
50101 var withNavigationViewButton = (0, import_compose42.createHigherOrderComponent)(
50102 (BlockEdit2) => (props) => {
50103 const isSupportedBlock = SUPPORTED_BLOCKS.includes(props.name);
50104 return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(import_jsx_runtime308.Fragment, { children: [
50105 /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(BlockEdit2, { ...props }, "edit"),
50106 props.isSelected && isSupportedBlock && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(NavigationViewButton, { ...props })
50107 ] });
50108 },
50109 "withNavigationViewButton"
50110 );
50111 (0, import_hooks52.addFilter)(
50112 "editor.BlockEdit",
50113 "core/editor/with-navigation-view-button",
50114 withNavigationViewButton
50115 );
50116
50117 // packages/editor/build-module/hooks/template-part-navigation-edit-button.mjs
50118 var import_hooks53 = __toESM(require_hooks(), 1);
50119 var import_compose43 = __toESM(require_compose(), 1);
50120 var import_element147 = __toESM(require_element(), 1);
50121 var import_i18n197 = __toESM(require_i18n(), 1);
50122 var import_block_editor65 = __toESM(require_block_editor(), 1);
50123 var import_components173 = __toESM(require_components(), 1);
50124 var import_data180 = __toESM(require_data(), 1);
50125 var import_jsx_runtime309 = __toESM(require_jsx_runtime(), 1);
50126 var NAVIGATION_BLOCK_NAME = "core/navigation";
50127 var TEMPLATE_PART_BLOCK_NAME = "core/template-part";
50128 var BLOCK_INSPECTOR_AREA = "edit-post/block";
50129 function TemplatePartNavigationEditButton({ clientId }) {
50130 const registry = (0, import_data180.useRegistry)();
50131 const { selectBlock: selectBlock2, flashBlock } = (0, import_data180.useDispatch)(import_block_editor65.store);
50132 const { requestInspectorTab } = unlock((0, import_data180.useDispatch)(import_block_editor65.store));
50133 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data180.useDispatch)(store2);
50134 const {
50135 hasNavigationBlocks,
50136 firstNavigationBlockId,
50137 isNavigationEditable
50138 } = (0, import_data180.useSelect)(
50139 (select6) => {
50140 const {
50141 getClientIdsOfDescendants: getClientIdsOfDescendants2,
50142 getBlockName: getBlockName2,
50143 getBlockEditingMode
50144 } = select6(import_block_editor65.store);
50145 const descendants = getClientIdsOfDescendants2(clientId);
50146 const navigationBlocksInTemplatePart = descendants.filter(
50147 (blockId) => getBlockName2(blockId) === NAVIGATION_BLOCK_NAME
50148 );
50149 const _hasNavigationBlocks = navigationBlocksInTemplatePart.length > 0;
50150 const _firstNavigationBlockId = _hasNavigationBlocks ? navigationBlocksInTemplatePart[0] : null;
50151 return {
50152 hasNavigationBlocks: _hasNavigationBlocks,
50153 firstNavigationBlockId: _firstNavigationBlockId,
50154 // We can't use the useBlockEditingMode hook here because the current
50155 // context is the template part, not the navigation block.
50156 isNavigationEditable: getBlockEditingMode(_firstNavigationBlockId) !== "disabled"
50157 };
50158 },
50159 [clientId]
50160 );
50161 const onEditNavigation = (0, import_element147.useCallback)(() => {
50162 if (firstNavigationBlockId) {
50163 registry.batch(() => {
50164 selectBlock2(firstNavigationBlockId);
50165 flashBlock(firstNavigationBlockId, 500);
50166 enableComplementaryArea2("core", BLOCK_INSPECTOR_AREA);
50167 requestInspectorTab("list", {
50168 openPanel: firstNavigationBlockId
50169 });
50170 });
50171 }
50172 }, [
50173 firstNavigationBlockId,
50174 registry,
50175 selectBlock2,
50176 flashBlock,
50177 enableComplementaryArea2,
50178 requestInspectorTab
50179 ]);
50180 if (!hasNavigationBlocks || !isNavigationEditable) {
50181 return null;
50182 }
50183 return /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(import_block_editor65.__unstableBlockToolbarLastItem, { children: /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(import_components173.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(
50184 import_components173.ToolbarButton,
50185 {
50186 label: (0, import_i18n197.__)("Edit navigation"),
50187 onClick: onEditNavigation,
50188 children: (0, import_i18n197.__)("Edit navigation")
50189 }
50190 ) }) });
50191 }
50192 var withTemplatePartNavigationEditButton = (0, import_compose43.createHigherOrderComponent)(
50193 (BlockEdit2) => (props) => {
50194 const isTemplatePart2 = props.name === TEMPLATE_PART_BLOCK_NAME;
50195 return /* @__PURE__ */ (0, import_jsx_runtime309.jsxs)(import_jsx_runtime309.Fragment, { children: [
50196 /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(BlockEdit2, { ...props }, "edit"),
50197 props.isSelected && isTemplatePart2 && /* @__PURE__ */ (0, import_jsx_runtime309.jsx)(
50198 TemplatePartNavigationEditButton,
50199 {
50200 clientId: props.clientId
50201 }
50202 )
50203 ] });
50204 },
50205 "withTemplatePartNavigationEditButton"
50206 );
50207 (0, import_hooks53.addFilter)(
50208 "editor.BlockEdit",
50209 "core/editor/with-template-part-navigation-edit-button",
50210 withTemplatePartNavigationEditButton
50211 );
50212
50213 // packages/editor/build-module/hooks/push-changes-to-global-styles/index.mjs
50214 var import_hooks54 = __toESM(require_hooks(), 1);
50215 var import_compose44 = __toESM(require_compose(), 1);
50216 var import_block_editor66 = __toESM(require_block_editor(), 1);
50217 var import_components174 = __toESM(require_components(), 1);
50218 var import_i18n198 = __toESM(require_i18n(), 1);
50219 var import_blocks30 = __toESM(require_blocks(), 1);
50220 var import_element148 = __toESM(require_element(), 1);
50221 var import_data181 = __toESM(require_data(), 1);
50222 var import_notices26 = __toESM(require_notices(), 1);
50223 var import_core_data106 = __toESM(require_core_data(), 1);
50224
50225 // packages/editor/build-module/utils/set-nested-value.mjs
50226 function setNestedValue(object, path, value) {
50227 if (!object || typeof object !== "object") {
50228 return object;
50229 }
50230 path.reduce((acc, key, idx) => {
50231 if (acc[key] === void 0) {
50232 if (Number.isInteger(path[idx + 1])) {
50233 acc[key] = [];
50234 } else {
50235 acc[key] = {};
50236 }
50237 }
50238 if (idx === path.length - 1) {
50239 acc[key] = value;
50240 }
50241 return acc[key];
50242 }, object);
50243 return object;
50244 }
50245
50246 // packages/editor/build-module/hooks/push-changes-to-global-styles/index.mjs
50247 var import_jsx_runtime310 = __toESM(require_jsx_runtime(), 1);
50248 var { cleanEmptyObject: cleanEmptyObject3 } = unlock(import_block_editor66.privateApis);
50249 var STYLE_PROPERTY2 = {
50250 ...import_blocks30.__EXPERIMENTAL_STYLE_PROPERTY,
50251 blockGap: { value: ["spacing", "blockGap"] }
50252 };
50253 var STYLE_PATH_TO_CSS_VAR_INFIX = {
50254 "border.color": "color",
50255 "color.background": "color",
50256 "color.text": "color",
50257 "elements.link.color.text": "color",
50258 "elements.link.:hover.color.text": "color",
50259 "elements.link.typography.fontFamily": "font-family",
50260 "elements.link.typography.fontSize": "font-size",
50261 "elements.button.color.text": "color",
50262 "elements.button.color.background": "color",
50263 "elements.button.typography.fontFamily": "font-family",
50264 "elements.button.typography.fontSize": "font-size",
50265 "elements.caption.color.text": "color",
50266 "elements.heading.color": "color",
50267 "elements.heading.color.background": "color",
50268 "elements.heading.typography.fontFamily": "font-family",
50269 "elements.heading.gradient": "gradient",
50270 "elements.heading.color.gradient": "gradient",
50271 "elements.h1.color": "color",
50272 "elements.h1.color.background": "color",
50273 "elements.h1.typography.fontFamily": "font-family",
50274 "elements.h1.color.gradient": "gradient",
50275 "elements.h2.color": "color",
50276 "elements.h2.color.background": "color",
50277 "elements.h2.typography.fontFamily": "font-family",
50278 "elements.h2.color.gradient": "gradient",
50279 "elements.h3.color": "color",
50280 "elements.h3.color.background": "color",
50281 "elements.h3.typography.fontFamily": "font-family",
50282 "elements.h3.color.gradient": "gradient",
50283 "elements.h4.color": "color",
50284 "elements.h4.color.background": "color",
50285 "elements.h4.typography.fontFamily": "font-family",
50286 "elements.h4.color.gradient": "gradient",
50287 "elements.h5.color": "color",
50288 "elements.h5.color.background": "color",
50289 "elements.h5.typography.fontFamily": "font-family",
50290 "elements.h5.color.gradient": "gradient",
50291 "elements.h6.color": "color",
50292 "elements.h6.color.background": "color",
50293 "elements.h6.typography.fontFamily": "font-family",
50294 "elements.h6.color.gradient": "gradient",
50295 "color.gradient": "gradient",
50296 blockGap: "spacing",
50297 "typography.fontSize": "font-size",
50298 "typography.fontFamily": "font-family"
50299 };
50300 var STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
50301 "border.color": "borderColor",
50302 "color.background": "backgroundColor",
50303 "color.text": "textColor",
50304 "color.gradient": "gradient",
50305 "typography.fontSize": "fontSize",
50306 "typography.fontFamily": "fontFamily"
50307 };
50308 var SUPPORTED_STYLES = ["border", "color", "spacing", "typography"];
50309 var getValueFromObjectPath2 = (object, path) => {
50310 let value = object;
50311 path.forEach((fieldName) => {
50312 value = value?.[fieldName];
50313 });
50314 return value;
50315 };
50316 var flatBorderProperties = ["borderColor", "borderWidth", "borderStyle"];
50317 var sides2 = ["top", "right", "bottom", "left"];
50318 function getBorderStyleChanges(border, presetColor, userStyle) {
50319 if (!border && !presetColor) {
50320 return [];
50321 }
50322 const changes = [
50323 ...getFallbackBorderStyleChange("top", border, userStyle),
50324 ...getFallbackBorderStyleChange("right", border, userStyle),
50325 ...getFallbackBorderStyleChange("bottom", border, userStyle),
50326 ...getFallbackBorderStyleChange("left", border, userStyle)
50327 ];
50328 const { color: customColor, style, width } = border || {};
50329 const hasColorOrWidth = presetColor || customColor || width;
50330 if (hasColorOrWidth && !style) {
50331 sides2.forEach((side) => {
50332 if (!userStyle?.[side]?.style) {
50333 changes.push({
50334 path: ["border", side, "style"],
50335 value: "solid"
50336 });
50337 }
50338 });
50339 }
50340 return changes;
50341 }
50342 function getFallbackBorderStyleChange(side, border, globalBorderStyle) {
50343 if (!border?.[side] || globalBorderStyle?.[side]?.style) {
50344 return [];
50345 }
50346 const { color, style, width } = border[side];
50347 const hasColorOrWidth = color || width;
50348 if (!hasColorOrWidth || style) {
50349 return [];
50350 }
50351 return [{ path: ["border", side, "style"], value: "solid" }];
50352 }
50353 function useChangesToPush(name2, attributes, userConfig) {
50354 const supports = (0, import_data181.useSelect)(
50355 (select6) => {
50356 return unlock(select6(import_blocks30.store)).getSupportedStyles(name2);
50357 },
50358 [name2]
50359 );
50360 const blockUserConfig = userConfig?.styles?.blocks?.[name2];
50361 return (0, import_element148.useMemo)(() => {
50362 const changes = supports.flatMap((key) => {
50363 if (!STYLE_PROPERTY2[key]) {
50364 return [];
50365 }
50366 const { value: path } = STYLE_PROPERTY2[key];
50367 const presetAttributeKey = path.join(".");
50368 const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]];
50369 const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : getValueFromObjectPath2(attributes.style, path);
50370 if (key === "linkColor") {
50371 const linkChanges = value ? [{ path, value }] : [];
50372 const hoverPath = [
50373 "elements",
50374 "link",
50375 ":hover",
50376 "color",
50377 "text"
50378 ];
50379 const hoverValue = getValueFromObjectPath2(
50380 attributes.style,
50381 hoverPath
50382 );
50383 if (hoverValue) {
50384 linkChanges.push({ path: hoverPath, value: hoverValue });
50385 }
50386 return linkChanges;
50387 }
50388 if (flatBorderProperties.includes(key) && value) {
50389 const borderChanges = [{ path, value }];
50390 sides2.forEach((side) => {
50391 const currentPath = [...path];
50392 currentPath.splice(-1, 0, side);
50393 borderChanges.push({ path: currentPath, value });
50394 });
50395 return borderChanges;
50396 }
50397 return value ? [{ path, value }] : [];
50398 });
50399 getBorderStyleChanges(
50400 attributes.style?.border,
50401 attributes.borderColor,
50402 blockUserConfig?.border
50403 ).forEach((change) => changes.push(change));
50404 return changes;
50405 }, [supports, attributes, blockUserConfig]);
50406 }
50407 function PushChangesToGlobalStylesControl({
50408 name: name2,
50409 attributes,
50410 setAttributes
50411 }) {
50412 const { user: userConfig, setUser: setUserConfig } = useGlobalStyles();
50413 const changes = useChangesToPush(name2, attributes, userConfig);
50414 const { __unstableMarkNextChangeAsNotPersistent } = (0, import_data181.useDispatch)(import_block_editor66.store);
50415 const { createSuccessNotice } = (0, import_data181.useDispatch)(import_notices26.store);
50416 const pushChanges = (0, import_element148.useCallback)(() => {
50417 if (changes.length === 0) {
50418 return;
50419 }
50420 if (changes.length > 0) {
50421 const { style: blockStyles } = attributes;
50422 const newBlockStyles = structuredClone(blockStyles);
50423 const newUserConfig = structuredClone(userConfig);
50424 for (const { path, value } of changes) {
50425 setNestedValue(newBlockStyles, path, void 0);
50426 setNestedValue(
50427 newUserConfig,
50428 ["styles", "blocks", name2, ...path],
50429 value
50430 );
50431 }
50432 const newBlockAttributes = {
50433 borderColor: void 0,
50434 backgroundColor: void 0,
50435 textColor: void 0,
50436 gradient: void 0,
50437 fontSize: void 0,
50438 fontFamily: void 0,
50439 style: cleanEmptyObject3(newBlockStyles)
50440 };
50441 __unstableMarkNextChangeAsNotPersistent();
50442 setAttributes(newBlockAttributes);
50443 setUserConfig(newUserConfig, { undoIgnore: true });
50444 createSuccessNotice(
50445 (0, import_i18n198.sprintf)(
50446 // translators: %s: Title of the block e.g. 'Heading'.
50447 (0, import_i18n198.__)("%s styles applied."),
50448 (0, import_blocks30.getBlockType)(name2).title
50449 ),
50450 {
50451 type: "snackbar",
50452 actions: [
50453 {
50454 label: (0, import_i18n198.__)("Undo"),
50455 onClick() {
50456 __unstableMarkNextChangeAsNotPersistent();
50457 setAttributes(attributes);
50458 setUserConfig(userConfig, {
50459 undoIgnore: true
50460 });
50461 }
50462 }
50463 ]
50464 }
50465 );
50466 }
50467 }, [
50468 __unstableMarkNextChangeAsNotPersistent,
50469 attributes,
50470 changes,
50471 createSuccessNotice,
50472 name2,
50473 setAttributes,
50474 setUserConfig,
50475 userConfig
50476 ]);
50477 return /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)(
50478 import_components174.BaseControl,
50479 {
50480 className: "editor-push-changes-to-global-styles-control",
50481 help: (0, import_i18n198.sprintf)(
50482 // translators: %s: Title of the block e.g. 'Heading'.
50483 (0, import_i18n198.__)(
50484 "Apply this block\u2019s typography, spacing, dimensions, and color styles to all %s blocks."
50485 ),
50486 (0, import_blocks30.getBlockType)(name2).title
50487 ),
50488 children: [
50489 /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(import_components174.BaseControl.VisualLabel, { children: (0, import_i18n198.__)("Styles") }),
50490 /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(
50491 import_components174.Button,
50492 {
50493 __next40pxDefaultSize: true,
50494 variant: "secondary",
50495 accessibleWhenDisabled: true,
50496 disabled: changes.length === 0,
50497 onClick: pushChanges,
50498 children: (0, import_i18n198.__)("Apply globally")
50499 }
50500 )
50501 ]
50502 }
50503 );
50504 }
50505 function PushChangesToGlobalStyles(props) {
50506 const blockEditingMode = (0, import_block_editor66.useBlockEditingMode)();
50507 const isBlockBasedTheme = (0, import_data181.useSelect)(
50508 (select6) => select6(import_core_data106.store).getCurrentTheme()?.is_block_theme,
50509 []
50510 );
50511 const supportsStyles = SUPPORTED_STYLES.some(
50512 (feature) => (0, import_blocks30.hasBlockSupport)(props.name, feature)
50513 );
50514 const isDisplayed = blockEditingMode === "default" && supportsStyles && isBlockBasedTheme;
50515 if (!isDisplayed) {
50516 return null;
50517 }
50518 return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(import_block_editor66.InspectorAdvancedControls, { children: /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(PushChangesToGlobalStylesControl, { ...props }) });
50519 }
50520 var withPushChangesToGlobalStyles = (0, import_compose44.createHigherOrderComponent)(
50521 (BlockEdit2) => (props) => /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)(import_jsx_runtime310.Fragment, { children: [
50522 /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(BlockEdit2, { ...props }, "edit"),
50523 props.isSelected && /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(PushChangesToGlobalStyles, { ...props })
50524 ] })
50525 );
50526 (0, import_hooks54.addFilter)(
50527 "editor.BlockEdit",
50528 "core/editor/push-changes-to-global-styles",
50529 withPushChangesToGlobalStyles
50530 );
50531
50532 // packages/editor/build-module/components/header/back-button.mjs
50533 var import_components175 = __toESM(require_components(), 1);
50534 var import_jsx_runtime311 = __toESM(require_jsx_runtime(), 1);
50535 var slotName = "__experimentalMainDashboardButton";
50536 var useHasBackButton = () => {
50537 const fills = (0, import_components175.__experimentalUseSlotFills)(slotName);
50538 return Boolean(fills && fills.length);
50539 };
50540 var { Fill: Fill10, Slot: Slot10 } = (0, import_components175.createSlotFill)(slotName);
50541 var BackButton = Fill10;
50542 var BackButtonSlot = () => {
50543 const fills = (0, import_components175.__experimentalUseSlotFills)(slotName);
50544 return /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(
50545 Slot10,
50546 {
50547 bubblesVirtually: true,
50548 fillProps: { length: !fills ? 0 : fills.length }
50549 }
50550 );
50551 };
50552 BackButton.Slot = BackButtonSlot;
50553 var back_button_default = BackButton;
50554
50555 // packages/editor/build-module/components/editor/index.mjs
50556 var import_data246 = __toESM(require_data(), 1);
50557 var import_core_data136 = __toESM(require_core_data(), 1);
50558 var import_components255 = __toESM(require_components(), 1);
50559 var import_i18n277 = __toESM(require_i18n(), 1);
50560
50561 // packages/editor/build-module/components/editor-interface/index.mjs
50562 var import_data217 = __toESM(require_data(), 1);
50563 var import_i18n249 = __toESM(require_i18n(), 1);
50564 var import_preferences24 = __toESM(require_preferences(), 1);
50565 var import_block_editor83 = __toESM(require_block_editor(), 1);
50566 var import_compose65 = __toESM(require_compose(), 1);
50567 var import_element213 = __toESM(require_element(), 1);
50568 var import_html_entities27 = __toESM(require_html_entities(), 1);
50569 var import_notices31 = __toESM(require_notices(), 1);
50570
50571 // packages/editor/build-module/components/header/index.mjs
50572 var import_block_editor72 = __toESM(require_block_editor(), 1);
50573 var import_data192 = __toESM(require_data(), 1);
50574 var import_compose50 = __toESM(require_compose(), 1);
50575 var import_preferences21 = __toESM(require_preferences(), 1);
50576 var import_element161 = __toESM(require_element(), 1);
50577
50578 // packages/editor/build-module/components/collapsible-block-toolbar/index.mjs
50579 var import_block_editor67 = __toESM(require_block_editor(), 1);
50580 var import_element149 = __toESM(require_element(), 1);
50581 var import_components176 = __toESM(require_components(), 1);
50582 var import_i18n199 = __toESM(require_i18n(), 1);
50583 var import_data182 = __toESM(require_data(), 1);
50584 var import_jsx_runtime312 = __toESM(require_jsx_runtime(), 1);
50585 var { useHasBlockToolbar } = unlock(import_block_editor67.privateApis);
50586 function CollapsibleBlockToolbar({ isCollapsed, onToggle }) {
50587 const { blockSelectionStart } = (0, import_data182.useSelect)((select6) => {
50588 return {
50589 blockSelectionStart: select6(import_block_editor67.store).getBlockSelectionStart()
50590 };
50591 }, []);
50592 const hasBlockToolbar = useHasBlockToolbar();
50593 const hasBlockSelection = !!blockSelectionStart;
50594 (0, import_element149.useEffect)(() => {
50595 if (blockSelectionStart) {
50596 onToggle(false);
50597 }
50598 }, [blockSelectionStart, onToggle]);
50599 if (!hasBlockToolbar) {
50600 return null;
50601 }
50602 return /* @__PURE__ */ (0, import_jsx_runtime312.jsxs)(import_jsx_runtime312.Fragment, { children: [
50603 /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
50604 "div",
50605 {
50606 className: clsx_default("editor-collapsible-block-toolbar", {
50607 "is-collapsed": isCollapsed || !hasBlockSelection
50608 }),
50609 children: /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(import_block_editor67.BlockToolbar, { hideDragHandle: true })
50610 }
50611 ),
50612 /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(import_components176.Popover.Slot, { name: "block-toolbar" }),
50613 /* @__PURE__ */ (0, import_jsx_runtime312.jsx)(
50614 import_components176.Button,
50615 {
50616 className: "editor-collapsible-block-toolbar__toggle",
50617 icon: isCollapsed ? next_default : previous_default,
50618 onClick: () => {
50619 onToggle(!isCollapsed);
50620 },
50621 label: isCollapsed ? (0, import_i18n199.__)("Show block tools") : (0, import_i18n199.__)("Hide block tools"),
50622 size: "compact"
50623 }
50624 )
50625 ] });
50626 }
50627
50628 // packages/editor/build-module/components/document-tools/index.mjs
50629 var import_compose45 = __toESM(require_compose(), 1);
50630 var import_data183 = __toESM(require_data(), 1);
50631 var import_i18n200 = __toESM(require_i18n(), 1);
50632 var import_block_editor68 = __toESM(require_block_editor(), 1);
50633 var import_components177 = __toESM(require_components(), 1);
50634 var import_element150 = __toESM(require_element(), 1);
50635 var import_keyboard_shortcuts5 = __toESM(require_keyboard_shortcuts(), 1);
50636 var import_preferences15 = __toESM(require_preferences(), 1);
50637 var import_jsx_runtime313 = __toESM(require_jsx_runtime(), 1);
50638 function DocumentTools({ className, disableBlockTools = false }) {
50639 const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2 } = (0, import_data183.useDispatch)(store);
50640 const {
50641 isDistractionFree,
50642 isInserterOpened: isInserterOpened2,
50643 isListViewOpen,
50644 listViewShortcut,
50645 inserterSidebarToggleRef: inserterSidebarToggleRef2,
50646 listViewToggleRef: listViewToggleRef2,
50647 showIconLabels
50648 } = (0, import_data183.useSelect)((select6) => {
50649 const { get } = select6(import_preferences15.store);
50650 const {
50651 isListViewOpened: isListViewOpened2,
50652 getEditorMode: getEditorMode2,
50653 getInserterSidebarToggleRef: getInserterSidebarToggleRef2,
50654 getListViewToggleRef: getListViewToggleRef2
50655 } = unlock(select6(store));
50656 const { getShortcutRepresentation } = select6(import_keyboard_shortcuts5.store);
50657 return {
50658 isInserterOpened: select6(store).isInserterOpened(),
50659 isListViewOpen: isListViewOpened2(),
50660 listViewShortcut: getShortcutRepresentation(
50661 "core/editor/toggle-list-view"
50662 ),
50663 inserterSidebarToggleRef: getInserterSidebarToggleRef2(),
50664 listViewToggleRef: getListViewToggleRef2(),
50665 showIconLabels: get("core", "showIconLabels"),
50666 isDistractionFree: get("core", "distractionFree"),
50667 isVisualMode: getEditorMode2() === "visual"
50668 };
50669 }, []);
50670 const preventDefault = (event) => {
50671 if (isInserterOpened2) {
50672 event.preventDefault();
50673 }
50674 };
50675 const isWideViewport = (0, import_compose45.useViewportMatch)("wide");
50676 const toolbarAriaLabel = (0, import_i18n200.__)("Document tools");
50677 const toggleListView = (0, import_element150.useCallback)(
50678 () => setIsListViewOpened2(!isListViewOpen),
50679 [setIsListViewOpened2, isListViewOpen]
50680 );
50681 const toggleInserter = (0, import_element150.useCallback)(
50682 () => setIsInserterOpened2(!isInserterOpened2),
50683 [isInserterOpened2, setIsInserterOpened2]
50684 );
50685 const longLabel = (0, import_i18n200._x)(
50686 "Block Inserter",
50687 "Generic label for block inserter button"
50688 );
50689 const shortLabel = !isInserterOpened2 ? (0, import_i18n200.__)("Add") : (0, import_i18n200.__)("Close");
50690 return (
50691 // Some plugins expect and use the `edit-post-header-toolbar` CSS class to
50692 // find the toolbar and inject UI elements into it. This is not officially
50693 // supported, but we're keeping it in the list of class names for backwards
50694 // compatibility.
50695 /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
50696 import_block_editor68.NavigableToolbar,
50697 {
50698 className: clsx_default(
50699 "editor-document-tools",
50700 "edit-post-header-toolbar",
50701 className
50702 ),
50703 "aria-label": toolbarAriaLabel,
50704 variant: "unstyled",
50705 children: /* @__PURE__ */ (0, import_jsx_runtime313.jsxs)("div", { className: "editor-document-tools__left", children: [
50706 !isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
50707 import_components177.ToolbarButton,
50708 {
50709 ref: inserterSidebarToggleRef2,
50710 className: "editor-document-tools__inserter-toggle",
50711 variant: "primary",
50712 isPressed: isInserterOpened2,
50713 onMouseDown: preventDefault,
50714 onClick: toggleInserter,
50715 disabled: disableBlockTools,
50716 icon: plus_default,
50717 label: showIconLabels ? shortLabel : longLabel,
50718 showTooltip: !showIconLabels,
50719 "aria-expanded": isInserterOpened2
50720 }
50721 ),
50722 (isWideViewport || !showIconLabels) && /* @__PURE__ */ (0, import_jsx_runtime313.jsxs)(import_jsx_runtime313.Fragment, { children: [
50723 /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
50724 import_components177.ToolbarItem,
50725 {
50726 as: undo_default2,
50727 showTooltip: !showIconLabels,
50728 variant: showIconLabels ? "tertiary" : void 0,
50729 size: "compact"
50730 }
50731 ),
50732 /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
50733 import_components177.ToolbarItem,
50734 {
50735 as: redo_default2,
50736 showTooltip: !showIconLabels,
50737 variant: showIconLabels ? "tertiary" : void 0,
50738 size: "compact"
50739 }
50740 ),
50741 !isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
50742 import_components177.ToolbarButton,
50743 {
50744 className: "editor-document-tools__document-overview-toggle",
50745 icon: list_view_default,
50746 disabled: disableBlockTools,
50747 isPressed: isListViewOpen,
50748 label: (0, import_i18n200.__)("Document Overview"),
50749 onClick: toggleListView,
50750 shortcut: listViewShortcut,
50751 showTooltip: !showIconLabels,
50752 variant: showIconLabels ? "tertiary" : void 0,
50753 "aria-expanded": isListViewOpen,
50754 ref: listViewToggleRef2
50755 }
50756 )
50757 ] })
50758 ] })
50759 }
50760 )
50761 );
50762 }
50763 var document_tools_default = DocumentTools;
50764
50765 // packages/editor/build-module/components/header/header-skeleton.mjs
50766 var import_components178 = __toESM(require_components(), 1);
50767 var import_jsx_runtime314 = __toESM(require_jsx_runtime(), 1);
50768 var toolbarVariations = {
50769 distractionFreeDisabled: { y: "-50px" },
50770 distractionFreeHover: { y: 0 },
50771 distractionFreeHidden: { y: "-50px" },
50772 visible: { y: 0 },
50773 hidden: { y: 0 }
50774 };
50775 var backButtonVariations = {
50776 distractionFreeDisabled: { x: "-100%" },
50777 distractionFreeHover: { x: 0 },
50778 distractionFreeHidden: { x: "-100%" },
50779 visible: { x: 0 },
50780 hidden: { x: 0 }
50781 };
50782 function HeaderSkeleton({
50783 className,
50784 toolbar,
50785 center,
50786 settings
50787 }) {
50788 const hasBackButton = useHasBackButton();
50789 return /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)("div", { className: clsx_default("editor-header edit-post-header", className), children: [
50790 hasBackButton && /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
50791 import_components178.__unstableMotion.div,
50792 {
50793 className: "editor-header__back-button",
50794 variants: backButtonVariations,
50795 transition: { type: "tween" },
50796 children: /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(back_button_default.Slot, {})
50797 }
50798 ),
50799 /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
50800 import_components178.__unstableMotion.div,
50801 {
50802 variants: toolbarVariations,
50803 className: "editor-header__toolbar",
50804 transition: { type: "tween" },
50805 children: toolbar
50806 }
50807 ),
50808 center && /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
50809 import_components178.__unstableMotion.div,
50810 {
50811 variants: toolbarVariations,
50812 className: "editor-header__center",
50813 transition: { type: "tween" },
50814 children: center
50815 }
50816 ),
50817 /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
50818 import_components178.__unstableMotion.div,
50819 {
50820 variants: toolbarVariations,
50821 transition: { type: "tween" },
50822 className: "editor-header__settings",
50823 children: settings
50824 }
50825 )
50826 ] });
50827 }
50828
50829 // packages/editor/build-module/components/more-menu/index.mjs
50830 var import_i18n203 = __toESM(require_i18n(), 1);
50831 var import_data186 = __toESM(require_data(), 1);
50832 var import_keycodes13 = __toESM(require_keycodes(), 1);
50833 var import_components183 = __toESM(require_components(), 1);
50834 var import_preferences16 = __toESM(require_preferences(), 1);
50835
50836 // packages/editor/build-module/components/more-menu/copy-content-menu-item.mjs
50837 var import_components179 = __toESM(require_components(), 1);
50838 var import_data184 = __toESM(require_data(), 1);
50839 var import_i18n201 = __toESM(require_i18n(), 1);
50840 var import_compose46 = __toESM(require_compose(), 1);
50841 var import_notices27 = __toESM(require_notices(), 1);
50842 var import_core_data107 = __toESM(require_core_data(), 1);
50843 var import_blocks31 = __toESM(require_blocks(), 1);
50844 var import_jsx_runtime315 = __toESM(require_jsx_runtime(), 1);
50845 function CopyContentMenuItem() {
50846 const { createNotice } = (0, import_data184.useDispatch)(import_notices27.store);
50847 const { getCurrentPostId: getCurrentPostId2, getCurrentPostType: getCurrentPostType2 } = (0, import_data184.useSelect)(store);
50848 const { getEditedEntityRecord } = (0, import_data184.useSelect)(import_core_data107.store);
50849 function getText() {
50850 const record = getEditedEntityRecord(
50851 "postType",
50852 getCurrentPostType2(),
50853 getCurrentPostId2()
50854 );
50855 if (!record) {
50856 return "";
50857 }
50858 if (typeof record.content === "function") {
50859 return record.content(record);
50860 } else if (record.blocks) {
50861 return (0, import_blocks31.__unstableSerializeAndClean)(record.blocks);
50862 } else if (record.content) {
50863 return record.content;
50864 }
50865 }
50866 function onSuccess() {
50867 createNotice("info", (0, import_i18n201.__)("All content copied."), {
50868 isDismissible: true,
50869 type: "snackbar"
50870 });
50871 }
50872 const ref = (0, import_compose46.useCopyToClipboard)(getText, onSuccess);
50873 return /* @__PURE__ */ (0, import_jsx_runtime315.jsx)(import_components179.MenuItem, { ref, children: (0, import_i18n201.__)("Copy all blocks") });
50874 }
50875
50876 // packages/editor/build-module/components/mode-switcher/index.mjs
50877 var import_i18n202 = __toESM(require_i18n(), 1);
50878 var import_components180 = __toESM(require_components(), 1);
50879 var import_data185 = __toESM(require_data(), 1);
50880 var import_keyboard_shortcuts6 = __toESM(require_keyboard_shortcuts(), 1);
50881 var import_jsx_runtime316 = __toESM(require_jsx_runtime(), 1);
50882 var MODES = [
50883 {
50884 value: "visual",
50885 label: (0, import_i18n202.__)("Visual editor")
50886 },
50887 {
50888 value: "text",
50889 label: (0, import_i18n202.__)("Code editor")
50890 }
50891 ];
50892 function ModeSwitcher() {
50893 const { shortcut, isRichEditingEnabled, isCodeEditingEnabled, mode } = (0, import_data185.useSelect)(
50894 (select6) => ({
50895 shortcut: select6(
50896 import_keyboard_shortcuts6.store
50897 ).getShortcutRepresentation("core/editor/toggle-mode"),
50898 isRichEditingEnabled: select6(store).getEditorSettings().richEditingEnabled,
50899 isCodeEditingEnabled: select6(store).getEditorSettings().codeEditingEnabled,
50900 mode: select6(store).getEditorMode()
50901 }),
50902 []
50903 );
50904 const { switchEditorMode: switchEditorMode2 } = (0, import_data185.useDispatch)(store);
50905 let selectedMode = mode;
50906 if (!isRichEditingEnabled && mode === "visual") {
50907 selectedMode = "text";
50908 }
50909 if (!isCodeEditingEnabled && mode === "text") {
50910 selectedMode = "visual";
50911 }
50912 const choices = MODES.map((choice) => {
50913 if (!isCodeEditingEnabled && choice.value === "text") {
50914 choice = {
50915 ...choice,
50916 disabled: true
50917 };
50918 }
50919 if (!isRichEditingEnabled && choice.value === "visual") {
50920 choice = {
50921 ...choice,
50922 disabled: true,
50923 info: (0, import_i18n202.__)(
50924 "You can enable the visual editor in your profile settings."
50925 )
50926 };
50927 }
50928 if (choice.value !== selectedMode && !choice.disabled) {
50929 return { ...choice, shortcut };
50930 }
50931 return choice;
50932 });
50933 return /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components180.MenuGroup, { label: (0, import_i18n202.__)("Editor"), children: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
50934 import_components180.MenuItemsChoice,
50935 {
50936 choices,
50937 value: selectedMode,
50938 onSelect: switchEditorMode2
50939 }
50940 ) });
50941 }
50942 var mode_switcher_default = ModeSwitcher;
50943
50944 // packages/editor/build-module/components/more-menu/tools-more-menu-group.mjs
50945 var import_components181 = __toESM(require_components(), 1);
50946 var import_jsx_runtime317 = __toESM(require_jsx_runtime(), 1);
50947 var { Fill: ToolsMoreMenuGroup, Slot: Slot11 } = (0, import_components181.createSlotFill)("ToolsMoreMenuGroup");
50948 ToolsMoreMenuGroup.Slot = ({ fillProps }) => /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(Slot11, { fillProps });
50949 var tools_more_menu_group_default = ToolsMoreMenuGroup;
50950
50951 // packages/editor/build-module/components/more-menu/view-more-menu-group.mjs
50952 var import_components182 = __toESM(require_components(), 1);
50953 var import_element151 = __toESM(require_element(), 1);
50954 var import_jsx_runtime318 = __toESM(require_jsx_runtime(), 1);
50955 var { Fill: ViewMoreMenuGroup, Slot: Slot12 } = (0, import_components182.createSlotFill)(
50956 import_element151.Platform.OS === "web" ? /* @__PURE__ */ Symbol("ViewMoreMenuGroup") : "ViewMoreMenuGroup"
50957 );
50958 ViewMoreMenuGroup.Slot = ({ fillProps }) => /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(Slot12, { fillProps });
50959 var view_more_menu_group_default = ViewMoreMenuGroup;
50960
50961 // packages/editor/build-module/components/more-menu/index.mjs
50962 var import_jsx_runtime319 = __toESM(require_jsx_runtime(), 1);
50963 function MoreMenu({ disabled = false }) {
50964 const { openModal: openModal2 } = (0, import_data186.useDispatch)(store2);
50965 const { set: setPreference } = (0, import_data186.useDispatch)(import_preferences16.store);
50966 const { toggleDistractionFree: toggleDistractionFree2 } = (0, import_data186.useDispatch)(store);
50967 const showIconLabels = (0, import_data186.useSelect)(
50968 (select6) => select6(import_preferences16.store).get("core", "showIconLabels"),
50969 []
50970 );
50971 const turnOffDistractionFree = () => {
50972 setPreference("core", "distractionFree", false);
50973 };
50974 return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(import_jsx_runtime319.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
50975 import_components183.DropdownMenu,
50976 {
50977 icon: more_vertical_default,
50978 label: (0, import_i18n203.__)("Options"),
50979 popoverProps: {
50980 placement: "bottom-end",
50981 className: "more-menu-dropdown__content"
50982 },
50983 toggleProps: {
50984 showTooltip: !showIconLabels,
50985 ...showIconLabels && { variant: "tertiary" },
50986 tooltipPosition: "bottom",
50987 size: "compact",
50988 disabled
50989 },
50990 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)(import_jsx_runtime319.Fragment, { children: [
50991 /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)(import_components183.MenuGroup, { label: (0, import_i18n203._x)("View", "noun"), children: [
50992 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
50993 import_preferences16.PreferenceToggleMenuItem,
50994 {
50995 scope: "core",
50996 name: "fixedToolbar",
50997 onToggle: turnOffDistractionFree,
50998 label: (0, import_i18n203.__)("Top toolbar"),
50999 info: (0, import_i18n203.__)(
51000 "Access all block and document tools in a single place"
51001 ),
51002 messageActivated: (0, import_i18n203.__)(
51003 "Top toolbar activated."
51004 ),
51005 messageDeactivated: (0, import_i18n203.__)(
51006 "Top toolbar deactivated."
51007 )
51008 }
51009 ),
51010 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
51011 import_preferences16.PreferenceToggleMenuItem,
51012 {
51013 scope: "core",
51014 name: "distractionFree",
51015 label: (0, import_i18n203.__)("Distraction free"),
51016 info: (0, import_i18n203.__)("Write with calmness"),
51017 handleToggling: false,
51018 onToggle: () => toggleDistractionFree2({
51019 createNotice: false
51020 }),
51021 messageActivated: (0, import_i18n203.__)(
51022 "Distraction free mode activated."
51023 ),
51024 messageDeactivated: (0, import_i18n203.__)(
51025 "Distraction free mode deactivated."
51026 ),
51027 shortcut: import_keycodes13.displayShortcut.primaryShift(
51028 "\\"
51029 )
51030 }
51031 ),
51032 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
51033 import_preferences16.PreferenceToggleMenuItem,
51034 {
51035 scope: "core",
51036 name: "focusMode",
51037 label: (0, import_i18n203.__)("Spotlight mode"),
51038 info: (0, import_i18n203.__)("Focus on one block at a time"),
51039 messageActivated: (0, import_i18n203.__)(
51040 "Spotlight mode activated."
51041 ),
51042 messageDeactivated: (0, import_i18n203.__)(
51043 "Spotlight mode deactivated."
51044 )
51045 }
51046 ),
51047 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(view_more_menu_group_default.Slot, { fillProps: { onClose } })
51048 ] }),
51049 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(mode_switcher_default, {}),
51050 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
51051 action_item_default.Slot,
51052 {
51053 name: "core/plugin-more-menu",
51054 label: (0, import_i18n203.__)("Panels"),
51055 fillProps: { onClick: onClose }
51056 }
51057 ),
51058 /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)(import_components183.MenuGroup, { label: (0, import_i18n203.__)("Tools"), children: [
51059 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
51060 import_components183.MenuItem,
51061 {
51062 onClick: () => openModal2("editor/keyboard-shortcut-help"),
51063 shortcut: import_keycodes13.displayShortcut.access("h"),
51064 children: (0, import_i18n203.__)("Keyboard shortcuts")
51065 }
51066 ),
51067 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(CopyContentMenuItem, {}),
51068 /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)(
51069 import_components183.MenuItem,
51070 {
51071 icon: external_default,
51072 href: (0, import_i18n203.__)(
51073 "https://wordpress.org/documentation/article/wordpress-block-editor/"
51074 ),
51075 target: "_blank",
51076 rel: "noopener noreferrer",
51077 children: [
51078 (0, import_i18n203.__)("Help"),
51079 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(import_components183.VisuallyHidden, {
51080 as: "span",
51081 /* translators: accessibility text */
51082 children: (0, import_i18n203.__)("(opens in a new tab)")
51083 })
51084 ]
51085 }
51086 ),
51087 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
51088 tools_more_menu_group_default.Slot,
51089 {
51090 fillProps: { onClose }
51091 }
51092 )
51093 ] }),
51094 /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(import_components183.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
51095 import_components183.MenuItem,
51096 {
51097 onClick: () => openModal2("editor/preferences"),
51098 children: (0, import_i18n203.__)("Preferences")
51099 }
51100 ) })
51101 ] })
51102 }
51103 ) });
51104 }
51105
51106 // packages/editor/build-module/components/post-publish-button/post-publish-button-or-toggle.mjs
51107 var import_compose47 = __toESM(require_compose(), 1);
51108 var import_data187 = __toESM(require_data(), 1);
51109 var import_jsx_runtime320 = __toESM(require_jsx_runtime(), 1);
51110 var IS_TOGGLE = "toggle";
51111 var IS_BUTTON = "button";
51112 function PostPublishButtonOrToggle({
51113 forceIsDirty,
51114 setEntitiesSavedStatesCallback
51115 }) {
51116 let component;
51117 const isSmallerThanMediumViewport = (0, import_compose47.useViewportMatch)("medium", "<");
51118 const { togglePublishSidebar: togglePublishSidebar2 } = (0, import_data187.useDispatch)(store);
51119 const {
51120 hasPublishAction,
51121 isBeingScheduled,
51122 isPending,
51123 isPublished,
51124 isPublishSidebarEnabled: isPublishSidebarEnabled2,
51125 isPublishSidebarOpened: isPublishSidebarOpened2,
51126 isScheduled,
51127 postStatus,
51128 postStatusHasChanged,
51129 postType: postType2
51130 } = (0, import_data187.useSelect)((select6) => {
51131 return {
51132 hasPublishAction: !!select6(store).getCurrentPost()?._links?.["wp:action-publish"],
51133 isBeingScheduled: select6(store).isEditedPostBeingScheduled(),
51134 isPending: select6(store).isCurrentPostPending(),
51135 isPublished: select6(store).isCurrentPostPublished(),
51136 isPublishSidebarEnabled: select6(store).isPublishSidebarEnabled(),
51137 isPublishSidebarOpened: select6(store).isPublishSidebarOpened(),
51138 isScheduled: select6(store).isCurrentPostScheduled(),
51139 postStatus: select6(store).getEditedPostAttribute("status"),
51140 postStatusHasChanged: select6(store).getPostEdits()?.status,
51141 postType: select6(store).getCurrentPostType()
51142 };
51143 }, []);
51144 if (postType2 === ATTACHMENT_POST_TYPE) {
51145 component = IS_BUTTON;
51146 } else if (isPublished || postStatusHasChanged && !["future", "publish"].includes(postStatus) || isScheduled && isBeingScheduled || isPending && !hasPublishAction && !isSmallerThanMediumViewport) {
51147 component = IS_BUTTON;
51148 } else if (isSmallerThanMediumViewport || isPublishSidebarEnabled2) {
51149 component = IS_TOGGLE;
51150 } else {
51151 component = IS_BUTTON;
51152 }
51153 return /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(
51154 post_publish_button_default,
51155 {
51156 forceIsDirty,
51157 isOpen: isPublishSidebarOpened2,
51158 isToggle: component === IS_TOGGLE,
51159 onToggle: togglePublishSidebar2,
51160 setEntitiesSavedStatesCallback
51161 }
51162 );
51163 }
51164
51165 // packages/editor/build-module/components/post-view-link/index.mjs
51166 var import_i18n204 = __toESM(require_i18n(), 1);
51167 var import_components184 = __toESM(require_components(), 1);
51168 var import_core_data108 = __toESM(require_core_data(), 1);
51169 var import_data188 = __toESM(require_data(), 1);
51170 var import_preferences17 = __toESM(require_preferences(), 1);
51171 var import_jsx_runtime321 = __toESM(require_jsx_runtime(), 1);
51172 function PostViewLink() {
51173 const { hasLoaded, permalink, isPublished, label, showIconLabels } = (0, import_data188.useSelect)((select6) => {
51174 const postTypeSlug = select6(store).getCurrentPostType();
51175 const postType2 = select6(import_core_data108.store).getPostType(postTypeSlug);
51176 const { get } = select6(import_preferences17.store);
51177 return {
51178 permalink: select6(store).getPermalink(),
51179 isPublished: select6(store).isCurrentPostPublished(),
51180 label: postType2?.labels.view_item,
51181 hasLoaded: !!postType2,
51182 showIconLabels: get("core", "showIconLabels")
51183 };
51184 }, []);
51185 if (!isPublished || !permalink || !hasLoaded) {
51186 return null;
51187 }
51188 return /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
51189 import_components184.Button,
51190 {
51191 icon: external_default,
51192 label: label || (0, import_i18n204.__)("View post"),
51193 href: permalink,
51194 target: "_blank",
51195 showTooltip: !showIconLabels,
51196 size: "compact"
51197 }
51198 );
51199 }
51200
51201 // packages/editor/build-module/components/preview-dropdown/index.mjs
51202 var import_compose48 = __toESM(require_compose(), 1);
51203 var import_components185 = __toESM(require_components(), 1);
51204 var import_i18n205 = __toESM(require_i18n(), 1);
51205 var import_data189 = __toESM(require_data(), 1);
51206 var import_core_data109 = __toESM(require_core_data(), 1);
51207 var import_preferences18 = __toESM(require_preferences(), 1);
51208 var import_block_editor69 = __toESM(require_block_editor(), 1);
51209 var import_jsx_runtime322 = __toESM(require_jsx_runtime(), 1);
51210 function PreviewDropdown({ forceIsAutosaveable, disabled }) {
51211 const {
51212 deviceType: deviceType2,
51213 homeUrl,
51214 isTemplate: isTemplate2,
51215 isViewable,
51216 showIconLabels,
51217 isTemplateHidden,
51218 templateId: templateId2
51219 } = (0, import_data189.useSelect)((select6) => {
51220 const {
51221 getDeviceType: getDeviceType2,
51222 getCurrentPostType: getCurrentPostType2,
51223 getCurrentTemplateId: getCurrentTemplateId2,
51224 getRenderingMode: getRenderingMode2
51225 } = select6(store);
51226 const { getEntityRecord, getPostType } = select6(import_core_data109.store);
51227 const { get } = select6(import_preferences18.store);
51228 const _currentPostType = getCurrentPostType2();
51229 return {
51230 deviceType: getDeviceType2(),
51231 homeUrl: getEntityRecord("root", "__unstableBase")?.home,
51232 isTemplate: _currentPostType === "wp_template",
51233 isViewable: getPostType(_currentPostType)?.viewable ?? false,
51234 showIconLabels: get("core", "showIconLabels"),
51235 isTemplateHidden: getRenderingMode2() === "post-only",
51236 templateId: getCurrentTemplateId2()
51237 };
51238 }, []);
51239 const { setDeviceType: setDeviceType2, setRenderingMode: setRenderingMode2, setDefaultRenderingMode: setDefaultRenderingMode2 } = unlock(
51240 (0, import_data189.useDispatch)(store)
51241 );
51242 const { resetZoomLevel } = unlock((0, import_data189.useDispatch)(import_block_editor69.store));
51243 const handleDevicePreviewChange = (newDeviceType) => {
51244 setDeviceType2(newDeviceType);
51245 resetZoomLevel();
51246 };
51247 const isMobile = (0, import_compose48.useViewportMatch)("medium", "<");
51248 if (isMobile) {
51249 return null;
51250 }
51251 const popoverProps = {
51252 placement: "bottom-end"
51253 };
51254 const toggleProps = {
51255 className: "editor-preview-dropdown__toggle",
51256 iconPosition: "right",
51257 size: "compact",
51258 showTooltip: !showIconLabels,
51259 disabled,
51260 accessibleWhenDisabled: disabled
51261 };
51262 const menuProps = {
51263 "aria-label": (0, import_i18n205.__)("View options")
51264 };
51265 const deviceIcons = {
51266 desktop: desktop_default,
51267 mobile: mobile_default,
51268 tablet: tablet_default
51269 };
51270 const choices = [
51271 {
51272 value: "Desktop",
51273 label: (0, import_i18n205.__)("Desktop"),
51274 icon: desktop_default
51275 },
51276 {
51277 value: "Tablet",
51278 label: (0, import_i18n205.__)("Tablet"),
51279 icon: tablet_default
51280 },
51281 {
51282 value: "Mobile",
51283 label: (0, import_i18n205.__)("Mobile"),
51284 icon: mobile_default
51285 }
51286 ];
51287 return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
51288 import_components185.DropdownMenu,
51289 {
51290 className: clsx_default(
51291 "editor-preview-dropdown",
51292 `editor-preview-dropdown--${deviceType2.toLowerCase()}`
51293 ),
51294 popoverProps,
51295 toggleProps,
51296 menuProps,
51297 icon: deviceIcons[deviceType2.toLowerCase()],
51298 label: (0, import_i18n205.__)("View"),
51299 disableOpenOnArrowDown: disabled,
51300 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime322.jsxs)(import_jsx_runtime322.Fragment, { children: [
51301 /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(import_components185.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
51302 import_components185.MenuItemsChoice,
51303 {
51304 choices,
51305 value: deviceType2,
51306 onSelect: handleDevicePreviewChange
51307 }
51308 ) }),
51309 isTemplate2 && /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(import_components185.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime322.jsxs)(
51310 import_components185.MenuItem,
51311 {
51312 href: homeUrl,
51313 target: "_blank",
51314 icon: external_default,
51315 onClick: onClose,
51316 children: [
51317 (0, import_i18n205.__)("View site"),
51318 /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(import_components185.VisuallyHidden, {
51319 as: "span",
51320 /* translators: accessibility text */
51321 children: (0, import_i18n205.__)("(opens in a new tab)")
51322 })
51323 ]
51324 }
51325 ) }),
51326 !isTemplate2 && !!templateId2 && /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(import_components185.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
51327 import_components185.MenuItem,
51328 {
51329 icon: !isTemplateHidden ? check_default : void 0,
51330 isSelected: !isTemplateHidden,
51331 role: "menuitemcheckbox",
51332 onClick: () => {
51333 const newRenderingMode = isTemplateHidden ? "template-locked" : "post-only";
51334 setRenderingMode2(newRenderingMode);
51335 setDefaultRenderingMode2(newRenderingMode);
51336 resetZoomLevel();
51337 },
51338 children: (0, import_i18n205.__)("Show template")
51339 }
51340 ) }),
51341 isViewable && /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(import_components185.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
51342 PostPreviewButton,
51343 {
51344 className: "editor-preview-dropdown__button-external",
51345 role: "menuitem",
51346 forceIsAutosaveable,
51347 "aria-label": (0, import_i18n205.__)("Preview in new tab"),
51348 textContent: /* @__PURE__ */ (0, import_jsx_runtime322.jsxs)(import_jsx_runtime322.Fragment, { children: [
51349 (0, import_i18n205.__)("Preview in new tab"),
51350 /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(import_components185.Icon, { icon: external_default })
51351 ] }),
51352 onPreview: onClose
51353 }
51354 ) }),
51355 /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
51356 action_item_default.Slot,
51357 {
51358 name: "core/plugin-preview-menu",
51359 fillProps: { onClick: onClose }
51360 }
51361 )
51362 ] })
51363 }
51364 );
51365 }
51366
51367 // packages/editor/build-module/components/zoom-out-toggle/index.mjs
51368 var import_components186 = __toESM(require_components(), 1);
51369 var import_i18n206 = __toESM(require_i18n(), 1);
51370 var import_element152 = __toESM(require_element(), 1);
51371 var import_data190 = __toESM(require_data(), 1);
51372 var import_block_editor70 = __toESM(require_block_editor(), 1);
51373 var import_preferences19 = __toESM(require_preferences(), 1);
51374 var import_keyboard_shortcuts7 = __toESM(require_keyboard_shortcuts(), 1);
51375 var import_keycodes14 = __toESM(require_keycodes(), 1);
51376 var import_jsx_runtime323 = __toESM(require_jsx_runtime(), 1);
51377 var ZoomOutToggle = ({ disabled }) => {
51378 const { isZoomOut, showIconLabels, isDistractionFree } = (0, import_data190.useSelect)(
51379 (select6) => ({
51380 isZoomOut: unlock(select6(import_block_editor70.store)).isZoomOut(),
51381 showIconLabels: select6(import_preferences19.store).get(
51382 "core",
51383 "showIconLabels"
51384 ),
51385 isDistractionFree: select6(import_preferences19.store).get(
51386 "core",
51387 "distractionFree"
51388 )
51389 })
51390 );
51391 const { resetZoomLevel, setZoomLevel } = unlock(
51392 (0, import_data190.useDispatch)(import_block_editor70.store)
51393 );
51394 const { registerShortcut, unregisterShortcut } = (0, import_data190.useDispatch)(
51395 import_keyboard_shortcuts7.store
51396 );
51397 (0, import_element152.useEffect)(() => {
51398 registerShortcut({
51399 name: "core/editor/zoom",
51400 category: "global",
51401 description: (0, import_i18n206.__)("Enter or exit zoom out."),
51402 keyCombination: {
51403 // `primaryShift+0` (`ctrl+shift+0`) is the shortcut for switching
51404 // to input mode in Windows, so apply a different key combination.
51405 modifier: (0, import_keycodes14.isAppleOS)() ? "primaryShift" : "secondary",
51406 character: "0"
51407 }
51408 });
51409 return () => {
51410 unregisterShortcut("core/editor/zoom");
51411 };
51412 }, [registerShortcut, unregisterShortcut]);
51413 (0, import_keyboard_shortcuts7.useShortcut)(
51414 "core/editor/zoom",
51415 () => {
51416 if (isZoomOut) {
51417 resetZoomLevel();
51418 } else {
51419 setZoomLevel("auto-scaled");
51420 }
51421 },
51422 {
51423 isDisabled: isDistractionFree
51424 }
51425 );
51426 const handleZoomOut = () => {
51427 if (isZoomOut) {
51428 resetZoomLevel();
51429 } else {
51430 setZoomLevel("auto-scaled");
51431 }
51432 };
51433 return /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(
51434 import_components186.Button,
51435 {
51436 accessibleWhenDisabled: true,
51437 disabled,
51438 onClick: handleZoomOut,
51439 icon: square_default,
51440 label: (0, import_i18n206.__)("Zoom Out"),
51441 isPressed: isZoomOut,
51442 size: "compact",
51443 showTooltip: !showIconLabels,
51444 className: "editor-zoom-out-toggle"
51445 }
51446 );
51447 };
51448 var zoom_out_toggle_default = ZoomOutToggle;
51449
51450 // packages/editor/build-module/components/collaborators-presence/index.mjs
51451 var import_components189 = __toESM(require_components(), 1);
51452 var import_element160 = __toESM(require_element(), 1);
51453 var import_core_data113 = __toESM(require_core_data(), 1);
51454 var import_i18n211 = __toESM(require_i18n(), 1);
51455
51456 // packages/editor/build-module/components/collaborators-presence/avatar/component.mjs
51457 var import_components187 = __toESM(require_components(), 1);
51458 var import_element154 = __toESM(require_element(), 1);
51459
51460 // packages/editor/build-module/components/collaborators-presence/avatar/use-image-loading-status.mjs
51461 var import_element153 = __toESM(require_element(), 1);
51462 function useImageLoadingStatus(src) {
51463 const [prevSrc, setPrevSrc] = (0, import_element153.useState)(src);
51464 const [status, setStatus] = (0, import_element153.useState)(
51465 src ? "loading" : "idle"
51466 );
51467 if (prevSrc !== src) {
51468 setPrevSrc(src);
51469 setStatus(src ? "loading" : "idle");
51470 }
51471 const handleLoad = (0, import_element153.useCallback)(() => setStatus("loaded"), []);
51472 const handleError = (0, import_element153.useCallback)(() => setStatus("error"), []);
51473 return { status, handleLoad, handleError };
51474 }
51475
51476 // packages/editor/build-module/components/collaborators-presence/avatar/component.mjs
51477 var import_jsx_runtime324 = __toESM(require_jsx_runtime(), 1);
51478 k([a11y_default]);
51479 var GRAY_900 = "#1e1e1e";
51480 var WHITE = "#fff";
51481 function Avatar({
51482 className,
51483 src,
51484 name: name2,
51485 label,
51486 variant,
51487 size: size3 = "default",
51488 borderColor,
51489 dimmed = false,
51490 statusIndicator,
51491 style,
51492 ...props
51493 }) {
51494 const {
51495 status: imageStatus,
51496 handleLoad,
51497 handleError
51498 } = useImageLoadingStatus(src);
51499 const imageLoaded = imageStatus === "loaded";
51500 const showBadge = variant === "badge" && !!name2;
51501 const initials = name2 ? name2.split(/\s+/).slice(0, 2).map((word) => word[0]).join("").toUpperCase() : void 0;
51502 const nameColor = (0, import_element154.useMemo)(
51503 () => borderColor && w2(borderColor).isReadable(GRAY_900, {
51504 level: "AA",
51505 size: "normal"
51506 }) ? GRAY_900 : WHITE,
51507 [borderColor]
51508 );
51509 const customProperties = {
51510 ...style,
51511 ...borderColor ? {
51512 "--editor-avatar-outline-color": borderColor,
51513 "--editor-avatar-name-color": nameColor
51514 } : {}
51515 };
51516 const avatar = /* @__PURE__ */ (0, import_jsx_runtime324.jsxs)(
51517 "div",
51518 {
51519 className: clsx_default("editor-avatar", className, {
51520 "has-avatar-border-color": !!borderColor,
51521 "has-src": imageLoaded,
51522 "is-badge": showBadge,
51523 "is-small": size3 === "small",
51524 "is-dimmed": dimmed
51525 }),
51526 style: customProperties,
51527 role: name2 ? "img" : void 0,
51528 "aria-label": name2 || void 0,
51529 ...props,
51530 children: [
51531 /* @__PURE__ */ (0, import_jsx_runtime324.jsxs)("span", { className: "editor-avatar__image", children: [
51532 src && /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(
51533 "img",
51534 {
51535 src,
51536 alt: "",
51537 crossOrigin: "anonymous",
51538 className: "editor-avatar__img",
51539 onLoad: handleLoad,
51540 onError: handleError
51541 }
51542 ),
51543 !imageLoaded && initials
51544 ] }),
51545 dimmed && !!statusIndicator && /* @__PURE__ */ (0, import_jsx_runtime324.jsx)("span", { className: "editor-avatar__status-indicator", children: /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(import_components187.Icon, { icon: statusIndicator }) }),
51546 showBadge && /* @__PURE__ */ (0, import_jsx_runtime324.jsx)("span", { className: "editor-avatar__name", children: label || name2 })
51547 ]
51548 }
51549 );
51550 if (name2 && (!showBadge || label)) {
51551 return /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(import_components187.Tooltip, { text: name2, children: avatar });
51552 }
51553 return avatar;
51554 }
51555 var component_default = Avatar;
51556
51557 // packages/editor/build-module/components/collaborators-presence/avatar-group/component.mjs
51558 var import_element155 = __toESM(require_element(), 1);
51559 var import_i18n207 = __toESM(require_i18n(), 1);
51560 var import_jsx_runtime325 = __toESM(require_jsx_runtime(), 1);
51561 function AvatarGroup({
51562 className,
51563 max: max2 = 3,
51564 children,
51565 ...props
51566 }) {
51567 const childArray = import_element155.Children.toArray(children);
51568 const visible = childArray.slice(0, max2);
51569 const overflowCount = childArray.length - max2;
51570 return /* @__PURE__ */ (0, import_jsx_runtime325.jsxs)(
51571 "div",
51572 {
51573 role: "group",
51574 className: clsx_default("editor-avatar-group", className),
51575 ...props,
51576 children: [
51577 visible,
51578 overflowCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(
51579 "span",
51580 {
51581 className: "editor-avatar-group__overflow",
51582 "aria-label": (0, import_i18n207.sprintf)(
51583 /* translators: %d: number of additional collaborators not shown */
51584 (0, import_i18n207._n)(
51585 "%d more collaborator",
51586 "%d more collaborators",
51587 overflowCount
51588 ),
51589 overflowCount
51590 ),
51591 children: `+${overflowCount}`
51592 }
51593 )
51594 ]
51595 }
51596 );
51597 }
51598 var component_default2 = AvatarGroup;
51599
51600 // packages/editor/build-module/components/collaborators-presence/list.mjs
51601 var import_i18n209 = __toESM(require_i18n(), 1);
51602 var import_components188 = __toESM(require_components(), 1);
51603 var import_a11y7 = __toESM(require_a11y(), 1);
51604
51605 // packages/editor/build-module/components/collaborators-overlay/get-avatar-url.mjs
51606 function getAvatarUrl(avatarUrls) {
51607 return avatarUrls?.["48"] || avatarUrls?.["96"] || avatarUrls?.["24"];
51608 }
51609
51610 // packages/editor/build-module/components/collab-sidebar/utils.mjs
51611 var import_i18n208 = __toESM(require_i18n(), 1);
51612 function sanitizeCommentString(str) {
51613 return str.trim();
51614 }
51615 function noop7() {
51616 }
51617 var AVATAR_BORDER_COLORS = [
51618 "#C36EFF",
51619 // Purple
51620 "#FF51A8",
51621 // Pink
51622 "#E4780A",
51623 // Orange
51624 "#FF35EE",
51625 // Magenta
51626 "#879F11",
51627 // Olive
51628 "#46A494",
51629 // Teal
51630 "#00A2C3"
51631 // Cyan
51632 ];
51633 function getAvatarBorderColor(userId) {
51634 return AVATAR_BORDER_COLORS[userId % AVATAR_BORDER_COLORS.length];
51635 }
51636 function getCommentExcerpt(text, excerptLength = 10) {
51637 if (!text) {
51638 return "";
51639 }
51640 const wordCountType = (0, import_i18n208._x)("words", "Word count type. Do not translate!");
51641 const rawText = text.trim();
51642 let trimmedExcerpt = "";
51643 if (wordCountType === "words") {
51644 trimmedExcerpt = rawText.split(" ", excerptLength).join(" ");
51645 } else if (wordCountType === "characters_excluding_spaces") {
51646 const textWithSpaces = rawText.split("", excerptLength).join("");
51647 const numberOfSpaces = textWithSpaces.length - textWithSpaces.replaceAll(" ", "").length;
51648 trimmedExcerpt = rawText.split("", excerptLength + numberOfSpaces).join("");
51649 } else if (wordCountType === "characters_including_spaces") {
51650 trimmedExcerpt = rawText.split("", excerptLength).join("");
51651 }
51652 const isTrimmed = trimmedExcerpt !== rawText;
51653 return isTrimmed ? trimmedExcerpt + "\u2026" : trimmedExcerpt;
51654 }
51655 function focusCommentThread(commentId, container, additionalSelector) {
51656 if (!container) {
51657 return;
51658 }
51659 const threadSelector = commentId && commentId !== "new" ? `[role=treeitem][id="comment-thread-${commentId}"]` : "[role=treeitem]:not([id])";
51660 const selector = additionalSelector ? `${threadSelector} ${additionalSelector}` : threadSelector;
51661 return new Promise((resolve) => {
51662 if (container.querySelector(selector)) {
51663 return resolve(container.querySelector(selector));
51664 }
51665 let timer = null;
51666 const observer = new window.MutationObserver(() => {
51667 if (container.querySelector(selector)) {
51668 clearTimeout(timer);
51669 observer.disconnect();
51670 resolve(container.querySelector(selector));
51671 }
51672 });
51673 observer.observe(container, {
51674 childList: true,
51675 subtree: true
51676 });
51677 timer = setTimeout(() => {
51678 observer.disconnect();
51679 resolve(null);
51680 }, 3e3);
51681 }).then((element) => element?.focus());
51682 }
51683
51684 // packages/editor/build-module/components/collaborators-presence/list.mjs
51685 var import_jsx_runtime326 = __toESM(require_jsx_runtime(), 1);
51686 if (typeof document !== "undefined" && !document.head.querySelector("style[data-wp-hash='9537a5e604']")) {
51687 const style = document.createElement("style");
51688 style.setAttribute("data-wp-hash", "9537a5e604");
51689 style.appendChild(document.createTextNode(".editor-collaborators-presence__list.components-popover .components-popover__content{background:#fff;border:1px solid #ddd;border-radius:8px;border-width:1px 0 0 1px;box-shadow:0 1px 2px #0000000d,0 2px 3px #0000000a,0 6px 6px #00000008,0 8px 8px #00000005}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-content{min-width:280px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header{align-items:center;display:flex;justify-content:space-between;padding:8px 16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title{display:flex;font-size:13px;font-weight:499;gap:4px;line-height:20px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title span{color:#757575}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action{padding:0}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action button{color:#1e1e1e;height:32px;padding:0;width:32px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-items{display:flex;flex-direction:column;padding-bottom:16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item{all:unset;align-items:center;box-sizing:border-box;cursor:pointer;display:flex;gap:8px;padding:12px 16px;transition:background-color .2s ease;width:100%}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:hover:not(:disabled){background-color:rgba(var(--wp-admin-theme-color--rgb),.04)}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:active:not(:disabled){background-color:rgba(var(--wp-admin-theme-color--rgb),.08)}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:focus-visible{outline:2px solid var(--wp-admin-theme-color,#3858e9);outline-offset:-2px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:disabled{cursor:default}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item-info{display:flex;flex:1;flex-direction:column;min-width:0}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item-name{color:#1e1e1e;font-size:13px;font-weight:499;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"));
51690 document.head.appendChild(style);
51691 }
51692 function CollaboratorsList({
51693 activeCollaborators,
51694 popoverAnchor,
51695 setIsPopoverVisible,
51696 cursorRegistry
51697 }) {
51698 const handleCollaboratorClick = (clientId) => {
51699 const success = cursorRegistry.scrollToCursor(clientId, {
51700 behavior: "smooth",
51701 block: "center",
51702 highlightDuration: 2e3
51703 });
51704 if (success) {
51705 (0, import_a11y7.speak)((0, import_i18n209.__)("Scrolled to cursor"), "polite");
51706 setIsPopoverVisible(false);
51707 }
51708 };
51709 return /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(
51710 import_components188.Popover,
51711 {
51712 anchor: popoverAnchor,
51713 placement: "bottom",
51714 offset: 8,
51715 className: "editor-collaborators-presence__list",
51716 onClose: () => setIsPopoverVisible(false),
51717 children: /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)("div", { className: "editor-collaborators-presence__list-content", children: [
51718 /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)("div", { className: "editor-collaborators-presence__list-header", children: [
51719 /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)("div", { className: "editor-collaborators-presence__list-header-title", children: [
51720 (0, import_i18n209.__)("Collaborators"),
51721 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)("span", { children: activeCollaborators.length })
51722 ] }),
51723 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)("div", { className: "editor-collaborators-presence__list-header-action", children: /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(
51724 import_components188.Button,
51725 {
51726 __next40pxDefaultSize: true,
51727 icon: close_small_default,
51728 iconSize: 24,
51729 label: (0, import_i18n209.__)("Close Collaborators List"),
51730 onClick: () => setIsPopoverVisible(false)
51731 }
51732 ) })
51733 ] }),
51734 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)("div", { className: "editor-collaborators-presence__list-items", children: activeCollaborators.map((collaboratorState) => {
51735 const isCurrentUser = collaboratorState.isMe;
51736 return /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)(
51737 "button",
51738 {
51739 className: "editor-collaborators-presence__list-item",
51740 disabled: isCurrentUser,
51741 onClick: () => handleCollaboratorClick(
51742 collaboratorState.clientId
51743 ),
51744 children: [
51745 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(
51746 component_default,
51747 {
51748 src: getAvatarUrl(
51749 collaboratorState.collaboratorInfo.avatar_urls
51750 ),
51751 name: collaboratorState.collaboratorInfo.name,
51752 borderColor: isCurrentUser ? "var(--wp-admin-theme-color)" : getAvatarBorderColor(
51753 collaboratorState.collaboratorInfo.id
51754 ),
51755 dimmed: !collaboratorState.isConnected
51756 }
51757 ),
51758 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)("div", { className: "editor-collaborators-presence__list-item-info", children: /* @__PURE__ */ (0, import_jsx_runtime326.jsx)("div", { className: "editor-collaborators-presence__list-item-name", children: isCurrentUser ? (0, import_i18n209.__)("You") : collaboratorState.collaboratorInfo.name }) })
51759 ]
51760 },
51761 collaboratorState.clientId
51762 );
51763 }) })
51764 ] })
51765 }
51766 );
51767 }
51768
51769 // packages/editor/build-module/components/collaborators-overlay/cursor-registry.mjs
51770 function highlightCursor(element, duration) {
51771 element.classList.add("collaborators-overlay-cursor-highlighted");
51772 setTimeout(() => {
51773 element.classList.remove("collaborators-overlay-cursor-highlighted");
51774 }, duration);
51775 }
51776 function createCursorRegistry() {
51777 const cursorMap = /* @__PURE__ */ new Map();
51778 return {
51779 /**
51780 * Register a cursor element when it's created.
51781 *
51782 * @param clientId - The clientId of the cursor to register.
51783 * @param element - The cursor element to register.
51784 */
51785 registerCursor(clientId, element) {
51786 cursorMap.set(clientId, element);
51787 },
51788 /**
51789 * Unregister a cursor element when it's removed.
51790 *
51791 * @param clientId - The clientId of the cursor to unregister.
51792 */
51793 unregisterCursor(clientId) {
51794 cursorMap.delete(clientId);
51795 },
51796 /**
51797 * Scroll to a cursor by clientId.
51798 *
51799 * @param clientId - The clientId of the cursor to scroll to.
51800 * @param options - The options for the scroll.
51801 * @return true if cursor was found and scrolled to, false otherwise.
51802 */
51803 scrollToCursor(clientId, options) {
51804 const cursorElement = cursorMap.get(clientId);
51805 if (!cursorElement) {
51806 return false;
51807 }
51808 cursorElement.scrollIntoView({
51809 behavior: options?.behavior ?? "smooth",
51810 block: options?.block ?? "center",
51811 inline: options?.inline ?? "nearest"
51812 });
51813 if (options?.highlightDuration) {
51814 highlightCursor(cursorElement, options.highlightDuration);
51815 }
51816 return true;
51817 },
51818 /**
51819 * Clear the registry.
51820 */
51821 removeAll() {
51822 cursorMap.clear();
51823 }
51824 };
51825 }
51826
51827 // packages/editor/build-module/components/collaborators-overlay/index.mjs
51828 var import_block_editor71 = __toESM(require_block_editor(), 1);
51829
51830 // packages/editor/build-module/components/collaborators-overlay/overlay.mjs
51831 var import_compose49 = __toESM(require_compose(), 1);
51832 var import_element159 = __toESM(require_element(), 1);
51833 var import_i18n210 = __toESM(require_i18n(), 1);
51834
51835 // packages/editor/build-module/components/collaborators-overlay/collaborator-styles.mjs
51836 var ELEVATION_X_SMALL = "0 1px 1px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.02), 0 3px 3px rgba(0, 0, 0, 0.02), 0 4px 4px rgba(0, 0, 0, 0.01)";
51837 var RADIUS_FULL = "9999px";
51838 var BUTTON_SIZE_COMPACT = "32px";
51839 var BUTTON_SIZE_SMALL = "24px";
51840 var GRID_UNIT_05 = "4px";
51841 var GRID_UNIT_10 = "8px";
51842 var BORDER_WIDTH = "1px";
51843 var BORDER_WIDTH_FOCUS_FALLBACK = "2px";
51844 var WHITE2 = "#fff";
51845 var FONT_SIZE_X_SMALL = "11px";
51846 var FONT_SIZE_MEDIUM = "13px";
51847 var FONT_WEIGHT_MEDIUM = "499";
51848 var FONT_LINE_HEIGHT_SMALL = "20px";
51849
51850 // packages/editor/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs
51851 var AVATAR_IFRAME_STYLES = `
51852.editor-avatar {
51853 position: relative;
51854 display: inline-flex;
51855 align-items: center;
51856 border-radius: ${RADIUS_FULL};
51857 flex-shrink: 0;
51858 box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 2px) ${WHITE2}, ${ELEVATION_X_SMALL};
51859}
51860.editor-avatar__image {
51861 box-sizing: border-box;
51862 position: relative;
51863 width: ${BUTTON_SIZE_COMPACT};
51864 height: ${BUTTON_SIZE_COMPACT};
51865 border-radius: ${RADIUS_FULL};
51866 border: 0;
51867 background-color: var(--wp-admin-theme-color, #3858e9);
51868 overflow: hidden;
51869 overflow: clip;
51870 flex-shrink: 0;
51871 font-size: 0;
51872 color: ${WHITE2};
51873}
51874.is-small > .editor-avatar__image {
51875 width: ${BUTTON_SIZE_SMALL};
51876 height: ${BUTTON_SIZE_SMALL};
51877}
51878.has-avatar-border-color > .editor-avatar__image {
51879 border: var(--wp-admin-border-width-focus, 2px) solid var(--editor-avatar-outline-color);
51880 background-clip: padding-box;
51881}
51882.has-avatar-border-color > .editor-avatar__image::after {
51883 content: "";
51884 position: absolute;
51885 inset: 0;
51886 border-radius: inherit;
51887 box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus, 2px) ${WHITE2};
51888 pointer-events: none;
51889 z-index: 1;
51890}
51891.editor-avatar__img {
51892 position: absolute;
51893 inset: 0;
51894 width: 100%;
51895 height: 100%;
51896 object-fit: cover;
51897 border-radius: inherit;
51898 opacity: 0;
51899}
51900.has-src > .editor-avatar__image > .editor-avatar__img {
51901 opacity: 1;
51902}
51903.editor-avatar:not(.has-src) > .editor-avatar__image {
51904 display: flex;
51905 align-items: center;
51906 justify-content: center;
51907 font-size: ${FONT_SIZE_X_SMALL};
51908 font-weight: ${FONT_WEIGHT_MEDIUM};
51909 border: 0;
51910 background-clip: border-box;
51911}
51912.editor-avatar:not(.has-src) > .editor-avatar__image::after {
51913 content: none;
51914}
51915.editor-avatar:not(.has-src).has-avatar-border-color > .editor-avatar__image {
51916 background-color: var(--editor-avatar-outline-color);
51917}
51918.editor-avatar__name {
51919 font-size: ${FONT_SIZE_MEDIUM};
51920 font-weight: ${FONT_WEIGHT_MEDIUM};
51921 line-height: ${FONT_LINE_HEIGHT_SMALL};
51922 color: var(--editor-avatar-name-color, ${WHITE2});
51923 min-width: 0;
51924 padding-bottom: 2px; /* $grid-unit-05 / 2 */
51925 overflow: hidden;
51926 opacity: 0;
51927 white-space: nowrap;
51928 transition: opacity 0.15s cubic-bezier(0.15, 0, 0.15, 1);
51929}
51930.editor-avatar.is-badge {
51931 display: inline-grid;
51932 grid-template-columns: min-content 0fr;
51933 column-gap: 0;
51934 padding-inline-end: 0;
51935 background-color: var(--wp-admin-theme-color, #3858e9);
51936 transition:
51937 grid-template-columns 0.3s cubic-bezier(0.15, 0, 0.15, 1),
51938 column-gap 0.3s cubic-bezier(0.15, 0, 0.15, 1),
51939 padding-inline-end 0.3s cubic-bezier(0.15, 0, 0.15, 1);
51940}
51941.editor-avatar.is-badge:hover {
51942 grid-template-columns: min-content 1fr;
51943 column-gap: ${GRID_UNIT_05};
51944 padding-inline-end: ${GRID_UNIT_10};
51945 transition-timing-function: cubic-bezier(0.85, 0, 0.85, 1);
51946}
51947.editor-avatar.is-badge:hover .editor-avatar__name {
51948 opacity: 1;
51949 transition-timing-function: cubic-bezier(0.85, 0, 0.85, 1);
51950}
51951.editor-avatar.is-badge.has-avatar-border-color {
51952 background-color: var(--editor-avatar-outline-color);
51953}
51954@media (prefers-reduced-motion: reduce) {
51955 .editor-avatar.is-badge,
51956 .editor-avatar__name {
51957 transition: none;
51958 }
51959}
51960`;
51961
51962 // packages/editor/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs
51963 var OVERLAY_IFRAME_STYLES = `
51964.block-canvas-cover {
51965 position: absolute;
51966 top: 0;
51967 left: 0;
51968 width: 100%;
51969 height: 100%;
51970 pointer-events: none;
51971 z-index: 20000;
51972}
51973.block-canvas-cover .collaborators-overlay-full {
51974 position: absolute;
51975 top: 0;
51976 left: 0;
51977 width: 100%;
51978 height: 100%;
51979}
51980.block-canvas-cover .collaborators-overlay-fixed {
51981 position: fixed;
51982 width: 100%;
51983 height: 100%;
51984}
51985.collaborators-overlay-user {
51986 position: absolute;
51987}
51988/* Cursor lines render below avatar labels across all users. The parent
51989 .collaborators-overlay-user has no z-index so it does not create a
51990 stacking context \u2014 children participate in the shared overlay context. */
51991.collaborators-overlay-user-cursor {
51992 position: absolute;
51993 z-index: 0;
51994 width: ${BORDER_WIDTH_FOCUS_FALLBACK};
51995 border-radius: ${BORDER_WIDTH};
51996 outline: ${BORDER_WIDTH} solid ${WHITE2};
51997 box-shadow: ${ELEVATION_X_SMALL};
51998 animation: collaborators-overlay-cursor-blink 1s infinite;
51999}
52000.collaborators-overlay-selection-rect {
52001 position: absolute;
52002 opacity: 0.15;
52003 pointer-events: none;
52004 border-radius: 2px;
52005}
52006
52007/* Overlay-specific positioning applied to the Avatar cursor label. */
52008.collaborators-overlay-user-label.editor-avatar {
52009 position: absolute;
52010 z-index: 1;
52011 transform: translate(-11px, -100%);
52012 margin-top: -${GRID_UNIT_05};
52013 pointer-events: auto;
52014 overflow: visible;
52015 width: max-content;
52016}
52017/* Avatar positioned above a highlighted block as a label. */
52018.collaborators-overlay-block-label.editor-avatar {
52019 position: absolute;
52020 z-index: 1;
52021 transform: translateY(calc(-100% - ${GRID_UNIT_10}));
52022 pointer-events: auto;
52023 overflow: visible;
52024 width: max-content;
52025}
52026
52027@keyframes collaborators-overlay-cursor-blink {
52028 0%, 45% { opacity: 1; }
52029 55%, 95% { opacity: 0; }
52030 100% { opacity: 1; }
52031}
52032.collaborators-overlay-cursor-highlighted .collaborators-overlay-user-cursor {
52033 animation: collaborators-overlay-cursor-highlight 0.6s ease-in-out 3;
52034}
52035.collaborators-overlay-cursor-highlighted .collaborators-overlay-user-label {
52036 animation: collaborators-overlay-label-highlight 0.6s ease-in-out 3;
52037}
52038@keyframes collaborators-overlay-cursor-highlight {
52039 0%, 100% {
52040 transform: scale(1);
52041 filter: drop-shadow(0 0 0 transparent);
52042 }
52043 50% {
52044 transform: scale(1.2);
52045 filter: drop-shadow(0 0 8px currentColor);
52046 }
52047}
52048@keyframes collaborators-overlay-label-highlight {
52049 0%, 100% {
52050 transform: translate(-11px, -100%) scale(1);
52051 filter: drop-shadow(0 0 0 transparent);
52052 }
52053 50% {
52054 transform: translate(-11px, -100%) scale(1.1);
52055 filter: drop-shadow(0 0 6px currentColor);
52056 }
52057}
52058.block-editor-block-list__block.is-collaborator-selected:not(:focus)::after {
52059 content: "";
52060 position: absolute;
52061 pointer-events: none;
52062 top: 0;
52063 right: 0;
52064 bottom: 0;
52065 left: 0;
52066 outline-color: var(--collaborator-outline-color);
52067 outline-style: solid;
52068 outline-width: calc(var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1));
52069 outline-offset: calc(-1 * var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1));
52070 box-shadow: inset 0 0 0 calc((var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1)) + 0.5px) rgba(${WHITE2}, 0.7);
52071 z-index: 1;
52072}
52073@media (prefers-reduced-motion: reduce) {
52074 .collaborators-overlay-user-label,
52075 .collaborators-overlay-user-cursor {
52076 animation: none;
52077 }
52078}
52079`;
52080
52081 // packages/editor/build-module/components/collaborators-overlay/timing-utils.mjs
52082 function setDelayedInterval(callback, delayMs) {
52083 let timerHandle = null;
52084 const runner = () => {
52085 try {
52086 callback();
52087 } catch (error) {
52088 }
52089 timerHandle = setTimeout(runner, delayMs);
52090 };
52091 timerHandle = setTimeout(runner, delayMs);
52092 return () => {
52093 if (timerHandle) {
52094 clearTimeout(timerHandle);
52095 }
52096 };
52097 }
52098
52099 // packages/editor/build-module/components/collaborators-overlay/use-block-highlighting.mjs
52100 var import_core_data110 = __toESM(require_core_data(), 1);
52101 var import_element157 = __toESM(require_element(), 1);
52102
52103 // packages/editor/build-module/components/collaborators-overlay/use-debounced-recompute.mjs
52104 var import_element156 = __toESM(require_element(), 1);
52105 function useDebouncedRecompute(delayMs) {
52106 const [recomputeToken, setRecomputeToken] = (0, import_element156.useState)(0);
52107 const timeoutRef = (0, import_element156.useRef)(null);
52108 const rerenderAfterDelay = (0, import_element156.useCallback)(() => {
52109 if (timeoutRef.current) {
52110 clearTimeout(timeoutRef.current);
52111 }
52112 timeoutRef.current = setTimeout(() => {
52113 setRecomputeToken((t4) => t4 + 1);
52114 }, delayMs);
52115 return () => {
52116 if (timeoutRef.current) {
52117 clearTimeout(timeoutRef.current);
52118 }
52119 };
52120 }, [delayMs]);
52121 return [recomputeToken, rerenderAfterDelay];
52122 }
52123
52124 // packages/editor/build-module/components/collaborators-overlay/use-block-highlighting.mjs
52125 var { useActiveCollaborators, useResolvedSelection } = unlock(import_core_data110.privateApis);
52126 var { SelectionType } = unlock(import_core_data110.privateApis);
52127 function useBlockHighlighting(overlayElement, blockEditorDocument, postId2, postType2, delayMs) {
52128 const highlightedBlockIds = (0, import_element157.useRef)(/* @__PURE__ */ new Set());
52129 const userStates = useActiveCollaborators(
52130 postId2 ?? null,
52131 postType2 ?? null
52132 );
52133 const resolveSelection = useResolvedSelection(
52134 postId2 ?? null,
52135 postType2 ?? null
52136 );
52137 const [highlights, setHighlights] = (0, import_element157.useState)(
52138 []
52139 );
52140 const [recomputeToken, rerenderHighlightsAfterDelay] = useDebouncedRecompute(delayMs);
52141 (0, import_element157.useEffect)(() => {
52142 if (!blockEditorDocument) {
52143 setHighlights([]);
52144 return;
52145 }
52146 const currentHighlightedIds = highlightedBlockIds.current;
52147 const seen = /* @__PURE__ */ new Set();
52148 const blocksToHighlight = userStates.filter((userState) => {
52149 const isWholeBlockSelected = userState.editorState?.selection?.type === SelectionType.WholeBlock;
52150 return !userState.isMe && isWholeBlockSelected;
52151 }).map((userState) => {
52152 let localClientId;
52153 try {
52154 ({ localClientId } = resolveSelection(
52155 userState.editorState?.selection
52156 ));
52157 } catch {
52158 return null;
52159 }
52160 if (!localClientId) {
52161 return null;
52162 }
52163 return {
52164 blockId: localClientId,
52165 color: userState.isMe ? "var(--wp-admin-theme-color)" : getAvatarBorderColor(userState.collaboratorInfo.id),
52166 userName: userState.collaboratorInfo.name,
52167 avatarUrl: getAvatarUrl(
52168 userState.collaboratorInfo.avatar_urls
52169 )
52170 };
52171 }).filter((block) => {
52172 if (!block) {
52173 return false;
52174 }
52175 if (seen.has(block.blockId)) {
52176 return false;
52177 }
52178 seen.add(block.blockId);
52179 return true;
52180 });
52181 const selectedBlockIds = new Set(
52182 blocksToHighlight.map((block) => block.blockId)
52183 );
52184 for (const blockId of currentHighlightedIds) {
52185 if (!selectedBlockIds.has(blockId)) {
52186 const blockElement = getBlockElementById(
52187 blockEditorDocument,
52188 blockId
52189 );
52190 if (blockElement) {
52191 blockElement.classList.remove("is-collaborator-selected");
52192 blockElement.style.removeProperty(
52193 "--collaborator-outline-color"
52194 );
52195 }
52196 currentHighlightedIds.delete(blockId);
52197 }
52198 }
52199 const results = [];
52200 const overlayRect = overlayElement?.getBoundingClientRect() ?? null;
52201 blocksToHighlight.forEach((block) => {
52202 const { color, blockId, userName, avatarUrl } = block;
52203 const blockElement = getBlockElementById(
52204 blockEditorDocument,
52205 blockId
52206 );
52207 if (!blockElement) {
52208 return;
52209 }
52210 blockElement.classList.add("is-collaborator-selected");
52211 blockElement.style.setProperty(
52212 "--collaborator-outline-color",
52213 color
52214 );
52215 currentHighlightedIds.add(blockId);
52216 if (overlayRect) {
52217 const blockRect = blockElement.getBoundingClientRect();
52218 results.push({
52219 blockId,
52220 userName,
52221 avatarUrl,
52222 color,
52223 x: blockRect.left - overlayRect.left,
52224 y: blockRect.top - overlayRect.top
52225 });
52226 }
52227 });
52228 setHighlights(results);
52229 return () => {
52230 for (const blockId of currentHighlightedIds) {
52231 const el = getBlockElementById(blockEditorDocument, blockId);
52232 if (el) {
52233 el.classList.remove("is-collaborator-selected");
52234 el.style.removeProperty("--collaborator-outline-color");
52235 }
52236 }
52237 currentHighlightedIds.clear();
52238 };
52239 }, [
52240 userStates,
52241 blockEditorDocument,
52242 overlayElement,
52243 recomputeToken,
52244 resolveSelection
52245 ]);
52246 return { highlights, rerenderHighlightsAfterDelay };
52247 }
52248 var getBlockElementById = (blockEditorDocument, blockId) => {
52249 return blockEditorDocument.querySelector(`[data-block="${blockId}"]`);
52250 };
52251
52252 // packages/editor/build-module/components/collaborators-overlay/use-render-cursors.mjs
52253 var import_core_data112 = __toESM(require_core_data(), 1);
52254 var import_data191 = __toESM(require_data(), 1);
52255 var import_element158 = __toESM(require_element(), 1);
52256 var import_preferences20 = __toESM(require_preferences(), 1);
52257
52258 // packages/editor/build-module/components/collaborators-overlay/compute-selection.mjs
52259 var import_core_data111 = __toESM(require_core_data(), 1);
52260
52261 // packages/editor/build-module/components/collaborators-overlay/cursor-dom-utils.mjs
52262 var MAX_NODE_OFFSET_COUNT = 500;
52263 var getCursorPosition = (absolutePositionIndex, blockElement, editorDocument, overlayRect) => {
52264 if (absolutePositionIndex === null || !blockElement) {
52265 return null;
52266 }
52267 return getOffsetPositionInBlock(
52268 blockElement,
52269 absolutePositionIndex,
52270 editorDocument,
52271 overlayRect
52272 ) ?? null;
52273 };
52274 var getOffsetPositionInBlock = (blockElement, charOffset, editorDocument, overlayRect) => {
52275 const { node, offset: offset3 } = findInnerBlockOffset(
52276 blockElement,
52277 charOffset,
52278 editorDocument
52279 );
52280 const cursorRange = editorDocument.createRange();
52281 try {
52282 cursorRange.setStart(node, offset3);
52283 } catch (error) {
52284 return null;
52285 }
52286 cursorRange.collapse(true);
52287 const cursorRect = cursorRange.getBoundingClientRect();
52288 const blockRect = blockElement.getBoundingClientRect();
52289 let cursorX = 0;
52290 let cursorY = 0;
52291 if (cursorRect.x === 0 && cursorRect.y === 0 && cursorRect.width === 0 && cursorRect.height === 0) {
52292 cursorX = blockRect.left - overlayRect.left;
52293 cursorY = blockRect.top - overlayRect.top;
52294 } else {
52295 cursorX = cursorRect.left - overlayRect.left;
52296 cursorY = cursorRect.top - overlayRect.top;
52297 }
52298 let cursorHeight = cursorRect.height;
52299 if (cursorHeight === 0) {
52300 const view = editorDocument.defaultView ?? window;
52301 cursorHeight = parseInt(view.getComputedStyle(blockElement).lineHeight, 10) || blockRect.height;
52302 }
52303 return {
52304 x: cursorX,
52305 y: cursorY,
52306 height: cursorHeight
52307 };
52308 };
52309 var getSelectionRects = (blockElement, startOffset, endOffset, editorDocument, overlayRect) => {
52310 let normalizedStart = startOffset;
52311 let normalizedEnd = endOffset;
52312 if (normalizedStart > normalizedEnd) {
52313 [normalizedStart, normalizedEnd] = [normalizedEnd, normalizedStart];
52314 }
52315 const startPos = findInnerBlockOffset(
52316 blockElement,
52317 normalizedStart,
52318 editorDocument
52319 );
52320 const endPos = findInnerBlockOffset(
52321 blockElement,
52322 normalizedEnd,
52323 editorDocument
52324 );
52325 const range = editorDocument.createRange();
52326 try {
52327 range.setStart(startPos.node, startPos.offset);
52328 range.setEnd(endPos.node, endPos.offset);
52329 } catch {
52330 return null;
52331 }
52332 const clientRects = range.getClientRects();
52333 const rects = [];
52334 for (const rect of clientRects) {
52335 if (rect.width === 0 && rect.height === 0) {
52336 continue;
52337 }
52338 const x2 = rect.left - overlayRect.left;
52339 const y3 = rect.top - overlayRect.top;
52340 const isDuplicate = rects.some(
52341 (r4) => r4.x === x2 && r4.y === y3 && r4.width === rect.width && r4.height === rect.height
52342 );
52343 if (isDuplicate) {
52344 continue;
52345 }
52346 rects.push({
52347 x: x2,
52348 y: y3,
52349 width: rect.width,
52350 height: rect.height
52351 });
52352 }
52353 return rects.length > 0 ? rects : null;
52354 };
52355 var getFullBlockSelectionRects = (blockElement, editorDocument, overlayRect) => {
52356 const range = editorDocument.createRange();
52357 range.selectNodeContents(blockElement);
52358 const clientRects = range.getClientRects();
52359 const rects = [];
52360 for (const rect of clientRects) {
52361 if (rect.width === 0 && rect.height === 0) {
52362 continue;
52363 }
52364 rects.push({
52365 x: rect.left - overlayRect.left,
52366 y: rect.top - overlayRect.top,
52367 width: rect.width,
52368 height: rect.height
52369 });
52370 }
52371 if (rects.length === 0) {
52372 const blockRect = blockElement.getBoundingClientRect();
52373 if (blockRect.width > 0 && blockRect.height > 0) {
52374 rects.push({
52375 x: blockRect.left - overlayRect.left,
52376 y: blockRect.top - overlayRect.top,
52377 width: blockRect.width,
52378 height: blockRect.height
52379 });
52380 }
52381 }
52382 return rects;
52383 };
52384 var getBlocksBetween = (startBlockId, endBlockId, editorDocument) => {
52385 const allBlocks = editorDocument.querySelectorAll("[data-block]");
52386 let startIndex = -1;
52387 let endIndex = -1;
52388 for (let i3 = 0; i3 < allBlocks.length; i3++) {
52389 const blockId = allBlocks[i3].getAttribute("data-block");
52390 if (blockId === startBlockId) {
52391 startIndex = i3;
52392 }
52393 if (blockId === endBlockId) {
52394 endIndex = i3;
52395 }
52396 }
52397 if (startIndex === -1 || endIndex === -1) {
52398 return [];
52399 }
52400 if (startIndex > endIndex) {
52401 [startIndex, endIndex] = [endIndex, startIndex];
52402 }
52403 const result = [];
52404 for (let i3 = startIndex + 1; i3 < endIndex; i3++) {
52405 result.push(allBlocks[i3]);
52406 }
52407 return result;
52408 };
52409 var findInnerBlockOffset = (blockElement, offset3, editorDocument) => {
52410 const treeWalker = editorDocument.createTreeWalker(
52411 blockElement,
52412 NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT
52413 // eslint-disable-line no-bitwise
52414 );
52415 let currentOffset = 0;
52416 let lastTextNode = null;
52417 let node = null;
52418 let nodeCount = 1;
52419 while (node = treeWalker.nextNode()) {
52420 nodeCount++;
52421 if (nodeCount > MAX_NODE_OFFSET_COUNT) {
52422 if (lastTextNode) {
52423 return { node: lastTextNode, offset: 0 };
52424 }
52425 return { node: blockElement, offset: 0 };
52426 }
52427 const nodeLength = node.nodeValue?.length ?? 0;
52428 if (node.nodeType === Node.ELEMENT_NODE) {
52429 if (node.nodeName === "BR") {
52430 if (currentOffset + 1 >= offset3) {
52431 const nodeAfterBr = treeWalker.nextNode();
52432 if (nodeAfterBr?.nodeType === Node.TEXT_NODE) {
52433 return { node: nodeAfterBr, offset: 0 };
52434 } else if (lastTextNode) {
52435 return {
52436 node: lastTextNode,
52437 offset: lastTextNode.nodeValue?.length ?? 0
52438 };
52439 }
52440 return { node: blockElement, offset: 0 };
52441 }
52442 currentOffset += 1;
52443 continue;
52444 } else {
52445 continue;
52446 }
52447 }
52448 if (nodeLength === 0) {
52449 continue;
52450 }
52451 if (currentOffset + nodeLength >= offset3) {
52452 return { node, offset: offset3 - currentOffset };
52453 }
52454 currentOffset += nodeLength;
52455 if (node.nodeType === Node.TEXT_NODE) {
52456 lastTextNode = node;
52457 }
52458 }
52459 if (lastTextNode && lastTextNode.nodeValue?.length) {
52460 return { node: lastTextNode, offset: lastTextNode.nodeValue.length };
52461 }
52462 return { node: blockElement, offset: 0 };
52463 };
52464 var isNodeBefore = (a3, b3) => a3.compareDocumentPosition(b3) === Node.DOCUMENT_POSITION_FOLLOWING;
52465
52466 // packages/editor/build-module/components/collaborators-overlay/compute-selection.mjs
52467 var { SelectionDirection, SelectionType: SelectionType2 } = unlock(
52468 import_core_data111.privateApis
52469 );
52470 function computeSelectionVisual(selection, start2, end, overlayContext) {
52471 if (selection.type === SelectionType2.None || selection.type === SelectionType2.WholeBlock) {
52472 return {};
52473 }
52474 if (selection.type === SelectionType2.Cursor) {
52475 return computeCursorOnly(start2, overlayContext);
52476 }
52477 if (!end) {
52478 return {};
52479 }
52480 return computeTextSelection(selection, start2, end, overlayContext);
52481 }
52482 function computeCursorOnly(start2, overlayContext) {
52483 if (!start2.localClientId) {
52484 return {};
52485 }
52486 const blockElement = overlayContext.editorDocument.querySelector(
52487 `[data-block="${start2.localClientId}"]`
52488 );
52489 return {
52490 coords: getCursorPosition(
52491 start2.richTextOffset,
52492 blockElement,
52493 overlayContext.editorDocument,
52494 overlayContext.overlayRect
52495 )
52496 };
52497 }
52498 function computeTextSelection(selection, start2, end, overlayContext) {
52499 if (!start2.localClientId || !end.localClientId || start2.richTextOffset === null || end.richTextOffset === null) {
52500 return {};
52501 }
52502 const isReverse = selection.selectionDirection === SelectionDirection.Backward;
52503 const activeEnd = isReverse ? start2 : end;
52504 let allRects;
52505 let activeEndBlock = null;
52506 if (selection.type === SelectionType2.SelectionInOneBlock) {
52507 const result = computeSingleBlockRects(start2, end, overlayContext);
52508 allRects = result.rects;
52509 activeEndBlock = result.blockElement;
52510 } else {
52511 const result = computeMultiBlockRects(start2, end, overlayContext);
52512 allRects = result.rects;
52513 activeEndBlock = activeEnd.localClientId === result.firstBlockClientId ? result.firstBlock : result.lastBlock;
52514 }
52515 if (allRects.length > 0) {
52516 return {
52517 coords: getCursorPosition(
52518 activeEnd.richTextOffset,
52519 activeEndBlock,
52520 overlayContext.editorDocument,
52521 overlayContext.overlayRect
52522 ),
52523 selectionRects: allRects
52524 };
52525 }
52526 const startBlock = overlayContext.editorDocument.querySelector(
52527 `[data-block="${start2.localClientId}"]`
52528 );
52529 return {
52530 coords: getCursorPosition(
52531 start2.richTextOffset,
52532 startBlock,
52533 overlayContext.editorDocument,
52534 overlayContext.overlayRect
52535 )
52536 };
52537 }
52538 function computeSingleBlockRects(start2, end, overlayContext) {
52539 const blockElement = overlayContext.editorDocument.querySelector(
52540 `[data-block="${start2.localClientId}"]`
52541 );
52542 if (!blockElement || start2.richTextOffset === null || end.richTextOffset === null) {
52543 return { rects: [], blockElement: null };
52544 }
52545 return {
52546 rects: getSelectionRects(
52547 blockElement,
52548 start2.richTextOffset,
52549 end.richTextOffset,
52550 overlayContext.editorDocument,
52551 overlayContext.overlayRect
52552 ) ?? [],
52553 blockElement
52554 };
52555 }
52556 function computeMultiBlockRects(start2, end, overlayContext) {
52557 let docFirst = start2;
52558 let docLast = end;
52559 let firstBlock = overlayContext.editorDocument.querySelector(
52560 `[data-block="${docFirst.localClientId}"]`
52561 );
52562 let lastBlock = overlayContext.editorDocument.querySelector(
52563 `[data-block="${docLast.localClientId}"]`
52564 );
52565 if (firstBlock && lastBlock && isNodeBefore(lastBlock, firstBlock)) {
52566 docFirst = end;
52567 docLast = start2;
52568 [firstBlock, lastBlock] = [lastBlock, firstBlock];
52569 }
52570 if (!firstBlock || !lastBlock || docFirst.richTextOffset === null || docLast.richTextOffset === null || !docFirst.localClientId || !docLast.localClientId) {
52571 return {
52572 rects: [],
52573 firstBlock: null,
52574 lastBlock: null,
52575 firstBlockClientId: null
52576 };
52577 }
52578 const allRects = [];
52579 const startRects = getSelectionRects(
52580 firstBlock,
52581 docFirst.richTextOffset,
52582 Number.MAX_SAFE_INTEGER,
52583 overlayContext.editorDocument,
52584 overlayContext.overlayRect
52585 );
52586 if (startRects) {
52587 allRects.push(...startRects);
52588 }
52589 const intermediateBlocks = getBlocksBetween(
52590 docFirst.localClientId,
52591 docLast.localClientId,
52592 overlayContext.editorDocument
52593 );
52594 for (const intermediateBlock of intermediateBlocks) {
52595 const rects = getFullBlockSelectionRects(
52596 intermediateBlock,
52597 overlayContext.editorDocument,
52598 overlayContext.overlayRect
52599 );
52600 allRects.push(...rects);
52601 }
52602 const endRects = getSelectionRects(
52603 lastBlock,
52604 0,
52605 docLast.richTextOffset,
52606 overlayContext.editorDocument,
52607 overlayContext.overlayRect
52608 );
52609 if (endRects) {
52610 allRects.push(...endRects);
52611 }
52612 return {
52613 rects: allRects,
52614 firstBlock,
52615 lastBlock,
52616 firstBlockClientId: docFirst.localClientId
52617 };
52618 }
52619
52620 // packages/editor/build-module/components/collaborators-overlay/use-render-cursors.mjs
52621 var { useActiveCollaborators: useActiveCollaborators2, useResolvedSelection: useResolvedSelection2 } = unlock(import_core_data112.privateApis);
52622 var { SelectionType: SelectionType3 } = unlock(import_core_data112.privateApis);
52623 function useRenderCursors(overlayElement, blockEditorDocument, postId2, postType2, delayMs) {
52624 const sortedUsers = useActiveCollaborators2(
52625 postId2 ?? null,
52626 postType2 ?? null
52627 );
52628 const resolveSelection = useResolvedSelection2(
52629 postId2 ?? null,
52630 postType2 ?? null
52631 );
52632 const showOwnCursor = (0, import_data191.useSelect)(
52633 (select6) => select6(import_preferences20.store).get("core", "showCollaborationCursor"),
52634 []
52635 );
52636 const [cursorPositions, setCursorPositions] = (0, import_element158.useState)(
52637 []
52638 );
52639 const [recomputeToken, rerenderCursorsAfterDelay] = useDebouncedRecompute(delayMs);
52640 (0, import_element158.useEffect)(() => {
52641 if (!overlayElement || !blockEditorDocument) {
52642 setCursorPositions([]);
52643 return;
52644 }
52645 const overlayRect = overlayElement.getBoundingClientRect();
52646 const overlayContext = {
52647 editorDocument: blockEditorDocument,
52648 overlayRect
52649 };
52650 const results = [];
52651 const hasOtherCollaborators = sortedUsers.some(
52652 (u3) => !u3.isMe
52653 );
52654 sortedUsers.forEach((user) => {
52655 if (user.isMe && (!showOwnCursor || !hasOtherCollaborators)) {
52656 return;
52657 }
52658 const selection = user.editorState?.selection ?? {
52659 type: SelectionType3.None
52660 };
52661 let start2 = {
52662 richTextOffset: null,
52663 localClientId: null
52664 };
52665 let end;
52666 if (selection.type === SelectionType3.Cursor) {
52667 try {
52668 start2 = resolveSelection(selection);
52669 } catch {
52670 return;
52671 }
52672 } else if (selection.type === SelectionType3.SelectionInOneBlock || selection.type === SelectionType3.SelectionInMultipleBlocks) {
52673 try {
52674 start2 = resolveSelection({
52675 type: SelectionType3.Cursor,
52676 cursorPosition: selection.cursorStartPosition
52677 });
52678 end = resolveSelection({
52679 type: SelectionType3.Cursor,
52680 cursorPosition: selection.cursorEndPosition
52681 });
52682 } catch {
52683 return;
52684 }
52685 }
52686 const userName = user.collaboratorInfo.name;
52687 const clientId = user.clientId;
52688 const color = user.isMe ? "var(--wp-admin-theme-color)" : getAvatarBorderColor(user.collaboratorInfo.id);
52689 const avatarUrl = getAvatarUrl(user.collaboratorInfo.avatar_urls);
52690 const selectionVisual = computeSelectionVisual(
52691 selection,
52692 start2,
52693 end,
52694 overlayContext
52695 );
52696 if (selectionVisual.coords) {
52697 const cursorData = {
52698 userName,
52699 clientId,
52700 color,
52701 avatarUrl,
52702 isMe: user.isMe,
52703 ...selectionVisual.coords
52704 };
52705 if (selectionVisual.selectionRects) {
52706 cursorData.selectionRects = selectionVisual.selectionRects;
52707 }
52708 results.push(cursorData);
52709 }
52710 });
52711 setCursorPositions(results);
52712 }, [
52713 blockEditorDocument,
52714 resolveSelection,
52715 overlayElement,
52716 sortedUsers,
52717 showOwnCursor,
52718 recomputeToken
52719 ]);
52720 return { cursors: cursorPositions, rerenderCursorsAfterDelay };
52721 }
52722
52723 // packages/editor/build-module/components/collaborators-overlay/overlay.mjs
52724 var import_jsx_runtime327 = __toESM(require_jsx_runtime(), 1);
52725 var RERENDER_DELAY_MS = 500;
52726 var CURSOR_REDRAW_INTERVAL_MS = 1e4;
52727 function Overlay({
52728 blockEditorDocument,
52729 postId: postId2,
52730 postType: postType2,
52731 cursorRegistry
52732 }) {
52733 const [overlayElement, setOverlayElement] = (0, import_element159.useState)(null);
52734 const { cursors, rerenderCursorsAfterDelay } = useRenderCursors(
52735 overlayElement,
52736 blockEditorDocument ?? null,
52737 postId2 ?? null,
52738 postType2 ?? null,
52739 RERENDER_DELAY_MS
52740 );
52741 const { highlights, rerenderHighlightsAfterDelay } = useBlockHighlighting(
52742 overlayElement,
52743 blockEditorDocument ?? null,
52744 postId2 ?? null,
52745 postType2 ?? null,
52746 RERENDER_DELAY_MS
52747 );
52748 const onResize = (0, import_element159.useCallback)(() => {
52749 rerenderCursorsAfterDelay();
52750 rerenderHighlightsAfterDelay();
52751 }, [rerenderCursorsAfterDelay, rerenderHighlightsAfterDelay]);
52752 const resizeObserverRef = (0, import_compose49.useResizeObserver)(onResize);
52753 (0, import_element159.useEffect)(() => {
52754 const cleanupCursors = rerenderCursorsAfterDelay();
52755 const cleanupHighlights = rerenderHighlightsAfterDelay();
52756 return () => {
52757 cleanupCursors();
52758 cleanupHighlights();
52759 };
52760 }, [rerenderCursorsAfterDelay, rerenderHighlightsAfterDelay]);
52761 (0, import_element159.useEffect)(() => {
52762 if (cursors.length === 0) {
52763 return;
52764 }
52765 return setDelayedInterval(
52766 rerenderCursorsAfterDelay,
52767 CURSOR_REDRAW_INTERVAL_MS
52768 );
52769 }, [cursors.length, rerenderCursorsAfterDelay]);
52770 const mergedRef = (0, import_compose49.useMergeRefs)([
52771 setOverlayElement,
52772 resizeObserverRef
52773 ]);
52774 const cursorRefsMap = (0, import_element159.useRef)(/* @__PURE__ */ new Map());
52775 (0, import_element159.useEffect)(() => {
52776 if (!cursorRegistry) {
52777 return;
52778 }
52779 const refs = cursorRefsMap.current;
52780 const currentIds = new Set(cursors.map((c6) => c6.clientId));
52781 for (const id of refs.keys()) {
52782 if (!currentIds.has(id)) {
52783 cursorRegistry.unregisterCursor(id);
52784 refs.delete(id);
52785 }
52786 }
52787 for (const [id, el] of refs.entries()) {
52788 cursorRegistry.registerCursor(id, el);
52789 }
52790 return () => cursorRegistry.removeAll();
52791 }, [cursors, cursorRegistry]);
52792 const setCursorRef = (0, import_element159.useCallback)(
52793 (clientId) => (el) => {
52794 if (el) {
52795 cursorRefsMap.current.set(clientId, el);
52796 } else {
52797 cursorRefsMap.current.delete(clientId);
52798 }
52799 },
52800 []
52801 );
52802 return /* @__PURE__ */ (0, import_jsx_runtime327.jsxs)("div", { className: "collaborators-overlay-full", ref: mergedRef, children: [
52803 /* @__PURE__ */ (0, import_jsx_runtime327.jsx)("style", { children: AVATAR_IFRAME_STYLES + OVERLAY_IFRAME_STYLES }),
52804 cursors.map((cursor) => /* @__PURE__ */ (0, import_jsx_runtime327.jsxs)("div", { children: [
52805 cursor.selectionRects?.map((rect, index2) => /* @__PURE__ */ (0, import_jsx_runtime327.jsx)(
52806 "div",
52807 {
52808 className: "collaborators-overlay-selection-rect",
52809 style: {
52810 left: `${rect.x}px`,
52811 top: `${rect.y}px`,
52812 width: `${rect.width}px`,
52813 height: `${rect.height}px`,
52814 backgroundColor: cursor.color
52815 }
52816 },
52817 `${cursor.clientId}-sel-${index2}`
52818 )),
52819 /* @__PURE__ */ (0, import_jsx_runtime327.jsxs)(
52820 "div",
52821 {
52822 ref: setCursorRef(cursor.clientId),
52823 className: "collaborators-overlay-user",
52824 style: {
52825 left: `${cursor.x}px`,
52826 top: `${cursor.y}px`
52827 },
52828 children: [
52829 !cursor.isMe && /* @__PURE__ */ (0, import_jsx_runtime327.jsx)(
52830 "div",
52831 {
52832 className: "collaborators-overlay-user-cursor",
52833 style: {
52834 backgroundColor: cursor.color,
52835 height: `${cursor.height}px`
52836 }
52837 }
52838 ),
52839 /* @__PURE__ */ (0, import_jsx_runtime327.jsx)(
52840 component_default,
52841 {
52842 className: "collaborators-overlay-user-label",
52843 variant: "badge",
52844 size: "small",
52845 src: cursor.avatarUrl,
52846 name: cursor.userName,
52847 label: cursor.isMe ? (0, import_i18n210.__)("You") : void 0,
52848 borderColor: cursor.color
52849 }
52850 )
52851 ]
52852 }
52853 )
52854 ] }, cursor.clientId)),
52855 highlights.map((highlight) => /* @__PURE__ */ (0, import_jsx_runtime327.jsx)(
52856 component_default,
52857 {
52858 className: "collaborators-overlay-block-label",
52859 variant: "badge",
52860 size: "small",
52861 src: highlight.avatarUrl,
52862 name: highlight.userName,
52863 borderColor: highlight.color,
52864 style: {
52865 left: `${highlight.x}px`,
52866 top: `${highlight.y}px`
52867 }
52868 },
52869 highlight.blockId
52870 ))
52871 ] });
52872 }
52873
52874 // packages/editor/build-module/components/collaborators-overlay/index.mjs
52875 var import_jsx_runtime328 = __toESM(require_jsx_runtime(), 1);
52876 var { BlockCanvasCover } = unlock(import_block_editor71.privateApis);
52877 function CollaboratorsOverlay({
52878 postId: postId2,
52879 postType: postType2,
52880 cursorRegistry
52881 }) {
52882 return /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(BlockCanvasCover.Fill, { children: ({
52883 containerRef
52884 }) => /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(
52885 Overlay,
52886 {
52887 blockEditorDocument: containerRef.current?.ownerDocument,
52888 postId: postId2,
52889 postType: postType2,
52890 cursorRegistry
52891 }
52892 ) });
52893 }
52894
52895 // packages/editor/build-module/components/collaborators-presence/index.mjs
52896 var import_jsx_runtime329 = __toESM(require_jsx_runtime(), 1);
52897 if (typeof document !== "undefined" && !document.head.querySelector("style[data-wp-hash='eee1778bc0']")) {
52898 const style = document.createElement("style");
52899 style.setAttribute("data-wp-hash", "eee1778bc0");
52900 style.appendChild(document.createTextNode(".editor-collaborators-presence{align-items:center;background:#f0f0f0;border-radius:4px;display:flex;flex-shrink:0;height:32px;margin-right:8px}.editor-collaborators-presence:has(.is-pressed),.editor-collaborators-presence:hover{background-color:#e0e0e0}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button{align-items:center;background:#0000;border-radius:4px;box-sizing:border-box;color:#2f2f2f;cursor:pointer;display:flex;height:100%;padding:4px;position:relative}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed:hover,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:hover{background:#0000;color:#2f2f2f}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:focus:not(:active){box-shadow:inset 0 0 0 var(--wp-admin-border-width-focus,2px) var(--wp-admin-theme-color,#007cba);outline:none}"));
52901 document.head.appendChild(style);
52902 }
52903 var { useActiveCollaborators: useActiveCollaborators3 } = unlock(import_core_data113.privateApis);
52904 function CollaboratorsPresence({
52905 postId: postId2,
52906 postType: postType2
52907 }) {
52908 const activeCollaborators = useActiveCollaborators3(
52909 postId2,
52910 postType2
52911 );
52912 const otherActiveCollaborators = activeCollaborators.filter(
52913 (c6) => !c6.isMe
52914 );
52915 const collaboratorsForList = (0, import_element160.useMemo)(() => {
52916 return [...activeCollaborators].sort((a3, b3) => {
52917 if (a3.isMe && !b3.isMe) {
52918 return -1;
52919 }
52920 if (!a3.isMe && b3.isMe) {
52921 return 1;
52922 }
52923 return 0;
52924 });
52925 }, [activeCollaborators]);
52926 const [cursorRegistry] = (0, import_element160.useState)(createCursorRegistry);
52927 const [isPopoverVisible, setIsPopoverVisible] = (0, import_element160.useState)(false);
52928 const [popoverAnchor, setPopoverAnchor] = (0, import_element160.useState)(
52929 null
52930 );
52931 if (otherActiveCollaborators.length === 0) {
52932 return null;
52933 }
52934 const me = activeCollaborators.find((c6) => c6.isMe);
52935 return /* @__PURE__ */ (0, import_jsx_runtime329.jsxs)(import_jsx_runtime329.Fragment, { children: [
52936 /* @__PURE__ */ (0, import_jsx_runtime329.jsxs)("div", { className: "editor-collaborators-presence", children: [
52937 /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(
52938 import_components189.Button,
52939 {
52940 __next40pxDefaultSize: true,
52941 className: "editor-collaborators-presence__button",
52942 onClick: () => setIsPopoverVisible(!isPopoverVisible),
52943 isPressed: isPopoverVisible,
52944 ref: setPopoverAnchor,
52945 "aria-label": (0, import_i18n211.sprintf)(
52946 // translators: %d: number of online collaborators.
52947 (0, import_i18n211.__)("Collaborators list, %d online"),
52948 collaboratorsForList.length
52949 ),
52950 children: /* @__PURE__ */ (0, import_jsx_runtime329.jsxs)(component_default2, { max: 4, children: [
52951 me && /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(
52952 component_default,
52953 {
52954 src: getAvatarUrl(
52955 me.collaboratorInfo.avatar_urls
52956 ),
52957 name: me.collaboratorInfo.name,
52958 borderColor: "var(--wp-admin-theme-color)",
52959 size: "small"
52960 },
52961 me.clientId
52962 ),
52963 otherActiveCollaborators.map(
52964 (collaboratorState) => /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(
52965 component_default,
52966 {
52967 src: getAvatarUrl(
52968 collaboratorState.collaboratorInfo.avatar_urls
52969 ),
52970 name: collaboratorState.collaboratorInfo.name,
52971 borderColor: getAvatarBorderColor(
52972 collaboratorState.collaboratorInfo.id
52973 ),
52974 size: "small"
52975 },
52976 collaboratorState.clientId
52977 )
52978 )
52979 ] })
52980 }
52981 ),
52982 isPopoverVisible && /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(
52983 CollaboratorsList,
52984 {
52985 activeCollaborators: collaboratorsForList,
52986 popoverAnchor,
52987 setIsPopoverVisible,
52988 cursorRegistry
52989 }
52990 )
52991 ] }),
52992 /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(
52993 CollaboratorsOverlay,
52994 {
52995 postId: postId2,
52996 postType: postType2,
52997 cursorRegistry
52998 }
52999 )
53000 ] });
53001 }
53002
53003 // packages/editor/build-module/components/header/index.mjs
53004 var import_jsx_runtime330 = __toESM(require_jsx_runtime(), 1);
53005 function Header({
53006 customSaveButton,
53007 forceIsDirty,
53008 setEntitiesSavedStatesCallback
53009 }) {
53010 const isWideViewport = (0, import_compose50.useViewportMatch)("large");
53011 const isLargeViewport = (0, import_compose50.useViewportMatch)("medium");
53012 const isTooNarrowForDocumentBar = (0, import_compose50.useMediaQuery)("(max-width: 403px)");
53013 const {
53014 postId: postId2,
53015 postType: postType2,
53016 isTextEditor,
53017 isPublishSidebarOpened: isPublishSidebarOpened2,
53018 showIconLabels,
53019 hasFixedToolbar,
53020 hasBlockSelection,
53021 hasSectionRootClientId,
53022 isStylesCanvasActive,
53023 isAttachment
53024 } = (0, import_data192.useSelect)((select6) => {
53025 const { get: getPreference } = select6(import_preferences21.store);
53026 const {
53027 getEditorMode: getEditorMode2,
53028 getCurrentPostType: getCurrentPostType2,
53029 getCurrentPostId: getCurrentPostId2,
53030 isPublishSidebarOpened: _isPublishSidebarOpened
53031 } = select6(store);
53032 const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock(
53033 select6(store)
53034 );
53035 const { getBlockSelectionStart: getBlockSelectionStart2, getSectionRootClientId } = unlock(
53036 select6(import_block_editor72.store)
53037 );
53038 return {
53039 postId: getCurrentPostId2(),
53040 postType: getCurrentPostType2(),
53041 isTextEditor: getEditorMode2() === "text",
53042 isPublishSidebarOpened: _isPublishSidebarOpened(),
53043 showIconLabels: getPreference("core", "showIconLabels"),
53044 hasFixedToolbar: getPreference("core", "fixedToolbar"),
53045 hasBlockSelection: !!getBlockSelectionStart2(),
53046 hasSectionRootClientId: !!getSectionRootClientId(),
53047 isStylesCanvasActive: !!getStylesPath2()?.startsWith("/revisions") || getShowStylebook2(),
53048 isAttachment: getCurrentPostType2() === ATTACHMENT_POST_TYPE && window?.__experimentalMediaEditor
53049 };
53050 }, []);
53051 const canBeZoomedOut = ["post", "page", "wp_template"].includes(postType2) && hasSectionRootClientId;
53052 const disablePreviewOption = [
53053 ATTACHMENT_POST_TYPE,
53054 NAVIGATION_POST_TYPE,
53055 TEMPLATE_PART_POST_TYPE,
53056 PATTERN_POST_TYPE
53057 ].includes(postType2) || isStylesCanvasActive;
53058 const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0, import_element161.useState)(true);
53059 const hasCenter = !isTooNarrowForDocumentBar && (!hasFixedToolbar || hasFixedToolbar && (!hasBlockSelection || isBlockToolsCollapsed));
53060 return /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(
53061 HeaderSkeleton,
53062 {
53063 toolbar: /* @__PURE__ */ (0, import_jsx_runtime330.jsxs)(import_jsx_runtime330.Fragment, { children: [
53064 !isAttachment && /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(
53065 document_tools_default,
53066 {
53067 disableBlockTools: isStylesCanvasActive || isTextEditor
53068 }
53069 ),
53070 hasFixedToolbar && isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(
53071 CollapsibleBlockToolbar,
53072 {
53073 isCollapsed: isBlockToolsCollapsed,
53074 onToggle: setIsBlockToolsCollapsed
53075 }
53076 )
53077 ] }),
53078 center: hasCenter ? /* @__PURE__ */ (0, import_jsx_runtime330.jsxs)(import_jsx_runtime330.Fragment, { children: [
53079 /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(
53080 CollaboratorsPresence,
53081 {
53082 postType: postType2,
53083 postId: postId2
53084 }
53085 ),
53086 /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(DocumentBar, {})
53087 ] }) : void 0,
53088 settings: /* @__PURE__ */ (0, import_jsx_runtime330.jsxs)(import_jsx_runtime330.Fragment, { children: [
53089 !customSaveButton && !isPublishSidebarOpened2 && /*
53090 * This button isn't completely hidden by the publish sidebar.
53091 * We can't hide the whole toolbar when the publish sidebar is open because
53092 * we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
53093 * We track that DOM node to return focus to the PostPublishButtonOrToggle
53094 * when the publish sidebar has been closed.
53095 */
53096 /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(PostSavedState, { forceIsDirty }),
53097 /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(PostViewLink, {}),
53098 /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(
53099 PreviewDropdown,
53100 {
53101 forceIsAutosaveable: forceIsDirty,
53102 disabled: disablePreviewOption
53103 }
53104 ),
53105 /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(
53106 PostPreviewButton,
53107 {
53108 className: "editor-header__post-preview-button",
53109 forceIsAutosaveable: forceIsDirty
53110 }
53111 ),
53112 isWideViewport && canBeZoomedOut && /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(zoom_out_toggle_default, { disabled: isStylesCanvasActive }),
53113 (isWideViewport || !showIconLabels) && /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(pinned_items_default.Slot, { scope: "core" }),
53114 !customSaveButton && /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(
53115 PostPublishButtonOrToggle,
53116 {
53117 forceIsDirty,
53118 setEntitiesSavedStatesCallback
53119 }
53120 ),
53121 customSaveButton,
53122 !isAttachment && /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(MoreMenu, {})
53123 ] })
53124 }
53125 );
53126 }
53127 var header_default2 = Header;
53128
53129 // packages/editor/build-module/components/inserter-sidebar/index.mjs
53130 var import_data193 = __toESM(require_data(), 1);
53131 var import_block_editor73 = __toESM(require_block_editor(), 1);
53132 var import_compose51 = __toESM(require_compose(), 1);
53133 var import_element162 = __toESM(require_element(), 1);
53134 var import_preferences22 = __toESM(require_preferences(), 1);
53135 var import_keycodes15 = __toESM(require_keycodes(), 1);
53136 var import_jsx_runtime331 = __toESM(require_jsx_runtime(), 1);
53137 var { PrivateInserterLibrary } = unlock(import_block_editor73.privateApis);
53138 function InserterSidebar() {
53139 const {
53140 blockSectionRootClientId,
53141 inserterSidebarToggleRef: inserterSidebarToggleRef2,
53142 inserter,
53143 showMostUsedBlocks,
53144 sidebarIsOpened
53145 } = (0, import_data193.useSelect)((select6) => {
53146 const {
53147 getInserterSidebarToggleRef: getInserterSidebarToggleRef2,
53148 getInserter: getInserter2,
53149 isPublishSidebarOpened: isPublishSidebarOpened2
53150 } = unlock(select6(store));
53151 const { getBlockRootClientId: getBlockRootClientId2, isZoomOut, getSectionRootClientId } = unlock(select6(import_block_editor73.store));
53152 const { get } = select6(import_preferences22.store);
53153 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = select6(store2);
53154 const getBlockSectionRootClientId = () => {
53155 if (isZoomOut()) {
53156 const sectionRootClientId = getSectionRootClientId();
53157 if (sectionRootClientId) {
53158 return sectionRootClientId;
53159 }
53160 }
53161 return getBlockRootClientId2();
53162 };
53163 return {
53164 inserterSidebarToggleRef: getInserterSidebarToggleRef2(),
53165 inserter: getInserter2(),
53166 showMostUsedBlocks: get("core", "mostUsedBlocks"),
53167 blockSectionRootClientId: getBlockSectionRootClientId(),
53168 sidebarIsOpened: !!(getActiveComplementaryArea2("core") || isPublishSidebarOpened2())
53169 };
53170 }, []);
53171 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data193.useDispatch)(store);
53172 const { disableComplementaryArea: disableComplementaryArea2 } = (0, import_data193.useDispatch)(store2);
53173 const isMobileViewport = (0, import_compose51.useViewportMatch)("medium", "<");
53174 const libraryRef = (0, import_element162.useRef)();
53175 const closeInserterSidebar = (0, import_element162.useCallback)(() => {
53176 setIsInserterOpened2(false);
53177 inserterSidebarToggleRef2.current?.focus();
53178 }, [inserterSidebarToggleRef2, setIsInserterOpened2]);
53179 const closeOnEscape = (0, import_element162.useCallback)(
53180 (event) => {
53181 if (event.keyCode === import_keycodes15.ESCAPE && !event.defaultPrevented) {
53182 event.preventDefault();
53183 closeInserterSidebar();
53184 }
53185 },
53186 [closeInserterSidebar]
53187 );
53188 const inserterContents = /* @__PURE__ */ (0, import_jsx_runtime331.jsx)("div", { className: "editor-inserter-sidebar__content", children: /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(
53189 PrivateInserterLibrary,
53190 {
53191 showMostUsedBlocks,
53192 showInserterHelpPanel: true,
53193 shouldFocusBlock: isMobileViewport,
53194 rootClientId: blockSectionRootClientId ?? inserter.rootClientId,
53195 __experimentalInsertionIndex: inserter.insertionIndex,
53196 onSelect: inserter.onSelect,
53197 __experimentalInitialTab: inserter.tab,
53198 __experimentalInitialCategory: inserter.category,
53199 __experimentalFilterValue: inserter.filterValue,
53200 onPatternCategorySelection: sidebarIsOpened ? () => disableComplementaryArea2("core") : void 0,
53201 ref: libraryRef,
53202 onClose: closeInserterSidebar
53203 }
53204 ) });
53205 return (
53206 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
53207 /* @__PURE__ */ (0, import_jsx_runtime331.jsx)("div", { onKeyDown: closeOnEscape, className: "editor-inserter-sidebar", children: inserterContents })
53208 );
53209 }
53210
53211 // packages/editor/build-module/components/list-view-sidebar/index.mjs
53212 var import_block_editor74 = __toESM(require_block_editor(), 1);
53213 var import_compose52 = __toESM(require_compose(), 1);
53214 var import_data194 = __toESM(require_data(), 1);
53215 var import_dom4 = __toESM(require_dom(), 1);
53216 var import_element163 = __toESM(require_element(), 1);
53217 var import_i18n213 = __toESM(require_i18n(), 1);
53218 var import_keyboard_shortcuts8 = __toESM(require_keyboard_shortcuts(), 1);
53219 var import_keycodes16 = __toESM(require_keycodes(), 1);
53220
53221 // packages/editor/build-module/components/list-view-sidebar/list-view-outline.mjs
53222 var import_components190 = __toESM(require_components(), 1);
53223 var import_i18n212 = __toESM(require_i18n(), 1);
53224 var import_jsx_runtime332 = __toESM(require_jsx_runtime(), 1);
53225 function ListViewOutline() {
53226 return /* @__PURE__ */ (0, import_jsx_runtime332.jsxs)(import_jsx_runtime332.Fragment, { children: [
53227 /* @__PURE__ */ (0, import_jsx_runtime332.jsxs)("div", { className: "editor-list-view-sidebar__outline", children: [
53228 /* @__PURE__ */ (0, import_jsx_runtime332.jsxs)("div", { children: [
53229 /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(import_components190.__experimentalText, { children: (0, import_i18n212.__)("Characters:") }),
53230 /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(import_components190.__experimentalText, { children: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(CharacterCount, {}) })
53231 ] }),
53232 /* @__PURE__ */ (0, import_jsx_runtime332.jsxs)("div", { children: [
53233 /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(import_components190.__experimentalText, { children: (0, import_i18n212.__)("Words:") }),
53234 /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(WordCount, {})
53235 ] }),
53236 /* @__PURE__ */ (0, import_jsx_runtime332.jsxs)("div", { children: [
53237 /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(import_components190.__experimentalText, { children: (0, import_i18n212.__)("Time to read:") }),
53238 /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(TimeToRead, {})
53239 ] })
53240 ] }),
53241 /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(DocumentOutline, {})
53242 ] });
53243 }
53244
53245 // packages/editor/build-module/components/list-view-sidebar/index.mjs
53246 var import_jsx_runtime333 = __toESM(require_jsx_runtime(), 1);
53247 var { TabbedSidebar } = unlock(import_block_editor74.privateApis);
53248 function ListViewSidebar() {
53249 const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data194.useDispatch)(store);
53250 const { getListViewToggleRef: getListViewToggleRef2 } = unlock((0, import_data194.useSelect)(store));
53251 const focusOnMountRef = (0, import_compose52.useFocusOnMount)("firstElement");
53252 const closeListView = (0, import_element163.useCallback)(() => {
53253 setIsListViewOpened2(false);
53254 getListViewToggleRef2().current?.focus();
53255 }, [getListViewToggleRef2, setIsListViewOpened2]);
53256 const closeOnEscape = (0, import_element163.useCallback)(
53257 (event) => {
53258 if (event.keyCode === import_keycodes16.ESCAPE && !event.defaultPrevented) {
53259 event.preventDefault();
53260 closeListView();
53261 }
53262 },
53263 [closeListView]
53264 );
53265 const [dropZoneElement, setDropZoneElement] = (0, import_element163.useState)(null);
53266 const [tab, setTab] = (0, import_element163.useState)("list-view");
53267 const sidebarRef = (0, import_element163.useRef)();
53268 const tabsRef = (0, import_element163.useRef)();
53269 const listViewRef = (0, import_element163.useRef)();
53270 const listViewContainerRef = (0, import_compose52.useMergeRefs)([
53271 focusOnMountRef,
53272 listViewRef,
53273 setDropZoneElement
53274 ]);
53275 function handleSidebarFocus(currentTab) {
53276 const tabPanelFocus = import_dom4.focus.tabbable.find(tabsRef.current)[0];
53277 if (currentTab === "list-view") {
53278 const listViewApplicationFocus = import_dom4.focus.tabbable.find(
53279 listViewRef.current
53280 )[0];
53281 const listViewFocusArea = sidebarRef.current.contains(
53282 listViewApplicationFocus
53283 ) ? listViewApplicationFocus : tabPanelFocus;
53284 listViewFocusArea.focus();
53285 } else {
53286 tabPanelFocus.focus();
53287 }
53288 }
53289 const handleToggleListViewShortcut = (0, import_element163.useCallback)(() => {
53290 if (sidebarRef.current.contains(
53291 sidebarRef.current.ownerDocument.activeElement
53292 )) {
53293 closeListView();
53294 } else {
53295 handleSidebarFocus(tab);
53296 }
53297 }, [closeListView, tab]);
53298 (0, import_keyboard_shortcuts8.useShortcut)("core/editor/toggle-list-view", handleToggleListViewShortcut);
53299 return (
53300 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
53301 /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
53302 "div",
53303 {
53304 className: "editor-list-view-sidebar",
53305 onKeyDown: closeOnEscape,
53306 ref: sidebarRef,
53307 children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
53308 TabbedSidebar,
53309 {
53310 tabs: [
53311 {
53312 name: "list-view",
53313 title: (0, import_i18n213._x)("List View", "Post overview"),
53314 panel: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)("div", { className: "editor-list-view-sidebar__list-view-container", children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)("div", { className: "editor-list-view-sidebar__list-view-panel-content", children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
53315 import_block_editor74.__experimentalListView,
53316 {
53317 dropZoneElement
53318 }
53319 ) }) }),
53320 panelRef: listViewContainerRef
53321 },
53322 {
53323 name: "outline",
53324 title: (0, import_i18n213._x)("Outline", "Post overview"),
53325 panel: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)("div", { className: "editor-list-view-sidebar__list-view-container", children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(ListViewOutline, {}) })
53326 }
53327 ],
53328 onClose: closeListView,
53329 onSelect: (tabName) => setTab(tabName),
53330 defaultTabId: "list-view",
53331 ref: tabsRef,
53332 closeButtonLabel: (0, import_i18n213.__)("Close")
53333 }
53334 )
53335 }
53336 )
53337 );
53338 }
53339
53340 // packages/editor/build-module/components/post-revisions-preview/revisions-header.mjs
53341 var import_data196 = __toESM(require_data(), 1);
53342 var import_components192 = __toESM(require_components(), 1);
53343 var import_i18n215 = __toESM(require_i18n(), 1);
53344
53345 // packages/editor/build-module/components/post-revisions-preview/revisions-slider.mjs
53346 var import_data195 = __toESM(require_data(), 1);
53347 var import_components191 = __toESM(require_components(), 1);
53348 var import_core_data114 = __toESM(require_core_data(), 1);
53349 var import_i18n214 = __toESM(require_i18n(), 1);
53350 var import_date9 = __toESM(require_date(), 1);
53351 var import_element164 = __toESM(require_element(), 1);
53352 var import_compose53 = __toESM(require_compose(), 1);
53353 var import_jsx_runtime334 = __toESM(require_jsx_runtime(), 1);
53354 function RevisionsSlider() {
53355 const {
53356 revisions: rawRevisions,
53357 perPage,
53358 currentRevisionId,
53359 revisionKey,
53360 revisionPage: revisionPage2,
53361 totalRevisions
53362 } = (0, import_data195.useSelect)((select6) => {
53363 const {
53364 getCurrentRevisionId: getCurrentRevisionId2,
53365 getRevisionPage: getRevisionPage2,
53366 getPageRevisions: getPageRevisions2,
53367 getRevisionsPerPage: getRevisionsPerPage2
53368 } = unlock(select6(store));
53369 const postType2 = select6(store).getCurrentPostType();
53370 if (!postType2) {
53371 return {};
53372 }
53373 const entityConfig = select6(import_core_data114.store).getEntityConfig(
53374 "postType",
53375 postType2
53376 );
53377 const _revisionKey = entityConfig?.revisionKey || "id";
53378 const _revisionPage = getRevisionPage2();
53379 return {
53380 revisions: getPageRevisions2(_revisionPage),
53381 perPage: getRevisionsPerPage2(),
53382 currentRevisionId: getCurrentRevisionId2(),
53383 revisionKey: _revisionKey,
53384 revisionPage: _revisionPage,
53385 totalRevisions: select6(store).getCurrentPostRevisionsCount()
53386 };
53387 }, []);
53388 const { setCurrentRevisionId: setCurrentRevisionId2, setRevisionPage: setRevisionPage2 } = unlock(
53389 (0, import_data195.useDispatch)(store)
53390 );
53391 const focusOnMountRef = (0, import_compose53.useFocusOnMount)(true);
53392 const isLoading = !rawRevisions;
53393 const totalPages = Math.ceil(totalRevisions / perPage) || 1;
53394 const revisions = (0, import_element164.useMemo)(
53395 () => rawRevisions && [...rawRevisions].reverse(),
53396 [rawRevisions]
53397 );
53398 const selectedIndex = revisions?.findIndex(
53399 (r4) => r4[revisionKey] === currentRevisionId
53400 );
53401 const handleSliderChange = (index2) => {
53402 const revision = revisions?.[index2];
53403 if (revision) {
53404 setCurrentRevisionId2(revision[revisionKey]);
53405 }
53406 };
53407 const dateSettings = (0, import_date9.getSettings)();
53408 const renderTooltipContent = (index2) => {
53409 const revision = revisions?.[index2];
53410 if (!revision) {
53411 return index2;
53412 }
53413 return (0, import_date9.dateI18n)(dateSettings.formats.datetime, revision.date);
53414 };
53415 const showPagination = totalPages > 1;
53416 if (isLoading && !showPagination) {
53417 return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(import_components191.Spinner, {});
53418 }
53419 if (!isLoading && !revisions?.length) {
53420 return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)("span", { className: "editor-revisions-header__no-revisions", children: (0, import_i18n214.__)("No revisions found.") });
53421 }
53422 if (totalRevisions <= 1) {
53423 return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)("span", { className: "editor-revisions-header__no-revisions", children: (0, import_i18n214.__)("Only one revision found.") });
53424 }
53425 const getPageRangeLabel = (page) => {
53426 const end = totalRevisions - (page - 1) * perPage;
53427 const start2 = Math.max(1, end - perPage + 1);
53428 return (0, import_i18n214.sprintf)(
53429 /* translators: 1: first revision number, 2: last revision number */
53430 (0, import_i18n214.__)("Revisions %1$s\u2013%2$s"),
53431 start2,
53432 end
53433 );
53434 };
53435 const sliderOrSpinner = isLoading || selectedIndex === -1 ? /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(import_components191.Spinner, {}) : /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
53436 import_components191.RangeControl,
53437 {
53438 __next40pxDefaultSize: true,
53439 ref: focusOnMountRef,
53440 "aria-valuetext": renderTooltipContent(selectedIndex),
53441 className: "editor-revisions-header__slider",
53442 hideLabelFromVision: true,
53443 label: (0, import_i18n214.__)("Revision"),
53444 max: revisions?.length - 1,
53445 min: 0,
53446 marks: true,
53447 onChange: handleSliderChange,
53448 renderTooltipContent,
53449 value: selectedIndex,
53450 withInputField: false
53451 }
53452 );
53453 if (!showPagination) {
53454 return sliderOrSpinner;
53455 }
53456 return /* @__PURE__ */ (0, import_jsx_runtime334.jsxs)(import_components191.__experimentalHStack, { spacing: 2, expanded: true, wrap: false, children: [
53457 /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
53458 import_components191.Button,
53459 {
53460 icon: chevron_left_default,
53461 label: revisionPage2 < totalPages ? getPageRangeLabel(revisionPage2 + 1) : (0, import_i18n214.__)("No older revisions"),
53462 onClick: () => setRevisionPage2(revisionPage2 + 1),
53463 disabled: isLoading || revisionPage2 >= totalPages,
53464 size: "compact",
53465 accessibleWhenDisabled: true
53466 }
53467 ),
53468 /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
53469 "div",
53470 {
53471 style: {
53472 flex: 1,
53473 minWidth: 0,
53474 display: "flex",
53475 justifyContent: "center"
53476 },
53477 children: sliderOrSpinner
53478 }
53479 ),
53480 /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
53481 import_components191.Button,
53482 {
53483 icon: chevron_right_default,
53484 label: revisionPage2 > 1 ? getPageRangeLabel(revisionPage2 - 1) : (0, import_i18n214.__)("No newer revisions"),
53485 onClick: () => setRevisionPage2(revisionPage2 - 1),
53486 disabled: isLoading || revisionPage2 <= 1,
53487 size: "compact",
53488 accessibleWhenDisabled: true
53489 }
53490 )
53491 ] });
53492 }
53493 var revisions_slider_default = RevisionsSlider;
53494
53495 // packages/editor/build-module/components/sidebar/constants.mjs
53496 var sidebars = {
53497 document: "edit-post/document",
53498 block: "edit-post/block"
53499 };
53500
53501 // packages/editor/build-module/components/post-revisions-preview/revisions-header.mjs
53502 var import_jsx_runtime335 = __toESM(require_jsx_runtime(), 1);
53503 function RevisionsHeader({ showDiff, onToggleDiff }) {
53504 const { currentRevisionId, sidebarIsOpened } = (0, import_data196.useSelect)((select6) => {
53505 return {
53506 currentRevisionId: unlock(
53507 select6(store)
53508 ).getCurrentRevisionId(),
53509 sidebarIsOpened: !!select6(store2).getActiveComplementaryArea(
53510 "core"
53511 )
53512 };
53513 }, []);
53514 const { setCurrentRevisionId: setCurrentRevisionId2, restoreRevision: restoreRevision2 } = unlock(
53515 (0, import_data196.useDispatch)(store)
53516 );
53517 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data196.useDispatch)(store2);
53518 const canRestore = !!currentRevisionId;
53519 const handleRestore = () => {
53520 if (currentRevisionId) {
53521 restoreRevision2(currentRevisionId);
53522 }
53523 };
53524 return /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(
53525 HeaderSkeleton,
53526 {
53527 className: "editor-revisions-header",
53528 toolbar: /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(
53529 import_components192.Button,
53530 {
53531 __next40pxDefaultSize: true,
53532 size: "compact",
53533 icon: seen_default,
53534 label: (0, import_i18n215._x)("Show changes", "revisions"),
53535 isPressed: showDiff,
53536 onClick: onToggleDiff
53537 }
53538 ),
53539 center: /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(revisions_slider_default, {}),
53540 settings: /* @__PURE__ */ (0, import_jsx_runtime335.jsxs)(import_jsx_runtime335.Fragment, { children: [
53541 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(PostPreviewButton, { className: "editor-header__post-preview-button" }),
53542 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(
53543 import_components192.Button,
53544 {
53545 __next40pxDefaultSize: true,
53546 icon: (0, import_i18n215.isRTL)() ? drawer_left_default : drawer_right_default,
53547 label: (0, import_i18n215._x)("Settings", "panel button label"),
53548 isPressed: sidebarIsOpened,
53549 "aria-expanded": sidebarIsOpened,
53550 onClick: () => {
53551 if (sidebarIsOpened) {
53552 disableComplementaryArea2("core");
53553 } else {
53554 enableComplementaryArea2(
53555 "core",
53556 sidebars.document
53557 );
53558 }
53559 },
53560 size: "compact"
53561 }
53562 ),
53563 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(
53564 import_components192.Button,
53565 {
53566 __next40pxDefaultSize: true,
53567 variant: "secondary",
53568 size: "compact",
53569 onClick: () => setCurrentRevisionId2(null),
53570 children: (0, import_i18n215.__)("Exit")
53571 }
53572 ),
53573 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(
53574 import_components192.Button,
53575 {
53576 __next40pxDefaultSize: true,
53577 accessibleWhenDisabled: true,
53578 variant: "primary",
53579 size: "compact",
53580 className: "editor-revisions-header__restore-button",
53581 disabled: !canRestore,
53582 onClick: handleRestore,
53583 children: (0, import_i18n215.__)("Restore")
53584 }
53585 ),
53586 /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(MoreMenu, { disabled: true })
53587 ] })
53588 }
53589 );
53590 }
53591 var revisions_header_default = RevisionsHeader;
53592
53593 // packages/editor/build-module/components/post-revisions-preview/revisions-canvas.mjs
53594 var import_components196 = __toESM(require_components(), 1);
53595 var import_block_editor82 = __toESM(require_block_editor(), 1);
53596 var import_data205 = __toESM(require_data(), 1);
53597 var import_element170 = __toESM(require_element(), 1);
53598 var import_hooks57 = __toESM(require_hooks(), 1);
53599
53600 // packages/editor/build-module/components/visual-editor/index.mjs
53601 var import_block_editor80 = __toESM(require_block_editor(), 1);
53602 var import_element168 = __toESM(require_element(), 1);
53603 var import_data203 = __toESM(require_data(), 1);
53604 var import_blocks34 = __toESM(require_blocks(), 1);
53605 var import_core_data117 = __toESM(require_core_data(), 1);
53606 var import_compose59 = __toESM(require_compose(), 1);
53607
53608 // packages/editor/build-module/components/visual-editor/edit-template-blocks-notification.mjs
53609 var import_data197 = __toESM(require_data(), 1);
53610 var import_core_data115 = __toESM(require_core_data(), 1);
53611 var import_element165 = __toESM(require_element(), 1);
53612 var import_i18n216 = __toESM(require_i18n(), 1);
53613 var import_components193 = __toESM(require_components(), 1);
53614 var import_jsx_runtime336 = __toESM(require_jsx_runtime(), 1);
53615 function EditTemplateBlocksNotification({ contentRef }) {
53616 const { onNavigateToEntityRecord, templateId: templateId2 } = (0, import_data197.useSelect)((select6) => {
53617 const { getEditorSettings: getEditorSettings2, getCurrentTemplateId: getCurrentTemplateId2 } = select6(store);
53618 return {
53619 onNavigateToEntityRecord: getEditorSettings2().onNavigateToEntityRecord,
53620 templateId: getCurrentTemplateId2()
53621 };
53622 }, []);
53623 const canEditTemplate = (0, import_data197.useSelect)(
53624 (select6) => !!select6(import_core_data115.store).canUser("create", {
53625 kind: "postType",
53626 name: "wp_template"
53627 }),
53628 []
53629 );
53630 const [isDialogOpen, setIsDialogOpen] = (0, import_element165.useState)(false);
53631 (0, import_element165.useEffect)(() => {
53632 const handleDblClick = (event) => {
53633 if (!canEditTemplate) {
53634 return;
53635 }
53636 if (!event.target.classList.contains("is-root-container") || event.target.dataset?.type === "core/template-part") {
53637 return;
53638 }
53639 if (!event.defaultPrevented) {
53640 event.preventDefault();
53641 setIsDialogOpen(true);
53642 }
53643 };
53644 const canvas = contentRef.current;
53645 canvas?.addEventListener("dblclick", handleDblClick);
53646 return () => {
53647 canvas?.removeEventListener("dblclick", handleDblClick);
53648 };
53649 }, [contentRef, canEditTemplate]);
53650 if (!canEditTemplate) {
53651 return null;
53652 }
53653 return /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(
53654 import_components193.__experimentalConfirmDialog,
53655 {
53656 isOpen: isDialogOpen,
53657 confirmButtonText: (0, import_i18n216.__)("Edit template"),
53658 onConfirm: () => {
53659 setIsDialogOpen(false);
53660 onNavigateToEntityRecord({
53661 postId: templateId2,
53662 postType: "wp_template"
53663 });
53664 },
53665 onCancel: () => setIsDialogOpen(false),
53666 size: "medium",
53667 children: (0, import_i18n216.__)(
53668 "You\u2019ve tried to select a block that is part of a template that may be used elsewhere on your site. Would you like to edit the template?"
53669 )
53670 }
53671 );
53672 }
53673
53674 // packages/editor/build-module/components/visual-editor/use-select-nearest-editable-block.mjs
53675 var import_compose54 = __toESM(require_compose(), 1);
53676 var import_data198 = __toESM(require_data(), 1);
53677 var import_block_editor75 = __toESM(require_block_editor(), 1);
53678 var DISTANCE_THRESHOLD = 500;
53679 function clamp2(value, min2, max2) {
53680 return Math.min(Math.max(value, min2), max2);
53681 }
53682 function distanceFromRect(x2, y3, rect) {
53683 const dx = x2 - clamp2(x2, rect.left, rect.right);
53684 const dy = y3 - clamp2(y3, rect.top, rect.bottom);
53685 return Math.sqrt(dx * dx + dy * dy);
53686 }
53687 function useSelectNearestEditableBlock({
53688 isEnabled = true
53689 } = {}) {
53690 const { getEnabledClientIdsTree, getBlockName: getBlockName2, getBlockOrder: getBlockOrder2 } = unlock(
53691 (0, import_data198.useSelect)(import_block_editor75.store)
53692 );
53693 const { selectBlock: selectBlock2 } = (0, import_data198.useDispatch)(import_block_editor75.store);
53694 return (0, import_compose54.useRefEffect)(
53695 (element) => {
53696 if (!isEnabled) {
53697 return;
53698 }
53699 const selectNearestEditableBlock = (x2, y3) => {
53700 const editableBlockClientIds = getEnabledClientIdsTree().flatMap(({ clientId }) => {
53701 const blockName = getBlockName2(clientId);
53702 if (blockName === "core/template-part") {
53703 return [];
53704 }
53705 if (blockName === "core/post-content") {
53706 const innerBlocks = getBlockOrder2(clientId);
53707 if (innerBlocks.length) {
53708 return innerBlocks;
53709 }
53710 }
53711 return [clientId];
53712 });
53713 let nearestDistance = Infinity, nearestClientId = null;
53714 for (const clientId of editableBlockClientIds) {
53715 const block = element.querySelector(
53716 `[data-block="${clientId}"]`
53717 );
53718 if (!block) {
53719 continue;
53720 }
53721 const rect = block.getBoundingClientRect();
53722 const distance = distanceFromRect(x2, y3, rect);
53723 if (distance < nearestDistance && distance < DISTANCE_THRESHOLD) {
53724 nearestDistance = distance;
53725 nearestClientId = clientId;
53726 }
53727 }
53728 if (nearestClientId) {
53729 selectBlock2(nearestClientId);
53730 }
53731 };
53732 const handleClick = (event) => {
53733 const shouldSelect = event.target === element || event.target.classList.contains("is-root-container");
53734 if (shouldSelect) {
53735 selectNearestEditableBlock(event.clientX, event.clientY);
53736 }
53737 };
53738 element.addEventListener("click", handleClick);
53739 return () => element.removeEventListener("click", handleClick);
53740 },
53741 [isEnabled]
53742 );
53743 }
53744
53745 // packages/editor/build-module/components/visual-editor/use-zoom-out-mode-exit.mjs
53746 var import_data199 = __toESM(require_data(), 1);
53747 var import_compose55 = __toESM(require_compose(), 1);
53748 var import_block_editor76 = __toESM(require_block_editor(), 1);
53749 function useZoomOutModeExit() {
53750 const { getSettings: getSettings10, isZoomOut } = unlock((0, import_data199.useSelect)(import_block_editor76.store));
53751 const { resetZoomLevel } = unlock((0, import_data199.useDispatch)(import_block_editor76.store));
53752 return (0, import_compose55.useRefEffect)(
53753 (node) => {
53754 function onDoubleClick(event) {
53755 if (!isZoomOut()) {
53756 return;
53757 }
53758 if (!event.defaultPrevented) {
53759 event.preventDefault();
53760 const { __experimentalSetIsInserterOpened } = getSettings10();
53761 if (typeof __experimentalSetIsInserterOpened === "function") {
53762 __experimentalSetIsInserterOpened(false);
53763 }
53764 resetZoomLevel();
53765 }
53766 }
53767 node.addEventListener("dblclick", onDoubleClick);
53768 return () => {
53769 node.removeEventListener("dblclick", onDoubleClick);
53770 };
53771 },
53772 [getSettings10, isZoomOut, resetZoomLevel]
53773 );
53774 }
53775
53776 // packages/editor/build-module/components/visual-editor/use-padding-appender.mjs
53777 var import_data200 = __toESM(require_data(), 1);
53778 var import_compose56 = __toESM(require_compose(), 1);
53779 var import_block_editor77 = __toESM(require_block_editor(), 1);
53780 var import_blocks32 = __toESM(require_blocks(), 1);
53781 var CSS2 = ':root :where(.editor-styles-wrapper)::after {content: ""; display: block; height: 40vh;}';
53782 function usePaddingAppender(enabled) {
53783 const registry = (0, import_data200.useRegistry)();
53784 const effect = (0, import_compose56.useRefEffect)(
53785 (node) => {
53786 function onMouseDown(event) {
53787 if (event.target !== node && // Tests for the parent element because in the iframed editor if the click is
53788 // below the padding the target will be the parent element (html) and should
53789 // still be treated as intent to append.
53790 event.target !== node.parentElement) {
53791 return;
53792 }
53793 const lastChild = node.lastElementChild;
53794 if (!lastChild) {
53795 return;
53796 }
53797 const lastChildRect = lastChild.getBoundingClientRect();
53798 if (event.clientY < lastChildRect.bottom) {
53799 return;
53800 }
53801 event.preventDefault();
53802 const blockOrder = registry.select(import_block_editor77.store).getBlockOrder("");
53803 const lastBlockClientId = blockOrder[blockOrder.length - 1];
53804 const lastBlock = registry.select(import_block_editor77.store).getBlock(lastBlockClientId);
53805 const { selectBlock: selectBlock2, insertDefaultBlock: insertDefaultBlock2 } = registry.dispatch(import_block_editor77.store);
53806 if (lastBlock && (0, import_blocks32.isUnmodifiedDefaultBlock)(lastBlock)) {
53807 selectBlock2(lastBlockClientId);
53808 } else {
53809 insertDefaultBlock2();
53810 }
53811 }
53812 const { ownerDocument } = node;
53813 ownerDocument.addEventListener("pointerdown", onMouseDown);
53814 return () => {
53815 ownerDocument.removeEventListener("pointerdown", onMouseDown);
53816 };
53817 },
53818 [registry]
53819 );
53820 return enabled ? [effect, CSS2] : [];
53821 }
53822
53823 // packages/editor/build-module/components/visual-editor/use-edit-content-only-section-exit.mjs
53824 var import_data201 = __toESM(require_data(), 1);
53825 var import_compose57 = __toESM(require_compose(), 1);
53826 var import_block_editor78 = __toESM(require_block_editor(), 1);
53827 function useEditContentOnlySectionExit() {
53828 const { getEditedContentOnlySection } = unlock(
53829 (0, import_data201.useSelect)(import_block_editor78.store)
53830 );
53831 const { stopEditingContentOnlySection } = unlock(
53832 (0, import_data201.useDispatch)(import_block_editor78.store)
53833 );
53834 return (0, import_compose57.useRefEffect)(
53835 (node) => {
53836 function onClick(event) {
53837 const editedContentOnlySection = getEditedContentOnlySection();
53838 if (!editedContentOnlySection) {
53839 return;
53840 }
53841 const isClickOutside = !event.target.closest(
53842 `[data-block="${editedContentOnlySection}"]`
53843 );
53844 if (isClickOutside && !event.defaultPrevented) {
53845 event.preventDefault();
53846 stopEditingContentOnlySection();
53847 }
53848 }
53849 node.addEventListener("click", onClick);
53850 return () => {
53851 node.removeEventListener("click", onClick);
53852 };
53853 },
53854 [getEditedContentOnlySection, stopEditingContentOnlySection]
53855 );
53856 }
53857
53858 // packages/editor/build-module/components/sync-connection-error-modal/index.mjs
53859 var import_data202 = __toESM(require_data(), 1);
53860 var import_compose58 = __toESM(require_compose(), 1);
53861 var import_blocks33 = __toESM(require_blocks(), 1);
53862 var import_core_data116 = __toESM(require_core_data(), 1);
53863 var import_block_editor79 = __toESM(require_block_editor(), 1);
53864 var import_components194 = __toESM(require_components(), 1);
53865 var import_hooks56 = __toESM(require_hooks(), 1);
53866 var import_element167 = __toESM(require_element(), 1);
53867 var import_i18n217 = __toESM(require_i18n(), 1);
53868
53869 // packages/editor/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs
53870 var import_element166 = __toESM(require_element(), 1);
53871 function useRetryCountdown(connectionStatus) {
53872 const [secondsRemaining, setSecondsRemaining] = (0, import_element166.useState)();
53873 const hasRetriedRef = (0, import_element166.useRef)(false);
53874 (0, import_element166.useEffect)(() => {
53875 if (!connectionStatus) {
53876 return;
53877 }
53878 if ("connected" === connectionStatus.status) {
53879 setSecondsRemaining(void 0);
53880 hasRetriedRef.current = false;
53881 return;
53882 }
53883 if ("disconnected" !== connectionStatus.status || !connectionStatus.willAutoRetryInMs) {
53884 return;
53885 }
53886 const { willAutoRetryInMs: retryInMs } = connectionStatus;
53887 const retryAt = Date.now() + retryInMs;
53888 const hasRetried = hasRetriedRef.current;
53889 hasRetriedRef.current = true;
53890 if (hasRetried) {
53891 setSecondsRemaining(0);
53892 }
53893 let countdownIntervalId = null;
53894 const startCountdown = () => {
53895 setSecondsRemaining(Math.ceil((retryAt - Date.now()) / 1e3));
53896 countdownIntervalId = setInterval(() => {
53897 const remaining = Math.ceil((retryAt - Date.now()) / 1e3);
53898 setSecondsRemaining(Math.max(0, remaining));
53899 if (remaining <= 0 && countdownIntervalId) {
53900 clearInterval(countdownIntervalId);
53901 }
53902 }, 1e3);
53903 };
53904 const retryingDelayId = hasRetried ? setTimeout(startCountdown, 500) : null;
53905 if (!retryingDelayId) {
53906 startCountdown();
53907 }
53908 return () => {
53909 if (retryingDelayId) {
53910 clearTimeout(retryingDelayId);
53911 }
53912 if (countdownIntervalId) {
53913 clearInterval(countdownIntervalId);
53914 }
53915 };
53916 }, [connectionStatus]);
53917 return {
53918 onManualRetry: () => {
53919 setSecondsRemaining(0);
53920 },
53921 secondsRemaining
53922 };
53923 }
53924
53925 // packages/editor/build-module/components/sync-connection-error-modal/index.mjs
53926 var import_jsx_runtime337 = __toESM(require_jsx_runtime(), 1);
53927 var { BlockCanvasCover: BlockCanvasCover2 } = unlock(import_block_editor79.privateApis);
53928 var { retrySyncConnection } = unlock(import_core_data116.privateApis);
53929 var INITIAL_DISCONNECTED_DEBOUNCE_MS = 2e4;
53930 function SyncConnectionErrorModal() {
53931 const [hasInitialized, setHasInitialized] = (0, import_element167.useState)(false);
53932 const [showModal, setShowModal] = (0, import_element167.useState)(false);
53933 const [isManualRetryAvailable, setIsManualRetryAvailable] = (0, import_element167.useState)(false);
53934 const { connectionStatus, isCollaborationEnabled, postType: postType2 } = (0, import_data202.useSelect)(
53935 (selectFn) => {
53936 const { getSyncConnectionStatus, getPostType } = unlock(
53937 selectFn(import_core_data116.store)
53938 );
53939 const { getCurrentPostType: getCurrentPostType2, isCollaborationEnabledForCurrentPost: isCollaborationEnabledForCurrentPost2 } = unlock(selectFn(store));
53940 const currentPostType = getCurrentPostType2();
53941 return {
53942 connectionStatus: getSyncConnectionStatus() || null,
53943 isCollaborationEnabled: isCollaborationEnabledForCurrentPost2(),
53944 postType: currentPostType ? getPostType(currentPostType) : null
53945 };
53946 },
53947 []
53948 );
53949 const { onManualRetry, secondsRemaining } = useRetryCountdown(connectionStatus);
53950 const copyButtonRef = (0, import_compose58.useCopyToClipboard)(() => {
53951 const blocks = (0, import_data202.select)(import_block_editor79.store).getBlocks();
53952 return (0, import_blocks33.serialize)(blocks);
53953 });
53954 (0, import_element167.useEffect)(() => {
53955 const timeout = setTimeout(() => {
53956 setHasInitialized(true);
53957 }, INITIAL_DISCONNECTED_DEBOUNCE_MS);
53958 return () => clearTimeout(timeout);
53959 }, []);
53960 (0, import_element167.useEffect)(() => {
53961 if ("connecting" === connectionStatus?.status) {
53962 return;
53963 }
53964 setIsManualRetryAvailable(
53965 connectionStatus !== null && "canManuallyRetry" in connectionStatus && connectionStatus.canManuallyRetry === true
53966 );
53967 }, [connectionStatus]);
53968 const canRetry = connectionStatus && "disconnected" === connectionStatus.status && (connectionStatus.canManuallyRetry || connectionStatus.willAutoRetryInMs);
53969 (0, import_element167.useEffect)(() => {
53970 if ("connected" === connectionStatus?.status) {
53971 setShowModal(false);
53972 return;
53973 }
53974 if (connectionStatus?.status && "connecting" !== connectionStatus.status && (!canRetry || connectionStatus.backgroundRetriesFailed)) {
53975 setShowModal(true);
53976 }
53977 }, [connectionStatus, canRetry]);
53978 if (!isCollaborationEnabled || !hasInitialized || !showModal) {
53979 return null;
53980 }
53981 const error = connectionStatus && "error" in connectionStatus ? connectionStatus?.error : void 0;
53982 if (!canRetry && (0, import_hooks56.applyFilters)(
53983 "editor.isSyncConnectionErrorHandled",
53984 false,
53985 error?.code
53986 ) !== false) {
53987 return null;
53988 }
53989 const manualRetry = isManualRetryAvailable ? () => {
53990 onManualRetry();
53991 retrySyncConnection();
53992 } : void 0;
53993 const messages = getSyncErrorMessages(error);
53994 let retryCountdownText = "";
53995 let isRetrying = false;
53996 if (secondsRemaining && secondsRemaining > 0) {
53997 retryCountdownText = (0, import_i18n217.sprintf)(
53998 /* translators: %d: number of seconds until retry */
53999 (0, import_i18n217._n)(
54000 "Retrying connection in %d second\u2026",
54001 "Retrying connection in %d seconds\u2026",
54002 secondsRemaining
54003 ),
54004 secondsRemaining
54005 );
54006 } else if (0 === secondsRemaining) {
54007 isRetrying = true;
54008 retryCountdownText = (0, import_i18n217.__)("Retrying\u2026");
54009 }
54010 let editPostHref = "edit.php";
54011 if (postType2?.slug) {
54012 editPostHref = `edit.php?post_type=${postType2.slug}`;
54013 }
54014 return /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(BlockCanvasCover2.Fill, { children: /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
54015 import_components194.Modal,
54016 {
54017 overlayClassName: "editor-sync-connection-error-modal",
54018 isDismissible: false,
54019 onRequestClose: () => {
54020 },
54021 shouldCloseOnClickOutside: false,
54022 shouldCloseOnEsc: false,
54023 size: "medium",
54024 title: messages.title,
54025 children: /* @__PURE__ */ (0, import_jsx_runtime337.jsxs)(import_components194.__experimentalVStack, { spacing: 6, children: [
54026 /* @__PURE__ */ (0, import_jsx_runtime337.jsx)("p", { children: messages.description }),
54027 retryCountdownText && /* @__PURE__ */ (0, import_jsx_runtime337.jsx)("p", { className: "editor-sync-connection-error-modal__retry-countdown", children: retryCountdownText }),
54028 /* @__PURE__ */ (0, import_jsx_runtime337.jsxs)(import_components194.__experimentalHStack, { justify: "right", children: [
54029 /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
54030 import_components194.Button,
54031 {
54032 __next40pxDefaultSize: true,
54033 href: editPostHref,
54034 isDestructive: true,
54035 variant: "tertiary",
54036 children: (0, import_i18n217.sprintf)(
54037 /* translators: %s: Post type name (e.g., "Posts", "Pages"). */
54038 (0, import_i18n217.__)("Back to %s"),
54039 postType2?.labels?.name ?? (0, import_i18n217.__)("Posts")
54040 )
54041 }
54042 ),
54043 /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
54044 import_components194.Button,
54045 {
54046 __next40pxDefaultSize: true,
54047 ref: copyButtonRef,
54048 variant: manualRetry ? "secondary" : "primary",
54049 children: (0, import_i18n217.__)("Copy Post Content")
54050 }
54051 ),
54052 manualRetry && /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
54053 import_components194.Button,
54054 {
54055 __next40pxDefaultSize: true,
54056 accessibleWhenDisabled: true,
54057 "aria-disabled": isRetrying,
54058 disabled: isRetrying,
54059 isBusy: isRetrying,
54060 variant: "primary",
54061 onClick: manualRetry,
54062 children: (0, import_i18n217.__)("Retry")
54063 }
54064 )
54065 ] })
54066 ] })
54067 }
54068 ) });
54069 }
54070
54071 // packages/editor/build-module/components/visual-editor/index.mjs
54072 var import_jsx_runtime338 = __toESM(require_jsx_runtime(), 1);
54073 var {
54074 LayoutStyle,
54075 useLayoutClasses,
54076 useLayoutStyles,
54077 ExperimentalBlockCanvas: BlockCanvas,
54078 useFlashEditableBlocks
54079 } = unlock(import_block_editor80.privateApis);
54080 function getPostContentAttributes(blocks) {
54081 for (let i3 = 0; i3 < blocks.length; i3++) {
54082 if (blocks[i3].name === "core/post-content") {
54083 return blocks[i3].attributes;
54084 }
54085 if (blocks[i3].innerBlocks.length) {
54086 const nestedPostContent = getPostContentAttributes(
54087 blocks[i3].innerBlocks
54088 );
54089 if (nestedPostContent) {
54090 return nestedPostContent;
54091 }
54092 }
54093 }
54094 }
54095 function checkForPostContentAtRootLevel(blocks) {
54096 for (let i3 = 0; i3 < blocks.length; i3++) {
54097 if (blocks[i3].name === "core/post-content") {
54098 return true;
54099 }
54100 }
54101 return false;
54102 }
54103 function VisualEditor({
54104 // Ideally as we unify post and site editors, we won't need these props.
54105 autoFocus,
54106 disableIframe = false,
54107 iframeProps,
54108 contentRef,
54109 className
54110 }) {
54111 const isMobileViewport = (0, import_compose59.useViewportMatch)("small", "<");
54112 const {
54113 renderingMode: renderingMode2,
54114 postContentAttributes,
54115 editedPostTemplate = {},
54116 wrapperBlockName,
54117 wrapperUniqueId,
54118 deviceType: deviceType2,
54119 isFocusedEntity,
54120 isDesignPostType,
54121 postType: postType2,
54122 isPreview,
54123 styles,
54124 canvasMinHeight: canvasMinHeight2
54125 } = (0, import_data203.useSelect)((select6) => {
54126 const {
54127 getCurrentPostId: getCurrentPostId2,
54128 getCurrentPostType: getCurrentPostType2,
54129 getCurrentTemplateId: getCurrentTemplateId2,
54130 getEditorSettings: getEditorSettings2,
54131 getRenderingMode: getRenderingMode2,
54132 getDeviceType: getDeviceType2,
54133 getCanvasMinHeight: getCanvasMinHeight2
54134 } = unlock(select6(store));
54135 const { getPostType, getEditedEntityRecord } = select6(import_core_data117.store);
54136 const postTypeSlug = getCurrentPostType2();
54137 const _renderingMode = getRenderingMode2();
54138 let _wrapperBlockName;
54139 if (postTypeSlug === PATTERN_POST_TYPE) {
54140 _wrapperBlockName = "core/block";
54141 } else if (_renderingMode === "post-only") {
54142 _wrapperBlockName = "core/post-content";
54143 }
54144 const editorSettings2 = getEditorSettings2();
54145 const supportsTemplateMode = editorSettings2.supportsTemplateMode;
54146 const postTypeObject = getPostType(postTypeSlug);
54147 const currentTemplateId = getCurrentTemplateId2();
54148 const template2 = currentTemplateId ? getEditedEntityRecord(
54149 "postType",
54150 TEMPLATE_POST_TYPE,
54151 currentTemplateId
54152 ) : void 0;
54153 return {
54154 renderingMode: _renderingMode,
54155 postContentAttributes: editorSettings2.postContentAttributes,
54156 isDesignPostType: DESIGN_POST_TYPES.includes(postTypeSlug),
54157 // Post template fetch returns a 404 on classic themes, which
54158 // messes with e2e tests, so check it's a block theme first.
54159 editedPostTemplate: postTypeObject?.viewable && supportsTemplateMode ? template2 : void 0,
54160 wrapperBlockName: _wrapperBlockName,
54161 wrapperUniqueId: getCurrentPostId2(),
54162 deviceType: getDeviceType2(),
54163 isFocusedEntity: !!editorSettings2.onNavigateToPreviousEntityRecord,
54164 postType: postTypeSlug,
54165 isPreview: editorSettings2.isPreviewMode,
54166 styles: editorSettings2.styles,
54167 canvasMinHeight: getCanvasMinHeight2()
54168 };
54169 }, []);
54170 const { isCleanNewPost: isCleanNewPost2 } = (0, import_data203.useSelect)(store);
54171 const {
54172 hasRootPaddingAwareAlignments,
54173 themeHasDisabledLayoutStyles,
54174 themeSupportsLayout,
54175 isZoomedOut
54176 } = (0, import_data203.useSelect)((select6) => {
54177 const { getSettings: getSettings10, isZoomOut: _isZoomOut } = unlock(
54178 select6(import_block_editor80.store)
54179 );
54180 const _settings = getSettings10();
54181 return {
54182 themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
54183 themeSupportsLayout: _settings.supportsLayout,
54184 hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
54185 isZoomedOut: _isZoomOut()
54186 };
54187 }, []);
54188 const localRef = (0, import_element168.useRef)();
54189 const deviceStyles = (0, import_block_editor80.__experimentalUseResizeCanvas)(deviceType2);
54190 const [globalLayoutSettings] = (0, import_block_editor80.useSettings)("layout");
54191 const fallbackLayout = (0, import_element168.useMemo)(() => {
54192 if (renderingMode2 !== "post-only" || isDesignPostType) {
54193 return { type: "default" };
54194 }
54195 if (themeSupportsLayout) {
54196 return { ...globalLayoutSettings, type: "constrained" };
54197 }
54198 return { type: "default" };
54199 }, [
54200 renderingMode2,
54201 themeSupportsLayout,
54202 globalLayoutSettings,
54203 isDesignPostType
54204 ]);
54205 const newestPostContentAttributes = (0, import_element168.useMemo)(() => {
54206 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks && postContentAttributes) {
54207 return postContentAttributes;
54208 }
54209 if (editedPostTemplate?.blocks) {
54210 return getPostContentAttributes(editedPostTemplate?.blocks);
54211 }
54212 const parseableContent = typeof editedPostTemplate?.content === "string" ? editedPostTemplate?.content : "";
54213 return getPostContentAttributes((0, import_blocks34.parse)(parseableContent)) || {};
54214 }, [
54215 editedPostTemplate?.content,
54216 editedPostTemplate?.blocks,
54217 postContentAttributes
54218 ]);
54219 const hasPostContentAtRootLevel = (0, import_element168.useMemo)(() => {
54220 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
54221 return false;
54222 }
54223 if (editedPostTemplate?.blocks) {
54224 return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
54225 }
54226 const parseableContent = typeof editedPostTemplate?.content === "string" ? editedPostTemplate?.content : "";
54227 return checkForPostContentAtRootLevel((0, import_blocks34.parse)(parseableContent)) || false;
54228 }, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
54229 const { layout = {}, align = "" } = newestPostContentAttributes || {};
54230 const postContentLayoutClasses = useLayoutClasses(
54231 newestPostContentAttributes,
54232 "core/post-content"
54233 );
54234 const blockListLayoutClass = clsx_default(
54235 {
54236 "is-layout-flow": !themeSupportsLayout
54237 },
54238 themeSupportsLayout && postContentLayoutClasses,
54239 align && `align${align}`
54240 );
54241 const postContentLayoutStyles = useLayoutStyles(
54242 newestPostContentAttributes,
54243 "core/post-content",
54244 ".block-editor-block-list__layout.is-root-container"
54245 );
54246 const postContentLayout = (0, import_element168.useMemo)(() => {
54247 return layout && (layout?.type === "constrained" || layout?.inherit || layout?.contentSize || layout?.wideSize) ? { ...globalLayoutSettings, ...layout, type: "constrained" } : { ...globalLayoutSettings, ...layout, type: "default" };
54248 }, [
54249 layout?.type,
54250 layout?.inherit,
54251 layout?.contentSize,
54252 layout?.wideSize,
54253 globalLayoutSettings
54254 ]);
54255 const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
54256 const postEditorLayout = blockListLayout?.type === "default" && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
54257 const observeTypingRef = (0, import_block_editor80.__unstableUseTypingObserver)();
54258 const titleRef = (0, import_element168.useRef)();
54259 (0, import_element168.useEffect)(() => {
54260 if (!autoFocus || !isCleanNewPost2()) {
54261 return;
54262 }
54263 titleRef?.current?.focus();
54264 }, [autoFocus, isCleanNewPost2]);
54265 const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
54266 .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
54267 .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
54268 .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
54269 const enableResizing = [
54270 NAVIGATION_POST_TYPE,
54271 TEMPLATE_PART_POST_TYPE,
54272 PATTERN_POST_TYPE
54273 ].includes(postType2) && // Disable in previews / view mode.
54274 !isPreview && // Disable resizing in mobile viewport.
54275 !isMobileViewport && // Disable resizing in zoomed-out mode.
54276 !isZoomedOut;
54277 const calculatedMinHeight = (0, import_element168.useMemo)(() => {
54278 if (!localRef.current) {
54279 return canvasMinHeight2;
54280 }
54281 const { ownerDocument } = localRef.current;
54282 const scrollTop = ownerDocument.documentElement.scrollTop || ownerDocument.body.scrollTop;
54283 return canvasMinHeight2 + scrollTop;
54284 }, [canvasMinHeight2]);
54285 const [paddingAppenderRef, paddingStyle] = usePaddingAppender(
54286 !isPreview && renderingMode2 === "post-only" && !isDesignPostType
54287 );
54288 const iframeStyles = (0, import_element168.useMemo)(() => {
54289 return [
54290 ...styles ?? [],
54291 {
54292 // Ensures margins of children are contained so that the body background paints behind them.
54293 // Otherwise, the background of html (when zoomed out) would show there and appear broken. It's
54294 // important mostly for post-only views yet conceivably an issue in templated views too.
54295 css: `:where(.block-editor-iframe__body){display:flow-root;${calculatedMinHeight ? `min-height:${calculatedMinHeight}px;` : ""}}.is-root-container{display:flow-root;${// Some themes will have `min-height: 100vh` for the root container,
54296 // which isn't a requirement in auto resize mode.
54297 enableResizing ? "min-height:0!important;" : ""}}
54298 ${paddingStyle ? paddingStyle : ""}
54299 ${enableResizing ? `.block-editor-iframe__html{background:var(--wp-editor-canvas-background);display:flex;align-items:center;justify-content:center;min-height:100vh;}.block-editor-iframe__body{width:100%;}` : ""}`
54300 // The CSS above centers the body content vertically when resizing is enabled and applies a background
54301 // color to the iframe HTML element to match the background color of the editor canvas.
54302 }
54303 ];
54304 }, [styles, enableResizing, calculatedMinHeight, paddingStyle]);
54305 const typewriterRef = (0, import_block_editor80.__unstableUseTypewriter)();
54306 contentRef = (0, import_compose59.useMergeRefs)([
54307 localRef,
54308 contentRef,
54309 renderingMode2 === "post-only" ? typewriterRef : null,
54310 useFlashEditableBlocks({
54311 isEnabled: renderingMode2 === "template-locked"
54312 }),
54313 useSelectNearestEditableBlock({
54314 isEnabled: renderingMode2 === "template-locked"
54315 }),
54316 useZoomOutModeExit(),
54317 paddingAppenderRef,
54318 useEditContentOnlySectionExit()
54319 ]);
54320 return /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(
54321 "div",
54322 {
54323 className: clsx_default(
54324 "editor-visual-editor",
54325 // this class is here for backward compatibility reasons.
54326 "edit-post-visual-editor",
54327 className,
54328 {
54329 "has-padding": isFocusedEntity || enableResizing,
54330 "is-resizable": enableResizing,
54331 "is-iframed": !disableIframe
54332 }
54333 ),
54334 children: [
54335 /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(SyncConnectionErrorModal, {}),
54336 /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(resizable_editor_default, { enableResizing, height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(
54337 BlockCanvas,
54338 {
54339 shouldIframe: !disableIframe,
54340 contentRef,
54341 styles: iframeStyles,
54342 height: "100%",
54343 iframeProps: {
54344 ...iframeProps,
54345 style: {
54346 ...iframeProps?.style,
54347 ...deviceStyles
54348 }
54349 },
54350 children: [
54351 themeSupportsLayout && !themeHasDisabledLayoutStyles && renderingMode2 === "post-only" && !isDesignPostType && /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(import_jsx_runtime338.Fragment, { children: [
54352 /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
54353 LayoutStyle,
54354 {
54355 selector: ".editor-visual-editor__post-title-wrapper",
54356 layout: fallbackLayout
54357 }
54358 ),
54359 /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
54360 LayoutStyle,
54361 {
54362 selector: ".block-editor-block-list__layout.is-root-container",
54363 layout: postEditorLayout
54364 }
54365 ),
54366 align && /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(LayoutStyle, { css: alignCSS }),
54367 postContentLayoutStyles && /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
54368 LayoutStyle,
54369 {
54370 layout: postContentLayout,
54371 css: postContentLayoutStyles
54372 }
54373 )
54374 ] }),
54375 renderingMode2 === "post-only" && !isDesignPostType && /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
54376 "div",
54377 {
54378 className: clsx_default(
54379 "editor-visual-editor__post-title-wrapper",
54380 // The following class is only here for backward compatibility
54381 // some themes might be using it to style the post title.
54382 "edit-post-visual-editor__post-title-wrapper",
54383 {
54384 "has-global-padding": hasRootPaddingAwareAlignments
54385 }
54386 ),
54387 contentEditable: false,
54388 ref: observeTypingRef,
54389 style: {
54390 // This is using inline styles
54391 // so it's applied for both iframed and non iframed editors.
54392 marginTop: "4rem"
54393 },
54394 children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(post_title_default, { ref: titleRef })
54395 }
54396 ),
54397 /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(
54398 import_block_editor80.RecursionProvider,
54399 {
54400 blockName: wrapperBlockName,
54401 uniqueId: wrapperUniqueId,
54402 children: [
54403 /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
54404 import_block_editor80.BlockList,
54405 {
54406 className: clsx_default(
54407 "is-" + deviceType2.toLowerCase() + "-preview",
54408 renderingMode2 !== "post-only" || isDesignPostType ? "wp-site-blocks" : `${blockListLayoutClass} wp-block-post-content`,
54409 // Ensure root level blocks receive default/flow blockGap styling rules.
54410 {
54411 "has-global-padding": renderingMode2 === "post-only" && !isDesignPostType && hasRootPaddingAwareAlignments
54412 }
54413 ),
54414 layout: blockListLayout,
54415 dropZoneElement: (
54416 // When iframed, pass in the html element of the iframe to
54417 // ensure the drop zone extends to the edges of the iframe.
54418 disableIframe ? localRef.current : localRef.current?.parentNode
54419 ),
54420 __unstableDisableDropZone: (
54421 // In template preview mode, disable drop zones at the root of the template.
54422 renderingMode2 === "template-locked" ? true : false
54423 )
54424 }
54425 ),
54426 renderingMode2 === "template-locked" && /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
54427 EditTemplateBlocksNotification,
54428 {
54429 contentRef: localRef
54430 }
54431 )
54432 ]
54433 }
54434 )
54435 ]
54436 }
54437 ) })
54438 ]
54439 }
54440 );
54441 }
54442 var visual_editor_default = VisualEditor;
54443
54444 // packages/editor/build-module/components/post-revisions-preview/diff-format-types.mjs
54445 var import_i18n218 = __toESM(require_i18n(), 1);
54446 var import_rich_text4 = __toESM(require_rich_text(), 1);
54447 var DIFF_FORMAT_TYPES = [
54448 {
54449 name: "revision/diff-removed",
54450 title: (0, import_i18n218.__)("Removed"),
54451 tagName: "del",
54452 className: "revision-diff-removed"
54453 },
54454 {
54455 name: "revision/diff-added",
54456 title: (0, import_i18n218.__)("Added"),
54457 tagName: "ins",
54458 className: "revision-diff-added"
54459 },
54460 {
54461 name: "revision/diff-format-added",
54462 title: (0, import_i18n218.__)("Format added"),
54463 tagName: "span",
54464 className: "revision-diff-format-added"
54465 },
54466 {
54467 name: "revision/diff-format-removed",
54468 title: (0, import_i18n218.__)("Format removed"),
54469 tagName: "span",
54470 className: "revision-diff-format-removed"
54471 },
54472 {
54473 name: "revision/diff-format-changed",
54474 title: (0, import_i18n218.__)("Format changed"),
54475 tagName: "span",
54476 className: "revision-diff-format-changed"
54477 }
54478 ];
54479 function registerDiffFormatTypes() {
54480 for (const formatType of DIFF_FORMAT_TYPES) {
54481 (0, import_rich_text4.registerFormatType)(formatType.name, {
54482 ...formatType,
54483 attributes: { title: "title" },
54484 edit: () => null
54485 });
54486 }
54487 }
54488 function unregisterDiffFormatTypes() {
54489 for (const formatType of DIFF_FORMAT_TYPES) {
54490 (0, import_rich_text4.unregisterFormatType)(formatType.name);
54491 }
54492 }
54493
54494 // packages/editor/build-module/components/post-revisions-preview/diff-markers.mjs
54495 var import_element169 = __toESM(require_element(), 1);
54496 var import_compose60 = __toESM(require_compose(), 1);
54497 var import_data204 = __toESM(require_data(), 1);
54498 var import_block_editor81 = __toESM(require_block_editor(), 1);
54499 var import_i18n219 = __toESM(require_i18n(), 1);
54500 var import_components195 = __toESM(require_components(), 1);
54501 var import_jsx_runtime339 = __toESM(require_jsx_runtime(), 1);
54502 var { useBlockElementRef } = unlock(import_block_editor81.privateApis);
54503 function collectDiffBlocks(blocks) {
54504 const result = [];
54505 for (const block of blocks) {
54506 if (block.__revisionDiffStatus?.status) {
54507 result.push({
54508 clientId: block.clientId,
54509 status: block.__revisionDiffStatus.status
54510 });
54511 }
54512 if (block.innerBlocks?.length) {
54513 result.push(...collectDiffBlocks(block.innerBlocks));
54514 }
54515 }
54516 return result;
54517 }
54518 var STATUS_LABELS = {
54519 added: (0, import_i18n219.__)("Go to added block"),
54520 removed: (0, import_i18n219.__)("Go to removed block"),
54521 modified: (0, import_i18n219.__)("Go to modified block")
54522 };
54523 function calculatePosition(el) {
54524 if (!el) {
54525 return null;
54526 }
54527 const doc = el.ownerDocument;
54528 const scrollHeight = doc.documentElement.scrollHeight;
54529 const rect = el.getBoundingClientRect();
54530 const scrollTop = doc.documentElement.scrollTop;
54531 const top = rect.top + scrollTop;
54532 return {
54533 top: top / scrollHeight * 100,
54534 height: rect.height / scrollHeight * 100
54535 };
54536 }
54537 function DiffMarkerButton({ clientId, status, subscribe }) {
54538 const blockRef = (0, import_element169.useRef)();
54539 useBlockElementRef(clientId, blockRef);
54540 const [position, setPosition] = (0, import_element169.useState)(
54541 () => calculatePosition(blockRef.current)
54542 );
54543 (0, import_element169.useEffect)(() => {
54544 return subscribe(() => {
54545 setPosition(calculatePosition(blockRef.current));
54546 });
54547 }, [subscribe]);
54548 (0, import_element169.useEffect)(() => {
54549 setPosition(calculatePosition(blockRef.current));
54550 }, [status]);
54551 if (!position) {
54552 return null;
54553 }
54554 return /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(import_components195.Tooltip, { text: STATUS_LABELS[status], children: /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
54555 "button",
54556 {
54557 className: `revision-diff-marker is-${status}`,
54558 style: {
54559 top: `${position.top}%`,
54560 height: `${Math.max(position.height, 0.5)}%`
54561 },
54562 onClick: () => blockRef.current?.focus(),
54563 "aria-label": STATUS_LABELS[status]
54564 }
54565 ) });
54566 }
54567 function useDiffMarkers() {
54568 const [isMounted, setIsMounted] = (0, import_element169.useState)(false);
54569 const subscribersRef = (0, import_element169.useRef)(/* @__PURE__ */ new Set());
54570 const blocks = (0, import_data204.useSelect)(
54571 (select6) => select6(import_block_editor81.store).getBlocks(),
54572 []
54573 );
54574 const diffBlocks = (0, import_element169.useMemo)(() => collectDiffBlocks(blocks), [blocks]);
54575 const subscribe = (0, import_element169.useCallback)((callback) => {
54576 subscribersRef.current.add(callback);
54577 return () => subscribersRef.current.delete(callback);
54578 }, []);
54579 const contentRef = (0, import_compose60.useRefEffect)((element) => {
54580 const { ownerDocument } = element;
54581 const { defaultView } = ownerDocument;
54582 const resizeObserver = new defaultView.ResizeObserver(() => {
54583 subscribersRef.current.forEach((cb) => cb());
54584 });
54585 resizeObserver.observe(ownerDocument.body);
54586 return () => {
54587 resizeObserver.disconnect();
54588 };
54589 }, []);
54590 return [
54591 (0, import_compose60.useMergeRefs)([contentRef, setIsMounted]),
54592 /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
54593 "div",
54594 {
54595 className: "revision-diff-markers",
54596 role: "navigation",
54597 "aria-label": (0, import_i18n219.__)("Document changes"),
54598 children: isMounted && diffBlocks.map(({ clientId, status }) => /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(
54599 DiffMarkerButton,
54600 {
54601 clientId,
54602 status,
54603 subscribe
54604 },
54605 clientId
54606 ))
54607 },
54608 "diff-markers"
54609 )
54610 ];
54611 }
54612
54613 // packages/editor/build-module/components/post-revisions-preview/revisions-canvas.mjs
54614 var import_jsx_runtime340 = __toESM(require_jsx_runtime(), 1);
54615 var { usePrivateStyleOverride } = unlock(import_block_editor82.privateApis);
54616 var REVISION_REMOVED_FILTER_SVG = `
54617<svg
54618 xmlns="http://www.w3.org/2000/svg"
54619 viewBox="0 0 0 0"
54620 width="0"
54621 height="0"
54622 focusable="false"
54623 role="none"
54624 aria-hidden="true"
54625 style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
54626>
54627 <defs>
54628 <filter id="revision-removed-filter" x="0" y="0" width="100%" height="100%">
54629 <!-- Desaturate and add red tint -->
54630 <feColorMatrix type="matrix"
54631 values="0.5 0.3 0.2 0 0.15
54632 0.2 0.2 0.1 0 0
54633 0.2 0.2 0.1 0 0
54634 0 0 0 0.8 0"/>
54635 </filter>
54636 </defs>
54637</svg>
54638`;
54639 var REVISION_DIFF_STYLES = `
54640 .is-revision-added {
54641 box-shadow: inset 0 0 0 9999px color-mix(in srgb, currentColor 5%, #00a32a 15%), 0 0 0 4px color-mix(in srgb, currentColor 5%, #00a32a 15%);
54642 outline: 3px solid #00a32a;
54643 outline-offset: 2px;
54644 }
54645 .is-revision-removed,
54646 .revision-diff-removed {
54647 text-decoration: line-through;
54648 filter: url(#revision-removed-filter);
54649 }
54650 .is-revision-removed {
54651 outline: 3px dashed #d63638;
54652 outline-offset: 2px;
54653 }
54654 .is-revision-modified {
54655 outline: 3px dotted #9a7000 !important;
54656 outline-offset: 2px;
54657 }
54658 .revision-diff-added {
54659 background-color: color-mix(in srgb, currentColor 5%, #00a32a 15%);
54660 text-decoration: none;
54661 }
54662 .revision-diff-format-added {
54663 text-decoration: underline wavy color-mix(in srgb, currentColor 30%, #00a32a 70%);
54664 text-decoration-thickness: 2px;
54665 }
54666 .revision-diff-format-removed {
54667 text-decoration: underline wavy color-mix(in srgb, currentColor 20%, #d63638 80%);
54668 text-decoration-thickness: 2px;
54669 }
54670 .revision-diff-format-changed {
54671 text-decoration: underline wavy color-mix(in srgb, currentColor 30%, #dba617 70%);
54672 text-decoration-thickness: 2px;
54673 }
54674`;
54675 function withRevisionDiffClasses(BlockListBlock) {
54676 return (props) => {
54677 const { block, className } = props;
54678 const diffStatus = block?.__revisionDiffStatus?.status;
54679 const enhancedClassName = clsx_default(className, {
54680 "is-revision-added": diffStatus === "added",
54681 "is-revision-removed": diffStatus === "removed",
54682 "is-revision-modified": diffStatus === "modified"
54683 });
54684 return /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(BlockListBlock, { ...props, className: enhancedClassName });
54685 };
54686 }
54687 var FILTER_NAME = "editor/revisions-canvas/withRevisionDiffClasses";
54688 (0, import_hooks57.addFilter)("editor.BlockListBlock", FILTER_NAME, withRevisionDiffClasses);
54689 function DiffStyleOverrides({ showDiff }) {
54690 usePrivateStyleOverride({
54691 css: showDiff ? REVISION_DIFF_STYLES : ""
54692 });
54693 usePrivateStyleOverride({
54694 assets: showDiff ? REVISION_REMOVED_FILTER_SVG : "",
54695 __unstableType: "svgs"
54696 });
54697 return null;
54698 }
54699 function CanvasContent({ showDiff }) {
54700 const [contentRef, diffMarkers] = useDiffMarkers();
54701 return /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)(import_jsx_runtime340.Fragment, { children: [
54702 /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(visual_editor_default, { contentRef }),
54703 showDiff && diffMarkers
54704 ] });
54705 }
54706 function RevisionsCanvas() {
54707 (0, import_element170.useEffect)(() => {
54708 registerDiffFormatTypes();
54709 return () => {
54710 unregisterDiffFormatTypes();
54711 };
54712 }, []);
54713 const { revision, showDiff } = (0, import_data205.useSelect)((select6) => {
54714 const { getCurrentRevision: getCurrentRevision2, isShowingRevisionDiff: isShowingRevisionDiff2 } = unlock(
54715 select6(store)
54716 );
54717 return {
54718 revision: getCurrentRevision2(),
54719 showDiff: isShowingRevisionDiff2()
54720 };
54721 }, []);
54722 return revision ? /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)(import_jsx_runtime340.Fragment, { children: [
54723 /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(DiffStyleOverrides, { showDiff }),
54724 /* @__PURE__ */ (0, import_jsx_runtime340.jsx)("div", { className: "editor-revisions-canvas__content", children: /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(CanvasContent, { showDiff }) })
54725 ] }) : /* @__PURE__ */ (0, import_jsx_runtime340.jsx)("div", { className: "editor-revisions-canvas__loading", children: /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(import_components196.Spinner, {}) });
54726 }
54727
54728 // packages/editor/build-module/components/collaborators-presence/use-collaborator-notifications.mjs
54729 var import_data206 = __toESM(require_data(), 1);
54730 var import_element171 = __toESM(require_element(), 1);
54731 var import_i18n220 = __toESM(require_i18n(), 1);
54732 var import_notices28 = __toESM(require_notices(), 1);
54733 var import_core_data118 = __toESM(require_core_data(), 1);
54734 var import_preferences23 = __toESM(require_preferences(), 1);
54735 var { useOnCollaboratorJoin, useOnCollaboratorLeave, useOnPostSave } = unlock(import_core_data118.privateApis);
54736 var NOTIFICATION_TYPE = {
54737 COLLAB_POST_UPDATED: "collab-post-updated",
54738 COLLAB_USER_ENTERED: "collab-user-entered",
54739 COLLAB_USER_EXITED: "collab-user-exited"
54740 };
54741 var PUBLISHED_STATUSES = ["publish", "private", "future"];
54742 function getPostUpdatedMessage(name2, status, isFirstPublish) {
54743 if (isFirstPublish) {
54744 return (0, import_i18n220.sprintf)((0, import_i18n220.__)("Post published by %s."), name2);
54745 }
54746 if (PUBLISHED_STATUSES.includes(status)) {
54747 return (0, import_i18n220.sprintf)((0, import_i18n220.__)("Post updated by %s."), name2);
54748 }
54749 return (0, import_i18n220.sprintf)((0, import_i18n220.__)("Draft saved by %s."), name2);
54750 }
54751 function useCollaboratorNotifications(postId2, postType2) {
54752 const { postStatus, isCollaborationEnabled, showNotifications } = (0, import_data206.useSelect)(
54753 (select6) => {
54754 const {
54755 getCurrentPostAttribute: getCurrentPostAttribute2,
54756 isCollaborationEnabledForCurrentPost: isCollaborationEnabledForCurrentPost2
54757 } = unlock(select6(store));
54758 return {
54759 postStatus: getCurrentPostAttribute2("status"),
54760 isCollaborationEnabled: isCollaborationEnabledForCurrentPost2(),
54761 showNotifications: select6(import_preferences23.store).get(
54762 "core",
54763 "showCollaborationNotifications"
54764 ) ?? true
54765 };
54766 },
54767 []
54768 );
54769 const { createNotice } = (0, import_data206.useDispatch)(import_notices28.store);
54770 const shouldSubscribe = isCollaborationEnabled && showNotifications;
54771 const effectivePostId = shouldSubscribe ? postId2 : null;
54772 const effectivePostType = shouldSubscribe ? postType2 : null;
54773 useOnCollaboratorJoin(
54774 effectivePostId,
54775 effectivePostType,
54776 (0, import_element171.useCallback)(
54777 (collaborator, me) => {
54778 if (me && collaborator.collaboratorInfo.enteredAt < me.collaboratorInfo.enteredAt) {
54779 return;
54780 }
54781 void createNotice(
54782 "info",
54783 (0, import_i18n220.sprintf)(
54784 /* translators: %s: collaborator display name */
54785 (0, import_i18n220.__)("%s has joined the post."),
54786 collaborator.collaboratorInfo.name
54787 ),
54788 {
54789 id: `${NOTIFICATION_TYPE.COLLAB_USER_ENTERED}-${collaborator.collaboratorInfo.id}`,
54790 type: "snackbar",
54791 isDismissible: false
54792 }
54793 );
54794 },
54795 [createNotice]
54796 )
54797 );
54798 useOnCollaboratorLeave(
54799 effectivePostId,
54800 effectivePostType,
54801 (0, import_element171.useCallback)(
54802 (collaborator) => {
54803 void createNotice(
54804 "info",
54805 (0, import_i18n220.sprintf)(
54806 /* translators: %s: collaborator display name */
54807 (0, import_i18n220.__)("%s has left the post."),
54808 collaborator.collaboratorInfo.name
54809 ),
54810 {
54811 id: `${NOTIFICATION_TYPE.COLLAB_USER_EXITED}-${collaborator.collaboratorInfo.id}`,
54812 type: "snackbar",
54813 isDismissible: false
54814 }
54815 );
54816 },
54817 [createNotice]
54818 )
54819 );
54820 useOnPostSave(
54821 effectivePostId,
54822 effectivePostType,
54823 (0, import_element171.useCallback)(
54824 (saveEvent, saver, prevEvent) => {
54825 if (!postStatus) {
54826 return;
54827 }
54828 const effectiveStatus = saveEvent.postStatus ?? postStatus ?? "draft";
54829 const prevStatus = prevEvent?.postStatus ?? postStatus;
54830 const isFirstPublish = !(prevStatus && PUBLISHED_STATUSES.includes(prevStatus)) && PUBLISHED_STATUSES.includes(effectiveStatus);
54831 const message2 = getPostUpdatedMessage(
54832 saver.collaboratorInfo.name,
54833 effectiveStatus,
54834 isFirstPublish
54835 );
54836 void createNotice("info", message2, {
54837 id: `${NOTIFICATION_TYPE.COLLAB_POST_UPDATED}-${saver.collaboratorInfo.id}`,
54838 type: "snackbar",
54839 isDismissible: false
54840 });
54841 },
54842 [createNotice, postStatus]
54843 )
54844 );
54845 }
54846
54847 // packages/editor/build-module/components/save-publish-panels/index.mjs
54848 var import_data207 = __toESM(require_data(), 1);
54849 var import_components197 = __toESM(require_components(), 1);
54850 var import_i18n221 = __toESM(require_i18n(), 1);
54851 var import_element172 = __toESM(require_element(), 1);
54852 var import_jsx_runtime341 = __toESM(require_jsx_runtime(), 1);
54853 var { Fill: Fill11, Slot: Slot13 } = (0, import_components197.createSlotFill)("ActionsPanel");
54854 function SavePublishPanels({
54855 setEntitiesSavedStatesCallback,
54856 closeEntitiesSavedStates,
54857 isEntitiesSavedStatesOpen,
54858 forceIsDirtyPublishPanel
54859 }) {
54860 const { closePublishSidebar: closePublishSidebar2, togglePublishSidebar: togglePublishSidebar2 } = (0, import_data207.useDispatch)(store);
54861 const {
54862 publishSidebarOpened,
54863 isPublishable,
54864 isDirty,
54865 hasOtherEntitiesChanges
54866 } = (0, import_data207.useSelect)((select6) => {
54867 const {
54868 isPublishSidebarOpened: isPublishSidebarOpened2,
54869 isEditedPostPublishable: isEditedPostPublishable2,
54870 isCurrentPostPublished: isCurrentPostPublished2,
54871 isEditedPostDirty: isEditedPostDirty2,
54872 hasNonPostEntityChanges: hasNonPostEntityChanges2
54873 } = select6(store);
54874 const _hasOtherEntitiesChanges = hasNonPostEntityChanges2();
54875 return {
54876 publishSidebarOpened: isPublishSidebarOpened2(),
54877 isPublishable: !isCurrentPostPublished2() && isEditedPostPublishable2(),
54878 isDirty: _hasOtherEntitiesChanges || isEditedPostDirty2(),
54879 hasOtherEntitiesChanges: _hasOtherEntitiesChanges
54880 };
54881 }, []);
54882 const openEntitiesSavedStates = (0, import_element172.useCallback)(
54883 () => setEntitiesSavedStatesCallback(true),
54884 []
54885 );
54886 let unmountableContent;
54887 if (publishSidebarOpened) {
54888 unmountableContent = /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
54889 post_publish_panel_default,
54890 {
54891 onClose: closePublishSidebar2,
54892 forceIsDirty: forceIsDirtyPublishPanel,
54893 PrePublishExtension: plugin_pre_publish_panel_default.Slot,
54894 PostPublishExtension: plugin_post_publish_panel_default.Slot
54895 }
54896 );
54897 } else if (isPublishable && !hasOtherEntitiesChanges) {
54898 unmountableContent = /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("div", { className: "editor-layout__toggle-publish-panel", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
54899 import_components197.Button,
54900 {
54901 __next40pxDefaultSize: true,
54902 variant: "secondary",
54903 onClick: togglePublishSidebar2,
54904 "aria-expanded": false,
54905 children: (0, import_i18n221.__)("Open publish panel")
54906 }
54907 ) });
54908 } else {
54909 unmountableContent = /* @__PURE__ */ (0, import_jsx_runtime341.jsx)("div", { className: "editor-layout__toggle-entities-saved-states-panel", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
54910 import_components197.Button,
54911 {
54912 __next40pxDefaultSize: true,
54913 variant: "secondary",
54914 onClick: openEntitiesSavedStates,
54915 "aria-expanded": false,
54916 "aria-haspopup": "dialog",
54917 disabled: !isDirty,
54918 accessibleWhenDisabled: true,
54919 children: (0, import_i18n221.__)("Open save panel")
54920 }
54921 ) });
54922 }
54923 return /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(import_jsx_runtime341.Fragment, { children: [
54924 isEntitiesSavedStatesOpen && /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(
54925 EntitiesSavedStates,
54926 {
54927 close: closeEntitiesSavedStates,
54928 renderDialog: true
54929 }
54930 ),
54931 /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Slot13, { bubblesVirtually: true }),
54932 !isEntitiesSavedStatesOpen && unmountableContent
54933 ] });
54934 }
54935
54936 // packages/editor/build-module/components/text-editor/index.mjs
54937 var import_components198 = __toESM(require_components(), 1);
54938 var import_data208 = __toESM(require_data(), 1);
54939 var import_i18n222 = __toESM(require_i18n(), 1);
54940 var import_keyboard_shortcuts9 = __toESM(require_keyboard_shortcuts(), 1);
54941 var import_element173 = __toESM(require_element(), 1);
54942 var import_jsx_runtime342 = __toESM(require_jsx_runtime(), 1);
54943 function TextEditor({ autoFocus = false }) {
54944 const { switchEditorMode: switchEditorMode2 } = (0, import_data208.useDispatch)(store);
54945 const { shortcut, isRichEditingEnabled } = (0, import_data208.useSelect)((select6) => {
54946 const { getEditorSettings: getEditorSettings2 } = select6(store);
54947 const { getShortcutRepresentation } = select6(import_keyboard_shortcuts9.store);
54948 return {
54949 shortcut: getShortcutRepresentation("core/editor/toggle-mode"),
54950 isRichEditingEnabled: getEditorSettings2().richEditingEnabled
54951 };
54952 }, []);
54953 const titleRef = (0, import_element173.useRef)();
54954 (0, import_element173.useEffect)(() => {
54955 if (autoFocus) {
54956 return;
54957 }
54958 titleRef?.current?.focus();
54959 }, [autoFocus]);
54960 return /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)("div", { className: "editor-text-editor", children: [
54961 isRichEditingEnabled && /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)("div", { className: "editor-text-editor__toolbar", children: [
54962 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)("h2", { children: (0, import_i18n222.__)("Editing code") }),
54963 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
54964 import_components198.Button,
54965 {
54966 __next40pxDefaultSize: true,
54967 variant: "tertiary",
54968 onClick: () => switchEditorMode2("visual"),
54969 shortcut,
54970 children: (0, import_i18n222.__)("Exit code editor")
54971 }
54972 )
54973 ] }),
54974 /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)("div", { className: "editor-text-editor__body", children: [
54975 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(post_title_raw_default, { ref: titleRef }),
54976 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(PostTextEditor, {})
54977 ] })
54978 ] });
54979 }
54980
54981 // packages/media-editor/build-module/components/media-editor-provider/index.mjs
54982 var import_element174 = __toESM(require_element(), 1);
54983 var import_jsx_runtime343 = __toESM(require_jsx_runtime(), 1);
54984 var MediaEditorContext = (0, import_element174.createContext)(
54985 void 0
54986 );
54987 function MediaEditorProvider({
54988 value,
54989 onChange,
54990 settings = {},
54991 children
54992 }) {
54993 const contextValue = {
54994 media: value,
54995 onChange,
54996 fields: settings.fields || []
54997 };
54998 return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(MediaEditorContext.Provider, { value: contextValue, children });
54999 }
55000 function useMediaEditorContext() {
55001 const context = (0, import_element174.useContext)(MediaEditorContext);
55002 if (!context) {
55003 throw new Error(
55004 "useMediaEditorContext must be used within MediaEditorProvider"
55005 );
55006 }
55007 return context;
55008 }
55009
55010 // packages/media-editor/build-module/components/media-preview/index.mjs
55011 var import_components199 = __toESM(require_components(), 1);
55012 var import_element175 = __toESM(require_element(), 1);
55013 var import_i18n223 = __toESM(require_i18n(), 1);
55014
55015 // packages/media-editor/build-module/utils/get-media-type.mjs
55016 function getMediaTypeFromMimeType(mimeType) {
55017 if (!mimeType) {
55018 return { type: "application" };
55019 }
55020 if (mimeType.startsWith("image/")) {
55021 return { type: "image" };
55022 }
55023 if (mimeType.startsWith("video/")) {
55024 return { type: "video" };
55025 }
55026 if (mimeType.startsWith("audio/")) {
55027 return { type: "audio" };
55028 }
55029 return { type: "application" };
55030 }
55031
55032 // packages/media-editor/build-module/components/media-preview/index.mjs
55033 var import_jsx_runtime344 = __toESM(require_jsx_runtime(), 1);
55034 function MediaPreviewContent({
55035 mediaType,
55036 mediaUrl,
55037 altText,
55038 displayTitle,
55039 mimeType,
55040 onLoad,
55041 onError,
55042 loadingState
55043 }) {
55044 switch (mediaType.type) {
55045 case "image":
55046 return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
55047 "img",
55048 {
55049 className: loadingState === "loaded" ? "loaded" : "",
55050 src: mediaUrl,
55051 alt: altText || "",
55052 onLoad,
55053 onError
55054 }
55055 );
55056 case "video":
55057 return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("video", { src: mediaUrl, controls: true, onError, children: displayTitle });
55058 case "audio":
55059 return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("audio", { src: mediaUrl, controls: true, onError, children: displayTitle });
55060 default:
55061 return /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)("div", { className: "media-editor-preview__file-info", children: [
55062 /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("p", { className: "media-editor-preview__file-name", children: displayTitle }),
55063 /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("p", { className: "media-editor-preview__mime-type", children: mimeType }),
55064 /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
55065 "a",
55066 {
55067 href: mediaUrl,
55068 target: "_blank",
55069 rel: "noopener noreferrer",
55070 className: "media-editor-preview__download-link",
55071 children: (0, import_i18n223.__)("View file")
55072 }
55073 )
55074 ] });
55075 }
55076 }
55077 function MediaPreview2(props) {
55078 const [loadingState, setLoadingState] = (0, import_element175.useState)("loading");
55079 const { media } = useMediaEditorContext();
55080 const {
55081 source_url: mediaUrl,
55082 mime_type: mimeType,
55083 alt_text: altText,
55084 title
55085 } = media || {};
55086 const mediaType = getMediaTypeFromMimeType(mimeType);
55087 if (!mediaUrl) {
55088 return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("div", { className: "media-editor-preview media-editor-preview--empty", children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("p", { children: (0, import_i18n223.__)("No media file available.") }) });
55089 }
55090 if (loadingState === "error") {
55091 return /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)("div", { className: "media-editor-preview media-editor-preview--error", children: [
55092 /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("p", { children: (0, import_i18n223.__)("Failed to load media file.") }),
55093 /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("p", { className: "media-editor-preview__url", children: mediaUrl })
55094 ] });
55095 }
55096 const displayTitle = typeof title === "string" ? title : title?.rendered || title?.raw;
55097 return /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(
55098 "div",
55099 {
55100 ...props,
55101 className: `media-editor-preview media-editor-preview--${mediaType.type}`,
55102 children: [
55103 mediaType.type === "image" && loadingState === "loading" && /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("div", { className: "media-editor-preview__spinner", children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(import_components199.Spinner, {}) }),
55104 /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
55105 MediaPreviewContent,
55106 {
55107 mediaType,
55108 mediaUrl,
55109 altText,
55110 displayTitle,
55111 mimeType,
55112 onLoad: () => setLoadingState("loaded"),
55113 onError: () => setLoadingState("error"),
55114 loadingState
55115 }
55116 )
55117 ]
55118 }
55119 );
55120 }
55121
55122 // packages/dataviews/build-module/constants.mjs
55123 var import_i18n224 = __toESM(require_i18n(), 1);
55124 var OPERATOR_IS_ANY2 = "isAny";
55125 var OPERATOR_IS_NONE = "isNone";
55126 var OPERATOR_IS_ALL = "isAll";
55127 var OPERATOR_IS_NOT_ALL = "isNotAll";
55128 var OPERATOR_BETWEEN = "between";
55129 var OPERATOR_IN_THE_PAST = "inThePast";
55130 var OPERATOR_OVER = "over";
55131 var OPERATOR_IS = "is";
55132 var OPERATOR_IS_NOT = "isNot";
55133 var OPERATOR_LESS_THAN = "lessThan";
55134 var OPERATOR_GREATER_THAN = "greaterThan";
55135 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
55136 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
55137 var OPERATOR_BEFORE = "before";
55138 var OPERATOR_AFTER = "after";
55139 var OPERATOR_BEFORE_INC = "beforeInc";
55140 var OPERATOR_AFTER_INC = "afterInc";
55141 var OPERATOR_CONTAINS = "contains";
55142 var OPERATOR_NOT_CONTAINS = "notContains";
55143 var OPERATOR_STARTS_WITH = "startsWith";
55144 var OPERATOR_ON = "on";
55145 var OPERATOR_NOT_ON = "notOn";
55146 var sortLabels = {
55147 asc: (0, import_i18n224.__)("Sort ascending"),
55148 desc: (0, import_i18n224.__)("Sort descending")
55149 };
55150
55151 // packages/dataviews/build-module/lock-unlock.mjs
55152 var import_private_apis4 = __toESM(require_private_apis(), 1);
55153 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
55154 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
55155 "@wordpress/dataviews"
55156 );
55157
55158 // packages/dataviews/build-module/hooks/use-elements.mjs
55159 var import_element176 = __toESM(require_element(), 1);
55160 var EMPTY_ARRAY9 = [];
55161 function useElements({
55162 elements: elements2,
55163 getElements
55164 }) {
55165 const staticElements = Array.isArray(elements2) && elements2.length > 0 ? elements2 : EMPTY_ARRAY9;
55166 const [records, setRecords] = (0, import_element176.useState)(staticElements);
55167 const [isLoading, setIsLoading] = (0, import_element176.useState)(false);
55168 (0, import_element176.useEffect)(() => {
55169 if (!getElements) {
55170 setRecords(staticElements);
55171 return;
55172 }
55173 let cancelled = false;
55174 setIsLoading(true);
55175 getElements().then((fetchedElements) => {
55176 if (!cancelled) {
55177 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
55178 setRecords(dynamicElements);
55179 }
55180 }).catch(() => {
55181 if (!cancelled) {
55182 setRecords(staticElements);
55183 }
55184 }).finally(() => {
55185 if (!cancelled) {
55186 setIsLoading(false);
55187 }
55188 });
55189 return () => {
55190 cancelled = true;
55191 };
55192 }, [getElements, staticElements]);
55193 return {
55194 elements: records,
55195 isLoading
55196 };
55197 }
55198
55199 // packages/dataviews/node_modules/date-fns/constants.js
55200 var daysInYear2 = 365.2425;
55201 var maxTime2 = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
55202 var minTime2 = -maxTime2;
55203 var millisecondsInWeek = 6048e5;
55204 var millisecondsInDay = 864e5;
55205 var secondsInHour2 = 3600;
55206 var secondsInDay2 = secondsInHour2 * 24;
55207 var secondsInWeek2 = secondsInDay2 * 7;
55208 var secondsInYear2 = secondsInDay2 * daysInYear2;
55209 var secondsInMonth2 = secondsInYear2 / 12;
55210 var secondsInQuarter2 = secondsInMonth2 * 3;
55211 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
55212
55213 // packages/dataviews/node_modules/date-fns/constructFrom.js
55214 function constructFrom(date, value) {
55215 if (typeof date === "function") return date(value);
55216 if (date && typeof date === "object" && constructFromSymbol in date)
55217 return date[constructFromSymbol](value);
55218 if (date instanceof Date) return new date.constructor(value);
55219 return new Date(value);
55220 }
55221
55222 // packages/dataviews/node_modules/date-fns/toDate.js
55223 function toDate2(argument, context) {
55224 return constructFrom(context || argument, argument);
55225 }
55226
55227 // packages/dataviews/node_modules/date-fns/addDays.js
55228 function addDays(date, amount, options) {
55229 const _date = toDate2(date, options?.in);
55230 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
55231 if (!amount) return _date;
55232 _date.setDate(_date.getDate() + amount);
55233 return _date;
55234 }
55235
55236 // packages/dataviews/node_modules/date-fns/addMonths.js
55237 function addMonths(date, amount, options) {
55238 const _date = toDate2(date, options?.in);
55239 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
55240 if (!amount) {
55241 return _date;
55242 }
55243 const dayOfMonth = _date.getDate();
55244 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
55245 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
55246 const daysInMonth = endOfDesiredMonth.getDate();
55247 if (dayOfMonth >= daysInMonth) {
55248 return endOfDesiredMonth;
55249 } else {
55250 _date.setFullYear(
55251 endOfDesiredMonth.getFullYear(),
55252 endOfDesiredMonth.getMonth(),
55253 dayOfMonth
55254 );
55255 return _date;
55256 }
55257 }
55258
55259 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
55260 var defaultOptions = {};
55261 function getDefaultOptions() {
55262 return defaultOptions;
55263 }
55264
55265 // packages/dataviews/node_modules/date-fns/startOfWeek.js
55266 function startOfWeek(date, options) {
55267 const defaultOptions2 = getDefaultOptions();
55268 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
55269 const _date = toDate2(date, options?.in);
55270 const day = _date.getDay();
55271 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
55272 _date.setDate(_date.getDate() - diff);
55273 _date.setHours(0, 0, 0, 0);
55274 return _date;
55275 }
55276
55277 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
55278 function startOfISOWeek(date, options) {
55279 return startOfWeek(date, { ...options, weekStartsOn: 1 });
55280 }
55281
55282 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
55283 function getISOWeekYear(date, options) {
55284 const _date = toDate2(date, options?.in);
55285 const year = _date.getFullYear();
55286 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
55287 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
55288 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
55289 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
55290 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
55291 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
55292 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
55293 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
55294 if (_date.getTime() >= startOfNextYear.getTime()) {
55295 return year + 1;
55296 } else if (_date.getTime() >= startOfThisYear.getTime()) {
55297 return year;
55298 } else {
55299 return year - 1;
55300 }
55301 }
55302
55303 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
55304 function getTimezoneOffsetInMilliseconds(date) {
55305 const _date = toDate2(date);
55306 const utcDate = new Date(
55307 Date.UTC(
55308 _date.getFullYear(),
55309 _date.getMonth(),
55310 _date.getDate(),
55311 _date.getHours(),
55312 _date.getMinutes(),
55313 _date.getSeconds(),
55314 _date.getMilliseconds()
55315 )
55316 );
55317 utcDate.setUTCFullYear(_date.getFullYear());
55318 return +date - +utcDate;
55319 }
55320
55321 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
55322 function normalizeDates(context, ...dates) {
55323 const normalize = constructFrom.bind(
55324 null,
55325 context || dates.find((date) => typeof date === "object")
55326 );
55327 return dates.map(normalize);
55328 }
55329
55330 // packages/dataviews/node_modules/date-fns/startOfDay.js
55331 function startOfDay(date, options) {
55332 const _date = toDate2(date, options?.in);
55333 _date.setHours(0, 0, 0, 0);
55334 return _date;
55335 }
55336
55337 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
55338 function differenceInCalendarDays(laterDate, earlierDate, options) {
55339 const [laterDate_, earlierDate_] = normalizeDates(
55340 options?.in,
55341 laterDate,
55342 earlierDate
55343 );
55344 const laterStartOfDay = startOfDay(laterDate_);
55345 const earlierStartOfDay = startOfDay(earlierDate_);
55346 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
55347 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
55348 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
55349 }
55350
55351 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
55352 function startOfISOWeekYear(date, options) {
55353 const year = getISOWeekYear(date, options);
55354 const fourthOfJanuary = constructFrom(options?.in || date, 0);
55355 fourthOfJanuary.setFullYear(year, 0, 4);
55356 fourthOfJanuary.setHours(0, 0, 0, 0);
55357 return startOfISOWeek(fourthOfJanuary);
55358 }
55359
55360 // packages/dataviews/node_modules/date-fns/addWeeks.js
55361 function addWeeks(date, amount, options) {
55362 return addDays(date, amount * 7, options);
55363 }
55364
55365 // packages/dataviews/node_modules/date-fns/addYears.js
55366 function addYears(date, amount, options) {
55367 return addMonths(date, amount * 12, options);
55368 }
55369
55370 // packages/dataviews/node_modules/date-fns/isDate.js
55371 function isDate(value) {
55372 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
55373 }
55374
55375 // packages/dataviews/node_modules/date-fns/isValid.js
55376 function isValid(date) {
55377 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate2(date)));
55378 }
55379
55380 // packages/dataviews/node_modules/date-fns/startOfMonth.js
55381 function startOfMonth2(date, options) {
55382 const _date = toDate2(date, options?.in);
55383 _date.setDate(1);
55384 _date.setHours(0, 0, 0, 0);
55385 return _date;
55386 }
55387
55388 // packages/dataviews/node_modules/date-fns/startOfYear.js
55389 function startOfYear(date, options) {
55390 const date_ = toDate2(date, options?.in);
55391 date_.setFullYear(date_.getFullYear(), 0, 1);
55392 date_.setHours(0, 0, 0, 0);
55393 return date_;
55394 }
55395
55396 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
55397 var formatDistanceLocale = {
55398 lessThanXSeconds: {
55399 one: "less than a second",
55400 other: "less than {{count}} seconds"
55401 },
55402 xSeconds: {
55403 one: "1 second",
55404 other: "{{count}} seconds"
55405 },
55406 halfAMinute: "half a minute",
55407 lessThanXMinutes: {
55408 one: "less than a minute",
55409 other: "less than {{count}} minutes"
55410 },
55411 xMinutes: {
55412 one: "1 minute",
55413 other: "{{count}} minutes"
55414 },
55415 aboutXHours: {
55416 one: "about 1 hour",
55417 other: "about {{count}} hours"
55418 },
55419 xHours: {
55420 one: "1 hour",
55421 other: "{{count}} hours"
55422 },
55423 xDays: {
55424 one: "1 day",
55425 other: "{{count}} days"
55426 },
55427 aboutXWeeks: {
55428 one: "about 1 week",
55429 other: "about {{count}} weeks"
55430 },
55431 xWeeks: {
55432 one: "1 week",
55433 other: "{{count}} weeks"
55434 },
55435 aboutXMonths: {
55436 one: "about 1 month",
55437 other: "about {{count}} months"
55438 },
55439 xMonths: {
55440 one: "1 month",
55441 other: "{{count}} months"
55442 },
55443 aboutXYears: {
55444 one: "about 1 year",
55445 other: "about {{count}} years"
55446 },
55447 xYears: {
55448 one: "1 year",
55449 other: "{{count}} years"
55450 },
55451 overXYears: {
55452 one: "over 1 year",
55453 other: "over {{count}} years"
55454 },
55455 almostXYears: {
55456 one: "almost 1 year",
55457 other: "almost {{count}} years"
55458 }
55459 };
55460 var formatDistance = (token, count, options) => {
55461 let result;
55462 const tokenValue = formatDistanceLocale[token];
55463 if (typeof tokenValue === "string") {
55464 result = tokenValue;
55465 } else if (count === 1) {
55466 result = tokenValue.one;
55467 } else {
55468 result = tokenValue.other.replace("{{count}}", count.toString());
55469 }
55470 if (options?.addSuffix) {
55471 if (options.comparison && options.comparison > 0) {
55472 return "in " + result;
55473 } else {
55474 return result + " ago";
55475 }
55476 }
55477 return result;
55478 };
55479
55480 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
55481 function buildFormatLongFn(args) {
55482 return (options = {}) => {
55483 const width = options.width ? String(options.width) : args.defaultWidth;
55484 const format6 = args.formats[width] || args.formats[args.defaultWidth];
55485 return format6;
55486 };
55487 }
55488
55489 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
55490 var dateFormats = {
55491 full: "EEEE, MMMM do, y",
55492 long: "MMMM do, y",
55493 medium: "MMM d, y",
55494 short: "MM/dd/yyyy"
55495 };
55496 var timeFormats = {
55497 full: "h:mm:ss a zzzz",
55498 long: "h:mm:ss a z",
55499 medium: "h:mm:ss a",
55500 short: "h:mm a"
55501 };
55502 var dateTimeFormats = {
55503 full: "{{date}} 'at' {{time}}",
55504 long: "{{date}} 'at' {{time}}",
55505 medium: "{{date}}, {{time}}",
55506 short: "{{date}}, {{time}}"
55507 };
55508 var formatLong = {
55509 date: buildFormatLongFn({
55510 formats: dateFormats,
55511 defaultWidth: "full"
55512 }),
55513 time: buildFormatLongFn({
55514 formats: timeFormats,
55515 defaultWidth: "full"
55516 }),
55517 dateTime: buildFormatLongFn({
55518 formats: dateTimeFormats,
55519 defaultWidth: "full"
55520 })
55521 };
55522
55523 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
55524 var formatRelativeLocale = {
55525 lastWeek: "'last' eeee 'at' p",
55526 yesterday: "'yesterday at' p",
55527 today: "'today at' p",
55528 tomorrow: "'tomorrow at' p",
55529 nextWeek: "eeee 'at' p",
55530 other: "P"
55531 };
55532 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
55533
55534 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
55535 function buildLocalizeFn(args) {
55536 return (value, options) => {
55537 const context = options?.context ? String(options.context) : "standalone";
55538 let valuesArray;
55539 if (context === "formatting" && args.formattingValues) {
55540 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
55541 const width = options?.width ? String(options.width) : defaultWidth;
55542 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
55543 } else {
55544 const defaultWidth = args.defaultWidth;
55545 const width = options?.width ? String(options.width) : args.defaultWidth;
55546 valuesArray = args.values[width] || args.values[defaultWidth];
55547 }
55548 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
55549 return valuesArray[index2];
55550 };
55551 }
55552
55553 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
55554 var eraValues = {
55555 narrow: ["B", "A"],
55556 abbreviated: ["BC", "AD"],
55557 wide: ["Before Christ", "Anno Domini"]
55558 };
55559 var quarterValues = {
55560 narrow: ["1", "2", "3", "4"],
55561 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
55562 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
55563 };
55564 var monthValues = {
55565 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
55566 abbreviated: [
55567 "Jan",
55568 "Feb",
55569 "Mar",
55570 "Apr",
55571 "May",
55572 "Jun",
55573 "Jul",
55574 "Aug",
55575 "Sep",
55576 "Oct",
55577 "Nov",
55578 "Dec"
55579 ],
55580 wide: [
55581 "January",
55582 "February",
55583 "March",
55584 "April",
55585 "May",
55586 "June",
55587 "July",
55588 "August",
55589 "September",
55590 "October",
55591 "November",
55592 "December"
55593 ]
55594 };
55595 var dayValues = {
55596 narrow: ["S", "M", "T", "W", "T", "F", "S"],
55597 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
55598 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
55599 wide: [
55600 "Sunday",
55601 "Monday",
55602 "Tuesday",
55603 "Wednesday",
55604 "Thursday",
55605 "Friday",
55606 "Saturday"
55607 ]
55608 };
55609 var dayPeriodValues = {
55610 narrow: {
55611 am: "a",
55612 pm: "p",
55613 midnight: "mi",
55614 noon: "n",
55615 morning: "morning",
55616 afternoon: "afternoon",
55617 evening: "evening",
55618 night: "night"
55619 },
55620 abbreviated: {
55621 am: "AM",
55622 pm: "PM",
55623 midnight: "midnight",
55624 noon: "noon",
55625 morning: "morning",
55626 afternoon: "afternoon",
55627 evening: "evening",
55628 night: "night"
55629 },
55630 wide: {
55631 am: "a.m.",
55632 pm: "p.m.",
55633 midnight: "midnight",
55634 noon: "noon",
55635 morning: "morning",
55636 afternoon: "afternoon",
55637 evening: "evening",
55638 night: "night"
55639 }
55640 };
55641 var formattingDayPeriodValues = {
55642 narrow: {
55643 am: "a",
55644 pm: "p",
55645 midnight: "mi",
55646 noon: "n",
55647 morning: "in the morning",
55648 afternoon: "in the afternoon",
55649 evening: "in the evening",
55650 night: "at night"
55651 },
55652 abbreviated: {
55653 am: "AM",
55654 pm: "PM",
55655 midnight: "midnight",
55656 noon: "noon",
55657 morning: "in the morning",
55658 afternoon: "in the afternoon",
55659 evening: "in the evening",
55660 night: "at night"
55661 },
55662 wide: {
55663 am: "a.m.",
55664 pm: "p.m.",
55665 midnight: "midnight",
55666 noon: "noon",
55667 morning: "in the morning",
55668 afternoon: "in the afternoon",
55669 evening: "in the evening",
55670 night: "at night"
55671 }
55672 };
55673 var ordinalNumber = (dirtyNumber, _options) => {
55674 const number = Number(dirtyNumber);
55675 const rem100 = number % 100;
55676 if (rem100 > 20 || rem100 < 10) {
55677 switch (rem100 % 10) {
55678 case 1:
55679 return number + "st";
55680 case 2:
55681 return number + "nd";
55682 case 3:
55683 return number + "rd";
55684 }
55685 }
55686 return number + "th";
55687 };
55688 var localize = {
55689 ordinalNumber,
55690 era: buildLocalizeFn({
55691 values: eraValues,
55692 defaultWidth: "wide"
55693 }),
55694 quarter: buildLocalizeFn({
55695 values: quarterValues,
55696 defaultWidth: "wide",
55697 argumentCallback: (quarter) => quarter - 1
55698 }),
55699 month: buildLocalizeFn({
55700 values: monthValues,
55701 defaultWidth: "wide"
55702 }),
55703 day: buildLocalizeFn({
55704 values: dayValues,
55705 defaultWidth: "wide"
55706 }),
55707 dayPeriod: buildLocalizeFn({
55708 values: dayPeriodValues,
55709 defaultWidth: "wide",
55710 formattingValues: formattingDayPeriodValues,
55711 defaultFormattingWidth: "wide"
55712 })
55713 };
55714
55715 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
55716 function buildMatchFn(args) {
55717 return (string, options = {}) => {
55718 const width = options.width;
55719 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
55720 const matchResult = string.match(matchPattern);
55721 if (!matchResult) {
55722 return null;
55723 }
55724 const matchedString = matchResult[0];
55725 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
55726 const key = Array.isArray(parsePatterns) ? findIndex2(parsePatterns, (pattern) => pattern.test(matchedString)) : (
55727 // [TODO] -- I challenge you to fix the type
55728 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
55729 );
55730 let value;
55731 value = args.valueCallback ? args.valueCallback(key) : key;
55732 value = options.valueCallback ? (
55733 // [TODO] -- I challenge you to fix the type
55734 options.valueCallback(value)
55735 ) : value;
55736 const rest = string.slice(matchedString.length);
55737 return { value, rest };
55738 };
55739 }
55740 function findKey(object, predicate) {
55741 for (const key in object) {
55742 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
55743 return key;
55744 }
55745 }
55746 return void 0;
55747 }
55748 function findIndex2(array, predicate) {
55749 for (let key = 0; key < array.length; key++) {
55750 if (predicate(array[key])) {
55751 return key;
55752 }
55753 }
55754 return void 0;
55755 }
55756
55757 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
55758 function buildMatchPatternFn(args) {
55759 return (string, options = {}) => {
55760 const matchResult = string.match(args.matchPattern);
55761 if (!matchResult) return null;
55762 const matchedString = matchResult[0];
55763 const parseResult = string.match(args.parsePattern);
55764 if (!parseResult) return null;
55765 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
55766 value = options.valueCallback ? options.valueCallback(value) : value;
55767 const rest = string.slice(matchedString.length);
55768 return { value, rest };
55769 };
55770 }
55771
55772 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
55773 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
55774 var parseOrdinalNumberPattern = /\d+/i;
55775 var matchEraPatterns = {
55776 narrow: /^(b|a)/i,
55777 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
55778 wide: /^(before christ|before common era|anno domini|common era)/i
55779 };
55780 var parseEraPatterns = {
55781 any: [/^b/i, /^(a|c)/i]
55782 };
55783 var matchQuarterPatterns = {
55784 narrow: /^[1234]/i,
55785 abbreviated: /^q[1234]/i,
55786 wide: /^[1234](th|st|nd|rd)? quarter/i
55787 };
55788 var parseQuarterPatterns = {
55789 any: [/1/i, /2/i, /3/i, /4/i]
55790 };
55791 var matchMonthPatterns = {
55792 narrow: /^[jfmasond]/i,
55793 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
55794 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
55795 };
55796 var parseMonthPatterns = {
55797 narrow: [
55798 /^j/i,
55799 /^f/i,
55800 /^m/i,
55801 /^a/i,
55802 /^m/i,
55803 /^j/i,
55804 /^j/i,
55805 /^a/i,
55806 /^s/i,
55807 /^o/i,
55808 /^n/i,
55809 /^d/i
55810 ],
55811 any: [
55812 /^ja/i,
55813 /^f/i,
55814 /^mar/i,
55815 /^ap/i,
55816 /^may/i,
55817 /^jun/i,
55818 /^jul/i,
55819 /^au/i,
55820 /^s/i,
55821 /^o/i,
55822 /^n/i,
55823 /^d/i
55824 ]
55825 };
55826 var matchDayPatterns = {
55827 narrow: /^[smtwf]/i,
55828 short: /^(su|mo|tu|we|th|fr|sa)/i,
55829 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
55830 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
55831 };
55832 var parseDayPatterns = {
55833 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
55834 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
55835 };
55836 var matchDayPeriodPatterns = {
55837 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
55838 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
55839 };
55840 var parseDayPeriodPatterns = {
55841 any: {
55842 am: /^a/i,
55843 pm: /^p/i,
55844 midnight: /^mi/i,
55845 noon: /^no/i,
55846 morning: /morning/i,
55847 afternoon: /afternoon/i,
55848 evening: /evening/i,
55849 night: /night/i
55850 }
55851 };
55852 var match2 = {
55853 ordinalNumber: buildMatchPatternFn({
55854 matchPattern: matchOrdinalNumberPattern,
55855 parsePattern: parseOrdinalNumberPattern,
55856 valueCallback: (value) => parseInt(value, 10)
55857 }),
55858 era: buildMatchFn({
55859 matchPatterns: matchEraPatterns,
55860 defaultMatchWidth: "wide",
55861 parsePatterns: parseEraPatterns,
55862 defaultParseWidth: "any"
55863 }),
55864 quarter: buildMatchFn({
55865 matchPatterns: matchQuarterPatterns,
55866 defaultMatchWidth: "wide",
55867 parsePatterns: parseQuarterPatterns,
55868 defaultParseWidth: "any",
55869 valueCallback: (index2) => index2 + 1
55870 }),
55871 month: buildMatchFn({
55872 matchPatterns: matchMonthPatterns,
55873 defaultMatchWidth: "wide",
55874 parsePatterns: parseMonthPatterns,
55875 defaultParseWidth: "any"
55876 }),
55877 day: buildMatchFn({
55878 matchPatterns: matchDayPatterns,
55879 defaultMatchWidth: "wide",
55880 parsePatterns: parseDayPatterns,
55881 defaultParseWidth: "any"
55882 }),
55883 dayPeriod: buildMatchFn({
55884 matchPatterns: matchDayPeriodPatterns,
55885 defaultMatchWidth: "any",
55886 parsePatterns: parseDayPeriodPatterns,
55887 defaultParseWidth: "any"
55888 })
55889 };
55890
55891 // packages/dataviews/node_modules/date-fns/locale/en-US.js
55892 var enUS = {
55893 code: "en-US",
55894 formatDistance,
55895 formatLong,
55896 formatRelative,
55897 localize,
55898 match: match2,
55899 options: {
55900 weekStartsOn: 0,
55901 firstWeekContainsDate: 1
55902 }
55903 };
55904
55905 // packages/dataviews/node_modules/date-fns/getDayOfYear.js
55906 function getDayOfYear(date, options) {
55907 const _date = toDate2(date, options?.in);
55908 const diff = differenceInCalendarDays(_date, startOfYear(_date));
55909 const dayOfYear = diff + 1;
55910 return dayOfYear;
55911 }
55912
55913 // packages/dataviews/node_modules/date-fns/getISOWeek.js
55914 function getISOWeek(date, options) {
55915 const _date = toDate2(date, options?.in);
55916 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
55917 return Math.round(diff / millisecondsInWeek) + 1;
55918 }
55919
55920 // packages/dataviews/node_modules/date-fns/getWeekYear.js
55921 function getWeekYear(date, options) {
55922 const _date = toDate2(date, options?.in);
55923 const year = _date.getFullYear();
55924 const defaultOptions2 = getDefaultOptions();
55925 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
55926 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
55927 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
55928 firstWeekOfNextYear.setHours(0, 0, 0, 0);
55929 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
55930 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
55931 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
55932 firstWeekOfThisYear.setHours(0, 0, 0, 0);
55933 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
55934 if (+_date >= +startOfNextYear) {
55935 return year + 1;
55936 } else if (+_date >= +startOfThisYear) {
55937 return year;
55938 } else {
55939 return year - 1;
55940 }
55941 }
55942
55943 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
55944 function startOfWeekYear(date, options) {
55945 const defaultOptions2 = getDefaultOptions();
55946 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
55947 const year = getWeekYear(date, options);
55948 const firstWeek = constructFrom(options?.in || date, 0);
55949 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
55950 firstWeek.setHours(0, 0, 0, 0);
55951 const _date = startOfWeek(firstWeek, options);
55952 return _date;
55953 }
55954
55955 // packages/dataviews/node_modules/date-fns/getWeek.js
55956 function getWeek(date, options) {
55957 const _date = toDate2(date, options?.in);
55958 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
55959 return Math.round(diff / millisecondsInWeek) + 1;
55960 }
55961
55962 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
55963 function addLeadingZeros(number, targetLength) {
55964 const sign = number < 0 ? "-" : "";
55965 const output = Math.abs(number).toString().padStart(targetLength, "0");
55966 return sign + output;
55967 }
55968
55969 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
55970 var lightFormatters = {
55971 // Year
55972 y(date, token) {
55973 const signedYear = date.getFullYear();
55974 const year = signedYear > 0 ? signedYear : 1 - signedYear;
55975 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
55976 },
55977 // Month
55978 M(date, token) {
55979 const month = date.getMonth();
55980 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
55981 },
55982 // Day of the month
55983 d(date, token) {
55984 return addLeadingZeros(date.getDate(), token.length);
55985 },
55986 // AM or PM
55987 a(date, token) {
55988 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
55989 switch (token) {
55990 case "a":
55991 case "aa":
55992 return dayPeriodEnumValue.toUpperCase();
55993 case "aaa":
55994 return dayPeriodEnumValue;
55995 case "aaaaa":
55996 return dayPeriodEnumValue[0];
55997 case "aaaa":
55998 default:
55999 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
56000 }
56001 },
56002 // Hour [1-12]
56003 h(date, token) {
56004 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
56005 },
56006 // Hour [0-23]
56007 H(date, token) {
56008 return addLeadingZeros(date.getHours(), token.length);
56009 },
56010 // Minute
56011 m(date, token) {
56012 return addLeadingZeros(date.getMinutes(), token.length);
56013 },
56014 // Second
56015 s(date, token) {
56016 return addLeadingZeros(date.getSeconds(), token.length);
56017 },
56018 // Fraction of second
56019 S(date, token) {
56020 const numberOfDigits = token.length;
56021 const milliseconds = date.getMilliseconds();
56022 const fractionalSeconds = Math.trunc(
56023 milliseconds * Math.pow(10, numberOfDigits - 3)
56024 );
56025 return addLeadingZeros(fractionalSeconds, token.length);
56026 }
56027 };
56028
56029 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
56030 var dayPeriodEnum = {
56031 am: "am",
56032 pm: "pm",
56033 midnight: "midnight",
56034 noon: "noon",
56035 morning: "morning",
56036 afternoon: "afternoon",
56037 evening: "evening",
56038 night: "night"
56039 };
56040 var formatters = {
56041 // Era
56042 G: function(date, token, localize2) {
56043 const era = date.getFullYear() > 0 ? 1 : 0;
56044 switch (token) {
56045 // AD, BC
56046 case "G":
56047 case "GG":
56048 case "GGG":
56049 return localize2.era(era, { width: "abbreviated" });
56050 // A, B
56051 case "GGGGG":
56052 return localize2.era(era, { width: "narrow" });
56053 // Anno Domini, Before Christ
56054 case "GGGG":
56055 default:
56056 return localize2.era(era, { width: "wide" });
56057 }
56058 },
56059 // Year
56060 y: function(date, token, localize2) {
56061 if (token === "yo") {
56062 const signedYear = date.getFullYear();
56063 const year = signedYear > 0 ? signedYear : 1 - signedYear;
56064 return localize2.ordinalNumber(year, { unit: "year" });
56065 }
56066 return lightFormatters.y(date, token);
56067 },
56068 // Local week-numbering year
56069 Y: function(date, token, localize2, options) {
56070 const signedWeekYear = getWeekYear(date, options);
56071 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
56072 if (token === "YY") {
56073 const twoDigitYear = weekYear % 100;
56074 return addLeadingZeros(twoDigitYear, 2);
56075 }
56076 if (token === "Yo") {
56077 return localize2.ordinalNumber(weekYear, { unit: "year" });
56078 }
56079 return addLeadingZeros(weekYear, token.length);
56080 },
56081 // ISO week-numbering year
56082 R: function(date, token) {
56083 const isoWeekYear = getISOWeekYear(date);
56084 return addLeadingZeros(isoWeekYear, token.length);
56085 },
56086 // Extended year. This is a single number designating the year of this calendar system.
56087 // The main difference between `y` and `u` localizers are B.C. years:
56088 // | Year | `y` | `u` |
56089 // |------|-----|-----|
56090 // | AC 1 | 1 | 1 |
56091 // | BC 1 | 1 | 0 |
56092 // | BC 2 | 2 | -1 |
56093 // Also `yy` always returns the last two digits of a year,
56094 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
56095 u: function(date, token) {
56096 const year = date.getFullYear();
56097 return addLeadingZeros(year, token.length);
56098 },
56099 // Quarter
56100 Q: function(date, token, localize2) {
56101 const quarter = Math.ceil((date.getMonth() + 1) / 3);
56102 switch (token) {
56103 // 1, 2, 3, 4
56104 case "Q":
56105 return String(quarter);
56106 // 01, 02, 03, 04
56107 case "QQ":
56108 return addLeadingZeros(quarter, 2);
56109 // 1st, 2nd, 3rd, 4th
56110 case "Qo":
56111 return localize2.ordinalNumber(quarter, { unit: "quarter" });
56112 // Q1, Q2, Q3, Q4
56113 case "QQQ":
56114 return localize2.quarter(quarter, {
56115 width: "abbreviated",
56116 context: "formatting"
56117 });
56118 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
56119 case "QQQQQ":
56120 return localize2.quarter(quarter, {
56121 width: "narrow",
56122 context: "formatting"
56123 });
56124 // 1st quarter, 2nd quarter, ...
56125 case "QQQQ":
56126 default:
56127 return localize2.quarter(quarter, {
56128 width: "wide",
56129 context: "formatting"
56130 });
56131 }
56132 },
56133 // Stand-alone quarter
56134 q: function(date, token, localize2) {
56135 const quarter = Math.ceil((date.getMonth() + 1) / 3);
56136 switch (token) {
56137 // 1, 2, 3, 4
56138 case "q":
56139 return String(quarter);
56140 // 01, 02, 03, 04
56141 case "qq":
56142 return addLeadingZeros(quarter, 2);
56143 // 1st, 2nd, 3rd, 4th
56144 case "qo":
56145 return localize2.ordinalNumber(quarter, { unit: "quarter" });
56146 // Q1, Q2, Q3, Q4
56147 case "qqq":
56148 return localize2.quarter(quarter, {
56149 width: "abbreviated",
56150 context: "standalone"
56151 });
56152 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
56153 case "qqqqq":
56154 return localize2.quarter(quarter, {
56155 width: "narrow",
56156 context: "standalone"
56157 });
56158 // 1st quarter, 2nd quarter, ...
56159 case "qqqq":
56160 default:
56161 return localize2.quarter(quarter, {
56162 width: "wide",
56163 context: "standalone"
56164 });
56165 }
56166 },
56167 // Month
56168 M: function(date, token, localize2) {
56169 const month = date.getMonth();
56170 switch (token) {
56171 case "M":
56172 case "MM":
56173 return lightFormatters.M(date, token);
56174 // 1st, 2nd, ..., 12th
56175 case "Mo":
56176 return localize2.ordinalNumber(month + 1, { unit: "month" });
56177 // Jan, Feb, ..., Dec
56178 case "MMM":
56179 return localize2.month(month, {
56180 width: "abbreviated",
56181 context: "formatting"
56182 });
56183 // J, F, ..., D
56184 case "MMMMM":
56185 return localize2.month(month, {
56186 width: "narrow",
56187 context: "formatting"
56188 });
56189 // January, February, ..., December
56190 case "MMMM":
56191 default:
56192 return localize2.month(month, { width: "wide", context: "formatting" });
56193 }
56194 },
56195 // Stand-alone month
56196 L: function(date, token, localize2) {
56197 const month = date.getMonth();
56198 switch (token) {
56199 // 1, 2, ..., 12
56200 case "L":
56201 return String(month + 1);
56202 // 01, 02, ..., 12
56203 case "LL":
56204 return addLeadingZeros(month + 1, 2);
56205 // 1st, 2nd, ..., 12th
56206 case "Lo":
56207 return localize2.ordinalNumber(month + 1, { unit: "month" });
56208 // Jan, Feb, ..., Dec
56209 case "LLL":
56210 return localize2.month(month, {
56211 width: "abbreviated",
56212 context: "standalone"
56213 });
56214 // J, F, ..., D
56215 case "LLLLL":
56216 return localize2.month(month, {
56217 width: "narrow",
56218 context: "standalone"
56219 });
56220 // January, February, ..., December
56221 case "LLLL":
56222 default:
56223 return localize2.month(month, { width: "wide", context: "standalone" });
56224 }
56225 },
56226 // Local week of year
56227 w: function(date, token, localize2, options) {
56228 const week = getWeek(date, options);
56229 if (token === "wo") {
56230 return localize2.ordinalNumber(week, { unit: "week" });
56231 }
56232 return addLeadingZeros(week, token.length);
56233 },
56234 // ISO week of year
56235 I: function(date, token, localize2) {
56236 const isoWeek = getISOWeek(date);
56237 if (token === "Io") {
56238 return localize2.ordinalNumber(isoWeek, { unit: "week" });
56239 }
56240 return addLeadingZeros(isoWeek, token.length);
56241 },
56242 // Day of the month
56243 d: function(date, token, localize2) {
56244 if (token === "do") {
56245 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
56246 }
56247 return lightFormatters.d(date, token);
56248 },
56249 // Day of year
56250 D: function(date, token, localize2) {
56251 const dayOfYear = getDayOfYear(date);
56252 if (token === "Do") {
56253 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
56254 }
56255 return addLeadingZeros(dayOfYear, token.length);
56256 },
56257 // Day of week
56258 E: function(date, token, localize2) {
56259 const dayOfWeek = date.getDay();
56260 switch (token) {
56261 // Tue
56262 case "E":
56263 case "EE":
56264 case "EEE":
56265 return localize2.day(dayOfWeek, {
56266 width: "abbreviated",
56267 context: "formatting"
56268 });
56269 // T
56270 case "EEEEE":
56271 return localize2.day(dayOfWeek, {
56272 width: "narrow",
56273 context: "formatting"
56274 });
56275 // Tu
56276 case "EEEEEE":
56277 return localize2.day(dayOfWeek, {
56278 width: "short",
56279 context: "formatting"
56280 });
56281 // Tuesday
56282 case "EEEE":
56283 default:
56284 return localize2.day(dayOfWeek, {
56285 width: "wide",
56286 context: "formatting"
56287 });
56288 }
56289 },
56290 // Local day of week
56291 e: function(date, token, localize2, options) {
56292 const dayOfWeek = date.getDay();
56293 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
56294 switch (token) {
56295 // Numerical value (Nth day of week with current locale or weekStartsOn)
56296 case "e":
56297 return String(localDayOfWeek);
56298 // Padded numerical value
56299 case "ee":
56300 return addLeadingZeros(localDayOfWeek, 2);
56301 // 1st, 2nd, ..., 7th
56302 case "eo":
56303 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
56304 case "eee":
56305 return localize2.day(dayOfWeek, {
56306 width: "abbreviated",
56307 context: "formatting"
56308 });
56309 // T
56310 case "eeeee":
56311 return localize2.day(dayOfWeek, {
56312 width: "narrow",
56313 context: "formatting"
56314 });
56315 // Tu
56316 case "eeeeee":
56317 return localize2.day(dayOfWeek, {
56318 width: "short",
56319 context: "formatting"
56320 });
56321 // Tuesday
56322 case "eeee":
56323 default:
56324 return localize2.day(dayOfWeek, {
56325 width: "wide",
56326 context: "formatting"
56327 });
56328 }
56329 },
56330 // Stand-alone local day of week
56331 c: function(date, token, localize2, options) {
56332 const dayOfWeek = date.getDay();
56333 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
56334 switch (token) {
56335 // Numerical value (same as in `e`)
56336 case "c":
56337 return String(localDayOfWeek);
56338 // Padded numerical value
56339 case "cc":
56340 return addLeadingZeros(localDayOfWeek, token.length);
56341 // 1st, 2nd, ..., 7th
56342 case "co":
56343 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
56344 case "ccc":
56345 return localize2.day(dayOfWeek, {
56346 width: "abbreviated",
56347 context: "standalone"
56348 });
56349 // T
56350 case "ccccc":
56351 return localize2.day(dayOfWeek, {
56352 width: "narrow",
56353 context: "standalone"
56354 });
56355 // Tu
56356 case "cccccc":
56357 return localize2.day(dayOfWeek, {
56358 width: "short",
56359 context: "standalone"
56360 });
56361 // Tuesday
56362 case "cccc":
56363 default:
56364 return localize2.day(dayOfWeek, {
56365 width: "wide",
56366 context: "standalone"
56367 });
56368 }
56369 },
56370 // ISO day of week
56371 i: function(date, token, localize2) {
56372 const dayOfWeek = date.getDay();
56373 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
56374 switch (token) {
56375 // 2
56376 case "i":
56377 return String(isoDayOfWeek);
56378 // 02
56379 case "ii":
56380 return addLeadingZeros(isoDayOfWeek, token.length);
56381 // 2nd
56382 case "io":
56383 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
56384 // Tue
56385 case "iii":
56386 return localize2.day(dayOfWeek, {
56387 width: "abbreviated",
56388 context: "formatting"
56389 });
56390 // T
56391 case "iiiii":
56392 return localize2.day(dayOfWeek, {
56393 width: "narrow",
56394 context: "formatting"
56395 });
56396 // Tu
56397 case "iiiiii":
56398 return localize2.day(dayOfWeek, {
56399 width: "short",
56400 context: "formatting"
56401 });
56402 // Tuesday
56403 case "iiii":
56404 default:
56405 return localize2.day(dayOfWeek, {
56406 width: "wide",
56407 context: "formatting"
56408 });
56409 }
56410 },
56411 // AM or PM
56412 a: function(date, token, localize2) {
56413 const hours = date.getHours();
56414 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
56415 switch (token) {
56416 case "a":
56417 case "aa":
56418 return localize2.dayPeriod(dayPeriodEnumValue, {
56419 width: "abbreviated",
56420 context: "formatting"
56421 });
56422 case "aaa":
56423 return localize2.dayPeriod(dayPeriodEnumValue, {
56424 width: "abbreviated",
56425 context: "formatting"
56426 }).toLowerCase();
56427 case "aaaaa":
56428 return localize2.dayPeriod(dayPeriodEnumValue, {
56429 width: "narrow",
56430 context: "formatting"
56431 });
56432 case "aaaa":
56433 default:
56434 return localize2.dayPeriod(dayPeriodEnumValue, {
56435 width: "wide",
56436 context: "formatting"
56437 });
56438 }
56439 },
56440 // AM, PM, midnight, noon
56441 b: function(date, token, localize2) {
56442 const hours = date.getHours();
56443 let dayPeriodEnumValue;
56444 if (hours === 12) {
56445 dayPeriodEnumValue = dayPeriodEnum.noon;
56446 } else if (hours === 0) {
56447 dayPeriodEnumValue = dayPeriodEnum.midnight;
56448 } else {
56449 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
56450 }
56451 switch (token) {
56452 case "b":
56453 case "bb":
56454 return localize2.dayPeriod(dayPeriodEnumValue, {
56455 width: "abbreviated",
56456 context: "formatting"
56457 });
56458 case "bbb":
56459 return localize2.dayPeriod(dayPeriodEnumValue, {
56460 width: "abbreviated",
56461 context: "formatting"
56462 }).toLowerCase();
56463 case "bbbbb":
56464 return localize2.dayPeriod(dayPeriodEnumValue, {
56465 width: "narrow",
56466 context: "formatting"
56467 });
56468 case "bbbb":
56469 default:
56470 return localize2.dayPeriod(dayPeriodEnumValue, {
56471 width: "wide",
56472 context: "formatting"
56473 });
56474 }
56475 },
56476 // in the morning, in the afternoon, in the evening, at night
56477 B: function(date, token, localize2) {
56478 const hours = date.getHours();
56479 let dayPeriodEnumValue;
56480 if (hours >= 17) {
56481 dayPeriodEnumValue = dayPeriodEnum.evening;
56482 } else if (hours >= 12) {
56483 dayPeriodEnumValue = dayPeriodEnum.afternoon;
56484 } else if (hours >= 4) {
56485 dayPeriodEnumValue = dayPeriodEnum.morning;
56486 } else {
56487 dayPeriodEnumValue = dayPeriodEnum.night;
56488 }
56489 switch (token) {
56490 case "B":
56491 case "BB":
56492 case "BBB":
56493 return localize2.dayPeriod(dayPeriodEnumValue, {
56494 width: "abbreviated",
56495 context: "formatting"
56496 });
56497 case "BBBBB":
56498 return localize2.dayPeriod(dayPeriodEnumValue, {
56499 width: "narrow",
56500 context: "formatting"
56501 });
56502 case "BBBB":
56503 default:
56504 return localize2.dayPeriod(dayPeriodEnumValue, {
56505 width: "wide",
56506 context: "formatting"
56507 });
56508 }
56509 },
56510 // Hour [1-12]
56511 h: function(date, token, localize2) {
56512 if (token === "ho") {
56513 let hours = date.getHours() % 12;
56514 if (hours === 0) hours = 12;
56515 return localize2.ordinalNumber(hours, { unit: "hour" });
56516 }
56517 return lightFormatters.h(date, token);
56518 },
56519 // Hour [0-23]
56520 H: function(date, token, localize2) {
56521 if (token === "Ho") {
56522 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
56523 }
56524 return lightFormatters.H(date, token);
56525 },
56526 // Hour [0-11]
56527 K: function(date, token, localize2) {
56528 const hours = date.getHours() % 12;
56529 if (token === "Ko") {
56530 return localize2.ordinalNumber(hours, { unit: "hour" });
56531 }
56532 return addLeadingZeros(hours, token.length);
56533 },
56534 // Hour [1-24]
56535 k: function(date, token, localize2) {
56536 let hours = date.getHours();
56537 if (hours === 0) hours = 24;
56538 if (token === "ko") {
56539 return localize2.ordinalNumber(hours, { unit: "hour" });
56540 }
56541 return addLeadingZeros(hours, token.length);
56542 },
56543 // Minute
56544 m: function(date, token, localize2) {
56545 if (token === "mo") {
56546 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
56547 }
56548 return lightFormatters.m(date, token);
56549 },
56550 // Second
56551 s: function(date, token, localize2) {
56552 if (token === "so") {
56553 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
56554 }
56555 return lightFormatters.s(date, token);
56556 },
56557 // Fraction of second
56558 S: function(date, token) {
56559 return lightFormatters.S(date, token);
56560 },
56561 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
56562 X: function(date, token, _localize) {
56563 const timezoneOffset = date.getTimezoneOffset();
56564 if (timezoneOffset === 0) {
56565 return "Z";
56566 }
56567 switch (token) {
56568 // Hours and optional minutes
56569 case "X":
56570 return formatTimezoneWithOptionalMinutes(timezoneOffset);
56571 // Hours, minutes and optional seconds without `:` delimiter
56572 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
56573 // so this token always has the same output as `XX`
56574 case "XXXX":
56575 case "XX":
56576 return formatTimezone(timezoneOffset);
56577 // Hours, minutes and optional seconds with `:` delimiter
56578 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
56579 // so this token always has the same output as `XXX`
56580 case "XXXXX":
56581 case "XXX":
56582 // Hours and minutes with `:` delimiter
56583 default:
56584 return formatTimezone(timezoneOffset, ":");
56585 }
56586 },
56587 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
56588 x: function(date, token, _localize) {
56589 const timezoneOffset = date.getTimezoneOffset();
56590 switch (token) {
56591 // Hours and optional minutes
56592 case "x":
56593 return formatTimezoneWithOptionalMinutes(timezoneOffset);
56594 // Hours, minutes and optional seconds without `:` delimiter
56595 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
56596 // so this token always has the same output as `xx`
56597 case "xxxx":
56598 case "xx":
56599 return formatTimezone(timezoneOffset);
56600 // Hours, minutes and optional seconds with `:` delimiter
56601 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
56602 // so this token always has the same output as `xxx`
56603 case "xxxxx":
56604 case "xxx":
56605 // Hours and minutes with `:` delimiter
56606 default:
56607 return formatTimezone(timezoneOffset, ":");
56608 }
56609 },
56610 // Timezone (GMT)
56611 O: function(date, token, _localize) {
56612 const timezoneOffset = date.getTimezoneOffset();
56613 switch (token) {
56614 // Short
56615 case "O":
56616 case "OO":
56617 case "OOO":
56618 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
56619 // Long
56620 case "OOOO":
56621 default:
56622 return "GMT" + formatTimezone(timezoneOffset, ":");
56623 }
56624 },
56625 // Timezone (specific non-location)
56626 z: function(date, token, _localize) {
56627 const timezoneOffset = date.getTimezoneOffset();
56628 switch (token) {
56629 // Short
56630 case "z":
56631 case "zz":
56632 case "zzz":
56633 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
56634 // Long
56635 case "zzzz":
56636 default:
56637 return "GMT" + formatTimezone(timezoneOffset, ":");
56638 }
56639 },
56640 // Seconds timestamp
56641 t: function(date, token, _localize) {
56642 const timestamp = Math.trunc(+date / 1e3);
56643 return addLeadingZeros(timestamp, token.length);
56644 },
56645 // Milliseconds timestamp
56646 T: function(date, token, _localize) {
56647 return addLeadingZeros(+date, token.length);
56648 }
56649 };
56650 function formatTimezoneShort(offset3, delimiter = "") {
56651 const sign = offset3 > 0 ? "-" : "+";
56652 const absOffset = Math.abs(offset3);
56653 const hours = Math.trunc(absOffset / 60);
56654 const minutes = absOffset % 60;
56655 if (minutes === 0) {
56656 return sign + String(hours);
56657 }
56658 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
56659 }
56660 function formatTimezoneWithOptionalMinutes(offset3, delimiter) {
56661 if (offset3 % 60 === 0) {
56662 const sign = offset3 > 0 ? "-" : "+";
56663 return sign + addLeadingZeros(Math.abs(offset3) / 60, 2);
56664 }
56665 return formatTimezone(offset3, delimiter);
56666 }
56667 function formatTimezone(offset3, delimiter = "") {
56668 const sign = offset3 > 0 ? "-" : "+";
56669 const absOffset = Math.abs(offset3);
56670 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
56671 const minutes = addLeadingZeros(absOffset % 60, 2);
56672 return sign + hours + delimiter + minutes;
56673 }
56674
56675 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
56676 var dateLongFormatter = (pattern, formatLong2) => {
56677 switch (pattern) {
56678 case "P":
56679 return formatLong2.date({ width: "short" });
56680 case "PP":
56681 return formatLong2.date({ width: "medium" });
56682 case "PPP":
56683 return formatLong2.date({ width: "long" });
56684 case "PPPP":
56685 default:
56686 return formatLong2.date({ width: "full" });
56687 }
56688 };
56689 var timeLongFormatter = (pattern, formatLong2) => {
56690 switch (pattern) {
56691 case "p":
56692 return formatLong2.time({ width: "short" });
56693 case "pp":
56694 return formatLong2.time({ width: "medium" });
56695 case "ppp":
56696 return formatLong2.time({ width: "long" });
56697 case "pppp":
56698 default:
56699 return formatLong2.time({ width: "full" });
56700 }
56701 };
56702 var dateTimeLongFormatter = (pattern, formatLong2) => {
56703 const matchResult = pattern.match(/(P+)(p+)?/) || [];
56704 const datePattern = matchResult[1];
56705 const timePattern = matchResult[2];
56706 if (!timePattern) {
56707 return dateLongFormatter(pattern, formatLong2);
56708 }
56709 let dateTimeFormat;
56710 switch (datePattern) {
56711 case "P":
56712 dateTimeFormat = formatLong2.dateTime({ width: "short" });
56713 break;
56714 case "PP":
56715 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
56716 break;
56717 case "PPP":
56718 dateTimeFormat = formatLong2.dateTime({ width: "long" });
56719 break;
56720 case "PPPP":
56721 default:
56722 dateTimeFormat = formatLong2.dateTime({ width: "full" });
56723 break;
56724 }
56725 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
56726 };
56727 var longFormatters = {
56728 p: timeLongFormatter,
56729 P: dateTimeLongFormatter
56730 };
56731
56732 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
56733 var dayOfYearTokenRE = /^D+$/;
56734 var weekYearTokenRE = /^Y+$/;
56735 var throwTokens = ["D", "DD", "YY", "YYYY"];
56736 function isProtectedDayOfYearToken(token) {
56737 return dayOfYearTokenRE.test(token);
56738 }
56739 function isProtectedWeekYearToken(token) {
56740 return weekYearTokenRE.test(token);
56741 }
56742 function warnOrThrowProtectedError(token, format6, input) {
56743 const _message = message(token, format6, input);
56744 console.warn(_message);
56745 if (throwTokens.includes(token)) throw new RangeError(_message);
56746 }
56747 function message(token, format6, input) {
56748 const subject = token[0] === "Y" ? "years" : "days of the month";
56749 return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format6}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
56750 }
56751
56752 // packages/dataviews/node_modules/date-fns/format.js
56753 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
56754 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
56755 var escapedStringRegExp = /^'([^]*?)'?$/;
56756 var doubleQuoteRegExp = /''/g;
56757 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
56758 function format(date, formatStr, options) {
56759 const defaultOptions2 = getDefaultOptions();
56760 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
56761 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
56762 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
56763 const originalDate = toDate2(date, options?.in);
56764 if (!isValid(originalDate)) {
56765 throw new RangeError("Invalid time value");
56766 }
56767 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
56768 const firstCharacter = substring[0];
56769 if (firstCharacter === "p" || firstCharacter === "P") {
56770 const longFormatter = longFormatters[firstCharacter];
56771 return longFormatter(substring, locale.formatLong);
56772 }
56773 return substring;
56774 }).join("").match(formattingTokensRegExp).map((substring) => {
56775 if (substring === "''") {
56776 return { isToken: false, value: "'" };
56777 }
56778 const firstCharacter = substring[0];
56779 if (firstCharacter === "'") {
56780 return { isToken: false, value: cleanEscapedString(substring) };
56781 }
56782 if (formatters[firstCharacter]) {
56783 return { isToken: true, value: substring };
56784 }
56785 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
56786 throw new RangeError(
56787 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
56788 );
56789 }
56790 return { isToken: false, value: substring };
56791 });
56792 if (locale.localize.preprocessor) {
56793 parts = locale.localize.preprocessor(originalDate, parts);
56794 }
56795 const formatterOptions = {
56796 firstWeekContainsDate,
56797 weekStartsOn,
56798 locale
56799 };
56800 return parts.map((part) => {
56801 if (!part.isToken) return part.value;
56802 const token = part.value;
56803 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
56804 warnOrThrowProtectedError(token, formatStr, String(date));
56805 }
56806 const formatter = formatters[token[0]];
56807 return formatter(originalDate, token, locale.localize, formatterOptions);
56808 }).join("");
56809 }
56810 function cleanEscapedString(input) {
56811 const matched = input.match(escapedStringRegExp);
56812 if (!matched) {
56813 return input;
56814 }
56815 return matched[1].replace(doubleQuoteRegExp, "'");
56816 }
56817
56818 // packages/dataviews/node_modules/date-fns/subDays.js
56819 function subDays(date, amount, options) {
56820 return addDays(date, -amount, options);
56821 }
56822
56823 // packages/dataviews/node_modules/date-fns/subMonths.js
56824 function subMonths(date, amount, options) {
56825 return addMonths(date, -amount, options);
56826 }
56827
56828 // packages/dataviews/node_modules/date-fns/subWeeks.js
56829 function subWeeks(date, amount, options) {
56830 return addWeeks(date, -amount, options);
56831 }
56832
56833 // packages/dataviews/node_modules/date-fns/subYears.js
56834 function subYears(date, amount, options) {
56835 return addYears(date, -amount, options);
56836 }
56837
56838 // packages/dataviews/build-module/utils/operators.mjs
56839 var import_i18n225 = __toESM(require_i18n(), 1);
56840 var import_element177 = __toESM(require_element(), 1);
56841 var import_date10 = __toESM(require_date(), 1);
56842 var import_jsx_runtime345 = __toESM(require_jsx_runtime(), 1);
56843 var filterTextWrappers = {
56844 Name: /* @__PURE__ */ (0, import_jsx_runtime345.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
56845 Value: /* @__PURE__ */ (0, import_jsx_runtime345.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
56846 };
56847 function getRelativeDate(value, unit) {
56848 switch (unit) {
56849 case "days":
56850 return subDays(/* @__PURE__ */ new Date(), value);
56851 case "weeks":
56852 return subWeeks(/* @__PURE__ */ new Date(), value);
56853 case "months":
56854 return subMonths(/* @__PURE__ */ new Date(), value);
56855 case "years":
56856 return subYears(/* @__PURE__ */ new Date(), value);
56857 default:
56858 return /* @__PURE__ */ new Date();
56859 }
56860 }
56861 var isNoneOperatorDefinition = {
56862 /* translators: DataViews operator name */
56863 label: (0, import_i18n225.__)("Is none of"),
56864 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
56865 (0, import_i18n225.sprintf)(
56866 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
56867 (0, import_i18n225.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
56868 filter.name,
56869 activeElements.map((element) => element.label).join(", ")
56870 ),
56871 filterTextWrappers
56872 ),
56873 filter: ((item, field, filterValue) => {
56874 if (!filterValue?.length) {
56875 return true;
56876 }
56877 const fieldValue = field.getValue({ item });
56878 if (Array.isArray(fieldValue)) {
56879 return !filterValue.some(
56880 (fv) => fieldValue.includes(fv)
56881 );
56882 } else if (typeof fieldValue === "string") {
56883 return !filterValue.includes(fieldValue);
56884 }
56885 return false;
56886 }),
56887 selection: "multi"
56888 };
56889 var OPERATORS = [
56890 {
56891 name: OPERATOR_IS_ANY2,
56892 /* translators: DataViews operator name */
56893 label: (0, import_i18n225.__)("Includes"),
56894 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
56895 (0, import_i18n225.sprintf)(
56896 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
56897 (0, import_i18n225.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
56898 filter.name,
56899 activeElements.map((element) => element.label).join(", ")
56900 ),
56901 filterTextWrappers
56902 ),
56903 filter(item, field, filterValue) {
56904 if (!filterValue?.length) {
56905 return true;
56906 }
56907 const fieldValue = field.getValue({ item });
56908 if (Array.isArray(fieldValue)) {
56909 return filterValue.some(
56910 (fv) => fieldValue.includes(fv)
56911 );
56912 } else if (typeof fieldValue === "string") {
56913 return filterValue.includes(fieldValue);
56914 }
56915 return false;
56916 },
56917 selection: "multi"
56918 },
56919 {
56920 name: OPERATOR_IS_NONE,
56921 ...isNoneOperatorDefinition
56922 },
56923 {
56924 name: OPERATOR_IS_ALL,
56925 /* translators: DataViews operator name */
56926 label: (0, import_i18n225.__)("Includes all"),
56927 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
56928 (0, import_i18n225.sprintf)(
56929 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
56930 (0, import_i18n225.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
56931 filter.name,
56932 activeElements.map((element) => element.label).join(", ")
56933 ),
56934 filterTextWrappers
56935 ),
56936 filter(item, field, filterValue) {
56937 if (!filterValue?.length) {
56938 return true;
56939 }
56940 return filterValue.every((value) => {
56941 return field.getValue({ item })?.includes(value);
56942 });
56943 },
56944 selection: "multi"
56945 },
56946 {
56947 name: OPERATOR_IS_NOT_ALL,
56948 ...isNoneOperatorDefinition
56949 },
56950 {
56951 name: OPERATOR_BETWEEN,
56952 /* translators: DataViews operator name */
56953 label: (0, import_i18n225.__)("Between (inc)"),
56954 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
56955 (0, import_i18n225.sprintf)(
56956 /* translators: 1: Filter name (e.g. "Item count"). 2: Filter value min. 3: Filter value max. e.g.: "Item count between (inc): 10 and 180". */
56957 (0, import_i18n225.__)(
56958 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
56959 ),
56960 filter.name,
56961 activeElements[0].label[0],
56962 activeElements[0].label[1]
56963 ),
56964 filterTextWrappers
56965 ),
56966 filter(item, field, filterValue) {
56967 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
56968 return true;
56969 }
56970 const fieldValue = field.getValue({ item });
56971 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
56972 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
56973 }
56974 return false;
56975 },
56976 selection: "custom"
56977 },
56978 {
56979 name: OPERATOR_IN_THE_PAST,
56980 /* translators: DataViews operator name */
56981 label: (0, import_i18n225.__)("In the past"),
56982 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
56983 (0, import_i18n225.sprintf)(
56984 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
56985 (0, import_i18n225.__)(
56986 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
56987 ),
56988 filter.name,
56989 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
56990 ),
56991 filterTextWrappers
56992 ),
56993 filter(item, field, filterValue) {
56994 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
56995 return true;
56996 }
56997 const targetDate = getRelativeDate(
56998 filterValue.value,
56999 filterValue.unit
57000 );
57001 const fieldValue = (0, import_date10.getDate)(field.getValue({ item }));
57002 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
57003 },
57004 selection: "custom"
57005 },
57006 {
57007 name: OPERATOR_OVER,
57008 /* translators: DataViews operator name */
57009 label: (0, import_i18n225.__)("Over"),
57010 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57011 (0, import_i18n225.sprintf)(
57012 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
57013 (0, import_i18n225.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
57014 filter.name,
57015 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
57016 ),
57017 filterTextWrappers
57018 ),
57019 filter(item, field, filterValue) {
57020 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
57021 return true;
57022 }
57023 const targetDate = getRelativeDate(
57024 filterValue.value,
57025 filterValue.unit
57026 );
57027 const fieldValue = (0, import_date10.getDate)(field.getValue({ item }));
57028 return fieldValue < targetDate;
57029 },
57030 selection: "custom"
57031 },
57032 {
57033 name: OPERATOR_IS,
57034 /* translators: DataViews operator name */
57035 label: (0, import_i18n225.__)("Is"),
57036 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57037 (0, import_i18n225.sprintf)(
57038 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
57039 (0, import_i18n225.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
57040 filter.name,
57041 activeElements[0].label
57042 ),
57043 filterTextWrappers
57044 ),
57045 filter(item, field, filterValue) {
57046 return filterValue === field.getValue({ item }) || filterValue === void 0;
57047 },
57048 selection: "single"
57049 },
57050 {
57051 name: OPERATOR_IS_NOT,
57052 /* translators: DataViews operator name */
57053 label: (0, import_i18n225.__)("Is not"),
57054 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57055 (0, import_i18n225.sprintf)(
57056 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
57057 (0, import_i18n225.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
57058 filter.name,
57059 activeElements[0].label
57060 ),
57061 filterTextWrappers
57062 ),
57063 filter(item, field, filterValue) {
57064 return filterValue !== field.getValue({ item });
57065 },
57066 selection: "single"
57067 },
57068 {
57069 name: OPERATOR_LESS_THAN,
57070 /* translators: DataViews operator name */
57071 label: (0, import_i18n225.__)("Less than"),
57072 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57073 (0, import_i18n225.sprintf)(
57074 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
57075 (0, import_i18n225.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
57076 filter.name,
57077 activeElements[0].label
57078 ),
57079 filterTextWrappers
57080 ),
57081 filter(item, field, filterValue) {
57082 if (filterValue === void 0) {
57083 return true;
57084 }
57085 const fieldValue = field.getValue({ item });
57086 return fieldValue < filterValue;
57087 },
57088 selection: "single"
57089 },
57090 {
57091 name: OPERATOR_GREATER_THAN,
57092 /* translators: DataViews operator name */
57093 label: (0, import_i18n225.__)("Greater than"),
57094 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57095 (0, import_i18n225.sprintf)(
57096 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
57097 (0, import_i18n225.__)(
57098 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
57099 ),
57100 filter.name,
57101 activeElements[0].label
57102 ),
57103 filterTextWrappers
57104 ),
57105 filter(item, field, filterValue) {
57106 if (filterValue === void 0) {
57107 return true;
57108 }
57109 const fieldValue = field.getValue({ item });
57110 return fieldValue > filterValue;
57111 },
57112 selection: "single"
57113 },
57114 {
57115 name: OPERATOR_LESS_THAN_OR_EQUAL,
57116 /* translators: DataViews operator name */
57117 label: (0, import_i18n225.__)("Less than or equal"),
57118 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57119 (0, import_i18n225.sprintf)(
57120 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
57121 (0, import_i18n225.__)(
57122 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
57123 ),
57124 filter.name,
57125 activeElements[0].label
57126 ),
57127 filterTextWrappers
57128 ),
57129 filter(item, field, filterValue) {
57130 if (filterValue === void 0) {
57131 return true;
57132 }
57133 const fieldValue = field.getValue({ item });
57134 return fieldValue <= filterValue;
57135 },
57136 selection: "single"
57137 },
57138 {
57139 name: OPERATOR_GREATER_THAN_OR_EQUAL,
57140 /* translators: DataViews operator name */
57141 label: (0, import_i18n225.__)("Greater than or equal"),
57142 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57143 (0, import_i18n225.sprintf)(
57144 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
57145 (0, import_i18n225.__)(
57146 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
57147 ),
57148 filter.name,
57149 activeElements[0].label
57150 ),
57151 filterTextWrappers
57152 ),
57153 filter(item, field, filterValue) {
57154 if (filterValue === void 0) {
57155 return true;
57156 }
57157 const fieldValue = field.getValue({ item });
57158 return fieldValue >= filterValue;
57159 },
57160 selection: "single"
57161 },
57162 {
57163 name: OPERATOR_BEFORE,
57164 /* translators: DataViews operator name */
57165 label: (0, import_i18n225.__)("Before"),
57166 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57167 (0, import_i18n225.sprintf)(
57168 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
57169 (0, import_i18n225.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
57170 filter.name,
57171 activeElements[0].label
57172 ),
57173 filterTextWrappers
57174 ),
57175 filter(item, field, filterValue) {
57176 if (filterValue === void 0) {
57177 return true;
57178 }
57179 const filterDate = (0, import_date10.getDate)(filterValue);
57180 const fieldDate = (0, import_date10.getDate)(field.getValue({ item }));
57181 return fieldDate < filterDate;
57182 },
57183 selection: "single"
57184 },
57185 {
57186 name: OPERATOR_AFTER,
57187 /* translators: DataViews operator name */
57188 label: (0, import_i18n225.__)("After"),
57189 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57190 (0, import_i18n225.sprintf)(
57191 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
57192 (0, import_i18n225.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
57193 filter.name,
57194 activeElements[0].label
57195 ),
57196 filterTextWrappers
57197 ),
57198 filter(item, field, filterValue) {
57199 if (filterValue === void 0) {
57200 return true;
57201 }
57202 const filterDate = (0, import_date10.getDate)(filterValue);
57203 const fieldDate = (0, import_date10.getDate)(field.getValue({ item }));
57204 return fieldDate > filterDate;
57205 },
57206 selection: "single"
57207 },
57208 {
57209 name: OPERATOR_BEFORE_INC,
57210 /* translators: DataViews operator name */
57211 label: (0, import_i18n225.__)("Before (inc)"),
57212 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57213 (0, import_i18n225.sprintf)(
57214 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
57215 (0, import_i18n225.__)(
57216 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
57217 ),
57218 filter.name,
57219 activeElements[0].label
57220 ),
57221 filterTextWrappers
57222 ),
57223 filter(item, field, filterValue) {
57224 if (filterValue === void 0) {
57225 return true;
57226 }
57227 const filterDate = (0, import_date10.getDate)(filterValue);
57228 const fieldDate = (0, import_date10.getDate)(field.getValue({ item }));
57229 return fieldDate <= filterDate;
57230 },
57231 selection: "single"
57232 },
57233 {
57234 name: OPERATOR_AFTER_INC,
57235 /* translators: DataViews operator name */
57236 label: (0, import_i18n225.__)("After (inc)"),
57237 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57238 (0, import_i18n225.sprintf)(
57239 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
57240 (0, import_i18n225.__)(
57241 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
57242 ),
57243 filter.name,
57244 activeElements[0].label
57245 ),
57246 filterTextWrappers
57247 ),
57248 filter(item, field, filterValue) {
57249 if (filterValue === void 0) {
57250 return true;
57251 }
57252 const filterDate = (0, import_date10.getDate)(filterValue);
57253 const fieldDate = (0, import_date10.getDate)(field.getValue({ item }));
57254 return fieldDate >= filterDate;
57255 },
57256 selection: "single"
57257 },
57258 {
57259 name: OPERATOR_CONTAINS,
57260 /* translators: DataViews operator name */
57261 label: (0, import_i18n225.__)("Contains"),
57262 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57263 (0, import_i18n225.sprintf)(
57264 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
57265 (0, import_i18n225.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
57266 filter.name,
57267 activeElements[0].label
57268 ),
57269 filterTextWrappers
57270 ),
57271 filter(item, field, filterValue) {
57272 if (filterValue === void 0) {
57273 return true;
57274 }
57275 const fieldValue = field.getValue({ item });
57276 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
57277 },
57278 selection: "single"
57279 },
57280 {
57281 name: OPERATOR_NOT_CONTAINS,
57282 /* translators: DataViews operator name */
57283 label: (0, import_i18n225.__)("Doesn't contain"),
57284 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57285 (0, import_i18n225.sprintf)(
57286 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
57287 (0, import_i18n225.__)(
57288 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
57289 ),
57290 filter.name,
57291 activeElements[0].label
57292 ),
57293 filterTextWrappers
57294 ),
57295 filter(item, field, filterValue) {
57296 if (filterValue === void 0) {
57297 return true;
57298 }
57299 const fieldValue = field.getValue({ item });
57300 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
57301 },
57302 selection: "single"
57303 },
57304 {
57305 name: OPERATOR_STARTS_WITH,
57306 /* translators: DataViews operator name */
57307 label: (0, import_i18n225.__)("Starts with"),
57308 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57309 (0, import_i18n225.sprintf)(
57310 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
57311 (0, import_i18n225.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
57312 filter.name,
57313 activeElements[0].label
57314 ),
57315 filterTextWrappers
57316 ),
57317 filter(item, field, filterValue) {
57318 if (filterValue === void 0) {
57319 return true;
57320 }
57321 const fieldValue = field.getValue({ item });
57322 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
57323 },
57324 selection: "single"
57325 },
57326 {
57327 name: OPERATOR_ON,
57328 /* translators: DataViews operator name */
57329 label: (0, import_i18n225.__)("On"),
57330 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57331 (0, import_i18n225.sprintf)(
57332 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
57333 (0, import_i18n225.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
57334 filter.name,
57335 activeElements[0].label
57336 ),
57337 filterTextWrappers
57338 ),
57339 filter(item, field, filterValue) {
57340 if (filterValue === void 0) {
57341 return true;
57342 }
57343 const filterDate = (0, import_date10.getDate)(filterValue);
57344 const fieldDate = (0, import_date10.getDate)(field.getValue({ item }));
57345 return filterDate.getTime() === fieldDate.getTime();
57346 },
57347 selection: "single"
57348 },
57349 {
57350 name: OPERATOR_NOT_ON,
57351 /* translators: DataViews operator name */
57352 label: (0, import_i18n225.__)("Not on"),
57353 filterText: (filter, activeElements) => (0, import_element177.createInterpolateElement)(
57354 (0, import_i18n225.sprintf)(
57355 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
57356 (0, import_i18n225.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
57357 filter.name,
57358 activeElements[0].label
57359 ),
57360 filterTextWrappers
57361 ),
57362 filter(item, field, filterValue) {
57363 if (filterValue === void 0) {
57364 return true;
57365 }
57366 const filterDate = (0, import_date10.getDate)(filterValue);
57367 const fieldDate = (0, import_date10.getDate)(field.getValue({ item }));
57368 return filterDate.getTime() !== fieldDate.getTime();
57369 },
57370 selection: "single"
57371 }
57372 ];
57373 var getOperatorByName = (name2) => OPERATORS.find((op) => op.name === name2);
57374 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
57375
57376 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
57377 var import_components200 = __toESM(require_components(), 1);
57378 var import_element178 = __toESM(require_element(), 1);
57379
57380 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
57381 function getCustomValidity(isValid2, validity) {
57382 let customValidity;
57383 if (isValid2?.required && validity?.required) {
57384 customValidity = validity?.required?.message ? validity.required : void 0;
57385 } else if (isValid2?.pattern && validity?.pattern) {
57386 customValidity = validity.pattern;
57387 } else if (isValid2?.min && validity?.min) {
57388 customValidity = validity.min;
57389 } else if (isValid2?.max && validity?.max) {
57390 customValidity = validity.max;
57391 } else if (isValid2?.minLength && validity?.minLength) {
57392 customValidity = validity.minLength;
57393 } else if (isValid2?.maxLength && validity?.maxLength) {
57394 customValidity = validity.maxLength;
57395 } else if (isValid2?.elements && validity?.elements) {
57396 customValidity = validity.elements;
57397 } else if (validity?.custom) {
57398 customValidity = validity.custom;
57399 }
57400 return customValidity;
57401 }
57402
57403 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
57404 var import_jsx_runtime346 = __toESM(require_jsx_runtime(), 1);
57405 var { ValidatedCheckboxControl } = unlock4(import_components200.privateApis);
57406 function Checkbox({
57407 field,
57408 onChange,
57409 data,
57410 hideLabelFromVision,
57411 markWhenOptional,
57412 validity
57413 }) {
57414 const { getValue: getValue2, setValue, label, description, isValid: isValid2 } = field;
57415 const onChangeControl = (0, import_element178.useCallback)(() => {
57416 onChange(
57417 setValue({ item: data, value: !getValue2({ item: data }) })
57418 );
57419 }, [data, getValue2, onChange, setValue]);
57420 return /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(
57421 ValidatedCheckboxControl,
57422 {
57423 required: !!field.isValid?.required,
57424 markWhenOptional,
57425 customValidity: getCustomValidity(isValid2, validity),
57426 hidden: hideLabelFromVision,
57427 label,
57428 help: description,
57429 checked: getValue2({ item: data }),
57430 onChange: onChangeControl
57431 }
57432 );
57433 }
57434
57435 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
57436 var import_components201 = __toESM(require_components(), 1);
57437 var import_element179 = __toESM(require_element(), 1);
57438 var import_jsx_runtime347 = __toESM(require_jsx_runtime(), 1);
57439 var { ValidatedComboboxControl } = unlock4(import_components201.privateApis);
57440 function Combobox({
57441 data,
57442 field,
57443 onChange,
57444 hideLabelFromVision,
57445 validity
57446 }) {
57447 const { label, description, placeholder, getValue: getValue2, setValue, isValid: isValid2 } = field;
57448 const value = getValue2({ item: data }) ?? "";
57449 const onChangeControl = (0, import_element179.useCallback)(
57450 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
57451 [data, onChange, setValue]
57452 );
57453 const { elements: elements2, isLoading } = useElements({
57454 elements: field.elements,
57455 getElements: field.getElements
57456 });
57457 if (isLoading) {
57458 return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(import_components201.Spinner, {});
57459 }
57460 return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
57461 ValidatedComboboxControl,
57462 {
57463 required: !!field.isValid?.required,
57464 customValidity: getCustomValidity(isValid2, validity),
57465 label,
57466 value,
57467 help: description,
57468 placeholder,
57469 options: elements2,
57470 onChange: onChangeControl,
57471 hideLabelFromVision,
57472 allowReset: true,
57473 expandOnFocus: true
57474 }
57475 );
57476 }
57477
57478 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
57479 var import_components203 = __toESM(require_components(), 1);
57480 var import_element181 = __toESM(require_element(), 1);
57481 var import_i18n227 = __toESM(require_i18n(), 1);
57482 var import_date12 = __toESM(require_date(), 1);
57483
57484 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
57485 var import_components202 = __toESM(require_components(), 1);
57486 var import_element180 = __toESM(require_element(), 1);
57487 var import_i18n226 = __toESM(require_i18n(), 1);
57488 var import_jsx_runtime348 = __toESM(require_jsx_runtime(), 1);
57489 var TIME_UNITS_OPTIONS = {
57490 [OPERATOR_IN_THE_PAST]: [
57491 { value: "days", label: (0, import_i18n226.__)("Days") },
57492 { value: "weeks", label: (0, import_i18n226.__)("Weeks") },
57493 { value: "months", label: (0, import_i18n226.__)("Months") },
57494 { value: "years", label: (0, import_i18n226.__)("Years") }
57495 ],
57496 [OPERATOR_OVER]: [
57497 { value: "days", label: (0, import_i18n226.__)("Days ago") },
57498 { value: "weeks", label: (0, import_i18n226.__)("Weeks ago") },
57499 { value: "months", label: (0, import_i18n226.__)("Months ago") },
57500 { value: "years", label: (0, import_i18n226.__)("Years ago") }
57501 ]
57502 };
57503 function RelativeDateControl({
57504 className,
57505 data,
57506 field,
57507 onChange,
57508 hideLabelFromVision,
57509 operator
57510 }) {
57511 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
57512 const { id, label, getValue: getValue2, setValue } = field;
57513 const fieldValue = getValue2({ item: data });
57514 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
57515 const onChangeValue = (0, import_element180.useCallback)(
57516 (newValue) => onChange(
57517 setValue({
57518 item: data,
57519 value: { value: Number(newValue), unit }
57520 })
57521 ),
57522 [onChange, setValue, data, unit]
57523 );
57524 const onChangeUnit = (0, import_element180.useCallback)(
57525 (newUnit) => onChange(
57526 setValue({
57527 item: data,
57528 value: { value: relValue, unit: newUnit }
57529 })
57530 ),
57531 [onChange, setValue, data, relValue]
57532 );
57533 return /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
57534 import_components202.BaseControl,
57535 {
57536 id,
57537 className: clsx_default(className, "dataviews-controls__relative-date"),
57538 label,
57539 hideLabelFromVision,
57540 children: /* @__PURE__ */ (0, import_jsx_runtime348.jsxs)(Stack, { direction: "row", gap: "sm", children: [
57541 /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
57542 import_components202.__experimentalNumberControl,
57543 {
57544 __next40pxDefaultSize: true,
57545 className: "dataviews-controls__relative-date-number",
57546 spinControls: "none",
57547 min: 1,
57548 step: 1,
57549 value: relValue,
57550 onChange: onChangeValue
57551 }
57552 ),
57553 /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
57554 import_components202.SelectControl,
57555 {
57556 className: "dataviews-controls__relative-date-unit",
57557 __next40pxDefaultSize: true,
57558 label: (0, import_i18n226.__)("Unit"),
57559 value: unit,
57560 options,
57561 onChange: onChangeUnit,
57562 hideLabelFromVision: true
57563 }
57564 )
57565 ] })
57566 }
57567 );
57568 }
57569
57570 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
57571 var import_date11 = __toESM(require_date(), 1);
57572 function parseDateTime(dateTimeString) {
57573 if (!dateTimeString) {
57574 return null;
57575 }
57576 const parsed = (0, import_date11.getDate)(dateTimeString);
57577 return parsed && isValid(parsed) ? parsed : null;
57578 }
57579
57580 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
57581 var import_jsx_runtime349 = __toESM(require_jsx_runtime(), 1);
57582 var { DateCalendar, ValidatedInputControl } = unlock4(import_components203.privateApis);
57583 var formatDateTime = (value) => {
57584 if (!value) {
57585 return "";
57586 }
57587 return (0, import_date12.dateI18n)("Y-m-d\\TH:i", (0, import_date12.getDate)(value));
57588 };
57589 function CalendarDateTimeControl({
57590 data,
57591 field,
57592 onChange,
57593 hideLabelFromVision,
57594 markWhenOptional,
57595 validity
57596 }) {
57597 const { id, label, description, setValue, getValue: getValue2, isValid: isValid2 } = field;
57598 const fieldValue = getValue2({ item: data });
57599 const value = typeof fieldValue === "string" ? fieldValue : void 0;
57600 const [calendarMonth, setCalendarMonth] = (0, import_element181.useState)(() => {
57601 const parsedDate = parseDateTime(value);
57602 return parsedDate || /* @__PURE__ */ new Date();
57603 });
57604 const inputControlRef = (0, import_element181.useRef)(null);
57605 const validationTimeoutRef = (0, import_element181.useRef)(void 0);
57606 const previousFocusRef = (0, import_element181.useRef)(null);
57607 const onChangeCallback = (0, import_element181.useCallback)(
57608 (newValue) => onChange(setValue({ item: data, value: newValue })),
57609 [data, onChange, setValue]
57610 );
57611 (0, import_element181.useEffect)(() => {
57612 return () => {
57613 if (validationTimeoutRef.current) {
57614 clearTimeout(validationTimeoutRef.current);
57615 }
57616 };
57617 }, []);
57618 const onSelectDate = (0, import_element181.useCallback)(
57619 (newDate) => {
57620 let dateTimeValue;
57621 if (newDate) {
57622 const wpDate = (0, import_date12.dateI18n)("Y-m-d", newDate);
57623 let wpTime;
57624 if (value) {
57625 wpTime = (0, import_date12.dateI18n)("H:i", (0, import_date12.getDate)(value));
57626 } else {
57627 wpTime = (0, import_date12.dateI18n)("H:i", newDate);
57628 }
57629 const finalDateTime = (0, import_date12.getDate)(`${wpDate}T${wpTime}`);
57630 dateTimeValue = finalDateTime.toISOString();
57631 onChangeCallback(dateTimeValue);
57632 if (validationTimeoutRef.current) {
57633 clearTimeout(validationTimeoutRef.current);
57634 }
57635 } else {
57636 onChangeCallback(void 0);
57637 }
57638 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
57639 validationTimeoutRef.current = setTimeout(() => {
57640 if (inputControlRef.current) {
57641 inputControlRef.current.focus();
57642 inputControlRef.current.blur();
57643 onChangeCallback(dateTimeValue);
57644 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
57645 previousFocusRef.current.focus();
57646 }
57647 }
57648 }, 0);
57649 },
57650 [onChangeCallback, value]
57651 );
57652 const handleManualDateTimeChange = (0, import_element181.useCallback)(
57653 (newValue) => {
57654 if (newValue) {
57655 const dateTime = (0, import_date12.getDate)(newValue);
57656 onChangeCallback(dateTime.toISOString());
57657 const parsedDate = parseDateTime(dateTime.toISOString());
57658 if (parsedDate) {
57659 setCalendarMonth(parsedDate);
57660 }
57661 } else {
57662 onChangeCallback(void 0);
57663 }
57664 },
57665 [onChangeCallback]
57666 );
57667 const { format: fieldFormat } = field;
57668 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date12.getSettings)().l10n.startOfWeek;
57669 const {
57670 timezone: { string: timezoneString }
57671 } = (0, import_date12.getSettings)();
57672 let displayLabel = label;
57673 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
57674 displayLabel = `${label} (${(0, import_i18n227.__)("Required")})`;
57675 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
57676 displayLabel = `${label} (${(0, import_i18n227.__)("Optional")})`;
57677 }
57678 return /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(
57679 import_components203.BaseControl,
57680 {
57681 id,
57682 label: displayLabel,
57683 help: description,
57684 hideLabelFromVision,
57685 children: /* @__PURE__ */ (0, import_jsx_runtime349.jsxs)(Stack, { direction: "column", gap: "lg", children: [
57686 /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(
57687 DateCalendar,
57688 {
57689 style: { width: "100%" },
57690 selected: value ? parseDateTime(value) || void 0 : void 0,
57691 onSelect: onSelectDate,
57692 month: calendarMonth,
57693 onMonthChange: setCalendarMonth,
57694 timeZone: timezoneString || void 0,
57695 weekStartsOn
57696 }
57697 ),
57698 /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(
57699 ValidatedInputControl,
57700 {
57701 ref: inputControlRef,
57702 __next40pxDefaultSize: true,
57703 required: !!isValid2?.required,
57704 customValidity: getCustomValidity(isValid2, validity),
57705 type: "datetime-local",
57706 label: (0, import_i18n227.__)("Date time"),
57707 hideLabelFromVision: true,
57708 value: formatDateTime(value),
57709 onChange: handleManualDateTimeChange
57710 }
57711 )
57712 ] })
57713 }
57714 );
57715 }
57716 function DateTime({
57717 data,
57718 field,
57719 onChange,
57720 hideLabelFromVision,
57721 markWhenOptional,
57722 operator,
57723 validity
57724 }) {
57725 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
57726 return /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(
57727 RelativeDateControl,
57728 {
57729 className: "dataviews-controls__datetime",
57730 data,
57731 field,
57732 onChange,
57733 hideLabelFromVision,
57734 operator
57735 }
57736 );
57737 }
57738 return /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(
57739 CalendarDateTimeControl,
57740 {
57741 data,
57742 field,
57743 onChange,
57744 hideLabelFromVision,
57745 markWhenOptional,
57746 validity
57747 }
57748 );
57749 }
57750
57751 // packages/dataviews/build-module/components/dataform-controls/date.mjs
57752 var import_components204 = __toESM(require_components(), 1);
57753 var import_element182 = __toESM(require_element(), 1);
57754 var import_i18n228 = __toESM(require_i18n(), 1);
57755 var import_date13 = __toESM(require_date(), 1);
57756 var import_jsx_runtime350 = __toESM(require_jsx_runtime(), 1);
57757 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock4(import_components204.privateApis);
57758 var DATE_PRESETS = [
57759 {
57760 id: "today",
57761 label: (0, import_i18n228.__)("Today"),
57762 getValue: () => (0, import_date13.getDate)(null)
57763 },
57764 {
57765 id: "yesterday",
57766 label: (0, import_i18n228.__)("Yesterday"),
57767 getValue: () => {
57768 const today = (0, import_date13.getDate)(null);
57769 return subDays(today, 1);
57770 }
57771 },
57772 {
57773 id: "past-week",
57774 label: (0, import_i18n228.__)("Past week"),
57775 getValue: () => {
57776 const today = (0, import_date13.getDate)(null);
57777 return subDays(today, 7);
57778 }
57779 },
57780 {
57781 id: "past-month",
57782 label: (0, import_i18n228.__)("Past month"),
57783 getValue: () => {
57784 const today = (0, import_date13.getDate)(null);
57785 return subMonths(today, 1);
57786 }
57787 }
57788 ];
57789 var DATE_RANGE_PRESETS = [
57790 {
57791 id: "last-7-days",
57792 label: (0, import_i18n228.__)("Last 7 days"),
57793 getValue: () => {
57794 const today = (0, import_date13.getDate)(null);
57795 return [subDays(today, 7), today];
57796 }
57797 },
57798 {
57799 id: "last-30-days",
57800 label: (0, import_i18n228.__)("Last 30 days"),
57801 getValue: () => {
57802 const today = (0, import_date13.getDate)(null);
57803 return [subDays(today, 30), today];
57804 }
57805 },
57806 {
57807 id: "month-to-date",
57808 label: (0, import_i18n228.__)("Month to date"),
57809 getValue: () => {
57810 const today = (0, import_date13.getDate)(null);
57811 return [startOfMonth2(today), today];
57812 }
57813 },
57814 {
57815 id: "last-year",
57816 label: (0, import_i18n228.__)("Last year"),
57817 getValue: () => {
57818 const today = (0, import_date13.getDate)(null);
57819 return [subYears(today, 1), today];
57820 }
57821 },
57822 {
57823 id: "year-to-date",
57824 label: (0, import_i18n228.__)("Year to date"),
57825 getValue: () => {
57826 const today = (0, import_date13.getDate)(null);
57827 return [startOfYear(today), today];
57828 }
57829 }
57830 ];
57831 var parseDate2 = (dateString) => {
57832 if (!dateString) {
57833 return null;
57834 }
57835 const parsed = (0, import_date13.getDate)(dateString);
57836 return parsed && isValid(parsed) ? parsed : null;
57837 };
57838 var formatDate = (date) => {
57839 if (!date) {
57840 return "";
57841 }
57842 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
57843 };
57844 function ValidatedDateControl({
57845 field,
57846 validity,
57847 inputRefs,
57848 isTouched,
57849 setIsTouched,
57850 children
57851 }) {
57852 const { isValid: isValid2 } = field;
57853 const [customValidity, setCustomValidity] = (0, import_element182.useState)(void 0);
57854 const validateRefs = (0, import_element182.useCallback)(() => {
57855 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
57856 for (const ref of refs) {
57857 const input = ref.current;
57858 if (input && !input.validity.valid) {
57859 setCustomValidity({
57860 type: "invalid",
57861 message: input.validationMessage
57862 });
57863 return;
57864 }
57865 }
57866 setCustomValidity(void 0);
57867 }, [inputRefs]);
57868 (0, import_element182.useEffect)(() => {
57869 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
57870 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
57871 for (const ref of refs) {
57872 const input = ref.current;
57873 if (input) {
57874 input.setCustomValidity(
57875 result?.type === "invalid" && result.message ? result.message : ""
57876 );
57877 }
57878 }
57879 }, [inputRefs, isValid2, validity]);
57880 (0, import_element182.useEffect)(() => {
57881 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
57882 const handleInvalid = (event) => {
57883 event.preventDefault();
57884 setIsTouched(true);
57885 };
57886 for (const ref of refs) {
57887 ref.current?.addEventListener("invalid", handleInvalid);
57888 }
57889 return () => {
57890 for (const ref of refs) {
57891 ref.current?.removeEventListener("invalid", handleInvalid);
57892 }
57893 };
57894 }, [inputRefs, setIsTouched]);
57895 (0, import_element182.useEffect)(() => {
57896 if (!isTouched) {
57897 return;
57898 }
57899 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
57900 if (result) {
57901 setCustomValidity(result);
57902 } else {
57903 validateRefs();
57904 }
57905 }, [isTouched, isValid2, validity, validateRefs]);
57906 const onBlur = (event) => {
57907 if (isTouched) {
57908 return;
57909 }
57910 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
57911 setIsTouched(true);
57912 }
57913 };
57914 return /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)("div", { onBlur, children: [
57915 children,
57916 /* @__PURE__ */ (0, import_jsx_runtime350.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(
57917 "p",
57918 {
57919 className: clsx_default(
57920 "components-validated-control__indicator",
57921 customValidity.type === "invalid" ? "is-invalid" : void 0
57922 ),
57923 children: [
57924 /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
57925 import_components204.Icon,
57926 {
57927 className: "components-validated-control__indicator-icon",
57928 icon: error_default,
57929 size: 16,
57930 fill: "currentColor"
57931 }
57932 ),
57933 customValidity.message
57934 ]
57935 }
57936 ) })
57937 ] });
57938 }
57939 function CalendarDateControl({
57940 data,
57941 field,
57942 onChange,
57943 hideLabelFromVision,
57944 markWhenOptional,
57945 validity
57946 }) {
57947 const {
57948 id,
57949 label,
57950 setValue,
57951 getValue: getValue2,
57952 isValid: isValid2,
57953 format: fieldFormat
57954 } = field;
57955 const [selectedPresetId, setSelectedPresetId] = (0, import_element182.useState)(
57956 null
57957 );
57958 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date13.getSettings)().l10n.startOfWeek;
57959 const fieldValue = getValue2({ item: data });
57960 const value = typeof fieldValue === "string" ? fieldValue : void 0;
57961 const [calendarMonth, setCalendarMonth] = (0, import_element182.useState)(() => {
57962 const parsedDate = parseDate2(value);
57963 return parsedDate || /* @__PURE__ */ new Date();
57964 });
57965 const [isTouched, setIsTouched] = (0, import_element182.useState)(false);
57966 const validityTargetRef = (0, import_element182.useRef)(null);
57967 const onChangeCallback = (0, import_element182.useCallback)(
57968 (newValue) => onChange(setValue({ item: data, value: newValue })),
57969 [data, onChange, setValue]
57970 );
57971 const onSelectDate = (0, import_element182.useCallback)(
57972 (newDate) => {
57973 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
57974 onChangeCallback(dateValue);
57975 setSelectedPresetId(null);
57976 setIsTouched(true);
57977 },
57978 [onChangeCallback]
57979 );
57980 const handlePresetClick = (0, import_element182.useCallback)(
57981 (preset) => {
57982 const presetDate = preset.getValue();
57983 const dateValue = formatDate(presetDate);
57984 setCalendarMonth(presetDate);
57985 onChangeCallback(dateValue);
57986 setSelectedPresetId(preset.id);
57987 setIsTouched(true);
57988 },
57989 [onChangeCallback]
57990 );
57991 const handleManualDateChange = (0, import_element182.useCallback)(
57992 (newValue) => {
57993 onChangeCallback(newValue);
57994 if (newValue) {
57995 const parsedDate = parseDate2(newValue);
57996 if (parsedDate) {
57997 setCalendarMonth(parsedDate);
57998 }
57999 }
58000 setSelectedPresetId(null);
58001 setIsTouched(true);
58002 },
58003 [onChangeCallback]
58004 );
58005 const {
58006 timezone: { string: timezoneString }
58007 } = (0, import_date13.getSettings)();
58008 let displayLabel = label;
58009 if (isValid2?.required && !markWhenOptional) {
58010 displayLabel = `${label} (${(0, import_i18n228.__)("Required")})`;
58011 } else if (!isValid2?.required && markWhenOptional) {
58012 displayLabel = `${label} (${(0, import_i18n228.__)("Optional")})`;
58013 }
58014 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58015 ValidatedDateControl,
58016 {
58017 field,
58018 validity,
58019 inputRefs: validityTargetRef,
58020 isTouched,
58021 setIsTouched,
58022 children: /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58023 import_components204.BaseControl,
58024 {
58025 id,
58026 className: "dataviews-controls__date",
58027 label: displayLabel,
58028 hideLabelFromVision,
58029 children: /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(Stack, { direction: "column", gap: "lg", children: [
58030 /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(
58031 Stack,
58032 {
58033 direction: "row",
58034 gap: "sm",
58035 wrap: "wrap",
58036 justify: "flex-start",
58037 children: [
58038 DATE_PRESETS.map((preset) => {
58039 const isSelected = selectedPresetId === preset.id;
58040 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58041 import_components204.Button,
58042 {
58043 className: "dataviews-controls__date-preset",
58044 variant: "tertiary",
58045 isPressed: isSelected,
58046 size: "small",
58047 onClick: () => handlePresetClick(preset),
58048 children: preset.label
58049 },
58050 preset.id
58051 );
58052 }),
58053 /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58054 import_components204.Button,
58055 {
58056 className: "dataviews-controls__date-preset",
58057 variant: "tertiary",
58058 isPressed: !selectedPresetId,
58059 size: "small",
58060 disabled: !!selectedPresetId,
58061 accessibleWhenDisabled: false,
58062 children: (0, import_i18n228.__)("Custom")
58063 }
58064 )
58065 ]
58066 }
58067 ),
58068 /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58069 import_components204.__experimentalInputControl,
58070 {
58071 __next40pxDefaultSize: true,
58072 ref: validityTargetRef,
58073 type: "date",
58074 label: (0, import_i18n228.__)("Date"),
58075 hideLabelFromVision: true,
58076 value,
58077 onChange: handleManualDateChange,
58078 required: !!field.isValid?.required
58079 }
58080 ),
58081 /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58082 DateCalendar2,
58083 {
58084 style: { width: "100%" },
58085 selected: value ? parseDate2(value) || void 0 : void 0,
58086 onSelect: onSelectDate,
58087 month: calendarMonth,
58088 onMonthChange: setCalendarMonth,
58089 timeZone: timezoneString || void 0,
58090 weekStartsOn
58091 }
58092 )
58093 ] })
58094 }
58095 )
58096 }
58097 );
58098 }
58099 function CalendarDateRangeControl({
58100 data,
58101 field,
58102 onChange,
58103 hideLabelFromVision,
58104 markWhenOptional,
58105 validity
58106 }) {
58107 const { id, label, getValue: getValue2, setValue, format: fieldFormat } = field;
58108 let value;
58109 const fieldValue = getValue2({ item: data });
58110 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
58111 value = fieldValue;
58112 }
58113 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date13.getSettings)().l10n.startOfWeek;
58114 const onChangeCallback = (0, import_element182.useCallback)(
58115 (newValue) => {
58116 onChange(
58117 setValue({
58118 item: data,
58119 value: newValue
58120 })
58121 );
58122 },
58123 [data, onChange, setValue]
58124 );
58125 const [selectedPresetId, setSelectedPresetId] = (0, import_element182.useState)(
58126 null
58127 );
58128 const selectedRange = (0, import_element182.useMemo)(() => {
58129 if (!value) {
58130 return { from: void 0, to: void 0 };
58131 }
58132 const [from, to2] = value;
58133 return {
58134 from: parseDate2(from) || void 0,
58135 to: parseDate2(to2) || void 0
58136 };
58137 }, [value]);
58138 const [calendarMonth, setCalendarMonth] = (0, import_element182.useState)(() => {
58139 return selectedRange.from || /* @__PURE__ */ new Date();
58140 });
58141 const [isTouched, setIsTouched] = (0, import_element182.useState)(false);
58142 const fromInputRef = (0, import_element182.useRef)(null);
58143 const toInputRef = (0, import_element182.useRef)(null);
58144 const updateDateRange = (0, import_element182.useCallback)(
58145 (fromDate, toDate3) => {
58146 if (fromDate && toDate3) {
58147 onChangeCallback([
58148 formatDate(fromDate),
58149 formatDate(toDate3)
58150 ]);
58151 } else if (!fromDate && !toDate3) {
58152 onChangeCallback(void 0);
58153 }
58154 },
58155 [onChangeCallback]
58156 );
58157 const onSelectCalendarRange = (0, import_element182.useCallback)(
58158 (newRange) => {
58159 updateDateRange(newRange?.from, newRange?.to);
58160 setSelectedPresetId(null);
58161 setIsTouched(true);
58162 },
58163 [updateDateRange]
58164 );
58165 const handlePresetClick = (0, import_element182.useCallback)(
58166 (preset) => {
58167 const [startDate2, endDate] = preset.getValue();
58168 setCalendarMonth(startDate2);
58169 updateDateRange(startDate2, endDate);
58170 setSelectedPresetId(preset.id);
58171 setIsTouched(true);
58172 },
58173 [updateDateRange]
58174 );
58175 const handleManualDateChange = (0, import_element182.useCallback)(
58176 (fromOrTo, newValue) => {
58177 const [currentFrom, currentTo] = value || [
58178 void 0,
58179 void 0
58180 ];
58181 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
58182 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
58183 updateDateRange(updatedFrom, updatedTo);
58184 if (newValue) {
58185 const parsedDate = parseDate2(newValue);
58186 if (parsedDate) {
58187 setCalendarMonth(parsedDate);
58188 }
58189 }
58190 setSelectedPresetId(null);
58191 setIsTouched(true);
58192 },
58193 [value, updateDateRange]
58194 );
58195 const { timezone } = (0, import_date13.getSettings)();
58196 let displayLabel = label;
58197 if (field.isValid?.required && !markWhenOptional) {
58198 displayLabel = `${label} (${(0, import_i18n228.__)("Required")})`;
58199 } else if (!field.isValid?.required && markWhenOptional) {
58200 displayLabel = `${label} (${(0, import_i18n228.__)("Optional")})`;
58201 }
58202 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58203 ValidatedDateControl,
58204 {
58205 field,
58206 validity,
58207 inputRefs: [fromInputRef, toInputRef],
58208 isTouched,
58209 setIsTouched,
58210 children: /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58211 import_components204.BaseControl,
58212 {
58213 id,
58214 className: "dataviews-controls__date",
58215 label: displayLabel,
58216 hideLabelFromVision,
58217 children: /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(Stack, { direction: "column", gap: "lg", children: [
58218 /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(
58219 Stack,
58220 {
58221 direction: "row",
58222 gap: "sm",
58223 wrap: "wrap",
58224 justify: "flex-start",
58225 children: [
58226 DATE_RANGE_PRESETS.map((preset) => {
58227 const isSelected = selectedPresetId === preset.id;
58228 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58229 import_components204.Button,
58230 {
58231 className: "dataviews-controls__date-preset",
58232 variant: "tertiary",
58233 isPressed: isSelected,
58234 size: "small",
58235 onClick: () => handlePresetClick(preset),
58236 children: preset.label
58237 },
58238 preset.id
58239 );
58240 }),
58241 /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58242 import_components204.Button,
58243 {
58244 className: "dataviews-controls__date-preset",
58245 variant: "tertiary",
58246 isPressed: !selectedPresetId,
58247 size: "small",
58248 accessibleWhenDisabled: false,
58249 disabled: !!selectedPresetId,
58250 children: (0, import_i18n228.__)("Custom")
58251 }
58252 )
58253 ]
58254 }
58255 ),
58256 /* @__PURE__ */ (0, import_jsx_runtime350.jsxs)(
58257 Stack,
58258 {
58259 direction: "row",
58260 gap: "sm",
58261 justify: "space-between",
58262 className: "dataviews-controls__date-range-inputs",
58263 children: [
58264 /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58265 import_components204.__experimentalInputControl,
58266 {
58267 __next40pxDefaultSize: true,
58268 ref: fromInputRef,
58269 type: "date",
58270 label: (0, import_i18n228.__)("From"),
58271 hideLabelFromVision: true,
58272 value: value?.[0],
58273 onChange: (newValue) => handleManualDateChange("from", newValue),
58274 required: !!field.isValid?.required
58275 }
58276 ),
58277 /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58278 import_components204.__experimentalInputControl,
58279 {
58280 __next40pxDefaultSize: true,
58281 ref: toInputRef,
58282 type: "date",
58283 label: (0, import_i18n228.__)("To"),
58284 hideLabelFromVision: true,
58285 value: value?.[1],
58286 onChange: (newValue) => handleManualDateChange("to", newValue),
58287 required: !!field.isValid?.required
58288 }
58289 )
58290 ]
58291 }
58292 ),
58293 /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58294 DateRangeCalendar,
58295 {
58296 style: { width: "100%" },
58297 selected: selectedRange,
58298 onSelect: onSelectCalendarRange,
58299 month: calendarMonth,
58300 onMonthChange: setCalendarMonth,
58301 timeZone: timezone.string || void 0,
58302 weekStartsOn
58303 }
58304 )
58305 ] })
58306 }
58307 )
58308 }
58309 );
58310 }
58311 function DateControl({
58312 data,
58313 field,
58314 onChange,
58315 hideLabelFromVision,
58316 markWhenOptional,
58317 operator,
58318 validity
58319 }) {
58320 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
58321 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58322 RelativeDateControl,
58323 {
58324 className: "dataviews-controls__date",
58325 data,
58326 field,
58327 onChange,
58328 hideLabelFromVision,
58329 operator
58330 }
58331 );
58332 }
58333 if (operator === OPERATOR_BETWEEN) {
58334 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58335 CalendarDateRangeControl,
58336 {
58337 data,
58338 field,
58339 onChange,
58340 hideLabelFromVision,
58341 markWhenOptional,
58342 validity
58343 }
58344 );
58345 }
58346 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(
58347 CalendarDateControl,
58348 {
58349 data,
58350 field,
58351 onChange,
58352 hideLabelFromVision,
58353 markWhenOptional,
58354 validity
58355 }
58356 );
58357 }
58358
58359 // packages/dataviews/build-module/components/dataform-controls/select.mjs
58360 var import_components205 = __toESM(require_components(), 1);
58361 var import_element183 = __toESM(require_element(), 1);
58362 var import_jsx_runtime351 = __toESM(require_jsx_runtime(), 1);
58363 var { ValidatedSelectControl } = unlock4(import_components205.privateApis);
58364 function Select({
58365 data,
58366 field,
58367 onChange,
58368 hideLabelFromVision,
58369 markWhenOptional,
58370 validity
58371 }) {
58372 const { type, label, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
58373 const isMultiple = type === "array";
58374 const value = getValue2({ item: data }) ?? (isMultiple ? [] : "");
58375 const onChangeControl = (0, import_element183.useCallback)(
58376 (newValue) => onChange(setValue({ item: data, value: newValue })),
58377 [data, onChange, setValue]
58378 );
58379 const { elements: elements2, isLoading } = useElements({
58380 elements: field.elements,
58381 getElements: field.getElements
58382 });
58383 if (isLoading) {
58384 return /* @__PURE__ */ (0, import_jsx_runtime351.jsx)(import_components205.Spinner, {});
58385 }
58386 return /* @__PURE__ */ (0, import_jsx_runtime351.jsx)(
58387 ValidatedSelectControl,
58388 {
58389 required: !!field.isValid?.required,
58390 markWhenOptional,
58391 customValidity: getCustomValidity(isValid2, validity),
58392 label,
58393 value,
58394 help: description,
58395 options: elements2,
58396 onChange: onChangeControl,
58397 __next40pxDefaultSize: true,
58398 hideLabelFromVision,
58399 multiple: isMultiple
58400 }
58401 );
58402 }
58403
58404 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
58405 var import_jsx_runtime352 = __toESM(require_jsx_runtime(), 1);
58406 var ELEMENTS_THRESHOLD = 10;
58407 function AdaptiveSelect(props) {
58408 const { field } = props;
58409 const { elements: elements2 } = useElements({
58410 elements: field.elements,
58411 getElements: field.getElements
58412 });
58413 if (elements2.length >= ELEMENTS_THRESHOLD) {
58414 return /* @__PURE__ */ (0, import_jsx_runtime352.jsx)(Combobox, { ...props });
58415 }
58416 return /* @__PURE__ */ (0, import_jsx_runtime352.jsx)(Select, { ...props });
58417 }
58418
58419 // packages/dataviews/build-module/components/dataform-controls/email.mjs
58420 var import_components207 = __toESM(require_components(), 1);
58421
58422 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
58423 var import_components206 = __toESM(require_components(), 1);
58424 var import_element184 = __toESM(require_element(), 1);
58425 var import_jsx_runtime353 = __toESM(require_jsx_runtime(), 1);
58426 var { ValidatedInputControl: ValidatedInputControl2 } = unlock4(import_components206.privateApis);
58427 function ValidatedText({
58428 data,
58429 field,
58430 onChange,
58431 hideLabelFromVision,
58432 markWhenOptional,
58433 type,
58434 prefix: prefix2,
58435 suffix,
58436 validity
58437 }) {
58438 const { label, placeholder, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
58439 const value = getValue2({ item: data });
58440 const onChangeControl = (0, import_element184.useCallback)(
58441 (newValue) => onChange(
58442 setValue({
58443 item: data,
58444 value: newValue
58445 })
58446 ),
58447 [data, setValue, onChange]
58448 );
58449 return /* @__PURE__ */ (0, import_jsx_runtime353.jsx)(
58450 ValidatedInputControl2,
58451 {
58452 required: !!isValid2.required,
58453 markWhenOptional,
58454 customValidity: getCustomValidity(isValid2, validity),
58455 label,
58456 placeholder,
58457 value: value ?? "",
58458 help: description,
58459 onChange: onChangeControl,
58460 hideLabelFromVision,
58461 type,
58462 prefix: prefix2,
58463 suffix,
58464 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
58465 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
58466 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
58467 __next40pxDefaultSize: true
58468 }
58469 );
58470 }
58471
58472 // packages/dataviews/build-module/components/dataform-controls/email.mjs
58473 var import_jsx_runtime354 = __toESM(require_jsx_runtime(), 1);
58474 function Email({
58475 data,
58476 field,
58477 onChange,
58478 hideLabelFromVision,
58479 markWhenOptional,
58480 validity
58481 }) {
58482 return /* @__PURE__ */ (0, import_jsx_runtime354.jsx)(
58483 ValidatedText,
58484 {
58485 ...{
58486 data,
58487 field,
58488 onChange,
58489 hideLabelFromVision,
58490 markWhenOptional,
58491 validity,
58492 type: "email",
58493 prefix: /* @__PURE__ */ (0, import_jsx_runtime354.jsx)(import_components207.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime354.jsx)(import_components207.Icon, { icon: envelope_default }) })
58494 }
58495 }
58496 );
58497 }
58498
58499 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
58500 var import_components208 = __toESM(require_components(), 1);
58501 var import_jsx_runtime355 = __toESM(require_jsx_runtime(), 1);
58502 function Telephone({
58503 data,
58504 field,
58505 onChange,
58506 hideLabelFromVision,
58507 markWhenOptional,
58508 validity
58509 }) {
58510 return /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(
58511 ValidatedText,
58512 {
58513 ...{
58514 data,
58515 field,
58516 onChange,
58517 hideLabelFromVision,
58518 markWhenOptional,
58519 validity,
58520 type: "tel",
58521 prefix: /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(import_components208.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(import_components208.Icon, { icon: mobile_default }) })
58522 }
58523 }
58524 );
58525 }
58526
58527 // packages/dataviews/build-module/components/dataform-controls/url.mjs
58528 var import_components209 = __toESM(require_components(), 1);
58529 var import_jsx_runtime356 = __toESM(require_jsx_runtime(), 1);
58530 function Url({
58531 data,
58532 field,
58533 onChange,
58534 hideLabelFromVision,
58535 markWhenOptional,
58536 validity
58537 }) {
58538 return /* @__PURE__ */ (0, import_jsx_runtime356.jsx)(
58539 ValidatedText,
58540 {
58541 ...{
58542 data,
58543 field,
58544 onChange,
58545 hideLabelFromVision,
58546 markWhenOptional,
58547 validity,
58548 type: "url",
58549 prefix: /* @__PURE__ */ (0, import_jsx_runtime356.jsx)(import_components209.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime356.jsx)(import_components209.Icon, { icon: link_default }) })
58550 }
58551 }
58552 );
58553 }
58554
58555 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
58556 var import_components210 = __toESM(require_components(), 1);
58557 var import_element185 = __toESM(require_element(), 1);
58558 var import_i18n229 = __toESM(require_i18n(), 1);
58559 var import_jsx_runtime357 = __toESM(require_jsx_runtime(), 1);
58560 var { ValidatedNumberControl } = unlock4(import_components210.privateApis);
58561 function toNumberOrEmpty(value) {
58562 if (value === "" || value === void 0) {
58563 return "";
58564 }
58565 const number = Number(value);
58566 return Number.isFinite(number) ? number : "";
58567 }
58568 function BetweenControls({
58569 value,
58570 onChange,
58571 hideLabelFromVision,
58572 step
58573 }) {
58574 const [min2 = "", max2 = ""] = value;
58575 const onChangeMin = (0, import_element185.useCallback)(
58576 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
58577 [onChange, max2]
58578 );
58579 const onChangeMax = (0, import_element185.useCallback)(
58580 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
58581 [onChange, min2]
58582 );
58583 return /* @__PURE__ */ (0, import_jsx_runtime357.jsx)(
58584 import_components210.BaseControl,
58585 {
58586 help: (0, import_i18n229.__)("The max. value must be greater than the min. value."),
58587 children: /* @__PURE__ */ (0, import_jsx_runtime357.jsxs)(import_components210.Flex, { direction: "row", gap: 4, children: [
58588 /* @__PURE__ */ (0, import_jsx_runtime357.jsx)(
58589 import_components210.__experimentalNumberControl,
58590 {
58591 label: (0, import_i18n229.__)("Min."),
58592 value: min2,
58593 max: max2 ? Number(max2) - step : void 0,
58594 onChange: onChangeMin,
58595 __next40pxDefaultSize: true,
58596 hideLabelFromVision,
58597 step
58598 }
58599 ),
58600 /* @__PURE__ */ (0, import_jsx_runtime357.jsx)(
58601 import_components210.__experimentalNumberControl,
58602 {
58603 label: (0, import_i18n229.__)("Max."),
58604 value: max2,
58605 min: min2 ? Number(min2) + step : void 0,
58606 onChange: onChangeMax,
58607 __next40pxDefaultSize: true,
58608 hideLabelFromVision,
58609 step
58610 }
58611 )
58612 ] })
58613 }
58614 );
58615 }
58616 function ValidatedNumber({
58617 data,
58618 field,
58619 onChange,
58620 hideLabelFromVision,
58621 markWhenOptional,
58622 operator,
58623 validity
58624 }) {
58625 const decimals = field.format?.decimals ?? 0;
58626 const step = Math.pow(10, Math.abs(decimals) * -1);
58627 const { label, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
58628 const value = getValue2({ item: data }) ?? "";
58629 const onChangeControl = (0, import_element185.useCallback)(
58630 (newValue) => {
58631 onChange(
58632 setValue({
58633 item: data,
58634 // Do not convert an empty string or undefined to a number,
58635 // otherwise there's a mismatch between the UI control (empty)
58636 // and the data relied by onChange (0).
58637 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
58638 })
58639 );
58640 },
58641 [data, onChange, setValue]
58642 );
58643 const onChangeBetweenControls = (0, import_element185.useCallback)(
58644 (newValue) => {
58645 onChange(
58646 setValue({
58647 item: data,
58648 value: newValue
58649 })
58650 );
58651 },
58652 [data, onChange, setValue]
58653 );
58654 if (operator === OPERATOR_BETWEEN) {
58655 let valueBetween = ["", ""];
58656 if (Array.isArray(value) && value.length === 2 && value.every(
58657 (element) => typeof element === "number" || element === ""
58658 )) {
58659 valueBetween = value;
58660 }
58661 return /* @__PURE__ */ (0, import_jsx_runtime357.jsx)(
58662 BetweenControls,
58663 {
58664 value: valueBetween,
58665 onChange: onChangeBetweenControls,
58666 hideLabelFromVision,
58667 step
58668 }
58669 );
58670 }
58671 return /* @__PURE__ */ (0, import_jsx_runtime357.jsx)(
58672 ValidatedNumberControl,
58673 {
58674 required: !!isValid2.required,
58675 markWhenOptional,
58676 customValidity: getCustomValidity(isValid2, validity),
58677 label,
58678 help: description,
58679 value,
58680 onChange: onChangeControl,
58681 __next40pxDefaultSize: true,
58682 hideLabelFromVision,
58683 step,
58684 min: isValid2.min ? isValid2.min.constraint : void 0,
58685 max: isValid2.max ? isValid2.max.constraint : void 0
58686 }
58687 );
58688 }
58689
58690 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
58691 var import_jsx_runtime358 = __toESM(require_jsx_runtime(), 1);
58692 function Integer(props) {
58693 return /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(ValidatedNumber, { ...props });
58694 }
58695
58696 // packages/dataviews/build-module/components/dataform-controls/number.mjs
58697 var import_jsx_runtime359 = __toESM(require_jsx_runtime(), 1);
58698 function Number2(props) {
58699 return /* @__PURE__ */ (0, import_jsx_runtime359.jsx)(ValidatedNumber, { ...props });
58700 }
58701
58702 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
58703 var import_components211 = __toESM(require_components(), 1);
58704 var import_element186 = __toESM(require_element(), 1);
58705 var import_jsx_runtime360 = __toESM(require_jsx_runtime(), 1);
58706 var { ValidatedRadioControl } = unlock4(import_components211.privateApis);
58707 function Radio({
58708 data,
58709 field,
58710 onChange,
58711 hideLabelFromVision,
58712 markWhenOptional,
58713 validity
58714 }) {
58715 const { label, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
58716 const { elements: elements2, isLoading } = useElements({
58717 elements: field.elements,
58718 getElements: field.getElements
58719 });
58720 const value = getValue2({ item: data });
58721 const onChangeControl = (0, import_element186.useCallback)(
58722 (newValue) => onChange(setValue({ item: data, value: newValue })),
58723 [data, onChange, setValue]
58724 );
58725 if (isLoading) {
58726 return /* @__PURE__ */ (0, import_jsx_runtime360.jsx)(import_components211.Spinner, {});
58727 }
58728 return /* @__PURE__ */ (0, import_jsx_runtime360.jsx)(
58729 ValidatedRadioControl,
58730 {
58731 required: !!field.isValid?.required,
58732 markWhenOptional,
58733 customValidity: getCustomValidity(isValid2, validity),
58734 label,
58735 help: description,
58736 onChange: onChangeControl,
58737 options: elements2,
58738 selected: value,
58739 hideLabelFromVision
58740 }
58741 );
58742 }
58743
58744 // packages/dataviews/build-module/components/dataform-controls/text.mjs
58745 var import_element187 = __toESM(require_element(), 1);
58746 var import_jsx_runtime361 = __toESM(require_jsx_runtime(), 1);
58747 function Text21({
58748 data,
58749 field,
58750 onChange,
58751 hideLabelFromVision,
58752 markWhenOptional,
58753 config: config2,
58754 validity
58755 }) {
58756 const { prefix: prefix2, suffix } = config2 || {};
58757 return /* @__PURE__ */ (0, import_jsx_runtime361.jsx)(
58758 ValidatedText,
58759 {
58760 ...{
58761 data,
58762 field,
58763 onChange,
58764 hideLabelFromVision,
58765 markWhenOptional,
58766 validity,
58767 prefix: prefix2 ? (0, import_element187.createElement)(prefix2) : void 0,
58768 suffix: suffix ? (0, import_element187.createElement)(suffix) : void 0
58769 }
58770 }
58771 );
58772 }
58773
58774 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
58775 var import_components212 = __toESM(require_components(), 1);
58776 var import_element188 = __toESM(require_element(), 1);
58777 var import_jsx_runtime362 = __toESM(require_jsx_runtime(), 1);
58778 var { ValidatedToggleControl } = unlock4(import_components212.privateApis);
58779 function Toggle({
58780 field,
58781 onChange,
58782 data,
58783 hideLabelFromVision,
58784 markWhenOptional,
58785 validity
58786 }) {
58787 const { label, description, getValue: getValue2, setValue, isValid: isValid2 } = field;
58788 const onChangeControl = (0, import_element188.useCallback)(() => {
58789 onChange(
58790 setValue({ item: data, value: !getValue2({ item: data }) })
58791 );
58792 }, [onChange, setValue, data, getValue2]);
58793 return /* @__PURE__ */ (0, import_jsx_runtime362.jsx)(
58794 ValidatedToggleControl,
58795 {
58796 required: !!isValid2.required,
58797 markWhenOptional,
58798 customValidity: getCustomValidity(isValid2, validity),
58799 hidden: hideLabelFromVision,
58800 label,
58801 help: description,
58802 checked: getValue2({ item: data }),
58803 onChange: onChangeControl
58804 }
58805 );
58806 }
58807
58808 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
58809 var import_components213 = __toESM(require_components(), 1);
58810 var import_element189 = __toESM(require_element(), 1);
58811 var import_jsx_runtime363 = __toESM(require_jsx_runtime(), 1);
58812 var { ValidatedTextareaControl } = unlock4(import_components213.privateApis);
58813 function Textarea2({
58814 data,
58815 field,
58816 onChange,
58817 hideLabelFromVision,
58818 markWhenOptional,
58819 config: config2,
58820 validity
58821 }) {
58822 const { rows = 4 } = config2 || {};
58823 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
58824 const value = field.getValue({ item: data });
58825 const onChangeControl = (0, import_element189.useCallback)(
58826 (newValue) => onChange(setValue({ item: data, value: newValue })),
58827 [data, onChange, setValue]
58828 );
58829 return /* @__PURE__ */ (0, import_jsx_runtime363.jsx)(
58830 ValidatedTextareaControl,
58831 {
58832 required: !!isValid2.required,
58833 markWhenOptional,
58834 customValidity: getCustomValidity(isValid2, validity),
58835 label,
58836 placeholder,
58837 value: value ?? "",
58838 help: description,
58839 onChange: onChangeControl,
58840 rows,
58841 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
58842 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
58843 __next40pxDefaultSize: true,
58844 hideLabelFromVision
58845 }
58846 );
58847 }
58848
58849 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
58850 var import_components214 = __toESM(require_components(), 1);
58851 var import_element190 = __toESM(require_element(), 1);
58852 var import_jsx_runtime364 = __toESM(require_jsx_runtime(), 1);
58853 var { ValidatedToggleGroupControl } = unlock4(import_components214.privateApis);
58854 function ToggleGroup({
58855 data,
58856 field,
58857 onChange,
58858 hideLabelFromVision,
58859 markWhenOptional,
58860 validity
58861 }) {
58862 const { getValue: getValue2, setValue, isValid: isValid2 } = field;
58863 const value = getValue2({ item: data });
58864 const onChangeControl = (0, import_element190.useCallback)(
58865 (newValue) => onChange(setValue({ item: data, value: newValue })),
58866 [data, onChange, setValue]
58867 );
58868 const { elements: elements2, isLoading } = useElements({
58869 elements: field.elements,
58870 getElements: field.getElements
58871 });
58872 if (isLoading) {
58873 return /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(import_components214.Spinner, {});
58874 }
58875 if (elements2.length === 0) {
58876 return null;
58877 }
58878 const selectedOption = elements2.find((el) => el.value === value);
58879 return /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(
58880 ValidatedToggleGroupControl,
58881 {
58882 required: !!field.isValid?.required,
58883 markWhenOptional,
58884 customValidity: getCustomValidity(isValid2, validity),
58885 __next40pxDefaultSize: true,
58886 isBlock: true,
58887 label: field.label,
58888 help: selectedOption?.description || field.description,
58889 onChange: onChangeControl,
58890 value,
58891 hideLabelFromVision,
58892 children: elements2.map((el) => /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(
58893 import_components214.__experimentalToggleGroupControlOption,
58894 {
58895 label: el.label,
58896 value: el.value
58897 },
58898 el.value
58899 ))
58900 }
58901 );
58902 }
58903
58904 // packages/dataviews/build-module/components/dataform-controls/array.mjs
58905 var import_components215 = __toESM(require_components(), 1);
58906 var import_element191 = __toESM(require_element(), 1);
58907 var import_jsx_runtime365 = __toESM(require_jsx_runtime(), 1);
58908 var { ValidatedFormTokenField } = unlock4(import_components215.privateApis);
58909 function ArrayControl({
58910 data,
58911 field,
58912 onChange,
58913 hideLabelFromVision,
58914 markWhenOptional,
58915 validity
58916 }) {
58917 const { label, placeholder, getValue: getValue2, setValue, isValid: isValid2 } = field;
58918 const value = getValue2({ item: data });
58919 const { elements: elements2, isLoading } = useElements({
58920 elements: field.elements,
58921 getElements: field.getElements
58922 });
58923 const arrayValueAsElements = (0, import_element191.useMemo)(
58924 () => Array.isArray(value) ? value.map((token) => {
58925 const element = elements2?.find(
58926 (suggestion) => suggestion.value === token
58927 );
58928 return element || { value: token, label: token };
58929 }) : [],
58930 [value, elements2]
58931 );
58932 const onChangeControl = (0, import_element191.useCallback)(
58933 (tokens) => {
58934 const valueTokens = tokens.map((token) => {
58935 if (typeof token === "object" && "value" in token) {
58936 return token.value;
58937 }
58938 return token;
58939 });
58940 onChange(setValue({ item: data, value: valueTokens }));
58941 },
58942 [onChange, setValue, data]
58943 );
58944 if (isLoading) {
58945 return /* @__PURE__ */ (0, import_jsx_runtime365.jsx)(import_components215.Spinner, {});
58946 }
58947 return /* @__PURE__ */ (0, import_jsx_runtime365.jsx)(
58948 ValidatedFormTokenField,
58949 {
58950 required: !!isValid2?.required,
58951 markWhenOptional,
58952 customValidity: getCustomValidity(isValid2, validity),
58953 label: hideLabelFromVision ? void 0 : label,
58954 value: arrayValueAsElements,
58955 onChange: onChangeControl,
58956 placeholder,
58957 suggestions: elements2?.map((element) => element.value),
58958 __experimentalValidateInput: (token) => {
58959 if (field.isValid?.elements && elements2) {
58960 return elements2.some(
58961 (element) => element.value === token || element.label === token
58962 );
58963 }
58964 return true;
58965 },
58966 __experimentalExpandOnFocus: elements2 && elements2.length > 0,
58967 __experimentalShowHowTo: !field.isValid?.elements,
58968 displayTransform: (token) => {
58969 if (typeof token === "object" && "label" in token) {
58970 return token.label;
58971 }
58972 if (typeof token === "string" && elements2) {
58973 const element = elements2.find(
58974 (el) => el.value === token
58975 );
58976 return element?.label || token;
58977 }
58978 return token;
58979 },
58980 __experimentalRenderItem: ({ item }) => {
58981 if (typeof item === "string" && elements2) {
58982 const element = elements2.find(
58983 (el) => el.value === item
58984 );
58985 return /* @__PURE__ */ (0, import_jsx_runtime365.jsx)("span", { children: element?.label || item });
58986 }
58987 return /* @__PURE__ */ (0, import_jsx_runtime365.jsx)("span", { children: item });
58988 }
58989 }
58990 );
58991 }
58992
58993 // packages/dataviews/build-module/components/dataform-controls/color.mjs
58994 var import_components216 = __toESM(require_components(), 1);
58995 var import_element192 = __toESM(require_element(), 1);
58996 var import_i18n230 = __toESM(require_i18n(), 1);
58997 var import_jsx_runtime366 = __toESM(require_jsx_runtime(), 1);
58998 var { ValidatedInputControl: ValidatedInputControl3 } = unlock4(import_components216.privateApis);
58999 var ColorPickerDropdown = ({
59000 color,
59001 onColorChange
59002 }) => {
59003 const validColor = color && w2(color).isValid() ? color : "#ffffff";
59004 return /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(
59005 import_components216.Dropdown,
59006 {
59007 className: "dataviews-controls__color-picker-dropdown",
59008 popoverProps: { resize: false },
59009 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(
59010 import_components216.Button,
59011 {
59012 onClick: onToggle,
59013 "aria-label": (0, import_i18n230.__)("Open color picker"),
59014 size: "small",
59015 icon: () => /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(import_components216.ColorIndicator, { colorValue: validColor })
59016 }
59017 ),
59018 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(import_components216.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(
59019 import_components216.ColorPicker,
59020 {
59021 color: validColor,
59022 onChange: onColorChange,
59023 enableAlpha: true
59024 }
59025 ) })
59026 }
59027 );
59028 };
59029 function Color({
59030 data,
59031 field,
59032 onChange,
59033 hideLabelFromVision,
59034 markWhenOptional,
59035 validity
59036 }) {
59037 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
59038 const value = field.getValue({ item: data }) || "";
59039 const handleColorChange = (0, import_element192.useCallback)(
59040 (newColor) => {
59041 onChange(setValue({ item: data, value: newColor }));
59042 },
59043 [data, onChange, setValue]
59044 );
59045 const handleInputChange = (0, import_element192.useCallback)(
59046 (newValue) => {
59047 onChange(setValue({ item: data, value: newValue || "" }));
59048 },
59049 [data, onChange, setValue]
59050 );
59051 return /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(
59052 ValidatedInputControl3,
59053 {
59054 required: !!field.isValid?.required,
59055 markWhenOptional,
59056 customValidity: getCustomValidity(isValid2, validity),
59057 label,
59058 placeholder,
59059 value,
59060 help: description,
59061 onChange: handleInputChange,
59062 hideLabelFromVision,
59063 type: "text",
59064 prefix: /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(import_components216.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(
59065 ColorPickerDropdown,
59066 {
59067 color: value,
59068 onColorChange: handleColorChange
59069 }
59070 ) })
59071 }
59072 );
59073 }
59074
59075 // packages/dataviews/build-module/components/dataform-controls/password.mjs
59076 var import_components217 = __toESM(require_components(), 1);
59077 var import_element193 = __toESM(require_element(), 1);
59078 var import_i18n231 = __toESM(require_i18n(), 1);
59079 var import_jsx_runtime367 = __toESM(require_jsx_runtime(), 1);
59080 function Password({
59081 data,
59082 field,
59083 onChange,
59084 hideLabelFromVision,
59085 markWhenOptional,
59086 validity
59087 }) {
59088 const [isVisible, setIsVisible] = (0, import_element193.useState)(false);
59089 const toggleVisibility = (0, import_element193.useCallback)(() => {
59090 setIsVisible((prev) => !prev);
59091 }, []);
59092 return /* @__PURE__ */ (0, import_jsx_runtime367.jsx)(
59093 ValidatedText,
59094 {
59095 ...{
59096 data,
59097 field,
59098 onChange,
59099 hideLabelFromVision,
59100 markWhenOptional,
59101 validity,
59102 type: isVisible ? "text" : "password",
59103 suffix: /* @__PURE__ */ (0, import_jsx_runtime367.jsx)(import_components217.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime367.jsx)(
59104 import_components217.Button,
59105 {
59106 icon: isVisible ? unseen_default : seen_default,
59107 onClick: toggleVisibility,
59108 size: "small",
59109 label: isVisible ? (0, import_i18n231.__)("Hide password") : (0, import_i18n231.__)("Show password")
59110 }
59111 ) })
59112 }
59113 }
59114 );
59115 }
59116
59117 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
59118 function hasElements(field) {
59119 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
59120 }
59121
59122 // packages/dataviews/build-module/components/dataform-controls/index.mjs
59123 var import_jsx_runtime368 = __toESM(require_jsx_runtime(), 1);
59124 var FORM_CONTROLS = {
59125 adaptiveSelect: AdaptiveSelect,
59126 array: ArrayControl,
59127 checkbox: Checkbox,
59128 color: Color,
59129 combobox: Combobox,
59130 datetime: DateTime,
59131 date: DateControl,
59132 email: Email,
59133 telephone: Telephone,
59134 url: Url,
59135 integer: Integer,
59136 number: Number2,
59137 password: Password,
59138 radio: Radio,
59139 select: Select,
59140 text: Text21,
59141 toggle: Toggle,
59142 textarea: Textarea2,
59143 toggleGroup: ToggleGroup
59144 };
59145 function isEditConfig(value) {
59146 return value && typeof value === "object" && typeof value.control === "string";
59147 }
59148 function createConfiguredControl(config2) {
59149 const { control, ...controlConfig } = config2;
59150 const BaseControlType = getControlByType(control);
59151 if (BaseControlType === null) {
59152 return null;
59153 }
59154 return function ConfiguredControl(props) {
59155 return /* @__PURE__ */ (0, import_jsx_runtime368.jsx)(BaseControlType, { ...props, config: controlConfig });
59156 };
59157 }
59158 function getControl(field, fallback) {
59159 if (typeof field.Edit === "function") {
59160 return field.Edit;
59161 }
59162 if (typeof field.Edit === "string") {
59163 return getControlByType(field.Edit);
59164 }
59165 if (isEditConfig(field.Edit)) {
59166 return createConfiguredControl(field.Edit);
59167 }
59168 if (hasElements(field) && field.type !== "array") {
59169 return getControlByType("adaptiveSelect");
59170 }
59171 if (fallback === null) {
59172 return null;
59173 }
59174 return getControlByType(fallback);
59175 }
59176 function getControlByType(type) {
59177 if (Object.keys(FORM_CONTROLS).includes(type)) {
59178 return FORM_CONTROLS[type];
59179 }
59180 return null;
59181 }
59182
59183 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
59184 function getFilterBy(field, defaultOperators, validOperators) {
59185 if (field.filterBy === false) {
59186 return false;
59187 }
59188 const operators = field.filterBy?.operators?.filter(
59189 (op) => validOperators.includes(op)
59190 ) ?? defaultOperators;
59191 if (operators.length === 0) {
59192 return false;
59193 }
59194 return {
59195 isPrimary: !!field.filterBy?.isPrimary,
59196 operators
59197 };
59198 }
59199 var get_filter_by_default = getFilterBy;
59200
59201 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
59202 var getValueFromId = (id) => ({ item }) => {
59203 const path = id.split(".");
59204 let value = item;
59205 for (const segment of path) {
59206 if (value.hasOwnProperty(segment)) {
59207 value = value[segment];
59208 } else {
59209 value = void 0;
59210 }
59211 }
59212 return value;
59213 };
59214 var get_value_from_id_default = getValueFromId;
59215
59216 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
59217 var setValueFromId = (id) => ({ value }) => {
59218 const path = id.split(".");
59219 const result = {};
59220 let current = result;
59221 for (const segment of path.slice(0, -1)) {
59222 current[segment] = {};
59223 current = current[segment];
59224 }
59225 current[path.at(-1)] = value;
59226 return result;
59227 };
59228 var set_value_from_id_default = setValueFromId;
59229
59230 // packages/dataviews/build-module/field-types/email.mjs
59231 var import_i18n232 = __toESM(require_i18n(), 1);
59232
59233 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
59234 function RenderFromElements({
59235 item,
59236 field
59237 }) {
59238 const { elements: elements2, isLoading } = useElements({
59239 elements: field.elements,
59240 getElements: field.getElements
59241 });
59242 const value = field.getValue({ item });
59243 if (isLoading) {
59244 return value;
59245 }
59246 if (elements2.length === 0) {
59247 return value;
59248 }
59249 return elements2?.find((element) => element.value === value)?.label || field.getValue({ item });
59250 }
59251
59252 // packages/dataviews/build-module/field-types/utils/render-default.mjs
59253 var import_jsx_runtime369 = __toESM(require_jsx_runtime(), 1);
59254 function render({
59255 item,
59256 field
59257 }) {
59258 if (field.hasElements) {
59259 return /* @__PURE__ */ (0, import_jsx_runtime369.jsx)(RenderFromElements, { item, field });
59260 }
59261 return field.getValueFormatted({ item, field });
59262 }
59263
59264 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
59265 var sort_text_default = (a3, b3, direction) => {
59266 return direction === "asc" ? a3.localeCompare(b3) : b3.localeCompare(a3);
59267 };
59268
59269 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
59270 function isValidRequired(item, field) {
59271 const value = field.getValue({ item });
59272 return ![void 0, "", null].includes(value);
59273 }
59274
59275 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
59276 function isValidMinLength(item, field) {
59277 if (typeof field.isValid.minLength?.constraint !== "number") {
59278 return false;
59279 }
59280 const value = field.getValue({ item });
59281 if ([void 0, "", null].includes(value)) {
59282 return true;
59283 }
59284 return String(value).length >= field.isValid.minLength.constraint;
59285 }
59286
59287 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
59288 function isValidMaxLength(item, field) {
59289 if (typeof field.isValid.maxLength?.constraint !== "number") {
59290 return false;
59291 }
59292 const value = field.getValue({ item });
59293 if ([void 0, "", null].includes(value)) {
59294 return true;
59295 }
59296 return String(value).length <= field.isValid.maxLength.constraint;
59297 }
59298
59299 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
59300 function isValidPattern(item, field) {
59301 if (field.isValid.pattern?.constraint === void 0) {
59302 return true;
59303 }
59304 try {
59305 const regexp = new RegExp(field.isValid.pattern.constraint);
59306 const value = field.getValue({ item });
59307 if ([void 0, "", null].includes(value)) {
59308 return true;
59309 }
59310 return regexp.test(String(value));
59311 } catch {
59312 return false;
59313 }
59314 }
59315
59316 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
59317 function isValidElements(item, field) {
59318 const elements2 = field.elements ?? [];
59319 const validValues = elements2.map((el) => el.value);
59320 if (validValues.length === 0) {
59321 return true;
59322 }
59323 const value = field.getValue({ item });
59324 return [].concat(value).every((v3) => validValues.includes(v3));
59325 }
59326
59327 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
59328 function getValueFormatted({
59329 item,
59330 field
59331 }) {
59332 return field.getValue({ item });
59333 }
59334 var get_value_formatted_default_default = getValueFormatted;
59335
59336 // packages/dataviews/build-module/field-types/email.mjs
59337 var emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
59338 function isValidCustom(item, field) {
59339 const value = field.getValue({ item });
59340 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
59341 return (0, import_i18n232.__)("Value must be a valid email address.");
59342 }
59343 return null;
59344 }
59345 var email_default = {
59346 type: "email",
59347 render,
59348 Edit: "email",
59349 sort: sort_text_default,
59350 enableSorting: true,
59351 enableGlobalSearch: false,
59352 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
59353 validOperators: [
59354 OPERATOR_IS,
59355 OPERATOR_IS_NOT,
59356 OPERATOR_CONTAINS,
59357 OPERATOR_NOT_CONTAINS,
59358 OPERATOR_STARTS_WITH,
59359 // Multiple selection
59360 OPERATOR_IS_ANY2,
59361 OPERATOR_IS_NONE,
59362 OPERATOR_IS_ALL,
59363 OPERATOR_IS_NOT_ALL
59364 ],
59365 format: {},
59366 getValueFormatted: get_value_formatted_default_default,
59367 validate: {
59368 required: isValidRequired,
59369 pattern: isValidPattern,
59370 minLength: isValidMinLength,
59371 maxLength: isValidMaxLength,
59372 elements: isValidElements,
59373 custom: isValidCustom
59374 }
59375 };
59376
59377 // packages/dataviews/build-module/field-types/integer.mjs
59378 var import_i18n233 = __toESM(require_i18n(), 1);
59379
59380 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
59381 var sort_number_default = (a3, b3, direction) => {
59382 return direction === "asc" ? a3 - b3 : b3 - a3;
59383 };
59384
59385 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
59386 function isValidMin(item, field) {
59387 if (typeof field.isValid.min?.constraint !== "number") {
59388 return false;
59389 }
59390 const value = field.getValue({ item });
59391 if ([void 0, "", null].includes(value)) {
59392 return true;
59393 }
59394 return Number(value) >= field.isValid.min.constraint;
59395 }
59396
59397 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
59398 function isValidMax(item, field) {
59399 if (typeof field.isValid.max?.constraint !== "number") {
59400 return false;
59401 }
59402 const value = field.getValue({ item });
59403 if ([void 0, "", null].includes(value)) {
59404 return true;
59405 }
59406 return Number(value) <= field.isValid.max.constraint;
59407 }
59408
59409 // packages/dataviews/build-module/field-types/integer.mjs
59410 var format2 = {
59411 separatorThousand: ","
59412 };
59413 function getValueFormatted2({
59414 item,
59415 field
59416 }) {
59417 let value = field.getValue({ item });
59418 if (value === null || value === void 0) {
59419 return "";
59420 }
59421 value = Number(value);
59422 if (!Number.isFinite(value)) {
59423 return String(value);
59424 }
59425 let formatInteger;
59426 if (field.type !== "integer") {
59427 formatInteger = format2;
59428 } else {
59429 formatInteger = field.format;
59430 }
59431 const { separatorThousand } = formatInteger;
59432 const integerValue = Math.trunc(value);
59433 if (!separatorThousand) {
59434 return String(integerValue);
59435 }
59436 return String(integerValue).replace(
59437 /\B(?=(\d{3})+(?!\d))/g,
59438 separatorThousand
59439 );
59440 }
59441 function isValidCustom2(item, field) {
59442 const value = field.getValue({ item });
59443 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
59444 return (0, import_i18n233.__)("Value must be an integer.");
59445 }
59446 return null;
59447 }
59448 var integer_default = {
59449 type: "integer",
59450 render,
59451 Edit: "integer",
59452 sort: sort_number_default,
59453 enableSorting: true,
59454 enableGlobalSearch: false,
59455 defaultOperators: [
59456 OPERATOR_IS,
59457 OPERATOR_IS_NOT,
59458 OPERATOR_LESS_THAN,
59459 OPERATOR_GREATER_THAN,
59460 OPERATOR_LESS_THAN_OR_EQUAL,
59461 OPERATOR_GREATER_THAN_OR_EQUAL,
59462 OPERATOR_BETWEEN
59463 ],
59464 validOperators: [
59465 // Single-selection
59466 OPERATOR_IS,
59467 OPERATOR_IS_NOT,
59468 OPERATOR_LESS_THAN,
59469 OPERATOR_GREATER_THAN,
59470 OPERATOR_LESS_THAN_OR_EQUAL,
59471 OPERATOR_GREATER_THAN_OR_EQUAL,
59472 OPERATOR_BETWEEN,
59473 // Multiple-selection
59474 OPERATOR_IS_ANY2,
59475 OPERATOR_IS_NONE,
59476 OPERATOR_IS_ALL,
59477 OPERATOR_IS_NOT_ALL
59478 ],
59479 format: format2,
59480 getValueFormatted: getValueFormatted2,
59481 validate: {
59482 required: isValidRequired,
59483 min: isValidMin,
59484 max: isValidMax,
59485 elements: isValidElements,
59486 custom: isValidCustom2
59487 }
59488 };
59489
59490 // packages/dataviews/build-module/field-types/number.mjs
59491 var import_i18n234 = __toESM(require_i18n(), 1);
59492 var format3 = {
59493 separatorThousand: ",",
59494 separatorDecimal: ".",
59495 decimals: 2
59496 };
59497 function getValueFormatted3({
59498 item,
59499 field
59500 }) {
59501 let value = field.getValue({ item });
59502 if (value === null || value === void 0) {
59503 return "";
59504 }
59505 value = Number(value);
59506 if (!Number.isFinite(value)) {
59507 return String(value);
59508 }
59509 let formatNumber;
59510 if (field.type !== "number") {
59511 formatNumber = format3;
59512 } else {
59513 formatNumber = field.format;
59514 }
59515 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
59516 const fixedValue = value.toFixed(decimals);
59517 const [integerPart, decimalPart] = fixedValue.split(".");
59518 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
59519 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
59520 }
59521 function isEmpty(value) {
59522 return value === "" || value === void 0 || value === null;
59523 }
59524 function isValidCustom3(item, field) {
59525 const value = field.getValue({ item });
59526 if (!isEmpty(value) && !Number.isFinite(value)) {
59527 return (0, import_i18n234.__)("Value must be a number.");
59528 }
59529 return null;
59530 }
59531 var number_default = {
59532 type: "number",
59533 render,
59534 Edit: "number",
59535 sort: sort_number_default,
59536 enableSorting: true,
59537 enableGlobalSearch: false,
59538 defaultOperators: [
59539 OPERATOR_IS,
59540 OPERATOR_IS_NOT,
59541 OPERATOR_LESS_THAN,
59542 OPERATOR_GREATER_THAN,
59543 OPERATOR_LESS_THAN_OR_EQUAL,
59544 OPERATOR_GREATER_THAN_OR_EQUAL,
59545 OPERATOR_BETWEEN
59546 ],
59547 validOperators: [
59548 // Single-selection
59549 OPERATOR_IS,
59550 OPERATOR_IS_NOT,
59551 OPERATOR_LESS_THAN,
59552 OPERATOR_GREATER_THAN,
59553 OPERATOR_LESS_THAN_OR_EQUAL,
59554 OPERATOR_GREATER_THAN_OR_EQUAL,
59555 OPERATOR_BETWEEN,
59556 // Multiple-selection
59557 OPERATOR_IS_ANY2,
59558 OPERATOR_IS_NONE,
59559 OPERATOR_IS_ALL,
59560 OPERATOR_IS_NOT_ALL
59561 ],
59562 format: format3,
59563 getValueFormatted: getValueFormatted3,
59564 validate: {
59565 required: isValidRequired,
59566 min: isValidMin,
59567 max: isValidMax,
59568 elements: isValidElements,
59569 custom: isValidCustom3
59570 }
59571 };
59572
59573 // packages/dataviews/build-module/field-types/text.mjs
59574 var text_default = {
59575 type: "text",
59576 render,
59577 Edit: "text",
59578 sort: sort_text_default,
59579 enableSorting: true,
59580 enableGlobalSearch: false,
59581 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
59582 validOperators: [
59583 // Single selection
59584 OPERATOR_IS,
59585 OPERATOR_IS_NOT,
59586 OPERATOR_CONTAINS,
59587 OPERATOR_NOT_CONTAINS,
59588 OPERATOR_STARTS_WITH,
59589 // Multiple selection
59590 OPERATOR_IS_ANY2,
59591 OPERATOR_IS_NONE,
59592 OPERATOR_IS_ALL,
59593 OPERATOR_IS_NOT_ALL
59594 ],
59595 format: {},
59596 getValueFormatted: get_value_formatted_default_default,
59597 validate: {
59598 required: isValidRequired,
59599 pattern: isValidPattern,
59600 minLength: isValidMinLength,
59601 maxLength: isValidMaxLength,
59602 elements: isValidElements
59603 }
59604 };
59605
59606 // packages/dataviews/build-module/field-types/datetime.mjs
59607 var import_date15 = __toESM(require_date(), 1);
59608 var format4 = {
59609 datetime: (0, import_date15.getSettings)().formats.datetime,
59610 weekStartsOn: (0, import_date15.getSettings)().l10n.startOfWeek
59611 };
59612 function getValueFormatted4({
59613 item,
59614 field
59615 }) {
59616 const value = field.getValue({ item });
59617 if (["", void 0, null].includes(value)) {
59618 return "";
59619 }
59620 let formatDatetime;
59621 if (field.type !== "datetime") {
59622 formatDatetime = format4;
59623 } else {
59624 formatDatetime = field.format;
59625 }
59626 return (0, import_date15.dateI18n)(formatDatetime.datetime, (0, import_date15.getDate)(value));
59627 }
59628 var sort = (a3, b3, direction) => {
59629 const timeA = new Date(a3).getTime();
59630 const timeB = new Date(b3).getTime();
59631 return direction === "asc" ? timeA - timeB : timeB - timeA;
59632 };
59633 var datetime_default = {
59634 type: "datetime",
59635 render,
59636 Edit: "datetime",
59637 sort,
59638 enableSorting: true,
59639 enableGlobalSearch: false,
59640 defaultOperators: [
59641 OPERATOR_ON,
59642 OPERATOR_NOT_ON,
59643 OPERATOR_BEFORE,
59644 OPERATOR_AFTER,
59645 OPERATOR_BEFORE_INC,
59646 OPERATOR_AFTER_INC,
59647 OPERATOR_IN_THE_PAST,
59648 OPERATOR_OVER
59649 ],
59650 validOperators: [
59651 OPERATOR_ON,
59652 OPERATOR_NOT_ON,
59653 OPERATOR_BEFORE,
59654 OPERATOR_AFTER,
59655 OPERATOR_BEFORE_INC,
59656 OPERATOR_AFTER_INC,
59657 OPERATOR_IN_THE_PAST,
59658 OPERATOR_OVER
59659 ],
59660 format: format4,
59661 getValueFormatted: getValueFormatted4,
59662 validate: {
59663 required: isValidRequired,
59664 elements: isValidElements
59665 }
59666 };
59667
59668 // packages/dataviews/build-module/field-types/date.mjs
59669 var import_date16 = __toESM(require_date(), 1);
59670 var format5 = {
59671 date: (0, import_date16.getSettings)().formats.date,
59672 weekStartsOn: (0, import_date16.getSettings)().l10n.startOfWeek
59673 };
59674 function getValueFormatted5({
59675 item,
59676 field
59677 }) {
59678 const value = field.getValue({ item });
59679 if (["", void 0, null].includes(value)) {
59680 return "";
59681 }
59682 let formatDate2;
59683 if (field.type !== "date") {
59684 formatDate2 = format5;
59685 } else {
59686 formatDate2 = field.format;
59687 }
59688 return (0, import_date16.dateI18n)(formatDate2.date, (0, import_date16.getDate)(value));
59689 }
59690 var sort2 = (a3, b3, direction) => {
59691 const timeA = new Date(a3).getTime();
59692 const timeB = new Date(b3).getTime();
59693 return direction === "asc" ? timeA - timeB : timeB - timeA;
59694 };
59695 var date_default2 = {
59696 type: "date",
59697 render,
59698 Edit: "date",
59699 sort: sort2,
59700 enableSorting: true,
59701 enableGlobalSearch: false,
59702 defaultOperators: [
59703 OPERATOR_ON,
59704 OPERATOR_NOT_ON,
59705 OPERATOR_BEFORE,
59706 OPERATOR_AFTER,
59707 OPERATOR_BEFORE_INC,
59708 OPERATOR_AFTER_INC,
59709 OPERATOR_IN_THE_PAST,
59710 OPERATOR_OVER,
59711 OPERATOR_BETWEEN
59712 ],
59713 validOperators: [
59714 OPERATOR_ON,
59715 OPERATOR_NOT_ON,
59716 OPERATOR_BEFORE,
59717 OPERATOR_AFTER,
59718 OPERATOR_BEFORE_INC,
59719 OPERATOR_AFTER_INC,
59720 OPERATOR_IN_THE_PAST,
59721 OPERATOR_OVER,
59722 OPERATOR_BETWEEN
59723 ],
59724 format: format5,
59725 getValueFormatted: getValueFormatted5,
59726 validate: {
59727 required: isValidRequired,
59728 elements: isValidElements
59729 }
59730 };
59731
59732 // packages/dataviews/build-module/field-types/boolean.mjs
59733 var import_i18n235 = __toESM(require_i18n(), 1);
59734
59735 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
59736 function isValidRequiredForBool(item, field) {
59737 const value = field.getValue({ item });
59738 return value === true;
59739 }
59740
59741 // packages/dataviews/build-module/field-types/boolean.mjs
59742 function getValueFormatted6({
59743 item,
59744 field
59745 }) {
59746 const value = field.getValue({ item });
59747 if (value === true) {
59748 return (0, import_i18n235.__)("True");
59749 }
59750 if (value === false) {
59751 return (0, import_i18n235.__)("False");
59752 }
59753 return "";
59754 }
59755 function isValidCustom4(item, field) {
59756 const value = field.getValue({ item });
59757 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
59758 return (0, import_i18n235.__)("Value must be true, false, or undefined");
59759 }
59760 return null;
59761 }
59762 var sort3 = (a3, b3, direction) => {
59763 const boolA = Boolean(a3);
59764 const boolB = Boolean(b3);
59765 if (boolA === boolB) {
59766 return 0;
59767 }
59768 if (direction === "asc") {
59769 return boolA ? 1 : -1;
59770 }
59771 return boolA ? -1 : 1;
59772 };
59773 var boolean_default = {
59774 type: "boolean",
59775 render,
59776 Edit: "checkbox",
59777 sort: sort3,
59778 validate: {
59779 required: isValidRequiredForBool,
59780 elements: isValidElements,
59781 custom: isValidCustom4
59782 },
59783 enableSorting: true,
59784 enableGlobalSearch: false,
59785 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
59786 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
59787 format: {},
59788 getValueFormatted: getValueFormatted6
59789 };
59790
59791 // packages/dataviews/build-module/field-types/media.mjs
59792 var media_default = {
59793 type: "media",
59794 render: () => null,
59795 Edit: null,
59796 sort: () => 0,
59797 enableSorting: false,
59798 enableGlobalSearch: false,
59799 defaultOperators: [],
59800 validOperators: [],
59801 format: {},
59802 getValueFormatted: get_value_formatted_default_default,
59803 // cannot validate any constraint, so
59804 // the only available validation for the field author
59805 // would be providing a custom validator.
59806 validate: {}
59807 };
59808
59809 // packages/dataviews/build-module/field-types/array.mjs
59810 var import_i18n236 = __toESM(require_i18n(), 1);
59811
59812 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
59813 function isValidRequiredForArray(item, field) {
59814 const value = field.getValue({ item });
59815 return Array.isArray(value) && value.length > 0 && value.every(
59816 (element) => ![void 0, "", null].includes(element)
59817 );
59818 }
59819
59820 // packages/dataviews/build-module/field-types/array.mjs
59821 function getValueFormatted7({
59822 item,
59823 field
59824 }) {
59825 const value = field.getValue({ item });
59826 const arr = Array.isArray(value) ? value : [];
59827 return arr.join(", ");
59828 }
59829 function render2({ item, field }) {
59830 return getValueFormatted7({ item, field });
59831 }
59832 function isValidCustom5(item, field) {
59833 const value = field.getValue({ item });
59834 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
59835 return (0, import_i18n236.__)("Value must be an array.");
59836 }
59837 if (!value.every((v3) => typeof v3 === "string")) {
59838 return (0, import_i18n236.__)("Every value must be a string.");
59839 }
59840 return null;
59841 }
59842 var sort4 = (a3, b3, direction) => {
59843 const arrA = Array.isArray(a3) ? a3 : [];
59844 const arrB = Array.isArray(b3) ? b3 : [];
59845 if (arrA.length !== arrB.length) {
59846 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
59847 }
59848 const joinedA = arrA.join(",");
59849 const joinedB = arrB.join(",");
59850 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
59851 };
59852 var array_default = {
59853 type: "array",
59854 render: render2,
59855 Edit: "array",
59856 sort: sort4,
59857 enableSorting: true,
59858 enableGlobalSearch: false,
59859 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
59860 validOperators: [
59861 OPERATOR_IS_ANY2,
59862 OPERATOR_IS_NONE,
59863 OPERATOR_IS_ALL,
59864 OPERATOR_IS_NOT_ALL
59865 ],
59866 format: {},
59867 getValueFormatted: getValueFormatted7,
59868 validate: {
59869 required: isValidRequiredForArray,
59870 elements: isValidElements,
59871 custom: isValidCustom5
59872 }
59873 };
59874
59875 // packages/dataviews/build-module/field-types/password.mjs
59876 function getValueFormatted8({
59877 item,
59878 field
59879 }) {
59880 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
59881 }
59882 var password_default2 = {
59883 type: "password",
59884 render,
59885 Edit: "password",
59886 sort: () => 0,
59887 // Passwords should not be sortable for security reasons
59888 enableSorting: false,
59889 enableGlobalSearch: false,
59890 defaultOperators: [],
59891 validOperators: [],
59892 format: {},
59893 getValueFormatted: getValueFormatted8,
59894 validate: {
59895 required: isValidRequired,
59896 pattern: isValidPattern,
59897 minLength: isValidMinLength,
59898 maxLength: isValidMaxLength,
59899 elements: isValidElements
59900 }
59901 };
59902
59903 // packages/dataviews/build-module/field-types/telephone.mjs
59904 var telephone_default = {
59905 type: "telephone",
59906 render,
59907 Edit: "telephone",
59908 sort: sort_text_default,
59909 enableSorting: true,
59910 enableGlobalSearch: false,
59911 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
59912 validOperators: [
59913 OPERATOR_IS,
59914 OPERATOR_IS_NOT,
59915 OPERATOR_CONTAINS,
59916 OPERATOR_NOT_CONTAINS,
59917 OPERATOR_STARTS_WITH,
59918 // Multiple selection
59919 OPERATOR_IS_ANY2,
59920 OPERATOR_IS_NONE,
59921 OPERATOR_IS_ALL,
59922 OPERATOR_IS_NOT_ALL
59923 ],
59924 format: {},
59925 getValueFormatted: get_value_formatted_default_default,
59926 validate: {
59927 required: isValidRequired,
59928 pattern: isValidPattern,
59929 minLength: isValidMinLength,
59930 maxLength: isValidMaxLength,
59931 elements: isValidElements
59932 }
59933 };
59934
59935 // packages/dataviews/build-module/field-types/color.mjs
59936 var import_i18n237 = __toESM(require_i18n(), 1);
59937 var import_jsx_runtime370 = __toESM(require_jsx_runtime(), 1);
59938 function render3({ item, field }) {
59939 if (field.hasElements) {
59940 return /* @__PURE__ */ (0, import_jsx_runtime370.jsx)(RenderFromElements, { item, field });
59941 }
59942 const value = get_value_formatted_default_default({ item, field });
59943 if (!value || !w2(value).isValid()) {
59944 return value;
59945 }
59946 return /* @__PURE__ */ (0, import_jsx_runtime370.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
59947 /* @__PURE__ */ (0, import_jsx_runtime370.jsx)(
59948 "div",
59949 {
59950 style: {
59951 width: "16px",
59952 height: "16px",
59953 borderRadius: "50%",
59954 backgroundColor: value,
59955 border: "1px solid #ddd",
59956 flexShrink: 0
59957 }
59958 }
59959 ),
59960 /* @__PURE__ */ (0, import_jsx_runtime370.jsx)("span", { children: value })
59961 ] });
59962 }
59963 function isValidCustom6(item, field) {
59964 const value = field.getValue({ item });
59965 if (![void 0, "", null].includes(value) && !w2(value).isValid()) {
59966 return (0, import_i18n237.__)("Value must be a valid color.");
59967 }
59968 return null;
59969 }
59970 var sort5 = (a3, b3, direction) => {
59971 const colorA = w2(a3);
59972 const colorB = w2(b3);
59973 if (!colorA.isValid() && !colorB.isValid()) {
59974 return 0;
59975 }
59976 if (!colorA.isValid()) {
59977 return direction === "asc" ? 1 : -1;
59978 }
59979 if (!colorB.isValid()) {
59980 return direction === "asc" ? -1 : 1;
59981 }
59982 const hslA = colorA.toHsl();
59983 const hslB = colorB.toHsl();
59984 if (hslA.h !== hslB.h) {
59985 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
59986 }
59987 if (hslA.s !== hslB.s) {
59988 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
59989 }
59990 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
59991 };
59992 var color_default2 = {
59993 type: "color",
59994 render: render3,
59995 Edit: "color",
59996 sort: sort5,
59997 enableSorting: true,
59998 enableGlobalSearch: false,
59999 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
60000 validOperators: [
60001 OPERATOR_IS,
60002 OPERATOR_IS_NOT,
60003 OPERATOR_IS_ANY2,
60004 OPERATOR_IS_NONE
60005 ],
60006 format: {},
60007 getValueFormatted: get_value_formatted_default_default,
60008 validate: {
60009 required: isValidRequired,
60010 elements: isValidElements,
60011 custom: isValidCustom6
60012 }
60013 };
60014
60015 // packages/dataviews/build-module/field-types/url.mjs
60016 var url_default = {
60017 type: "url",
60018 render,
60019 Edit: "url",
60020 sort: sort_text_default,
60021 enableSorting: true,
60022 enableGlobalSearch: false,
60023 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE],
60024 validOperators: [
60025 OPERATOR_IS,
60026 OPERATOR_IS_NOT,
60027 OPERATOR_CONTAINS,
60028 OPERATOR_NOT_CONTAINS,
60029 OPERATOR_STARTS_WITH,
60030 // Multiple selection
60031 OPERATOR_IS_ANY2,
60032 OPERATOR_IS_NONE,
60033 OPERATOR_IS_ALL,
60034 OPERATOR_IS_NOT_ALL
60035 ],
60036 format: {},
60037 getValueFormatted: get_value_formatted_default_default,
60038 validate: {
60039 required: isValidRequired,
60040 pattern: isValidPattern,
60041 minLength: isValidMinLength,
60042 maxLength: isValidMaxLength,
60043 elements: isValidElements
60044 }
60045 };
60046
60047 // packages/dataviews/build-module/field-types/no-type.mjs
60048 var sort6 = (a3, b3, direction) => {
60049 if (typeof a3 === "number" && typeof b3 === "number") {
60050 return sort_number_default(a3, b3, direction);
60051 }
60052 return sort_text_default(a3, b3, direction);
60053 };
60054 var no_type_default = {
60055 // type: no type for this one
60056 render,
60057 Edit: null,
60058 sort: sort6,
60059 enableSorting: true,
60060 enableGlobalSearch: false,
60061 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
60062 validOperators: getAllOperatorNames(),
60063 format: {},
60064 getValueFormatted: get_value_formatted_default_default,
60065 validate: {
60066 required: isValidRequired,
60067 elements: isValidElements
60068 }
60069 };
60070
60071 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
60072 function getIsValid(field, fieldType) {
60073 let required;
60074 if (field.isValid?.required === true && fieldType.validate.required !== void 0) {
60075 required = {
60076 constraint: true,
60077 validate: fieldType.validate.required
60078 };
60079 }
60080 let elements2;
60081 if ((field.isValid?.elements === true || // elements is enabled unless the field opts-out
60082 field.isValid?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
60083 elements2 = {
60084 constraint: true,
60085 validate: fieldType.validate.elements
60086 };
60087 }
60088 let min2;
60089 if (typeof field.isValid?.min === "number" && fieldType.validate.min !== void 0) {
60090 min2 = {
60091 constraint: field.isValid.min,
60092 validate: fieldType.validate.min
60093 };
60094 }
60095 let max2;
60096 if (typeof field.isValid?.max === "number" && fieldType.validate.max !== void 0) {
60097 max2 = {
60098 constraint: field.isValid.max,
60099 validate: fieldType.validate.max
60100 };
60101 }
60102 let minLength;
60103 if (typeof field.isValid?.minLength === "number" && fieldType.validate.minLength !== void 0) {
60104 minLength = {
60105 constraint: field.isValid.minLength,
60106 validate: fieldType.validate.minLength
60107 };
60108 }
60109 let maxLength;
60110 if (typeof field.isValid?.maxLength === "number" && fieldType.validate.maxLength !== void 0) {
60111 maxLength = {
60112 constraint: field.isValid.maxLength,
60113 validate: fieldType.validate.maxLength
60114 };
60115 }
60116 let pattern;
60117 if (field.isValid?.pattern !== void 0 && fieldType.validate.pattern !== void 0) {
60118 pattern = {
60119 constraint: field.isValid?.pattern,
60120 validate: fieldType.validate.pattern
60121 };
60122 }
60123 const custom = field.isValid?.custom ?? fieldType.validate.custom;
60124 return {
60125 required,
60126 elements: elements2,
60127 min: min2,
60128 max: max2,
60129 minLength,
60130 maxLength,
60131 pattern,
60132 custom
60133 };
60134 }
60135
60136 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
60137 function getFilter(fieldType) {
60138 return fieldType.validOperators.reduce((accumulator, operator) => {
60139 const operatorObj = getOperatorByName(operator);
60140 if (operatorObj?.filter) {
60141 accumulator[operator] = operatorObj.filter;
60142 }
60143 return accumulator;
60144 }, {});
60145 }
60146
60147 // packages/dataviews/build-module/field-types/utils/get-format.mjs
60148 function getFormat(field, fieldType) {
60149 return {
60150 ...fieldType.format,
60151 ...field.format
60152 };
60153 }
60154 var get_format_default = getFormat;
60155
60156 // packages/dataviews/build-module/field-types/index.mjs
60157 function getFieldTypeByName(type) {
60158 const found = [
60159 email_default,
60160 integer_default,
60161 number_default,
60162 text_default,
60163 datetime_default,
60164 date_default2,
60165 boolean_default,
60166 media_default,
60167 array_default,
60168 password_default2,
60169 telephone_default,
60170 color_default2,
60171 url_default
60172 ].find((fieldType) => fieldType?.type === type);
60173 if (!!found) {
60174 return found;
60175 }
60176 return no_type_default;
60177 }
60178 function normalizeFields(fields2) {
60179 return fields2.map((field) => {
60180 const fieldType = getFieldTypeByName(field.type);
60181 const getValue2 = field.getValue || get_value_from_id_default(field.id);
60182 const sort7 = function(a3, b3, direction) {
60183 const aValue = getValue2({ item: a3 });
60184 const bValue = getValue2({ item: b3 });
60185 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
60186 };
60187 return {
60188 id: field.id,
60189 label: field.label || field.id,
60190 header: field.header || field.label || field.id,
60191 description: field.description,
60192 placeholder: field.placeholder,
60193 getValue: getValue2,
60194 setValue: field.setValue || set_value_from_id_default(field.id),
60195 elements: field.elements,
60196 getElements: field.getElements,
60197 hasElements: hasElements(field),
60198 isVisible: field.isVisible,
60199 enableHiding: field.enableHiding ?? true,
60200 readOnly: field.readOnly ?? false,
60201 // The type provides defaults for the following props
60202 type: fieldType.type,
60203 render: field.render ?? fieldType.render,
60204 Edit: getControl(field, fieldType.Edit),
60205 sort: sort7,
60206 enableSorting: field.enableSorting ?? fieldType.enableSorting,
60207 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
60208 isValid: getIsValid(field, fieldType),
60209 filterBy: get_filter_by_default(
60210 field,
60211 fieldType.defaultOperators,
60212 fieldType.validOperators
60213 ),
60214 filter: getFilter(fieldType),
60215 format: get_format_default(field, fieldType),
60216 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
60217 };
60218 });
60219 }
60220
60221 // packages/dataviews/build-module/dataform/index.mjs
60222 var import_element205 = __toESM(require_element(), 1);
60223
60224 // packages/dataviews/build-module/components/dataform-context/index.mjs
60225 var import_element194 = __toESM(require_element(), 1);
60226 var import_jsx_runtime371 = __toESM(require_jsx_runtime(), 1);
60227 var DataFormContext = (0, import_element194.createContext)({
60228 fields: []
60229 });
60230 DataFormContext.displayName = "DataFormContext";
60231 function DataFormProvider({
60232 fields: fields2,
60233 children
60234 }) {
60235 return /* @__PURE__ */ (0, import_jsx_runtime371.jsx)(DataFormContext.Provider, { value: { fields: fields2 }, children });
60236 }
60237 var dataform_context_default = DataFormContext;
60238
60239 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
60240 var import_element204 = __toESM(require_element(), 1);
60241
60242 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
60243 var import_element195 = __toESM(require_element(), 1);
60244 var import_components218 = __toESM(require_components(), 1);
60245
60246 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
60247 var DEFAULT_LAYOUT = {
60248 type: "regular",
60249 labelPosition: "top"
60250 };
60251 var normalizeCardSummaryField = (sum) => {
60252 if (typeof sum === "string") {
60253 return [{ id: sum, visibility: "when-collapsed" }];
60254 }
60255 return sum.map((item) => {
60256 if (typeof item === "string") {
60257 return { id: item, visibility: "when-collapsed" };
60258 }
60259 return { id: item.id, visibility: item.visibility };
60260 });
60261 };
60262 function normalizeLayout(layout) {
60263 let normalizedLayout = DEFAULT_LAYOUT;
60264 if (layout?.type === "regular") {
60265 normalizedLayout = {
60266 type: "regular",
60267 labelPosition: layout?.labelPosition ?? "top"
60268 };
60269 } else if (layout?.type === "panel") {
60270 const summary = layout.summary ?? [];
60271 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
60272 normalizedLayout = {
60273 type: "panel",
60274 labelPosition: layout?.labelPosition ?? "side",
60275 openAs: layout?.openAs ?? "dropdown",
60276 summary: normalizedSummary,
60277 editVisibility: layout?.editVisibility ?? "on-hover"
60278 };
60279 } else if (layout?.type === "card") {
60280 if (layout.withHeader === false) {
60281 normalizedLayout = {
60282 type: "card",
60283 withHeader: false,
60284 isOpened: true,
60285 summary: [],
60286 isCollapsible: false
60287 };
60288 } else {
60289 const summary = layout.summary ?? [];
60290 normalizedLayout = {
60291 type: "card",
60292 withHeader: true,
60293 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
60294 summary: normalizeCardSummaryField(summary),
60295 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
60296 };
60297 }
60298 } else if (layout?.type === "row") {
60299 normalizedLayout = {
60300 type: "row",
60301 alignment: layout?.alignment ?? "center",
60302 styles: layout?.styles ?? {}
60303 };
60304 } else if (layout?.type === "details") {
60305 normalizedLayout = {
60306 type: "details",
60307 summary: layout?.summary ?? ""
60308 };
60309 }
60310 return normalizedLayout;
60311 }
60312 function normalizeForm(form) {
60313 const normalizedFormLayout = normalizeLayout(form?.layout);
60314 const normalizedFields = (form.fields ?? []).map(
60315 (field) => {
60316 if (typeof field === "string") {
60317 return {
60318 id: field,
60319 layout: normalizedFormLayout
60320 };
60321 }
60322 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
60323 return {
60324 id: field.id,
60325 layout: fieldLayout,
60326 ...!!field.label && { label: field.label },
60327 ...!!field.description && {
60328 description: field.description
60329 },
60330 ..."children" in field && Array.isArray(field.children) && {
60331 children: normalizeForm({
60332 fields: field.children,
60333 layout: DEFAULT_LAYOUT
60334 }).fields
60335 }
60336 };
60337 }
60338 );
60339 return {
60340 layout: normalizedFormLayout,
60341 fields: normalizedFields
60342 };
60343 }
60344 var normalize_form_default = normalizeForm;
60345
60346 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
60347 var import_jsx_runtime372 = __toESM(require_jsx_runtime(), 1);
60348 function Header2({ title }) {
60349 return /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(
60350 Stack,
60351 {
60352 direction: "column",
60353 className: "dataforms-layouts-regular__header",
60354 gap: "lg",
60355 children: /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(import_components218.__experimentalHeading, { level: 2, size: 13, children: title }) })
60356 }
60357 );
60358 }
60359 function FormRegularField({
60360 data,
60361 field,
60362 onChange,
60363 hideLabelFromVision,
60364 markWhenOptional,
60365 validity
60366 }) {
60367 const { fields: fields2 } = (0, import_element195.useContext)(dataform_context_default);
60368 const layout = field.layout;
60369 const form = (0, import_element195.useMemo)(
60370 () => ({
60371 layout: DEFAULT_LAYOUT,
60372 fields: !!field.children ? field.children : []
60373 }),
60374 [field]
60375 );
60376 if (!!field.children) {
60377 return /* @__PURE__ */ (0, import_jsx_runtime372.jsxs)(import_jsx_runtime372.Fragment, { children: [
60378 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(Header2, { title: field.label }),
60379 /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(
60380 DataFormLayout,
60381 {
60382 data,
60383 form,
60384 onChange,
60385 validity: validity?.children
60386 }
60387 )
60388 ] });
60389 }
60390 const labelPosition = layout.labelPosition;
60391 const fieldDefinition = fields2.find(
60392 (fieldDef) => fieldDef.id === field.id
60393 );
60394 if (!fieldDefinition || !fieldDefinition.Edit) {
60395 return null;
60396 }
60397 if (labelPosition === "side") {
60398 return /* @__PURE__ */ (0, import_jsx_runtime372.jsxs)(
60399 Stack,
60400 {
60401 direction: "row",
60402 className: "dataforms-layouts-regular__field",
60403 gap: "sm",
60404 children: [
60405 /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(
60406 "div",
60407 {
60408 className: clsx_default(
60409 "dataforms-layouts-regular__field-label",
60410 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
60411 ),
60412 children: /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(import_components218.BaseControl.VisualLabel, { children: fieldDefinition.label })
60413 }
60414 ),
60415 /* @__PURE__ */ (0, import_jsx_runtime372.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(
60416 fieldDefinition.render,
60417 {
60418 item: data,
60419 field: fieldDefinition
60420 }
60421 ) : /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(
60422 fieldDefinition.Edit,
60423 {
60424 data,
60425 field: fieldDefinition,
60426 onChange,
60427 hideLabelFromVision: true,
60428 markWhenOptional,
60429 validity
60430 },
60431 fieldDefinition.id
60432 ) })
60433 ]
60434 }
60435 );
60436 }
60437 return /* @__PURE__ */ (0, import_jsx_runtime372.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(import_jsx_runtime372.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime372.jsxs)(import_jsx_runtime372.Fragment, { children: [
60438 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(import_components218.BaseControl.VisualLabel, { children: fieldDefinition.label }),
60439 /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(
60440 fieldDefinition.render,
60441 {
60442 item: data,
60443 field: fieldDefinition
60444 }
60445 )
60446 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(
60447 fieldDefinition.Edit,
60448 {
60449 data,
60450 field: fieldDefinition,
60451 onChange,
60452 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
60453 markWhenOptional,
60454 validity
60455 }
60456 ) });
60457 }
60458
60459 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
60460 var import_deepmerge3 = __toESM(require_cjs(), 1);
60461 var import_components221 = __toESM(require_components(), 1);
60462 var import_i18n240 = __toESM(require_i18n(), 1);
60463 var import_element200 = __toESM(require_element(), 1);
60464 var import_compose62 = __toESM(require_compose(), 1);
60465
60466 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
60467 var import_components220 = __toESM(require_components(), 1);
60468 var import_i18n238 = __toESM(require_i18n(), 1);
60469 var import_compose61 = __toESM(require_compose(), 1);
60470 var import_element196 = __toESM(require_element(), 1);
60471
60472 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
60473 function getLabelClassName(labelPosition, showError) {
60474 return clsx_default(
60475 "dataforms-layouts-panel__field-label",
60476 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
60477 { "has-error": showError }
60478 );
60479 }
60480 var get_label_classname_default = getLabelClassName;
60481
60482 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
60483 var import_components219 = __toESM(require_components(), 1);
60484 var import_jsx_runtime373 = __toESM(require_jsx_runtime(), 1);
60485 function getLabelContent(showError, errorMessage, fieldLabel) {
60486 return showError ? /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(import_components219.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime373.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
60487 /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(import_components219.Icon, { icon: error_default, size: 16 }),
60488 fieldLabel
60489 ] }) }) : fieldLabel;
60490 }
60491 var get_label_content_default = getLabelContent;
60492
60493 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
60494 function getFirstValidationError(validity) {
60495 if (!validity) {
60496 return void 0;
60497 }
60498 const validityRules = Object.keys(validity).filter(
60499 (key) => key !== "children"
60500 );
60501 for (const key of validityRules) {
60502 const rule = validity[key];
60503 if (rule === void 0) {
60504 continue;
60505 }
60506 if (rule.type === "invalid") {
60507 if (rule.message) {
60508 return rule.message;
60509 }
60510 if (key === "required") {
60511 return "A required field is empty";
60512 }
60513 return "Unidentified validation error";
60514 }
60515 }
60516 if (validity.children) {
60517 for (const childValidity of Object.values(validity.children)) {
60518 const childError = getFirstValidationError(childValidity);
60519 if (childError) {
60520 return childError;
60521 }
60522 }
60523 }
60524 return void 0;
60525 }
60526 var get_first_validation_error_default = getFirstValidationError;
60527
60528 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
60529 var import_jsx_runtime374 = __toESM(require_jsx_runtime(), 1);
60530 function SummaryButton({
60531 data,
60532 field,
60533 fieldLabel,
60534 summaryFields,
60535 validity,
60536 touched,
60537 disabled,
60538 onClick,
60539 "aria-expanded": ariaExpanded
60540 }) {
60541 const { labelPosition, editVisibility } = field.layout;
60542 const errorMessage = get_first_validation_error_default(validity);
60543 const showError = touched && !!errorMessage;
60544 const labelClassName = get_label_classname_default(labelPosition, showError);
60545 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
60546 const className = clsx_default(
60547 "dataforms-layouts-panel__field-trigger",
60548 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
60549 {
60550 "is-disabled": disabled,
60551 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
60552 }
60553 );
60554 const controlId = (0, import_compose61.useInstanceId)(
60555 SummaryButton,
60556 "dataforms-layouts-panel__field-control"
60557 );
60558 const ariaLabel = showError ? (0, import_i18n238.sprintf)(
60559 // translators: %s: Field name.
60560 (0, import_i18n238._x)("Edit %s (has errors)", "field"),
60561 fieldLabel || ""
60562 ) : (0, import_i18n238.sprintf)(
60563 // translators: %s: Field name.
60564 (0, import_i18n238._x)("Edit %s", "field"),
60565 fieldLabel || ""
60566 );
60567 const rowRef = (0, import_element196.useRef)(null);
60568 const handleRowClick = () => {
60569 const selection = rowRef.current?.ownerDocument.defaultView?.getSelection();
60570 if (selection && selection.toString().length > 0) {
60571 return;
60572 }
60573 onClick();
60574 };
60575 const handleKeyDown = (event) => {
60576 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
60577 event.preventDefault();
60578 onClick();
60579 }
60580 };
60581 return /* @__PURE__ */ (0, import_jsx_runtime374.jsxs)(
60582 "div",
60583 {
60584 ref: rowRef,
60585 className,
60586 onClick: !disabled ? handleRowClick : void 0,
60587 onKeyDown: !disabled ? handleKeyDown : void 0,
60588 children: [
60589 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime374.jsx)("span", { className: labelClassName, children: labelContent }),
60590 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(import_components220.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime374.jsx)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(import_components220.Icon, { icon: error_default, size: 16 }) }) }),
60591 /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(
60592 "span",
60593 {
60594 id: `${controlId}`,
60595 className: "dataforms-layouts-panel__field-control",
60596 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(
60597 "span",
60598 {
60599 style: {
60600 display: "flex",
60601 flexDirection: "column",
60602 alignItems: "flex-start",
60603 width: "100%",
60604 gap: "2px"
60605 },
60606 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(
60607 "span",
60608 {
60609 style: { width: "100%" },
60610 children: /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(
60611 summaryField.render,
60612 {
60613 item: data,
60614 field: summaryField
60615 }
60616 )
60617 },
60618 summaryField.id
60619 ))
60620 }
60621 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(
60622 summaryField.render,
60623 {
60624 item: data,
60625 field: summaryField
60626 },
60627 summaryField.id
60628 ))
60629 }
60630 ),
60631 !disabled && /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(
60632 import_components220.Button,
60633 {
60634 className: "dataforms-layouts-panel__field-trigger-icon",
60635 label: ariaLabel,
60636 showTooltip: false,
60637 icon: pencil_default,
60638 size: "small",
60639 "aria-expanded": ariaExpanded,
60640 "aria-haspopup": "dialog",
60641 "aria-describedby": `${controlId}`
60642 }
60643 )
60644 ]
60645 }
60646 );
60647 }
60648
60649 // packages/dataviews/build-module/hooks/use-form-validity.mjs
60650 var import_deepmerge2 = __toESM(require_cjs(), 1);
60651 var import_es62 = __toESM(require_es6(), 1);
60652 var import_element197 = __toESM(require_element(), 1);
60653 var import_i18n239 = __toESM(require_i18n(), 1);
60654 function isFormValid(formValidity) {
60655 if (!formValidity) {
60656 return true;
60657 }
60658 return Object.values(formValidity).every((fieldValidation) => {
60659 return Object.entries(fieldValidation).every(
60660 ([key, validation]) => {
60661 if (key === "children" && validation && typeof validation === "object") {
60662 return isFormValid(validation);
60663 }
60664 return validation.type !== "invalid" && validation.type !== "validating";
60665 }
60666 );
60667 });
60668 }
60669 function getFormFieldsToValidate(form, fields2) {
60670 const normalizedForm = normalize_form_default(form);
60671 if (normalizedForm.fields.length === 0) {
60672 return [];
60673 }
60674 const fieldsMap = /* @__PURE__ */ new Map();
60675 fields2.forEach((field) => {
60676 fieldsMap.set(field.id, field);
60677 });
60678 function processFormField(formField) {
60679 if ("children" in formField && Array.isArray(formField.children)) {
60680 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
60681 if (processedChildren.length === 0) {
60682 return null;
60683 }
60684 const fieldDef2 = fieldsMap.get(formField.id);
60685 if (fieldDef2) {
60686 const [normalizedField2] = normalizeFields([
60687 fieldDef2
60688 ]);
60689 return {
60690 id: formField.id,
60691 children: processedChildren,
60692 field: normalizedField2
60693 };
60694 }
60695 return {
60696 id: formField.id,
60697 children: processedChildren
60698 };
60699 }
60700 const fieldDef = fieldsMap.get(formField.id);
60701 if (!fieldDef) {
60702 return null;
60703 }
60704 const [normalizedField] = normalizeFields([fieldDef]);
60705 return {
60706 id: formField.id,
60707 children: [],
60708 field: normalizedField
60709 };
60710 }
60711 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
60712 return toValidate;
60713 }
60714 function setValidityAtPath(formValidity, fieldValidity, path) {
60715 if (!formValidity) {
60716 formValidity = {};
60717 }
60718 if (path.length === 0) {
60719 return formValidity;
60720 }
60721 const result = { ...formValidity };
60722 let current = result;
60723 for (let i3 = 0; i3 < path.length - 1; i3++) {
60724 const segment = path[i3];
60725 if (!current[segment]) {
60726 current[segment] = {};
60727 }
60728 current[segment] = { ...current[segment] };
60729 current = current[segment];
60730 }
60731 const finalKey = path[path.length - 1];
60732 current[finalKey] = {
60733 ...current[finalKey] || {},
60734 ...fieldValidity
60735 };
60736 return result;
60737 }
60738 function removeValidationProperty(formValidity, path, property) {
60739 if (!formValidity || path.length === 0) {
60740 return formValidity;
60741 }
60742 const result = { ...formValidity };
60743 let current = result;
60744 for (let i3 = 0; i3 < path.length - 1; i3++) {
60745 const segment = path[i3];
60746 if (!current[segment]) {
60747 return formValidity;
60748 }
60749 current[segment] = { ...current[segment] };
60750 current = current[segment];
60751 }
60752 const finalKey = path[path.length - 1];
60753 if (!current[finalKey]) {
60754 return formValidity;
60755 }
60756 const fieldValidity = { ...current[finalKey] };
60757 delete fieldValidity[property];
60758 if (Object.keys(fieldValidity).length === 0) {
60759 delete current[finalKey];
60760 } else {
60761 current[finalKey] = fieldValidity;
60762 }
60763 if (Object.keys(result).length === 0) {
60764 return void 0;
60765 }
60766 return result;
60767 }
60768 function handleElementsValidationAsync(promise, formField, promiseHandler) {
60769 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
60770 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
60771 elementsCounterRef.current[formField.id] = currentToken;
60772 promise.then((result) => {
60773 if (currentToken !== elementsCounterRef.current[formField.id]) {
60774 return;
60775 }
60776 if (!Array.isArray(result)) {
60777 setFormValidity((prev) => {
60778 const newFormValidity = setValidityAtPath(
60779 prev,
60780 {
60781 elements: {
60782 type: "invalid",
60783 message: (0, import_i18n239.__)("Could not validate elements.")
60784 }
60785 },
60786 [...path, formField.id]
60787 );
60788 return newFormValidity;
60789 });
60790 return;
60791 }
60792 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
60793 ...formField.field,
60794 elements: result
60795 })) {
60796 setFormValidity((prev) => {
60797 const newFormValidity = setValidityAtPath(
60798 prev,
60799 {
60800 elements: {
60801 type: "invalid",
60802 message: (0, import_i18n239.__)(
60803 "Value must be one of the elements."
60804 )
60805 }
60806 },
60807 [...path, formField.id]
60808 );
60809 return newFormValidity;
60810 });
60811 } else {
60812 setFormValidity((prev) => {
60813 return removeValidationProperty(
60814 prev,
60815 [...path, formField.id],
60816 "elements"
60817 );
60818 });
60819 }
60820 }).catch((error) => {
60821 if (currentToken !== elementsCounterRef.current[formField.id]) {
60822 return;
60823 }
60824 let errorMessage;
60825 if (error instanceof Error) {
60826 errorMessage = error.message;
60827 } else {
60828 errorMessage = String(error) || (0, import_i18n239.__)(
60829 "Unknown error when running elements validation asynchronously."
60830 );
60831 }
60832 setFormValidity((prev) => {
60833 const newFormValidity = setValidityAtPath(
60834 prev,
60835 {
60836 elements: {
60837 type: "invalid",
60838 message: errorMessage
60839 }
60840 },
60841 [...path, formField.id]
60842 );
60843 return newFormValidity;
60844 });
60845 });
60846 }
60847 function handleCustomValidationAsync(promise, formField, promiseHandler) {
60848 const { customCounterRef, setFormValidity, path } = promiseHandler;
60849 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
60850 customCounterRef.current[formField.id] = currentToken;
60851 promise.then((result) => {
60852 if (currentToken !== customCounterRef.current[formField.id]) {
60853 return;
60854 }
60855 if (result === null) {
60856 setFormValidity((prev) => {
60857 return removeValidationProperty(
60858 prev,
60859 [...path, formField.id],
60860 "custom"
60861 );
60862 });
60863 return;
60864 }
60865 if (typeof result === "string") {
60866 setFormValidity((prev) => {
60867 const newFormValidity = setValidityAtPath(
60868 prev,
60869 {
60870 custom: {
60871 type: "invalid",
60872 message: result
60873 }
60874 },
60875 [...path, formField.id]
60876 );
60877 return newFormValidity;
60878 });
60879 return;
60880 }
60881 setFormValidity((prev) => {
60882 const newFormValidity = setValidityAtPath(
60883 prev,
60884 {
60885 custom: {
60886 type: "invalid",
60887 message: (0, import_i18n239.__)("Validation could not be processed.")
60888 }
60889 },
60890 [...path, formField.id]
60891 );
60892 return newFormValidity;
60893 });
60894 }).catch((error) => {
60895 if (currentToken !== customCounterRef.current[formField.id]) {
60896 return;
60897 }
60898 let errorMessage;
60899 if (error instanceof Error) {
60900 errorMessage = error.message;
60901 } else {
60902 errorMessage = String(error) || (0, import_i18n239.__)(
60903 "Unknown error when running custom validation asynchronously."
60904 );
60905 }
60906 setFormValidity((prev) => {
60907 const newFormValidity = setValidityAtPath(
60908 prev,
60909 {
60910 custom: {
60911 type: "invalid",
60912 message: errorMessage
60913 }
60914 },
60915 [...path, formField.id]
60916 );
60917 return newFormValidity;
60918 });
60919 });
60920 }
60921 function validateFormField(item, formField, promiseHandler) {
60922 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
60923 return {
60924 required: { type: "invalid" }
60925 };
60926 }
60927 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
60928 return {
60929 pattern: {
60930 type: "invalid",
60931 message: (0, import_i18n239.__)("Value does not match the required pattern.")
60932 }
60933 };
60934 }
60935 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
60936 return {
60937 min: {
60938 type: "invalid",
60939 message: (0, import_i18n239.__)("Value is below the minimum.")
60940 }
60941 };
60942 }
60943 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
60944 return {
60945 max: {
60946 type: "invalid",
60947 message: (0, import_i18n239.__)("Value is above the maximum.")
60948 }
60949 };
60950 }
60951 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
60952 return {
60953 minLength: {
60954 type: "invalid",
60955 message: (0, import_i18n239.__)("Value is too short.")
60956 }
60957 };
60958 }
60959 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
60960 return {
60961 maxLength: {
60962 type: "invalid",
60963 message: (0, import_i18n239.__)("Value is too long.")
60964 }
60965 };
60966 }
60967 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
60968 return {
60969 elements: {
60970 type: "invalid",
60971 message: (0, import_i18n239.__)("Value must be one of the elements.")
60972 }
60973 };
60974 }
60975 let customError;
60976 if (!!formField.field && formField.field.isValid.custom) {
60977 try {
60978 const value = formField.field.getValue({ item });
60979 customError = formField.field.isValid.custom(
60980 (0, import_deepmerge2.default)(
60981 item,
60982 formField.field.setValue({
60983 item,
60984 value
60985 })
60986 ),
60987 formField.field
60988 );
60989 } catch (error) {
60990 let errorMessage;
60991 if (error instanceof Error) {
60992 errorMessage = error.message;
60993 } else {
60994 errorMessage = String(error) || (0, import_i18n239.__)("Unknown error when running custom validation.");
60995 }
60996 return {
60997 custom: {
60998 type: "invalid",
60999 message: errorMessage
61000 }
61001 };
61002 }
61003 }
61004 if (typeof customError === "string") {
61005 return {
61006 custom: {
61007 type: "invalid",
61008 message: customError
61009 }
61010 };
61011 }
61012 const fieldValidity = {};
61013 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
61014 handleElementsValidationAsync(
61015 formField.field.getElements(),
61016 formField,
61017 promiseHandler
61018 );
61019 fieldValidity.elements = {
61020 type: "validating",
61021 message: (0, import_i18n239.__)("Validating\u2026")
61022 };
61023 }
61024 if (customError instanceof Promise) {
61025 handleCustomValidationAsync(customError, formField, promiseHandler);
61026 fieldValidity.custom = {
61027 type: "validating",
61028 message: (0, import_i18n239.__)("Validating\u2026")
61029 };
61030 }
61031 if (Object.keys(fieldValidity).length > 0) {
61032 return fieldValidity;
61033 }
61034 if (formField.children.length > 0) {
61035 const result = {};
61036 formField.children.forEach((child) => {
61037 result[child.id] = validateFormField(item, child, {
61038 ...promiseHandler,
61039 path: [...promiseHandler.path, formField.id, "children"]
61040 });
61041 });
61042 const filteredResult = {};
61043 Object.entries(result).forEach(([key, value]) => {
61044 if (value !== void 0) {
61045 filteredResult[key] = value;
61046 }
61047 });
61048 if (Object.keys(filteredResult).length === 0) {
61049 return void 0;
61050 }
61051 return {
61052 children: filteredResult
61053 };
61054 }
61055 return void 0;
61056 }
61057 function getFormFieldValue(formField, item) {
61058 const fieldValue = formField?.field?.getValue({ item });
61059 if (formField.children.length === 0) {
61060 return fieldValue;
61061 }
61062 const childrenValues = formField.children.map(
61063 (child) => getFormFieldValue(child, item)
61064 );
61065 if (!childrenValues) {
61066 return fieldValue;
61067 }
61068 return {
61069 value: fieldValue,
61070 children: childrenValues
61071 };
61072 }
61073 function useFormValidity(item, fields2, form) {
61074 const [formValidity, setFormValidity] = (0, import_element197.useState)();
61075 const customCounterRef = (0, import_element197.useRef)({});
61076 const elementsCounterRef = (0, import_element197.useRef)({});
61077 const previousValuesRef = (0, import_element197.useRef)({});
61078 const validate = (0, import_element197.useCallback)(() => {
61079 const promiseHandler = {
61080 customCounterRef,
61081 elementsCounterRef,
61082 setFormValidity,
61083 path: [],
61084 item
61085 };
61086 const formFieldsToValidate = getFormFieldsToValidate(form, fields2);
61087 if (formFieldsToValidate.length === 0) {
61088 setFormValidity(void 0);
61089 return;
61090 }
61091 const newFormValidity = {};
61092 const untouchedFields = [];
61093 formFieldsToValidate.forEach((formField) => {
61094 const value = getFormFieldValue(formField, item);
61095 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
61096 previousValuesRef.current[formField.id],
61097 value
61098 )) {
61099 untouchedFields.push(formField.id);
61100 return;
61101 }
61102 previousValuesRef.current[formField.id] = value;
61103 const fieldValidity = validateFormField(
61104 item,
61105 formField,
61106 promiseHandler
61107 );
61108 if (fieldValidity !== void 0) {
61109 newFormValidity[formField.id] = fieldValidity;
61110 }
61111 });
61112 setFormValidity((existingFormValidity) => {
61113 let validity = {
61114 ...existingFormValidity,
61115 ...newFormValidity
61116 };
61117 const fieldsToKeep = [
61118 ...untouchedFields,
61119 ...Object.keys(newFormValidity)
61120 ];
61121 Object.keys(validity).forEach((key) => {
61122 if (validity && !fieldsToKeep.includes(key)) {
61123 delete validity[key];
61124 }
61125 });
61126 if (Object.keys(validity).length === 0) {
61127 validity = void 0;
61128 }
61129 const areEqual = (0, import_es62.default)(existingFormValidity, validity);
61130 if (areEqual) {
61131 return existingFormValidity;
61132 }
61133 return validity;
61134 });
61135 }, [item, fields2, form]);
61136 (0, import_element197.useEffect)(() => {
61137 validate();
61138 }, [validate]);
61139 return {
61140 validity: formValidity,
61141 isValid: isFormValid(formValidity)
61142 };
61143 }
61144 var use_form_validity_default = useFormValidity;
61145
61146 // packages/dataviews/build-module/hooks/use-report-validity.mjs
61147 var import_element198 = __toESM(require_element(), 1);
61148 function useReportValidity(ref, shouldReport) {
61149 (0, import_element198.useEffect)(() => {
61150 if (shouldReport && ref.current) {
61151 const inputs = ref.current.querySelectorAll(
61152 "input, textarea, select"
61153 );
61154 inputs.forEach((input) => {
61155 input.reportValidity();
61156 });
61157 }
61158 }, [shouldReport, ref]);
61159 }
61160
61161 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
61162 var import_element199 = __toESM(require_element(), 1);
61163
61164 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
61165 function extractSummaryIds(summary) {
61166 if (Array.isArray(summary)) {
61167 return summary.map(
61168 (item) => typeof item === "string" ? item : item.id
61169 );
61170 }
61171 return [];
61172 }
61173 var getSummaryFields = (summaryField, fields2) => {
61174 if (Array.isArray(summaryField) && summaryField.length > 0) {
61175 const summaryIds = extractSummaryIds(summaryField);
61176 return summaryIds.map(
61177 (summaryId) => fields2.find((_field) => _field.id === summaryId)
61178 ).filter((_field) => _field !== void 0);
61179 }
61180 return [];
61181 };
61182
61183 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
61184 var getFieldDefinition = (field, fields2) => {
61185 const fieldDefinition = fields2.find((_field) => _field.id === field.id);
61186 if (!fieldDefinition) {
61187 return fields2.find((_field) => {
61188 if (!!field.children) {
61189 const simpleChildren = field.children.filter(
61190 (child) => !child.children
61191 );
61192 if (simpleChildren.length === 0) {
61193 return false;
61194 }
61195 return _field.id === simpleChildren[0].id;
61196 }
61197 return _field.id === field.id;
61198 });
61199 }
61200 return fieldDefinition;
61201 };
61202 function useFieldFromFormField(field) {
61203 const { fields: fields2 } = (0, import_element199.useContext)(dataform_context_default);
61204 const layout = field.layout;
61205 const summaryFields = getSummaryFields(layout.summary, fields2);
61206 const fieldDefinition = getFieldDefinition(field, fields2);
61207 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
61208 if (summaryFields.length === 0) {
61209 return {
61210 summaryFields: fieldDefinition ? [fieldDefinition] : [],
61211 fieldDefinition,
61212 fieldLabel
61213 };
61214 }
61215 return {
61216 summaryFields,
61217 fieldDefinition,
61218 fieldLabel
61219 };
61220 }
61221 var use_field_from_form_field_default = useFieldFromFormField;
61222
61223 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
61224 var import_jsx_runtime375 = __toESM(require_jsx_runtime(), 1);
61225 function ModalContent({
61226 data,
61227 field,
61228 onChange,
61229 fieldLabel,
61230 onClose,
61231 touched
61232 }) {
61233 const { fields: fields2 } = (0, import_element200.useContext)(dataform_context_default);
61234 const [changes, setChanges] = (0, import_element200.useState)({});
61235 const modalData = (0, import_element200.useMemo)(() => {
61236 return (0, import_deepmerge3.default)(data, changes, {
61237 arrayMerge: (target, source) => source
61238 });
61239 }, [data, changes]);
61240 const form = (0, import_element200.useMemo)(
61241 () => ({
61242 layout: DEFAULT_LAYOUT,
61243 fields: !!field.children ? field.children : (
61244 // If not explicit children return the field id itself.
61245 [{ id: field.id, layout: DEFAULT_LAYOUT }]
61246 )
61247 }),
61248 [field]
61249 );
61250 const fieldsAsFieldType = fields2.map((f3) => ({
61251 ...f3,
61252 Edit: f3.Edit === null ? void 0 : f3.Edit,
61253 isValid: {
61254 required: f3.isValid.required?.constraint,
61255 elements: f3.isValid.elements?.constraint,
61256 min: f3.isValid.min?.constraint,
61257 max: f3.isValid.max?.constraint,
61258 pattern: f3.isValid.pattern?.constraint,
61259 minLength: f3.isValid.minLength?.constraint,
61260 maxLength: f3.isValid.maxLength?.constraint
61261 }
61262 }));
61263 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
61264 const onApply = () => {
61265 onChange(changes);
61266 onClose();
61267 };
61268 const handleOnChange = (newValue) => {
61269 setChanges(
61270 (prev) => (0, import_deepmerge3.default)(prev, newValue, {
61271 arrayMerge: (target, source) => source
61272 })
61273 );
61274 };
61275 const focusOnMountRef = (0, import_compose62.useFocusOnMount)("firstInputElement");
61276 const contentRef = (0, import_element200.useRef)(null);
61277 const mergedRef = (0, import_compose62.useMergeRefs)([focusOnMountRef, contentRef]);
61278 useReportValidity(contentRef, touched);
61279 return /* @__PURE__ */ (0, import_jsx_runtime375.jsxs)(
61280 import_components221.Modal,
61281 {
61282 className: "dataforms-layouts-panel__modal",
61283 onRequestClose: onClose,
61284 isFullScreen: false,
61285 title: fieldLabel,
61286 size: "medium",
61287 children: [
61288 /* @__PURE__ */ (0, import_jsx_runtime375.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime375.jsx)(
61289 DataFormLayout,
61290 {
61291 data: modalData,
61292 form,
61293 onChange: handleOnChange,
61294 validity,
61295 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime375.jsx)(
61296 FieldLayout,
61297 {
61298 data: modalData,
61299 field: childField,
61300 onChange: handleOnChange,
61301 hideLabelFromVision: form.fields.length < 2,
61302 markWhenOptional,
61303 validity: childFieldValidity
61304 },
61305 childField.id
61306 )
61307 }
61308 ) }),
61309 /* @__PURE__ */ (0, import_jsx_runtime375.jsxs)(
61310 Stack,
61311 {
61312 direction: "row",
61313 className: "dataforms-layouts-panel__modal-footer",
61314 gap: "md",
61315 children: [
61316 /* @__PURE__ */ (0, import_jsx_runtime375.jsx)(import_components221.__experimentalSpacer, { style: { flex: 1 } }),
61317 /* @__PURE__ */ (0, import_jsx_runtime375.jsx)(
61318 import_components221.Button,
61319 {
61320 variant: "tertiary",
61321 onClick: onClose,
61322 __next40pxDefaultSize: true,
61323 children: (0, import_i18n240.__)("Cancel")
61324 }
61325 ),
61326 /* @__PURE__ */ (0, import_jsx_runtime375.jsx)(
61327 import_components221.Button,
61328 {
61329 variant: "primary",
61330 onClick: onApply,
61331 __next40pxDefaultSize: true,
61332 children: (0, import_i18n240.__)("Apply")
61333 }
61334 )
61335 ]
61336 }
61337 )
61338 ]
61339 }
61340 );
61341 }
61342 function PanelModal({
61343 data,
61344 field,
61345 onChange,
61346 validity
61347 }) {
61348 const [touched, setTouched] = (0, import_element200.useState)(false);
61349 const [isOpen, setIsOpen] = (0, import_element200.useState)(false);
61350 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
61351 if (!fieldDefinition) {
61352 return null;
61353 }
61354 const handleClose = () => {
61355 setIsOpen(false);
61356 setTouched(true);
61357 };
61358 return /* @__PURE__ */ (0, import_jsx_runtime375.jsxs)(import_jsx_runtime375.Fragment, { children: [
61359 /* @__PURE__ */ (0, import_jsx_runtime375.jsx)(
61360 SummaryButton,
61361 {
61362 data,
61363 field,
61364 fieldLabel,
61365 summaryFields,
61366 validity,
61367 touched,
61368 disabled: fieldDefinition.readOnly === true,
61369 onClick: () => setIsOpen(true),
61370 "aria-expanded": isOpen
61371 }
61372 ),
61373 isOpen && /* @__PURE__ */ (0, import_jsx_runtime375.jsx)(
61374 ModalContent,
61375 {
61376 data,
61377 field,
61378 onChange,
61379 fieldLabel: fieldLabel ?? "",
61380 onClose: handleClose,
61381 touched
61382 }
61383 )
61384 ] });
61385 }
61386 var modal_default2 = PanelModal;
61387
61388 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
61389 var import_components222 = __toESM(require_components(), 1);
61390 var import_i18n241 = __toESM(require_i18n(), 1);
61391 var import_element201 = __toESM(require_element(), 1);
61392 var import_compose63 = __toESM(require_compose(), 1);
61393 var import_jsx_runtime376 = __toESM(require_jsx_runtime(), 1);
61394 function DropdownHeader({
61395 title,
61396 onClose
61397 }) {
61398 return /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(
61399 Stack,
61400 {
61401 direction: "column",
61402 className: "dataforms-layouts-panel__dropdown-header",
61403 gap: "lg",
61404 children: /* @__PURE__ */ (0, import_jsx_runtime376.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
61405 title && /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(import_components222.__experimentalHeading, { level: 2, size: 13, children: title }),
61406 /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(import_components222.__experimentalSpacer, { style: { flex: 1 } }),
61407 onClose && /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(
61408 import_components222.Button,
61409 {
61410 label: (0, import_i18n241.__)("Close"),
61411 icon: close_small_default,
61412 onClick: onClose,
61413 size: "small"
61414 }
61415 )
61416 ] })
61417 }
61418 );
61419 }
61420 function DropdownContentWithValidation({
61421 touched,
61422 children
61423 }) {
61424 const ref = (0, import_element201.useRef)(null);
61425 useReportValidity(ref, touched);
61426 return /* @__PURE__ */ (0, import_jsx_runtime376.jsx)("div", { ref, children });
61427 }
61428 function PanelDropdown({
61429 data,
61430 field,
61431 onChange,
61432 validity
61433 }) {
61434 const [touched, setTouched] = (0, import_element201.useState)(false);
61435 const [popoverAnchor, setPopoverAnchor] = (0, import_element201.useState)(
61436 null
61437 );
61438 const popoverProps = (0, import_element201.useMemo)(
61439 () => ({
61440 // Anchor the popover to the middle of the entire row so that it doesn't
61441 // move around when the label changes.
61442 anchor: popoverAnchor,
61443 placement: "left-start",
61444 offset: 36,
61445 shift: true
61446 }),
61447 [popoverAnchor]
61448 );
61449 const [dialogRef, dialogProps] = (0, import_compose63.__experimentalUseDialog)({
61450 focusOnMount: "firstInputElement"
61451 });
61452 const form = (0, import_element201.useMemo)(
61453 () => ({
61454 layout: DEFAULT_LAYOUT,
61455 fields: !!field.children ? field.children : (
61456 // If not explicit children return the field id itself.
61457 [{ id: field.id, layout: DEFAULT_LAYOUT }]
61458 )
61459 }),
61460 [field]
61461 );
61462 const formValidity = (0, import_element201.useMemo)(() => {
61463 if (validity === void 0) {
61464 return void 0;
61465 }
61466 if (!!field.children) {
61467 return validity?.children;
61468 }
61469 return { [field.id]: validity };
61470 }, [validity, field]);
61471 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
61472 if (!fieldDefinition) {
61473 return null;
61474 }
61475 return /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(
61476 "div",
61477 {
61478 ref: setPopoverAnchor,
61479 className: "dataforms-layouts-panel__field-dropdown-anchor",
61480 children: /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(
61481 import_components222.Dropdown,
61482 {
61483 contentClassName: "dataforms-layouts-panel__field-dropdown",
61484 popoverProps,
61485 focusOnMount: false,
61486 onToggle: (willOpen) => {
61487 if (!willOpen) {
61488 setTouched(true);
61489 }
61490 },
61491 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(
61492 SummaryButton,
61493 {
61494 data,
61495 field,
61496 fieldLabel,
61497 summaryFields,
61498 validity,
61499 touched,
61500 disabled: fieldDefinition.readOnly === true,
61501 onClick: onToggle,
61502 "aria-expanded": isOpen
61503 }
61504 ),
61505 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime376.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
61506 /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(
61507 DropdownHeader,
61508 {
61509 title: fieldLabel,
61510 onClose
61511 }
61512 ),
61513 /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(
61514 DataFormLayout,
61515 {
61516 data,
61517 form,
61518 onChange,
61519 validity: formValidity,
61520 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime376.jsx)(
61521 FieldLayout,
61522 {
61523 data,
61524 field: childField,
61525 onChange,
61526 hideLabelFromVision: (form?.fields ?? []).length < 2,
61527 markWhenOptional,
61528 validity: childFieldValidity
61529 },
61530 childField.id
61531 )
61532 }
61533 )
61534 ] }) })
61535 }
61536 )
61537 }
61538 );
61539 }
61540 var dropdown_default = PanelDropdown;
61541
61542 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
61543 var import_jsx_runtime377 = __toESM(require_jsx_runtime(), 1);
61544 function FormPanelField({
61545 data,
61546 field,
61547 onChange,
61548 validity
61549 }) {
61550 const layout = field.layout;
61551 if (layout.openAs === "modal") {
61552 return /* @__PURE__ */ (0, import_jsx_runtime377.jsx)(
61553 modal_default2,
61554 {
61555 data,
61556 field,
61557 onChange,
61558 validity
61559 }
61560 );
61561 }
61562 return /* @__PURE__ */ (0, import_jsx_runtime377.jsx)(
61563 dropdown_default,
61564 {
61565 data,
61566 field,
61567 onChange,
61568 validity
61569 }
61570 );
61571 }
61572
61573 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
61574 var import_components223 = __toESM(require_components(), 1);
61575 var import_compose64 = __toESM(require_compose(), 1);
61576 var import_element202 = __toESM(require_element(), 1);
61577 var import_i18n243 = __toESM(require_i18n(), 1);
61578
61579 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
61580 var import_i18n242 = __toESM(require_i18n(), 1);
61581 var import_jsx_runtime378 = __toESM(require_jsx_runtime(), 1);
61582 function countInvalidFields(validity) {
61583 if (!validity) {
61584 return 0;
61585 }
61586 let count = 0;
61587 const validityRules = Object.keys(validity).filter(
61588 (key) => key !== "children"
61589 );
61590 for (const key of validityRules) {
61591 const rule = validity[key];
61592 if (rule?.type === "invalid") {
61593 count++;
61594 }
61595 }
61596 if (validity.children) {
61597 for (const childValidity of Object.values(validity.children)) {
61598 count += countInvalidFields(childValidity);
61599 }
61600 }
61601 return count;
61602 }
61603 function ValidationBadge({
61604 validity
61605 }) {
61606 const invalidCount = countInvalidFields(validity);
61607 if (invalidCount === 0) {
61608 return null;
61609 }
61610 return /* @__PURE__ */ (0, import_jsx_runtime378.jsx)(Badge2, { intent: "high", children: (0, import_i18n242.sprintf)(
61611 /* translators: %d: Number of fields that need attention */
61612 (0, import_i18n242._n)(
61613 "%d field needs attention",
61614 "%d fields need attention",
61615 invalidCount
61616 ),
61617 invalidCount
61618 ) });
61619 }
61620
61621 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
61622 var import_jsx_runtime379 = __toESM(require_jsx_runtime(), 1);
61623 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
61624 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
61625 return false;
61626 }
61627 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
61628 const fieldConfig = summaryConfigArray.find((config2) => {
61629 if (typeof config2 === "string") {
61630 return config2 === summaryField.id;
61631 }
61632 if (typeof config2 === "object" && "id" in config2) {
61633 return config2.id === summaryField.id;
61634 }
61635 return false;
61636 });
61637 if (!fieldConfig) {
61638 return false;
61639 }
61640 if (typeof fieldConfig === "string") {
61641 return true;
61642 }
61643 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
61644 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
61645 }
61646 return true;
61647 }
61648 function FormCardField({
61649 data,
61650 field,
61651 onChange,
61652 hideLabelFromVision,
61653 markWhenOptional,
61654 validity
61655 }) {
61656 const { fields: fields2 } = (0, import_element202.useContext)(dataform_context_default);
61657 const layout = field.layout;
61658 const cardBodyRef = (0, import_element202.useRef)(null);
61659 const bodyId = (0, import_compose64.useInstanceId)(
61660 FormCardField,
61661 "dataforms-layouts-card-card-body"
61662 );
61663 const form = (0, import_element202.useMemo)(
61664 () => ({
61665 layout: DEFAULT_LAYOUT,
61666 fields: field.children ?? []
61667 }),
61668 [field]
61669 );
61670 const { isOpened, isCollapsible } = layout;
61671 const [internalIsOpen, setIsOpen] = (0, import_element202.useState)(isOpened);
61672 const [touched, setTouched] = (0, import_element202.useState)(false);
61673 (0, import_element202.useEffect)(() => {
61674 setIsOpen(isOpened);
61675 }, [isOpened]);
61676 const toggle = (0, import_element202.useCallback)(() => {
61677 setIsOpen((prev) => {
61678 if (prev) {
61679 setTouched(true);
61680 }
61681 return !prev;
61682 });
61683 }, []);
61684 const isOpen = isCollapsible ? internalIsOpen : true;
61685 const handleBlur = (0, import_element202.useCallback)(() => {
61686 setTouched(true);
61687 }, [setTouched]);
61688 useReportValidity(cardBodyRef, isOpen && touched);
61689 const summaryFields = getSummaryFields(layout.summary, fields2);
61690 const visibleSummaryFields = summaryFields.filter(
61691 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
61692 );
61693 const validationBadge = touched && layout.isCollapsible ? /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(ValidationBadge, { validity }) : null;
61694 const sizeCard = {
61695 blockStart: "medium",
61696 blockEnd: "medium",
61697 inlineStart: "medium",
61698 inlineEnd: "medium"
61699 };
61700 let label = field.label;
61701 let withHeader;
61702 let bodyContent;
61703 if (field.children) {
61704 withHeader = !!label && layout.withHeader;
61705 bodyContent = /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)(import_jsx_runtime379.Fragment, { children: [
61706 field.description && /* @__PURE__ */ (0, import_jsx_runtime379.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
61707 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(
61708 DataFormLayout,
61709 {
61710 data,
61711 form,
61712 onChange,
61713 validity: validity?.children
61714 }
61715 )
61716 ] });
61717 } else {
61718 const fieldDefinition = fields2.find(
61719 (fieldDef) => fieldDef.id === field.id
61720 );
61721 if (!fieldDefinition || !fieldDefinition.Edit) {
61722 return null;
61723 }
61724 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
61725 if (!SingleFieldLayout) {
61726 return null;
61727 }
61728 label = fieldDefinition.label;
61729 withHeader = !!label && layout.withHeader;
61730 bodyContent = /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(
61731 SingleFieldLayout,
61732 {
61733 data,
61734 field,
61735 onChange,
61736 hideLabelFromVision: hideLabelFromVision || withHeader,
61737 markWhenOptional,
61738 validity
61739 }
61740 );
61741 }
61742 const sizeCardBody = {
61743 blockStart: withHeader ? "none" : "medium",
61744 blockEnd: "medium",
61745 inlineStart: "medium",
61746 inlineEnd: "medium"
61747 };
61748 return /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)(import_components223.Card, { className: "dataforms-layouts-card__field", size: sizeCard, children: [
61749 withHeader && /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)(
61750 import_components223.CardHeader,
61751 {
61752 className: "dataforms-layouts-card__field-header",
61753 onClick: isCollapsible ? toggle : void 0,
61754 style: {
61755 cursor: isCollapsible ? "pointer" : void 0
61756 },
61757 isBorderless: true,
61758 children: [
61759 /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)(
61760 "div",
61761 {
61762 style: {
61763 // Match the expand/collapse button's height to avoid layout
61764 // differences when that button is not displayed.
61765 height: isCollapsible ? void 0 : "40px",
61766 width: "100%",
61767 display: "flex",
61768 justifyContent: "space-between",
61769 alignItems: "center"
61770 },
61771 children: [
61772 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)("span", { className: "dataforms-layouts-card__field-header-label", children: label }),
61773 validationBadge,
61774 visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */ (0, import_jsx_runtime379.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map(
61775 (summaryField) => /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(
61776 summaryField.render,
61777 {
61778 item: data,
61779 field: summaryField
61780 },
61781 summaryField.id
61782 )
61783 ) })
61784 ]
61785 }
61786 ),
61787 isCollapsible && /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(
61788 import_components223.Button,
61789 {
61790 __next40pxDefaultSize: true,
61791 variant: "tertiary",
61792 icon: isOpen ? chevron_up_default : chevron_down_default,
61793 "aria-expanded": isOpen,
61794 "aria-controls": bodyId,
61795 "aria-label": isOpen ? (0, import_i18n243.__)("Collapse") : (0, import_i18n243.__)("Expand")
61796 }
61797 )
61798 ]
61799 }
61800 ),
61801 (isOpen || !withHeader) && // If it doesn't have a header, keep it open.
61802 // Otherwise, the card will not be visible.
61803 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)(
61804 import_components223.CardBody,
61805 {
61806 id: bodyId,
61807 size: sizeCardBody,
61808 className: "dataforms-layouts-card__field-control",
61809 ref: cardBodyRef,
61810 onBlur: handleBlur,
61811 children: bodyContent
61812 }
61813 )
61814 ] });
61815 }
61816
61817 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
61818 var import_components224 = __toESM(require_components(), 1);
61819 var import_jsx_runtime380 = __toESM(require_jsx_runtime(), 1);
61820 function Header3({ title }) {
61821 return /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(
61822 Stack,
61823 {
61824 direction: "column",
61825 className: "dataforms-layouts-row__header",
61826 gap: "lg",
61827 children: /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(import_components224.__experimentalHeading, { level: 2, size: 13, children: title }) })
61828 }
61829 );
61830 }
61831 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(import_jsx_runtime380.Fragment, { children });
61832 function FormRowField({
61833 data,
61834 field,
61835 onChange,
61836 hideLabelFromVision,
61837 markWhenOptional,
61838 validity
61839 }) {
61840 const layout = field.layout;
61841 if (!!field.children) {
61842 const form = {
61843 layout: DEFAULT_LAYOUT,
61844 fields: field.children
61845 };
61846 return /* @__PURE__ */ (0, import_jsx_runtime380.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
61847 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(Header3, { title: field.label }),
61848 /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(
61849 DataFormLayout,
61850 {
61851 data,
61852 form,
61853 onChange,
61854 validity: validity?.children,
61855 as: EMPTY_WRAPPER,
61856 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(
61857 "div",
61858 {
61859 className: "dataforms-layouts-row__field-control",
61860 style: layout.styles[childField.id],
61861 children: /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(
61862 FieldLayout,
61863 {
61864 data,
61865 field: childField,
61866 onChange,
61867 hideLabelFromVision,
61868 markWhenOptional,
61869 validity: childFieldValidity
61870 }
61871 )
61872 },
61873 childField.id
61874 )
61875 }
61876 ) })
61877 ] });
61878 }
61879 const RegularLayout = getFormFieldLayout("regular")?.component;
61880 if (!RegularLayout) {
61881 return null;
61882 }
61883 return /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(import_jsx_runtime380.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime380.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime380.jsx)(
61884 RegularLayout,
61885 {
61886 data,
61887 field,
61888 onChange,
61889 markWhenOptional,
61890 validity
61891 }
61892 ) }) });
61893 }
61894
61895 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
61896 var import_element203 = __toESM(require_element(), 1);
61897 var import_i18n244 = __toESM(require_i18n(), 1);
61898 var import_jsx_runtime381 = __toESM(require_jsx_runtime(), 1);
61899 function FormDetailsField({
61900 data,
61901 field,
61902 onChange,
61903 validity
61904 }) {
61905 const { fields: fields2 } = (0, import_element203.useContext)(dataform_context_default);
61906 const detailsRef = (0, import_element203.useRef)(null);
61907 const contentRef = (0, import_element203.useRef)(null);
61908 const [touched, setTouched] = (0, import_element203.useState)(false);
61909 const [isOpen, setIsOpen] = (0, import_element203.useState)(false);
61910 const form = (0, import_element203.useMemo)(
61911 () => ({
61912 layout: DEFAULT_LAYOUT,
61913 fields: field.children ?? []
61914 }),
61915 [field]
61916 );
61917 (0, import_element203.useEffect)(() => {
61918 const details = detailsRef.current;
61919 if (!details) {
61920 return;
61921 }
61922 const handleToggle = () => {
61923 const nowOpen = details.open;
61924 if (!nowOpen) {
61925 setTouched(true);
61926 }
61927 setIsOpen(nowOpen);
61928 };
61929 details.addEventListener("toggle", handleToggle);
61930 return () => {
61931 details.removeEventListener("toggle", handleToggle);
61932 };
61933 }, []);
61934 useReportValidity(contentRef, isOpen && touched);
61935 const handleBlur = (0, import_element203.useCallback)(() => {
61936 setTouched(true);
61937 }, []);
61938 if (!field.children) {
61939 return null;
61940 }
61941 const summaryFieldId = field.layout.summary ?? "";
61942 const summaryField = summaryFieldId ? fields2.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
61943 let summaryContent;
61944 if (summaryField && summaryField.render) {
61945 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime381.jsx)(summaryField.render, { item: data, field: summaryField });
61946 } else {
61947 summaryContent = field.label || (0, import_i18n244.__)("More details");
61948 }
61949 return /* @__PURE__ */ (0, import_jsx_runtime381.jsxs)(
61950 "details",
61951 {
61952 ref: detailsRef,
61953 className: "dataforms-layouts-details__details",
61954 children: [
61955 /* @__PURE__ */ (0, import_jsx_runtime381.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime381.jsxs)(
61956 Stack,
61957 {
61958 direction: "row",
61959 align: "center",
61960 gap: "md",
61961 className: "dataforms-layouts-details__summary-content",
61962 children: [
61963 summaryContent,
61964 touched && /* @__PURE__ */ (0, import_jsx_runtime381.jsx)(ValidationBadge, { validity })
61965 ]
61966 }
61967 ) }),
61968 /* @__PURE__ */ (0, import_jsx_runtime381.jsx)(
61969 "div",
61970 {
61971 ref: contentRef,
61972 className: "dataforms-layouts-details__content",
61973 onBlur: handleBlur,
61974 children: /* @__PURE__ */ (0, import_jsx_runtime381.jsx)(
61975 DataFormLayout,
61976 {
61977 data,
61978 form,
61979 onChange,
61980 validity: validity?.children
61981 }
61982 )
61983 }
61984 )
61985 ]
61986 }
61987 );
61988 }
61989
61990 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
61991 var import_jsx_runtime382 = __toESM(require_jsx_runtime(), 1);
61992 var FORM_FIELD_LAYOUTS = [
61993 {
61994 type: "regular",
61995 component: FormRegularField,
61996 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(
61997 Stack,
61998 {
61999 direction: "column",
62000 className: "dataforms-layouts__wrapper",
62001 gap: "lg",
62002 children
62003 }
62004 )
62005 },
62006 {
62007 type: "panel",
62008 component: FormPanelField,
62009 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(
62010 Stack,
62011 {
62012 direction: "column",
62013 className: "dataforms-layouts__wrapper",
62014 gap: "md",
62015 children
62016 }
62017 )
62018 },
62019 {
62020 type: "card",
62021 component: FormCardField,
62022 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(
62023 Stack,
62024 {
62025 direction: "column",
62026 className: "dataforms-layouts__wrapper",
62027 gap: "xl",
62028 children
62029 }
62030 )
62031 },
62032 {
62033 type: "row",
62034 component: FormRowField,
62035 wrapper: ({
62036 children,
62037 layout
62038 }) => /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(
62039 Stack,
62040 {
62041 direction: "column",
62042 className: "dataforms-layouts__wrapper",
62043 gap: "lg",
62044 children: /* @__PURE__ */ (0, import_jsx_runtime382.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(
62045 Stack,
62046 {
62047 direction: "row",
62048 gap: "lg",
62049 align: layout.alignment,
62050 children
62051 }
62052 ) })
62053 }
62054 )
62055 },
62056 {
62057 type: "details",
62058 component: FormDetailsField
62059 }
62060 ];
62061 function getFormFieldLayout(type) {
62062 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
62063 }
62064
62065 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
62066 var import_jsx_runtime383 = __toESM(require_jsx_runtime(), 1);
62067 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime383.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
62068 function DataFormLayout({
62069 data,
62070 form,
62071 onChange,
62072 validity,
62073 children,
62074 as
62075 }) {
62076 const { fields: fieldDefinitions } = (0, import_element204.useContext)(dataform_context_default);
62077 const markWhenOptional = (0, import_element204.useMemo)(() => {
62078 const requiredCount = fieldDefinitions.filter(
62079 (f3) => !!f3.isValid?.required
62080 ).length;
62081 const optionalCount = fieldDefinitions.length - requiredCount;
62082 return requiredCount > optionalCount;
62083 }, [fieldDefinitions]);
62084 function getFieldDefinition2(field) {
62085 return fieldDefinitions.find(
62086 (fieldDefinition) => fieldDefinition.id === field.id
62087 );
62088 }
62089 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
62090 return /* @__PURE__ */ (0, import_jsx_runtime383.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
62091 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
62092 if (!FieldLayout) {
62093 return null;
62094 }
62095 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
62096 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
62097 return null;
62098 }
62099 if (children) {
62100 return children(
62101 FieldLayout,
62102 formField,
62103 validity?.[formField.id],
62104 markWhenOptional
62105 );
62106 }
62107 return /* @__PURE__ */ (0, import_jsx_runtime383.jsx)(
62108 FieldLayout,
62109 {
62110 data,
62111 field: formField,
62112 onChange,
62113 markWhenOptional,
62114 validity: validity?.[formField.id]
62115 },
62116 formField.id
62117 );
62118 }) });
62119 }
62120
62121 // packages/dataviews/build-module/dataform/index.mjs
62122 var import_jsx_runtime384 = __toESM(require_jsx_runtime(), 1);
62123 function DataForm({
62124 data,
62125 form,
62126 fields: fields2,
62127 onChange,
62128 validity
62129 }) {
62130 const normalizedForm = (0, import_element205.useMemo)(() => normalize_form_default(form), [form]);
62131 const normalizedFields = (0, import_element205.useMemo)(
62132 () => normalizeFields(fields2),
62133 [fields2]
62134 );
62135 if (!form.fields) {
62136 return null;
62137 }
62138 return /* @__PURE__ */ (0, import_jsx_runtime384.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime384.jsx)(
62139 DataFormLayout,
62140 {
62141 data,
62142 form: normalizedForm,
62143 onChange,
62144 validity
62145 }
62146 ) });
62147 }
62148
62149 // packages/media-editor/build-module/components/media-form/index.mjs
62150 var import_components225 = __toESM(require_components(), 1);
62151 var import_jsx_runtime385 = __toESM(require_jsx_runtime(), 1);
62152 function MediaForm({
62153 form: formOverrides,
62154 header
62155 }) {
62156 const { media, fields: fields2, onChange } = useMediaEditorContext();
62157 if (!media || !onChange) {
62158 return /* @__PURE__ */ (0, import_jsx_runtime385.jsx)("div", { className: "media-editor-form media-editor-form--loading", children: /* @__PURE__ */ (0, import_jsx_runtime385.jsx)(import_components225.Spinner, {}) });
62159 }
62160 const defaultForm = {
62161 layout: {
62162 type: "panel"
62163 },
62164 fields: fields2.map((field) => {
62165 if (["title", "alt_text", "caption", "description"].includes(
62166 field.id
62167 )) {
62168 return {
62169 id: field.id,
62170 layout: {
62171 type: "regular",
62172 labelPosition: "top"
62173 }
62174 };
62175 }
62176 return field.id;
62177 })
62178 };
62179 const form = formOverrides || defaultForm;
62180 return /* @__PURE__ */ (0, import_jsx_runtime385.jsx)("div", { className: "media-editor-form", children: /* @__PURE__ */ (0, import_jsx_runtime385.jsxs)(import_components225.__experimentalVStack, { spacing: 4, children: [
62181 header,
62182 /* @__PURE__ */ (0, import_jsx_runtime385.jsx)(
62183 DataForm,
62184 {
62185 data: media,
62186 fields: fields2,
62187 form,
62188 onChange
62189 }
62190 )
62191 ] }) });
62192 }
62193
62194 // packages/editor/build-module/components/media/preview.mjs
62195 var import_data209 = __toESM(require_data(), 1);
62196 var import_jsx_runtime386 = __toESM(require_jsx_runtime(), 1);
62197 function MediaPreview3(props) {
62198 const { media } = (0, import_data209.useSelect)((select6) => {
62199 const currentPost = select6(store).getCurrentPost();
62200 return {
62201 media: currentPost
62202 };
62203 }, []);
62204 return /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(MediaEditorProvider, { value: media, children: /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(MediaPreview2, { ...props }) });
62205 }
62206
62207 // packages/editor/build-module/components/media/metadata-panel.mjs
62208 var import_data216 = __toESM(require_data(), 1);
62209 var import_element212 = __toESM(require_element(), 1);
62210 var import_core_data124 = __toESM(require_core_data(), 1);
62211
62212 // packages/editor/build-module/components/post-fields/index.mjs
62213 var import_element206 = __toESM(require_element(), 1);
62214 var import_data210 = __toESM(require_data(), 1);
62215 function usePostFields({
62216 postType: postType2
62217 }) {
62218 const { registerPostTypeSchema: registerPostTypeSchema2 } = unlock((0, import_data210.useDispatch)(store));
62219 (0, import_element206.useEffect)(() => {
62220 registerPostTypeSchema2(postType2);
62221 }, [registerPostTypeSchema2, postType2]);
62222 const { fields: fields2 } = (0, import_data210.useSelect)(
62223 (select6) => {
62224 const { getEntityFields: getEntityFields3 } = unlock(select6(store));
62225 return {
62226 fields: getEntityFields3("postType", postType2)
62227 };
62228 },
62229 [postType2]
62230 );
62231 return fields2;
62232 }
62233 var post_fields_default = usePostFields;
62234
62235 // packages/editor/build-module/components/post-card-panel/index.mjs
62236 var import_components229 = __toESM(require_components(), 1);
62237 var import_core_data123 = __toESM(require_core_data(), 1);
62238 var import_data215 = __toESM(require_data(), 1);
62239 var import_element211 = __toESM(require_element(), 1);
62240 var import_i18n248 = __toESM(require_i18n(), 1);
62241 var import_dom5 = __toESM(require_dom(), 1);
62242
62243 // packages/editor/build-module/components/post-actions/index.mjs
62244 var import_data214 = __toESM(require_data(), 1);
62245 var import_element210 = __toESM(require_element(), 1);
62246 var import_i18n247 = __toESM(require_i18n(), 1);
62247 var import_components228 = __toESM(require_components(), 1);
62248 var import_core_data122 = __toESM(require_core_data(), 1);
62249
62250 // packages/editor/build-module/components/post-actions/actions.mjs
62251 var import_data213 = __toESM(require_data(), 1);
62252 var import_element209 = __toESM(require_element(), 1);
62253 var import_core_data121 = __toESM(require_core_data(), 1);
62254
62255 // packages/editor/build-module/components/post-actions/set-as-homepage.mjs
62256 var import_i18n245 = __toESM(require_i18n(), 1);
62257 var import_element207 = __toESM(require_element(), 1);
62258 var import_components226 = __toESM(require_components(), 1);
62259 var import_data211 = __toESM(require_data(), 1);
62260 var import_core_data119 = __toESM(require_core_data(), 1);
62261 var import_notices29 = __toESM(require_notices(), 1);
62262
62263 // packages/editor/build-module/utils/get-item-title.mjs
62264 var import_html_entities26 = __toESM(require_html_entities(), 1);
62265 function getItemTitle2(item) {
62266 if (typeof item.title === "string") {
62267 return (0, import_html_entities26.decodeEntities)(item.title);
62268 }
62269 if (item.title && "rendered" in item.title) {
62270 return (0, import_html_entities26.decodeEntities)(item.title.rendered);
62271 }
62272 if (item.title && "raw" in item.title) {
62273 return (0, import_html_entities26.decodeEntities)(item.title.raw);
62274 }
62275 return "";
62276 }
62277
62278 // packages/editor/build-module/components/post-actions/set-as-homepage.mjs
62279 var import_jsx_runtime387 = __toESM(require_jsx_runtime(), 1);
62280 var SetAsHomepageModal = ({ items, closeModal: closeModal2 }) => {
62281 const [item] = items;
62282 const pageTitle = getItemTitle2(item);
62283 const { showOnFront, currentHomePage, isSaving } = (0, import_data211.useSelect)(
62284 (select6) => {
62285 const { getEntityRecord, isSavingEntityRecord } = select6(import_core_data119.store);
62286 const siteSettings = getEntityRecord("root", "site");
62287 const currentHomePageItem = getEntityRecord(
62288 "postType",
62289 "page",
62290 siteSettings?.page_on_front
62291 );
62292 return {
62293 showOnFront: siteSettings?.show_on_front,
62294 currentHomePage: currentHomePageItem,
62295 isSaving: isSavingEntityRecord("root", "site")
62296 };
62297 }
62298 );
62299 const { saveEntityRecord } = (0, import_data211.useDispatch)(import_core_data119.store);
62300 const { createSuccessNotice, createErrorNotice } = (0, import_data211.useDispatch)(import_notices29.store);
62301 async function onSetPageAsHomepage(event) {
62302 event.preventDefault();
62303 try {
62304 await saveEntityRecord("root", "site", {
62305 page_on_front: item.id,
62306 show_on_front: "page"
62307 });
62308 createSuccessNotice((0, import_i18n245.__)("Homepage updated."), {
62309 type: "snackbar"
62310 });
62311 } catch (error) {
62312 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n245.__)("An error occurred while setting the homepage.");
62313 createErrorNotice(errorMessage, { type: "snackbar" });
62314 } finally {
62315 closeModal2?.();
62316 }
62317 }
62318 let modalWarning = "";
62319 if ("posts" === showOnFront) {
62320 modalWarning = (0, import_i18n245.__)(
62321 "This will replace the current homepage which is set to display latest posts."
62322 );
62323 } else if (currentHomePage) {
62324 modalWarning = (0, import_i18n245.sprintf)(
62325 // translators: %s: title of the current home page.
62326 (0, import_i18n245.__)('This will replace the current homepage: "%s"'),
62327 getItemTitle2(currentHomePage)
62328 );
62329 }
62330 const modalText = (0, import_i18n245.sprintf)(
62331 // translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message.
62332 (0, import_i18n245.__)('Set "%1$s" as the site homepage? %2$s'),
62333 pageTitle,
62334 modalWarning
62335 ).trim();
62336 const modalButtonLabel = (0, import_i18n245.__)("Set homepage");
62337 return /* @__PURE__ */ (0, import_jsx_runtime387.jsx)("form", { onSubmit: onSetPageAsHomepage, children: /* @__PURE__ */ (0, import_jsx_runtime387.jsxs)(import_components226.__experimentalVStack, { spacing: "5", children: [
62338 /* @__PURE__ */ (0, import_jsx_runtime387.jsx)(import_components226.__experimentalText, { children: modalText }),
62339 /* @__PURE__ */ (0, import_jsx_runtime387.jsxs)(import_components226.__experimentalHStack, { justify: "right", children: [
62340 /* @__PURE__ */ (0, import_jsx_runtime387.jsx)(
62341 import_components226.Button,
62342 {
62343 __next40pxDefaultSize: true,
62344 variant: "tertiary",
62345 onClick: () => {
62346 closeModal2?.();
62347 },
62348 disabled: isSaving,
62349 accessibleWhenDisabled: true,
62350 children: (0, import_i18n245.__)("Cancel")
62351 }
62352 ),
62353 /* @__PURE__ */ (0, import_jsx_runtime387.jsx)(
62354 import_components226.Button,
62355 {
62356 __next40pxDefaultSize: true,
62357 variant: "primary",
62358 type: "submit",
62359 disabled: isSaving,
62360 accessibleWhenDisabled: true,
62361 children: modalButtonLabel
62362 }
62363 )
62364 ] })
62365 ] }) });
62366 };
62367 var useSetAsHomepageAction = () => {
62368 const { pageOnFront, pageForPosts } = (0, import_data211.useSelect)((select6) => {
62369 const { getEntityRecord, canUser } = select6(import_core_data119.store);
62370 const siteSettings = canUser("read", {
62371 kind: "root",
62372 name: "site"
62373 }) ? getEntityRecord("root", "site") : void 0;
62374 return {
62375 pageOnFront: siteSettings?.page_on_front,
62376 pageForPosts: siteSettings?.page_for_posts
62377 };
62378 });
62379 return (0, import_element207.useMemo)(
62380 () => ({
62381 id: "set-as-homepage",
62382 label: (0, import_i18n245.__)("Set as homepage"),
62383 isEligible(post2) {
62384 if (post2.status !== "publish") {
62385 return false;
62386 }
62387 if (post2.type !== "page") {
62388 return false;
62389 }
62390 if (pageOnFront === post2.id) {
62391 return false;
62392 }
62393 if (pageForPosts === post2.id) {
62394 return false;
62395 }
62396 return true;
62397 },
62398 modalFocusOnMount: "firstContentElement",
62399 RenderModal: SetAsHomepageModal
62400 }),
62401 [pageForPosts, pageOnFront]
62402 );
62403 };
62404
62405 // packages/editor/build-module/components/post-actions/set-as-posts-page.mjs
62406 var import_i18n246 = __toESM(require_i18n(), 1);
62407 var import_element208 = __toESM(require_element(), 1);
62408 var import_components227 = __toESM(require_components(), 1);
62409 var import_data212 = __toESM(require_data(), 1);
62410 var import_core_data120 = __toESM(require_core_data(), 1);
62411 var import_notices30 = __toESM(require_notices(), 1);
62412 var import_jsx_runtime388 = __toESM(require_jsx_runtime(), 1);
62413 var SetAsPostsPageModal = ({ items, closeModal: closeModal2 }) => {
62414 const [item] = items;
62415 const pageTitle = getItemTitle2(item);
62416 const { currentPostsPage, isPageForPostsSet, isSaving } = (0, import_data212.useSelect)(
62417 (select6) => {
62418 const { getEntityRecord, isSavingEntityRecord } = select6(import_core_data120.store);
62419 const siteSettings = getEntityRecord("root", "site");
62420 const currentPostsPageItem = getEntityRecord(
62421 "postType",
62422 "page",
62423 siteSettings?.page_for_posts
62424 );
62425 return {
62426 currentPostsPage: currentPostsPageItem,
62427 isPageForPostsSet: siteSettings?.page_for_posts !== 0,
62428 isSaving: isSavingEntityRecord("root", "site")
62429 };
62430 }
62431 );
62432 const { saveEntityRecord } = (0, import_data212.useDispatch)(import_core_data120.store);
62433 const { createSuccessNotice, createErrorNotice } = (0, import_data212.useDispatch)(import_notices30.store);
62434 async function onSetPageAsPostsPage(event) {
62435 event.preventDefault();
62436 try {
62437 await saveEntityRecord("root", "site", {
62438 page_for_posts: item.id,
62439 show_on_front: "page"
62440 });
62441 createSuccessNotice((0, import_i18n246.__)("Posts page updated."), {
62442 type: "snackbar"
62443 });
62444 } catch (error) {
62445 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n246.__)("An error occurred while setting the posts page.");
62446 createErrorNotice(errorMessage, { type: "snackbar" });
62447 } finally {
62448 closeModal2?.();
62449 }
62450 }
62451 const modalWarning = isPageForPostsSet && currentPostsPage ? (0, import_i18n246.sprintf)(
62452 // translators: %s: title of the current posts page.
62453 (0, import_i18n246.__)('This will replace the current posts page: "%s"'),
62454 getItemTitle2(currentPostsPage)
62455 ) : (0, import_i18n246.__)("This page will show the latest posts.");
62456 const modalText = (0, import_i18n246.sprintf)(
62457 // translators: %1$s: title of the page to be set as the posts page, %2$s: posts page replacement warning message.
62458 (0, import_i18n246.__)('Set "%1$s" as the posts page? %2$s'),
62459 pageTitle,
62460 modalWarning
62461 );
62462 const modalButtonLabel = (0, import_i18n246.__)("Set posts page");
62463 return /* @__PURE__ */ (0, import_jsx_runtime388.jsx)("form", { onSubmit: onSetPageAsPostsPage, children: /* @__PURE__ */ (0, import_jsx_runtime388.jsxs)(import_components227.__experimentalVStack, { spacing: "5", children: [
62464 /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(import_components227.__experimentalText, { children: modalText }),
62465 /* @__PURE__ */ (0, import_jsx_runtime388.jsxs)(import_components227.__experimentalHStack, { justify: "right", children: [
62466 /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(
62467 import_components227.Button,
62468 {
62469 __next40pxDefaultSize: true,
62470 variant: "tertiary",
62471 onClick: () => {
62472 closeModal2?.();
62473 },
62474 disabled: isSaving,
62475 accessibleWhenDisabled: true,
62476 children: (0, import_i18n246.__)("Cancel")
62477 }
62478 ),
62479 /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(
62480 import_components227.Button,
62481 {
62482 __next40pxDefaultSize: true,
62483 variant: "primary",
62484 type: "submit",
62485 disabled: isSaving,
62486 accessibleWhenDisabled: true,
62487 children: modalButtonLabel
62488 }
62489 )
62490 ] })
62491 ] }) });
62492 };
62493 var useSetAsPostsPageAction = () => {
62494 const { pageOnFront, pageForPosts } = (0, import_data212.useSelect)((select6) => {
62495 const { getEntityRecord, canUser } = select6(import_core_data120.store);
62496 const siteSettings = canUser("read", {
62497 kind: "root",
62498 name: "site"
62499 }) ? getEntityRecord("root", "site") : void 0;
62500 return {
62501 pageOnFront: siteSettings?.page_on_front,
62502 pageForPosts: siteSettings?.page_for_posts
62503 };
62504 });
62505 return (0, import_element208.useMemo)(
62506 () => ({
62507 id: "set-as-posts-page",
62508 label: (0, import_i18n246.__)("Set as posts page"),
62509 isEligible(post2) {
62510 if (post2.status !== "publish") {
62511 return false;
62512 }
62513 if (post2.type !== "page") {
62514 return false;
62515 }
62516 if (pageOnFront === post2.id) {
62517 return false;
62518 }
62519 if (pageForPosts === post2.id) {
62520 return false;
62521 }
62522 return true;
62523 },
62524 modalFocusOnMount: "firstContentElement",
62525 RenderModal: SetAsPostsPageModal
62526 }),
62527 [pageForPosts, pageOnFront]
62528 );
62529 };
62530
62531 // packages/editor/build-module/components/post-actions/actions.mjs
62532 var import_jsx_runtime389 = __toESM(require_jsx_runtime(), 1);
62533 function usePostActions({ postType: postType2, onActionPerformed, context }) {
62534 const { defaultActions } = (0, import_data213.useSelect)(
62535 (select6) => {
62536 const { getEntityActions: getEntityActions3 } = unlock(select6(store));
62537 return {
62538 defaultActions: getEntityActions3("postType", postType2)
62539 };
62540 },
62541 [postType2]
62542 );
62543 const shouldShowHomepageActions = (0, import_data213.useSelect)(
62544 (select6) => {
62545 if (postType2 !== "page") {
62546 return false;
62547 }
62548 const { getDefaultTemplateId, getEntityRecord, canUser } = select6(import_core_data121.store);
62549 const canUpdateSettings = canUser("update", {
62550 kind: "root",
62551 name: "site"
62552 });
62553 if (!canUpdateSettings) {
62554 return false;
62555 }
62556 const frontPageTemplateId = getDefaultTemplateId({
62557 slug: "front-page"
62558 });
62559 if (!frontPageTemplateId) {
62560 return true;
62561 }
62562 const frontPageTemplate = getEntityRecord(
62563 "postType",
62564 "wp_template",
62565 frontPageTemplateId
62566 );
62567 if (!frontPageTemplate) {
62568 return true;
62569 }
62570 return frontPageTemplate.slug !== "front-page";
62571 },
62572 [postType2]
62573 );
62574 const setAsHomepageAction = useSetAsHomepageAction();
62575 const setAsPostsPageAction = useSetAsPostsPageAction();
62576 const { registerPostTypeSchema: registerPostTypeSchema2 } = unlock((0, import_data213.useDispatch)(store));
62577 (0, import_element209.useEffect)(() => {
62578 registerPostTypeSchema2(postType2);
62579 }, [registerPostTypeSchema2, postType2]);
62580 return (0, import_element209.useMemo)(() => {
62581 let actions2 = [...defaultActions];
62582 if (shouldShowHomepageActions) {
62583 actions2.push(setAsHomepageAction, setAsPostsPageAction);
62584 }
62585 actions2 = actions2.sort(
62586 (a3, b3) => b3.id === "move-to-trash" ? -1 : 0
62587 );
62588 actions2 = actions2.filter((action) => {
62589 if (!action.context) {
62590 return true;
62591 }
62592 return action.context === context;
62593 });
62594 if (onActionPerformed) {
62595 for (let i3 = 0; i3 < actions2.length; ++i3) {
62596 if (actions2[i3].callback) {
62597 const existingCallback = actions2[i3].callback;
62598 actions2[i3] = {
62599 ...actions2[i3],
62600 callback: (items, argsObject) => {
62601 existingCallback(items, {
62602 ...argsObject,
62603 onActionPerformed: (_items) => {
62604 if (argsObject?.onActionPerformed) {
62605 argsObject.onActionPerformed(_items);
62606 }
62607 onActionPerformed(
62608 actions2[i3].id,
62609 _items
62610 );
62611 }
62612 });
62613 }
62614 };
62615 }
62616 if (actions2[i3].RenderModal) {
62617 const ExistingRenderModal = actions2[i3].RenderModal;
62618 actions2[i3] = {
62619 ...actions2[i3],
62620 RenderModal: (props) => {
62621 return /* @__PURE__ */ (0, import_jsx_runtime389.jsx)(
62622 ExistingRenderModal,
62623 {
62624 ...props,
62625 onActionPerformed: (_items) => {
62626 if (props.onActionPerformed) {
62627 props.onActionPerformed(_items);
62628 }
62629 onActionPerformed(
62630 actions2[i3].id,
62631 _items
62632 );
62633 }
62634 }
62635 );
62636 }
62637 };
62638 }
62639 }
62640 }
62641 return actions2;
62642 }, [
62643 context,
62644 defaultActions,
62645 onActionPerformed,
62646 setAsHomepageAction,
62647 setAsPostsPageAction,
62648 shouldShowHomepageActions
62649 ]);
62650 }
62651
62652 // packages/editor/build-module/components/post-actions/index.mjs
62653 var import_jsx_runtime390 = __toESM(require_jsx_runtime(), 1);
62654 var { Menu: Menu5, kebabCase: kebabCase4 } = unlock(import_components228.privateApis);
62655 function PostActions({ postType: postType2, postId: postId2, onActionPerformed }) {
62656 const [activeModalAction, setActiveModalAction] = (0, import_element210.useState)(null);
62657 const { item, permissions } = (0, import_data214.useSelect)(
62658 (select6) => {
62659 const { getEditedEntityRecord, getEntityRecordPermissions } = unlock(select6(import_core_data122.store));
62660 return {
62661 item: getEditedEntityRecord("postType", postType2, postId2),
62662 permissions: getEntityRecordPermissions(
62663 "postType",
62664 postType2,
62665 postId2
62666 )
62667 };
62668 },
62669 [postId2, postType2]
62670 );
62671 const itemWithPermissions = (0, import_element210.useMemo)(() => {
62672 return {
62673 ...item,
62674 permissions
62675 };
62676 }, [item, permissions]);
62677 const allActions = usePostActions({ postType: postType2, onActionPerformed });
62678 const actions2 = (0, import_element210.useMemo)(() => {
62679 return allActions.filter((action) => {
62680 return !action.isEligible || action.isEligible(itemWithPermissions);
62681 });
62682 }, [allActions, itemWithPermissions]);
62683 return /* @__PURE__ */ (0, import_jsx_runtime390.jsxs)(import_jsx_runtime390.Fragment, { children: [
62684 /* @__PURE__ */ (0, import_jsx_runtime390.jsxs)(Menu5, { placement: "bottom-end", children: [
62685 /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(
62686 Menu5.TriggerButton,
62687 {
62688 render: /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(
62689 import_components228.Button,
62690 {
62691 size: "small",
62692 icon: more_vertical_default,
62693 label: (0, import_i18n247.__)("Actions"),
62694 disabled: !actions2.length,
62695 accessibleWhenDisabled: true,
62696 className: "editor-all-actions-button"
62697 }
62698 )
62699 }
62700 ),
62701 /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(Menu5.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(
62702 ActionsDropdownMenuGroup,
62703 {
62704 actions: actions2,
62705 items: [itemWithPermissions],
62706 setActiveModalAction
62707 }
62708 ) })
62709 ] }),
62710 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(
62711 ActionModal,
62712 {
62713 action: activeModalAction,
62714 items: [itemWithPermissions],
62715 closeModal: () => setActiveModalAction(null)
62716 }
62717 )
62718 ] });
62719 }
62720 function DropdownMenuItemTrigger({ action, onClick, items }) {
62721 const label = typeof action.label === "string" ? action.label : action.label(items);
62722 return /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(Menu5.Item, { onClick, children: /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(Menu5.ItemLabel, { children: label }) });
62723 }
62724 function ActionModal({ action, items, closeModal: closeModal2 }) {
62725 const label = typeof action.label === "string" ? action.label : action.label(items);
62726 return /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(
62727 import_components228.Modal,
62728 {
62729 title: action.modalHeader || label,
62730 __experimentalHideHeader: !!action.hideModalHeader,
62731 onRequestClose: closeModal2 ?? (() => {
62732 }),
62733 focusOnMount: "firstContentElement",
62734 size: "medium",
62735 overlayClassName: `editor-action-modal editor-action-modal__${kebabCase4(
62736 action.id
62737 )}`,
62738 children: /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(action.RenderModal, { items, closeModal: closeModal2 })
62739 }
62740 );
62741 }
62742 function ActionsDropdownMenuGroup({ actions: actions2, items, setActiveModalAction }) {
62743 const registry = (0, import_data214.useRegistry)();
62744 return /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(Menu5.Group, { children: actions2.map((action) => {
62745 return /* @__PURE__ */ (0, import_jsx_runtime390.jsx)(
62746 DropdownMenuItemTrigger,
62747 {
62748 action,
62749 onClick: () => {
62750 if ("RenderModal" in action) {
62751 setActiveModalAction(action);
62752 return;
62753 }
62754 action.callback(items, { registry });
62755 },
62756 items
62757 },
62758 action.id
62759 );
62760 }) });
62761 }
62762
62763 // packages/editor/build-module/components/post-card-panel/index.mjs
62764 var import_jsx_runtime391 = __toESM(require_jsx_runtime(), 1);
62765 var { Badge: Badge3 } = unlock(import_components229.privateApis);
62766 function PostCardPanel({
62767 postType: postType2,
62768 postId: postId2,
62769 hideActions = false,
62770 onActionPerformed,
62771 onClose
62772 }) {
62773 const postIds = (0, import_element211.useMemo)(
62774 () => Array.isArray(postId2) ? postId2 : [postId2],
62775 [postId2]
62776 );
62777 const { postTitle, icon, labels, isRevision } = (0, import_data215.useSelect)(
62778 (select6) => {
62779 const { getEditedEntityRecord, getCurrentTheme, getPostType } = select6(import_core_data123.store);
62780 const {
62781 getPostIcon: getPostIcon2,
62782 getCurrentPostType: getCurrentPostType2,
62783 isRevisionsMode: isRevisionsMode2,
62784 getCurrentRevision: getCurrentRevision2
62785 } = unlock(select6(store));
62786 let _title = "";
62787 if (isRevisionsMode2()) {
62788 const parentPostType = getCurrentPostType2();
62789 const _record2 = getCurrentRevision2();
62790 _title = _record2?.title?.rendered || _record2?.title?.raw || "";
62791 return {
62792 postTitle: _title,
62793 icon: getPostIcon2(parentPostType, {
62794 area: _record2?.area
62795 }),
62796 labels: getPostType(parentPostType)?.labels,
62797 isRevision: true
62798 };
62799 }
62800 const _record = getEditedEntityRecord(
62801 "postType",
62802 postType2,
62803 postIds[0]
62804 );
62805 if (postIds.length === 1) {
62806 const { default_template_types: templateTypes = [] } = getCurrentTheme() ?? {};
62807 const _templateInfo = [
62808 TEMPLATE_POST_TYPE,
62809 TEMPLATE_PART_POST_TYPE
62810 ].includes(postType2) ? getTemplateInfo({
62811 template: _record,
62812 templateTypes
62813 }) : {};
62814 _title = _templateInfo?.title || _record?.title;
62815 }
62816 return {
62817 postTitle: _title,
62818 icon: getPostIcon2(postType2, {
62819 area: _record?.area
62820 }),
62821 labels: getPostType(postType2)?.labels
62822 };
62823 },
62824 [postIds, postType2]
62825 );
62826 const pageTypeBadge = usePageTypeBadge(postId2);
62827 let title = (0, import_i18n248.__)("No title");
62828 if (labels?.name && postIds.length > 1) {
62829 title = (0, import_i18n248.sprintf)(
62830 // translators: %1$d number of selected items %2$s: Name of the plural post type e.g: "Posts".
62831 (0, import_i18n248.__)("%1$d %2$s"),
62832 postIds.length,
62833 labels?.name
62834 );
62835 } else if (postTitle) {
62836 title = (0, import_dom5.__unstableStripHTML)(postTitle);
62837 }
62838 return /* @__PURE__ */ (0, import_jsx_runtime391.jsxs)(import_components229.__experimentalVStack, { spacing: 1, className: "editor-post-card-panel", children: [
62839 /* @__PURE__ */ (0, import_jsx_runtime391.jsxs)(
62840 import_components229.__experimentalHStack,
62841 {
62842 spacing: 2,
62843 className: "editor-post-card-panel__header",
62844 alignment: "flex-start",
62845 children: [
62846 /* @__PURE__ */ (0, import_jsx_runtime391.jsx)(import_components229.Icon, { className: "editor-post-card-panel__icon", icon }),
62847 /* @__PURE__ */ (0, import_jsx_runtime391.jsxs)(
62848 import_components229.__experimentalText,
62849 {
62850 numberOfLines: 2,
62851 truncate: true,
62852 className: "editor-post-card-panel__title",
62853 as: "h2",
62854 children: [
62855 /* @__PURE__ */ (0, import_jsx_runtime391.jsx)("span", { className: "editor-post-card-panel__title-name", children: title }),
62856 pageTypeBadge && postIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime391.jsx)(Badge3, { children: pageTypeBadge })
62857 ]
62858 }
62859 ),
62860 !hideActions && postIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime391.jsx)(import_jsx_runtime391.Fragment, { children: isRevision ? /* @__PURE__ */ (0, import_jsx_runtime391.jsx)(
62861 import_components229.Button,
62862 {
62863 size: "small",
62864 icon: more_vertical_default,
62865 label: (0, import_i18n248.__)("Actions"),
62866 disabled: true,
62867 accessibleWhenDisabled: true,
62868 className: "editor-all-actions-button"
62869 }
62870 ) : /* @__PURE__ */ (0, import_jsx_runtime391.jsx)(
62871 PostActions,
62872 {
62873 postType: postType2,
62874 postId: postIds[0],
62875 onActionPerformed
62876 }
62877 ) }),
62878 onClose && /* @__PURE__ */ (0, import_jsx_runtime391.jsx)(
62879 import_components229.Button,
62880 {
62881 size: "small",
62882 icon: close_default,
62883 label: (0, import_i18n248.__)("Close"),
62884 onClick: onClose
62885 }
62886 )
62887 ]
62888 }
62889 ),
62890 postIds.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime391.jsx)(import_components229.__experimentalText, { className: "editor-post-card-panel__description", children: (0, import_i18n248.sprintf)(
62891 // translators: %s: Name of the plural post type e.g: "Posts".
62892 (0, import_i18n248.__)("Changes will be applied to all selected %s."),
62893 labels?.name.toLowerCase()
62894 ) })
62895 ] });
62896 }
62897
62898 // packages/editor/build-module/components/post-panel-section/index.mjs
62899 var import_components230 = __toESM(require_components(), 1);
62900 var import_jsx_runtime392 = __toESM(require_jsx_runtime(), 1);
62901 function PostPanelSection({ className, children }) {
62902 return /* @__PURE__ */ (0, import_jsx_runtime392.jsx)(import_components230.__experimentalVStack, { className: clsx_default("editor-post-panel__section", className), children });
62903 }
62904 var post_panel_section_default = PostPanelSection;
62905
62906 // packages/editor/build-module/components/media/metadata-panel.mjs
62907 var import_jsx_runtime393 = __toESM(require_jsx_runtime(), 1);
62908 function MediaMetadataPanel({ onActionPerformed }) {
62909 const { media, postType: postType2, postId: postId2 } = (0, import_data216.useSelect)((select6) => {
62910 const _postType = select6(store).getCurrentPostType();
62911 const _postId = select6(store).getCurrentPostId();
62912 const currentPost = select6(import_core_data124.store).getEditedEntityRecord(
62913 "postType",
62914 _postType,
62915 _postId,
62916 {
62917 _embed: "author,wp:attached-to"
62918 }
62919 );
62920 return {
62921 media: currentPost,
62922 postType: _postType,
62923 postId: _postId
62924 };
62925 }, []);
62926 const { editPost: editPost2 } = (0, import_data216.useDispatch)(store);
62927 const fields2 = post_fields_default({ postType: "attachment" });
62928 const settings = (0, import_element212.useMemo)(
62929 () => ({
62930 fields: fields2
62931 }),
62932 [fields2]
62933 );
62934 const handleUpdate = (updates) => {
62935 editPost2(updates);
62936 };
62937 return /* @__PURE__ */ (0, import_jsx_runtime393.jsx)(post_panel_section_default, { className: "editor-media-metadata-panel", children: /* @__PURE__ */ (0, import_jsx_runtime393.jsx)(
62938 MediaEditorProvider,
62939 {
62940 value: media,
62941 settings,
62942 onChange: handleUpdate,
62943 children: /* @__PURE__ */ (0, import_jsx_runtime393.jsx)(
62944 MediaForm,
62945 {
62946 header: /* @__PURE__ */ (0, import_jsx_runtime393.jsx)(
62947 PostCardPanel,
62948 {
62949 postType: postType2,
62950 postId: postId2,
62951 onActionPerformed
62952 }
62953 )
62954 }
62955 )
62956 }
62957 ) });
62958 }
62959
62960 // packages/editor/build-module/components/editor-interface/index.mjs
62961 var import_jsx_runtime394 = __toESM(require_jsx_runtime(), 1);
62962 var interfaceLabels = {
62963 /* translators: accessibility text for the editor top bar landmark region. */
62964 header: (0, import_i18n249.__)("Editor top bar"),
62965 /* translators: accessibility text for the editor content landmark region. */
62966 body: (0, import_i18n249.__)("Editor content"),
62967 /* translators: accessibility text for the editor settings landmark region. */
62968 sidebar: (0, import_i18n249.__)("Editor settings"),
62969 /* translators: accessibility text for the editor publish landmark region. */
62970 actions: (0, import_i18n249.__)("Editor publish"),
62971 /* translators: accessibility text for the editor footer landmark region. */
62972 footer: (0, import_i18n249.__)("Editor footer")
62973 };
62974 var Notices = () => /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(
62975 import_notices31.InlineNotices,
62976 {
62977 pinnedNoticesClassName: "editor-notices__pinned",
62978 dismissibleNoticesClassName: "editor-notices__dismissible",
62979 children: /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(TemplateValidationNotice, {})
62980 }
62981 );
62982 function EditorInterface({
62983 className,
62984 children,
62985 forceIsDirty,
62986 contentRef,
62987 disableIframe,
62988 autoFocus,
62989 customSaveButton,
62990 customSavePanel,
62991 forceDisableBlockTools,
62992 iframeProps
62993 }) {
62994 const {
62995 mode,
62996 postId: postId2,
62997 postType: postType2,
62998 isAttachment,
62999 isInserterOpened: isInserterOpened2,
63000 isListViewOpened: isListViewOpened2,
63001 isDistractionFree,
63002 isPreviewMode,
63003 showBlockBreadcrumbs,
63004 postTypeLabel,
63005 stylesPath: stylesPath2,
63006 showStylebook: showStylebook2,
63007 isRevisionsMode: isRevisionsMode2,
63008 showDiff
63009 } = (0, import_data217.useSelect)((select6) => {
63010 const { get } = select6(import_preferences24.store);
63011 const {
63012 getEditorSettings: getEditorSettings2,
63013 getPostTypeLabel: getPostTypeLabel2,
63014 getCurrentPostType: getCurrentPostType2,
63015 getCurrentPostId: getCurrentPostId2
63016 } = select6(store);
63017 const {
63018 getStylesPath: getStylesPath2,
63019 getShowStylebook: getShowStylebook2,
63020 isRevisionsMode: _isRevisionsMode,
63021 isShowingRevisionDiff: isShowingRevisionDiff2
63022 } = unlock(select6(store));
63023 const editorSettings2 = getEditorSettings2();
63024 let _mode = select6(store).getEditorMode();
63025 if (!editorSettings2.richEditingEnabled && _mode === "visual") {
63026 _mode = "text";
63027 }
63028 if (!editorSettings2.codeEditingEnabled && _mode === "text") {
63029 _mode = "visual";
63030 }
63031 return {
63032 mode: _mode,
63033 postId: getCurrentPostId2(),
63034 postType: getCurrentPostType2(),
63035 isInserterOpened: select6(store).isInserterOpened(),
63036 isListViewOpened: select6(store).isListViewOpened(),
63037 isDistractionFree: get("core", "distractionFree"),
63038 isPreviewMode: editorSettings2.isPreviewMode,
63039 showBlockBreadcrumbs: get("core", "showBlockBreadcrumbs"),
63040 postTypeLabel: getPostTypeLabel2(),
63041 stylesPath: getStylesPath2(),
63042 showStylebook: getShowStylebook2(),
63043 isAttachment: getCurrentPostType2() === "attachment" && window?.__experimentalMediaEditor,
63044 isRevisionsMode: _isRevisionsMode(),
63045 showDiff: isShowingRevisionDiff2()
63046 };
63047 }, []);
63048 const { setShowRevisionDiff: setShowRevisionDiff2 } = unlock((0, import_data217.useDispatch)(store));
63049 useCollaboratorNotifications(postId2, postType2);
63050 const isLargeViewport = (0, import_compose65.useViewportMatch)("medium");
63051 const secondarySidebarLabel = isListViewOpened2 ? (0, import_i18n249.__)("Document Overview") : (0, import_i18n249.__)("Block Library");
63052 const shouldShowMediaEditor = !!isAttachment;
63053 const shouldShowStylesCanvas = !isAttachment && (showStylebook2 || stylesPath2?.startsWith("/revisions"));
63054 const shouldShowBlockEditor = !shouldShowMediaEditor && !shouldShowStylesCanvas;
63055 const [entitiesSavedStatesCallback, setEntitiesSavedStatesCallback] = (0, import_element213.useState)(false);
63056 const closeEntitiesSavedStates = (0, import_element213.useCallback)(
63057 (arg) => {
63058 if (typeof entitiesSavedStatesCallback === "function") {
63059 entitiesSavedStatesCallback(arg);
63060 }
63061 setEntitiesSavedStatesCallback(false);
63062 },
63063 [entitiesSavedStatesCallback]
63064 );
63065 if (isRevisionsMode2) {
63066 return /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(
63067 interface_skeleton_default,
63068 {
63069 className: clsx_default("editor-editor-interface", className),
63070 labels: interfaceLabels,
63071 header: /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(
63072 revisions_header_default,
63073 {
63074 showDiff,
63075 onToggleDiff: () => setShowRevisionDiff2(!showDiff)
63076 }
63077 ),
63078 content: /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(RevisionsCanvas, {}),
63079 sidebar: /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(complementary_area_default.Slot, { scope: "core" })
63080 }
63081 );
63082 }
63083 return /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(
63084 interface_skeleton_default,
63085 {
63086 isDistractionFree,
63087 className: clsx_default("editor-editor-interface", className, {
63088 "is-entity-save-view-open": !!entitiesSavedStatesCallback,
63089 "is-distraction-free": isDistractionFree && !isPreviewMode
63090 }),
63091 labels: {
63092 ...interfaceLabels,
63093 secondarySidebar: secondarySidebarLabel
63094 },
63095 header: !isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(
63096 header_default2,
63097 {
63098 forceIsDirty,
63099 setEntitiesSavedStatesCallback,
63100 customSaveButton,
63101 forceDisableBlockTools
63102 }
63103 ),
63104 editorNotices: /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(Notices, {}),
63105 secondarySidebar: !isAttachment && !isPreviewMode && mode === "visual" && (isInserterOpened2 && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(InserterSidebar, {}) || isListViewOpened2 && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(ListViewSidebar, {})),
63106 sidebar: !isPreviewMode && !isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(complementary_area_default.Slot, { scope: "core" }),
63107 content: /* @__PURE__ */ (0, import_jsx_runtime394.jsxs)(import_jsx_runtime394.Fragment, { children: [
63108 !isDistractionFree && !isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(Notices, {}),
63109 shouldShowMediaEditor && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(MediaPreview3, { ...iframeProps }),
63110 shouldShowStylesCanvas && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(StylesCanvas, {}),
63111 shouldShowBlockEditor && /* @__PURE__ */ (0, import_jsx_runtime394.jsxs)(import_jsx_runtime394.Fragment, { children: [
63112 !isPreviewMode && mode === "text" && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(
63113 TextEditor,
63114 {
63115 autoFocus
63116 }
63117 ),
63118 !isPreviewMode && !isLargeViewport && mode === "visual" && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(import_block_editor83.BlockToolbar, { hideDragHandle: true }),
63119 (isPreviewMode || mode === "visual") && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(
63120 visual_editor_default,
63121 {
63122 contentRef,
63123 disableIframe,
63124 autoFocus,
63125 iframeProps
63126 }
63127 ),
63128 children,
63129 /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(
63130 CollaboratorsOverlay,
63131 {
63132 postId: postId2,
63133 postType: postType2
63134 }
63135 )
63136 ] })
63137 ] }),
63138 footer: !isPreviewMode && !isDistractionFree && isLargeViewport && showBlockBreadcrumbs && mode === "visual" && /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(
63139 import_block_editor83.BlockBreadcrumb,
63140 {
63141 rootLabelText: postTypeLabel ? (0, import_html_entities27.decodeEntities)(postTypeLabel) : void 0
63142 }
63143 ),
63144 actions: !isPreviewMode ? customSavePanel || /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(
63145 SavePublishPanels,
63146 {
63147 closeEntitiesSavedStates,
63148 isEntitiesSavedStatesOpen: entitiesSavedStatesCallback,
63149 setEntitiesSavedStatesCallback,
63150 forceIsDirtyPublishPanel: forceIsDirty
63151 }
63152 ) : void 0
63153 }
63154 );
63155 }
63156
63157 // packages/editor/build-module/components/sidebar/index.mjs
63158 var import_block_editor93 = __toESM(require_block_editor(), 1);
63159 var import_data236 = __toESM(require_data(), 1);
63160 var import_element224 = __toESM(require_element(), 1);
63161 var import_i18n265 = __toESM(require_i18n(), 1);
63162 var import_keyboard_shortcuts10 = __toESM(require_keyboard_shortcuts(), 1);
63163 var import_components244 = __toESM(require_components(), 1);
63164
63165 // packages/editor/build-module/components/pattern-overrides-panel/index.mjs
63166 var import_data218 = __toESM(require_data(), 1);
63167 var import_patterns9 = __toESM(require_patterns(), 1);
63168 var import_jsx_runtime395 = __toESM(require_jsx_runtime(), 1);
63169 var { OverridesPanel } = unlock(import_patterns9.privateApis);
63170 function PatternOverridesPanel() {
63171 const supportsPatternOverridesPanel = (0, import_data218.useSelect)(
63172 (select6) => select6(store).getCurrentPostType() === "wp_block",
63173 []
63174 );
63175 if (!supportsPatternOverridesPanel) {
63176 return null;
63177 }
63178 return /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(OverridesPanel, {});
63179 }
63180
63181 // packages/editor/build-module/components/sidebar/post-summary.mjs
63182 var import_components238 = __toESM(require_components(), 1);
63183 var import_data227 = __toESM(require_data(), 1);
63184 var import_i18n258 = __toESM(require_i18n(), 1);
63185 var import_url23 = __toESM(require_url(), 1);
63186
63187 // packages/editor/build-module/components/post-content-information/index.mjs
63188 var import_components231 = __toESM(require_components(), 1);
63189 var import_data219 = __toESM(require_data(), 1);
63190 var import_i18n250 = __toESM(require_i18n(), 1);
63191 var import_wordcount4 = __toESM(require_wordcount(), 1);
63192 var import_element214 = __toESM(require_element(), 1);
63193 var import_core_data125 = __toESM(require_core_data(), 1);
63194 var import_jsx_runtime396 = __toESM(require_jsx_runtime(), 1);
63195 var AVERAGE_READING_RATE2 = 189;
63196 function PostContentInformation() {
63197 const { postContent } = (0, import_data219.useSelect)((select6) => {
63198 const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select6(store);
63199 const { getCurrentRevision: getCurrentRevision2, isRevisionsMode: isRevisionsMode2 } = unlock(
63200 select6(store)
63201 );
63202 if (isRevisionsMode2()) {
63203 return {
63204 postContent: getCurrentRevision2()?.content?.raw
63205 };
63206 }
63207 const { canUser } = select6(import_core_data125.store);
63208 const { getEntityRecord } = select6(import_core_data125.store);
63209 const siteSettings = canUser("read", {
63210 kind: "root",
63211 name: "site"
63212 }) ? getEntityRecord("root", "site") : void 0;
63213 const postType2 = getCurrentPostType2();
63214 const _id = getCurrentPostId2();
63215 const isPostsPage = +_id === siteSettings?.page_for_posts;
63216 const showPostContentInfo = !isPostsPage && ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(
63217 postType2
63218 );
63219 return {
63220 postContent: showPostContentInfo && getEditedPostAttribute2("content")
63221 };
63222 }, []);
63223 const wordCountType = (0, import_i18n250._x)("words", "Word count type. Do not translate!");
63224 const wordsCounted = (0, import_element214.useMemo)(
63225 () => postContent ? (0, import_wordcount4.count)(postContent, wordCountType) : 0,
63226 [postContent, wordCountType]
63227 );
63228 if (!wordsCounted) {
63229 return null;
63230 }
63231 const readingTime = Math.round(wordsCounted / AVERAGE_READING_RATE2);
63232 const wordsCountText = (0, import_i18n250.sprintf)(
63233 // translators: %s: the number of words in the post.
63234 (0, import_i18n250._n)("%s word", "%s words", wordsCounted),
63235 wordsCounted.toLocaleString()
63236 );
63237 const minutesText = readingTime <= 1 ? (0, import_i18n250.__)("1 minute") : (0, import_i18n250.sprintf)(
63238 /* translators: %s: the number of minutes to read the post. */
63239 (0, import_i18n250._n)("%s minute", "%s minutes", readingTime),
63240 readingTime.toLocaleString()
63241 );
63242 return /* @__PURE__ */ (0, import_jsx_runtime396.jsx)("div", { className: "editor-post-content-information", children: /* @__PURE__ */ (0, import_jsx_runtime396.jsx)(import_components231.__experimentalText, { children: (0, import_i18n250.sprintf)(
63243 /* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */
63244 (0, import_i18n250.__)("%1$s, %2$s read time."),
63245 wordsCountText,
63246 minutesText
63247 ) }) });
63248 }
63249
63250 // packages/editor/build-module/components/post-format/panel.mjs
63251 var import_components232 = __toESM(require_components(), 1);
63252 var import_i18n251 = __toESM(require_i18n(), 1);
63253 var import_data220 = __toESM(require_data(), 1);
63254 var import_element215 = __toESM(require_element(), 1);
63255 var import_block_editor84 = __toESM(require_block_editor(), 1);
63256 var import_jsx_runtime397 = __toESM(require_jsx_runtime(), 1);
63257 function PostFormat2() {
63258 const { postFormat } = (0, import_data220.useSelect)((select6) => {
63259 const { getEditedPostAttribute: getEditedPostAttribute2 } = select6(store);
63260 const _postFormat = getEditedPostAttribute2("format");
63261 return {
63262 postFormat: _postFormat ?? "standard"
63263 };
63264 }, []);
63265 const activeFormat = POST_FORMATS.find(
63266 (format6) => format6.id === postFormat
63267 );
63268 const [popoverAnchor, setPopoverAnchor] = (0, import_element215.useState)(null);
63269 const popoverProps = (0, import_element215.useMemo)(
63270 () => ({
63271 // Anchor the popover to the middle of the entire row so that it doesn't
63272 // move around when the label changes.
63273 anchor: popoverAnchor,
63274 placement: "left-start",
63275 offset: 36,
63276 shift: true
63277 }),
63278 [popoverAnchor]
63279 );
63280 return /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(PostFormatCheck, { children: /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(post_panel_row_default, { label: (0, import_i18n251.__)("Format"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(
63281 import_components232.Dropdown,
63282 {
63283 popoverProps,
63284 contentClassName: "editor-post-format__dialog",
63285 focusOnMount: true,
63286 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(
63287 import_components232.Button,
63288 {
63289 size: "compact",
63290 variant: "tertiary",
63291 "aria-expanded": isOpen,
63292 "aria-label": (0, import_i18n251.sprintf)(
63293 // translators: %s: Current post format.
63294 (0, import_i18n251.__)("Change format: %s"),
63295 activeFormat?.caption
63296 ),
63297 onClick: onToggle,
63298 children: activeFormat?.caption
63299 }
63300 ),
63301 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime397.jsxs)("div", { className: "editor-post-format__dialog-content", children: [
63302 /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(
63303 import_block_editor84.__experimentalInspectorPopoverHeader,
63304 {
63305 title: (0, import_i18n251.__)("Format"),
63306 onClose
63307 }
63308 ),
63309 /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(PostFormat, {})
63310 ] })
63311 }
63312 ) }) });
63313 }
63314 var panel_default4 = PostFormat2;
63315
63316 // packages/editor/build-module/components/post-last-edited-panel/index.mjs
63317 var import_components233 = __toESM(require_components(), 1);
63318 var import_data221 = __toESM(require_data(), 1);
63319 var import_i18n252 = __toESM(require_i18n(), 1);
63320 var import_date18 = __toESM(require_date(), 1);
63321 var import_jsx_runtime398 = __toESM(require_jsx_runtime(), 1);
63322 function PostLastEditedPanel() {
63323 const modified = (0, import_data221.useSelect)(
63324 (select6) => select6(store).getEditedPostAttribute("modified"),
63325 []
63326 );
63327 if (!modified) {
63328 return null;
63329 }
63330 return /* @__PURE__ */ (0, import_jsx_runtime398.jsx)("div", { className: "editor-post-last-edited-panel", children: /* @__PURE__ */ (0, import_jsx_runtime398.jsx)(import_components233.__experimentalText, { children: (0, import_i18n252.sprintf)(
63331 // translators: %s: Human-readable time difference, e.g. "2 days ago".
63332 (0, import_i18n252.__)("Last edited %s."),
63333 (0, import_date18.humanTimeDiff)(modified)
63334 ) }) });
63335 }
63336
63337 // packages/editor/build-module/components/revision-created-panel/index.mjs
63338 var import_components234 = __toESM(require_components(), 1);
63339 var import_data222 = __toESM(require_data(), 1);
63340 var import_i18n253 = __toESM(require_i18n(), 1);
63341 var import_date19 = __toESM(require_date(), 1);
63342 var import_jsx_runtime399 = __toESM(require_jsx_runtime(), 1);
63343 function RevisionCreatedPanel() {
63344 const date = (0, import_data222.useSelect)((select6) => {
63345 const { getCurrentRevision: getCurrentRevision2 } = unlock(select6(store));
63346 return getCurrentRevision2()?.date;
63347 }, []);
63348 if (!date) {
63349 return null;
63350 }
63351 return /* @__PURE__ */ (0, import_jsx_runtime399.jsx)("div", { className: "editor-post-last-edited-panel", children: /* @__PURE__ */ (0, import_jsx_runtime399.jsx)(import_components234.__experimentalText, { children: (0, import_i18n253.sprintf)(
63352 // translators: %s: Human-readable time difference, e.g. "2 days ago".
63353 (0, import_i18n253.__)("Created %s."),
63354 (0, import_date19.humanTimeDiff)(date)
63355 ) }) });
63356 }
63357
63358 // packages/editor/build-module/components/blog-title/index.mjs
63359 var import_i18n254 = __toESM(require_i18n(), 1);
63360 var import_compose66 = __toESM(require_compose(), 1);
63361 var import_data223 = __toESM(require_data(), 1);
63362 var import_core_data126 = __toESM(require_core_data(), 1);
63363 var import_html_entities28 = __toESM(require_html_entities(), 1);
63364 var import_components235 = __toESM(require_components(), 1);
63365 var import_element216 = __toESM(require_element(), 1);
63366 var import_block_editor85 = __toESM(require_block_editor(), 1);
63367 var import_jsx_runtime400 = __toESM(require_jsx_runtime(), 1);
63368 var EMPTY_OBJECT5 = {};
63369 function BlogTitle() {
63370 const { editEntityRecord } = (0, import_data223.useDispatch)(import_core_data126.store);
63371 const { postsPageTitle, postsPageId, isTemplate: isTemplate2, postSlug } = (0, import_data223.useSelect)(
63372 (select6) => {
63373 const { getEntityRecord, getEditedEntityRecord, canUser } = select6(import_core_data126.store);
63374 const siteSettings = canUser("read", {
63375 kind: "root",
63376 name: "site"
63377 }) ? getEntityRecord("root", "site") : void 0;
63378 const _postsPageRecord = siteSettings?.page_for_posts ? getEditedEntityRecord(
63379 "postType",
63380 "page",
63381 siteSettings?.page_for_posts
63382 ) : EMPTY_OBJECT5;
63383 const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2 } = select6(store);
63384 return {
63385 postsPageId: _postsPageRecord?.id,
63386 postsPageTitle: _postsPageRecord?.title,
63387 isTemplate: getCurrentPostType2() === TEMPLATE_POST_TYPE,
63388 postSlug: getEditedPostAttribute2("slug")
63389 };
63390 },
63391 []
63392 );
63393 const [popoverAnchor, setPopoverAnchor] = (0, import_element216.useState)(null);
63394 const popoverProps = (0, import_element216.useMemo)(
63395 () => ({
63396 // Anchor the popover to the middle of the entire row so that it doesn't
63397 // move around when the label changes.
63398 anchor: popoverAnchor,
63399 placement: "left-start",
63400 offset: 36,
63401 shift: true
63402 }),
63403 [popoverAnchor]
63404 );
63405 if (!isTemplate2 || !["home", "index"].includes(postSlug) || !postsPageId) {
63406 return null;
63407 }
63408 const setPostsPageTitle = (newValue) => {
63409 editEntityRecord("postType", "page", postsPageId, {
63410 title: newValue
63411 });
63412 };
63413 const decodedTitle = (0, import_html_entities28.decodeEntities)(postsPageTitle);
63414 return /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(post_panel_row_default, { label: (0, import_i18n254.__)("Blog title"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(
63415 import_components235.Dropdown,
63416 {
63417 popoverProps,
63418 contentClassName: "editor-blog-title-dropdown__content",
63419 focusOnMount: true,
63420 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(
63421 import_components235.Button,
63422 {
63423 size: "compact",
63424 variant: "tertiary",
63425 "aria-expanded": isOpen,
63426 "aria-label": (0, import_i18n254.sprintf)(
63427 // translators: %s: Current post link.
63428 (0, import_i18n254.__)("Change blog title: %s"),
63429 decodedTitle
63430 ),
63431 onClick: onToggle,
63432 children: decodedTitle
63433 }
63434 ),
63435 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime400.jsxs)(import_jsx_runtime400.Fragment, { children: [
63436 /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(
63437 import_block_editor85.__experimentalInspectorPopoverHeader,
63438 {
63439 title: (0, import_i18n254.__)("Blog title"),
63440 onClose
63441 }
63442 ),
63443 /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(
63444 import_components235.__experimentalInputControl,
63445 {
63446 placeholder: (0, import_i18n254.__)("No title"),
63447 size: "__unstable-large",
63448 value: postsPageTitle,
63449 onChange: (0, import_compose66.debounce)(setPostsPageTitle, 300),
63450 label: (0, import_i18n254.__)("Blog title"),
63451 help: (0, import_i18n254.__)(
63452 "Set the Posts Page title. Appears in search results, and when the page is shared on social media."
63453 ),
63454 hideLabelFromVision: true
63455 }
63456 )
63457 ] })
63458 }
63459 ) });
63460 }
63461
63462 // packages/editor/build-module/components/posts-per-page/index.mjs
63463 var import_i18n255 = __toESM(require_i18n(), 1);
63464 var import_data224 = __toESM(require_data(), 1);
63465 var import_core_data127 = __toESM(require_core_data(), 1);
63466 var import_components236 = __toESM(require_components(), 1);
63467 var import_element217 = __toESM(require_element(), 1);
63468 var import_block_editor86 = __toESM(require_block_editor(), 1);
63469 var import_jsx_runtime401 = __toESM(require_jsx_runtime(), 1);
63470 function PostsPerPage() {
63471 const { editEntityRecord } = (0, import_data224.useDispatch)(import_core_data127.store);
63472 const { postsPerPage, isTemplate: isTemplate2, postSlug } = (0, import_data224.useSelect)((select6) => {
63473 const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2 } = select6(store);
63474 const { getEditedEntityRecord, canUser } = select6(import_core_data127.store);
63475 const siteSettings = canUser("read", {
63476 kind: "root",
63477 name: "site"
63478 }) ? getEditedEntityRecord("root", "site") : void 0;
63479 return {
63480 isTemplate: getCurrentPostType2() === TEMPLATE_POST_TYPE,
63481 postSlug: getEditedPostAttribute2("slug"),
63482 postsPerPage: siteSettings?.posts_per_page || 1
63483 };
63484 }, []);
63485 const [popoverAnchor, setPopoverAnchor] = (0, import_element217.useState)(null);
63486 const popoverProps = (0, import_element217.useMemo)(
63487 () => ({
63488 // Anchor the popover to the middle of the entire row so that it doesn't
63489 // move around when the label changes.
63490 anchor: popoverAnchor,
63491 placement: "left-start",
63492 offset: 36,
63493 shift: true
63494 }),
63495 [popoverAnchor]
63496 );
63497 if (!isTemplate2 || !["home", "index"].includes(postSlug)) {
63498 return null;
63499 }
63500 const setPostsPerPage = (newValue) => {
63501 editEntityRecord("root", "site", void 0, {
63502 posts_per_page: newValue
63503 });
63504 };
63505 return /* @__PURE__ */ (0, import_jsx_runtime401.jsx)(post_panel_row_default, { label: (0, import_i18n255.__)("Posts per page"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime401.jsx)(
63506 import_components236.Dropdown,
63507 {
63508 popoverProps,
63509 contentClassName: "editor-posts-per-page-dropdown__content",
63510 focusOnMount: true,
63511 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime401.jsx)(
63512 import_components236.Button,
63513 {
63514 size: "compact",
63515 variant: "tertiary",
63516 "aria-expanded": isOpen,
63517 "aria-label": (0, import_i18n255.__)("Change posts per page"),
63518 onClick: onToggle,
63519 children: postsPerPage
63520 }
63521 ),
63522 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime401.jsxs)(import_jsx_runtime401.Fragment, { children: [
63523 /* @__PURE__ */ (0, import_jsx_runtime401.jsx)(
63524 import_block_editor86.__experimentalInspectorPopoverHeader,
63525 {
63526 title: (0, import_i18n255.__)("Posts per page"),
63527 onClose
63528 }
63529 ),
63530 /* @__PURE__ */ (0, import_jsx_runtime401.jsx)(
63531 import_components236.__experimentalNumberControl,
63532 {
63533 placeholder: 0,
63534 value: postsPerPage,
63535 size: "__unstable-large",
63536 spinControls: "custom",
63537 step: "1",
63538 min: "1",
63539 onChange: setPostsPerPage,
63540 label: (0, import_i18n255.__)("Posts per page"),
63541 help: (0, import_i18n255.__)(
63542 "Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting."
63543 ),
63544 hideLabelFromVision: true
63545 }
63546 )
63547 ] })
63548 }
63549 ) });
63550 }
63551
63552 // packages/editor/build-module/components/site-discussion/index.mjs
63553 var import_i18n256 = __toESM(require_i18n(), 1);
63554 var import_data225 = __toESM(require_data(), 1);
63555 var import_core_data128 = __toESM(require_core_data(), 1);
63556 var import_components237 = __toESM(require_components(), 1);
63557 var import_element218 = __toESM(require_element(), 1);
63558 var import_block_editor87 = __toESM(require_block_editor(), 1);
63559 var import_jsx_runtime402 = __toESM(require_jsx_runtime(), 1);
63560 var COMMENT_OPTIONS2 = [
63561 {
63562 label: (0, import_i18n256._x)("Open", 'Adjective: e.g. "Comments are open"'),
63563 value: "open",
63564 description: (0, import_i18n256.__)("Visitors can add new comments and replies.")
63565 },
63566 {
63567 label: (0, import_i18n256.__)("Closed"),
63568 value: "",
63569 description: [
63570 (0, import_i18n256.__)("Visitors cannot add new comments or replies."),
63571 (0, import_i18n256.__)("Existing comments remain visible.")
63572 ].join(" ")
63573 }
63574 ];
63575 function SiteDiscussion() {
63576 const { editEntityRecord } = (0, import_data225.useDispatch)(import_core_data128.store);
63577 const { allowCommentsOnNewPosts, isTemplate: isTemplate2, postSlug } = (0, import_data225.useSelect)(
63578 (select6) => {
63579 const { getEditedPostAttribute: getEditedPostAttribute2, getCurrentPostType: getCurrentPostType2 } = select6(store);
63580 const { getEditedEntityRecord, canUser } = select6(import_core_data128.store);
63581 const siteSettings = canUser("read", {
63582 kind: "root",
63583 name: "site"
63584 }) ? getEditedEntityRecord("root", "site") : void 0;
63585 return {
63586 isTemplate: getCurrentPostType2() === TEMPLATE_POST_TYPE,
63587 postSlug: getEditedPostAttribute2("slug"),
63588 allowCommentsOnNewPosts: siteSettings?.default_comment_status || ""
63589 };
63590 },
63591 []
63592 );
63593 const [popoverAnchor, setPopoverAnchor] = (0, import_element218.useState)(null);
63594 const popoverProps = (0, import_element218.useMemo)(
63595 () => ({
63596 // Anchor the popover to the middle of the entire row so that it doesn't
63597 // move around when the label changes.
63598 anchor: popoverAnchor,
63599 placement: "left-start",
63600 offset: 36,
63601 shift: true
63602 }),
63603 [popoverAnchor]
63604 );
63605 if (!isTemplate2 || !["home", "index"].includes(postSlug)) {
63606 return null;
63607 }
63608 const setAllowCommentsOnNewPosts = (newValue) => {
63609 editEntityRecord("root", "site", void 0, {
63610 default_comment_status: newValue ? "open" : null
63611 });
63612 };
63613 return /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(post_panel_row_default, { label: (0, import_i18n256.__)("Discussion"), ref: setPopoverAnchor, children: /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(
63614 import_components237.Dropdown,
63615 {
63616 popoverProps,
63617 contentClassName: "editor-site-discussion-dropdown__content",
63618 focusOnMount: true,
63619 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(
63620 import_components237.Button,
63621 {
63622 size: "compact",
63623 variant: "tertiary",
63624 "aria-expanded": isOpen,
63625 "aria-label": (0, import_i18n256.__)("Change discussion settings"),
63626 onClick: onToggle,
63627 children: allowCommentsOnNewPosts ? (0, import_i18n256.__)("Comments open") : (0, import_i18n256.__)("Comments closed")
63628 }
63629 ),
63630 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime402.jsxs)(import_jsx_runtime402.Fragment, { children: [
63631 /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(
63632 import_block_editor87.__experimentalInspectorPopoverHeader,
63633 {
63634 title: (0, import_i18n256.__)("Discussion"),
63635 onClose
63636 }
63637 ),
63638 /* @__PURE__ */ (0, import_jsx_runtime402.jsxs)(import_components237.__experimentalVStack, { spacing: 3, children: [
63639 /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(import_components237.__experimentalText, { children: (0, import_i18n256.__)(
63640 "Changes will apply to new posts only. Individual posts may override these settings."
63641 ) }),
63642 /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(
63643 import_components237.RadioControl,
63644 {
63645 className: "editor-site-discussion__options",
63646 hideLabelFromVision: true,
63647 label: (0, import_i18n256.__)("Comment status"),
63648 options: COMMENT_OPTIONS2,
63649 onChange: setAllowCommentsOnNewPosts,
63650 selected: allowCommentsOnNewPosts
63651 }
63652 )
63653 ] })
63654 ] })
63655 }
63656 ) });
63657 }
63658
63659 // packages/editor/build-module/components/revision-author-panel/index.mjs
63660 var import_data226 = __toESM(require_data(), 1);
63661 var import_core_data129 = __toESM(require_core_data(), 1);
63662 var import_html_entities29 = __toESM(require_html_entities(), 1);
63663 var import_i18n257 = __toESM(require_i18n(), 1);
63664 var import_jsx_runtime403 = __toESM(require_jsx_runtime(), 1);
63665 function RevisionAuthorPanel() {
63666 const authorName = (0, import_data226.useSelect)((select6) => {
63667 const { getCurrentRevision: getCurrentRevision2 } = unlock(select6(store));
63668 const revision = getCurrentRevision2();
63669 if (!revision?.author) {
63670 return null;
63671 }
63672 const author = select6(import_core_data129.store).getUser(revision.author);
63673 return author?.name;
63674 }, []);
63675 if (!authorName) {
63676 return null;
63677 }
63678 return /* @__PURE__ */ (0, import_jsx_runtime403.jsx)(post_panel_row_default, { label: (0, import_i18n257.__)("Author"), children: (0, import_html_entities29.decodeEntities)(authorName) });
63679 }
63680
63681 // packages/editor/build-module/components/sidebar/post-summary.mjs
63682 var import_jsx_runtime404 = __toESM(require_jsx_runtime(), 1);
63683 var PANEL_NAME5 = "post-status";
63684 function PostSummary({ onActionPerformed }) {
63685 const { isRemovedPostStatusPanel, postType: postType2, postId: postId2, revisionId: revisionId2 } = (0, import_data227.useSelect)((select6) => {
63686 const {
63687 isEditorPanelRemoved: isEditorPanelRemoved2,
63688 getCurrentPostType: getCurrentPostType2,
63689 getCurrentPostId: getCurrentPostId2,
63690 getCurrentRevisionId: getCurrentRevisionId2
63691 } = unlock(select6(store));
63692 return {
63693 isRemovedPostStatusPanel: isEditorPanelRemoved2(PANEL_NAME5),
63694 postType: getCurrentPostType2(),
63695 postId: getCurrentPostId2(),
63696 revisionId: getCurrentRevisionId2()
63697 };
63698 }, []);
63699 const isRevisionsMode2 = !!revisionId2;
63700 const shouldShowPostStatusPanel = !isRemovedPostStatusPanel && !isRevisionsMode2;
63701 return /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(post_panel_section_default, { className: "editor-post-summary", children: /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(plugin_post_status_info_default.Slot, { children: (fills) => /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(import_jsx_runtime404.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime404.jsxs)(import_components238.__experimentalVStack, { spacing: 4, children: [
63702 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(
63703 PostCardPanel,
63704 {
63705 postType: postType2,
63706 postId: postId2,
63707 onActionPerformed
63708 }
63709 ),
63710 !isRevisionsMode2 && /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(
63711 PostFeaturedImagePanel,
63712 {
63713 withPanelBody: false
63714 }
63715 ),
63716 !isRevisionsMode2 && /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PrivatePostExcerptPanel, {}),
63717 /* @__PURE__ */ (0, import_jsx_runtime404.jsxs)(import_components238.__experimentalVStack, { spacing: 1, children: [
63718 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PostContentInformation, {}),
63719 isRevisionsMode2 ? /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(RevisionCreatedPanel, {}) : /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PostLastEditedPanel, {})
63720 ] }),
63721 isRevisionsMode2 && revisionId2 && /* @__PURE__ */ (0, import_jsx_runtime404.jsxs)(import_jsx_runtime404.Fragment, { children: [
63722 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(
63723 import_components238.ExternalLink,
63724 {
63725 href: (0, import_url23.addQueryArgs)("revision.php", {
63726 revision: revisionId2
63727 }),
63728 children: (0, import_i18n258.__)(
63729 "Open classic revisions screen"
63730 )
63731 }
63732 ),
63733 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(RevisionAuthorPanel, {})
63734 ] }),
63735 shouldShowPostStatusPanel && /* @__PURE__ */ (0, import_jsx_runtime404.jsxs)(import_components238.__experimentalVStack, { spacing: 4, children: [
63736 /* @__PURE__ */ (0, import_jsx_runtime404.jsxs)(import_components238.__experimentalVStack, { spacing: 1, children: [
63737 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PostStatus, {}),
63738 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PostSchedulePanel, {}),
63739 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PostURLPanel, {}),
63740 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(panel_default, {}),
63741 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PostTemplatePanel, {}),
63742 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PostDiscussionPanel, {}),
63743 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PrivatePostLastRevision, {}),
63744 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PageAttributesPanel, {}),
63745 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PostSyncStatus, {}),
63746 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(BlogTitle, {}),
63747 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(PostsPerPage, {}),
63748 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(SiteDiscussion, {}),
63749 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(panel_default4, {}),
63750 fills
63751 ] }),
63752 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(
63753 PostTrash,
63754 {
63755 onActionPerformed
63756 }
63757 )
63758 ] })
63759 ] }) }) }) });
63760 }
63761
63762 // packages/editor/build-module/components/revision-fields-diff/index.mjs
63763 var import_word2 = __toESM(require_word(), 1);
63764 var import_data228 = __toESM(require_data(), 1);
63765 var import_element219 = __toESM(require_element(), 1);
63766 var import_i18n259 = __toESM(require_i18n(), 1);
63767
63768 // packages/editor/build-module/components/revision-diff-panel/index.mjs
63769 var import_components239 = __toESM(require_components(), 1);
63770 var import_jsx_runtime405 = __toESM(require_jsx_runtime(), 1);
63771 function RevisionDiffPanel({ title, entries, initialOpen }) {
63772 if (!entries) {
63773 return null;
63774 }
63775 const fields2 = Object.entries(entries).map(([key, parts]) => /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(post_panel_row_default, { label: key, children: /* @__PURE__ */ (0, import_jsx_runtime405.jsx)("span", { className: "editor-revision-fields-diff__value", children: parts.map((part, index2) => {
63776 if (part.added) {
63777 return /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(
63778 "ins",
63779 {
63780 className: "editor-revision-fields-diff__added",
63781 children: part.value
63782 },
63783 index2
63784 );
63785 }
63786 if (part.removed) {
63787 return /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(
63788 "del",
63789 {
63790 className: "editor-revision-fields-diff__removed",
63791 children: part.value
63792 },
63793 index2
63794 );
63795 }
63796 return /* @__PURE__ */ (0, import_jsx_runtime405.jsx)("span", { children: part.value }, index2);
63797 }) }) }, key));
63798 return /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(import_components239.PanelBody, { title, initialOpen, children: fields2 });
63799 }
63800
63801 // packages/editor/build-module/components/revision-fields-diff/index.mjs
63802 var import_jsx_runtime406 = __toESM(require_jsx_runtime(), 1);
63803 function stringifyValue2(value) {
63804 if (value === null || value === void 0) {
63805 return "";
63806 }
63807 if (typeof value === "object") {
63808 return JSON.stringify(value, null, 2);
63809 }
63810 return String(value);
63811 }
63812 function RevisionFieldsDiffPanel() {
63813 const { revision, previousRevision } = (0, import_data228.useSelect)((select6) => {
63814 const { getCurrentRevision: getCurrentRevision2, getPreviousRevision: getPreviousRevision2 } = unlock(
63815 select6(store)
63816 );
63817 return {
63818 revision: getCurrentRevision2(),
63819 previousRevision: getPreviousRevision2()
63820 };
63821 }, []);
63822 const entries = (0, import_element219.useMemo)(() => {
63823 if (!revision) {
63824 return null;
63825 }
63826 const revisionMeta = revision.meta ?? {};
63827 const previousMeta = previousRevision?.meta ?? {};
63828 const allMetaKeys = /* @__PURE__ */ new Set([
63829 ...Object.keys(revisionMeta),
63830 ...Object.keys(previousMeta)
63831 ]);
63832 const result = {};
63833 for (const key of allMetaKeys) {
63834 const revStr = stringifyValue2(revisionMeta[key]);
63835 const prevStr = stringifyValue2(previousMeta[key]);
63836 if (!revStr && !prevStr) {
63837 continue;
63838 }
63839 result[key] = (0, import_word2.diffWords)(prevStr, revStr);
63840 }
63841 if (Object.keys(result).length === 0) {
63842 return null;
63843 }
63844 return result;
63845 }, [revision, previousRevision]);
63846 return /* @__PURE__ */ (0, import_jsx_runtime406.jsx)(
63847 RevisionDiffPanel,
63848 {
63849 title: (0, import_i18n259.__)("Meta"),
63850 entries,
63851 initialOpen: false
63852 }
63853 );
63854 }
63855
63856 // packages/editor/build-module/components/post-transform-panel/index.mjs
63857 var import_data230 = __toESM(require_data(), 1);
63858 var import_core_data131 = __toESM(require_core_data(), 1);
63859 var import_components240 = __toESM(require_components(), 1);
63860 var import_i18n260 = __toESM(require_i18n(), 1);
63861 var import_block_editor88 = __toESM(require_block_editor(), 1);
63862 var import_blocks36 = __toESM(require_blocks(), 1);
63863
63864 // packages/editor/build-module/components/post-transform-panel/hooks.mjs
63865 var import_data229 = __toESM(require_data(), 1);
63866 var import_element220 = __toESM(require_element(), 1);
63867 var import_core_data130 = __toESM(require_core_data(), 1);
63868 var import_blocks35 = __toESM(require_blocks(), 1);
63869 var import_patterns10 = __toESM(require_patterns(), 1);
63870 var { EXCLUDED_PATTERN_SOURCES, PATTERN_TYPES: PATTERN_TYPES5 } = unlock(import_patterns10.privateApis);
63871 function injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet) {
63872 block.innerBlocks = block.innerBlocks.map((innerBlock) => {
63873 return injectThemeAttributeInBlockTemplateContent(
63874 innerBlock,
63875 currentThemeStylesheet
63876 );
63877 });
63878 if (block.name === "core/template-part" && block.attributes.theme === void 0) {
63879 block.attributes.theme = currentThemeStylesheet;
63880 }
63881 return block;
63882 }
63883 function filterPatterns(patterns2, template2) {
63884 const filterOutDuplicatesByName = (currentItem, index2, items) => index2 === items.findIndex((item) => currentItem.name === item.name);
63885 const filterOutExcludedPatternSources = (pattern) => {
63886 if (template2.area === "navigation-overlay" && pattern.blockTypes?.includes(
63887 "core/template-part/navigation-overlay"
63888 )) {
63889 return true;
63890 }
63891 return !EXCLUDED_PATTERN_SOURCES.includes(pattern.source);
63892 };
63893 const filterCompatiblePatterns = (pattern) => pattern.templateTypes?.includes(template2.slug) || pattern.blockTypes?.includes("core/template-part/" + template2.area);
63894 return patterns2.filter((pattern, index2, items) => {
63895 return filterOutDuplicatesByName(pattern, index2, items) && filterOutExcludedPatternSources(pattern) && filterCompatiblePatterns(pattern);
63896 });
63897 }
63898 function preparePatterns(patterns2, currentThemeStylesheet) {
63899 return patterns2.map((pattern) => ({
63900 ...pattern,
63901 keywords: pattern.keywords || [],
63902 type: PATTERN_TYPES5.theme,
63903 blocks: (0, import_blocks35.parse)(pattern.content, {
63904 __unstableSkipMigrationLogs: true
63905 }).map(
63906 (block) => injectThemeAttributeInBlockTemplateContent(
63907 block,
63908 currentThemeStylesheet
63909 )
63910 )
63911 }));
63912 }
63913 function useAvailablePatterns({ area, name: name2, slug }) {
63914 const { blockPatterns, restBlockPatterns, currentThemeStylesheet } = (0, import_data229.useSelect)((select6) => {
63915 const { getEditorSettings: getEditorSettings2 } = select6(store);
63916 const settings = getEditorSettings2();
63917 return {
63918 blockPatterns: settings.__experimentalAdditionalBlockPatterns ?? settings.__experimentalBlockPatterns,
63919 restBlockPatterns: select6(import_core_data130.store).getBlockPatterns(),
63920 currentThemeStylesheet: select6(import_core_data130.store).getCurrentTheme().stylesheet
63921 };
63922 }, []);
63923 return (0, import_element220.useMemo)(() => {
63924 const mergedPatterns = [
63925 ...blockPatterns || [],
63926 ...restBlockPatterns || []
63927 ];
63928 const filteredPatterns = filterPatterns(mergedPatterns, {
63929 area,
63930 name: name2,
63931 slug
63932 });
63933 return preparePatterns(filteredPatterns, currentThemeStylesheet);
63934 }, [
63935 area,
63936 name2,
63937 slug,
63938 blockPatterns,
63939 restBlockPatterns,
63940 currentThemeStylesheet
63941 ]);
63942 }
63943
63944 // packages/editor/build-module/components/post-transform-panel/index.mjs
63945 var import_jsx_runtime407 = __toESM(require_jsx_runtime(), 1);
63946 function TemplatesList2({ availableTemplates, onSelect }) {
63947 if (!availableTemplates || availableTemplates?.length === 0) {
63948 return null;
63949 }
63950 return /* @__PURE__ */ (0, import_jsx_runtime407.jsx)(
63951 import_block_editor88.__experimentalBlockPatternsList,
63952 {
63953 label: (0, import_i18n260.__)("Templates"),
63954 blockPatterns: availableTemplates,
63955 onClickPattern: onSelect,
63956 showTitlesAsTooltip: true
63957 }
63958 );
63959 }
63960 function PostTransform() {
63961 const { area, name: name2, slug, postType: postType2, postId: postId2 } = (0, import_data230.useSelect)((select6) => {
63962 const { getCurrentPostType: getCurrentPostType2, getCurrentPostId: getCurrentPostId2 } = select6(store);
63963 const { getEditedEntityRecord } = select6(import_core_data131.store);
63964 const type = getCurrentPostType2();
63965 const id = getCurrentPostId2();
63966 const record = getEditedEntityRecord("postType", type, id);
63967 return {
63968 area: record?.area,
63969 name: record?.name,
63970 slug: record?.slug,
63971 postType: type,
63972 postId: id
63973 };
63974 }, []);
63975 const { editEntityRecord } = (0, import_data230.useDispatch)(import_core_data131.store);
63976 const availablePatterns = useAvailablePatterns({ area, name: name2, slug });
63977 const onTemplateSelect = async (selectedTemplate) => {
63978 await editEntityRecord("postType", postType2, postId2, {
63979 blocks: selectedTemplate.blocks,
63980 content: (0, import_blocks36.serialize)(selectedTemplate.blocks)
63981 });
63982 };
63983 if (!availablePatterns?.length) {
63984 return null;
63985 }
63986 return /* @__PURE__ */ (0, import_jsx_runtime407.jsx)(
63987 import_components240.PanelBody,
63988 {
63989 title: (0, import_i18n260.__)("Design"),
63990 initialOpen: postType2 === TEMPLATE_PART_POST_TYPE,
63991 children: /* @__PURE__ */ (0, import_jsx_runtime407.jsx)(
63992 TemplatesList2,
63993 {
63994 availableTemplates: availablePatterns,
63995 onSelect: onTemplateSelect
63996 }
63997 )
63998 }
63999 );
64000 }
64001 function PostTransformPanel() {
64002 const { postType: postType2 } = (0, import_data230.useSelect)((select6) => {
64003 const { getCurrentPostType: getCurrentPostType2 } = select6(store);
64004 return {
64005 postType: getCurrentPostType2()
64006 };
64007 }, []);
64008 if (![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(postType2)) {
64009 return null;
64010 }
64011 return /* @__PURE__ */ (0, import_jsx_runtime407.jsx)(PostTransform, {});
64012 }
64013
64014 // packages/editor/build-module/components/sidebar/header.mjs
64015 var import_components241 = __toESM(require_components(), 1);
64016 var import_i18n261 = __toESM(require_i18n(), 1);
64017 var import_data231 = __toESM(require_data(), 1);
64018 var import_element221 = __toESM(require_element(), 1);
64019 var import_html_entities30 = __toESM(require_html_entities(), 1);
64020 var import_jsx_runtime408 = __toESM(require_jsx_runtime(), 1);
64021 var { Tabs: Tabs4 } = unlock(import_components241.privateApis);
64022 var SidebarHeader = (_, ref) => {
64023 const { postTypeLabel, isAttachment, isRevisionsMode: isRevisionsMode2 } = (0, import_data231.useSelect)(
64024 (select6) => {
64025 const { getPostTypeLabel: getPostTypeLabel2, getCurrentPostType: getCurrentPostType2 } = select6(store);
64026 const { isRevisionsMode: _isRevisionsMode } = unlock(
64027 select6(store)
64028 );
64029 return {
64030 postTypeLabel: getPostTypeLabel2(),
64031 isAttachment: getCurrentPostType2() === ATTACHMENT_POST_TYPE && window?.__experimentalMediaEditor,
64032 isRevisionsMode: _isRevisionsMode()
64033 };
64034 },
64035 []
64036 );
64037 let documentLabel;
64038 if (isRevisionsMode2) {
64039 documentLabel = (0, import_i18n261.__)("Revision");
64040 } else if (postTypeLabel) {
64041 documentLabel = (0, import_html_entities30.decodeEntities)(postTypeLabel);
64042 } else {
64043 documentLabel = (0, import_i18n261._x)("Document", "noun, panel");
64044 }
64045 return /* @__PURE__ */ (0, import_jsx_runtime408.jsxs)(Tabs4.TabList, { ref, children: [
64046 /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(
64047 Tabs4.Tab,
64048 {
64049 tabId: sidebars.document,
64050 "data-tab-id": sidebars.document,
64051 children: documentLabel
64052 }
64053 ),
64054 !isAttachment && /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(
64055 Tabs4.Tab,
64056 {
64057 tabId: sidebars.block,
64058 "data-tab-id": sidebars.block,
64059 children: (0, import_i18n261.__)("Block")
64060 }
64061 )
64062 ] });
64063 };
64064 var header_default3 = (0, import_element221.forwardRef)(SidebarHeader);
64065
64066 // packages/editor/build-module/components/template-content-panel/index.mjs
64067 var import_data232 = __toESM(require_data(), 1);
64068 var import_block_editor89 = __toESM(require_block_editor(), 1);
64069 var import_components242 = __toESM(require_components(), 1);
64070 var import_i18n262 = __toESM(require_i18n(), 1);
64071 var import_jsx_runtime409 = __toESM(require_jsx_runtime(), 1);
64072 var { BlockQuickNavigation } = unlock(import_block_editor89.privateApis);
64073 var TEMPLATE_PART_BLOCK = "core/template-part";
64074 function TemplateContentPanelInner({ postType: postType2 }) {
64075 const postContentBlockTypes = usePostContentBlockTypes();
64076 const clientIds = (0, import_data232.useSelect)(
64077 (select6) => {
64078 const { getPostBlocksByName: getPostBlocksByName2 } = unlock(select6(store));
64079 return getPostBlocksByName2(
64080 TEMPLATE_POST_TYPE === postType2 ? TEMPLATE_PART_BLOCK : postContentBlockTypes
64081 );
64082 },
64083 [postType2, postContentBlockTypes]
64084 );
64085 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data232.useDispatch)(store2);
64086 if (clientIds.length === 0) {
64087 return null;
64088 }
64089 return /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(import_components242.PanelBody, { title: (0, import_i18n262.__)("Content"), children: /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(
64090 BlockQuickNavigation,
64091 {
64092 clientIds,
64093 onSelect: () => {
64094 enableComplementaryArea2("core", "edit-post/document");
64095 }
64096 }
64097 ) });
64098 }
64099 function TemplateContentPanel() {
64100 const { postType: postType2, renderingMode: renderingMode2 } = (0, import_data232.useSelect)((select6) => {
64101 const { getCurrentPostType: getCurrentPostType2, getRenderingMode: getRenderingMode2 } = unlock(
64102 select6(store)
64103 );
64104 return {
64105 postType: getCurrentPostType2(),
64106 renderingMode: getRenderingMode2()
64107 };
64108 }, []);
64109 if (renderingMode2 === "post-only" && postType2 !== TEMPLATE_POST_TYPE) {
64110 return null;
64111 }
64112 return /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(TemplateContentPanelInner, { postType: postType2 });
64113 }
64114
64115 // packages/editor/build-module/components/template-part-content-panel/index.mjs
64116 var import_data233 = __toESM(require_data(), 1);
64117 var import_element222 = __toESM(require_element(), 1);
64118 var import_blocks37 = __toESM(require_blocks(), 1);
64119 var import_block_editor90 = __toESM(require_block_editor(), 1);
64120 var import_components243 = __toESM(require_components(), 1);
64121 var import_i18n263 = __toESM(require_i18n(), 1);
64122 var import_jsx_runtime410 = __toESM(require_jsx_runtime(), 1);
64123 var { BlockQuickNavigation: BlockQuickNavigation2 } = unlock(import_block_editor90.privateApis);
64124 function TemplatePartContentPanelInner() {
64125 const blockTypes = (0, import_data233.useSelect)((select6) => {
64126 const { getBlockTypes: getBlockTypes6 } = select6(import_blocks37.store);
64127 return getBlockTypes6();
64128 }, []);
64129 const themeBlockNames = (0, import_element222.useMemo)(() => {
64130 return blockTypes.filter((blockType) => {
64131 return blockType.category === "theme";
64132 }).map(({ name: name2 }) => name2);
64133 }, [blockTypes]);
64134 const themeBlocks = (0, import_data233.useSelect)(
64135 (select6) => {
64136 const { getBlocksByName } = select6(import_block_editor90.store);
64137 return getBlocksByName(themeBlockNames);
64138 },
64139 [themeBlockNames]
64140 );
64141 if (themeBlocks.length === 0) {
64142 return null;
64143 }
64144 return /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(import_components243.PanelBody, { title: (0, import_i18n263.__)("Content"), children: /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(BlockQuickNavigation2, { clientIds: themeBlocks }) });
64145 }
64146 function TemplatePartContentPanel() {
64147 const postType2 = (0, import_data233.useSelect)((select6) => {
64148 const { getCurrentPostType: getCurrentPostType2 } = select6(store);
64149 return getCurrentPostType2();
64150 }, []);
64151 if (postType2 !== TEMPLATE_PART_POST_TYPE) {
64152 return null;
64153 }
64154 return /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(TemplatePartContentPanelInner, {});
64155 }
64156
64157 // packages/editor/build-module/components/revision-block-diff/index.mjs
64158 var import_block_editor91 = __toESM(require_block_editor(), 1);
64159 var import_data234 = __toESM(require_data(), 1);
64160 var import_i18n264 = __toESM(require_i18n(), 1);
64161 var import_jsx_runtime411 = __toESM(require_jsx_runtime(), 1);
64162 function RevisionBlockDiffPanel() {
64163 const { block } = (0, import_data234.useSelect)((select6) => {
64164 const { getSelectedBlock: getSelectedBlock2 } = select6(import_block_editor91.store);
64165 return {
64166 block: getSelectedBlock2()
64167 };
64168 }, []);
64169 if (!block) {
64170 return null;
64171 }
64172 const changedAttributes = block.attributes?.__revisionDiffStatus?.changedAttributes;
64173 return /* @__PURE__ */ (0, import_jsx_runtime411.jsx)(
64174 RevisionDiffPanel,
64175 {
64176 title: (0, import_i18n264.__)("Changed attributes"),
64177 entries: changedAttributes,
64178 initialOpen: true
64179 }
64180 );
64181 }
64182
64183 // packages/editor/build-module/components/provider/use-auto-switch-editor-sidebars.mjs
64184 var import_data235 = __toESM(require_data(), 1);
64185 var import_element223 = __toESM(require_element(), 1);
64186 var import_block_editor92 = __toESM(require_block_editor(), 1);
64187 var import_preferences25 = __toESM(require_preferences(), 1);
64188 function useAutoSwitchEditorSidebars() {
64189 const { hasBlockSelection } = (0, import_data235.useSelect)((select6) => {
64190 return {
64191 hasBlockSelection: !!select6(import_block_editor92.store).getBlockSelectionStart()
64192 };
64193 }, []);
64194 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data235.useSelect)(store2);
64195 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data235.useDispatch)(store2);
64196 const { get: getPreference } = (0, import_data235.useSelect)(import_preferences25.store);
64197 (0, import_element223.useEffect)(() => {
64198 const activeGeneralSidebar = getActiveComplementaryArea2("core");
64199 const isEditorSidebarOpened = [
64200 "edit-post/document",
64201 "edit-post/block"
64202 ].includes(activeGeneralSidebar);
64203 const isDistractionFree = getPreference("core", "distractionFree");
64204 if (!isEditorSidebarOpened || isDistractionFree) {
64205 return;
64206 }
64207 if (hasBlockSelection) {
64208 enableComplementaryArea2("core", "edit-post/block");
64209 } else {
64210 enableComplementaryArea2("core", "edit-post/document");
64211 }
64212 }, [
64213 hasBlockSelection,
64214 getActiveComplementaryArea2,
64215 enableComplementaryArea2,
64216 getPreference
64217 ]);
64218 }
64219 var use_auto_switch_editor_sidebars_default = useAutoSwitchEditorSidebars;
64220
64221 // packages/editor/build-module/components/sidebar/index.mjs
64222 var import_jsx_runtime412 = __toESM(require_jsx_runtime(), 1);
64223 var { Tabs: Tabs5 } = unlock(import_components244.privateApis);
64224 var SIDEBAR_ACTIVE_BY_DEFAULT = import_element224.Platform.select({
64225 web: true,
64226 native: false
64227 });
64228 var SidebarContent = ({
64229 tabName,
64230 keyboardShortcut,
64231 onActionPerformed,
64232 extraPanels,
64233 postType: postType2
64234 }) => {
64235 const tabListRef = (0, import_element224.useRef)(null);
64236 const tabsContextValue = (0, import_element224.useContext)(Tabs5.Context);
64237 const isAttachment = postType2 === ATTACHMENT_POST_TYPE;
64238 const isRevisionsMode2 = (0, import_data236.useSelect)((select6) => {
64239 return unlock(select6(store)).isRevisionsMode();
64240 });
64241 (0, import_element224.useEffect)(() => {
64242 const tabsElements = Array.from(
64243 tabListRef.current?.querySelectorAll('[role="tab"]') || []
64244 );
64245 const selectedTabElement = tabsElements.find(
64246 // We are purposefully using a custom `data-tab-id` attribute here
64247 // because we don't want rely on any assumptions about `Tabs`
64248 // component internals.
64249 (element) => element.getAttribute("data-tab-id") === tabName
64250 );
64251 const activeElement = selectedTabElement?.ownerDocument.activeElement;
64252 const tabsHasFocus = tabsElements.some((element) => {
64253 return activeElement && activeElement.id === element.id;
64254 });
64255 if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) {
64256 selectedTabElement?.focus();
64257 }
64258 }, [tabName]);
64259 return /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
64260 PluginSidebar,
64261 {
64262 identifier: tabName,
64263 header: /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(Tabs5.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(header_default3, { ref: tabListRef }) }),
64264 closeLabel: (0, import_i18n265.__)("Close Settings"),
64265 className: "editor-sidebar__panel",
64266 headerClassName: "editor-sidebar__panel-tabs",
64267 title: (
64268 /* translators: button label text should, if possible, be under 16 characters. */
64269 (0, import_i18n265._x)("Settings", "panel button label")
64270 ),
64271 toggleShortcut: keyboardShortcut,
64272 icon: (0, import_i18n265.isRTL)() ? drawer_left_default : drawer_right_default,
64273 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
64274 children: /* @__PURE__ */ (0, import_jsx_runtime412.jsxs)(Tabs5.Context.Provider, { value: tabsContextValue, children: [
64275 /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(Tabs5.TabPanel, { tabId: sidebars.document, focusable: false, children: isAttachment ? /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
64276 MediaMetadataPanel,
64277 {
64278 onActionPerformed
64279 }
64280 ) : /* @__PURE__ */ (0, import_jsx_runtime412.jsxs)(import_jsx_runtime412.Fragment, { children: [
64281 /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
64282 PostSummary,
64283 {
64284 onActionPerformed
64285 }
64286 ),
64287 isRevisionsMode2 && /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(RevisionFieldsDiffPanel, {}),
64288 !isRevisionsMode2 && /* @__PURE__ */ (0, import_jsx_runtime412.jsxs)(import_jsx_runtime412.Fragment, { children: [
64289 /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(plugin_document_setting_panel_default.Slot, {}),
64290 /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(TemplateContentPanel, {}),
64291 /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(TemplatePartContentPanel, {}),
64292 /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(PostTransformPanel, {}),
64293 /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(PostTaxonomies2, {}),
64294 /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(PatternOverridesPanel, {}),
64295 extraPanels
64296 ] })
64297 ] }) }),
64298 !isAttachment && /* @__PURE__ */ (0, import_jsx_runtime412.jsxs)(Tabs5.TabPanel, { tabId: sidebars.block, focusable: false, children: [
64299 /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(import_block_editor93.BlockInspector, {}),
64300 isRevisionsMode2 && /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(RevisionBlockDiffPanel, {})
64301 ] })
64302 ] })
64303 }
64304 );
64305 };
64306 var Sidebar = ({ extraPanels, onActionPerformed }) => {
64307 use_auto_switch_editor_sidebars_default();
64308 const { tabName, keyboardShortcut, showSummary, postType: postType2 } = (0, import_data236.useSelect)(
64309 (select6) => {
64310 const shortcut = select6(
64311 import_keyboard_shortcuts10.store
64312 ).getShortcutRepresentation("core/editor/toggle-sidebar");
64313 const sidebar = select6(store2).getActiveComplementaryArea("core");
64314 const _isEditorSidebarOpened = [
64315 sidebars.block,
64316 sidebars.document
64317 ].includes(sidebar);
64318 let _tabName = sidebar;
64319 if (!_isEditorSidebarOpened) {
64320 _tabName = !!select6(
64321 import_block_editor93.store
64322 ).getBlockSelectionStart() ? sidebars.block : sidebars.document;
64323 }
64324 const _postType = select6(store).getCurrentPostType();
64325 return {
64326 tabName: _tabName,
64327 keyboardShortcut: shortcut,
64328 showSummary: ![
64329 TEMPLATE_POST_TYPE,
64330 TEMPLATE_PART_POST_TYPE,
64331 NAVIGATION_POST_TYPE
64332 ].includes(_postType),
64333 postType: _postType
64334 };
64335 },
64336 []
64337 );
64338 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data236.useDispatch)(store2);
64339 const onTabSelect = (0, import_element224.useCallback)(
64340 (newSelectedTabId) => {
64341 if (!!newSelectedTabId) {
64342 enableComplementaryArea2("core", newSelectedTabId);
64343 }
64344 },
64345 [enableComplementaryArea2]
64346 );
64347 return /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
64348 Tabs5,
64349 {
64350 selectedTabId: tabName,
64351 onSelect: onTabSelect,
64352 selectOnMove: false,
64353 children: /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(
64354 SidebarContent,
64355 {
64356 tabName,
64357 keyboardShortcut,
64358 showSummary,
64359 onActionPerformed,
64360 extraPanels,
64361 postType: postType2
64362 }
64363 )
64364 }
64365 );
64366 };
64367 var sidebar_default2 = Sidebar;
64368
64369 // packages/editor/build-module/components/collab-sidebar/index.mjs
64370 var import_i18n273 = __toESM(require_i18n(), 1);
64371 var import_data242 = __toESM(require_data(), 1);
64372 var import_components251 = __toESM(require_components(), 1);
64373 var import_element229 = __toESM(require_element(), 1);
64374 var import_compose69 = __toESM(require_compose(), 1);
64375 var import_keyboard_shortcuts12 = __toESM(require_keyboard_shortcuts(), 1);
64376 var import_block_editor100 = __toESM(require_block_editor(), 1);
64377 var import_preferences26 = __toESM(require_preferences(), 1);
64378
64379 // packages/editor/build-module/components/collab-sidebar/constants.mjs
64380 var ALL_NOTES_SIDEBAR = "edit-post/collab-history-sidebar";
64381 var FLOATING_NOTES_SIDEBAR = "edit-post/collab-sidebar";
64382 var SIDEBARS = [ALL_NOTES_SIDEBAR, FLOATING_NOTES_SIDEBAR];
64383
64384 // packages/editor/build-module/components/collab-sidebar/comments.mjs
64385 var import_element227 = __toESM(require_element(), 1);
64386 var import_components248 = __toESM(require_components(), 1);
64387 var import_compose68 = __toESM(require_compose(), 1);
64388 var import_i18n270 = __toESM(require_i18n(), 1);
64389 var import_data240 = __toESM(require_data(), 1);
64390 var import_dom8 = __toESM(require_dom(), 1);
64391 var import_block_editor97 = __toESM(require_block_editor(), 1);
64392
64393 // packages/editor/build-module/components/collab-sidebar/comment-author-info.mjs
64394 var import_components245 = __toESM(require_components(), 1);
64395 var import_i18n266 = __toESM(require_i18n(), 1);
64396 var import_date20 = __toESM(require_date(), 1);
64397 var import_core_data132 = __toESM(require_core_data(), 1);
64398 var import_data237 = __toESM(require_data(), 1);
64399 var import_block_editor94 = __toESM(require_block_editor(), 1);
64400 var import_jsx_runtime413 = __toESM(require_jsx_runtime(), 1);
64401 function CommentAuthorInfo({ avatar, name: name2, date, userId }) {
64402 const hasAvatar = !!avatar;
64403 const dateSettings = (0, import_date20.getSettings)();
64404 const {
64405 currentUserAvatar,
64406 currentUserName,
64407 currentUserId,
64408 dateFormat = dateSettings.formats.date
64409 } = (0, import_data237.useSelect)(
64410 (select6) => {
64411 const { canUser, getCurrentUser, getEntityRecord } = select6(import_core_data132.store);
64412 const siteSettings = canUser("read", {
64413 kind: "root",
64414 name: "site"
64415 }) ? getEntityRecord("root", "site") : void 0;
64416 if (hasAvatar) {
64417 return {
64418 dateFormat: siteSettings?.date_format
64419 };
64420 }
64421 const { getSettings: getSettings10 } = select6(import_block_editor94.store);
64422 const { __experimentalDiscussionSettings } = getSettings10();
64423 const defaultAvatar = __experimentalDiscussionSettings?.avatarURL;
64424 const userData = getCurrentUser();
64425 return {
64426 currentUserAvatar: userData?.avatar_urls?.[48] ?? defaultAvatar,
64427 currentUserName: userData?.name,
64428 currentUserId: userData?.id,
64429 dateFormat: siteSettings?.date_format
64430 };
64431 },
64432 [hasAvatar]
64433 );
64434 const commentDate = (0, import_date20.getDate)(date);
64435 const commentDateTime = (0, import_date20.dateI18n)("c", commentDate);
64436 const shouldShowHumanTimeDiff = Math.floor((/* @__PURE__ */ new Date() - commentDate) / (1e3 * 60 * 60 * 24)) < 30;
64437 const commentDateText = shouldShowHumanTimeDiff ? (0, import_date20.humanTimeDiff)(commentDate) : (0, import_date20.dateI18n)(dateFormat, commentDate);
64438 const tooltipText = (0, import_date20.dateI18n)(
64439 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
64440 (0, import_i18n266._x)("F j, Y g:i\xA0a", "Note date full date format"),
64441 date
64442 );
64443 return /* @__PURE__ */ (0, import_jsx_runtime413.jsxs)(import_jsx_runtime413.Fragment, { children: [
64444 /* @__PURE__ */ (0, import_jsx_runtime413.jsx)(
64445 "img",
64446 {
64447 src: avatar || currentUserAvatar,
64448 className: "editor-collab-sidebar-panel__user-avatar",
64449 alt: (0, import_i18n266.__)("User avatar"),
64450 width: 32,
64451 height: 32,
64452 style: {
64453 borderColor: getAvatarBorderColor(
64454 userId ?? currentUserId
64455 )
64456 }
64457 }
64458 ),
64459 /* @__PURE__ */ (0, import_jsx_runtime413.jsxs)(import_components245.__experimentalVStack, { spacing: "0", children: [
64460 /* @__PURE__ */ (0, import_jsx_runtime413.jsx)("span", { className: "editor-collab-sidebar-panel__user-name", children: name2 ?? currentUserName }),
64461 date && /* @__PURE__ */ (0, import_jsx_runtime413.jsx)(import_components245.Tooltip, { text: tooltipText, children: /* @__PURE__ */ (0, import_jsx_runtime413.jsx)(
64462 "time",
64463 {
64464 dateTime: commentDateTime,
64465 className: "editor-collab-sidebar-panel__user-time",
64466 children: commentDateText
64467 }
64468 ) })
64469 ] })
64470 ] });
64471 }
64472 var comment_author_info_default = CommentAuthorInfo;
64473
64474 // packages/editor/build-module/components/collab-sidebar/comment-form.mjs
64475 var import_react_autosize_textarea2 = __toESM(require_lib(), 1);
64476 var import_element225 = __toESM(require_element(), 1);
64477 var import_components246 = __toESM(require_components(), 1);
64478 var import_i18n267 = __toESM(require_i18n(), 1);
64479 var import_compose67 = __toESM(require_compose(), 1);
64480 var import_keycodes17 = __toESM(require_keycodes(), 1);
64481 var import_jsx_runtime414 = __toESM(require_jsx_runtime(), 1);
64482 function CommentForm({
64483 onSubmit,
64484 onCancel,
64485 thread,
64486 submitButtonText,
64487 labelText,
64488 reflowComments = noop7
64489 }) {
64490 const [inputComment, setInputComment] = (0, import_element225.useState)(
64491 thread?.content?.raw ?? ""
64492 );
64493 const debouncedCommentUpdated = (0, import_compose67.useDebounce)(reflowComments, 100);
64494 const updateComment = (value) => {
64495 setInputComment(value);
64496 };
64497 const inputId = (0, import_compose67.useInstanceId)(CommentForm, "comment-input");
64498 const isDisabled = inputComment === thread?.content?.raw || !sanitizeCommentString(inputComment).length;
64499 return /* @__PURE__ */ (0, import_jsx_runtime414.jsxs)(
64500 import_components246.__experimentalVStack,
64501 {
64502 className: "editor-collab-sidebar-panel__comment-form",
64503 spacing: "4",
64504 as: "form",
64505 onSubmit: (event) => {
64506 event.preventDefault();
64507 onSubmit(inputComment);
64508 setInputComment("");
64509 },
64510 children: [
64511 /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(import_components246.VisuallyHidden, { as: "label", htmlFor: inputId, children: labelText ?? (0, import_i18n267.__)("Note") }),
64512 /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(
64513 import_react_autosize_textarea2.default,
64514 {
64515 id: inputId,
64516 value: inputComment ?? "",
64517 onChange: (comment) => {
64518 updateComment(comment.target.value);
64519 debouncedCommentUpdated();
64520 },
64521 rows: 1,
64522 maxRows: 20,
64523 onKeyDown: (event) => {
64524 if (import_keycodes17.isKeyboardEvent.primary(event, "Enter") && !isDisabled) {
64525 event.target.parentNode.requestSubmit();
64526 }
64527 if (event.key === "Escape") {
64528 event.preventDefault();
64529 onCancel(event);
64530 }
64531 }
64532 }
64533 ),
64534 /* @__PURE__ */ (0, import_jsx_runtime414.jsxs)(import_components246.__experimentalHStack, { spacing: "2", justify: "flex-end", wrap: true, children: [
64535 /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(import_components246.Button, { size: "compact", variant: "tertiary", onClick: onCancel, children: /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(import_components246.__experimentalTruncate, { children: (0, import_i18n267.__)("Cancel") }) }),
64536 /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(
64537 import_components246.Button,
64538 {
64539 size: "compact",
64540 accessibleWhenDisabled: true,
64541 variant: "primary",
64542 type: "submit",
64543 disabled: isDisabled,
64544 children: /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(import_components246.__experimentalTruncate, { children: submitButtonText })
64545 }
64546 )
64547 ] })
64548 ]
64549 }
64550 );
64551 }
64552 var comment_form_default = CommentForm;
64553
64554 // node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
64555 var React7 = __toESM(require_react(), 1);
64556 var import_react7 = __toESM(require_react(), 1);
64557 var ReactDOM = __toESM(require_react_dom(), 1);
64558 var index = typeof document !== "undefined" ? import_react7.useLayoutEffect : import_react7.useEffect;
64559 function deepEqual(a3, b3) {
64560 if (a3 === b3) {
64561 return true;
64562 }
64563 if (typeof a3 !== typeof b3) {
64564 return false;
64565 }
64566 if (typeof a3 === "function" && a3.toString() === b3.toString()) {
64567 return true;
64568 }
64569 let length;
64570 let i3;
64571 let keys;
64572 if (a3 && b3 && typeof a3 === "object") {
64573 if (Array.isArray(a3)) {
64574 length = a3.length;
64575 if (length !== b3.length) return false;
64576 for (i3 = length; i3-- !== 0; ) {
64577 if (!deepEqual(a3[i3], b3[i3])) {
64578 return false;
64579 }
64580 }
64581 return true;
64582 }
64583 keys = Object.keys(a3);
64584 length = keys.length;
64585 if (length !== Object.keys(b3).length) {
64586 return false;
64587 }
64588 for (i3 = length; i3-- !== 0; ) {
64589 if (!{}.hasOwnProperty.call(b3, keys[i3])) {
64590 return false;
64591 }
64592 }
64593 for (i3 = length; i3-- !== 0; ) {
64594 const key = keys[i3];
64595 if (key === "_owner" && a3.$$typeof) {
64596 continue;
64597 }
64598 if (!deepEqual(a3[key], b3[key])) {
64599 return false;
64600 }
64601 }
64602 return true;
64603 }
64604 return a3 !== a3 && b3 !== b3;
64605 }
64606 function getDPR(element) {
64607 if (typeof window === "undefined") {
64608 return 1;
64609 }
64610 const win = element.ownerDocument.defaultView || window;
64611 return win.devicePixelRatio || 1;
64612 }
64613 function roundByDPR(element, value) {
64614 const dpr = getDPR(element);
64615 return Math.round(value * dpr) / dpr;
64616 }
64617 function useLatestRef(value) {
64618 const ref = React7.useRef(value);
64619 index(() => {
64620 ref.current = value;
64621 });
64622 return ref;
64623 }
64624 function useFloating(options) {
64625 if (options === void 0) {
64626 options = {};
64627 }
64628 const {
64629 placement = "bottom",
64630 strategy = "absolute",
64631 middleware = [],
64632 platform: platform2,
64633 elements: {
64634 reference: externalReference,
64635 floating: externalFloating
64636 } = {},
64637 transform = true,
64638 whileElementsMounted,
64639 open
64640 } = options;
64641 const [data, setData] = React7.useState({
64642 x: 0,
64643 y: 0,
64644 strategy,
64645 placement,
64646 middlewareData: {},
64647 isPositioned: false
64648 });
64649 const [latestMiddleware, setLatestMiddleware] = React7.useState(middleware);
64650 if (!deepEqual(latestMiddleware, middleware)) {
64651 setLatestMiddleware(middleware);
64652 }
64653 const [_reference, _setReference] = React7.useState(null);
64654 const [_floating, _setFloating] = React7.useState(null);
64655 const setReference = React7.useCallback((node) => {
64656 if (node !== referenceRef.current) {
64657 referenceRef.current = node;
64658 _setReference(node);
64659 }
64660 }, []);
64661 const setFloating = React7.useCallback((node) => {
64662 if (node !== floatingRef.current) {
64663 floatingRef.current = node;
64664 _setFloating(node);
64665 }
64666 }, []);
64667 const referenceEl = externalReference || _reference;
64668 const floatingEl = externalFloating || _floating;
64669 const referenceRef = React7.useRef(null);
64670 const floatingRef = React7.useRef(null);
64671 const dataRef = React7.useRef(data);
64672 const hasWhileElementsMounted = whileElementsMounted != null;
64673 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
64674 const platformRef = useLatestRef(platform2);
64675 const update4 = React7.useCallback(() => {
64676 if (!referenceRef.current || !floatingRef.current) {
64677 return;
64678 }
64679 const config2 = {
64680 placement,
64681 strategy,
64682 middleware: latestMiddleware
64683 };
64684 if (platformRef.current) {
64685 config2.platform = platformRef.current;
64686 }
64687 computePosition2(referenceRef.current, floatingRef.current, config2).then((data2) => {
64688 const fullData = {
64689 ...data2,
64690 isPositioned: true
64691 };
64692 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
64693 dataRef.current = fullData;
64694 ReactDOM.flushSync(() => {
64695 setData(fullData);
64696 });
64697 }
64698 });
64699 }, [latestMiddleware, placement, strategy, platformRef]);
64700 index(() => {
64701 if (open === false && dataRef.current.isPositioned) {
64702 dataRef.current.isPositioned = false;
64703 setData((data2) => ({
64704 ...data2,
64705 isPositioned: false
64706 }));
64707 }
64708 }, [open]);
64709 const isMountedRef = React7.useRef(false);
64710 index(() => {
64711 isMountedRef.current = true;
64712 return () => {
64713 isMountedRef.current = false;
64714 };
64715 }, []);
64716 index(() => {
64717 if (referenceEl) referenceRef.current = referenceEl;
64718 if (floatingEl) floatingRef.current = floatingEl;
64719 if (referenceEl && floatingEl) {
64720 if (whileElementsMountedRef.current) {
64721 return whileElementsMountedRef.current(referenceEl, floatingEl, update4);
64722 }
64723 update4();
64724 }
64725 }, [referenceEl, floatingEl, update4, whileElementsMountedRef, hasWhileElementsMounted]);
64726 const refs = React7.useMemo(() => ({
64727 reference: referenceRef,
64728 floating: floatingRef,
64729 setReference,
64730 setFloating
64731 }), [setReference, setFloating]);
64732 const elements2 = React7.useMemo(() => ({
64733 reference: referenceEl,
64734 floating: floatingEl
64735 }), [referenceEl, floatingEl]);
64736 const floatingStyles = React7.useMemo(() => {
64737 const initialStyles = {
64738 position: strategy,
64739 left: 0,
64740 top: 0
64741 };
64742 if (!elements2.floating) {
64743 return initialStyles;
64744 }
64745 const x2 = roundByDPR(elements2.floating, data.x);
64746 const y3 = roundByDPR(elements2.floating, data.y);
64747 if (transform) {
64748 return {
64749 ...initialStyles,
64750 transform: "translate(" + x2 + "px, " + y3 + "px)",
64751 ...getDPR(elements2.floating) >= 1.5 && {
64752 willChange: "transform"
64753 }
64754 };
64755 }
64756 return {
64757 position: strategy,
64758 left: x2,
64759 top: y3
64760 };
64761 }, [strategy, transform, elements2.floating, data.x, data.y]);
64762 return React7.useMemo(() => ({
64763 ...data,
64764 update: update4,
64765 refs,
64766 elements: elements2,
64767 floatingStyles
64768 }), [data, update4, refs, elements2, floatingStyles]);
64769 }
64770
64771 // packages/editor/build-module/components/collab-sidebar/hooks.mjs
64772 var import_i18n268 = __toESM(require_i18n(), 1);
64773 var import_element226 = __toESM(require_element(), 1);
64774 var import_core_data133 = __toESM(require_core_data(), 1);
64775 var import_data238 = __toESM(require_data(), 1);
64776 var import_block_editor95 = __toESM(require_block_editor(), 1);
64777 var import_notices32 = __toESM(require_notices(), 1);
64778 var import_html_entities31 = __toESM(require_html_entities(), 1);
64779 var { useBlockElement, cleanEmptyObject: cleanEmptyObject4 } = unlock(import_block_editor95.privateApis);
64780 function useBlockComments(postId2) {
64781 const [commentLastUpdated, reflowComments] = (0, import_element226.useReducer)(
64782 () => Date.now(),
64783 0
64784 );
64785 const queryArgs = {
64786 post: postId2,
64787 type: "note",
64788 status: "all",
64789 per_page: -1
64790 };
64791 const { records: threads } = (0, import_core_data133.useEntityRecords)(
64792 "root",
64793 "comment",
64794 queryArgs,
64795 { enabled: !!postId2 && typeof postId2 === "number" }
64796 );
64797 const { getBlockAttributes: getBlockAttributes2 } = (0, import_data238.useSelect)(import_block_editor95.store);
64798 const { clientIds } = (0, import_data238.useSelect)((select6) => {
64799 const { getClientIdsWithDescendants: getClientIdsWithDescendants2 } = select6(import_block_editor95.store);
64800 return {
64801 clientIds: getClientIdsWithDescendants2()
64802 };
64803 }, []);
64804 const { resultComments, unresolvedSortedThreads } = (0, import_element226.useMemo)(() => {
64805 if (!threads || threads.length === 0) {
64806 return { resultComments: [], unresolvedSortedThreads: [] };
64807 }
64808 const blocksWithComments = clientIds.reduce((results, clientId) => {
64809 const commentId = getBlockAttributes2(clientId)?.metadata?.noteId;
64810 if (commentId) {
64811 results[clientId] = commentId;
64812 }
64813 return results;
64814 }, {});
64815 const compare = {};
64816 const result = [];
64817 const commentIdToBlockClientId = Object.keys(
64818 blocksWithComments
64819 ).reduce((mapping, clientId) => {
64820 mapping[blocksWithComments[clientId]] = clientId;
64821 return mapping;
64822 }, {});
64823 threads.forEach((item) => {
64824 const itemBlock = commentIdToBlockClientId[item.id];
64825 compare[item.id] = {
64826 ...item,
64827 reply: [],
64828 blockClientId: item.parent === 0 ? itemBlock : null
64829 };
64830 });
64831 threads.forEach((item) => {
64832 if (item.parent === 0) {
64833 result.push(compare[item.id]);
64834 } else if (compare[item.parent]) {
64835 compare[item.parent].reply.push(compare[item.id]);
64836 }
64837 });
64838 if (0 === result?.length) {
64839 return { resultComments: [], unresolvedSortedThreads: [] };
64840 }
64841 const updatedResult = result.map((item) => ({
64842 ...item,
64843 reply: [...item.reply].reverse()
64844 }));
64845 const threadIdMap = new Map(
64846 updatedResult.map((thread) => [String(thread.id), thread])
64847 );
64848 const mappedIds = new Set(
64849 Object.values(blocksWithComments).map((id) => String(id))
64850 );
64851 const unresolvedSortedComments = Object.values(blocksWithComments).map((commentId) => threadIdMap.get(String(commentId))).filter(
64852 (thread) => thread !== void 0 && thread.status === "hold"
64853 );
64854 const resolvedSortedComments = Object.values(blocksWithComments).map((commentId) => threadIdMap.get(String(commentId))).filter(
64855 (thread) => thread !== void 0 && thread.status === "approved"
64856 );
64857 const orphanedComments = updatedResult.filter(
64858 (thread) => !mappedIds.has(String(thread.id))
64859 );
64860 const allSortedComments = [
64861 ...unresolvedSortedComments,
64862 ...resolvedSortedComments,
64863 ...orphanedComments
64864 ];
64865 return {
64866 resultComments: allSortedComments,
64867 unresolvedSortedThreads: unresolvedSortedComments
64868 };
64869 }, [clientIds, threads, getBlockAttributes2]);
64870 return {
64871 resultComments,
64872 unresolvedSortedThreads,
64873 reflowComments,
64874 commentLastUpdated
64875 };
64876 }
64877 function useBlockCommentsActions(reflowComments = noop7) {
64878 const { createNotice } = (0, import_data238.useDispatch)(import_notices32.store);
64879 const { saveEntityRecord, deleteEntityRecord } = (0, import_data238.useDispatch)(import_core_data133.store);
64880 const { getCurrentPostId: getCurrentPostId2 } = (0, import_data238.useSelect)(store);
64881 const { getBlockAttributes: getBlockAttributes2, getSelectedBlockClientId: getSelectedBlockClientId2 } = (0, import_data238.useSelect)(import_block_editor95.store);
64882 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data238.useDispatch)(import_block_editor95.store);
64883 const onError = (error) => {
64884 const errorMessage = error.message && error.code !== "unknown_error" ? (0, import_html_entities31.decodeEntities)(error.message) : (0, import_i18n268.__)("An error occurred while performing an update.");
64885 createNotice("error", errorMessage, {
64886 type: "snackbar",
64887 isDismissible: true
64888 });
64889 };
64890 const onCreate = async ({ content, parent }) => {
64891 try {
64892 const savedRecord = await saveEntityRecord(
64893 "root",
64894 "comment",
64895 {
64896 post: getCurrentPostId2(),
64897 content,
64898 status: "hold",
64899 type: "note",
64900 parent: parent || 0
64901 },
64902 { throwOnError: true }
64903 );
64904 if (!parent && savedRecord?.id) {
64905 const clientId = getSelectedBlockClientId2();
64906 const metadata = getBlockAttributes2(clientId)?.metadata;
64907 updateBlockAttributes2(clientId, {
64908 metadata: {
64909 ...metadata,
64910 noteId: savedRecord.id
64911 }
64912 });
64913 }
64914 createNotice(
64915 "snackbar",
64916 parent ? (0, import_i18n268.__)("Reply added.") : (0, import_i18n268.__)("Note added."),
64917 {
64918 type: "snackbar",
64919 isDismissible: true
64920 }
64921 );
64922 setTimeout(reflowComments, 300);
64923 return savedRecord;
64924 } catch (error) {
64925 reflowComments();
64926 onError(error);
64927 }
64928 };
64929 const onEdit = async ({ id, content, status }) => {
64930 const messageType = status ? status : "updated";
64931 const messages = {
64932 approved: (0, import_i18n268.__)("Note marked as resolved."),
64933 hold: (0, import_i18n268.__)("Note reopened."),
64934 updated: (0, import_i18n268.__)("Note updated.")
64935 };
64936 try {
64937 if (status === "approved" || status === "hold") {
64938 await saveEntityRecord(
64939 "root",
64940 "comment",
64941 {
64942 id,
64943 status
64944 },
64945 {
64946 throwOnError: true
64947 }
64948 );
64949 const newCommentData = {
64950 post: getCurrentPostId2(),
64951 content: content || "",
64952 // Empty content for resolve, content for reopen.
64953 type: "note",
64954 status,
64955 parent: id,
64956 meta: {
64957 _wp_note_status: status === "approved" ? "resolved" : "reopen"
64958 }
64959 };
64960 await saveEntityRecord("root", "comment", newCommentData, {
64961 throwOnError: true
64962 });
64963 } else {
64964 const updateData = {
64965 id,
64966 content,
64967 status
64968 };
64969 await saveEntityRecord("root", "comment", updateData, {
64970 throwOnError: true
64971 });
64972 }
64973 createNotice(
64974 "snackbar",
64975 messages[messageType] ?? (0, import_i18n268.__)("Note updated."),
64976 {
64977 type: "snackbar",
64978 isDismissible: true
64979 }
64980 );
64981 reflowComments();
64982 } catch (error) {
64983 reflowComments();
64984 onError(error);
64985 }
64986 };
64987 const onDelete = async (comment) => {
64988 try {
64989 await deleteEntityRecord(
64990 "root",
64991 "comment",
64992 comment.id,
64993 void 0,
64994 {
64995 throwOnError: true
64996 }
64997 );
64998 if (!comment.parent) {
64999 const clientId = getSelectedBlockClientId2();
65000 const metadata = getBlockAttributes2(clientId)?.metadata;
65001 updateBlockAttributes2(clientId, {
65002 metadata: cleanEmptyObject4({
65003 ...metadata,
65004 noteId: void 0
65005 })
65006 });
65007 }
65008 createNotice("snackbar", (0, import_i18n268.__)("Note deleted."), {
65009 type: "snackbar",
65010 isDismissible: true
65011 });
65012 reflowComments();
65013 } catch (error) {
65014 reflowComments();
65015 onError(error);
65016 }
65017 };
65018 return { onCreate, onEdit, onDelete };
65019 }
65020 function useEnableFloatingSidebar(enabled = false) {
65021 const registry = (0, import_data238.useRegistry)();
65022 (0, import_element226.useEffect)(() => {
65023 if (!enabled) {
65024 return;
65025 }
65026 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = registry.select(store2);
65027 const { disableComplementaryArea: disableComplementaryArea2, enableComplementaryArea: enableComplementaryArea2 } = registry.dispatch(store2);
65028 const unsubscribe = registry.subscribe(() => {
65029 if (getActiveComplementaryArea2("core") === null) {
65030 enableComplementaryArea2("core", FLOATING_NOTES_SIDEBAR);
65031 }
65032 });
65033 return () => {
65034 unsubscribe();
65035 if (getActiveComplementaryArea2("core") === FLOATING_NOTES_SIDEBAR) {
65036 disableComplementaryArea2("core", FLOATING_NOTES_SIDEBAR);
65037 }
65038 };
65039 }, [enabled, registry]);
65040 }
65041 function useFloatingThread({
65042 thread,
65043 calculatedOffset,
65044 setHeights,
65045 selectedThread,
65046 setBlockRef,
65047 commentLastUpdated
65048 }) {
65049 const blockElement = useBlockElement(thread.blockClientId);
65050 const updateHeight = (0, import_element226.useCallback)(
65051 (id, newHeight) => {
65052 setHeights((prev) => {
65053 if (prev[id] !== newHeight) {
65054 return { ...prev, [id]: newHeight };
65055 }
65056 return prev;
65057 });
65058 },
65059 [setHeights]
65060 );
65061 const { y: y3, refs } = useFloating({
65062 placement: "right-start",
65063 middleware: [
65064 offset2({
65065 crossAxis: calculatedOffset || -16
65066 })
65067 ],
65068 whileElementsMounted: autoUpdate
65069 });
65070 (0, import_element226.useEffect)(() => {
65071 if (blockElement) {
65072 refs.setReference(blockElement);
65073 }
65074 }, [blockElement, refs, commentLastUpdated]);
65075 (0, import_element226.useEffect)(() => {
65076 if (refs.floating?.current) {
65077 setBlockRef(thread.id, blockElement);
65078 }
65079 }, [blockElement, thread.id, refs.floating, setBlockRef]);
65080 (0, import_element226.useEffect)(() => {
65081 if (refs.floating?.current) {
65082 const newHeight = refs.floating.current.scrollHeight;
65083 updateHeight(thread.id, newHeight);
65084 }
65085 }, [
65086 thread.id,
65087 updateHeight,
65088 refs.floating,
65089 selectedThread,
65090 commentLastUpdated
65091 ]);
65092 return {
65093 y: y3,
65094 refs
65095 };
65096 }
65097
65098 // packages/editor/build-module/components/collab-sidebar/add-comment.mjs
65099 var import_i18n269 = __toESM(require_i18n(), 1);
65100 var import_data239 = __toESM(require_data(), 1);
65101 var import_components247 = __toESM(require_components(), 1);
65102 var import_block_editor96 = __toESM(require_block_editor(), 1);
65103 var import_jsx_runtime415 = __toESM(require_jsx_runtime(), 1);
65104 var { useBlockElement: useBlockElement2 } = unlock(import_block_editor96.privateApis);
65105 function AddComment({
65106 onSubmit,
65107 commentSidebarRef,
65108 reflowComments = noop7,
65109 isFloating = false,
65110 y: y3,
65111 refs
65112 }) {
65113 const { clientId } = (0, import_data239.useSelect)((select6) => {
65114 const { getSelectedBlockClientId: getSelectedBlockClientId2 } = select6(import_block_editor96.store);
65115 return {
65116 clientId: getSelectedBlockClientId2()
65117 };
65118 }, []);
65119 const selectedNote2 = (0, import_data239.useSelect)(
65120 (select6) => unlock(select6(store)).getSelectedNote(),
65121 []
65122 );
65123 const blockElement = useBlockElement2(clientId);
65124 const { toggleBlockSpotlight } = unlock((0, import_data239.useDispatch)(import_block_editor96.store));
65125 const { selectNote: selectNote2 } = unlock((0, import_data239.useDispatch)(store));
65126 const unselectThread = () => {
65127 selectNote2(void 0);
65128 blockElement?.focus();
65129 toggleBlockSpotlight(clientId, false);
65130 };
65131 if (selectedNote2 !== "new" || !clientId) {
65132 return null;
65133 }
65134 return /* @__PURE__ */ (0, import_jsx_runtime415.jsxs)(
65135 import_components247.__experimentalVStack,
65136 {
65137 className: clsx_default(
65138 "editor-collab-sidebar-panel__thread is-selected",
65139 {
65140 "is-floating": isFloating
65141 }
65142 ),
65143 spacing: "3",
65144 tabIndex: 0,
65145 "aria-label": (0, import_i18n269.__)("New note"),
65146 role: "treeitem",
65147 ref: isFloating ? refs.setFloating : void 0,
65148 style: isFloating ? (
65149 // Delay showing the floating note box until a Y position is known to prevent blink.
65150 { top: y3, opacity: !y3 ? 0 : void 0 }
65151 ) : void 0,
65152 onBlur: (event) => {
65153 if (event.currentTarget.contains(event.relatedTarget)) {
65154 return;
65155 }
65156 toggleBlockSpotlight(clientId, false);
65157 selectNote2(void 0);
65158 },
65159 children: [
65160 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(import_components247.__experimentalHStack, { alignment: "left", spacing: "3", children: /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(comment_author_info_default, {}) }),
65161 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(
65162 comment_form_default,
65163 {
65164 onSubmit: async (inputComment) => {
65165 const { id } = await onSubmit({ content: inputComment });
65166 selectNote2(id);
65167 focusCommentThread(id, commentSidebarRef.current);
65168 },
65169 onCancel: unselectThread,
65170 reflowComments,
65171 submitButtonText: (0, import_i18n269.__)("Add note"),
65172 labelText: (0, import_i18n269.__)("New note")
65173 }
65174 )
65175 ]
65176 }
65177 );
65178 }
65179
65180 // packages/editor/build-module/components/collab-sidebar/comments.mjs
65181 var import_jsx_runtime416 = __toESM(require_jsx_runtime(), 1);
65182 var { useBlockElement: useBlockElement3 } = unlock(import_block_editor97.privateApis);
65183 var { Menu: Menu6 } = unlock(import_components248.privateApis);
65184 function Comments({
65185 threads: noteThreads,
65186 onEditComment,
65187 onAddReply,
65188 onCommentDelete,
65189 commentSidebarRef,
65190 reflowComments,
65191 isFloating = false,
65192 commentLastUpdated
65193 }) {
65194 const [heights, setHeights] = (0, import_element227.useState)({});
65195 const [boardOffsets, setBoardOffsets] = (0, import_element227.useState)({});
65196 const [blockRefs, setBlockRefs] = (0, import_element227.useState)({});
65197 const { setCanvasMinHeight: setCanvasMinHeight2, selectNote: selectNote2 } = unlock(
65198 (0, import_data240.useDispatch)(store)
65199 );
65200 const { selectBlock: selectBlock2, toggleBlockSpotlight } = unlock(
65201 (0, import_data240.useDispatch)(import_block_editor97.store)
65202 );
65203 const { blockCommentId, selectedBlockClientId, orderedBlockIds } = (0, import_data240.useSelect)((select6) => {
65204 const {
65205 getBlockAttributes: getBlockAttributes2,
65206 getSelectedBlockClientId: getSelectedBlockClientId2,
65207 getClientIdsWithDescendants: getClientIdsWithDescendants2
65208 } = select6(import_block_editor97.store);
65209 const clientId = getSelectedBlockClientId2();
65210 return {
65211 blockCommentId: clientId ? getBlockAttributes2(clientId)?.metadata?.noteId : null,
65212 selectedBlockClientId: clientId,
65213 orderedBlockIds: getClientIdsWithDescendants2()
65214 };
65215 }, []);
65216 const { selectedNote: selectedNote2, noteFocused } = (0, import_data240.useSelect)((select6) => {
65217 const { getSelectedNote: getSelectedNote2, isNoteFocused: isNoteFocused2 } = unlock(
65218 select6(store)
65219 );
65220 return {
65221 selectedNote: getSelectedNote2(),
65222 noteFocused: isNoteFocused2()
65223 };
65224 }, []);
65225 const relatedBlockElement = useBlockElement3(selectedBlockClientId);
65226 const threads = (0, import_element227.useMemo)(() => {
65227 const t4 = [...noteThreads];
65228 const orderedThreads = [];
65229 if (isFloating && selectedNote2 === "new") {
65230 const newNoteThread = {
65231 id: "new",
65232 blockClientId: selectedBlockClientId,
65233 content: { rendered: "" }
65234 };
65235 orderedBlockIds.forEach((blockId) => {
65236 if (blockId === selectedBlockClientId) {
65237 orderedThreads.push(newNoteThread);
65238 } else {
65239 const threadForBlock = t4.find(
65240 (thread) => thread.blockClientId === blockId
65241 );
65242 if (threadForBlock) {
65243 orderedThreads.push(threadForBlock);
65244 }
65245 }
65246 });
65247 return orderedThreads;
65248 }
65249 return t4;
65250 }, [
65251 noteThreads,
65252 isFloating,
65253 selectedNote2,
65254 selectedBlockClientId,
65255 orderedBlockIds
65256 ]);
65257 const handleDelete = async (comment) => {
65258 const currentIndex = threads.findIndex((t4) => t4.id === comment.id);
65259 const nextThread = threads[currentIndex + 1];
65260 const prevThread = threads[currentIndex - 1];
65261 await onCommentDelete(comment);
65262 if (comment.parent !== 0) {
65263 selectNote2(comment.parent);
65264 focusCommentThread(comment.parent, commentSidebarRef.current);
65265 return;
65266 }
65267 if (nextThread) {
65268 selectNote2(nextThread.id);
65269 focusCommentThread(nextThread.id, commentSidebarRef.current);
65270 } else if (prevThread) {
65271 selectNote2(prevThread.id);
65272 focusCommentThread(prevThread.id, commentSidebarRef.current);
65273 } else {
65274 selectNote2(void 0);
65275 toggleBlockSpotlight(comment.blockClientId, false);
65276 relatedBlockElement?.focus();
65277 }
65278 };
65279 (0, import_element227.useEffect)(() => {
65280 selectNote2(blockCommentId ?? void 0);
65281 }, [blockCommentId, selectNote2]);
65282 (0, import_element227.useEffect)(() => {
65283 if (noteFocused && selectedNote2) {
65284 focusCommentThread(
65285 selectedNote2,
65286 commentSidebarRef.current,
65287 selectedNote2 === "new" ? "textarea" : void 0
65288 );
65289 selectNote2(selectedNote2);
65290 }
65291 }, [noteFocused, selectedNote2, selectNote2, commentSidebarRef]);
65292 (0, import_element227.useEffect)(() => {
65293 const calculateAllOffsets = () => {
65294 const offsets = {};
65295 if (!isFloating) {
65296 return { offsets, minHeight: 0 };
65297 }
65298 const selectedThreadIndex = threads.findIndex(
65299 (t4) => t4.id === selectedNote2
65300 );
65301 const breakIndex = selectedThreadIndex === -1 ? 0 : selectedThreadIndex;
65302 const selectedThreadData = threads[breakIndex];
65303 if (!selectedThreadData || !blockRefs[selectedThreadData.id]) {
65304 return { offsets, minHeight: 0 };
65305 }
65306 let blockElement = blockRefs[selectedThreadData.id];
65307 let blockRect = blockElement?.getBoundingClientRect();
65308 const selectedThreadTop = blockRect?.top || 0;
65309 const selectedThreadHeight = heights[selectedThreadData.id] || 0;
65310 offsets[selectedThreadData.id] = -16;
65311 let previousThreadData = {
65312 threadTop: selectedThreadTop - 16,
65313 threadHeight: selectedThreadHeight
65314 };
65315 for (let i3 = breakIndex + 1; i3 < threads.length; i3++) {
65316 const thread = threads[i3];
65317 if (!blockRefs[thread.id]) {
65318 continue;
65319 }
65320 blockElement = blockRefs[thread.id];
65321 blockRect = blockElement?.getBoundingClientRect();
65322 const threadTop = blockRect?.top || 0;
65323 const threadHeight = heights[thread.id] || 0;
65324 let additionalOffset = -16;
65325 const previousBottom = previousThreadData.threadTop + previousThreadData.threadHeight;
65326 if (threadTop < previousBottom + 16) {
65327 additionalOffset = previousBottom - threadTop + 20;
65328 }
65329 offsets[thread.id] = additionalOffset;
65330 previousThreadData = {
65331 threadTop: threadTop + additionalOffset,
65332 threadHeight
65333 };
65334 }
65335 let nextThreadData = {
65336 threadTop: selectedThreadTop - 16
65337 };
65338 for (let i3 = selectedThreadIndex - 1; i3 >= 0; i3--) {
65339 const thread = threads[i3];
65340 if (!blockRefs[thread.id]) {
65341 continue;
65342 }
65343 blockElement = blockRefs[thread.id];
65344 blockRect = blockElement?.getBoundingClientRect();
65345 const threadTop = blockRect?.top || 0;
65346 const threadHeight = heights[thread.id] || 0;
65347 let additionalOffset = -16;
65348 const threadBottom = threadTop + threadHeight;
65349 if (threadBottom > nextThreadData.threadTop) {
65350 additionalOffset = nextThreadData.threadTop - threadTop - threadHeight - 20;
65351 }
65352 offsets[thread.id] = additionalOffset;
65353 nextThreadData = {
65354 threadTop: threadTop + additionalOffset
65355 };
65356 }
65357 let editorMinHeight = 0;
65358 const lastThread = threads[threads.length - 1];
65359 if (blockRefs[lastThread.id]) {
65360 const lastBlockElement = blockRefs[lastThread.id];
65361 const lastBlockRect = lastBlockElement?.getBoundingClientRect();
65362 const lastThreadTop = lastBlockRect?.top || 0;
65363 const lastThreadHeight = heights[lastThread.id] || 0;
65364 const lastThreadOffset = offsets[lastThread.id] || 0;
65365 editorMinHeight = lastThreadTop + lastThreadHeight + lastThreadOffset + 32;
65366 }
65367 return { offsets, minHeight: editorMinHeight };
65368 };
65369 const { offsets: newOffsets, minHeight } = calculateAllOffsets();
65370 if (Object.keys(newOffsets).length > 0) {
65371 setBoardOffsets(newOffsets);
65372 }
65373 setCanvasMinHeight2(minHeight);
65374 }, [
65375 heights,
65376 blockRefs,
65377 isFloating,
65378 threads,
65379 selectedNote2,
65380 setCanvasMinHeight2
65381 ]);
65382 const handleThreadNavigation = (event, thread, isSelected) => {
65383 if (event.defaultPrevented) {
65384 return;
65385 }
65386 const currentIndex = threads.findIndex((t4) => t4.id === thread.id);
65387 if ((event.key === "Enter" || event.key === "ArrowRight") && event.currentTarget === event.target && !isSelected) {
65388 selectNote2(thread.id);
65389 if (!!thread.blockClientId) {
65390 selectBlock2(thread.blockClientId, null);
65391 toggleBlockSpotlight(thread.blockClientId, true);
65392 }
65393 } else if ((event.key === "Enter" || event.key === "ArrowLeft") && event.currentTarget === event.target && isSelected || event.key === "Escape") {
65394 selectNote2(void 0);
65395 if (thread.blockClientId) {
65396 toggleBlockSpotlight(thread.blockClientId, false);
65397 }
65398 focusCommentThread(thread.id, commentSidebarRef.current);
65399 } else if (event.key === "ArrowDown" && currentIndex < threads.length - 1 && event.currentTarget === event.target) {
65400 const nextThread = threads[currentIndex + 1];
65401 focusCommentThread(nextThread.id, commentSidebarRef.current);
65402 } else if (event.key === "ArrowUp" && currentIndex > 0 && event.currentTarget === event.target) {
65403 const prevThread = threads[currentIndex - 1];
65404 focusCommentThread(prevThread.id, commentSidebarRef.current);
65405 } else if (event.key === "Home" && event.currentTarget === event.target) {
65406 focusCommentThread(threads[0].id, commentSidebarRef.current);
65407 } else if (event.key === "End" && event.currentTarget === event.target) {
65408 focusCommentThread(
65409 threads[threads.length - 1].id,
65410 commentSidebarRef.current
65411 );
65412 }
65413 };
65414 const setBlockRef = (0, import_element227.useCallback)((id, blockRef) => {
65415 setBlockRefs((prev) => ({ ...prev, [id]: blockRef }));
65416 }, []);
65417 const hasThreads = Array.isArray(threads) && threads.length > 0;
65418 if (!hasThreads && !isFloating) {
65419 return /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65420 AddComment,
65421 {
65422 onSubmit: onAddReply,
65423 commentSidebarRef
65424 }
65425 );
65426 }
65427 return /* @__PURE__ */ (0, import_jsx_runtime416.jsxs)(import_jsx_runtime416.Fragment, { children: [
65428 !isFloating && selectedNote2 === "new" && /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65429 AddComment,
65430 {
65431 onSubmit: onAddReply,
65432 commentSidebarRef
65433 }
65434 ),
65435 threads.map((thread) => /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65436 Thread,
65437 {
65438 thread,
65439 onAddReply,
65440 onCommentDelete: handleDelete,
65441 onEditComment,
65442 isSelected: selectedNote2 === thread.id,
65443 commentSidebarRef,
65444 reflowComments,
65445 isFloating,
65446 calculatedOffset: boardOffsets[thread.id] ?? 0,
65447 setHeights,
65448 setBlockRef,
65449 commentLastUpdated,
65450 onKeyDown: (event) => handleThreadNavigation(
65451 event,
65452 thread,
65453 selectedNote2 === thread.id
65454 )
65455 },
65456 thread.id
65457 ))
65458 ] });
65459 }
65460 function Thread({
65461 thread,
65462 onEditComment,
65463 onAddReply,
65464 onCommentDelete,
65465 isSelected,
65466 commentSidebarRef,
65467 reflowComments,
65468 isFloating,
65469 calculatedOffset,
65470 setHeights,
65471 setBlockRef,
65472 commentLastUpdated,
65473 onKeyDown
65474 }) {
65475 const { toggleBlockHighlight, selectBlock: selectBlock2, toggleBlockSpotlight } = unlock(
65476 (0, import_data240.useDispatch)(import_block_editor97.store)
65477 );
65478 const { selectNote: selectNote2 } = unlock((0, import_data240.useDispatch)(store));
65479 const selectedNote2 = (0, import_data240.useSelect)(
65480 (select6) => unlock(select6(store)).getSelectedNote(),
65481 []
65482 );
65483 const relatedBlockElement = useBlockElement3(thread.blockClientId);
65484 const debouncedToggleBlockHighlight = (0, import_compose68.useDebounce)(
65485 toggleBlockHighlight,
65486 50
65487 );
65488 const { y: y3, refs } = useFloatingThread({
65489 thread,
65490 calculatedOffset,
65491 setHeights,
65492 setBlockRef,
65493 selectedThread: selectedNote2,
65494 commentLastUpdated
65495 });
65496 const isKeyboardTabbingRef = (0, import_element227.useRef)(false);
65497 const onMouseEnter = () => {
65498 debouncedToggleBlockHighlight(thread.blockClientId, true);
65499 };
65500 const onMouseLeave = () => {
65501 debouncedToggleBlockHighlight(thread.blockClientId, false);
65502 };
65503 const onFocus = () => {
65504 toggleBlockHighlight(thread.blockClientId, true);
65505 };
65506 const onBlur = (event) => {
65507 const isNoteFocused2 = event.relatedTarget?.closest(
65508 ".editor-collab-sidebar-panel__thread"
65509 );
65510 const isDialogFocused = event.relatedTarget?.closest('[role="dialog"]');
65511 const isTabbing = isKeyboardTabbingRef.current;
65512 if (isNoteFocused2 && !isTabbing) {
65513 return;
65514 }
65515 if (isDialogFocused) {
65516 return;
65517 }
65518 if (isTabbing && event.currentTarget.contains(event.relatedTarget)) {
65519 return;
65520 }
65521 toggleBlockHighlight(thread.blockClientId, false);
65522 unselectThread();
65523 };
65524 const handleCommentSelect = () => {
65525 selectNote2(thread.id);
65526 toggleBlockSpotlight(thread.blockClientId, true);
65527 if (!!thread.blockClientId) {
65528 selectBlock2(thread.blockClientId, null);
65529 }
65530 };
65531 const unselectThread = () => {
65532 selectNote2(void 0);
65533 toggleBlockSpotlight(thread.blockClientId, false);
65534 };
65535 const allReplies = thread?.reply || [];
65536 const lastReply = allReplies.length > 0 ? allReplies[allReplies.length - 1] : void 0;
65537 const restReplies = allReplies.length > 0 ? allReplies.slice(0, -1) : [];
65538 const commentExcerpt = getCommentExcerpt(
65539 (0, import_dom8.__unstableStripHTML)(thread.content?.rendered),
65540 10
65541 );
65542 const ariaLabel = !!thread.blockClientId ? (0, import_i18n270.sprintf)(
65543 // translators: %s: note excerpt
65544 (0, import_i18n270.__)("Note: %s"),
65545 commentExcerpt
65546 ) : (0, import_i18n270.sprintf)(
65547 // translators: %s: note excerpt
65548 (0, import_i18n270.__)("Original block deleted. Note: %s"),
65549 commentExcerpt
65550 );
65551 if (isFloating && thread.id === "new") {
65552 return /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65553 AddComment,
65554 {
65555 onSubmit: onAddReply,
65556 commentSidebarRef,
65557 reflowComments,
65558 isFloating,
65559 y: y3,
65560 refs
65561 }
65562 );
65563 }
65564 return /* @__PURE__ */ (0, import_jsx_runtime416.jsxs)(
65565 import_components248.__experimentalVStack,
65566 {
65567 className: clsx_default("editor-collab-sidebar-panel__thread", {
65568 "is-selected": isSelected,
65569 "is-floating": isFloating
65570 }),
65571 id: `comment-thread-${thread.id}`,
65572 spacing: "3",
65573 onClick: handleCommentSelect,
65574 onMouseEnter,
65575 onMouseLeave,
65576 onFocus,
65577 onBlur,
65578 onKeyUp: (event) => {
65579 if (event.key === "Tab") {
65580 isKeyboardTabbingRef.current = false;
65581 }
65582 },
65583 onKeyDown: (event) => {
65584 if (event.key === "Tab") {
65585 isKeyboardTabbingRef.current = true;
65586 } else {
65587 onKeyDown(event);
65588 }
65589 },
65590 tabIndex: 0,
65591 role: "treeitem",
65592 "aria-label": ariaLabel,
65593 "aria-expanded": isSelected,
65594 ref: isFloating ? refs.setFloating : void 0,
65595 style: isFloating ? { top: y3 } : void 0,
65596 children: [
65597 /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65598 import_components248.Button,
65599 {
65600 className: "editor-collab-sidebar-panel__skip-to-comment",
65601 variant: "secondary",
65602 size: "compact",
65603 onClick: () => {
65604 focusCommentThread(
65605 thread.id,
65606 commentSidebarRef.current,
65607 "textarea"
65608 );
65609 },
65610 children: (0, import_i18n270.__)("Add new reply")
65611 }
65612 ),
65613 !thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(import_components248.__experimentalText, { as: "p", weight: 500, variant: "muted", children: (0, import_i18n270.__)("Original block deleted.") }),
65614 /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65615 CommentBoard,
65616 {
65617 thread,
65618 isExpanded: isSelected,
65619 onEdit: (params = {}) => {
65620 onEditComment(params);
65621 if (params.status === "approved") {
65622 unselectThread();
65623 if (isFloating) {
65624 relatedBlockElement?.focus();
65625 } else {
65626 focusCommentThread(
65627 thread.id,
65628 commentSidebarRef.current
65629 );
65630 }
65631 }
65632 },
65633 onDelete: onCommentDelete,
65634 reflowComments
65635 }
65636 ),
65637 isSelected && allReplies.map((reply) => /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65638 CommentBoard,
65639 {
65640 thread: reply,
65641 parent: thread,
65642 isExpanded: isSelected,
65643 onEdit: onEditComment,
65644 onDelete: onCommentDelete,
65645 reflowComments
65646 },
65647 reply.id
65648 )),
65649 !isSelected && restReplies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(import_components248.__experimentalHStack, { className: "editor-collab-sidebar-panel__more-reply-separator", children: /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65650 import_components248.Button,
65651 {
65652 size: "compact",
65653 variant: "tertiary",
65654 className: "editor-collab-sidebar-panel__more-reply-button",
65655 onClick: () => {
65656 selectNote2(thread.id);
65657 focusCommentThread(
65658 thread.id,
65659 commentSidebarRef.current
65660 );
65661 },
65662 children: (0, import_i18n270.sprintf)(
65663 // translators: %s: number of replies.
65664 (0, import_i18n270._n)(
65665 "%s more reply",
65666 "%s more replies",
65667 restReplies.length
65668 ),
65669 restReplies.length
65670 )
65671 }
65672 ) }),
65673 !isSelected && lastReply && /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65674 CommentBoard,
65675 {
65676 thread: lastReply,
65677 parent: thread,
65678 isExpanded: isSelected,
65679 onEdit: onEditComment,
65680 onDelete: onCommentDelete,
65681 reflowComments
65682 }
65683 ),
65684 isSelected && /* @__PURE__ */ (0, import_jsx_runtime416.jsxs)(import_components248.__experimentalVStack, { spacing: "2", role: "treeitem", children: [
65685 /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(import_components248.__experimentalHStack, { alignment: "left", spacing: "3", justify: "flex-start", children: /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(comment_author_info_default, {}) }),
65686 /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(import_components248.__experimentalVStack, { spacing: "2", children: /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65687 comment_form_default,
65688 {
65689 onSubmit: (inputComment) => {
65690 if ("approved" === thread.status) {
65691 onEditComment({
65692 id: thread.id,
65693 status: "hold",
65694 content: inputComment
65695 });
65696 } else {
65697 onAddReply({
65698 content: inputComment,
65699 parent: thread.id
65700 });
65701 }
65702 },
65703 onCancel: (event) => {
65704 event.stopPropagation();
65705 unselectThread();
65706 focusCommentThread(
65707 thread.id,
65708 commentSidebarRef.current
65709 );
65710 },
65711 submitButtonText: "approved" === thread.status ? (0, import_i18n270.__)("Reopen & Reply") : (0, import_i18n270.__)("Reply"),
65712 rows: "approved" === thread.status ? 2 : 4,
65713 labelText: (0, import_i18n270.sprintf)(
65714 // translators: %1$s: note identifier, %2$s: author name
65715 (0, import_i18n270.__)("Reply to note %1$s by %2$s"),
65716 thread.id,
65717 thread.author_name
65718 ),
65719 reflowComments
65720 }
65721 ) })
65722 ] }),
65723 !!thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65724 import_components248.Button,
65725 {
65726 className: "editor-collab-sidebar-panel__skip-to-block",
65727 variant: "secondary",
65728 size: "compact",
65729 onClick: (event) => {
65730 event.stopPropagation();
65731 relatedBlockElement?.focus();
65732 },
65733 children: (0, import_i18n270.__)("Back to block")
65734 }
65735 )
65736 ]
65737 }
65738 );
65739 }
65740 var CommentBoard = ({
65741 thread,
65742 parent,
65743 isExpanded,
65744 onEdit,
65745 onDelete,
65746 reflowComments
65747 }) => {
65748 const [actionState, setActionState] = (0, import_element227.useState)(false);
65749 const [showConfirmDialog, setShowConfirmDialog] = (0, import_element227.useState)(false);
65750 const actionButtonRef = (0, import_element227.useRef)(null);
65751 const handleConfirmDelete = () => {
65752 onDelete(thread);
65753 setActionState(false);
65754 setShowConfirmDialog(false);
65755 };
65756 const handleCancel = () => {
65757 setActionState(false);
65758 setShowConfirmDialog(false);
65759 actionButtonRef.current?.focus();
65760 };
65761 const isResolutionComment = thread.type === "note" && thread.meta && (thread.meta._wp_note_status === "resolved" || thread.meta._wp_note_status === "reopen");
65762 const actions2 = [
65763 {
65764 id: "edit",
65765 title: (0, import_i18n270.__)("Edit"),
65766 isEligible: ({ status }) => status !== "approved",
65767 onClick: () => {
65768 setActionState("edit");
65769 }
65770 },
65771 {
65772 id: "reopen",
65773 title: (0, import_i18n270._x)("Reopen", "Reopen note"),
65774 isEligible: ({ status }) => status === "approved",
65775 onClick: () => {
65776 onEdit({ id: thread.id, status: "hold" });
65777 }
65778 },
65779 {
65780 id: "delete",
65781 title: (0, import_i18n270.__)("Delete"),
65782 isEligible: () => true,
65783 onClick: () => {
65784 setActionState("delete");
65785 setShowConfirmDialog(true);
65786 }
65787 }
65788 ];
65789 const canResolve = thread.parent === 0;
65790 const moreActions = parent?.status !== "approved" ? actions2.filter((item) => item.isEligible(thread)) : [];
65791 const deleteConfirmMessage = (
65792 // When deleting a top level note, descendants will also be deleted.
65793 thread.parent === 0 ? (0, import_i18n270.__)(
65794 "Are you sure you want to delete this note? This will also delete all of this note's replies."
65795 ) : (0, import_i18n270.__)("Are you sure you want to delete this reply?")
65796 );
65797 return /* @__PURE__ */ (0, import_jsx_runtime416.jsxs)(
65798 import_components248.__experimentalVStack,
65799 {
65800 spacing: "2",
65801 role: thread.parent !== 0 ? "treeitem" : void 0,
65802 children: [
65803 /* @__PURE__ */ (0, import_jsx_runtime416.jsxs)(import_components248.__experimentalHStack, { alignment: "left", spacing: "3", justify: "flex-start", children: [
65804 /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65805 comment_author_info_default,
65806 {
65807 avatar: thread?.author_avatar_urls?.[48],
65808 name: thread?.author_name,
65809 date: thread?.date,
65810 userId: thread?.author
65811 }
65812 ),
65813 isExpanded && /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65814 import_components248.FlexItem,
65815 {
65816 className: "editor-collab-sidebar-panel__comment-status",
65817 onClick: (event) => {
65818 event.stopPropagation();
65819 },
65820 children: /* @__PURE__ */ (0, import_jsx_runtime416.jsxs)(import_components248.__experimentalHStack, { spacing: "0", children: [
65821 canResolve && /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65822 import_components248.Button,
65823 {
65824 label: (0, import_i18n270._x)(
65825 "Resolve",
65826 "Mark note as resolved"
65827 ),
65828 size: "small",
65829 icon: published_default,
65830 disabled: thread.status === "approved",
65831 accessibleWhenDisabled: thread.status === "approved",
65832 onClick: () => {
65833 onEdit({
65834 id: thread.id,
65835 status: "approved"
65836 });
65837 }
65838 }
65839 ),
65840 /* @__PURE__ */ (0, import_jsx_runtime416.jsxs)(Menu6, { placement: "bottom-end", children: [
65841 /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65842 Menu6.TriggerButton,
65843 {
65844 render: /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65845 import_components248.Button,
65846 {
65847 ref: actionButtonRef,
65848 size: "small",
65849 icon: more_vertical_default,
65850 label: (0, import_i18n270.__)("Actions"),
65851 disabled: !moreActions.length,
65852 accessibleWhenDisabled: true
65853 }
65854 )
65855 }
65856 ),
65857 /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65858 Menu6.Popover,
65859 {
65860 modal: false,
65861 children: moreActions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65862 Menu6.Item,
65863 {
65864 onClick: () => action.onClick(),
65865 children: /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(Menu6.ItemLabel, { children: action.title })
65866 },
65867 action.id
65868 ))
65869 }
65870 )
65871 ] })
65872 ] })
65873 }
65874 )
65875 ] }),
65876 "edit" === actionState ? /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65877 comment_form_default,
65878 {
65879 onSubmit: (value) => {
65880 onEdit({
65881 id: thread.id,
65882 content: value
65883 });
65884 setActionState(false);
65885 actionButtonRef.current?.focus();
65886 },
65887 onCancel: () => handleCancel(),
65888 thread,
65889 submitButtonText: (0, import_i18n270._x)("Update", "verb"),
65890 labelText: (0, import_i18n270.sprintf)(
65891 // translators: %1$s: note identifier, %2$s: author name.
65892 (0, import_i18n270.__)("Edit note %1$s by %2$s"),
65893 thread.id,
65894 thread.author_name
65895 ),
65896 reflowComments
65897 }
65898 ) : /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65899 import_element227.RawHTML,
65900 {
65901 className: clsx_default(
65902 "editor-collab-sidebar-panel__user-comment",
65903 {
65904 "editor-collab-sidebar-panel__resolution-text": isResolutionComment
65905 }
65906 ),
65907 children: isResolutionComment ? (() => {
65908 const actionText = thread.meta._wp_note_status === "resolved" ? (0, import_i18n270.__)("Marked as resolved") : (0, import_i18n270.__)("Reopened");
65909 const content = thread?.content?.raw;
65910 if (content && typeof content === "string" && content.trim() !== "") {
65911 return (0, import_i18n270.sprintf)(
65912 // translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text.
65913 (0, import_i18n270.__)("%1$s: %2$s"),
65914 actionText,
65915 content
65916 );
65917 }
65918 return actionText;
65919 })() : thread?.content?.rendered
65920 }
65921 ),
65922 "delete" === actionState && /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(
65923 import_components248.__experimentalConfirmDialog,
65924 {
65925 isOpen: showConfirmDialog,
65926 onConfirm: handleConfirmDelete,
65927 onCancel: handleCancel,
65928 confirmButtonText: (0, import_i18n270.__)("Delete"),
65929 children: deleteConfirmMessage
65930 }
65931 )
65932 ]
65933 }
65934 );
65935 };
65936
65937 // packages/editor/build-module/components/collab-sidebar/comment-menu-item.mjs
65938 var import_components249 = __toESM(require_components(), 1);
65939 var import_i18n271 = __toESM(require_i18n(), 1);
65940 var import_block_editor98 = __toESM(require_block_editor(), 1);
65941 var import_data241 = __toESM(require_data(), 1);
65942 var import_blocks38 = __toESM(require_blocks(), 1);
65943 var import_keyboard_shortcuts11 = __toESM(require_keyboard_shortcuts(), 1);
65944 var import_jsx_runtime417 = __toESM(require_jsx_runtime(), 1);
65945 var { CommentIconSlotFill } = unlock(import_block_editor98.privateApis);
65946 var AddCommentMenuItem = ({ clientId, onClick, isDistractionFree }) => {
65947 const block = (0, import_data241.useSelect)(
65948 (select6) => {
65949 return select6(import_block_editor98.store).getBlock(clientId);
65950 },
65951 [clientId]
65952 );
65953 const shortcut = (0, import_data241.useSelect)(
65954 (select6) => select6(import_keyboard_shortcuts11.store).getShortcutRepresentation(
65955 "core/editor/new-note"
65956 ),
65957 []
65958 );
65959 if (!block?.isValid || block?.name === (0, import_blocks38.getUnregisteredTypeHandlerName)()) {
65960 return null;
65961 }
65962 const isDisabled = isDistractionFree || block?.name === "core/freeform";
65963 let infoText;
65964 if (isDistractionFree) {
65965 infoText = (0, import_i18n271.__)("Notes are disabled in distraction free mode.");
65966 } else if (block?.name === "core/freeform") {
65967 infoText = (0, import_i18n271.__)("Convert to blocks to add notes.");
65968 }
65969 return /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(
65970 import_components249.MenuItem,
65971 {
65972 onClick,
65973 "aria-haspopup": "dialog",
65974 disabled: isDisabled,
65975 info: infoText,
65976 shortcut,
65977 children: (0, import_i18n271.__)("Add note")
65978 }
65979 );
65980 };
65981 var AddCommentMenuItemFill = ({ onClick, isDistractionFree }) => {
65982 return /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(CommentIconSlotFill.Fill, { children: ({ clientId, onClose }) => /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(
65983 AddCommentMenuItem,
65984 {
65985 clientId,
65986 isDistractionFree,
65987 onClick: () => {
65988 onClick(clientId);
65989 onClose();
65990 }
65991 }
65992 ) });
65993 };
65994 var comment_menu_item_default = AddCommentMenuItemFill;
65995
65996 // packages/editor/build-module/components/collab-sidebar/comment-indicator-toolbar.mjs
65997 var import_components250 = __toESM(require_components(), 1);
65998 var import_i18n272 = __toESM(require_i18n(), 1);
65999 var import_element228 = __toESM(require_element(), 1);
66000 var import_block_editor99 = __toESM(require_block_editor(), 1);
66001 var import_jsx_runtime418 = __toESM(require_jsx_runtime(), 1);
66002 var { CommentIconToolbarSlotFill } = unlock(import_block_editor99.privateApis);
66003 var CommentAvatarIndicator = ({ onClick, thread }) => {
66004 const threadParticipants = (0, import_element228.useMemo)(() => {
66005 if (!thread) {
66006 return [];
66007 }
66008 const participantsMap = /* @__PURE__ */ new Map();
66009 const allComments = [thread, ...thread.reply];
66010 allComments.sort((a3, b3) => new Date(a3.date) - new Date(b3.date));
66011 allComments.forEach((comment) => {
66012 if (comment.author_name && comment.author_avatar_urls) {
66013 if (!participantsMap.has(comment.author)) {
66014 participantsMap.set(comment.author, {
66015 name: comment.author_name,
66016 avatar: comment.author_avatar_urls?.["48"] || comment.author_avatar_urls?.["96"],
66017 id: comment.author,
66018 date: comment.date
66019 });
66020 }
66021 }
66022 });
66023 return Array.from(participantsMap.values());
66024 }, [thread]);
66025 if (!threadParticipants.length) {
66026 return null;
66027 }
66028 const maxAvatars = 3;
66029 const isOverflow = threadParticipants.length > maxAvatars;
66030 const visibleParticipants = isOverflow ? threadParticipants.slice(0, maxAvatars - 1) : threadParticipants;
66031 const overflowCount = Math.max(
66032 0,
66033 threadParticipants.length - visibleParticipants.length
66034 );
66035 const threadHasMoreParticipants = threadParticipants.length > 100;
66036 const overflowText = threadHasMoreParticipants && overflowCount > 0 ? (0, import_i18n272.__)("100+") : (0, import_i18n272.sprintf)(
66037 // translators: %s: Number of participants.
66038 (0, import_i18n272.__)("+%s"),
66039 overflowCount
66040 );
66041 return /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(CommentIconToolbarSlotFill.Fill, { children: /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(
66042 import_components250.ToolbarButton,
66043 {
66044 className: "comment-avatar-indicator",
66045 label: (0, import_i18n272.__)("View notes"),
66046 onClick: () => onClick(),
66047 showTooltip: true,
66048 children: /* @__PURE__ */ (0, import_jsx_runtime418.jsxs)(import_components250.__experimentalHStack, { spacing: "1", children: [
66049 visibleParticipants.map((participant) => /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(
66050 "img",
66051 {
66052 src: participant.avatar,
66053 alt: participant.name,
66054 className: "comment-avatar",
66055 style: {
66056 borderColor: getAvatarBorderColor(
66057 participant.id
66058 )
66059 }
66060 },
66061 participant.id
66062 )),
66063 overflowCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(import_components250.__experimentalText, { weight: 500, children: overflowText })
66064 ] })
66065 }
66066 ) });
66067 };
66068 var comment_indicator_toolbar_default = CommentAvatarIndicator;
66069
66070 // packages/editor/build-module/components/collab-sidebar/index.mjs
66071 var import_jsx_runtime419 = __toESM(require_jsx_runtime(), 1);
66072 function NotesSidebarContent({
66073 styles,
66074 comments,
66075 commentSidebarRef,
66076 reflowComments,
66077 commentLastUpdated,
66078 isFloating = false
66079 }) {
66080 const { onCreate, onEdit, onDelete } = useBlockCommentsActions(reflowComments);
66081 return /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(
66082 import_components251.__experimentalVStack,
66083 {
66084 className: "editor-collab-sidebar-panel",
66085 style: styles,
66086 role: "tree",
66087 spacing: "3",
66088 justify: "flex-start",
66089 ref: (node) => {
66090 if (node) {
66091 commentSidebarRef.current = node;
66092 }
66093 },
66094 "aria-label": isFloating ? (0, import_i18n273.__)("Unresolved notes") : (0, import_i18n273.__)("All notes"),
66095 children: /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(
66096 Comments,
66097 {
66098 threads: comments,
66099 onEditComment: onEdit,
66100 onAddReply: onCreate,
66101 onCommentDelete: onDelete,
66102 commentSidebarRef,
66103 reflowComments,
66104 commentLastUpdated,
66105 isFloating
66106 }
66107 )
66108 }
66109 );
66110 }
66111 function NotesSidebar({ postId: postId2 }) {
66112 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = (0, import_data242.useSelect)(store2);
66113 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data242.useDispatch)(store2);
66114 const { toggleBlockSpotlight, selectBlock: selectBlock2 } = unlock(
66115 (0, import_data242.useDispatch)(import_block_editor100.store)
66116 );
66117 const { selectNote: selectNote2 } = unlock((0, import_data242.useDispatch)(store));
66118 const isLargeViewport = (0, import_compose69.useViewportMatch)("medium");
66119 const commentSidebarRef = (0, import_element229.useRef)(null);
66120 const { clientId, blockCommentId, isClassicBlock } = (0, import_data242.useSelect)(
66121 (select6) => {
66122 const {
66123 getBlockAttributes: getBlockAttributes2,
66124 getSelectedBlockClientId: getSelectedBlockClientId2,
66125 getBlockName: getBlockName2
66126 } = select6(import_block_editor100.store);
66127 const _clientId = getSelectedBlockClientId2();
66128 return {
66129 clientId: _clientId,
66130 blockCommentId: _clientId ? getBlockAttributes2(_clientId)?.metadata?.noteId : null,
66131 isClassicBlock: _clientId ? getBlockName2(_clientId) === "core/freeform" : false
66132 };
66133 },
66134 []
66135 );
66136 const { isDistractionFree } = (0, import_data242.useSelect)((select6) => {
66137 const { get } = select6(import_preferences26.store);
66138 return {
66139 isDistractionFree: get("core", "distractionFree")
66140 };
66141 }, []);
66142 const selectedNote2 = (0, import_data242.useSelect)(
66143 (select6) => unlock(select6(store)).getSelectedNote(),
66144 []
66145 );
66146 const {
66147 resultComments,
66148 unresolvedSortedThreads,
66149 reflowComments,
66150 commentLastUpdated
66151 } = useBlockComments(postId2);
66152 const showFloatingSidebar = isLargeViewport;
66153 const showAllNotesSidebar = resultComments.length > 0 || !showFloatingSidebar;
66154 useEnableFloatingSidebar(
66155 showFloatingSidebar && (unresolvedSortedThreads.length > 0 || selectedNote2 !== void 0)
66156 );
66157 (0, import_keyboard_shortcuts12.useShortcut)(
66158 "core/editor/new-note",
66159 (event) => {
66160 event.preventDefault();
66161 openTheSidebar();
66162 },
66163 {
66164 // When multiple notes per block are supported. Remove note ID check.
66165 // See: https://github.com/WordPress/gutenberg/pull/75147.
66166 isDisabled: isDistractionFree || isClassicBlock || !clientId || !!blockCommentId
66167 }
66168 );
66169 const { merged: GlobalStyles } = useGlobalStylesContext();
66170 const backgroundColor = GlobalStyles?.styles?.color?.background;
66171 const currentThread = blockCommentId ? resultComments.find((thread) => thread.id === blockCommentId) : null;
66172 async function openTheSidebar(selectedClientId) {
66173 const prevArea = await getActiveComplementaryArea2("core");
66174 const activeNotesArea = SIDEBARS.find((name2) => name2 === prevArea);
66175 const targetClientId = selectedClientId && selectedClientId !== clientId ? selectedClientId : clientId;
66176 const targetNote = resultComments.find(
66177 (note) => note.blockClientId === targetClientId
66178 );
66179 if (targetNote?.status === "approved") {
66180 enableComplementaryArea2("core", ALL_NOTES_SIDEBAR);
66181 } else if (!activeNotesArea || !showAllNotesSidebar) {
66182 enableComplementaryArea2(
66183 "core",
66184 showFloatingSidebar ? FLOATING_NOTES_SIDEBAR : ALL_NOTES_SIDEBAR
66185 );
66186 }
66187 const currentArea = await getActiveComplementaryArea2("core");
66188 if (!SIDEBARS.includes(currentArea)) {
66189 return;
66190 }
66191 selectBlock2(targetClientId, null);
66192 toggleBlockSpotlight(targetClientId, true);
66193 selectNote2(targetNote ? targetNote.id : "new", { focus: true });
66194 }
66195 if (isDistractionFree) {
66196 return /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(comment_menu_item_default, { isDistractionFree: true });
66197 }
66198 return /* @__PURE__ */ (0, import_jsx_runtime419.jsxs)(import_jsx_runtime419.Fragment, { children: [
66199 !!currentThread && /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(
66200 comment_indicator_toolbar_default,
66201 {
66202 thread: currentThread,
66203 onClick: openTheSidebar
66204 }
66205 ),
66206 /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(comment_menu_item_default, { onClick: openTheSidebar }),
66207 showAllNotesSidebar && /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(
66208 PluginSidebar,
66209 {
66210 identifier: ALL_NOTES_SIDEBAR,
66211 name: ALL_NOTES_SIDEBAR,
66212 title: (0, import_i18n273.__)("All notes"),
66213 header: /* @__PURE__ */ (0, import_jsx_runtime419.jsx)("h2", { className: "interface-complementary-area-header__title", children: (0, import_i18n273.__)("All notes") }),
66214 icon: comment_default,
66215 closeLabel: (0, import_i18n273.__)("Close Notes"),
66216 children: /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(
66217 NotesSidebarContent,
66218 {
66219 comments: resultComments,
66220 commentSidebarRef
66221 }
66222 )
66223 }
66224 ),
66225 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(
66226 PluginSidebar,
66227 {
66228 isPinnable: false,
66229 header: false,
66230 identifier: FLOATING_NOTES_SIDEBAR,
66231 className: "editor-collab-sidebar",
66232 headerClassName: "editor-collab-sidebar__header",
66233 backgroundColor,
66234 children: /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(
66235 NotesSidebarContent,
66236 {
66237 comments: unresolvedSortedThreads,
66238 commentSidebarRef,
66239 reflowComments,
66240 commentLastUpdated,
66241 styles: {
66242 backgroundColor
66243 },
66244 isFloating: true
66245 }
66246 )
66247 }
66248 )
66249 ] });
66250 }
66251 function NotesSidebarContainer() {
66252 const { postId: postId2, editorMode, revisionsMode } = (0, import_data242.useSelect)((select6) => {
66253 const { getCurrentPostId: getCurrentPostId2, getEditorMode: getEditorMode2, isRevisionsMode: isRevisionsMode2 } = unlock(
66254 select6(store)
66255 );
66256 return {
66257 postId: getCurrentPostId2(),
66258 editorMode: getEditorMode2(),
66259 revisionsMode: isRevisionsMode2()
66260 };
66261 }, []);
66262 if (!postId2 || typeof postId2 !== "number") {
66263 return null;
66264 }
66265 if (editorMode === "text" || revisionsMode) {
66266 return null;
66267 }
66268 return /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(post_type_support_check_default, { supportKeys: "editor.notes", children: /* @__PURE__ */ (0, import_jsx_runtime419.jsx)(NotesSidebar, { postId: postId2 }) });
66269 }
66270
66271 // packages/editor/build-module/components/global-styles-sidebar/index.mjs
66272 var import_components254 = __toESM(require_components(), 1);
66273 var import_i18n276 = __toESM(require_i18n(), 1);
66274 var import_data245 = __toESM(require_data(), 1);
66275 var import_element230 = __toESM(require_element(), 1);
66276 var import_preferences29 = __toESM(require_preferences(), 1);
66277 var import_compose70 = __toESM(require_compose(), 1);
66278 var import_core_data135 = __toESM(require_core_data(), 1);
66279
66280 // packages/editor/build-module/components/global-styles/menu.mjs
66281 var import_components252 = __toESM(require_components(), 1);
66282 var import_data243 = __toESM(require_data(), 1);
66283 var import_i18n274 = __toESM(require_i18n(), 1);
66284 var import_preferences27 = __toESM(require_preferences(), 1);
66285 var import_core_data134 = __toESM(require_core_data(), 1);
66286 var import_jsx_runtime420 = __toESM(require_jsx_runtime(), 1);
66287 function GlobalStylesActionMenu({
66288 hideWelcomeGuide = false,
66289 onChangePath
66290 }) {
66291 const { user, setUser } = useGlobalStyles();
66292 const canReset = !!user && (Object.keys(user?.styles ?? {}).length > 0 || Object.keys(user?.settings ?? {}).length > 0);
66293 const onReset = () => {
66294 setUser({ styles: {}, settings: {} });
66295 };
66296 const { toggle } = (0, import_data243.useDispatch)(import_preferences27.store);
66297 const { canEditCSS } = (0, import_data243.useSelect)((select6) => {
66298 const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select6(import_core_data134.store);
66299 const globalStylesId = __experimentalGetCurrentGlobalStylesId();
66300 const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0;
66301 return {
66302 canEditCSS: !!globalStyles?._links?.["wp:action-edit-css"]
66303 };
66304 }, []);
66305 const loadCustomCSS = () => {
66306 onChangePath("/css");
66307 };
66308 return /* @__PURE__ */ (0, import_jsx_runtime420.jsx)(
66309 import_components252.DropdownMenu,
66310 {
66311 icon: more_vertical_default,
66312 label: (0, import_i18n274.__)("More"),
66313 toggleProps: { size: "compact" },
66314 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime420.jsxs)(import_jsx_runtime420.Fragment, { children: [
66315 /* @__PURE__ */ (0, import_jsx_runtime420.jsxs)(import_components252.MenuGroup, { children: [
66316 canEditCSS && /* @__PURE__ */ (0, import_jsx_runtime420.jsx)(import_components252.MenuItem, { onClick: loadCustomCSS, children: (0, import_i18n274.__)("Additional CSS") }),
66317 !hideWelcomeGuide && /* @__PURE__ */ (0, import_jsx_runtime420.jsx)(
66318 import_components252.MenuItem,
66319 {
66320 onClick: () => {
66321 toggle(
66322 "core/edit-site",
66323 "welcomeGuideStyles"
66324 );
66325 onClose();
66326 },
66327 children: (0, import_i18n274.__)("Welcome Guide")
66328 }
66329 )
66330 ] }),
66331 /* @__PURE__ */ (0, import_jsx_runtime420.jsx)(import_components252.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime420.jsx)(
66332 import_components252.MenuItem,
66333 {
66334 onClick: () => {
66335 onReset();
66336 onClose();
66337 },
66338 disabled: !canReset,
66339 children: (0, import_i18n274.__)("Reset styles")
66340 }
66341 ) })
66342 ] })
66343 }
66344 );
66345 }
66346
66347 // packages/editor/build-module/components/global-styles-sidebar/default-sidebar.mjs
66348 var import_jsx_runtime421 = __toESM(require_jsx_runtime(), 1);
66349 function DefaultSidebar({
66350 className,
66351 identifier,
66352 title,
66353 icon,
66354 children,
66355 closeLabel,
66356 header,
66357 headerClassName,
66358 panelClassName,
66359 isActiveByDefault
66360 }) {
66361 return /* @__PURE__ */ (0, import_jsx_runtime421.jsxs)(import_jsx_runtime421.Fragment, { children: [
66362 /* @__PURE__ */ (0, import_jsx_runtime421.jsx)(
66363 complementary_area_default,
66364 {
66365 className,
66366 scope: "core",
66367 identifier,
66368 title,
66369 icon,
66370 closeLabel,
66371 header,
66372 headerClassName,
66373 panelClassName,
66374 isActiveByDefault,
66375 children
66376 }
66377 ),
66378 /* @__PURE__ */ (0, import_jsx_runtime421.jsx)(
66379 ComplementaryAreaMoreMenuItem,
66380 {
66381 scope: "core",
66382 identifier,
66383 icon,
66384 children: title
66385 }
66386 )
66387 ] });
66388 }
66389
66390 // packages/editor/build-module/components/global-styles-sidebar/welcome-guide.mjs
66391 var import_data244 = __toESM(require_data(), 1);
66392 var import_components253 = __toESM(require_components(), 1);
66393 var import_i18n275 = __toESM(require_i18n(), 1);
66394 var import_preferences28 = __toESM(require_preferences(), 1);
66395
66396 // packages/editor/build-module/components/global-styles-sidebar/welcome-guide-image.mjs
66397 var import_jsx_runtime422 = __toESM(require_jsx_runtime(), 1);
66398 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) {
66399 return /* @__PURE__ */ (0, import_jsx_runtime422.jsxs)("picture", { className: "editor-welcome-guide__image", children: [
66400 /* @__PURE__ */ (0, import_jsx_runtime422.jsx)(
66401 "source",
66402 {
66403 srcSet: nonAnimatedSrc,
66404 media: "(prefers-reduced-motion: reduce)"
66405 }
66406 ),
66407 /* @__PURE__ */ (0, import_jsx_runtime422.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" })
66408 ] });
66409 }
66410
66411 // packages/editor/build-module/components/global-styles-sidebar/welcome-guide.mjs
66412 var import_jsx_runtime423 = __toESM(require_jsx_runtime(), 1);
66413 function WelcomeGuideStyles() {
66414 const { toggle } = (0, import_data244.useDispatch)(import_preferences28.store);
66415 const { isActive, isStylesOpen } = (0, import_data244.useSelect)((select6) => {
66416 const sidebar = select6(store2).getActiveComplementaryArea("core");
66417 return {
66418 isActive: !!select6(import_preferences28.store).get(
66419 "core/edit-site",
66420 "welcomeGuideStyles"
66421 ),
66422 isStylesOpen: sidebar === "edit-site/global-styles"
66423 };
66424 }, []);
66425 if (!isActive || !isStylesOpen) {
66426 return null;
66427 }
66428 const welcomeLabel = (0, import_i18n275.__)("Welcome to Styles");
66429 return /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
66430 import_components253.Guide,
66431 {
66432 className: "editor-welcome-guide guide-styles",
66433 contentLabel: welcomeLabel,
66434 finishButtonText: (0, import_i18n275.__)("Get started"),
66435 onFinish: () => toggle("core/edit-site", "welcomeGuideStyles"),
66436 pages: [
66437 {
66438 image: /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
66439 WelcomeGuideImage,
66440 {
66441 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.svg?1",
66442 animatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.gif?1"
66443 }
66444 ),
66445 content: /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)(import_jsx_runtime423.Fragment, { children: [
66446 /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("h1", { className: "editor-welcome-guide__heading", children: welcomeLabel }),
66447 /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("p", { className: "editor-welcome-guide__text", children: (0, import_i18n275.__)(
66448 "Tweak your site, or give it a whole new look! Get creative \u2014 how about a new color palette for your buttons, or choosing a new font? Take a look at what you can do here."
66449 ) })
66450 ] })
66451 },
66452 {
66453 image: /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
66454 WelcomeGuideImage,
66455 {
66456 nonAnimatedSrc: "https://s.w.org/images/block-editor/set-the-design.svg?1",
66457 animatedSrc: "https://s.w.org/images/block-editor/set-the-design.gif?1"
66458 }
66459 ),
66460 content: /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)(import_jsx_runtime423.Fragment, { children: [
66461 /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("h1", { className: "editor-welcome-guide__heading", children: (0, import_i18n275.__)("Set the design") }),
66462 /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("p", { className: "editor-welcome-guide__text", children: (0, import_i18n275.__)(
66463 "You can customize your site as much as you like with different colors, typography, and layouts. Or if you prefer, just leave it up to your theme to handle!"
66464 ) })
66465 ] })
66466 },
66467 {
66468 image: /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
66469 WelcomeGuideImage,
66470 {
66471 nonAnimatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.svg?1",
66472 animatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.gif?1"
66473 }
66474 ),
66475 content: /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)(import_jsx_runtime423.Fragment, { children: [
66476 /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("h1", { className: "editor-welcome-guide__heading", children: (0, import_i18n275.__)("Personalize blocks") }),
66477 /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("p", { className: "editor-welcome-guide__text", children: (0, import_i18n275.__)(
66478 "You can adjust your blocks to ensure a cohesive experience across your site \u2014 add your unique colors to a branded Button block, or adjust the Heading block to your preferred size."
66479 ) })
66480 ] })
66481 },
66482 {
66483 image: /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
66484 WelcomeGuideImage,
66485 {
66486 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
66487 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
66488 }
66489 ),
66490 content: /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)(import_jsx_runtime423.Fragment, { children: [
66491 /* @__PURE__ */ (0, import_jsx_runtime423.jsx)("h1", { className: "editor-welcome-guide__heading", children: (0, import_i18n275.__)("Learn more") }),
66492 /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)("p", { className: "editor-welcome-guide__text", children: [
66493 (0, import_i18n275.__)(
66494 "New to block themes and styling your site?"
66495 ),
66496 " ",
66497 /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(
66498 import_components253.ExternalLink,
66499 {
66500 href: (0, import_i18n275.__)(
66501 "https://wordpress.org/documentation/article/styles-overview/"
66502 ),
66503 children: (0, import_i18n275.__)(
66504 "Here\u2019s a detailed guide to learn how to make the most of it."
66505 )
66506 }
66507 )
66508 ] })
66509 ] })
66510 }
66511 ]
66512 }
66513 );
66514 }
66515
66516 // packages/editor/build-module/components/global-styles-sidebar/index.mjs
66517 var import_jsx_runtime424 = __toESM(require_jsx_runtime(), 1);
66518 function GlobalStylesSidebar() {
66519 const {
66520 shouldResetNavigation,
66521 stylesPath: stylesPath2,
66522 showStylebook: showStylebook2,
66523 showListViewByDefault,
66524 hasRevisions,
66525 activeComplementaryArea
66526 } = (0, import_data245.useSelect)((select6) => {
66527 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = select6(store2);
66528 const { getStylesPath: getStylesPath2, getShowStylebook: getShowStylebook2 } = unlock(
66529 select6(store)
66530 );
66531 const _isVisualEditorMode = "visual" === select6(store).getEditorMode();
66532 const _showListViewByDefault = select6(import_preferences29.store).get(
66533 "core",
66534 "showListViewByDefault"
66535 );
66536 const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select6(import_core_data135.store);
66537 const globalStylesId = __experimentalGetCurrentGlobalStylesId();
66538 const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0;
66539 return {
66540 stylesPath: getStylesPath2(),
66541 showStylebook: getShowStylebook2(),
66542 shouldResetNavigation: "edit-site/global-styles" !== getActiveComplementaryArea2("core") || !_isVisualEditorMode,
66543 showListViewByDefault: _showListViewByDefault,
66544 hasRevisions: !!globalStyles?._links?.["version-history"]?.[0]?.count,
66545 activeComplementaryArea: select6(store2).getActiveComplementaryArea("core")
66546 };
66547 }, []);
66548 const { setStylesPath: setStylesPath2, setShowStylebook: setShowStylebook2, resetStylesNavigation: resetStylesNavigation2 } = unlock(
66549 (0, import_data245.useDispatch)(store)
66550 );
66551 const isMobileViewport = (0, import_compose70.useViewportMatch)("medium", "<");
66552 const isRevisionsOpened = stylesPath2.startsWith("/revisions") && !showStylebook2;
66553 const isRevisionsStyleBookOpened = stylesPath2.startsWith("/revisions") && showStylebook2;
66554 const previousActiveArea = (0, import_compose70.usePrevious)(activeComplementaryArea);
66555 (0, import_element230.useEffect)(() => {
66556 if (activeComplementaryArea === "edit-site/global-styles" && previousActiveArea !== "edit-site/global-styles") {
66557 resetStylesNavigation2();
66558 }
66559 }, [activeComplementaryArea, previousActiveArea, resetStylesNavigation2]);
66560 (0, import_element230.useEffect)(() => {
66561 if (shouldResetNavigation) {
66562 resetStylesNavigation2();
66563 }
66564 }, [shouldResetNavigation, resetStylesNavigation2]);
66565 const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data245.useDispatch)(store);
66566 const toggleRevisions = () => {
66567 setIsListViewOpened2(false);
66568 if (isRevisionsOpened || isRevisionsStyleBookOpened) {
66569 setStylesPath2("/");
66570 } else {
66571 setStylesPath2("/revisions");
66572 }
66573 };
66574 const toggleStyleBook = () => {
66575 setIsListViewOpened2(showStylebook2 && showListViewByDefault);
66576 setShowStylebook2(!showStylebook2);
66577 };
66578 return /* @__PURE__ */ (0, import_jsx_runtime424.jsxs)(import_jsx_runtime424.Fragment, { children: [
66579 /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(
66580 DefaultSidebar,
66581 {
66582 className: "editor-global-styles-sidebar",
66583 identifier: "edit-site/global-styles",
66584 title: (0, import_i18n276.__)("Styles"),
66585 icon: styles_default,
66586 closeLabel: (0, import_i18n276.__)("Close Styles"),
66587 panelClassName: "editor-global-styles-sidebar__panel",
66588 header: /* @__PURE__ */ (0, import_jsx_runtime424.jsxs)(
66589 import_components254.Flex,
66590 {
66591 className: "editor-global-styles-sidebar__header",
66592 gap: 1,
66593 children: [
66594 /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(import_components254.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime424.jsx)("h2", { className: "editor-global-styles-sidebar__header-title", children: (0, import_i18n276.__)("Styles") }) }),
66595 /* @__PURE__ */ (0, import_jsx_runtime424.jsxs)(
66596 import_components254.Flex,
66597 {
66598 justify: "flex-end",
66599 gap: 1,
66600 className: "editor-global-styles-sidebar__header-actions",
66601 children: [
66602 !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(import_components254.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(
66603 import_components254.Button,
66604 {
66605 icon: seen_default,
66606 label: (0, import_i18n276.__)("Style Book"),
66607 isPressed: showStylebook2,
66608 accessibleWhenDisabled: true,
66609 disabled: shouldResetNavigation,
66610 onClick: toggleStyleBook,
66611 size: "compact"
66612 }
66613 ) }),
66614 /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(import_components254.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(
66615 import_components254.Button,
66616 {
66617 label: (0, import_i18n276.__)("Revisions"),
66618 icon: backup_default,
66619 onClick: toggleRevisions,
66620 accessibleWhenDisabled: true,
66621 disabled: !hasRevisions,
66622 isPressed: isRevisionsOpened || isRevisionsStyleBookOpened,
66623 size: "compact"
66624 }
66625 ) }),
66626 /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(
66627 GlobalStylesActionMenu,
66628 {
66629 onChangePath: setStylesPath2
66630 }
66631 )
66632 ]
66633 }
66634 )
66635 ]
66636 }
66637 ),
66638 children: /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(
66639 GlobalStylesUIWrapper,
66640 {
66641 path: stylesPath2,
66642 onPathChange: setStylesPath2
66643 }
66644 )
66645 }
66646 ),
66647 /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(WelcomeGuideStyles, {})
66648 ] });
66649 }
66650
66651 // packages/editor/build-module/components/editor/index.mjs
66652 var import_jsx_runtime425 = __toESM(require_jsx_runtime(), 1);
66653 function Editor({
66654 postType: postType2,
66655 postId: postId2,
66656 templateId: templateId2,
66657 settings,
66658 children,
66659 initialEdits,
66660 // This could be part of the settings.
66661 onActionPerformed,
66662 // The following abstractions are not ideal but necessary
66663 // to account for site editor and post editor differences for now.
66664 extraContent,
66665 extraSidebarPanels,
66666 ...props
66667 }) {
66668 const {
66669 post: post2,
66670 template: template2,
66671 hasLoadedPost,
66672 error,
66673 isBlockTheme,
66674 showGlobalStyles
66675 } = (0, import_data246.useSelect)(
66676 (select6) => {
66677 const {
66678 getEntityRecord,
66679 getResolutionError,
66680 hasFinishedResolution,
66681 getCurrentTheme,
66682 __experimentalGetCurrentGlobalStylesId,
66683 canUser
66684 } = select6(import_core_data136.store);
66685 const { getRenderingMode: getRenderingMode2, getCurrentPostType: getCurrentPostType2 } = select6(store);
66686 const postArgs = ["postType", postType2, postId2];
66687 const renderingMode2 = getRenderingMode2();
66688 const currentPostType = getCurrentPostType2();
66689 const _isBlockTheme = getCurrentTheme()?.is_block_theme;
66690 const globalStylesId = __experimentalGetCurrentGlobalStylesId();
66691 const userCanEditGlobalStyles = globalStylesId ? canUser("update", {
66692 kind: "root",
66693 name: "globalStyles",
66694 id: globalStylesId
66695 }) : false;
66696 return {
66697 post: getEntityRecord(...postArgs),
66698 template: templateId2 ? getEntityRecord(
66699 "postType",
66700 TEMPLATE_POST_TYPE,
66701 templateId2
66702 ) : void 0,
66703 hasLoadedPost: hasFinishedResolution(
66704 "getEntityRecord",
66705 postArgs
66706 ),
66707 error: getResolutionError("getEntityRecord", postArgs)?.message,
66708 isBlockTheme: _isBlockTheme,
66709 showGlobalStyles: _isBlockTheme && userCanEditGlobalStyles && (currentPostType === "wp_template" || renderingMode2 === "template-locked")
66710 };
66711 },
66712 [postType2, postId2, templateId2]
66713 );
66714 return /* @__PURE__ */ (0, import_jsx_runtime425.jsxs)(import_jsx_runtime425.Fragment, { children: [
66715 hasLoadedPost && !post2 && /* @__PURE__ */ (0, import_jsx_runtime425.jsx)(
66716 import_components255.Notice,
66717 {
66718 status: !!error ? "error" : "warning",
66719 isDismissible: false,
66720 children: !error ? (0, import_i18n277.__)(
66721 "You attempted to edit an item that doesn't exist. Perhaps it was deleted?"
66722 ) : error
66723 }
66724 ),
66725 !!post2 && /* @__PURE__ */ (0, import_jsx_runtime425.jsxs)(
66726 ExperimentalEditorProvider,
66727 {
66728 post: post2,
66729 __unstableTemplate: template2,
66730 settings,
66731 initialEdits,
66732 useSubRegistry: false,
66733 children: [
66734 /* @__PURE__ */ (0, import_jsx_runtime425.jsx)(EditorInterface, { ...props, children: extraContent }),
66735 children,
66736 /* @__PURE__ */ (0, import_jsx_runtime425.jsx)(
66737 sidebar_default2,
66738 {
66739 onActionPerformed,
66740 extraPanels: extraSidebarPanels
66741 }
66742 ),
66743 /* @__PURE__ */ (0, import_jsx_runtime425.jsx)(NotesSidebarContainer, {}),
66744 isBlockTheme && /* @__PURE__ */ (0, import_jsx_runtime425.jsx)(GlobalStylesRenderer, {}),
66745 showGlobalStyles && /* @__PURE__ */ (0, import_jsx_runtime425.jsx)(GlobalStylesSidebar, {})
66746 ]
66747 }
66748 )
66749 ] });
66750 }
66751 var editor_default = Editor;
66752
66753 // packages/editor/build-module/components/preferences-modal/index.mjs
66754 var import_i18n279 = __toESM(require_i18n(), 1);
66755 var import_compose71 = __toESM(require_compose(), 1);
66756 var import_data249 = __toESM(require_data(), 1);
66757 var import_element232 = __toESM(require_element(), 1);
66758 var import_preferences32 = __toESM(require_preferences(), 1);
66759
66760 // packages/editor/build-module/components/preferences-modal/enable-publish-sidebar.mjs
66761 var import_data247 = __toESM(require_data(), 1);
66762 var import_preferences30 = __toESM(require_preferences(), 1);
66763 var import_jsx_runtime426 = __toESM(require_jsx_runtime(), 1);
66764 var { PreferenceBaseOption: PreferenceBaseOption2 } = unlock(import_preferences30.privateApis);
66765 function EnablePublishSidebarOption(props) {
66766 const isChecked = (0, import_data247.useSelect)((select6) => {
66767 return select6(store).isPublishSidebarEnabled();
66768 }, []);
66769 const { enablePublishSidebar: enablePublishSidebar2, disablePublishSidebar: disablePublishSidebar2 } = (0, import_data247.useDispatch)(store);
66770 return /* @__PURE__ */ (0, import_jsx_runtime426.jsx)(
66771 PreferenceBaseOption2,
66772 {
66773 isChecked,
66774 onChange: (isEnabled) => isEnabled ? enablePublishSidebar2() : disablePublishSidebar2(),
66775 ...props
66776 }
66777 );
66778 }
66779
66780 // packages/editor/build-module/components/block-visibility/index.mjs
66781 var import_data248 = __toESM(require_data(), 1);
66782 var import_preferences31 = __toESM(require_preferences(), 1);
66783 var import_blocks39 = __toESM(require_blocks(), 1);
66784 var import_element231 = __toESM(require_element(), 1);
66785 var import_components256 = __toESM(require_components(), 1);
66786 var import_i18n278 = __toESM(require_i18n(), 1);
66787 var import_block_editor101 = __toESM(require_block_editor(), 1);
66788 var import_jsx_runtime427 = __toESM(require_jsx_runtime(), 1);
66789 var { BlockManager } = unlock(import_block_editor101.privateApis);
66790 var EMPTY_ARRAY10 = [];
66791 function BlockVisibility() {
66792 const { showBlockTypes: showBlockTypes2, hideBlockTypes: hideBlockTypes2 } = unlock(
66793 (0, import_data248.useDispatch)(store)
66794 );
66795 const {
66796 blockTypes,
66797 allowedBlockTypes: _allowedBlockTypes,
66798 hiddenBlockTypes: _hiddenBlockTypes
66799 } = (0, import_data248.useSelect)((select6) => {
66800 return {
66801 blockTypes: select6(import_blocks39.store).getBlockTypes(),
66802 allowedBlockTypes: select6(store).getEditorSettings().allowedBlockTypes,
66803 hiddenBlockTypes: select6(import_preferences31.store).get("core", "hiddenBlockTypes") ?? EMPTY_ARRAY10
66804 };
66805 }, []);
66806 const allowedBlockTypes = (0, import_element231.useMemo)(() => {
66807 if (_allowedBlockTypes === true) {
66808 return blockTypes;
66809 }
66810 return blockTypes.filter(({ name: name2 }) => {
66811 return _allowedBlockTypes?.includes(name2);
66812 });
66813 }, [_allowedBlockTypes, blockTypes]);
66814 const filteredBlockTypes = allowedBlockTypes.filter(
66815 (blockType) => (0, import_blocks39.hasBlockSupport)(blockType, "inserter", true) && (!blockType.parent || blockType.parent.includes("core/post-content"))
66816 );
66817 const hiddenBlockTypes = _hiddenBlockTypes.filter((hiddenBlock) => {
66818 return filteredBlockTypes.some(
66819 (registeredBlock) => registeredBlock.name === hiddenBlock
66820 );
66821 });
66822 const selectedBlockTypes = filteredBlockTypes.filter(
66823 (blockType) => !hiddenBlockTypes.includes(blockType.name)
66824 );
66825 const numberOfHiddenBlocks = filteredBlockTypes.length - selectedBlockTypes.length;
66826 function enableAllBlockTypes() {
66827 onChangeSelectedBlockTypes(filteredBlockTypes);
66828 }
66829 const onChangeSelectedBlockTypes = (newSelectedBlockTypes) => {
66830 if (selectedBlockTypes.length > newSelectedBlockTypes.length) {
66831 const blockTypesToHide = selectedBlockTypes.filter(
66832 (blockType) => !newSelectedBlockTypes.find(
66833 ({ name: name2 }) => name2 === blockType.name
66834 )
66835 );
66836 hideBlockTypes2(blockTypesToHide.map(({ name: name2 }) => name2));
66837 } else if (selectedBlockTypes.length < newSelectedBlockTypes.length) {
66838 const blockTypesToShow = newSelectedBlockTypes.filter(
66839 (blockType) => !selectedBlockTypes.find(
66840 ({ name: name2 }) => name2 === blockType.name
66841 )
66842 );
66843 showBlockTypes2(blockTypesToShow.map(({ name: name2 }) => name2));
66844 }
66845 };
66846 return /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)("div", { className: "editor-block-visibility", children: [
66847 !!numberOfHiddenBlocks && /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)("div", { className: "editor-block-visibility__disabled-blocks-count", children: [
66848 (0, import_i18n278.sprintf)(
66849 /* translators: %d: number of blocks. */
66850 (0, import_i18n278._n)(
66851 "%d block is hidden.",
66852 "%d blocks are hidden.",
66853 numberOfHiddenBlocks
66854 ),
66855 numberOfHiddenBlocks
66856 ),
66857 /* @__PURE__ */ (0, import_jsx_runtime427.jsx)(
66858 import_components256.Button,
66859 {
66860 __next40pxDefaultSize: true,
66861 variant: "link",
66862 onClick: enableAllBlockTypes,
66863 children: (0, import_i18n278.__)("Reset")
66864 }
66865 )
66866 ] }),
66867 /* @__PURE__ */ (0, import_jsx_runtime427.jsx)(
66868 BlockManager,
66869 {
66870 blockTypes: filteredBlockTypes,
66871 selectedBlockTypes,
66872 onChange: onChangeSelectedBlockTypes,
66873 showSelectAll: false
66874 }
66875 )
66876 ] });
66877 }
66878
66879 // packages/editor/build-module/components/preferences-modal/index.mjs
66880 var import_jsx_runtime428 = __toESM(require_jsx_runtime(), 1);
66881 var {
66882 PreferencesModal,
66883 PreferencesModalTabs,
66884 PreferencesModalSection,
66885 PreferenceToggleControl
66886 } = unlock(import_preferences32.privateApis);
66887 function EditorPreferencesModal({ extraSections = {} }) {
66888 const isActive = (0, import_data249.useSelect)((select6) => {
66889 return select6(store2).isModalActive("editor/preferences");
66890 }, []);
66891 const { closeModal: closeModal2 } = (0, import_data249.useDispatch)(store2);
66892 if (!isActive) {
66893 return null;
66894 }
66895 return /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(PreferencesModal, { closeModal: closeModal2, children: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(PreferencesModalContents, { extraSections }) });
66896 }
66897 function PreferencesModalContents({ extraSections = {} }) {
66898 const isLargeViewport = (0, import_compose71.useViewportMatch)("medium");
66899 const { showBlockBreadcrumbsOption, showCollaborationOptions } = (0, import_data249.useSelect)(
66900 (select6) => {
66901 const { getEditorSettings: getEditorSettings2, isCollaborationEnabledForCurrentPost: isCollaborationEnabledForCurrentPost2 } = unlock(select6(store));
66902 const { get } = select6(import_preferences32.store);
66903 const isRichEditingEnabled = getEditorSettings2().richEditingEnabled;
66904 const isDistractionFreeEnabled = get("core", "distractionFree");
66905 return {
66906 showBlockBreadcrumbsOption: !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled,
66907 showCollaborationOptions: isCollaborationEnabledForCurrentPost2()
66908 };
66909 },
66910 [isLargeViewport]
66911 );
66912 const { setIsListViewOpened: setIsListViewOpened2, setIsInserterOpened: setIsInserterOpened2 } = (0, import_data249.useDispatch)(store);
66913 const { set: setPreference } = (0, import_data249.useDispatch)(import_preferences32.store);
66914 const sections = (0, import_element232.useMemo)(
66915 () => [
66916 {
66917 name: "general",
66918 tabLabel: (0, import_i18n279.__)("General"),
66919 content: /* @__PURE__ */ (0, import_jsx_runtime428.jsxs)(import_jsx_runtime428.Fragment, { children: [
66920 /* @__PURE__ */ (0, import_jsx_runtime428.jsxs)(
66921 PreferencesModalSection,
66922 {
66923 title: (0, import_i18n279.__)("Interface"),
66924 children: [
66925 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
66926 PreferenceToggleControl,
66927 {
66928 scope: "core",
66929 featureName: "showListViewByDefault",
66930 help: (0, import_i18n279.__)(
66931 "Opens the List View panel by default."
66932 ),
66933 label: (0, import_i18n279.__)("Always open List View")
66934 }
66935 ),
66936 showBlockBreadcrumbsOption && /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
66937 PreferenceToggleControl,
66938 {
66939 scope: "core",
66940 featureName: "showBlockBreadcrumbs",
66941 help: (0, import_i18n279.__)(
66942 "Display the block hierarchy trail at the bottom of the editor."
66943 ),
66944 label: (0, import_i18n279.__)("Show block breadcrumbs")
66945 }
66946 ),
66947 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
66948 PreferenceToggleControl,
66949 {
66950 scope: "core",
66951 featureName: "allowRightClickOverrides",
66952 help: (0, import_i18n279.__)(
66953 "Allows contextual List View menus via right-click, overriding browser defaults."
66954 ),
66955 label: (0, import_i18n279.__)(
66956 "Allow right-click contextual menus"
66957 )
66958 }
66959 ),
66960 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
66961 PreferenceToggleControl,
66962 {
66963 scope: "core",
66964 featureName: "enableChoosePatternModal",
66965 help: (0, import_i18n279.__)(
66966 "Pick from starter content when creating a new page."
66967 ),
66968 label: (0, import_i18n279.__)("Show starter patterns")
66969 }
66970 ),
66971 showCollaborationOptions && /* @__PURE__ */ (0, import_jsx_runtime428.jsxs)(import_jsx_runtime428.Fragment, { children: [
66972 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
66973 PreferenceToggleControl,
66974 {
66975 scope: "core",
66976 featureName: "showCollaborationCursor",
66977 help: (0, import_i18n279.__)(
66978 "Show your own avatar inside blocks during collaborative editing sessions."
66979 ),
66980 label: (0, import_i18n279.__)(
66981 "Show avatar in blocks"
66982 )
66983 }
66984 ),
66985 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
66986 PreferenceToggleControl,
66987 {
66988 scope: "core",
66989 featureName: "showCollaborationNotifications",
66990 help: (0, import_i18n279.__)(
66991 "Show notifications when collaborators join, leave, or save the post."
66992 ),
66993 label: (0, import_i18n279.__)(
66994 "Show collaboration notifications"
66995 )
66996 }
66997 )
66998 ] })
66999 ]
67000 }
67001 ),
67002 /* @__PURE__ */ (0, import_jsx_runtime428.jsxs)(
67003 PreferencesModalSection,
67004 {
67005 title: (0, import_i18n279.__)("Document settings"),
67006 description: (0, import_i18n279.__)(
67007 "Select what settings are shown in the document panel."
67008 ),
67009 children: [
67010 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(enable_plugin_document_setting_panel_default.Slot, {}),
67011 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67012 post_taxonomies_default,
67013 {
67014 taxonomyWrapper: (content, taxonomy) => /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67015 EnablePanelOption,
67016 {
67017 label: taxonomy.labels.menu_name,
67018 panelName: `taxonomy-panel-${taxonomy.slug}`
67019 }
67020 )
67021 }
67022 ),
67023 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(check_default4, { children: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67024 EnablePanelOption,
67025 {
67026 label: (0, import_i18n279.__)("Featured image"),
67027 panelName: "featured-image"
67028 }
67029 ) }),
67030 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(check_default3, { children: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67031 EnablePanelOption,
67032 {
67033 label: (0, import_i18n279.__)("Excerpt"),
67034 panelName: "post-excerpt"
67035 }
67036 ) }),
67037 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67038 post_type_support_check_default,
67039 {
67040 supportKeys: ["comments", "trackbacks"],
67041 children: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67042 EnablePanelOption,
67043 {
67044 label: (0, import_i18n279.__)("Discussion"),
67045 panelName: "discussion-panel"
67046 }
67047 )
67048 }
67049 ),
67050 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(check_default2, { children: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67051 EnablePanelOption,
67052 {
67053 label: (0, import_i18n279.__)("Page attributes"),
67054 panelName: "page-attributes"
67055 }
67056 ) })
67057 ]
67058 }
67059 ),
67060 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67061 PreferencesModalSection,
67062 {
67063 title: (0, import_i18n279.__)("Publishing"),
67064 children: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67065 EnablePublishSidebarOption,
67066 {
67067 help: (0, import_i18n279.__)(
67068 "Review settings, such as visibility and tags."
67069 ),
67070 label: (0, import_i18n279.__)(
67071 "Enable pre-publish checks"
67072 )
67073 }
67074 )
67075 }
67076 ),
67077 extraSections?.general
67078 ] })
67079 },
67080 {
67081 name: "appearance",
67082 tabLabel: (0, import_i18n279.__)("Appearance"),
67083 content: /* @__PURE__ */ (0, import_jsx_runtime428.jsxs)(
67084 PreferencesModalSection,
67085 {
67086 title: (0, import_i18n279.__)("Appearance"),
67087 description: (0, import_i18n279.__)(
67088 "Customize the editor interface to suit your needs."
67089 ),
67090 children: [
67091 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67092 PreferenceToggleControl,
67093 {
67094 scope: "core",
67095 featureName: "fixedToolbar",
67096 onToggle: () => setPreference(
67097 "core",
67098 "distractionFree",
67099 false
67100 ),
67101 help: (0, import_i18n279.__)(
67102 "Access all block and document tools in a single place."
67103 ),
67104 label: (0, import_i18n279.__)("Top toolbar")
67105 }
67106 ),
67107 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67108 PreferenceToggleControl,
67109 {
67110 scope: "core",
67111 featureName: "distractionFree",
67112 onToggle: () => {
67113 setPreference(
67114 "core",
67115 "fixedToolbar",
67116 true
67117 );
67118 setIsInserterOpened2(false);
67119 setIsListViewOpened2(false);
67120 },
67121 help: (0, import_i18n279.__)(
67122 "Reduce visual distractions by hiding the toolbar and other elements to focus on writing."
67123 ),
67124 label: (0, import_i18n279.__)("Distraction free")
67125 }
67126 ),
67127 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67128 PreferenceToggleControl,
67129 {
67130 scope: "core",
67131 featureName: "focusMode",
67132 help: (0, import_i18n279.__)(
67133 "Highlights the current block and fades other content."
67134 ),
67135 label: (0, import_i18n279.__)("Spotlight mode")
67136 }
67137 ),
67138 extraSections?.appearance
67139 ]
67140 }
67141 )
67142 },
67143 {
67144 name: "accessibility",
67145 tabLabel: (0, import_i18n279.__)("Accessibility"),
67146 content: /* @__PURE__ */ (0, import_jsx_runtime428.jsxs)(import_jsx_runtime428.Fragment, { children: [
67147 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67148 PreferencesModalSection,
67149 {
67150 title: (0, import_i18n279.__)("Navigation"),
67151 description: (0, import_i18n279.__)(
67152 "Optimize the editing experience for enhanced control."
67153 ),
67154 children: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67155 PreferenceToggleControl,
67156 {
67157 scope: "core",
67158 featureName: "keepCaretInsideBlock",
67159 help: (0, import_i18n279.__)(
67160 "Keeps the text cursor within blocks while navigating with arrow keys, preventing it from moving to other blocks and enhancing accessibility for keyboard users."
67161 ),
67162 label: (0, import_i18n279.__)(
67163 "Contain text cursor inside block"
67164 )
67165 }
67166 )
67167 }
67168 ),
67169 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67170 PreferencesModalSection,
67171 {
67172 title: (0, import_i18n279.__)("Interface"),
67173 children: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67174 PreferenceToggleControl,
67175 {
67176 scope: "core",
67177 featureName: "showIconLabels",
67178 label: (0, import_i18n279.__)("Show button text labels"),
67179 help: (0, import_i18n279.__)(
67180 "Show text instead of icons on buttons across the interface."
67181 )
67182 }
67183 )
67184 }
67185 )
67186 ] })
67187 },
67188 {
67189 name: "blocks",
67190 tabLabel: (0, import_i18n279.__)("Blocks"),
67191 content: /* @__PURE__ */ (0, import_jsx_runtime428.jsxs)(import_jsx_runtime428.Fragment, { children: [
67192 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(PreferencesModalSection, { title: (0, import_i18n279.__)("Inserter"), children: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67193 PreferenceToggleControl,
67194 {
67195 scope: "core",
67196 featureName: "mostUsedBlocks",
67197 help: (0, import_i18n279.__)(
67198 "Adds a category with the most frequently used blocks in the inserter."
67199 ),
67200 label: (0, import_i18n279.__)("Show most used blocks")
67201 }
67202 ) }),
67203 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67204 PreferencesModalSection,
67205 {
67206 title: (0, import_i18n279.__)("Manage block visibility"),
67207 description: (0, import_i18n279.__)(
67208 "Disable blocks that you don't want to appear in the inserter. They can always be toggled back on later."
67209 ),
67210 children: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(BlockVisibility, {})
67211 }
67212 )
67213 ] })
67214 },
67215 window.__clientSideMediaProcessing && {
67216 name: "media",
67217 tabLabel: (0, import_i18n279.__)("Media"),
67218 content: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(import_jsx_runtime428.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime428.jsxs)(
67219 PreferencesModalSection,
67220 {
67221 title: (0, import_i18n279.__)("General"),
67222 description: (0, import_i18n279.__)(
67223 "Customize options related to the media upload flow."
67224 ),
67225 children: [
67226 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67227 PreferenceToggleControl,
67228 {
67229 scope: "core/media",
67230 featureName: "optimizeOnUpload",
67231 help: (0, import_i18n279.__)(
67232 "Compress media items before uploading to the server."
67233 ),
67234 label: (0, import_i18n279.__)("Pre-upload compression")
67235 }
67236 ),
67237 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(
67238 PreferenceToggleControl,
67239 {
67240 scope: "core/media",
67241 featureName: "requireApproval",
67242 help: (0, import_i18n279.__)(
67243 "Require approval step when optimizing existing media."
67244 ),
67245 label: (0, import_i18n279.__)("Approval step")
67246 }
67247 )
67248 ]
67249 }
67250 ) })
67251 }
67252 ].filter(Boolean),
67253 [
67254 showBlockBreadcrumbsOption,
67255 showCollaborationOptions,
67256 extraSections,
67257 setIsInserterOpened2,
67258 setIsListViewOpened2,
67259 setPreference,
67260 isLargeViewport
67261 ]
67262 );
67263 return /* @__PURE__ */ (0, import_jsx_runtime428.jsx)(PreferencesModalTabs, { sections });
67264 }
67265
67266 // packages/editor/build-module/bindings/api.mjs
67267 var import_blocks40 = __toESM(require_blocks(), 1);
67268
67269 // packages/editor/build-module/bindings/pattern-overrides.mjs
67270 var import_block_editor102 = __toESM(require_block_editor(), 1);
67271 var CONTENT = "content";
67272 var pattern_overrides_default = {
67273 name: "core/pattern-overrides",
67274 getValues({ select: select6, clientId, context, bindings }) {
67275 const patternOverridesContent = context["pattern/overrides"];
67276 const { getBlockAttributes: getBlockAttributes2 } = select6(import_block_editor102.store);
67277 const currentBlockAttributes = getBlockAttributes2(clientId);
67278 const overridesValues = {};
67279 for (const attributeName of Object.keys(bindings)) {
67280 const overridableValue = patternOverridesContent?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
67281 if (overridableValue === void 0) {
67282 overridesValues[attributeName] = currentBlockAttributes[attributeName];
67283 continue;
67284 } else {
67285 overridesValues[attributeName] = overridableValue === "" ? void 0 : overridableValue;
67286 }
67287 }
67288 return overridesValues;
67289 },
67290 setValues({ select: select6, dispatch: dispatch7, clientId, bindings }) {
67291 const { getBlockAttributes: getBlockAttributes2, getBlockParentsByBlockName, getBlocks: getBlocks2 } = select6(import_block_editor102.store);
67292 const currentBlockAttributes = getBlockAttributes2(clientId);
67293 const blockName = currentBlockAttributes?.metadata?.name;
67294 if (!blockName) {
67295 return;
67296 }
67297 const [patternClientId] = getBlockParentsByBlockName(
67298 clientId,
67299 "core/block",
67300 true
67301 );
67302 const attributes = Object.entries(bindings).reduce(
67303 (attrs, [key, { newValue }]) => {
67304 attrs[key] = newValue;
67305 return attrs;
67306 },
67307 {}
67308 );
67309 if (!patternClientId) {
67310 const syncBlocksWithSameName = (blocks) => {
67311 for (const block of blocks) {
67312 if (block.attributes?.metadata?.name === blockName) {
67313 dispatch7(import_block_editor102.store).updateBlockAttributes(
67314 block.clientId,
67315 attributes
67316 );
67317 }
67318 syncBlocksWithSameName(block.innerBlocks);
67319 }
67320 };
67321 syncBlocksWithSameName(getBlocks2());
67322 return;
67323 }
67324 const currentBindingValue = getBlockAttributes2(patternClientId)?.[CONTENT];
67325 dispatch7(import_block_editor102.store).updateBlockAttributes(patternClientId, {
67326 [CONTENT]: {
67327 ...currentBindingValue,
67328 [blockName]: {
67329 ...currentBindingValue?.[blockName],
67330 ...Object.entries(attributes).reduce(
67331 (acc, [key, value]) => {
67332 acc[key] = value === void 0 ? "" : value;
67333 return acc;
67334 },
67335 {}
67336 )
67337 }
67338 }
67339 });
67340 },
67341 canUserEditValue: () => true
67342 };
67343
67344 // packages/editor/build-module/bindings/post-data.mjs
67345 var import_i18n280 = __toESM(require_i18n(), 1);
67346 var import_core_data137 = __toESM(require_core_data(), 1);
67347 var import_block_editor103 = __toESM(require_block_editor(), 1);
67348 var NAVIGATION_BLOCK_TYPES = [
67349 "core/navigation-link",
67350 "core/navigation-submenu"
67351 ];
67352 var postDataFields = [
67353 {
67354 label: (0, import_i18n280.__)("Post Date"),
67355 args: { field: "date" },
67356 type: "string"
67357 },
67358 {
67359 label: (0, import_i18n280.__)("Post Modified Date"),
67360 args: { field: "modified" },
67361 type: "string"
67362 },
67363 {
67364 label: (0, import_i18n280.__)("Post Link"),
67365 args: { field: "link" },
67366 type: "string"
67367 }
67368 ];
67369 var post_data_default = {
67370 name: "core/post-data",
67371 getValues({ select: select6, context, bindings, clientId }) {
67372 const { getBlockAttributes: getBlockAttributes2, getBlockName: getBlockName2 } = select6(import_block_editor103.store);
67373 const blockName = getBlockName2(clientId);
67374 const isNavigationBlock = NAVIGATION_BLOCK_TYPES.includes(blockName);
67375 let postId2, postType2;
67376 if (isNavigationBlock) {
67377 const blockAttributes = getBlockAttributes2(clientId);
67378 postId2 = blockAttributes?.id;
67379 postType2 = blockAttributes?.type;
67380 } else {
67381 postId2 = context?.postId;
67382 postType2 = context?.postType;
67383 }
67384 const { getEditedEntityRecord } = select6(import_core_data137.store);
67385 const entityDataValues = getEditedEntityRecord(
67386 "postType",
67387 postType2,
67388 postId2
67389 );
67390 const newValues = {};
67391 for (const [attributeName, binding] of Object.entries(bindings)) {
67392 const postDataField = postDataFields.find(
67393 (field) => field.args.field === binding.args.field
67394 );
67395 if (!postDataField) {
67396 newValues[attributeName] = binding.args.field;
67397 } else if (!entityDataValues) {
67398 newValues[attributeName] = postDataField.label;
67399 } else {
67400 newValues[attributeName] = entityDataValues[binding.args.field];
67401 }
67402 }
67403 return newValues;
67404 },
67405 setValues({ dispatch: dispatch7, context, bindings, clientId, select: select6 }) {
67406 const { getBlockName: getBlockName2 } = select6(import_block_editor103.store);
67407 const blockName = getBlockName2(clientId);
67408 if (NAVIGATION_BLOCK_TYPES.includes(blockName)) {
67409 return false;
67410 }
67411 const newData = {};
67412 Object.values(bindings).forEach(({ args, newValue }) => {
67413 newData[args.field] = newValue;
67414 });
67415 dispatch7(import_core_data137.store).editEntityRecord(
67416 "postType",
67417 context?.postType,
67418 context?.postId,
67419 newData
67420 );
67421 },
67422 canUserEditValue({ select: select6, context }) {
67423 const { getBlockName: getBlockName2, getSelectedBlockClientId: getSelectedBlockClientId2 } = select6(import_block_editor103.store);
67424 const clientId = getSelectedBlockClientId2();
67425 const blockName = getBlockName2(clientId);
67426 if (NAVIGATION_BLOCK_TYPES.includes(blockName)) {
67427 return false;
67428 }
67429 if (context?.query || context?.queryId) {
67430 return false;
67431 }
67432 if (!context?.postType) {
67433 return false;
67434 }
67435 const canUserEdit = select6(import_core_data137.store).canUser("update", {
67436 kind: "postType",
67437 name: context?.postType,
67438 id: context?.postId
67439 });
67440 if (!canUserEdit) {
67441 return false;
67442 }
67443 return true;
67444 },
67445 getFieldsList({ context, select: select6 }) {
67446 const selectedBlock = select6(import_block_editor103.store).getSelectedBlock();
67447 if (selectedBlock?.name !== "core/post-date") {
67448 return [];
67449 }
67450 if (!context || !context.postId || !context.postType) {
67451 return [];
67452 }
67453 return postDataFields;
67454 }
67455 };
67456
67457 // packages/editor/build-module/bindings/post-meta.mjs
67458 var import_core_data138 = __toESM(require_core_data(), 1);
67459 function getPostMetaFields(select6, context) {
67460 const { getRegisteredPostMeta } = unlock(select6(import_core_data138.store));
67461 const registeredFields = getRegisteredPostMeta(context?.postType);
67462 const metaFields = [];
67463 Object.entries(registeredFields).forEach(([key, props]) => {
67464 if (key === "footnotes" || key.charAt(0) === "_") {
67465 return;
67466 }
67467 metaFields.push({
67468 label: props.title || key,
67469 args: { key },
67470 default: props.default,
67471 type: props.type
67472 });
67473 });
67474 return metaFields;
67475 }
67476 function getValue({ select: select6, context, args }) {
67477 const metaFields = getPostMetaFields(select6, context);
67478 const metaField = metaFields.find(
67479 (field) => field.args.key === args.key
67480 );
67481 if (!metaField) {
67482 return args.key;
67483 }
67484 if (!context?.postId) {
67485 return metaField.default || metaField.label || args.key;
67486 }
67487 const { getEditedEntityRecord } = select6(import_core_data138.store);
67488 const entityMetaValues = getEditedEntityRecord(
67489 "postType",
67490 context?.postType,
67491 context?.postId
67492 ).meta;
67493 return entityMetaValues?.[args.key] ?? metaField?.label ?? args.key;
67494 }
67495 var post_meta_default = {
67496 name: "core/post-meta",
67497 getValues({ select: select6, context, bindings }) {
67498 const newValues = {};
67499 for (const [attributeName, binding] of Object.entries(bindings)) {
67500 newValues[attributeName] = getValue({
67501 select: select6,
67502 context,
67503 args: binding.args
67504 });
67505 }
67506 return newValues;
67507 },
67508 setValues({ dispatch: dispatch7, context, bindings }) {
67509 const newMeta = {};
67510 Object.values(bindings).forEach(({ args, newValue }) => {
67511 newMeta[args.key] = newValue;
67512 });
67513 dispatch7(import_core_data138.store).editEntityRecord(
67514 "postType",
67515 context?.postType,
67516 context?.postId,
67517 {
67518 meta: newMeta
67519 }
67520 );
67521 },
67522 canUserEditValue({ select: select6, context, args }) {
67523 if (context?.query || context?.queryId) {
67524 return false;
67525 }
67526 if (!context?.postType) {
67527 return false;
67528 }
67529 const metaFields = getPostMetaFields(select6, context);
67530 const hasMatchingMetaField = metaFields.some(
67531 (field) => field.args.key === args.key
67532 );
67533 if (!hasMatchingMetaField) {
67534 return false;
67535 }
67536 const areCustomFieldsEnabled = select6(store).getEditorSettings().enableCustomFields;
67537 if (areCustomFieldsEnabled) {
67538 return false;
67539 }
67540 const canUserEdit = select6(import_core_data138.store).canUser("update", {
67541 kind: "postType",
67542 name: context?.postType,
67543 id: context?.postId
67544 });
67545 if (!canUserEdit) {
67546 return false;
67547 }
67548 return true;
67549 },
67550 getFieldsList({ select: select6, context }) {
67551 const metaFields = getPostMetaFields(select6, context);
67552 return metaFields.map(
67553 ({ default: defaultProp, ...otherProps }) => ({
67554 ...otherProps
67555 })
67556 );
67557 }
67558 };
67559
67560 // packages/editor/build-module/bindings/term-data.mjs
67561 var import_i18n281 = __toESM(require_i18n(), 1);
67562 var import_core_data139 = __toESM(require_core_data(), 1);
67563 var import_block_editor104 = __toESM(require_block_editor(), 1);
67564 var NAVIGATION_BLOCK_TYPES2 = [
67565 "core/navigation-link",
67566 "core/navigation-submenu"
67567 ];
67568 var termDataFields = [
67569 {
67570 label: (0, import_i18n281.__)("Term ID"),
67571 args: { field: "id" },
67572 type: "string"
67573 },
67574 {
67575 label: (0, import_i18n281.__)("Name"),
67576 args: { field: "name" },
67577 type: "string"
67578 },
67579 {
67580 label: (0, import_i18n281.__)("Slug"),
67581 args: { field: "slug" },
67582 type: "string"
67583 },
67584 {
67585 label: (0, import_i18n281.__)("Link"),
67586 args: { field: "link" },
67587 type: "string"
67588 },
67589 {
67590 label: (0, import_i18n281.__)("Description"),
67591 args: { field: "description" },
67592 type: "string"
67593 },
67594 {
67595 label: (0, import_i18n281.__)("Parent ID"),
67596 args: { field: "parent" },
67597 type: "string"
67598 },
67599 {
67600 label: (0, import_i18n281.__)("Count"),
67601 args: { field: "count" },
67602 type: "string"
67603 }
67604 ];
67605 var term_data_default = {
67606 name: "core/term-data",
67607 usesContext: ["taxonomy", "termId", "termData"],
67608 getValues({ select: select6, context, bindings, clientId }) {
67609 const { getEntityRecord } = select6(import_core_data139.store);
67610 const { getBlockAttributes: getBlockAttributes2, getBlockName: getBlockName2 } = select6(import_block_editor104.store);
67611 const blockName = getBlockName2(clientId);
67612 const isNavigationBlock = NAVIGATION_BLOCK_TYPES2.includes(blockName);
67613 let termDataValues;
67614 if (isNavigationBlock) {
67615 const blockAttributes = getBlockAttributes2(clientId);
67616 const typeFromAttributes = blockAttributes?.type;
67617 const taxonomy = typeFromAttributes === "tag" ? "post_tag" : typeFromAttributes;
67618 termDataValues = getEntityRecord(
67619 "taxonomy",
67620 taxonomy,
67621 blockAttributes?.id
67622 );
67623 } else if (context.termId && context.taxonomy) {
67624 termDataValues = getEntityRecord(
67625 "taxonomy",
67626 context.taxonomy,
67627 context.termId
67628 );
67629 }
67630 if (!termDataValues && context?.termData && !isNavigationBlock) {
67631 termDataValues = context.termData;
67632 }
67633 const newValues = {};
67634 for (const [attributeName, binding] of Object.entries(bindings)) {
67635 const termDataField = termDataFields.find(
67636 (field) => field.args.field === binding.args.field
67637 );
67638 if (!termDataField) {
67639 newValues[attributeName] = binding.args.field;
67640 } else if (!termDataValues || termDataValues[binding.args.field] === void 0) {
67641 newValues[attributeName] = termDataField.label;
67642 } else if (binding.args.field === "count") {
67643 newValues[attributeName] = "(" + termDataValues[binding.args.field] + ")";
67644 } else {
67645 newValues[attributeName] = termDataValues[binding.args.field];
67646 }
67647 }
67648 return newValues;
67649 },
67650 // eslint-disable-next-line no-unused-vars
67651 setValues({ dispatch: dispatch7, context, bindings }) {
67652 return false;
67653 },
67654 canUserEditValue({ select: select6, context }) {
67655 const { getBlockName: getBlockName2, getSelectedBlockClientId: getSelectedBlockClientId2 } = select6(import_block_editor104.store);
67656 const clientId = getSelectedBlockClientId2();
67657 const blockName = getBlockName2(clientId);
67658 if (NAVIGATION_BLOCK_TYPES2.includes(blockName)) {
67659 return false;
67660 }
67661 if (context?.termQuery) {
67662 return false;
67663 }
67664 if (!context?.taxonomy || !context?.termId) {
67665 return false;
67666 }
67667 return false;
67668 },
67669 getFieldsList({ context, select: select6 }) {
67670 const { getBlockAttributes: getBlockAttributes2, getBlockName: getBlockName2, getSelectedBlockClientId: getSelectedBlockClientId2 } = select6(import_block_editor104.store);
67671 const clientId = getSelectedBlockClientId2();
67672 const blockName = getBlockName2(clientId);
67673 if (NAVIGATION_BLOCK_TYPES2.includes(blockName)) {
67674 const blockAttributes = getBlockAttributes2(clientId);
67675 if (!blockAttributes || !blockAttributes.id || !blockAttributes.type) {
67676 return [];
67677 }
67678 return termDataFields;
67679 }
67680 if (!context) {
67681 return [];
67682 }
67683 if (context.taxonomy && context.termId || context.termData) {
67684 return termDataFields;
67685 }
67686 return [];
67687 }
67688 };
67689
67690 // packages/editor/build-module/bindings/api.mjs
67691 function registerCoreBlockBindingsSources() {
67692 (0, import_blocks40.registerBlockBindingsSource)(pattern_overrides_default);
67693 (0, import_blocks40.registerBlockBindingsSource)(post_data_default);
67694 (0, import_blocks40.registerBlockBindingsSource)(post_meta_default);
67695 (0, import_blocks40.registerBlockBindingsSource)(term_data_default);
67696 }
67697
67698 // packages/editor/build-module/private-apis.mjs
67699 var { store: interfaceStore, ...remainingInterfaceApis } = build_module_exports;
67700 var privateApis18 = {};
67701 lock(privateApis18, {
67702 CreateTemplatePartModal,
67703 patternTitleField: pattern_title_default,
67704 templateTitleField: template_title_default,
67705 BackButton: back_button_default,
67706 EntitiesSavedStatesExtensible,
67707 Editor: editor_default,
67708 PluginPostExcerpt: plugin_default,
67709 PostCardPanel,
67710 PreferencesModal: EditorPreferencesModal,
67711 usePostActions,
67712 usePostFields: post_fields_default,
67713 ToolsMoreMenuGroup: tools_more_menu_group_default,
67714 ViewMoreMenuGroup: view_more_menu_group_default,
67715 ResizableEditor: resizable_editor_default,
67716 registerCoreBlockBindingsSources,
67717 getTemplateInfo,
67718 // Global Styles
67719 GlobalStylesUIWrapper,
67720 GlobalStylesActionMenu,
67721 StyleBookPreview,
67722 useGlobalStyles,
67723 useStyle: useStyle2,
67724 // This is a temporary private API while we're updating the site editor to use EditorProvider.
67725 interfaceStore,
67726 ...remainingInterfaceApis
67727 });
67728
67729 // packages/editor/build-module/dataviews/api.mjs
67730 var import_data250 = __toESM(require_data(), 1);
67731 function registerEntityAction2(kind, name2, config2) {
67732 const { registerEntityAction: _registerEntityAction } = unlock(
67733 (0, import_data250.dispatch)(store)
67734 );
67735 if (false) {
67736 _registerEntityAction(kind, name2, config2);
67737 }
67738 }
67739 function unregisterEntityAction2(kind, name2, actionId) {
67740 const { unregisterEntityAction: _unregisterEntityAction } = unlock(
67741 (0, import_data250.dispatch)(store)
67742 );
67743 if (false) {
67744 _unregisterEntityAction(kind, name2, actionId);
67745 }
67746 }
67747 function registerEntityField2(kind, name2, config2) {
67748 const { registerEntityField: _registerEntityField } = unlock(
67749 (0, import_data250.dispatch)(store)
67750 );
67751 if (false) {
67752 _registerEntityField(kind, name2, config2);
67753 }
67754 }
67755 function unregisterEntityField2(kind, name2, fieldId) {
67756 const { unregisterEntityField: _unregisterEntityField } = unlock(
67757 (0, import_data250.dispatch)(store)
67758 );
67759 if (false) {
67760 _unregisterEntityField(kind, name2, fieldId);
67761 }
67762 }
67763
67764 // packages/editor/build-module/index.mjs
67765 var import_block_editor105 = __toESM(require_block_editor(), 1);
67766 return __toCommonJS(index_exports);
67767})();
67768/*! Bundled license information:
67769
67770react-is/cjs/react-is.development.js:
67771 (** @license React v16.13.1
67772 * react-is.development.js
67773 *
67774 * Copyright (c) Facebook, Inc. and its affiliates.
67775 *
67776 * This source code is licensed under the MIT license found in the
67777 * LICENSE file in the root directory of this source tree.
67778 *)
67779
67780object-assign/index.js:
67781 (*
67782 object-assign
67783 (c) Sindre Sorhus
67784 @license MIT
67785 *)
67786
67787autosize/dist/autosize.js:
67788 (*!
67789 autosize 4.0.2
67790 license: MIT
67791 http://www.jacklmoore.com/autosize
67792 *)
67793
67794is-plain-object/dist/is-plain-object.mjs:
67795 (*!
67796 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
67797 *
67798 * Copyright (c) 2014-2017, Jon Schlinkert.
67799 * Released under the MIT License.
67800 *)
67801*/
67802