| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 (function() { 2 "use strict"; 3 var wp; 4 (wp ||= {}).blocks = (() => { 5 var __create = Object.create; 6 var __defProp = Object.defineProperty; 7 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 8 var __getOwnPropNames = Object.getOwnPropertyNames; 9 var __getProtoOf = Object.getPrototypeOf; 10 var __hasOwnProp = Object.prototype.hasOwnProperty; 11 var __commonJS = (cb, mod) => function __require() { 12 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 13 }; 14 var __export = (target, all) => { 15 for (var name in all) 16 __defProp(target, name, { get: all[name], enumerable: true }); 17 }; 18 var __copyProps = (to, from, except, desc) => { 19 if (from && typeof from === "object" || typeof from === "function") { 20 for (let key of __getOwnPropNames(from)) 21 if (!__hasOwnProp.call(to, key) && key !== except) 22 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 23 } 24 return to; 25 }; 26 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 27 // If the importer is in node compatibility mode or this is not an ESM 28 // file that has been converted to a CommonJS file using a Babel- 29 // compatible transform (i.e. "__esModule" has not been set), then set 30 // "default" to the CommonJS "module.exports" for node compatibility. 31 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 32 mod 33 )); 34 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 35 36 // package-external:@wordpress/data 37 var require_data = __commonJS({ 38 "package-external:@wordpress/data"(exports, module) { 39 module.exports = window.wp.data; 40 } 41 }); 42 43 // package-external:@wordpress/i18n 44 var require_i18n = __commonJS({ 45 "package-external:@wordpress/i18n"(exports, module) { 46 module.exports = window.wp.i18n; 47 } 48 }); 49 50 // package-external:@wordpress/element 51 var require_element = __commonJS({ 52 "package-external:@wordpress/element"(exports, module) { 53 module.exports = window.wp.element; 54 } 55 }); 56 57 // package-external:@wordpress/dom 58 var require_dom = __commonJS({ 59 "package-external:@wordpress/dom"(exports, module) { 60 module.exports = window.wp.dom; 61 } 62 }); 63 64 // package-external:@wordpress/rich-text 65 var require_rich_text = __commonJS({ 66 "package-external:@wordpress/rich-text"(exports, module) { 67 module.exports = window.wp.richText; 68 } 69 }); 70 71 // package-external:@wordpress/deprecated 72 var require_deprecated = __commonJS({ 73 "package-external:@wordpress/deprecated"(exports, module) { 74 module.exports = window.wp.deprecated; 75 } 76 }); 77 78 // package-external:@wordpress/warning 79 var require_warning = __commonJS({ 80 "package-external:@wordpress/warning"(exports, module) { 81 module.exports = window.wp.warning; 82 } 83 }); 84 85 // package-external:@wordpress/private-apis 86 var require_private_apis = __commonJS({ 87 "package-external:@wordpress/private-apis"(exports, module) { 88 module.exports = window.wp.privateApis; 89 } 90 }); 91 92 // node_modules/remove-accents/index.js 93 var require_remove_accents = __commonJS({ 94 "node_modules/remove-accents/index.js"(exports, module) { 95 var characterMap = { 96 "\xC0": "A", 97 "\xC1": "A", 98 "\xC2": "A", 99 "\xC3": "A", 100 "\xC4": "A", 101 "\xC5": "A", 102 "\u1EA4": "A", 103 "\u1EAE": "A", 104 "\u1EB2": "A", 105 "\u1EB4": "A", 106 "\u1EB6": "A", 107 "\xC6": "AE", 108 "\u1EA6": "A", 109 "\u1EB0": "A", 110 "\u0202": "A", 111 "\u1EA2": "A", 112 "\u1EA0": "A", 113 "\u1EA8": "A", 114 "\u1EAA": "A", 115 "\u1EAC": "A", 116 "\xC7": "C", 117 "\u1E08": "C", 118 "\xC8": "E", 119 "\xC9": "E", 120 "\xCA": "E", 121 "\xCB": "E", 122 "\u1EBE": "E", 123 "\u1E16": "E", 124 "\u1EC0": "E", 125 "\u1E14": "E", 126 "\u1E1C": "E", 127 "\u0206": "E", 128 "\u1EBA": "E", 129 "\u1EBC": "E", 130 "\u1EB8": "E", 131 "\u1EC2": "E", 132 "\u1EC4": "E", 133 "\u1EC6": "E", 134 "\xCC": "I", 135 "\xCD": "I", 136 "\xCE": "I", 137 "\xCF": "I", 138 "\u1E2E": "I", 139 "\u020A": "I", 140 "\u1EC8": "I", 141 "\u1ECA": "I", 142 "\xD0": "D", 143 "\xD1": "N", 144 "\xD2": "O", 145 "\xD3": "O", 146 "\xD4": "O", 147 "\xD5": "O", 148 "\xD6": "O", 149 "\xD8": "O", 150 "\u1ED0": "O", 151 "\u1E4C": "O", 152 "\u1E52": "O", 153 "\u020E": "O", 154 "\u1ECE": "O", 155 "\u1ECC": "O", 156 "\u1ED4": "O", 157 "\u1ED6": "O", 158 "\u1ED8": "O", 159 "\u1EDC": "O", 160 "\u1EDE": "O", 161 "\u1EE0": "O", 162 "\u1EDA": "O", 163 "\u1EE2": "O", 164 "\xD9": "U", 165 "\xDA": "U", 166 "\xDB": "U", 167 "\xDC": "U", 168 "\u1EE6": "U", 169 "\u1EE4": "U", 170 "\u1EEC": "U", 171 "\u1EEE": "U", 172 "\u1EF0": "U", 173 "\xDD": "Y", 174 "\xE0": "a", 175 "\xE1": "a", 176 "\xE2": "a", 177 "\xE3": "a", 178 "\xE4": "a", 179 "\xE5": "a", 180 "\u1EA5": "a", 181 "\u1EAF": "a", 182 "\u1EB3": "a", 183 "\u1EB5": "a", 184 "\u1EB7": "a", 185 "\xE6": "ae", 186 "\u1EA7": "a", 187 "\u1EB1": "a", 188 "\u0203": "a", 189 "\u1EA3": "a", 190 "\u1EA1": "a", 191 "\u1EA9": "a", 192 "\u1EAB": "a", 193 "\u1EAD": "a", 194 "\xE7": "c", 195 "\u1E09": "c", 196 "\xE8": "e", 197 "\xE9": "e", 198 "\xEA": "e", 199 "\xEB": "e", 200 "\u1EBF": "e", 201 "\u1E17": "e", 202 "\u1EC1": "e", 203 "\u1E15": "e", 204 "\u1E1D": "e", 205 "\u0207": "e", 206 "\u1EBB": "e", 207 "\u1EBD": "e", 208 "\u1EB9": "e", 209 "\u1EC3": "e", 210 "\u1EC5": "e", 211 "\u1EC7": "e", 212 "\xEC": "i", 213 "\xED": "i", 214 "\xEE": "i", 215 "\xEF": "i", 216 "\u1E2F": "i", 217 "\u020B": "i", 218 "\u1EC9": "i", 219 "\u1ECB": "i", 220 "\xF0": "d", 221 "\xF1": "n", 222 "\xF2": "o", 223 "\xF3": "o", 224 "\xF4": "o", 225 "\xF5": "o", 226 "\xF6": "o", 227 "\xF8": "o", 228 "\u1ED1": "o", 229 "\u1E4D": "o", 230 "\u1E53": "o", 231 "\u020F": "o", 232 "\u1ECF": "o", 233 "\u1ECD": "o", 234 "\u1ED5": "o", 235 "\u1ED7": "o", 236 "\u1ED9": "o", 237 "\u1EDD": "o", 238 "\u1EDF": "o", 239 "\u1EE1": "o", 240 "\u1EDB": "o", 241 "\u1EE3": "o", 242 "\xF9": "u", 243 "\xFA": "u", 244 "\xFB": "u", 245 "\xFC": "u", 246 "\u1EE7": "u", 247 "\u1EE5": "u", 248 "\u1EED": "u", 249 "\u1EEF": "u", 250 "\u1EF1": "u", 251 "\xFD": "y", 252 "\xFF": "y", 253 "\u0100": "A", 254 "\u0101": "a", 255 "\u0102": "A", 256 "\u0103": "a", 257 "\u0104": "A", 258 "\u0105": "a", 259 "\u0106": "C", 260 "\u0107": "c", 261 "\u0108": "C", 262 "\u0109": "c", 263 "\u010A": "C", 264 "\u010B": "c", 265 "\u010C": "C", 266 "\u010D": "c", 267 "C\u0306": "C", 268 "c\u0306": "c", 269 "\u010E": "D", 270 "\u010F": "d", 271 "\u0110": "D", 272 "\u0111": "d", 273 "\u0112": "E", 274 "\u0113": "e", 275 "\u0114": "E", 276 "\u0115": "e", 277 "\u0116": "E", 278 "\u0117": "e", 279 "\u0118": "E", 280 "\u0119": "e", 281 "\u011A": "E", 282 "\u011B": "e", 283 "\u011C": "G", 284 "\u01F4": "G", 285 "\u011D": "g", 286 "\u01F5": "g", 287 "\u011E": "G", 288 "\u011F": "g", 289 "\u0120": "G", 290 "\u0121": "g", 291 "\u0122": "G", 292 "\u0123": "g", 293 "\u0124": "H", 294 "\u0125": "h", 295 "\u0126": "H", 296 "\u0127": "h", 297 "\u1E2A": "H", 298 "\u1E2B": "h", 299 "\u0128": "I", 300 "\u0129": "i", 301 "\u012A": "I", 302 "\u012B": "i", 303 "\u012C": "I", 304 "\u012D": "i", 305 "\u012E": "I", 306 "\u012F": "i", 307 "\u0130": "I", 308 "\u0131": "i", 309 "\u0132": "IJ", 310 "\u0133": "ij", 311 "\u0134": "J", 312 "\u0135": "j", 313 "\u0136": "K", 314 "\u0137": "k", 315 "\u1E30": "K", 316 "\u1E31": "k", 317 "K\u0306": "K", 318 "k\u0306": "k", 319 "\u0139": "L", 320 "\u013A": "l", 321 "\u013B": "L", 322 "\u013C": "l", 323 "\u013D": "L", 324 "\u013E": "l", 325 "\u013F": "L", 326 "\u0140": "l", 327 "\u0141": "l", 328 "\u0142": "l", 329 "\u1E3E": "M", 330 "\u1E3F": "m", 331 "M\u0306": "M", 332 "m\u0306": "m", 333 "\u0143": "N", 334 "\u0144": "n", 335 "\u0145": "N", 336 "\u0146": "n", 337 "\u0147": "N", 338 "\u0148": "n", 339 "\u0149": "n", 340 "N\u0306": "N", 341 "n\u0306": "n", 342 "\u014C": "O", 343 "\u014D": "o", 344 "\u014E": "O", 345 "\u014F": "o", 346 "\u0150": "O", 347 "\u0151": "o", 348 "\u0152": "OE", 349 "\u0153": "oe", 350 "P\u0306": "P", 351 "p\u0306": "p", 352 "\u0154": "R", 353 "\u0155": "r", 354 "\u0156": "R", 355 "\u0157": "r", 356 "\u0158": "R", 357 "\u0159": "r", 358 "R\u0306": "R", 359 "r\u0306": "r", 360 "\u0212": "R", 361 "\u0213": "r", 362 "\u015A": "S", 363 "\u015B": "s", 364 "\u015C": "S", 365 "\u015D": "s", 366 "\u015E": "S", 367 "\u0218": "S", 368 "\u0219": "s", 369 "\u015F": "s", 370 "\u0160": "S", 371 "\u0161": "s", 372 "\u0162": "T", 373 "\u0163": "t", 374 "\u021B": "t", 375 "\u021A": "T", 376 "\u0164": "T", 377 "\u0165": "t", 378 "\u0166": "T", 379 "\u0167": "t", 380 "T\u0306": "T", 381 "t\u0306": "t", 382 "\u0168": "U", 383 "\u0169": "u", 384 "\u016A": "U", 385 "\u016B": "u", 386 "\u016C": "U", 387 "\u016D": "u", 388 "\u016E": "U", 389 "\u016F": "u", 390 "\u0170": "U", 391 "\u0171": "u", 392 "\u0172": "U", 393 "\u0173": "u", 394 "\u0216": "U", 395 "\u0217": "u", 396 "V\u0306": "V", 397 "v\u0306": "v", 398 "\u0174": "W", 399 "\u0175": "w", 400 "\u1E82": "W", 401 "\u1E83": "w", 402 "X\u0306": "X", 403 "x\u0306": "x", 404 "\u0176": "Y", 405 "\u0177": "y", 406 "\u0178": "Y", 407 "Y\u0306": "Y", 408 "y\u0306": "y", 409 "\u0179": "Z", 410 "\u017A": "z", 411 "\u017B": "Z", 412 "\u017C": "z", 413 "\u017D": "Z", 414 "\u017E": "z", 415 "\u017F": "s", 416 "\u0192": "f", 417 "\u01A0": "O", 418 "\u01A1": "o", 419 "\u01AF": "U", 420 "\u01B0": "u", 421 "\u01CD": "A", 422 "\u01CE": "a", 423 "\u01CF": "I", 424 "\u01D0": "i", 425 "\u01D1": "O", 426 "\u01D2": "o", 427 "\u01D3": "U", 428 "\u01D4": "u", 429 "\u01D5": "U", 430 "\u01D6": "u", 431 "\u01D7": "U", 432 "\u01D8": "u", 433 "\u01D9": "U", 434 "\u01DA": "u", 435 "\u01DB": "U", 436 "\u01DC": "u", 437 "\u1EE8": "U", 438 "\u1EE9": "u", 439 "\u1E78": "U", 440 "\u1E79": "u", 441 "\u01FA": "A", 442 "\u01FB": "a", 443 "\u01FC": "AE", 444 "\u01FD": "ae", 445 "\u01FE": "O", 446 "\u01FF": "o", 447 "\xDE": "TH", 448 "\xFE": "th", 449 "\u1E54": "P", 450 "\u1E55": "p", 451 "\u1E64": "S", 452 "\u1E65": "s", 453 "X\u0301": "X", 454 "x\u0301": "x", 455 "\u0403": "\u0413", 456 "\u0453": "\u0433", 457 "\u040C": "\u041A", 458 "\u045C": "\u043A", 459 "A\u030B": "A", 460 "a\u030B": "a", 461 "E\u030B": "E", 462 "e\u030B": "e", 463 "I\u030B": "I", 464 "i\u030B": "i", 465 "\u01F8": "N", 466 "\u01F9": "n", 467 "\u1ED2": "O", 468 "\u1ED3": "o", 469 "\u1E50": "O", 470 "\u1E51": "o", 471 "\u1EEA": "U", 472 "\u1EEB": "u", 473 "\u1E80": "W", 474 "\u1E81": "w", 475 "\u1EF2": "Y", 476 "\u1EF3": "y", 477 "\u0200": "A", 478 "\u0201": "a", 479 "\u0204": "E", 480 "\u0205": "e", 481 "\u0208": "I", 482 "\u0209": "i", 483 "\u020C": "O", 484 "\u020D": "o", 485 "\u0210": "R", 486 "\u0211": "r", 487 "\u0214": "U", 488 "\u0215": "u", 489 "B\u030C": "B", 490 "b\u030C": "b", 491 "\u010C\u0323": "C", 492 "\u010D\u0323": "c", 493 "\xCA\u030C": "E", 494 "\xEA\u030C": "e", 495 "F\u030C": "F", 496 "f\u030C": "f", 497 "\u01E6": "G", 498 "\u01E7": "g", 499 "\u021E": "H", 500 "\u021F": "h", 501 "J\u030C": "J", 502 "\u01F0": "j", 503 "\u01E8": "K", 504 "\u01E9": "k", 505 "M\u030C": "M", 506 "m\u030C": "m", 507 "P\u030C": "P", 508 "p\u030C": "p", 509 "Q\u030C": "Q", 510 "q\u030C": "q", 511 "\u0158\u0329": "R", 512 "\u0159\u0329": "r", 513 "\u1E66": "S", 514 "\u1E67": "s", 515 "V\u030C": "V", 516 "v\u030C": "v", 517 "W\u030C": "W", 518 "w\u030C": "w", 519 "X\u030C": "X", 520 "x\u030C": "x", 521 "Y\u030C": "Y", 522 "y\u030C": "y", 523 "A\u0327": "A", 524 "a\u0327": "a", 525 "B\u0327": "B", 526 "b\u0327": "b", 527 "\u1E10": "D", 528 "\u1E11": "d", 529 "\u0228": "E", 530 "\u0229": "e", 531 "\u0190\u0327": "E", 532 "\u025B\u0327": "e", 533 "\u1E28": "H", 534 "\u1E29": "h", 535 "I\u0327": "I", 536 "i\u0327": "i", 537 "\u0197\u0327": "I", 538 "\u0268\u0327": "i", 539 "M\u0327": "M", 540 "m\u0327": "m", 541 "O\u0327": "O", 542 "o\u0327": "o", 543 "Q\u0327": "Q", 544 "q\u0327": "q", 545 "U\u0327": "U", 546 "u\u0327": "u", 547 "X\u0327": "X", 548 "x\u0327": "x", 549 "Z\u0327": "Z", 550 "z\u0327": "z", 551 "\u0439": "\u0438", 552 "\u0419": "\u0418", 553 "\u0451": "\u0435", 554 "\u0401": "\u0415" 555 }; 556 var chars = Object.keys(characterMap).join("|"); 557 var allAccents = new RegExp(chars, "g"); 558 var firstAccent = new RegExp(chars, ""); 559 function matcher3(match) { 560 return characterMap[match]; 561 } 562 var removeAccents2 = function(string) { 563 return string.replace(allAccents, matcher3); 564 }; 565 var hasAccents = function(string) { 566 return !!string.match(firstAccent); 567 }; 568 module.exports = removeAccents2; 569 module.exports.has = hasAccents; 570 module.exports.remove = removeAccents2; 571 } 572 }); 573 574 // node_modules/fast-deep-equal/es6/index.js 575 var require_es6 = __commonJS({ 576 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 577 "use strict"; 578 module.exports = function equal(a, b2) { 579 if (a === b2) return true; 580 if (a && b2 && typeof a == "object" && typeof b2 == "object") { 581 if (a.constructor !== b2.constructor) return false; 582 var length, i, keys; 583 if (Array.isArray(a)) { 584 length = a.length; 585 if (length != b2.length) return false; 586 for (i = length; i-- !== 0; ) 587 if (!equal(a[i], b2[i])) return false; 588 return true; 589 } 590 if (a instanceof Map && b2 instanceof Map) { 591 if (a.size !== b2.size) return false; 592 for (i of a.entries()) 593 if (!b2.has(i[0])) return false; 594 for (i of a.entries()) 595 if (!equal(i[1], b2.get(i[0]))) return false; 596 return true; 597 } 598 if (a instanceof Set && b2 instanceof Set) { 599 if (a.size !== b2.size) return false; 600 for (i of a.entries()) 601 if (!b2.has(i[0])) return false; 602 return true; 603 } 604 if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b2)) { 605 length = a.length; 606 if (length != b2.length) return false; 607 for (i = length; i-- !== 0; ) 608 if (a[i] !== b2[i]) return false; 609 return true; 610 } 611 if (a.constructor === RegExp) return a.source === b2.source && a.flags === b2.flags; 612 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b2.valueOf(); 613 if (a.toString !== Object.prototype.toString) return a.toString() === b2.toString(); 614 keys = Object.keys(a); 615 length = keys.length; 616 if (length !== Object.keys(b2).length) return false; 617 for (i = length; i-- !== 0; ) 618 if (!Object.prototype.hasOwnProperty.call(b2, keys[i])) return false; 619 for (i = length; i-- !== 0; ) { 620 var key = keys[i]; 621 if (!equal(a[key], b2[key])) return false; 622 } 623 return true; 624 } 625 return a !== a && b2 !== b2; 626 }; 627 } 628 }); 629 630 // packages/blocks/node_modules/react-is/cjs/react-is.development.js 631 var require_react_is_development = __commonJS({ 632 "packages/blocks/node_modules/react-is/cjs/react-is.development.js"(exports) { 633 "use strict"; 634 if (true) { 635 (function() { 636 "use strict"; 637 var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.element"); 638 var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"); 639 var REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"); 640 var REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"); 641 var REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"); 642 var REACT_PROVIDER_TYPE = /* @__PURE__ */ Symbol.for("react.provider"); 643 var REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"); 644 var REACT_SERVER_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.server_context"); 645 var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"); 646 var REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"); 647 var REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"); 648 var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"); 649 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); 650 var REACT_OFFSCREEN_TYPE = /* @__PURE__ */ Symbol.for("react.offscreen"); 651 var enableScopeAPI = false; 652 var enableCacheElement = false; 653 var enableTransitionTracing = false; 654 var enableLegacyHidden = false; 655 var enableDebugTracing = false; 656 var REACT_MODULE_REFERENCE; 657 { 658 REACT_MODULE_REFERENCE = /* @__PURE__ */ Symbol.for("react.module.reference"); 659 } 660 function isValidElementType2(type) { 661 if (typeof type === "string" || typeof type === "function") { 662 return true; 663 } 664 if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) { 665 return true; 666 } 667 if (typeof type === "object" && type !== null) { 668 if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object 669 // types supported by any Flight configuration anywhere since 670 // we don't know which Flight build this will end up being used 671 // with. 672 type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) { 673 return true; 674 } 675 } 676 return false; 677 } 678 function typeOf(object) { 679 if (typeof object === "object" && object !== null) { 680 var $$typeof = object.$$typeof; 681 switch ($$typeof) { 682 case REACT_ELEMENT_TYPE: 683 var type = object.type; 684 switch (type) { 685 case REACT_FRAGMENT_TYPE: 686 case REACT_PROFILER_TYPE: 687 case REACT_STRICT_MODE_TYPE: 688 case REACT_SUSPENSE_TYPE: 689 case REACT_SUSPENSE_LIST_TYPE: 690 return type; 691 default: 692 var $$typeofType = type && type.$$typeof; 693 switch ($$typeofType) { 694 case REACT_SERVER_CONTEXT_TYPE: 695 case REACT_CONTEXT_TYPE: 696 case REACT_FORWARD_REF_TYPE: 697 case REACT_LAZY_TYPE: 698 case REACT_MEMO_TYPE: 699 case REACT_PROVIDER_TYPE: 700 return $$typeofType; 701 default: 702 return $$typeof; 703 } 704 } 705 case REACT_PORTAL_TYPE: 706 return $$typeof; 707 } 708 } 709 return void 0; 710 } 711 var ContextConsumer = REACT_CONTEXT_TYPE; 712 var ContextProvider = REACT_PROVIDER_TYPE; 713 var Element = REACT_ELEMENT_TYPE; 714 var ForwardRef = REACT_FORWARD_REF_TYPE; 715 var Fragment = REACT_FRAGMENT_TYPE; 716 var Lazy = REACT_LAZY_TYPE; 717 var Memo = REACT_MEMO_TYPE; 718 var Portal = REACT_PORTAL_TYPE; 719 var Profiler = REACT_PROFILER_TYPE; 720 var StrictMode = REACT_STRICT_MODE_TYPE; 721 var Suspense = REACT_SUSPENSE_TYPE; 722 var SuspenseList = REACT_SUSPENSE_LIST_TYPE; 723 var hasWarnedAboutDeprecatedIsAsyncMode = false; 724 var hasWarnedAboutDeprecatedIsConcurrentMode = false; 725 function isAsyncMode(object) { 726 { 727 if (!hasWarnedAboutDeprecatedIsAsyncMode) { 728 hasWarnedAboutDeprecatedIsAsyncMode = true; 729 console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+."); 730 } 731 } 732 return false; 733 } 734 function isConcurrentMode(object) { 735 { 736 if (!hasWarnedAboutDeprecatedIsConcurrentMode) { 737 hasWarnedAboutDeprecatedIsConcurrentMode = true; 738 console["warn"]("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+."); 739 } 740 } 741 return false; 742 } 743 function isContextConsumer(object) { 744 return typeOf(object) === REACT_CONTEXT_TYPE; 745 } 746 function isContextProvider(object) { 747 return typeOf(object) === REACT_PROVIDER_TYPE; 748 } 749 function isElement(object) { 750 return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 751 } 752 function isForwardRef(object) { 753 return typeOf(object) === REACT_FORWARD_REF_TYPE; 754 } 755 function isFragment(object) { 756 return typeOf(object) === REACT_FRAGMENT_TYPE; 757 } 758 function isLazy(object) { 759 return typeOf(object) === REACT_LAZY_TYPE; 760 } 761 function isMemo(object) { 762 return typeOf(object) === REACT_MEMO_TYPE; 763 } 764 function isPortal(object) { 765 return typeOf(object) === REACT_PORTAL_TYPE; 766 } 767 function isProfiler(object) { 768 return typeOf(object) === REACT_PROFILER_TYPE; 769 } 770 function isStrictMode(object) { 771 return typeOf(object) === REACT_STRICT_MODE_TYPE; 772 } 773 function isSuspense(object) { 774 return typeOf(object) === REACT_SUSPENSE_TYPE; 775 } 776 function isSuspenseList(object) { 777 return typeOf(object) === REACT_SUSPENSE_LIST_TYPE; 778 } 779 exports.ContextConsumer = ContextConsumer; 780 exports.ContextProvider = ContextProvider; 781 exports.Element = Element; 782 exports.ForwardRef = ForwardRef; 783 exports.Fragment = Fragment; 784 exports.Lazy = Lazy; 785 exports.Memo = Memo; 786 exports.Portal = Portal; 787 exports.Profiler = Profiler; 788 exports.StrictMode = StrictMode; 789 exports.Suspense = Suspense; 790 exports.SuspenseList = SuspenseList; 791 exports.isAsyncMode = isAsyncMode; 792 exports.isConcurrentMode = isConcurrentMode; 793 exports.isContextConsumer = isContextConsumer; 794 exports.isContextProvider = isContextProvider; 795 exports.isElement = isElement; 796 exports.isForwardRef = isForwardRef; 797 exports.isFragment = isFragment; 798 exports.isLazy = isLazy; 799 exports.isMemo = isMemo; 800 exports.isPortal = isPortal; 801 exports.isProfiler = isProfiler; 802 exports.isStrictMode = isStrictMode; 803 exports.isSuspense = isSuspense; 804 exports.isSuspenseList = isSuspenseList; 805 exports.isValidElementType = isValidElementType2; 806 exports.typeOf = typeOf; 807 })(); 808 } 809 } 810 }); 811 812 // packages/blocks/node_modules/react-is/index.js 813 var require_react_is = __commonJS({ 814 "packages/blocks/node_modules/react-is/index.js"(exports, module) { 815 "use strict"; 816 if (false) { 817 module.exports = null; 818 } else { 819 module.exports = require_react_is_development(); 820 } 821 } 822 }); 823 824 // package-external:@wordpress/hooks 825 var require_hooks = __commonJS({ 826 "package-external:@wordpress/hooks"(exports, module) { 827 module.exports = window.wp.hooks; 828 } 829 }); 830 831 // package-external:@wordpress/block-serialization-default-parser 832 var require_block_serialization_default_parser = __commonJS({ 833 "package-external:@wordpress/block-serialization-default-parser"(exports, module) { 834 module.exports = window.wp.blockSerializationDefaultParser; 835 } 836 }); 837 838 // package-external:@wordpress/autop 839 var require_autop = __commonJS({ 840 "package-external:@wordpress/autop"(exports, module) { 841 module.exports = window.wp.autop; 842 } 843 }); 844 845 // package-external:@wordpress/is-shallow-equal 846 var require_is_shallow_equal = __commonJS({ 847 "package-external:@wordpress/is-shallow-equal"(exports, module) { 848 module.exports = window.wp.isShallowEqual; 849 } 850 }); 851 852 // vendor-external:react/jsx-runtime 853 var require_jsx_runtime = __commonJS({ 854 "vendor-external:react/jsx-runtime"(exports, module) { 855 module.exports = window.ReactJSXRuntime; 856 } 857 }); 858 859 // package-external:@wordpress/html-entities 860 var require_html_entities = __commonJS({ 861 "package-external:@wordpress/html-entities"(exports, module) { 862 module.exports = window.wp.htmlEntities; 863 } 864 }); 865 866 // package-external:@wordpress/shortcode 867 var require_shortcode = __commonJS({ 868 "package-external:@wordpress/shortcode"(exports, module) { 869 module.exports = window.wp.shortcode; 870 } 871 }); 872 873 // package-external:@wordpress/blob 874 var require_blob = __commonJS({ 875 "package-external:@wordpress/blob"(exports, module) { 876 module.exports = window.wp.blob; 877 } 878 }); 879 880 // packages/blocks/build-module/index.mjs 881 var index_exports = {}; 882 __export(index_exports, { 883 __EXPERIMENTAL_ELEMENTS: () => __EXPERIMENTAL_ELEMENTS, 884 __EXPERIMENTAL_PATHS_WITH_OVERRIDE: () => __EXPERIMENTAL_PATHS_WITH_OVERRIDE, 885 __EXPERIMENTAL_STYLE_PROPERTY: () => __EXPERIMENTAL_STYLE_PROPERTY, 886 __experimentalCloneSanitizedBlock: () => __experimentalCloneSanitizedBlock, 887 __experimentalGetAccessibleBlockLabel: () => getAccessibleBlockLabel, 888 __experimentalGetBlockAttributesNamesByRole: () => __experimentalGetBlockAttributesNamesByRole, 889 __experimentalGetBlockLabel: () => getBlockLabel, 890 __experimentalSanitizeBlockAttributes: () => __experimentalSanitizeBlockAttributes, 891 __unstableGetBlockProps: () => getBlockProps, 892 __unstableGetInnerBlocksProps: () => getInnerBlocksProps, 893 __unstableSerializeAndClean: () => __unstableSerializeAndClean, 894 children: () => children_default, 895 cloneBlock: () => cloneBlock, 896 cloneSanitizedBlock: () => cloneSanitizedBlock, 897 createBlock: () => createBlock, 898 createBlocksFromInnerBlocksTemplate: () => createBlocksFromInnerBlocksTemplate, 899 doBlocksMatchTemplate: () => doBlocksMatchTemplate, 900 findTransform: () => findTransform, 901 getBlockAttributes: () => getBlockAttributes, 902 getBlockAttributesNamesByRole: () => getBlockAttributesNamesByRole, 903 getBlockBindingsSource: () => getBlockBindingsSource, 904 getBlockBindingsSources: () => getBlockBindingsSources, 905 getBlockContent: () => getBlockInnerHTML, 906 getBlockDefaultClassName: () => getBlockDefaultClassName, 907 getBlockFromExample: () => getBlockFromExample, 908 getBlockMenuDefaultClassName: () => getBlockMenuDefaultClassName, 909 getBlockSupport: () => getBlockSupport, 910 getBlockTransforms: () => getBlockTransforms, 911 getBlockType: () => getBlockType, 912 getBlockTypes: () => getBlockTypes, 913 getBlockVariations: () => getBlockVariations, 914 getCategories: () => getCategories2, 915 getChildBlockNames: () => getChildBlockNames, 916 getDefaultBlockName: () => getDefaultBlockName, 917 getFreeformContentHandlerName: () => getFreeformContentHandlerName, 918 getGroupingBlockName: () => getGroupingBlockName, 919 getPhrasingContentSchema: () => deprecatedGetPhrasingContentSchema, 920 getPossibleBlockTransformations: () => getPossibleBlockTransformations, 921 getSaveContent: () => getSaveContent, 922 getSaveElement: () => getSaveElement, 923 getUnregisteredTypeHandlerName: () => getUnregisteredTypeHandlerName, 924 hasBlockSupport: () => hasBlockSupport, 925 hasChildBlocks: () => hasChildBlocks, 926 hasChildBlocksWithInserterSupport: () => hasChildBlocksWithInserterSupport, 927 isReusableBlock: () => isReusableBlock, 928 isTemplatePart: () => isTemplatePart, 929 isUnmodifiedBlock: () => isUnmodifiedBlock, 930 isUnmodifiedDefaultBlock: () => isUnmodifiedDefaultBlock, 931 isValidBlockContent: () => isValidBlockContent, 932 isValidIcon: () => isValidIcon, 933 node: () => node_default, 934 normalizeIconObject: () => normalizeIconObject, 935 parse: () => parse2, 936 parseWithAttributeSchema: () => parseWithAttributeSchema, 937 pasteHandler: () => pasteHandler, 938 privateApis: () => privateApis, 939 rawHandler: () => rawHandler, 940 registerBlockBindingsSource: () => registerBlockBindingsSource, 941 registerBlockCollection: () => registerBlockCollection, 942 registerBlockStyle: () => registerBlockStyle, 943 registerBlockType: () => registerBlockType, 944 registerBlockVariation: () => registerBlockVariation, 945 sanitizeBlockAttributes: () => sanitizeBlockAttributes, 946 serialize: () => serialize, 947 serializeRawBlock: () => serializeRawBlock, 948 setCategories: () => setCategories2, 949 setDefaultBlockName: () => setDefaultBlockName, 950 setFreeformContentHandlerName: () => setFreeformContentHandlerName, 951 setGroupingBlockName: () => setGroupingBlockName, 952 setUnregisteredTypeHandlerName: () => setUnregisteredTypeHandlerName, 953 store: () => store, 954 switchToBlockType: () => switchToBlockType, 955 synchronizeBlocksWithTemplate: () => synchronizeBlocksWithTemplate, 956 unregisterBlockBindingsSource: () => unregisterBlockBindingsSource, 957 unregisterBlockStyle: () => unregisterBlockStyle, 958 unregisterBlockType: () => unregisterBlockType, 959 unregisterBlockVariation: () => unregisterBlockVariation, 960 unstable__bootstrapServerSideBlockDefinitions: () => unstable__bootstrapServerSideBlockDefinitions, 961 updateCategory: () => updateCategory2, 962 validateBlock: () => validateBlock, 963 withBlockContentContext: () => withBlockContentContext 964 }); 965 966 // packages/blocks/build-module/store/index.mjs 967 var import_data5 = __toESM(require_data(), 1); 968 969 // node_modules/tslib/tslib.es6.mjs 970 var __assign = function() { 971 __assign = Object.assign || function __assign2(t2) { 972 for (var s, i = 1, n = arguments.length; i < n; i++) { 973 s = arguments[i]; 974 for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2)) t2[p2] = s[p2]; 975 } 976 return t2; 977 }; 978 return __assign.apply(this, arguments); 979 }; 980 981 // node_modules/lower-case/dist.es2015/index.js 982 function lowerCase(str) { 983 return str.toLowerCase(); 984 } 985 986 // node_modules/no-case/dist.es2015/index.js 987 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 988 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 989 function noCase(input, options) { 990 if (options === void 0) { 991 options = {}; 992 } 993 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; 994 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 995 var start = 0; 996 var end = result.length; 997 while (result.charAt(start) === "\0") 998 start++; 999 while (result.charAt(end - 1) === "\0") 1000 end--; 1001 return result.slice(start, end).split("\0").map(transform).join(delimiter); 1002 } 1003 function replace(input, re, value) { 1004 if (re instanceof RegExp) 1005 return input.replace(re, value); 1006 return re.reduce(function(input2, re2) { 1007 return input2.replace(re2, value); 1008 }, input); 1009 } 1010 1011 // node_modules/pascal-case/dist.es2015/index.js 1012 function pascalCaseTransform(input, index) { 1013 var firstChar = input.charAt(0); 1014 var lowerChars = input.substr(1).toLowerCase(); 1015 if (index > 0 && firstChar >= "0" && firstChar <= "9") { 1016 return "_" + firstChar + lowerChars; 1017 } 1018 return "" + firstChar.toUpperCase() + lowerChars; 1019 } 1020 function pascalCase(input, options) { 1021 if (options === void 0) { 1022 options = {}; 1023 } 1024 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); 1025 } 1026 1027 // node_modules/camel-case/dist.es2015/index.js 1028 function camelCaseTransform(input, index) { 1029 if (index === 0) 1030 return input.toLowerCase(); 1031 return pascalCaseTransform(input, index); 1032 } 1033 function camelCase(input, options) { 1034 if (options === void 0) { 1035 options = {}; 1036 } 1037 return pascalCase(input, __assign({ transform: camelCaseTransform }, options)); 1038 } 1039 1040 // packages/blocks/build-module/store/reducer.mjs 1041 var import_data2 = __toESM(require_data(), 1); 1042 var import_i18n3 = __toESM(require_i18n(), 1); 1043 1044 // node_modules/colord/index.mjs 1045 for (r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, t2 = function(r3) { 1046 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 1047 }, n = function(r3, t3, n2) { 1048 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = Math.pow(10, t3)), Math.round(n2 * r3) / n2 + 0; 1049 }, u = function(r3, t3, n2) { 1050 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t3 ? r3 : t3; 1051 }, e2 = function(r3) { 1052 return (r3 = isFinite(r3) ? r3 % 360 : 0) < 0 ? r3 + 360 : r3; 1053 }, o2 = function(r3, t3) { 1054 return void 0 === t3 && (t3 = 0), n(r3, t3) % 360; 1055 }, a = function(r3) { 1056 return { r: u(r3.r, 0, 255), g: u(r3.g, 0, 255), b: u(r3.b, 0, 255), a: u(r3.a) }; 1057 }, i = function(r3) { 1058 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 1059 }, s = /^#([0-9a-f]{3,8})$/i, d2 = function(r3, t3) { 1060 var n2 = r3.charCodeAt(t3); 1061 return (15 & n2) + 9 * (n2 >> 6); 1062 }, h = function(r3, t3) { 1063 return d2(r3, t3) << 4 | d2(r3, t3 + 1); 1064 }, b2 = [], f2 = 0; f2 < 256; f2++) b2.push((f2 < 16 ? "0" : "") + f2.toString(16)); 1065 var r2; 1066 var t2; 1067 var n; 1068 var u; 1069 var e2; 1070 var o2; 1071 var a; 1072 var i; 1073 var s; 1074 var d2; 1075 var h; 1076 var b2; 1077 var f2; 1078 var g = function(r2) { 1079 return b2[u(r2, 0, 255)]; 1080 }; 1081 var c = function(r2) { 1082 var t2 = r2.r, n = r2.g, u = r2.b, e2 = r2.a, o2 = Math.max(t2, n, u), a = o2 - Math.min(t2, n, u), i = a ? o2 === t2 ? (n - u) / a : o2 === n ? 2 + (u - t2) / a : 4 + (t2 - n) / a : 0; 1083 return { h: 60 * (i < 0 ? i + 6 : i), s: o2 ? a / o2 * 100 : 0, v: o2 / 255 * 100, a: e2 }; 1084 }; 1085 var v = function(r2) { 1086 var t2 = r2.h, n = r2.s, u = r2.v, e2 = r2.a; 1087 t2 = t2 / 360 * 6, n /= 100, u /= 100; 1088 var o2 = Math.floor(t2), a = u * (1 - n), i = u * (1 - (t2 - o2) * n), s = u * (1 - (1 - t2 + o2) * n), d2 = o2 % 6; 1089 return { r: 255 * [u, i, a, a, s, u][d2], g: 255 * [s, u, u, i, a, a][d2], b: 255 * [a, a, s, u, u, i][d2], a: e2 }; 1090 }; 1091 var l = function(r2) { 1092 return { h: e2(r2.h), s: u(r2.s, 0, 100), l: u(r2.l, 0, 100), a: u(r2.a) }; 1093 }; 1094 var p = function(r2) { 1095 return { h: o2(r2.h), s: n(r2.s), l: n(r2.l), a: n(r2.a, 3) }; 1096 }; 1097 var m = function(r2) { 1098 return v((n = (t2 = r2).s, { h: t2.h, s: (n *= ((u = t2.l) < 50 ? u : 100 - u) / 100) > 0 ? 2 * n / (u + n) * 100 : 0, v: u + n, a: t2.a })); 1099 var t2, n, u; 1100 }; 1101 var y = function(r2) { 1102 return { h: (t2 = c(r2)).h, s: (e2 = (200 - (n = t2.s)) * (u = t2.v) / 100) > 0 && e2 < 200 ? n * u / 100 / (e2 <= 100 ? e2 : 200 - e2) * 100 : 0, l: e2 / 2, a: t2.a }; 1103 var t2, n, u, e2; 1104 }; 1105 var N = /^hsla?\(\s*([+-]?(?:\d*\.\d+|\d+))(deg|rad|grad|turn)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))%\s*,\s*([+-]?(?:\d*\.\d+|\d+))%\s*(?:,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i; 1106 var x = /^hsla?\(\s*([+-]?(?:\d*\.\d+|\d+))(deg|rad|grad|turn)?\s+([+-]?(?:\d*\.\d+|\d+))%\s+([+-]?(?:\d*\.\d+|\d+))%\s*(?:\/\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i; 1107 var M = /^rgba?\(\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*(?:,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i; 1108 var H = /^rgba?\(\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s+([+-]?(?:\d*\.\d+|\d+))(%)?\s+([+-]?(?:\d*\.\d+|\d+))(%)?\s*(?:\/\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i; 1109 var $ = { string: [[function(r2) { 1110 if (!s.test(r2)) return null; 1111 var t2 = r2.length; 1112 return t2 <= 5 ? { r: 17 * d2(r2, 1), g: 17 * d2(r2, 2), b: 17 * d2(r2, 3), a: 5 === t2 ? n(17 * d2(r2, 4) / 255, 2) : 1 } : 7 === t2 || 9 === t2 ? { r: h(r2, 1), g: h(r2, 3), b: h(r2, 5), a: 9 === t2 ? n(h(r2, 7) / 255, 2) : 1 } : null; 1113 }, "hex"], [function(r2) { 1114 var t2 = M.exec(r2) || H.exec(r2); 1115 return t2 ? t2[2] !== t2[4] || t2[4] !== t2[6] ? null : a({ r: Number(t2[1]) / (t2[2] ? 100 / 255 : 1), g: Number(t2[3]) / (t2[4] ? 100 / 255 : 1), b: Number(t2[5]) / (t2[6] ? 100 / 255 : 1), a: void 0 === t2[7] ? 1 : Number(t2[7]) / (t2[8] ? 100 : 1) }) : null; 1116 }, "rgb"], [function(t2) { 1117 var n = N.exec(t2) || x.exec(t2); 1118 if (!n) return null; 1119 var u, e2, o2 = l({ h: (u = n[1], e2 = n[2], void 0 === e2 && (e2 = "deg"), Number(u) * (r2[e2] || 1)), s: Number(n[3]), l: Number(n[4]), a: void 0 === n[5] ? 1 : Number(n[5]) / (n[6] ? 100 : 1) }); 1120 return m(o2); 1121 }, "hsl"]], object: [[function(r2) { 1122 var n = r2.r, u = r2.g, e2 = r2.b, o2 = r2.a, i = void 0 === o2 ? 1 : o2; 1123 return t2(n) && t2(u) && t2(e2) ? a({ r: Number(n), g: Number(u), b: Number(e2), a: Number(i) }) : null; 1124 }, "rgb"], [function(r2) { 1125 var n = r2.h, u = r2.s, e2 = r2.l, o2 = r2.a, a = void 0 === o2 ? 1 : o2; 1126 if (!t2(n) || !t2(u) || !t2(e2)) return null; 1127 var i = l({ h: Number(n), s: Number(u), l: Number(e2), a: Number(a) }); 1128 return m(i); 1129 }, "hsl"], [function(r2) { 1130 var n = r2.h, o2 = r2.s, a = r2.v, i = r2.a, s = void 0 === i ? 1 : i; 1131 if (!t2(n) || !t2(o2) || !t2(a)) return null; 1132 var d2 = (function(r3) { 1133 return { h: e2(r3.h), s: u(r3.s, 0, 100), v: u(r3.v, 0, 100), a: u(r3.a) }; 1134 })({ h: Number(n), s: Number(o2), v: Number(a), a: Number(s) }); 1135 return v(d2); 1136 }, "hsv"]] }; 1137 var j = function(r2, t2) { 1138 for (var n = 0; n < t2.length; n++) { 1139 var u = t2[n][0](r2); 1140 if (u) return [u, t2[n][1]]; 1141 } 1142 return [null, void 0]; 1143 }; 1144 var w = function(r2) { 1145 return "string" == typeof r2 ? j(r2.trim(), $.string) : "object" == typeof r2 && null !== r2 ? j(r2, $.object) : [null, void 0]; 1146 }; 1147 var k = function(r2, t2) { 1148 var n = y(r2); 1149 return { h: n.h, s: u(n.s + 100 * t2, 0, 100), l: n.l, a: n.a }; 1150 }; 1151 var E = function(r2) { 1152 return (299 * r2.r + 587 * r2.g + 114 * r2.b) / 1e3 / 255; 1153 }; 1154 var R = function(r2, t2) { 1155 var n = y(r2); 1156 return { h: n.h, s: n.s, l: u(n.l + 100 * t2, 0, 100), a: n.a }; 1157 }; 1158 var q = (function() { 1159 function r2(r3) { 1160 this.parsed = w(r3)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 1161 } 1162 return r2.prototype.isValid = function() { 1163 return null !== this.parsed; 1164 }, r2.prototype.brightness = function() { 1165 return n(E(this.rgba), 2); 1166 }, r2.prototype.isDark = function() { 1167 return E(this.rgba) < 0.5; 1168 }, r2.prototype.isLight = function() { 1169 return E(this.rgba) >= 0.5; 1170 }, r2.prototype.toHex = function() { 1171 return r3 = i(this.rgba), t2 = r3.r, u = r3.g, e2 = r3.b, a = (o2 = r3.a) < 1 ? g(n(255 * o2)) : "", "#" + g(t2) + g(u) + g(e2) + a; 1172 var r3, t2, u, e2, o2, a; 1173 }, r2.prototype.toRgb = function() { 1174 return i(this.rgba); 1175 }, r2.prototype.toRgbString = function() { 1176 return r3 = i(this.rgba), t2 = r3.r, n = r3.g, u = r3.b, (e2 = r3.a) < 1 ? "rgba(" + t2 + ", " + n + ", " + u + ", " + e2 + ")" : "rgb(" + t2 + ", " + n + ", " + u + ")"; 1177 var r3, t2, n, u, e2; 1178 }, r2.prototype.toHsl = function() { 1179 return p(y(this.rgba)); 1180 }, r2.prototype.toHslString = function() { 1181 return r3 = p(y(this.rgba)), t2 = r3.h, n = r3.s, u = r3.l, (e2 = r3.a) < 1 ? "hsla(" + t2 + ", " + n + "%, " + u + "%, " + e2 + ")" : "hsl(" + t2 + ", " + n + "%, " + u + "%)"; 1182 var r3, t2, n, u, e2; 1183 }, r2.prototype.toHsv = function() { 1184 return r3 = c(this.rgba), { h: o2(r3.h), s: n(r3.s), v: n(r3.v), a: n(r3.a, 3) }; 1185 var r3; 1186 }, r2.prototype.invert = function() { 1187 return A({ r: 255 - (r3 = this.rgba).r, g: 255 - r3.g, b: 255 - r3.b, a: r3.a }); 1188 var r3; 1189 }, r2.prototype.saturate = function(r3) { 1190 return void 0 === r3 && (r3 = 0.1), A(k(this.rgba, r3)); 1191 }, r2.prototype.desaturate = function(r3) { 1192 return void 0 === r3 && (r3 = 0.1), A(k(this.rgba, -r3)); 1193 }, r2.prototype.grayscale = function() { 1194 return A(k(this.rgba, -1)); 1195 }, r2.prototype.lighten = function(r3) { 1196 return void 0 === r3 && (r3 = 0.1), A(R(this.rgba, r3)); 1197 }, r2.prototype.darken = function(r3) { 1198 return void 0 === r3 && (r3 = 0.1), A(R(this.rgba, -r3)); 1199 }, r2.prototype.rotate = function(r3) { 1200 return void 0 === r3 && (r3 = 15), this.hue(y(this.rgba).h + r3); 1201 }, r2.prototype.alpha = function(r3) { 1202 return "number" == typeof r3 ? A({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r3 }) : n(this.rgba.a, 3); 1203 var t2; 1204 }, r2.prototype.hue = function(r3) { 1205 var t2 = y(this.rgba); 1206 return "number" == typeof r3 ? A({ h: r3, s: t2.s, l: t2.l, a: t2.a }) : o2(t2.h); 1207 }, r2.prototype.isEqual = function(r3) { 1208 return this.toHex() === A(r3).toHex(); 1209 }, r2; 1210 })(); 1211 var A = function(r2) { 1212 return r2 instanceof q ? r2 : new q(r2); 1213 }; 1214 var C = []; 1215 var D = function(r2) { 1216 r2.forEach(function(r3) { 1217 C.indexOf(r3) < 0 && (r3(q, $), C.push(r3)); 1218 }); 1219 }; 1220 1221 // node_modules/colord/plugins/names.mjs 1222 var e = function(e2, f2) { 1223 var a = { white: "#ffffff", bisque: "#ffe4c4", blue: "#0000ff", cadetblue: "#5f9ea0", chartreuse: "#7fff00", chocolate: "#d2691e", coral: "#ff7f50", antiquewhite: "#faebd7", aqua: "#00ffff", azure: "#f0ffff", whitesmoke: "#f5f5f5", papayawhip: "#ffefd5", plum: "#dda0dd", blanchedalmond: "#ffebcd", black: "#000000", gold: "#ffd700", goldenrod: "#daa520", gainsboro: "#dcdcdc", cornsilk: "#fff8dc", cornflowerblue: "#6495ed", burlywood: "#deb887", aquamarine: "#7fffd4", beige: "#f5f5dc", crimson: "#dc143c", cyan: "#00ffff", darkblue: "#00008b", darkcyan: "#008b8b", darkgoldenrod: "#b8860b", darkkhaki: "#bdb76b", darkgray: "#a9a9a9", darkgreen: "#006400", darkgrey: "#a9a9a9", peachpuff: "#ffdab9", darkmagenta: "#8b008b", darkred: "#8b0000", darkorchid: "#9932cc", darkorange: "#ff8c00", darkslateblue: "#483d8b", gray: "#808080", darkslategray: "#2f4f4f", darkslategrey: "#2f4f4f", deeppink: "#ff1493", deepskyblue: "#00bfff", wheat: "#f5deb3", firebrick: "#b22222", floralwhite: "#fffaf0", ghostwhite: "#f8f8ff", darkviolet: "#9400d3", magenta: "#ff00ff", green: "#008000", dodgerblue: "#1e90ff", grey: "#808080", honeydew: "#f0fff0", hotpink: "#ff69b4", blueviolet: "#8a2be2", forestgreen: "#228b22", lawngreen: "#7cfc00", indianred: "#cd5c5c", indigo: "#4b0082", fuchsia: "#ff00ff", brown: "#a52a2a", maroon: "#800000", mediumblue: "#0000cd", lightcoral: "#f08080", darkturquoise: "#00ced1", lightcyan: "#e0ffff", ivory: "#fffff0", lightyellow: "#ffffe0", lightsalmon: "#ffa07a", lightseagreen: "#20b2aa", linen: "#faf0e6", mediumaquamarine: "#66cdaa", lemonchiffon: "#fffacd", lime: "#00ff00", khaki: "#f0e68c", mediumseagreen: "#3cb371", limegreen: "#32cd32", mediumspringgreen: "#00fa9a", lightskyblue: "#87cefa", lightblue: "#add8e6", midnightblue: "#191970", lightpink: "#ffb6c1", mistyrose: "#ffe4e1", moccasin: "#ffe4b5", mintcream: "#f5fffa", lightslategray: "#778899", lightslategrey: "#778899", navajowhite: "#ffdead", navy: "#000080", mediumvioletred: "#c71585", powderblue: "#b0e0e6", palegoldenrod: "#eee8aa", oldlace: "#fdf5e6", paleturquoise: "#afeeee", mediumturquoise: "#48d1cc", mediumorchid: "#ba55d3", rebeccapurple: "#663399", lightsteelblue: "#b0c4de", mediumslateblue: "#7b68ee", thistle: "#d8bfd8", tan: "#d2b48c", orchid: "#da70d6", mediumpurple: "#9370db", purple: "#800080", pink: "#ffc0cb", skyblue: "#87ceeb", springgreen: "#00ff7f", palegreen: "#98fb98", red: "#ff0000", yellow: "#ffff00", slateblue: "#6a5acd", lavenderblush: "#fff0f5", peru: "#cd853f", palevioletred: "#db7093", violet: "#ee82ee", teal: "#008080", slategray: "#708090", slategrey: "#708090", aliceblue: "#f0f8ff", darkseagreen: "#8fbc8f", darkolivegreen: "#556b2f", greenyellow: "#adff2f", seagreen: "#2e8b57", seashell: "#fff5ee", tomato: "#ff6347", silver: "#c0c0c0", sienna: "#a0522d", lavender: "#e6e6fa", lightgreen: "#90ee90", orange: "#ffa500", orangered: "#ff4500", steelblue: "#4682b4", royalblue: "#4169e1", turquoise: "#40e0d0", yellowgreen: "#9acd32", salmon: "#fa8072", saddlebrown: "#8b4513", sandybrown: "#f4a460", rosybrown: "#bc8f8f", darksalmon: "#e9967a", lightgoldenrodyellow: "#fafad2", snow: "#fffafa", lightgrey: "#d3d3d3", lightgray: "#d3d3d3", dimgray: "#696969", dimgrey: "#696969", olivedrab: "#6b8e23", olive: "#808000" }, r2 = {}; 1224 for (var d2 in a) r2[a[d2]] = d2; 1225 var l4 = {}; 1226 e2.prototype.toName = function(f3) { 1227 if (!(this.rgba.a || this.rgba.r || this.rgba.g || this.rgba.b)) return "transparent"; 1228 var d3, i, n = r2[this.toHex()]; 1229 if (n) return n; 1230 if (null == f3 ? void 0 : f3.closest) { 1231 var o2 = this.toRgb(), t2 = 1 / 0, b2 = "black"; 1232 if (!l4.length) for (var c2 in a) l4[c2] = new e2(a[c2]).toRgb(); 1233 for (var g2 in a) { 1234 var u = (d3 = o2, i = l4[g2], Math.pow(d3.r - i.r, 2) + Math.pow(d3.g - i.g, 2) + Math.pow(d3.b - i.b, 2)); 1235 u < t2 && (t2 = u, b2 = g2); 1236 } 1237 return b2; 1238 } 1239 }; 1240 f2.string.push([function(f3) { 1241 var r3 = f3.toLowerCase(), d3 = "transparent" === r3 ? "#0000" : a[r3]; 1242 return d3 ? new e2(d3).toRgb() : null; 1243 }, "name"]); 1244 }; 1245 1246 // node_modules/colord/plugins/a11y.mjs 1247 var o = function(o2) { 1248 var t2 = o2 / 255; 1249 return t2 < 0.04045 ? t2 / 12.92 : Math.pow((t2 + 0.055) / 1.055, 2.4); 1250 }; 1251 var t = function(t2) { 1252 return 0.2126 * o(t2.r) + 0.7152 * o(t2.g) + 0.0722 * o(t2.b); 1253 }; 1254 var r = function(o2) { 1255 o2.prototype.luminance = function() { 1256 return o3 = t(this.rgba), void 0 === (r2 = 2) && (r2 = 0), void 0 === n && (n = Math.pow(10, r2)), Math.round(n * o3) / n + 0; 1257 var o3, r2, n; 1258 }, o2.prototype.contrast = function(r2) { 1259 void 0 === r2 && (r2 = "#FFF"); 1260 var n, a, i, e2, v3, u, d2, c2 = r2 instanceof o2 ? r2 : new o2(r2); 1261 return e2 = this.rgba, v3 = c2.toRgb(), u = t(e2), d2 = t(v3), n = u > d2 ? (u + 0.05) / (d2 + 0.05) : (d2 + 0.05) / (u + 0.05), void 0 === (a = 2) && (a = 0), void 0 === i && (i = Math.pow(10, a)), Math.floor(i * n) / i + 0; 1262 }, o2.prototype.isReadable = function(o3, t2) { 1263 return void 0 === o3 && (o3 = "#FFF"), void 0 === t2 && (t2 = {}), this.contrast(o3) >= (e2 = void 0 === (i = (r2 = t2).size) ? "normal" : i, "AAA" === (a = void 0 === (n = r2.level) ? "AA" : n) && "normal" === e2 ? 7 : "AA" === a && "large" === e2 ? 3 : 4.5); 1264 var r2, n, a, i, e2; 1265 }; 1266 }; 1267 1268 // packages/blocks/build-module/api/utils.mjs 1269 var import_element = __toESM(require_element(), 1); 1270 var import_i18n2 = __toESM(require_i18n(), 1); 1271 var import_dom = __toESM(require_dom(), 1); 1272 var import_rich_text = __toESM(require_rich_text(), 1); 1273 var import_deprecated = __toESM(require_deprecated(), 1); 1274 1275 // packages/blocks/build-module/api/constants.mjs 1276 var BLOCK_ICON_DEFAULT = "block-default"; 1277 var DEPRECATED_ENTRY_KEYS = [ 1278 "attributes", 1279 "supports", 1280 "save", 1281 "migrate", 1282 "isEligible", 1283 "apiVersion" 1284 ]; 1285 var __EXPERIMENTAL_STYLE_PROPERTY = { 1286 // Kept for back-compatibility purposes. 1287 "--wp--style--color--link": { 1288 value: ["color", "link"], 1289 support: ["color", "link"] 1290 }, 1291 aspectRatio: { 1292 value: ["dimensions", "aspectRatio"], 1293 support: ["dimensions", "aspectRatio"], 1294 useEngine: true 1295 }, 1296 background: { 1297 value: ["color", "gradient"], 1298 support: ["color", "gradients"], 1299 useEngine: true 1300 }, 1301 backgroundColor: { 1302 value: ["color", "background"], 1303 support: ["color", "background"], 1304 requiresOptOut: true, 1305 useEngine: true 1306 }, 1307 backgroundImage: { 1308 value: ["background", "backgroundImage"], 1309 support: ["background", "backgroundImage"], 1310 useEngine: true 1311 }, 1312 backgroundRepeat: { 1313 value: ["background", "backgroundRepeat"], 1314 support: ["background", "backgroundRepeat"], 1315 useEngine: true 1316 }, 1317 backgroundSize: { 1318 value: ["background", "backgroundSize"], 1319 support: ["background", "backgroundSize"], 1320 useEngine: true 1321 }, 1322 backgroundPosition: { 1323 value: ["background", "backgroundPosition"], 1324 support: ["background", "backgroundPosition"], 1325 useEngine: true 1326 }, 1327 backgroundGradient: { 1328 value: ["background", "gradient"], 1329 support: ["background", "gradient"], 1330 useEngine: true 1331 }, 1332 borderColor: { 1333 value: ["border", "color"], 1334 support: ["__experimentalBorder", "color"], 1335 useEngine: true 1336 }, 1337 borderRadius: { 1338 value: ["border", "radius"], 1339 support: ["__experimentalBorder", "radius"], 1340 properties: { 1341 borderTopLeftRadius: "topLeft", 1342 borderTopRightRadius: "topRight", 1343 borderBottomLeftRadius: "bottomLeft", 1344 borderBottomRightRadius: "bottomRight" 1345 }, 1346 useEngine: true 1347 }, 1348 borderStyle: { 1349 value: ["border", "style"], 1350 support: ["__experimentalBorder", "style"], 1351 useEngine: true 1352 }, 1353 borderWidth: { 1354 value: ["border", "width"], 1355 support: ["__experimentalBorder", "width"], 1356 useEngine: true 1357 }, 1358 borderTopColor: { 1359 value: ["border", "top", "color"], 1360 support: ["__experimentalBorder", "color"], 1361 useEngine: true 1362 }, 1363 borderTopStyle: { 1364 value: ["border", "top", "style"], 1365 support: ["__experimentalBorder", "style"], 1366 useEngine: true 1367 }, 1368 borderTopWidth: { 1369 value: ["border", "top", "width"], 1370 support: ["__experimentalBorder", "width"], 1371 useEngine: true 1372 }, 1373 borderRightColor: { 1374 value: ["border", "right", "color"], 1375 support: ["__experimentalBorder", "color"], 1376 useEngine: true 1377 }, 1378 borderRightStyle: { 1379 value: ["border", "right", "style"], 1380 support: ["__experimentalBorder", "style"], 1381 useEngine: true 1382 }, 1383 borderRightWidth: { 1384 value: ["border", "right", "width"], 1385 support: ["__experimentalBorder", "width"], 1386 useEngine: true 1387 }, 1388 borderBottomColor: { 1389 value: ["border", "bottom", "color"], 1390 support: ["__experimentalBorder", "color"], 1391 useEngine: true 1392 }, 1393 borderBottomStyle: { 1394 value: ["border", "bottom", "style"], 1395 support: ["__experimentalBorder", "style"], 1396 useEngine: true 1397 }, 1398 borderBottomWidth: { 1399 value: ["border", "bottom", "width"], 1400 support: ["__experimentalBorder", "width"], 1401 useEngine: true 1402 }, 1403 borderLeftColor: { 1404 value: ["border", "left", "color"], 1405 support: ["__experimentalBorder", "color"], 1406 useEngine: true 1407 }, 1408 borderLeftStyle: { 1409 value: ["border", "left", "style"], 1410 support: ["__experimentalBorder", "style"], 1411 useEngine: true 1412 }, 1413 borderLeftWidth: { 1414 value: ["border", "left", "width"], 1415 support: ["__experimentalBorder", "width"], 1416 useEngine: true 1417 }, 1418 color: { 1419 value: ["color", "text"], 1420 support: ["color", "text"], 1421 requiresOptOut: true, 1422 useEngine: true 1423 }, 1424 columnCount: { 1425 value: ["typography", "textColumns"], 1426 support: ["typography", "textColumns"], 1427 useEngine: true 1428 }, 1429 filter: { 1430 value: ["filter", "duotone"], 1431 support: ["filter", "duotone"] 1432 }, 1433 linkColor: { 1434 value: ["elements", "link", "color", "text"], 1435 support: ["color", "link"] 1436 }, 1437 captionColor: { 1438 value: ["elements", "caption", "color", "text"], 1439 support: ["color", "caption"] 1440 }, 1441 buttonColor: { 1442 value: ["elements", "button", "color", "text"], 1443 support: ["color", "button"] 1444 }, 1445 buttonBackgroundColor: { 1446 value: ["elements", "button", "color", "background"], 1447 support: ["color", "button"] 1448 }, 1449 headingColor: { 1450 value: ["elements", "heading", "color", "text"], 1451 support: ["color", "heading"] 1452 }, 1453 headingBackgroundColor: { 1454 value: ["elements", "heading", "color", "background"], 1455 support: ["color", "heading"] 1456 }, 1457 fontFamily: { 1458 value: ["typography", "fontFamily"], 1459 support: ["typography", "__experimentalFontFamily"], 1460 useEngine: true 1461 }, 1462 fontSize: { 1463 value: ["typography", "fontSize"], 1464 support: ["typography", "fontSize"], 1465 useEngine: true 1466 }, 1467 fontStyle: { 1468 value: ["typography", "fontStyle"], 1469 support: ["typography", "__experimentalFontStyle"], 1470 useEngine: true 1471 }, 1472 fontWeight: { 1473 value: ["typography", "fontWeight"], 1474 support: ["typography", "__experimentalFontWeight"], 1475 useEngine: true 1476 }, 1477 lineHeight: { 1478 value: ["typography", "lineHeight"], 1479 support: ["typography", "lineHeight"], 1480 useEngine: true 1481 }, 1482 margin: { 1483 value: ["spacing", "margin"], 1484 support: ["spacing", "margin"], 1485 properties: { 1486 marginTop: "top", 1487 marginRight: "right", 1488 marginBottom: "bottom", 1489 marginLeft: "left" 1490 }, 1491 useEngine: true 1492 }, 1493 minHeight: { 1494 value: ["dimensions", "minHeight"], 1495 support: ["dimensions", "minHeight"], 1496 useEngine: true 1497 }, 1498 minWidth: { 1499 value: ["dimensions", "minWidth"], 1500 support: ["dimensions", "minWidth"], 1501 useEngine: true 1502 }, 1503 height: { 1504 value: ["dimensions", "height"], 1505 support: ["dimensions", "height"], 1506 useEngine: true 1507 }, 1508 width: { 1509 value: ["dimensions", "width"], 1510 support: ["dimensions", "width"], 1511 useEngine: true 1512 }, 1513 padding: { 1514 value: ["spacing", "padding"], 1515 support: ["spacing", "padding"], 1516 properties: { 1517 paddingTop: "top", 1518 paddingRight: "right", 1519 paddingBottom: "bottom", 1520 paddingLeft: "left" 1521 }, 1522 useEngine: true 1523 }, 1524 textAlign: { 1525 value: ["typography", "textAlign"], 1526 support: ["typography", "textAlign"], 1527 useEngine: false 1528 }, 1529 textDecoration: { 1530 value: ["typography", "textDecoration"], 1531 support: ["typography", "__experimentalTextDecoration"], 1532 useEngine: true 1533 }, 1534 textTransform: { 1535 value: ["typography", "textTransform"], 1536 support: ["typography", "__experimentalTextTransform"], 1537 useEngine: true 1538 }, 1539 letterSpacing: { 1540 value: ["typography", "letterSpacing"], 1541 support: ["typography", "__experimentalLetterSpacing"], 1542 useEngine: true 1543 }, 1544 textIndent: { 1545 value: ["typography", "textIndent"], 1546 support: ["typography", "textIndent"], 1547 useEngine: true 1548 }, 1549 textShadow: { 1550 value: ["typography", "textShadow"], 1551 support: ["typography", "textShadow"], 1552 useEngine: true 1553 }, 1554 writingMode: { 1555 value: ["typography", "writingMode"], 1556 support: ["typography", "__experimentalWritingMode"], 1557 useEngine: true 1558 }, 1559 "--wp--style--root--padding": { 1560 value: ["spacing", "padding"], 1561 support: ["spacing", "padding"], 1562 properties: { 1563 "--wp--style--root--padding-top": "top", 1564 "--wp--style--root--padding-right": "right", 1565 "--wp--style--root--padding-bottom": "bottom", 1566 "--wp--style--root--padding-left": "left" 1567 }, 1568 rootOnly: true 1569 } 1570 }; 1571 var __EXPERIMENTAL_ELEMENTS = { 1572 link: "a:where(:not(.wp-element-button))", 1573 heading: "h1, h2, h3, h4, h5, h6", 1574 h1: "h1", 1575 h2: "h2", 1576 h3: "h3", 1577 h4: "h4", 1578 h5: "h5", 1579 h6: "h6", 1580 button: ".wp-element-button, .wp-block-button__link", 1581 caption: ".wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption", 1582 cite: "cite", 1583 label: "label", 1584 select: "select", 1585 textInput: "textarea, input:where([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=url])" 1586 }; 1587 var __EXPERIMENTAL_PATHS_WITH_OVERRIDE = { 1588 "color.duotone": true, 1589 "color.gradients": true, 1590 "color.palette": true, 1591 "dimensions.aspectRatios": true, 1592 "typography.fontSizes": true, 1593 "spacing.spacingSizes": true 1594 }; 1595 1596 // packages/blocks/build-module/api/registration.mjs 1597 var import_data = __toESM(require_data(), 1); 1598 var import_i18n = __toESM(require_i18n(), 1); 1599 var import_warning = __toESM(require_warning(), 1); 1600 1601 // packages/blocks/build-module/api/i18n-block.json 1602 var i18n_block_default = { 1603 title: "block title", 1604 description: "block description", 1605 keywords: ["block keyword"], 1606 styles: [ 1607 { 1608 label: "block style label" 1609 } 1610 ], 1611 variations: [ 1612 { 1613 title: "block variation title", 1614 description: "block variation description", 1615 keywords: ["block variation keyword"] 1616 } 1617 ] 1618 }; 1619 1620 // packages/blocks/build-module/lock-unlock.mjs 1621 var import_private_apis = __toESM(require_private_apis(), 1); 1622 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 1623 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 1624 "@wordpress/blocks" 1625 ); 1626 1627 // packages/blocks/build-module/api/registration.mjs 1628 function isObject(object) { 1629 return object !== null && typeof object === "object"; 1630 } 1631 function unstable__bootstrapServerSideBlockDefinitions(definitions) { 1632 const { addBootstrappedBlockType: addBootstrappedBlockType2 } = unlock((0, import_data.dispatch)(store)); 1633 for (const [name, blockType] of Object.entries(definitions)) { 1634 addBootstrappedBlockType2(name, blockType); 1635 } 1636 } 1637 function getBlockSettingsFromMetadata({ 1638 textdomain, 1639 ...metadata 1640 }) { 1641 const allowedFields = [ 1642 "apiVersion", 1643 "title", 1644 "category", 1645 "parent", 1646 "ancestor", 1647 "icon", 1648 "description", 1649 "keywords", 1650 "attributes", 1651 "providesContext", 1652 "usesContext", 1653 "selectors", 1654 "supports", 1655 "styles", 1656 "example", 1657 "variations", 1658 "blockHooks", 1659 "allowedBlocks" 1660 ]; 1661 const settings = Object.fromEntries( 1662 Object.entries(metadata).filter( 1663 ([key]) => allowedFields.includes(key) 1664 ) 1665 ); 1666 if (textdomain) { 1667 Object.keys(i18n_block_default).forEach((key) => { 1668 if (!settings[key]) { 1669 return; 1670 } 1671 settings[key] = translateBlockSettingUsingI18nSchema( 1672 i18n_block_default[key], 1673 settings[key], 1674 textdomain 1675 ); 1676 }); 1677 } 1678 return settings; 1679 } 1680 function registerBlockType(blockNameOrMetadata, settings) { 1681 const name = isObject(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata; 1682 if (typeof name !== "string") { 1683 (0, import_warning.default)("Block names must be strings."); 1684 return; 1685 } 1686 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) { 1687 (0, import_warning.default)( 1688 "Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block" 1689 ); 1690 return; 1691 } 1692 if ((0, import_data.select)(store).getBlockType(name)) { 1693 (0, import_warning.default)('Block "' + name + '" is already registered.'); 1694 return; 1695 } 1696 const { addBootstrappedBlockType: addBootstrappedBlockType2, addUnprocessedBlockType: addUnprocessedBlockType2 } = unlock( 1697 (0, import_data.dispatch)(store) 1698 ); 1699 if (isObject(blockNameOrMetadata)) { 1700 const metadata = getBlockSettingsFromMetadata(blockNameOrMetadata); 1701 addBootstrappedBlockType2(name, metadata); 1702 } 1703 addUnprocessedBlockType2(name, settings); 1704 return (0, import_data.select)(store).getBlockType(name); 1705 } 1706 function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) { 1707 if (typeof i18nSchema === "string" && typeof settingValue === "string") { 1708 return (0, import_i18n._x)(settingValue, i18nSchema, textdomain); 1709 } 1710 if (Array.isArray(i18nSchema) && i18nSchema.length && Array.isArray(settingValue)) { 1711 return settingValue.map( 1712 (value) => translateBlockSettingUsingI18nSchema( 1713 i18nSchema[0], 1714 value, 1715 textdomain 1716 ) 1717 ); 1718 } 1719 if (isObject(i18nSchema) && Object.entries(i18nSchema).length && isObject(settingValue)) { 1720 return Object.keys(settingValue).reduce( 1721 (accumulator, key) => { 1722 if (!i18nSchema[key]) { 1723 accumulator[key] = settingValue[key]; 1724 return accumulator; 1725 } 1726 accumulator[key] = translateBlockSettingUsingI18nSchema( 1727 i18nSchema[key], 1728 settingValue[key], 1729 textdomain 1730 ); 1731 return accumulator; 1732 }, 1733 {} 1734 ); 1735 } 1736 return settingValue; 1737 } 1738 function registerBlockCollection(namespace, { title, icon }) { 1739 (0, import_data.dispatch)(store).addBlockCollection(namespace, title, icon); 1740 } 1741 function unregisterBlockType(name) { 1742 const oldBlock = (0, import_data.select)(store).getBlockType(name); 1743 if (!oldBlock) { 1744 (0, import_warning.default)('Block "' + name + '" is not registered.'); 1745 return; 1746 } 1747 (0, import_data.dispatch)(store).removeBlockTypes(name); 1748 return oldBlock; 1749 } 1750 function setFreeformContentHandlerName(blockName) { 1751 (0, import_data.dispatch)(store).setFreeformFallbackBlockName(blockName); 1752 } 1753 function getFreeformContentHandlerName() { 1754 return (0, import_data.select)(store).getFreeformFallbackBlockName(); 1755 } 1756 function getGroupingBlockName() { 1757 return (0, import_data.select)(store).getGroupingBlockName(); 1758 } 1759 function setUnregisteredTypeHandlerName(blockName) { 1760 (0, import_data.dispatch)(store).setUnregisteredFallbackBlockName(blockName); 1761 } 1762 function getUnregisteredTypeHandlerName() { 1763 return (0, import_data.select)(store).getUnregisteredFallbackBlockName(); 1764 } 1765 function setDefaultBlockName(name) { 1766 (0, import_data.dispatch)(store).setDefaultBlockName(name); 1767 } 1768 function setGroupingBlockName(name) { 1769 (0, import_data.dispatch)(store).setGroupingBlockName(name); 1770 } 1771 function getDefaultBlockName() { 1772 return (0, import_data.select)(store).getDefaultBlockName(); 1773 } 1774 function getBlockType(name) { 1775 return (0, import_data.select)(store)?.getBlockType(name); 1776 } 1777 function getBlockTypes() { 1778 return (0, import_data.select)(store).getBlockTypes(); 1779 } 1780 function getBlockSupport(nameOrType, feature, defaultSupports) { 1781 return (0, import_data.select)(store).getBlockSupport( 1782 nameOrType, 1783 feature, 1784 defaultSupports 1785 ); 1786 } 1787 function hasBlockSupport(nameOrType, feature, defaultSupports) { 1788 return (0, import_data.select)(store).hasBlockSupport( 1789 nameOrType, 1790 feature, 1791 defaultSupports 1792 ); 1793 } 1794 function isReusableBlock(blockOrType) { 1795 return blockOrType?.name === "core/block"; 1796 } 1797 function isTemplatePart(blockOrType) { 1798 return blockOrType?.name === "core/template-part"; 1799 } 1800 var getChildBlockNames = (blockName) => { 1801 return (0, import_data.select)(store).getChildBlockNames(blockName); 1802 }; 1803 var hasChildBlocks = (blockName) => { 1804 return (0, import_data.select)(store).hasChildBlocks(blockName); 1805 }; 1806 var hasChildBlocksWithInserterSupport = (blockName) => { 1807 return (0, import_data.select)(store).hasChildBlocksWithInserterSupport(blockName); 1808 }; 1809 var registerBlockStyle = (blockNames, styleVariation) => { 1810 (0, import_data.dispatch)(store).addBlockStyles(blockNames, styleVariation); 1811 }; 1812 var unregisterBlockStyle = (blockName, styleVariationName) => { 1813 (0, import_data.dispatch)(store).removeBlockStyles(blockName, styleVariationName); 1814 }; 1815 var getBlockVariations = (blockName, scope) => { 1816 return (0, import_data.select)(store).getBlockVariations(blockName, scope); 1817 }; 1818 var registerBlockVariation = (blockName, variation) => { 1819 if (Array.isArray(variation)) { 1820 for (const v3 of variation) { 1821 if (typeof v3.name !== "string") { 1822 (0, import_warning.default)("Variation names must be unique strings."); 1823 } 1824 } 1825 } else if (typeof variation.name !== "string") { 1826 (0, import_warning.default)("Variation names must be unique strings."); 1827 } 1828 (0, import_data.dispatch)(store).addBlockVariations(blockName, variation); 1829 }; 1830 var unregisterBlockVariation = (blockName, variationName) => { 1831 (0, import_data.dispatch)(store).removeBlockVariations(blockName, variationName); 1832 }; 1833 var registerBlockBindingsSource = (source) => { 1834 const { 1835 name, 1836 label, 1837 usesContext, 1838 getValues, 1839 setValues, 1840 canUserEditValue, 1841 getFieldsList 1842 } = source; 1843 const existingSource = unlock( 1844 (0, import_data.select)(store) 1845 ).getBlockBindingsSource(name); 1846 const serverProps = ["label", "usesContext"]; 1847 for (const prop2 in existingSource) { 1848 if (!serverProps.includes(prop2) && existingSource[prop2]) { 1849 (0, import_warning.default)( 1850 'Block bindings source "' + name + '" is already registered.' 1851 ); 1852 return; 1853 } 1854 } 1855 if (!name) { 1856 (0, import_warning.default)("Block bindings source must contain a name."); 1857 return; 1858 } 1859 if (typeof name !== "string") { 1860 (0, import_warning.default)("Block bindings source name must be a string."); 1861 return; 1862 } 1863 if (/[A-Z]+/.test(name)) { 1864 (0, import_warning.default)( 1865 "Block bindings source name must not contain uppercase characters." 1866 ); 1867 return; 1868 } 1869 if (!/^[a-z0-9/-]+$/.test(name)) { 1870 (0, import_warning.default)( 1871 "Block bindings source name must contain only valid characters: lowercase characters, hyphens, or digits. Example: my-plugin/my-custom-source." 1872 ); 1873 return; 1874 } 1875 if (!/^[a-z0-9-]+\/[a-z0-9-]+$/.test(name)) { 1876 (0, import_warning.default)( 1877 "Block bindings source name must contain a namespace and valid characters. Example: my-plugin/my-custom-source." 1878 ); 1879 return; 1880 } 1881 if (!label && !existingSource?.label) { 1882 (0, import_warning.default)("Block bindings source must contain a label."); 1883 return; 1884 } 1885 if (label && typeof label !== "string") { 1886 (0, import_warning.default)("Block bindings source label must be a string."); 1887 return; 1888 } 1889 if (label && existingSource?.label && label !== existingSource?.label) { 1890 (0, import_warning.default)('Block bindings "' + name + '" source label was overridden.'); 1891 } 1892 if (usesContext && !Array.isArray(usesContext)) { 1893 (0, import_warning.default)("Block bindings source usesContext must be an array."); 1894 return; 1895 } 1896 if (getValues && typeof getValues !== "function") { 1897 (0, import_warning.default)("Block bindings source getValues must be a function."); 1898 return; 1899 } 1900 if (setValues && typeof setValues !== "function") { 1901 (0, import_warning.default)("Block bindings source setValues must be a function."); 1902 return; 1903 } 1904 if (canUserEditValue && typeof canUserEditValue !== "function") { 1905 (0, import_warning.default)("Block bindings source canUserEditValue must be a function."); 1906 return; 1907 } 1908 if (getFieldsList && typeof getFieldsList !== "function") { 1909 (0, import_warning.default)("Block bindings source getFieldsList must be a function."); 1910 return; 1911 } 1912 return unlock((0, import_data.dispatch)(store)).addBlockBindingsSource(source); 1913 }; 1914 function unregisterBlockBindingsSource(name) { 1915 const oldSource = getBlockBindingsSource(name); 1916 if (!oldSource) { 1917 (0, import_warning.default)('Block bindings source "' + name + '" is not registered.'); 1918 return; 1919 } 1920 unlock((0, import_data.dispatch)(store)).removeBlockBindingsSource(name); 1921 } 1922 function getBlockBindingsSource(name) { 1923 return unlock((0, import_data.select)(store)).getBlockBindingsSource(name); 1924 } 1925 function getBlockBindingsSources() { 1926 return unlock((0, import_data.select)(store)).getAllBlockBindingsSources(); 1927 } 1928 1929 // packages/blocks/build-module/api/utils.mjs 1930 D([e, r]); 1931 var ICON_COLORS = ["#191e23", "#f8f9f9"]; 1932 function isUnmodifiedBlock(block, role) { 1933 const blockAttributes = getBlockType(block.name)?.attributes ?? {}; 1934 const attributesByRole = role ? Object.entries(blockAttributes).filter(([key, definition]) => { 1935 if (role === "content" && key === "metadata") { 1936 return Object.keys( 1937 block.attributes[key]?.bindings ?? {} 1938 ).length > 0; 1939 } 1940 return definition.role === role || definition.__experimentalRole === role; 1941 }) : []; 1942 const attributesToCheck = !!attributesByRole.length ? attributesByRole : Object.entries(blockAttributes); 1943 return attributesToCheck.every(([key, definition]) => { 1944 const value = block.attributes[key]; 1945 if (definition.hasOwnProperty("default")) { 1946 return value === definition.default; 1947 } 1948 if (definition.type === "rich-text") { 1949 return !value?.length; 1950 } 1951 return value === void 0; 1952 }); 1953 } 1954 function isUnmodifiedDefaultBlock(block, role) { 1955 return block.name === getDefaultBlockName() && isUnmodifiedBlock(block, role); 1956 } 1957 function isValidIcon(icon) { 1958 return !!icon && (typeof icon === "string" || (0, import_element.isValidElement)(icon) || typeof icon === "function" || icon instanceof import_element.Component); 1959 } 1960 function normalizeIconObject(icon) { 1961 const resolvedIcon = icon || BLOCK_ICON_DEFAULT; 1962 if (isValidIcon(resolvedIcon)) { 1963 return { src: resolvedIcon }; 1964 } 1965 const iconDescriptor = resolvedIcon; 1966 if ("background" in iconDescriptor) { 1967 const colordBgColor = A(iconDescriptor.background); 1968 const getColorContrast = (iconColor) => colordBgColor.contrast(iconColor); 1969 const maxContrast = Math.max(...ICON_COLORS.map(getColorContrast)); 1970 return { 1971 ...iconDescriptor, 1972 foreground: iconDescriptor.foreground ? iconDescriptor.foreground : ICON_COLORS.find( 1973 (iconColor) => getColorContrast(iconColor) === maxContrast 1974 ), 1975 shadowColor: colordBgColor.alpha(0.3).toRgbString() 1976 }; 1977 } 1978 return iconDescriptor; 1979 } 1980 function normalizeBlockType(blockTypeOrName) { 1981 if (typeof blockTypeOrName === "string") { 1982 return getBlockType(blockTypeOrName); 1983 } 1984 return blockTypeOrName; 1985 } 1986 function getBlockLabel(blockType, attributes, context = "visual") { 1987 const { __experimentalLabel: getLabel, title } = blockType; 1988 const label = getLabel && getLabel(attributes, { context }); 1989 if (!label) { 1990 return title; 1991 } 1992 if (label.toPlainText) { 1993 return label.toPlainText(); 1994 } 1995 return (0, import_dom.__unstableStripHTML)(label); 1996 } 1997 function getAccessibleBlockLabel(blockType, attributes, position, direction = "vertical") { 1998 const title = blockType?.title ?? ""; 1999 const label = blockType ? getBlockLabel(blockType, attributes, "accessibility") : ""; 2000 const hasPosition = position !== void 0; 2001 const hasLabel = label && label !== title; 2002 if (hasPosition && direction === "vertical") { 2003 if (hasLabel) { 2004 return (0, import_i18n2.sprintf)( 2005 /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */ 2006 (0, import_i18n2.__)("%1$s Block. Row %2$d. %3$s"), 2007 title, 2008 position, 2009 label 2010 ); 2011 } 2012 return (0, import_i18n2.sprintf)( 2013 /* translators: accessibility text. 1: The block title. 2: The block row number. */ 2014 (0, import_i18n2.__)("%1$s Block. Row %2$d"), 2015 title, 2016 position 2017 ); 2018 } else if (hasPosition && direction === "horizontal") { 2019 if (hasLabel) { 2020 return (0, import_i18n2.sprintf)( 2021 /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */ 2022 (0, import_i18n2.__)("%1$s Block. Column %2$d. %3$s"), 2023 title, 2024 position, 2025 label 2026 ); 2027 } 2028 return (0, import_i18n2.sprintf)( 2029 /* translators: accessibility text. 1: The block title. 2: The block column number. */ 2030 (0, import_i18n2.__)("%1$s Block. Column %2$d"), 2031 title, 2032 position 2033 ); 2034 } 2035 if (hasLabel) { 2036 return (0, import_i18n2.sprintf)( 2037 /* translators: accessibility text. 1: The block title. 2: The block label. */ 2038 (0, import_i18n2.__)("%1$s Block. %2$s"), 2039 title, 2040 label 2041 ); 2042 } 2043 return (0, import_i18n2.sprintf)( 2044 /* translators: accessibility text. %s: The block title. */ 2045 (0, import_i18n2.__)("%s Block"), 2046 title 2047 ); 2048 } 2049 function getDefault(attributeSchema) { 2050 if (attributeSchema.default !== void 0) { 2051 return attributeSchema.default; 2052 } 2053 if (attributeSchema.type === "rich-text") { 2054 return new import_rich_text.RichTextData(); 2055 } 2056 return void 0; 2057 } 2058 function isBlockRegistered(name) { 2059 return getBlockType(name) !== void 0; 2060 } 2061 function sanitizeBlockAttributes(name, attributes) { 2062 const blockType = getBlockType(name); 2063 if (void 0 === blockType) { 2064 throw new Error(`Block type '$name}' is not registered.`); 2065 } 2066 return Object.entries(blockType.attributes).reduce( 2067 (accumulator, [key, schema]) => { 2068 const value = attributes[key]; 2069 if (void 0 !== value) { 2070 if (schema.type === "rich-text") { 2071 if (value instanceof import_rich_text.RichTextData) { 2072 accumulator[key] = value; 2073 } else if (typeof value === "string") { 2074 accumulator[key] = import_rich_text.RichTextData.fromHTMLString(value); 2075 } 2076 } else if (schema.type === "string" && value instanceof import_rich_text.RichTextData) { 2077 accumulator[key] = value.toHTMLString(); 2078 } else { 2079 accumulator[key] = value; 2080 } 2081 } else { 2082 const _default = getDefault(schema); 2083 if (void 0 !== _default) { 2084 accumulator[key] = _default; 2085 } 2086 } 2087 if (["node", "children"].indexOf(schema.source ?? "") !== -1) { 2088 if (typeof accumulator[key] === "string") { 2089 accumulator[key] = [accumulator[key]]; 2090 } else if (!Array.isArray(accumulator[key])) { 2091 accumulator[key] = []; 2092 } 2093 } 2094 return accumulator; 2095 }, 2096 {} 2097 ); 2098 } 2099 function __experimentalSanitizeBlockAttributes(name, attributes) { 2100 (0, import_deprecated.default)("__experimentalSanitizeBlockAttributes", { 2101 since: "7.1", 2102 alternative: "sanitizeBlockAttributes" 2103 }); 2104 return sanitizeBlockAttributes(name, attributes); 2105 } 2106 function getBlockAttributesNamesByRole(name, role) { 2107 const attributes = getBlockType(name)?.attributes; 2108 if (!attributes) { 2109 return []; 2110 } 2111 const attributesNames = Object.keys(attributes); 2112 if (!role) { 2113 return attributesNames; 2114 } 2115 return attributesNames.filter((attributeName) => { 2116 const attribute = attributes[attributeName]; 2117 if (attribute?.role === role) { 2118 return true; 2119 } 2120 if (attribute?.__experimentalRole === role) { 2121 (0, import_deprecated.default)("__experimentalRole attribute", { 2122 since: "6.7", 2123 version: "6.8", 2124 alternative: "role attribute", 2125 hint: `Check the block.json of the $name} block.` 2126 }); 2127 return true; 2128 } 2129 return false; 2130 }); 2131 } 2132 var __experimentalGetBlockAttributesNamesByRole = (...args) => { 2133 (0, import_deprecated.default)("__experimentalGetBlockAttributesNamesByRole", { 2134 since: "6.7", 2135 version: "6.8", 2136 alternative: "getBlockAttributesNamesByRole" 2137 }); 2138 return getBlockAttributesNamesByRole(...args); 2139 }; 2140 function isContentBlock(name) { 2141 const blockType = getBlockType(name); 2142 const attributes = blockType?.attributes; 2143 const supportsContentRole = blockType?.supports?.contentRole; 2144 if (supportsContentRole) { 2145 return true; 2146 } 2147 if (!attributes) { 2148 return false; 2149 } 2150 return !!Object.keys(attributes)?.some((attributeKey) => { 2151 const attribute = attributes[attributeKey]; 2152 return attribute?.role === "content" || attribute?.__experimentalRole === "content"; 2153 }); 2154 } 2155 function omit(object, keys) { 2156 const keysArray = Array.isArray(keys) ? keys : [keys]; 2157 return Object.fromEntries( 2158 Object.entries(object).filter( 2159 ([key]) => !keysArray.includes(key) 2160 ) 2161 ); 2162 } 2163 2164 // packages/blocks/build-module/store/reducer.mjs 2165 var DEFAULT_CATEGORIES = [ 2166 { slug: "text", title: (0, import_i18n3.__)("Text") }, 2167 { slug: "media", title: (0, import_i18n3.__)("Media") }, 2168 { slug: "design", title: (0, import_i18n3.__)("Design") }, 2169 { slug: "widgets", title: (0, import_i18n3.__)("Widgets") }, 2170 { slug: "theme", title: (0, import_i18n3.__)("Theme") }, 2171 { slug: "embed", title: (0, import_i18n3.__)("Embeds") }, 2172 { slug: "reusable", title: (0, import_i18n3.__)("Reusable blocks") } 2173 ]; 2174 function keyBlockTypesByName(types) { 2175 return types.reduce( 2176 (newBlockTypes, block) => ({ 2177 ...newBlockTypes, 2178 [block.name]: block 2179 }), 2180 {} 2181 ); 2182 } 2183 function getUniqueItemsByName(items) { 2184 return items.reduce((acc, currentItem) => { 2185 if (!acc.some((item) => item.name === currentItem.name)) { 2186 acc.push(currentItem); 2187 } 2188 return acc; 2189 }, []); 2190 } 2191 function bootstrappedBlockTypes(state = {}, action) { 2192 switch (action.type) { 2193 case "ADD_BOOTSTRAPPED_BLOCK_TYPE": 2194 const { name, blockType } = action; 2195 const serverDefinition = state[name]; 2196 if (serverDefinition) { 2197 return state; 2198 } 2199 const newDefinition = Object.fromEntries( 2200 Object.entries(blockType).filter( 2201 ([, value]) => value !== null && value !== void 0 2202 ).map(([key, value]) => [camelCase(key), value]) 2203 ); 2204 newDefinition.name = name; 2205 return { 2206 ...state, 2207 [name]: newDefinition 2208 }; 2209 case "REMOVE_BLOCK_TYPES": 2210 return omit(state, action.names); 2211 } 2212 return state; 2213 } 2214 function unprocessedBlockTypes(state = {}, action) { 2215 switch (action.type) { 2216 case "ADD_UNPROCESSED_BLOCK_TYPE": 2217 return { 2218 ...state, 2219 [action.name]: action.blockType 2220 }; 2221 case "REMOVE_BLOCK_TYPES": 2222 return omit(state, action.names); 2223 } 2224 return state; 2225 } 2226 function blockTypes(state = {}, action) { 2227 switch (action.type) { 2228 case "ADD_BLOCK_TYPES": 2229 return { 2230 ...state, 2231 ...keyBlockTypesByName(action.blockTypes) 2232 }; 2233 case "REMOVE_BLOCK_TYPES": 2234 return omit(state, action.names); 2235 } 2236 return state; 2237 } 2238 function blockStyles(state = {}, action) { 2239 switch (action.type) { 2240 case "ADD_BLOCK_TYPES": 2241 return { 2242 ...state, 2243 ...Object.fromEntries( 2244 Object.entries( 2245 keyBlockTypesByName(action.blockTypes) 2246 ).map(([name, blockType]) => [ 2247 name, 2248 getUniqueItemsByName([ 2249 ...(blockType.styles ?? []).map((style) => ({ 2250 ...style, 2251 source: "block" 2252 })), 2253 ...(state[blockType.name] ?? []).filter( 2254 ({ source }) => "block" !== source 2255 ) 2256 ]) 2257 ]) 2258 ) 2259 }; 2260 case "ADD_BLOCK_STYLES": 2261 const updatedStyles = {}; 2262 action.blockNames.forEach((blockName) => { 2263 updatedStyles[blockName] = getUniqueItemsByName([ 2264 ...state[blockName] ?? [], 2265 ...action.styles 2266 ]); 2267 }); 2268 return { ...state, ...updatedStyles }; 2269 case "REMOVE_BLOCK_STYLES": 2270 return { 2271 ...state, 2272 [action.blockName]: (state[action.blockName] ?? []).filter( 2273 (style) => action.styleNames.indexOf(style.name) === -1 2274 ) 2275 }; 2276 } 2277 return state; 2278 } 2279 function blockVariations(state = {}, action) { 2280 switch (action.type) { 2281 case "ADD_BLOCK_TYPES": 2282 return { 2283 ...state, 2284 ...Object.fromEntries( 2285 Object.entries( 2286 keyBlockTypesByName(action.blockTypes) 2287 ).map(([name, blockType]) => { 2288 return [ 2289 name, 2290 getUniqueItemsByName([ 2291 ...(blockType.variations ?? []).map( 2292 (variation) => ({ 2293 ...variation, 2294 source: "block" 2295 }) 2296 ), 2297 ...(state[blockType.name] ?? []).filter( 2298 ({ source }) => "block" !== source 2299 ) 2300 ]) 2301 ]; 2302 }) 2303 ) 2304 }; 2305 case "ADD_BLOCK_VARIATIONS": 2306 return { 2307 ...state, 2308 [action.blockName]: getUniqueItemsByName([ 2309 ...state[action.blockName] ?? [], 2310 ...action.variations 2311 ]) 2312 }; 2313 case "REMOVE_BLOCK_VARIATIONS": 2314 return { 2315 ...state, 2316 [action.blockName]: (state[action.blockName] ?? []).filter( 2317 (variation) => action.variationNames.indexOf(variation.name) === -1 2318 ) 2319 }; 2320 } 2321 return state; 2322 } 2323 function createBlockNameSetterReducer(setActionType) { 2324 return (state = null, action) => { 2325 switch (action.type) { 2326 case "REMOVE_BLOCK_TYPES": 2327 if (action.names.indexOf(state) !== -1) { 2328 return null; 2329 } 2330 return state; 2331 case setActionType: 2332 return action.name || null; 2333 } 2334 return state; 2335 }; 2336 } 2337 var defaultBlockName = createBlockNameSetterReducer( 2338 "SET_DEFAULT_BLOCK_NAME" 2339 ); 2340 var freeformFallbackBlockName = createBlockNameSetterReducer( 2341 "SET_FREEFORM_FALLBACK_BLOCK_NAME" 2342 ); 2343 var unregisteredFallbackBlockName = createBlockNameSetterReducer( 2344 "SET_UNREGISTERED_FALLBACK_BLOCK_NAME" 2345 ); 2346 var groupingBlockName = createBlockNameSetterReducer( 2347 "SET_GROUPING_BLOCK_NAME" 2348 ); 2349 function categories(state = DEFAULT_CATEGORIES, action) { 2350 switch (action.type) { 2351 case "SET_CATEGORIES": 2352 const uniqueCategories = /* @__PURE__ */ new Map(); 2353 (action.categories || []).forEach((category) => { 2354 uniqueCategories.set(category.slug, category); 2355 }); 2356 return [...uniqueCategories.values()]; 2357 case "UPDATE_CATEGORY": { 2358 if (!action.category || !Object.keys(action.category).length) { 2359 return state; 2360 } 2361 const categoryToChange = state.find( 2362 ({ slug }) => slug === action.slug 2363 ); 2364 if (categoryToChange) { 2365 return state.map((category) => { 2366 if (category.slug === action.slug) { 2367 return { 2368 ...category, 2369 ...action.category 2370 }; 2371 } 2372 return category; 2373 }); 2374 } 2375 } 2376 } 2377 return state; 2378 } 2379 function collections(state = {}, action) { 2380 switch (action.type) { 2381 case "ADD_BLOCK_COLLECTION": 2382 return { 2383 ...state, 2384 [action.namespace]: { 2385 title: action.title, 2386 icon: action.icon 2387 } 2388 }; 2389 case "REMOVE_BLOCK_COLLECTION": 2390 return omit(state, action.namespace); 2391 } 2392 return state; 2393 } 2394 function getMergedUsesContext(existingUsesContext = [], newUsesContext = []) { 2395 const mergedArrays = Array.from( 2396 new Set(existingUsesContext.concat(newUsesContext)) 2397 ); 2398 return mergedArrays.length > 0 ? mergedArrays : void 0; 2399 } 2400 function blockBindingsSources(state = {}, action) { 2401 switch (action.type) { 2402 case "ADD_BLOCK_BINDINGS_SOURCE": 2403 return { 2404 ...state, 2405 [action.name]: { 2406 label: action.label || state[action.name]?.label, 2407 usesContext: getMergedUsesContext( 2408 state[action.name]?.usesContext, 2409 action.usesContext 2410 ), 2411 getValues: action.getValues, 2412 setValues: action.setValues, 2413 // Only set `canUserEditValue` if `setValues` is also defined. 2414 canUserEditValue: action.setValues && action.canUserEditValue, 2415 getFieldsList: action.getFieldsList 2416 } 2417 }; 2418 case "REMOVE_BLOCK_BINDINGS_SOURCE": 2419 return omit(state, action.name); 2420 } 2421 return state; 2422 } 2423 var reducer_default = (0, import_data2.combineReducers)({ 2424 bootstrappedBlockTypes, 2425 unprocessedBlockTypes, 2426 blockTypes, 2427 blockStyles, 2428 blockVariations, 2429 defaultBlockName, 2430 freeformFallbackBlockName, 2431 unregisteredFallbackBlockName, 2432 groupingBlockName, 2433 categories, 2434 collections, 2435 blockBindingsSources 2436 }); 2437 2438 // packages/blocks/build-module/store/selectors.mjs 2439 var selectors_exports = {}; 2440 __export(selectors_exports, { 2441 __experimentalHasContentRoleAttribute: () => __experimentalHasContentRoleAttribute, 2442 getActiveBlockVariation: () => getActiveBlockVariation, 2443 getBlockStyles: () => getBlockStyles, 2444 getBlockSupport: () => getBlockSupport2, 2445 getBlockType: () => getBlockType2, 2446 getBlockTypes: () => getBlockTypes2, 2447 getBlockVariations: () => getBlockVariations2, 2448 getCategories: () => getCategories, 2449 getChildBlockNames: () => getChildBlockNames2, 2450 getCollections: () => getCollections, 2451 getDefaultBlockName: () => getDefaultBlockName2, 2452 getDefaultBlockVariation: () => getDefaultBlockVariation, 2453 getFreeformFallbackBlockName: () => getFreeformFallbackBlockName, 2454 getGroupingBlockName: () => getGroupingBlockName2, 2455 getUnregisteredFallbackBlockName: () => getUnregisteredFallbackBlockName, 2456 hasBlockSupport: () => hasBlockSupport2, 2457 hasChildBlocks: () => hasChildBlocks2, 2458 hasChildBlocksWithInserterSupport: () => hasChildBlocksWithInserterSupport2, 2459 isMatchingSearchTerm: () => isMatchingSearchTerm 2460 }); 2461 var import_remove_accents = __toESM(require_remove_accents(), 1); 2462 var import_es6 = __toESM(require_es6(), 1); 2463 var import_data4 = __toESM(require_data(), 1); 2464 var import_rich_text2 = __toESM(require_rich_text(), 1); 2465 var import_deprecated3 = __toESM(require_deprecated(), 1); 2466 2467 // packages/blocks/build-module/store/utils.mjs 2468 var getValueFromObjectPath = (object, path, defaultValue) => { 2469 const normalizedPath = Array.isArray(path) ? path : path.split("."); 2470 let value = object; 2471 normalizedPath.forEach((fieldName) => { 2472 value = value?.[fieldName]; 2473 }); 2474 return value ?? defaultValue; 2475 }; 2476 function isObject2(candidate) { 2477 return typeof candidate === "object" && candidate !== null && candidate.constructor === Object; 2478 } 2479 function matchesAttributes(blockAttributes, variationAttributes) { 2480 if (isObject2(blockAttributes) && isObject2(variationAttributes)) { 2481 return Object.entries(variationAttributes).every( 2482 ([key, value]) => matchesAttributes(blockAttributes?.[key], value) 2483 ); 2484 } 2485 return blockAttributes === variationAttributes; 2486 } 2487 2488 // packages/blocks/build-module/store/private-selectors.mjs 2489 var private_selectors_exports = {}; 2490 __export(private_selectors_exports, { 2491 getAllBlockBindingsSources: () => getAllBlockBindingsSources, 2492 getBlockBindingsSource: () => getBlockBindingsSource2, 2493 getBlockBindingsSourceFieldsList: () => getBlockBindingsSourceFieldsList, 2494 getBlockKeyboardShortcuts: () => getBlockKeyboardShortcuts, 2495 getBootstrappedBlockType: () => getBootstrappedBlockType, 2496 getSupportedStyles: () => getSupportedStyles, 2497 getUnprocessedBlockTypes: () => getUnprocessedBlockTypes, 2498 hasContentRoleAttribute: () => hasContentRoleAttribute 2499 }); 2500 var import_data3 = __toESM(require_data(), 1); 2501 var import_deprecated2 = __toESM(require_deprecated(), 1); 2502 var ROOT_BLOCK_SUPPORTS = [ 2503 "background", 2504 "backgroundColor", 2505 "color", 2506 "linkColor", 2507 "captionColor", 2508 "buttonColor", 2509 "headingColor", 2510 "fontFamily", 2511 "fontSize", 2512 "fontStyle", 2513 "fontWeight", 2514 "lineHeight", 2515 "padding", 2516 "contentSize", 2517 "wideSize", 2518 "blockGap", 2519 "textAlign", 2520 "textDecoration", 2521 "textIndent", 2522 "textTransform", 2523 "textShadow", 2524 "letterSpacing" 2525 ]; 2526 function filterElementBlockSupports(blockSupports, name, element) { 2527 return blockSupports.filter((support) => { 2528 if (support === "fontSize" && element === "heading") { 2529 return false; 2530 } 2531 if (support === "textDecoration" && !name && element !== "link") { 2532 return false; 2533 } 2534 if (support === "textTransform" && !name && !(["heading", "h1", "h2", "h3", "h4", "h5", "h6"].includes( 2535 element 2536 ) || element === "button" || element === "caption" || element === "text")) { 2537 return false; 2538 } 2539 if (support === "letterSpacing" && !name && !(["heading", "h1", "h2", "h3", "h4", "h5", "h6"].includes( 2540 element 2541 ) || element === "button" || element === "caption" || element === "text")) { 2542 return false; 2543 } 2544 if (support === "textIndent" && !name) { 2545 return false; 2546 } 2547 if (support === "textColumns" && !name) { 2548 return false; 2549 } 2550 return true; 2551 }); 2552 } 2553 var getSupportedStyles = (0, import_data3.createSelector)( 2554 (state, name, element) => { 2555 if (!name) { 2556 return filterElementBlockSupports( 2557 ROOT_BLOCK_SUPPORTS, 2558 name, 2559 element 2560 ); 2561 } 2562 const blockType = getBlockType2(state, name); 2563 if (!blockType) { 2564 return []; 2565 } 2566 const supportKeys = []; 2567 const supports = blockType?.supports; 2568 if (supports?.spacing?.blockGap) { 2569 supportKeys.push("blockGap"); 2570 } 2571 if (supports?.shadow) { 2572 supportKeys.push("shadow"); 2573 } 2574 const stylePropertyMap = __EXPERIMENTAL_STYLE_PROPERTY; 2575 Object.keys(stylePropertyMap).forEach((styleName) => { 2576 if (!stylePropertyMap[styleName].support) { 2577 return; 2578 } 2579 if (stylePropertyMap[styleName].requiresOptOut) { 2580 if (supports && stylePropertyMap[styleName].support[0] in supports && getValueFromObjectPath( 2581 supports, 2582 stylePropertyMap[styleName].support 2583 ) !== false) { 2584 supportKeys.push(styleName); 2585 return; 2586 } 2587 } 2588 if (supports && getValueFromObjectPath( 2589 supports, 2590 stylePropertyMap[styleName].support, 2591 false 2592 )) { 2593 supportKeys.push(styleName); 2594 } 2595 }); 2596 return filterElementBlockSupports(supportKeys, name, element); 2597 }, 2598 (state, name) => [ 2599 state.blockTypes[name] 2600 ] 2601 ); 2602 function getBootstrappedBlockType(state, name) { 2603 return state.bootstrappedBlockTypes[name]; 2604 } 2605 function getUnprocessedBlockTypes(state) { 2606 return state.unprocessedBlockTypes; 2607 } 2608 function getAllBlockBindingsSources(state) { 2609 return state.blockBindingsSources; 2610 } 2611 function getBlockBindingsSource2(state, sourceName) { 2612 return state.blockBindingsSources[sourceName]; 2613 } 2614 var getBlockBindingsSourceFieldsList = (0, import_data3.createRegistrySelector)( 2615 (select3) => (0, import_data3.createSelector)( 2616 (state, source, blockContext) => { 2617 if (!source.getFieldsList) { 2618 return []; 2619 } 2620 const context = {}; 2621 if (source?.usesContext?.length) { 2622 for (const key of source.usesContext) { 2623 context[key] = blockContext[key]; 2624 } 2625 } 2626 return source.getFieldsList({ select: select3, context }); 2627 }, 2628 (state, source, blockContext) => [source.getFieldsList, source.usesContext, blockContext] 2629 ) 2630 ); 2631 var getBlockKeyboardShortcuts = (0, import_data3.createSelector)( 2632 (state) => { 2633 const shortcuts = []; 2634 for (const blockName of Object.keys(state.blockTypes)) { 2635 for (const variation of state.blockVariations[blockName] ?? []) { 2636 if (!variation.shortcut) { 2637 continue; 2638 } 2639 shortcuts.push({ 2640 ...variation.shortcut, 2641 targetBlockName: blockName, 2642 blockNames: [blockName], 2643 variationName: variation.name 2644 }); 2645 } 2646 const transforms = state.blockTypes[blockName]?.transforms; 2647 for (const transform of transforms?.to ?? []) { 2648 if (transform.type !== "block") { 2649 continue; 2650 } 2651 const targetBlockName = transform.blocks?.[0]; 2652 if (!targetBlockName) { 2653 continue; 2654 } 2655 for (const shortcut of transform.shortcuts ?? []) { 2656 shortcuts.push({ 2657 ...shortcut, 2658 targetBlockName, 2659 blockNames: [blockName], 2660 variationName: shortcut.variationName ?? transform.variationName 2661 }); 2662 } 2663 } 2664 for (const transform of transforms?.from ?? []) { 2665 if (transform.type !== "block" || !transform.blocks?.length) { 2666 continue; 2667 } 2668 for (const shortcut of transform.shortcuts ?? []) { 2669 shortcuts.push({ 2670 ...shortcut, 2671 targetBlockName: blockName, 2672 blockNames: transform.blocks, 2673 variationName: shortcut.variationName ?? transform.variationName 2674 }); 2675 } 2676 } 2677 } 2678 return shortcuts; 2679 }, 2680 (state) => [state.blockTypes, state.blockVariations] 2681 ); 2682 var hasContentRoleAttribute = (state, blockTypeName) => { 2683 const blockType = getBlockType2(state, blockTypeName); 2684 if (!blockType) { 2685 return false; 2686 } 2687 return Object.values(blockType.attributes).some( 2688 ({ role, __experimentalRole }) => { 2689 if (role === "content") { 2690 return true; 2691 } 2692 if (__experimentalRole === "content") { 2693 (0, import_deprecated2.default)("__experimentalRole attribute", { 2694 since: "6.7", 2695 version: "6.8", 2696 alternative: "role attribute", 2697 hint: `Check the block.json of the $blockTypeName} block.` 2698 }); 2699 return true; 2700 } 2701 return false; 2702 } 2703 ); 2704 }; 2705 2706 // packages/blocks/build-module/store/selectors.mjs 2707 var getNormalizedBlockType = (state, nameOrType) => "string" === typeof nameOrType ? getBlockType2(state, nameOrType) : nameOrType; 2708 var getBlockTypes2 = (0, import_data4.createSelector)( 2709 (state) => Object.values(state.blockTypes), 2710 (state) => [state.blockTypes] 2711 ); 2712 function getBlockType2(state, name) { 2713 return state.blockTypes[name]; 2714 } 2715 function getBlockStyles(state, name) { 2716 return state.blockStyles[name]; 2717 } 2718 var getBlockVariations2 = (0, import_data4.createSelector)( 2719 (state, blockName, scope) => { 2720 const variations = state.blockVariations[blockName]; 2721 if (!variations || !scope) { 2722 return variations; 2723 } 2724 return variations.filter((variation) => { 2725 return (variation.scope || ["block", "inserter"]).includes( 2726 scope 2727 ); 2728 }); 2729 }, 2730 (state, blockName) => [ 2731 state.blockVariations[blockName] 2732 ] 2733 ); 2734 function getActiveBlockVariation(state, blockName, attributes, scope, innerContent) { 2735 const variations = getBlockVariations2(state, blockName, scope); 2736 if (!variations) { 2737 return variations; 2738 } 2739 if (innerContent) { 2740 const innerContentMatch = variations.find( 2741 (variation) => variation.innerContent && (0, import_es6.default)(variation.innerContent, innerContent) 2742 ); 2743 if (innerContentMatch) { 2744 return innerContentMatch; 2745 } 2746 } 2747 const blockType = getBlockType2(state, blockName); 2748 const attributeKeys = Object.keys(blockType?.attributes || {}); 2749 let match; 2750 let maxMatchedAttributes = 0; 2751 for (const variation of variations) { 2752 if (variation.innerContent) { 2753 continue; 2754 } 2755 if (Array.isArray(variation.isActive)) { 2756 const definedAttributes = variation.isActive.filter( 2757 (attribute) => { 2758 const topLevelAttribute = attribute.split(".")[0]; 2759 return attributeKeys.includes(topLevelAttribute); 2760 } 2761 ); 2762 const definedAttributesLength = definedAttributes.length; 2763 if (definedAttributesLength === 0) { 2764 continue; 2765 } 2766 const isMatch = definedAttributes.every((attribute) => { 2767 const variationAttributeValue = getValueFromObjectPath( 2768 variation.attributes, 2769 attribute 2770 ); 2771 if (variationAttributeValue === void 0) { 2772 return false; 2773 } 2774 let blockAttributeValue = getValueFromObjectPath( 2775 attributes, 2776 attribute 2777 ); 2778 if (blockAttributeValue instanceof import_rich_text2.RichTextData) { 2779 blockAttributeValue = blockAttributeValue.toHTMLString(); 2780 } 2781 return matchesAttributes( 2782 blockAttributeValue, 2783 variationAttributeValue 2784 ); 2785 }); 2786 if (isMatch && definedAttributesLength > maxMatchedAttributes) { 2787 match = variation; 2788 maxMatchedAttributes = definedAttributesLength; 2789 } 2790 } else if (variation.isActive?.( 2791 attributes, 2792 variation.attributes 2793 )) { 2794 return match || variation; 2795 } 2796 } 2797 if (!match && ["block", "transform"].includes(scope)) { 2798 match = variations.find( 2799 (variation) => variation?.isDefault && !Object.hasOwn(variation, "isActive") 2800 ); 2801 } 2802 return match; 2803 } 2804 function getDefaultBlockVariation(state, blockName, scope) { 2805 const variations = getBlockVariations2(state, blockName, scope); 2806 const defaultVariation = [...variations || []].reverse().find(({ isDefault }) => !!isDefault); 2807 return defaultVariation || variations?.[0]; 2808 } 2809 function getCategories(state) { 2810 return state.categories; 2811 } 2812 function getCollections(state) { 2813 return state.collections; 2814 } 2815 function getDefaultBlockName2(state) { 2816 return state.defaultBlockName; 2817 } 2818 function getFreeformFallbackBlockName(state) { 2819 return state.freeformFallbackBlockName; 2820 } 2821 function getUnregisteredFallbackBlockName(state) { 2822 return state.unregisteredFallbackBlockName; 2823 } 2824 function getGroupingBlockName2(state) { 2825 return state.groupingBlockName; 2826 } 2827 var getChildBlockNames2 = (0, import_data4.createSelector)( 2828 (state, blockName) => { 2829 return getBlockTypes2(state).filter((blockType) => { 2830 return blockType.parent?.includes(blockName); 2831 }).map(({ name }) => name); 2832 }, 2833 (state) => [state.blockTypes] 2834 ); 2835 var getBlockSupport2 = (state, nameOrType, feature, defaultSupports) => { 2836 const blockType = getNormalizedBlockType(state, nameOrType); 2837 if (!blockType?.supports) { 2838 return defaultSupports; 2839 } 2840 return getValueFromObjectPath( 2841 blockType.supports, 2842 feature, 2843 defaultSupports 2844 ); 2845 }; 2846 function hasBlockSupport2(state, nameOrType, feature, defaultSupports) { 2847 return !!getBlockSupport2(state, nameOrType, feature, defaultSupports); 2848 } 2849 function getNormalizedSearchTerm(term) { 2850 return (0, import_remove_accents.default)(term ?? "").toLowerCase().trim(); 2851 } 2852 function isMatchingSearchTerm(state, nameOrType, searchTerm = "") { 2853 const blockType = getNormalizedBlockType(state, nameOrType); 2854 const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm); 2855 const isSearchMatch = (candidate) => getNormalizedSearchTerm(candidate).includes(normalizedSearchTerm); 2856 return isSearchMatch(blockType?.title) || blockType?.keywords?.some(isSearchMatch) || isSearchMatch(blockType?.category) || typeof blockType?.description === "string" && isSearchMatch(blockType.description); 2857 } 2858 var hasChildBlocks2 = (state, blockName) => { 2859 return getChildBlockNames2(state, blockName).length > 0; 2860 }; 2861 var hasChildBlocksWithInserterSupport2 = (state, blockName) => { 2862 return getChildBlockNames2(state, blockName).some((childBlockName) => { 2863 return hasBlockSupport2(state, childBlockName, "inserter", true); 2864 }); 2865 }; 2866 var __experimentalHasContentRoleAttribute = (...args) => { 2867 (0, import_deprecated3.default)("__experimentalHasContentRoleAttribute", { 2868 since: "6.7", 2869 version: "6.8", 2870 hint: "This is a private selector." 2871 }); 2872 return hasContentRoleAttribute(...args); 2873 }; 2874 2875 // packages/blocks/build-module/store/actions.mjs 2876 var actions_exports = {}; 2877 __export(actions_exports, { 2878 __experimentalReapplyBlockFilters: () => __experimentalReapplyBlockFilters, 2879 addBlockCollection: () => addBlockCollection, 2880 addBlockStyles: () => addBlockStyles, 2881 addBlockTypes: () => addBlockTypes, 2882 addBlockVariations: () => addBlockVariations, 2883 reapplyBlockTypeFilters: () => reapplyBlockTypeFilters, 2884 removeBlockCollection: () => removeBlockCollection, 2885 removeBlockStyles: () => removeBlockStyles, 2886 removeBlockTypes: () => removeBlockTypes, 2887 removeBlockVariations: () => removeBlockVariations, 2888 setCategories: () => setCategories, 2889 setDefaultBlockName: () => setDefaultBlockName2, 2890 setFreeformFallbackBlockName: () => setFreeformFallbackBlockName, 2891 setGroupingBlockName: () => setGroupingBlockName2, 2892 setUnregisteredFallbackBlockName: () => setUnregisteredFallbackBlockName, 2893 updateCategory: () => updateCategory 2894 }); 2895 var import_deprecated5 = __toESM(require_deprecated(), 1); 2896 2897 // node_modules/is-plain-object/dist/is-plain-object.mjs 2898 function isObject3(o2) { 2899 return Object.prototype.toString.call(o2) === "[object Object]"; 2900 } 2901 function isPlainObject(o2) { 2902 var ctor, prot; 2903 if (isObject3(o2) === false) return false; 2904 ctor = o2.constructor; 2905 if (ctor === void 0) return true; 2906 prot = ctor.prototype; 2907 if (isObject3(prot) === false) return false; 2908 if (prot.hasOwnProperty("isPrototypeOf") === false) { 2909 return false; 2910 } 2911 return true; 2912 } 2913 2914 // packages/blocks/build-module/store/process-block-type.mjs 2915 var import_react_is = __toESM(require_react_is(), 1); 2916 var import_deprecated4 = __toESM(require_deprecated(), 1); 2917 var import_hooks = __toESM(require_hooks(), 1); 2918 var import_warning2 = __toESM(require_warning(), 1); 2919 var LEGACY_CATEGORY_MAPPING = { 2920 common: "text", 2921 formatting: "text", 2922 layout: "design" 2923 }; 2924 function mergeBlockVariations(bootstrappedVariations = [], clientVariations = []) { 2925 const result = [...bootstrappedVariations]; 2926 clientVariations.forEach((clientVariation) => { 2927 const index = result.findIndex( 2928 (bootstrappedVariation) => bootstrappedVariation.name === clientVariation.name 2929 ); 2930 if (index !== -1) { 2931 result[index] = { ...result[index], ...clientVariation }; 2932 } else { 2933 result.push(clientVariation); 2934 } 2935 }); 2936 return result; 2937 } 2938 var processBlockType = (name, blockSettings) => ({ 2939 select: select3 2940 }) => { 2941 const bootstrappedBlockType = select3.getBootstrappedBlockType(name); 2942 const blockType = { 2943 apiVersion: 1, 2944 name, 2945 icon: BLOCK_ICON_DEFAULT, 2946 keywords: [], 2947 attributes: {}, 2948 providesContext: {}, 2949 usesContext: [], 2950 selectors: {}, 2951 supports: {}, 2952 styles: [], 2953 blockHooks: {}, 2954 save: () => null, 2955 ...bootstrappedBlockType, 2956 ...blockSettings, 2957 // blockType.variations can be defined as a filePath. 2958 variations: mergeBlockVariations( 2959 Array.isArray(bootstrappedBlockType?.variations) ? bootstrappedBlockType.variations : [], 2960 Array.isArray(blockSettings?.variations) ? blockSettings.variations : [] 2961 ) 2962 }; 2963 if (!blockType.attributes || typeof blockType.attributes !== "object") { 2964 (0, import_warning2.default)( 2965 'The block "' + name + '" is registering attributes as `null` or `undefined`. Use an empty object (`attributes: {}`) or exclude the `attributes` key.' 2966 ); 2967 blockType.attributes = {}; 2968 } 2969 const settings = (0, import_hooks.applyFilters)( 2970 "blocks.registerBlockType", 2971 blockType, 2972 name, 2973 null 2974 ); 2975 if (settings.apiVersion <= 2) { 2976 (0, import_deprecated4.default)("Block with API version 2 or lower", { 2977 since: "6.9", 2978 hint: `The block "$name}" is registered with API version $settings.apiVersion}. This means that the post editor may work as a non-iframe editor. Since all editors are planned to work as iframes in the future, set the \`apiVersion\` field to 3 and test the block inside the iframe editor.`, 2979 link: "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/block-migration-for-iframe-editor-compatibility/" 2980 }); 2981 } 2982 if (settings.description && typeof settings.description !== "string") { 2983 (0, import_deprecated4.default)("Declaring non-string block descriptions", { 2984 since: "6.2" 2985 }); 2986 } 2987 if (settings.deprecated) { 2988 settings.deprecated = settings.deprecated.map( 2989 (deprecation) => Object.fromEntries( 2990 Object.entries( 2991 // Only keep valid deprecation keys. 2992 (0, import_hooks.applyFilters)( 2993 "blocks.registerBlockType", 2994 // Merge deprecation keys with pre-filter settings 2995 // so that filters that depend on specific keys being 2996 // present don't fail. 2997 { 2998 // Omit deprecation keys here so that deprecations 2999 // can opt out of specific keys like "supports". 3000 ...omit(blockType, DEPRECATED_ENTRY_KEYS), 3001 ...deprecation 3002 }, 3003 blockType.name, 3004 deprecation 3005 ) 3006 ).filter( 3007 ([key]) => DEPRECATED_ENTRY_KEYS.includes(key) 3008 ) 3009 ) 3010 ); 3011 } 3012 if (!isPlainObject(settings)) { 3013 (0, import_warning2.default)("Block settings must be a valid object."); 3014 return; 3015 } 3016 if (typeof settings.save !== "function") { 3017 (0, import_warning2.default)('The "save" property must be a valid function.'); 3018 return; 3019 } 3020 if ("edit" in settings && !(0, import_react_is.isValidElementType)(settings.edit)) { 3021 (0, import_warning2.default)('The "edit" property must be a valid component.'); 3022 return; 3023 } 3024 if (typeof settings.category === "string" && LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) { 3025 settings.category = LEGACY_CATEGORY_MAPPING[settings.category]; 3026 } 3027 if ("category" in settings && !select3.getCategories().some( 3028 ({ slug }) => slug === settings.category 3029 )) { 3030 (0, import_warning2.default)( 3031 'The block "' + name + '" is registered with an invalid category "' + settings.category + '".' 3032 ); 3033 delete settings.category; 3034 } 3035 if (!("title" in settings) || settings.title === "") { 3036 (0, import_warning2.default)('The block "' + name + '" must have a title.'); 3037 return; 3038 } 3039 if (typeof settings.title !== "string") { 3040 (0, import_warning2.default)("Block titles must be strings."); 3041 return; 3042 } 3043 const icon = normalizeIconObject(settings.icon); 3044 settings.icon = icon; 3045 if (!isValidIcon(icon.src)) { 3046 (0, import_warning2.default)( 3047 "The icon passed is invalid. The icon should be a string, an element, a function, or an object following the specifications documented in https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#icon-optional" 3048 ); 3049 return; 3050 } 3051 if (typeof settings?.parent === "string" || settings?.parent instanceof String) { 3052 settings.parent = [settings.parent]; 3053 (0, import_warning2.default)( 3054 "Parent must be undefined or an array of strings (block types), but it is a string." 3055 ); 3056 } 3057 if (!Array.isArray(settings?.parent) && settings?.parent !== void 0) { 3058 (0, import_warning2.default)( 3059 "Parent must be undefined or an array of block types, but it is " + settings.parent 3060 ); 3061 return; 3062 } 3063 if (1 === settings?.parent?.length && name === settings.parent[0]) { 3064 (0, import_warning2.default)( 3065 'Block "' + name + '" cannot be a parent of itself. Please remove the block name from the parent list.' 3066 ); 3067 return; 3068 } 3069 return settings; 3070 }; 3071 3072 // packages/blocks/build-module/store/actions.mjs 3073 function addBlockTypes(blockTypes2) { 3074 return { 3075 type: "ADD_BLOCK_TYPES", 3076 blockTypes: Array.isArray(blockTypes2) ? blockTypes2 : [blockTypes2] 3077 }; 3078 } 3079 function reapplyBlockTypeFilters() { 3080 return ({ dispatch: dispatch3, select: select3 }) => { 3081 const processedBlockTypes = []; 3082 for (const [name, settings] of Object.entries( 3083 select3.getUnprocessedBlockTypes() 3084 )) { 3085 const result = dispatch3(processBlockType(name, settings)); 3086 if (result) { 3087 processedBlockTypes.push(result); 3088 } 3089 } 3090 if (!processedBlockTypes.length) { 3091 return; 3092 } 3093 dispatch3.addBlockTypes(processedBlockTypes); 3094 }; 3095 } 3096 function __experimentalReapplyBlockFilters() { 3097 (0, import_deprecated5.default)( 3098 'wp.data.dispatch( "core/blocks" ).__experimentalReapplyBlockFilters', 3099 { 3100 since: "6.4", 3101 alternative: "reapplyBlockFilters" 3102 } 3103 ); 3104 return reapplyBlockTypeFilters(); 3105 } 3106 function removeBlockTypes(names) { 3107 return { 3108 type: "REMOVE_BLOCK_TYPES", 3109 names: Array.isArray(names) ? names : [names] 3110 }; 3111 } 3112 function addBlockStyles(blockNames, styles) { 3113 return { 3114 type: "ADD_BLOCK_STYLES", 3115 styles: Array.isArray(styles) ? styles : [styles], 3116 blockNames: Array.isArray(blockNames) ? blockNames : [blockNames] 3117 }; 3118 } 3119 function removeBlockStyles(blockName, styleNames) { 3120 return { 3121 type: "REMOVE_BLOCK_STYLES", 3122 styleNames: Array.isArray(styleNames) ? styleNames : [styleNames], 3123 blockName 3124 }; 3125 } 3126 function addBlockVariations(blockName, variations) { 3127 return { 3128 type: "ADD_BLOCK_VARIATIONS", 3129 variations: Array.isArray(variations) ? variations : [variations], 3130 blockName 3131 }; 3132 } 3133 function removeBlockVariations(blockName, variationNames) { 3134 return { 3135 type: "REMOVE_BLOCK_VARIATIONS", 3136 variationNames: Array.isArray(variationNames) ? variationNames : [variationNames], 3137 blockName 3138 }; 3139 } 3140 function setDefaultBlockName2(name) { 3141 return { 3142 type: "SET_DEFAULT_BLOCK_NAME", 3143 name 3144 }; 3145 } 3146 function setFreeformFallbackBlockName(name) { 3147 return { 3148 type: "SET_FREEFORM_FALLBACK_BLOCK_NAME", 3149 name 3150 }; 3151 } 3152 function setUnregisteredFallbackBlockName(name) { 3153 return { 3154 type: "SET_UNREGISTERED_FALLBACK_BLOCK_NAME", 3155 name 3156 }; 3157 } 3158 function setGroupingBlockName2(name) { 3159 return { 3160 type: "SET_GROUPING_BLOCK_NAME", 3161 name 3162 }; 3163 } 3164 function setCategories(categories2) { 3165 return { 3166 type: "SET_CATEGORIES", 3167 categories: categories2 3168 }; 3169 } 3170 function updateCategory(slug, category) { 3171 return { 3172 type: "UPDATE_CATEGORY", 3173 slug, 3174 category 3175 }; 3176 } 3177 function addBlockCollection(namespace, title, icon) { 3178 return { 3179 type: "ADD_BLOCK_COLLECTION", 3180 namespace, 3181 title, 3182 icon 3183 }; 3184 } 3185 function removeBlockCollection(namespace) { 3186 return { 3187 type: "REMOVE_BLOCK_COLLECTION", 3188 namespace 3189 }; 3190 } 3191 3192 // packages/blocks/build-module/store/private-actions.mjs 3193 var private_actions_exports = {}; 3194 __export(private_actions_exports, { 3195 addBlockBindingsSource: () => addBlockBindingsSource, 3196 addBootstrappedBlockType: () => addBootstrappedBlockType, 3197 addUnprocessedBlockType: () => addUnprocessedBlockType, 3198 removeBlockBindingsSource: () => removeBlockBindingsSource 3199 }); 3200 function addBootstrappedBlockType(name, blockType) { 3201 return { 3202 type: "ADD_BOOTSTRAPPED_BLOCK_TYPE", 3203 name, 3204 blockType 3205 }; 3206 } 3207 function addUnprocessedBlockType(name, blockType) { 3208 return ({ dispatch: dispatch3 }) => { 3209 dispatch3({ type: "ADD_UNPROCESSED_BLOCK_TYPE", name, blockType }); 3210 const processedBlockType = dispatch3( 3211 processBlockType(name, blockType) 3212 ); 3213 if (!processedBlockType) { 3214 return; 3215 } 3216 dispatch3.addBlockTypes(processedBlockType); 3217 }; 3218 } 3219 function addBlockBindingsSource(source) { 3220 return { 3221 type: "ADD_BLOCK_BINDINGS_SOURCE", 3222 name: source.name, 3223 label: source.label, 3224 usesContext: source.usesContext, 3225 getValues: source.getValues, 3226 setValues: source.setValues, 3227 canUserEditValue: source.canUserEditValue, 3228 getFieldsList: source.getFieldsList 3229 }; 3230 } 3231 function removeBlockBindingsSource(name) { 3232 return { 3233 type: "REMOVE_BLOCK_BINDINGS_SOURCE", 3234 name 3235 }; 3236 } 3237 3238 // packages/blocks/build-module/store/constants.mjs 3239 var STORE_NAME = "core/blocks"; 3240 3241 // packages/blocks/build-module/store/index.mjs 3242 var store = (0, import_data5.createReduxStore)(STORE_NAME, { 3243 reducer: reducer_default, 3244 selectors: selectors_exports, 3245 actions: actions_exports 3246 }); 3247 (0, import_data5.register)(store); 3248 unlock(store).registerPrivateSelectors(private_selectors_exports); 3249 unlock(store).registerPrivateActions(private_actions_exports); 3250 3251 // node_modules/uuid/dist/stringify.js 3252 var byteToHex = []; 3253 for (let i = 0; i < 256; ++i) { 3254 byteToHex.push((i + 256).toString(16).slice(1)); 3255 } 3256 function unsafeStringify(arr, offset = 0) { 3257 return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); 3258 } 3259 3260 // node_modules/uuid/dist/rng.js 3261 var rnds8 = new Uint8Array(16); 3262 function rng() { 3263 return crypto.getRandomValues(rnds8); 3264 } 3265 3266 // node_modules/uuid/dist/v4.js 3267 function v4(options, buf, offset) { 3268 if (!buf && !options && crypto.randomUUID) { 3269 return crypto.randomUUID(); 3270 } 3271 return _v4(options, buf, offset); 3272 } 3273 function _v4(options, buf, offset) { 3274 options = options || {}; 3275 const rnds = options.random ?? options.rng?.() ?? rng(); 3276 if (rnds.length < 16) { 3277 throw new Error("Random bytes length must be >= 16"); 3278 } 3279 rnds[6] = rnds[6] & 15 | 64; 3280 rnds[8] = rnds[8] & 63 | 128; 3281 if (buf) { 3282 offset = offset || 0; 3283 if (offset < 0 || offset + 16 > buf.length) { 3284 throw new RangeError(`UUID byte range $offset}:$offset + 15} is out of buffer bounds`); 3285 } 3286 for (let i = 0; i < 16; ++i) { 3287 buf[offset + i] = rnds[i]; 3288 } 3289 return buf; 3290 } 3291 return unsafeStringify(rnds); 3292 } 3293 var v4_default = v4; 3294 3295 // packages/blocks/build-module/api/factory.mjs 3296 var import_hooks2 = __toESM(require_hooks(), 1); 3297 var import_deprecated6 = __toESM(require_deprecated(), 1); 3298 var import_warning3 = __toESM(require_warning(), 1); 3299 var isBlockTypeTransform = (transform) => transform?.type === "block"; 3300 var getBlockTypeWithTransformMetadata = (blockType, transform) => transform.variationName ? { ...blockType, variationName: transform.variationName } : blockType; 3301 function createBlock(name, attributes = {}, innerBlocks = [], innerContent) { 3302 if (!isBlockRegistered(name)) { 3303 return createBlock("core/missing", { 3304 originalName: name, 3305 originalContent: "", 3306 originalUndelimitedContent: "" 3307 }); 3308 } 3309 const sanitizedAttributes = sanitizeBlockAttributes(name, attributes); 3310 const clientId = v4_default(); 3311 const block = { 3312 clientId, 3313 name, 3314 isValid: true, 3315 attributes: sanitizedAttributes, 3316 innerBlocks 3317 }; 3318 if (innerContent) { 3319 if (name === "core/html") { 3320 block.innerContent = innerContent; 3321 } else { 3322 (0, import_warning3.default)( 3323 `The innerContent argument passed to createBlock for the "$name}" block was ignored. Only the Custom HTML block stores static inner content.` 3324 ); 3325 } 3326 } 3327 return block; 3328 } 3329 function createBlocksFromInnerBlocksTemplate(innerBlocksOrTemplate = []) { 3330 return innerBlocksOrTemplate.map((innerBlock) => { 3331 const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [ 3332 innerBlock.name, 3333 innerBlock.attributes, 3334 innerBlock.innerBlocks, 3335 innerBlock.innerContent 3336 ]; 3337 const [name, attributes, innerBlocks = [], innerContent] = innerBlockTemplate; 3338 return createBlock( 3339 name, 3340 attributes, 3341 createBlocksFromInnerBlocksTemplate( 3342 innerBlocks 3343 ), 3344 innerContent 3345 ); 3346 }); 3347 } 3348 function cloneSanitizedBlock(block, mergeAttributes = {}, newInnerBlocks) { 3349 const { name } = block; 3350 if (!isBlockRegistered(name)) { 3351 return createBlock("core/missing", { 3352 originalName: name, 3353 originalContent: "", 3354 originalUndelimitedContent: "" 3355 }); 3356 } 3357 const clientId = v4_default(); 3358 const sanitizedAttributes = sanitizeBlockAttributes(name, { 3359 ...block.attributes, 3360 ...mergeAttributes 3361 }); 3362 return { 3363 ...block, 3364 clientId, 3365 attributes: sanitizedAttributes, 3366 innerBlocks: newInnerBlocks || block.innerBlocks.map( 3367 (innerBlock) => cloneSanitizedBlock(innerBlock) 3368 ) 3369 }; 3370 } 3371 function __experimentalCloneSanitizedBlock(block, mergeAttributes = {}, newInnerBlocks) { 3372 (0, import_deprecated6.default)("__experimentalCloneSanitizedBlock", { 3373 since: "7.1", 3374 alternative: "cloneSanitizedBlock" 3375 }); 3376 return cloneSanitizedBlock(block, mergeAttributes, newInnerBlocks); 3377 } 3378 function cloneBlock(block, mergeAttributes = {}, newInnerBlocks) { 3379 const clientId = v4_default(); 3380 return { 3381 ...block, 3382 clientId, 3383 attributes: { 3384 ...block.attributes, 3385 ...mergeAttributes 3386 }, 3387 innerBlocks: newInnerBlocks || block.innerBlocks.map((innerBlock) => cloneBlock(innerBlock)) 3388 }; 3389 } 3390 var isPossibleTransformForSource = (transform, direction, blocks) => { 3391 if (!blocks.length) { 3392 return false; 3393 } 3394 const isMultiBlock = blocks.length > 1; 3395 const firstBlockName = blocks[0].name; 3396 const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock; 3397 if (!isValidForMultiBlocks) { 3398 return false; 3399 } 3400 if (!isWildcardBlockTransform(transform) && !blocks.every((block) => block.name === firstBlockName)) { 3401 return false; 3402 } 3403 const sourceBlock = blocks[0]; 3404 const hasMatchingName = direction !== "from" || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform); 3405 if (!hasMatchingName) { 3406 return false; 3407 } 3408 if (!isMultiBlock && direction === "from" && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) { 3409 return false; 3410 } 3411 if (!maybeCheckTransformIsMatch(transform, blocks)) { 3412 return false; 3413 } 3414 return true; 3415 }; 3416 var getBlockTypesForPossibleFromTransforms = (blocks) => { 3417 if (!blocks.length) { 3418 return []; 3419 } 3420 const allBlockTypes = getBlockTypes(); 3421 const blockTypesWithPossibleFromTransforms = allBlockTypes.flatMap( 3422 (blockType) => { 3423 const fromTransforms = getBlockTransforms("from", blockType.name); 3424 return fromTransforms.filter(isBlockTypeTransform).filter( 3425 (transform) => isPossibleTransformForSource(transform, "from", blocks) 3426 ).map( 3427 (transform) => getBlockTypeWithTransformMetadata(blockType, transform) 3428 ); 3429 } 3430 ); 3431 return blockTypesWithPossibleFromTransforms; 3432 }; 3433 var getBlockTypesForPossibleToTransforms = (blocks) => { 3434 if (!blocks.length) { 3435 return []; 3436 } 3437 const sourceBlock = blocks[0]; 3438 const blockType = getBlockType(sourceBlock.name); 3439 const transformsTo = blockType ? getBlockTransforms("to", blockType.name) : []; 3440 const possibleTransforms = transformsTo.filter(isBlockTypeTransform).filter( 3441 (transform) => isPossibleTransformForSource(transform, "to", blocks) 3442 ); 3443 return possibleTransforms.flatMap((transformation) => { 3444 return (transformation.blocks ?? []).map((name) => { 3445 const transformedBlockType = getBlockType(name); 3446 return transformedBlockType ? getBlockTypeWithTransformMetadata( 3447 transformedBlockType, 3448 transformation 3449 ) : void 0; 3450 }); 3451 }).filter((bt2) => !!bt2); 3452 }; 3453 var isWildcardBlockTransform = (t2) => isBlockTypeTransform(t2) && Array.isArray(t2.blocks) && t2.blocks.includes("*"); 3454 var isContainerGroupBlock = (name) => name === getGroupingBlockName(); 3455 function getPossibleBlockTransformations(blocks) { 3456 if (!blocks.length) { 3457 return []; 3458 } 3459 const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks); 3460 const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks); 3461 const blockTypesByNameAndVariation = /* @__PURE__ */ new Map(); 3462 for (const blockType of [ 3463 ...blockTypesForFromTransforms, 3464 ...blockTypesForToTransforms 3465 ]) { 3466 const key = blockType.variationName ? `$blockType.name}/$blockType.variationName}` : blockType.name; 3467 if (!blockTypesByNameAndVariation.has(key)) { 3468 blockTypesByNameAndVariation.set(key, blockType); 3469 } 3470 } 3471 return [...blockTypesByNameAndVariation.values()]; 3472 } 3473 function findTransform(transforms, predicate) { 3474 const hooks = (0, import_hooks2.createHooks)(); 3475 for (let i = 0; i < transforms.length; i++) { 3476 const candidate = transforms[i]; 3477 if (predicate(candidate)) { 3478 hooks.addFilter( 3479 "transform", 3480 "transform/" + i.toString(), 3481 (result) => result ? result : candidate, 3482 candidate.priority 3483 ); 3484 } 3485 } 3486 return hooks.applyFilters("transform", null); 3487 } 3488 function getBlockTransforms(direction, blockTypeOrName) { 3489 if (blockTypeOrName === void 0) { 3490 return getBlockTypes().map(({ name }) => getBlockTransforms(direction, name)).flat(); 3491 } 3492 const blockType = normalizeBlockType(blockTypeOrName); 3493 const directionTransforms = blockType?.transforms?.[direction]; 3494 if (!blockType || !Array.isArray(directionTransforms)) { 3495 return []; 3496 } 3497 return directionTransforms.map((transform) => ({ 3498 ...transform, 3499 blockName: blockType.name 3500 })); 3501 } 3502 function maybeCheckTransformIsMatch(transform, blocks) { 3503 if (typeof transform.isMatch !== "function") { 3504 return true; 3505 } 3506 const sourceBlock = blocks[0]; 3507 const attributes = transform.isMultiBlock ? blocks.map((block2) => block2.attributes) : sourceBlock.attributes; 3508 const block = transform.isMultiBlock ? blocks : sourceBlock; 3509 return transform.isMatch(attributes, block); 3510 } 3511 function switchToBlockType(blocks, name, variationName) { 3512 const blocksArray = Array.isArray(blocks) ? blocks : [blocks]; 3513 const isMultiBlock = blocksArray.length > 1; 3514 const firstBlock = blocksArray[0]; 3515 const sourceName = firstBlock.name; 3516 const transformationsFrom = getBlockTransforms("from", name).filter( 3517 isBlockTypeTransform 3518 ); 3519 const transformationsTo = getBlockTransforms("to", sourceName).filter( 3520 isBlockTypeTransform 3521 ); 3522 const isMatchingVariation = (t2) => variationName ? t2.variationName === variationName : !t2.variationName; 3523 const transformation = findTransform( 3524 transformationsTo, 3525 (t2) => isMatchingVariation(t2) && (isWildcardBlockTransform(t2) || t2.blocks.indexOf(name) !== -1) && (!isMultiBlock || !!t2.isMultiBlock) && maybeCheckTransformIsMatch(t2, blocksArray) 3526 ) || findTransform( 3527 transformationsFrom, 3528 (t2) => isMatchingVariation(t2) && (isWildcardBlockTransform(t2) || t2.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || !!t2.isMultiBlock) && maybeCheckTransformIsMatch(t2, blocksArray) 3529 ); 3530 if (!transformation) { 3531 return null; 3532 } 3533 let transformationResults; 3534 if (transformation.isMultiBlock) { 3535 if ("__experimentalConvert" in transformation) { 3536 transformationResults = transformation.__experimentalConvert(blocksArray); 3537 } else { 3538 transformationResults = transformation.transform( 3539 blocksArray.map((currentBlock) => currentBlock.attributes), 3540 blocksArray.map((currentBlock) => currentBlock.innerBlocks) 3541 ); 3542 } 3543 } else if ("__experimentalConvert" in transformation) { 3544 transformationResults = transformation.__experimentalConvert(firstBlock); 3545 } else { 3546 transformationResults = transformation.transform( 3547 firstBlock.attributes, 3548 firstBlock.innerBlocks 3549 ); 3550 } 3551 if (transformationResults === null || typeof transformationResults !== "object") { 3552 return null; 3553 } 3554 transformationResults = Array.isArray(transformationResults) ? transformationResults : [transformationResults]; 3555 if (transformationResults.some( 3556 (result) => !getBlockType(result.name) 3557 )) { 3558 return null; 3559 } 3560 const hasSwitchedBlock = transformationResults.some( 3561 (result) => result.name === name 3562 ); 3563 if (!hasSwitchedBlock) { 3564 return null; 3565 } 3566 const ret = transformationResults.map((result, index, results) => { 3567 return (0, import_hooks2.applyFilters)( 3568 "blocks.switchToBlockType.transformedBlock", 3569 result, 3570 blocks, 3571 index, 3572 results 3573 ); 3574 }); 3575 return ret; 3576 } 3577 var getBlockFromExample = (name, example) => createBlock( 3578 name, 3579 example.attributes, 3580 (example.innerBlocks ?? []).map( 3581 (innerBlock) => getBlockFromExample(innerBlock.name, innerBlock) 3582 ), 3583 example.innerContent 3584 ); 3585 3586 // packages/blocks/build-module/api/parser/index.mjs 3587 var import_block_serialization_default_parser = __toESM(require_block_serialization_default_parser(), 1); 3588 var import_autop2 = __toESM(require_autop(), 1); 3589 3590 // packages/blocks/build-module/api/serializer.mjs 3591 var import_element2 = __toESM(require_element(), 1); 3592 var import_hooks3 = __toESM(require_hooks(), 1); 3593 var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1); 3594 var import_autop = __toESM(require_autop(), 1); 3595 var import_deprecated7 = __toESM(require_deprecated(), 1); 3596 3597 // packages/blocks/build-module/api/parser/serialize-raw-block.mjs 3598 function serializeRawBlock(rawBlock, options = {}) { 3599 const { isCommentDelimited = true } = options; 3600 const { 3601 blockName, 3602 attrs = {}, 3603 innerBlocks = [], 3604 innerContent = [] 3605 } = rawBlock; 3606 let childIndex = 0; 3607 const content = innerContent.map( 3608 (item) => ( 3609 // `null` denotes a nested block, otherwise we have an HTML fragment. 3610 item !== null ? item : serializeRawBlock(innerBlocks[childIndex++], options) 3611 ) 3612 ).join("\n").replace(/\n+/g, "\n").trim(); 3613 return isCommentDelimited ? getCommentDelimitedContent(blockName ?? void 0, attrs, content) : content; 3614 } 3615 3616 // packages/blocks/build-module/api/serializer.mjs 3617 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 3618 function getBlockDefaultClassName(blockName) { 3619 const className = "wp-block-" + blockName.replace(/\//, "-").replace(/^core-/, ""); 3620 return (0, import_hooks3.applyFilters)( 3621 "blocks.getBlockDefaultClassName", 3622 className, 3623 blockName 3624 ); 3625 } 3626 function getBlockMenuDefaultClassName(blockName) { 3627 const className = "editor-block-list-item-" + blockName.replace(/\//, "-").replace(/^core-/, ""); 3628 return (0, import_hooks3.applyFilters)( 3629 "blocks.getBlockMenuDefaultClassName", 3630 className, 3631 blockName 3632 ); 3633 } 3634 var blockPropsProvider = {}; 3635 var innerBlocksPropsProvider = {}; 3636 function getBlockProps(props = {}) { 3637 const { blockType, attributes } = blockPropsProvider; 3638 return getBlockProps.skipFilters ? props : (0, import_hooks3.applyFilters)( 3639 "blocks.getSaveContent.extraProps", 3640 { ...props }, 3641 blockType, 3642 attributes 3643 ); 3644 } 3645 function getInnerBlocksProps(props = {}) { 3646 const { innerBlocks } = innerBlocksPropsProvider; 3647 if (!Array.isArray(innerBlocks)) { 3648 return { ...props, children: innerBlocks }; 3649 } 3650 const html2 = serialize(innerBlocks, { isInnerBlocks: true }); 3651 const children = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_element2.RawHTML, { children: html2 }); 3652 return { ...props, children }; 3653 } 3654 function getSaveElement(blockTypeOrName, attributes, innerBlocks = []) { 3655 const blockType = normalizeBlockType(blockTypeOrName); 3656 if (!blockType?.save) { 3657 return null; 3658 } 3659 let save = blockType.save; 3660 if (save.prototype instanceof import_element2.Component) { 3661 const SaveClass = save; 3662 const instance = new SaveClass({ attributes }); 3663 save = instance.render.bind(instance); 3664 } 3665 blockPropsProvider.blockType = blockType; 3666 blockPropsProvider.attributes = attributes; 3667 innerBlocksPropsProvider.innerBlocks = innerBlocks; 3668 let element = save({ 3669 attributes, 3670 innerBlocks 3671 }); 3672 if (element !== null && typeof element === "object" && (0, import_hooks3.hasFilter)("blocks.getSaveContent.extraProps") && !((blockType.apiVersion ?? 0) > 1)) { 3673 const props = (0, import_hooks3.applyFilters)( 3674 "blocks.getSaveContent.extraProps", 3675 { ...element.props }, 3676 blockType, 3677 attributes 3678 ); 3679 if (!(0, import_is_shallow_equal.isShallowEqual)(props, element.props)) { 3680 element = (0, import_element2.cloneElement)( 3681 element, 3682 props 3683 ); 3684 } 3685 } 3686 return (0, import_hooks3.applyFilters)( 3687 "blocks.getSaveElement", 3688 element, 3689 blockType, 3690 attributes 3691 ); 3692 } 3693 function getSaveContent(blockTypeOrName, attributes, innerBlocks) { 3694 const blockType = normalizeBlockType( 3695 blockTypeOrName 3696 ); 3697 if (!blockType) { 3698 return ""; 3699 } 3700 return (0, import_element2.renderToString)( 3701 getSaveElement(blockType, attributes, innerBlocks) 3702 ); 3703 } 3704 function getCommentAttributes(blockType, attributes) { 3705 return Object.entries(blockType.attributes ?? {}).reduce( 3706 (accumulator, [key, attributeSchema]) => { 3707 const value = attributes[key]; 3708 if (void 0 === value) { 3709 return accumulator; 3710 } 3711 if (attributeSchema.source !== void 0) { 3712 return accumulator; 3713 } 3714 if (attributeSchema.role === "local") { 3715 return accumulator; 3716 } 3717 if (attributeSchema.__experimentalRole === "local") { 3718 (0, import_deprecated7.default)("__experimentalRole attribute", { 3719 since: "6.7", 3720 version: "6.8", 3721 alternative: "role attribute", 3722 hint: `Check the block.json of the $blockType?.name} block.` 3723 }); 3724 return accumulator; 3725 } 3726 if ("default" in attributeSchema && JSON.stringify(attributeSchema.default) === JSON.stringify(value)) { 3727 return accumulator; 3728 } 3729 accumulator[key] = value; 3730 return accumulator; 3731 }, 3732 {} 3733 ); 3734 } 3735 function serializeAttributes(attributes) { 3736 return JSON.stringify(attributes).replaceAll("\\\\", "\\u005c").replaceAll("--", "\\u002d\\u002d").replaceAll("<", "\\u003c").replaceAll(">", "\\u003e").replaceAll("&", "\\u0026").replaceAll('\\"', "\\u0022"); 3737 } 3738 function serializeInnerContent(innerContent, innerBlocks) { 3739 let childIndex = 0; 3740 const parts = innerContent.map((item) => { 3741 if (item !== null) { 3742 return item; 3743 } 3744 const innerBlock = innerBlocks[childIndex++]; 3745 return innerBlock ? serializeBlock(innerBlock, { isInnerBlocks: true }) : ""; 3746 }); 3747 for (; childIndex < innerBlocks.length; childIndex++) { 3748 parts.push( 3749 serializeBlock(innerBlocks[childIndex], { isInnerBlocks: true }) 3750 ); 3751 } 3752 return parts.join("").trim(); 3753 } 3754 function getBlockInnerHTML(block) { 3755 if (block.innerContent && block.name === "core/html") { 3756 return serializeInnerContent(block.innerContent, block.innerBlocks); 3757 } 3758 let saveContent = block.originalContent ?? ""; 3759 if (block.isValid || block.innerBlocks.length) { 3760 try { 3761 saveContent = getSaveContent( 3762 block.name, 3763 block.attributes, 3764 block.innerBlocks 3765 ); 3766 } catch { 3767 } 3768 } 3769 return saveContent; 3770 } 3771 function getCommentDelimitedContent(rawBlockName, attributes, content) { 3772 const serializedAttributes = attributes && Object.entries(attributes).length ? serializeAttributes(attributes) + " " : ""; 3773 const blockName = rawBlockName?.startsWith("core/") ? rawBlockName.slice(5) : rawBlockName; 3774 if (!content) { 3775 return `<!-- wp:$blockName} $serializedAttributes}/-->`; 3776 } 3777 return `<!-- wp:$blockName} $serializedAttributes}--> 3778 ` + content + ` 3779 <!-- /wp:$blockName} -->`; 3780 } 3781 function serializeBlock(block, { isInnerBlocks = false } = {}) { 3782 if (!block.isValid && block.__unstableBlockSource) { 3783 return serializeRawBlock(block.__unstableBlockSource); 3784 } 3785 const blockName = block.name; 3786 const saveContent = getBlockInnerHTML(block); 3787 if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) { 3788 return saveContent; 3789 } 3790 const blockType = getBlockType(blockName); 3791 if (!blockType) { 3792 return saveContent; 3793 } 3794 const saveAttributes = getCommentAttributes(blockType, block.attributes); 3795 return getCommentDelimitedContent(blockName, saveAttributes, saveContent); 3796 } 3797 var __unstableSerializeAndClean = /* @__PURE__ */ (() => { 3798 const cache = /* @__PURE__ */ new WeakMap(); 3799 return (blocks) => { 3800 const cached = cache.get(blocks); 3801 if (cached !== void 0) { 3802 return cached; 3803 } 3804 let effectiveBlocks = blocks; 3805 if (effectiveBlocks.length === 1 && isUnmodifiedDefaultBlock(effectiveBlocks[0])) { 3806 effectiveBlocks = []; 3807 } 3808 let content = serialize(effectiveBlocks); 3809 if (effectiveBlocks.length === 1 && effectiveBlocks[0].name === getFreeformContentHandlerName() && effectiveBlocks[0].name === "core/freeform") { 3810 content = (0, import_autop.removep)(content); 3811 } 3812 cache.set(blocks, content); 3813 return content; 3814 }; 3815 })(); 3816 function serialize(blocks, options) { 3817 const blocksArray = Array.isArray(blocks) ? blocks : [blocks]; 3818 return blocksArray.map((block) => serializeBlock(block, options)).join("\n\n"); 3819 } 3820 3821 // node_modules/simple-html-tokenizer/dist/es6/index.js 3822 var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/; 3823 var CHARCODE = /^#([0-9]+)$/; 3824 var NAMED = /^([A-Za-z0-9]+)$/; 3825 var EntityParser = ( 3826 /** @class */ 3827 (function() { 3828 function EntityParser2(named) { 3829 this.named = named; 3830 } 3831 EntityParser2.prototype.parse = function(entity) { 3832 if (!entity) { 3833 return; 3834 } 3835 var matches = entity.match(HEXCHARCODE); 3836 if (matches) { 3837 return String.fromCharCode(parseInt(matches[1], 16)); 3838 } 3839 matches = entity.match(CHARCODE); 3840 if (matches) { 3841 return String.fromCharCode(parseInt(matches[1], 10)); 3842 } 3843 matches = entity.match(NAMED); 3844 if (matches) { 3845 return this.named[matches[1]]; 3846 } 3847 }; 3848 return EntityParser2; 3849 })() 3850 ); 3851 var WSP = /[\t\n\f ]/; 3852 var ALPHA = /[A-Za-z]/; 3853 var CRLF = /\r\n?/g; 3854 function isSpace(char) { 3855 return WSP.test(char); 3856 } 3857 function isAlpha(char) { 3858 return ALPHA.test(char); 3859 } 3860 function preprocessInput(input) { 3861 return input.replace(CRLF, "\n"); 3862 } 3863 var EventedTokenizer = ( 3864 /** @class */ 3865 (function() { 3866 function EventedTokenizer2(delegate, entityParser) { 3867 this.delegate = delegate; 3868 this.entityParser = entityParser; 3869 this.state = "beforeData"; 3870 this.line = -1; 3871 this.column = -1; 3872 this.input = ""; 3873 this.index = -1; 3874 this.tagNameBuffer = ""; 3875 this.states = { 3876 beforeData: function() { 3877 var char = this.peek(); 3878 if (char === "<") { 3879 this.transitionTo( 3880 "tagOpen" 3881 /* tagOpen */ 3882 ); 3883 this.markTagStart(); 3884 this.consume(); 3885 } else { 3886 if (char === "\n") { 3887 var tag = this.tagNameBuffer.toLowerCase(); 3888 if (tag === "pre" || tag === "textarea") { 3889 this.consume(); 3890 } 3891 } 3892 this.transitionTo( 3893 "data" 3894 /* data */ 3895 ); 3896 this.delegate.beginData(); 3897 } 3898 }, 3899 data: function() { 3900 var char = this.peek(); 3901 if (char === "<") { 3902 this.delegate.finishData(); 3903 this.transitionTo( 3904 "tagOpen" 3905 /* tagOpen */ 3906 ); 3907 this.markTagStart(); 3908 this.consume(); 3909 } else if (char === "&") { 3910 this.consume(); 3911 this.delegate.appendToData(this.consumeCharRef() || "&"); 3912 } else { 3913 this.consume(); 3914 this.delegate.appendToData(char); 3915 } 3916 }, 3917 tagOpen: function() { 3918 var char = this.consume(); 3919 if (char === "!") { 3920 this.transitionTo( 3921 "markupDeclarationOpen" 3922 /* markupDeclarationOpen */ 3923 ); 3924 } else if (char === "/") { 3925 this.transitionTo( 3926 "endTagOpen" 3927 /* endTagOpen */ 3928 ); 3929 } else if (char === "@" || char === ":" || isAlpha(char)) { 3930 this.transitionTo( 3931 "tagName" 3932 /* tagName */ 3933 ); 3934 this.tagNameBuffer = ""; 3935 this.delegate.beginStartTag(); 3936 this.appendToTagName(char); 3937 } 3938 }, 3939 markupDeclarationOpen: function() { 3940 var char = this.consume(); 3941 if (char === "-" && this.input.charAt(this.index) === "-") { 3942 this.consume(); 3943 this.transitionTo( 3944 "commentStart" 3945 /* commentStart */ 3946 ); 3947 this.delegate.beginComment(); 3948 } 3949 }, 3950 commentStart: function() { 3951 var char = this.consume(); 3952 if (char === "-") { 3953 this.transitionTo( 3954 "commentStartDash" 3955 /* commentStartDash */ 3956 ); 3957 } else if (char === ">") { 3958 this.delegate.finishComment(); 3959 this.transitionTo( 3960 "beforeData" 3961 /* beforeData */ 3962 ); 3963 } else { 3964 this.delegate.appendToCommentData(char); 3965 this.transitionTo( 3966 "comment" 3967 /* comment */ 3968 ); 3969 } 3970 }, 3971 commentStartDash: function() { 3972 var char = this.consume(); 3973 if (char === "-") { 3974 this.transitionTo( 3975 "commentEnd" 3976 /* commentEnd */ 3977 ); 3978 } else if (char === ">") { 3979 this.delegate.finishComment(); 3980 this.transitionTo( 3981 "beforeData" 3982 /* beforeData */ 3983 ); 3984 } else { 3985 this.delegate.appendToCommentData("-"); 3986 this.transitionTo( 3987 "comment" 3988 /* comment */ 3989 ); 3990 } 3991 }, 3992 comment: function() { 3993 var char = this.consume(); 3994 if (char === "-") { 3995 this.transitionTo( 3996 "commentEndDash" 3997 /* commentEndDash */ 3998 ); 3999 } else { 4000 this.delegate.appendToCommentData(char); 4001 } 4002 }, 4003 commentEndDash: function() { 4004 var char = this.consume(); 4005 if (char === "-") { 4006 this.transitionTo( 4007 "commentEnd" 4008 /* commentEnd */ 4009 ); 4010 } else { 4011 this.delegate.appendToCommentData("-" + char); 4012 this.transitionTo( 4013 "comment" 4014 /* comment */ 4015 ); 4016 } 4017 }, 4018 commentEnd: function() { 4019 var char = this.consume(); 4020 if (char === ">") { 4021 this.delegate.finishComment(); 4022 this.transitionTo( 4023 "beforeData" 4024 /* beforeData */ 4025 ); 4026 } else { 4027 this.delegate.appendToCommentData("--" + char); 4028 this.transitionTo( 4029 "comment" 4030 /* comment */ 4031 ); 4032 } 4033 }, 4034 tagName: function() { 4035 var char = this.consume(); 4036 if (isSpace(char)) { 4037 this.transitionTo( 4038 "beforeAttributeName" 4039 /* beforeAttributeName */ 4040 ); 4041 } else if (char === "/") { 4042 this.transitionTo( 4043 "selfClosingStartTag" 4044 /* selfClosingStartTag */ 4045 ); 4046 } else if (char === ">") { 4047 this.delegate.finishTag(); 4048 this.transitionTo( 4049 "beforeData" 4050 /* beforeData */ 4051 ); 4052 } else { 4053 this.appendToTagName(char); 4054 } 4055 }, 4056 beforeAttributeName: function() { 4057 var char = this.peek(); 4058 if (isSpace(char)) { 4059 this.consume(); 4060 return; 4061 } else if (char === "/") { 4062 this.transitionTo( 4063 "selfClosingStartTag" 4064 /* selfClosingStartTag */ 4065 ); 4066 this.consume(); 4067 } else if (char === ">") { 4068 this.consume(); 4069 this.delegate.finishTag(); 4070 this.transitionTo( 4071 "beforeData" 4072 /* beforeData */ 4073 ); 4074 } else if (char === "=") { 4075 this.delegate.reportSyntaxError("attribute name cannot start with equals sign"); 4076 this.transitionTo( 4077 "attributeName" 4078 /* attributeName */ 4079 ); 4080 this.delegate.beginAttribute(); 4081 this.consume(); 4082 this.delegate.appendToAttributeName(char); 4083 } else { 4084 this.transitionTo( 4085 "attributeName" 4086 /* attributeName */ 4087 ); 4088 this.delegate.beginAttribute(); 4089 } 4090 }, 4091 attributeName: function() { 4092 var char = this.peek(); 4093 if (isSpace(char)) { 4094 this.transitionTo( 4095 "afterAttributeName" 4096 /* afterAttributeName */ 4097 ); 4098 this.consume(); 4099 } else if (char === "/") { 4100 this.delegate.beginAttributeValue(false); 4101 this.delegate.finishAttributeValue(); 4102 this.consume(); 4103 this.transitionTo( 4104 "selfClosingStartTag" 4105 /* selfClosingStartTag */ 4106 ); 4107 } else if (char === "=") { 4108 this.transitionTo( 4109 "beforeAttributeValue" 4110 /* beforeAttributeValue */ 4111 ); 4112 this.consume(); 4113 } else if (char === ">") { 4114 this.delegate.beginAttributeValue(false); 4115 this.delegate.finishAttributeValue(); 4116 this.consume(); 4117 this.delegate.finishTag(); 4118 this.transitionTo( 4119 "beforeData" 4120 /* beforeData */ 4121 ); 4122 } else if (char === '"' || char === "'" || char === "<") { 4123 this.delegate.reportSyntaxError(char + " is not a valid character within attribute names"); 4124 this.consume(); 4125 this.delegate.appendToAttributeName(char); 4126 } else { 4127 this.consume(); 4128 this.delegate.appendToAttributeName(char); 4129 } 4130 }, 4131 afterAttributeName: function() { 4132 var char = this.peek(); 4133 if (isSpace(char)) { 4134 this.consume(); 4135 return; 4136 } else if (char === "/") { 4137 this.delegate.beginAttributeValue(false); 4138 this.delegate.finishAttributeValue(); 4139 this.consume(); 4140 this.transitionTo( 4141 "selfClosingStartTag" 4142 /* selfClosingStartTag */ 4143 ); 4144 } else if (char === "=") { 4145 this.consume(); 4146 this.transitionTo( 4147 "beforeAttributeValue" 4148 /* beforeAttributeValue */ 4149 ); 4150 } else if (char === ">") { 4151 this.delegate.beginAttributeValue(false); 4152 this.delegate.finishAttributeValue(); 4153 this.consume(); 4154 this.delegate.finishTag(); 4155 this.transitionTo( 4156 "beforeData" 4157 /* beforeData */ 4158 ); 4159 } else { 4160 this.delegate.beginAttributeValue(false); 4161 this.delegate.finishAttributeValue(); 4162 this.transitionTo( 4163 "attributeName" 4164 /* attributeName */ 4165 ); 4166 this.delegate.beginAttribute(); 4167 this.consume(); 4168 this.delegate.appendToAttributeName(char); 4169 } 4170 }, 4171 beforeAttributeValue: function() { 4172 var char = this.peek(); 4173 if (isSpace(char)) { 4174 this.consume(); 4175 } else if (char === '"') { 4176 this.transitionTo( 4177 "attributeValueDoubleQuoted" 4178 /* attributeValueDoubleQuoted */ 4179 ); 4180 this.delegate.beginAttributeValue(true); 4181 this.consume(); 4182 } else if (char === "'") { 4183 this.transitionTo( 4184 "attributeValueSingleQuoted" 4185 /* attributeValueSingleQuoted */ 4186 ); 4187 this.delegate.beginAttributeValue(true); 4188 this.consume(); 4189 } else if (char === ">") { 4190 this.delegate.beginAttributeValue(false); 4191 this.delegate.finishAttributeValue(); 4192 this.consume(); 4193 this.delegate.finishTag(); 4194 this.transitionTo( 4195 "beforeData" 4196 /* beforeData */ 4197 ); 4198 } else { 4199 this.transitionTo( 4200 "attributeValueUnquoted" 4201 /* attributeValueUnquoted */ 4202 ); 4203 this.delegate.beginAttributeValue(false); 4204 this.consume(); 4205 this.delegate.appendToAttributeValue(char); 4206 } 4207 }, 4208 attributeValueDoubleQuoted: function() { 4209 var char = this.consume(); 4210 if (char === '"') { 4211 this.delegate.finishAttributeValue(); 4212 this.transitionTo( 4213 "afterAttributeValueQuoted" 4214 /* afterAttributeValueQuoted */ 4215 ); 4216 } else if (char === "&") { 4217 this.delegate.appendToAttributeValue(this.consumeCharRef() || "&"); 4218 } else { 4219 this.delegate.appendToAttributeValue(char); 4220 } 4221 }, 4222 attributeValueSingleQuoted: function() { 4223 var char = this.consume(); 4224 if (char === "'") { 4225 this.delegate.finishAttributeValue(); 4226 this.transitionTo( 4227 "afterAttributeValueQuoted" 4228 /* afterAttributeValueQuoted */ 4229 ); 4230 } else if (char === "&") { 4231 this.delegate.appendToAttributeValue(this.consumeCharRef() || "&"); 4232 } else { 4233 this.delegate.appendToAttributeValue(char); 4234 } 4235 }, 4236 attributeValueUnquoted: function() { 4237 var char = this.peek(); 4238 if (isSpace(char)) { 4239 this.delegate.finishAttributeValue(); 4240 this.consume(); 4241 this.transitionTo( 4242 "beforeAttributeName" 4243 /* beforeAttributeName */ 4244 ); 4245 } else if (char === "/") { 4246 this.delegate.finishAttributeValue(); 4247 this.consume(); 4248 this.transitionTo( 4249 "selfClosingStartTag" 4250 /* selfClosingStartTag */ 4251 ); 4252 } else if (char === "&") { 4253 this.consume(); 4254 this.delegate.appendToAttributeValue(this.consumeCharRef() || "&"); 4255 } else if (char === ">") { 4256 this.delegate.finishAttributeValue(); 4257 this.consume(); 4258 this.delegate.finishTag(); 4259 this.transitionTo( 4260 "beforeData" 4261 /* beforeData */ 4262 ); 4263 } else { 4264 this.consume(); 4265 this.delegate.appendToAttributeValue(char); 4266 } 4267 }, 4268 afterAttributeValueQuoted: function() { 4269 var char = this.peek(); 4270 if (isSpace(char)) { 4271 this.consume(); 4272 this.transitionTo( 4273 "beforeAttributeName" 4274 /* beforeAttributeName */ 4275 ); 4276 } else if (char === "/") { 4277 this.consume(); 4278 this.transitionTo( 4279 "selfClosingStartTag" 4280 /* selfClosingStartTag */ 4281 ); 4282 } else if (char === ">") { 4283 this.consume(); 4284 this.delegate.finishTag(); 4285 this.transitionTo( 4286 "beforeData" 4287 /* beforeData */ 4288 ); 4289 } else { 4290 this.transitionTo( 4291 "beforeAttributeName" 4292 /* beforeAttributeName */ 4293 ); 4294 } 4295 }, 4296 selfClosingStartTag: function() { 4297 var char = this.peek(); 4298 if (char === ">") { 4299 this.consume(); 4300 this.delegate.markTagAsSelfClosing(); 4301 this.delegate.finishTag(); 4302 this.transitionTo( 4303 "beforeData" 4304 /* beforeData */ 4305 ); 4306 } else { 4307 this.transitionTo( 4308 "beforeAttributeName" 4309 /* beforeAttributeName */ 4310 ); 4311 } 4312 }, 4313 endTagOpen: function() { 4314 var char = this.consume(); 4315 if (char === "@" || char === ":" || isAlpha(char)) { 4316 this.transitionTo( 4317 "tagName" 4318 /* tagName */ 4319 ); 4320 this.tagNameBuffer = ""; 4321 this.delegate.beginEndTag(); 4322 this.appendToTagName(char); 4323 } 4324 } 4325 }; 4326 this.reset(); 4327 } 4328 EventedTokenizer2.prototype.reset = function() { 4329 this.transitionTo( 4330 "beforeData" 4331 /* beforeData */ 4332 ); 4333 this.input = ""; 4334 this.index = 0; 4335 this.line = 1; 4336 this.column = 0; 4337 this.delegate.reset(); 4338 }; 4339 EventedTokenizer2.prototype.transitionTo = function(state) { 4340 this.state = state; 4341 }; 4342 EventedTokenizer2.prototype.tokenize = function(input) { 4343 this.reset(); 4344 this.tokenizePart(input); 4345 this.tokenizeEOF(); 4346 }; 4347 EventedTokenizer2.prototype.tokenizePart = function(input) { 4348 this.input += preprocessInput(input); 4349 while (this.index < this.input.length) { 4350 var handler = this.states[this.state]; 4351 if (handler !== void 0) { 4352 handler.call(this); 4353 } else { 4354 throw new Error("unhandled state " + this.state); 4355 } 4356 } 4357 }; 4358 EventedTokenizer2.prototype.tokenizeEOF = function() { 4359 this.flushData(); 4360 }; 4361 EventedTokenizer2.prototype.flushData = function() { 4362 if (this.state === "data") { 4363 this.delegate.finishData(); 4364 this.transitionTo( 4365 "beforeData" 4366 /* beforeData */ 4367 ); 4368 } 4369 }; 4370 EventedTokenizer2.prototype.peek = function() { 4371 return this.input.charAt(this.index); 4372 }; 4373 EventedTokenizer2.prototype.consume = function() { 4374 var char = this.peek(); 4375 this.index++; 4376 if (char === "\n") { 4377 this.line++; 4378 this.column = 0; 4379 } else { 4380 this.column++; 4381 } 4382 return char; 4383 }; 4384 EventedTokenizer2.prototype.consumeCharRef = function() { 4385 var endIndex = this.input.indexOf(";", this.index); 4386 if (endIndex === -1) { 4387 return; 4388 } 4389 var entity = this.input.slice(this.index, endIndex); 4390 var chars = this.entityParser.parse(entity); 4391 if (chars) { 4392 var count = entity.length; 4393 while (count) { 4394 this.consume(); 4395 count--; 4396 } 4397 this.consume(); 4398 return chars; 4399 } 4400 }; 4401 EventedTokenizer2.prototype.markTagStart = function() { 4402 this.delegate.tagOpen(); 4403 }; 4404 EventedTokenizer2.prototype.appendToTagName = function(char) { 4405 this.tagNameBuffer += char; 4406 this.delegate.appendToTagName(char); 4407 }; 4408 return EventedTokenizer2; 4409 })() 4410 ); 4411 var Tokenizer = ( 4412 /** @class */ 4413 (function() { 4414 function Tokenizer2(entityParser, options) { 4415 if (options === void 0) { 4416 options = {}; 4417 } 4418 this.options = options; 4419 this.token = null; 4420 this.startLine = 1; 4421 this.startColumn = 0; 4422 this.tokens = []; 4423 this.tokenizer = new EventedTokenizer(this, entityParser); 4424 this._currentAttribute = void 0; 4425 } 4426 Tokenizer2.prototype.tokenize = function(input) { 4427 this.tokens = []; 4428 this.tokenizer.tokenize(input); 4429 return this.tokens; 4430 }; 4431 Tokenizer2.prototype.tokenizePart = function(input) { 4432 this.tokens = []; 4433 this.tokenizer.tokenizePart(input); 4434 return this.tokens; 4435 }; 4436 Tokenizer2.prototype.tokenizeEOF = function() { 4437 this.tokens = []; 4438 this.tokenizer.tokenizeEOF(); 4439 return this.tokens[0]; 4440 }; 4441 Tokenizer2.prototype.reset = function() { 4442 this.token = null; 4443 this.startLine = 1; 4444 this.startColumn = 0; 4445 }; 4446 Tokenizer2.prototype.current = function() { 4447 var token = this.token; 4448 if (token === null) { 4449 throw new Error("token was unexpectedly null"); 4450 } 4451 if (arguments.length === 0) { 4452 return token; 4453 } 4454 for (var i = 0; i < arguments.length; i++) { 4455 if (token.type === arguments[i]) { 4456 return token; 4457 } 4458 } 4459 throw new Error("token type was unexpectedly " + token.type); 4460 }; 4461 Tokenizer2.prototype.push = function(token) { 4462 this.token = token; 4463 this.tokens.push(token); 4464 }; 4465 Tokenizer2.prototype.currentAttribute = function() { 4466 return this._currentAttribute; 4467 }; 4468 Tokenizer2.prototype.addLocInfo = function() { 4469 if (this.options.loc) { 4470 this.current().loc = { 4471 start: { 4472 line: this.startLine, 4473 column: this.startColumn 4474 }, 4475 end: { 4476 line: this.tokenizer.line, 4477 column: this.tokenizer.column 4478 } 4479 }; 4480 } 4481 this.startLine = this.tokenizer.line; 4482 this.startColumn = this.tokenizer.column; 4483 }; 4484 Tokenizer2.prototype.beginData = function() { 4485 this.push({ 4486 type: "Chars", 4487 chars: "" 4488 }); 4489 }; 4490 Tokenizer2.prototype.appendToData = function(char) { 4491 this.current( 4492 "Chars" 4493 /* Chars */ 4494 ).chars += char; 4495 }; 4496 Tokenizer2.prototype.finishData = function() { 4497 this.addLocInfo(); 4498 }; 4499 Tokenizer2.prototype.beginComment = function() { 4500 this.push({ 4501 type: "Comment", 4502 chars: "" 4503 }); 4504 }; 4505 Tokenizer2.prototype.appendToCommentData = function(char) { 4506 this.current( 4507 "Comment" 4508 /* Comment */ 4509 ).chars += char; 4510 }; 4511 Tokenizer2.prototype.finishComment = function() { 4512 this.addLocInfo(); 4513 }; 4514 Tokenizer2.prototype.tagOpen = function() { 4515 }; 4516 Tokenizer2.prototype.beginStartTag = function() { 4517 this.push({ 4518 type: "StartTag", 4519 tagName: "", 4520 attributes: [], 4521 selfClosing: false 4522 }); 4523 }; 4524 Tokenizer2.prototype.beginEndTag = function() { 4525 this.push({ 4526 type: "EndTag", 4527 tagName: "" 4528 }); 4529 }; 4530 Tokenizer2.prototype.finishTag = function() { 4531 this.addLocInfo(); 4532 }; 4533 Tokenizer2.prototype.markTagAsSelfClosing = function() { 4534 this.current( 4535 "StartTag" 4536 /* StartTag */ 4537 ).selfClosing = true; 4538 }; 4539 Tokenizer2.prototype.appendToTagName = function(char) { 4540 this.current( 4541 "StartTag", 4542 "EndTag" 4543 /* EndTag */ 4544 ).tagName += char; 4545 }; 4546 Tokenizer2.prototype.beginAttribute = function() { 4547 this._currentAttribute = ["", "", false]; 4548 }; 4549 Tokenizer2.prototype.appendToAttributeName = function(char) { 4550 this.currentAttribute()[0] += char; 4551 }; 4552 Tokenizer2.prototype.beginAttributeValue = function(isQuoted) { 4553 this.currentAttribute()[2] = isQuoted; 4554 }; 4555 Tokenizer2.prototype.appendToAttributeValue = function(char) { 4556 this.currentAttribute()[1] += char; 4557 }; 4558 Tokenizer2.prototype.finishAttributeValue = function() { 4559 this.current( 4560 "StartTag" 4561 /* StartTag */ 4562 ).attributes.push(this._currentAttribute); 4563 }; 4564 Tokenizer2.prototype.reportSyntaxError = function(message) { 4565 this.current().syntaxError = message; 4566 }; 4567 return Tokenizer2; 4568 })() 4569 ); 4570 4571 // packages/blocks/build-module/api/validation/index.mjs 4572 var import_es62 = __toESM(require_es6(), 1); 4573 var import_deprecated8 = __toESM(require_deprecated(), 1); 4574 var import_html_entities = __toESM(require_html_entities(), 1); 4575 4576 // packages/blocks/build-module/api/validation/logger.mjs 4577 function createLogger() { 4578 function createLogHandler(logger) { 4579 return (message, ...args) => logger("Block validation: " + message, ...args); 4580 } 4581 return { 4582 // eslint-disable-next-line no-console 4583 error: createLogHandler(console.error), 4584 // eslint-disable-next-line no-console 4585 warning: createLogHandler(console.warn), 4586 getItems() { 4587 return []; 4588 } 4589 }; 4590 } 4591 function createQueuedLogger() { 4592 const queue = []; 4593 const logger = createLogger(); 4594 return { 4595 error(...args) { 4596 queue.push({ log: logger.error, args }); 4597 }, 4598 warning(...args) { 4599 queue.push({ log: logger.warning, args }); 4600 }, 4601 getItems() { 4602 return queue; 4603 } 4604 }; 4605 } 4606 4607 // packages/blocks/build-module/api/validation/index.mjs 4608 var identity = (x3) => x3; 4609 var REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g; 4610 var REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/; 4611 var REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/; 4612 var BOOLEAN_ATTRIBUTES = [ 4613 "allowfullscreen", 4614 "allowpaymentrequest", 4615 "allowusermedia", 4616 "async", 4617 "autofocus", 4618 "autoplay", 4619 "checked", 4620 "controls", 4621 "default", 4622 "defer", 4623 "disabled", 4624 "download", 4625 "formnovalidate", 4626 "hidden", 4627 "ismap", 4628 "itemscope", 4629 "loop", 4630 "multiple", 4631 "muted", 4632 "nomodule", 4633 "novalidate", 4634 "open", 4635 "playsinline", 4636 "readonly", 4637 "required", 4638 "reversed", 4639 "selected", 4640 "typemustmatch" 4641 ]; 4642 var ENUMERATED_ATTRIBUTES = [ 4643 "autocapitalize", 4644 "autocomplete", 4645 "charset", 4646 "contenteditable", 4647 "crossorigin", 4648 "decoding", 4649 "dir", 4650 "draggable", 4651 "enctype", 4652 "formenctype", 4653 "formmethod", 4654 "http-equiv", 4655 "inputmode", 4656 "kind", 4657 "method", 4658 "preload", 4659 "scope", 4660 "shape", 4661 "spellcheck", 4662 "translate", 4663 "type", 4664 "wrap" 4665 ]; 4666 var MEANINGFUL_ATTRIBUTES = [ 4667 ...BOOLEAN_ATTRIBUTES, 4668 ...ENUMERATED_ATTRIBUTES 4669 ]; 4670 var TEXT_NORMALIZATIONS = [ 4671 identity, 4672 getTextWithCollapsedWhitespace 4673 ]; 4674 var REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i; 4675 var REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/; 4676 var REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i; 4677 function isValidCharacterReference(text2) { 4678 return REGEXP_NAMED_CHARACTER_REFERENCE.test(text2) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text2) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text2); 4679 } 4680 var DecodeEntityParser = class { 4681 /** 4682 * Returns a substitute string for an entity string sequence between `&` 4683 * and `;`, or undefined if no substitution should occur. 4684 * 4685 * @param entity Entity fragment discovered in HTML. 4686 * 4687 * @return Entity substitute value. 4688 */ 4689 parse(entity) { 4690 if (isValidCharacterReference(entity)) { 4691 return (0, import_html_entities.decodeEntities)("&" + entity + ";"); 4692 } 4693 return void 0; 4694 } 4695 }; 4696 function getTextPiecesSplitOnWhitespace(text2) { 4697 return text2.trim().split(REGEXP_WHITESPACE); 4698 } 4699 function getTextWithCollapsedWhitespace(text2) { 4700 return getTextPiecesSplitOnWhitespace(text2).join(" "); 4701 } 4702 function getMeaningfulAttributePairs(token) { 4703 return (token.attributes ?? []).filter((pair) => { 4704 const [key, value] = pair; 4705 return value || key.indexOf("data-") === 0 || MEANINGFUL_ATTRIBUTES.includes(key); 4706 }); 4707 } 4708 function isEquivalentTextTokens(actual, expected, logger = createLogger()) { 4709 let actualChars = actual.chars; 4710 let expectedChars = expected.chars; 4711 for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) { 4712 const normalize = TEXT_NORMALIZATIONS[i]; 4713 actualChars = normalize(actualChars); 4714 expectedChars = normalize(expectedChars); 4715 if (actualChars === expectedChars) { 4716 return true; 4717 } 4718 } 4719 logger.warning( 4720 "Expected text `%s`, saw `%s`.", 4721 expected.chars, 4722 actual.chars 4723 ); 4724 return false; 4725 } 4726 function getNormalizedLength(value) { 4727 if (0 === parseFloat(value)) { 4728 return "0"; 4729 } 4730 if (value.indexOf(".") === 0) { 4731 return "0" + value; 4732 } 4733 return value; 4734 } 4735 function getNormalizedStyleValue(value) { 4736 const textPieces = getTextPiecesSplitOnWhitespace(value); 4737 const normalizedPieces = textPieces.map(getNormalizedLength); 4738 const result = normalizedPieces.join(" "); 4739 return result.replace(REGEXP_STYLE_URL_TYPE, "url($1)"); 4740 } 4741 function getStyleProperties(text2) { 4742 const pairs = text2.replace(/;?\s*$/, "").split(";").map((style) => { 4743 const [key, ...valueParts] = style.split(":"); 4744 const value = valueParts.join(":"); 4745 return [key.trim(), getNormalizedStyleValue(value.trim())]; 4746 }); 4747 return Object.fromEntries(pairs); 4748 } 4749 var isEqualAttributesOfName = { 4750 class: (actual, expected) => { 4751 const [actualPieces, expectedPieces] = [actual, expected].map( 4752 getTextPiecesSplitOnWhitespace 4753 ); 4754 const actualDiff = actualPieces.filter( 4755 (c2) => !expectedPieces.includes(c2) 4756 ); 4757 const expectedDiff = expectedPieces.filter( 4758 (c2) => !actualPieces.includes(c2) 4759 ); 4760 return actualDiff.length === 0 && expectedDiff.length === 0; 4761 }, 4762 style: (actual, expected) => { 4763 return (0, import_es62.default)( 4764 ...[actual, expected].map(getStyleProperties) 4765 ); 4766 }, 4767 // For each boolean attribute, mere presence of attribute in both is enough 4768 // to assume equivalence. 4769 ...Object.fromEntries( 4770 BOOLEAN_ATTRIBUTES.map((attribute) => [attribute, () => true]) 4771 ) 4772 }; 4773 function isEqualTagAttributePairs(actual, expected, logger = createLogger()) { 4774 if (actual.length !== expected.length) { 4775 logger.warning( 4776 "Expected attributes %o, instead saw %o.", 4777 expected, 4778 actual 4779 ); 4780 return false; 4781 } 4782 const expectedAttributes = {}; 4783 for (let i = 0; i < expected.length; i++) { 4784 expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1]; 4785 } 4786 for (let i = 0; i < actual.length; i++) { 4787 const [name, actualValue] = actual[i]; 4788 const nameLower = name.toLowerCase(); 4789 if (!expectedAttributes.hasOwnProperty(nameLower)) { 4790 logger.warning("Encountered unexpected attribute `%s`.", name); 4791 return false; 4792 } 4793 const expectedValue = expectedAttributes[nameLower]; 4794 const isEqualAttributes = isEqualAttributesOfName[nameLower]; 4795 if (isEqualAttributes) { 4796 if (!isEqualAttributes(actualValue, expectedValue)) { 4797 logger.warning( 4798 "Expected attribute `%s` of value `%s`, saw `%s`.", 4799 name, 4800 expectedValue, 4801 actualValue 4802 ); 4803 return false; 4804 } 4805 } else if (actualValue !== expectedValue) { 4806 logger.warning( 4807 "Expected attribute `%s` of value `%s`, saw `%s`.", 4808 name, 4809 expectedValue, 4810 actualValue 4811 ); 4812 return false; 4813 } 4814 } 4815 return true; 4816 } 4817 var isEqualTokensOfType = { 4818 StartTag: (actual, expected, logger = createLogger()) => { 4819 if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case- 4820 // insensitive check on the assumption that the majority case will 4821 // have exactly equal tag names. 4822 actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) { 4823 logger.warning( 4824 "Expected tag name `%s`, instead saw `%s`.", 4825 expected.tagName, 4826 actual.tagName 4827 ); 4828 return false; 4829 } 4830 return isEqualTagAttributePairs( 4831 ...[actual, expected].map(getMeaningfulAttributePairs), 4832 logger 4833 ); 4834 }, 4835 Chars: isEquivalentTextTokens, 4836 Comment: isEquivalentTextTokens 4837 }; 4838 function getNextNonWhitespaceToken(tokens) { 4839 let token; 4840 while (token = tokens.shift()) { 4841 if (token.type !== "Chars") { 4842 return token; 4843 } 4844 if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) { 4845 return token; 4846 } 4847 } 4848 return void 0; 4849 } 4850 function getHTMLTokens(html2, logger = createLogger()) { 4851 try { 4852 return new Tokenizer(new DecodeEntityParser()).tokenize( 4853 html2 4854 ); 4855 } catch { 4856 logger.warning("Malformed HTML detected: %s", html2); 4857 } 4858 return null; 4859 } 4860 function isClosedByToken(currentToken, nextToken) { 4861 if (!currentToken.selfClosing) { 4862 return false; 4863 } 4864 if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === "EndTag") { 4865 return true; 4866 } 4867 return false; 4868 } 4869 function isEquivalentHTML(actual, expected, logger = createLogger()) { 4870 if (actual === expected) { 4871 return true; 4872 } 4873 const [actualTokens, expectedTokens] = [actual, expected].map( 4874 (html2) => getHTMLTokens(html2, logger) 4875 ); 4876 if (!actualTokens || !expectedTokens) { 4877 return false; 4878 } 4879 let actualToken, expectedToken; 4880 while (actualToken = getNextNonWhitespaceToken(actualTokens)) { 4881 expectedToken = getNextNonWhitespaceToken(expectedTokens); 4882 if (!expectedToken) { 4883 logger.warning( 4884 "Expected end of content, instead saw %o.", 4885 actualToken 4886 ); 4887 return false; 4888 } 4889 if (actualToken.type !== expectedToken.type) { 4890 logger.warning( 4891 "Expected token of type `%s` (%o), instead saw `%s` (%o).", 4892 expectedToken.type, 4893 expectedToken, 4894 actualToken.type, 4895 actualToken 4896 ); 4897 return false; 4898 } 4899 const isEqualTokens = isEqualTokensOfType[actualToken.type]; 4900 if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) { 4901 return false; 4902 } 4903 if (isClosedByToken(actualToken, expectedTokens[0])) { 4904 getNextNonWhitespaceToken(expectedTokens); 4905 } else if (isClosedByToken(expectedToken, actualTokens[0])) { 4906 getNextNonWhitespaceToken(actualTokens); 4907 } 4908 } 4909 if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) { 4910 logger.warning( 4911 "Expected %o, instead saw end of content.", 4912 expectedToken 4913 ); 4914 return false; 4915 } 4916 return true; 4917 } 4918 function validateBlock(block, blockTypeOrName = block.name) { 4919 const isFallbackBlock = block.name === getFreeformContentHandlerName() || block.name === getUnregisteredTypeHandlerName(); 4920 if (isFallbackBlock) { 4921 return [true, []]; 4922 } 4923 const logger = createQueuedLogger(); 4924 const blockType = normalizeBlockType(blockTypeOrName); 4925 let generatedBlockContent; 4926 try { 4927 generatedBlockContent = getSaveContent(blockType, block.attributes); 4928 } catch (error) { 4929 logger.error( 4930 "Block validation failed because an error occurred while generating block content:\n\n%s", 4931 error.toString() 4932 ); 4933 return [false, logger.getItems()]; 4934 } 4935 const isValid = isEquivalentHTML( 4936 block.originalContent, 4937 generatedBlockContent, 4938 logger 4939 ); 4940 if (!isValid) { 4941 logger.error( 4942 "Block validation failed for `%s` (%o).\n\nContent generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s", 4943 blockType.name, 4944 blockType, 4945 generatedBlockContent, 4946 block.originalContent 4947 ); 4948 } 4949 return [isValid, logger.getItems()]; 4950 } 4951 function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) { 4952 (0, import_deprecated8.default)("isValidBlockContent introduces opportunity for data loss", { 4953 since: "12.6", 4954 plugin: "Gutenberg", 4955 alternative: "validateBlock" 4956 }); 4957 const blockType = normalizeBlockType(blockTypeOrName); 4958 const block = { 4959 clientId: "", 4960 name: blockType.name, 4961 isValid: true, 4962 attributes, 4963 innerBlocks: [], 4964 originalContent: originalBlockContent 4965 }; 4966 const [isValid] = validateBlock(block, blockType); 4967 return isValid; 4968 } 4969 4970 // packages/blocks/build-module/api/parser/convert-legacy-block.mjs 4971 function normalizeStyleStateAliases(style) { 4972 if (true) { 4973 return style; 4974 } 4975 if (!style || typeof style !== "object" || Array.isArray(style)) { 4976 return style; 4977 } 4978 let normalizedStyle = style; 4979 const viewportAliases = { 4980 "@mobile": "mobile", 4981 "@tablet": "tablet" 4982 }; 4983 Object.entries(viewportAliases).forEach(([state, legacyState]) => { 4984 if (!Object.hasOwn(normalizedStyle, legacyState)) { 4985 return; 4986 } 4987 if (normalizedStyle === style) { 4988 normalizedStyle = { ...normalizedStyle }; 4989 } 4990 if (!Object.hasOwn(normalizedStyle, state)) { 4991 normalizedStyle[state] = normalizedStyle[legacyState]; 4992 } 4993 delete normalizedStyle[legacyState]; 4994 }); 4995 return normalizedStyle; 4996 } 4997 function convertLegacyBlockNameAndAttributes(name, attributes) { 4998 const newAttributes = { ...attributes }; 4999 if ("core/cover-image" === name) { 5000 name = "core/cover"; 5001 } 5002 if ("core/text" === name || "core/cover-text" === name) { 5003 name = "core/paragraph"; 5004 } 5005 if (name && name.indexOf("core/social-link-") === 0) { 5006 newAttributes.service = name.substring(17); 5007 name = "core/social-link"; 5008 } 5009 if (name && name.indexOf("core-embed/") === 0) { 5010 const providerSlug = name.substring(11); 5011 const deprecated13 = { 5012 speaker: "speaker-deck", 5013 polldaddy: "crowdsignal" 5014 }; 5015 newAttributes.providerNameSlug = providerSlug in deprecated13 ? deprecated13[providerSlug] : providerSlug; 5016 if (!["amazon-kindle", "wordpress"].includes(providerSlug)) { 5017 newAttributes.responsive = true; 5018 } 5019 name = "core/embed"; 5020 } 5021 if (name === "core/post-comment-author") { 5022 name = "core/comment-author-name"; 5023 } 5024 if (name === "core/post-comment-content") { 5025 name = "core/comment-content"; 5026 } 5027 if (name === "core/post-comment-date") { 5028 name = "core/comment-date"; 5029 } 5030 if (name === "core/comments-query-loop") { 5031 name = "core/comments"; 5032 const className = newAttributes.className ?? ""; 5033 if (!className.includes("wp-block-comments-query-loop")) { 5034 newAttributes.className = [ 5035 "wp-block-comments-query-loop", 5036 className 5037 ].join(" "); 5038 } 5039 } 5040 if (name === "core/post-comments") { 5041 name = "core/comments"; 5042 newAttributes.legacy = true; 5043 } 5044 const layout = attributes.layout; 5045 if (layout?.type === "grid" && typeof layout?.columnCount === "string") { 5046 newAttributes.layout = { 5047 ...newAttributes.layout, 5048 columnCount: parseInt(layout.columnCount, 10) 5049 }; 5050 } 5051 const style = attributes.style; 5052 const styleLayout = style?.layout; 5053 if (typeof styleLayout?.columnSpan === "string") { 5054 const columnSpanNumber = parseInt(styleLayout.columnSpan, 10); 5055 newAttributes.style = { 5056 ...newAttributes.style, 5057 layout: { 5058 ...newAttributes.style?.layout, 5059 columnSpan: isNaN(columnSpanNumber) ? void 0 : columnSpanNumber 5060 } 5061 }; 5062 } 5063 if (typeof styleLayout?.rowSpan === "string") { 5064 const rowSpanNumber = parseInt(styleLayout.rowSpan, 10); 5065 newAttributes.style = { 5066 ...newAttributes.style, 5067 layout: { 5068 ...newAttributes.style?.layout, 5069 rowSpan: isNaN(rowSpanNumber) ? void 0 : rowSpanNumber 5070 } 5071 }; 5072 } 5073 const normalizedStyle = normalizeStyleStateAliases(newAttributes.style); 5074 if (normalizedStyle !== newAttributes.style) { 5075 newAttributes.style = normalizedStyle; 5076 } 5077 return [name, newAttributes]; 5078 } 5079 5080 // node_modules/hpq/es/get-path.js 5081 function getPath(object, path) { 5082 var segments = path.split("."); 5083 var segment; 5084 while (segment = segments.shift()) { 5085 if (!(segment in object)) { 5086 return; 5087 } 5088 object = object[segment]; 5089 } 5090 return object; 5091 } 5092 5093 // node_modules/hpq/es/index.js 5094 var getDocument = /* @__PURE__ */ (function() { 5095 var doc; 5096 return function() { 5097 if (!doc) { 5098 doc = document.implementation.createHTMLDocument(""); 5099 } 5100 return doc; 5101 }; 5102 })(); 5103 function parse(source, matchers) { 5104 if (!matchers) { 5105 return; 5106 } 5107 if ("string" === typeof source) { 5108 var doc = getDocument(); 5109 doc.body.innerHTML = source; 5110 source = doc.body; 5111 } 5112 if (typeof matchers === "function") { 5113 return matchers(source); 5114 } 5115 if (Object !== matchers.constructor) { 5116 return; 5117 } 5118 return Object.keys(matchers).reduce(function(memo, key) { 5119 var inner = matchers[key]; 5120 memo[key] = parse(source, inner); 5121 return memo; 5122 }, {}); 5123 } 5124 function prop(arg1, arg2) { 5125 var name; 5126 var selector; 5127 if (1 === arguments.length) { 5128 name = arg1; 5129 selector = void 0; 5130 } else { 5131 name = arg2; 5132 selector = arg1; 5133 } 5134 return function(node) { 5135 var match = node; 5136 if (selector) { 5137 match = node.querySelector(selector); 5138 } 5139 if (match) { 5140 return getPath(match, name); 5141 } 5142 }; 5143 } 5144 function attr(arg1, arg2) { 5145 var name; 5146 var selector; 5147 if (1 === arguments.length) { 5148 name = arg1; 5149 selector = void 0; 5150 } else { 5151 name = arg2; 5152 selector = arg1; 5153 } 5154 return function(node) { 5155 var attributes = prop(selector, "attributes")(node); 5156 if (attributes && Object.prototype.hasOwnProperty.call(attributes, name)) { 5157 return attributes[name].value; 5158 } 5159 }; 5160 } 5161 function text(selector) { 5162 return prop(selector, "textContent"); 5163 } 5164 function query(selector, matchers) { 5165 return function(node) { 5166 var matches = node.querySelectorAll(selector); 5167 return [].map.call(matches, function(match) { 5168 return parse(match, matchers); 5169 }); 5170 }; 5171 } 5172 5173 // node_modules/memize/dist/index.js 5174 function memize(fn, options) { 5175 var size = 0; 5176 var head; 5177 var tail; 5178 options = options || {}; 5179 function memoized() { 5180 var node = head, len = arguments.length, args, i; 5181 searchCache: while (node) { 5182 if (node.args.length !== arguments.length) { 5183 node = node.next; 5184 continue; 5185 } 5186 for (i = 0; i < len; i++) { 5187 if (node.args[i] !== arguments[i]) { 5188 node = node.next; 5189 continue searchCache; 5190 } 5191 } 5192 if (node !== head) { 5193 if (node === tail) { 5194 tail = node.prev; 5195 } 5196 node.prev.next = node.next; 5197 if (node.next) { 5198 node.next.prev = node.prev; 5199 } 5200 node.next = head; 5201 node.prev = null; 5202 head.prev = node; 5203 head = node; 5204 } 5205 return node.val; 5206 } 5207 args = new Array(len); 5208 for (i = 0; i < len; i++) { 5209 args[i] = arguments[i]; 5210 } 5211 node = { 5212 args, 5213 // Generate the result from original function 5214 val: fn.apply(null, args) 5215 }; 5216 if (head) { 5217 head.prev = node; 5218 node.next = head; 5219 } else { 5220 tail = node; 5221 } 5222 if (size === /** @type {MemizeOptions} */ 5223 options.maxSize) { 5224 tail = /** @type {MemizeCacheNode} */ 5225 tail.prev; 5226 tail.next = null; 5227 } else { 5228 size++; 5229 } 5230 head = node; 5231 return node.val; 5232 } 5233 memoized.clear = function() { 5234 head = null; 5235 tail = null; 5236 size = 0; 5237 }; 5238 return memoized; 5239 } 5240 5241 // packages/blocks/build-module/api/parser/get-block-attributes.mjs 5242 var import_hooks4 = __toESM(require_hooks(), 1); 5243 var import_rich_text4 = __toESM(require_rich_text(), 1); 5244 5245 // packages/blocks/build-module/api/matchers.mjs 5246 var import_rich_text3 = __toESM(require_rich_text(), 1); 5247 5248 // packages/blocks/build-module/api/node.mjs 5249 var import_deprecated10 = __toESM(require_deprecated(), 1); 5250 5251 // packages/blocks/build-module/api/children.mjs 5252 var import_element3 = __toESM(require_element(), 1); 5253 var import_deprecated9 = __toESM(require_deprecated(), 1); 5254 function getSerializeCapableElement(children) { 5255 return children; 5256 } 5257 function getChildrenArray(children) { 5258 (0, import_deprecated9.default)("wp.blocks.children.getChildrenArray", { 5259 since: "6.1", 5260 version: "6.3", 5261 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5262 }); 5263 return children; 5264 } 5265 function concat(...blockNodes) { 5266 (0, import_deprecated9.default)("wp.blocks.children.concat", { 5267 since: "6.1", 5268 version: "6.3", 5269 alternative: "wp.richText.concat", 5270 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5271 }); 5272 const result = []; 5273 for (let i = 0; i < blockNodes.length; i++) { 5274 const blockNode = Array.isArray(blockNodes[i]) ? blockNodes[i] : [blockNodes[i]]; 5275 for (let j2 = 0; j2 < blockNode.length; j2++) { 5276 const child = blockNode[j2]; 5277 const canConcatToPreviousString = typeof child === "string" && typeof result[result.length - 1] === "string"; 5278 if (canConcatToPreviousString) { 5279 result[result.length - 1] += child; 5280 } else { 5281 result.push(child); 5282 } 5283 } 5284 } 5285 return result; 5286 } 5287 function fromDOM22(domNodes) { 5288 (0, import_deprecated9.default)("wp.blocks.children.fromDOM", { 5289 since: "6.1", 5290 version: "6.3", 5291 alternative: "wp.richText.create", 5292 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5293 }); 5294 const result = []; 5295 for (let i = 0; i < domNodes.length; i++) { 5296 try { 5297 result.push(fromDOM2(domNodes[i])); 5298 } catch { 5299 } 5300 } 5301 return result; 5302 } 5303 function toHTML(children) { 5304 (0, import_deprecated9.default)("wp.blocks.children.toHTML", { 5305 since: "6.1", 5306 version: "6.3", 5307 alternative: "wp.richText.toHTMLString", 5308 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5309 }); 5310 const element = getSerializeCapableElement(children); 5311 return (0, import_element3.renderToString)(element); 5312 } 5313 function matcher(selector) { 5314 (0, import_deprecated9.default)("wp.blocks.children.matcher", { 5315 since: "6.1", 5316 version: "6.3", 5317 alternative: "html source", 5318 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5319 }); 5320 return (domNode) => { 5321 let match = domNode; 5322 if (selector) { 5323 match = domNode.querySelector(selector); 5324 } 5325 if (match) { 5326 return fromDOM22(match.childNodes); 5327 } 5328 return []; 5329 }; 5330 } 5331 var children_default = { 5332 concat, 5333 getChildrenArray, 5334 fromDOM: fromDOM22, 5335 toHTML, 5336 matcher 5337 }; 5338 5339 // packages/blocks/build-module/api/node.mjs 5340 function isNodeOfType(node, type) { 5341 (0, import_deprecated10.default)("wp.blocks.node.isNodeOfType", { 5342 since: "6.1", 5343 version: "6.3", 5344 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5345 }); 5346 return typeof node !== "string" && node?.type === type; 5347 } 5348 function getNamedNodeMapAsObject(nodeMap) { 5349 const result = {}; 5350 for (let i = 0; i < nodeMap.length; i++) { 5351 const { name, value } = nodeMap[i]; 5352 result[name] = value; 5353 } 5354 return result; 5355 } 5356 function fromDOM2(domNode) { 5357 (0, import_deprecated10.default)("wp.blocks.node.fromDOM", { 5358 since: "6.1", 5359 version: "6.3", 5360 alternative: "wp.richText.create", 5361 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5362 }); 5363 if (domNode.nodeType === domNode.TEXT_NODE) { 5364 return domNode.nodeValue; 5365 } 5366 if (domNode.nodeType !== domNode.ELEMENT_NODE) { 5367 throw new TypeError( 5368 "A block node can only be created from a node of type text or element." 5369 ); 5370 } 5371 return { 5372 type: domNode.nodeName.toLowerCase(), 5373 props: { 5374 ...getNamedNodeMapAsObject(domNode.attributes), 5375 children: fromDOM22(domNode.childNodes) 5376 } 5377 }; 5378 } 5379 function toHTML2(node) { 5380 (0, import_deprecated10.default)("wp.blocks.node.toHTML", { 5381 since: "6.1", 5382 version: "6.3", 5383 alternative: "wp.richText.toHTMLString", 5384 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5385 }); 5386 return toHTML([node]); 5387 } 5388 function matcher2(selector) { 5389 (0, import_deprecated10.default)("wp.blocks.node.matcher", { 5390 since: "6.1", 5391 version: "6.3", 5392 alternative: "html source", 5393 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 5394 }); 5395 return (domNode) => { 5396 let match = domNode; 5397 if (selector) { 5398 match = domNode.querySelector(selector); 5399 } 5400 try { 5401 return fromDOM2(match); 5402 } catch { 5403 return null; 5404 } 5405 }; 5406 } 5407 var node_default = { 5408 isNodeOfType, 5409 fromDOM: fromDOM2, 5410 toHTML: toHTML2, 5411 matcher: matcher2 5412 }; 5413 5414 // packages/blocks/build-module/api/matchers.mjs 5415 function html(selector, multilineTag) { 5416 return (domNode) => { 5417 let match = domNode; 5418 if (selector) { 5419 match = domNode.querySelector(selector); 5420 } 5421 if (!match) { 5422 return ""; 5423 } 5424 if (multilineTag) { 5425 let value = ""; 5426 const length = match.children.length; 5427 for (let index = 0; index < length; index++) { 5428 const child = match.children[index]; 5429 if (child.nodeName.toLowerCase() !== multilineTag) { 5430 continue; 5431 } 5432 value += child.outerHTML; 5433 } 5434 return value; 5435 } 5436 return match.innerHTML; 5437 }; 5438 } 5439 var richText = (selector, preserveWhiteSpace) => (el) => { 5440 const target = selector ? el.querySelector(selector) : el; 5441 return target ? import_rich_text3.RichTextData.fromHTMLElement(target, { 5442 preserveWhiteSpace 5443 }) : import_rich_text3.RichTextData.empty(); 5444 }; 5445 5446 // packages/blocks/build-module/api/parser/get-block-attributes.mjs 5447 var toBooleanAttributeMatcher = (matcher3) => (domNode) => matcher3(domNode) !== void 0; 5448 function isOfType(value, type) { 5449 switch (type) { 5450 case "rich-text": 5451 return value instanceof import_rich_text4.RichTextData; 5452 case "string": 5453 return typeof value === "string"; 5454 case "boolean": 5455 return typeof value === "boolean"; 5456 case "object": 5457 return !!value && value.constructor === Object; 5458 case "null": 5459 return value === null; 5460 case "array": 5461 return Array.isArray(value); 5462 case "integer": 5463 case "number": 5464 return typeof value === "number"; 5465 } 5466 return true; 5467 } 5468 function isOfTypes(value, types) { 5469 return types.some((type) => isOfType(value, type)); 5470 } 5471 function getBlockAttribute(attributeKey, attributeSchema, innerDOM, commentAttributes, innerHTML) { 5472 let value; 5473 switch (attributeSchema.source) { 5474 // An undefined source means that it's an attribute serialized to the 5475 // block's "comment". 5476 case void 0: 5477 value = commentAttributes ? commentAttributes[attributeKey] : void 0; 5478 break; 5479 // raw source means that it's the original raw block content. 5480 case "raw": 5481 value = innerHTML; 5482 break; 5483 case "attribute": 5484 case "property": 5485 case "html": 5486 case "text": 5487 case "rich-text": 5488 case "children": 5489 case "node": 5490 case "query": 5491 case "tag": 5492 value = parseWithAttributeSchema(innerDOM, attributeSchema); 5493 break; 5494 } 5495 if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) { 5496 value = void 0; 5497 } 5498 if (value === void 0) { 5499 value = getDefault(attributeSchema); 5500 } 5501 return value; 5502 } 5503 function isValidByType(value, type) { 5504 return type === void 0 || isOfTypes(value, Array.isArray(type) ? type : [type]); 5505 } 5506 function isValidByEnum(value, enumSet) { 5507 return !Array.isArray(enumSet) || enumSet.includes(value); 5508 } 5509 var matcherFromSource = memize( 5510 (sourceConfig) => { 5511 switch (sourceConfig.source) { 5512 case "attribute": { 5513 const matcher3 = attr( 5514 sourceConfig.selector, 5515 sourceConfig.attribute 5516 ); 5517 if (sourceConfig.type === "boolean") { 5518 return toBooleanAttributeMatcher(matcher3); 5519 } 5520 return matcher3; 5521 } 5522 case "html": 5523 return html(sourceConfig.selector, sourceConfig.multiline); 5524 case "text": 5525 return text(sourceConfig.selector); 5526 case "rich-text": 5527 return richText( 5528 sourceConfig.selector, 5529 sourceConfig.__unstablePreserveWhiteSpace 5530 ); 5531 case "children": 5532 return matcher(sourceConfig.selector); 5533 case "node": 5534 return matcher2(sourceConfig.selector); 5535 case "query": 5536 const subMatchers = Object.fromEntries( 5537 Object.entries(sourceConfig.query).map( 5538 ([key, subSourceConfig]) => [ 5539 key, 5540 matcherFromSource(subSourceConfig) 5541 ] 5542 ) 5543 ); 5544 return query(sourceConfig.selector, subMatchers); 5545 case "tag": { 5546 const matcher3 = prop(sourceConfig.selector, "nodeName"); 5547 return (domNode) => matcher3(domNode)?.toLowerCase(); 5548 } 5549 default: 5550 console.error( 5551 `Unknown source type "${sourceConfig.source}"` 5552 ); 5553 return void 0; 5554 } 5555 } 5556 ); 5557 function parseHtml(innerHTML) { 5558 return parse( 5559 innerHTML ?? "", 5560 (h) => h 5561 ); 5562 } 5563 function parseWithAttributeSchema(innerHTML, attributeSchema) { 5564 return matcherFromSource(attributeSchema)( 5565 parseHtml(innerHTML) 5566 ); 5567 } 5568 function getBlockAttributes(blockTypeOrName, innerHTML, attributes = {}) { 5569 const doc = parseHtml(innerHTML); 5570 const blockType = normalizeBlockType(blockTypeOrName); 5571 const blockAttributes = Object.fromEntries( 5572 Object.entries(blockType?.attributes ?? {}).map( 5573 ([key, schema]) => [ 5574 key, 5575 getBlockAttribute(key, schema, doc, attributes, innerHTML) 5576 ] 5577 ) 5578 ); 5579 return (0, import_hooks4.applyFilters)( 5580 "blocks.getBlockAttributes", 5581 blockAttributes, 5582 blockType, 5583 innerHTML, 5584 attributes 5585 ); 5586 } 5587 5588 // packages/blocks/build-module/api/parser/fix-custom-classname.mjs 5589 var CLASS_ATTR_SCHEMA = { 5590 type: "string", 5591 source: "attribute", 5592 selector: "[data-custom-class-name] > *", 5593 attribute: "class" 5594 }; 5595 function getHTMLRootElementClasses(innerHTML) { 5596 const parsed = parseWithAttributeSchema( 5597 `<div data-custom-class-name>$innerHTML}</div>`, 5598 CLASS_ATTR_SCHEMA 5599 ); 5600 return parsed ? parsed.trim().split(/\s+/) : []; 5601 } 5602 function fixCustomClassname(blockAttributes, blockType, innerHTML) { 5603 if (!hasBlockSupport(blockType, "customClassName", true)) { 5604 return blockAttributes; 5605 } 5606 const modifiedBlockAttributes = { ...blockAttributes }; 5607 const { className: omittedClassName, ...attributesSansClassName } = modifiedBlockAttributes; 5608 const serialized = getSaveContent(blockType, attributesSansClassName); 5609 const defaultClasses = getHTMLRootElementClasses(serialized); 5610 const actualClasses = getHTMLRootElementClasses(innerHTML); 5611 const customClasses = actualClasses.filter( 5612 (className) => !defaultClasses.includes(className) 5613 ); 5614 if (customClasses.length) { 5615 modifiedBlockAttributes.className = customClasses.join(" "); 5616 } else if (serialized) { 5617 delete modifiedBlockAttributes.className; 5618 } 5619 return modifiedBlockAttributes; 5620 } 5621 5622 // packages/blocks/build-module/api/parser/fix-global-attribute.mjs 5623 function getHTMLRootElement(innerHTML, dataAttribute, attributeSchema) { 5624 const parsed = parseWithAttributeSchema( 5625 `<div $dataAttribute}>$innerHTML}</div>`, 5626 attributeSchema 5627 ); 5628 return parsed; 5629 } 5630 function fixGlobalAttribute(blockAttributes, blockType, innerHTML, supportKey, dataAttribute, attributeSchema) { 5631 if (!hasBlockSupport(blockType, supportKey, false)) { 5632 return blockAttributes; 5633 } 5634 const modifiedBlockAttributes = { ...blockAttributes }; 5635 const attributeValue = getHTMLRootElement( 5636 innerHTML, 5637 dataAttribute, 5638 attributeSchema 5639 ); 5640 if (attributeValue) { 5641 modifiedBlockAttributes[supportKey] = attributeValue; 5642 } 5643 return modifiedBlockAttributes; 5644 } 5645 5646 // packages/blocks/build-module/api/parser/apply-built-in-validation-fixes.mjs 5647 var ARIA_LABEL_ATTR_SCHEMA = { 5648 type: "string", 5649 source: "attribute", 5650 selector: "[data-aria-label] > *", 5651 attribute: "aria-label" 5652 }; 5653 var ANCHOR_ATTR_SCHEMA = { 5654 type: "string", 5655 source: "attribute", 5656 selector: "[data-anchor] > *", 5657 attribute: "id" 5658 }; 5659 function applyBuiltInValidationFixes(block, blockType) { 5660 const { attributes, originalContent } = block; 5661 let updatedBlockAttributes = attributes; 5662 updatedBlockAttributes = fixCustomClassname( 5663 attributes, 5664 blockType, 5665 originalContent ?? "" 5666 ); 5667 updatedBlockAttributes = fixGlobalAttribute( 5668 updatedBlockAttributes, 5669 blockType, 5670 originalContent ?? "", 5671 "ariaLabel", 5672 "data-aria-label", 5673 ARIA_LABEL_ATTR_SCHEMA 5674 ); 5675 updatedBlockAttributes = fixGlobalAttribute( 5676 updatedBlockAttributes, 5677 blockType, 5678 originalContent ?? "", 5679 "anchor", 5680 "data-anchor", 5681 ANCHOR_ATTR_SCHEMA 5682 ); 5683 return { 5684 ...block, 5685 attributes: updatedBlockAttributes 5686 }; 5687 } 5688 5689 // packages/blocks/build-module/api/parser/apply-block-deprecated-versions.mjs 5690 function stubFalse() { 5691 return false; 5692 } 5693 function applyBlockDeprecatedVersions(block, rawBlock, blockType) { 5694 const parsedAttributes = rawBlock.attrs ?? {}; 5695 const { deprecated: deprecatedDefinitions } = blockType; 5696 if (!deprecatedDefinitions || !deprecatedDefinitions.length) { 5697 return block; 5698 } 5699 for (let i = 0; i < deprecatedDefinitions.length; i++) { 5700 const { isEligible = stubFalse } = deprecatedDefinitions[i]; 5701 if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks, { 5702 blockNode: rawBlock, 5703 block 5704 })) { 5705 continue; 5706 } 5707 const deprecatedBlockType = Object.assign( 5708 omit( 5709 blockType, 5710 DEPRECATED_ENTRY_KEYS 5711 ), 5712 deprecatedDefinitions[i] 5713 ); 5714 let migratedBlock = { 5715 ...block, 5716 attributes: getBlockAttributes( 5717 deprecatedBlockType, 5718 block.originalContent ?? "", 5719 parsedAttributes 5720 ) 5721 }; 5722 let [isValid] = validateBlock(migratedBlock, deprecatedBlockType); 5723 if (!isValid) { 5724 migratedBlock = applyBuiltInValidationFixes( 5725 migratedBlock, 5726 deprecatedBlockType 5727 ); 5728 [isValid] = validateBlock(migratedBlock, deprecatedBlockType); 5729 } 5730 if (!isValid) { 5731 continue; 5732 } 5733 let migratedInnerBlocks = migratedBlock.innerBlocks; 5734 let migratedAttributes = migratedBlock.attributes; 5735 const { migrate } = deprecatedBlockType; 5736 if (migrate) { 5737 let migrated = migrate(migratedAttributes, block.innerBlocks); 5738 if (!Array.isArray(migrated)) { 5739 migrated = [migrated]; 5740 } 5741 [ 5742 migratedAttributes = parsedAttributes, 5743 migratedInnerBlocks = block.innerBlocks 5744 ] = migrated; 5745 } 5746 block = { 5747 ...block, 5748 attributes: migratedAttributes, 5749 innerBlocks: migratedInnerBlocks, 5750 isValid: true, 5751 validationIssues: [] 5752 }; 5753 } 5754 return block; 5755 } 5756 5757 // packages/blocks/build-module/api/parser/index.mjs 5758 function convertLegacyBlocks(rawBlock) { 5759 const [correctName, correctedAttributes] = convertLegacyBlockNameAndAttributes( 5760 rawBlock.blockName, 5761 rawBlock.attrs ?? {} 5762 ); 5763 return { 5764 ...rawBlock, 5765 blockName: correctName, 5766 attrs: correctedAttributes 5767 }; 5768 } 5769 function normalizeRawBlock(rawBlock, options) { 5770 const fallbackBlockName = getFreeformContentHandlerName(); 5771 const rawBlockName = rawBlock.blockName || getFreeformContentHandlerName(); 5772 const rawAttributes = rawBlock.attrs || {}; 5773 const rawInnerBlocks = rawBlock.innerBlocks || []; 5774 let rawInnerHTML = rawBlock.innerHTML.trim(); 5775 if (rawBlockName === fallbackBlockName && rawBlockName === "core/freeform" && !options?.__unstableSkipAutop) { 5776 rawInnerHTML = (0, import_autop2.autop)(rawInnerHTML).trim(); 5777 } 5778 return { 5779 ...rawBlock, 5780 blockName: rawBlockName, 5781 attrs: rawAttributes, 5782 innerHTML: rawInnerHTML, 5783 innerBlocks: rawInnerBlocks 5784 }; 5785 } 5786 function createMissingBlockType(rawBlock) { 5787 const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName(); 5788 const originalUndelimitedContent = serializeRawBlock(rawBlock, { 5789 isCommentDelimited: false 5790 }); 5791 const originalContent = serializeRawBlock(rawBlock, { 5792 isCommentDelimited: true 5793 }); 5794 return { 5795 blockName: unregisteredFallbackBlock, 5796 attrs: { 5797 originalName: rawBlock.blockName, 5798 originalContent, 5799 originalUndelimitedContent 5800 }, 5801 innerHTML: rawBlock.blockName ? originalContent : rawBlock.innerHTML, 5802 innerBlocks: rawBlock.innerBlocks, 5803 innerContent: rawBlock.innerContent 5804 }; 5805 } 5806 function applyBlockValidation(unvalidatedBlock, blockType) { 5807 const [isValid] = validateBlock(unvalidatedBlock, blockType); 5808 if (isValid) { 5809 return { ...unvalidatedBlock, isValid, validationIssues: [] }; 5810 } 5811 const fixedBlock = applyBuiltInValidationFixes( 5812 unvalidatedBlock, 5813 blockType 5814 ); 5815 const [isFixedValid, validationIssues] = validateBlock( 5816 fixedBlock, 5817 blockType 5818 ); 5819 return { ...fixedBlock, isValid: isFixedValid, validationIssues }; 5820 } 5821 function parseRawBlock(rawBlock, options) { 5822 let normalizedBlock = normalizeRawBlock(rawBlock, options); 5823 normalizedBlock = convertLegacyBlocks(normalizedBlock); 5824 let blockType = getBlockType(normalizedBlock.blockName); 5825 if (!blockType) { 5826 normalizedBlock = createMissingBlockType(normalizedBlock); 5827 blockType = getBlockType(normalizedBlock.blockName); 5828 } 5829 const isFallbackBlock = normalizedBlock.blockName === getFreeformContentHandlerName() || normalizedBlock.blockName === getUnregisteredTypeHandlerName(); 5830 if (!blockType || !normalizedBlock.innerHTML && isFallbackBlock) { 5831 return; 5832 } 5833 const parsedInnerBlocks = normalizedBlock.innerBlocks.map((innerBlock) => parseRawBlock(innerBlock, options)).filter((innerBlock) => !!innerBlock); 5834 const parsedBlock = createBlock( 5835 normalizedBlock.blockName, 5836 getBlockAttributes( 5837 blockType, 5838 normalizedBlock.innerHTML, 5839 normalizedBlock.attrs 5840 ), 5841 parsedInnerBlocks 5842 ); 5843 parsedBlock.originalContent = normalizedBlock.innerHTML; 5844 if (blockType.name === "core/html") { 5845 parsedBlock.innerContent = normalizedBlock.innerContent ?? [ 5846 normalizedBlock.innerHTML 5847 ]; 5848 parsedBlock.isValid = true; 5849 parsedBlock.validationIssues = []; 5850 return parsedBlock; 5851 } 5852 const validatedBlock = applyBlockValidation(parsedBlock, blockType); 5853 const { validationIssues } = validatedBlock; 5854 const updatedBlock = applyBlockDeprecatedVersions( 5855 validatedBlock, 5856 normalizedBlock, 5857 blockType 5858 ); 5859 if (!updatedBlock.isValid) { 5860 updatedBlock.__unstableBlockSource = rawBlock; 5861 } 5862 if (!validatedBlock.isValid && updatedBlock.isValid && !options?.__unstableSkipMigrationLogs) { 5863 console.groupCollapsed("Updated Block: %s", blockType.name); 5864 console.info( 5865 "Block successfully updated for `%s` (%o).\n\nNew content generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s", 5866 blockType.name, 5867 blockType, 5868 getSaveContent(blockType, updatedBlock.attributes), 5869 updatedBlock.originalContent 5870 ); 5871 console.groupEnd(); 5872 } else if (!validatedBlock.isValid && !updatedBlock.isValid) { 5873 validationIssues.forEach(({ log: log2, args }) => log2(...args)); 5874 } 5875 return updatedBlock; 5876 } 5877 function parse2(content, options) { 5878 return (0, import_block_serialization_default_parser.parse)(content).reduce( 5879 (accumulator, rawBlock) => { 5880 const block = parseRawBlock( 5881 rawBlock, 5882 options 5883 ); 5884 if (block) { 5885 accumulator.push(block); 5886 } 5887 return accumulator; 5888 }, 5889 [] 5890 ); 5891 } 5892 5893 // packages/blocks/build-module/api/raw-handling/index.mjs 5894 var import_deprecated11 = __toESM(require_deprecated(), 1); 5895 var import_dom13 = __toESM(require_dom(), 1); 5896 5897 // packages/blocks/build-module/api/raw-handling/get-raw-transforms.mjs 5898 function getRawTransforms() { 5899 return getBlockTransforms("from").filter( 5900 (transform) => transform.type === "raw" 5901 ).map((transform) => ({ 5902 ...transform, 5903 isMatch: transform.isMatch ?? ((node) => !!transform.selector && node.matches(transform.selector)) 5904 })); 5905 } 5906 5907 // packages/blocks/build-module/api/raw-handling/html-to-blocks.mjs 5908 function htmlToBlocks(html2, handler) { 5909 const doc = document.implementation.createHTMLDocument(""); 5910 doc.body.innerHTML = html2; 5911 return Array.from(doc.body.children).flatMap((node) => { 5912 const transforms = getRawTransforms(); 5913 const rawTransform = findTransform( 5914 transforms, 5915 (transform2) => transform2.isMatch(node) 5916 ); 5917 if (!rawTransform) { 5918 return createBlock( 5919 // Should not be hardcoded. 5920 "core/html", 5921 {}, 5922 [], 5923 [node.outerHTML] 5924 ); 5925 } 5926 const { transform, blockName } = rawTransform; 5927 if (transform) { 5928 const block = transform(node, handler); 5929 if (node.hasAttribute("class")) { 5930 block.attributes.className = node.getAttribute("class"); 5931 } 5932 return block; 5933 } 5934 return createBlock( 5935 blockName, 5936 getBlockAttributes(blockName, node.outerHTML) 5937 ); 5938 }); 5939 } 5940 5941 // packages/blocks/build-module/api/raw-handling/normalise-blocks.mjs 5942 var import_dom2 = __toESM(require_dom(), 1); 5943 function normaliseBlocks(HTML, options = {}) { 5944 const decuDoc = document.implementation.createHTMLDocument(""); 5945 const accuDoc = document.implementation.createHTMLDocument(""); 5946 const decu = decuDoc.body; 5947 const accu = accuDoc.body; 5948 decu.innerHTML = HTML; 5949 while (decu.firstChild) { 5950 const node = decu.firstChild; 5951 if (node.nodeType === node.TEXT_NODE) { 5952 if ((0, import_dom2.isEmpty)(node)) { 5953 decu.removeChild(node); 5954 } else { 5955 if (!accu.lastChild || accu.lastChild.nodeName !== "P") { 5956 accu.appendChild(accuDoc.createElement("P")); 5957 } 5958 accu.lastChild.appendChild(node); 5959 } 5960 } else if (node.nodeType === node.ELEMENT_NODE) { 5961 if (node.nodeName === "BR") { 5962 if (node.nextSibling && node.nextSibling.nodeName === "BR") { 5963 accu.appendChild(accuDoc.createElement("P")); 5964 decu.removeChild(node.nextSibling); 5965 } 5966 if (accu.lastChild && accu.lastChild.nodeName === "P" && accu.lastChild.hasChildNodes()) { 5967 accu.lastChild.appendChild(node); 5968 } else { 5969 decu.removeChild(node); 5970 } 5971 } else if (node.nodeName === "P") { 5972 if ((0, import_dom2.isEmpty)(node) && !options.raw) { 5973 decu.removeChild(node); 5974 } else { 5975 accu.appendChild(node); 5976 } 5977 } else if ((0, import_dom2.isPhrasingContent)(node)) { 5978 if (!accu.lastChild || accu.lastChild.nodeName !== "P") { 5979 accu.appendChild(accuDoc.createElement("P")); 5980 } 5981 accu.lastChild.appendChild(node); 5982 } else { 5983 accu.appendChild(node); 5984 } 5985 } else { 5986 decu.removeChild(node); 5987 } 5988 } 5989 return accu.innerHTML; 5990 } 5991 5992 // packages/blocks/build-module/api/raw-handling/special-comment-converter.mjs 5993 var import_dom3 = __toESM(require_dom(), 1); 5994 function specialCommentConverter(node, doc) { 5995 if (node.nodeType !== node.COMMENT_NODE) { 5996 return; 5997 } 5998 if (node.nodeValue !== "nextpage" && node.nodeValue.indexOf("more") !== 0) { 5999 return; 6000 } 6001 const block = createBlock2(node, doc); 6002 if (!node.parentNode || node.parentNode.nodeName !== "P") { 6003 (0, import_dom3.replace)(node, block); 6004 } else { 6005 const childNodes = Array.from(node.parentNode.childNodes); 6006 const nodeIndex = childNodes.indexOf(node); 6007 const wrapperNode = node.parentNode.parentNode || doc.body; 6008 const paragraphBuilder = (acc, child) => { 6009 if (!acc) { 6010 acc = doc.createElement("p"); 6011 } 6012 acc.appendChild(child); 6013 return acc; 6014 }; 6015 [ 6016 childNodes.slice(0, nodeIndex).reduce(paragraphBuilder, null), 6017 block, 6018 childNodes.slice(nodeIndex + 1).reduce(paragraphBuilder, null) 6019 ].forEach( 6020 (element) => element && wrapperNode.insertBefore(element, node.parentNode) 6021 ); 6022 (0, import_dom3.remove)(node.parentNode); 6023 } 6024 } 6025 function createBlock2(commentNode, doc) { 6026 if (commentNode.nodeValue === "nextpage") { 6027 return createNextpage(doc); 6028 } 6029 const customText = commentNode.nodeValue.slice(4).trim(); 6030 let sibling = commentNode; 6031 let noTeaser = false; 6032 while (sibling = sibling.nextSibling) { 6033 if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === "noteaser") { 6034 noTeaser = true; 6035 (0, import_dom3.remove)(sibling); 6036 break; 6037 } 6038 } 6039 return createMore(customText, noTeaser, doc); 6040 } 6041 function createMore(customText, noTeaser, doc) { 6042 const node = doc.createElement("wp-block"); 6043 node.dataset.block = "core/more"; 6044 if (customText) { 6045 node.dataset.customText = customText; 6046 } 6047 if (noTeaser) { 6048 node.dataset.noTeaser = ""; 6049 } 6050 return node; 6051 } 6052 function createNextpage(doc) { 6053 const node = doc.createElement("wp-block"); 6054 node.dataset.block = "core/nextpage"; 6055 return node; 6056 } 6057 6058 // packages/blocks/build-module/api/raw-handling/list-reducer.mjs 6059 var import_dom4 = __toESM(require_dom(), 1); 6060 function isList(node) { 6061 return node.nodeName === "OL" || node.nodeName === "UL"; 6062 } 6063 function shallowTextContent(element) { 6064 return Array.from(element.childNodes).map(({ nodeValue = "" }) => nodeValue).join(""); 6065 } 6066 function listReducer(node) { 6067 if (!isList(node)) { 6068 return; 6069 } 6070 const list = node; 6071 const prevElement = list.previousElementSibling; 6072 if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) { 6073 while (list.firstChild) { 6074 prevElement.appendChild(list.firstChild); 6075 } 6076 list.parentNode.removeChild(list); 6077 } 6078 const parentElement = node.parentNode; 6079 if (parentElement && parentElement.nodeName === "LI" && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) { 6080 const parentListItem = parentElement; 6081 const prevListItem = parentListItem.previousElementSibling; 6082 const parentList = parentListItem.parentNode; 6083 if (prevListItem) { 6084 prevListItem.appendChild(list); 6085 parentList.removeChild(parentListItem); 6086 } 6087 } 6088 if (parentElement && isList(parentElement)) { 6089 const prevListItem = list.previousElementSibling; 6090 if (prevListItem) { 6091 prevListItem.appendChild(node); 6092 } else { 6093 (0, import_dom4.unwrap)(node); 6094 } 6095 } 6096 } 6097 6098 // packages/blocks/build-module/api/raw-handling/blockquote-normaliser.mjs 6099 function blockquoteNormaliser(options = {}) { 6100 return (bq) => { 6101 if (bq.nodeName !== "BLOCKQUOTE") { 6102 return; 6103 } 6104 const node = bq; 6105 node.innerHTML = normaliseBlocks(node.innerHTML, options); 6106 }; 6107 } 6108 6109 // packages/blocks/build-module/api/raw-handling/figure-content-reducer.mjs 6110 var import_dom5 = __toESM(require_dom(), 1); 6111 function isFigureContent(node, schema) { 6112 const tag = node.nodeName.toLowerCase(); 6113 if (tag === "figcaption" || (0, import_dom5.isTextContent)(node)) { 6114 return false; 6115 } 6116 return tag in (schema?.figure?.children ?? {}); 6117 } 6118 function canHaveAnchor(node, schema) { 6119 const tag = node.nodeName.toLowerCase(); 6120 return tag in (schema?.figure?.children?.a?.children ?? {}); 6121 } 6122 function wrapFigureContent(element, beforeElement = element) { 6123 const figure = element.ownerDocument.createElement("figure"); 6124 beforeElement.parentNode.insertBefore(figure, beforeElement); 6125 figure.appendChild(element); 6126 } 6127 function figureContentReducer(node, doc, schema) { 6128 if (!schema || !isFigureContent(node, schema)) { 6129 return; 6130 } 6131 let nodeToInsert = node; 6132 const parentNode = node.parentNode; 6133 if (canHaveAnchor(node, schema) && parentNode.nodeName === "A" && parentNode.childNodes.length === 1) { 6134 nodeToInsert = node.parentNode; 6135 } 6136 const wrapper = nodeToInsert.closest("p,div"); 6137 if (wrapper) { 6138 const element = node; 6139 if (!element.classList) { 6140 wrapFigureContent(nodeToInsert, wrapper); 6141 } else if (element.classList.contains("alignright") || element.classList.contains("alignleft") || element.classList.contains("aligncenter") || !wrapper.textContent.trim()) { 6142 wrapFigureContent(nodeToInsert, wrapper); 6143 } 6144 } else { 6145 wrapFigureContent(nodeToInsert); 6146 } 6147 } 6148 6149 // packages/blocks/build-module/api/raw-handling/shortcode-converter.mjs 6150 var import_shortcode = __toESM(require_shortcode(), 1); 6151 var castArray = (maybeArray) => Array.isArray(maybeArray) ? maybeArray : [maybeArray]; 6152 var beforeLineRegexp = /(\n|<p>|<br\s*\/?>)\s*$/; 6153 var afterLineRegexp = /^\s*(\n|<\/p>|<br\s*\/?>)/; 6154 function segmentHTMLToShortcodeBlock(HTML, lastIndex = 0, excludedBlockNames = []) { 6155 const transformsFrom = getBlockTransforms("from").filter( 6156 (transform) => transform.type === "shortcode" 6157 ); 6158 const transformation = findTransform( 6159 transformsFrom, 6160 (transform) => excludedBlockNames.indexOf(transform.blockName) === -1 && castArray(transform.tag).some( 6161 (tag) => (0, import_shortcode.regexp)(tag).test(HTML) 6162 ) 6163 ); 6164 if (!transformation) { 6165 return [HTML]; 6166 } 6167 const transformTags = castArray(transformation.tag); 6168 const transformTag = transformTags.find( 6169 (tag) => (0, import_shortcode.regexp)(tag).test(HTML) 6170 ); 6171 const previousIndex = lastIndex; 6172 const match = (0, import_shortcode.next)(transformTag, HTML, lastIndex); 6173 if (!match) { 6174 return [HTML]; 6175 } 6176 lastIndex = match.index + match.content.length; 6177 const beforeHTML = HTML.substr(0, match.index); 6178 const afterHTML = HTML.substr(lastIndex); 6179 if (!match.shortcode.content?.includes("<") && !(beforeLineRegexp.test(beforeHTML) && afterLineRegexp.test(afterHTML))) { 6180 return segmentHTMLToShortcodeBlock(HTML, lastIndex); 6181 } 6182 if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) { 6183 return segmentHTMLToShortcodeBlock(HTML, previousIndex, [ 6184 ...excludedBlockNames, 6185 transformation.blockName 6186 ]); 6187 } 6188 let blocks = []; 6189 if (typeof transformation.transform === "function") { 6190 blocks = [].concat( 6191 transformation.transform(match.shortcode.attrs, match) 6192 ); 6193 blocks = blocks.map((block) => { 6194 block.originalContent = match.shortcode.content; 6195 return applyBuiltInValidationFixes( 6196 block, 6197 getBlockType(block.name) 6198 ); 6199 }); 6200 } else { 6201 const blockType = getBlockType(transformation.blockName); 6202 if (!blockType) { 6203 return [HTML]; 6204 } 6205 const transformAttributes = transformation.attributes ?? blockType.attributes; 6206 const attributes = Object.fromEntries( 6207 Object.entries(transformAttributes).filter(([, schema]) => schema.shortcode).map(([key, schema]) => [ 6208 key, 6209 schema.shortcode(match.shortcode.attrs, match) 6210 ]) 6211 ); 6212 const transformationBlockType = { 6213 ...blockType, 6214 attributes: transformAttributes 6215 }; 6216 let block = createBlock( 6217 transformation.blockName, 6218 getBlockAttributes( 6219 transformationBlockType, 6220 match.shortcode.content, 6221 attributes 6222 ) 6223 ); 6224 block.originalContent = match.shortcode.content; 6225 block = applyBuiltInValidationFixes(block, transformationBlockType); 6226 blocks = [block]; 6227 } 6228 return [ 6229 ...segmentHTMLToShortcodeBlock( 6230 beforeHTML.replace(beforeLineRegexp, "") 6231 ), 6232 ...blocks, 6233 ...segmentHTMLToShortcodeBlock( 6234 afterHTML.replace(afterLineRegexp, "") 6235 ) 6236 ]; 6237 } 6238 var shortcode_converter_default = segmentHTMLToShortcodeBlock; 6239 6240 // packages/blocks/build-module/api/raw-handling/utils.mjs 6241 var import_dom6 = __toESM(require_dom(), 1); 6242 function getBlockContentSchemaFromTransforms(transforms, context) { 6243 const phrasingContentSchema = (0, import_dom6.getPhrasingContentSchema)(context); 6244 const schemaArgs = { phrasingContentSchema, isPaste: context === "paste" }; 6245 const schemas = transforms.map(({ isMatch, blockName, schema }) => { 6246 const hasAnchorSupport = hasBlockSupport(blockName, "anchor"); 6247 schema = typeof schema === "function" ? schema(schemaArgs) : schema; 6248 if (!hasAnchorSupport && !isMatch) { 6249 return schema; 6250 } 6251 if (!schema) { 6252 return {}; 6253 } 6254 return Object.fromEntries( 6255 Object.entries(schema).map(([key, value]) => { 6256 let attributes = value.attributes || []; 6257 if (hasAnchorSupport) { 6258 attributes = [...attributes, "id"]; 6259 } 6260 return [ 6261 key, 6262 { 6263 ...value, 6264 attributes, 6265 isMatch: isMatch ? isMatch : void 0 6266 } 6267 ]; 6268 }) 6269 ); 6270 }); 6271 function mergeTagNameSchemaProperties(objValue, srcValue, key) { 6272 switch (key) { 6273 case "children": { 6274 if (objValue === "*" || srcValue === "*") { 6275 return "*"; 6276 } 6277 return mergeSchemas( 6278 { ...objValue || {} }, 6279 srcValue || {} 6280 ); 6281 } 6282 case "attributes": 6283 case "require": { 6284 return Array.from( 6285 /* @__PURE__ */ new Set([...objValue || [], ...srcValue || []]) 6286 ); 6287 } 6288 case "isMatch": { 6289 if (!objValue || !srcValue) { 6290 return void 0; 6291 } 6292 return (...args) => { 6293 return objValue(...args) || srcValue(...args); 6294 }; 6295 } 6296 case "classes": { 6297 if ((objValue || []).includes("*") || (srcValue || []).includes("*")) { 6298 return ["*"]; 6299 } 6300 return [...objValue || [], ...srcValue || []]; 6301 } 6302 } 6303 } 6304 function mergeTagNameSchemas(a, b2) { 6305 if (a === b2) { 6306 return a; 6307 } 6308 for (const key in b2) { 6309 if (a[key]) { 6310 a[key] = mergeTagNameSchemaProperties( 6311 a[key], 6312 b2[key], 6313 key 6314 ); 6315 } else if (Array.isArray(b2[key])) { 6316 a[key] = b2[key].slice(); 6317 } else { 6318 a[key] = { ...b2[key] }; 6319 } 6320 } 6321 return a; 6322 } 6323 function mergeSchemas(a, b2) { 6324 if (a === b2) { 6325 return a; 6326 } 6327 for (const key in b2) { 6328 if (a[key]) { 6329 a[key] = mergeTagNameSchemas(a[key], b2[key]); 6330 } else if (Array.isArray(b2[key])) { 6331 a[key] = b2[key].slice(); 6332 } else { 6333 a[key] = { ...b2[key] }; 6334 } 6335 } 6336 return a; 6337 } 6338 return schemas.reduce(mergeSchemas, {}); 6339 } 6340 function getBlockContentSchema(context) { 6341 return getBlockContentSchemaFromTransforms(getRawTransforms(), context); 6342 } 6343 function isPlain(HTML) { 6344 if (!/<(?!br[ />])/i.test(HTML)) { 6345 return true; 6346 } 6347 const doc = document.implementation.createHTMLDocument(""); 6348 doc.body.innerHTML = HTML; 6349 if (doc.body.children.length !== 1) { 6350 return false; 6351 } 6352 const wrapper = doc.body.children.item(0); 6353 const descendants = wrapper.getElementsByTagName("*"); 6354 for (let i = 0; i < descendants.length; i++) { 6355 if (descendants.item(i).tagName !== "BR") { 6356 return false; 6357 } 6358 } 6359 if (wrapper.tagName !== "SPAN") { 6360 return false; 6361 } 6362 return true; 6363 } 6364 function deepFilterNodeList(nodeList, filters, doc, schema) { 6365 Array.from(nodeList).forEach((node) => { 6366 deepFilterNodeList(node.childNodes, filters, doc, schema); 6367 filters.forEach((item) => { 6368 if (!doc.contains(node)) { 6369 return; 6370 } 6371 item(node, doc, schema); 6372 }); 6373 }); 6374 } 6375 function deepFilterHTML(HTML, filters = [], schema) { 6376 const doc = document.implementation.createHTMLDocument(""); 6377 doc.body.innerHTML = HTML; 6378 deepFilterNodeList(doc.body.childNodes, filters, doc, schema); 6379 return doc.body.innerHTML; 6380 } 6381 function getSibling(node, which) { 6382 const sibling = node[`$which}Sibling`]; 6383 if (sibling && (0, import_dom6.isPhrasingContent)(sibling)) { 6384 return sibling; 6385 } 6386 const { parentNode } = node; 6387 if (!parentNode || !(0, import_dom6.isPhrasingContent)(parentNode)) { 6388 return; 6389 } 6390 return getSibling(parentNode, which); 6391 } 6392 6393 // packages/blocks/build-module/api/raw-handling/paste-handler.mjs 6394 var import_dom12 = __toESM(require_dom(), 1); 6395 6396 // packages/blocks/build-module/api/raw-handling/comment-remover.mjs 6397 var import_dom7 = __toESM(require_dom(), 1); 6398 function commentRemover(node) { 6399 if (node.nodeType === node.COMMENT_NODE) { 6400 (0, import_dom7.remove)(node); 6401 } 6402 } 6403 6404 // packages/blocks/build-module/api/raw-handling/is-inline-content.mjs 6405 var import_dom8 = __toESM(require_dom(), 1); 6406 function isInline(node, contextTag) { 6407 if ((0, import_dom8.isTextContent)(node)) { 6408 return true; 6409 } 6410 if (!contextTag) { 6411 return false; 6412 } 6413 const tag = node.nodeName.toLowerCase(); 6414 const inlineAllowedTagGroups = [ 6415 ["ul", "li", "ol"], 6416 ["h1", "h2", "h3", "h4", "h5", "h6"] 6417 ]; 6418 return inlineAllowedTagGroups.some( 6419 (tagGroup) => [tag, contextTag].filter((t2) => !tagGroup.includes(t2)).length === 0 6420 ); 6421 } 6422 function deepCheck(nodes, contextTag) { 6423 return nodes.every( 6424 (node) => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag) 6425 ); 6426 } 6427 function isDoubleBR(node) { 6428 return node.nodeName === "BR" && !!node.previousSibling && node.previousSibling.nodeName === "BR"; 6429 } 6430 function isInlineContent(HTML, contextTag) { 6431 const doc = document.implementation.createHTMLDocument(""); 6432 doc.body.innerHTML = HTML; 6433 const nodes = Array.from(doc.body.children); 6434 return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag); 6435 } 6436 6437 // packages/blocks/build-module/api/raw-handling/phrasing-content-reducer.mjs 6438 var import_dom9 = __toESM(require_dom(), 1); 6439 function phrasingContentReducer(node, doc) { 6440 if (node.nodeName === "SPAN" && node.style) { 6441 const { 6442 fontWeight, 6443 fontStyle, 6444 textDecorationLine, 6445 textDecoration, 6446 verticalAlign 6447 } = node.style; 6448 const element = node; 6449 if (fontWeight === "bold" || fontWeight === "700") { 6450 (0, import_dom9.wrap)(doc.createElement("strong"), element); 6451 } 6452 if (fontStyle === "italic") { 6453 (0, import_dom9.wrap)(doc.createElement("em"), element); 6454 } 6455 if (textDecorationLine === "line-through" || textDecoration.includes("line-through")) { 6456 (0, import_dom9.wrap)(doc.createElement("s"), element); 6457 } 6458 if (verticalAlign === "super") { 6459 (0, import_dom9.wrap)(doc.createElement("sup"), element); 6460 } else if (verticalAlign === "sub") { 6461 (0, import_dom9.wrap)(doc.createElement("sub"), element); 6462 } 6463 } else if (node.nodeName === "B") { 6464 (0, import_dom9.replaceTag)(node, "strong"); 6465 } else if (node.nodeName === "I") { 6466 (0, import_dom9.replaceTag)(node, "em"); 6467 } else if (node.nodeName === "A") { 6468 const anchor = node; 6469 if (anchor.target && anchor.target.toLowerCase() === "_blank") { 6470 anchor.rel = "noopener"; 6471 } else { 6472 anchor.removeAttribute("target"); 6473 anchor.removeAttribute("rel"); 6474 } 6475 if (anchor.name && !anchor.id) { 6476 anchor.id = anchor.name; 6477 } 6478 if (anchor.id && !anchor.ownerDocument.querySelector(`[href="#$anchor.id}"]`)) { 6479 anchor.removeAttribute("id"); 6480 } 6481 } 6482 } 6483 6484 // packages/blocks/build-module/api/raw-handling/head-remover.mjs 6485 function headRemover(node) { 6486 if (node.nodeName !== "SCRIPT" && node.nodeName !== "NOSCRIPT" && node.nodeName !== "TEMPLATE" && node.nodeName !== "STYLE") { 6487 return; 6488 } 6489 node.parentNode.removeChild(node); 6490 } 6491 6492 // packages/blocks/build-module/api/raw-handling/ms-list-ignore.mjs 6493 function msListIgnore(node) { 6494 if (node.nodeType !== node.ELEMENT_NODE) { 6495 return; 6496 } 6497 const el = node; 6498 const style = el.getAttribute("style"); 6499 if (!style || !style.includes("mso-list")) { 6500 return; 6501 } 6502 const rules = style.split(";").reduce( 6503 (acc, rule) => { 6504 const [key, value] = rule.split(":"); 6505 if (key && value) { 6506 acc[key.trim().toLowerCase()] = value.trim().toLowerCase(); 6507 } 6508 return acc; 6509 }, 6510 {} 6511 ); 6512 if (rules["mso-list"] === "ignore") { 6513 el.remove(); 6514 } 6515 } 6516 6517 // packages/blocks/build-module/api/raw-handling/ms-list-converter.mjs 6518 function isList2(node) { 6519 return node.nodeName === "OL" || node.nodeName === "UL"; 6520 } 6521 function msListConverter(node, doc) { 6522 if (node.nodeName !== "P") { 6523 return; 6524 } 6525 const element = node; 6526 const style = element.getAttribute("style"); 6527 if (!style || !style.includes("mso-list")) { 6528 return; 6529 } 6530 const prevNode = element.previousElementSibling; 6531 if (!prevNode || !isList2(prevNode)) { 6532 const type = element.textContent.trim().slice(0, 1); 6533 const isNumeric = /[1iIaA]/.test(type); 6534 const newListNode = doc.createElement(isNumeric ? "ol" : "ul"); 6535 if (isNumeric) { 6536 newListNode.setAttribute("type", type); 6537 } 6538 element.parentNode.insertBefore(newListNode, element); 6539 } 6540 const listNode = element.previousElementSibling; 6541 const listType = listNode.nodeName; 6542 const listItem = doc.createElement("li"); 6543 let receivingNode = listNode; 6544 listItem.innerHTML = deepFilterHTML(element.innerHTML, [msListIgnore]); 6545 const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style); 6546 let level = matches ? parseInt(matches[1], 10) - 1 || 0 : 0; 6547 while (level--) { 6548 receivingNode = receivingNode.lastChild || receivingNode; 6549 if (isList2(receivingNode)) { 6550 receivingNode = receivingNode.lastChild || receivingNode; 6551 } 6552 } 6553 if (!isList2(receivingNode)) { 6554 receivingNode = receivingNode.appendChild( 6555 doc.createElement(listType) 6556 ); 6557 } 6558 receivingNode.appendChild(listItem); 6559 element.parentNode.removeChild(element); 6560 } 6561 6562 // packages/blocks/build-module/api/raw-handling/image-corrector.mjs 6563 var import_blob = __toESM(require_blob(), 1); 6564 function imageCorrector(img) { 6565 if (img.nodeName !== "IMG") { 6566 return; 6567 } 6568 const node = img; 6569 if (node.src.indexOf("file:") === 0) { 6570 node.src = ""; 6571 } 6572 if (node.src.indexOf("data:") === 0) { 6573 const [properties, data] = node.src.split(","); 6574 const [type] = properties.slice(5).split(";"); 6575 if (!data || !type) { 6576 node.src = ""; 6577 return; 6578 } 6579 let decoded; 6580 try { 6581 decoded = atob(data); 6582 } catch { 6583 node.src = ""; 6584 return; 6585 } 6586 const uint8Array = new Uint8Array(decoded.length); 6587 for (let i = 0; i < uint8Array.length; i++) { 6588 uint8Array[i] = decoded.charCodeAt(i); 6589 } 6590 const name = type.replace("/", "."); 6591 const file = new window.File([uint8Array], name, { type }); 6592 node.src = (0, import_blob.createBlobURL)(file); 6593 } 6594 if (node.height === 1 || node.width === 1) { 6595 node.parentNode.removeChild(node); 6596 } 6597 } 6598 6599 // packages/blocks/build-module/api/raw-handling/div-normaliser.mjs 6600 function divNormaliser(div) { 6601 if (div.nodeName !== "DIV") { 6602 return; 6603 } 6604 const node = div; 6605 node.innerHTML = normaliseBlocks(node.innerHTML); 6606 } 6607 6608 // node_modules/marked/lib/marked.esm.js 6609 function A2() { 6610 return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null }; 6611 } 6612 var T = A2(); 6613 function U(l4) { 6614 T = l4; 6615 } 6616 var E2 = { exec: () => null }; 6617 function I(l4) { 6618 let e2 = []; 6619 return (t2) => { 6620 let n = Math.max(0, Math.min(3, t2 - 1)), i = e2[n]; 6621 return i || (i = l4(n), e2[n] = i), i; 6622 }; 6623 } 6624 function d(l4, e2 = "") { 6625 let t2 = typeof l4 == "string" ? l4 : l4.source, n = { replace: (i, r2) => { 6626 let o2 = typeof r2 == "string" ? r2 : r2.source; 6627 return o2 = o2.replace(m2.caret, "$1"), t2 = t2.replace(i, o2), n; 6628 }, getRegex: () => new RegExp(t2, e2) }; 6629 return n; 6630 } 6631 var we = ((l4 = "") => { 6632 try { 6633 return !!new RegExp("(?<=1)(?<!1)" + l4); 6634 } catch { 6635 return false; 6636 } 6637 })(); 6638 var m2 = { codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, endingSpaceTabChar: /[ \t]$/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l4) => new RegExp(`^( {0,3}${l4})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: I((l4) => new RegExp(`^ {0,${l4}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: I((l4) => new RegExp(`^ {0,${l4}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)), fencesBeginRegex: I((l4) => new RegExp(`^ {0,${l4}}(?:\`\`\`|~~~)`)), headingBeginRegex: I((l4) => new RegExp(`^ {0,${l4}}#`)), htmlBeginRegex: I((l4) => new RegExp(`^ {0,${l4}}(?:</?(?:${H2})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`, "i")), blockquoteBeginRegex: I((l4) => new RegExp(`^ {0,${l4}}>`)) }; 6639 var ye = /^(?:[ \t]*(?:\n|$))+/; 6640 var Pe = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/; 6641 var Se = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/; 6642 var v2 = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/; 6643 var _e = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/; 6644 var K = / {0,3}(?:[*+-]|\d{1,9}[.)])/; 6645 var le = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/; 6646 var ue = d(le).replace(/bull/g, K).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(); 6647 var $e = d(le).replace(/bull/g, K).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(); 6648 var W = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/; 6649 var Le = /^[^\n]+/; 6650 var X = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/; 6651 var ze = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", X).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(); 6652 var Ee = d(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, K).getRegex(); 6653 var H2 = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul"; 6654 var J = /<!--(?:-?>|[\s\S]*?(?:-->|$))/; 6655 var Me = d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", J).replace("tag", H2).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(); 6656 var pe = (l4) => d(W).replace("hr", v2).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", l4).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H2).getRegex(); 6657 var Ae = pe(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/); 6658 var Ie = pe(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/); 6659 var Ce = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Ie).getRegex(); 6660 var V = { blockquote: Ce, code: Pe, def: ze, fences: Se, heading: _e, hr: v2, html: Me, lheading: ue, list: Ee, newline: ye, paragraph: Ae, table: E2, text: Le }; 6661 var ie = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", v2).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H2).getRegex(); 6662 var Be = { ...V, lheading: $e, table: ie, paragraph: d(W).replace("hr", v2).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ie).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H2).getRegex() }; 6663 var De = { ...V, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", J).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: E2, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(W).replace("hr", v2).replace("heading", ` *#{1,6} *[^ 6664 ]`).replace("lheading", ue).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }; 6665 var qe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/; 6666 var ve = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/; 6667 var ce = /^( {2,}|\\)\n(?!\s*$)[ \t]*/; 6668 var He = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/; 6669 var _ = /[\p{P}\p{S}]/u; 6670 var C2 = /[\s\p{P}\p{S}]/u; 6671 var Z = /[^\s\p{P}\p{S}]/u; 6672 var Ze = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, C2).getRegex(); 6673 var Ge = /[\p{Pi}\p{Ps}"']/u; 6674 var he = /(?!~)[\p{P}\p{S}]/u; 6675 var Qe = /(?!~)[\s\p{P}\p{S}]/u; 6676 var Ne = /(?:[^\s\p{P}\p{S}]|~)/u; 6677 var je = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", we ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(); 6678 var de = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/; 6679 var Ue = d(de, "u").replace(/punct/g, _).getRegex(); 6680 var Fe = d(de, "u").replace(/punct/g, he).getRegex(); 6681 var Ke = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/; 6682 var We = d(Ke, "u").replace(/openQuote/g, Ge).replace(/punct/g, _).getRegex(); 6683 var ke = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)"; 6684 var Xe = d(ke, "gu").replace(/notPunctSpace/g, Z).replace(/punctSpace/g, C2).replace(/punct/g, _).getRegex(); 6685 var Je = d(ke, "gu").replace(/notPunctSpace/g, Ne).replace(/punctSpace/g, Qe).replace(/punct/g, he).getRegex(); 6686 var Ve = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)"; 6687 var Ye = d(Ve, "gu").replace(/notPunctSpace/g, Z).replace(/punctSpace/g, C2).replace(/punct/g, _).getRegex(); 6688 var et = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, Z).replace(/punctSpace/g, C2).replace(/punct/g, _).getRegex(); 6689 var tt = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)"; 6690 var nt = d(tt, "gu").replace(/notPunctSpace/g, Z).replace(/punctSpace/g, C2).replace(/punct/g, _).getRegex(); 6691 var rt = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex(); 6692 var st = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)"; 6693 var it = d(st, "gu").replace(/notPunctSpace/g, Z).replace(/punctSpace/g, C2).replace(/punct/g, _).getRegex(); 6694 var ot = d(/\\(punct)/, "gu").replace(/punct/g, _).getRegex(); 6695 var at = d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(); 6696 var lt = d(J).replace("(?:-->|$)", "-->").getRegex(); 6697 var ut = d("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", lt).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(); 6698 var ge = /\[(?:\\[\s\S]|[^\[\]\\])*\]/; 6699 var N2 = d(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", ge).getRegex(); 6700 var pt = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", N2).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(); 6701 var ct = d(/^!?\[(label)\]\[(ref)\]/).replace("label", N2).replace("ref", X).getRegex(); 6702 var ht = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", X).getRegex(); 6703 var oe = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/; 6704 var dt = d(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", ge).getRegex(); 6705 var kt = d("reflink|nolink(?!\\()", "g").replace("reflink", d(/^!?\[(label)\]\[(ref)\]/).replace("label", dt).replace("ref", oe).getRegex()).replace("nolink", d(/^!?\[(ref)\](?:\[\])?/).replace("ref", oe).getRegex()).getRegex(); 6706 var ae = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/; 6707 var Y = { _backpedal: E2, anyPunctuation: ot, autolink: at, blockSkip: je, br: ce, code: ve, del: E2, delLDelim: E2, delRDelim: E2, emStrongLDelim: Ue, emStrongRDelimAst: Xe, emStrongRDelimUnd: et, escape: qe, link: pt, nolink: ht, punctuation: Ze, reflink: ct, reflinkSearch: kt, tag: ut, text: He, url: E2 }; 6708 var gt = { ...Y, emStrongLDelim: We, emStrongRDelimAst: Ye, emStrongRDelimUnd: nt, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", N2).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", N2).getRegex() }; 6709 var F = { ...Y, emStrongRDelimAst: Je, emStrongLDelim: Fe, delLDelim: rt, delRDelim: it, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ae).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ae).getRegex() }; 6710 var ft = { ...F, br: d(ce).replace("{2,}", "*").getRegex(), text: d(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }; 6711 var G = { normal: V, gfm: Be, pedantic: De }; 6712 var B = { normal: Y, gfm: F, breaks: ft, pedantic: gt }; 6713 var mt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }; 6714 var fe = (l4) => mt[l4]; 6715 function R2(l4, e2) { 6716 if (e2) { 6717 if (m2.escapeTest.test(l4)) return l4.replace(m2.escapeReplace, fe); 6718 } else if (m2.escapeTestNoEncode.test(l4)) return l4.replace(m2.escapeReplaceNoEncode, fe); 6719 return l4; 6720 } 6721 function ee(l4) { 6722 try { 6723 l4 = encodeURI(l4).replace(m2.percentDecode, "%"); 6724 } catch { 6725 return null; 6726 } 6727 return l4; 6728 } 6729 function te(l4, e2) { 6730 let t2 = l4.replace(m2.findPipe, (r2, o2, s) => { 6731 let u = false, a = o2; 6732 for (; --a >= 0 && s[a] === "\\"; ) u = !u; 6733 return u ? "|" : " |"; 6734 }), n = t2.split(m2.splitPipe), i = 0; 6735 if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e2) if (n.length > e2) n.splice(e2); 6736 else for (; n.length < e2; ) n.push(""); 6737 for (; i < n.length; i++) n[i] = n[i].trim().replace(m2.slashPipe, "|"); 6738 return n; 6739 } 6740 function $2(l4, e2, t2) { 6741 let n = l4.length; 6742 if (n === 0) return ""; 6743 let i = 0; 6744 for (; i < n; ) { 6745 let r2 = l4.charAt(n - i - 1); 6746 if (r2 === e2 && !t2) i++; 6747 else if (r2 !== e2 && t2) i++; 6748 else break; 6749 } 6750 return l4.slice(0, n - i); 6751 } 6752 function ne(l4) { 6753 let e2 = l4.split(` 6754 `), t2 = e2.length - 1; 6755 for (; t2 >= 0 && m2.blankLine.test(e2[t2]); ) t2--; 6756 return e2.length - t2 <= 2 ? l4 : e2.slice(0, t2 + 1).join(` 6757 `); 6758 } 6759 function D2(l4) { 6760 return l4.toLowerCase().toUpperCase().toLowerCase(); 6761 } 6762 function me(l4, e2) { 6763 if (l4.indexOf(e2[1]) === -1) return -1; 6764 let t2 = 0; 6765 for (let n = 0; n < l4.length; n++) if (l4[n] === "\\") n++; 6766 else if (l4[n] === e2[0]) t2++; 6767 else if (l4[n] === e2[1] && (t2--, t2 < 0)) return n; 6768 return t2 > 0 ? -2 : -1; 6769 } 6770 function xe(l4, e2 = 0) { 6771 let t2 = e2, n = ""; 6772 for (let i of l4) if (i === " ") { 6773 let r2 = 4 - t2 % 4; 6774 n += " ".repeat(r2), t2 += r2; 6775 } else n += i, t2++; 6776 return n; 6777 } 6778 function be(l4, e2, t2, n, i) { 6779 let r2 = e2.href, o2 = e2.title || null, s = l4[1].replace(i.other.outputLinkReplace, "$1"), u = l4[0].charAt(0) === "!"; 6780 n.state.inLink = true; 6781 let a = n.state.linkEmitted, p2 = n.state.inRawBlock; 6782 n.state.linkEmitted = false; 6783 let c2 = n.inlineTokens(s), h = n.state.linkEmitted; 6784 if (n.state.linkEmitted = a, n.state.inLink = false, !u) { 6785 if (h) { 6786 n.state.inRawBlock = p2; 6787 return; 6788 } 6789 n.state.linkEmitted = true; 6790 } 6791 return { type: u ? "image" : "link", raw: t2, href: r2, title: o2, text: s, tokens: c2 }; 6792 } 6793 function xt(l4, e2, t2) { 6794 let n = l4.match(t2.other.indentCodeCompensation); 6795 if (n === null) return e2; 6796 let i = n[1]; 6797 return e2.split(` 6798 `).map((r2) => { 6799 let o2 = r2.match(t2.other.beginningSpace); 6800 if (o2 === null) return r2; 6801 let [s] = o2; 6802 return r2.slice(Math.min(s.length, i.length)); 6803 }).join(` 6804 `); 6805 } 6806 function Re(l4, e2, t2, n) { 6807 if (!e2.includes("<")) return false; 6808 for (let i = 0; i < e2.length; i++) { 6809 if (e2[i] === "\\") { 6810 i++; 6811 continue; 6812 } 6813 if (e2[i] === "`") { 6814 let s = n.inline.code.exec(e2.slice(i)); 6815 if (s) { 6816 i += s[0].length - 1; 6817 continue; 6818 } 6819 } 6820 if (e2[i] !== "<") continue; 6821 let r2 = l4.slice(t2 + i), o2 = n.inline.tag.exec(r2) || n.inline.autolink.exec(r2); 6822 if (o2) { 6823 if (o2[0].length > e2.length - i) return true; 6824 i += o2[0].length - 1; 6825 } 6826 } 6827 return false; 6828 } 6829 var y2 = class { 6830 options; 6831 rules; 6832 lexer; 6833 constructor(e2) { 6834 this.options = e2 || T; 6835 } 6836 space(e2) { 6837 let t2 = this.rules.block.newline.exec(e2); 6838 if (t2 && t2[0].length > 0) return { type: "space", raw: t2[0] }; 6839 } 6840 code(e2) { 6841 let t2 = this.rules.block.code.exec(e2); 6842 if (t2) { 6843 let n = this.options.pedantic ? t2[0] : ne(t2[0]), i = n.replace(this.rules.other.codeRemoveIndent, ""); 6844 return { type: "code", raw: n, codeBlockStyle: "indented", text: i }; 6845 } 6846 } 6847 fences(e2) { 6848 let t2 = this.rules.block.fences.exec(e2); 6849 if (t2) { 6850 let n = t2[0], i = xt(n, t2[3] || "", this.rules); 6851 return { type: "code", raw: n, lang: t2[2] ? t2[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t2[2], text: i }; 6852 } 6853 } 6854 heading(e2) { 6855 let t2 = this.rules.block.heading.exec(e2); 6856 if (t2) { 6857 let n = t2[2].trim(); 6858 if (this.rules.other.endingHash.test(n)) { 6859 let i = $2(n, "#"); 6860 (this.options.pedantic || !i || this.rules.other.endingSpaceTabChar.test(i)) && (n = i.trim()); 6861 } 6862 return { type: "heading", raw: $2(t2[0], ` 6863 `), depth: t2[1].length, text: n, tokens: this.lexer.inline(n) }; 6864 } 6865 } 6866 hr(e2) { 6867 let t2 = this.rules.block.hr.exec(e2); 6868 if (t2) return { type: "hr", raw: $2(t2[0], ` 6869 `) }; 6870 } 6871 blockquote(e2) { 6872 let t2 = this.rules.block.blockquote.exec(e2); 6873 if (t2) { 6874 let n = $2(t2[0], ` 6875 `).split(` 6876 `), i = "", r2 = "", o2 = []; 6877 for (; n.length > 0; ) { 6878 let s = false, u = [], a; 6879 for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) u.push(n[a]), s = true; 6880 else if (!s) u.push(n[a]); 6881 else break; 6882 n = n.slice(a); 6883 let p2 = u.join(` 6884 `), c2 = p2.replace(this.rules.other.blockquoteSetextReplace, ` 6885 $1`).replace(this.rules.other.blockquoteSetextReplace2, ""); 6886 i = i ? `$i} 6887 $p2}` : p2, r2 = r2 ? `$r2} 6888 $c2}` : c2; 6889 let h = this.lexer.state.top; 6890 if (this.lexer.state.top = true, this.lexer.blockTokens(c2, o2, true), this.lexer.state.top = h, n.length === 0) break; 6891 let k2 = o2.at(-1); 6892 if (k2?.type === "code") break; 6893 if (k2?.type === "blockquote") { 6894 let O = k2, g2 = n.join(` 6895 `), w2 = O.raw + ` 6896 ` + g2.replace(this.rules.other.blockquoteSetextReplace2, ""), z = this.blockquote(w2); 6897 o2[o2.length - 1] = z, i = `$i} 6898 $g2}`, r2 = r2.substring(0, r2.length - O.text.length) + z.text; 6899 break; 6900 } else if (k2?.type === "list") { 6901 let O = k2, g2 = O.raw + ` 6902 ` + n.join(` 6903 `), w2 = this.list(g2); 6904 o2[o2.length - 1] = w2, i = i.substring(0, i.length - k2.raw.length) + w2.raw, r2 = r2.substring(0, r2.length - O.raw.length) + w2.raw, n = g2.substring(o2.at(-1).raw.length).split(` 6905 `); 6906 continue; 6907 } 6908 } 6909 return { type: "blockquote", raw: i, tokens: o2, text: r2 }; 6910 } 6911 } 6912 list(e2) { 6913 let t2 = this.rules.block.list.exec(e2); 6914 if (t2) { 6915 let n = t2[1].trim(), i = n.length > 1, r2 = { type: "list", raw: "", ordered: i, start: i ? +n.slice(0, -1) : "", loose: false, items: [] }; 6916 n = i ? `\\d{1,9}\\$n.slice(-1)}` : `\\$n}`, this.options.pedantic && (n = i ? n : "[*+-]"); 6917 let o2 = this.rules.other.listItemRegex(n), s = false; 6918 for (; e2; ) { 6919 let a = false, p2 = "", c2 = ""; 6920 if (!(t2 = o2.exec(e2)) || this.rules.block.hr.test(e2)) break; 6921 p2 = t2[0], e2 = e2.substring(p2.length); 6922 let h = xe(t2[2].split(` 6923 `, 1)[0], t2[1].length), k2 = e2.split(` 6924 `, 1)[0], O = !h.trim(), g2 = 0; 6925 if (this.options.pedantic ? (g2 = 2, c2 = h.trimStart()) : O ? g2 = t2[1].length + 1 : (g2 = h.search(this.rules.other.nonSpaceChar), g2 = g2 > 4 ? 1 : g2, c2 = h.slice(g2), g2 += t2[1].length), O && this.rules.other.blankLine.test(k2) && (p2 += k2 + ` 6926 `, e2 = e2.substring(k2.length + 1), a = true), !a) { 6927 let w2 = this.rules.other.nextBulletRegex(g2), z = this.rules.other.hrRegex(g2), re = this.rules.other.fencesBeginRegex(g2), se = this.rules.other.headingBeginRegex(g2), Te = this.rules.other.htmlBeginRegex(g2), Oe = this.rules.other.blockquoteBeginRegex(g2); 6928 for (; e2; ) { 6929 let j2 = e2.split(` 6930 `, 1)[0], q2; 6931 if (k2 = j2, this.options.pedantic ? (k2 = k2.replace(this.rules.other.listReplaceNesting, " "), q2 = k2) : q2 = k2.replace(this.rules.other.tabCharGlobal, " "), re.test(k2) || se.test(k2) || Te.test(k2) || Oe.test(k2) || w2.test(k2) || z.test(k2)) break; 6932 if (q2.search(this.rules.other.nonSpaceChar) >= g2 || !k2.trim()) c2 += ` 6933 ` + q2.slice(g2); 6934 else { 6935 if (O || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || re.test(h) || se.test(h) || z.test(h)) break; 6936 c2 += ` 6937 ` + k2; 6938 } 6939 O = !k2.trim(), p2 += j2 + ` 6940 `, e2 = e2.substring(j2.length + 1), h = q2.slice(g2); 6941 } 6942 } 6943 r2.loose || (s ? r2.loose = true : this.rules.other.doubleBlankLine.test(p2) && (s = true)), r2.items.push({ type: "list_item", raw: p2, task: !!this.options.gfm && this.rules.other.listIsTask.test(c2), loose: false, text: c2, tokens: [] }), r2.raw += p2; 6944 } 6945 let u = r2.items.at(-1); 6946 if (u) u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd(); 6947 else return; 6948 r2.raw = r2.raw.trimEnd(); 6949 for (let a of r2.items) if (this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []), !r2.loose) { 6950 let p2 = a.tokens.filter((h) => h.type === "space"), c2 = p2.length > 0 && p2.some((h) => this.rules.other.anyLine.test(h.raw)); 6951 r2.loose = c2; 6952 } 6953 for (let a of r2.items) { 6954 let p2 = a.tokens[0]; 6955 if (a.task && (p2?.type === "text" || p2?.type === "paragraph")) { 6956 a.text = a.text.replace(this.rules.other.listReplaceTask, ""), p2.raw = p2.raw.replace(this.rules.other.listReplaceTask, ""), p2.text = p2.text.replace(this.rules.other.listReplaceTask, ""); 6957 for (let h = this.lexer.inlineQueue.length - 1; h >= 0; h--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)) { 6958 this.lexer.inlineQueue[h].src = this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask, ""); 6959 break; 6960 } 6961 let c2 = this.rules.other.listTaskCheckbox.exec(a.raw); 6962 if (c2) { 6963 let h = { type: "checkbox", raw: c2[0] + " ", checked: c2[0] !== "[ ]" }; 6964 a.checked = h.checked, r2.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = h.raw + a.tokens[0].raw, a.tokens[0].text = h.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(h)) : a.tokens.unshift({ type: "paragraph", raw: h.raw, text: h.raw, tokens: [h] }) : a.tokens.unshift(h); 6965 } 6966 } else a.task && (a.task = false); 6967 } 6968 if (r2.loose) for (let a of r2.items) { 6969 a.loose = true; 6970 for (let p2 of a.tokens) p2.type === "text" && (p2.type = "paragraph"); 6971 } 6972 return r2; 6973 } 6974 } 6975 html(e2) { 6976 let t2 = this.rules.block.html.exec(e2); 6977 if (t2) { 6978 let n = ne(t2[0]); 6979 return { type: "html", block: true, raw: n, pre: t2[1] === "pre" || t2[1] === "script" || t2[1] === "style", text: n }; 6980 } 6981 } 6982 def(e2) { 6983 let t2 = this.rules.block.def.exec(e2); 6984 if (t2) { 6985 let n = D2(t2[1]).replace(this.rules.other.multipleSpaceGlobal, " "), i = t2[2] ? t2[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r2 = t2[3] ? t2[3].substring(1, t2[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t2[3]; 6986 return { type: "def", tag: n, raw: $2(t2[0], ` 6987 `), href: i, title: r2 }; 6988 } 6989 } 6990 table(e2) { 6991 let t2 = this.rules.block.table.exec(e2); 6992 if (!t2 || !this.rules.other.tableDelimiter.test(t2[2])) return; 6993 let n = te(t2[1]), i = t2[2].replace(this.rules.other.tableAlignChars, "").split("|"), r2 = t2[3]?.trim() ? t2[3].replace(this.rules.other.tableRowBlankLine, "").split(` 6994 `) : [], o2 = { type: "table", raw: $2(t2[0], ` 6995 `), header: [], align: [], rows: [] }; 6996 if (n.length === i.length) { 6997 for (let s of i) this.rules.other.tableAlignRight.test(s) ? o2.align.push("right") : this.rules.other.tableAlignCenter.test(s) ? o2.align.push("center") : this.rules.other.tableAlignLeft.test(s) ? o2.align.push("left") : o2.align.push(null); 6998 for (let s = 0; s < n.length; s++) o2.header.push({ text: n[s], tokens: this.lexer.inline(n[s]), header: true, align: o2.align[s] }); 6999 for (let s of r2) o2.rows.push(te(s, o2.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: o2.align[a] }))); 7000 return o2; 7001 } 7002 } 7003 lheading(e2) { 7004 let t2 = this.rules.block.lheading.exec(e2); 7005 if (t2) { 7006 let n = t2[1].trim(); 7007 return { type: "heading", raw: $2(t2[0], ` 7008 `), depth: t2[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) }; 7009 } 7010 } 7011 paragraph(e2) { 7012 let t2 = this.rules.block.paragraph.exec(e2); 7013 if (t2) { 7014 let n = t2[1].charAt(t2[1].length - 1) === ` 7015 ` ? t2[1].slice(0, -1) : t2[1]; 7016 return { type: "paragraph", raw: t2[0], text: n, tokens: this.lexer.inline(n) }; 7017 } 7018 } 7019 text(e2) { 7020 let t2 = this.rules.block.text.exec(e2); 7021 if (t2) return { type: "text", raw: t2[0], text: t2[0], tokens: this.lexer.inline(t2[0]) }; 7022 } 7023 escape(e2) { 7024 let t2 = this.rules.inline.escape.exec(e2); 7025 if (t2) return { type: "escape", raw: t2[0], text: t2[1] }; 7026 } 7027 tag(e2) { 7028 let t2 = this.rules.inline.tag.exec(e2); 7029 if (t2) return !this.lexer.state.inLink && this.rules.other.startATag.test(t2[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t2[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t2[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t2[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t2[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t2[0] }; 7030 } 7031 link(e2) { 7032 let t2 = this.rules.inline.link.exec(e2); 7033 if (t2) { 7034 let n = t2[0].charAt(0) === "!" ? 2 : 1; 7035 if (!this.options.pedantic && Re(e2, t2[1], n, this.rules)) return; 7036 let i = t2[2].trim(); 7037 if (!this.options.pedantic && this.rules.other.startAngleBracket.test(i)) { 7038 if (!this.rules.other.endAngleBracket.test(i)) return; 7039 let s = $2(i.slice(0, -1), "\\"); 7040 if ((i.length - s.length) % 2 === 0) return; 7041 } else { 7042 let s = me(t2[2], "()"); 7043 if (s === -2) return; 7044 if (s > -1) { 7045 let a = (t2[0].indexOf("!") === 0 ? 5 : 4) + t2[1].length + s; 7046 t2[2] = t2[2].substring(0, s), t2[0] = t2[0].substring(0, a).trim(), t2[3] = ""; 7047 } 7048 } 7049 let r2 = t2[2], o2 = ""; 7050 if (this.options.pedantic) { 7051 let s = this.rules.other.pedanticHrefTitle.exec(r2); 7052 s && (r2 = s[1], o2 = s[3]); 7053 } else o2 = t2[3] ? t2[3].slice(1, -1) : ""; 7054 return r2 = r2.trim(), this.rules.other.startAngleBracket.test(r2) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(i) ? r2 = r2.slice(1) : r2 = r2.slice(1, -1)), be(t2, { href: r2 && r2.replace(this.rules.inline.anyPunctuation, "$1"), title: o2 && o2.replace(this.rules.inline.anyPunctuation, "$1") }, t2[0], this.lexer, this.rules); 7055 } 7056 } 7057 reflink(e2, t2) { 7058 let n; 7059 if ((n = this.rules.inline.reflink.exec(e2)) || (n = this.rules.inline.nolink.exec(e2))) { 7060 let i = n[0].charAt(0) === "!" ? 2 : 1; 7061 if (!this.options.pedantic && Re(e2, n[1], i, this.rules)) return; 7062 let r2 = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), o2 = t2[D2(r2)]; 7063 if (!o2) { 7064 let s = n[0].charAt(0); 7065 return { type: "text", raw: s, text: s }; 7066 } 7067 return be(n, o2, n[0], this.lexer, this.rules); 7068 } 7069 } 7070 emStrong(e2, t2, n = "") { 7071 let i = this.rules.inline.emStrongLDelim.exec(e2); 7072 if (!i || !i[1] && !i[2] && !i[3] && !i[4] || i[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return; 7073 if (!(i[1] || i[3] || "") || !n || this.rules.inline.punctuation.exec(n)) { 7074 let o2 = [...i[0]].length - 1, s, u, a = o2, p2 = 0, c2 = i[0][0], h = n === c2, k2 = c2 === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd; 7075 for (k2.lastIndex = 0, t2 = t2.slice(-1 * e2.length + o2); (i = k2.exec(t2)) !== null; ) { 7076 if (s = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !s) continue; 7077 if (u = [...s].length, i[3] || i[4]) { 7078 a += u; 7079 continue; 7080 } else if (i[5] || i[6]) { 7081 if (o2 % 3 && !((o2 + u) % 3)) { 7082 p2 += u; 7083 continue; 7084 } 7085 if (h) break; 7086 } 7087 if (a -= u, a > 0) continue; 7088 u = Math.min(u, u + a + p2); 7089 let O = [...i[0]][0].length, g2 = e2.slice(0, o2 + i.index + O + u); 7090 if (Math.min(o2, u) % 2) { 7091 let z = g2.slice(1, -1); 7092 return { type: "em", raw: g2, text: z, tokens: this.lexer.inlineTokens(z) }; 7093 } 7094 let w2 = g2.slice(2, -2); 7095 return { type: "strong", raw: g2, text: w2, tokens: this.lexer.inlineTokens(w2) }; 7096 } 7097 } 7098 } 7099 codespan(e2) { 7100 let t2 = this.rules.inline.code.exec(e2); 7101 if (t2) { 7102 let n = t2[2].replace(this.rules.other.newLineCharGlobal, " "), i = this.rules.other.nonSpaceChar.test(n), r2 = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n); 7103 return i && r2 && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t2[0], text: n }; 7104 } 7105 } 7106 br(e2) { 7107 let t2 = this.rules.inline.br.exec(e2); 7108 if (t2) return { type: "br", raw: t2[0] }; 7109 } 7110 del(e2, t2, n = "") { 7111 let i = this.rules.inline.delLDelim.exec(e2); 7112 if (!i) return; 7113 if (!(i[1] || "") || !n || this.rules.inline.punctuation.exec(n)) { 7114 let o2 = [...i[0]].length - 1, s, u, a = o2, p2 = this.rules.inline.delRDelim; 7115 for (p2.lastIndex = 0, t2 = t2.slice(-1 * e2.length + o2); (i = p2.exec(t2)) !== null; ) { 7116 if (s = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !s || (u = [...s].length, u !== o2)) continue; 7117 if (i[3] || i[4]) { 7118 a += u; 7119 continue; 7120 } 7121 if (a -= u, a > 0) continue; 7122 u = Math.min(u, u + a); 7123 let c2 = [...i[0]][0].length, h = e2.slice(0, o2 + i.index + c2 + u), k2 = h.slice(o2, -o2); 7124 return { type: "del", raw: h, text: k2, tokens: this.lexer.inlineTokens(k2) }; 7125 } 7126 } 7127 } 7128 autolink(e2) { 7129 let t2 = this.rules.inline.autolink.exec(e2); 7130 if (t2) { 7131 let n, i; 7132 return t2[2] === "@" ? (n = t2[1], i = "mailto:" + n) : (n = t2[1], i = n), { type: "link", raw: t2[0], text: n, href: i, autolink: true, tokens: [{ type: "text", raw: n, text: n }] }; 7133 } 7134 } 7135 url(e2) { 7136 let t2; 7137 if (t2 = this.rules.inline.url.exec(e2)) { 7138 let n, i; 7139 if (t2[2] === "@") n = t2[0], i = "mailto:" + n; 7140 else { 7141 let r2; 7142 do 7143 r2 = t2[0], t2[0] = this.rules.inline._backpedal.exec(t2[0])?.[0] ?? ""; 7144 while (r2 !== t2[0]); 7145 n = t2[0], t2[1] === "www." ? i = "http://" + t2[0] : i = t2[0]; 7146 } 7147 return { type: "link", raw: t2[0], text: n, href: i, autolink: true, tokens: [{ type: "text", raw: n, text: n }] }; 7148 } 7149 } 7150 inlineText(e2) { 7151 let t2 = this.rules.inline.text.exec(e2); 7152 if (t2) { 7153 let n = this.lexer.state.inRawBlock; 7154 return { type: "text", raw: t2[0], text: t2[0], escaped: n }; 7155 } 7156 } 7157 }; 7158 var x2 = class l2 { 7159 tokens; 7160 options; 7161 state; 7162 inlineQueue; 7163 tokenizer; 7164 constructor(e2) { 7165 this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e2 || T, this.options.tokenizer = this.options.tokenizer || new y2(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, top: true }; 7166 let t2 = { other: m2, block: G.normal, inline: B.normal }; 7167 this.options.pedantic ? (t2.block = G.pedantic, t2.inline = B.pedantic) : this.options.gfm && (t2.block = G.gfm, this.options.breaks ? t2.inline = B.breaks : t2.inline = B.gfm), this.tokenizer.rules = t2; 7168 } 7169 static get rules() { 7170 return { block: G, inline: B }; 7171 } 7172 static lex(e2, t2) { 7173 return new l2(t2).lex(e2); 7174 } 7175 static lexInline(e2, t2) { 7176 return new l2(t2).inlineTokens(e2); 7177 } 7178 lex(e2) { 7179 e2 = e2.replace(m2.carriageReturn, ` 7180 `), this.blockTokens(e2, this.tokens); 7181 for (let t2 = 0; t2 < this.inlineQueue.length; t2++) { 7182 let n = this.inlineQueue[t2]; 7183 this.inlineTokens(n.src, n.tokens); 7184 } 7185 return this.inlineQueue = [], this.tokens; 7186 } 7187 blockTokens(e2, t2 = [], n = false) { 7188 this.tokenizer.lexer = this, this.options.pedantic && (e2 = e2.replace(m2.tabCharGlobal, " ").replace(m2.spaceLine, "")); 7189 let i = 1 / 0; 7190 for (; e2; ) { 7191 if (e2.length < i) i = e2.length; 7192 else { 7193 this.infiniteLoopError(e2.charCodeAt(0)); 7194 break; 7195 } 7196 let r2; 7197 if (this.options.extensions?.block?.some((s) => (r2 = s.call({ lexer: this }, e2, t2)) ? (e2 = e2.substring(r2.raw.length), t2.push(r2), true) : false)) continue; 7198 if (r2 = this.tokenizer.space(e2)) { 7199 e2 = e2.substring(r2.raw.length); 7200 let s = t2.at(-1); 7201 r2.raw.length === 1 && s !== void 0 ? s.raw += ` 7202 ` : t2.push(r2); 7203 continue; 7204 } 7205 if (r2 = this.tokenizer.code(e2)) { 7206 e2 = e2.substring(r2.raw.length); 7207 let s = t2.at(-1); 7208 s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(` 7209 `) ? "" : ` 7210 `) + r2.raw, s.text += ` 7211 ` + r2.text, this.inlineQueue.at(-1).src = s.text) : t2.push(r2); 7212 continue; 7213 } 7214 if (r2 = this.tokenizer.fences(e2)) { 7215 e2 = e2.substring(r2.raw.length), t2.push(r2); 7216 continue; 7217 } 7218 if (r2 = this.tokenizer.heading(e2)) { 7219 e2 = e2.substring(r2.raw.length), t2.push(r2); 7220 continue; 7221 } 7222 if (r2 = this.tokenizer.hr(e2)) { 7223 e2 = e2.substring(r2.raw.length), t2.push(r2); 7224 continue; 7225 } 7226 if (r2 = this.tokenizer.blockquote(e2)) { 7227 e2 = e2.substring(r2.raw.length), t2.push(r2); 7228 continue; 7229 } 7230 if (r2 = this.tokenizer.list(e2)) { 7231 e2 = e2.substring(r2.raw.length), t2.push(r2); 7232 continue; 7233 } 7234 if (r2 = this.tokenizer.html(e2)) { 7235 e2 = e2.substring(r2.raw.length), t2.push(r2); 7236 continue; 7237 } 7238 if (r2 = this.tokenizer.def(e2)) { 7239 e2 = e2.substring(r2.raw.length); 7240 let s = t2.at(-1); 7241 s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(` 7242 `) ? "" : ` 7243 `) + r2.raw, s.text += ` 7244 ` + r2.raw, this.inlineQueue.at(-1).src = s.text) : this.tokens.links[r2.tag] || (this.tokens.links[r2.tag] = { href: r2.href, title: r2.title }, t2.push(r2)); 7245 continue; 7246 } 7247 if (r2 = this.tokenizer.table(e2)) { 7248 e2 = e2.substring(r2.raw.length), t2.push(r2); 7249 continue; 7250 } 7251 if (r2 = this.tokenizer.lheading(e2)) { 7252 e2 = e2.substring(r2.raw.length), t2.push(r2); 7253 continue; 7254 } 7255 let o2 = e2; 7256 if (this.options.extensions?.startBlock) { 7257 let s = 1 / 0, u = e2.slice(1), a; 7258 this.options.extensions.startBlock.forEach((p2) => { 7259 a = p2.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (s = Math.min(s, a)); 7260 }), s < 1 / 0 && s >= 0 && (o2 = e2.substring(0, s + 1)); 7261 } 7262 if (this.state.top && (r2 = this.tokenizer.paragraph(o2))) { 7263 let s = t2.at(-1); 7264 n && s?.type === "paragraph" ? (s.raw += (s.raw.endsWith(` 7265 `) ? "" : ` 7266 `) + r2.raw, s.text += ` 7267 ` + r2.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t2.push(r2), n = o2.length !== e2.length, e2 = e2.substring(r2.raw.length); 7268 continue; 7269 } 7270 if (r2 = this.tokenizer.text(e2)) { 7271 e2 = e2.substring(r2.raw.length); 7272 let s = t2.at(-1); 7273 s?.type === "text" ? (s.raw += (s.raw.endsWith(` 7274 `) ? "" : ` 7275 `) + r2.raw, s.text += ` 7276 ` + r2.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t2.push(r2); 7277 continue; 7278 } 7279 if (e2) { 7280 this.infiniteLoopError(e2.charCodeAt(0)); 7281 break; 7282 } 7283 } 7284 return this.state.top = true, t2; 7285 } 7286 inline(e2, t2 = []) { 7287 return this.inlineQueue.push({ src: e2, tokens: t2 }), t2; 7288 } 7289 linkInText(e2) { 7290 if (!e2.includes("[")) return false; 7291 let t2 = this.tokenizer.rules.inline.link; 7292 for (let n of e2.matchAll(this.tokenizer.rules.inline.blockSkip)) if (t2.test(n[0]) && e2.charAt(n.index - 1) !== "!") return true; 7293 for (let n of e2.matchAll(this.tokenizer.rules.inline.reflinkSearch)) { 7294 let i = n[0], r2 = i.lastIndexOf("["); 7295 if (!(i.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, D2(i.slice(r2 + 1, -1)))) && !(r2 > 1 && this.linkInText(i.slice(1, r2 - 1)))) return true; 7296 } 7297 return false; 7298 } 7299 inlineTokens(e2, t2 = []) { 7300 this.tokenizer.lexer = this; 7301 let n = e2; 7302 if (this.tokens.links && e2.includes("[")) { 7303 let s = this.tokenizer.rules.inline.reflinkSearch, u = (a) => { 7304 let p2 = a.lastIndexOf("["); 7305 if (!Object.hasOwn(this.tokens.links, D2(a.slice(p2 + 1, -1)))) return a; 7306 if (p2 > 1 && a.charAt(0) !== "!") { 7307 let c2 = a.slice(1, p2 - 1); 7308 if (this.linkInText(c2)) return "[" + c2.replace(s, u) + "][" + "a".repeat(a.length - p2 - 2) + "]"; 7309 } 7310 return "[" + "a".repeat(a.length - 2) + "]"; 7311 }; 7312 n = n.replace(s, u); 7313 } 7314 n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (s) => "+".repeat(s.length)), n = n.replace(this.tokenizer.rules.inline.blockSkip, (s, u, a) => { 7315 let p2 = a ? a.length : 0; 7316 return s.slice(0, p2) + "[" + "a".repeat(s.length - p2 - 2) + "]"; 7317 }), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n; 7318 let i = false, r2 = "", o2 = 1 / 0; 7319 for (; e2; ) { 7320 if (e2.length < o2) o2 = e2.length; 7321 else { 7322 this.infiniteLoopError(e2.charCodeAt(0)); 7323 break; 7324 } 7325 i || (r2 = ""), i = false; 7326 let s; 7327 if (this.options.extensions?.inline?.some((a) => (s = a.call({ lexer: this }, e2, t2)) ? (e2 = e2.substring(s.raw.length), t2.push(s), true) : false)) continue; 7328 if (s = this.tokenizer.escape(e2)) { 7329 e2 = e2.substring(s.raw.length), t2.push(s); 7330 continue; 7331 } 7332 if (s = this.tokenizer.tag(e2)) { 7333 e2 = e2.substring(s.raw.length), t2.push(s); 7334 continue; 7335 } 7336 if (s = this.tokenizer.link(e2)) { 7337 e2 = e2.substring(s.raw.length), t2.push(s); 7338 continue; 7339 } 7340 if (s = this.tokenizer.reflink(e2, this.tokens.links)) { 7341 e2 = e2.substring(s.raw.length); 7342 let a = t2.at(-1); 7343 s.type === "text" && a?.type === "text" ? (a.raw += s.raw, a.text += s.text) : t2.push(s); 7344 continue; 7345 } 7346 if (s = this.tokenizer.emStrong(e2, n, r2)) { 7347 e2 = e2.substring(s.raw.length), t2.push(s); 7348 continue; 7349 } 7350 if (s = this.tokenizer.codespan(e2)) { 7351 e2 = e2.substring(s.raw.length), t2.push(s); 7352 continue; 7353 } 7354 if (s = this.tokenizer.br(e2)) { 7355 e2 = e2.substring(s.raw.length), t2.push(s); 7356 continue; 7357 } 7358 if (s = this.tokenizer.del(e2, n, r2)) { 7359 e2 = e2.substring(s.raw.length), t2.push(s); 7360 continue; 7361 } 7362 if (s = this.tokenizer.autolink(e2)) { 7363 e2 = e2.substring(s.raw.length), t2.push(s); 7364 continue; 7365 } 7366 if (!this.state.inLink && (s = this.tokenizer.url(e2))) { 7367 e2 = e2.substring(s.raw.length), t2.push(s); 7368 continue; 7369 } 7370 let u = e2; 7371 if (this.options.extensions?.startInline) { 7372 let a = 1 / 0, p2 = e2.slice(1), c2; 7373 this.options.extensions.startInline.forEach((h) => { 7374 c2 = h.call({ lexer: this }, p2), typeof c2 == "number" && c2 >= 0 && (a = Math.min(a, c2)); 7375 }), a < 1 / 0 && a >= 0 && (u = e2.substring(0, a + 1)); 7376 } 7377 if (s = this.tokenizer.inlineText(u)) { 7378 e2 = e2.substring(s.raw.length), s.raw.slice(-1) !== "_" && (r2 = s.raw.slice(-1)), i = true; 7379 let a = t2.at(-1); 7380 a?.type === "text" ? (a.raw += s.raw, a.text += s.text) : t2.push(s); 7381 continue; 7382 } 7383 if (e2) { 7384 this.infiniteLoopError(e2.charCodeAt(0)); 7385 break; 7386 } 7387 } 7388 return t2; 7389 } 7390 infiniteLoopError(e2) { 7391 let t2 = "Infinite loop on byte: " + e2; 7392 if (this.options.silent) console.error(t2); 7393 else throw new Error(t2); 7394 } 7395 }; 7396 var P = class { 7397 options; 7398 parser; 7399 constructor(e2) { 7400 this.options = e2 || T; 7401 } 7402 space(e2) { 7403 return ""; 7404 } 7405 code({ text: e2, lang: t2, escaped: n }) { 7406 let i = (t2 || "").match(m2.notSpaceStart)?.[0], r2 = e2 ? e2.replace(m2.endingNewline, "") + ` 7407 ` : ""; 7408 return i ? '<pre><code class="language-' + R2(i) + '">' + (n ? r2 : R2(r2, true)) + `</code></pre> 7409 ` : "<pre><code>" + (n ? r2 : R2(r2, true)) + `</code></pre> 7410 `; 7411 } 7412 blockquote({ tokens: e2 }) { 7413 return `<blockquote> 7414 $this.parser.parse(e2)}</blockquote> 7415 `; 7416 } 7417 html({ text: e2 }) { 7418 return e2; 7419 } 7420 def(e2) { 7421 return ""; 7422 } 7423 heading({ tokens: e2, depth: t2 }) { 7424 return `<h$t2}>$this.parser.parseInline(e2)}</h$t2}> 7425 `; 7426 } 7427 hr(e2) { 7428 return `<hr> 7429 `; 7430 } 7431 list(e2) { 7432 let t2 = e2.ordered, n = e2.start, i = ""; 7433 for (let s = 0; s < e2.items.length; s++) { 7434 let u = e2.items[s]; 7435 i += this.listitem(u); 7436 } 7437 let r2 = t2 ? "ol" : "ul", o2 = t2 && n !== 1 ? ' start="' + n + '"' : ""; 7438 return "<" + r2 + o2 + `> 7439 ` + i + "</" + r2 + `> 7440 `; 7441 } 7442 listitem(e2) { 7443 return `<li>$this.parser.parse(e2.tokens)}</li> 7444 `; 7445 } 7446 checkbox({ checked: e2 }) { 7447 return "<input " + (e2 ? 'checked="" ' : "") + 'disabled="" type="checkbox"> '; 7448 } 7449 paragraph({ tokens: e2 }) { 7450 return `<p>$this.parser.parseInline(e2)}</p> 7451 `; 7452 } 7453 table(e2) { 7454 let t2 = "", n = ""; 7455 for (let r2 = 0; r2 < e2.header.length; r2++) n += this.tablecell(e2.header[r2]); 7456 t2 += this.tablerow({ text: n }); 7457 let i = ""; 7458 for (let r2 = 0; r2 < e2.rows.length; r2++) { 7459 let o2 = e2.rows[r2]; 7460 n = ""; 7461 for (let s = 0; s < o2.length; s++) n += this.tablecell(o2[s]); 7462 i += this.tablerow({ text: n }); 7463 } 7464 return i && (i = `<tbody>$i}</tbody>`), `<table> 7465 <thead> 7466 ` + t2 + `</thead> 7467 ` + i + `</table> 7468 `; 7469 } 7470 tablerow({ text: e2 }) { 7471 return `<tr> 7472 $e2}</tr> 7473 `; 7474 } 7475 tablecell(e2) { 7476 let t2 = this.parser.parseInline(e2.tokens), n = e2.header ? "th" : "td"; 7477 return (e2.align ? `<$n} align="$e2.align}">` : `<$n}>`) + t2 + `</$n}> 7478 `; 7479 } 7480 strong({ tokens: e2 }) { 7481 return `<strong>$this.parser.parseInline(e2)}</strong>`; 7482 } 7483 em({ tokens: e2 }) { 7484 return `<em>$this.parser.parseInline(e2)}</em>`; 7485 } 7486 codespan({ text: e2 }) { 7487 return `<code>$R2(e2, true)}</code>`; 7488 } 7489 br(e2) { 7490 return "<br>"; 7491 } 7492 del({ tokens: e2 }) { 7493 return `<del>$this.parser.parseInline(e2)}</del>`; 7494 } 7495 link({ href: e2, title: t2, text: n, tokens: i, autolink: r2 }) { 7496 let o2 = r2 ? R2(n, true) : this.parser.parseInline(i), s = ee(e2); 7497 if (s === null) return o2; 7498 e2 = R2(s, r2); 7499 let u = '<a href="' + e2 + '"'; 7500 return t2 && (u += ' title="' + R2(t2) + '"'), u += ">" + o2 + "</a>", u; 7501 } 7502 image({ href: e2, title: t2, text: n, tokens: i }) { 7503 i && (n = this.parser.parseInline(i, this.parser.textRenderer)); 7504 let r2 = ee(e2); 7505 if (r2 === null) return R2(n); 7506 e2 = r2; 7507 let o2 = `<img src="$R2(e2)}" alt="$R2(n)}"`; 7508 return t2 && (o2 += ` title="$R2(t2)}"`), o2 += ">", o2; 7509 } 7510 text(e2) { 7511 return "tokens" in e2 && e2.tokens ? this.parser.parseInline(e2.tokens) : "escaped" in e2 && e2.escaped ? e2.text : R2(e2.text); 7512 } 7513 }; 7514 var L = class { 7515 strong({ text: e2 }) { 7516 return e2; 7517 } 7518 em({ text: e2 }) { 7519 return e2; 7520 } 7521 codespan({ text: e2 }) { 7522 return e2; 7523 } 7524 del({ text: e2 }) { 7525 return e2; 7526 } 7527 html({ text: e2 }) { 7528 return e2; 7529 } 7530 text({ text: e2 }) { 7531 return e2; 7532 } 7533 link({ text: e2 }) { 7534 return "" + e2; 7535 } 7536 image({ text: e2 }) { 7537 return "" + e2; 7538 } 7539 br() { 7540 return ""; 7541 } 7542 checkbox({ raw: e2 }) { 7543 return e2; 7544 } 7545 }; 7546 var b = class l3 { 7547 options; 7548 renderer; 7549 textRenderer; 7550 constructor(e2) { 7551 this.options = e2 || T, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L(); 7552 } 7553 static parse(e2, t2) { 7554 return new l3(t2).parse(e2); 7555 } 7556 static parseInline(e2, t2) { 7557 return new l3(t2).parseInline(e2); 7558 } 7559 parse(e2) { 7560 this.renderer.parser = this; 7561 let t2 = ""; 7562 for (let n = 0; n < e2.length; n++) { 7563 let i = e2[n]; 7564 if (this.options.extensions?.renderers?.[i.type]) { 7565 let o2 = i, s = this.options.extensions.renderers[o2.type].call({ parser: this }, o2); 7566 if (s !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(o2.type)) { 7567 t2 += s || ""; 7568 continue; 7569 } 7570 } 7571 let r2 = i; 7572 switch (r2.type) { 7573 case "space": { 7574 t2 += this.renderer.space(r2); 7575 break; 7576 } 7577 case "hr": { 7578 t2 += this.renderer.hr(r2); 7579 break; 7580 } 7581 case "heading": { 7582 t2 += this.renderer.heading(r2); 7583 break; 7584 } 7585 case "code": { 7586 t2 += this.renderer.code(r2); 7587 break; 7588 } 7589 case "table": { 7590 t2 += this.renderer.table(r2); 7591 break; 7592 } 7593 case "blockquote": { 7594 t2 += this.renderer.blockquote(r2); 7595 break; 7596 } 7597 case "list": { 7598 t2 += this.renderer.list(r2); 7599 break; 7600 } 7601 case "checkbox": { 7602 t2 += this.renderer.checkbox(r2); 7603 break; 7604 } 7605 case "html": { 7606 t2 += this.renderer.html(r2); 7607 break; 7608 } 7609 case "def": { 7610 t2 += this.renderer.def(r2); 7611 break; 7612 } 7613 case "paragraph": { 7614 t2 += this.renderer.paragraph(r2); 7615 break; 7616 } 7617 case "text": { 7618 t2 += this.renderer.text(r2); 7619 break; 7620 } 7621 default: { 7622 let o2 = 'Token with "' + r2.type + '" type was not found.'; 7623 if (this.options.silent) return console.error(o2), ""; 7624 throw new Error(o2); 7625 } 7626 } 7627 } 7628 return t2; 7629 } 7630 parseInline(e2, t2 = this.renderer) { 7631 this.renderer.parser = this; 7632 let n = ""; 7633 for (let i = 0; i < e2.length; i++) { 7634 let r2 = e2[i]; 7635 if (this.options.extensions?.renderers?.[r2.type]) { 7636 let s = this.options.extensions.renderers[r2.type].call({ parser: this }, r2); 7637 if (s !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r2.type)) { 7638 n += s || ""; 7639 continue; 7640 } 7641 } 7642 let o2 = r2; 7643 switch (o2.type) { 7644 case "escape": { 7645 n += t2.text(o2); 7646 break; 7647 } 7648 case "html": { 7649 n += t2.html(o2); 7650 break; 7651 } 7652 case "link": { 7653 n += t2.link(o2); 7654 break; 7655 } 7656 case "image": { 7657 n += t2.image(o2); 7658 break; 7659 } 7660 case "checkbox": { 7661 n += t2.checkbox(o2); 7662 break; 7663 } 7664 case "strong": { 7665 n += t2.strong(o2); 7666 break; 7667 } 7668 case "em": { 7669 n += t2.em(o2); 7670 break; 7671 } 7672 case "codespan": { 7673 n += t2.codespan(o2); 7674 break; 7675 } 7676 case "br": { 7677 n += t2.br(o2); 7678 break; 7679 } 7680 case "del": { 7681 n += t2.del(o2); 7682 break; 7683 } 7684 case "text": { 7685 n += t2.text(o2); 7686 break; 7687 } 7688 default: { 7689 let s = 'Token with "' + o2.type + '" type was not found.'; 7690 if (this.options.silent) return console.error(s), ""; 7691 throw new Error(s); 7692 } 7693 } 7694 } 7695 return n; 7696 } 7697 }; 7698 var S = class { 7699 options; 7700 block; 7701 constructor(e2) { 7702 this.options = e2 || T; 7703 } 7704 static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]); 7705 static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]); 7706 preprocess(e2) { 7707 return e2; 7708 } 7709 postprocess(e2) { 7710 return e2; 7711 } 7712 processAllTokens(e2) { 7713 return e2; 7714 } 7715 emStrongMask(e2) { 7716 return e2; 7717 } 7718 provideLexer(e2 = this.block) { 7719 return e2 ? x2.lex : x2.lexInline; 7720 } 7721 provideParser(e2 = this.block) { 7722 return e2 ? b.parse : b.parseInline; 7723 } 7724 }; 7725 var Q = class { 7726 defaults = A2(); 7727 options = this.setOptions; 7728 parse = this.parseMarkdown(true); 7729 parseInline = this.parseMarkdown(false); 7730 Parser = b; 7731 Renderer = P; 7732 TextRenderer = L; 7733 Lexer = x2; 7734 Tokenizer = y2; 7735 Hooks = S; 7736 constructor(...e2) { 7737 this.use(...e2); 7738 } 7739 walkTokens(e2, t2) { 7740 let n = []; 7741 for (let i of e2) switch (n = n.concat(t2.call(this, i)), i.type) { 7742 case "table": { 7743 let r2 = i; 7744 for (let o2 of r2.header) n = n.concat(this.walkTokens(o2.tokens, t2)); 7745 for (let o2 of r2.rows) for (let s of o2) n = n.concat(this.walkTokens(s.tokens, t2)); 7746 break; 7747 } 7748 case "list": { 7749 let r2 = i; 7750 n = n.concat(this.walkTokens(r2.items, t2)); 7751 break; 7752 } 7753 default: { 7754 let r2 = i; 7755 this.defaults.extensions?.childTokens?.[r2.type] ? this.defaults.extensions.childTokens[r2.type].forEach((o2) => { 7756 let s = r2[o2].flat(1 / 0); 7757 n = n.concat(this.walkTokens(s, t2)); 7758 }) : r2.tokens && (n = n.concat(this.walkTokens(r2.tokens, t2))); 7759 } 7760 } 7761 return n; 7762 } 7763 use(...e2) { 7764 let t2 = this.defaults.extensions || { renderers: {}, childTokens: {} }; 7765 return e2.forEach((n) => { 7766 let i = { ...n }; 7767 if (i.async = this.defaults.async || i.async || false, n.extensions && (n.extensions.forEach((r2) => { 7768 if (!r2.name) throw new Error("extension name required"); 7769 if ("renderer" in r2) { 7770 let o2 = t2.renderers[r2.name]; 7771 o2 ? t2.renderers[r2.name] = function(...s) { 7772 let u = r2.renderer.apply(this, s); 7773 return u === false && (u = o2.apply(this, s)), u; 7774 } : t2.renderers[r2.name] = r2.renderer; 7775 } 7776 if ("tokenizer" in r2) { 7777 if (!r2.level || r2.level !== "block" && r2.level !== "inline") throw new Error("extension level must be 'block' or 'inline'"); 7778 let o2 = t2[r2.level]; 7779 o2 ? o2.unshift(r2.tokenizer) : t2[r2.level] = [r2.tokenizer], r2.start && (r2.level === "block" ? t2.startBlock ? t2.startBlock.push(r2.start) : t2.startBlock = [r2.start] : r2.level === "inline" && (t2.startInline ? t2.startInline.push(r2.start) : t2.startInline = [r2.start])); 7780 } 7781 "childTokens" in r2 && r2.childTokens && (t2.childTokens[r2.name] = r2.childTokens); 7782 }), i.extensions = t2), n.renderer) { 7783 let r2 = this.defaults.renderer || new P(this.defaults); 7784 for (let o2 in n.renderer) { 7785 if (!(o2 in r2)) throw new Error(`renderer '$o2}' does not exist`); 7786 if (["options", "parser"].includes(o2)) continue; 7787 let s = o2, u = n.renderer[s], a = r2[s]; 7788 r2[s] = (...p2) => { 7789 let c2 = u.apply(r2, p2); 7790 return c2 === false && (c2 = a.apply(r2, p2)), c2 || ""; 7791 }; 7792 } 7793 i.renderer = r2; 7794 } 7795 if (n.tokenizer) { 7796 let r2 = this.defaults.tokenizer || new y2(this.defaults); 7797 for (let o2 in n.tokenizer) { 7798 if (!(o2 in r2)) throw new Error(`tokenizer '$o2}' does not exist`); 7799 if (["options", "rules", "lexer"].includes(o2)) continue; 7800 let s = o2, u = n.tokenizer[s], a = r2[s]; 7801 r2[s] = (...p2) => { 7802 let c2 = u.apply(r2, p2); 7803 return c2 === false && (c2 = a.apply(r2, p2)), c2; 7804 }; 7805 } 7806 i.tokenizer = r2; 7807 } 7808 if (n.hooks) { 7809 let r2 = this.defaults.hooks || new S(); 7810 for (let o2 in n.hooks) { 7811 if (!(o2 in r2)) throw new Error(`hook '$o2}' does not exist`); 7812 if (["options", "block"].includes(o2)) continue; 7813 let s = o2, u = n.hooks[s], a = r2[s]; 7814 S.passThroughHooks.has(o2) ? r2[s] = (p2) => { 7815 if (this.defaults.async && S.passThroughHooksRespectAsync.has(o2)) return (async () => { 7816 let h = await u.call(r2, p2); 7817 return a.call(r2, h); 7818 })(); 7819 let c2 = u.call(r2, p2); 7820 return a.call(r2, c2); 7821 } : r2[s] = (...p2) => { 7822 if (this.defaults.async) return (async () => { 7823 let h = await u.apply(r2, p2); 7824 return h === false && (h = await a.apply(r2, p2)), h; 7825 })(); 7826 let c2 = u.apply(r2, p2); 7827 return c2 === false && (c2 = a.apply(r2, p2)), c2; 7828 }; 7829 } 7830 i.hooks = r2; 7831 } 7832 if (n.walkTokens) { 7833 let r2 = this.defaults.walkTokens, o2 = n.walkTokens; 7834 i.walkTokens = function(s) { 7835 let u = []; 7836 return u.push(o2.call(this, s)), r2 && (u = u.concat(r2.call(this, s))), u; 7837 }; 7838 } 7839 this.defaults = { ...this.defaults, ...i }; 7840 }), this; 7841 } 7842 setOptions(e2) { 7843 return this.defaults = { ...this.defaults, ...e2 }, this; 7844 } 7845 lexer(e2, t2) { 7846 return x2.lex(e2, t2 ?? this.defaults); 7847 } 7848 parser(e2, t2) { 7849 return b.parse(e2, t2 ?? this.defaults); 7850 } 7851 parseMarkdown(e2) { 7852 return (n, i) => { 7853 let r2 = { ...i }, o2 = { ...this.defaults, ...r2 }, s = this.onError(!!o2.silent, !!o2.async); 7854 if (this.defaults.async === true && r2.async === false) return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.")); 7855 if (typeof n > "u" || n === null) return s(new Error("marked(): input parameter is undefined or null")); 7856 if (typeof n != "string") return s(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected")); 7857 if (o2.hooks && (o2.hooks.options = o2, o2.hooks.block = e2), o2.async) return (async () => { 7858 let u = o2.hooks ? await o2.hooks.preprocess(n) : n, p2 = await (o2.hooks ? await o2.hooks.provideLexer(e2) : e2 ? x2.lex : x2.lexInline)(u, o2), c2 = o2.hooks ? await o2.hooks.processAllTokens(p2) : p2; 7859 o2.walkTokens && await Promise.all(this.walkTokens(c2, o2.walkTokens)); 7860 let k2 = await (o2.hooks ? await o2.hooks.provideParser(e2) : e2 ? b.parse : b.parseInline)(c2, o2); 7861 return o2.hooks ? await o2.hooks.postprocess(k2) : k2; 7862 })().catch(s); 7863 try { 7864 o2.hooks && (n = o2.hooks.preprocess(n)); 7865 let a = (o2.hooks ? o2.hooks.provideLexer(e2) : e2 ? x2.lex : x2.lexInline)(n, o2); 7866 o2.hooks && (a = o2.hooks.processAllTokens(a)), o2.walkTokens && this.walkTokens(a, o2.walkTokens); 7867 let c2 = (o2.hooks ? o2.hooks.provideParser(e2) : e2 ? b.parse : b.parseInline)(a, o2); 7868 return o2.hooks && (c2 = o2.hooks.postprocess(c2)), c2; 7869 } catch (u) { 7870 return s(u); 7871 } 7872 }; 7873 } 7874 onError(e2, t2) { 7875 return (n) => { 7876 if (n.message += ` 7877 Please report this to https://github.com/markedjs/marked.`, e2) { 7878 let i = "<p>An error occurred:</p><pre>" + R2(n.message + "", true) + "</pre>"; 7879 return t2 ? Promise.resolve(i) : i; 7880 } 7881 if (t2) return Promise.reject(n); 7882 throw n; 7883 }; 7884 } 7885 }; 7886 var M2 = new Q(); 7887 function f(l4, e2) { 7888 return M2.parse(l4, e2); 7889 } 7890 f.options = f.setOptions = function(l4) { 7891 return M2.setOptions(l4), f.defaults = M2.defaults, U(f.defaults), f; 7892 }; 7893 f.getDefaults = A2; 7894 f.defaults = T; 7895 function bt(...l4) { 7896 return M2.use(...l4), f.defaults = M2.defaults, U(f.defaults), f; 7897 } 7898 f.use = bt; 7899 f.walkTokens = function(l4, e2) { 7900 return M2.walkTokens(l4, e2); 7901 }; 7902 f.parseInline = M2.parseInline; 7903 f.Parser = b; 7904 f.parser = b.parse; 7905 f.Renderer = P; 7906 f.TextRenderer = L; 7907 f.Lexer = x2; 7908 f.lexer = x2.lex; 7909 f.Tokenizer = y2; 7910 f.Hooks = S; 7911 f.parse = f; 7912 var un = f.options; 7913 var pn = f.setOptions; 7914 var cn = f.walkTokens; 7915 var hn = f.parseInline; 7916 var kn = b.parse; 7917 var gn = x2.lex; 7918 7919 // packages/blocks/build-module/api/raw-handling/markdown-converter.mjs 7920 function escapeBodyText(value) { 7921 return value.replace(/&(?!#?\w+;)/g, "&").replace(/</g, "<").replace(/>/g, ">"); 7922 } 7923 var converter = new Q({ 7924 gfm: true, 7925 breaks: true, 7926 renderer: { 7927 // Match showdown's `omitExtraWLInCodeBlocks`: marked appends `\n` 7928 // before `</code>`, which leaks into the Code block's content as a 7929 // trailing blank line. 7930 code({ text: text2, lang }) { 7931 const language = (lang || "").match(/^\S*/)?.[0]; 7932 const cls = language ? ` class="$language} language-$language}"` : ""; 7933 return `<pre><code$cls}>$escapeBodyText( 7934 text2 7935 )}</code></pre>`; 7936 }, 7937 text(token) { 7938 if ("tokens" in token && token.tokens || "escaped" in token && token.escaped) { 7939 return false; 7940 } 7941 return escapeBodyText(token.text); 7942 } 7943 } 7944 }); 7945 function slackMarkdownVariantCorrector(text2) { 7946 return text2.replace( 7947 /((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, 7948 (match, p1, p2, p3) => `$p1} 7949 $p2} 7950 $p3}` 7951 ); 7952 } 7953 function bulletsToAsterisks(text2) { 7954 return text2.replace(/(^|\n)•( +)/g, "$1*$2"); 7955 } 7956 function escapeSingleLineOrderedListMarker(text2) { 7957 if (text2.includes("\n")) { 7958 return text2; 7959 } 7960 return text2.replace(/^(\d+)\.(\s)/, "$1\\.$2"); 7961 } 7962 var correctors = [ 7963 escapeSingleLineOrderedListMarker, 7964 bulletsToAsterisks, 7965 slackMarkdownVariantCorrector 7966 ]; 7967 function markdownConverter(text2) { 7968 return converter.parse( 7969 correctors.reduce( 7970 (current, corrector) => corrector(current), 7971 text2 7972 ), 7973 { async: false } 7974 ); 7975 } 7976 7977 // packages/blocks/build-module/api/raw-handling/iframe-remover.mjs 7978 function iframeRemover(iframe) { 7979 if (iframe.nodeName === "IFRAME") { 7980 const node = iframe; 7981 const text2 = node.ownerDocument.createTextNode(node.src); 7982 node.parentNode.replaceChild(text2, node); 7983 } 7984 } 7985 7986 // packages/blocks/build-module/api/raw-handling/google-docs-uid-remover.mjs 7987 var import_dom10 = __toESM(require_dom(), 1); 7988 function googleDocsUIdRemover(node) { 7989 const el = node; 7990 if (!el.id || el.id.indexOf("docs-internal-guid-") !== 0) { 7991 return; 7992 } 7993 if (el.tagName === "B") { 7994 (0, import_dom10.unwrap)(node); 7995 } else { 7996 el.removeAttribute("id"); 7997 } 7998 } 7999 8000 // packages/blocks/build-module/api/raw-handling/html-formatting-remover.mjs 8001 function isFormattingSpace(character) { 8002 return character === " " || character === "\r" || character === "\n" || character === " "; 8003 } 8004 function htmlFormattingRemover(node) { 8005 if (node.nodeType !== node.TEXT_NODE) { 8006 return; 8007 } 8008 let parent = node; 8009 while (parent = parent.parentNode) { 8010 if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === "PRE") { 8011 return; 8012 } 8013 } 8014 const textNode = node; 8015 let newData = textNode.data.replace(/[ \r\n\t]+/g, " "); 8016 if (newData[0] === " ") { 8017 const previousSibling = getSibling(node, "previous"); 8018 if (!previousSibling || previousSibling.nodeName === "BR" || previousSibling.textContent.slice(-1) === " ") { 8019 newData = newData.slice(1); 8020 } 8021 } 8022 if (newData[newData.length - 1] === " ") { 8023 const nextSibling = getSibling(node, "next"); 8024 if (!nextSibling || nextSibling.nodeName === "BR" || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) { 8025 newData = newData.slice(0, -1); 8026 } 8027 } 8028 if (!newData) { 8029 node.parentNode.removeChild(node); 8030 } else { 8031 textNode.data = newData; 8032 } 8033 } 8034 8035 // packages/blocks/build-module/api/raw-handling/format-space-corrector.mjs 8036 var import_dom11 = __toESM(require_dom(), 1); 8037 function moveEdgeSpace(node, doc, isLeading) { 8038 const child = isLeading ? node.firstChild : node.lastChild; 8039 if (!child || child.nodeType !== node.TEXT_NODE) { 8040 return; 8041 } 8042 const text2 = child; 8043 const edgeIndex = isLeading ? 0 : text2.data.length - 1; 8044 if (text2.data[edgeIndex] !== " ") { 8045 return; 8046 } 8047 text2.data = isLeading ? text2.data.slice(1) : text2.data.slice(0, -1); 8048 if (!text2.data) { 8049 node.removeChild(text2); 8050 } 8051 node.parentNode.insertBefore( 8052 doc.createTextNode(" "), 8053 isLeading ? node : node.nextSibling 8054 ); 8055 } 8056 function formatSpaceCorrector(node, doc) { 8057 if (node.nodeType !== node.ELEMENT_NODE || !(0, import_dom11.isPhrasingContent)(node)) { 8058 return; 8059 } 8060 moveEdgeSpace(node, doc, true); 8061 moveEdgeSpace(node, doc, false); 8062 } 8063 8064 // packages/blocks/build-module/api/raw-handling/br-remover.mjs 8065 function brRemover(node) { 8066 if (node.nodeName !== "BR") { 8067 return; 8068 } 8069 if (getSibling(node, "next")) { 8070 return; 8071 } 8072 node.parentNode.removeChild(node); 8073 } 8074 8075 // packages/blocks/build-module/api/raw-handling/empty-paragraph-remover.mjs 8076 function emptyParagraphRemover(node) { 8077 if (node.nodeName !== "P") { 8078 return; 8079 } 8080 if (node.hasChildNodes()) { 8081 return; 8082 } 8083 node.parentNode.removeChild(node); 8084 } 8085 8086 // packages/blocks/build-module/api/raw-handling/slack-paragraph-corrector.mjs 8087 function slackParagraphCorrector(node) { 8088 if (node.nodeName !== "SPAN") { 8089 return; 8090 } 8091 if (node.getAttribute("data-stringify-type") !== "paragraph-break") { 8092 return; 8093 } 8094 const parentNode = node.parentNode; 8095 parentNode.insertBefore(node.ownerDocument.createElement("br"), node); 8096 parentNode.insertBefore(node.ownerDocument.createElement("br"), node); 8097 parentNode.removeChild(node); 8098 } 8099 8100 // packages/blocks/build-module/api/raw-handling/latex-to-math.mjs 8101 function isLatexMathMode(text2) { 8102 const lettersRegex = /[\p{L}\s]+/gu; 8103 let match; 8104 while (match = lettersRegex.exec(text2)) { 8105 if (text2[match.index - 1] === "{") { 8106 continue; 8107 } 8108 let sequence = match[0]; 8109 if (text2[match.index - 1] === "\\") { 8110 sequence = sequence.replace(/^[a-zA-Z]+/, ""); 8111 } 8112 if (sequence.length < 6) { 8113 continue; 8114 } 8115 return false; 8116 } 8117 if (/\\[a-zA-Z]+\s*\{/g.test(text2)) { 8118 return true; 8119 } 8120 const softClues = [ 8121 (t2) => t2.includes("^") && !t2.startsWith("^"), 8122 (t2) => ["=", "+", "-", "/", "*"].some( 8123 (operator) => t2.includes(operator) 8124 ), 8125 (t2) => /\\[a-zA-Z]+/g.test(t2) 8126 ]; 8127 if (softClues.filter((clue) => clue(text2)).length >= 2) { 8128 return true; 8129 } 8130 return false; 8131 } 8132 8133 // packages/blocks/build-module/api/raw-handling/heading-transformer.mjs 8134 function headingTransformer(node) { 8135 if (node.nodeType !== node.ELEMENT_NODE) { 8136 return; 8137 } 8138 const element = node; 8139 if (element.tagName === "P" && element.getAttribute("role") === "heading" && element.hasAttribute("aria-level")) { 8140 const level = parseInt(element.getAttribute("aria-level"), 10); 8141 if (level >= 1 && level <= 6) { 8142 const headingTag = `H$level}`; 8143 const newHeading = element.ownerDocument.createElement(headingTag); 8144 Array.from(element.attributes).forEach((attr2) => { 8145 if (attr2.name !== "role" && attr2.name !== "aria-level") { 8146 newHeading.setAttribute(attr2.name, attr2.value); 8147 } 8148 }); 8149 while (element.firstChild) { 8150 newHeading.appendChild(element.firstChild); 8151 } 8152 element.parentNode.replaceChild(newHeading, element); 8153 } 8154 } 8155 } 8156 8157 // packages/blocks/build-module/api/raw-handling/paste-handler.mjs 8158 var log = (...args) => window?.console?.log?.(...args); 8159 function filterInlineHTML(HTML) { 8160 HTML = deepFilterHTML(HTML, [ 8161 headRemover, 8162 googleDocsUIdRemover, 8163 msListIgnore, 8164 phrasingContentReducer, 8165 commentRemover 8166 ]); 8167 HTML = (0, import_dom12.removeInvalidHTML)( 8168 HTML, 8169 (0, import_dom12.getPhrasingContentSchema)("paste"), 8170 true 8171 ); 8172 HTML = deepFilterHTML(HTML, [ 8173 htmlFormattingRemover, 8174 formatSpaceCorrector, 8175 brRemover 8176 ]); 8177 log("Processed inline HTML:\n\n", HTML); 8178 return HTML; 8179 } 8180 function pasteHandler({ 8181 HTML = "", 8182 plainText = "", 8183 mode = "AUTO", 8184 tagName 8185 }) { 8186 log("Received HTML (pasteHandler):\n\n", HTML); 8187 log("Received plain text (pasteHandler):\n\n", plainText); 8188 HTML = HTML.replace(/<meta[^>]+>/g, ""); 8189 HTML = HTML.replace( 8190 /^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, 8191 "" 8192 ); 8193 HTML = HTML.replace( 8194 /(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, 8195 "" 8196 ); 8197 if (mode !== "INLINE") { 8198 const content = HTML ? HTML : plainText; 8199 if (content.indexOf("<!-- wp:") !== -1) { 8200 const parseResult = parse2(content); 8201 const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === "core/freeform"; 8202 if (!isSingleFreeFormBlock) { 8203 return parseResult; 8204 } 8205 } 8206 } 8207 HTML = HTML.normalize(); 8208 HTML = deepFilterHTML(HTML, [slackParagraphCorrector]); 8209 const isPlainText = plainText && (!HTML || isPlain(HTML)); 8210 if (isPlainText && isLatexMathMode(plainText)) { 8211 return [createBlock("core/math", { latex: plainText })]; 8212 } 8213 if (isPlainText) { 8214 HTML = plainText; 8215 if (!/^\s+$/.test(plainText)) { 8216 HTML = markdownConverter(HTML); 8217 } 8218 } 8219 const pieces = shortcode_converter_default(HTML); 8220 const hasShortcodes = pieces.length > 1; 8221 if (isPlainText && !hasShortcodes) { 8222 if (mode === "AUTO" && plainText.indexOf("\n") === -1 && plainText.indexOf("<p>") !== 0 && HTML.indexOf("<p>") === 0) { 8223 mode = "INLINE"; 8224 } 8225 } 8226 if (mode === "INLINE") { 8227 return filterInlineHTML(HTML); 8228 } 8229 if (mode === "AUTO" && !hasShortcodes && isInlineContent(HTML, tagName)) { 8230 return filterInlineHTML(HTML); 8231 } 8232 const phrasingContentSchema = (0, import_dom12.getPhrasingContentSchema)("paste"); 8233 const blockContentSchema = getBlockContentSchema("paste"); 8234 const blocks = pieces.map((piece) => { 8235 if (typeof piece !== "string") { 8236 return piece; 8237 } 8238 const filters = [ 8239 googleDocsUIdRemover, 8240 msListConverter, 8241 headRemover, 8242 listReducer, 8243 imageCorrector, 8244 phrasingContentReducer, 8245 specialCommentConverter, 8246 commentRemover, 8247 iframeRemover, 8248 figureContentReducer, 8249 blockquoteNormaliser(), 8250 divNormaliser, 8251 headingTransformer 8252 ]; 8253 const schema = { 8254 ...blockContentSchema, 8255 // Keep top-level phrasing content, normalised by `normaliseBlocks`. 8256 ...phrasingContentSchema 8257 }; 8258 piece = deepFilterHTML(piece, filters, blockContentSchema); 8259 piece = (0, import_dom12.removeInvalidHTML)(piece, schema, false); 8260 piece = normaliseBlocks(piece); 8261 piece = deepFilterHTML( 8262 piece, 8263 [ 8264 htmlFormattingRemover, 8265 formatSpaceCorrector, 8266 brRemover, 8267 emptyParagraphRemover 8268 ], 8269 blockContentSchema 8270 ); 8271 log("Processed HTML piece:\n\n", piece); 8272 return htmlToBlocks(piece, pasteHandler); 8273 }).flat().filter(Boolean); 8274 if (mode === "AUTO" && blocks.length === 1 && hasBlockSupport(blocks[0].name, "__unstablePasteTextInline", false)) { 8275 const trimRegex = /^[\n]+|[\n]+$/g; 8276 const trimmedPlainText = plainText.replace(trimRegex, ""); 8277 if (trimmedPlainText !== "" && trimmedPlainText.indexOf("\n") === -1) { 8278 return (0, import_dom12.removeInvalidHTML)( 8279 getBlockInnerHTML(blocks[0]), 8280 phrasingContentSchema, 8281 false 8282 ).replace(trimRegex, ""); 8283 } 8284 } 8285 return blocks; 8286 } 8287 8288 // packages/blocks/build-module/api/raw-handling/index.mjs 8289 function deprecatedGetPhrasingContentSchema(context) { 8290 (0, import_deprecated11.default)("wp.blocks.getPhrasingContentSchema", { 8291 since: "5.6", 8292 alternative: "wp.dom.getPhrasingContentSchema" 8293 }); 8294 return (0, import_dom13.getPhrasingContentSchema)(context); 8295 } 8296 function rawHandler({ HTML = "" }) { 8297 if (HTML.indexOf("<!-- wp:") !== -1) { 8298 const parseResult = parse2(HTML); 8299 const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === "core/freeform"; 8300 if (!isSingleFreeFormBlock) { 8301 return parseResult; 8302 } 8303 } 8304 const pieces = shortcode_converter_default(HTML); 8305 const blockContentSchema = getBlockContentSchema(); 8306 return pieces.map((piece) => { 8307 if (typeof piece !== "string") { 8308 return piece; 8309 } 8310 const filters = [ 8311 // Needed to adjust invalid lists. 8312 listReducer, 8313 // Needed to create more and nextpage blocks. 8314 specialCommentConverter, 8315 // Needed to create media blocks. 8316 figureContentReducer, 8317 // Needed to create the quote block, which cannot handle text 8318 // without wrapper paragraphs. 8319 blockquoteNormaliser({ raw: true }) 8320 ]; 8321 piece = deepFilterHTML(piece, filters, blockContentSchema); 8322 piece = normaliseBlocks(piece, { raw: true }); 8323 return htmlToBlocks(piece, rawHandler); 8324 }).flat().filter(Boolean); 8325 } 8326 8327 // packages/blocks/build-module/api/categories.mjs 8328 var import_data6 = __toESM(require_data(), 1); 8329 function getCategories2() { 8330 return (0, import_data6.select)(store).getCategories(); 8331 } 8332 function setCategories2(categories2) { 8333 (0, import_data6.dispatch)(store).setCategories(categories2); 8334 } 8335 function updateCategory2(slug, category) { 8336 (0, import_data6.dispatch)(store).updateCategory(slug, category); 8337 } 8338 8339 // packages/blocks/build-module/api/templates.mjs 8340 var import_element4 = __toESM(require_element(), 1); 8341 function doBlocksMatchTemplate(blocks = [], template = []) { 8342 return blocks.length === template.length && template.every(([name, , innerBlocksTemplate], index) => { 8343 const block = blocks[index]; 8344 return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate); 8345 }); 8346 } 8347 var isHTMLAttribute = (attributeDefinition) => attributeDefinition?.source === "html"; 8348 var isQueryAttribute = (attributeDefinition) => attributeDefinition?.source === "query"; 8349 function normalizeAttributes(schema, values) { 8350 if (!values) { 8351 return {}; 8352 } 8353 return Object.fromEntries( 8354 Object.entries(values).map(([key, value]) => [ 8355 key, 8356 normalizeAttribute(schema[key], value) 8357 ]) 8358 ); 8359 } 8360 function normalizeAttribute(definition, value) { 8361 if (isHTMLAttribute(definition) && Array.isArray(value)) { 8362 return (0, import_element4.renderToString)(value); 8363 } 8364 if (isQueryAttribute(definition) && value) { 8365 return value.map( 8366 (subValues) => { 8367 return normalizeAttributes(definition.query, subValues); 8368 } 8369 ); 8370 } 8371 return value; 8372 } 8373 function synchronizeBlocksWithTemplate(blocks = [], template) { 8374 if (!template) { 8375 return blocks; 8376 } 8377 return template.map( 8378 ([name, attributes, innerBlocksTemplate], index) => { 8379 const block = blocks[index]; 8380 if (block && block.name === name) { 8381 const innerBlocks = synchronizeBlocksWithTemplate( 8382 block.innerBlocks, 8383 innerBlocksTemplate 8384 ); 8385 return { ...block, innerBlocks }; 8386 } 8387 const blockType = getBlockType(name); 8388 const normalizedAttributes = normalizeAttributes( 8389 blockType?.attributes ?? {}, 8390 attributes 8391 ); 8392 const [blockName, blockAttributes] = convertLegacyBlockNameAndAttributes( 8393 name, 8394 normalizedAttributes 8395 ); 8396 return createBlock( 8397 blockName, 8398 blockAttributes, 8399 synchronizeBlocksWithTemplate([], innerBlocksTemplate) 8400 ); 8401 } 8402 ); 8403 } 8404 8405 // packages/blocks/build-module/api/index.mjs 8406 var editableRootKey = /* @__PURE__ */ Symbol("editableRoot"); 8407 var privateApis = {}; 8408 lock(privateApis, { 8409 isContentBlock, 8410 editableRootKey, 8411 parseRawBlock 8412 }); 8413 8414 // packages/blocks/build-module/deprecated.mjs 8415 var import_deprecated12 = __toESM(require_deprecated(), 1); 8416 function withBlockContentContext(OriginalComponent) { 8417 (0, import_deprecated12.default)("wp.blocks.withBlockContentContext", { 8418 since: "6.1" 8419 }); 8420 return OriginalComponent; 8421 } 8422 return __toCommonJS(index_exports); 8423 })(); 8424 /*! Bundled license information: 8425 8426 react-is/cjs/react-is.development.js: 8427 (** 8428 * @license React 8429 * react-is.development.js 8430 * 8431 * Copyright (c) Facebook, Inc. and its affiliates. 8432 * 8433 * This source code is licensed under the MIT license found in the 8434 * LICENSE file in the root directory of this source tree. 8435 *) 8436 8437 is-plain-object/dist/is-plain-object.mjs: 8438 (*! 8439 * is-plain-object <https://github.com/jonschlinkert/is-plain-object> 8440 * 8441 * Copyright (c) 2014-2017, Jon Schlinkert. 8442 * Released under the MIT License. 8443 *) 8444 */ 8445 (window.wp ||= {}).blocks = wp.blocks; 8446 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Fri Oct 9 08:20:33 2026 | Cross-referenced by PHPXref |