PluginProbe
Gutenberg / 23.5.1
Gutenberg v23.5.1
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / scripts / edit-widgets / index.js

index.js in Gutenberg 23.5.1, at build/scripts/edit-widgets/index.js

4,671 lines 178.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var wp;
2 (wp ||= {}).editWidgets = (() => {
3 var __create = Object.create;
4 var __defProp = Object.defineProperty;
5 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6 var __getOwnPropNames = Object.getOwnPropertyNames;
7 var __getProtoOf = Object.getPrototypeOf;
8 var __hasOwnProp = Object.prototype.hasOwnProperty;
9 var __commonJS = (cb, mod) => function __require() {
10 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11 };
12 var __export = (target, all) => {
13 for (var name2 in all)
14 __defProp(target, name2, { get: all[name2], enumerable: true });
15 };
16 var __copyProps = (to, from, except, desc) => {
17 if (from && typeof from === "object" || typeof from === "function") {
18 for (let key of __getOwnPropNames(from))
19 if (!__hasOwnProp.call(to, key) && key !== except)
20 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21 }
22 return to;
23 };
24 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25 // If the importer is in node compatibility mode or this is not an ESM
26 // file that has been converted to a CommonJS file using a Babel-
27 // compatible transform (i.e. "__esModule" has not been set), then set
28 // "default" to the CommonJS "module.exports" for node compatibility.
29 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30 mod
31 ));
32 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
34 // package-external:@wordpress/blocks
35 var require_blocks = __commonJS({
36 "package-external:@wordpress/blocks"(exports, module) {
37 module.exports = window.wp.blocks;
38 }
39 });
40
41 // package-external:@wordpress/data
42 var require_data = __commonJS({
43 "package-external:@wordpress/data"(exports, module) {
44 module.exports = window.wp.data;
45 }
46 });
47
48 // package-external:@wordpress/deprecated
49 var require_deprecated = __commonJS({
50 "package-external:@wordpress/deprecated"(exports, module) {
51 module.exports = window.wp.deprecated;
52 }
53 });
54
55 // package-external:@wordpress/element
56 var require_element = __commonJS({
57 "package-external:@wordpress/element"(exports, module) {
58 module.exports = window.wp.element;
59 }
60 });
61
62 // package-external:@wordpress/block-library
63 var require_block_library = __commonJS({
64 "package-external:@wordpress/block-library"(exports, module) {
65 module.exports = window.wp.blockLibrary;
66 }
67 });
68
69 // package-external:@wordpress/core-data
70 var require_core_data = __commonJS({
71 "package-external:@wordpress/core-data"(exports, module) {
72 module.exports = window.wp.coreData;
73 }
74 });
75
76 // package-external:@wordpress/widgets
77 var require_widgets = __commonJS({
78 "package-external:@wordpress/widgets"(exports, module) {
79 module.exports = window.wp.widgets;
80 }
81 });
82
83 // package-external:@wordpress/preferences
84 var require_preferences = __commonJS({
85 "package-external:@wordpress/preferences"(exports, module) {
86 module.exports = window.wp.preferences;
87 }
88 });
89
90 // package-external:@wordpress/api-fetch
91 var require_api_fetch = __commonJS({
92 "package-external:@wordpress/api-fetch"(exports, module) {
93 module.exports = window.wp.apiFetch;
94 }
95 });
96
97 // package-external:@wordpress/i18n
98 var require_i18n = __commonJS({
99 "package-external:@wordpress/i18n"(exports, module) {
100 module.exports = window.wp.i18n;
101 }
102 });
103
104 // package-external:@wordpress/notices
105 var require_notices = __commonJS({
106 "package-external:@wordpress/notices"(exports, module) {
107 module.exports = window.wp.notices;
108 }
109 });
110
111 // package-external:@wordpress/components
112 var require_components = __commonJS({
113 "package-external:@wordpress/components"(exports, module) {
114 module.exports = window.wp.components;
115 }
116 });
117
118 // package-external:@wordpress/primitives
119 var require_primitives = __commonJS({
120 "package-external:@wordpress/primitives"(exports, module) {
121 module.exports = window.wp.primitives;
122 }
123 });
124
125 // vendor-external:react/jsx-runtime
126 var require_jsx_runtime = __commonJS({
127 "vendor-external:react/jsx-runtime"(exports, module) {
128 module.exports = window.ReactJSXRuntime;
129 }
130 });
131
132 // package-external:@wordpress/viewport
133 var require_viewport = __commonJS({
134 "package-external:@wordpress/viewport"(exports, module) {
135 module.exports = window.wp.viewport;
136 }
137 });
138
139 // package-external:@wordpress/compose
140 var require_compose = __commonJS({
141 "package-external:@wordpress/compose"(exports, module) {
142 module.exports = window.wp.compose;
143 }
144 });
145
146 // package-external:@wordpress/plugins
147 var require_plugins = __commonJS({
148 "package-external:@wordpress/plugins"(exports, module) {
149 module.exports = window.wp.plugins;
150 }
151 });
152
153 // vendor-external:react
154 var require_react = __commonJS({
155 "vendor-external:react"(exports, module) {
156 module.exports = window.React;
157 }
158 });
159
160 // package-external:@wordpress/private-apis
161 var require_private_apis = __commonJS({
162 "package-external:@wordpress/private-apis"(exports, module) {
163 module.exports = window.wp.privateApis;
164 }
165 });
166
167 // package-external:@wordpress/block-editor
168 var require_block_editor = __commonJS({
169 "package-external:@wordpress/block-editor"(exports, module) {
170 module.exports = window.wp.blockEditor;
171 }
172 });
173
174 // package-external:@wordpress/hooks
175 var require_hooks = __commonJS({
176 "package-external:@wordpress/hooks"(exports, module) {
177 module.exports = window.wp.hooks;
178 }
179 });
180
181 // package-external:@wordpress/media-utils
182 var require_media_utils = __commonJS({
183 "package-external:@wordpress/media-utils"(exports, module) {
184 module.exports = window.wp.mediaUtils;
185 }
186 });
187
188 // package-external:@wordpress/patterns
189 var require_patterns = __commonJS({
190 "package-external:@wordpress/patterns"(exports, module) {
191 module.exports = window.wp.patterns;
192 }
193 });
194
195 // package-external:@wordpress/keyboard-shortcuts
196 var require_keyboard_shortcuts = __commonJS({
197 "package-external:@wordpress/keyboard-shortcuts"(exports, module) {
198 module.exports = window.wp.keyboardShortcuts;
199 }
200 });
201
202 // package-external:@wordpress/keycodes
203 var require_keycodes = __commonJS({
204 "package-external:@wordpress/keycodes"(exports, module) {
205 module.exports = window.wp.keycodes;
206 }
207 });
208
209 // package-external:@wordpress/url
210 var require_url = __commonJS({
211 "package-external:@wordpress/url"(exports, module) {
212 module.exports = window.wp.url;
213 }
214 });
215
216 // package-external:@wordpress/dom
217 var require_dom = __commonJS({
218 "package-external:@wordpress/dom"(exports, module) {
219 module.exports = window.wp.dom;
220 }
221 });
222
223 // packages/edit-widgets/build-module/index.mjs
224 var index_exports = {};
225 __export(index_exports, {
226 initialize: () => initialize,
227 initializeEditor: () => initializeEditor,
228 reinitializeEditor: () => reinitializeEditor,
229 store: () => store2
230 });
231 var import_blocks3 = __toESM(require_blocks(), 1);
232 var import_data32 = __toESM(require_data(), 1);
233 var import_deprecated6 = __toESM(require_deprecated(), 1);
234 var import_element26 = __toESM(require_element(), 1);
235 var import_block_library2 = __toESM(require_block_library(), 1);
236 var import_core_data12 = __toESM(require_core_data(), 1);
237 var import_widgets5 = __toESM(require_widgets(), 1);
238 var import_preferences10 = __toESM(require_preferences(), 1);
239
240 // packages/edit-widgets/build-module/store/index.mjs
241 var import_api_fetch = __toESM(require_api_fetch(), 1);
242 var import_data8 = __toESM(require_data(), 1);
243
244 // packages/edit-widgets/build-module/store/reducer.mjs
245 var import_data = __toESM(require_data(), 1);
246 function widgetAreasOpenState(state = {}, action) {
247 const { type } = action;
248 switch (type) {
249 case "SET_WIDGET_AREAS_OPEN_STATE": {
250 return action.widgetAreasOpenState;
251 }
252 case "SET_IS_WIDGET_AREA_OPEN": {
253 const { clientId, isOpen } = action;
254 return {
255 ...state,
256 [clientId]: isOpen
257 };
258 }
259 default: {
260 return state;
261 }
262 }
263 }
264 function blockInserterPanel(state = false, action) {
265 switch (action.type) {
266 case "SET_IS_LIST_VIEW_OPENED":
267 return action.isOpen ? false : state;
268 case "SET_IS_INSERTER_OPENED":
269 return action.value;
270 }
271 return state;
272 }
273 function listViewPanel(state = false, action) {
274 switch (action.type) {
275 case "SET_IS_INSERTER_OPENED":
276 return action.value ? false : state;
277 case "SET_IS_LIST_VIEW_OPENED":
278 return action.isOpen;
279 }
280 return state;
281 }
282 function listViewToggleRef(state = { current: null }) {
283 return state;
284 }
285 function inserterSidebarToggleRef(state = { current: null }) {
286 return state;
287 }
288 function widgetSavingLock(state = {}, action) {
289 switch (action.type) {
290 case "LOCK_WIDGET_SAVING":
291 return { ...state, [action.lockName]: true };
292 case "UNLOCK_WIDGET_SAVING": {
293 const { [action.lockName]: removedLockName, ...restState } = state;
294 return restState;
295 }
296 }
297 return state;
298 }
299 var reducer_default = (0, import_data.combineReducers)({
300 blockInserterPanel,
301 inserterSidebarToggleRef,
302 listViewPanel,
303 listViewToggleRef,
304 widgetAreasOpenState,
305 widgetSavingLock
306 });
307
308 // packages/edit-widgets/build-module/store/resolvers.mjs
309 var resolvers_exports = {};
310 __export(resolvers_exports, {
311 getWidgetAreas: () => getWidgetAreas,
312 getWidgets: () => getWidgets
313 });
314 var import_blocks2 = __toESM(require_blocks(), 1);
315 var import_core_data2 = __toESM(require_core_data(), 1);
316
317 // packages/edit-widgets/build-module/store/actions.mjs
318 var actions_exports2 = {};
319 __export(actions_exports2, {
320 closeGeneralSidebar: () => closeGeneralSidebar,
321 lockWidgetSaving: () => lockWidgetSaving,
322 moveBlockToWidgetArea: () => moveBlockToWidgetArea,
323 persistStubPost: () => persistStubPost,
324 saveEditedWidgetAreas: () => saveEditedWidgetAreas,
325 saveWidgetArea: () => saveWidgetArea,
326 saveWidgetAreas: () => saveWidgetAreas,
327 setIsInserterOpened: () => setIsInserterOpened,
328 setIsListViewOpened: () => setIsListViewOpened,
329 setIsWidgetAreaOpen: () => setIsWidgetAreaOpen,
330 setWidgetAreasOpenState: () => setWidgetAreasOpenState,
331 setWidgetIdForClientId: () => setWidgetIdForClientId,
332 unlockWidgetSaving: () => unlockWidgetSaving
333 });
334 var import_i18n3 = __toESM(require_i18n(), 1);
335 var import_notices = __toESM(require_notices(), 1);
336
337 // node_modules/clsx/dist/clsx.mjs
338 function r(e) {
339 var t, f, n = "";
340 if ("string" == typeof e || "number" == typeof e) n += e;
341 else if ("object" == typeof e) if (Array.isArray(e)) {
342 var o = e.length;
343 for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
344 } else for (f in e) e[f] && (n && (n += " "), n += f);
345 return n;
346 }
347 function clsx() {
348 for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
349 return n;
350 }
351 var clsx_default = clsx;
352
353 // packages/interface/build-module/components/complementary-area/index.mjs
354 var import_components5 = __toESM(require_components(), 1);
355 var import_data6 = __toESM(require_data(), 1);
356 var import_i18n = __toESM(require_i18n(), 1);
357
358 // packages/icons/build-module/library/block-default.mjs
359 var import_primitives = __toESM(require_primitives(), 1);
360 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
361 var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) });
362
363 // packages/icons/build-module/library/check.mjs
364 var import_primitives2 = __toESM(require_primitives(), 1);
365 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
366 var check_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
367
368 // packages/icons/build-module/library/close-small.mjs
369 var import_primitives3 = __toESM(require_primitives(), 1);
370 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
371 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.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" }) });
372
373 // packages/icons/build-module/library/drawer-left.mjs
374 var import_primitives4 = __toESM(require_primitives(), 1);
375 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
376 var drawer_left_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z" }) });
377
378 // packages/icons/build-module/library/drawer-right.mjs
379 var import_primitives5 = __toESM(require_primitives(), 1);
380 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
381 var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.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" }) });
382
383 // packages/icons/build-module/library/external.mjs
384 var import_primitives6 = __toESM(require_primitives(), 1);
385 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
386 var external_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" }) });
387
388 // packages/icons/build-module/library/list-view.mjs
389 var import_primitives7 = __toESM(require_primitives(), 1);
390 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
391 var list_view_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" }) });
392
393 // packages/icons/build-module/library/more-vertical.mjs
394 var import_primitives8 = __toESM(require_primitives(), 1);
395 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
396 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
397
398 // packages/icons/build-module/library/plus.mjs
399 var import_primitives9 = __toESM(require_primitives(), 1);
400 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
401 var plus_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" }) });
402
403 // packages/icons/build-module/library/redo.mjs
404 var import_primitives10 = __toESM(require_primitives(), 1);
405 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
406 var redo_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z" }) });
407
408 // packages/icons/build-module/library/star-empty.mjs
409 var import_primitives11 = __toESM(require_primitives(), 1);
410 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
411 var star_empty_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z" }) });
412
413 // packages/icons/build-module/library/star-filled.mjs
414 var import_primitives12 = __toESM(require_primitives(), 1);
415 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
416 var star_filled_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" }) });
417
418 // packages/icons/build-module/library/undo.mjs
419 var import_primitives13 = __toESM(require_primitives(), 1);
420 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
421 var undo_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z" }) });
422
423 // packages/interface/build-module/components/complementary-area/index.mjs
424 var import_element2 = __toESM(require_element(), 1);
425 var import_viewport = __toESM(require_viewport(), 1);
426 var import_preferences3 = __toESM(require_preferences(), 1);
427 var import_compose = __toESM(require_compose(), 1);
428 var import_plugins2 = __toESM(require_plugins(), 1);
429
430 // packages/interface/build-module/components/complementary-area-toggle/index.mjs
431 var import_components = __toESM(require_components(), 1);
432 var import_data5 = __toESM(require_data(), 1);
433 var import_plugins = __toESM(require_plugins(), 1);
434
435 // packages/interface/build-module/store/index.mjs
436 var import_data4 = __toESM(require_data(), 1);
437
438 // packages/interface/build-module/store/actions.mjs
439 var actions_exports = {};
440 __export(actions_exports, {
441 closeModal: () => closeModal,
442 disableComplementaryArea: () => disableComplementaryArea,
443 enableComplementaryArea: () => enableComplementaryArea,
444 openModal: () => openModal,
445 pinItem: () => pinItem,
446 setDefaultComplementaryArea: () => setDefaultComplementaryArea,
447 setFeatureDefaults: () => setFeatureDefaults,
448 setFeatureValue: () => setFeatureValue,
449 toggleFeature: () => toggleFeature,
450 unpinItem: () => unpinItem
451 });
452 var import_deprecated2 = __toESM(require_deprecated(), 1);
453 var import_preferences = __toESM(require_preferences(), 1);
454
455 // packages/interface/build-module/store/deprecated.mjs
456 var import_deprecated = __toESM(require_deprecated(), 1);
457 function normalizeComplementaryAreaScope(scope) {
458 if (["core/edit-post", "core/edit-site"].includes(scope)) {
459 (0, import_deprecated.default)(`${scope} interface scope`, {
460 alternative: "core interface scope",
461 hint: "core/edit-post and core/edit-site are merging.",
462 version: "6.6"
463 });
464 return "core";
465 }
466 return scope;
467 }
468 function normalizeComplementaryAreaName(scope, name2) {
469 if (scope === "core" && name2 === "edit-site/template") {
470 (0, import_deprecated.default)(`edit-site/template sidebar`, {
471 alternative: "edit-post/document",
472 version: "6.6"
473 });
474 return "edit-post/document";
475 }
476 if (scope === "core" && name2 === "edit-site/block-inspector") {
477 (0, import_deprecated.default)(`edit-site/block-inspector sidebar`, {
478 alternative: "edit-post/block",
479 version: "6.6"
480 });
481 return "edit-post/block";
482 }
483 return name2;
484 }
485
486 // packages/interface/build-module/store/actions.mjs
487 var setDefaultComplementaryArea = (scope, area) => {
488 scope = normalizeComplementaryAreaScope(scope);
489 area = normalizeComplementaryAreaName(scope, area);
490 return {
491 type: "SET_DEFAULT_COMPLEMENTARY_AREA",
492 scope,
493 area
494 };
495 };
496 var enableComplementaryArea = (scope, area) => ({ registry, dispatch: dispatch2 }) => {
497 if (!area) {
498 return;
499 }
500 scope = normalizeComplementaryAreaScope(scope);
501 area = normalizeComplementaryAreaName(scope, area);
502 const isComplementaryAreaVisible = registry.select(import_preferences.store).get(scope, "isComplementaryAreaVisible");
503 if (!isComplementaryAreaVisible) {
504 registry.dispatch(import_preferences.store).set(scope, "isComplementaryAreaVisible", true);
505 }
506 dispatch2({
507 type: "ENABLE_COMPLEMENTARY_AREA",
508 scope,
509 area
510 });
511 };
512 var disableComplementaryArea = (scope) => ({ registry }) => {
513 scope = normalizeComplementaryAreaScope(scope);
514 const isComplementaryAreaVisible = registry.select(import_preferences.store).get(scope, "isComplementaryAreaVisible");
515 if (isComplementaryAreaVisible) {
516 registry.dispatch(import_preferences.store).set(scope, "isComplementaryAreaVisible", false);
517 }
518 };
519 var pinItem = (scope, item) => ({ registry }) => {
520 if (!item) {
521 return;
522 }
523 scope = normalizeComplementaryAreaScope(scope);
524 item = normalizeComplementaryAreaName(scope, item);
525 const pinnedItems = registry.select(import_preferences.store).get(scope, "pinnedItems");
526 if (pinnedItems?.[item] === true) {
527 return;
528 }
529 registry.dispatch(import_preferences.store).set(scope, "pinnedItems", {
530 ...pinnedItems,
531 [item]: true
532 });
533 };
534 var unpinItem = (scope, item) => ({ registry }) => {
535 if (!item) {
536 return;
537 }
538 scope = normalizeComplementaryAreaScope(scope);
539 item = normalizeComplementaryAreaName(scope, item);
540 const pinnedItems = registry.select(import_preferences.store).get(scope, "pinnedItems");
541 registry.dispatch(import_preferences.store).set(scope, "pinnedItems", {
542 ...pinnedItems,
543 [item]: false
544 });
545 };
546 function toggleFeature(scope, featureName) {
547 return function({ registry }) {
548 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).toggleFeature`, {
549 since: "6.0",
550 alternative: `dispatch( 'core/preferences' ).toggle`
551 });
552 registry.dispatch(import_preferences.store).toggle(scope, featureName);
553 };
554 }
555 function setFeatureValue(scope, featureName, value) {
556 return function({ registry }) {
557 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).setFeatureValue`, {
558 since: "6.0",
559 alternative: `dispatch( 'core/preferences' ).set`
560 });
561 registry.dispatch(import_preferences.store).set(scope, featureName, !!value);
562 };
563 }
564 function setFeatureDefaults(scope, defaults) {
565 return function({ registry }) {
566 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).setFeatureDefaults`, {
567 since: "6.0",
568 alternative: `dispatch( 'core/preferences' ).setDefaults`
569 });
570 registry.dispatch(import_preferences.store).setDefaults(scope, defaults);
571 };
572 }
573 function openModal(name2) {
574 return {
575 type: "OPEN_MODAL",
576 name: name2
577 };
578 }
579 function closeModal() {
580 return {
581 type: "CLOSE_MODAL"
582 };
583 }
584
585 // packages/interface/build-module/store/selectors.mjs
586 var selectors_exports = {};
587 __export(selectors_exports, {
588 getActiveComplementaryArea: () => getActiveComplementaryArea,
589 isComplementaryAreaLoading: () => isComplementaryAreaLoading,
590 isFeatureActive: () => isFeatureActive,
591 isItemPinned: () => isItemPinned,
592 isModalActive: () => isModalActive
593 });
594 var import_data2 = __toESM(require_data(), 1);
595 var import_deprecated4 = __toESM(require_deprecated(), 1);
596 var import_preferences2 = __toESM(require_preferences(), 1);
597 var getActiveComplementaryArea = (0, import_data2.createRegistrySelector)(
598 (select) => (state, scope) => {
599 scope = normalizeComplementaryAreaScope(scope);
600 const isComplementaryAreaVisible = select(import_preferences2.store).get(
601 scope,
602 "isComplementaryAreaVisible"
603 );
604 if (isComplementaryAreaVisible === void 0) {
605 return void 0;
606 }
607 if (isComplementaryAreaVisible === false) {
608 return null;
609 }
610 return state?.complementaryAreas?.[scope];
611 }
612 );
613 var isComplementaryAreaLoading = (0, import_data2.createRegistrySelector)(
614 (select) => (state, scope) => {
615 scope = normalizeComplementaryAreaScope(scope);
616 const isVisible = select(import_preferences2.store).get(
617 scope,
618 "isComplementaryAreaVisible"
619 );
620 const identifier = state?.complementaryAreas?.[scope];
621 return isVisible && identifier === void 0;
622 }
623 );
624 var isItemPinned = (0, import_data2.createRegistrySelector)(
625 (select) => (state, scope, item) => {
626 scope = normalizeComplementaryAreaScope(scope);
627 item = normalizeComplementaryAreaName(scope, item);
628 const pinnedItems = select(import_preferences2.store).get(
629 scope,
630 "pinnedItems"
631 );
632 return pinnedItems?.[item] ?? true;
633 }
634 );
635 var isFeatureActive = (0, import_data2.createRegistrySelector)(
636 (select) => (state, scope, featureName) => {
637 (0, import_deprecated4.default)(
638 `select( 'core/interface' ).isFeatureActive( scope, featureName )`,
639 {
640 since: "6.0",
641 alternative: `select( 'core/preferences' ).get( scope, featureName )`
642 }
643 );
644 return !!select(import_preferences2.store).get(scope, featureName);
645 }
646 );
647 function isModalActive(state, modalName) {
648 return state.activeModal === modalName;
649 }
650
651 // packages/interface/build-module/store/reducer.mjs
652 var import_data3 = __toESM(require_data(), 1);
653 function complementaryAreas(state = {}, action) {
654 switch (action.type) {
655 case "SET_DEFAULT_COMPLEMENTARY_AREA": {
656 const { scope, area } = action;
657 if (state[scope]) {
658 return state;
659 }
660 return {
661 ...state,
662 [scope]: area
663 };
664 }
665 case "ENABLE_COMPLEMENTARY_AREA": {
666 const { scope, area } = action;
667 return {
668 ...state,
669 [scope]: area
670 };
671 }
672 }
673 return state;
674 }
675 function activeModal(state = null, action) {
676 switch (action.type) {
677 case "OPEN_MODAL":
678 return action.name;
679 case "CLOSE_MODAL":
680 return null;
681 }
682 return state;
683 }
684 var reducer_default2 = (0, import_data3.combineReducers)({
685 complementaryAreas,
686 activeModal
687 });
688
689 // packages/interface/build-module/store/constants.mjs
690 var STORE_NAME = "core/interface";
691
692 // packages/interface/build-module/store/index.mjs
693 var store = (0, import_data4.createReduxStore)(STORE_NAME, {
694 reducer: reducer_default2,
695 actions: actions_exports,
696 selectors: selectors_exports
697 });
698 (0, import_data4.register)(store);
699
700 // packages/interface/build-module/components/complementary-area-toggle/index.mjs
701 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
702 function roleSupportsCheckedState(role) {
703 return [
704 "checkbox",
705 "option",
706 "radio",
707 "switch",
708 "menuitemcheckbox",
709 "menuitemradio",
710 "treeitem"
711 ].includes(role);
712 }
713 function ComplementaryAreaToggle({
714 as = import_components.Button,
715 scope,
716 identifier: identifierProp,
717 icon: iconProp,
718 selectedIcon,
719 name: name2,
720 shortcut,
721 ...props
722 }) {
723 const ComponentToUse = as;
724 const context = (0, import_plugins.usePluginContext)();
725 const icon = iconProp || context.icon;
726 const identifier = identifierProp || `${context.name}/${name2}`;
727 const isSelected = (0, import_data5.useSelect)(
728 (select) => select(store).getActiveComplementaryArea(scope) === identifier,
729 [identifier, scope]
730 );
731 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data5.useDispatch)(store);
732 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
733 ComponentToUse,
734 {
735 icon: selectedIcon && isSelected ? selectedIcon : icon,
736 "aria-controls": identifier.replace("/", ":"),
737 "aria-checked": roleSupportsCheckedState(props.role) ? isSelected : void 0,
738 onClick: () => {
739 if (isSelected) {
740 disableComplementaryArea2(scope);
741 } else {
742 enableComplementaryArea2(scope, identifier);
743 }
744 },
745 shortcut,
746 ...props
747 }
748 );
749 }
750
751 // packages/interface/build-module/components/complementary-area-header/index.mjs
752 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
753 var ComplementaryAreaHeader = ({
754 children,
755 className,
756 toggleButtonProps
757 }) => {
758 const toggleButton = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ComplementaryAreaToggle, { icon: close_small_default, ...toggleButtonProps });
759 return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
760 "div",
761 {
762 className: clsx_default(
763 "components-panel__header",
764 "interface-complementary-area-header",
765 className
766 ),
767 tabIndex: -1,
768 children: [
769 children,
770 toggleButton
771 ]
772 }
773 );
774 };
775 var complementary_area_header_default = ComplementaryAreaHeader;
776
777 // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs
778 var import_components3 = __toESM(require_components(), 1);
779
780 // packages/interface/build-module/components/action-item/index.mjs
781 var import_components2 = __toESM(require_components(), 1);
782 var import_element = __toESM(require_element(), 1);
783 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
784 var noop = () => {
785 };
786 function ActionItemSlot({
787 name: name2,
788 as: Component2 = import_components2.MenuGroup,
789 fillProps = {},
790 bubblesVirtually,
791 ...props
792 }) {
793 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
794 import_components2.Slot,
795 {
796 name: name2,
797 bubblesVirtually,
798 fillProps,
799 children: (fills) => {
800 if (!import_element.Children.toArray(fills).length) {
801 return null;
802 }
803 const initializedByPlugins = [];
804 import_element.Children.forEach(
805 fills,
806 ({
807 props: { __unstableExplicitMenuItem, __unstableTarget }
808 }) => {
809 if (__unstableTarget && __unstableExplicitMenuItem) {
810 initializedByPlugins.push(__unstableTarget);
811 }
812 }
813 );
814 const children = import_element.Children.map(fills, (child) => {
815 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(
816 child.props.__unstableTarget
817 )) {
818 return null;
819 }
820 return child;
821 });
822 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Component2, { ...props, children });
823 }
824 }
825 );
826 }
827 function ActionItem({ name: name2, as: Component2 = import_components2.Button, onClick, ...props }) {
828 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_components2.Fill, { name: name2, children: ({ onClick: fpOnClick }) => {
829 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
830 Component2,
831 {
832 onClick: onClick || fpOnClick ? (...args) => {
833 (onClick || noop)(...args);
834 (fpOnClick || noop)(...args);
835 } : void 0,
836 ...props
837 }
838 );
839 } });
840 }
841 ActionItem.Slot = ActionItemSlot;
842 var action_item_default = ActionItem;
843
844 // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs
845 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
846 var PluginsMenuItem = ({
847 // Menu item is marked with unstable prop for backward compatibility.
848 // They are removed so they don't leak to DOM elements.
849 // @see https://github.com/WordPress/gutenberg/issues/14457
850 __unstableExplicitMenuItem,
851 __unstableTarget,
852 ...restProps
853 }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_components3.MenuItem, { ...restProps });
854 function ComplementaryAreaMoreMenuItem({
855 scope,
856 target,
857 __unstableExplicitMenuItem,
858 ...props
859 }) {
860 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
861 ComplementaryAreaToggle,
862 {
863 as: (toggleProps) => {
864 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
865 action_item_default,
866 {
867 __unstableExplicitMenuItem,
868 __unstableTarget: `${scope}/${target}`,
869 as: PluginsMenuItem,
870 name: `${scope}/plugin-more-menu`,
871 ...toggleProps
872 }
873 );
874 },
875 role: "menuitemcheckbox",
876 selectedIcon: check_default,
877 name: target,
878 scope,
879 ...props
880 }
881 );
882 }
883
884 // packages/interface/build-module/components/pinned-items/index.mjs
885 var import_components4 = __toESM(require_components(), 1);
886 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
887 function PinnedItems({ scope, ...props }) {
888 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components4.Fill, { name: `PinnedItems/${scope}`, ...props });
889 }
890 function PinnedItemsSlot({ scope, className, ...props }) {
891 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components4.Slot, { name: `PinnedItems/${scope}`, ...props, children: (fills) => fills?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
892 "div",
893 {
894 className: clsx_default(
895 className,
896 "interface-pinned-items"
897 ),
898 children: fills
899 }
900 ) });
901 }
902 PinnedItems.Slot = PinnedItemsSlot;
903 var pinned_items_default = PinnedItems;
904
905 // packages/interface/build-module/components/complementary-area/index.mjs
906 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
907 var ANIMATION_DURATION = 0.3;
908 function ComplementaryAreaSlot({ scope, ...props }) {
909 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.Slot, { name: `ComplementaryArea/${scope}`, ...props });
910 }
911 var SIDEBAR_WIDTH = 280;
912 var variants = {
913 open: { width: SIDEBAR_WIDTH },
914 closed: { width: 0 },
915 mobileOpen: { width: "100vw" }
916 };
917 function ComplementaryAreaFill({
918 activeArea,
919 isActive,
920 scope,
921 children,
922 className,
923 id
924 }) {
925 const disableMotion = (0, import_compose.useReducedMotion)();
926 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
927 const previousActiveArea = (0, import_compose.usePrevious)(activeArea);
928 const previousIsActive = (0, import_compose.usePrevious)(isActive);
929 const [, setState] = (0, import_element2.useState)({});
930 (0, import_element2.useEffect)(() => {
931 setState({});
932 }, [isActive]);
933 const transition = {
934 type: "tween",
935 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION,
936 ease: [0.6, 0, 0.4, 1]
937 };
938 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.Fill, { name: `ComplementaryArea/${scope}`, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.__unstableAnimatePresence, { initial: false, children: (previousIsActive || isActive) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
939 import_components5.__unstableMotion.div,
940 {
941 variants,
942 initial: "closed",
943 animate: isMobileViewport ? "mobileOpen" : "open",
944 exit: "closed",
945 transition,
946 className: "interface-complementary-area__fill",
947 children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
948 "div",
949 {
950 id,
951 className,
952 style: {
953 width: isMobileViewport ? "100vw" : SIDEBAR_WIDTH
954 },
955 children
956 }
957 )
958 }
959 ) }) });
960 }
961 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
962 const previousIsSmallRef = (0, import_element2.useRef)(false);
963 const shouldOpenWhenNotSmallRef = (0, import_element2.useRef)(false);
964 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data6.useDispatch)(store);
965 (0, import_element2.useEffect)(() => {
966 if (isActive && isSmall && !previousIsSmallRef.current) {
967 disableComplementaryArea2(scope);
968 shouldOpenWhenNotSmallRef.current = true;
969 } else if (
970 // If there is a flag indicating the complementary area should be
971 // enabled when we go from small to big window size and we are going
972 // from a small to big window size.
973 shouldOpenWhenNotSmallRef.current && !isSmall && previousIsSmallRef.current
974 ) {
975 shouldOpenWhenNotSmallRef.current = false;
976 enableComplementaryArea2(scope, identifier);
977 } else if (
978 // If the flag is indicating the current complementary should be
979 // reopened but another complementary area becomes active, remove
980 // the flag.
981 shouldOpenWhenNotSmallRef.current && activeArea && activeArea !== identifier
982 ) {
983 shouldOpenWhenNotSmallRef.current = false;
984 }
985 if (isSmall !== previousIsSmallRef.current) {
986 previousIsSmallRef.current = isSmall;
987 }
988 }, [
989 isActive,
990 isSmall,
991 scope,
992 identifier,
993 activeArea,
994 disableComplementaryArea2,
995 enableComplementaryArea2
996 ]);
997 }
998 function ComplementaryArea({
999 children,
1000 className,
1001 closeLabel = (0, import_i18n.__)("Close plugin"),
1002 identifier: identifierProp,
1003 header,
1004 headerClassName,
1005 icon: iconProp,
1006 isPinnable = true,
1007 panelClassName,
1008 scope,
1009 name: name2,
1010 title,
1011 toggleShortcut,
1012 isActiveByDefault
1013 }) {
1014 const context = (0, import_plugins2.usePluginContext)();
1015 const icon = iconProp || context.icon;
1016 const identifier = identifierProp || `${context.name}/${name2}`;
1017 const [isReady, setIsReady] = (0, import_element2.useState)(false);
1018 const {
1019 isLoading,
1020 isActive,
1021 isPinned,
1022 activeArea,
1023 isSmall,
1024 isLarge,
1025 showIconLabels
1026 } = (0, import_data6.useSelect)(
1027 (select) => {
1028 const {
1029 getActiveComplementaryArea: getActiveComplementaryArea2,
1030 isComplementaryAreaLoading: isComplementaryAreaLoading2,
1031 isItemPinned: isItemPinned2
1032 } = select(store);
1033 const { get } = select(import_preferences3.store);
1034 const _activeArea = getActiveComplementaryArea2(scope);
1035 return {
1036 isLoading: isComplementaryAreaLoading2(scope),
1037 isActive: _activeArea === identifier,
1038 isPinned: isItemPinned2(scope, identifier),
1039 activeArea: _activeArea,
1040 isSmall: select(import_viewport.store).isViewportMatch("< medium"),
1041 isLarge: select(import_viewport.store).isViewportMatch("large"),
1042 showIconLabels: get("core", "showIconLabels")
1043 };
1044 },
1045 [identifier, scope]
1046 );
1047 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
1048 useAdjustComplementaryListener(
1049 scope,
1050 identifier,
1051 activeArea,
1052 isActive,
1053 isSmall
1054 );
1055 const {
1056 enableComplementaryArea: enableComplementaryArea2,
1057 disableComplementaryArea: disableComplementaryArea2,
1058 pinItem: pinItem2,
1059 unpinItem: unpinItem2
1060 } = (0, import_data6.useDispatch)(store);
1061 (0, import_element2.useEffect)(() => {
1062 if (isActiveByDefault && activeArea === void 0 && !isSmall) {
1063 enableComplementaryArea2(scope, identifier);
1064 } else if (activeArea === void 0 && isSmall) {
1065 disableComplementaryArea2(scope, identifier);
1066 }
1067 setIsReady(true);
1068 }, [
1069 activeArea,
1070 isActiveByDefault,
1071 scope,
1072 identifier,
1073 isSmall,
1074 enableComplementaryArea2,
1075 disableComplementaryArea2
1076 ]);
1077 if (!isReady) {
1078 return;
1079 }
1080 return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
1081 isPinnable && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(pinned_items_default, { scope, children: isPinned && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1082 ComplementaryAreaToggle,
1083 {
1084 scope,
1085 identifier,
1086 isPressed: isActive && (!showIconLabels || isLarge),
1087 "aria-expanded": isActive,
1088 "aria-disabled": isLoading,
1089 label: title,
1090 icon: showIconLabels ? check_default : icon,
1091 showTooltip: !showIconLabels,
1092 variant: showIconLabels ? "tertiary" : void 0,
1093 size: "compact",
1094 shortcut: toggleShortcut
1095 }
1096 ) }),
1097 name2 && isPinnable && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1098 ComplementaryAreaMoreMenuItem,
1099 {
1100 target: name2,
1101 scope,
1102 icon,
1103 identifier,
1104 children: title
1105 }
1106 ),
1107 /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1108 ComplementaryAreaFill,
1109 {
1110 activeArea,
1111 isActive,
1112 className: clsx_default("interface-complementary-area", className),
1113 scope,
1114 id: identifier.replace("/", ":"),
1115 children: [
1116 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1117 complementary_area_header_default,
1118 {
1119 className: headerClassName,
1120 closeLabel,
1121 onClose: () => disableComplementaryArea2(scope),
1122 toggleButtonProps: {
1123 label: closeLabel,
1124 size: "compact",
1125 shortcut: toggleShortcut,
1126 scope,
1127 identifier
1128 },
1129 children: header || /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
1130 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h2", { className: "interface-complementary-area-header__title", children: title }),
1131 isPinnable && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1132 import_components5.Button,
1133 {
1134 className: "interface-complementary-area__pin-unpin-item",
1135 icon: isPinned ? star_filled_default : star_empty_default,
1136 label: isPinned ? (0, import_i18n.__)("Unpin from toolbar") : (0, import_i18n.__)("Pin to toolbar"),
1137 onClick: () => (isPinned ? unpinItem2 : pinItem2)(
1138 scope,
1139 identifier
1140 ),
1141 isPressed: isPinned,
1142 "aria-expanded": isPinned,
1143 size: "compact"
1144 }
1145 )
1146 ] })
1147 }
1148 ),
1149 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.Panel, { className: panelClassName, children })
1150 ]
1151 }
1152 )
1153 ] });
1154 }
1155 ComplementaryArea.Slot = ComplementaryAreaSlot;
1156 var complementary_area_default = ComplementaryArea;
1157
1158 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1159 var React = __toESM(require_react(), 1);
1160 var UNINITIALIZED = {};
1161 function useRefWithInit(init, initArg) {
1162 const ref = React.useRef(UNINITIALIZED);
1163 if (ref.current === UNINITIALIZED) {
1164 ref.current = init(initArg);
1165 }
1166 return ref;
1167 }
1168
1169 // node_modules/@base-ui/utils/esm/warn.js
1170 var set;
1171 if (true) {
1172 set = /* @__PURE__ */ new Set();
1173 }
1174 function warn(...messages) {
1175 if (true) {
1176 const messageKey = messages.join(" ");
1177 if (!set.has(messageKey)) {
1178 set.add(messageKey);
1179 console.warn(`Base UI: ${messageKey}`);
1180 }
1181 }
1182 }
1183
1184 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1185 var React4 = __toESM(require_react(), 1);
1186
1187 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1188 function useMergedRefs(a, b, c, d) {
1189 const forkRef = useRefWithInit(createForkRef).current;
1190 if (didChange(forkRef, a, b, c, d)) {
1191 update(forkRef, [a, b, c, d]);
1192 }
1193 return forkRef.callback;
1194 }
1195 function useMergedRefsN(refs) {
1196 const forkRef = useRefWithInit(createForkRef).current;
1197 if (didChangeN(forkRef, refs)) {
1198 update(forkRef, refs);
1199 }
1200 return forkRef.callback;
1201 }
1202 function createForkRef() {
1203 return {
1204 callback: null,
1205 cleanup: null,
1206 refs: []
1207 };
1208 }
1209 function didChange(forkRef, a, b, c, d) {
1210 return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
1211 }
1212 function didChangeN(forkRef, newRefs) {
1213 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1214 }
1215 function update(forkRef, refs) {
1216 forkRef.refs = refs;
1217 if (refs.every((ref) => ref == null)) {
1218 forkRef.callback = null;
1219 return;
1220 }
1221 forkRef.callback = (instance) => {
1222 if (forkRef.cleanup) {
1223 forkRef.cleanup();
1224 forkRef.cleanup = null;
1225 }
1226 if (instance != null) {
1227 const cleanupCallbacks = Array(refs.length).fill(null);
1228 for (let i = 0; i < refs.length; i += 1) {
1229 const ref = refs[i];
1230 if (ref == null) {
1231 continue;
1232 }
1233 switch (typeof ref) {
1234 case "function": {
1235 const refCleanup = ref(instance);
1236 if (typeof refCleanup === "function") {
1237 cleanupCallbacks[i] = refCleanup;
1238 }
1239 break;
1240 }
1241 case "object": {
1242 ref.current = instance;
1243 break;
1244 }
1245 default:
1246 }
1247 }
1248 forkRef.cleanup = () => {
1249 for (let i = 0; i < refs.length; i += 1) {
1250 const ref = refs[i];
1251 if (ref == null) {
1252 continue;
1253 }
1254 switch (typeof ref) {
1255 case "function": {
1256 const cleanupCallback = cleanupCallbacks[i];
1257 if (typeof cleanupCallback === "function") {
1258 cleanupCallback();
1259 } else {
1260 ref(null);
1261 }
1262 break;
1263 }
1264 case "object": {
1265 ref.current = null;
1266 break;
1267 }
1268 default:
1269 }
1270 }
1271 };
1272 }
1273 };
1274 }
1275
1276 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1277 var React3 = __toESM(require_react(), 1);
1278
1279 // node_modules/@base-ui/utils/esm/reactVersion.js
1280 var React2 = __toESM(require_react(), 1);
1281 var majorVersion = parseInt(React2.version, 10);
1282 function isReactVersionAtLeast(reactVersionToCheck) {
1283 return majorVersion >= reactVersionToCheck;
1284 }
1285
1286 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1287 function getReactElementRef(element) {
1288 if (!/* @__PURE__ */ React3.isValidElement(element)) {
1289 return null;
1290 }
1291 const reactElement = element;
1292 const propsWithRef = reactElement.props;
1293 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1294 }
1295
1296 // node_modules/@base-ui/utils/esm/mergeObjects.js
1297 function mergeObjects(a, b) {
1298 if (a && !b) {
1299 return a;
1300 }
1301 if (!a && b) {
1302 return b;
1303 }
1304 if (a || b) {
1305 return {
1306 ...a,
1307 ...b
1308 };
1309 }
1310 return void 0;
1311 }
1312
1313 // node_modules/@base-ui/utils/esm/empty.js
1314 var EMPTY_ARRAY = Object.freeze([]);
1315 var EMPTY_OBJECT = Object.freeze({});
1316
1317 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1318 function getStateAttributesProps(state, customMapping) {
1319 const props = {};
1320 for (const key in state) {
1321 const value = state[key];
1322 if (customMapping?.hasOwnProperty(key)) {
1323 const customProps = customMapping[key](value);
1324 if (customProps != null) {
1325 Object.assign(props, customProps);
1326 }
1327 continue;
1328 }
1329 if (value === true) {
1330 props[`data-${key.toLowerCase()}`] = "";
1331 } else if (value) {
1332 props[`data-${key.toLowerCase()}`] = value.toString();
1333 }
1334 }
1335 return props;
1336 }
1337
1338 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1339 function resolveClassName(className, state) {
1340 return typeof className === "function" ? className(state) : className;
1341 }
1342
1343 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1344 function resolveStyle(style, state) {
1345 return typeof style === "function" ? style(state) : style;
1346 }
1347
1348 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1349 var EMPTY_PROPS = {};
1350 function mergeProps(a, b, c, d, e) {
1351 if (!c && !d && !e && !a) {
1352 return createInitialMergedProps(b);
1353 }
1354 let merged = createInitialMergedProps(a);
1355 if (b) {
1356 merged = mergeInto(merged, b);
1357 }
1358 if (c) {
1359 merged = mergeInto(merged, c);
1360 }
1361 if (d) {
1362 merged = mergeInto(merged, d);
1363 }
1364 if (e) {
1365 merged = mergeInto(merged, e);
1366 }
1367 return merged;
1368 }
1369 function mergePropsN(props) {
1370 if (props.length === 0) {
1371 return EMPTY_PROPS;
1372 }
1373 if (props.length === 1) {
1374 return createInitialMergedProps(props[0]);
1375 }
1376 let merged = createInitialMergedProps(props[0]);
1377 for (let i = 1; i < props.length; i += 1) {
1378 merged = mergeInto(merged, props[i]);
1379 }
1380 return merged;
1381 }
1382 function createInitialMergedProps(inputProps) {
1383 if (isPropsGetter(inputProps)) {
1384 return {
1385 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1386 };
1387 }
1388 return copyInitialProps(inputProps);
1389 }
1390 function mergeInto(merged, inputProps) {
1391 if (isPropsGetter(inputProps)) {
1392 return resolvePropsGetter(inputProps, merged);
1393 }
1394 return mutablyMergeInto(merged, inputProps);
1395 }
1396 function copyInitialProps(inputProps) {
1397 const copiedProps = {
1398 ...inputProps
1399 };
1400 for (const propName in copiedProps) {
1401 const propValue = copiedProps[propName];
1402 if (isEventHandler(propName, propValue)) {
1403 copiedProps[propName] = wrapEventHandler(propValue);
1404 }
1405 }
1406 return copiedProps;
1407 }
1408 function mutablyMergeInto(mergedProps, externalProps) {
1409 if (!externalProps) {
1410 return mergedProps;
1411 }
1412 for (const propName in externalProps) {
1413 const externalPropValue = externalProps[propName];
1414 switch (propName) {
1415 case "style": {
1416 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1417 break;
1418 }
1419 case "className": {
1420 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1421 break;
1422 }
1423 default: {
1424 if (isEventHandler(propName, externalPropValue)) {
1425 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1426 } else {
1427 mergedProps[propName] = externalPropValue;
1428 }
1429 }
1430 }
1431 }
1432 return mergedProps;
1433 }
1434 function isEventHandler(key, value) {
1435 const code0 = key.charCodeAt(0);
1436 const code1 = key.charCodeAt(1);
1437 const code2 = key.charCodeAt(2);
1438 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1439 }
1440 function isPropsGetter(inputProps) {
1441 return typeof inputProps === "function";
1442 }
1443 function resolvePropsGetter(inputProps, previousProps) {
1444 if (isPropsGetter(inputProps)) {
1445 return inputProps(previousProps);
1446 }
1447 return inputProps ?? EMPTY_PROPS;
1448 }
1449 function mergeEventHandlers(ourHandler, theirHandler) {
1450 if (!theirHandler) {
1451 return ourHandler;
1452 }
1453 if (!ourHandler) {
1454 return wrapEventHandler(theirHandler);
1455 }
1456 return (...args) => {
1457 const event = args[0];
1458 if (isSyntheticEvent(event)) {
1459 const baseUIEvent = event;
1460 makeEventPreventable(baseUIEvent);
1461 const result2 = theirHandler(...args);
1462 if (!baseUIEvent.baseUIHandlerPrevented) {
1463 ourHandler?.(...args);
1464 }
1465 return result2;
1466 }
1467 const result = theirHandler(...args);
1468 ourHandler?.(...args);
1469 return result;
1470 };
1471 }
1472 function wrapEventHandler(handler) {
1473 if (!handler) {
1474 return handler;
1475 }
1476 return (...args) => {
1477 const event = args[0];
1478 if (isSyntheticEvent(event)) {
1479 makeEventPreventable(event);
1480 }
1481 return handler(...args);
1482 };
1483 }
1484 function makeEventPreventable(event) {
1485 event.preventBaseUIHandler = () => {
1486 event.baseUIHandlerPrevented = true;
1487 };
1488 return event;
1489 }
1490 function mergeClassNames(ourClassName, theirClassName) {
1491 if (theirClassName) {
1492 if (ourClassName) {
1493 return theirClassName + " " + ourClassName;
1494 }
1495 return theirClassName;
1496 }
1497 return ourClassName;
1498 }
1499 function isSyntheticEvent(event) {
1500 return event != null && typeof event === "object" && "nativeEvent" in event;
1501 }
1502
1503 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1504 var import_react = __toESM(require_react(), 1);
1505 function useRenderElement(element, componentProps, params = {}) {
1506 const renderProp = componentProps.render;
1507 const outProps = useRenderElementProps(componentProps, params);
1508 if (params.enabled === false) {
1509 return null;
1510 }
1511 const state = params.state ?? EMPTY_OBJECT;
1512 return evaluateRenderProp(element, renderProp, outProps, state);
1513 }
1514 function useRenderElementProps(componentProps, params = {}) {
1515 const {
1516 className: classNameProp,
1517 style: styleProp,
1518 render: renderProp
1519 } = componentProps;
1520 const {
1521 state = EMPTY_OBJECT,
1522 ref,
1523 props,
1524 stateAttributesMapping,
1525 enabled = true
1526 } = params;
1527 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1528 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1529 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
1530 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1531 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1532 if (typeof document !== "undefined") {
1533 if (!enabled) {
1534 useMergedRefs(null, null);
1535 } else if (Array.isArray(ref)) {
1536 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1537 } else {
1538 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1539 }
1540 }
1541 if (!enabled) {
1542 return EMPTY_OBJECT;
1543 }
1544 if (className !== void 0) {
1545 outProps.className = mergeClassNames(outProps.className, className);
1546 }
1547 if (style !== void 0) {
1548 outProps.style = mergeObjects(outProps.style, style);
1549 }
1550 return outProps;
1551 }
1552 function resolveRenderFunctionProps(props) {
1553 if (Array.isArray(props)) {
1554 return mergePropsN(props);
1555 }
1556 return mergeProps(void 0, props);
1557 }
1558 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1559 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1560 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1561 function evaluateRenderProp(element, render, props, state) {
1562 if (render) {
1563 if (typeof render === "function") {
1564 if (true) {
1565 warnIfRenderPropLooksLikeComponent(render);
1566 }
1567 return render(props, state);
1568 }
1569 const mergedProps = mergeProps(props, render.props);
1570 mergedProps.ref = props.ref;
1571 let newElement = render;
1572 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1573 const children = React4.Children.toArray(render);
1574 newElement = children[0];
1575 }
1576 if (true) {
1577 if (!/* @__PURE__ */ React4.isValidElement(newElement)) {
1578 throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
1579 }
1580 }
1581 return /* @__PURE__ */ React4.cloneElement(newElement, mergedProps);
1582 }
1583 if (element) {
1584 if (typeof element === "string") {
1585 return renderTag(element, props);
1586 }
1587 }
1588 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1589 }
1590 function warnIfRenderPropLooksLikeComponent(renderFn) {
1591 const functionName = renderFn.name;
1592 if (functionName.length === 0) {
1593 return;
1594 }
1595 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1596 return;
1597 }
1598 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1599 return;
1600 }
1601 warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
1602 }
1603 function renderTag(Tag, props) {
1604 if (Tag === "button") {
1605 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1606 type: "button",
1607 ...props,
1608 key: props.key
1609 });
1610 }
1611 if (Tag === "img") {
1612 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1613 alt: "",
1614 ...props,
1615 key: props.key
1616 });
1617 }
1618 return /* @__PURE__ */ React4.createElement(Tag, props);
1619 }
1620
1621 // node_modules/@base-ui/react/esm/use-render/useRender.js
1622 function useRender(params) {
1623 return useRenderElement(params.defaultTagName ?? "div", params, params);
1624 }
1625
1626 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
1627 var import_element3 = __toESM(require_element(), 1);
1628 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
1629 function getRuntime() {
1630 const globalScope = globalThis;
1631 if (globalScope.__wpStyleRuntime) {
1632 return globalScope.__wpStyleRuntime;
1633 }
1634 globalScope.__wpStyleRuntime = {
1635 documents: /* @__PURE__ */ new Map(),
1636 styles: /* @__PURE__ */ new Map(),
1637 injectedStyles: /* @__PURE__ */ new WeakMap()
1638 };
1639 if (typeof document !== "undefined") {
1640 registerDocument(document);
1641 }
1642 return globalScope.__wpStyleRuntime;
1643 }
1644 function documentContainsStyleHash(targetDocument, hash) {
1645 if (!targetDocument.head) {
1646 return false;
1647 }
1648 for (const style of targetDocument.head.querySelectorAll(
1649 `style[${STYLE_HASH_ATTRIBUTE}]`
1650 )) {
1651 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
1652 return true;
1653 }
1654 }
1655 return false;
1656 }
1657 function injectStyle(targetDocument, hash, css) {
1658 if (!targetDocument.head) {
1659 return;
1660 }
1661 const runtime = getRuntime();
1662 let injectedStyles = runtime.injectedStyles.get(targetDocument);
1663 if (!injectedStyles) {
1664 injectedStyles = /* @__PURE__ */ new Set();
1665 runtime.injectedStyles.set(targetDocument, injectedStyles);
1666 }
1667 if (injectedStyles.has(hash)) {
1668 return;
1669 }
1670 if (documentContainsStyleHash(targetDocument, hash)) {
1671 injectedStyles.add(hash);
1672 return;
1673 }
1674 const style = targetDocument.createElement("style");
1675 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
1676 style.appendChild(targetDocument.createTextNode(css));
1677 targetDocument.head.appendChild(style);
1678 injectedStyles.add(hash);
1679 }
1680 function registerDocument(targetDocument) {
1681 const runtime = getRuntime();
1682 runtime.documents.set(
1683 targetDocument,
1684 (runtime.documents.get(targetDocument) ?? 0) + 1
1685 );
1686 for (const [hash, css] of runtime.styles) {
1687 injectStyle(targetDocument, hash, css);
1688 }
1689 return () => {
1690 const count = runtime.documents.get(targetDocument);
1691 if (count === void 0) {
1692 return;
1693 }
1694 if (count <= 1) {
1695 runtime.documents.delete(targetDocument);
1696 return;
1697 }
1698 runtime.documents.set(targetDocument, count - 1);
1699 };
1700 }
1701 function registerStyle(hash, css) {
1702 const runtime = getRuntime();
1703 runtime.styles.set(hash, css);
1704 for (const targetDocument of runtime.documents.keys()) {
1705 injectStyle(targetDocument, hash, css);
1706 }
1707 }
1708 if (typeof process === "undefined" || true) {
1709 registerStyle("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}}");
1710 }
1711 var style_default = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
1712 var VisuallyHidden = (0, import_element3.forwardRef)(
1713 function VisuallyHidden2({ render, ...restProps }, ref) {
1714 const element = useRender({
1715 render,
1716 ref,
1717 props: mergeProps(
1718 { className: style_default["visually-hidden"] },
1719 restProps,
1720 {
1721 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
1722 "data-visually-hidden": ""
1723 }
1724 )
1725 });
1726 return element;
1727 }
1728 );
1729
1730 // packages/admin-ui/build-module/navigable-region/index.mjs
1731 var import_element4 = __toESM(require_element(), 1);
1732 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1733 var NavigableRegion = (0, import_element4.forwardRef)(
1734 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
1735 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1736 Tag,
1737 {
1738 ref,
1739 className: clsx_default("admin-ui-navigable-region", className),
1740 "aria-label": ariaLabel,
1741 role: "region",
1742 tabIndex: "-1",
1743 ...props,
1744 children
1745 }
1746 );
1747 }
1748 );
1749 NavigableRegion.displayName = "NavigableRegion";
1750 var navigable_region_default = NavigableRegion;
1751
1752 // packages/interface/build-module/components/interface-skeleton/index.mjs
1753 var import_element5 = __toESM(require_element(), 1);
1754 var import_components6 = __toESM(require_components(), 1);
1755 var import_i18n2 = __toESM(require_i18n(), 1);
1756 var import_compose2 = __toESM(require_compose(), 1);
1757 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1758 var ANIMATION_DURATION2 = 0.25;
1759 var commonTransition = {
1760 type: "tween",
1761 duration: ANIMATION_DURATION2,
1762 ease: [0.6, 0, 0.4, 1]
1763 };
1764 function useHTMLClass(className) {
1765 (0, import_element5.useEffect)(() => {
1766 const element = document && document.querySelector(`html:not(.${className})`);
1767 if (!element) {
1768 return;
1769 }
1770 element.classList.toggle(className);
1771 return () => {
1772 element.classList.toggle(className);
1773 };
1774 }, [className]);
1775 }
1776 var headerVariants = {
1777 hidden: { opacity: 1, marginTop: -60 },
1778 visible: { opacity: 1, marginTop: 0 },
1779 distractionFreeHover: {
1780 opacity: 1,
1781 marginTop: 0,
1782 transition: {
1783 ...commonTransition,
1784 delay: 0.2,
1785 delayChildren: 0.2
1786 }
1787 },
1788 distractionFreeHidden: {
1789 opacity: 0,
1790 marginTop: -60
1791 },
1792 distractionFreeDisabled: {
1793 opacity: 0,
1794 marginTop: 0,
1795 transition: {
1796 ...commonTransition,
1797 delay: 0.8,
1798 delayChildren: 0.8
1799 }
1800 }
1801 };
1802 function InterfaceSkeleton({
1803 isDistractionFree,
1804 footer,
1805 header,
1806 editorNotices,
1807 sidebar,
1808 secondarySidebar,
1809 content,
1810 actions,
1811 labels,
1812 className
1813 }, ref) {
1814 const [secondarySidebarResizeListener, secondarySidebarSize] = (0, import_compose2.useResizeObserver)();
1815 const isMobileViewport = (0, import_compose2.useViewportMatch)("medium", "<");
1816 const disableMotion = (0, import_compose2.useReducedMotion)();
1817 const defaultTransition = {
1818 type: "tween",
1819 duration: disableMotion ? 0 : ANIMATION_DURATION2,
1820 ease: [0.6, 0, 0.4, 1]
1821 };
1822 useHTMLClass("interface-interface-skeleton__html-container");
1823 const defaultLabels = {
1824 /* translators: accessibility text for the top bar landmark region. */
1825 header: (0, import_i18n2._x)("Header", "header landmark area"),
1826 /* translators: accessibility text for the content landmark region. */
1827 body: (0, import_i18n2.__)("Content"),
1828 /* translators: accessibility text for the secondary sidebar landmark region. */
1829 secondarySidebar: (0, import_i18n2.__)("Block Library"),
1830 /* translators: accessibility text for the settings landmark region. */
1831 sidebar: (0, import_i18n2._x)("Settings", "settings landmark area"),
1832 /* translators: accessibility text for the publish landmark region. */
1833 actions: (0, import_i18n2.__)("Publish"),
1834 /* translators: accessibility text for the footer landmark region. */
1835 footer: (0, import_i18n2.__)("Footer")
1836 };
1837 const mergedLabels = { ...defaultLabels, ...labels };
1838 return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1839 "div",
1840 {
1841 ref,
1842 className: clsx_default(
1843 className,
1844 "interface-interface-skeleton",
1845 !!footer && "has-footer"
1846 ),
1847 children: [
1848 /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "interface-interface-skeleton__editor", children: [
1849 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components6.__unstableAnimatePresence, { initial: false, children: !!header && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1850 navigable_region_default,
1851 {
1852 as: import_components6.__unstableMotion.div,
1853 className: "interface-interface-skeleton__header",
1854 ariaLabel: mergedLabels.header,
1855 initial: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden",
1856 whileHover: isDistractionFree && !isMobileViewport ? "distractionFreeHover" : "visible",
1857 animate: isDistractionFree && !isMobileViewport ? "distractionFreeDisabled" : "visible",
1858 exit: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden",
1859 variants: headerVariants,
1860 transition: defaultTransition,
1861 children: header
1862 }
1863 ) }),
1864 isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "interface-interface-skeleton__header", children: editorNotices }),
1865 /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "interface-interface-skeleton__body", children: [
1866 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components6.__unstableAnimatePresence, { initial: false, children: !!secondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1867 navigable_region_default,
1868 {
1869 className: "interface-interface-skeleton__secondary-sidebar",
1870 ariaLabel: mergedLabels.secondarySidebar,
1871 as: import_components6.__unstableMotion.div,
1872 initial: "closed",
1873 animate: "open",
1874 exit: "closed",
1875 variants: {
1876 open: { width: secondarySidebarSize.width },
1877 closed: { width: 0 }
1878 },
1879 transition: defaultTransition,
1880 children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1881 import_components6.__unstableMotion.div,
1882 {
1883 style: {
1884 position: "absolute",
1885 width: isMobileViewport ? "100vw" : "fit-content",
1886 height: "100%",
1887 left: 0
1888 },
1889 variants: {
1890 open: { x: 0 },
1891 closed: { x: "-100%" }
1892 },
1893 transition: defaultTransition,
1894 children: [
1895 secondarySidebarResizeListener,
1896 secondarySidebar
1897 ]
1898 }
1899 )
1900 }
1901 ) }),
1902 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1903 navigable_region_default,
1904 {
1905 className: "interface-interface-skeleton__content",
1906 ariaLabel: mergedLabels.body,
1907 children: content
1908 }
1909 ),
1910 !!sidebar && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1911 navigable_region_default,
1912 {
1913 className: "interface-interface-skeleton__sidebar",
1914 ariaLabel: mergedLabels.sidebar,
1915 children: sidebar
1916 }
1917 ),
1918 !!actions && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1919 navigable_region_default,
1920 {
1921 className: "interface-interface-skeleton__actions",
1922 ariaLabel: mergedLabels.actions,
1923 children: actions
1924 }
1925 )
1926 ] })
1927 ] }),
1928 !!footer && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1929 navigable_region_default,
1930 {
1931 className: "interface-interface-skeleton__footer",
1932 ariaLabel: mergedLabels.footer,
1933 children: footer
1934 }
1935 )
1936 ]
1937 }
1938 );
1939 }
1940 var interface_skeleton_default = (0, import_element5.forwardRef)(InterfaceSkeleton);
1941
1942 // packages/edit-widgets/build-module/store/actions.mjs
1943 var import_widgets2 = __toESM(require_widgets(), 1);
1944 var import_core_data = __toESM(require_core_data(), 1);
1945 var import_block_editor = __toESM(require_block_editor(), 1);
1946
1947 // packages/edit-widgets/build-module/store/transformers.mjs
1948 var import_blocks = __toESM(require_blocks(), 1);
1949 var import_widgets = __toESM(require_widgets(), 1);
1950 function transformWidgetToBlock(widget) {
1951 if (widget.id_base === "block") {
1952 const parsedBlocks = (0, import_blocks.parse)(widget.instance.raw.content, {
1953 __unstableSkipAutop: true
1954 });
1955 if (!parsedBlocks.length) {
1956 return (0, import_widgets.addWidgetIdToBlock)(
1957 (0, import_blocks.createBlock)("core/paragraph", {}, []),
1958 widget.id
1959 );
1960 }
1961 return (0, import_widgets.addWidgetIdToBlock)(parsedBlocks[0], widget.id);
1962 }
1963 let attributes;
1964 if (widget._embedded.about[0].is_multi) {
1965 attributes = {
1966 idBase: widget.id_base,
1967 instance: widget.instance
1968 };
1969 } else {
1970 attributes = {
1971 id: widget.id
1972 };
1973 }
1974 return (0, import_widgets.addWidgetIdToBlock)(
1975 (0, import_blocks.createBlock)("core/legacy-widget", attributes, []),
1976 widget.id
1977 );
1978 }
1979 function transformBlockToWidget(block, relatedWidget = {}) {
1980 let widget;
1981 const isValidLegacyWidgetBlock = block.name === "core/legacy-widget" && (block.attributes.id || block.attributes.instance);
1982 if (isValidLegacyWidgetBlock) {
1983 widget = {
1984 ...relatedWidget,
1985 id: block.attributes.id ?? relatedWidget.id,
1986 id_base: block.attributes.idBase ?? relatedWidget.id_base,
1987 instance: block.attributes.instance ?? relatedWidget.instance
1988 };
1989 } else {
1990 widget = {
1991 ...relatedWidget,
1992 id_base: "block",
1993 instance: {
1994 raw: {
1995 content: (0, import_blocks.serialize)(block)
1996 }
1997 }
1998 };
1999 }
2000 delete widget.rendered;
2001 delete widget.rendered_form;
2002 return widget;
2003 }
2004
2005 // packages/edit-widgets/build-module/store/utils.mjs
2006 var KIND = "root";
2007 var WIDGET_AREA_ENTITY_TYPE = "sidebar";
2008 var POST_TYPE = "postType";
2009 var buildWidgetAreaPostId = (widgetAreaId) => `widget-area-${widgetAreaId}`;
2010 var buildWidgetAreasPostId = () => `widget-areas`;
2011 function buildWidgetAreasQuery() {
2012 return {
2013 per_page: -1
2014 };
2015 }
2016 function buildWidgetsQuery() {
2017 return {
2018 per_page: -1,
2019 _embed: "about"
2020 };
2021 }
2022 var createStubPost = (id, blocks) => ({
2023 id,
2024 slug: id,
2025 status: "draft",
2026 type: "page",
2027 blocks,
2028 meta: {
2029 widgetAreaId: id
2030 }
2031 });
2032
2033 // packages/edit-widgets/build-module/store/constants.mjs
2034 var STORE_NAME2 = "core/edit-widgets";
2035
2036 // packages/edit-widgets/build-module/store/actions.mjs
2037 var persistStubPost = (id, blocks) => ({ registry }) => {
2038 const stubPost = createStubPost(id, blocks);
2039 registry.dispatch(import_core_data.store).receiveEntityRecords(
2040 KIND,
2041 POST_TYPE,
2042 stubPost,
2043 { id: stubPost.id },
2044 false
2045 );
2046 return stubPost;
2047 };
2048 var saveEditedWidgetAreas = () => async ({ select, dispatch: dispatch2, registry }) => {
2049 const editedWidgetAreas = select.getEditedWidgetAreas();
2050 if (!editedWidgetAreas?.length) {
2051 return;
2052 }
2053 try {
2054 await dispatch2.saveWidgetAreas(editedWidgetAreas);
2055 registry.dispatch(import_notices.store).createSuccessNotice((0, import_i18n3.__)("Widgets saved."), {
2056 type: "snackbar"
2057 });
2058 } catch (e) {
2059 registry.dispatch(import_notices.store).createErrorNotice(
2060 /* translators: %s: The error message. */
2061 (0, import_i18n3.sprintf)((0, import_i18n3.__)("There was an error. %s"), e.message),
2062 {
2063 type: "snackbar"
2064 }
2065 );
2066 }
2067 };
2068 var saveWidgetAreas = (widgetAreas) => async ({ dispatch: dispatch2, registry }) => {
2069 try {
2070 for (const widgetArea of widgetAreas) {
2071 await dispatch2.saveWidgetArea(widgetArea.id);
2072 }
2073 } finally {
2074 await registry.dispatch(import_core_data.store).finishResolution(
2075 "getEntityRecord",
2076 KIND,
2077 WIDGET_AREA_ENTITY_TYPE,
2078 buildWidgetAreasQuery()
2079 );
2080 }
2081 };
2082 var saveWidgetArea = (widgetAreaId) => async ({ dispatch: dispatch2, select, registry }) => {
2083 const widgets = select.getWidgets();
2084 const post = registry.select(import_core_data.store).getEditedEntityRecord(
2085 KIND,
2086 POST_TYPE,
2087 buildWidgetAreaPostId(widgetAreaId)
2088 );
2089 const areaWidgets = Object.values(widgets).filter(
2090 ({ sidebar }) => sidebar === widgetAreaId
2091 );
2092 const usedReferenceWidgets = [];
2093 const widgetsBlocks = post.blocks.filter((block) => {
2094 const { id } = block.attributes;
2095 if (block.name === "core/legacy-widget" && id) {
2096 if (usedReferenceWidgets.includes(id)) {
2097 return false;
2098 }
2099 usedReferenceWidgets.push(id);
2100 }
2101 return true;
2102 });
2103 const deletedWidgets = [];
2104 for (const widget of areaWidgets) {
2105 const widgetsNewArea = select.getWidgetAreaForWidgetId(widget.id);
2106 if (!widgetsNewArea) {
2107 deletedWidgets.push(widget);
2108 }
2109 }
2110 const batchMeta = [];
2111 const batchTasks = [];
2112 const sidebarWidgetsIds = [];
2113 for (let i = 0; i < widgetsBlocks.length; i++) {
2114 const block = widgetsBlocks[i];
2115 const widgetId = (0, import_widgets2.getWidgetIdFromBlock)(block);
2116 const oldWidget = widgets[widgetId];
2117 const widget = transformBlockToWidget(block, oldWidget);
2118 sidebarWidgetsIds.push(widgetId);
2119 if (oldWidget) {
2120 registry.dispatch(import_core_data.store).editEntityRecord(
2121 "root",
2122 "widget",
2123 widgetId,
2124 {
2125 ...widget,
2126 sidebar: widgetAreaId
2127 },
2128 { undoIgnore: true }
2129 );
2130 const hasEdits = registry.select(import_core_data.store).hasEditsForEntityRecord("root", "widget", widgetId);
2131 if (!hasEdits) {
2132 continue;
2133 }
2134 batchTasks.push(
2135 ({ saveEditedEntityRecord }) => saveEditedEntityRecord("root", "widget", widgetId)
2136 );
2137 } else {
2138 batchTasks.push(
2139 ({ saveEntityRecord }) => saveEntityRecord("root", "widget", {
2140 ...widget,
2141 sidebar: widgetAreaId
2142 })
2143 );
2144 }
2145 batchMeta.push({
2146 block,
2147 position: i,
2148 clientId: block.clientId
2149 });
2150 }
2151 for (const widget of deletedWidgets) {
2152 batchTasks.push(
2153 ({ deleteEntityRecord }) => deleteEntityRecord("root", "widget", widget.id, {
2154 force: true
2155 })
2156 );
2157 }
2158 const records = await registry.dispatch(import_core_data.store).__experimentalBatch(batchTasks);
2159 const preservedRecords = records.filter(
2160 (record) => !record.hasOwnProperty("deleted")
2161 );
2162 const failedWidgetNames = [];
2163 for (let i = 0; i < preservedRecords.length; i++) {
2164 const widget = preservedRecords[i];
2165 const { block, position } = batchMeta[i];
2166 post.blocks[position].attributes.__internalWidgetId = widget.id;
2167 const error = registry.select(import_core_data.store).getLastEntitySaveError("root", "widget", widget.id);
2168 if (error) {
2169 failedWidgetNames.push(block.attributes?.name || block?.name);
2170 }
2171 if (!sidebarWidgetsIds[position]) {
2172 sidebarWidgetsIds[position] = widget.id;
2173 }
2174 }
2175 if (failedWidgetNames.length) {
2176 throw new Error(
2177 (0, import_i18n3.sprintf)(
2178 /* translators: %s: List of widget names */
2179 (0, import_i18n3.__)("Could not save the following widgets: %s."),
2180 failedWidgetNames.join(", ")
2181 )
2182 );
2183 }
2184 registry.dispatch(import_core_data.store).editEntityRecord(
2185 KIND,
2186 WIDGET_AREA_ENTITY_TYPE,
2187 widgetAreaId,
2188 {
2189 widgets: sidebarWidgetsIds
2190 },
2191 { undoIgnore: true }
2192 );
2193 dispatch2(trySaveWidgetArea(widgetAreaId));
2194 registry.dispatch(import_core_data.store).receiveEntityRecords(KIND, POST_TYPE, post, void 0);
2195 };
2196 var trySaveWidgetArea = (widgetAreaId) => ({ registry }) => {
2197 registry.dispatch(import_core_data.store).saveEditedEntityRecord(
2198 KIND,
2199 WIDGET_AREA_ENTITY_TYPE,
2200 widgetAreaId,
2201 {
2202 throwOnError: true
2203 }
2204 );
2205 };
2206 function setWidgetIdForClientId(clientId, widgetId) {
2207 return {
2208 type: "SET_WIDGET_ID_FOR_CLIENT_ID",
2209 clientId,
2210 widgetId
2211 };
2212 }
2213 function setWidgetAreasOpenState(widgetAreasOpenState2) {
2214 return {
2215 type: "SET_WIDGET_AREAS_OPEN_STATE",
2216 widgetAreasOpenState: widgetAreasOpenState2
2217 };
2218 }
2219 function setIsWidgetAreaOpen(clientId, isOpen) {
2220 return {
2221 type: "SET_IS_WIDGET_AREA_OPEN",
2222 clientId,
2223 isOpen
2224 };
2225 }
2226 function setIsInserterOpened(value) {
2227 return {
2228 type: "SET_IS_INSERTER_OPENED",
2229 value
2230 };
2231 }
2232 function setIsListViewOpened(isOpen) {
2233 return {
2234 type: "SET_IS_LIST_VIEW_OPENED",
2235 isOpen
2236 };
2237 }
2238 var closeGeneralSidebar = () => ({ registry }) => {
2239 registry.dispatch(store).disableComplementaryArea(STORE_NAME2);
2240 };
2241 var moveBlockToWidgetArea = (clientId, widgetAreaId) => async ({ dispatch: dispatch2, select, registry }) => {
2242 const sourceRootClientId = registry.select(import_block_editor.store).getBlockRootClientId(clientId);
2243 const widgetAreas = registry.select(import_block_editor.store).getBlocks();
2244 const destinationWidgetAreaBlock = widgetAreas.find(
2245 ({ attributes }) => attributes.id === widgetAreaId
2246 );
2247 const destinationRootClientId = destinationWidgetAreaBlock.clientId;
2248 const destinationInnerBlocksClientIds = registry.select(import_block_editor.store).getBlockOrder(destinationRootClientId);
2249 const destinationIndex = destinationInnerBlocksClientIds.length;
2250 const isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(
2251 destinationRootClientId
2252 );
2253 if (!isDestinationWidgetAreaOpen) {
2254 dispatch2.setIsWidgetAreaOpen(destinationRootClientId, true);
2255 }
2256 registry.dispatch(import_block_editor.store).moveBlocksToPosition(
2257 [clientId],
2258 sourceRootClientId,
2259 destinationRootClientId,
2260 destinationIndex
2261 );
2262 };
2263 function unlockWidgetSaving(lockName) {
2264 return {
2265 type: "UNLOCK_WIDGET_SAVING",
2266 lockName
2267 };
2268 }
2269 function lockWidgetSaving(lockName) {
2270 return {
2271 type: "LOCK_WIDGET_SAVING",
2272 lockName
2273 };
2274 }
2275
2276 // packages/edit-widgets/build-module/store/resolvers.mjs
2277 var getWidgetAreas = () => async ({ dispatch: dispatch2, registry }) => {
2278 const query = buildWidgetAreasQuery();
2279 const widgetAreas = await registry.resolveSelect(import_core_data2.store).getEntityRecords(KIND, WIDGET_AREA_ENTITY_TYPE, query);
2280 const widgetAreaBlocks = [];
2281 const sortedWidgetAreas = widgetAreas.sort((a, b) => {
2282 if (a.id === "wp_inactive_widgets") {
2283 return 1;
2284 }
2285 if (b.id === "wp_inactive_widgets") {
2286 return -1;
2287 }
2288 return 0;
2289 });
2290 for (const widgetArea of sortedWidgetAreas) {
2291 widgetAreaBlocks.push(
2292 (0, import_blocks2.createBlock)("core/widget-area", {
2293 id: widgetArea.id,
2294 name: widgetArea.name
2295 })
2296 );
2297 if (!widgetArea.widgets.length) {
2298 dispatch2(
2299 persistStubPost(
2300 buildWidgetAreaPostId(widgetArea.id),
2301 []
2302 )
2303 );
2304 }
2305 }
2306 const widgetAreasOpenState2 = {};
2307 widgetAreaBlocks.forEach((widgetAreaBlock, index) => {
2308 widgetAreasOpenState2[widgetAreaBlock.clientId] = index === 0;
2309 });
2310 dispatch2(setWidgetAreasOpenState(widgetAreasOpenState2));
2311 dispatch2(
2312 persistStubPost(buildWidgetAreasPostId(), widgetAreaBlocks)
2313 );
2314 };
2315 var getWidgets = () => async ({ dispatch: dispatch2, registry }) => {
2316 const query = buildWidgetsQuery();
2317 const widgets = await registry.resolveSelect(import_core_data2.store).getEntityRecords("root", "widget", query);
2318 const groupedBySidebar = {};
2319 for (const widget of widgets) {
2320 const block = transformWidgetToBlock(widget);
2321 groupedBySidebar[widget.sidebar] = groupedBySidebar[widget.sidebar] || [];
2322 groupedBySidebar[widget.sidebar].push(block);
2323 }
2324 for (const sidebarId in groupedBySidebar) {
2325 if (groupedBySidebar.hasOwnProperty(sidebarId)) {
2326 dispatch2(
2327 persistStubPost(
2328 buildWidgetAreaPostId(sidebarId),
2329 groupedBySidebar[sidebarId]
2330 )
2331 );
2332 }
2333 }
2334 };
2335
2336 // packages/edit-widgets/build-module/store/selectors.mjs
2337 var selectors_exports2 = {};
2338 __export(selectors_exports2, {
2339 __experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint,
2340 canInsertBlockInWidgetArea: () => canInsertBlockInWidgetArea,
2341 getEditedWidgetAreas: () => getEditedWidgetAreas,
2342 getIsWidgetAreaOpen: () => getIsWidgetAreaOpen,
2343 getParentWidgetAreaBlock: () => getParentWidgetAreaBlock,
2344 getReferenceWidgetBlocks: () => getReferenceWidgetBlocks,
2345 getWidget: () => getWidget,
2346 getWidgetAreaForWidgetId: () => getWidgetAreaForWidgetId,
2347 getWidgetAreas: () => getWidgetAreas2,
2348 getWidgets: () => getWidgets2,
2349 isInserterOpened: () => isInserterOpened,
2350 isListViewOpened: () => isListViewOpened,
2351 isSavingWidgetAreas: () => isSavingWidgetAreas,
2352 isWidgetSavingLocked: () => isWidgetSavingLocked
2353 });
2354 var import_data7 = __toESM(require_data(), 1);
2355 var import_widgets3 = __toESM(require_widgets(), 1);
2356 var import_core_data3 = __toESM(require_core_data(), 1);
2357 var import_block_editor2 = __toESM(require_block_editor(), 1);
2358 var EMPTY_INSERTION_POINT = {
2359 rootClientId: void 0,
2360 insertionIndex: void 0
2361 };
2362 var getWidgets2 = (0, import_data7.createRegistrySelector)(
2363 (select) => (0, import_data7.createSelector)(
2364 () => {
2365 const widgets = select(import_core_data3.store).getEntityRecords(
2366 "root",
2367 "widget",
2368 buildWidgetsQuery()
2369 );
2370 return (
2371 // Key widgets by their ID.
2372 widgets?.reduce(
2373 (allWidgets, widget) => ({
2374 ...allWidgets,
2375 [widget.id]: widget
2376 }),
2377 {}
2378 ) ?? {}
2379 );
2380 },
2381 () => [
2382 select(import_core_data3.store).getEntityRecords(
2383 "root",
2384 "widget",
2385 buildWidgetsQuery()
2386 )
2387 ]
2388 )
2389 );
2390 var getWidget = (0, import_data7.createRegistrySelector)(
2391 (select) => (state, id) => {
2392 const widgets = select(STORE_NAME2).getWidgets();
2393 return widgets[id];
2394 }
2395 );
2396 var getWidgetAreas2 = (0, import_data7.createRegistrySelector)((select) => () => {
2397 const query = buildWidgetAreasQuery();
2398 return select(import_core_data3.store).getEntityRecords(
2399 KIND,
2400 WIDGET_AREA_ENTITY_TYPE,
2401 query
2402 );
2403 });
2404 var getWidgetAreaForWidgetId = (0, import_data7.createRegistrySelector)(
2405 (select) => (state, widgetId) => {
2406 const widgetAreas = select(STORE_NAME2).getWidgetAreas();
2407 return widgetAreas.find((widgetArea) => {
2408 const post = select(import_core_data3.store).getEditedEntityRecord(
2409 KIND,
2410 POST_TYPE,
2411 buildWidgetAreaPostId(widgetArea.id)
2412 );
2413 const blockWidgetIds = post.blocks.map(
2414 (block) => (0, import_widgets3.getWidgetIdFromBlock)(block)
2415 );
2416 return blockWidgetIds.includes(widgetId);
2417 });
2418 }
2419 );
2420 var getParentWidgetAreaBlock = (0, import_data7.createRegistrySelector)(
2421 (select) => (state, clientId) => {
2422 const { getBlock, getBlockName, getBlockParents } = select(import_block_editor2.store);
2423 const blockParents = getBlockParents(clientId);
2424 const widgetAreaClientId = blockParents.find(
2425 (parentClientId) => getBlockName(parentClientId) === "core/widget-area"
2426 );
2427 return getBlock(widgetAreaClientId);
2428 }
2429 );
2430 var getEditedWidgetAreas = (0, import_data7.createRegistrySelector)(
2431 (select) => (state, ids) => {
2432 let widgetAreas = select(STORE_NAME2).getWidgetAreas();
2433 if (!widgetAreas) {
2434 return [];
2435 }
2436 if (ids) {
2437 widgetAreas = widgetAreas.filter(
2438 ({ id }) => ids.includes(id)
2439 );
2440 }
2441 return widgetAreas.filter(
2442 ({ id }) => select(import_core_data3.store).hasEditsForEntityRecord(
2443 KIND,
2444 POST_TYPE,
2445 buildWidgetAreaPostId(id)
2446 )
2447 ).map(
2448 ({ id }) => select(import_core_data3.store).getEditedEntityRecord(
2449 KIND,
2450 WIDGET_AREA_ENTITY_TYPE,
2451 id
2452 )
2453 );
2454 }
2455 );
2456 var getReferenceWidgetBlocks = (0, import_data7.createRegistrySelector)(
2457 (select) => (state, referenceWidgetName = null) => {
2458 const results = [];
2459 const widgetAreas = select(STORE_NAME2).getWidgetAreas();
2460 for (const _widgetArea of widgetAreas) {
2461 const post = select(import_core_data3.store).getEditedEntityRecord(
2462 KIND,
2463 POST_TYPE,
2464 buildWidgetAreaPostId(_widgetArea.id)
2465 );
2466 for (const block of post.blocks) {
2467 if (block.name === "core/legacy-widget" && (!referenceWidgetName || block.attributes?.referenceWidgetName === referenceWidgetName)) {
2468 results.push(block);
2469 }
2470 }
2471 }
2472 return results;
2473 }
2474 );
2475 var isSavingWidgetAreas = (0, import_data7.createRegistrySelector)((select) => () => {
2476 const widgetAreasIds = select(STORE_NAME2).getWidgetAreas()?.map(({ id }) => id);
2477 if (!widgetAreasIds) {
2478 return false;
2479 }
2480 for (const id of widgetAreasIds) {
2481 const isSaving = select(import_core_data3.store).isSavingEntityRecord(
2482 KIND,
2483 WIDGET_AREA_ENTITY_TYPE,
2484 id
2485 );
2486 if (isSaving) {
2487 return true;
2488 }
2489 }
2490 const widgetIds = [
2491 ...Object.keys(select(STORE_NAME2).getWidgets()),
2492 void 0
2493 // account for new widgets without an ID
2494 ];
2495 for (const id of widgetIds) {
2496 const isSaving = select(import_core_data3.store).isSavingEntityRecord(
2497 "root",
2498 "widget",
2499 id
2500 );
2501 if (isSaving) {
2502 return true;
2503 }
2504 }
2505 return false;
2506 });
2507 var getIsWidgetAreaOpen = (state, clientId) => {
2508 const { widgetAreasOpenState: widgetAreasOpenState2 } = state;
2509 return !!widgetAreasOpenState2[clientId];
2510 };
2511 function isInserterOpened(state) {
2512 return !!state.blockInserterPanel;
2513 }
2514 function __experimentalGetInsertionPoint(state) {
2515 if (typeof state.blockInserterPanel === "boolean") {
2516 return EMPTY_INSERTION_POINT;
2517 }
2518 return state.blockInserterPanel;
2519 }
2520 var canInsertBlockInWidgetArea = (0, import_data7.createRegistrySelector)(
2521 (select) => (state, blockName) => {
2522 const widgetAreas = select(import_block_editor2.store).getBlocks();
2523 const [firstWidgetArea] = widgetAreas;
2524 return select(import_block_editor2.store).canInsertBlockType(
2525 blockName,
2526 firstWidgetArea.clientId
2527 );
2528 }
2529 );
2530 function isListViewOpened(state) {
2531 return state.listViewPanel;
2532 }
2533 function isWidgetSavingLocked(state) {
2534 return Object.keys(state.widgetSavingLock).length > 0;
2535 }
2536
2537 // packages/edit-widgets/build-module/store/private-selectors.mjs
2538 var private_selectors_exports = {};
2539 __export(private_selectors_exports, {
2540 getInserterSidebarToggleRef: () => getInserterSidebarToggleRef,
2541 getListViewToggleRef: () => getListViewToggleRef
2542 });
2543 function getListViewToggleRef(state) {
2544 return state.listViewToggleRef;
2545 }
2546 function getInserterSidebarToggleRef(state) {
2547 return state.inserterSidebarToggleRef;
2548 }
2549
2550 // packages/edit-widgets/build-module/lock-unlock.mjs
2551 var import_private_apis = __toESM(require_private_apis(), 1);
2552 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
2553 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
2554 "@wordpress/edit-widgets"
2555 );
2556
2557 // packages/edit-widgets/build-module/store/index.mjs
2558 var storeConfig = {
2559 reducer: reducer_default,
2560 selectors: selectors_exports2,
2561 resolvers: resolvers_exports,
2562 actions: actions_exports2
2563 };
2564 var store2 = (0, import_data8.createReduxStore)(STORE_NAME2, storeConfig);
2565 (0, import_data8.register)(store2);
2566 import_api_fetch.default.use(function(options, next) {
2567 if (options.path?.indexOf("/wp/v2/types/widget-area") === 0) {
2568 return Promise.resolve({});
2569 }
2570 return next(options);
2571 });
2572 unlock(store2).registerPrivateSelectors(private_selectors_exports);
2573
2574 // packages/edit-widgets/build-module/filters/move-to-widget-area.mjs
2575 var import_block_editor3 = __toESM(require_block_editor(), 1);
2576 var import_compose3 = __toESM(require_compose(), 1);
2577 var import_data9 = __toESM(require_data(), 1);
2578 var import_hooks = __toESM(require_hooks(), 1);
2579 var import_widgets4 = __toESM(require_widgets(), 1);
2580 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
2581 var withMoveToWidgetAreaToolbarItem = (0, import_compose3.createHigherOrderComponent)(
2582 (BlockEdit) => (props) => {
2583 const { clientId, name: blockName } = props;
2584 const { widgetAreas, currentWidgetAreaId, canInsertBlockInWidgetArea: canInsertBlockInWidgetArea2 } = (0, import_data9.useSelect)(
2585 (select) => {
2586 if (blockName === "core/widget-area") {
2587 return {};
2588 }
2589 const selectors = select(store2);
2590 const widgetAreaBlock = selectors.getParentWidgetAreaBlock(clientId);
2591 return {
2592 widgetAreas: selectors.getWidgetAreas(),
2593 currentWidgetAreaId: widgetAreaBlock?.attributes?.id,
2594 canInsertBlockInWidgetArea: selectors.canInsertBlockInWidgetArea(blockName)
2595 };
2596 },
2597 [clientId, blockName]
2598 );
2599 const { moveBlockToWidgetArea: moveBlockToWidgetArea2 } = (0, import_data9.useDispatch)(store2);
2600 const hasMultipleWidgetAreas = widgetAreas?.length > 1;
2601 const isMoveToWidgetAreaVisible = blockName !== "core/widget-area" && hasMultipleWidgetAreas && canInsertBlockInWidgetArea2;
2602 return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
2603 /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BlockEdit, { ...props }, "edit"),
2604 isMoveToWidgetAreaVisible && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_block_editor3.BlockControls, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2605 import_widgets4.MoveToWidgetArea,
2606 {
2607 widgetAreas,
2608 currentWidgetAreaId,
2609 onSelect: (widgetAreaId) => {
2610 moveBlockToWidgetArea2(
2611 props.clientId,
2612 widgetAreaId
2613 );
2614 }
2615 }
2616 ) })
2617 ] });
2618 },
2619 "withMoveToWidgetAreaToolbarItem"
2620 );
2621 (0, import_hooks.addFilter)(
2622 "editor.BlockEdit",
2623 "core/edit-widgets/block-edit",
2624 withMoveToWidgetAreaToolbarItem
2625 );
2626
2627 // packages/edit-widgets/build-module/filters/replace-media-upload.mjs
2628 var import_hooks2 = __toESM(require_hooks(), 1);
2629 var import_media_utils = __toESM(require_media_utils(), 1);
2630 var replaceMediaUpload = () => import_media_utils.MediaUpload;
2631 (0, import_hooks2.addFilter)(
2632 "editor.MediaUpload",
2633 "core/edit-widgets/replace-media-upload",
2634 replaceMediaUpload
2635 );
2636
2637 // packages/edit-widgets/build-module/blocks/widget-area/index.mjs
2638 var widget_area_exports = {};
2639 __export(widget_area_exports, {
2640 metadata: () => block_default,
2641 name: () => name,
2642 settings: () => settings
2643 });
2644 var import_i18n4 = __toESM(require_i18n(), 1);
2645
2646 // packages/edit-widgets/build-module/blocks/widget-area/block.json
2647 var block_default = {
2648 $schema: "https://schemas.wp.org/trunk/block.json",
2649 apiVersion: 3,
2650 name: "core/widget-area",
2651 title: "Widget Area",
2652 category: "widgets",
2653 attributes: {
2654 id: {
2655 type: "string"
2656 },
2657 name: {
2658 type: "string"
2659 }
2660 },
2661 supports: {
2662 html: false,
2663 inserter: false,
2664 customClassName: false,
2665 reusable: false,
2666 renaming: false,
2667 visibility: false,
2668 __experimentalToolbar: false,
2669 __experimentalParentSelector: false,
2670 __experimentalDisableBlockOverlay: true
2671 },
2672 editorStyle: "wp-block-widget-area-editor",
2673 style: "wp-block-widget-area"
2674 };
2675
2676 // packages/edit-widgets/build-module/blocks/widget-area/edit/index.mjs
2677 var import_element8 = __toESM(require_element(), 1);
2678 var import_data10 = __toESM(require_data(), 1);
2679 var import_core_data5 = __toESM(require_core_data(), 1);
2680 var import_components7 = __toESM(require_components(), 1);
2681 var import_block_editor5 = __toESM(require_block_editor(), 1);
2682
2683 // packages/edit-widgets/build-module/blocks/widget-area/edit/inner-blocks.mjs
2684 var import_core_data4 = __toESM(require_core_data(), 1);
2685 var import_block_editor4 = __toESM(require_block_editor(), 1);
2686 var import_element7 = __toESM(require_element(), 1);
2687
2688 // packages/edit-widgets/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs
2689 var import_element6 = __toESM(require_element(), 1);
2690 var useIsDraggingWithin = (elementRef) => {
2691 const [isDraggingWithin, setIsDraggingWithin] = (0, import_element6.useState)(false);
2692 (0, import_element6.useEffect)(() => {
2693 const { ownerDocument } = elementRef.current;
2694 function handleDragStart(event) {
2695 handleDragEnter(event);
2696 }
2697 function handleDragEnd() {
2698 setIsDraggingWithin(false);
2699 }
2700 function handleDragEnter(event) {
2701 if (elementRef.current.contains(event.target)) {
2702 setIsDraggingWithin(true);
2703 } else {
2704 setIsDraggingWithin(false);
2705 }
2706 }
2707 ownerDocument.addEventListener("dragstart", handleDragStart);
2708 ownerDocument.addEventListener("dragend", handleDragEnd);
2709 ownerDocument.addEventListener("dragenter", handleDragEnter);
2710 return () => {
2711 ownerDocument.removeEventListener("dragstart", handleDragStart);
2712 ownerDocument.removeEventListener("dragend", handleDragEnd);
2713 ownerDocument.removeEventListener("dragenter", handleDragEnter);
2714 };
2715 }, []);
2716 return isDraggingWithin;
2717 };
2718 var use_is_dragging_within_default = useIsDraggingWithin;
2719
2720 // packages/edit-widgets/build-module/blocks/widget-area/edit/inner-blocks.mjs
2721 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
2722 function WidgetAreaInnerBlocks({ id }) {
2723 const [blocks, onInput, onChange] = (0, import_core_data4.useEntityBlockEditor)(
2724 "root",
2725 "postType"
2726 );
2727 const innerBlocksRef = (0, import_element7.useRef)();
2728 const isDraggingWithinInnerBlocks = use_is_dragging_within_default(innerBlocksRef);
2729 const shouldHighlightDropZone = isDraggingWithinInnerBlocks;
2730 const innerBlocksProps = (0, import_block_editor4.useInnerBlocksProps)(
2731 { ref: innerBlocksRef },
2732 {
2733 value: blocks,
2734 onInput,
2735 onChange,
2736 templateLock: false,
2737 renderAppender: import_block_editor4.InnerBlocks.ButtonBlockAppender
2738 }
2739 );
2740 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2741 "div",
2742 {
2743 "data-widget-area-id": id,
2744 className: clsx_default(
2745 "wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper",
2746 {
2747 "wp-block-widget-area__highlight-drop-zone": shouldHighlightDropZone
2748 }
2749 ),
2750 children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ...innerBlocksProps })
2751 }
2752 );
2753 }
2754
2755 // packages/edit-widgets/build-module/blocks/widget-area/edit/index.mjs
2756 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
2757 function WidgetAreaEdit({
2758 clientId,
2759 attributes: { id, name: name2 }
2760 }) {
2761 const isOpen = (0, import_data10.useSelect)(
2762 (select) => select(store2).getIsWidgetAreaOpen(clientId),
2763 [clientId]
2764 );
2765 const { setIsWidgetAreaOpen: setIsWidgetAreaOpen2 } = (0, import_data10.useDispatch)(store2);
2766 const wrapper = (0, import_element8.useRef)();
2767 const setOpen = (0, import_element8.useCallback)(
2768 (openState) => setIsWidgetAreaOpen2(clientId, openState),
2769 [clientId]
2770 );
2771 const isDragging = useIsDragging(wrapper);
2772 const isDraggingWithin = use_is_dragging_within_default(wrapper);
2773 const [openedWhileDragging, setOpenedWhileDragging] = (0, import_element8.useState)(false);
2774 (0, import_element8.useEffect)(() => {
2775 if (!isDragging) {
2776 setOpenedWhileDragging(false);
2777 return;
2778 }
2779 if (isDraggingWithin && !isOpen) {
2780 setOpen(true);
2781 setOpenedWhileDragging(true);
2782 } else if (!isDraggingWithin && isOpen && openedWhileDragging) {
2783 setOpen(false);
2784 }
2785 }, [isOpen, isDragging, isDraggingWithin, openedWhileDragging]);
2786 const blockProps = (0, import_block_editor5.useBlockProps)();
2787 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components7.Panel, { ref: wrapper, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2788 import_components7.PanelBody,
2789 {
2790 title: name2,
2791 opened: isOpen,
2792 onToggle: () => {
2793 setIsWidgetAreaOpen2(clientId, !isOpen);
2794 },
2795 scrollAfterOpen: !isDragging,
2796 children: ({ opened }) => (
2797 // This is required to ensure LegacyWidget blocks are not
2798 // unmounted when the panel is collapsed. Unmounting legacy
2799 // widgets may have unintended consequences (e.g. TinyMCE
2800 // not being properly reinitialized)
2801 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2802 import_components7.__unstableDisclosureContent,
2803 {
2804 className: "wp-block-widget-area__panel-body-content",
2805 visible: opened,
2806 children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2807 import_core_data5.EntityProvider,
2808 {
2809 kind: "root",
2810 type: "postType",
2811 id: `widget-area-${id}`,
2812 children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(WidgetAreaInnerBlocks, { id })
2813 }
2814 )
2815 }
2816 )
2817 )
2818 }
2819 ) }) });
2820 }
2821 var useIsDragging = (elementRef) => {
2822 const [isDragging, setIsDragging] = (0, import_element8.useState)(false);
2823 (0, import_element8.useEffect)(() => {
2824 const { ownerDocument } = elementRef.current;
2825 function handleDragStart() {
2826 setIsDragging(true);
2827 }
2828 function handleDragEnd() {
2829 setIsDragging(false);
2830 }
2831 ownerDocument.addEventListener("dragstart", handleDragStart);
2832 ownerDocument.addEventListener("dragend", handleDragEnd);
2833 return () => {
2834 ownerDocument.removeEventListener("dragstart", handleDragStart);
2835 ownerDocument.removeEventListener("dragend", handleDragEnd);
2836 };
2837 }, []);
2838 return isDragging;
2839 };
2840
2841 // packages/edit-widgets/build-module/blocks/widget-area/index.mjs
2842 var { name } = block_default;
2843 var settings = {
2844 title: (0, import_i18n4.__)("Widget Area"),
2845 description: (0, import_i18n4.__)("A widget area container."),
2846 __experimentalLabel: ({ name: label }) => label,
2847 edit: WidgetAreaEdit
2848 };
2849
2850 // packages/edit-widgets/build-module/components/layout/index.mjs
2851 var import_i18n21 = __toESM(require_i18n(), 1);
2852 var import_data31 = __toESM(require_data(), 1);
2853 var import_plugins3 = __toESM(require_plugins(), 1);
2854 var import_notices4 = __toESM(require_notices(), 1);
2855 var import_components22 = __toESM(require_components(), 1);
2856
2857 // packages/edit-widgets/build-module/components/error-boundary/index.mjs
2858 var import_element9 = __toESM(require_element(), 1);
2859 var import_i18n5 = __toESM(require_i18n(), 1);
2860 var import_components8 = __toESM(require_components(), 1);
2861 var import_block_editor6 = __toESM(require_block_editor(), 1);
2862 var import_compose4 = __toESM(require_compose(), 1);
2863 var import_hooks3 = __toESM(require_hooks(), 1);
2864 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
2865 function CopyButton({ text, children }) {
2866 const ref = (0, import_compose4.useCopyToClipboard)(text);
2867 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_components8.Button, { __next40pxDefaultSize: true, variant: "secondary", ref, children });
2868 }
2869 function ErrorBoundaryWarning({ message, error }) {
2870 const actions = [
2871 /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopyButton, { text: error.stack, children: (0, import_i18n5.__)("Copy Error") }, "copy-error")
2872 ];
2873 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_block_editor6.Warning, { className: "edit-widgets-error-boundary", actions, children: message });
2874 }
2875 var ErrorBoundary = class extends import_element9.Component {
2876 constructor() {
2877 super(...arguments);
2878 this.state = {
2879 error: null
2880 };
2881 }
2882 componentDidCatch(error) {
2883 (0, import_hooks3.doAction)("editor.ErrorBoundary.errorLogged", error);
2884 }
2885 static getDerivedStateFromError(error) {
2886 return { error };
2887 }
2888 render() {
2889 if (!this.state.error) {
2890 return this.props.children;
2891 }
2892 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2893 ErrorBoundaryWarning,
2894 {
2895 message: (0, import_i18n5.__)(
2896 "The editor has encountered an unexpected error."
2897 ),
2898 error: this.state.error
2899 }
2900 );
2901 }
2902 };
2903
2904 // packages/edit-widgets/build-module/components/widget-areas-block-editor-provider/index.mjs
2905 var import_components9 = __toESM(require_components(), 1);
2906 var import_compose5 = __toESM(require_compose(), 1);
2907 var import_media_utils2 = __toESM(require_media_utils(), 1);
2908 var import_data13 = __toESM(require_data(), 1);
2909 var import_core_data8 = __toESM(require_core_data(), 1);
2910 var import_element11 = __toESM(require_element(), 1);
2911 var import_block_editor8 = __toESM(require_block_editor(), 1);
2912 var import_patterns = __toESM(require_patterns(), 1);
2913 var import_preferences4 = __toESM(require_preferences(), 1);
2914 var import_block_library = __toESM(require_block_library(), 1);
2915
2916 // packages/edit-widgets/build-module/components/keyboard-shortcuts/index.mjs
2917 var import_element10 = __toESM(require_element(), 1);
2918 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1);
2919 var import_keycodes = __toESM(require_keycodes(), 1);
2920 var import_data11 = __toESM(require_data(), 1);
2921 var import_i18n6 = __toESM(require_i18n(), 1);
2922 var import_core_data6 = __toESM(require_core_data(), 1);
2923 function KeyboardShortcuts() {
2924 const { redo, undo } = (0, import_data11.useDispatch)(import_core_data6.store);
2925 const { saveEditedWidgetAreas: saveEditedWidgetAreas2 } = (0, import_data11.useDispatch)(store2);
2926 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/undo", (event) => {
2927 undo();
2928 event.preventDefault();
2929 });
2930 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/redo", (event) => {
2931 redo();
2932 event.preventDefault();
2933 });
2934 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/save", (event) => {
2935 event.preventDefault();
2936 saveEditedWidgetAreas2();
2937 });
2938 return null;
2939 }
2940 function KeyboardShortcutsRegister() {
2941 const { registerShortcut } = (0, import_data11.useDispatch)(import_keyboard_shortcuts.store);
2942 (0, import_element10.useEffect)(() => {
2943 registerShortcut({
2944 name: "core/edit-widgets/undo",
2945 category: "global",
2946 description: (0, import_i18n6.__)("Undo your last changes."),
2947 keyCombination: {
2948 modifier: "primary",
2949 character: "z"
2950 }
2951 });
2952 registerShortcut({
2953 name: "core/edit-widgets/redo",
2954 category: "global",
2955 description: (0, import_i18n6.__)("Redo your last undo."),
2956 keyCombination: {
2957 modifier: "primaryShift",
2958 character: "z"
2959 },
2960 // Disable on Apple OS because it conflicts with the browser's
2961 // history shortcut. It's a fine alias for both Windows and Linux.
2962 // Since there's no conflict for Ctrl+Shift+Z on both Windows and
2963 // Linux, we keep it as the default for consistency.
2964 aliases: (0, import_keycodes.isAppleOS)() ? [] : [
2965 {
2966 modifier: "primary",
2967 character: "y"
2968 }
2969 ]
2970 });
2971 registerShortcut({
2972 name: "core/edit-widgets/save",
2973 category: "global",
2974 description: (0, import_i18n6.__)("Save your changes."),
2975 keyCombination: {
2976 modifier: "primary",
2977 character: "s"
2978 }
2979 });
2980 registerShortcut({
2981 name: "core/edit-widgets/keyboard-shortcuts",
2982 category: "main",
2983 description: (0, import_i18n6.__)("Display these keyboard shortcuts."),
2984 keyCombination: {
2985 modifier: "access",
2986 character: "h"
2987 }
2988 });
2989 registerShortcut({
2990 name: "core/edit-widgets/next-region",
2991 category: "global",
2992 description: (0, import_i18n6.__)("Navigate to the next part of the editor."),
2993 keyCombination: {
2994 modifier: "ctrl",
2995 character: "`"
2996 },
2997 aliases: [
2998 {
2999 modifier: "access",
3000 character: "n"
3001 }
3002 ]
3003 });
3004 registerShortcut({
3005 name: "core/edit-widgets/previous-region",
3006 category: "global",
3007 description: (0, import_i18n6.__)("Navigate to the previous part of the editor."),
3008 keyCombination: {
3009 modifier: "ctrlShift",
3010 character: "`"
3011 },
3012 aliases: [
3013 {
3014 modifier: "access",
3015 character: "p"
3016 },
3017 {
3018 modifier: "ctrlShift",
3019 character: "~"
3020 }
3021 ]
3022 });
3023 }, [registerShortcut]);
3024 return null;
3025 }
3026 KeyboardShortcuts.Register = KeyboardShortcutsRegister;
3027 var keyboard_shortcuts_default = KeyboardShortcuts;
3028
3029 // packages/edit-widgets/build-module/hooks/use-last-selected-widget-area.mjs
3030 var import_data12 = __toESM(require_data(), 1);
3031 var import_block_editor7 = __toESM(require_block_editor(), 1);
3032 var import_core_data7 = __toESM(require_core_data(), 1);
3033 var useLastSelectedWidgetArea = () => (0, import_data12.useSelect)((select) => {
3034 const { getBlockSelectionEnd, getBlockName } = select(import_block_editor7.store);
3035 const selectionEndClientId = getBlockSelectionEnd();
3036 if (getBlockName(selectionEndClientId) === "core/widget-area") {
3037 return selectionEndClientId;
3038 }
3039 const { getParentWidgetAreaBlock: getParentWidgetAreaBlock2 } = select(store2);
3040 const widgetAreaBlock = getParentWidgetAreaBlock2(selectionEndClientId);
3041 const widgetAreaBlockClientId = widgetAreaBlock?.clientId;
3042 if (widgetAreaBlockClientId) {
3043 return widgetAreaBlockClientId;
3044 }
3045 const { getEntityRecord } = select(import_core_data7.store);
3046 const widgetAreasPost = getEntityRecord(
3047 KIND,
3048 POST_TYPE,
3049 buildWidgetAreasPostId()
3050 );
3051 return widgetAreasPost?.blocks[0]?.clientId;
3052 }, []);
3053 var use_last_selected_widget_area_default = useLastSelectedWidgetArea;
3054
3055 // packages/edit-widgets/build-module/constants.mjs
3056 var ALLOW_REUSABLE_BLOCKS = false;
3057 var ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;
3058
3059 // packages/edit-widgets/build-module/components/widget-areas-block-editor-provider/index.mjs
3060 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
3061 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor8.privateApis);
3062 var { PatternsMenuItems } = unlock(import_patterns.privateApis);
3063 var { BlockKeyboardShortcuts } = unlock(import_block_library.privateApis);
3064 var EMPTY_ARRAY2 = [];
3065 function WidgetAreasBlockEditorProvider({
3066 blockEditorSettings,
3067 children,
3068 ...props
3069 }) {
3070 const isLargeViewport = (0, import_compose5.useViewportMatch)("medium");
3071 const {
3072 hasUploadPermissions,
3073 reusableBlocks,
3074 isFixedToolbarActive,
3075 keepCaretInsideBlock,
3076 pageOnFront,
3077 pageForPosts
3078 } = (0, import_data13.useSelect)((select) => {
3079 const { canUser, getEntityRecord, getEntityRecords } = select(import_core_data8.store);
3080 const siteSettings = canUser("read", {
3081 kind: "root",
3082 name: "site"
3083 }) ? getEntityRecord("root", "site") : void 0;
3084 return {
3085 hasUploadPermissions: canUser("create", {
3086 kind: "postType",
3087 name: "attachment"
3088 }) ?? true,
3089 reusableBlocks: ALLOW_REUSABLE_BLOCKS ? getEntityRecords("postType", "wp_block") : EMPTY_ARRAY2,
3090 isFixedToolbarActive: !!select(import_preferences4.store).get(
3091 "core/edit-widgets",
3092 "fixedToolbar"
3093 ),
3094 keepCaretInsideBlock: !!select(import_preferences4.store).get(
3095 "core/edit-widgets",
3096 "keepCaretInsideBlock"
3097 ),
3098 pageOnFront: siteSettings?.page_on_front,
3099 pageForPosts: siteSettings?.page_for_posts
3100 };
3101 }, []);
3102 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data13.useDispatch)(store2);
3103 const settings2 = (0, import_element11.useMemo)(() => {
3104 let mediaUploadBlockEditor;
3105 if (hasUploadPermissions) {
3106 mediaUploadBlockEditor = ({ onError, ...argumentsObject }) => {
3107 (0, import_media_utils2.uploadMedia)({
3108 wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,
3109 onError: ({ message }) => onError(message),
3110 ...argumentsObject
3111 });
3112 };
3113 }
3114 return {
3115 ...blockEditorSettings,
3116 __experimentalReusableBlocks: reusableBlocks,
3117 hasFixedToolbar: isFixedToolbarActive || !isLargeViewport,
3118 keepCaretInsideBlock,
3119 mediaUpload: mediaUploadBlockEditor,
3120 templateLock: "all",
3121 __experimentalSetIsInserterOpened: setIsInserterOpened2,
3122 pageOnFront,
3123 pageForPosts,
3124 editorTool: "edit"
3125 };
3126 }, [
3127 hasUploadPermissions,
3128 blockEditorSettings,
3129 isFixedToolbarActive,
3130 isLargeViewport,
3131 keepCaretInsideBlock,
3132 reusableBlocks,
3133 setIsInserterOpened2,
3134 pageOnFront,
3135 pageForPosts
3136 ]);
3137 const widgetAreaId = use_last_selected_widget_area_default();
3138 const [blocks, onInput, onChange] = (0, import_core_data8.useEntityBlockEditor)(
3139 KIND,
3140 POST_TYPE,
3141 { id: buildWidgetAreasPostId() }
3142 );
3143 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_components9.SlotFillProvider, { children: [
3144 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(keyboard_shortcuts_default.Register, {}),
3145 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(BlockKeyboardShortcuts, {}),
3146 /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3147 ExperimentalBlockEditorProvider,
3148 {
3149 value: blocks,
3150 onInput,
3151 onChange,
3152 settings: settings2,
3153 useSubRegistry: false,
3154 ...props,
3155 children: [
3156 children,
3157 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PatternsMenuItems, { rootClientId: widgetAreaId })
3158 ]
3159 }
3160 )
3161 ] });
3162 }
3163
3164 // packages/edit-widgets/build-module/components/sidebar/index.mjs
3165 var import_element13 = __toESM(require_element(), 1);
3166 var import_i18n8 = __toESM(require_i18n(), 1);
3167 var import_block_editor10 = __toESM(require_block_editor(), 1);
3168 var import_components11 = __toESM(require_components(), 1);
3169 var import_data15 = __toESM(require_data(), 1);
3170
3171 // packages/edit-widgets/build-module/components/sidebar/widget-areas.mjs
3172 var import_data14 = __toESM(require_data(), 1);
3173 var import_element12 = __toESM(require_element(), 1);
3174 var import_block_editor9 = __toESM(require_block_editor(), 1);
3175 var import_components10 = __toESM(require_components(), 1);
3176 var import_i18n7 = __toESM(require_i18n(), 1);
3177 var import_url = __toESM(require_url(), 1);
3178 var import_dom = __toESM(require_dom(), 1);
3179 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
3180 function WidgetAreas({ selectedWidgetAreaId }) {
3181 const widgetAreas = (0, import_data14.useSelect)(
3182 (select) => select(store2).getWidgetAreas(),
3183 []
3184 );
3185 const selectedWidgetArea = (0, import_element12.useMemo)(
3186 () => selectedWidgetAreaId && widgetAreas?.find(
3187 (widgetArea) => widgetArea.id === selectedWidgetAreaId
3188 ),
3189 [selectedWidgetAreaId, widgetAreas]
3190 );
3191 let description;
3192 if (!selectedWidgetArea) {
3193 description = (0, import_i18n7.__)(
3194 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
3195 "Widget Areas are global parts in your site\u2019s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer."
3196 );
3197 } else if (selectedWidgetAreaId === "wp_inactive_widgets") {
3198 description = (0, import_i18n7.__)(
3199 "Blocks in this Widget Area will not be displayed in your site."
3200 );
3201 } else {
3202 description = selectedWidgetArea.description;
3203 }
3204 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "edit-widgets-widget-areas", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "edit-widgets-widget-areas__top-container", children: [
3205 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_block_editor9.BlockIcon, { icon: block_default_default }),
3206 /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { children: [
3207 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3208 "p",
3209 {
3210 dangerouslySetInnerHTML: {
3211 __html: (0, import_dom.safeHTML)(description)
3212 }
3213 }
3214 ),
3215 widgetAreas?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: (0, import_i18n7.__)(
3216 "Your theme does not contain any Widget Areas."
3217 ) }),
3218 !selectedWidgetArea && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3219 import_components10.Button,
3220 {
3221 __next40pxDefaultSize: true,
3222 href: (0, import_url.addQueryArgs)("customize.php", {
3223 "autofocus[panel]": "widgets",
3224 return: window.location.pathname
3225 }),
3226 variant: "tertiary",
3227 children: (0, import_i18n7.__)("Manage with live preview")
3228 }
3229 )
3230 ] })
3231 ] }) });
3232 }
3233
3234 // packages/edit-widgets/build-module/components/sidebar/index.mjs
3235 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
3236 var SIDEBAR_ACTIVE_BY_DEFAULT = true;
3237 var BLOCK_INSPECTOR_IDENTIFIER = "edit-widgets/block-inspector";
3238 var WIDGET_AREAS_IDENTIFIER = "edit-widgets/block-areas";
3239 var { Tabs } = unlock(import_components11.privateApis);
3240 function SidebarHeader({ selectedWidgetAreaBlock }) {
3241 return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tabs.TabList, { children: [
3242 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Tab, { tabId: WIDGET_AREAS_IDENTIFIER, children: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : (0, import_i18n8.__)("Widget Areas") }),
3243 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Tab, { tabId: BLOCK_INSPECTOR_IDENTIFIER, children: (0, import_i18n8.__)("Block") })
3244 ] });
3245 }
3246 function SidebarContent({
3247 hasSelectedNonAreaBlock,
3248 currentArea,
3249 isGeneralSidebarOpen,
3250 selectedWidgetAreaBlock
3251 }) {
3252 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data15.useDispatch)(store);
3253 (0, import_element13.useEffect)(() => {
3254 if (hasSelectedNonAreaBlock && currentArea === WIDGET_AREAS_IDENTIFIER && isGeneralSidebarOpen) {
3255 enableComplementaryArea2(
3256 "core/edit-widgets",
3257 BLOCK_INSPECTOR_IDENTIFIER
3258 );
3259 }
3260 if (!hasSelectedNonAreaBlock && currentArea === BLOCK_INSPECTOR_IDENTIFIER && isGeneralSidebarOpen) {
3261 enableComplementaryArea2(
3262 "core/edit-widgets",
3263 WIDGET_AREAS_IDENTIFIER
3264 );
3265 }
3266 }, [hasSelectedNonAreaBlock, enableComplementaryArea2]);
3267 const tabsContextValue = (0, import_element13.useContext)(Tabs.Context);
3268 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3269 complementary_area_default,
3270 {
3271 className: "edit-widgets-sidebar",
3272 header: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3273 SidebarHeader,
3274 {
3275 selectedWidgetAreaBlock
3276 }
3277 ) }),
3278 headerClassName: "edit-widgets-sidebar__panel-tabs",
3279 title: (0, import_i18n8.__)("Settings"),
3280 closeLabel: (0, import_i18n8.__)("Close Settings"),
3281 scope: "core/edit-widgets",
3282 identifier: currentArea,
3283 icon: (0, import_i18n8.isRTL)() ? drawer_left_default : drawer_right_default,
3284 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
3285 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tabs.Context.Provider, { value: tabsContextValue, children: [
3286 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3287 Tabs.TabPanel,
3288 {
3289 tabId: WIDGET_AREAS_IDENTIFIER,
3290 focusable: false,
3291 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3292 WidgetAreas,
3293 {
3294 selectedWidgetAreaId: selectedWidgetAreaBlock?.attributes.id
3295 }
3296 )
3297 }
3298 ),
3299 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3300 Tabs.TabPanel,
3301 {
3302 tabId: BLOCK_INSPECTOR_IDENTIFIER,
3303 focusable: false,
3304 children: hasSelectedNonAreaBlock ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_block_editor10.BlockInspector, {}) : (
3305 // Pretend that Widget Areas are part of the UI by not
3306 // showing the Block Inspector when one is selected.
3307 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "block-editor-block-inspector__no-blocks", children: (0, import_i18n8.__)("No block selected.") })
3308 )
3309 }
3310 )
3311 ] })
3312 }
3313 );
3314 }
3315 function Sidebar() {
3316 const {
3317 currentArea,
3318 hasSelectedNonAreaBlock,
3319 isGeneralSidebarOpen,
3320 selectedWidgetAreaBlock
3321 } = (0, import_data15.useSelect)((select) => {
3322 const { getSelectedBlock, getBlock, getBlockParentsByBlockName } = select(import_block_editor10.store);
3323 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = select(store);
3324 const selectedBlock = getSelectedBlock();
3325 const activeArea = getActiveComplementaryArea2(store2.name);
3326 let currentSelection = activeArea;
3327 if (!currentSelection) {
3328 if (selectedBlock) {
3329 currentSelection = BLOCK_INSPECTOR_IDENTIFIER;
3330 } else {
3331 currentSelection = WIDGET_AREAS_IDENTIFIER;
3332 }
3333 }
3334 let widgetAreaBlock;
3335 if (selectedBlock) {
3336 if (selectedBlock.name === "core/widget-area") {
3337 widgetAreaBlock = selectedBlock;
3338 } else {
3339 widgetAreaBlock = getBlock(
3340 getBlockParentsByBlockName(
3341 selectedBlock.clientId,
3342 "core/widget-area"
3343 )[0]
3344 );
3345 }
3346 }
3347 return {
3348 currentArea: currentSelection,
3349 hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !== "core/widget-area"),
3350 isGeneralSidebarOpen: !!activeArea,
3351 selectedWidgetAreaBlock: widgetAreaBlock
3352 };
3353 }, []);
3354 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data15.useDispatch)(store);
3355 const onTabSelect = (0, import_element13.useCallback)(
3356 (newSelectedTabId) => {
3357 if (!!newSelectedTabId) {
3358 enableComplementaryArea2(
3359 store2.name,
3360 newSelectedTabId
3361 );
3362 }
3363 },
3364 [enableComplementaryArea2]
3365 );
3366 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3367 Tabs,
3368 {
3369 selectedTabId: isGeneralSidebarOpen ? currentArea : null,
3370 onSelect: onTabSelect,
3371 selectOnMove: false,
3372 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3373 SidebarContent,
3374 {
3375 hasSelectedNonAreaBlock,
3376 currentArea,
3377 isGeneralSidebarOpen,
3378 selectedWidgetAreaBlock
3379 }
3380 )
3381 }
3382 );
3383 }
3384
3385 // packages/edit-widgets/build-module/components/layout/interface.mjs
3386 var import_compose12 = __toESM(require_compose(), 1);
3387 var import_block_editor17 = __toESM(require_block_editor(), 1);
3388 var import_element23 = __toESM(require_element(), 1);
3389 var import_data28 = __toESM(require_data(), 1);
3390 var import_i18n18 = __toESM(require_i18n(), 1);
3391 var import_preferences8 = __toESM(require_preferences(), 1);
3392
3393 // packages/edit-widgets/build-module/components/header/index.mjs
3394 var import_block_editor12 = __toESM(require_block_editor(), 1);
3395 var import_data22 = __toESM(require_data(), 1);
3396 var import_element19 = __toESM(require_element(), 1);
3397 var import_i18n16 = __toESM(require_i18n(), 1);
3398 var import_components19 = __toESM(require_components(), 1);
3399 var import_compose8 = __toESM(require_compose(), 1);
3400 var import_preferences6 = __toESM(require_preferences(), 1);
3401
3402 // packages/edit-widgets/build-module/components/header/document-tools/index.mjs
3403 var import_data18 = __toESM(require_data(), 1);
3404 var import_i18n11 = __toESM(require_i18n(), 1);
3405 var import_components14 = __toESM(require_components(), 1);
3406 var import_block_editor11 = __toESM(require_block_editor(), 1);
3407 var import_element16 = __toESM(require_element(), 1);
3408 var import_compose6 = __toESM(require_compose(), 1);
3409
3410 // packages/edit-widgets/build-module/components/header/undo-redo/undo.mjs
3411 var import_i18n9 = __toESM(require_i18n(), 1);
3412 var import_components12 = __toESM(require_components(), 1);
3413 var import_data16 = __toESM(require_data(), 1);
3414 var import_keycodes2 = __toESM(require_keycodes(), 1);
3415 var import_core_data9 = __toESM(require_core_data(), 1);
3416 var import_element14 = __toESM(require_element(), 1);
3417 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3418 function UndoButton(props, ref) {
3419 const hasUndo = (0, import_data16.useSelect)(
3420 (select) => select(import_core_data9.store).hasUndo(),
3421 []
3422 );
3423 const { undo } = (0, import_data16.useDispatch)(import_core_data9.store);
3424 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
3425 import_components12.Button,
3426 {
3427 ...props,
3428 ref,
3429 icon: !(0, import_i18n9.isRTL)() ? undo_default : redo_default,
3430 label: (0, import_i18n9.__)("Undo"),
3431 shortcut: import_keycodes2.displayShortcut.primary("z"),
3432 "aria-disabled": !hasUndo,
3433 onClick: hasUndo ? undo : void 0,
3434 size: "compact"
3435 }
3436 );
3437 }
3438 var undo_default2 = (0, import_element14.forwardRef)(UndoButton);
3439
3440 // packages/edit-widgets/build-module/components/header/undo-redo/redo.mjs
3441 var import_i18n10 = __toESM(require_i18n(), 1);
3442 var import_components13 = __toESM(require_components(), 1);
3443 var import_data17 = __toESM(require_data(), 1);
3444 var import_keycodes3 = __toESM(require_keycodes(), 1);
3445 var import_core_data10 = __toESM(require_core_data(), 1);
3446 var import_element15 = __toESM(require_element(), 1);
3447 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
3448 function RedoButton(props, ref) {
3449 const shortcut = (0, import_keycodes3.isAppleOS)() ? import_keycodes3.displayShortcut.primaryShift("z") : import_keycodes3.displayShortcut.primary("y");
3450 const hasRedo = (0, import_data17.useSelect)(
3451 (select) => select(import_core_data10.store).hasRedo(),
3452 []
3453 );
3454 const { redo } = (0, import_data17.useDispatch)(import_core_data10.store);
3455 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3456 import_components13.Button,
3457 {
3458 ...props,
3459 ref,
3460 icon: !(0, import_i18n10.isRTL)() ? redo_default : undo_default,
3461 label: (0, import_i18n10.__)("Redo"),
3462 shortcut,
3463 "aria-disabled": !hasRedo,
3464 onClick: hasRedo ? redo : void 0,
3465 size: "compact"
3466 }
3467 );
3468 }
3469 var redo_default2 = (0, import_element15.forwardRef)(RedoButton);
3470
3471 // packages/edit-widgets/build-module/components/header/document-tools/index.mjs
3472 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3473 function DocumentTools() {
3474 const isMediumViewport = (0, import_compose6.useViewportMatch)("medium");
3475 const {
3476 isInserterOpen,
3477 isListViewOpen,
3478 inserterSidebarToggleRef: inserterSidebarToggleRef2,
3479 listViewToggleRef: listViewToggleRef2
3480 } = (0, import_data18.useSelect)((select) => {
3481 const {
3482 isInserterOpened: isInserterOpened2,
3483 getInserterSidebarToggleRef: getInserterSidebarToggleRef2,
3484 isListViewOpened: isListViewOpened2,
3485 getListViewToggleRef: getListViewToggleRef2
3486 } = unlock(select(store2));
3487 return {
3488 isInserterOpen: isInserterOpened2(),
3489 isListViewOpen: isListViewOpened2(),
3490 inserterSidebarToggleRef: getInserterSidebarToggleRef2(),
3491 listViewToggleRef: getListViewToggleRef2()
3492 };
3493 }, []);
3494 const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2 } = (0, import_data18.useDispatch)(store2);
3495 const toggleListView = (0, import_element16.useCallback)(
3496 () => setIsListViewOpened2(!isListViewOpen),
3497 [setIsListViewOpened2, isListViewOpen]
3498 );
3499 const toggleInserterSidebar = (0, import_element16.useCallback)(
3500 () => setIsInserterOpened2(!isInserterOpen),
3501 [setIsInserterOpened2, isInserterOpen]
3502 );
3503 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3504 import_block_editor11.NavigableToolbar,
3505 {
3506 className: "edit-widgets-header-toolbar",
3507 "aria-label": (0, import_i18n11.__)("Document tools"),
3508 variant: "unstyled",
3509 children: [
3510 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3511 import_components14.ToolbarItem,
3512 {
3513 ref: inserterSidebarToggleRef2,
3514 as: import_components14.Button,
3515 className: "edit-widgets-header-toolbar__inserter-toggle",
3516 variant: "primary",
3517 isPressed: isInserterOpen,
3518 onMouseDown: (event) => {
3519 event.preventDefault();
3520 },
3521 onClick: toggleInserterSidebar,
3522 icon: plus_default,
3523 label: (0, import_i18n11._x)(
3524 "Block Inserter",
3525 "Generic label for block inserter button"
3526 ),
3527 size: "compact"
3528 }
3529 ),
3530 isMediumViewport && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
3531 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components14.ToolbarItem, { as: undo_default2 }),
3532 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components14.ToolbarItem, { as: redo_default2 }),
3533 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3534 import_components14.ToolbarItem,
3535 {
3536 as: import_components14.Button,
3537 className: "edit-widgets-header-toolbar__list-view-toggle",
3538 icon: list_view_default,
3539 isPressed: isListViewOpen,
3540 label: (0, import_i18n11.__)("List View"),
3541 onClick: toggleListView,
3542 ref: listViewToggleRef2,
3543 size: "compact"
3544 }
3545 )
3546 ] })
3547 ]
3548 }
3549 );
3550 }
3551 var document_tools_default = DocumentTools;
3552
3553 // packages/edit-widgets/build-module/components/save-button/index.mjs
3554 var import_components15 = __toESM(require_components(), 1);
3555 var import_i18n12 = __toESM(require_i18n(), 1);
3556 var import_data19 = __toESM(require_data(), 1);
3557 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3558 function SaveButton() {
3559 const { hasEditedWidgetAreaIds, isSaving, isWidgetSaveLocked } = (0, import_data19.useSelect)(
3560 (select) => {
3561 const {
3562 getEditedWidgetAreas: getEditedWidgetAreas2,
3563 isSavingWidgetAreas: isSavingWidgetAreas2,
3564 isWidgetSavingLocked: isWidgetSavingLocked2
3565 } = select(store2);
3566 return {
3567 hasEditedWidgetAreaIds: getEditedWidgetAreas2()?.length > 0,
3568 isSaving: isSavingWidgetAreas2(),
3569 isWidgetSaveLocked: isWidgetSavingLocked2()
3570 };
3571 },
3572 []
3573 );
3574 const { saveEditedWidgetAreas: saveEditedWidgetAreas2 } = (0, import_data19.useDispatch)(store2);
3575 const isDisabled = isWidgetSaveLocked || isSaving || !hasEditedWidgetAreaIds;
3576 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3577 import_components15.Button,
3578 {
3579 variant: "primary",
3580 isBusy: isSaving,
3581 "aria-disabled": isDisabled,
3582 onClick: isDisabled ? void 0 : saveEditedWidgetAreas2,
3583 size: "compact",
3584 children: isSaving ? (0, import_i18n12.__)("Saving\u2026") : (0, import_i18n12.__)("Update")
3585 }
3586 );
3587 }
3588 var save_button_default = SaveButton;
3589
3590 // packages/edit-widgets/build-module/components/more-menu/index.mjs
3591 var import_components18 = __toESM(require_components(), 1);
3592 var import_element18 = __toESM(require_element(), 1);
3593 var import_i18n15 = __toESM(require_i18n(), 1);
3594 var import_preferences5 = __toESM(require_preferences(), 1);
3595 var import_keycodes5 = __toESM(require_keycodes(), 1);
3596 var import_keyboard_shortcuts5 = __toESM(require_keyboard_shortcuts(), 1);
3597 var import_compose7 = __toESM(require_compose(), 1);
3598
3599 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/index.mjs
3600 var import_components16 = __toESM(require_components(), 1);
3601 var import_i18n14 = __toESM(require_i18n(), 1);
3602 var import_keyboard_shortcuts4 = __toESM(require_keyboard_shortcuts(), 1);
3603 var import_data21 = __toESM(require_data(), 1);
3604
3605 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/config.mjs
3606 var import_i18n13 = __toESM(require_i18n(), 1);
3607 var textFormattingShortcuts = [
3608 {
3609 keyCombination: { modifier: "primary", character: "b" },
3610 description: (0, import_i18n13.__)("Make the selected text bold.")
3611 },
3612 {
3613 keyCombination: { modifier: "primary", character: "i" },
3614 description: (0, import_i18n13.__)("Make the selected text italic.")
3615 },
3616 {
3617 keyCombination: { modifier: "primary", character: "k" },
3618 description: (0, import_i18n13.__)("Convert the selected text into a link.")
3619 },
3620 {
3621 keyCombination: { modifier: "primaryShift", character: "k" },
3622 description: (0, import_i18n13.__)("Remove a link.")
3623 },
3624 {
3625 keyCombination: { character: "[[" },
3626 description: (0, import_i18n13.__)("Insert a link to a post or page.")
3627 },
3628 {
3629 keyCombination: { modifier: "primary", character: "u" },
3630 description: (0, import_i18n13.__)("Underline the selected text.")
3631 },
3632 {
3633 keyCombination: { modifier: "access", character: "d" },
3634 description: (0, import_i18n13.__)("Strikethrough the selected text.")
3635 },
3636 {
3637 keyCombination: { modifier: "access", character: "x" },
3638 description: (0, import_i18n13.__)("Make the selected text inline code.")
3639 },
3640 {
3641 keyCombination: {
3642 modifier: "access",
3643 character: "0"
3644 },
3645 aliases: [
3646 {
3647 modifier: "access",
3648 character: "7"
3649 }
3650 ],
3651 description: (0, import_i18n13.__)("Convert the current heading to a paragraph.")
3652 },
3653 {
3654 keyCombination: { modifier: "access", character: "1-6" },
3655 description: (0, import_i18n13.__)(
3656 "Convert the current paragraph or heading to a heading of level 1 to 6."
3657 )
3658 },
3659 {
3660 keyCombination: { modifier: "primaryShift", character: "SPACE" },
3661 description: (0, import_i18n13.__)("Add non breaking space.")
3662 }
3663 ];
3664
3665 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs
3666 var import_element17 = __toESM(require_element(), 1);
3667 var import_keycodes4 = __toESM(require_keycodes(), 1);
3668 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3669 function KeyCombination({ keyCombination, forceAriaLabel }) {
3670 const shortcut = keyCombination.modifier ? import_keycodes4.displayShortcutList[keyCombination.modifier](
3671 keyCombination.character
3672 ) : keyCombination.character;
3673 const ariaLabel = keyCombination.modifier ? import_keycodes4.shortcutAriaLabel[keyCombination.modifier](
3674 keyCombination.character
3675 ) : keyCombination.character;
3676 const shortcuts = Array.isArray(shortcut) ? shortcut : [shortcut];
3677 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3678 "kbd",
3679 {
3680 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key-combination",
3681 "aria-label": forceAriaLabel || ariaLabel,
3682 children: shortcuts.map((character, index) => {
3683 if (character === "+") {
3684 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_element17.Fragment, { children: character }, index);
3685 }
3686 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3687 "kbd",
3688 {
3689 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key",
3690 children: character
3691 },
3692 index
3693 );
3694 })
3695 }
3696 );
3697 }
3698 function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) {
3699 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
3700 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-description", children: description }),
3701 /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-term", children: [
3702 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3703 KeyCombination,
3704 {
3705 keyCombination,
3706 forceAriaLabel: ariaLabel
3707 }
3708 ),
3709 aliases.map((alias, index) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3710 KeyCombination,
3711 {
3712 keyCombination: alias,
3713 forceAriaLabel: ariaLabel
3714 },
3715 index
3716 ))
3717 ] })
3718 ] });
3719 }
3720 var shortcut_default = Shortcut;
3721
3722 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs
3723 var import_data20 = __toESM(require_data(), 1);
3724 var import_keyboard_shortcuts3 = __toESM(require_keyboard_shortcuts(), 1);
3725 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3726 function DynamicShortcut({ name: name2 }) {
3727 const { keyCombination, description, aliases } = (0, import_data20.useSelect)(
3728 (select) => {
3729 const {
3730 getShortcutKeyCombination,
3731 getShortcutDescription,
3732 getShortcutAliases
3733 } = select(import_keyboard_shortcuts3.store);
3734 return {
3735 keyCombination: getShortcutKeyCombination(name2),
3736 aliases: getShortcutAliases(name2),
3737 description: getShortcutDescription(name2)
3738 };
3739 },
3740 [name2]
3741 );
3742 if (!keyCombination) {
3743 return null;
3744 }
3745 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3746 shortcut_default,
3747 {
3748 keyCombination,
3749 description,
3750 aliases
3751 }
3752 );
3753 }
3754 var dynamic_shortcut_default = DynamicShortcut;
3755
3756 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/index.mjs
3757 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
3758 var ShortcutList = ({ shortcuts }) => (
3759 /*
3760 * Disable reason: The `list` ARIA role is redundant but
3761 * Safari+VoiceOver won't announce the list otherwise.
3762 */
3763 /* eslint-disable jsx-a11y/no-redundant-roles */
3764 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3765 "ul",
3766 {
3767 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-list",
3768 role: "list",
3769 children: shortcuts.map((shortcut, index) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3770 "li",
3771 {
3772 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut",
3773 children: typeof shortcut === "string" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dynamic_shortcut_default, { name: shortcut }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(shortcut_default, { ...shortcut })
3774 },
3775 index
3776 ))
3777 }
3778 )
3779 );
3780 var ShortcutSection = ({ title, shortcuts, className }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
3781 "section",
3782 {
3783 className: clsx_default(
3784 "edit-widgets-keyboard-shortcut-help-modal__section",
3785 className
3786 ),
3787 children: [
3788 !!title && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h2", { className: "edit-widgets-keyboard-shortcut-help-modal__section-title", children: title }),
3789 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ShortcutList, { shortcuts })
3790 ]
3791 }
3792 );
3793 var ShortcutCategorySection = ({
3794 title,
3795 categoryName,
3796 additionalShortcuts = []
3797 }) => {
3798 const categoryShortcuts = (0, import_data21.useSelect)(
3799 (select) => {
3800 return select(import_keyboard_shortcuts4.store).getCategoryShortcuts(
3801 categoryName
3802 );
3803 },
3804 [categoryName]
3805 );
3806 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3807 ShortcutSection,
3808 {
3809 title,
3810 shortcuts: categoryShortcuts.concat(additionalShortcuts)
3811 }
3812 );
3813 };
3814 function KeyboardShortcutHelpModal({
3815 isModalActive: isModalActive2,
3816 toggleModal
3817 }) {
3818 (0, import_keyboard_shortcuts4.useShortcut)("core/edit-widgets/keyboard-shortcuts", toggleModal, {
3819 bindGlobal: true
3820 });
3821 if (!isModalActive2) {
3822 return null;
3823 }
3824 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
3825 import_components16.Modal,
3826 {
3827 className: "edit-widgets-keyboard-shortcut-help-modal",
3828 title: (0, import_i18n14.__)("Keyboard shortcuts"),
3829 onRequestClose: toggleModal,
3830 children: [
3831 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3832 ShortcutSection,
3833 {
3834 className: "edit-widgets-keyboard-shortcut-help-modal__main-shortcuts",
3835 shortcuts: ["core/edit-widgets/keyboard-shortcuts"]
3836 }
3837 ),
3838 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3839 ShortcutCategorySection,
3840 {
3841 title: (0, import_i18n14.__)("Global shortcuts"),
3842 categoryName: "global"
3843 }
3844 ),
3845 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3846 ShortcutCategorySection,
3847 {
3848 title: (0, import_i18n14.__)("Selection shortcuts"),
3849 categoryName: "selection"
3850 }
3851 ),
3852 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3853 ShortcutCategorySection,
3854 {
3855 title: (0, import_i18n14.__)("Block shortcuts"),
3856 categoryName: "block",
3857 additionalShortcuts: [
3858 {
3859 keyCombination: { character: "/" },
3860 description: (0, import_i18n14.__)(
3861 "Change the block type after adding a new paragraph."
3862 ),
3863 /* translators: The forward-slash character. e.g. '/'. */
3864 ariaLabel: (0, import_i18n14.__)("Forward-slash")
3865 }
3866 ]
3867 }
3868 ),
3869 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3870 ShortcutSection,
3871 {
3872 title: (0, import_i18n14.__)("Text formatting"),
3873 shortcuts: textFormattingShortcuts
3874 }
3875 ),
3876 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3877 ShortcutCategorySection,
3878 {
3879 title: (0, import_i18n14.__)("List View shortcuts"),
3880 categoryName: "list-view"
3881 }
3882 )
3883 ]
3884 }
3885 );
3886 }
3887
3888 // packages/edit-widgets/build-module/components/more-menu/tools-more-menu-group.mjs
3889 var import_components17 = __toESM(require_components(), 1);
3890 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
3891 var { Fill: ToolsMoreMenuGroup, Slot: Slot4 } = (0, import_components17.createSlotFill)(
3892 "EditWidgetsToolsMoreMenuGroup"
3893 );
3894 ToolsMoreMenuGroup.Slot = ({ fillProps }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Slot4, { fillProps, children: (fills) => fills.length > 0 && fills });
3895 var tools_more_menu_group_default = ToolsMoreMenuGroup;
3896
3897 // packages/edit-widgets/build-module/components/more-menu/index.mjs
3898 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
3899 function MoreMenu() {
3900 const [
3901 isKeyboardShortcutsModalActive,
3902 setIsKeyboardShortcutsModalVisible
3903 ] = (0, import_element18.useState)(false);
3904 const toggleKeyboardShortcutsModal = () => setIsKeyboardShortcutsModalVisible(!isKeyboardShortcutsModalActive);
3905 (0, import_keyboard_shortcuts5.useShortcut)(
3906 "core/edit-widgets/keyboard-shortcuts",
3907 toggleKeyboardShortcutsModal
3908 );
3909 const isLargeViewport = (0, import_compose7.useViewportMatch)("medium");
3910 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3911 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3912 import_components18.DropdownMenu,
3913 {
3914 icon: more_vertical_default,
3915 label: (0, import_i18n15.__)("Options"),
3916 popoverProps: {
3917 placement: "bottom-end",
3918 className: "more-menu-dropdown__content"
3919 },
3920 toggleProps: {
3921 tooltipPosition: "bottom",
3922 size: "compact"
3923 },
3924 children: (onClose) => /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3925 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components18.MenuGroup, { label: (0, import_i18n15._x)("View", "noun"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3926 import_preferences5.PreferenceToggleMenuItem,
3927 {
3928 scope: "core/edit-widgets",
3929 name: "fixedToolbar",
3930 label: (0, import_i18n15.__)("Top toolbar"),
3931 info: (0, import_i18n15.__)(
3932 "Access all block and document tools in a single place"
3933 ),
3934 messageActivated: (0, import_i18n15.__)(
3935 "Top toolbar activated"
3936 ),
3937 messageDeactivated: (0, import_i18n15.__)(
3938 "Top toolbar deactivated"
3939 )
3940 }
3941 ) }),
3942 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_components18.MenuGroup, { label: (0, import_i18n15.__)("Tools"), children: [
3943 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3944 import_components18.MenuItem,
3945 {
3946 onClick: () => {
3947 setIsKeyboardShortcutsModalVisible(true);
3948 },
3949 shortcut: import_keycodes5.displayShortcut.access("h"),
3950 children: (0, import_i18n15.__)("Keyboard shortcuts")
3951 }
3952 ),
3953 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3954 import_preferences5.PreferenceToggleMenuItem,
3955 {
3956 scope: "core/edit-widgets",
3957 name: "welcomeGuide",
3958 label: (0, import_i18n15.__)("Welcome Guide")
3959 }
3960 ),
3961 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3962 import_components18.MenuItem,
3963 {
3964 role: "menuitem",
3965 icon: external_default,
3966 href: (0, import_i18n15.__)(
3967 "https://wordpress.org/documentation/article/block-based-widgets-editor/"
3968 ),
3969 target: "_blank",
3970 rel: "noopener",
3971 children: [
3972 (0, import_i18n15.__)("Help"),
3973 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(VisuallyHidden, {
3974 render: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", {}),
3975 /* translators: accessibility text */
3976 children: (0, import_i18n15.__)("(opens in a new tab)")
3977 })
3978 ]
3979 }
3980 ),
3981 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3982 tools_more_menu_group_default.Slot,
3983 {
3984 fillProps: { onClose }
3985 }
3986 )
3987 ] }),
3988 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_components18.MenuGroup, { label: (0, import_i18n15.__)("Preferences"), children: [
3989 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3990 import_preferences5.PreferenceToggleMenuItem,
3991 {
3992 scope: "core/edit-widgets",
3993 name: "keepCaretInsideBlock",
3994 label: (0, import_i18n15.__)(
3995 "Contain text cursor inside block"
3996 ),
3997 info: (0, import_i18n15.__)(
3998 "Aids screen readers by stopping text caret from leaving blocks."
3999 ),
4000 messageActivated: (0, import_i18n15.__)(
4001 "Contain text cursor inside block activated"
4002 ),
4003 messageDeactivated: (0, import_i18n15.__)(
4004 "Contain text cursor inside block deactivated"
4005 )
4006 }
4007 ),
4008 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4009 import_preferences5.PreferenceToggleMenuItem,
4010 {
4011 scope: "core/edit-widgets",
4012 name: "themeStyles",
4013 info: (0, import_i18n15.__)(
4014 "Make the editor look like your theme."
4015 ),
4016 label: (0, import_i18n15.__)("Use theme styles")
4017 }
4018 ),
4019 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4020 import_preferences5.PreferenceToggleMenuItem,
4021 {
4022 scope: "core/edit-widgets",
4023 name: "showBlockBreadcrumbs",
4024 label: (0, import_i18n15.__)("Display block breadcrumbs"),
4025 info: (0, import_i18n15.__)(
4026 "Shows block breadcrumbs at the bottom of the editor."
4027 ),
4028 messageActivated: (0, import_i18n15.__)(
4029 "Display block breadcrumbs activated"
4030 ),
4031 messageDeactivated: (0, import_i18n15.__)(
4032 "Display block breadcrumbs deactivated"
4033 )
4034 }
4035 )
4036 ] })
4037 ] })
4038 }
4039 ),
4040 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4041 KeyboardShortcutHelpModal,
4042 {
4043 isModalActive: isKeyboardShortcutsModalActive,
4044 toggleModal: toggleKeyboardShortcutsModal
4045 }
4046 )
4047 ] });
4048 }
4049
4050 // packages/edit-widgets/build-module/components/header/index.mjs
4051 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
4052 function Header() {
4053 const isLargeViewport = (0, import_compose8.useViewportMatch)("medium");
4054 const blockToolbarRef = (0, import_element19.useRef)();
4055 const { hasFixedToolbar } = (0, import_data22.useSelect)(
4056 (select) => ({
4057 hasFixedToolbar: !!select(import_preferences6.store).get(
4058 "core/edit-widgets",
4059 "fixedToolbar"
4060 )
4061 }),
4062 []
4063 );
4064 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header", children: [
4065 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header__navigable-toolbar-wrapper", children: [
4066 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h1", { className: "edit-widgets-header__title", children: (0, import_i18n16.__)("Widgets") }),
4067 !isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4068 VisuallyHidden,
4069 {
4070 className: "edit-widgets-header__title",
4071 render: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h1", {}),
4072 children: (0, import_i18n16.__)("Widgets")
4073 }
4074 ),
4075 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(document_tools_default, {}),
4076 hasFixedToolbar && isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
4077 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "selected-block-tools-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_block_editor12.BlockToolbar, { hideDragHandle: true }) }),
4078 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4079 import_components19.Popover.Slot,
4080 {
4081 ref: blockToolbarRef,
4082 name: "block-toolbar"
4083 }
4084 )
4085 ] })
4086 ] }),
4087 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header__actions", children: [
4088 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(pinned_items_default.Slot, { scope: "core/edit-widgets" }),
4089 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(save_button_default, {}),
4090 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(MoreMenu, {})
4091 ] })
4092 ] }) });
4093 }
4094 var header_default = Header;
4095
4096 // packages/edit-widgets/build-module/components/widget-areas-block-editor-content/index.mjs
4097 var import_block_editor13 = __toESM(require_block_editor(), 1);
4098 var import_compose9 = __toESM(require_compose(), 1);
4099 var import_data23 = __toESM(require_data(), 1);
4100 var import_element20 = __toESM(require_element(), 1);
4101 var import_preferences7 = __toESM(require_preferences(), 1);
4102
4103 // packages/edit-widgets/build-module/components/notices/index.mjs
4104 var import_notices2 = __toESM(require_notices(), 1);
4105 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
4106 function Notices() {
4107 return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
4108 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4109 import_notices2.InlineNotices,
4110 {
4111 pinnedNoticesClassName: "edit-widgets-notices__pinned",
4112 dismissibleNoticesClassName: "edit-widgets-notices__dismissible"
4113 }
4114 ),
4115 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_notices2.SnackbarNotices, { className: "edit-widgets-notices__snackbar" })
4116 ] });
4117 }
4118 var notices_default = Notices;
4119
4120 // packages/edit-widgets/build-module/components/widget-areas-block-editor-content/index.mjs
4121 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
4122 function WidgetAreasBlockEditorContent({
4123 blockEditorSettings
4124 }) {
4125 const hasThemeStyles = (0, import_data23.useSelect)(
4126 (select) => !!select(import_preferences7.store).get(
4127 "core/edit-widgets",
4128 "themeStyles"
4129 ),
4130 []
4131 );
4132 const isLargeViewport = (0, import_compose9.useViewportMatch)("medium");
4133 const styles = (0, import_element20.useMemo)(() => {
4134 return hasThemeStyles ? blockEditorSettings.styles : [];
4135 }, [blockEditorSettings, hasThemeStyles]);
4136 return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "edit-widgets-block-editor", children: [
4137 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(notices_default, {}),
4138 !isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.BlockToolbar, { hideDragHandle: true }),
4139 /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_block_editor13.BlockTools, { children: [
4140 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(keyboard_shortcuts_default, {}),
4141 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4142 import_block_editor13.__unstableEditorStyles,
4143 {
4144 styles,
4145 scope: ":where(.editor-styles-wrapper)"
4146 }
4147 ),
4148 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.BlockSelectionClearer, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.WritingFlow, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.BlockList, { className: "edit-widgets-main-block-list" }) }) })
4149 ] })
4150 ] });
4151 }
4152
4153 // packages/edit-widgets/build-module/components/secondary-sidebar/index.mjs
4154 var import_data27 = __toESM(require_data(), 1);
4155
4156 // packages/edit-widgets/build-module/components/secondary-sidebar/inserter-sidebar.mjs
4157 var import_block_editor15 = __toESM(require_block_editor(), 1);
4158 var import_compose10 = __toESM(require_compose(), 1);
4159 var import_element21 = __toESM(require_element(), 1);
4160 var import_data25 = __toESM(require_data(), 1);
4161
4162 // packages/edit-widgets/build-module/hooks/use-widget-library-insertion-point.mjs
4163 var import_data24 = __toESM(require_data(), 1);
4164 var import_block_editor14 = __toESM(require_block_editor(), 1);
4165 var import_core_data11 = __toESM(require_core_data(), 1);
4166 var useWidgetLibraryInsertionPoint = () => {
4167 const firstRootId = (0, import_data24.useSelect)((select) => {
4168 const { getEntityRecord } = select(import_core_data11.store);
4169 const widgetAreasPost = getEntityRecord(
4170 KIND,
4171 POST_TYPE,
4172 buildWidgetAreasPostId()
4173 );
4174 return widgetAreasPost?.blocks[0]?.clientId;
4175 }, []);
4176 return (0, import_data24.useSelect)(
4177 (select) => {
4178 const {
4179 getBlockRootClientId,
4180 getBlockSelectionEnd,
4181 getBlockOrder,
4182 getBlockIndex
4183 } = select(import_block_editor14.store);
4184 const insertionPoint = select(store2).__experimentalGetInsertionPoint();
4185 if (insertionPoint.rootClientId) {
4186 return insertionPoint;
4187 }
4188 const clientId = getBlockSelectionEnd() || firstRootId;
4189 const rootClientId = getBlockRootClientId(clientId);
4190 if (clientId && rootClientId === "") {
4191 return {
4192 rootClientId: clientId,
4193 insertionIndex: getBlockOrder(clientId).length
4194 };
4195 }
4196 return {
4197 rootClientId,
4198 insertionIndex: getBlockIndex(clientId) + 1
4199 };
4200 },
4201 [firstRootId]
4202 );
4203 };
4204 var use_widget_library_insertion_point_default = useWidgetLibraryInsertionPoint;
4205
4206 // packages/edit-widgets/build-module/components/secondary-sidebar/inserter-sidebar.mjs
4207 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
4208 function InserterSidebar() {
4209 const isMobileViewport = (0, import_compose10.useViewportMatch)("medium", "<");
4210 const { rootClientId, insertionIndex } = use_widget_library_insertion_point_default();
4211 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data25.useDispatch)(store2);
4212 const closeInserter = (0, import_element21.useCallback)(() => {
4213 return setIsInserterOpened2(false);
4214 }, [setIsInserterOpened2]);
4215 const libraryRef = (0, import_element21.useRef)();
4216 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "edit-widgets-layout__inserter-panel", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "edit-widgets-layout__inserter-panel-content", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4217 import_block_editor15.__experimentalLibrary,
4218 {
4219 showInserterHelpPanel: true,
4220 shouldFocusBlock: isMobileViewport,
4221 rootClientId,
4222 __experimentalInsertionIndex: insertionIndex,
4223 ref: libraryRef,
4224 onClose: closeInserter
4225 }
4226 ) }) });
4227 }
4228
4229 // packages/edit-widgets/build-module/components/secondary-sidebar/list-view-sidebar.mjs
4230 var import_block_editor16 = __toESM(require_block_editor(), 1);
4231 var import_components20 = __toESM(require_components(), 1);
4232 var import_compose11 = __toESM(require_compose(), 1);
4233 var import_data26 = __toESM(require_data(), 1);
4234 var import_element22 = __toESM(require_element(), 1);
4235 var import_i18n17 = __toESM(require_i18n(), 1);
4236 var import_keycodes6 = __toESM(require_keycodes(), 1);
4237 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
4238 function ListViewSidebar() {
4239 const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data26.useDispatch)(store2);
4240 const { getListViewToggleRef: getListViewToggleRef2 } = unlock((0, import_data26.useSelect)(store2));
4241 const [dropZoneElement, setDropZoneElement] = (0, import_element22.useState)(null);
4242 const focusOnMountRef = (0, import_compose11.useFocusOnMount)("firstElement");
4243 const closeListView = (0, import_element22.useCallback)(() => {
4244 setIsListViewOpened2(false);
4245 getListViewToggleRef2().current?.focus();
4246 }, [getListViewToggleRef2, setIsListViewOpened2]);
4247 const closeOnEscape = (0, import_element22.useCallback)(
4248 (event) => {
4249 if (event.keyCode === import_keycodes6.ESCAPE && !event.defaultPrevented) {
4250 event.preventDefault();
4251 closeListView();
4252 }
4253 },
4254 [closeListView]
4255 );
4256 return (
4257 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
4258 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
4259 "div",
4260 {
4261 className: "edit-widgets-editor__list-view-panel",
4262 onKeyDown: closeOnEscape,
4263 children: [
4264 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "edit-widgets-editor__list-view-panel-header", children: [
4265 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: (0, import_i18n17.__)("List View") }),
4266 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4267 import_components20.Button,
4268 {
4269 icon: close_small_default,
4270 label: (0, import_i18n17.__)("Close"),
4271 onClick: closeListView,
4272 size: "compact"
4273 }
4274 )
4275 ] }),
4276 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4277 "div",
4278 {
4279 className: "edit-widgets-editor__list-view-panel-content",
4280 ref: (0, import_compose11.useMergeRefs)([focusOnMountRef, setDropZoneElement]),
4281 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_block_editor16.__experimentalListView, { dropZoneElement })
4282 }
4283 )
4284 ]
4285 }
4286 )
4287 );
4288 }
4289
4290 // packages/edit-widgets/build-module/components/secondary-sidebar/index.mjs
4291 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
4292 function SecondarySidebar() {
4293 const { isInserterOpen, isListViewOpen } = (0, import_data27.useSelect)((select) => {
4294 const { isInserterOpened: isInserterOpened2, isListViewOpened: isListViewOpened2 } = select(store2);
4295 return {
4296 isInserterOpen: isInserterOpened2(),
4297 isListViewOpen: isListViewOpened2()
4298 };
4299 }, []);
4300 if (isInserterOpen) {
4301 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(InserterSidebar, {});
4302 }
4303 if (isListViewOpen) {
4304 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ListViewSidebar, {});
4305 }
4306 return null;
4307 }
4308
4309 // packages/edit-widgets/build-module/components/layout/interface.mjs
4310 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
4311 var interfaceLabels = {
4312 /* translators: accessibility text for the widgets screen top bar landmark region. */
4313 header: (0, import_i18n18.__)("Widgets top bar"),
4314 /* translators: accessibility text for the widgets screen content landmark region. */
4315 body: (0, import_i18n18.__)("Widgets and blocks"),
4316 /* translators: accessibility text for the widgets screen settings landmark region. */
4317 sidebar: (0, import_i18n18.__)("Widgets settings"),
4318 /* translators: accessibility text for the widgets screen footer landmark region. */
4319 footer: (0, import_i18n18.__)("Widgets footer")
4320 };
4321 function Interface({ blockEditorSettings }) {
4322 const isMobileViewport = (0, import_compose12.useViewportMatch)("medium", "<");
4323 const isHugeViewport = (0, import_compose12.useViewportMatch)("huge", ">=");
4324 const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2, closeGeneralSidebar: closeGeneralSidebar2 } = (0, import_data28.useDispatch)(store2);
4325 const {
4326 hasBlockBreadCrumbsEnabled,
4327 hasSidebarEnabled,
4328 isInserterOpened: isInserterOpened2,
4329 isListViewOpened: isListViewOpened2
4330 } = (0, import_data28.useSelect)(
4331 (select) => ({
4332 hasSidebarEnabled: !!select(
4333 store
4334 ).getActiveComplementaryArea(store2.name),
4335 isInserterOpened: !!select(store2).isInserterOpened(),
4336 isListViewOpened: !!select(store2).isListViewOpened(),
4337 hasBlockBreadCrumbsEnabled: !!select(import_preferences8.store).get(
4338 "core/edit-widgets",
4339 "showBlockBreadcrumbs"
4340 )
4341 }),
4342 []
4343 );
4344 (0, import_element23.useEffect)(() => {
4345 if (hasSidebarEnabled && !isHugeViewport) {
4346 setIsInserterOpened2(false);
4347 setIsListViewOpened2(false);
4348 }
4349 }, [hasSidebarEnabled, isHugeViewport]);
4350 (0, import_element23.useEffect)(() => {
4351 if ((isInserterOpened2 || isListViewOpened2) && !isHugeViewport) {
4352 closeGeneralSidebar2();
4353 }
4354 }, [isInserterOpened2, isListViewOpened2, isHugeViewport]);
4355 const secondarySidebarLabel = isListViewOpened2 ? (0, import_i18n18.__)("List View") : (0, import_i18n18.__)("Block Library");
4356 const hasSecondarySidebar = isListViewOpened2 || isInserterOpened2;
4357 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4358 interface_skeleton_default,
4359 {
4360 labels: {
4361 ...interfaceLabels,
4362 secondarySidebar: secondarySidebarLabel
4363 },
4364 header: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(header_default, {}),
4365 secondarySidebar: hasSecondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(SecondarySidebar, {}),
4366 sidebar: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(complementary_area_default.Slot, { scope: "core/edit-widgets" }),
4367 content: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_jsx_runtime44.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4368 WidgetAreasBlockEditorContent,
4369 {
4370 blockEditorSettings
4371 }
4372 ) }),
4373 footer: hasBlockBreadCrumbsEnabled && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "edit-widgets-layout__footer", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_block_editor17.BlockBreadcrumb, { rootLabelText: (0, import_i18n18.__)("Widgets") }) })
4374 }
4375 );
4376 }
4377 var interface_default = Interface;
4378
4379 // packages/edit-widgets/build-module/components/layout/unsaved-changes-warning.mjs
4380 var import_i18n19 = __toESM(require_i18n(), 1);
4381 var import_element24 = __toESM(require_element(), 1);
4382 var import_data29 = __toESM(require_data(), 1);
4383 function UnsavedChangesWarning() {
4384 const isDirty = (0, import_data29.useSelect)((select) => {
4385 const { getEditedWidgetAreas: getEditedWidgetAreas2 } = select(store2);
4386 const editedWidgetAreas = getEditedWidgetAreas2();
4387 return editedWidgetAreas?.length > 0;
4388 }, []);
4389 (0, import_element24.useEffect)(() => {
4390 const warnIfUnsavedChanges = (event) => {
4391 if (isDirty) {
4392 event.returnValue = (0, import_i18n19.__)(
4393 "You have unsaved changes. If you proceed, they will be lost."
4394 );
4395 return event.returnValue;
4396 }
4397 };
4398 window.addEventListener("beforeunload", warnIfUnsavedChanges);
4399 return () => {
4400 window.removeEventListener("beforeunload", warnIfUnsavedChanges);
4401 };
4402 }, [isDirty]);
4403 return null;
4404 }
4405
4406 // packages/edit-widgets/build-module/components/welcome-guide/index.mjs
4407 var import_data30 = __toESM(require_data(), 1);
4408 var import_components21 = __toESM(require_components(), 1);
4409 var import_i18n20 = __toESM(require_i18n(), 1);
4410 var import_element25 = __toESM(require_element(), 1);
4411 var import_preferences9 = __toESM(require_preferences(), 1);
4412 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
4413 function WelcomeGuide() {
4414 const isActive = (0, import_data30.useSelect)(
4415 (select) => !!select(import_preferences9.store).get(
4416 "core/edit-widgets",
4417 "welcomeGuide"
4418 ),
4419 []
4420 );
4421 const { toggle } = (0, import_data30.useDispatch)(import_preferences9.store);
4422 const widgetAreas = (0, import_data30.useSelect)(
4423 (select) => select(store2).getWidgetAreas({ per_page: -1 }),
4424 []
4425 );
4426 if (!isActive) {
4427 return null;
4428 }
4429 const isEntirelyBlockWidgets = widgetAreas?.every(
4430 (widgetArea) => widgetArea.id === "wp_inactive_widgets" || widgetArea.widgets.every(
4431 (widgetId) => widgetId.startsWith("block-")
4432 )
4433 );
4434 const numWidgetAreas = widgetAreas?.filter(
4435 (widgetArea) => widgetArea.id !== "wp_inactive_widgets"
4436 ).length ?? 0;
4437 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4438 import_components21.Guide,
4439 {
4440 className: "edit-widgets-welcome-guide",
4441 contentLabel: (0, import_i18n20.__)("Welcome to block Widgets"),
4442 finishButtonText: (0, import_i18n20.__)("Get started"),
4443 onFinish: () => toggle("core/edit-widgets", "welcomeGuide"),
4444 pages: [
4445 {
4446 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4447 WelcomeGuideImage,
4448 {
4449 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.svg",
4450 animatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.gif"
4451 }
4452 ),
4453 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4454 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Welcome to block Widgets") }),
4455 isEntirelyBlockWidgets ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_jsx_runtime45.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.sprintf)(
4456 // Translators: %s: Number of block areas in the current theme.
4457 (0, import_i18n20._n)(
4458 "Your theme provides %s \u201Cblock\u201D area for you to add and edit content.\xA0Try adding a search bar, social icons, or other types of blocks here and see how they\u2019ll look on your site.",
4459 "Your theme provides %s different \u201Cblock\u201D areas for you to add and edit content.\xA0Try adding a search bar, social icons, or other types of blocks here and see how they\u2019ll look on your site.",
4460 numWidgetAreas
4461 ),
4462 numWidgetAreas
4463 ) }) }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4464 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.__)(
4465 "You can now add any block to your site\u2019s widget areas. Don\u2019t worry, all of your favorite widgets still work flawlessly."
4466 ) }),
4467 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("p", { className: "edit-widgets-welcome-guide__text", children: [
4468 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("strong", { children: (0, import_i18n20.__)(
4469 "Want to stick with the old widgets?"
4470 ) }),
4471 " ",
4472 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4473 import_components21.ExternalLink,
4474 {
4475 href: (0, import_i18n20.__)(
4476 "https://wordpress.org/plugins/classic-widgets/"
4477 ),
4478 children: (0, import_i18n20.__)(
4479 "Get the Classic Widgets plugin."
4480 )
4481 }
4482 )
4483 ] })
4484 ] })
4485 ] })
4486 },
4487 {
4488 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4489 WelcomeGuideImage,
4490 {
4491 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-editor.svg",
4492 animatedSrc: "https://s.w.org/images/block-editor/welcome-editor.gif"
4493 }
4494 ),
4495 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4496 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Customize each block") }),
4497 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.__)(
4498 "Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected."
4499 ) })
4500 ] })
4501 },
4502 {
4503 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4504 WelcomeGuideImage,
4505 {
4506 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-library.svg",
4507 animatedSrc: "https://s.w.org/images/block-editor/welcome-library.gif"
4508 }
4509 ),
4510 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4511 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Explore all blocks") }),
4512 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_element25.createInterpolateElement)(
4513 (0, import_i18n20.__)(
4514 "All of the blocks available to you live in the block library. You\u2019ll find it wherever you see the <InserterIconImage /> icon."
4515 ),
4516 {
4517 InserterIconImage: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4518 "img",
4519 {
4520 className: "edit-widgets-welcome-guide__inserter-icon",
4521 alt: (0, import_i18n20.__)("inserter"),
4522 src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A"
4523 }
4524 )
4525 }
4526 ) })
4527 ] })
4528 },
4529 {
4530 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4531 WelcomeGuideImage,
4532 {
4533 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
4534 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
4535 }
4536 ),
4537 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4538 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Learn more") }),
4539 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_element25.createInterpolateElement)(
4540 (0, import_i18n20.__)(
4541 "New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>"
4542 ),
4543 {
4544 a: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4545 import_components21.ExternalLink,
4546 {
4547 href: (0, import_i18n20.__)(
4548 "https://wordpress.org/documentation/article/wordpress-block-editor/"
4549 )
4550 }
4551 )
4552 }
4553 ) })
4554 ] })
4555 }
4556 ]
4557 }
4558 );
4559 }
4560 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) {
4561 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("picture", { className: "edit-widgets-welcome-guide__image", children: [
4562 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4563 "source",
4564 {
4565 srcSet: nonAnimatedSrc,
4566 media: "(prefers-reduced-motion: reduce)"
4567 }
4568 ),
4569 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" })
4570 ] });
4571 }
4572
4573 // packages/edit-widgets/build-module/components/layout/index.mjs
4574 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
4575 function Layout({ blockEditorSettings }) {
4576 const { createErrorNotice } = (0, import_data31.useDispatch)(import_notices4.store);
4577 function onPluginAreaError(name2) {
4578 createErrorNotice(
4579 (0, import_i18n21.sprintf)(
4580 /* translators: %s: plugin name */
4581 (0, import_i18n21.__)(
4582 'The "%s" plugin has encountered an error and cannot be rendered.'
4583 ),
4584 name2
4585 )
4586 );
4587 }
4588 const navigateRegionsProps = (0, import_components22.__unstableUseNavigateRegions)();
4589 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4590 "div",
4591 {
4592 className: navigateRegionsProps.className,
4593 ...navigateRegionsProps,
4594 ref: navigateRegionsProps.ref,
4595 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
4596 WidgetAreasBlockEditorProvider,
4597 {
4598 blockEditorSettings,
4599 children: [
4600 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(interface_default, { blockEditorSettings }),
4601 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Sidebar, {}),
4602 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_plugins3.PluginArea, { onError: onPluginAreaError }),
4603 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(UnsavedChangesWarning, {}),
4604 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(WelcomeGuide, {})
4605 ]
4606 }
4607 )
4608 }
4609 ) });
4610 }
4611 var layout_default = Layout;
4612
4613 // packages/edit-widgets/build-module/index.mjs
4614 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
4615 var disabledBlocks = [
4616 "core/more",
4617 "core/freeform",
4618 "core/template-part",
4619 ...ALLOW_REUSABLE_BLOCKS ? [] : ["core/block"]
4620 ];
4621 function initializeEditor(id, settings2) {
4622 const target = document.getElementById(id);
4623 const root = (0, import_element26.createRoot)(target);
4624 const coreBlocks = (0, import_block_library2.__experimentalGetCoreBlocks)().filter((block) => {
4625 return !(disabledBlocks.includes(block.name) || block.name.startsWith("core/post") || block.name.startsWith("core/query") || block.name.startsWith("core/site") || block.name.startsWith("core/navigation") || block.name.startsWith("core/term"));
4626 });
4627 (0, import_data32.dispatch)(import_preferences10.store).setDefaults("core/edit-widgets", {
4628 fixedToolbar: false,
4629 welcomeGuide: true,
4630 showBlockBreadcrumbs: true,
4631 themeStyles: true
4632 });
4633 (0, import_data32.dispatch)(import_blocks3.store).reapplyBlockTypeFilters();
4634 (0, import_block_library2.registerCoreBlocks)(coreBlocks);
4635 (0, import_widgets5.registerLegacyWidgetBlock)();
4636 if (true) {
4637 (0, import_block_library2.__experimentalRegisterExperimentalCoreBlocks)({
4638 enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS
4639 });
4640 }
4641 (0, import_widgets5.registerLegacyWidgetVariations)(settings2);
4642 registerBlock(widget_area_exports);
4643 (0, import_widgets5.registerWidgetGroupBlock)();
4644 settings2.__experimentalFetchLinkSuggestions = (search, searchOptions) => (0, import_core_data12.__experimentalFetchLinkSuggestions)(search, searchOptions, settings2);
4645 (0, import_blocks3.setFreeformContentHandlerName)("core/html");
4646 root.render(
4647 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_element26.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(layout_default, { blockEditorSettings: settings2 }) })
4648 );
4649 return root;
4650 }
4651 var initialize = initializeEditor;
4652 function reinitializeEditor() {
4653 (0, import_deprecated6.default)("wp.editWidgets.reinitializeEditor", {
4654 since: "6.2",
4655 version: "6.3"
4656 });
4657 }
4658 var registerBlock = (block) => {
4659 if (!block) {
4660 return;
4661 }
4662 const { metadata, settings: settings2, name: name2 } = block;
4663 if (metadata) {
4664 (0, import_blocks3.unstable__bootstrapServerSideBlockDefinitions)({ [name2]: metadata });
4665 }
4666 (0, import_blocks3.registerBlockType)(name2, settings2);
4667 };
4668 return __toCommonJS(index_exports);
4669 })();
4670 //# sourceMappingURL=index.js.map
4671