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