PluginProbe
Gutenberg / 22.3.0
Gutenberg v22.3.0
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 22.3.0, at build/scripts/edit-widgets/index.js

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