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