| 1 |
"use strict"; |
| 2 |
var wp; |
| 3 |
(wp ||= {}).blocks = (() => { |
| 4 |
var __create = Object.create; |
| 5 |
var __defProp = Object.defineProperty; |
| 6 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 7 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
| 8 |
var __getProtoOf = Object.getPrototypeOf; |
| 9 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 10 |
var __commonJS = (cb, mod) => function __require() { |
| 11 |
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; |
| 12 |
}; |
| 13 |
var __export = (target, all) => { |
| 14 |
for (var name in all) |
| 15 |
__defProp(target, name, { get: all[name], enumerable: true }); |
| 16 |
}; |
| 17 |
var __copyProps = (to, from, except, desc) => { |
| 18 |
if (from && typeof from === "object" || typeof from === "function") { |
| 19 |
for (let key of __getOwnPropNames(from)) |
| 20 |
if (!__hasOwnProp.call(to, key) && key !== except) |
| 21 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
| 22 |
} |
| 23 |
return to; |
| 24 |
}; |
| 25 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
| 26 |
// If the importer is in node compatibility mode or this is not an ESM |
| 27 |
// file that has been converted to a CommonJS file using a Babel- |
| 28 |
// compatible transform (i.e. "__esModule" has not been set), then set |
| 29 |
// "default" to the CommonJS "module.exports" for node compatibility. |
| 30 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
| 31 |
mod |
| 32 |
)); |
| 33 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
| 34 |
|
| 35 |
// package-external:@wordpress/data |
| 36 |
var require_data = __commonJS({ |
| 37 |
"package-external:@wordpress/data"(exports, module) { |
| 38 |
module.exports = window.wp.data; |
| 39 |
} |
| 40 |
}); |
| 41 |
|
| 42 |
// package-external:@wordpress/i18n |
| 43 |
var require_i18n = __commonJS({ |
| 44 |
"package-external:@wordpress/i18n"(exports, module) { |
| 45 |
module.exports = window.wp.i18n; |
| 46 |
} |
| 47 |
}); |
| 48 |
|
| 49 |
// package-external:@wordpress/element |
| 50 |
var require_element = __commonJS({ |
| 51 |
"package-external:@wordpress/element"(exports, module) { |
| 52 |
module.exports = window.wp.element; |
| 53 |
} |
| 54 |
}); |
| 55 |
|
| 56 |
// package-external:@wordpress/dom |
| 57 |
var require_dom = __commonJS({ |
| 58 |
"package-external:@wordpress/dom"(exports, module) { |
| 59 |
module.exports = window.wp.dom; |
| 60 |
} |
| 61 |
}); |
| 62 |
|
| 63 |
// package-external:@wordpress/rich-text |
| 64 |
var require_rich_text = __commonJS({ |
| 65 |
"package-external:@wordpress/rich-text"(exports, module) { |
| 66 |
module.exports = window.wp.richText; |
| 67 |
} |
| 68 |
}); |
| 69 |
|
| 70 |
// package-external:@wordpress/deprecated |
| 71 |
var require_deprecated = __commonJS({ |
| 72 |
"package-external:@wordpress/deprecated"(exports, module) { |
| 73 |
module.exports = window.wp.deprecated; |
| 74 |
} |
| 75 |
}); |
| 76 |
|
| 77 |
// package-external:@wordpress/warning |
| 78 |
var require_warning = __commonJS({ |
| 79 |
"package-external:@wordpress/warning"(exports, module) { |
| 80 |
module.exports = window.wp.warning; |
| 81 |
} |
| 82 |
}); |
| 83 |
|
| 84 |
// package-external:@wordpress/private-apis |
| 85 |
var require_private_apis = __commonJS({ |
| 86 |
"package-external:@wordpress/private-apis"(exports, module) { |
| 87 |
module.exports = window.wp.privateApis; |
| 88 |
} |
| 89 |
}); |
| 90 |
|
| 91 |
// node_modules/remove-accents/index.js |
| 92 |
var require_remove_accents = __commonJS({ |
| 93 |
"node_modules/remove-accents/index.js"(exports, module) { |
| 94 |
var characterMap = { |
| 95 |
"\xC0": "A", |
| 96 |
"\xC1": "A", |
| 97 |
"\xC2": "A", |
| 98 |
"\xC3": "A", |
| 99 |
"\xC4": "A", |
| 100 |
"\xC5": "A", |
| 101 |
"\u1EA4": "A", |
| 102 |
"\u1EAE": "A", |
| 103 |
"\u1EB2": "A", |
| 104 |
"\u1EB4": "A", |
| 105 |
"\u1EB6": "A", |
| 106 |
"\xC6": "AE", |
| 107 |
"\u1EA6": "A", |
| 108 |
"\u1EB0": "A", |
| 109 |
"\u0202": "A", |
| 110 |
"\u1EA2": "A", |
| 111 |
"\u1EA0": "A", |
| 112 |
"\u1EA8": "A", |
| 113 |
"\u1EAA": "A", |
| 114 |
"\u1EAC": "A", |
| 115 |
"\xC7": "C", |
| 116 |
"\u1E08": "C", |
| 117 |
"\xC8": "E", |
| 118 |
"\xC9": "E", |
| 119 |
"\xCA": "E", |
| 120 |
"\xCB": "E", |
| 121 |
"\u1EBE": "E", |
| 122 |
"\u1E16": "E", |
| 123 |
"\u1EC0": "E", |
| 124 |
"\u1E14": "E", |
| 125 |
"\u1E1C": "E", |
| 126 |
"\u0206": "E", |
| 127 |
"\u1EBA": "E", |
| 128 |
"\u1EBC": "E", |
| 129 |
"\u1EB8": "E", |
| 130 |
"\u1EC2": "E", |
| 131 |
"\u1EC4": "E", |
| 132 |
"\u1EC6": "E", |
| 133 |
"\xCC": "I", |
| 134 |
"\xCD": "I", |
| 135 |
"\xCE": "I", |
| 136 |
"\xCF": "I", |
| 137 |
"\u1E2E": "I", |
| 138 |
"\u020A": "I", |
| 139 |
"\u1EC8": "I", |
| 140 |
"\u1ECA": "I", |
| 141 |
"\xD0": "D", |
| 142 |
"\xD1": "N", |
| 143 |
"\xD2": "O", |
| 144 |
"\xD3": "O", |
| 145 |
"\xD4": "O", |
| 146 |
"\xD5": "O", |
| 147 |
"\xD6": "O", |
| 148 |
"\xD8": "O", |
| 149 |
"\u1ED0": "O", |
| 150 |
"\u1E4C": "O", |
| 151 |
"\u1E52": "O", |
| 152 |
"\u020E": "O", |
| 153 |
"\u1ECE": "O", |
| 154 |
"\u1ECC": "O", |
| 155 |
"\u1ED4": "O", |
| 156 |
"\u1ED6": "O", |
| 157 |
"\u1ED8": "O", |
| 158 |
"\u1EDC": "O", |
| 159 |
"\u1EDE": "O", |
| 160 |
"\u1EE0": "O", |
| 161 |
"\u1EDA": "O", |
| 162 |
"\u1EE2": "O", |
| 163 |
"\xD9": "U", |
| 164 |
"\xDA": "U", |
| 165 |
"\xDB": "U", |
| 166 |
"\xDC": "U", |
| 167 |
"\u1EE6": "U", |
| 168 |
"\u1EE4": "U", |
| 169 |
"\u1EEC": "U", |
| 170 |
"\u1EEE": "U", |
| 171 |
"\u1EF0": "U", |
| 172 |
"\xDD": "Y", |
| 173 |
"\xE0": "a", |
| 174 |
"\xE1": "a", |
| 175 |
"\xE2": "a", |
| 176 |
"\xE3": "a", |
| 177 |
"\xE4": "a", |
| 178 |
"\xE5": "a", |
| 179 |
"\u1EA5": "a", |
| 180 |
"\u1EAF": "a", |
| 181 |
"\u1EB3": "a", |
| 182 |
"\u1EB5": "a", |
| 183 |
"\u1EB7": "a", |
| 184 |
"\xE6": "ae", |
| 185 |
"\u1EA7": "a", |
| 186 |
"\u1EB1": "a", |
| 187 |
"\u0203": "a", |
| 188 |
"\u1EA3": "a", |
| 189 |
"\u1EA1": "a", |
| 190 |
"\u1EA9": "a", |
| 191 |
"\u1EAB": "a", |
| 192 |
"\u1EAD": "a", |
| 193 |
"\xE7": "c", |
| 194 |
"\u1E09": "c", |
| 195 |
"\xE8": "e", |
| 196 |
"\xE9": "e", |
| 197 |
"\xEA": "e", |
| 198 |
"\xEB": "e", |
| 199 |
"\u1EBF": "e", |
| 200 |
"\u1E17": "e", |
| 201 |
"\u1EC1": "e", |
| 202 |
"\u1E15": "e", |
| 203 |
"\u1E1D": "e", |
| 204 |
"\u0207": "e", |
| 205 |
"\u1EBB": "e", |
| 206 |
"\u1EBD": "e", |
| 207 |
"\u1EB9": "e", |
| 208 |
"\u1EC3": "e", |
| 209 |
"\u1EC5": "e", |
| 210 |
"\u1EC7": "e", |
| 211 |
"\xEC": "i", |
| 212 |
"\xED": "i", |
| 213 |
"\xEE": "i", |
| 214 |
"\xEF": "i", |
| 215 |
"\u1E2F": "i", |
| 216 |
"\u020B": "i", |
| 217 |
"\u1EC9": "i", |
| 218 |
"\u1ECB": "i", |
| 219 |
"\xF0": "d", |
| 220 |
"\xF1": "n", |
| 221 |
"\xF2": "o", |
| 222 |
"\xF3": "o", |
| 223 |
"\xF4": "o", |
| 224 |
"\xF5": "o", |
| 225 |
"\xF6": "o", |
| 226 |
"\xF8": "o", |
| 227 |
"\u1ED1": "o", |
| 228 |
"\u1E4D": "o", |
| 229 |
"\u1E53": "o", |
| 230 |
"\u020F": "o", |
| 231 |
"\u1ECF": "o", |
| 232 |
"\u1ECD": "o", |
| 233 |
"\u1ED5": "o", |
| 234 |
"\u1ED7": "o", |
| 235 |
"\u1ED9": "o", |
| 236 |
"\u1EDD": "o", |
| 237 |
"\u1EDF": "o", |
| 238 |
"\u1EE1": "o", |
| 239 |
"\u1EDB": "o", |
| 240 |
"\u1EE3": "o", |
| 241 |
"\xF9": "u", |
| 242 |
"\xFA": "u", |
| 243 |
"\xFB": "u", |
| 244 |
"\xFC": "u", |
| 245 |
"\u1EE7": "u", |
| 246 |
"\u1EE5": "u", |
| 247 |
"\u1EED": "u", |
| 248 |
"\u1EEF": "u", |
| 249 |
"\u1EF1": "u", |
| 250 |
"\xFD": "y", |
| 251 |
"\xFF": "y", |
| 252 |
"\u0100": "A", |
| 253 |
"\u0101": "a", |
| 254 |
"\u0102": "A", |
| 255 |
"\u0103": "a", |
| 256 |
"\u0104": "A", |
| 257 |
"\u0105": "a", |
| 258 |
"\u0106": "C", |
| 259 |
"\u0107": "c", |
| 260 |
"\u0108": "C", |
| 261 |
"\u0109": "c", |
| 262 |
"\u010A": "C", |
| 263 |
"\u010B": "c", |
| 264 |
"\u010C": "C", |
| 265 |
"\u010D": "c", |
| 266 |
"C\u0306": "C", |
| 267 |
"c\u0306": "c", |
| 268 |
"\u010E": "D", |
| 269 |
"\u010F": "d", |
| 270 |
"\u0110": "D", |
| 271 |
"\u0111": "d", |
| 272 |
"\u0112": "E", |
| 273 |
"\u0113": "e", |
| 274 |
"\u0114": "E", |
| 275 |
"\u0115": "e", |
| 276 |
"\u0116": "E", |
| 277 |
"\u0117": "e", |
| 278 |
"\u0118": "E", |
| 279 |
"\u0119": "e", |
| 280 |
"\u011A": "E", |
| 281 |
"\u011B": "e", |
| 282 |
"\u011C": "G", |
| 283 |
"\u01F4": "G", |
| 284 |
"\u011D": "g", |
| 285 |
"\u01F5": "g", |
| 286 |
"\u011E": "G", |
| 287 |
"\u011F": "g", |
| 288 |
"\u0120": "G", |
| 289 |
"\u0121": "g", |
| 290 |
"\u0122": "G", |
| 291 |
"\u0123": "g", |
| 292 |
"\u0124": "H", |
| 293 |
"\u0125": "h", |
| 294 |
"\u0126": "H", |
| 295 |
"\u0127": "h", |
| 296 |
"\u1E2A": "H", |
| 297 |
"\u1E2B": "h", |
| 298 |
"\u0128": "I", |
| 299 |
"\u0129": "i", |
| 300 |
"\u012A": "I", |
| 301 |
"\u012B": "i", |
| 302 |
"\u012C": "I", |
| 303 |
"\u012D": "i", |
| 304 |
"\u012E": "I", |
| 305 |
"\u012F": "i", |
| 306 |
"\u0130": "I", |
| 307 |
"\u0131": "i", |
| 308 |
"\u0132": "IJ", |
| 309 |
"\u0133": "ij", |
| 310 |
"\u0134": "J", |
| 311 |
"\u0135": "j", |
| 312 |
"\u0136": "K", |
| 313 |
"\u0137": "k", |
| 314 |
"\u1E30": "K", |
| 315 |
"\u1E31": "k", |
| 316 |
"K\u0306": "K", |
| 317 |
"k\u0306": "k", |
| 318 |
"\u0139": "L", |
| 319 |
"\u013A": "l", |
| 320 |
"\u013B": "L", |
| 321 |
"\u013C": "l", |
| 322 |
"\u013D": "L", |
| 323 |
"\u013E": "l", |
| 324 |
"\u013F": "L", |
| 325 |
"\u0140": "l", |
| 326 |
"\u0141": "l", |
| 327 |
"\u0142": "l", |
| 328 |
"\u1E3E": "M", |
| 329 |
"\u1E3F": "m", |
| 330 |
"M\u0306": "M", |
| 331 |
"m\u0306": "m", |
| 332 |
"\u0143": "N", |
| 333 |
"\u0144": "n", |
| 334 |
"\u0145": "N", |
| 335 |
"\u0146": "n", |
| 336 |
"\u0147": "N", |
| 337 |
"\u0148": "n", |
| 338 |
"\u0149": "n", |
| 339 |
"N\u0306": "N", |
| 340 |
"n\u0306": "n", |
| 341 |
"\u014C": "O", |
| 342 |
"\u014D": "o", |
| 343 |
"\u014E": "O", |
| 344 |
"\u014F": "o", |
| 345 |
"\u0150": "O", |
| 346 |
"\u0151": "o", |
| 347 |
"\u0152": "OE", |
| 348 |
"\u0153": "oe", |
| 349 |
"P\u0306": "P", |
| 350 |
"p\u0306": "p", |
| 351 |
"\u0154": "R", |
| 352 |
"\u0155": "r", |
| 353 |
"\u0156": "R", |
| 354 |
"\u0157": "r", |
| 355 |
"\u0158": "R", |
| 356 |
"\u0159": "r", |
| 357 |
"R\u0306": "R", |
| 358 |
"r\u0306": "r", |
| 359 |
"\u0212": "R", |
| 360 |
"\u0213": "r", |
| 361 |
"\u015A": "S", |
| 362 |
"\u015B": "s", |
| 363 |
"\u015C": "S", |
| 364 |
"\u015D": "s", |
| 365 |
"\u015E": "S", |
| 366 |
"\u0218": "S", |
| 367 |
"\u0219": "s", |
| 368 |
"\u015F": "s", |
| 369 |
"\u0160": "S", |
| 370 |
"\u0161": "s", |
| 371 |
"\u0162": "T", |
| 372 |
"\u0163": "t", |
| 373 |
"\u021B": "t", |
| 374 |
"\u021A": "T", |
| 375 |
"\u0164": "T", |
| 376 |
"\u0165": "t", |
| 377 |
"\u0166": "T", |
| 378 |
"\u0167": "t", |
| 379 |
"T\u0306": "T", |
| 380 |
"t\u0306": "t", |
| 381 |
"\u0168": "U", |
| 382 |
"\u0169": "u", |
| 383 |
"\u016A": "U", |
| 384 |
"\u016B": "u", |
| 385 |
"\u016C": "U", |
| 386 |
"\u016D": "u", |
| 387 |
"\u016E": "U", |
| 388 |
"\u016F": "u", |
| 389 |
"\u0170": "U", |
| 390 |
"\u0171": "u", |
| 391 |
"\u0172": "U", |
| 392 |
"\u0173": "u", |
| 393 |
"\u0216": "U", |
| 394 |
"\u0217": "u", |
| 395 |
"V\u0306": "V", |
| 396 |
"v\u0306": "v", |
| 397 |
"\u0174": "W", |
| 398 |
"\u0175": "w", |
| 399 |
"\u1E82": "W", |
| 400 |
"\u1E83": "w", |
| 401 |
"X\u0306": "X", |
| 402 |
"x\u0306": "x", |
| 403 |
"\u0176": "Y", |
| 404 |
"\u0177": "y", |
| 405 |
"\u0178": "Y", |
| 406 |
"Y\u0306": "Y", |
| 407 |
"y\u0306": "y", |
| 408 |
"\u0179": "Z", |
| 409 |
"\u017A": "z", |
| 410 |
"\u017B": "Z", |
| 411 |
"\u017C": "z", |
| 412 |
"\u017D": "Z", |
| 413 |
"\u017E": "z", |
| 414 |
"\u017F": "s", |
| 415 |
"\u0192": "f", |
| 416 |
"\u01A0": "O", |
| 417 |
"\u01A1": "o", |
| 418 |
"\u01AF": "U", |
| 419 |
"\u01B0": "u", |
| 420 |
"\u01CD": "A", |
| 421 |
"\u01CE": "a", |
| 422 |
"\u01CF": "I", |
| 423 |
"\u01D0": "i", |
| 424 |
"\u01D1": "O", |
| 425 |
"\u01D2": "o", |
| 426 |
"\u01D3": "U", |
| 427 |
"\u01D4": "u", |
| 428 |
"\u01D5": "U", |
| 429 |
"\u01D6": "u", |
| 430 |
"\u01D7": "U", |
| 431 |
"\u01D8": "u", |
| 432 |
"\u01D9": "U", |
| 433 |
"\u01DA": "u", |
| 434 |
"\u01DB": "U", |
| 435 |
"\u01DC": "u", |
| 436 |
"\u1EE8": "U", |
| 437 |
"\u1EE9": "u", |
| 438 |
"\u1E78": "U", |
| 439 |
"\u1E79": "u", |
| 440 |
"\u01FA": "A", |
| 441 |
"\u01FB": "a", |
| 442 |
"\u01FC": "AE", |
| 443 |
"\u01FD": "ae", |
| 444 |
"\u01FE": "O", |
| 445 |
"\u01FF": "o", |
| 446 |
"\xDE": "TH", |
| 447 |
"\xFE": "th", |
| 448 |
"\u1E54": "P", |
| 449 |
"\u1E55": "p", |
| 450 |
"\u1E64": "S", |
| 451 |
"\u1E65": "s", |
| 452 |
"X\u0301": "X", |
| 453 |
"x\u0301": "x", |
| 454 |
"\u0403": "\u0413", |
| 455 |
"\u0453": "\u0433", |
| 456 |
"\u040C": "\u041A", |
| 457 |
"\u045C": "\u043A", |
| 458 |
"A\u030B": "A", |
| 459 |
"a\u030B": "a", |
| 460 |
"E\u030B": "E", |
| 461 |
"e\u030B": "e", |
| 462 |
"I\u030B": "I", |
| 463 |
"i\u030B": "i", |
| 464 |
"\u01F8": "N", |
| 465 |
"\u01F9": "n", |
| 466 |
"\u1ED2": "O", |
| 467 |
"\u1ED3": "o", |
| 468 |
"\u1E50": "O", |
| 469 |
"\u1E51": "o", |
| 470 |
"\u1EEA": "U", |
| 471 |
"\u1EEB": "u", |
| 472 |
"\u1E80": "W", |
| 473 |
"\u1E81": "w", |
| 474 |
"\u1EF2": "Y", |
| 475 |
"\u1EF3": "y", |
| 476 |
"\u0200": "A", |
| 477 |
"\u0201": "a", |
| 478 |
"\u0204": "E", |
| 479 |
"\u0205": "e", |
| 480 |
"\u0208": "I", |
| 481 |
"\u0209": "i", |
| 482 |
"\u020C": "O", |
| 483 |
"\u020D": "o", |
| 484 |
"\u0210": "R", |
| 485 |
"\u0211": "r", |
| 486 |
"\u0214": "U", |
| 487 |
"\u0215": "u", |
| 488 |
"B\u030C": "B", |
| 489 |
"b\u030C": "b", |
| 490 |
"\u010C\u0323": "C", |
| 491 |
"\u010D\u0323": "c", |
| 492 |
"\xCA\u030C": "E", |
| 493 |
"\xEA\u030C": "e", |
| 494 |
"F\u030C": "F", |
| 495 |
"f\u030C": "f", |
| 496 |
"\u01E6": "G", |
| 497 |
"\u01E7": "g", |
| 498 |
"\u021E": "H", |
| 499 |
"\u021F": "h", |
| 500 |
"J\u030C": "J", |
| 501 |
"\u01F0": "j", |
| 502 |
"\u01E8": "K", |
| 503 |
"\u01E9": "k", |
| 504 |
"M\u030C": "M", |
| 505 |
"m\u030C": "m", |
| 506 |
"P\u030C": "P", |
| 507 |
"p\u030C": "p", |
| 508 |
"Q\u030C": "Q", |
| 509 |
"q\u030C": "q", |
| 510 |
"\u0158\u0329": "R", |
| 511 |
"\u0159\u0329": "r", |
| 512 |
"\u1E66": "S", |
| 513 |
"\u1E67": "s", |
| 514 |
"V\u030C": "V", |
| 515 |
"v\u030C": "v", |
| 516 |
"W\u030C": "W", |
| 517 |
"w\u030C": "w", |
| 518 |
"X\u030C": "X", |
| 519 |
"x\u030C": "x", |
| 520 |
"Y\u030C": "Y", |
| 521 |
"y\u030C": "y", |
| 522 |
"A\u0327": "A", |
| 523 |
"a\u0327": "a", |
| 524 |
"B\u0327": "B", |
| 525 |
"b\u0327": "b", |
| 526 |
"\u1E10": "D", |
| 527 |
"\u1E11": "d", |
| 528 |
"\u0228": "E", |
| 529 |
"\u0229": "e", |
| 530 |
"\u0190\u0327": "E", |
| 531 |
"\u025B\u0327": "e", |
| 532 |
"\u1E28": "H", |
| 533 |
"\u1E29": "h", |
| 534 |
"I\u0327": "I", |
| 535 |
"i\u0327": "i", |
| 536 |
"\u0197\u0327": "I", |
| 537 |
"\u0268\u0327": "i", |
| 538 |
"M\u0327": "M", |
| 539 |
"m\u0327": "m", |
| 540 |
"O\u0327": "O", |
| 541 |
"o\u0327": "o", |
| 542 |
"Q\u0327": "Q", |
| 543 |
"q\u0327": "q", |
| 544 |
"U\u0327": "U", |
| 545 |
"u\u0327": "u", |
| 546 |
"X\u0327": "X", |
| 547 |
"x\u0327": "x", |
| 548 |
"Z\u0327": "Z", |
| 549 |
"z\u0327": "z", |
| 550 |
"\u0439": "\u0438", |
| 551 |
"\u0419": "\u0418", |
| 552 |
"\u0451": "\u0435", |
| 553 |
"\u0401": "\u0415" |
| 554 |
}; |
| 555 |
var chars = Object.keys(characterMap).join("|"); |
| 556 |
var allAccents = new RegExp(chars, "g"); |
| 557 |
var firstAccent = new RegExp(chars, ""); |
| 558 |
function matcher3(match) { |
| 559 |
return characterMap[match]; |
| 560 |
} |
| 561 |
var removeAccents2 = function(string) { |
| 562 |
return string.replace(allAccents, matcher3); |
| 563 |
}; |
| 564 |
var hasAccents = function(string) { |
| 565 |
return !!string.match(firstAccent); |
| 566 |
}; |
| 567 |
module.exports = removeAccents2; |
| 568 |
module.exports.has = hasAccents; |
| 569 |
module.exports.remove = removeAccents2; |
| 570 |
} |
| 571 |
}); |
| 572 |
|
| 573 |
// packages/blocks/node_modules/react-is/cjs/react-is.development.js |
| 574 |
var require_react_is_development = __commonJS({ |
| 575 |
"packages/blocks/node_modules/react-is/cjs/react-is.development.js"(exports) { |
| 576 |
"use strict"; |
| 577 |
if (true) { |
| 578 |
(function() { |
| 579 |
"use strict"; |
| 580 |
var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.element"); |
| 581 |
var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"); |
| 582 |
var REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"); |
| 583 |
var REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"); |
| 584 |
var REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"); |
| 585 |
var REACT_PROVIDER_TYPE = /* @__PURE__ */ Symbol.for("react.provider"); |
| 586 |
var REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"); |
| 587 |
var REACT_SERVER_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.server_context"); |
| 588 |
var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"); |
| 589 |
var REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"); |
| 590 |
var REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"); |
| 591 |
var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"); |
| 592 |
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"); |
| 593 |
var REACT_OFFSCREEN_TYPE = /* @__PURE__ */ Symbol.for("react.offscreen"); |
| 594 |
var enableScopeAPI = false; |
| 595 |
var enableCacheElement = false; |
| 596 |
var enableTransitionTracing = false; |
| 597 |
var enableLegacyHidden = false; |
| 598 |
var enableDebugTracing = false; |
| 599 |
var REACT_MODULE_REFERENCE; |
| 600 |
{ |
| 601 |
REACT_MODULE_REFERENCE = /* @__PURE__ */ Symbol.for("react.module.reference"); |
| 602 |
} |
| 603 |
function isValidElementType2(type) { |
| 604 |
if (typeof type === "string" || typeof type === "function") { |
| 605 |
return true; |
| 606 |
} |
| 607 |
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) { |
| 608 |
return true; |
| 609 |
} |
| 610 |
if (typeof type === "object" && type !== null) { |
| 611 |
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 |
| 612 |
// types supported by any Flight configuration anywhere since |
| 613 |
// we don't know which Flight build this will end up being used |
| 614 |
// with. |
| 615 |
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) { |
| 616 |
return true; |
| 617 |
} |
| 618 |
} |
| 619 |
return false; |
| 620 |
} |
| 621 |
function typeOf(object) { |
| 622 |
if (typeof object === "object" && object !== null) { |
| 623 |
var $$typeof = object.$$typeof; |
| 624 |
switch ($$typeof) { |
| 625 |
case REACT_ELEMENT_TYPE: |
| 626 |
var type = object.type; |
| 627 |
switch (type) { |
| 628 |
case REACT_FRAGMENT_TYPE: |
| 629 |
case REACT_PROFILER_TYPE: |
| 630 |
case REACT_STRICT_MODE_TYPE: |
| 631 |
case REACT_SUSPENSE_TYPE: |
| 632 |
case REACT_SUSPENSE_LIST_TYPE: |
| 633 |
return type; |
| 634 |
default: |
| 635 |
var $$typeofType = type && type.$$typeof; |
| 636 |
switch ($$typeofType) { |
| 637 |
case REACT_SERVER_CONTEXT_TYPE: |
| 638 |
case REACT_CONTEXT_TYPE: |
| 639 |
case REACT_FORWARD_REF_TYPE: |
| 640 |
case REACT_LAZY_TYPE: |
| 641 |
case REACT_MEMO_TYPE: |
| 642 |
case REACT_PROVIDER_TYPE: |
| 643 |
return $$typeofType; |
| 644 |
default: |
| 645 |
return $$typeof; |
| 646 |
} |
| 647 |
} |
| 648 |
case REACT_PORTAL_TYPE: |
| 649 |
return $$typeof; |
| 650 |
} |
| 651 |
} |
| 652 |
return void 0; |
| 653 |
} |
| 654 |
var ContextConsumer = REACT_CONTEXT_TYPE; |
| 655 |
var ContextProvider = REACT_PROVIDER_TYPE; |
| 656 |
var Element = REACT_ELEMENT_TYPE; |
| 657 |
var ForwardRef = REACT_FORWARD_REF_TYPE; |
| 658 |
var Fragment = REACT_FRAGMENT_TYPE; |
| 659 |
var Lazy = REACT_LAZY_TYPE; |
| 660 |
var Memo = REACT_MEMO_TYPE; |
| 661 |
var Portal = REACT_PORTAL_TYPE; |
| 662 |
var Profiler = REACT_PROFILER_TYPE; |
| 663 |
var StrictMode = REACT_STRICT_MODE_TYPE; |
| 664 |
var Suspense = REACT_SUSPENSE_TYPE; |
| 665 |
var SuspenseList = REACT_SUSPENSE_LIST_TYPE; |
| 666 |
var hasWarnedAboutDeprecatedIsAsyncMode = false; |
| 667 |
var hasWarnedAboutDeprecatedIsConcurrentMode = false; |
| 668 |
function isAsyncMode(object) { |
| 669 |
{ |
| 670 |
if (!hasWarnedAboutDeprecatedIsAsyncMode) { |
| 671 |
hasWarnedAboutDeprecatedIsAsyncMode = true; |
| 672 |
console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+."); |
| 673 |
} |
| 674 |
} |
| 675 |
return false; |
| 676 |
} |
| 677 |
function isConcurrentMode(object) { |
| 678 |
{ |
| 679 |
if (!hasWarnedAboutDeprecatedIsConcurrentMode) { |
| 680 |
hasWarnedAboutDeprecatedIsConcurrentMode = true; |
| 681 |
console["warn"]("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+."); |
| 682 |
} |
| 683 |
} |
| 684 |
return false; |
| 685 |
} |
| 686 |
function isContextConsumer(object) { |
| 687 |
return typeOf(object) === REACT_CONTEXT_TYPE; |
| 688 |
} |
| 689 |
function isContextProvider(object) { |
| 690 |
return typeOf(object) === REACT_PROVIDER_TYPE; |
| 691 |
} |
| 692 |
function isElement(object) { |
| 693 |
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; |
| 694 |
} |
| 695 |
function isForwardRef(object) { |
| 696 |
return typeOf(object) === REACT_FORWARD_REF_TYPE; |
| 697 |
} |
| 698 |
function isFragment(object) { |
| 699 |
return typeOf(object) === REACT_FRAGMENT_TYPE; |
| 700 |
} |
| 701 |
function isLazy(object) { |
| 702 |
return typeOf(object) === REACT_LAZY_TYPE; |
| 703 |
} |
| 704 |
function isMemo(object) { |
| 705 |
return typeOf(object) === REACT_MEMO_TYPE; |
| 706 |
} |
| 707 |
function isPortal(object) { |
| 708 |
return typeOf(object) === REACT_PORTAL_TYPE; |
| 709 |
} |
| 710 |
function isProfiler(object) { |
| 711 |
return typeOf(object) === REACT_PROFILER_TYPE; |
| 712 |
} |
| 713 |
function isStrictMode(object) { |
| 714 |
return typeOf(object) === REACT_STRICT_MODE_TYPE; |
| 715 |
} |
| 716 |
function isSuspense(object) { |
| 717 |
return typeOf(object) === REACT_SUSPENSE_TYPE; |
| 718 |
} |
| 719 |
function isSuspenseList(object) { |
| 720 |
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE; |
| 721 |
} |
| 722 |
exports.ContextConsumer = ContextConsumer; |
| 723 |
exports.ContextProvider = ContextProvider; |
| 724 |
exports.Element = Element; |
| 725 |
exports.ForwardRef = ForwardRef; |
| 726 |
exports.Fragment = Fragment; |
| 727 |
exports.Lazy = Lazy; |
| 728 |
exports.Memo = Memo; |
| 729 |
exports.Portal = Portal; |
| 730 |
exports.Profiler = Profiler; |
| 731 |
exports.StrictMode = StrictMode; |
| 732 |
exports.Suspense = Suspense; |
| 733 |
exports.SuspenseList = SuspenseList; |
| 734 |
exports.isAsyncMode = isAsyncMode; |
| 735 |
exports.isConcurrentMode = isConcurrentMode; |
| 736 |
exports.isContextConsumer = isContextConsumer; |
| 737 |
exports.isContextProvider = isContextProvider; |
| 738 |
exports.isElement = isElement; |
| 739 |
exports.isForwardRef = isForwardRef; |
| 740 |
exports.isFragment = isFragment; |
| 741 |
exports.isLazy = isLazy; |
| 742 |
exports.isMemo = isMemo; |
| 743 |
exports.isPortal = isPortal; |
| 744 |
exports.isProfiler = isProfiler; |
| 745 |
exports.isStrictMode = isStrictMode; |
| 746 |
exports.isSuspense = isSuspense; |
| 747 |
exports.isSuspenseList = isSuspenseList; |
| 748 |
exports.isValidElementType = isValidElementType2; |
| 749 |
exports.typeOf = typeOf; |
| 750 |
})(); |
| 751 |
} |
| 752 |
} |
| 753 |
}); |
| 754 |
|
| 755 |
// packages/blocks/node_modules/react-is/index.js |
| 756 |
var require_react_is = __commonJS({ |
| 757 |
"packages/blocks/node_modules/react-is/index.js"(exports, module) { |
| 758 |
"use strict"; |
| 759 |
if (false) { |
| 760 |
module.exports = null; |
| 761 |
} else { |
| 762 |
module.exports = require_react_is_development(); |
| 763 |
} |
| 764 |
} |
| 765 |
}); |
| 766 |
|
| 767 |
// package-external:@wordpress/hooks |
| 768 |
var require_hooks = __commonJS({ |
| 769 |
"package-external:@wordpress/hooks"(exports, module) { |
| 770 |
module.exports = window.wp.hooks; |
| 771 |
} |
| 772 |
}); |
| 773 |
|
| 774 |
// package-external:@wordpress/block-serialization-default-parser |
| 775 |
var require_block_serialization_default_parser = __commonJS({ |
| 776 |
"package-external:@wordpress/block-serialization-default-parser"(exports, module) { |
| 777 |
module.exports = window.wp.blockSerializationDefaultParser; |
| 778 |
} |
| 779 |
}); |
| 780 |
|
| 781 |
// package-external:@wordpress/autop |
| 782 |
var require_autop = __commonJS({ |
| 783 |
"package-external:@wordpress/autop"(exports, module) { |
| 784 |
module.exports = window.wp.autop; |
| 785 |
} |
| 786 |
}); |
| 787 |
|
| 788 |
// package-external:@wordpress/is-shallow-equal |
| 789 |
var require_is_shallow_equal = __commonJS({ |
| 790 |
"package-external:@wordpress/is-shallow-equal"(exports, module) { |
| 791 |
module.exports = window.wp.isShallowEqual; |
| 792 |
} |
| 793 |
}); |
| 794 |
|
| 795 |
// vendor-external:react/jsx-runtime |
| 796 |
var require_jsx_runtime = __commonJS({ |
| 797 |
"vendor-external:react/jsx-runtime"(exports, module) { |
| 798 |
module.exports = window.ReactJSXRuntime; |
| 799 |
} |
| 800 |
}); |
| 801 |
|
| 802 |
// node_modules/fast-deep-equal/es6/index.js |
| 803 |
var require_es6 = __commonJS({ |
| 804 |
"node_modules/fast-deep-equal/es6/index.js"(exports, module) { |
| 805 |
"use strict"; |
| 806 |
module.exports = function equal(a2, b3) { |
| 807 |
if (a2 === b3) return true; |
| 808 |
if (a2 && b3 && typeof a2 == "object" && typeof b3 == "object") { |
| 809 |
if (a2.constructor !== b3.constructor) return false; |
| 810 |
var length, i2, keys; |
| 811 |
if (Array.isArray(a2)) { |
| 812 |
length = a2.length; |
| 813 |
if (length != b3.length) return false; |
| 814 |
for (i2 = length; i2-- !== 0; ) |
| 815 |
if (!equal(a2[i2], b3[i2])) return false; |
| 816 |
return true; |
| 817 |
} |
| 818 |
if (a2 instanceof Map && b3 instanceof Map) { |
| 819 |
if (a2.size !== b3.size) return false; |
| 820 |
for (i2 of a2.entries()) |
| 821 |
if (!b3.has(i2[0])) return false; |
| 822 |
for (i2 of a2.entries()) |
| 823 |
if (!equal(i2[1], b3.get(i2[0]))) return false; |
| 824 |
return true; |
| 825 |
} |
| 826 |
if (a2 instanceof Set && b3 instanceof Set) { |
| 827 |
if (a2.size !== b3.size) return false; |
| 828 |
for (i2 of a2.entries()) |
| 829 |
if (!b3.has(i2[0])) return false; |
| 830 |
return true; |
| 831 |
} |
| 832 |
if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b3)) { |
| 833 |
length = a2.length; |
| 834 |
if (length != b3.length) return false; |
| 835 |
for (i2 = length; i2-- !== 0; ) |
| 836 |
if (a2[i2] !== b3[i2]) return false; |
| 837 |
return true; |
| 838 |
} |
| 839 |
if (a2.constructor === RegExp) return a2.source === b3.source && a2.flags === b3.flags; |
| 840 |
if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b3.valueOf(); |
| 841 |
if (a2.toString !== Object.prototype.toString) return a2.toString() === b3.toString(); |
| 842 |
keys = Object.keys(a2); |
| 843 |
length = keys.length; |
| 844 |
if (length !== Object.keys(b3).length) return false; |
| 845 |
for (i2 = length; i2-- !== 0; ) |
| 846 |
if (!Object.prototype.hasOwnProperty.call(b3, keys[i2])) return false; |
| 847 |
for (i2 = length; i2-- !== 0; ) { |
| 848 |
var key = keys[i2]; |
| 849 |
if (!equal(a2[key], b3[key])) return false; |
| 850 |
} |
| 851 |
return true; |
| 852 |
} |
| 853 |
return a2 !== a2 && b3 !== b3; |
| 854 |
}; |
| 855 |
} |
| 856 |
}); |
| 857 |
|
| 858 |
// package-external:@wordpress/html-entities |
| 859 |
var require_html_entities = __commonJS({ |
| 860 |
"package-external:@wordpress/html-entities"(exports, module) { |
| 861 |
module.exports = window.wp.htmlEntities; |
| 862 |
} |
| 863 |
}); |
| 864 |
|
| 865 |
// package-external:@wordpress/shortcode |
| 866 |
var require_shortcode = __commonJS({ |
| 867 |
"package-external:@wordpress/shortcode"(exports, module) { |
| 868 |
module.exports = window.wp.shortcode; |
| 869 |
} |
| 870 |
}); |
| 871 |
|
| 872 |
// package-external:@wordpress/blob |
| 873 |
var require_blob = __commonJS({ |
| 874 |
"package-external:@wordpress/blob"(exports, module) { |
| 875 |
module.exports = window.wp.blob; |
| 876 |
} |
| 877 |
}); |
| 878 |
|
| 879 |
// packages/blocks/build-module/index.mjs |
| 880 |
var index_exports = {}; |
| 881 |
__export(index_exports, { |
| 882 |
__EXPERIMENTAL_ELEMENTS: () => __EXPERIMENTAL_ELEMENTS, |
| 883 |
__EXPERIMENTAL_PATHS_WITH_OVERRIDE: () => __EXPERIMENTAL_PATHS_WITH_OVERRIDE, |
| 884 |
__EXPERIMENTAL_STYLE_PROPERTY: () => __EXPERIMENTAL_STYLE_PROPERTY, |
| 885 |
__experimentalCloneSanitizedBlock: () => __experimentalCloneSanitizedBlock, |
| 886 |
__experimentalGetAccessibleBlockLabel: () => getAccessibleBlockLabel, |
| 887 |
__experimentalGetBlockAttributesNamesByRole: () => __experimentalGetBlockAttributesNamesByRole, |
| 888 |
__experimentalGetBlockLabel: () => getBlockLabel, |
| 889 |
__experimentalSanitizeBlockAttributes: () => __experimentalSanitizeBlockAttributes, |
| 890 |
__unstableGetBlockProps: () => getBlockProps, |
| 891 |
__unstableGetInnerBlocksProps: () => getInnerBlocksProps, |
| 892 |
__unstableSerializeAndClean: () => __unstableSerializeAndClean, |
| 893 |
children: () => children_default, |
| 894 |
cloneBlock: () => cloneBlock, |
| 895 |
createBlock: () => createBlock, |
| 896 |
createBlocksFromInnerBlocksTemplate: () => createBlocksFromInnerBlocksTemplate, |
| 897 |
doBlocksMatchTemplate: () => doBlocksMatchTemplate, |
| 898 |
findTransform: () => findTransform, |
| 899 |
getBlockAttributes: () => getBlockAttributes, |
| 900 |
getBlockAttributesNamesByRole: () => getBlockAttributesNamesByRole, |
| 901 |
getBlockBindingsSource: () => getBlockBindingsSource, |
| 902 |
getBlockBindingsSources: () => getBlockBindingsSources, |
| 903 |
getBlockContent: () => getBlockInnerHTML, |
| 904 |
getBlockDefaultClassName: () => getBlockDefaultClassName, |
| 905 |
getBlockFromExample: () => getBlockFromExample, |
| 906 |
getBlockMenuDefaultClassName: () => getBlockMenuDefaultClassName, |
| 907 |
getBlockSupport: () => getBlockSupport, |
| 908 |
getBlockTransforms: () => getBlockTransforms, |
| 909 |
getBlockType: () => getBlockType, |
| 910 |
getBlockTypes: () => getBlockTypes, |
| 911 |
getBlockVariations: () => getBlockVariations, |
| 912 |
getCategories: () => getCategories2, |
| 913 |
getChildBlockNames: () => getChildBlockNames, |
| 914 |
getDefaultBlockName: () => getDefaultBlockName, |
| 915 |
getFreeformContentHandlerName: () => getFreeformContentHandlerName, |
| 916 |
getGroupingBlockName: () => getGroupingBlockName, |
| 917 |
getPhrasingContentSchema: () => deprecatedGetPhrasingContentSchema, |
| 918 |
getPossibleBlockTransformations: () => getPossibleBlockTransformations, |
| 919 |
getSaveContent: () => getSaveContent, |
| 920 |
getSaveElement: () => getSaveElement, |
| 921 |
getUnregisteredTypeHandlerName: () => getUnregisteredTypeHandlerName, |
| 922 |
hasBlockSupport: () => hasBlockSupport, |
| 923 |
hasChildBlocks: () => hasChildBlocks, |
| 924 |
hasChildBlocksWithInserterSupport: () => hasChildBlocksWithInserterSupport, |
| 925 |
isReusableBlock: () => isReusableBlock, |
| 926 |
isTemplatePart: () => isTemplatePart, |
| 927 |
isUnmodifiedBlock: () => isUnmodifiedBlock, |
| 928 |
isUnmodifiedDefaultBlock: () => isUnmodifiedDefaultBlock, |
| 929 |
isValidBlockContent: () => isValidBlockContent, |
| 930 |
isValidIcon: () => isValidIcon, |
| 931 |
node: () => node_default, |
| 932 |
normalizeIconObject: () => normalizeIconObject, |
| 933 |
parse: () => parse2, |
| 934 |
parseWithAttributeSchema: () => parseWithAttributeSchema, |
| 935 |
pasteHandler: () => pasteHandler, |
| 936 |
privateApis: () => privateApis, |
| 937 |
rawHandler: () => rawHandler, |
| 938 |
registerBlockBindingsSource: () => registerBlockBindingsSource, |
| 939 |
registerBlockCollection: () => registerBlockCollection, |
| 940 |
registerBlockStyle: () => registerBlockStyle, |
| 941 |
registerBlockType: () => registerBlockType, |
| 942 |
registerBlockVariation: () => registerBlockVariation, |
| 943 |
serialize: () => serialize, |
| 944 |
serializeRawBlock: () => serializeRawBlock, |
| 945 |
setCategories: () => setCategories2, |
| 946 |
setDefaultBlockName: () => setDefaultBlockName, |
| 947 |
setFreeformContentHandlerName: () => setFreeformContentHandlerName, |
| 948 |
setGroupingBlockName: () => setGroupingBlockName, |
| 949 |
setUnregisteredTypeHandlerName: () => setUnregisteredTypeHandlerName, |
| 950 |
store: () => store, |
| 951 |
switchToBlockType: () => switchToBlockType, |
| 952 |
synchronizeBlocksWithTemplate: () => synchronizeBlocksWithTemplate, |
| 953 |
unregisterBlockBindingsSource: () => unregisterBlockBindingsSource, |
| 954 |
unregisterBlockStyle: () => unregisterBlockStyle, |
| 955 |
unregisterBlockType: () => unregisterBlockType, |
| 956 |
unregisterBlockVariation: () => unregisterBlockVariation, |
| 957 |
unstable__bootstrapServerSideBlockDefinitions: () => unstable__bootstrapServerSideBlockDefinitions, |
| 958 |
updateCategory: () => updateCategory2, |
| 959 |
validateBlock: () => validateBlock, |
| 960 |
withBlockContentContext: () => withBlockContentContext |
| 961 |
}); |
| 962 |
|
| 963 |
// packages/blocks/build-module/store/index.mjs |
| 964 |
var import_data5 = __toESM(require_data(), 1); |
| 965 |
|
| 966 |
// node_modules/tslib/tslib.es6.mjs |
| 967 |
var __assign = function() { |
| 968 |
__assign = Object.assign || function __assign2(t3) { |
| 969 |
for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) { |
| 970 |
s2 = arguments[i2]; |
| 971 |
for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t3[p2] = s2[p2]; |
| 972 |
} |
| 973 |
return t3; |
| 974 |
}; |
| 975 |
return __assign.apply(this, arguments); |
| 976 |
}; |
| 977 |
|
| 978 |
// node_modules/lower-case/dist.es2015/index.js |
| 979 |
function lowerCase(str) { |
| 980 |
return str.toLowerCase(); |
| 981 |
} |
| 982 |
|
| 983 |
// node_modules/no-case/dist.es2015/index.js |
| 984 |
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; |
| 985 |
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; |
| 986 |
function noCase(input, options) { |
| 987 |
if (options === void 0) { |
| 988 |
options = {}; |
| 989 |
} |
| 990 |
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; |
| 991 |
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); |
| 992 |
var start = 0; |
| 993 |
var end = result.length; |
| 994 |
while (result.charAt(start) === "\0") |
| 995 |
start++; |
| 996 |
while (result.charAt(end - 1) === "\0") |
| 997 |
end--; |
| 998 |
return result.slice(start, end).split("\0").map(transform).join(delimiter); |
| 999 |
} |
| 1000 |
function replace(input, re2, value) { |
| 1001 |
if (re2 instanceof RegExp) |
| 1002 |
return input.replace(re2, value); |
| 1003 |
return re2.reduce(function(input2, re3) { |
| 1004 |
return input2.replace(re3, value); |
| 1005 |
}, input); |
| 1006 |
} |
| 1007 |
|
| 1008 |
// node_modules/pascal-case/dist.es2015/index.js |
| 1009 |
function pascalCaseTransform(input, index) { |
| 1010 |
var firstChar = input.charAt(0); |
| 1011 |
var lowerChars = input.substr(1).toLowerCase(); |
| 1012 |
if (index > 0 && firstChar >= "0" && firstChar <= "9") { |
| 1013 |
return "_" + firstChar + lowerChars; |
| 1014 |
} |
| 1015 |
return "" + firstChar.toUpperCase() + lowerChars; |
| 1016 |
} |
| 1017 |
function pascalCase(input, options) { |
| 1018 |
if (options === void 0) { |
| 1019 |
options = {}; |
| 1020 |
} |
| 1021 |
return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); |
| 1022 |
} |
| 1023 |
|
| 1024 |
// node_modules/camel-case/dist.es2015/index.js |
| 1025 |
function camelCaseTransform(input, index) { |
| 1026 |
if (index === 0) |
| 1027 |
return input.toLowerCase(); |
| 1028 |
return pascalCaseTransform(input, index); |
| 1029 |
} |
| 1030 |
function camelCase(input, options) { |
| 1031 |
if (options === void 0) { |
| 1032 |
options = {}; |
| 1033 |
} |
| 1034 |
return pascalCase(input, __assign({ transform: camelCaseTransform }, options)); |
| 1035 |
} |
| 1036 |
|
| 1037 |
// packages/blocks/build-module/store/reducer.mjs |
| 1038 |
var import_data2 = __toESM(require_data(), 1); |
| 1039 |
var import_i18n3 = __toESM(require_i18n(), 1); |
| 1040 |
|
| 1041 |
// node_modules/colord/index.mjs |
| 1042 |
var r = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; |
| 1043 |
var t = function(r2) { |
| 1044 |
return "string" == typeof r2 ? r2.length > 0 : "number" == typeof r2; |
| 1045 |
}; |
| 1046 |
var n = function(r2, t3, n2) { |
| 1047 |
return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = Math.pow(10, t3)), Math.round(n2 * r2) / n2 + 0; |
| 1048 |
}; |
| 1049 |
var e = function(r2, t3, n2) { |
| 1050 |
return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = 1), r2 > n2 ? n2 : r2 > t3 ? r2 : t3; |
| 1051 |
}; |
| 1052 |
var u = function(r2) { |
| 1053 |
return (r2 = isFinite(r2) ? r2 % 360 : 0) > 0 ? r2 : r2 + 360; |
| 1054 |
}; |
| 1055 |
var a = function(r2) { |
| 1056 |
return { r: e(r2.r, 0, 255), g: e(r2.g, 0, 255), b: e(r2.b, 0, 255), a: e(r2.a) }; |
| 1057 |
}; |
| 1058 |
var o = function(r2) { |
| 1059 |
return { r: n(r2.r), g: n(r2.g), b: n(r2.b), a: n(r2.a, 3) }; |
| 1060 |
}; |
| 1061 |
var i = /^#([0-9a-f]{3,8})$/i; |
| 1062 |
var s = function(r2) { |
| 1063 |
var t3 = r2.toString(16); |
| 1064 |
return t3.length < 2 ? "0" + t3 : t3; |
| 1065 |
}; |
| 1066 |
var h = function(r2) { |
| 1067 |
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; |
| 1068 |
return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o3 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; |
| 1069 |
}; |
| 1070 |
var b = function(r2) { |
| 1071 |
var t3 = r2.h, n2 = r2.s, e2 = r2.v, u2 = r2.a; |
| 1072 |
t3 = t3 / 360 * 6, n2 /= 100, e2 /= 100; |
| 1073 |
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; |
| 1074 |
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 }; |
| 1075 |
}; |
| 1076 |
var g = function(r2) { |
| 1077 |
return { h: u(r2.h), s: e(r2.s, 0, 100), l: e(r2.l, 0, 100), a: e(r2.a) }; |
| 1078 |
}; |
| 1079 |
var d = function(r2) { |
| 1080 |
return { h: n(r2.h), s: n(r2.s), l: n(r2.l), a: n(r2.a, 3) }; |
| 1081 |
}; |
| 1082 |
var f = function(r2) { |
| 1083 |
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 })); |
| 1084 |
var t3, n2, e2; |
| 1085 |
}; |
| 1086 |
var c = function(r2) { |
| 1087 |
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 }; |
| 1088 |
var t3, n2, e2, u2; |
| 1089 |
}; |
| 1090 |
var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; |
| 1091 |
var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; |
| 1092 |
var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; |
| 1093 |
var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; |
| 1094 |
var y = { string: [[function(r2) { |
| 1095 |
var t3 = i.exec(r2); |
| 1096 |
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; |
| 1097 |
}, "hex"], [function(r2) { |
| 1098 |
var t3 = v.exec(r2) || m.exec(r2); |
| 1099 |
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; |
| 1100 |
}, "rgb"], [function(t3) { |
| 1101 |
var n2 = l.exec(t3) || p.exec(t3); |
| 1102 |
if (!n2) return null; |
| 1103 |
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) }); |
| 1104 |
return f(a2); |
| 1105 |
}, "hsl"]], object: [[function(r2) { |
| 1106 |
var n2 = r2.r, e2 = r2.g, u2 = r2.b, o3 = r2.a, i2 = void 0 === o3 ? 1 : o3; |
| 1107 |
return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; |
| 1108 |
}, "rgb"], [function(r2) { |
| 1109 |
var n2 = r2.h, e2 = r2.s, u2 = r2.l, a2 = r2.a, o3 = void 0 === a2 ? 1 : a2; |
| 1110 |
if (!t(n2) || !t(e2) || !t(u2)) return null; |
| 1111 |
var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o3) }); |
| 1112 |
return f(i2); |
| 1113 |
}, "hsl"], [function(r2) { |
| 1114 |
var n2 = r2.h, a2 = r2.s, o3 = r2.v, i2 = r2.a, s2 = void 0 === i2 ? 1 : i2; |
| 1115 |
if (!t(n2) || !t(a2) || !t(o3)) return null; |
| 1116 |
var h2 = (function(r3) { |
| 1117 |
return { h: u(r3.h), s: e(r3.s, 0, 100), v: e(r3.v, 0, 100), a: e(r3.a) }; |
| 1118 |
})({ h: Number(n2), s: Number(a2), v: Number(o3), a: Number(s2) }); |
| 1119 |
return b(h2); |
| 1120 |
}, "hsv"]] }; |
| 1121 |
var N = function(r2, t3) { |
| 1122 |
for (var n2 = 0; n2 < t3.length; n2++) { |
| 1123 |
var e2 = t3[n2][0](r2); |
| 1124 |
if (e2) return [e2, t3[n2][1]]; |
| 1125 |
} |
| 1126 |
return [null, void 0]; |
| 1127 |
}; |
| 1128 |
var x = function(r2) { |
| 1129 |
return "string" == typeof r2 ? N(r2.trim(), y.string) : "object" == typeof r2 && null !== r2 ? N(r2, y.object) : [null, void 0]; |
| 1130 |
}; |
| 1131 |
var M = function(r2, t3) { |
| 1132 |
var n2 = c(r2); |
| 1133 |
return { h: n2.h, s: e(n2.s + 100 * t3, 0, 100), l: n2.l, a: n2.a }; |
| 1134 |
}; |
| 1135 |
var H = function(r2) { |
| 1136 |
return (299 * r2.r + 587 * r2.g + 114 * r2.b) / 1e3 / 255; |
| 1137 |
}; |
| 1138 |
var $ = function(r2, t3) { |
| 1139 |
var n2 = c(r2); |
| 1140 |
return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t3, 0, 100), a: n2.a }; |
| 1141 |
}; |
| 1142 |
var j = (function() { |
| 1143 |
function r2(r3) { |
| 1144 |
this.parsed = x(r3)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; |
| 1145 |
} |
| 1146 |
return r2.prototype.isValid = function() { |
| 1147 |
return null !== this.parsed; |
| 1148 |
}, r2.prototype.brightness = function() { |
| 1149 |
return n(H(this.rgba), 2); |
| 1150 |
}, r2.prototype.isDark = function() { |
| 1151 |
return H(this.rgba) < 0.5; |
| 1152 |
}, r2.prototype.isLight = function() { |
| 1153 |
return H(this.rgba) >= 0.5; |
| 1154 |
}, r2.prototype.toHex = function() { |
| 1155 |
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; |
| 1156 |
var r3, t3, e2, u2, a2, i2; |
| 1157 |
}, r2.prototype.toRgb = function() { |
| 1158 |
return o(this.rgba); |
| 1159 |
}, r2.prototype.toRgbString = function() { |
| 1160 |
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 + ")"; |
| 1161 |
var r3, t3, n2, e2, u2; |
| 1162 |
}, r2.prototype.toHsl = function() { |
| 1163 |
return d(c(this.rgba)); |
| 1164 |
}, r2.prototype.toHslString = function() { |
| 1165 |
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 + "%)"; |
| 1166 |
var r3, t3, n2, e2, u2; |
| 1167 |
}, r2.prototype.toHsv = function() { |
| 1168 |
return r3 = h(this.rgba), { h: n(r3.h), s: n(r3.s), v: n(r3.v), a: n(r3.a, 3) }; |
| 1169 |
var r3; |
| 1170 |
}, r2.prototype.invert = function() { |
| 1171 |
return w({ r: 255 - (r3 = this.rgba).r, g: 255 - r3.g, b: 255 - r3.b, a: r3.a }); |
| 1172 |
var r3; |
| 1173 |
}, r2.prototype.saturate = function(r3) { |
| 1174 |
return void 0 === r3 && (r3 = 0.1), w(M(this.rgba, r3)); |
| 1175 |
}, r2.prototype.desaturate = function(r3) { |
| 1176 |
return void 0 === r3 && (r3 = 0.1), w(M(this.rgba, -r3)); |
| 1177 |
}, r2.prototype.grayscale = function() { |
| 1178 |
return w(M(this.rgba, -1)); |
| 1179 |
}, r2.prototype.lighten = function(r3) { |
| 1180 |
return void 0 === r3 && (r3 = 0.1), w($(this.rgba, r3)); |
| 1181 |
}, r2.prototype.darken = function(r3) { |
| 1182 |
return void 0 === r3 && (r3 = 0.1), w($(this.rgba, -r3)); |
| 1183 |
}, r2.prototype.rotate = function(r3) { |
| 1184 |
return void 0 === r3 && (r3 = 15), this.hue(this.hue() + r3); |
| 1185 |
}, r2.prototype.alpha = function(r3) { |
| 1186 |
return "number" == typeof r3 ? w({ r: (t3 = this.rgba).r, g: t3.g, b: t3.b, a: r3 }) : n(this.rgba.a, 3); |
| 1187 |
var t3; |
| 1188 |
}, r2.prototype.hue = function(r3) { |
| 1189 |
var t3 = c(this.rgba); |
| 1190 |
return "number" == typeof r3 ? w({ h: r3, s: t3.s, l: t3.l, a: t3.a }) : n(t3.h); |
| 1191 |
}, r2.prototype.isEqual = function(r3) { |
| 1192 |
return this.toHex() === w(r3).toHex(); |
| 1193 |
}, r2; |
| 1194 |
})(); |
| 1195 |
var w = function(r2) { |
| 1196 |
return r2 instanceof j ? r2 : new j(r2); |
| 1197 |
}; |
| 1198 |
var S = []; |
| 1199 |
var k = function(r2) { |
| 1200 |
r2.forEach(function(r3) { |
| 1201 |
S.indexOf(r3) < 0 && (r3(j, y), S.push(r3)); |
| 1202 |
}); |
| 1203 |
}; |
| 1204 |
|
| 1205 |
// node_modules/colord/plugins/names.mjs |
| 1206 |
function names_default(e2, f2) { |
| 1207 |
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 = {}; |
| 1208 |
for (var d3 in a2) r2[a2[d3]] = d3; |
| 1209 |
var l4 = {}; |
| 1210 |
e2.prototype.toName = function(f3) { |
| 1211 |
if (!(this.rgba.a || this.rgba.r || this.rgba.g || this.rgba.b)) return "transparent"; |
| 1212 |
var d4, i2, n2 = r2[this.toHex()]; |
| 1213 |
if (n2) return n2; |
| 1214 |
if (null == f3 ? void 0 : f3.closest) { |
| 1215 |
var o3 = this.toRgb(), t3 = 1 / 0, b3 = "black"; |
| 1216 |
if (!l4.length) for (var c2 in a2) l4[c2] = new e2(a2[c2]).toRgb(); |
| 1217 |
for (var g3 in a2) { |
| 1218 |
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)); |
| 1219 |
u2 < t3 && (t3 = u2, b3 = g3); |
| 1220 |
} |
| 1221 |
return b3; |
| 1222 |
} |
| 1223 |
}; |
| 1224 |
f2.string.push([function(f3) { |
| 1225 |
var r3 = f3.toLowerCase(), d4 = "transparent" === r3 ? "#0000" : a2[r3]; |
| 1226 |
return d4 ? new e2(d4).toRgb() : null; |
| 1227 |
}, "name"]); |
| 1228 |
} |
| 1229 |
|
| 1230 |
// node_modules/colord/plugins/a11y.mjs |
| 1231 |
var o2 = function(o3) { |
| 1232 |
var t3 = o3 / 255; |
| 1233 |
return t3 < 0.04045 ? t3 / 12.92 : Math.pow((t3 + 0.055) / 1.055, 2.4); |
| 1234 |
}; |
| 1235 |
var t2 = function(t3) { |
| 1236 |
return 0.2126 * o2(t3.r) + 0.7152 * o2(t3.g) + 0.0722 * o2(t3.b); |
| 1237 |
}; |
| 1238 |
function a11y_default(o3) { |
| 1239 |
o3.prototype.luminance = function() { |
| 1240 |
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; |
| 1241 |
var o4, r2, n2; |
| 1242 |
}, o3.prototype.contrast = function(r2) { |
| 1243 |
void 0 === r2 && (r2 = "#FFF"); |
| 1244 |
var n2, a2, i2, e2, v3, u2, d3, c2 = r2 instanceof o3 ? r2 : new o3(r2); |
| 1245 |
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; |
| 1246 |
}, o3.prototype.isReadable = function(o4, t3) { |
| 1247 |
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); |
| 1248 |
var r2, n2, a2, i2, e2; |
| 1249 |
}; |
| 1250 |
} |
| 1251 |
|
| 1252 |
// packages/blocks/build-module/api/utils.mjs |
| 1253 |
var import_element = __toESM(require_element(), 1); |
| 1254 |
var import_i18n2 = __toESM(require_i18n(), 1); |
| 1255 |
var import_dom = __toESM(require_dom(), 1); |
| 1256 |
var import_rich_text = __toESM(require_rich_text(), 1); |
| 1257 |
var import_deprecated = __toESM(require_deprecated(), 1); |
| 1258 |
|
| 1259 |
// packages/blocks/build-module/api/constants.mjs |
| 1260 |
var BLOCK_ICON_DEFAULT = "block-default"; |
| 1261 |
var DEPRECATED_ENTRY_KEYS = [ |
| 1262 |
"attributes", |
| 1263 |
"supports", |
| 1264 |
"save", |
| 1265 |
"migrate", |
| 1266 |
"isEligible", |
| 1267 |
"apiVersion" |
| 1268 |
]; |
| 1269 |
var __EXPERIMENTAL_STYLE_PROPERTY = { |
| 1270 |
// Kept for back-compatibility purposes. |
| 1271 |
"--wp--style--color--link": { |
| 1272 |
value: ["color", "link"], |
| 1273 |
support: ["color", "link"] |
| 1274 |
}, |
| 1275 |
aspectRatio: { |
| 1276 |
value: ["dimensions", "aspectRatio"], |
| 1277 |
support: ["dimensions", "aspectRatio"], |
| 1278 |
useEngine: true |
| 1279 |
}, |
| 1280 |
background: { |
| 1281 |
value: ["color", "gradient"], |
| 1282 |
support: ["color", "gradients"], |
| 1283 |
useEngine: true |
| 1284 |
}, |
| 1285 |
backgroundColor: { |
| 1286 |
value: ["color", "background"], |
| 1287 |
support: ["color", "background"], |
| 1288 |
requiresOptOut: true, |
| 1289 |
useEngine: true |
| 1290 |
}, |
| 1291 |
backgroundImage: { |
| 1292 |
value: ["background", "backgroundImage"], |
| 1293 |
support: ["background", "backgroundImage"], |
| 1294 |
useEngine: true |
| 1295 |
}, |
| 1296 |
backgroundRepeat: { |
| 1297 |
value: ["background", "backgroundRepeat"], |
| 1298 |
support: ["background", "backgroundRepeat"], |
| 1299 |
useEngine: true |
| 1300 |
}, |
| 1301 |
backgroundSize: { |
| 1302 |
value: ["background", "backgroundSize"], |
| 1303 |
support: ["background", "backgroundSize"], |
| 1304 |
useEngine: true |
| 1305 |
}, |
| 1306 |
backgroundPosition: { |
| 1307 |
value: ["background", "backgroundPosition"], |
| 1308 |
support: ["background", "backgroundPosition"], |
| 1309 |
useEngine: true |
| 1310 |
}, |
| 1311 |
backgroundGradient: { |
| 1312 |
value: ["background", "gradient"], |
| 1313 |
support: ["background", "gradient"], |
| 1314 |
useEngine: true |
| 1315 |
}, |
| 1316 |
borderColor: { |
| 1317 |
value: ["border", "color"], |
| 1318 |
support: ["__experimentalBorder", "color"], |
| 1319 |
useEngine: true |
| 1320 |
}, |
| 1321 |
borderRadius: { |
| 1322 |
value: ["border", "radius"], |
| 1323 |
support: ["__experimentalBorder", "radius"], |
| 1324 |
properties: { |
| 1325 |
borderTopLeftRadius: "topLeft", |
| 1326 |
borderTopRightRadius: "topRight", |
| 1327 |
borderBottomLeftRadius: "bottomLeft", |
| 1328 |
borderBottomRightRadius: "bottomRight" |
| 1329 |
}, |
| 1330 |
useEngine: true |
| 1331 |
}, |
| 1332 |
borderStyle: { |
| 1333 |
value: ["border", "style"], |
| 1334 |
support: ["__experimentalBorder", "style"], |
| 1335 |
useEngine: true |
| 1336 |
}, |
| 1337 |
borderWidth: { |
| 1338 |
value: ["border", "width"], |
| 1339 |
support: ["__experimentalBorder", "width"], |
| 1340 |
useEngine: true |
| 1341 |
}, |
| 1342 |
borderTopColor: { |
| 1343 |
value: ["border", "top", "color"], |
| 1344 |
support: ["__experimentalBorder", "color"], |
| 1345 |
useEngine: true |
| 1346 |
}, |
| 1347 |
borderTopStyle: { |
| 1348 |
value: ["border", "top", "style"], |
| 1349 |
support: ["__experimentalBorder", "style"], |
| 1350 |
useEngine: true |
| 1351 |
}, |
| 1352 |
borderTopWidth: { |
| 1353 |
value: ["border", "top", "width"], |
| 1354 |
support: ["__experimentalBorder", "width"], |
| 1355 |
useEngine: true |
| 1356 |
}, |
| 1357 |
borderRightColor: { |
| 1358 |
value: ["border", "right", "color"], |
| 1359 |
support: ["__experimentalBorder", "color"], |
| 1360 |
useEngine: true |
| 1361 |
}, |
| 1362 |
borderRightStyle: { |
| 1363 |
value: ["border", "right", "style"], |
| 1364 |
support: ["__experimentalBorder", "style"], |
| 1365 |
useEngine: true |
| 1366 |
}, |
| 1367 |
borderRightWidth: { |
| 1368 |
value: ["border", "right", "width"], |
| 1369 |
support: ["__experimentalBorder", "width"], |
| 1370 |
useEngine: true |
| 1371 |
}, |
| 1372 |
borderBottomColor: { |
| 1373 |
value: ["border", "bottom", "color"], |
| 1374 |
support: ["__experimentalBorder", "color"], |
| 1375 |
useEngine: true |
| 1376 |
}, |
| 1377 |
borderBottomStyle: { |
| 1378 |
value: ["border", "bottom", "style"], |
| 1379 |
support: ["__experimentalBorder", "style"], |
| 1380 |
useEngine: true |
| 1381 |
}, |
| 1382 |
borderBottomWidth: { |
| 1383 |
value: ["border", "bottom", "width"], |
| 1384 |
support: ["__experimentalBorder", "width"], |
| 1385 |
useEngine: true |
| 1386 |
}, |
| 1387 |
borderLeftColor: { |
| 1388 |
value: ["border", "left", "color"], |
| 1389 |
support: ["__experimentalBorder", "color"], |
| 1390 |
useEngine: true |
| 1391 |
}, |
| 1392 |
borderLeftStyle: { |
| 1393 |
value: ["border", "left", "style"], |
| 1394 |
support: ["__experimentalBorder", "style"], |
| 1395 |
useEngine: true |
| 1396 |
}, |
| 1397 |
borderLeftWidth: { |
| 1398 |
value: ["border", "left", "width"], |
| 1399 |
support: ["__experimentalBorder", "width"], |
| 1400 |
useEngine: true |
| 1401 |
}, |
| 1402 |
color: { |
| 1403 |
value: ["color", "text"], |
| 1404 |
support: ["color", "text"], |
| 1405 |
requiresOptOut: true, |
| 1406 |
useEngine: true |
| 1407 |
}, |
| 1408 |
columnCount: { |
| 1409 |
value: ["typography", "textColumns"], |
| 1410 |
support: ["typography", "textColumns"], |
| 1411 |
useEngine: true |
| 1412 |
}, |
| 1413 |
filter: { |
| 1414 |
value: ["filter", "duotone"], |
| 1415 |
support: ["filter", "duotone"] |
| 1416 |
}, |
| 1417 |
linkColor: { |
| 1418 |
value: ["elements", "link", "color", "text"], |
| 1419 |
support: ["color", "link"] |
| 1420 |
}, |
| 1421 |
captionColor: { |
| 1422 |
value: ["elements", "caption", "color", "text"], |
| 1423 |
support: ["color", "caption"] |
| 1424 |
}, |
| 1425 |
buttonColor: { |
| 1426 |
value: ["elements", "button", "color", "text"], |
| 1427 |
support: ["color", "button"] |
| 1428 |
}, |
| 1429 |
buttonBackgroundColor: { |
| 1430 |
value: ["elements", "button", "color", "background"], |
| 1431 |
support: ["color", "button"] |
| 1432 |
}, |
| 1433 |
headingColor: { |
| 1434 |
value: ["elements", "heading", "color", "text"], |
| 1435 |
support: ["color", "heading"] |
| 1436 |
}, |
| 1437 |
headingBackgroundColor: { |
| 1438 |
value: ["elements", "heading", "color", "background"], |
| 1439 |
support: ["color", "heading"] |
| 1440 |
}, |
| 1441 |
fontFamily: { |
| 1442 |
value: ["typography", "fontFamily"], |
| 1443 |
support: ["typography", "__experimentalFontFamily"], |
| 1444 |
useEngine: true |
| 1445 |
}, |
| 1446 |
fontSize: { |
| 1447 |
value: ["typography", "fontSize"], |
| 1448 |
support: ["typography", "fontSize"], |
| 1449 |
useEngine: true |
| 1450 |
}, |
| 1451 |
fontStyle: { |
| 1452 |
value: ["typography", "fontStyle"], |
| 1453 |
support: ["typography", "__experimentalFontStyle"], |
| 1454 |
useEngine: true |
| 1455 |
}, |
| 1456 |
fontWeight: { |
| 1457 |
value: ["typography", "fontWeight"], |
| 1458 |
support: ["typography", "__experimentalFontWeight"], |
| 1459 |
useEngine: true |
| 1460 |
}, |
| 1461 |
lineHeight: { |
| 1462 |
value: ["typography", "lineHeight"], |
| 1463 |
support: ["typography", "lineHeight"], |
| 1464 |
useEngine: true |
| 1465 |
}, |
| 1466 |
margin: { |
| 1467 |
value: ["spacing", "margin"], |
| 1468 |
support: ["spacing", "margin"], |
| 1469 |
properties: { |
| 1470 |
marginTop: "top", |
| 1471 |
marginRight: "right", |
| 1472 |
marginBottom: "bottom", |
| 1473 |
marginLeft: "left" |
| 1474 |
}, |
| 1475 |
useEngine: true |
| 1476 |
}, |
| 1477 |
minHeight: { |
| 1478 |
value: ["dimensions", "minHeight"], |
| 1479 |
support: ["dimensions", "minHeight"], |
| 1480 |
useEngine: true |
| 1481 |
}, |
| 1482 |
minWidth: { |
| 1483 |
value: ["dimensions", "minWidth"], |
| 1484 |
support: ["dimensions", "minWidth"], |
| 1485 |
useEngine: true |
| 1486 |
}, |
| 1487 |
height: { |
| 1488 |
value: ["dimensions", "height"], |
| 1489 |
support: ["dimensions", "height"], |
| 1490 |
useEngine: true |
| 1491 |
}, |
| 1492 |
width: { |
| 1493 |
value: ["dimensions", "width"], |
| 1494 |
support: ["dimensions", "width"], |
| 1495 |
useEngine: true |
| 1496 |
}, |
| 1497 |
padding: { |
| 1498 |
value: ["spacing", "padding"], |
| 1499 |
support: ["spacing", "padding"], |
| 1500 |
properties: { |
| 1501 |
paddingTop: "top", |
| 1502 |
paddingRight: "right", |
| 1503 |
paddingBottom: "bottom", |
| 1504 |
paddingLeft: "left" |
| 1505 |
}, |
| 1506 |
useEngine: true |
| 1507 |
}, |
| 1508 |
textAlign: { |
| 1509 |
value: ["typography", "textAlign"], |
| 1510 |
support: ["typography", "textAlign"], |
| 1511 |
useEngine: false |
| 1512 |
}, |
| 1513 |
textDecoration: { |
| 1514 |
value: ["typography", "textDecoration"], |
| 1515 |
support: ["typography", "__experimentalTextDecoration"], |
| 1516 |
useEngine: true |
| 1517 |
}, |
| 1518 |
textTransform: { |
| 1519 |
value: ["typography", "textTransform"], |
| 1520 |
support: ["typography", "__experimentalTextTransform"], |
| 1521 |
useEngine: true |
| 1522 |
}, |
| 1523 |
letterSpacing: { |
| 1524 |
value: ["typography", "letterSpacing"], |
| 1525 |
support: ["typography", "__experimentalLetterSpacing"], |
| 1526 |
useEngine: true |
| 1527 |
}, |
| 1528 |
textIndent: { |
| 1529 |
value: ["typography", "textIndent"], |
| 1530 |
support: ["typography", "textIndent"], |
| 1531 |
useEngine: true |
| 1532 |
}, |
| 1533 |
writingMode: { |
| 1534 |
value: ["typography", "writingMode"], |
| 1535 |
support: ["typography", "__experimentalWritingMode"], |
| 1536 |
useEngine: true |
| 1537 |
}, |
| 1538 |
"--wp--style--root--padding": { |
| 1539 |
value: ["spacing", "padding"], |
| 1540 |
support: ["spacing", "padding"], |
| 1541 |
properties: { |
| 1542 |
"--wp--style--root--padding-top": "top", |
| 1543 |
"--wp--style--root--padding-right": "right", |
| 1544 |
"--wp--style--root--padding-bottom": "bottom", |
| 1545 |
"--wp--style--root--padding-left": "left" |
| 1546 |
}, |
| 1547 |
rootOnly: true |
| 1548 |
} |
| 1549 |
}; |
| 1550 |
var __EXPERIMENTAL_ELEMENTS = { |
| 1551 |
link: "a:where(:not(.wp-element-button))", |
| 1552 |
heading: "h1, h2, h3, h4, h5, h6", |
| 1553 |
h1: "h1", |
| 1554 |
h2: "h2", |
| 1555 |
h3: "h3", |
| 1556 |
h4: "h4", |
| 1557 |
h5: "h5", |
| 1558 |
h6: "h6", |
| 1559 |
button: ".wp-element-button, .wp-block-button__link", |
| 1560 |
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", |
| 1561 |
cite: "cite", |
| 1562 |
select: "select", |
| 1563 |
textInput: "textarea, input:where([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=url])" |
| 1564 |
}; |
| 1565 |
var __EXPERIMENTAL_PATHS_WITH_OVERRIDE = { |
| 1566 |
"color.duotone": true, |
| 1567 |
"color.gradients": true, |
| 1568 |
"color.palette": true, |
| 1569 |
"dimensions.aspectRatios": true, |
| 1570 |
"typography.fontSizes": true, |
| 1571 |
"spacing.spacingSizes": true |
| 1572 |
}; |
| 1573 |
|
| 1574 |
// packages/blocks/build-module/api/registration.mjs |
| 1575 |
var import_data = __toESM(require_data(), 1); |
| 1576 |
var import_i18n = __toESM(require_i18n(), 1); |
| 1577 |
var import_warning = __toESM(require_warning(), 1); |
| 1578 |
|
| 1579 |
// packages/blocks/build-module/api/i18n-block.json |
| 1580 |
var i18n_block_default = { |
| 1581 |
title: "block title", |
| 1582 |
description: "block description", |
| 1583 |
keywords: ["block keyword"], |
| 1584 |
styles: [ |
| 1585 |
{ |
| 1586 |
label: "block style label" |
| 1587 |
} |
| 1588 |
], |
| 1589 |
variations: [ |
| 1590 |
{ |
| 1591 |
title: "block variation title", |
| 1592 |
description: "block variation description", |
| 1593 |
keywords: ["block variation keyword"] |
| 1594 |
} |
| 1595 |
] |
| 1596 |
}; |
| 1597 |
|
| 1598 |
// packages/blocks/build-module/lock-unlock.mjs |
| 1599 |
var import_private_apis = __toESM(require_private_apis(), 1); |
| 1600 |
var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( |
| 1601 |
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", |
| 1602 |
"@wordpress/blocks" |
| 1603 |
); |
| 1604 |
|
| 1605 |
// packages/blocks/build-module/api/registration.mjs |
| 1606 |
function isObject(object) { |
| 1607 |
return object !== null && typeof object === "object"; |
| 1608 |
} |
| 1609 |
function unstable__bootstrapServerSideBlockDefinitions(definitions) { |
| 1610 |
const { addBootstrappedBlockType: addBootstrappedBlockType2 } = unlock((0, import_data.dispatch)(store)); |
| 1611 |
for (const [name, blockType] of Object.entries(definitions)) { |
| 1612 |
addBootstrappedBlockType2(name, blockType); |
| 1613 |
} |
| 1614 |
} |
| 1615 |
function getBlockSettingsFromMetadata({ |
| 1616 |
textdomain, |
| 1617 |
...metadata |
| 1618 |
}) { |
| 1619 |
const allowedFields = [ |
| 1620 |
"apiVersion", |
| 1621 |
"title", |
| 1622 |
"category", |
| 1623 |
"parent", |
| 1624 |
"ancestor", |
| 1625 |
"icon", |
| 1626 |
"description", |
| 1627 |
"keywords", |
| 1628 |
"attributes", |
| 1629 |
"providesContext", |
| 1630 |
"usesContext", |
| 1631 |
"selectors", |
| 1632 |
"supports", |
| 1633 |
"styles", |
| 1634 |
"example", |
| 1635 |
"variations", |
| 1636 |
"blockHooks", |
| 1637 |
"allowedBlocks" |
| 1638 |
]; |
| 1639 |
const settings = Object.fromEntries( |
| 1640 |
Object.entries(metadata).filter( |
| 1641 |
([key]) => allowedFields.includes(key) |
| 1642 |
) |
| 1643 |
); |
| 1644 |
if (textdomain) { |
| 1645 |
Object.keys(i18n_block_default).forEach((key) => { |
| 1646 |
if (!settings[key]) { |
| 1647 |
return; |
| 1648 |
} |
| 1649 |
settings[key] = translateBlockSettingUsingI18nSchema( |
| 1650 |
i18n_block_default[key], |
| 1651 |
settings[key], |
| 1652 |
textdomain |
| 1653 |
); |
| 1654 |
}); |
| 1655 |
} |
| 1656 |
return settings; |
| 1657 |
} |
| 1658 |
function registerBlockType(blockNameOrMetadata, settings) { |
| 1659 |
const name = isObject(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata; |
| 1660 |
if (typeof name !== "string") { |
| 1661 |
(0, import_warning.default)("Block names must be strings."); |
| 1662 |
return; |
| 1663 |
} |
| 1664 |
if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) { |
| 1665 |
(0, import_warning.default)( |
| 1666 |
"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" |
| 1667 |
); |
| 1668 |
return; |
| 1669 |
} |
| 1670 |
if ((0, import_data.select)(store).getBlockType(name)) { |
| 1671 |
(0, import_warning.default)('Block "' + name + '" is already registered.'); |
| 1672 |
return; |
| 1673 |
} |
| 1674 |
const { addBootstrappedBlockType: addBootstrappedBlockType2, addUnprocessedBlockType: addUnprocessedBlockType2 } = unlock( |
| 1675 |
(0, import_data.dispatch)(store) |
| 1676 |
); |
| 1677 |
if (isObject(blockNameOrMetadata)) { |
| 1678 |
const metadata = getBlockSettingsFromMetadata(blockNameOrMetadata); |
| 1679 |
addBootstrappedBlockType2(name, metadata); |
| 1680 |
} |
| 1681 |
addUnprocessedBlockType2(name, settings); |
| 1682 |
return (0, import_data.select)(store).getBlockType(name); |
| 1683 |
} |
| 1684 |
function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) { |
| 1685 |
if (typeof i18nSchema === "string" && typeof settingValue === "string") { |
| 1686 |
return (0, import_i18n._x)(settingValue, i18nSchema, textdomain); |
| 1687 |
} |
| 1688 |
if (Array.isArray(i18nSchema) && i18nSchema.length && Array.isArray(settingValue)) { |
| 1689 |
return settingValue.map( |
| 1690 |
(value) => translateBlockSettingUsingI18nSchema( |
| 1691 |
i18nSchema[0], |
| 1692 |
value, |
| 1693 |
textdomain |
| 1694 |
) |
| 1695 |
); |
| 1696 |
} |
| 1697 |
if (isObject(i18nSchema) && Object.entries(i18nSchema).length && isObject(settingValue)) { |
| 1698 |
return Object.keys(settingValue).reduce( |
| 1699 |
(accumulator, key) => { |
| 1700 |
if (!i18nSchema[key]) { |
| 1701 |
accumulator[key] = settingValue[key]; |
| 1702 |
return accumulator; |
| 1703 |
} |
| 1704 |
accumulator[key] = translateBlockSettingUsingI18nSchema( |
| 1705 |
i18nSchema[key], |
| 1706 |
settingValue[key], |
| 1707 |
textdomain |
| 1708 |
); |
| 1709 |
return accumulator; |
| 1710 |
}, |
| 1711 |
{} |
| 1712 |
); |
| 1713 |
} |
| 1714 |
return settingValue; |
| 1715 |
} |
| 1716 |
function registerBlockCollection(namespace, { title, icon }) { |
| 1717 |
(0, import_data.dispatch)(store).addBlockCollection(namespace, title, icon); |
| 1718 |
} |
| 1719 |
function unregisterBlockType(name) { |
| 1720 |
const oldBlock = (0, import_data.select)(store).getBlockType(name); |
| 1721 |
if (!oldBlock) { |
| 1722 |
(0, import_warning.default)('Block "' + name + '" is not registered.'); |
| 1723 |
return; |
| 1724 |
} |
| 1725 |
(0, import_data.dispatch)(store).removeBlockTypes(name); |
| 1726 |
return oldBlock; |
| 1727 |
} |
| 1728 |
function setFreeformContentHandlerName(blockName) { |
| 1729 |
(0, import_data.dispatch)(store).setFreeformFallbackBlockName(blockName); |
| 1730 |
} |
| 1731 |
function getFreeformContentHandlerName() { |
| 1732 |
return (0, import_data.select)(store).getFreeformFallbackBlockName(); |
| 1733 |
} |
| 1734 |
function getGroupingBlockName() { |
| 1735 |
return (0, import_data.select)(store).getGroupingBlockName(); |
| 1736 |
} |
| 1737 |
function setUnregisteredTypeHandlerName(blockName) { |
| 1738 |
(0, import_data.dispatch)(store).setUnregisteredFallbackBlockName(blockName); |
| 1739 |
} |
| 1740 |
function getUnregisteredTypeHandlerName() { |
| 1741 |
return (0, import_data.select)(store).getUnregisteredFallbackBlockName(); |
| 1742 |
} |
| 1743 |
function setDefaultBlockName(name) { |
| 1744 |
(0, import_data.dispatch)(store).setDefaultBlockName(name); |
| 1745 |
} |
| 1746 |
function setGroupingBlockName(name) { |
| 1747 |
(0, import_data.dispatch)(store).setGroupingBlockName(name); |
| 1748 |
} |
| 1749 |
function getDefaultBlockName() { |
| 1750 |
return (0, import_data.select)(store).getDefaultBlockName(); |
| 1751 |
} |
| 1752 |
function getBlockType(name) { |
| 1753 |
return (0, import_data.select)(store)?.getBlockType(name); |
| 1754 |
} |
| 1755 |
function getBlockTypes() { |
| 1756 |
return (0, import_data.select)(store).getBlockTypes(); |
| 1757 |
} |
| 1758 |
function getBlockSupport(nameOrType, feature, defaultSupports) { |
| 1759 |
return (0, import_data.select)(store).getBlockSupport( |
| 1760 |
nameOrType, |
| 1761 |
feature, |
| 1762 |
defaultSupports |
| 1763 |
); |
| 1764 |
} |
| 1765 |
function hasBlockSupport(nameOrType, feature, defaultSupports) { |
| 1766 |
return (0, import_data.select)(store).hasBlockSupport( |
| 1767 |
nameOrType, |
| 1768 |
feature, |
| 1769 |
defaultSupports |
| 1770 |
); |
| 1771 |
} |
| 1772 |
function isReusableBlock(blockOrType) { |
| 1773 |
return blockOrType?.name === "core/block"; |
| 1774 |
} |
| 1775 |
function isTemplatePart(blockOrType) { |
| 1776 |
return blockOrType?.name === "core/template-part"; |
| 1777 |
} |
| 1778 |
var getChildBlockNames = (blockName) => { |
| 1779 |
return (0, import_data.select)(store).getChildBlockNames(blockName); |
| 1780 |
}; |
| 1781 |
var hasChildBlocks = (blockName) => { |
| 1782 |
return (0, import_data.select)(store).hasChildBlocks(blockName); |
| 1783 |
}; |
| 1784 |
var hasChildBlocksWithInserterSupport = (blockName) => { |
| 1785 |
return (0, import_data.select)(store).hasChildBlocksWithInserterSupport(blockName); |
| 1786 |
}; |
| 1787 |
var registerBlockStyle = (blockNames, styleVariation) => { |
| 1788 |
(0, import_data.dispatch)(store).addBlockStyles(blockNames, styleVariation); |
| 1789 |
}; |
| 1790 |
var unregisterBlockStyle = (blockName, styleVariationName) => { |
| 1791 |
(0, import_data.dispatch)(store).removeBlockStyles(blockName, styleVariationName); |
| 1792 |
}; |
| 1793 |
var getBlockVariations = (blockName, scope) => { |
| 1794 |
return (0, import_data.select)(store).getBlockVariations(blockName, scope); |
| 1795 |
}; |
| 1796 |
var registerBlockVariation = (blockName, variation) => { |
| 1797 |
if (Array.isArray(variation)) { |
| 1798 |
for (const v3 of variation) { |
| 1799 |
if (typeof v3.name !== "string") { |
| 1800 |
(0, import_warning.default)("Variation names must be unique strings."); |
| 1801 |
} |
| 1802 |
} |
| 1803 |
} else if (typeof variation.name !== "string") { |
| 1804 |
(0, import_warning.default)("Variation names must be unique strings."); |
| 1805 |
} |
| 1806 |
(0, import_data.dispatch)(store).addBlockVariations(blockName, variation); |
| 1807 |
}; |
| 1808 |
var unregisterBlockVariation = (blockName, variationName) => { |
| 1809 |
(0, import_data.dispatch)(store).removeBlockVariations(blockName, variationName); |
| 1810 |
}; |
| 1811 |
var registerBlockBindingsSource = (source) => { |
| 1812 |
const { |
| 1813 |
name, |
| 1814 |
label, |
| 1815 |
usesContext, |
| 1816 |
getValues, |
| 1817 |
setValues, |
| 1818 |
canUserEditValue, |
| 1819 |
getFieldsList |
| 1820 |
} = source; |
| 1821 |
const existingSource = unlock( |
| 1822 |
(0, import_data.select)(store) |
| 1823 |
).getBlockBindingsSource(name); |
| 1824 |
const serverProps = ["label", "usesContext"]; |
| 1825 |
for (const prop2 in existingSource) { |
| 1826 |
if (!serverProps.includes(prop2) && existingSource[prop2]) { |
| 1827 |
(0, import_warning.default)( |
| 1828 |
'Block bindings source "' + name + '" is already registered.' |
| 1829 |
); |
| 1830 |
return; |
| 1831 |
} |
| 1832 |
} |
| 1833 |
if (!name) { |
| 1834 |
(0, import_warning.default)("Block bindings source must contain a name."); |
| 1835 |
return; |
| 1836 |
} |
| 1837 |
if (typeof name !== "string") { |
| 1838 |
(0, import_warning.default)("Block bindings source name must be a string."); |
| 1839 |
return; |
| 1840 |
} |
| 1841 |
if (/[A-Z]+/.test(name)) { |
| 1842 |
(0, import_warning.default)( |
| 1843 |
"Block bindings source name must not contain uppercase characters." |
| 1844 |
); |
| 1845 |
return; |
| 1846 |
} |
| 1847 |
if (!/^[a-z0-9/-]+$/.test(name)) { |
| 1848 |
(0, import_warning.default)( |
| 1849 |
"Block bindings source name must contain only valid characters: lowercase characters, hyphens, or digits. Example: my-plugin/my-custom-source." |
| 1850 |
); |
| 1851 |
return; |
| 1852 |
} |
| 1853 |
if (!/^[a-z0-9-]+\/[a-z0-9-]+$/.test(name)) { |
| 1854 |
(0, import_warning.default)( |
| 1855 |
"Block bindings source name must contain a namespace and valid characters. Example: my-plugin/my-custom-source." |
| 1856 |
); |
| 1857 |
return; |
| 1858 |
} |
| 1859 |
if (!label && !existingSource?.label) { |
| 1860 |
(0, import_warning.default)("Block bindings source must contain a label."); |
| 1861 |
return; |
| 1862 |
} |
| 1863 |
if (label && typeof label !== "string") { |
| 1864 |
(0, import_warning.default)("Block bindings source label must be a string."); |
| 1865 |
return; |
| 1866 |
} |
| 1867 |
if (label && existingSource?.label && label !== existingSource?.label) { |
| 1868 |
(0, import_warning.default)('Block bindings "' + name + '" source label was overridden.'); |
| 1869 |
} |
| 1870 |
if (usesContext && !Array.isArray(usesContext)) { |
| 1871 |
(0, import_warning.default)("Block bindings source usesContext must be an array."); |
| 1872 |
return; |
| 1873 |
} |
| 1874 |
if (getValues && typeof getValues !== "function") { |
| 1875 |
(0, import_warning.default)("Block bindings source getValues must be a function."); |
| 1876 |
return; |
| 1877 |
} |
| 1878 |
if (setValues && typeof setValues !== "function") { |
| 1879 |
(0, import_warning.default)("Block bindings source setValues must be a function."); |
| 1880 |
return; |
| 1881 |
} |
| 1882 |
if (canUserEditValue && typeof canUserEditValue !== "function") { |
| 1883 |
(0, import_warning.default)("Block bindings source canUserEditValue must be a function."); |
| 1884 |
return; |
| 1885 |
} |
| 1886 |
if (getFieldsList && typeof getFieldsList !== "function") { |
| 1887 |
(0, import_warning.default)("Block bindings source getFieldsList must be a function."); |
| 1888 |
return; |
| 1889 |
} |
| 1890 |
return unlock((0, import_data.dispatch)(store)).addBlockBindingsSource(source); |
| 1891 |
}; |
| 1892 |
function unregisterBlockBindingsSource(name) { |
| 1893 |
const oldSource = getBlockBindingsSource(name); |
| 1894 |
if (!oldSource) { |
| 1895 |
(0, import_warning.default)('Block bindings source "' + name + '" is not registered.'); |
| 1896 |
return; |
| 1897 |
} |
| 1898 |
unlock((0, import_data.dispatch)(store)).removeBlockBindingsSource(name); |
| 1899 |
} |
| 1900 |
function getBlockBindingsSource(name) { |
| 1901 |
return unlock((0, import_data.select)(store)).getBlockBindingsSource(name); |
| 1902 |
} |
| 1903 |
function getBlockBindingsSources() { |
| 1904 |
return unlock((0, import_data.select)(store)).getAllBlockBindingsSources(); |
| 1905 |
} |
| 1906 |
|
| 1907 |
// packages/blocks/build-module/api/utils.mjs |
| 1908 |
k([names_default, a11y_default]); |
| 1909 |
var ICON_COLORS = ["#191e23", "#f8f9f9"]; |
| 1910 |
function isUnmodifiedBlock(block, role) { |
| 1911 |
const blockAttributes = getBlockType(block.name)?.attributes ?? {}; |
| 1912 |
const attributesByRole = role ? Object.entries(blockAttributes).filter(([key, definition]) => { |
| 1913 |
if (role === "content" && key === "metadata") { |
| 1914 |
return Object.keys( |
| 1915 |
block.attributes[key]?.bindings ?? {} |
| 1916 |
).length > 0; |
| 1917 |
} |
| 1918 |
return definition.role === role || definition.__experimentalRole === role; |
| 1919 |
}) : []; |
| 1920 |
const attributesToCheck = !!attributesByRole.length ? attributesByRole : Object.entries(blockAttributes); |
| 1921 |
return attributesToCheck.every(([key, definition]) => { |
| 1922 |
const value = block.attributes[key]; |
| 1923 |
if (definition.hasOwnProperty("default")) { |
| 1924 |
return value === definition.default; |
| 1925 |
} |
| 1926 |
if (definition.type === "rich-text") { |
| 1927 |
return !value?.length; |
| 1928 |
} |
| 1929 |
return value === void 0; |
| 1930 |
}); |
| 1931 |
} |
| 1932 |
function isUnmodifiedDefaultBlock(block, role) { |
| 1933 |
return block.name === getDefaultBlockName() && isUnmodifiedBlock(block, role); |
| 1934 |
} |
| 1935 |
function isValidIcon(icon) { |
| 1936 |
return !!icon && (typeof icon === "string" || (0, import_element.isValidElement)(icon) || typeof icon === "function" || icon instanceof import_element.Component); |
| 1937 |
} |
| 1938 |
function normalizeIconObject(icon) { |
| 1939 |
const resolvedIcon = icon || BLOCK_ICON_DEFAULT; |
| 1940 |
if (isValidIcon(resolvedIcon)) { |
| 1941 |
return { src: resolvedIcon }; |
| 1942 |
} |
| 1943 |
const iconDescriptor = resolvedIcon; |
| 1944 |
if ("background" in iconDescriptor) { |
| 1945 |
const colordBgColor = w(iconDescriptor.background); |
| 1946 |
const getColorContrast = (iconColor) => colordBgColor.contrast(iconColor); |
| 1947 |
const maxContrast = Math.max(...ICON_COLORS.map(getColorContrast)); |
| 1948 |
return { |
| 1949 |
...iconDescriptor, |
| 1950 |
foreground: iconDescriptor.foreground ? iconDescriptor.foreground : ICON_COLORS.find( |
| 1951 |
(iconColor) => getColorContrast(iconColor) === maxContrast |
| 1952 |
), |
| 1953 |
shadowColor: colordBgColor.alpha(0.3).toRgbString() |
| 1954 |
}; |
| 1955 |
} |
| 1956 |
return iconDescriptor; |
| 1957 |
} |
| 1958 |
function normalizeBlockType(blockTypeOrName) { |
| 1959 |
if (typeof blockTypeOrName === "string") { |
| 1960 |
return getBlockType(blockTypeOrName); |
| 1961 |
} |
| 1962 |
return blockTypeOrName; |
| 1963 |
} |
| 1964 |
function getBlockLabel(blockType, attributes, context = "visual") { |
| 1965 |
const { __experimentalLabel: getLabel, title } = blockType; |
| 1966 |
const label = getLabel && getLabel(attributes, { context }); |
| 1967 |
if (!label) { |
| 1968 |
return title; |
| 1969 |
} |
| 1970 |
if (label.toPlainText) { |
| 1971 |
return label.toPlainText(); |
| 1972 |
} |
| 1973 |
return (0, import_dom.__unstableStripHTML)(label); |
| 1974 |
} |
| 1975 |
function getAccessibleBlockLabel(blockType, attributes, position, direction = "vertical") { |
| 1976 |
const title = blockType?.title ?? ""; |
| 1977 |
const label = blockType ? getBlockLabel(blockType, attributes, "accessibility") : ""; |
| 1978 |
const hasPosition = position !== void 0; |
| 1979 |
const hasLabel = label && label !== title; |
| 1980 |
if (hasPosition && direction === "vertical") { |
| 1981 |
if (hasLabel) { |
| 1982 |
return (0, import_i18n2.sprintf)( |
| 1983 |
/* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */ |
| 1984 |
(0, import_i18n2.__)("%1$s Block. Row %2$d. %3$s"), |
| 1985 |
title, |
| 1986 |
position, |
| 1987 |
label |
| 1988 |
); |
| 1989 |
} |
| 1990 |
return (0, import_i18n2.sprintf)( |
| 1991 |
/* translators: accessibility text. 1: The block title. 2: The block row number. */ |
| 1992 |
(0, import_i18n2.__)("%1$s Block. Row %2$d"), |
| 1993 |
title, |
| 1994 |
position |
| 1995 |
); |
| 1996 |
} else if (hasPosition && direction === "horizontal") { |
| 1997 |
if (hasLabel) { |
| 1998 |
return (0, import_i18n2.sprintf)( |
| 1999 |
/* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */ |
| 2000 |
(0, import_i18n2.__)("%1$s Block. Column %2$d. %3$s"), |
| 2001 |
title, |
| 2002 |
position, |
| 2003 |
label |
| 2004 |
); |
| 2005 |
} |
| 2006 |
return (0, import_i18n2.sprintf)( |
| 2007 |
/* translators: accessibility text. 1: The block title. 2: The block column number. */ |
| 2008 |
(0, import_i18n2.__)("%1$s Block. Column %2$d"), |
| 2009 |
title, |
| 2010 |
position |
| 2011 |
); |
| 2012 |
} |
| 2013 |
if (hasLabel) { |
| 2014 |
return (0, import_i18n2.sprintf)( |
| 2015 |
/* translators: accessibility text. 1: The block title. 2: The block label. */ |
| 2016 |
(0, import_i18n2.__)("%1$s Block. %2$s"), |
| 2017 |
title, |
| 2018 |
label |
| 2019 |
); |
| 2020 |
} |
| 2021 |
return (0, import_i18n2.sprintf)( |
| 2022 |
/* translators: accessibility text. %s: The block title. */ |
| 2023 |
(0, import_i18n2.__)("%s Block"), |
| 2024 |
title |
| 2025 |
); |
| 2026 |
} |
| 2027 |
function getDefault(attributeSchema) { |
| 2028 |
if (attributeSchema.default !== void 0) { |
| 2029 |
return attributeSchema.default; |
| 2030 |
} |
| 2031 |
if (attributeSchema.type === "rich-text") { |
| 2032 |
return new import_rich_text.RichTextData(); |
| 2033 |
} |
| 2034 |
return void 0; |
| 2035 |
} |
| 2036 |
function isBlockRegistered(name) { |
| 2037 |
return getBlockType(name) !== void 0; |
| 2038 |
} |
| 2039 |
function __experimentalSanitizeBlockAttributes(name, attributes) { |
| 2040 |
const blockType = getBlockType(name); |
| 2041 |
if (void 0 === blockType) { |
| 2042 |
throw new Error(`Block type '${name}' is not registered.`); |
| 2043 |
} |
| 2044 |
return Object.entries(blockType.attributes).reduce( |
| 2045 |
(accumulator, [key, schema]) => { |
| 2046 |
const value = attributes[key]; |
| 2047 |
if (void 0 !== value) { |
| 2048 |
if (schema.type === "rich-text") { |
| 2049 |
if (value instanceof import_rich_text.RichTextData) { |
| 2050 |
accumulator[key] = value; |
| 2051 |
} else if (typeof value === "string") { |
| 2052 |
accumulator[key] = import_rich_text.RichTextData.fromHTMLString(value); |
| 2053 |
} |
| 2054 |
} else if (schema.type === "string" && value instanceof import_rich_text.RichTextData) { |
| 2055 |
accumulator[key] = value.toHTMLString(); |
| 2056 |
} else { |
| 2057 |
accumulator[key] = value; |
| 2058 |
} |
| 2059 |
} else { |
| 2060 |
const _default = getDefault(schema); |
| 2061 |
if (void 0 !== _default) { |
| 2062 |
accumulator[key] = _default; |
| 2063 |
} |
| 2064 |
} |
| 2065 |
if (["node", "children"].indexOf(schema.source ?? "") !== -1) { |
| 2066 |
if (typeof accumulator[key] === "string") { |
| 2067 |
accumulator[key] = [accumulator[key]]; |
| 2068 |
} else if (!Array.isArray(accumulator[key])) { |
| 2069 |
accumulator[key] = []; |
| 2070 |
} |
| 2071 |
} |
| 2072 |
return accumulator; |
| 2073 |
}, |
| 2074 |
{} |
| 2075 |
); |
| 2076 |
} |
| 2077 |
function getBlockAttributesNamesByRole(name, role) { |
| 2078 |
const attributes = getBlockType(name)?.attributes; |
| 2079 |
if (!attributes) { |
| 2080 |
return []; |
| 2081 |
} |
| 2082 |
const attributesNames = Object.keys(attributes); |
| 2083 |
if (!role) { |
| 2084 |
return attributesNames; |
| 2085 |
} |
| 2086 |
return attributesNames.filter((attributeName) => { |
| 2087 |
const attribute = attributes[attributeName]; |
| 2088 |
if (attribute?.role === role) { |
| 2089 |
return true; |
| 2090 |
} |
| 2091 |
if (attribute?.__experimentalRole === role) { |
| 2092 |
(0, import_deprecated.default)("__experimentalRole attribute", { |
| 2093 |
since: "6.7", |
| 2094 |
version: "6.8", |
| 2095 |
alternative: "role attribute", |
| 2096 |
hint: `Check the block.json of the ${name} block.` |
| 2097 |
}); |
| 2098 |
return true; |
| 2099 |
} |
| 2100 |
return false; |
| 2101 |
}); |
| 2102 |
} |
| 2103 |
var __experimentalGetBlockAttributesNamesByRole = (...args) => { |
| 2104 |
(0, import_deprecated.default)("__experimentalGetBlockAttributesNamesByRole", { |
| 2105 |
since: "6.7", |
| 2106 |
version: "6.8", |
| 2107 |
alternative: "getBlockAttributesNamesByRole" |
| 2108 |
}); |
| 2109 |
return getBlockAttributesNamesByRole(...args); |
| 2110 |
}; |
| 2111 |
function isContentBlock(name) { |
| 2112 |
const blockType = getBlockType(name); |
| 2113 |
const attributes = blockType?.attributes; |
| 2114 |
const supportsContentRole = blockType?.supports?.contentRole; |
| 2115 |
if (supportsContentRole) { |
| 2116 |
return true; |
| 2117 |
} |
| 2118 |
if (!attributes) { |
| 2119 |
return false; |
| 2120 |
} |
| 2121 |
return !!Object.keys(attributes)?.some((attributeKey) => { |
| 2122 |
const attribute = attributes[attributeKey]; |
| 2123 |
return attribute?.role === "content" || attribute?.__experimentalRole === "content"; |
| 2124 |
}); |
| 2125 |
} |
| 2126 |
function omit(object, keys) { |
| 2127 |
const keysArray = Array.isArray(keys) ? keys : [keys]; |
| 2128 |
return Object.fromEntries( |
| 2129 |
Object.entries(object).filter( |
| 2130 |
([key]) => !keysArray.includes(key) |
| 2131 |
) |
| 2132 |
); |
| 2133 |
} |
| 2134 |
|
| 2135 |
// packages/blocks/build-module/store/reducer.mjs |
| 2136 |
var DEFAULT_CATEGORIES = [ |
| 2137 |
{ slug: "text", title: (0, import_i18n3.__)("Text") }, |
| 2138 |
{ slug: "media", title: (0, import_i18n3.__)("Media") }, |
| 2139 |
{ slug: "design", title: (0, import_i18n3.__)("Design") }, |
| 2140 |
{ slug: "widgets", title: (0, import_i18n3.__)("Widgets") }, |
| 2141 |
{ slug: "theme", title: (0, import_i18n3.__)("Theme") }, |
| 2142 |
{ slug: "embed", title: (0, import_i18n3.__)("Embeds") }, |
| 2143 |
{ slug: "reusable", title: (0, import_i18n3.__)("Reusable blocks") } |
| 2144 |
]; |
| 2145 |
function keyBlockTypesByName(types) { |
| 2146 |
return types.reduce( |
| 2147 |
(newBlockTypes, block) => ({ |
| 2148 |
...newBlockTypes, |
| 2149 |
[block.name]: block |
| 2150 |
}), |
| 2151 |
{} |
| 2152 |
); |
| 2153 |
} |
| 2154 |
function getUniqueItemsByName(items) { |
| 2155 |
return items.reduce((acc, currentItem) => { |
| 2156 |
if (!acc.some((item) => item.name === currentItem.name)) { |
| 2157 |
acc.push(currentItem); |
| 2158 |
} |
| 2159 |
return acc; |
| 2160 |
}, []); |
| 2161 |
} |
| 2162 |
function bootstrappedBlockTypes(state = {}, action) { |
| 2163 |
switch (action.type) { |
| 2164 |
case "ADD_BOOTSTRAPPED_BLOCK_TYPE": |
| 2165 |
const { name, blockType } = action; |
| 2166 |
const serverDefinition = state[name]; |
| 2167 |
if (serverDefinition) { |
| 2168 |
return state; |
| 2169 |
} |
| 2170 |
const newDefinition = Object.fromEntries( |
| 2171 |
Object.entries(blockType).filter( |
| 2172 |
([, value]) => value !== null && value !== void 0 |
| 2173 |
).map(([key, value]) => [camelCase(key), value]) |
| 2174 |
); |
| 2175 |
newDefinition.name = name; |
| 2176 |
return { |
| 2177 |
...state, |
| 2178 |
[name]: newDefinition |
| 2179 |
}; |
| 2180 |
case "REMOVE_BLOCK_TYPES": |
| 2181 |
return omit(state, action.names); |
| 2182 |
} |
| 2183 |
return state; |
| 2184 |
} |
| 2185 |
function unprocessedBlockTypes(state = {}, action) { |
| 2186 |
switch (action.type) { |
| 2187 |
case "ADD_UNPROCESSED_BLOCK_TYPE": |
| 2188 |
return { |
| 2189 |
...state, |
| 2190 |
[action.name]: action.blockType |
| 2191 |
}; |
| 2192 |
case "REMOVE_BLOCK_TYPES": |
| 2193 |
return omit(state, action.names); |
| 2194 |
} |
| 2195 |
return state; |
| 2196 |
} |
| 2197 |
function blockTypes(state = {}, action) { |
| 2198 |
switch (action.type) { |
| 2199 |
case "ADD_BLOCK_TYPES": |
| 2200 |
return { |
| 2201 |
...state, |
| 2202 |
...keyBlockTypesByName(action.blockTypes) |
| 2203 |
}; |
| 2204 |
case "REMOVE_BLOCK_TYPES": |
| 2205 |
return omit(state, action.names); |
| 2206 |
} |
| 2207 |
return state; |
| 2208 |
} |
| 2209 |
function blockStyles(state = {}, action) { |
| 2210 |
switch (action.type) { |
| 2211 |
case "ADD_BLOCK_TYPES": |
| 2212 |
return { |
| 2213 |
...state, |
| 2214 |
...Object.fromEntries( |
| 2215 |
Object.entries( |
| 2216 |
keyBlockTypesByName(action.blockTypes) |
| 2217 |
).map(([name, blockType]) => [ |
| 2218 |
name, |
| 2219 |
getUniqueItemsByName([ |
| 2220 |
...(blockType.styles ?? []).map((style) => ({ |
| 2221 |
...style, |
| 2222 |
source: "block" |
| 2223 |
})), |
| 2224 |
...(state[blockType.name] ?? []).filter( |
| 2225 |
({ source }) => "block" !== source |
| 2226 |
) |
| 2227 |
]) |
| 2228 |
]) |
| 2229 |
) |
| 2230 |
}; |
| 2231 |
case "ADD_BLOCK_STYLES": |
| 2232 |
const updatedStyles = {}; |
| 2233 |
action.blockNames.forEach((blockName) => { |
| 2234 |
updatedStyles[blockName] = getUniqueItemsByName([ |
| 2235 |
...state[blockName] ?? [], |
| 2236 |
...action.styles |
| 2237 |
]); |
| 2238 |
}); |
| 2239 |
return { ...state, ...updatedStyles }; |
| 2240 |
case "REMOVE_BLOCK_STYLES": |
| 2241 |
return { |
| 2242 |
...state, |
| 2243 |
[action.blockName]: (state[action.blockName] ?? []).filter( |
| 2244 |
(style) => action.styleNames.indexOf(style.name) === -1 |
| 2245 |
) |
| 2246 |
}; |
| 2247 |
} |
| 2248 |
return state; |
| 2249 |
} |
| 2250 |
function blockVariations(state = {}, action) { |
| 2251 |
switch (action.type) { |
| 2252 |
case "ADD_BLOCK_TYPES": |
| 2253 |
return { |
| 2254 |
...state, |
| 2255 |
...Object.fromEntries( |
| 2256 |
Object.entries( |
| 2257 |
keyBlockTypesByName(action.blockTypes) |
| 2258 |
).map(([name, blockType]) => { |
| 2259 |
return [ |
| 2260 |
name, |
| 2261 |
getUniqueItemsByName([ |
| 2262 |
...(blockType.variations ?? []).map( |
| 2263 |
(variation) => ({ |
| 2264 |
...variation, |
| 2265 |
source: "block" |
| 2266 |
}) |
| 2267 |
), |
| 2268 |
...(state[blockType.name] ?? []).filter( |
| 2269 |
({ source }) => "block" !== source |
| 2270 |
) |
| 2271 |
]) |
| 2272 |
]; |
| 2273 |
}) |
| 2274 |
) |
| 2275 |
}; |
| 2276 |
case "ADD_BLOCK_VARIATIONS": |
| 2277 |
return { |
| 2278 |
...state, |
| 2279 |
[action.blockName]: getUniqueItemsByName([ |
| 2280 |
...state[action.blockName] ?? [], |
| 2281 |
...action.variations |
| 2282 |
]) |
| 2283 |
}; |
| 2284 |
case "REMOVE_BLOCK_VARIATIONS": |
| 2285 |
return { |
| 2286 |
...state, |
| 2287 |
[action.blockName]: (state[action.blockName] ?? []).filter( |
| 2288 |
(variation) => action.variationNames.indexOf(variation.name) === -1 |
| 2289 |
) |
| 2290 |
}; |
| 2291 |
} |
| 2292 |
return state; |
| 2293 |
} |
| 2294 |
function createBlockNameSetterReducer(setActionType) { |
| 2295 |
return (state = null, action) => { |
| 2296 |
switch (action.type) { |
| 2297 |
case "REMOVE_BLOCK_TYPES": |
| 2298 |
if (action.names.indexOf(state) !== -1) { |
| 2299 |
return null; |
| 2300 |
} |
| 2301 |
return state; |
| 2302 |
case setActionType: |
| 2303 |
return action.name || null; |
| 2304 |
} |
| 2305 |
return state; |
| 2306 |
}; |
| 2307 |
} |
| 2308 |
var defaultBlockName = createBlockNameSetterReducer( |
| 2309 |
"SET_DEFAULT_BLOCK_NAME" |
| 2310 |
); |
| 2311 |
var freeformFallbackBlockName = createBlockNameSetterReducer( |
| 2312 |
"SET_FREEFORM_FALLBACK_BLOCK_NAME" |
| 2313 |
); |
| 2314 |
var unregisteredFallbackBlockName = createBlockNameSetterReducer( |
| 2315 |
"SET_UNREGISTERED_FALLBACK_BLOCK_NAME" |
| 2316 |
); |
| 2317 |
var groupingBlockName = createBlockNameSetterReducer( |
| 2318 |
"SET_GROUPING_BLOCK_NAME" |
| 2319 |
); |
| 2320 |
function categories(state = DEFAULT_CATEGORIES, action) { |
| 2321 |
switch (action.type) { |
| 2322 |
case "SET_CATEGORIES": |
| 2323 |
const uniqueCategories = /* @__PURE__ */ new Map(); |
| 2324 |
(action.categories || []).forEach((category) => { |
| 2325 |
uniqueCategories.set(category.slug, category); |
| 2326 |
}); |
| 2327 |
return [...uniqueCategories.values()]; |
| 2328 |
case "UPDATE_CATEGORY": { |
| 2329 |
if (!action.category || !Object.keys(action.category).length) { |
| 2330 |
return state; |
| 2331 |
} |
| 2332 |
const categoryToChange = state.find( |
| 2333 |
({ slug }) => slug === action.slug |
| 2334 |
); |
| 2335 |
if (categoryToChange) { |
| 2336 |
return state.map((category) => { |
| 2337 |
if (category.slug === action.slug) { |
| 2338 |
return { |
| 2339 |
...category, |
| 2340 |
...action.category |
| 2341 |
}; |
| 2342 |
} |
| 2343 |
return category; |
| 2344 |
}); |
| 2345 |
} |
| 2346 |
} |
| 2347 |
} |
| 2348 |
return state; |
| 2349 |
} |
| 2350 |
function collections(state = {}, action) { |
| 2351 |
switch (action.type) { |
| 2352 |
case "ADD_BLOCK_COLLECTION": |
| 2353 |
return { |
| 2354 |
...state, |
| 2355 |
[action.namespace]: { |
| 2356 |
title: action.title, |
| 2357 |
icon: action.icon |
| 2358 |
} |
| 2359 |
}; |
| 2360 |
case "REMOVE_BLOCK_COLLECTION": |
| 2361 |
return omit(state, action.namespace); |
| 2362 |
} |
| 2363 |
return state; |
| 2364 |
} |
| 2365 |
function getMergedUsesContext(existingUsesContext = [], newUsesContext = []) { |
| 2366 |
const mergedArrays = Array.from( |
| 2367 |
new Set(existingUsesContext.concat(newUsesContext)) |
| 2368 |
); |
| 2369 |
return mergedArrays.length > 0 ? mergedArrays : void 0; |
| 2370 |
} |
| 2371 |
function blockBindingsSources(state = {}, action) { |
| 2372 |
switch (action.type) { |
| 2373 |
case "ADD_BLOCK_BINDINGS_SOURCE": |
| 2374 |
return { |
| 2375 |
...state, |
| 2376 |
[action.name]: { |
| 2377 |
label: action.label || state[action.name]?.label, |
| 2378 |
usesContext: getMergedUsesContext( |
| 2379 |
state[action.name]?.usesContext, |
| 2380 |
action.usesContext |
| 2381 |
), |
| 2382 |
getValues: action.getValues, |
| 2383 |
setValues: action.setValues, |
| 2384 |
// Only set `canUserEditValue` if `setValues` is also defined. |
| 2385 |
canUserEditValue: action.setValues && action.canUserEditValue, |
| 2386 |
getFieldsList: action.getFieldsList |
| 2387 |
} |
| 2388 |
}; |
| 2389 |
case "REMOVE_BLOCK_BINDINGS_SOURCE": |
| 2390 |
return omit(state, action.name); |
| 2391 |
} |
| 2392 |
return state; |
| 2393 |
} |
| 2394 |
var reducer_default = (0, import_data2.combineReducers)({ |
| 2395 |
bootstrappedBlockTypes, |
| 2396 |
unprocessedBlockTypes, |
| 2397 |
blockTypes, |
| 2398 |
blockStyles, |
| 2399 |
blockVariations, |
| 2400 |
defaultBlockName, |
| 2401 |
freeformFallbackBlockName, |
| 2402 |
unregisteredFallbackBlockName, |
| 2403 |
groupingBlockName, |
| 2404 |
categories, |
| 2405 |
collections, |
| 2406 |
blockBindingsSources |
| 2407 |
}); |
| 2408 |
|
| 2409 |
// packages/blocks/build-module/store/selectors.mjs |
| 2410 |
var selectors_exports = {}; |
| 2411 |
__export(selectors_exports, { |
| 2412 |
__experimentalHasContentRoleAttribute: () => __experimentalHasContentRoleAttribute, |
| 2413 |
getActiveBlockVariation: () => getActiveBlockVariation, |
| 2414 |
getBlockStyles: () => getBlockStyles, |
| 2415 |
getBlockSupport: () => getBlockSupport2, |
| 2416 |
getBlockType: () => getBlockType2, |
| 2417 |
getBlockTypes: () => getBlockTypes2, |
| 2418 |
getBlockVariations: () => getBlockVariations2, |
| 2419 |
getCategories: () => getCategories, |
| 2420 |
getChildBlockNames: () => getChildBlockNames2, |
| 2421 |
getCollections: () => getCollections, |
| 2422 |
getDefaultBlockName: () => getDefaultBlockName2, |
| 2423 |
getDefaultBlockVariation: () => getDefaultBlockVariation, |
| 2424 |
getFreeformFallbackBlockName: () => getFreeformFallbackBlockName, |
| 2425 |
getGroupingBlockName: () => getGroupingBlockName2, |
| 2426 |
getUnregisteredFallbackBlockName: () => getUnregisteredFallbackBlockName, |
| 2427 |
hasBlockSupport: () => hasBlockSupport2, |
| 2428 |
hasChildBlocks: () => hasChildBlocks2, |
| 2429 |
hasChildBlocksWithInserterSupport: () => hasChildBlocksWithInserterSupport2, |
| 2430 |
isMatchingSearchTerm: () => isMatchingSearchTerm |
| 2431 |
}); |
| 2432 |
var import_remove_accents = __toESM(require_remove_accents(), 1); |
| 2433 |
var import_data4 = __toESM(require_data(), 1); |
| 2434 |
var import_rich_text2 = __toESM(require_rich_text(), 1); |
| 2435 |
var import_deprecated3 = __toESM(require_deprecated(), 1); |
| 2436 |
|
| 2437 |
// packages/blocks/build-module/store/utils.mjs |
| 2438 |
var getValueFromObjectPath = (object, path, defaultValue) => { |
| 2439 |
const normalizedPath = Array.isArray(path) ? path : path.split("."); |
| 2440 |
let value = object; |
| 2441 |
normalizedPath.forEach((fieldName) => { |
| 2442 |
value = value?.[fieldName]; |
| 2443 |
}); |
| 2444 |
return value ?? defaultValue; |
| 2445 |
}; |
| 2446 |
function isObject2(candidate) { |
| 2447 |
return typeof candidate === "object" && candidate !== null && candidate.constructor === Object; |
| 2448 |
} |
| 2449 |
function matchesAttributes(blockAttributes, variationAttributes) { |
| 2450 |
if (isObject2(blockAttributes) && isObject2(variationAttributes)) { |
| 2451 |
return Object.entries(variationAttributes).every( |
| 2452 |
([key, value]) => matchesAttributes(blockAttributes?.[key], value) |
| 2453 |
); |
| 2454 |
} |
| 2455 |
return blockAttributes === variationAttributes; |
| 2456 |
} |
| 2457 |
|
| 2458 |
// packages/blocks/build-module/store/private-selectors.mjs |
| 2459 |
var private_selectors_exports = {}; |
| 2460 |
__export(private_selectors_exports, { |
| 2461 |
getAllBlockBindingsSources: () => getAllBlockBindingsSources, |
| 2462 |
getBlockBindingsSource: () => getBlockBindingsSource2, |
| 2463 |
getBlockBindingsSourceFieldsList: () => getBlockBindingsSourceFieldsList, |
| 2464 |
getBootstrappedBlockType: () => getBootstrappedBlockType, |
| 2465 |
getSupportedStyles: () => getSupportedStyles, |
| 2466 |
getUnprocessedBlockTypes: () => getUnprocessedBlockTypes, |
| 2467 |
hasContentRoleAttribute: () => hasContentRoleAttribute |
| 2468 |
}); |
| 2469 |
var import_data3 = __toESM(require_data(), 1); |
| 2470 |
var import_deprecated2 = __toESM(require_deprecated(), 1); |
| 2471 |
var ROOT_BLOCK_SUPPORTS = [ |
| 2472 |
"background", |
| 2473 |
"backgroundColor", |
| 2474 |
"color", |
| 2475 |
"linkColor", |
| 2476 |
"captionColor", |
| 2477 |
"buttonColor", |
| 2478 |
"headingColor", |
| 2479 |
"fontFamily", |
| 2480 |
"fontSize", |
| 2481 |
"fontStyle", |
| 2482 |
"fontWeight", |
| 2483 |
"lineHeight", |
| 2484 |
"padding", |
| 2485 |
"contentSize", |
| 2486 |
"wideSize", |
| 2487 |
"blockGap", |
| 2488 |
"textAlign", |
| 2489 |
"textDecoration", |
| 2490 |
"textIndent", |
| 2491 |
"textTransform", |
| 2492 |
"letterSpacing" |
| 2493 |
]; |
| 2494 |
function filterElementBlockSupports(blockSupports, name, element) { |
| 2495 |
return blockSupports.filter((support) => { |
| 2496 |
if (support === "fontSize" && element === "heading") { |
| 2497 |
return false; |
| 2498 |
} |
| 2499 |
if (support === "textDecoration" && !name && element !== "link") { |
| 2500 |
return false; |
| 2501 |
} |
| 2502 |
if (support === "textTransform" && !name && !(["heading", "h1", "h2", "h3", "h4", "h5", "h6"].includes( |
| 2503 |
element |
| 2504 |
) || element === "button" || element === "caption" || element === "text")) { |
| 2505 |
return false; |
| 2506 |
} |
| 2507 |
if (support === "letterSpacing" && !name && !(["heading", "h1", "h2", "h3", "h4", "h5", "h6"].includes( |
| 2508 |
element |
| 2509 |
) || element === "button" || element === "caption" || element === "text")) { |
| 2510 |
return false; |
| 2511 |
} |
| 2512 |
if (support === "textIndent" && !name) { |
| 2513 |
return false; |
| 2514 |
} |
| 2515 |
if (support === "textColumns" && !name) { |
| 2516 |
return false; |
| 2517 |
} |
| 2518 |
return true; |
| 2519 |
}); |
| 2520 |
} |
| 2521 |
var getSupportedStyles = (0, import_data3.createSelector)( |
| 2522 |
(state, name, element) => { |
| 2523 |
if (!name) { |
| 2524 |
return filterElementBlockSupports( |
| 2525 |
ROOT_BLOCK_SUPPORTS, |
| 2526 |
name, |
| 2527 |
element |
| 2528 |
); |
| 2529 |
} |
| 2530 |
const blockType = getBlockType2(state, name); |
| 2531 |
if (!blockType) { |
| 2532 |
return []; |
| 2533 |
} |
| 2534 |
const supportKeys = []; |
| 2535 |
const supports = blockType?.supports; |
| 2536 |
if (supports?.spacing?.blockGap) { |
| 2537 |
supportKeys.push("blockGap"); |
| 2538 |
} |
| 2539 |
if (supports?.shadow) { |
| 2540 |
supportKeys.push("shadow"); |
| 2541 |
} |
| 2542 |
const stylePropertyMap = __EXPERIMENTAL_STYLE_PROPERTY; |
| 2543 |
Object.keys(stylePropertyMap).forEach((styleName) => { |
| 2544 |
if (!stylePropertyMap[styleName].support) { |
| 2545 |
return; |
| 2546 |
} |
| 2547 |
if (stylePropertyMap[styleName].requiresOptOut) { |
| 2548 |
if (supports && stylePropertyMap[styleName].support[0] in supports && getValueFromObjectPath( |
| 2549 |
supports, |
| 2550 |
stylePropertyMap[styleName].support |
| 2551 |
) !== false) { |
| 2552 |
supportKeys.push(styleName); |
| 2553 |
return; |
| 2554 |
} |
| 2555 |
} |
| 2556 |
if (supports && getValueFromObjectPath( |
| 2557 |
supports, |
| 2558 |
stylePropertyMap[styleName].support, |
| 2559 |
false |
| 2560 |
)) { |
| 2561 |
supportKeys.push(styleName); |
| 2562 |
} |
| 2563 |
}); |
| 2564 |
return filterElementBlockSupports(supportKeys, name, element); |
| 2565 |
}, |
| 2566 |
(state, name) => [ |
| 2567 |
state.blockTypes[name] |
| 2568 |
] |
| 2569 |
); |
| 2570 |
function getBootstrappedBlockType(state, name) { |
| 2571 |
return state.bootstrappedBlockTypes[name]; |
| 2572 |
} |
| 2573 |
function getUnprocessedBlockTypes(state) { |
| 2574 |
return state.unprocessedBlockTypes; |
| 2575 |
} |
| 2576 |
function getAllBlockBindingsSources(state) { |
| 2577 |
return state.blockBindingsSources; |
| 2578 |
} |
| 2579 |
function getBlockBindingsSource2(state, sourceName) { |
| 2580 |
return state.blockBindingsSources[sourceName]; |
| 2581 |
} |
| 2582 |
var getBlockBindingsSourceFieldsList = (0, import_data3.createRegistrySelector)( |
| 2583 |
(select3) => (0, import_data3.createSelector)( |
| 2584 |
(state, source, blockContext) => { |
| 2585 |
if (!source.getFieldsList) { |
| 2586 |
return []; |
| 2587 |
} |
| 2588 |
const context = {}; |
| 2589 |
if (source?.usesContext?.length) { |
| 2590 |
for (const key of source.usesContext) { |
| 2591 |
context[key] = blockContext[key]; |
| 2592 |
} |
| 2593 |
} |
| 2594 |
return source.getFieldsList({ select: select3, context }); |
| 2595 |
}, |
| 2596 |
(state, source, blockContext) => [source.getFieldsList, source.usesContext, blockContext] |
| 2597 |
) |
| 2598 |
); |
| 2599 |
var hasContentRoleAttribute = (state, blockTypeName) => { |
| 2600 |
const blockType = getBlockType2(state, blockTypeName); |
| 2601 |
if (!blockType) { |
| 2602 |
return false; |
| 2603 |
} |
| 2604 |
return Object.values(blockType.attributes).some( |
| 2605 |
({ role, __experimentalRole }) => { |
| 2606 |
if (role === "content") { |
| 2607 |
return true; |
| 2608 |
} |
| 2609 |
if (__experimentalRole === "content") { |
| 2610 |
(0, import_deprecated2.default)("__experimentalRole attribute", { |
| 2611 |
since: "6.7", |
| 2612 |
version: "6.8", |
| 2613 |
alternative: "role attribute", |
| 2614 |
hint: `Check the block.json of the ${blockTypeName} block.` |
| 2615 |
}); |
| 2616 |
return true; |
| 2617 |
} |
| 2618 |
return false; |
| 2619 |
} |
| 2620 |
); |
| 2621 |
}; |
| 2622 |
|
| 2623 |
// packages/blocks/build-module/store/selectors.mjs |
| 2624 |
var getNormalizedBlockType = (state, nameOrType) => "string" === typeof nameOrType ? getBlockType2(state, nameOrType) : nameOrType; |
| 2625 |
var getBlockTypes2 = (0, import_data4.createSelector)( |
| 2626 |
(state) => Object.values(state.blockTypes), |
| 2627 |
(state) => [state.blockTypes] |
| 2628 |
); |
| 2629 |
function getBlockType2(state, name) { |
| 2630 |
return state.blockTypes[name]; |
| 2631 |
} |
| 2632 |
function getBlockStyles(state, name) { |
| 2633 |
return state.blockStyles[name]; |
| 2634 |
} |
| 2635 |
var getBlockVariations2 = (0, import_data4.createSelector)( |
| 2636 |
(state, blockName, scope) => { |
| 2637 |
const variations = state.blockVariations[blockName]; |
| 2638 |
if (!variations || !scope) { |
| 2639 |
return variations; |
| 2640 |
} |
| 2641 |
return variations.filter((variation) => { |
| 2642 |
return (variation.scope || ["block", "inserter"]).includes( |
| 2643 |
scope |
| 2644 |
); |
| 2645 |
}); |
| 2646 |
}, |
| 2647 |
(state, blockName) => [ |
| 2648 |
state.blockVariations[blockName] |
| 2649 |
] |
| 2650 |
); |
| 2651 |
function getActiveBlockVariation(state, blockName, attributes, scope) { |
| 2652 |
const variations = getBlockVariations2(state, blockName, scope); |
| 2653 |
if (!variations) { |
| 2654 |
return variations; |
| 2655 |
} |
| 2656 |
const blockType = getBlockType2(state, blockName); |
| 2657 |
const attributeKeys = Object.keys(blockType?.attributes || {}); |
| 2658 |
let match; |
| 2659 |
let maxMatchedAttributes = 0; |
| 2660 |
for (const variation of variations) { |
| 2661 |
if (Array.isArray(variation.isActive)) { |
| 2662 |
const definedAttributes = variation.isActive.filter( |
| 2663 |
(attribute) => { |
| 2664 |
const topLevelAttribute = attribute.split(".")[0]; |
| 2665 |
return attributeKeys.includes(topLevelAttribute); |
| 2666 |
} |
| 2667 |
); |
| 2668 |
const definedAttributesLength = definedAttributes.length; |
| 2669 |
if (definedAttributesLength === 0) { |
| 2670 |
continue; |
| 2671 |
} |
| 2672 |
const isMatch = definedAttributes.every((attribute) => { |
| 2673 |
const variationAttributeValue = getValueFromObjectPath( |
| 2674 |
variation.attributes, |
| 2675 |
attribute |
| 2676 |
); |
| 2677 |
if (variationAttributeValue === void 0) { |
| 2678 |
return false; |
| 2679 |
} |
| 2680 |
let blockAttributeValue = getValueFromObjectPath( |
| 2681 |
attributes, |
| 2682 |
attribute |
| 2683 |
); |
| 2684 |
if (blockAttributeValue instanceof import_rich_text2.RichTextData) { |
| 2685 |
blockAttributeValue = blockAttributeValue.toHTMLString(); |
| 2686 |
} |
| 2687 |
return matchesAttributes( |
| 2688 |
blockAttributeValue, |
| 2689 |
variationAttributeValue |
| 2690 |
); |
| 2691 |
}); |
| 2692 |
if (isMatch && definedAttributesLength > maxMatchedAttributes) { |
| 2693 |
match = variation; |
| 2694 |
maxMatchedAttributes = definedAttributesLength; |
| 2695 |
} |
| 2696 |
} else if (variation.isActive?.( |
| 2697 |
attributes, |
| 2698 |
variation.attributes |
| 2699 |
)) { |
| 2700 |
return match || variation; |
| 2701 |
} |
| 2702 |
} |
| 2703 |
if (!match && ["block", "transform"].includes(scope)) { |
| 2704 |
match = variations.find( |
| 2705 |
(variation) => variation?.isDefault && !Object.hasOwn(variation, "isActive") |
| 2706 |
); |
| 2707 |
} |
| 2708 |
return match; |
| 2709 |
} |
| 2710 |
function getDefaultBlockVariation(state, blockName, scope) { |
| 2711 |
const variations = getBlockVariations2(state, blockName, scope); |
| 2712 |
const defaultVariation = [...variations || []].reverse().find(({ isDefault }) => !!isDefault); |
| 2713 |
return defaultVariation || variations?.[0]; |
| 2714 |
} |
| 2715 |
function getCategories(state) { |
| 2716 |
return state.categories; |
| 2717 |
} |
| 2718 |
function getCollections(state) { |
| 2719 |
return state.collections; |
| 2720 |
} |
| 2721 |
function getDefaultBlockName2(state) { |
| 2722 |
return state.defaultBlockName; |
| 2723 |
} |
| 2724 |
function getFreeformFallbackBlockName(state) { |
| 2725 |
return state.freeformFallbackBlockName; |
| 2726 |
} |
| 2727 |
function getUnregisteredFallbackBlockName(state) { |
| 2728 |
return state.unregisteredFallbackBlockName; |
| 2729 |
} |
| 2730 |
function getGroupingBlockName2(state) { |
| 2731 |
return state.groupingBlockName; |
| 2732 |
} |
| 2733 |
var getChildBlockNames2 = (0, import_data4.createSelector)( |
| 2734 |
(state, blockName) => { |
| 2735 |
return getBlockTypes2(state).filter((blockType) => { |
| 2736 |
return blockType.parent?.includes(blockName); |
| 2737 |
}).map(({ name }) => name); |
| 2738 |
}, |
| 2739 |
(state) => [state.blockTypes] |
| 2740 |
); |
| 2741 |
var getBlockSupport2 = (state, nameOrType, feature, defaultSupports) => { |
| 2742 |
const blockType = getNormalizedBlockType(state, nameOrType); |
| 2743 |
if (!blockType?.supports) { |
| 2744 |
return defaultSupports; |
| 2745 |
} |
| 2746 |
return getValueFromObjectPath( |
| 2747 |
blockType.supports, |
| 2748 |
feature, |
| 2749 |
defaultSupports |
| 2750 |
); |
| 2751 |
}; |
| 2752 |
function hasBlockSupport2(state, nameOrType, feature, defaultSupports) { |
| 2753 |
return !!getBlockSupport2(state, nameOrType, feature, defaultSupports); |
| 2754 |
} |
| 2755 |
function getNormalizedSearchTerm(term) { |
| 2756 |
return (0, import_remove_accents.default)(term ?? "").toLowerCase().trim(); |
| 2757 |
} |
| 2758 |
function isMatchingSearchTerm(state, nameOrType, searchTerm = "") { |
| 2759 |
const blockType = getNormalizedBlockType(state, nameOrType); |
| 2760 |
const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm); |
| 2761 |
const isSearchMatch = (candidate) => getNormalizedSearchTerm(candidate).includes(normalizedSearchTerm); |
| 2762 |
return isSearchMatch(blockType?.title) || blockType?.keywords?.some(isSearchMatch) || isSearchMatch(blockType?.category) || typeof blockType?.description === "string" && isSearchMatch(blockType.description); |
| 2763 |
} |
| 2764 |
var hasChildBlocks2 = (state, blockName) => { |
| 2765 |
return getChildBlockNames2(state, blockName).length > 0; |
| 2766 |
}; |
| 2767 |
var hasChildBlocksWithInserterSupport2 = (state, blockName) => { |
| 2768 |
return getChildBlockNames2(state, blockName).some((childBlockName) => { |
| 2769 |
return hasBlockSupport2(state, childBlockName, "inserter", true); |
| 2770 |
}); |
| 2771 |
}; |
| 2772 |
var __experimentalHasContentRoleAttribute = (...args) => { |
| 2773 |
(0, import_deprecated3.default)("__experimentalHasContentRoleAttribute", { |
| 2774 |
since: "6.7", |
| 2775 |
version: "6.8", |
| 2776 |
hint: "This is a private selector." |
| 2777 |
}); |
| 2778 |
return hasContentRoleAttribute(...args); |
| 2779 |
}; |
| 2780 |
|
| 2781 |
// packages/blocks/build-module/store/actions.mjs |
| 2782 |
var actions_exports = {}; |
| 2783 |
__export(actions_exports, { |
| 2784 |
__experimentalReapplyBlockFilters: () => __experimentalReapplyBlockFilters, |
| 2785 |
addBlockCollection: () => addBlockCollection, |
| 2786 |
addBlockStyles: () => addBlockStyles, |
| 2787 |
addBlockTypes: () => addBlockTypes, |
| 2788 |
addBlockVariations: () => addBlockVariations, |
| 2789 |
reapplyBlockTypeFilters: () => reapplyBlockTypeFilters, |
| 2790 |
removeBlockCollection: () => removeBlockCollection, |
| 2791 |
removeBlockStyles: () => removeBlockStyles, |
| 2792 |
removeBlockTypes: () => removeBlockTypes, |
| 2793 |
removeBlockVariations: () => removeBlockVariations, |
| 2794 |
setCategories: () => setCategories, |
| 2795 |
setDefaultBlockName: () => setDefaultBlockName2, |
| 2796 |
setFreeformFallbackBlockName: () => setFreeformFallbackBlockName, |
| 2797 |
setGroupingBlockName: () => setGroupingBlockName2, |
| 2798 |
setUnregisteredFallbackBlockName: () => setUnregisteredFallbackBlockName, |
| 2799 |
updateCategory: () => updateCategory |
| 2800 |
}); |
| 2801 |
var import_deprecated5 = __toESM(require_deprecated(), 1); |
| 2802 |
|
| 2803 |
// node_modules/is-plain-object/dist/is-plain-object.mjs |
| 2804 |
function isObject3(o3) { |
| 2805 |
return Object.prototype.toString.call(o3) === "[object Object]"; |
| 2806 |
} |
| 2807 |
function isPlainObject(o3) { |
| 2808 |
var ctor, prot; |
| 2809 |
if (isObject3(o3) === false) return false; |
| 2810 |
ctor = o3.constructor; |
| 2811 |
if (ctor === void 0) return true; |
| 2812 |
prot = ctor.prototype; |
| 2813 |
if (isObject3(prot) === false) return false; |
| 2814 |
if (prot.hasOwnProperty("isPrototypeOf") === false) { |
| 2815 |
return false; |
| 2816 |
} |
| 2817 |
return true; |
| 2818 |
} |
| 2819 |
|
| 2820 |
// packages/blocks/build-module/store/process-block-type.mjs |
| 2821 |
var import_react_is = __toESM(require_react_is(), 1); |
| 2822 |
var import_deprecated4 = __toESM(require_deprecated(), 1); |
| 2823 |
var import_hooks = __toESM(require_hooks(), 1); |
| 2824 |
var import_warning2 = __toESM(require_warning(), 1); |
| 2825 |
var LEGACY_CATEGORY_MAPPING = { |
| 2826 |
common: "text", |
| 2827 |
formatting: "text", |
| 2828 |
layout: "design" |
| 2829 |
}; |
| 2830 |
function mergeBlockVariations(bootstrappedVariations = [], clientVariations = []) { |
| 2831 |
const result = [...bootstrappedVariations]; |
| 2832 |
clientVariations.forEach((clientVariation) => { |
| 2833 |
const index = result.findIndex( |
| 2834 |
(bootstrappedVariation) => bootstrappedVariation.name === clientVariation.name |
| 2835 |
); |
| 2836 |
if (index !== -1) { |
| 2837 |
result[index] = { ...result[index], ...clientVariation }; |
| 2838 |
} else { |
| 2839 |
result.push(clientVariation); |
| 2840 |
} |
| 2841 |
}); |
| 2842 |
return result; |
| 2843 |
} |
| 2844 |
var processBlockType = (name, blockSettings) => ({ |
| 2845 |
select: select3 |
| 2846 |
}) => { |
| 2847 |
const bootstrappedBlockType = select3.getBootstrappedBlockType(name); |
| 2848 |
const blockType = { |
| 2849 |
apiVersion: 1, |
| 2850 |
name, |
| 2851 |
icon: BLOCK_ICON_DEFAULT, |
| 2852 |
keywords: [], |
| 2853 |
attributes: {}, |
| 2854 |
providesContext: {}, |
| 2855 |
usesContext: [], |
| 2856 |
selectors: {}, |
| 2857 |
supports: {}, |
| 2858 |
styles: [], |
| 2859 |
blockHooks: {}, |
| 2860 |
save: () => null, |
| 2861 |
...bootstrappedBlockType, |
| 2862 |
...blockSettings, |
| 2863 |
// blockType.variations can be defined as a filePath. |
| 2864 |
variations: mergeBlockVariations( |
| 2865 |
Array.isArray(bootstrappedBlockType?.variations) ? bootstrappedBlockType.variations : [], |
| 2866 |
Array.isArray(blockSettings?.variations) ? blockSettings.variations : [] |
| 2867 |
) |
| 2868 |
}; |
| 2869 |
if (!blockType.attributes || typeof blockType.attributes !== "object") { |
| 2870 |
(0, import_warning2.default)( |
| 2871 |
'The block "' + name + '" is registering attributes as `null` or `undefined`. Use an empty object (`attributes: {}`) or exclude the `attributes` key.' |
| 2872 |
); |
| 2873 |
blockType.attributes = {}; |
| 2874 |
} |
| 2875 |
const settings = (0, import_hooks.applyFilters)( |
| 2876 |
"blocks.registerBlockType", |
| 2877 |
blockType, |
| 2878 |
name, |
| 2879 |
null |
| 2880 |
); |
| 2881 |
if (settings.apiVersion <= 2) { |
| 2882 |
(0, import_deprecated4.default)("Block with API version 2 or lower", { |
| 2883 |
since: "6.9", |
| 2884 |
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.`, |
| 2885 |
link: "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/block-migration-for-iframe-editor-compatibility/" |
| 2886 |
}); |
| 2887 |
} |
| 2888 |
if (settings.description && typeof settings.description !== "string") { |
| 2889 |
(0, import_deprecated4.default)("Declaring non-string block descriptions", { |
| 2890 |
since: "6.2" |
| 2891 |
}); |
| 2892 |
} |
| 2893 |
if (settings.deprecated) { |
| 2894 |
settings.deprecated = settings.deprecated.map( |
| 2895 |
(deprecation) => Object.fromEntries( |
| 2896 |
Object.entries( |
| 2897 |
// Only keep valid deprecation keys. |
| 2898 |
(0, import_hooks.applyFilters)( |
| 2899 |
"blocks.registerBlockType", |
| 2900 |
// Merge deprecation keys with pre-filter settings |
| 2901 |
// so that filters that depend on specific keys being |
| 2902 |
// present don't fail. |
| 2903 |
{ |
| 2904 |
// Omit deprecation keys here so that deprecations |
| 2905 |
// can opt out of specific keys like "supports". |
| 2906 |
...omit(blockType, DEPRECATED_ENTRY_KEYS), |
| 2907 |
...deprecation |
| 2908 |
}, |
| 2909 |
blockType.name, |
| 2910 |
deprecation |
| 2911 |
) |
| 2912 |
).filter( |
| 2913 |
([key]) => DEPRECATED_ENTRY_KEYS.includes(key) |
| 2914 |
) |
| 2915 |
) |
| 2916 |
); |
| 2917 |
} |
| 2918 |
if (!isPlainObject(settings)) { |
| 2919 |
(0, import_warning2.default)("Block settings must be a valid object."); |
| 2920 |
return; |
| 2921 |
} |
| 2922 |
if (typeof settings.save !== "function") { |
| 2923 |
(0, import_warning2.default)('The "save" property must be a valid function.'); |
| 2924 |
return; |
| 2925 |
} |
| 2926 |
if ("edit" in settings && !(0, import_react_is.isValidElementType)(settings.edit)) { |
| 2927 |
(0, import_warning2.default)('The "edit" property must be a valid component.'); |
| 2928 |
return; |
| 2929 |
} |
| 2930 |
if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) { |
| 2931 |
settings.category = LEGACY_CATEGORY_MAPPING[settings.category]; |
| 2932 |
} |
| 2933 |
if ("category" in settings && !select3.getCategories().some( |
| 2934 |
({ slug }) => slug === settings.category |
| 2935 |
)) { |
| 2936 |
(0, import_warning2.default)( |
| 2937 |
'The block "' + name + '" is registered with an invalid category "' + settings.category + '".' |
| 2938 |
); |
| 2939 |
delete settings.category; |
| 2940 |
} |
| 2941 |
if (!("title" in settings) || settings.title === "") { |
| 2942 |
(0, import_warning2.default)('The block "' + name + '" must have a title.'); |
| 2943 |
return; |
| 2944 |
} |
| 2945 |
if (typeof settings.title !== "string") { |
| 2946 |
(0, import_warning2.default)("Block titles must be strings."); |
| 2947 |
return; |
| 2948 |
} |
| 2949 |
settings.icon = normalizeIconObject(settings.icon); |
| 2950 |
if (!isValidIcon(settings.icon.src)) { |
| 2951 |
(0, import_warning2.default)( |
| 2952 |
"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" |
| 2953 |
); |
| 2954 |
return; |
| 2955 |
} |
| 2956 |
if (typeof settings?.parent === "string" || settings?.parent instanceof String) { |
| 2957 |
settings.parent = [settings.parent]; |
| 2958 |
(0, import_warning2.default)( |
| 2959 |
"Parent must be undefined or an array of strings (block types), but it is a string." |
| 2960 |
); |
| 2961 |
} |
| 2962 |
if (!Array.isArray(settings?.parent) && settings?.parent !== void 0) { |
| 2963 |
(0, import_warning2.default)( |
| 2964 |
"Parent must be undefined or an array of block types, but it is " + settings.parent |
| 2965 |
); |
| 2966 |
return; |
| 2967 |
} |
| 2968 |
if (1 === settings?.parent?.length && name === settings.parent[0]) { |
| 2969 |
(0, import_warning2.default)( |
| 2970 |
'Block "' + name + '" cannot be a parent of itself. Please remove the block name from the parent list.' |
| 2971 |
); |
| 2972 |
return; |
| 2973 |
} |
| 2974 |
return settings; |
| 2975 |
}; |
| 2976 |
|
| 2977 |
// packages/blocks/build-module/store/actions.mjs |
| 2978 |
function addBlockTypes(blockTypes2) { |
| 2979 |
return { |
| 2980 |
type: "ADD_BLOCK_TYPES", |
| 2981 |
blockTypes: Array.isArray(blockTypes2) ? blockTypes2 : [blockTypes2] |
| 2982 |
}; |
| 2983 |
} |
| 2984 |
function reapplyBlockTypeFilters() { |
| 2985 |
return ({ dispatch: dispatch3, select: select3 }) => { |
| 2986 |
const processedBlockTypes = []; |
| 2987 |
for (const [name, settings] of Object.entries( |
| 2988 |
select3.getUnprocessedBlockTypes() |
| 2989 |
)) { |
| 2990 |
const result = dispatch3(processBlockType(name, settings)); |
| 2991 |
if (result) { |
| 2992 |
processedBlockTypes.push(result); |
| 2993 |
} |
| 2994 |
} |
| 2995 |
if (!processedBlockTypes.length) { |
| 2996 |
return; |
| 2997 |
} |
| 2998 |
dispatch3.addBlockTypes(processedBlockTypes); |
| 2999 |
}; |
| 3000 |
} |
| 3001 |
function __experimentalReapplyBlockFilters() { |
| 3002 |
(0, import_deprecated5.default)( |
| 3003 |
'wp.data.dispatch( "core/blocks" ).__experimentalReapplyBlockFilters', |
| 3004 |
{ |
| 3005 |
since: "6.4", |
| 3006 |
alternative: "reapplyBlockFilters" |
| 3007 |
} |
| 3008 |
); |
| 3009 |
return reapplyBlockTypeFilters(); |
| 3010 |
} |
| 3011 |
function removeBlockTypes(names) { |
| 3012 |
return { |
| 3013 |
type: "REMOVE_BLOCK_TYPES", |
| 3014 |
names: Array.isArray(names) ? names : [names] |
| 3015 |
}; |
| 3016 |
} |
| 3017 |
function addBlockStyles(blockNames, styles) { |
| 3018 |
return { |
| 3019 |
type: "ADD_BLOCK_STYLES", |
| 3020 |
styles: Array.isArray(styles) ? styles : [styles], |
| 3021 |
blockNames: Array.isArray(blockNames) ? blockNames : [blockNames] |
| 3022 |
}; |
| 3023 |
} |
| 3024 |
function removeBlockStyles(blockName, styleNames) { |
| 3025 |
return { |
| 3026 |
type: "REMOVE_BLOCK_STYLES", |
| 3027 |
styleNames: Array.isArray(styleNames) ? styleNames : [styleNames], |
| 3028 |
blockName |
| 3029 |
}; |
| 3030 |
} |
| 3031 |
function addBlockVariations(blockName, variations) { |
| 3032 |
return { |
| 3033 |
type: "ADD_BLOCK_VARIATIONS", |
| 3034 |
variations: Array.isArray(variations) ? variations : [variations], |
| 3035 |
blockName |
| 3036 |
}; |
| 3037 |
} |
| 3038 |
function removeBlockVariations(blockName, variationNames) { |
| 3039 |
return { |
| 3040 |
type: "REMOVE_BLOCK_VARIATIONS", |
| 3041 |
variationNames: Array.isArray(variationNames) ? variationNames : [variationNames], |
| 3042 |
blockName |
| 3043 |
}; |
| 3044 |
} |
| 3045 |
function setDefaultBlockName2(name) { |
| 3046 |
return { |
| 3047 |
type: "SET_DEFAULT_BLOCK_NAME", |
| 3048 |
name |
| 3049 |
}; |
| 3050 |
} |
| 3051 |
function setFreeformFallbackBlockName(name) { |
| 3052 |
return { |
| 3053 |
type: "SET_FREEFORM_FALLBACK_BLOCK_NAME", |
| 3054 |
name |
| 3055 |
}; |
| 3056 |
} |
| 3057 |
function setUnregisteredFallbackBlockName(name) { |
| 3058 |
return { |
| 3059 |
type: "SET_UNREGISTERED_FALLBACK_BLOCK_NAME", |
| 3060 |
name |
| 3061 |
}; |
| 3062 |
} |
| 3063 |
function setGroupingBlockName2(name) { |
| 3064 |
return { |
| 3065 |
type: "SET_GROUPING_BLOCK_NAME", |
| 3066 |
name |
| 3067 |
}; |
| 3068 |
} |
| 3069 |
function setCategories(categories2) { |
| 3070 |
return { |
| 3071 |
type: "SET_CATEGORIES", |
| 3072 |
categories: categories2 |
| 3073 |
}; |
| 3074 |
} |
| 3075 |
function updateCategory(slug, category) { |
| 3076 |
return { |
| 3077 |
type: "UPDATE_CATEGORY", |
| 3078 |
slug, |
| 3079 |
category |
| 3080 |
}; |
| 3081 |
} |
| 3082 |
function addBlockCollection(namespace, title, icon) { |
| 3083 |
return { |
| 3084 |
type: "ADD_BLOCK_COLLECTION", |
| 3085 |
namespace, |
| 3086 |
title, |
| 3087 |
icon |
| 3088 |
}; |
| 3089 |
} |
| 3090 |
function removeBlockCollection(namespace) { |
| 3091 |
return { |
| 3092 |
type: "REMOVE_BLOCK_COLLECTION", |
| 3093 |
namespace |
| 3094 |
}; |
| 3095 |
} |
| 3096 |
|
| 3097 |
// packages/blocks/build-module/store/private-actions.mjs |
| 3098 |
var private_actions_exports = {}; |
| 3099 |
__export(private_actions_exports, { |
| 3100 |
addBlockBindingsSource: () => addBlockBindingsSource, |
| 3101 |
addBootstrappedBlockType: () => addBootstrappedBlockType, |
| 3102 |
addUnprocessedBlockType: () => addUnprocessedBlockType, |
| 3103 |
removeBlockBindingsSource: () => removeBlockBindingsSource |
| 3104 |
}); |
| 3105 |
function addBootstrappedBlockType(name, blockType) { |
| 3106 |
return { |
| 3107 |
type: "ADD_BOOTSTRAPPED_BLOCK_TYPE", |
| 3108 |
name, |
| 3109 |
blockType |
| 3110 |
}; |
| 3111 |
} |
| 3112 |
function addUnprocessedBlockType(name, blockType) { |
| 3113 |
return ({ dispatch: dispatch3 }) => { |
| 3114 |
dispatch3({ type: "ADD_UNPROCESSED_BLOCK_TYPE", name, blockType }); |
| 3115 |
const processedBlockType = dispatch3( |
| 3116 |
processBlockType(name, blockType) |
| 3117 |
); |
| 3118 |
if (!processedBlockType) { |
| 3119 |
return; |
| 3120 |
} |
| 3121 |
dispatch3.addBlockTypes(processedBlockType); |
| 3122 |
}; |
| 3123 |
} |
| 3124 |
function addBlockBindingsSource(source) { |
| 3125 |
return { |
| 3126 |
type: "ADD_BLOCK_BINDINGS_SOURCE", |
| 3127 |
name: source.name, |
| 3128 |
label: source.label, |
| 3129 |
usesContext: source.usesContext, |
| 3130 |
getValues: source.getValues, |
| 3131 |
setValues: source.setValues, |
| 3132 |
canUserEditValue: source.canUserEditValue, |
| 3133 |
getFieldsList: source.getFieldsList |
| 3134 |
}; |
| 3135 |
} |
| 3136 |
function removeBlockBindingsSource(name) { |
| 3137 |
return { |
| 3138 |
type: "REMOVE_BLOCK_BINDINGS_SOURCE", |
| 3139 |
name |
| 3140 |
}; |
| 3141 |
} |
| 3142 |
|
| 3143 |
// packages/blocks/build-module/store/constants.mjs |
| 3144 |
var STORE_NAME = "core/blocks"; |
| 3145 |
|
| 3146 |
// packages/blocks/build-module/store/index.mjs |
| 3147 |
var store = (0, import_data5.createReduxStore)(STORE_NAME, { |
| 3148 |
reducer: reducer_default, |
| 3149 |
selectors: selectors_exports, |
| 3150 |
actions: actions_exports |
| 3151 |
}); |
| 3152 |
(0, import_data5.register)(store); |
| 3153 |
unlock(store).registerPrivateSelectors(private_selectors_exports); |
| 3154 |
unlock(store).registerPrivateActions(private_actions_exports); |
| 3155 |
|
| 3156 |
// node_modules/uuid/dist/stringify.js |
| 3157 |
var byteToHex = []; |
| 3158 |
for (let i2 = 0; i2 < 256; ++i2) { |
| 3159 |
byteToHex.push((i2 + 256).toString(16).slice(1)); |
| 3160 |
} |
| 3161 |
function unsafeStringify(arr, offset = 0) { |
| 3162 |
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(); |
| 3163 |
} |
| 3164 |
|
| 3165 |
// node_modules/uuid/dist/rng.js |
| 3166 |
var rnds8 = new Uint8Array(16); |
| 3167 |
function rng() { |
| 3168 |
return crypto.getRandomValues(rnds8); |
| 3169 |
} |
| 3170 |
|
| 3171 |
// node_modules/uuid/dist/v4.js |
| 3172 |
function v4(options, buf, offset) { |
| 3173 |
if (!buf && !options && crypto.randomUUID) { |
| 3174 |
return crypto.randomUUID(); |
| 3175 |
} |
| 3176 |
return _v4(options, buf, offset); |
| 3177 |
} |
| 3178 |
function _v4(options, buf, offset) { |
| 3179 |
options = options || {}; |
| 3180 |
const rnds = options.random ?? options.rng?.() ?? rng(); |
| 3181 |
if (rnds.length < 16) { |
| 3182 |
throw new Error("Random bytes length must be >= 16"); |
| 3183 |
} |
| 3184 |
rnds[6] = rnds[6] & 15 | 64; |
| 3185 |
rnds[8] = rnds[8] & 63 | 128; |
| 3186 |
if (buf) { |
| 3187 |
offset = offset || 0; |
| 3188 |
if (offset < 0 || offset + 16 > buf.length) { |
| 3189 |
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`); |
| 3190 |
} |
| 3191 |
for (let i2 = 0; i2 < 16; ++i2) { |
| 3192 |
buf[offset + i2] = rnds[i2]; |
| 3193 |
} |
| 3194 |
return buf; |
| 3195 |
} |
| 3196 |
return unsafeStringify(rnds); |
| 3197 |
} |
| 3198 |
var v4_default = v4; |
| 3199 |
|
| 3200 |
// packages/blocks/build-module/api/factory.mjs |
| 3201 |
var import_hooks2 = __toESM(require_hooks(), 1); |
| 3202 |
var getBlockTypeWithTransformMetadata = (blockType, transform) => transform.variationName ? { ...blockType, variationName: transform.variationName } : blockType; |
| 3203 |
function createBlock(name, attributes = {}, innerBlocks = []) { |
| 3204 |
if (!isBlockRegistered(name)) { |
| 3205 |
return createBlock("core/missing", { |
| 3206 |
originalName: name, |
| 3207 |
originalContent: "", |
| 3208 |
originalUndelimitedContent: "" |
| 3209 |
}); |
| 3210 |
} |
| 3211 |
const sanitizedAttributes = __experimentalSanitizeBlockAttributes( |
| 3212 |
name, |
| 3213 |
attributes |
| 3214 |
); |
| 3215 |
const clientId = v4_default(); |
| 3216 |
return { |
| 3217 |
clientId, |
| 3218 |
name, |
| 3219 |
isValid: true, |
| 3220 |
attributes: sanitizedAttributes, |
| 3221 |
innerBlocks |
| 3222 |
}; |
| 3223 |
} |
| 3224 |
function createBlocksFromInnerBlocksTemplate(innerBlocksOrTemplate = []) { |
| 3225 |
return innerBlocksOrTemplate.map((innerBlock) => { |
| 3226 |
const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [ |
| 3227 |
innerBlock.name, |
| 3228 |
innerBlock.attributes, |
| 3229 |
innerBlock.innerBlocks |
| 3230 |
]; |
| 3231 |
const [name, attributes, innerBlocks = []] = innerBlockTemplate; |
| 3232 |
return createBlock( |
| 3233 |
name, |
| 3234 |
attributes, |
| 3235 |
createBlocksFromInnerBlocksTemplate( |
| 3236 |
innerBlocks |
| 3237 |
) |
| 3238 |
); |
| 3239 |
}); |
| 3240 |
} |
| 3241 |
function __experimentalCloneSanitizedBlock(block, mergeAttributes = {}, newInnerBlocks) { |
| 3242 |
const { name } = block; |
| 3243 |
if (!isBlockRegistered(name)) { |
| 3244 |
return createBlock("core/missing", { |
| 3245 |
originalName: name, |
| 3246 |
originalContent: "", |
| 3247 |
originalUndelimitedContent: "" |
| 3248 |
}); |
| 3249 |
} |
| 3250 |
const clientId = v4_default(); |
| 3251 |
const sanitizedAttributes = __experimentalSanitizeBlockAttributes(name, { |
| 3252 |
...block.attributes, |
| 3253 |
...mergeAttributes |
| 3254 |
}); |
| 3255 |
return { |
| 3256 |
...block, |
| 3257 |
clientId, |
| 3258 |
attributes: sanitizedAttributes, |
| 3259 |
innerBlocks: newInnerBlocks || block.innerBlocks.map( |
| 3260 |
(innerBlock) => __experimentalCloneSanitizedBlock(innerBlock) |
| 3261 |
) |
| 3262 |
}; |
| 3263 |
} |
| 3264 |
function cloneBlock(block, mergeAttributes = {}, newInnerBlocks) { |
| 3265 |
const clientId = v4_default(); |
| 3266 |
return { |
| 3267 |
...block, |
| 3268 |
clientId, |
| 3269 |
attributes: { |
| 3270 |
...block.attributes, |
| 3271 |
...mergeAttributes |
| 3272 |
}, |
| 3273 |
innerBlocks: newInnerBlocks || block.innerBlocks.map((innerBlock) => cloneBlock(innerBlock)) |
| 3274 |
}; |
| 3275 |
} |
| 3276 |
var isPossibleTransformForSource = (transform, direction, blocks) => { |
| 3277 |
if (!blocks.length) { |
| 3278 |
return false; |
| 3279 |
} |
| 3280 |
const isMultiBlock = blocks.length > 1; |
| 3281 |
const firstBlockName = blocks[0].name; |
| 3282 |
const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock; |
| 3283 |
if (!isValidForMultiBlocks) { |
| 3284 |
return false; |
| 3285 |
} |
| 3286 |
if (!isWildcardBlockTransform(transform) && !blocks.every((block) => block.name === firstBlockName)) { |
| 3287 |
return false; |
| 3288 |
} |
| 3289 |
const isBlockType = transform.type === "block"; |
| 3290 |
if (!isBlockType) { |
| 3291 |
return false; |
| 3292 |
} |
| 3293 |
const sourceBlock = blocks[0]; |
| 3294 |
const hasMatchingName = direction !== "from" || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform); |
| 3295 |
if (!hasMatchingName) { |
| 3296 |
return false; |
| 3297 |
} |
| 3298 |
if (!isMultiBlock && direction === "from" && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) { |
| 3299 |
return false; |
| 3300 |
} |
| 3301 |
if (!maybeCheckTransformIsMatch(transform, blocks)) { |
| 3302 |
return false; |
| 3303 |
} |
| 3304 |
return true; |
| 3305 |
}; |
| 3306 |
var getBlockTypesForPossibleFromTransforms = (blocks) => { |
| 3307 |
if (!blocks.length) { |
| 3308 |
return []; |
| 3309 |
} |
| 3310 |
const allBlockTypes = getBlockTypes(); |
| 3311 |
const blockTypesWithPossibleFromTransforms = allBlockTypes.flatMap( |
| 3312 |
(blockType) => { |
| 3313 |
const fromTransforms = getBlockTransforms("from", blockType.name); |
| 3314 |
return fromTransforms.filter( |
| 3315 |
(transform) => isPossibleTransformForSource(transform, "from", blocks) |
| 3316 |
).map( |
| 3317 |
(transform) => getBlockTypeWithTransformMetadata(blockType, transform) |
| 3318 |
); |
| 3319 |
} |
| 3320 |
); |
| 3321 |
return blockTypesWithPossibleFromTransforms; |
| 3322 |
}; |
| 3323 |
var getBlockTypesForPossibleToTransforms = (blocks) => { |
| 3324 |
if (!blocks.length) { |
| 3325 |
return []; |
| 3326 |
} |
| 3327 |
const sourceBlock = blocks[0]; |
| 3328 |
const blockType = getBlockType(sourceBlock.name); |
| 3329 |
const transformsTo = blockType ? getBlockTransforms("to", blockType.name) : []; |
| 3330 |
const possibleTransforms = transformsTo.filter((transform) => { |
| 3331 |
return transform && isPossibleTransformForSource(transform, "to", blocks); |
| 3332 |
}); |
| 3333 |
return possibleTransforms.flatMap((transformation) => { |
| 3334 |
return (transformation.blocks || []).map((name) => { |
| 3335 |
const transformedBlockType = getBlockType(name); |
| 3336 |
return transformedBlockType ? getBlockTypeWithTransformMetadata( |
| 3337 |
transformedBlockType, |
| 3338 |
transformation |
| 3339 |
) : void 0; |
| 3340 |
}); |
| 3341 |
}).filter((bt) => !!bt); |
| 3342 |
}; |
| 3343 |
var isWildcardBlockTransform = (t3) => !!t3 && t3.type === "block" && Array.isArray(t3.blocks) && t3.blocks.includes("*"); |
| 3344 |
var isContainerGroupBlock = (name) => name === getGroupingBlockName(); |
| 3345 |
function getPossibleBlockTransformations(blocks) { |
| 3346 |
if (!blocks.length) { |
| 3347 |
return []; |
| 3348 |
} |
| 3349 |
const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks); |
| 3350 |
const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks); |
| 3351 |
const blockTypesByNameAndVariation = /* @__PURE__ */ new Map(); |
| 3352 |
for (const blockType of [ |
| 3353 |
...blockTypesForFromTransforms, |
| 3354 |
...blockTypesForToTransforms |
| 3355 |
]) { |
| 3356 |
const key = blockType.variationName ? `${blockType.name}/${blockType.variationName}` : blockType.name; |
| 3357 |
if (!blockTypesByNameAndVariation.has(key)) { |
| 3358 |
blockTypesByNameAndVariation.set(key, blockType); |
| 3359 |
} |
| 3360 |
} |
| 3361 |
return [...blockTypesByNameAndVariation.values()]; |
| 3362 |
} |
| 3363 |
function findTransform(transforms, predicate) { |
| 3364 |
const hooks = (0, import_hooks2.createHooks)(); |
| 3365 |
for (let i2 = 0; i2 < transforms.length; i2++) { |
| 3366 |
const candidate = transforms[i2]; |
| 3367 |
if (predicate(candidate)) { |
| 3368 |
hooks.addFilter( |
| 3369 |
"transform", |
| 3370 |
"transform/" + i2.toString(), |
| 3371 |
(result) => result ? result : candidate, |
| 3372 |
candidate.priority |
| 3373 |
); |
| 3374 |
} |
| 3375 |
} |
| 3376 |
return hooks.applyFilters("transform", null); |
| 3377 |
} |
| 3378 |
function getBlockTransforms(direction, blockTypeOrName) { |
| 3379 |
if (blockTypeOrName === void 0) { |
| 3380 |
return getBlockTypes().map(({ name }) => getBlockTransforms(direction, name)).flat(); |
| 3381 |
} |
| 3382 |
const blockType = normalizeBlockType(blockTypeOrName); |
| 3383 |
const { name: blockName, transforms } = blockType || {}; |
| 3384 |
const directionTransforms = transforms?.[direction]; |
| 3385 |
if (!transforms || !Array.isArray(directionTransforms)) { |
| 3386 |
return []; |
| 3387 |
} |
| 3388 |
const usingMobileTransformations = transforms.supportedMobileTransforms && Array.isArray(transforms.supportedMobileTransforms); |
| 3389 |
const filteredTransforms = usingMobileTransformations ? directionTransforms.filter((t3) => { |
| 3390 |
if (t3.type === "raw") { |
| 3391 |
return true; |
| 3392 |
} |
| 3393 |
if (t3.type === "prefix") { |
| 3394 |
return true; |
| 3395 |
} |
| 3396 |
if (!t3.blocks || !t3.blocks.length) { |
| 3397 |
return false; |
| 3398 |
} |
| 3399 |
if (isWildcardBlockTransform(t3)) { |
| 3400 |
return true; |
| 3401 |
} |
| 3402 |
return t3.blocks.every( |
| 3403 |
(transformBlockName) => transforms.supportedMobileTransforms.includes( |
| 3404 |
transformBlockName |
| 3405 |
) |
| 3406 |
); |
| 3407 |
}) : directionTransforms; |
| 3408 |
return filteredTransforms.map((transform) => ({ |
| 3409 |
...transform, |
| 3410 |
blockName, |
| 3411 |
usingMobileTransformations |
| 3412 |
})); |
| 3413 |
} |
| 3414 |
function maybeCheckTransformIsMatch(transform, blocks) { |
| 3415 |
if (typeof transform.isMatch !== "function") { |
| 3416 |
return true; |
| 3417 |
} |
| 3418 |
const sourceBlock = blocks[0]; |
| 3419 |
const attributes = transform.isMultiBlock ? blocks.map((block2) => block2.attributes) : sourceBlock.attributes; |
| 3420 |
const block = transform.isMultiBlock ? blocks : sourceBlock; |
| 3421 |
return transform.isMatch(attributes, block); |
| 3422 |
} |
| 3423 |
function switchToBlockType(blocks, name, variationName) { |
| 3424 |
const blocksArray = Array.isArray(blocks) ? blocks : [blocks]; |
| 3425 |
const isMultiBlock = blocksArray.length > 1; |
| 3426 |
const firstBlock = blocksArray[0]; |
| 3427 |
const sourceName = firstBlock.name; |
| 3428 |
const transformationsFrom = getBlockTransforms("from", name); |
| 3429 |
const transformationsTo = getBlockTransforms("to", sourceName); |
| 3430 |
const isMatchingVariation = (t3) => variationName ? t3.variationName === variationName : !t3.variationName; |
| 3431 |
const transformation = findTransform( |
| 3432 |
transformationsTo, |
| 3433 |
(t3) => t3.type === "block" && isMatchingVariation(t3) && (isWildcardBlockTransform(t3) || t3.blocks.indexOf(name) !== -1) && (!isMultiBlock || !!t3.isMultiBlock) && maybeCheckTransformIsMatch(t3, blocksArray) |
| 3434 |
) || findTransform( |
| 3435 |
transformationsFrom, |
| 3436 |
(t3) => t3.type === "block" && isMatchingVariation(t3) && (isWildcardBlockTransform(t3) || t3.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || !!t3.isMultiBlock) && maybeCheckTransformIsMatch(t3, blocksArray) |
| 3437 |
); |
| 3438 |
if (!transformation) { |
| 3439 |
return null; |
| 3440 |
} |
| 3441 |
let transformationResults; |
| 3442 |
if (transformation.isMultiBlock) { |
| 3443 |
if ("__experimentalConvert" in transformation) { |
| 3444 |
transformationResults = transformation.__experimentalConvert(blocksArray); |
| 3445 |
} else { |
| 3446 |
transformationResults = transformation.transform( |
| 3447 |
blocksArray.map((currentBlock) => currentBlock.attributes), |
| 3448 |
blocksArray.map((currentBlock) => currentBlock.innerBlocks) |
| 3449 |
); |
| 3450 |
} |
| 3451 |
} else if ("__experimentalConvert" in transformation) { |
| 3452 |
transformationResults = transformation.__experimentalConvert(firstBlock); |
| 3453 |
} else { |
| 3454 |
transformationResults = transformation.transform( |
| 3455 |
firstBlock.attributes, |
| 3456 |
firstBlock.innerBlocks |
| 3457 |
); |
| 3458 |
} |
| 3459 |
if (transformationResults === null || typeof transformationResults !== "object") { |
| 3460 |
return null; |
| 3461 |
} |
| 3462 |
transformationResults = Array.isArray(transformationResults) ? transformationResults : [transformationResults]; |
| 3463 |
if (transformationResults.some( |
| 3464 |
(result) => !getBlockType(result.name) |
| 3465 |
)) { |
| 3466 |
return null; |
| 3467 |
} |
| 3468 |
const hasSwitchedBlock = transformationResults.some( |
| 3469 |
(result) => result.name === name |
| 3470 |
); |
| 3471 |
if (!hasSwitchedBlock) { |
| 3472 |
return null; |
| 3473 |
} |
| 3474 |
const ret = transformationResults.map((result, index, results) => { |
| 3475 |
return (0, import_hooks2.applyFilters)( |
| 3476 |
"blocks.switchToBlockType.transformedBlock", |
| 3477 |
result, |
| 3478 |
blocks, |
| 3479 |
index, |
| 3480 |
results |
| 3481 |
); |
| 3482 |
}); |
| 3483 |
return ret; |
| 3484 |
} |
| 3485 |
var getBlockFromExample = (name, example) => createBlock( |
| 3486 |
name, |
| 3487 |
example.attributes, |
| 3488 |
(example.innerBlocks ?? []).map( |
| 3489 |
(innerBlock) => getBlockFromExample(innerBlock.name, innerBlock) |
| 3490 |
) |
| 3491 |
); |
| 3492 |
|
| 3493 |
// packages/blocks/build-module/api/parser/index.mjs |
| 3494 |
var import_block_serialization_default_parser = __toESM(require_block_serialization_default_parser(), 1); |
| 3495 |
var import_autop2 = __toESM(require_autop(), 1); |
| 3496 |
|
| 3497 |
// packages/blocks/build-module/api/serializer.mjs |
| 3498 |
var import_element2 = __toESM(require_element(), 1); |
| 3499 |
var import_hooks3 = __toESM(require_hooks(), 1); |
| 3500 |
var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1); |
| 3501 |
var import_autop = __toESM(require_autop(), 1); |
| 3502 |
var import_deprecated6 = __toESM(require_deprecated(), 1); |
| 3503 |
|
| 3504 |
// packages/blocks/build-module/api/parser/serialize-raw-block.mjs |
| 3505 |
function serializeRawBlock(rawBlock, options = {}) { |
| 3506 |
const { isCommentDelimited = true } = options; |
| 3507 |
const { |
| 3508 |
blockName, |
| 3509 |
attrs = {}, |
| 3510 |
innerBlocks = [], |
| 3511 |
innerContent = [] |
| 3512 |
} = rawBlock; |
| 3513 |
let childIndex = 0; |
| 3514 |
const content = innerContent.map( |
| 3515 |
(item) => ( |
| 3516 |
// `null` denotes a nested block, otherwise we have an HTML fragment. |
| 3517 |
item !== null ? item : serializeRawBlock(innerBlocks[childIndex++], options) |
| 3518 |
) |
| 3519 |
).join("\n").replace(/\n+/g, "\n").trim(); |
| 3520 |
return isCommentDelimited ? getCommentDelimitedContent(blockName ?? void 0, attrs, content) : content; |
| 3521 |
} |
| 3522 |
|
| 3523 |
// packages/blocks/build-module/api/serializer.mjs |
| 3524 |
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); |
| 3525 |
function getBlockDefaultClassName(blockName) { |
| 3526 |
const className = "wp-block-" + blockName.replace(/\//, "-").replace(/^core-/, ""); |
| 3527 |
return (0, import_hooks3.applyFilters)( |
| 3528 |
"blocks.getBlockDefaultClassName", |
| 3529 |
className, |
| 3530 |
blockName |
| 3531 |
); |
| 3532 |
} |
| 3533 |
function getBlockMenuDefaultClassName(blockName) { |
| 3534 |
const className = "editor-block-list-item-" + blockName.replace(/\//, "-").replace(/^core-/, ""); |
| 3535 |
return (0, import_hooks3.applyFilters)( |
| 3536 |
"blocks.getBlockMenuDefaultClassName", |
| 3537 |
className, |
| 3538 |
blockName |
| 3539 |
); |
| 3540 |
} |
| 3541 |
var blockPropsProvider = {}; |
| 3542 |
var innerBlocksPropsProvider = {}; |
| 3543 |
function getBlockProps(props = {}) { |
| 3544 |
const { blockType, attributes } = blockPropsProvider; |
| 3545 |
return getBlockProps.skipFilters ? props : (0, import_hooks3.applyFilters)( |
| 3546 |
"blocks.getSaveContent.extraProps", |
| 3547 |
{ ...props }, |
| 3548 |
blockType, |
| 3549 |
attributes |
| 3550 |
); |
| 3551 |
} |
| 3552 |
function getInnerBlocksProps(props = {}) { |
| 3553 |
const { innerBlocks } = innerBlocksPropsProvider; |
| 3554 |
if (!Array.isArray(innerBlocks)) { |
| 3555 |
return { ...props, children: innerBlocks }; |
| 3556 |
} |
| 3557 |
const html2 = serialize(innerBlocks, { isInnerBlocks: true }); |
| 3558 |
const children = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_element2.RawHTML, { children: html2 }); |
| 3559 |
return { ...props, children }; |
| 3560 |
} |
| 3561 |
function getSaveElement(blockTypeOrName, attributes, innerBlocks = []) { |
| 3562 |
const blockType = normalizeBlockType(blockTypeOrName); |
| 3563 |
if (!blockType?.save) { |
| 3564 |
return null; |
| 3565 |
} |
| 3566 |
let save = blockType.save; |
| 3567 |
if (save.prototype instanceof import_element2.Component) { |
| 3568 |
const SaveClass = save; |
| 3569 |
const instance = new SaveClass({ attributes }); |
| 3570 |
save = instance.render.bind(instance); |
| 3571 |
} |
| 3572 |
blockPropsProvider.blockType = blockType; |
| 3573 |
blockPropsProvider.attributes = attributes; |
| 3574 |
innerBlocksPropsProvider.innerBlocks = innerBlocks; |
| 3575 |
let element = save({ |
| 3576 |
attributes, |
| 3577 |
innerBlocks |
| 3578 |
}); |
| 3579 |
if (element !== null && typeof element === "object" && (0, import_hooks3.hasFilter)("blocks.getSaveContent.extraProps") && !((blockType.apiVersion ?? 0) > 1)) { |
| 3580 |
const props = (0, import_hooks3.applyFilters)( |
| 3581 |
"blocks.getSaveContent.extraProps", |
| 3582 |
{ ...element.props }, |
| 3583 |
blockType, |
| 3584 |
attributes |
| 3585 |
); |
| 3586 |
if (!(0, import_is_shallow_equal.isShallowEqual)(props, element.props)) { |
| 3587 |
element = (0, import_element2.cloneElement)( |
| 3588 |
element, |
| 3589 |
props |
| 3590 |
); |
| 3591 |
} |
| 3592 |
} |
| 3593 |
return (0, import_hooks3.applyFilters)( |
| 3594 |
"blocks.getSaveElement", |
| 3595 |
element, |
| 3596 |
blockType, |
| 3597 |
attributes |
| 3598 |
); |
| 3599 |
} |
| 3600 |
function getSaveContent(blockTypeOrName, attributes, innerBlocks) { |
| 3601 |
const blockType = normalizeBlockType( |
| 3602 |
blockTypeOrName |
| 3603 |
); |
| 3604 |
if (!blockType) { |
| 3605 |
return ""; |
| 3606 |
} |
| 3607 |
return (0, import_element2.renderToString)( |
| 3608 |
getSaveElement(blockType, attributes, innerBlocks) |
| 3609 |
); |
| 3610 |
} |
| 3611 |
function getCommentAttributes(blockType, attributes) { |
| 3612 |
return Object.entries(blockType.attributes ?? {}).reduce( |
| 3613 |
(accumulator, [key, attributeSchema]) => { |
| 3614 |
const value = attributes[key]; |
| 3615 |
if (void 0 === value) { |
| 3616 |
return accumulator; |
| 3617 |
} |
| 3618 |
if (attributeSchema.source !== void 0) { |
| 3619 |
return accumulator; |
| 3620 |
} |
| 3621 |
if (attributeSchema.role === "local") { |
| 3622 |
return accumulator; |
| 3623 |
} |
| 3624 |
if (attributeSchema.__experimentalRole === "local") { |
| 3625 |
(0, import_deprecated6.default)("__experimentalRole attribute", { |
| 3626 |
since: "6.7", |
| 3627 |
version: "6.8", |
| 3628 |
alternative: "role attribute", |
| 3629 |
hint: `Check the block.json of the ${blockType?.name} block.` |
| 3630 |
}); |
| 3631 |
return accumulator; |
| 3632 |
} |
| 3633 |
if ("default" in attributeSchema && JSON.stringify(attributeSchema.default) === JSON.stringify(value)) { |
| 3634 |
return accumulator; |
| 3635 |
} |
| 3636 |
accumulator[key] = value; |
| 3637 |
return accumulator; |
| 3638 |
}, |
| 3639 |
{} |
| 3640 |
); |
| 3641 |
} |
| 3642 |
function serializeAttributes(attributes) { |
| 3643 |
return JSON.stringify(attributes).replaceAll("\\\\", "\\u005c").replaceAll("--", "\\u002d\\u002d").replaceAll("<", "\\u003c").replaceAll(">", "\\u003e").replaceAll("&", "\\u0026").replaceAll('\\"', "\\u0022"); |
| 3644 |
} |
| 3645 |
function getBlockInnerHTML(block) { |
| 3646 |
let saveContent = block.originalContent ?? ""; |
| 3647 |
if (block.isValid || block.innerBlocks.length) { |
| 3648 |
try { |
| 3649 |
saveContent = getSaveContent( |
| 3650 |
block.name, |
| 3651 |
block.attributes, |
| 3652 |
block.innerBlocks |
| 3653 |
); |
| 3654 |
} catch { |
| 3655 |
} |
| 3656 |
} |
| 3657 |
return saveContent; |
| 3658 |
} |
| 3659 |
function getCommentDelimitedContent(rawBlockName, attributes, content) { |
| 3660 |
const serializedAttributes = attributes && Object.entries(attributes).length ? serializeAttributes(attributes) + " " : ""; |
| 3661 |
const blockName = rawBlockName?.startsWith("core/") ? rawBlockName.slice(5) : rawBlockName; |
| 3662 |
if (!content) { |
| 3663 |
return `<!-- wp:${blockName} ${serializedAttributes}/-->`; |
| 3664 |
} |
| 3665 |
return `<!-- wp:${blockName} ${serializedAttributes}--> |
| 3666 |
` + content + ` |
| 3667 |
<!-- /wp:${blockName} -->`; |
| 3668 |
} |
| 3669 |
function serializeBlock(block, { isInnerBlocks = false } = {}) { |
| 3670 |
if (!block.isValid && block.__unstableBlockSource) { |
| 3671 |
return serializeRawBlock(block.__unstableBlockSource); |
| 3672 |
} |
| 3673 |
const blockName = block.name; |
| 3674 |
const saveContent = getBlockInnerHTML(block); |
| 3675 |
if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) { |
| 3676 |
return saveContent; |
| 3677 |
} |
| 3678 |
const blockType = getBlockType(blockName); |
| 3679 |
if (!blockType) { |
| 3680 |
return saveContent; |
| 3681 |
} |
| 3682 |
const saveAttributes = getCommentAttributes(blockType, block.attributes); |
| 3683 |
return getCommentDelimitedContent(blockName, saveAttributes, saveContent); |
| 3684 |
} |
| 3685 |
var __unstableSerializeAndClean = /* @__PURE__ */ (() => { |
| 3686 |
const cache = /* @__PURE__ */ new WeakMap(); |
| 3687 |
return (blocks) => { |
| 3688 |
const cached = cache.get(blocks); |
| 3689 |
if (cached !== void 0) { |
| 3690 |
return cached; |
| 3691 |
} |
| 3692 |
let effectiveBlocks = blocks; |
| 3693 |
if (effectiveBlocks.length === 1 && isUnmodifiedDefaultBlock(effectiveBlocks[0])) { |
| 3694 |
effectiveBlocks = []; |
| 3695 |
} |
| 3696 |
let content = serialize(effectiveBlocks); |
| 3697 |
if (effectiveBlocks.length === 1 && effectiveBlocks[0].name === getFreeformContentHandlerName() && effectiveBlocks[0].name === "core/freeform") { |
| 3698 |
content = (0, import_autop.removep)(content); |
| 3699 |
} |
| 3700 |
cache.set(blocks, content); |
| 3701 |
return content; |
| 3702 |
}; |
| 3703 |
})(); |
| 3704 |
function serialize(blocks, options) { |
| 3705 |
const blocksArray = Array.isArray(blocks) ? blocks : [blocks]; |
| 3706 |
return blocksArray.map((block) => serializeBlock(block, options)).join("\n\n"); |
| 3707 |
} |
| 3708 |
|
| 3709 |
// node_modules/simple-html-tokenizer/dist/es6/index.js |
| 3710 |
var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/; |
| 3711 |
var CHARCODE = /^#([0-9]+)$/; |
| 3712 |
var NAMED = /^([A-Za-z0-9]+)$/; |
| 3713 |
var EntityParser = ( |
| 3714 |
/** @class */ |
| 3715 |
(function() { |
| 3716 |
function EntityParser2(named) { |
| 3717 |
this.named = named; |
| 3718 |
} |
| 3719 |
EntityParser2.prototype.parse = function(entity) { |
| 3720 |
if (!entity) { |
| 3721 |
return; |
| 3722 |
} |
| 3723 |
var matches = entity.match(HEXCHARCODE); |
| 3724 |
if (matches) { |
| 3725 |
return String.fromCharCode(parseInt(matches[1], 16)); |
| 3726 |
} |
| 3727 |
matches = entity.match(CHARCODE); |
| 3728 |
if (matches) { |
| 3729 |
return String.fromCharCode(parseInt(matches[1], 10)); |
| 3730 |
} |
| 3731 |
matches = entity.match(NAMED); |
| 3732 |
if (matches) { |
| 3733 |
return this.named[matches[1]]; |
| 3734 |
} |
| 3735 |
}; |
| 3736 |
return EntityParser2; |
| 3737 |
})() |
| 3738 |
); |
| 3739 |
var WSP = /[\t\n\f ]/; |
| 3740 |
var ALPHA = /[A-Za-z]/; |
| 3741 |
var CRLF = /\r\n?/g; |
| 3742 |
function isSpace(char) { |
| 3743 |
return WSP.test(char); |
| 3744 |
} |
| 3745 |
function isAlpha(char) { |
| 3746 |
return ALPHA.test(char); |
| 3747 |
} |
| 3748 |
function preprocessInput(input) { |
| 3749 |
return input.replace(CRLF, "\n"); |
| 3750 |
} |
| 3751 |
var EventedTokenizer = ( |
| 3752 |
/** @class */ |
| 3753 |
(function() { |
| 3754 |
function EventedTokenizer2(delegate, entityParser) { |
| 3755 |
this.delegate = delegate; |
| 3756 |
this.entityParser = entityParser; |
| 3757 |
this.state = "beforeData"; |
| 3758 |
this.line = -1; |
| 3759 |
this.column = -1; |
| 3760 |
this.input = ""; |
| 3761 |
this.index = -1; |
| 3762 |
this.tagNameBuffer = ""; |
| 3763 |
this.states = { |
| 3764 |
beforeData: function() { |
| 3765 |
var char = this.peek(); |
| 3766 |
if (char === "<") { |
| 3767 |
this.transitionTo( |
| 3768 |
"tagOpen" |
| 3769 |
/* tagOpen */ |
| 3770 |
); |
| 3771 |
this.markTagStart(); |
| 3772 |
this.consume(); |
| 3773 |
} else { |
| 3774 |
if (char === "\n") { |
| 3775 |
var tag = this.tagNameBuffer.toLowerCase(); |
| 3776 |
if (tag === "pre" || tag === "textarea") { |
| 3777 |
this.consume(); |
| 3778 |
} |
| 3779 |
} |
| 3780 |
this.transitionTo( |
| 3781 |
"data" |
| 3782 |
/* data */ |
| 3783 |
); |
| 3784 |
this.delegate.beginData(); |
| 3785 |
} |
| 3786 |
}, |
| 3787 |
data: function() { |
| 3788 |
var char = this.peek(); |
| 3789 |
if (char === "<") { |
| 3790 |
this.delegate.finishData(); |
| 3791 |
this.transitionTo( |
| 3792 |
"tagOpen" |
| 3793 |
/* tagOpen */ |
| 3794 |
); |
| 3795 |
this.markTagStart(); |
| 3796 |
this.consume(); |
| 3797 |
} else if (char === "&") { |
| 3798 |
this.consume(); |
| 3799 |
this.delegate.appendToData(this.consumeCharRef() || "&"); |
| 3800 |
} else { |
| 3801 |
this.consume(); |
| 3802 |
this.delegate.appendToData(char); |
| 3803 |
} |
| 3804 |
}, |
| 3805 |
tagOpen: function() { |
| 3806 |
var char = this.consume(); |
| 3807 |
if (char === "!") { |
| 3808 |
this.transitionTo( |
| 3809 |
"markupDeclarationOpen" |
| 3810 |
/* markupDeclarationOpen */ |
| 3811 |
); |
| 3812 |
} else if (char === "/") { |
| 3813 |
this.transitionTo( |
| 3814 |
"endTagOpen" |
| 3815 |
/* endTagOpen */ |
| 3816 |
); |
| 3817 |
} else if (char === "@" || char === ":" || isAlpha(char)) { |
| 3818 |
this.transitionTo( |
| 3819 |
"tagName" |
| 3820 |
/* tagName */ |
| 3821 |
); |
| 3822 |
this.tagNameBuffer = ""; |
| 3823 |
this.delegate.beginStartTag(); |
| 3824 |
this.appendToTagName(char); |
| 3825 |
} |
| 3826 |
}, |
| 3827 |
markupDeclarationOpen: function() { |
| 3828 |
var char = this.consume(); |
| 3829 |
if (char === "-" && this.input.charAt(this.index) === "-") { |
| 3830 |
this.consume(); |
| 3831 |
this.transitionTo( |
| 3832 |
"commentStart" |
| 3833 |
/* commentStart */ |
| 3834 |
); |
| 3835 |
this.delegate.beginComment(); |
| 3836 |
} |
| 3837 |
}, |
| 3838 |
commentStart: function() { |
| 3839 |
var char = this.consume(); |
| 3840 |
if (char === "-") { |
| 3841 |
this.transitionTo( |
| 3842 |
"commentStartDash" |
| 3843 |
/* commentStartDash */ |
| 3844 |
); |
| 3845 |
} else if (char === ">") { |
| 3846 |
this.delegate.finishComment(); |
| 3847 |
this.transitionTo( |
| 3848 |
"beforeData" |
| 3849 |
/* beforeData */ |
| 3850 |
); |
| 3851 |
} else { |
| 3852 |
this.delegate.appendToCommentData(char); |
| 3853 |
this.transitionTo( |
| 3854 |
"comment" |
| 3855 |
/* comment */ |
| 3856 |
); |
| 3857 |
} |
| 3858 |
}, |
| 3859 |
commentStartDash: function() { |
| 3860 |
var char = this.consume(); |
| 3861 |
if (char === "-") { |
| 3862 |
this.transitionTo( |
| 3863 |
"commentEnd" |
| 3864 |
/* commentEnd */ |
| 3865 |
); |
| 3866 |
} else if (char === ">") { |
| 3867 |
this.delegate.finishComment(); |
| 3868 |
this.transitionTo( |
| 3869 |
"beforeData" |
| 3870 |
/* beforeData */ |
| 3871 |
); |
| 3872 |
} else { |
| 3873 |
this.delegate.appendToCommentData("-"); |
| 3874 |
this.transitionTo( |
| 3875 |
"comment" |
| 3876 |
/* comment */ |
| 3877 |
); |
| 3878 |
} |
| 3879 |
}, |
| 3880 |
comment: function() { |
| 3881 |
var char = this.consume(); |
| 3882 |
if (char === "-") { |
| 3883 |
this.transitionTo( |
| 3884 |
"commentEndDash" |
| 3885 |
/* commentEndDash */ |
| 3886 |
); |
| 3887 |
} else { |
| 3888 |
this.delegate.appendToCommentData(char); |
| 3889 |
} |
| 3890 |
}, |
| 3891 |
commentEndDash: function() { |
| 3892 |
var char = this.consume(); |
| 3893 |
if (char === "-") { |
| 3894 |
this.transitionTo( |
| 3895 |
"commentEnd" |
| 3896 |
/* commentEnd */ |
| 3897 |
); |
| 3898 |
} else { |
| 3899 |
this.delegate.appendToCommentData("-" + char); |
| 3900 |
this.transitionTo( |
| 3901 |
"comment" |
| 3902 |
/* comment */ |
| 3903 |
); |
| 3904 |
} |
| 3905 |
}, |
| 3906 |
commentEnd: function() { |
| 3907 |
var char = this.consume(); |
| 3908 |
if (char === ">") { |
| 3909 |
this.delegate.finishComment(); |
| 3910 |
this.transitionTo( |
| 3911 |
"beforeData" |
| 3912 |
/* beforeData */ |
| 3913 |
); |
| 3914 |
} else { |
| 3915 |
this.delegate.appendToCommentData("--" + char); |
| 3916 |
this.transitionTo( |
| 3917 |
"comment" |
| 3918 |
/* comment */ |
| 3919 |
); |
| 3920 |
} |
| 3921 |
}, |
| 3922 |
tagName: function() { |
| 3923 |
var char = this.consume(); |
| 3924 |
if (isSpace(char)) { |
| 3925 |
this.transitionTo( |
| 3926 |
"beforeAttributeName" |
| 3927 |
/* beforeAttributeName */ |
| 3928 |
); |
| 3929 |
} else if (char === "/") { |
| 3930 |
this.transitionTo( |
| 3931 |
"selfClosingStartTag" |
| 3932 |
/* selfClosingStartTag */ |
| 3933 |
); |
| 3934 |
} else if (char === ">") { |
| 3935 |
this.delegate.finishTag(); |
| 3936 |
this.transitionTo( |
| 3937 |
"beforeData" |
| 3938 |
/* beforeData */ |
| 3939 |
); |
| 3940 |
} else { |
| 3941 |
this.appendToTagName(char); |
| 3942 |
} |
| 3943 |
}, |
| 3944 |
beforeAttributeName: function() { |
| 3945 |
var char = this.peek(); |
| 3946 |
if (isSpace(char)) { |
| 3947 |
this.consume(); |
| 3948 |
return; |
| 3949 |
} else if (char === "/") { |
| 3950 |
this.transitionTo( |
| 3951 |
"selfClosingStartTag" |
| 3952 |
/* selfClosingStartTag */ |
| 3953 |
); |
| 3954 |
this.consume(); |
| 3955 |
} else if (char === ">") { |
| 3956 |
this.consume(); |
| 3957 |
this.delegate.finishTag(); |
| 3958 |
this.transitionTo( |
| 3959 |
"beforeData" |
| 3960 |
/* beforeData */ |
| 3961 |
); |
| 3962 |
} else if (char === "=") { |
| 3963 |
this.delegate.reportSyntaxError("attribute name cannot start with equals sign"); |
| 3964 |
this.transitionTo( |
| 3965 |
"attributeName" |
| 3966 |
/* attributeName */ |
| 3967 |
); |
| 3968 |
this.delegate.beginAttribute(); |
| 3969 |
this.consume(); |
| 3970 |
this.delegate.appendToAttributeName(char); |
| 3971 |
} else { |
| 3972 |
this.transitionTo( |
| 3973 |
"attributeName" |
| 3974 |
/* attributeName */ |
| 3975 |
); |
| 3976 |
this.delegate.beginAttribute(); |
| 3977 |
} |
| 3978 |
}, |
| 3979 |
attributeName: function() { |
| 3980 |
var char = this.peek(); |
| 3981 |
if (isSpace(char)) { |
| 3982 |
this.transitionTo( |
| 3983 |
"afterAttributeName" |
| 3984 |
/* afterAttributeName */ |
| 3985 |
); |
| 3986 |
this.consume(); |
| 3987 |
} else if (char === "/") { |
| 3988 |
this.delegate.beginAttributeValue(false); |
| 3989 |
this.delegate.finishAttributeValue(); |
| 3990 |
this.consume(); |
| 3991 |
this.transitionTo( |
| 3992 |
"selfClosingStartTag" |
| 3993 |
/* selfClosingStartTag */ |
| 3994 |
); |
| 3995 |
} else if (char === "=") { |
| 3996 |
this.transitionTo( |
| 3997 |
"beforeAttributeValue" |
| 3998 |
/* beforeAttributeValue */ |
| 3999 |
); |
| 4000 |
this.consume(); |
| 4001 |
} else if (char === ">") { |
| 4002 |
this.delegate.beginAttributeValue(false); |
| 4003 |
this.delegate.finishAttributeValue(); |
| 4004 |
this.consume(); |
| 4005 |
this.delegate.finishTag(); |
| 4006 |
this.transitionTo( |
| 4007 |
"beforeData" |
| 4008 |
/* beforeData */ |
| 4009 |
); |
| 4010 |
} else if (char === '"' || char === "'" || char === "<") { |
| 4011 |
this.delegate.reportSyntaxError(char + " is not a valid character within attribute names"); |
| 4012 |
this.consume(); |
| 4013 |
this.delegate.appendToAttributeName(char); |
| 4014 |
} else { |
| 4015 |
this.consume(); |
| 4016 |
this.delegate.appendToAttributeName(char); |
| 4017 |
} |
| 4018 |
}, |
| 4019 |
afterAttributeName: function() { |
| 4020 |
var char = this.peek(); |
| 4021 |
if (isSpace(char)) { |
| 4022 |
this.consume(); |
| 4023 |
return; |
| 4024 |
} else if (char === "/") { |
| 4025 |
this.delegate.beginAttributeValue(false); |
| 4026 |
this.delegate.finishAttributeValue(); |
| 4027 |
this.consume(); |
| 4028 |
this.transitionTo( |
| 4029 |
"selfClosingStartTag" |
| 4030 |
/* selfClosingStartTag */ |
| 4031 |
); |
| 4032 |
} else if (char === "=") { |
| 4033 |
this.consume(); |
| 4034 |
this.transitionTo( |
| 4035 |
"beforeAttributeValue" |
| 4036 |
/* beforeAttributeValue */ |
| 4037 |
); |
| 4038 |
} else if (char === ">") { |
| 4039 |
this.delegate.beginAttributeValue(false); |
| 4040 |
this.delegate.finishAttributeValue(); |
| 4041 |
this.consume(); |
| 4042 |
this.delegate.finishTag(); |
| 4043 |
this.transitionTo( |
| 4044 |
"beforeData" |
| 4045 |
/* beforeData */ |
| 4046 |
); |
| 4047 |
} else { |
| 4048 |
this.delegate.beginAttributeValue(false); |
| 4049 |
this.delegate.finishAttributeValue(); |
| 4050 |
this.transitionTo( |
| 4051 |
"attributeName" |
| 4052 |
/* attributeName */ |
| 4053 |
); |
| 4054 |
this.delegate.beginAttribute(); |
| 4055 |
this.consume(); |
| 4056 |
this.delegate.appendToAttributeName(char); |
| 4057 |
} |
| 4058 |
}, |
| 4059 |
beforeAttributeValue: function() { |
| 4060 |
var char = this.peek(); |
| 4061 |
if (isSpace(char)) { |
| 4062 |
this.consume(); |
| 4063 |
} else if (char === '"') { |
| 4064 |
this.transitionTo( |
| 4065 |
"attributeValueDoubleQuoted" |
| 4066 |
/* attributeValueDoubleQuoted */ |
| 4067 |
); |
| 4068 |
this.delegate.beginAttributeValue(true); |
| 4069 |
this.consume(); |
| 4070 |
} else if (char === "'") { |
| 4071 |
this.transitionTo( |
| 4072 |
"attributeValueSingleQuoted" |
| 4073 |
/* attributeValueSingleQuoted */ |
| 4074 |
); |
| 4075 |
this.delegate.beginAttributeValue(true); |
| 4076 |
this.consume(); |
| 4077 |
} else if (char === ">") { |
| 4078 |
this.delegate.beginAttributeValue(false); |
| 4079 |
this.delegate.finishAttributeValue(); |
| 4080 |
this.consume(); |
| 4081 |
this.delegate.finishTag(); |
| 4082 |
this.transitionTo( |
| 4083 |
"beforeData" |
| 4084 |
/* beforeData */ |
| 4085 |
); |
| 4086 |
} else { |
| 4087 |
this.transitionTo( |
| 4088 |
"attributeValueUnquoted" |
| 4089 |
/* attributeValueUnquoted */ |
| 4090 |
); |
| 4091 |
this.delegate.beginAttributeValue(false); |
| 4092 |
this.consume(); |
| 4093 |
this.delegate.appendToAttributeValue(char); |
| 4094 |
} |
| 4095 |
}, |
| 4096 |
attributeValueDoubleQuoted: function() { |
| 4097 |
var char = this.consume(); |
| 4098 |
if (char === '"') { |
| 4099 |
this.delegate.finishAttributeValue(); |
| 4100 |
this.transitionTo( |
| 4101 |
"afterAttributeValueQuoted" |
| 4102 |
/* afterAttributeValueQuoted */ |
| 4103 |
); |
| 4104 |
} else if (char === "&") { |
| 4105 |
this.delegate.appendToAttributeValue(this.consumeCharRef() || "&"); |
| 4106 |
} else { |
| 4107 |
this.delegate.appendToAttributeValue(char); |
| 4108 |
} |
| 4109 |
}, |
| 4110 |
attributeValueSingleQuoted: function() { |
| 4111 |
var char = this.consume(); |
| 4112 |
if (char === "'") { |
| 4113 |
this.delegate.finishAttributeValue(); |
| 4114 |
this.transitionTo( |
| 4115 |
"afterAttributeValueQuoted" |
| 4116 |
/* afterAttributeValueQuoted */ |
| 4117 |
); |
| 4118 |
} else if (char === "&") { |
| 4119 |
this.delegate.appendToAttributeValue(this.consumeCharRef() || "&"); |
| 4120 |
} else { |
| 4121 |
this.delegate.appendToAttributeValue(char); |
| 4122 |
} |
| 4123 |
}, |
| 4124 |
attributeValueUnquoted: function() { |
| 4125 |
var char = this.peek(); |
| 4126 |
if (isSpace(char)) { |
| 4127 |
this.delegate.finishAttributeValue(); |
| 4128 |
this.consume(); |
| 4129 |
this.transitionTo( |
| 4130 |
"beforeAttributeName" |
| 4131 |
/* beforeAttributeName */ |
| 4132 |
); |
| 4133 |
} else if (char === "/") { |
| 4134 |
this.delegate.finishAttributeValue(); |
| 4135 |
this.consume(); |
| 4136 |
this.transitionTo( |
| 4137 |
"selfClosingStartTag" |
| 4138 |
/* selfClosingStartTag */ |
| 4139 |
); |
| 4140 |
} else if (char === "&") { |
| 4141 |
this.consume(); |
| 4142 |
this.delegate.appendToAttributeValue(this.consumeCharRef() || "&"); |
| 4143 |
} else if (char === ">") { |
| 4144 |
this.delegate.finishAttributeValue(); |
| 4145 |
this.consume(); |
| 4146 |
this.delegate.finishTag(); |
| 4147 |
this.transitionTo( |
| 4148 |
"beforeData" |
| 4149 |
/* beforeData */ |
| 4150 |
); |
| 4151 |
} else { |
| 4152 |
this.consume(); |
| 4153 |
this.delegate.appendToAttributeValue(char); |
| 4154 |
} |
| 4155 |
}, |
| 4156 |
afterAttributeValueQuoted: function() { |
| 4157 |
var char = this.peek(); |
| 4158 |
if (isSpace(char)) { |
| 4159 |
this.consume(); |
| 4160 |
this.transitionTo( |
| 4161 |
"beforeAttributeName" |
| 4162 |
/* beforeAttributeName */ |
| 4163 |
); |
| 4164 |
} else if (char === "/") { |
| 4165 |
this.consume(); |
| 4166 |
this.transitionTo( |
| 4167 |
"selfClosingStartTag" |
| 4168 |
/* selfClosingStartTag */ |
| 4169 |
); |
| 4170 |
} else if (char === ">") { |
| 4171 |
this.consume(); |
| 4172 |
this.delegate.finishTag(); |
| 4173 |
this.transitionTo( |
| 4174 |
"beforeData" |
| 4175 |
/* beforeData */ |
| 4176 |
); |
| 4177 |
} else { |
| 4178 |
this.transitionTo( |
| 4179 |
"beforeAttributeName" |
| 4180 |
/* beforeAttributeName */ |
| 4181 |
); |
| 4182 |
} |
| 4183 |
}, |
| 4184 |
selfClosingStartTag: function() { |
| 4185 |
var char = this.peek(); |
| 4186 |
if (char === ">") { |
| 4187 |
this.consume(); |
| 4188 |
this.delegate.markTagAsSelfClosing(); |
| 4189 |
this.delegate.finishTag(); |
| 4190 |
this.transitionTo( |
| 4191 |
"beforeData" |
| 4192 |
/* beforeData */ |
| 4193 |
); |
| 4194 |
} else { |
| 4195 |
this.transitionTo( |
| 4196 |
"beforeAttributeName" |
| 4197 |
/* beforeAttributeName */ |
| 4198 |
); |
| 4199 |
} |
| 4200 |
}, |
| 4201 |
endTagOpen: function() { |
| 4202 |
var char = this.consume(); |
| 4203 |
if (char === "@" || char === ":" || isAlpha(char)) { |
| 4204 |
this.transitionTo( |
| 4205 |
"tagName" |
| 4206 |
/* tagName */ |
| 4207 |
); |
| 4208 |
this.tagNameBuffer = ""; |
| 4209 |
this.delegate.beginEndTag(); |
| 4210 |
this.appendToTagName(char); |
| 4211 |
} |
| 4212 |
} |
| 4213 |
}; |
| 4214 |
this.reset(); |
| 4215 |
} |
| 4216 |
EventedTokenizer2.prototype.reset = function() { |
| 4217 |
this.transitionTo( |
| 4218 |
"beforeData" |
| 4219 |
/* beforeData */ |
| 4220 |
); |
| 4221 |
this.input = ""; |
| 4222 |
this.index = 0; |
| 4223 |
this.line = 1; |
| 4224 |
this.column = 0; |
| 4225 |
this.delegate.reset(); |
| 4226 |
}; |
| 4227 |
EventedTokenizer2.prototype.transitionTo = function(state) { |
| 4228 |
this.state = state; |
| 4229 |
}; |
| 4230 |
EventedTokenizer2.prototype.tokenize = function(input) { |
| 4231 |
this.reset(); |
| 4232 |
this.tokenizePart(input); |
| 4233 |
this.tokenizeEOF(); |
| 4234 |
}; |
| 4235 |
EventedTokenizer2.prototype.tokenizePart = function(input) { |
| 4236 |
this.input += preprocessInput(input); |
| 4237 |
while (this.index < this.input.length) { |
| 4238 |
var handler = this.states[this.state]; |
| 4239 |
if (handler !== void 0) { |
| 4240 |
handler.call(this); |
| 4241 |
} else { |
| 4242 |
throw new Error("unhandled state " + this.state); |
| 4243 |
} |
| 4244 |
} |
| 4245 |
}; |
| 4246 |
EventedTokenizer2.prototype.tokenizeEOF = function() { |
| 4247 |
this.flushData(); |
| 4248 |
}; |
| 4249 |
EventedTokenizer2.prototype.flushData = function() { |
| 4250 |
if (this.state === "data") { |
| 4251 |
this.delegate.finishData(); |
| 4252 |
this.transitionTo( |
| 4253 |
"beforeData" |
| 4254 |
/* beforeData */ |
| 4255 |
); |
| 4256 |
} |
| 4257 |
}; |
| 4258 |
EventedTokenizer2.prototype.peek = function() { |
| 4259 |
return this.input.charAt(this.index); |
| 4260 |
}; |
| 4261 |
EventedTokenizer2.prototype.consume = function() { |
| 4262 |
var char = this.peek(); |
| 4263 |
this.index++; |
| 4264 |
if (char === "\n") { |
| 4265 |
this.line++; |
| 4266 |
this.column = 0; |
| 4267 |
} else { |
| 4268 |
this.column++; |
| 4269 |
} |
| 4270 |
return char; |
| 4271 |
}; |
| 4272 |
EventedTokenizer2.prototype.consumeCharRef = function() { |
| 4273 |
var endIndex = this.input.indexOf(";", this.index); |
| 4274 |
if (endIndex === -1) { |
| 4275 |
return; |
| 4276 |
} |
| 4277 |
var entity = this.input.slice(this.index, endIndex); |
| 4278 |
var chars = this.entityParser.parse(entity); |
| 4279 |
if (chars) { |
| 4280 |
var count = entity.length; |
| 4281 |
while (count) { |
| 4282 |
this.consume(); |
| 4283 |
count--; |
| 4284 |
} |
| 4285 |
this.consume(); |
| 4286 |
return chars; |
| 4287 |
} |
| 4288 |
}; |
| 4289 |
EventedTokenizer2.prototype.markTagStart = function() { |
| 4290 |
this.delegate.tagOpen(); |
| 4291 |
}; |
| 4292 |
EventedTokenizer2.prototype.appendToTagName = function(char) { |
| 4293 |
this.tagNameBuffer += char; |
| 4294 |
this.delegate.appendToTagName(char); |
| 4295 |
}; |
| 4296 |
return EventedTokenizer2; |
| 4297 |
})() |
| 4298 |
); |
| 4299 |
var Tokenizer = ( |
| 4300 |
/** @class */ |
| 4301 |
(function() { |
| 4302 |
function Tokenizer2(entityParser, options) { |
| 4303 |
if (options === void 0) { |
| 4304 |
options = {}; |
| 4305 |
} |
| 4306 |
this.options = options; |
| 4307 |
this.token = null; |
| 4308 |
this.startLine = 1; |
| 4309 |
this.startColumn = 0; |
| 4310 |
this.tokens = []; |
| 4311 |
this.tokenizer = new EventedTokenizer(this, entityParser); |
| 4312 |
this._currentAttribute = void 0; |
| 4313 |
} |
| 4314 |
Tokenizer2.prototype.tokenize = function(input) { |
| 4315 |
this.tokens = []; |
| 4316 |
this.tokenizer.tokenize(input); |
| 4317 |
return this.tokens; |
| 4318 |
}; |
| 4319 |
Tokenizer2.prototype.tokenizePart = function(input) { |
| 4320 |
this.tokens = []; |
| 4321 |
this.tokenizer.tokenizePart(input); |
| 4322 |
return this.tokens; |
| 4323 |
}; |
| 4324 |
Tokenizer2.prototype.tokenizeEOF = function() { |
| 4325 |
this.tokens = []; |
| 4326 |
this.tokenizer.tokenizeEOF(); |
| 4327 |
return this.tokens[0]; |
| 4328 |
}; |
| 4329 |
Tokenizer2.prototype.reset = function() { |
| 4330 |
this.token = null; |
| 4331 |
this.startLine = 1; |
| 4332 |
this.startColumn = 0; |
| 4333 |
}; |
| 4334 |
Tokenizer2.prototype.current = function() { |
| 4335 |
var token = this.token; |
| 4336 |
if (token === null) { |
| 4337 |
throw new Error("token was unexpectedly null"); |
| 4338 |
} |
| 4339 |
if (arguments.length === 0) { |
| 4340 |
return token; |
| 4341 |
} |
| 4342 |
for (var i2 = 0; i2 < arguments.length; i2++) { |
| 4343 |
if (token.type === arguments[i2]) { |
| 4344 |
return token; |
| 4345 |
} |
| 4346 |
} |
| 4347 |
throw new Error("token type was unexpectedly " + token.type); |
| 4348 |
}; |
| 4349 |
Tokenizer2.prototype.push = function(token) { |
| 4350 |
this.token = token; |
| 4351 |
this.tokens.push(token); |
| 4352 |
}; |
| 4353 |
Tokenizer2.prototype.currentAttribute = function() { |
| 4354 |
return this._currentAttribute; |
| 4355 |
}; |
| 4356 |
Tokenizer2.prototype.addLocInfo = function() { |
| 4357 |
if (this.options.loc) { |
| 4358 |
this.current().loc = { |
| 4359 |
start: { |
| 4360 |
line: this.startLine, |
| 4361 |
column: this.startColumn |
| 4362 |
}, |
| 4363 |
end: { |
| 4364 |
line: this.tokenizer.line, |
| 4365 |
column: this.tokenizer.column |
| 4366 |
} |
| 4367 |
}; |
| 4368 |
} |
| 4369 |
this.startLine = this.tokenizer.line; |
| 4370 |
this.startColumn = this.tokenizer.column; |
| 4371 |
}; |
| 4372 |
Tokenizer2.prototype.beginData = function() { |
| 4373 |
this.push({ |
| 4374 |
type: "Chars", |
| 4375 |
chars: "" |
| 4376 |
}); |
| 4377 |
}; |
| 4378 |
Tokenizer2.prototype.appendToData = function(char) { |
| 4379 |
this.current( |
| 4380 |
"Chars" |
| 4381 |
/* Chars */ |
| 4382 |
).chars += char; |
| 4383 |
}; |
| 4384 |
Tokenizer2.prototype.finishData = function() { |
| 4385 |
this.addLocInfo(); |
| 4386 |
}; |
| 4387 |
Tokenizer2.prototype.beginComment = function() { |
| 4388 |
this.push({ |
| 4389 |
type: "Comment", |
| 4390 |
chars: "" |
| 4391 |
}); |
| 4392 |
}; |
| 4393 |
Tokenizer2.prototype.appendToCommentData = function(char) { |
| 4394 |
this.current( |
| 4395 |
"Comment" |
| 4396 |
/* Comment */ |
| 4397 |
).chars += char; |
| 4398 |
}; |
| 4399 |
Tokenizer2.prototype.finishComment = function() { |
| 4400 |
this.addLocInfo(); |
| 4401 |
}; |
| 4402 |
Tokenizer2.prototype.tagOpen = function() { |
| 4403 |
}; |
| 4404 |
Tokenizer2.prototype.beginStartTag = function() { |
| 4405 |
this.push({ |
| 4406 |
type: "StartTag", |
| 4407 |
tagName: "", |
| 4408 |
attributes: [], |
| 4409 |
selfClosing: false |
| 4410 |
}); |
| 4411 |
}; |
| 4412 |
Tokenizer2.prototype.beginEndTag = function() { |
| 4413 |
this.push({ |
| 4414 |
type: "EndTag", |
| 4415 |
tagName: "" |
| 4416 |
}); |
| 4417 |
}; |
| 4418 |
Tokenizer2.prototype.finishTag = function() { |
| 4419 |
this.addLocInfo(); |
| 4420 |
}; |
| 4421 |
Tokenizer2.prototype.markTagAsSelfClosing = function() { |
| 4422 |
this.current( |
| 4423 |
"StartTag" |
| 4424 |
/* StartTag */ |
| 4425 |
).selfClosing = true; |
| 4426 |
}; |
| 4427 |
Tokenizer2.prototype.appendToTagName = function(char) { |
| 4428 |
this.current( |
| 4429 |
"StartTag", |
| 4430 |
"EndTag" |
| 4431 |
/* EndTag */ |
| 4432 |
).tagName += char; |
| 4433 |
}; |
| 4434 |
Tokenizer2.prototype.beginAttribute = function() { |
| 4435 |
this._currentAttribute = ["", "", false]; |
| 4436 |
}; |
| 4437 |
Tokenizer2.prototype.appendToAttributeName = function(char) { |
| 4438 |
this.currentAttribute()[0] += char; |
| 4439 |
}; |
| 4440 |
Tokenizer2.prototype.beginAttributeValue = function(isQuoted) { |
| 4441 |
this.currentAttribute()[2] = isQuoted; |
| 4442 |
}; |
| 4443 |
Tokenizer2.prototype.appendToAttributeValue = function(char) { |
| 4444 |
this.currentAttribute()[1] += char; |
| 4445 |
}; |
| 4446 |
Tokenizer2.prototype.finishAttributeValue = function() { |
| 4447 |
this.current( |
| 4448 |
"StartTag" |
| 4449 |
/* StartTag */ |
| 4450 |
).attributes.push(this._currentAttribute); |
| 4451 |
}; |
| 4452 |
Tokenizer2.prototype.reportSyntaxError = function(message) { |
| 4453 |
this.current().syntaxError = message; |
| 4454 |
}; |
| 4455 |
return Tokenizer2; |
| 4456 |
})() |
| 4457 |
); |
| 4458 |
|
| 4459 |
// packages/blocks/build-module/api/validation/index.mjs |
| 4460 |
var import_es6 = __toESM(require_es6(), 1); |
| 4461 |
var import_deprecated7 = __toESM(require_deprecated(), 1); |
| 4462 |
var import_html_entities = __toESM(require_html_entities(), 1); |
| 4463 |
|
| 4464 |
// packages/blocks/build-module/api/validation/logger.mjs |
| 4465 |
function createLogger() { |
| 4466 |
function createLogHandler(logger) { |
| 4467 |
return (message, ...args) => logger("Block validation: " + message, ...args); |
| 4468 |
} |
| 4469 |
return { |
| 4470 |
// eslint-disable-next-line no-console |
| 4471 |
error: createLogHandler(console.error), |
| 4472 |
// eslint-disable-next-line no-console |
| 4473 |
warning: createLogHandler(console.warn), |
| 4474 |
getItems() { |
| 4475 |
return []; |
| 4476 |
} |
| 4477 |
}; |
| 4478 |
} |
| 4479 |
function createQueuedLogger() { |
| 4480 |
const queue = []; |
| 4481 |
const logger = createLogger(); |
| 4482 |
return { |
| 4483 |
error(...args) { |
| 4484 |
queue.push({ log: logger.error, args }); |
| 4485 |
}, |
| 4486 |
warning(...args) { |
| 4487 |
queue.push({ log: logger.warning, args }); |
| 4488 |
}, |
| 4489 |
getItems() { |
| 4490 |
return queue; |
| 4491 |
} |
| 4492 |
}; |
| 4493 |
} |
| 4494 |
|
| 4495 |
// packages/blocks/build-module/api/validation/index.mjs |
| 4496 |
var identity = (x3) => x3; |
| 4497 |
var REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g; |
| 4498 |
var REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/; |
| 4499 |
var REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/; |
| 4500 |
var BOOLEAN_ATTRIBUTES = [ |
| 4501 |
"allowfullscreen", |
| 4502 |
"allowpaymentrequest", |
| 4503 |
"allowusermedia", |
| 4504 |
"async", |
| 4505 |
"autofocus", |
| 4506 |
"autoplay", |
| 4507 |
"checked", |
| 4508 |
"controls", |
| 4509 |
"default", |
| 4510 |
"defer", |
| 4511 |
"disabled", |
| 4512 |
"download", |
| 4513 |
"formnovalidate", |
| 4514 |
"hidden", |
| 4515 |
"ismap", |
| 4516 |
"itemscope", |
| 4517 |
"loop", |
| 4518 |
"multiple", |
| 4519 |
"muted", |
| 4520 |
"nomodule", |
| 4521 |
"novalidate", |
| 4522 |
"open", |
| 4523 |
"playsinline", |
| 4524 |
"readonly", |
| 4525 |
"required", |
| 4526 |
"reversed", |
| 4527 |
"selected", |
| 4528 |
"typemustmatch" |
| 4529 |
]; |
| 4530 |
var ENUMERATED_ATTRIBUTES = [ |
| 4531 |
"autocapitalize", |
| 4532 |
"autocomplete", |
| 4533 |
"charset", |
| 4534 |
"contenteditable", |
| 4535 |
"crossorigin", |
| 4536 |
"decoding", |
| 4537 |
"dir", |
| 4538 |
"draggable", |
| 4539 |
"enctype", |
| 4540 |
"formenctype", |
| 4541 |
"formmethod", |
| 4542 |
"http-equiv", |
| 4543 |
"inputmode", |
| 4544 |
"kind", |
| 4545 |
"method", |
| 4546 |
"preload", |
| 4547 |
"scope", |
| 4548 |
"shape", |
| 4549 |
"spellcheck", |
| 4550 |
"translate", |
| 4551 |
"type", |
| 4552 |
"wrap" |
| 4553 |
]; |
| 4554 |
var MEANINGFUL_ATTRIBUTES = [ |
| 4555 |
...BOOLEAN_ATTRIBUTES, |
| 4556 |
...ENUMERATED_ATTRIBUTES |
| 4557 |
]; |
| 4558 |
var TEXT_NORMALIZATIONS = [ |
| 4559 |
identity, |
| 4560 |
getTextWithCollapsedWhitespace |
| 4561 |
]; |
| 4562 |
var REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i; |
| 4563 |
var REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/; |
| 4564 |
var REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i; |
| 4565 |
function isValidCharacterReference(text2) { |
| 4566 |
return REGEXP_NAMED_CHARACTER_REFERENCE.test(text2) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text2) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text2); |
| 4567 |
} |
| 4568 |
var DecodeEntityParser = class { |
| 4569 |
/** |
| 4570 |
* Returns a substitute string for an entity string sequence between `&` |
| 4571 |
* and `;`, or undefined if no substitution should occur. |
| 4572 |
* |
| 4573 |
* @param entity Entity fragment discovered in HTML. |
| 4574 |
* |
| 4575 |
* @return Entity substitute value. |
| 4576 |
*/ |
| 4577 |
parse(entity) { |
| 4578 |
if (isValidCharacterReference(entity)) { |
| 4579 |
return (0, import_html_entities.decodeEntities)("&" + entity + ";"); |
| 4580 |
} |
| 4581 |
return void 0; |
| 4582 |
} |
| 4583 |
}; |
| 4584 |
function getTextPiecesSplitOnWhitespace(text2) { |
| 4585 |
return text2.trim().split(REGEXP_WHITESPACE); |
| 4586 |
} |
| 4587 |
function getTextWithCollapsedWhitespace(text2) { |
| 4588 |
return getTextPiecesSplitOnWhitespace(text2).join(" "); |
| 4589 |
} |
| 4590 |
function getMeaningfulAttributePairs(token) { |
| 4591 |
return (token.attributes ?? []).filter((pair) => { |
| 4592 |
const [key, value] = pair; |
| 4593 |
return value || key.indexOf("data-") === 0 || MEANINGFUL_ATTRIBUTES.includes(key); |
| 4594 |
}); |
| 4595 |
} |
| 4596 |
function isEquivalentTextTokens(actual, expected, logger = createLogger()) { |
| 4597 |
let actualChars = actual.chars; |
| 4598 |
let expectedChars = expected.chars; |
| 4599 |
for (let i2 = 0; i2 < TEXT_NORMALIZATIONS.length; i2++) { |
| 4600 |
const normalize = TEXT_NORMALIZATIONS[i2]; |
| 4601 |
actualChars = normalize(actualChars); |
| 4602 |
expectedChars = normalize(expectedChars); |
| 4603 |
if (actualChars === expectedChars) { |
| 4604 |
return true; |
| 4605 |
} |
| 4606 |
} |
| 4607 |
logger.warning( |
| 4608 |
"Expected text `%s`, saw `%s`.", |
| 4609 |
expected.chars, |
| 4610 |
actual.chars |
| 4611 |
); |
| 4612 |
return false; |
| 4613 |
} |
| 4614 |
function getNormalizedLength(value) { |
| 4615 |
if (0 === parseFloat(value)) { |
| 4616 |
return "0"; |
| 4617 |
} |
| 4618 |
if (value.indexOf(".") === 0) { |
| 4619 |
return "0" + value; |
| 4620 |
} |
| 4621 |
return value; |
| 4622 |
} |
| 4623 |
function getNormalizedStyleValue(value) { |
| 4624 |
const textPieces = getTextPiecesSplitOnWhitespace(value); |
| 4625 |
const normalizedPieces = textPieces.map(getNormalizedLength); |
| 4626 |
const result = normalizedPieces.join(" "); |
| 4627 |
return result.replace(REGEXP_STYLE_URL_TYPE, "url($1)"); |
| 4628 |
} |
| 4629 |
function getStyleProperties(text2) { |
| 4630 |
const pairs = text2.replace(/;?\s*$/, "").split(";").map((style) => { |
| 4631 |
const [key, ...valueParts] = style.split(":"); |
| 4632 |
const value = valueParts.join(":"); |
| 4633 |
return [key.trim(), getNormalizedStyleValue(value.trim())]; |
| 4634 |
}); |
| 4635 |
return Object.fromEntries(pairs); |
| 4636 |
} |
| 4637 |
var isEqualAttributesOfName = { |
| 4638 |
class: (actual, expected) => { |
| 4639 |
const [actualPieces, expectedPieces] = [actual, expected].map( |
| 4640 |
getTextPiecesSplitOnWhitespace |
| 4641 |
); |
| 4642 |
const actualDiff = actualPieces.filter( |
| 4643 |
(c2) => !expectedPieces.includes(c2) |
| 4644 |
); |
| 4645 |
const expectedDiff = expectedPieces.filter( |
| 4646 |
(c2) => !actualPieces.includes(c2) |
| 4647 |
); |
| 4648 |
return actualDiff.length === 0 && expectedDiff.length === 0; |
| 4649 |
}, |
| 4650 |
style: (actual, expected) => { |
| 4651 |
return (0, import_es6.default)( |
| 4652 |
...[actual, expected].map(getStyleProperties) |
| 4653 |
); |
| 4654 |
}, |
| 4655 |
// For each boolean attribute, mere presence of attribute in both is enough |
| 4656 |
// to assume equivalence. |
| 4657 |
...Object.fromEntries( |
| 4658 |
BOOLEAN_ATTRIBUTES.map((attribute) => [attribute, () => true]) |
| 4659 |
) |
| 4660 |
}; |
| 4661 |
function isEqualTagAttributePairs(actual, expected, logger = createLogger()) { |
| 4662 |
if (actual.length !== expected.length) { |
| 4663 |
logger.warning( |
| 4664 |
"Expected attributes %o, instead saw %o.", |
| 4665 |
expected, |
| 4666 |
actual |
| 4667 |
); |
| 4668 |
return false; |
| 4669 |
} |
| 4670 |
const expectedAttributes = {}; |
| 4671 |
for (let i2 = 0; i2 < expected.length; i2++) { |
| 4672 |
expectedAttributes[expected[i2][0].toLowerCase()] = expected[i2][1]; |
| 4673 |
} |
| 4674 |
for (let i2 = 0; i2 < actual.length; i2++) { |
| 4675 |
const [name, actualValue] = actual[i2]; |
| 4676 |
const nameLower = name.toLowerCase(); |
| 4677 |
if (!expectedAttributes.hasOwnProperty(nameLower)) { |
| 4678 |
logger.warning("Encountered unexpected attribute `%s`.", name); |
| 4679 |
return false; |
| 4680 |
} |
| 4681 |
const expectedValue = expectedAttributes[nameLower]; |
| 4682 |
const isEqualAttributes = isEqualAttributesOfName[nameLower]; |
| 4683 |
if (isEqualAttributes) { |
| 4684 |
if (!isEqualAttributes(actualValue, expectedValue)) { |
| 4685 |
logger.warning( |
| 4686 |
"Expected attribute `%s` of value `%s`, saw `%s`.", |
| 4687 |
name, |
| 4688 |
expectedValue, |
| 4689 |
actualValue |
| 4690 |
); |
| 4691 |
return false; |
| 4692 |
} |
| 4693 |
} else if (actualValue !== expectedValue) { |
| 4694 |
logger.warning( |
| 4695 |
"Expected attribute `%s` of value `%s`, saw `%s`.", |
| 4696 |
name, |
| 4697 |
expectedValue, |
| 4698 |
actualValue |
| 4699 |
); |
| 4700 |
return false; |
| 4701 |
} |
| 4702 |
} |
| 4703 |
return true; |
| 4704 |
} |
| 4705 |
var isEqualTokensOfType = { |
| 4706 |
StartTag: (actual, expected, logger = createLogger()) => { |
| 4707 |
if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case- |
| 4708 |
// insensitive check on the assumption that the majority case will |
| 4709 |
// have exactly equal tag names. |
| 4710 |
actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) { |
| 4711 |
logger.warning( |
| 4712 |
"Expected tag name `%s`, instead saw `%s`.", |
| 4713 |
expected.tagName, |
| 4714 |
actual.tagName |
| 4715 |
); |
| 4716 |
return false; |
| 4717 |
} |
| 4718 |
return isEqualTagAttributePairs( |
| 4719 |
...[actual, expected].map(getMeaningfulAttributePairs), |
| 4720 |
logger |
| 4721 |
); |
| 4722 |
}, |
| 4723 |
Chars: isEquivalentTextTokens, |
| 4724 |
Comment: isEquivalentTextTokens |
| 4725 |
}; |
| 4726 |
function getNextNonWhitespaceToken(tokens) { |
| 4727 |
let token; |
| 4728 |
while (token = tokens.shift()) { |
| 4729 |
if (token.type !== "Chars") { |
| 4730 |
return token; |
| 4731 |
} |
| 4732 |
if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) { |
| 4733 |
return token; |
| 4734 |
} |
| 4735 |
} |
| 4736 |
return void 0; |
| 4737 |
} |
| 4738 |
function getHTMLTokens(html2, logger = createLogger()) { |
| 4739 |
try { |
| 4740 |
return new Tokenizer(new DecodeEntityParser()).tokenize( |
| 4741 |
html2 |
| 4742 |
); |
| 4743 |
} catch { |
| 4744 |
logger.warning("Malformed HTML detected: %s", html2); |
| 4745 |
} |
| 4746 |
return null; |
| 4747 |
} |
| 4748 |
function isClosedByToken(currentToken, nextToken) { |
| 4749 |
if (!currentToken.selfClosing) { |
| 4750 |
return false; |
| 4751 |
} |
| 4752 |
if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === "EndTag") { |
| 4753 |
return true; |
| 4754 |
} |
| 4755 |
return false; |
| 4756 |
} |
| 4757 |
function isEquivalentHTML(actual, expected, logger = createLogger()) { |
| 4758 |
if (actual === expected) { |
| 4759 |
return true; |
| 4760 |
} |
| 4761 |
const [actualTokens, expectedTokens] = [actual, expected].map( |
| 4762 |
(html2) => getHTMLTokens(html2, logger) |
| 4763 |
); |
| 4764 |
if (!actualTokens || !expectedTokens) { |
| 4765 |
return false; |
| 4766 |
} |
| 4767 |
let actualToken, expectedToken; |
| 4768 |
while (actualToken = getNextNonWhitespaceToken(actualTokens)) { |
| 4769 |
expectedToken = getNextNonWhitespaceToken(expectedTokens); |
| 4770 |
if (!expectedToken) { |
| 4771 |
logger.warning( |
| 4772 |
"Expected end of content, instead saw %o.", |
| 4773 |
actualToken |
| 4774 |
); |
| 4775 |
return false; |
| 4776 |
} |
| 4777 |
if (actualToken.type !== expectedToken.type) { |
| 4778 |
logger.warning( |
| 4779 |
"Expected token of type `%s` (%o), instead saw `%s` (%o).", |
| 4780 |
expectedToken.type, |
| 4781 |
expectedToken, |
| 4782 |
actualToken.type, |
| 4783 |
actualToken |
| 4784 |
); |
| 4785 |
return false; |
| 4786 |
} |
| 4787 |
const isEqualTokens = isEqualTokensOfType[actualToken.type]; |
| 4788 |
if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) { |
| 4789 |
return false; |
| 4790 |
} |
| 4791 |
if (isClosedByToken(actualToken, expectedTokens[0])) { |
| 4792 |
getNextNonWhitespaceToken(expectedTokens); |
| 4793 |
} else if (isClosedByToken(expectedToken, actualTokens[0])) { |
| 4794 |
getNextNonWhitespaceToken(actualTokens); |
| 4795 |
} |
| 4796 |
} |
| 4797 |
if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) { |
| 4798 |
logger.warning( |
| 4799 |
"Expected %o, instead saw end of content.", |
| 4800 |
expectedToken |
| 4801 |
); |
| 4802 |
return false; |
| 4803 |
} |
| 4804 |
return true; |
| 4805 |
} |
| 4806 |
function validateBlock(block, blockTypeOrName = block.name) { |
| 4807 |
const isFallbackBlock = block.name === getFreeformContentHandlerName() || block.name === getUnregisteredTypeHandlerName(); |
| 4808 |
if (isFallbackBlock) { |
| 4809 |
return [true, []]; |
| 4810 |
} |
| 4811 |
const logger = createQueuedLogger(); |
| 4812 |
const blockType = normalizeBlockType(blockTypeOrName); |
| 4813 |
let generatedBlockContent; |
| 4814 |
try { |
| 4815 |
generatedBlockContent = getSaveContent(blockType, block.attributes); |
| 4816 |
} catch (error) { |
| 4817 |
logger.error( |
| 4818 |
"Block validation failed because an error occurred while generating block content:\n\n%s", |
| 4819 |
error.toString() |
| 4820 |
); |
| 4821 |
return [false, logger.getItems()]; |
| 4822 |
} |
| 4823 |
const isValid = isEquivalentHTML( |
| 4824 |
block.originalContent, |
| 4825 |
generatedBlockContent, |
| 4826 |
logger |
| 4827 |
); |
| 4828 |
if (!isValid) { |
| 4829 |
logger.error( |
| 4830 |
"Block validation failed for `%s` (%o).\n\nContent generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s", |
| 4831 |
blockType.name, |
| 4832 |
blockType, |
| 4833 |
generatedBlockContent, |
| 4834 |
block.originalContent |
| 4835 |
); |
| 4836 |
} |
| 4837 |
return [isValid, logger.getItems()]; |
| 4838 |
} |
| 4839 |
function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) { |
| 4840 |
(0, import_deprecated7.default)("isValidBlockContent introduces opportunity for data loss", { |
| 4841 |
since: "12.6", |
| 4842 |
plugin: "Gutenberg", |
| 4843 |
alternative: "validateBlock" |
| 4844 |
}); |
| 4845 |
const blockType = normalizeBlockType(blockTypeOrName); |
| 4846 |
const block = { |
| 4847 |
clientId: "", |
| 4848 |
name: blockType.name, |
| 4849 |
isValid: true, |
| 4850 |
attributes, |
| 4851 |
innerBlocks: [], |
| 4852 |
originalContent: originalBlockContent |
| 4853 |
}; |
| 4854 |
const [isValid] = validateBlock(block, blockType); |
| 4855 |
return isValid; |
| 4856 |
} |
| 4857 |
|
| 4858 |
// packages/blocks/build-module/api/parser/convert-legacy-block.mjs |
| 4859 |
function normalizeStyleStateAliases(style) { |
| 4860 |
if (false) { |
| 4861 |
return style; |
| 4862 |
} |
| 4863 |
if (!style || typeof style !== "object" || Array.isArray(style)) { |
| 4864 |
return style; |
| 4865 |
} |
| 4866 |
let normalizedStyle = style; |
| 4867 |
const viewportAliases = { |
| 4868 |
"@mobile": "mobile", |
| 4869 |
"@tablet": "tablet" |
| 4870 |
}; |
| 4871 |
Object.entries(viewportAliases).forEach(([state, legacyState]) => { |
| 4872 |
if (!Object.hasOwn(normalizedStyle, legacyState)) { |
| 4873 |
return; |
| 4874 |
} |
| 4875 |
if (normalizedStyle === style) { |
| 4876 |
normalizedStyle = { ...normalizedStyle }; |
| 4877 |
} |
| 4878 |
if (!Object.hasOwn(normalizedStyle, state)) { |
| 4879 |
normalizedStyle[state] = normalizedStyle[legacyState]; |
| 4880 |
} |
| 4881 |
delete normalizedStyle[legacyState]; |
| 4882 |
}); |
| 4883 |
return normalizedStyle; |
| 4884 |
} |
| 4885 |
function convertLegacyBlockNameAndAttributes(name, attributes) { |
| 4886 |
const newAttributes = { ...attributes }; |
| 4887 |
if ("core/cover-image" === name) { |
| 4888 |
name = "core/cover"; |
| 4889 |
} |
| 4890 |
if ("core/text" === name || "core/cover-text" === name) { |
| 4891 |
name = "core/paragraph"; |
| 4892 |
} |
| 4893 |
if (name && name.indexOf("core/social-link-") === 0) { |
| 4894 |
newAttributes.service = name.substring(17); |
| 4895 |
name = "core/social-link"; |
| 4896 |
} |
| 4897 |
if (name && name.indexOf("core-embed/") === 0) { |
| 4898 |
const providerSlug = name.substring(11); |
| 4899 |
const deprecated12 = { |
| 4900 |
speaker: "speaker-deck", |
| 4901 |
polldaddy: "crowdsignal" |
| 4902 |
}; |
| 4903 |
newAttributes.providerNameSlug = providerSlug in deprecated12 ? deprecated12[providerSlug] : providerSlug; |
| 4904 |
if (!["amazon-kindle", "wordpress"].includes(providerSlug)) { |
| 4905 |
newAttributes.responsive = true; |
| 4906 |
} |
| 4907 |
name = "core/embed"; |
| 4908 |
} |
| 4909 |
if (name === "core/post-comment-author") { |
| 4910 |
name = "core/comment-author-name"; |
| 4911 |
} |
| 4912 |
if (name === "core/post-comment-content") { |
| 4913 |
name = "core/comment-content"; |
| 4914 |
} |
| 4915 |
if (name === "core/post-comment-date") { |
| 4916 |
name = "core/comment-date"; |
| 4917 |
} |
| 4918 |
if (name === "core/comments-query-loop") { |
| 4919 |
name = "core/comments"; |
| 4920 |
const className = newAttributes.className ?? ""; |
| 4921 |
if (!className.includes("wp-block-comments-query-loop")) { |
| 4922 |
newAttributes.className = [ |
| 4923 |
"wp-block-comments-query-loop", |
| 4924 |
className |
| 4925 |
].join(" "); |
| 4926 |
} |
| 4927 |
} |
| 4928 |
if (name === "core/post-comments") { |
| 4929 |
name = "core/comments"; |
| 4930 |
newAttributes.legacy = true; |
| 4931 |
} |
| 4932 |
const layout = attributes.layout; |
| 4933 |
if (layout?.type === "grid" && typeof layout?.columnCount === "string") { |
| 4934 |
newAttributes.layout = { |
| 4935 |
...newAttributes.layout, |
| 4936 |
columnCount: parseInt(layout.columnCount, 10) |
| 4937 |
}; |
| 4938 |
} |
| 4939 |
const style = attributes.style; |
| 4940 |
const styleLayout = style?.layout; |
| 4941 |
if (typeof styleLayout?.columnSpan === "string") { |
| 4942 |
const columnSpanNumber = parseInt(styleLayout.columnSpan, 10); |
| 4943 |
newAttributes.style = { |
| 4944 |
...newAttributes.style, |
| 4945 |
layout: { |
| 4946 |
...newAttributes.style?.layout, |
| 4947 |
columnSpan: isNaN(columnSpanNumber) ? void 0 : columnSpanNumber |
| 4948 |
} |
| 4949 |
}; |
| 4950 |
} |
| 4951 |
if (typeof styleLayout?.rowSpan === "string") { |
| 4952 |
const rowSpanNumber = parseInt(styleLayout.rowSpan, 10); |
| 4953 |
newAttributes.style = { |
| 4954 |
...newAttributes.style, |
| 4955 |
layout: { |
| 4956 |
...newAttributes.style?.layout, |
| 4957 |
rowSpan: isNaN(rowSpanNumber) ? void 0 : rowSpanNumber |
| 4958 |
} |
| 4959 |
}; |
| 4960 |
} |
| 4961 |
const normalizedStyle = normalizeStyleStateAliases(newAttributes.style); |
| 4962 |
if (normalizedStyle !== newAttributes.style) { |
| 4963 |
newAttributes.style = normalizedStyle; |
| 4964 |
} |
| 4965 |
return [name, newAttributes]; |
| 4966 |
} |
| 4967 |
|
| 4968 |
// node_modules/hpq/es/get-path.js |
| 4969 |
function getPath(object, path) { |
| 4970 |
var segments = path.split("."); |
| 4971 |
var segment; |
| 4972 |
while (segment = segments.shift()) { |
| 4973 |
if (!(segment in object)) { |
| 4974 |
return; |
| 4975 |
} |
| 4976 |
object = object[segment]; |
| 4977 |
} |
| 4978 |
return object; |
| 4979 |
} |
| 4980 |
|
| 4981 |
// node_modules/hpq/es/index.js |
| 4982 |
var getDocument = /* @__PURE__ */ (function() { |
| 4983 |
var doc; |
| 4984 |
return function() { |
| 4985 |
if (!doc) { |
| 4986 |
doc = document.implementation.createHTMLDocument(""); |
| 4987 |
} |
| 4988 |
return doc; |
| 4989 |
}; |
| 4990 |
})(); |
| 4991 |
function parse(source, matchers) { |
| 4992 |
if (!matchers) { |
| 4993 |
return; |
| 4994 |
} |
| 4995 |
if ("string" === typeof source) { |
| 4996 |
var doc = getDocument(); |
| 4997 |
doc.body.innerHTML = source; |
| 4998 |
source = doc.body; |
| 4999 |
} |
| 5000 |
if ("function" === typeof matchers) { |
| 5001 |
return matchers(source); |
| 5002 |
} |
| 5003 |
if (Object !== matchers.constructor) { |
| 5004 |
return; |
| 5005 |
} |
| 5006 |
return Object.keys(matchers).reduce(function(memo, key) { |
| 5007 |
memo[key] = parse(source, matchers[key]); |
| 5008 |
return memo; |
| 5009 |
}, {}); |
| 5010 |
} |
| 5011 |
function prop(selector, name) { |
| 5012 |
if (1 === arguments.length) { |
| 5013 |
name = selector; |
| 5014 |
selector = void 0; |
| 5015 |
} |
| 5016 |
return function(node) { |
| 5017 |
var match = node; |
| 5018 |
if (selector) { |
| 5019 |
match = node.querySelector(selector); |
| 5020 |
} |
| 5021 |
if (match) { |
| 5022 |
return getPath(match, name); |
| 5023 |
} |
| 5024 |
}; |
| 5025 |
} |
| 5026 |
function attr(selector, name) { |
| 5027 |
if (1 === arguments.length) { |
| 5028 |
name = selector; |
| 5029 |
selector = void 0; |
| 5030 |
} |
| 5031 |
return function(node) { |
| 5032 |
var attributes = prop(selector, "attributes")(node); |
| 5033 |
if (attributes && attributes.hasOwnProperty(name)) { |
| 5034 |
return attributes[name].value; |
| 5035 |
} |
| 5036 |
}; |
| 5037 |
} |
| 5038 |
function text(selector) { |
| 5039 |
return prop(selector, "textContent"); |
| 5040 |
} |
| 5041 |
function query(selector, matchers) { |
| 5042 |
return function(node) { |
| 5043 |
var matches = node.querySelectorAll(selector); |
| 5044 |
return [].map.call(matches, function(match) { |
| 5045 |
return parse(match, matchers); |
| 5046 |
}); |
| 5047 |
}; |
| 5048 |
} |
| 5049 |
|
| 5050 |
// node_modules/memize/dist/index.js |
| 5051 |
function memize(fn, options) { |
| 5052 |
var size = 0; |
| 5053 |
var head; |
| 5054 |
var tail; |
| 5055 |
options = options || {}; |
| 5056 |
function memoized() { |
| 5057 |
var node = head, len = arguments.length, args, i2; |
| 5058 |
searchCache: while (node) { |
| 5059 |
if (node.args.length !== arguments.length) { |
| 5060 |
node = node.next; |
| 5061 |
continue; |
| 5062 |
} |
| 5063 |
for (i2 = 0; i2 < len; i2++) { |
| 5064 |
if (node.args[i2] !== arguments[i2]) { |
| 5065 |
node = node.next; |
| 5066 |
continue searchCache; |
| 5067 |
} |
| 5068 |
} |
| 5069 |
if (node !== head) { |
| 5070 |
if (node === tail) { |
| 5071 |
tail = node.prev; |
| 5072 |
} |
| 5073 |
node.prev.next = node.next; |
| 5074 |
if (node.next) { |
| 5075 |
node.next.prev = node.prev; |
| 5076 |
} |
| 5077 |
node.next = head; |
| 5078 |
node.prev = null; |
| 5079 |
head.prev = node; |
| 5080 |
head = node; |
| 5081 |
} |
| 5082 |
return node.val; |
| 5083 |
} |
| 5084 |
args = new Array(len); |
| 5085 |
for (i2 = 0; i2 < len; i2++) { |
| 5086 |
args[i2] = arguments[i2]; |
| 5087 |
} |
| 5088 |
node = { |
| 5089 |
args, |
| 5090 |
// Generate the result from original function |
| 5091 |
val: fn.apply(null, args) |
| 5092 |
}; |
| 5093 |
if (head) { |
| 5094 |
head.prev = node; |
| 5095 |
node.next = head; |
| 5096 |
} else { |
| 5097 |
tail = node; |
| 5098 |
} |
| 5099 |
if (size === /** @type {MemizeOptions} */ |
| 5100 |
options.maxSize) { |
| 5101 |
tail = /** @type {MemizeCacheNode} */ |
| 5102 |
tail.prev; |
| 5103 |
tail.next = null; |
| 5104 |
} else { |
| 5105 |
size++; |
| 5106 |
} |
| 5107 |
head = node; |
| 5108 |
return node.val; |
| 5109 |
} |
| 5110 |
memoized.clear = function() { |
| 5111 |
head = null; |
| 5112 |
tail = null; |
| 5113 |
size = 0; |
| 5114 |
}; |
| 5115 |
return memoized; |
| 5116 |
} |
| 5117 |
|
| 5118 |
// packages/blocks/build-module/api/parser/get-block-attributes.mjs |
| 5119 |
var import_hooks4 = __toESM(require_hooks(), 1); |
| 5120 |
var import_rich_text4 = __toESM(require_rich_text(), 1); |
| 5121 |
|
| 5122 |
// packages/blocks/build-module/api/matchers.mjs |
| 5123 |
var import_rich_text3 = __toESM(require_rich_text(), 1); |
| 5124 |
|
| 5125 |
// packages/blocks/build-module/api/node.mjs |
| 5126 |
var import_deprecated9 = __toESM(require_deprecated(), 1); |
| 5127 |
|
| 5128 |
// packages/blocks/build-module/api/children.mjs |
| 5129 |
var import_element3 = __toESM(require_element(), 1); |
| 5130 |
var import_deprecated8 = __toESM(require_deprecated(), 1); |
| 5131 |
function getSerializeCapableElement(children) { |
| 5132 |
return children; |
| 5133 |
} |
| 5134 |
function getChildrenArray(children) { |
| 5135 |
(0, import_deprecated8.default)("wp.blocks.children.getChildrenArray", { |
| 5136 |
since: "6.1", |
| 5137 |
version: "6.3", |
| 5138 |
link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" |
| 5139 |
}); |
| 5140 |
return children; |
| 5141 |
} |
| 5142 |
function concat(...blockNodes) { |
| 5143 |
(0, import_deprecated8.default)("wp.blocks.children.concat", { |
| 5144 |
since: "6.1", |
| 5145 |
version: "6.3", |
| 5146 |
alternative: "wp.richText.concat", |
| 5147 |
link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" |
| 5148 |
}); |
| 5149 |
const result = []; |
| 5150 |
for (let i2 = 0; i2 < blockNodes.length; i2++) { |
| 5151 |
const blockNode = Array.isArray(blockNodes[i2]) ? blockNodes[i2] : [blockNodes[i2]]; |
| 5152 |
for (let j3 = 0; j3 < blockNode.length; j3++) { |
| 5153 |
const child = blockNode[j3]; |
| 5154 |
const canConcatToPreviousString = typeof child === "string" && typeof result[result.length - 1] === "string"; |
| 5155 |
if (canConcatToPreviousString) { |
| 5156 |
result[result.length - 1] += child; |
| 5157 |
} else { |
| 5158 |
result.push(child); |
| 5159 |
} |
| 5160 |
} |
| 5161 |
} |
| 5162 |
return result; |
| 5163 |
} |
| 5164 |
function fromDOM22(domNodes) { |
| 5165 |
(0, import_deprecated8.default)("wp.blocks.children.fromDOM", { |
| 5166 |
since: "6.1", |
| 5167 |
version: "6.3", |
| 5168 |
alternative: "wp.richText.create", |
| 5169 |
link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" |
| 5170 |
}); |
| 5171 |
const result = []; |
| 5172 |
for (let i2 = 0; i2 < domNodes.length; i2++) { |
| 5173 |
try { |
| 5174 |
result.push(fromDOM2(domNodes[i2])); |
| 5175 |
} catch { |
| 5176 |
} |
| 5177 |
} |
| 5178 |
return result; |
| 5179 |
} |
| 5180 |
function toHTML(children) { |
| 5181 |
(0, import_deprecated8.default)("wp.blocks.children.toHTML", { |
| 5182 |
since: "6.1", |
| 5183 |
version: "6.3", |
| 5184 |
alternative: "wp.richText.toHTMLString", |
| 5185 |
link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" |
| 5186 |
}); |
| 5187 |
const element = getSerializeCapableElement(children); |
| 5188 |
return (0, import_element3.renderToString)(element); |
| 5189 |
} |
| 5190 |
function matcher(selector) { |
| 5191 |
(0, import_deprecated8.default)("wp.blocks.children.matcher", { |
| 5192 |
since: "6.1", |
| 5193 |
version: "6.3", |
| 5194 |
alternative: "html source", |
| 5195 |
link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" |
| 5196 |
}); |
| 5197 |
return (domNode) => { |
| 5198 |
let match = domNode; |
| 5199 |
if (selector) { |
| 5200 |
match = domNode.querySelector(selector); |
| 5201 |
} |
| 5202 |
if (match) { |
| 5203 |
return fromDOM22(match.childNodes); |
| 5204 |
} |
| 5205 |
return []; |
| 5206 |
}; |
| 5207 |
} |
| 5208 |
var children_default = { |
| 5209 |
concat, |
| 5210 |
getChildrenArray, |
| 5211 |
fromDOM: fromDOM22, |
| 5212 |
toHTML, |
| 5213 |
matcher |
| 5214 |
}; |
| 5215 |
|
| 5216 |
// packages/blocks/build-module/api/node.mjs |
| 5217 |
function isNodeOfType(node, type) { |
| 5218 |
(0, import_deprecated9.default)("wp.blocks.node.isNodeOfType", { |
| 5219 |
since: "6.1", |
| 5220 |
version: "6.3", |
| 5221 |
link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" |
| 5222 |
}); |
| 5223 |
return typeof node !== "string" && node?.type === type; |
| 5224 |
} |
| 5225 |
function getNamedNodeMapAsObject(nodeMap) { |
| 5226 |
const result = {}; |
| 5227 |
for (let i2 = 0; i2 < nodeMap.length; i2++) { |
| 5228 |
const { name, value } = nodeMap[i2]; |
| 5229 |
result[name] = value; |
| 5230 |
} |
| 5231 |
return result; |
| 5232 |
} |
| 5233 |
function fromDOM2(domNode) { |
| 5234 |
(0, import_deprecated9.default)("wp.blocks.node.fromDOM", { |
| 5235 |
since: "6.1", |
| 5236 |
version: "6.3", |
| 5237 |
alternative: "wp.richText.create", |
| 5238 |
link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" |
| 5239 |
}); |
| 5240 |
if (domNode.nodeType === domNode.TEXT_NODE) { |
| 5241 |
return domNode.nodeValue; |
| 5242 |
} |
| 5243 |
if (domNode.nodeType !== domNode.ELEMENT_NODE) { |
| 5244 |
throw new TypeError( |
| 5245 |
"A block node can only be created from a node of type text or element." |
| 5246 |
); |
| 5247 |
} |
| 5248 |
return { |
| 5249 |
type: domNode.nodeName.toLowerCase(), |
| 5250 |
props: { |
| 5251 |
...getNamedNodeMapAsObject(domNode.attributes), |
| 5252 |
children: fromDOM22(domNode.childNodes) |
| 5253 |
} |
| 5254 |
}; |
| 5255 |
} |
| 5256 |
function toHTML2(node) { |
| 5257 |
(0, import_deprecated9.default)("wp.blocks.node.toHTML", { |
| 5258 |
since: "6.1", |
| 5259 |
version: "6.3", |
| 5260 |
alternative: "wp.richText.toHTMLString", |
| 5261 |
link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" |
| 5262 |
}); |
| 5263 |
return toHTML([node]); |
| 5264 |
} |
| 5265 |
function matcher2(selector) { |
| 5266 |
(0, import_deprecated9.default)("wp.blocks.node.matcher", { |
| 5267 |
since: "6.1", |
| 5268 |
version: "6.3", |
| 5269 |
alternative: "html source", |
| 5270 |
link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" |
| 5271 |
}); |
| 5272 |
return (domNode) => { |
| 5273 |
let match = domNode; |
| 5274 |
if (selector) { |
| 5275 |
match = domNode.querySelector(selector); |
| 5276 |
} |
| 5277 |
try { |
| 5278 |
return fromDOM2(match); |
| 5279 |
} catch { |
| 5280 |
return null; |
| 5281 |
} |
| 5282 |
}; |
| 5283 |
} |
| 5284 |
var node_default = { |
| 5285 |
isNodeOfType, |
| 5286 |
fromDOM: fromDOM2, |
| 5287 |
toHTML: toHTML2, |
| 5288 |
matcher: matcher2 |
| 5289 |
}; |
| 5290 |
|
| 5291 |
// packages/blocks/build-module/api/matchers.mjs |
| 5292 |
function html(selector, multilineTag) { |
| 5293 |
return (domNode) => { |
| 5294 |
let match = domNode; |
| 5295 |
if (selector) { |
| 5296 |
match = domNode.querySelector(selector); |
| 5297 |
} |
| 5298 |
if (!match) { |
| 5299 |
return ""; |
| 5300 |
} |
| 5301 |
if (multilineTag) { |
| 5302 |
let value = ""; |
| 5303 |
const length = match.children.length; |
| 5304 |
for (let index = 0; index < length; index++) { |
| 5305 |
const child = match.children[index]; |
| 5306 |
if (child.nodeName.toLowerCase() !== multilineTag) { |
| 5307 |
continue; |
| 5308 |
} |
| 5309 |
value += child.outerHTML; |
| 5310 |
} |
| 5311 |
return value; |
| 5312 |
} |
| 5313 |
return match.innerHTML; |
| 5314 |
}; |
| 5315 |
} |
| 5316 |
var richText = (selector, preserveWhiteSpace) => (el) => { |
| 5317 |
const target = selector ? el.querySelector(selector) : el; |
| 5318 |
return target ? import_rich_text3.RichTextData.fromHTMLElement(target, { |
| 5319 |
preserveWhiteSpace |
| 5320 |
}) : import_rich_text3.RichTextData.empty(); |
| 5321 |
}; |
| 5322 |
|
| 5323 |
// packages/blocks/build-module/api/parser/get-block-attributes.mjs |
| 5324 |
var toBooleanAttributeMatcher = (matcher3) => (value) => matcher3(value) !== void 0; |
| 5325 |
function isOfType(value, type) { |
| 5326 |
switch (type) { |
| 5327 |
case "rich-text": |
| 5328 |
return value instanceof import_rich_text4.RichTextData; |
| 5329 |
case "string": |
| 5330 |
return typeof value === "string"; |
| 5331 |
case "boolean": |
| 5332 |
return typeof value === "boolean"; |
| 5333 |
case "object": |
| 5334 |
return !!value && value.constructor === Object; |
| 5335 |
case "null": |
| 5336 |
return value === null; |
| 5337 |
case "array": |
| 5338 |
return Array.isArray(value); |
| 5339 |
case "integer": |
| 5340 |
case "number": |
| 5341 |
return typeof value === "number"; |
| 5342 |
} |
| 5343 |
return true; |
| 5344 |
} |
| 5345 |
function isOfTypes(value, types) { |
| 5346 |
return types.some((type) => isOfType(value, type)); |
| 5347 |
} |
| 5348 |
function getBlockAttribute(attributeKey, attributeSchema, innerDOM, commentAttributes, innerHTML) { |
| 5349 |
let value; |
| 5350 |
switch (attributeSchema.source) { |
| 5351 |
// An undefined source means that it's an attribute serialized to the |
| 5352 |
// block's "comment". |
| 5353 |
case void 0: |
| 5354 |
value = commentAttributes ? commentAttributes[attributeKey] : void 0; |
| 5355 |
break; |
| 5356 |
// raw source means that it's the original raw block content. |
| 5357 |
case "raw": |
| 5358 |
value = innerHTML; |
| 5359 |
break; |
| 5360 |
case "attribute": |
| 5361 |
case "property": |
| 5362 |
case "html": |
| 5363 |
case "text": |
| 5364 |
case "rich-text": |
| 5365 |
case "children": |
| 5366 |
case "node": |
| 5367 |
case "query": |
| 5368 |
case "tag": |
| 5369 |
value = parseWithAttributeSchema(innerDOM, attributeSchema); |
| 5370 |
break; |
| 5371 |
} |
| 5372 |
if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) { |
| 5373 |
value = void 0; |
| 5374 |
} |
| 5375 |
if (value === void 0) { |
| 5376 |
value = getDefault(attributeSchema); |
| 5377 |
} |
| 5378 |
return value; |
| 5379 |
} |
| 5380 |
function isValidByType(value, type) { |
| 5381 |
return type === void 0 || isOfTypes(value, Array.isArray(type) ? type : [type]); |
| 5382 |
} |
| 5383 |
function isValidByEnum(value, enumSet) { |
| 5384 |
return !Array.isArray(enumSet) || enumSet.includes(value); |
| 5385 |
} |
| 5386 |
var matcherFromSource = memize( |
| 5387 |
(sourceConfig) => { |
| 5388 |
switch (sourceConfig.source) { |
| 5389 |
case "attribute": { |
| 5390 |
let matcher3 = attr( |
| 5391 |
sourceConfig.selector, |
| 5392 |
sourceConfig.attribute |
| 5393 |
); |
| 5394 |
if (sourceConfig.type === "boolean") { |
| 5395 |
matcher3 = toBooleanAttributeMatcher(matcher3); |
| 5396 |
} |
| 5397 |
return matcher3; |
| 5398 |
} |
| 5399 |
case "html": |
| 5400 |
return html(sourceConfig.selector, sourceConfig.multiline); |
| 5401 |
case "text": |
| 5402 |
return text(sourceConfig.selector); |
| 5403 |
case "rich-text": |
| 5404 |
return richText( |
| 5405 |
sourceConfig.selector, |
| 5406 |
sourceConfig.__unstablePreserveWhiteSpace |
| 5407 |
); |
| 5408 |
case "children": |
| 5409 |
return matcher(sourceConfig.selector); |
| 5410 |
case "node": |
| 5411 |
return matcher2(sourceConfig.selector); |
| 5412 |
case "query": |
| 5413 |
const subMatchers = Object.fromEntries( |
| 5414 |
Object.entries(sourceConfig.query).map( |
| 5415 |
([key, subSourceConfig]) => [ |
| 5416 |
key, |
| 5417 |
matcherFromSource(subSourceConfig) |
| 5418 |
] |
| 5419 |
) |
| 5420 |
); |
| 5421 |
return query(sourceConfig.selector, subMatchers); |
| 5422 |
case "tag": { |
| 5423 |
const matcher3 = prop(sourceConfig.selector, "nodeName"); |
| 5424 |
return (domNode) => matcher3(domNode)?.toLowerCase(); |
| 5425 |
} |
| 5426 |
default: |
| 5427 |
console.error( |
| 5428 |
`Unknown source type "${sourceConfig.source}"` |
| 5429 |
); |
| 5430 |
return void 0; |
| 5431 |
} |
| 5432 |
} |
| 5433 |
); |
| 5434 |
function parseHtml(innerHTML) { |
| 5435 |
return parse(innerHTML, (h2) => h2); |
| 5436 |
} |
| 5437 |
function parseWithAttributeSchema(innerHTML, attributeSchema) { |
| 5438 |
return matcherFromSource(attributeSchema)( |
| 5439 |
parseHtml(innerHTML) |
| 5440 |
); |
| 5441 |
} |
| 5442 |
function getBlockAttributes(blockTypeOrName, innerHTML, attributes = {}) { |
| 5443 |
const doc = parseHtml(innerHTML); |
| 5444 |
const blockType = normalizeBlockType(blockTypeOrName); |
| 5445 |
const blockAttributes = Object.fromEntries( |
| 5446 |
Object.entries(blockType?.attributes ?? {}).map( |
| 5447 |
([key, schema]) => [ |
| 5448 |
key, |
| 5449 |
getBlockAttribute(key, schema, doc, attributes, innerHTML) |
| 5450 |
] |
| 5451 |
) |
| 5452 |
); |
| 5453 |
return (0, import_hooks4.applyFilters)( |
| 5454 |
"blocks.getBlockAttributes", |
| 5455 |
blockAttributes, |
| 5456 |
blockType, |
| 5457 |
innerHTML, |
| 5458 |
attributes |
| 5459 |
); |
| 5460 |
} |
| 5461 |
|
| 5462 |
// packages/blocks/build-module/api/parser/fix-custom-classname.mjs |
| 5463 |
var CLASS_ATTR_SCHEMA = { |
| 5464 |
type: "string", |
| 5465 |
source: "attribute", |
| 5466 |
selector: "[data-custom-class-name] > *", |
| 5467 |
attribute: "class" |
| 5468 |
}; |
| 5469 |
function getHTMLRootElementClasses(innerHTML) { |
| 5470 |
const parsed = parseWithAttributeSchema( |
| 5471 |
`<div data-custom-class-name>${innerHTML}</div>`, |
| 5472 |
CLASS_ATTR_SCHEMA |
| 5473 |
); |
| 5474 |
return parsed ? parsed.trim().split(/\s+/) : []; |
| 5475 |
} |
| 5476 |
function fixCustomClassname(blockAttributes, blockType, innerHTML) { |
| 5477 |
if (!hasBlockSupport(blockType, "customClassName", true)) { |
| 5478 |
return blockAttributes; |
| 5479 |
} |
| 5480 |
const modifiedBlockAttributes = { ...blockAttributes }; |
| 5481 |
const { className: omittedClassName, ...attributesSansClassName } = modifiedBlockAttributes; |
| 5482 |
const serialized = getSaveContent(blockType, attributesSansClassName); |
| 5483 |
const defaultClasses = getHTMLRootElementClasses(serialized); |
| 5484 |
const actualClasses = getHTMLRootElementClasses(innerHTML); |
| 5485 |
const customClasses = actualClasses.filter( |
| 5486 |
(className) => !defaultClasses.includes(className) |
| 5487 |
); |
| 5488 |
if (customClasses.length) { |
| 5489 |
modifiedBlockAttributes.className = customClasses.join(" "); |
| 5490 |
} else if (serialized) { |
| 5491 |
delete modifiedBlockAttributes.className; |
| 5492 |
} |
| 5493 |
return modifiedBlockAttributes; |
| 5494 |
} |
| 5495 |
|
| 5496 |
// packages/blocks/build-module/api/parser/fix-global-attribute.mjs |
| 5497 |
function getHTMLRootElement(innerHTML, dataAttribute, attributeSchema) { |
| 5498 |
const parsed = parseWithAttributeSchema( |
| 5499 |
`<div ${dataAttribute}>${innerHTML}</div>`, |
| 5500 |
attributeSchema |
| 5501 |
); |
| 5502 |
return parsed; |
| 5503 |
} |
| 5504 |
function fixGlobalAttribute(blockAttributes, blockType, innerHTML, supportKey, dataAttribute, attributeSchema) { |
| 5505 |
if (!hasBlockSupport(blockType, supportKey, false)) { |
| 5506 |
return blockAttributes; |
| 5507 |
} |
| 5508 |
const modifiedBlockAttributes = { ...blockAttributes }; |
| 5509 |
const attributeValue = getHTMLRootElement( |
| 5510 |
innerHTML, |
| 5511 |
dataAttribute, |
| 5512 |
attributeSchema |
| 5513 |
); |
| 5514 |
if (attributeValue) { |
| 5515 |
modifiedBlockAttributes[supportKey] = attributeValue; |
| 5516 |
} |
| 5517 |
return modifiedBlockAttributes; |
| 5518 |
} |
| 5519 |
|
| 5520 |
// packages/blocks/build-module/api/parser/apply-built-in-validation-fixes.mjs |
| 5521 |
var ARIA_LABEL_ATTR_SCHEMA = { |
| 5522 |
type: "string", |
| 5523 |
source: "attribute", |
| 5524 |
selector: "[data-aria-label] > *", |
| 5525 |
attribute: "aria-label" |
| 5526 |
}; |
| 5527 |
var ANCHOR_ATTR_SCHEMA = { |
| 5528 |
type: "string", |
| 5529 |
source: "attribute", |
| 5530 |
selector: "[data-anchor] > *", |
| 5531 |
attribute: "id" |
| 5532 |
}; |
| 5533 |
function applyBuiltInValidationFixes(block, blockType) { |
| 5534 |
const { attributes, originalContent } = block; |
| 5535 |
let updatedBlockAttributes = attributes; |
| 5536 |
updatedBlockAttributes = fixCustomClassname( |
| 5537 |
attributes, |
| 5538 |
blockType, |
| 5539 |
originalContent ?? "" |
| 5540 |
); |
| 5541 |
updatedBlockAttributes = fixGlobalAttribute( |
| 5542 |
updatedBlockAttributes, |
| 5543 |
blockType, |
| 5544 |
originalContent ?? "", |
| 5545 |
"ariaLabel", |
| 5546 |
"data-aria-label", |
| 5547 |
ARIA_LABEL_ATTR_SCHEMA |
| 5548 |
); |
| 5549 |
updatedBlockAttributes = fixGlobalAttribute( |
| 5550 |
updatedBlockAttributes, |
| 5551 |
blockType, |
| 5552 |
originalContent ?? "", |
| 5553 |
"anchor", |
| 5554 |
"data-anchor", |
| 5555 |
ANCHOR_ATTR_SCHEMA |
| 5556 |
); |
| 5557 |
return { |
| 5558 |
...block, |
| 5559 |
attributes: updatedBlockAttributes |
| 5560 |
}; |
| 5561 |
} |
| 5562 |
|
| 5563 |
// packages/blocks/build-module/api/parser/apply-block-deprecated-versions.mjs |
| 5564 |
function stubFalse() { |
| 5565 |
return false; |
| 5566 |
} |
| 5567 |
function applyBlockDeprecatedVersions(block, rawBlock, blockType) { |
| 5568 |
const parsedAttributes = rawBlock.attrs ?? {}; |
| 5569 |
const { deprecated: deprecatedDefinitions } = blockType; |
| 5570 |
if (!deprecatedDefinitions || !deprecatedDefinitions.length) { |
| 5571 |
return block; |
| 5572 |
} |
| 5573 |
for (let i2 = 0; i2 < deprecatedDefinitions.length; i2++) { |
| 5574 |
const { isEligible = stubFalse } = deprecatedDefinitions[i2]; |
| 5575 |
if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks, { |
| 5576 |
blockNode: rawBlock, |
| 5577 |
block |
| 5578 |
})) { |
| 5579 |
continue; |
| 5580 |
} |
| 5581 |
const deprecatedBlockType = Object.assign( |
| 5582 |
omit( |
| 5583 |
blockType, |
| 5584 |
DEPRECATED_ENTRY_KEYS |
| 5585 |
), |
| 5586 |
deprecatedDefinitions[i2] |
| 5587 |
); |
| 5588 |
let migratedBlock = { |
| 5589 |
...block, |
| 5590 |
attributes: getBlockAttributes( |
| 5591 |
deprecatedBlockType, |
| 5592 |
block.originalContent ?? "", |
| 5593 |
parsedAttributes |
| 5594 |
) |
| 5595 |
}; |
| 5596 |
let [isValid] = validateBlock(migratedBlock, deprecatedBlockType); |
| 5597 |
if (!isValid) { |
| 5598 |
migratedBlock = applyBuiltInValidationFixes( |
| 5599 |
migratedBlock, |
| 5600 |
deprecatedBlockType |
| 5601 |
); |
| 5602 |
[isValid] = validateBlock(migratedBlock, deprecatedBlockType); |
| 5603 |
} |
| 5604 |
if (!isValid) { |
| 5605 |
continue; |
| 5606 |
} |
| 5607 |
let migratedInnerBlocks = migratedBlock.innerBlocks; |
| 5608 |
let migratedAttributes = migratedBlock.attributes; |
| 5609 |
const { migrate } = deprecatedBlockType; |
| 5610 |
if (migrate) { |
| 5611 |
let migrated = migrate(migratedAttributes, block.innerBlocks); |
| 5612 |
if (!Array.isArray(migrated)) { |
| 5613 |
migrated = [migrated]; |
| 5614 |
} |
| 5615 |
[ |
| 5616 |
migratedAttributes = parsedAttributes, |
| 5617 |
migratedInnerBlocks = block.innerBlocks |
| 5618 |
] = migrated; |
| 5619 |
} |
| 5620 |
block = { |
| 5621 |
...block, |
| 5622 |
attributes: migratedAttributes, |
| 5623 |
innerBlocks: migratedInnerBlocks, |
| 5624 |
isValid: true, |
| 5625 |
validationIssues: [] |
| 5626 |
}; |
| 5627 |
} |
| 5628 |
return block; |
| 5629 |
} |
| 5630 |
|
| 5631 |
// packages/blocks/build-module/api/parser/index.mjs |
| 5632 |
function convertLegacyBlocks(rawBlock) { |
| 5633 |
const [correctName, correctedAttributes] = convertLegacyBlockNameAndAttributes( |
| 5634 |
rawBlock.blockName, |
| 5635 |
rawBlock.attrs ?? {} |
| 5636 |
); |
| 5637 |
return { |
| 5638 |
...rawBlock, |
| 5639 |
blockName: correctName, |
| 5640 |
attrs: correctedAttributes |
| 5641 |
}; |
| 5642 |
} |
| 5643 |
function normalizeRawBlock(rawBlock, options) { |
| 5644 |
const fallbackBlockName = getFreeformContentHandlerName(); |
| 5645 |
const rawBlockName = rawBlock.blockName || getFreeformContentHandlerName(); |
| 5646 |
const rawAttributes = rawBlock.attrs || {}; |
| 5647 |
const rawInnerBlocks = rawBlock.innerBlocks || []; |
| 5648 |
let rawInnerHTML = rawBlock.innerHTML.trim(); |
| 5649 |
if (rawBlockName === fallbackBlockName && rawBlockName === "core/freeform" && !options?.__unstableSkipAutop) { |
| 5650 |
rawInnerHTML = (0, import_autop2.autop)(rawInnerHTML).trim(); |
| 5651 |
} |
| 5652 |
return { |
| 5653 |
...rawBlock, |
| 5654 |
blockName: rawBlockName, |
| 5655 |
attrs: rawAttributes, |
| 5656 |
innerHTML: rawInnerHTML, |
| 5657 |
innerBlocks: rawInnerBlocks |
| 5658 |
}; |
| 5659 |
} |
| 5660 |
function createMissingBlockType(rawBlock) { |
| 5661 |
const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName(); |
| 5662 |
const originalUndelimitedContent = serializeRawBlock(rawBlock, { |
| 5663 |
isCommentDelimited: false |
| 5664 |
}); |
| 5665 |
const originalContent = serializeRawBlock(rawBlock, { |
| 5666 |
isCommentDelimited: true |
| 5667 |
}); |
| 5668 |
return { |
| 5669 |
blockName: unregisteredFallbackBlock, |
| 5670 |
attrs: { |
| 5671 |
originalName: rawBlock.blockName, |
| 5672 |
originalContent, |
| 5673 |
originalUndelimitedContent |
| 5674 |
}, |
| 5675 |
innerHTML: rawBlock.blockName ? originalContent : rawBlock.innerHTML, |
| 5676 |
innerBlocks: rawBlock.innerBlocks, |
| 5677 |
innerContent: rawBlock.innerContent |
| 5678 |
}; |
| 5679 |
} |
| 5680 |
function applyBlockValidation(unvalidatedBlock, blockType) { |
| 5681 |
const [isValid] = validateBlock(unvalidatedBlock, blockType); |
| 5682 |
if (isValid) { |
| 5683 |
return { ...unvalidatedBlock, isValid, validationIssues: [] }; |
| 5684 |
} |
| 5685 |
const fixedBlock = applyBuiltInValidationFixes( |
| 5686 |
unvalidatedBlock, |
| 5687 |
blockType |
| 5688 |
); |
| 5689 |
const [isFixedValid, validationIssues] = validateBlock( |
| 5690 |
fixedBlock, |
| 5691 |
blockType |
| 5692 |
); |
| 5693 |
return { ...fixedBlock, isValid: isFixedValid, validationIssues }; |
| 5694 |
} |
| 5695 |
function parseRawBlock(rawBlock, options) { |
| 5696 |
let normalizedBlock = normalizeRawBlock(rawBlock, options); |
| 5697 |
normalizedBlock = convertLegacyBlocks(normalizedBlock); |
| 5698 |
let blockType = getBlockType(normalizedBlock.blockName); |
| 5699 |
if (!blockType) { |
| 5700 |
normalizedBlock = createMissingBlockType(normalizedBlock); |
| 5701 |
blockType = getBlockType(normalizedBlock.blockName); |
| 5702 |
} |
| 5703 |
const isFallbackBlock = normalizedBlock.blockName === getFreeformContentHandlerName() || normalizedBlock.blockName === getUnregisteredTypeHandlerName(); |
| 5704 |
if (!blockType || !normalizedBlock.innerHTML && isFallbackBlock) { |
| 5705 |
return; |
| 5706 |
} |
| 5707 |
const parsedInnerBlocks = normalizedBlock.innerBlocks.map((innerBlock) => parseRawBlock(innerBlock, options)).filter((innerBlock) => !!innerBlock); |
| 5708 |
const parsedBlock = createBlock( |
| 5709 |
normalizedBlock.blockName, |
| 5710 |
getBlockAttributes( |
| 5711 |
blockType, |
| 5712 |
normalizedBlock.innerHTML, |
| 5713 |
normalizedBlock.attrs |
| 5714 |
), |
| 5715 |
parsedInnerBlocks |
| 5716 |
); |
| 5717 |
parsedBlock.originalContent = normalizedBlock.innerHTML; |
| 5718 |
const validatedBlock = applyBlockValidation(parsedBlock, blockType); |
| 5719 |
const { validationIssues } = validatedBlock; |
| 5720 |
const updatedBlock = applyBlockDeprecatedVersions( |
| 5721 |
validatedBlock, |
| 5722 |
normalizedBlock, |
| 5723 |
blockType |
| 5724 |
); |
| 5725 |
if (!updatedBlock.isValid) { |
| 5726 |
updatedBlock.__unstableBlockSource = rawBlock; |
| 5727 |
} |
| 5728 |
if (!validatedBlock.isValid && updatedBlock.isValid && !options?.__unstableSkipMigrationLogs) { |
| 5729 |
console.groupCollapsed("Updated Block: %s", blockType.name); |
| 5730 |
console.info( |
| 5731 |
"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", |
| 5732 |
blockType.name, |
| 5733 |
blockType, |
| 5734 |
getSaveContent(blockType, updatedBlock.attributes), |
| 5735 |
updatedBlock.originalContent |
| 5736 |
); |
| 5737 |
console.groupEnd(); |
| 5738 |
} else if (!validatedBlock.isValid && !updatedBlock.isValid) { |
| 5739 |
validationIssues.forEach(({ log: log2, args }) => log2(...args)); |
| 5740 |
} |
| 5741 |
return updatedBlock; |
| 5742 |
} |
| 5743 |
function parse2(content, options) { |
| 5744 |
return (0, import_block_serialization_default_parser.parse)(content).reduce( |
| 5745 |
(accumulator, rawBlock) => { |
| 5746 |
const block = parseRawBlock( |
| 5747 |
rawBlock, |
| 5748 |
options |
| 5749 |
); |
| 5750 |
if (block) { |
| 5751 |
accumulator.push(block); |
| 5752 |
} |
| 5753 |
return accumulator; |
| 5754 |
}, |
| 5755 |
[] |
| 5756 |
); |
| 5757 |
} |
| 5758 |
|
| 5759 |
// packages/blocks/build-module/api/raw-handling/index.mjs |
| 5760 |
var import_deprecated10 = __toESM(require_deprecated(), 1); |
| 5761 |
var import_dom13 = __toESM(require_dom(), 1); |
| 5762 |
|
| 5763 |
// packages/blocks/build-module/api/raw-handling/get-raw-transforms.mjs |
| 5764 |
function getRawTransforms() { |
| 5765 |
return getBlockTransforms("from").filter(({ type }) => type === "raw").map((transform) => { |
| 5766 |
return transform.isMatch ? transform : { |
| 5767 |
...transform, |
| 5768 |
isMatch: (node) => transform.selector && node.matches(transform.selector) |
| 5769 |
}; |
| 5770 |
}); |
| 5771 |
} |
| 5772 |
|
| 5773 |
// packages/blocks/build-module/api/raw-handling/html-to-blocks.mjs |
| 5774 |
function htmlToBlocks(html2, handler) { |
| 5775 |
const doc = document.implementation.createHTMLDocument(""); |
| 5776 |
doc.body.innerHTML = html2; |
| 5777 |
return Array.from(doc.body.children).flatMap((node) => { |
| 5778 |
const transforms = getRawTransforms(); |
| 5779 |
const rawTransform = findTransform( |
| 5780 |
transforms, |
| 5781 |
((t3) => { |
| 5782 |
const transform2 = t3; |
| 5783 |
return transform2.isMatch(node); |
| 5784 |
}) |
| 5785 |
); |
| 5786 |
if (!rawTransform) { |
| 5787 |
return createBlock( |
| 5788 |
// Should not be hardcoded. |
| 5789 |
"core/html", |
| 5790 |
getBlockAttributes("core/html", node.outerHTML) |
| 5791 |
); |
| 5792 |
} |
| 5793 |
const { transform, blockName } = rawTransform; |
| 5794 |
if (transform) { |
| 5795 |
const block = transform(node, handler); |
| 5796 |
if (node.hasAttribute("class")) { |
| 5797 |
block.attributes.className = node.getAttribute("class"); |
| 5798 |
} |
| 5799 |
return block; |
| 5800 |
} |
| 5801 |
return createBlock( |
| 5802 |
blockName, |
| 5803 |
getBlockAttributes(blockName, node.outerHTML) |
| 5804 |
); |
| 5805 |
}); |
| 5806 |
} |
| 5807 |
|
| 5808 |
// packages/blocks/build-module/api/raw-handling/normalise-blocks.mjs |
| 5809 |
var import_dom2 = __toESM(require_dom(), 1); |
| 5810 |
function normaliseBlocks(HTML, options = {}) { |
| 5811 |
const decuDoc = document.implementation.createHTMLDocument(""); |
| 5812 |
const accuDoc = document.implementation.createHTMLDocument(""); |
| 5813 |
const decu = decuDoc.body; |
| 5814 |
const accu = accuDoc.body; |
| 5815 |
decu.innerHTML = HTML; |
| 5816 |
while (decu.firstChild) { |
| 5817 |
const node = decu.firstChild; |
| 5818 |
if (node.nodeType === node.TEXT_NODE) { |
| 5819 |
if ((0, import_dom2.isEmpty)(node)) { |
| 5820 |
decu.removeChild(node); |
| 5821 |
} else { |
| 5822 |
if (!accu.lastChild || accu.lastChild.nodeName !== "P") { |
| 5823 |
accu.appendChild(accuDoc.createElement("P")); |
| 5824 |
} |
| 5825 |
accu.lastChild.appendChild(node); |
| 5826 |
} |
| 5827 |
} else if (node.nodeType === node.ELEMENT_NODE) { |
| 5828 |
if (node.nodeName === "BR") { |
| 5829 |
if (node.nextSibling && node.nextSibling.nodeName === "BR") { |
| 5830 |
accu.appendChild(accuDoc.createElement("P")); |
| 5831 |
decu.removeChild(node.nextSibling); |
| 5832 |
} |
| 5833 |
if (accu.lastChild && accu.lastChild.nodeName === "P" && accu.lastChild.hasChildNodes()) { |
| 5834 |
accu.lastChild.appendChild(node); |
| 5835 |
} else { |
| 5836 |
decu.removeChild(node); |
| 5837 |
} |
| 5838 |
} else if (node.nodeName === "P") { |
| 5839 |
if ((0, import_dom2.isEmpty)(node) && !options.raw) { |
| 5840 |
decu.removeChild(node); |
| 5841 |
} else { |
| 5842 |
accu.appendChild(node); |
| 5843 |
} |
| 5844 |
} else if ((0, import_dom2.isPhrasingContent)(node)) { |
| 5845 |
if (!accu.lastChild || accu.lastChild.nodeName !== "P") { |
| 5846 |
accu.appendChild(accuDoc.createElement("P")); |
| 5847 |
} |
| 5848 |
accu.lastChild.appendChild(node); |
| 5849 |
} else { |
| 5850 |
accu.appendChild(node); |
| 5851 |
} |
| 5852 |
} else { |
| 5853 |
decu.removeChild(node); |
| 5854 |
} |
| 5855 |
} |
| 5856 |
return accu.innerHTML; |
| 5857 |
} |
| 5858 |
|
| 5859 |
// packages/blocks/build-module/api/raw-handling/special-comment-converter.mjs |
| 5860 |
var import_dom3 = __toESM(require_dom(), 1); |
| 5861 |
function specialCommentConverter(node, doc) { |
| 5862 |
if (node.nodeType !== node.COMMENT_NODE) { |
| 5863 |
return; |
| 5864 |
} |
| 5865 |
if (node.nodeValue !== "nextpage" && node.nodeValue.indexOf("more") !== 0) { |
| 5866 |
return; |
| 5867 |
} |
| 5868 |
const block = createBlock2(node, doc); |
| 5869 |
if (!node.parentNode || node.parentNode.nodeName !== "P") { |
| 5870 |
(0, import_dom3.replace)(node, block); |
| 5871 |
} else { |
| 5872 |
const childNodes = Array.from(node.parentNode.childNodes); |
| 5873 |
const nodeIndex = childNodes.indexOf(node); |
| 5874 |
const wrapperNode = node.parentNode.parentNode || doc.body; |
| 5875 |
const paragraphBuilder = (acc, child) => { |
| 5876 |
if (!acc) { |
| 5877 |
acc = doc.createElement("p"); |
| 5878 |
} |
| 5879 |
acc.appendChild(child); |
| 5880 |
return acc; |
| 5881 |
}; |
| 5882 |
[ |
| 5883 |
childNodes.slice(0, nodeIndex).reduce(paragraphBuilder, null), |
| 5884 |
block, |
| 5885 |
childNodes.slice(nodeIndex + 1).reduce(paragraphBuilder, null) |
| 5886 |
].forEach( |
| 5887 |
(element) => element && wrapperNode.insertBefore(element, node.parentNode) |
| 5888 |
); |
| 5889 |
(0, import_dom3.remove)(node.parentNode); |
| 5890 |
} |
| 5891 |
} |
| 5892 |
function createBlock2(commentNode, doc) { |
| 5893 |
if (commentNode.nodeValue === "nextpage") { |
| 5894 |
return createNextpage(doc); |
| 5895 |
} |
| 5896 |
const customText = commentNode.nodeValue.slice(4).trim(); |
| 5897 |
let sibling = commentNode; |
| 5898 |
let noTeaser = false; |
| 5899 |
while (sibling = sibling.nextSibling) { |
| 5900 |
if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === "noteaser") { |
| 5901 |
noTeaser = true; |
| 5902 |
(0, import_dom3.remove)(sibling); |
| 5903 |
break; |
| 5904 |
} |
| 5905 |
} |
| 5906 |
return createMore(customText, noTeaser, doc); |
| 5907 |
} |
| 5908 |
function createMore(customText, noTeaser, doc) { |
| 5909 |
const node = doc.createElement("wp-block"); |
| 5910 |
node.dataset.block = "core/more"; |
| 5911 |
if (customText) { |
| 5912 |
node.dataset.customText = customText; |
| 5913 |
} |
| 5914 |
if (noTeaser) { |
| 5915 |
node.dataset.noTeaser = ""; |
| 5916 |
} |
| 5917 |
return node; |
| 5918 |
} |
| 5919 |
function createNextpage(doc) { |
| 5920 |
const node = doc.createElement("wp-block"); |
| 5921 |
node.dataset.block = "core/nextpage"; |
| 5922 |
return node; |
| 5923 |
} |
| 5924 |
|
| 5925 |
// packages/blocks/build-module/api/raw-handling/list-reducer.mjs |
| 5926 |
var import_dom4 = __toESM(require_dom(), 1); |
| 5927 |
function isList(node) { |
| 5928 |
return node.nodeName === "OL" || node.nodeName === "UL"; |
| 5929 |
} |
| 5930 |
function shallowTextContent(element) { |
| 5931 |
return Array.from(element.childNodes).map(({ nodeValue = "" }) => nodeValue).join(""); |
| 5932 |
} |
| 5933 |
function listReducer(node) { |
| 5934 |
if (!isList(node)) { |
| 5935 |
return; |
| 5936 |
} |
| 5937 |
const list = node; |
| 5938 |
const prevElement = list.previousElementSibling; |
| 5939 |
if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) { |
| 5940 |
while (list.firstChild) { |
| 5941 |
prevElement.appendChild(list.firstChild); |
| 5942 |
} |
| 5943 |
list.parentNode.removeChild(list); |
| 5944 |
} |
| 5945 |
const parentElement = node.parentNode; |
| 5946 |
if (parentElement && parentElement.nodeName === "LI" && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) { |
| 5947 |
const parentListItem = parentElement; |
| 5948 |
const prevListItem = parentListItem.previousElementSibling; |
| 5949 |
const parentList = parentListItem.parentNode; |
| 5950 |
if (prevListItem) { |
| 5951 |
prevListItem.appendChild(list); |
| 5952 |
parentList.removeChild(parentListItem); |
| 5953 |
} |
| 5954 |
} |
| 5955 |
if (parentElement && isList(parentElement)) { |
| 5956 |
const prevListItem = list.previousElementSibling; |
| 5957 |
if (prevListItem) { |
| 5958 |
prevListItem.appendChild(node); |
| 5959 |
} else { |
| 5960 |
(0, import_dom4.unwrap)(node); |
| 5961 |
} |
| 5962 |
} |
| 5963 |
} |
| 5964 |
|
| 5965 |
// packages/blocks/build-module/api/raw-handling/blockquote-normaliser.mjs |
| 5966 |
function blockquoteNormaliser(options = {}) { |
| 5967 |
return (bq) => { |
| 5968 |
if (bq.nodeName !== "BLOCKQUOTE") { |
| 5969 |
return; |
| 5970 |
} |
| 5971 |
const node = bq; |
| 5972 |
node.innerHTML = normaliseBlocks(node.innerHTML, options); |
| 5973 |
}; |
| 5974 |
} |
| 5975 |
|
| 5976 |
// packages/blocks/build-module/api/raw-handling/figure-content-reducer.mjs |
| 5977 |
var import_dom5 = __toESM(require_dom(), 1); |
| 5978 |
function isFigureContent(node, schema) { |
| 5979 |
const tag = node.nodeName.toLowerCase(); |
| 5980 |
if (tag === "figcaption" || (0, import_dom5.isTextContent)(node)) { |
| 5981 |
return false; |
| 5982 |
} |
| 5983 |
return tag in (schema?.figure?.children ?? {}); |
| 5984 |
} |
| 5985 |
function canHaveAnchor(node, schema) { |
| 5986 |
const tag = node.nodeName.toLowerCase(); |
| 5987 |
return tag in (schema?.figure?.children?.a?.children ?? {}); |
| 5988 |
} |
| 5989 |
function wrapFigureContent(element, beforeElement = element) { |
| 5990 |
const figure = element.ownerDocument.createElement("figure"); |
| 5991 |
beforeElement.parentNode.insertBefore(figure, beforeElement); |
| 5992 |
figure.appendChild(element); |
| 5993 |
} |
| 5994 |
function figureContentReducer(node, doc, schema) { |
| 5995 |
if (!schema || !isFigureContent(node, schema)) { |
| 5996 |
return; |
| 5997 |
} |
| 5998 |
let nodeToInsert = node; |
| 5999 |
const parentNode = node.parentNode; |
| 6000 |
if (canHaveAnchor(node, schema) && parentNode.nodeName === "A" && parentNode.childNodes.length === 1) { |
| 6001 |
nodeToInsert = node.parentNode; |
| 6002 |
} |
| 6003 |
const wrapper = nodeToInsert.closest("p,div"); |
| 6004 |
if (wrapper) { |
| 6005 |
const element = node; |
| 6006 |
if (!element.classList) { |
| 6007 |
wrapFigureContent(nodeToInsert, wrapper); |
| 6008 |
} else if (element.classList.contains("alignright") || element.classList.contains("alignleft") || element.classList.contains("aligncenter") || !wrapper.textContent.trim()) { |
| 6009 |
wrapFigureContent(nodeToInsert, wrapper); |
| 6010 |
} |
| 6011 |
} else { |
| 6012 |
wrapFigureContent(nodeToInsert); |
| 6013 |
} |
| 6014 |
} |
| 6015 |
|
| 6016 |
// packages/blocks/build-module/api/raw-handling/shortcode-converter.mjs |
| 6017 |
var import_shortcode = __toESM(require_shortcode(), 1); |
| 6018 |
var castArray = (maybeArray) => Array.isArray(maybeArray) ? maybeArray : [maybeArray]; |
| 6019 |
var beforeLineRegexp = /(\n|<p>|<br\s*\/?>)\s*$/; |
| 6020 |
var afterLineRegexp = /^\s*(\n|<\/p>|<br\s*\/?>)/; |
| 6021 |
function segmentHTMLToShortcodeBlock(HTML, lastIndex = 0, excludedBlockNames = []) { |
| 6022 |
const transformsFrom = getBlockTransforms( |
| 6023 |
"from" |
| 6024 |
); |
| 6025 |
const transformation = findTransform( |
| 6026 |
transformsFrom, |
| 6027 |
((transform) => { |
| 6028 |
const t3 = transform; |
| 6029 |
return excludedBlockNames.indexOf(t3.blockName) === -1 && t3.type === "shortcode" && castArray(t3.tag).some( |
| 6030 |
(tag) => (0, import_shortcode.regexp)(tag).test(HTML) |
| 6031 |
); |
| 6032 |
}) |
| 6033 |
); |
| 6034 |
if (!transformation) { |
| 6035 |
return [HTML]; |
| 6036 |
} |
| 6037 |
const transformTags = castArray(transformation.tag); |
| 6038 |
const transformTag = transformTags.find( |
| 6039 |
(tag) => (0, import_shortcode.regexp)(tag).test(HTML) |
| 6040 |
); |
| 6041 |
let match; |
| 6042 |
const previousIndex = lastIndex; |
| 6043 |
if (match = (0, import_shortcode.next)(transformTag, HTML, lastIndex)) { |
| 6044 |
lastIndex = match.index + match.content.length; |
| 6045 |
const beforeHTML = HTML.substr(0, match.index); |
| 6046 |
const afterHTML = HTML.substr(lastIndex); |
| 6047 |
if (!match.shortcode.content?.includes("<") && !(beforeLineRegexp.test(beforeHTML) && afterLineRegexp.test(afterHTML))) { |
| 6048 |
return segmentHTMLToShortcodeBlock(HTML, lastIndex); |
| 6049 |
} |
| 6050 |
if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) { |
| 6051 |
return segmentHTMLToShortcodeBlock(HTML, previousIndex, [ |
| 6052 |
...excludedBlockNames, |
| 6053 |
transformation.blockName |
| 6054 |
]); |
| 6055 |
} |
| 6056 |
let blocks = []; |
| 6057 |
if (typeof transformation.transform === "function") { |
| 6058 |
blocks = [].concat( |
| 6059 |
transformation.transform(match.shortcode.attrs, match) |
| 6060 |
); |
| 6061 |
blocks = blocks.map((block) => { |
| 6062 |
block.originalContent = match.shortcode.content; |
| 6063 |
return applyBuiltInValidationFixes( |
| 6064 |
block, |
| 6065 |
getBlockType(block.name) |
| 6066 |
); |
| 6067 |
}); |
| 6068 |
} else { |
| 6069 |
const attributes = Object.fromEntries( |
| 6070 |
Object.entries(transformation.attributes).filter(([, schema]) => schema.shortcode).map(([key, schema]) => [ |
| 6071 |
key, |
| 6072 |
schema.shortcode(match.shortcode.attrs, match) |
| 6073 |
]) |
| 6074 |
); |
| 6075 |
const blockType = getBlockType(transformation.blockName); |
| 6076 |
if (!blockType) { |
| 6077 |
return [HTML]; |
| 6078 |
} |
| 6079 |
const transformationBlockType = { |
| 6080 |
...blockType, |
| 6081 |
attributes: transformation.attributes |
| 6082 |
}; |
| 6083 |
let block = createBlock( |
| 6084 |
transformation.blockName, |
| 6085 |
getBlockAttributes( |
| 6086 |
transformationBlockType, |
| 6087 |
match.shortcode.content, |
| 6088 |
attributes |
| 6089 |
) |
| 6090 |
); |
| 6091 |
block.originalContent = match.shortcode.content; |
| 6092 |
block = applyBuiltInValidationFixes( |
| 6093 |
block, |
| 6094 |
transformationBlockType |
| 6095 |
); |
| 6096 |
blocks = [block]; |
| 6097 |
} |
| 6098 |
return [ |
| 6099 |
...segmentHTMLToShortcodeBlock( |
| 6100 |
beforeHTML.replace(beforeLineRegexp, "") |
| 6101 |
), |
| 6102 |
...blocks, |
| 6103 |
...segmentHTMLToShortcodeBlock( |
| 6104 |
afterHTML.replace(afterLineRegexp, "") |
| 6105 |
) |
| 6106 |
]; |
| 6107 |
} |
| 6108 |
return [HTML]; |
| 6109 |
} |
| 6110 |
var shortcode_converter_default = segmentHTMLToShortcodeBlock; |
| 6111 |
|
| 6112 |
// packages/blocks/build-module/api/raw-handling/utils.mjs |
| 6113 |
var import_dom6 = __toESM(require_dom(), 1); |
| 6114 |
function getBlockContentSchemaFromTransforms(transforms, context) { |
| 6115 |
const phrasingContentSchema = (0, import_dom6.getPhrasingContentSchema)(context); |
| 6116 |
const schemaArgs = { phrasingContentSchema, isPaste: context === "paste" }; |
| 6117 |
const schemas = transforms.map(({ isMatch, blockName, schema }) => { |
| 6118 |
const hasAnchorSupport = hasBlockSupport(blockName, "anchor"); |
| 6119 |
schema = typeof schema === "function" ? schema(schemaArgs) : schema; |
| 6120 |
if (!hasAnchorSupport && !isMatch) { |
| 6121 |
return schema; |
| 6122 |
} |
| 6123 |
if (!schema) { |
| 6124 |
return {}; |
| 6125 |
} |
| 6126 |
return Object.fromEntries( |
| 6127 |
Object.entries(schema).map(([key, value]) => { |
| 6128 |
let attributes = value.attributes || []; |
| 6129 |
if (hasAnchorSupport) { |
| 6130 |
attributes = [...attributes, "id"]; |
| 6131 |
} |
| 6132 |
return [ |
| 6133 |
key, |
| 6134 |
{ |
| 6135 |
...value, |
| 6136 |
attributes, |
| 6137 |
isMatch: isMatch ? isMatch : void 0 |
| 6138 |
} |
| 6139 |
]; |
| 6140 |
}) |
| 6141 |
); |
| 6142 |
}); |
| 6143 |
function mergeTagNameSchemaProperties(objValue, srcValue, key) { |
| 6144 |
switch (key) { |
| 6145 |
case "children": { |
| 6146 |
if (objValue === "*" || srcValue === "*") { |
| 6147 |
return "*"; |
| 6148 |
} |
| 6149 |
return mergeSchemas( |
| 6150 |
{ ...objValue || {} }, |
| 6151 |
srcValue || {} |
| 6152 |
); |
| 6153 |
} |
| 6154 |
case "attributes": |
| 6155 |
case "require": { |
| 6156 |
return Array.from( |
| 6157 |
/* @__PURE__ */ new Set([...objValue || [], ...srcValue || []]) |
| 6158 |
); |
| 6159 |
} |
| 6160 |
case "isMatch": { |
| 6161 |
if (!objValue || !srcValue) { |
| 6162 |
return void 0; |
| 6163 |
} |
| 6164 |
return (...args) => { |
| 6165 |
return objValue(...args) || srcValue(...args); |
| 6166 |
}; |
| 6167 |
} |
| 6168 |
case "classes": { |
| 6169 |
if ((objValue || []).includes("*") || (srcValue || []).includes("*")) { |
| 6170 |
return ["*"]; |
| 6171 |
} |
| 6172 |
return [...objValue || [], ...srcValue || []]; |
| 6173 |
} |
| 6174 |
} |
| 6175 |
} |
| 6176 |
function mergeTagNameSchemas(a2, b3) { |
| 6177 |
if (a2 === b3) { |
| 6178 |
return a2; |
| 6179 |
} |
| 6180 |
for (const key in b3) { |
| 6181 |
if (a2[key]) { |
| 6182 |
a2[key] = mergeTagNameSchemaProperties( |
| 6183 |
a2[key], |
| 6184 |
b3[key], |
| 6185 |
key |
| 6186 |
); |
| 6187 |
} else if (Array.isArray(b3[key])) { |
| 6188 |
a2[key] = b3[key].slice(); |
| 6189 |
} else { |
| 6190 |
a2[key] = { ...b3[key] }; |
| 6191 |
} |
| 6192 |
} |
| 6193 |
return a2; |
| 6194 |
} |
| 6195 |
function mergeSchemas(a2, b3) { |
| 6196 |
if (a2 === b3) { |
| 6197 |
return a2; |
| 6198 |
} |
| 6199 |
for (const key in b3) { |
| 6200 |
if (a2[key]) { |
| 6201 |
a2[key] = mergeTagNameSchemas(a2[key], b3[key]); |
| 6202 |
} else if (Array.isArray(b3[key])) { |
| 6203 |
a2[key] = b3[key].slice(); |
| 6204 |
} else { |
| 6205 |
a2[key] = { ...b3[key] }; |
| 6206 |
} |
| 6207 |
} |
| 6208 |
return a2; |
| 6209 |
} |
| 6210 |
return schemas.reduce(mergeSchemas, {}); |
| 6211 |
} |
| 6212 |
function getBlockContentSchema(context) { |
| 6213 |
return getBlockContentSchemaFromTransforms(getRawTransforms(), context); |
| 6214 |
} |
| 6215 |
function isPlain(HTML) { |
| 6216 |
if (!/<(?!br[ />])/i.test(HTML)) { |
| 6217 |
return true; |
| 6218 |
} |
| 6219 |
const doc = document.implementation.createHTMLDocument(""); |
| 6220 |
doc.body.innerHTML = HTML; |
| 6221 |
if (doc.body.children.length !== 1) { |
| 6222 |
return false; |
| 6223 |
} |
| 6224 |
const wrapper = doc.body.children.item(0); |
| 6225 |
const descendants = wrapper.getElementsByTagName("*"); |
| 6226 |
for (let i2 = 0; i2 < descendants.length; i2++) { |
| 6227 |
if (descendants.item(i2).tagName !== "BR") { |
| 6228 |
return false; |
| 6229 |
} |
| 6230 |
} |
| 6231 |
if (wrapper.tagName !== "SPAN") { |
| 6232 |
return false; |
| 6233 |
} |
| 6234 |
return true; |
| 6235 |
} |
| 6236 |
function deepFilterNodeList(nodeList, filters, doc, schema) { |
| 6237 |
Array.from(nodeList).forEach((node) => { |
| 6238 |
deepFilterNodeList(node.childNodes, filters, doc, schema); |
| 6239 |
filters.forEach((item) => { |
| 6240 |
if (!doc.contains(node)) { |
| 6241 |
return; |
| 6242 |
} |
| 6243 |
item(node, doc, schema); |
| 6244 |
}); |
| 6245 |
}); |
| 6246 |
} |
| 6247 |
function deepFilterHTML(HTML, filters = [], schema) { |
| 6248 |
const doc = document.implementation.createHTMLDocument(""); |
| 6249 |
doc.body.innerHTML = HTML; |
| 6250 |
deepFilterNodeList(doc.body.childNodes, filters, doc, schema); |
| 6251 |
return doc.body.innerHTML; |
| 6252 |
} |
| 6253 |
function getSibling(node, which) { |
| 6254 |
const sibling = node[`${which}Sibling`]; |
| 6255 |
if (sibling && (0, import_dom6.isPhrasingContent)(sibling)) { |
| 6256 |
return sibling; |
| 6257 |
} |
| 6258 |
const { parentNode } = node; |
| 6259 |
if (!parentNode || !(0, import_dom6.isPhrasingContent)(parentNode)) { |
| 6260 |
return; |
| 6261 |
} |
| 6262 |
return getSibling(parentNode, which); |
| 6263 |
} |
| 6264 |
|
| 6265 |
// packages/blocks/build-module/api/raw-handling/paste-handler.mjs |
| 6266 |
var import_dom12 = __toESM(require_dom(), 1); |
| 6267 |
|
| 6268 |
// packages/blocks/build-module/api/raw-handling/comment-remover.mjs |
| 6269 |
var import_dom7 = __toESM(require_dom(), 1); |
| 6270 |
function commentRemover(node) { |
| 6271 |
if (node.nodeType === node.COMMENT_NODE) { |
| 6272 |
(0, import_dom7.remove)(node); |
| 6273 |
} |
| 6274 |
} |
| 6275 |
|
| 6276 |
// packages/blocks/build-module/api/raw-handling/is-inline-content.mjs |
| 6277 |
var import_dom8 = __toESM(require_dom(), 1); |
| 6278 |
function isInline(node, contextTag) { |
| 6279 |
if ((0, import_dom8.isTextContent)(node)) { |
| 6280 |
return true; |
| 6281 |
} |
| 6282 |
if (!contextTag) { |
| 6283 |
return false; |
| 6284 |
} |
| 6285 |
const tag = node.nodeName.toLowerCase(); |
| 6286 |
const inlineAllowedTagGroups = [ |
| 6287 |
["ul", "li", "ol"], |
| 6288 |
["h1", "h2", "h3", "h4", "h5", "h6"] |
| 6289 |
]; |
| 6290 |
return inlineAllowedTagGroups.some( |
| 6291 |
(tagGroup) => [tag, contextTag].filter((t3) => !tagGroup.includes(t3)).length === 0 |
| 6292 |
); |
| 6293 |
} |
| 6294 |
function deepCheck(nodes, contextTag) { |
| 6295 |
return nodes.every( |
| 6296 |
(node) => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag) |
| 6297 |
); |
| 6298 |
} |
| 6299 |
function isDoubleBR(node) { |
| 6300 |
return node.nodeName === "BR" && !!node.previousSibling && node.previousSibling.nodeName === "BR"; |
| 6301 |
} |
| 6302 |
function isInlineContent(HTML, contextTag) { |
| 6303 |
const doc = document.implementation.createHTMLDocument(""); |
| 6304 |
doc.body.innerHTML = HTML; |
| 6305 |
const nodes = Array.from(doc.body.children); |
| 6306 |
return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag); |
| 6307 |
} |
| 6308 |
|
| 6309 |
// packages/blocks/build-module/api/raw-handling/phrasing-content-reducer.mjs |
| 6310 |
var import_dom9 = __toESM(require_dom(), 1); |
| 6311 |
function phrasingContentReducer(node, doc) { |
| 6312 |
if (node.nodeName === "SPAN" && node.style) { |
| 6313 |
const { |
| 6314 |
fontWeight, |
| 6315 |
fontStyle, |
| 6316 |
textDecorationLine, |
| 6317 |
textDecoration, |
| 6318 |
verticalAlign |
| 6319 |
} = node.style; |
| 6320 |
const element = node; |
| 6321 |
if (fontWeight === "bold" || fontWeight === "700") { |
| 6322 |
(0, import_dom9.wrap)(doc.createElement("strong"), element); |
| 6323 |
} |
| 6324 |
if (fontStyle === "italic") { |
| 6325 |
(0, import_dom9.wrap)(doc.createElement("em"), element); |
| 6326 |
} |
| 6327 |
if (textDecorationLine === "line-through" || textDecoration.includes("line-through")) { |
| 6328 |
(0, import_dom9.wrap)(doc.createElement("s"), element); |
| 6329 |
} |
| 6330 |
if (verticalAlign === "super") { |
| 6331 |
(0, import_dom9.wrap)(doc.createElement("sup"), element); |
| 6332 |
} else if (verticalAlign === "sub") { |
| 6333 |
(0, import_dom9.wrap)(doc.createElement("sub"), element); |
| 6334 |
} |
| 6335 |
} else if (node.nodeName === "B") { |
| 6336 |
(0, import_dom9.replaceTag)(node, "strong"); |
| 6337 |
} else if (node.nodeName === "I") { |
| 6338 |
(0, import_dom9.replaceTag)(node, "em"); |
| 6339 |
} else if (node.nodeName === "A") { |
| 6340 |
const anchor = node; |
| 6341 |
if (anchor.target && anchor.target.toLowerCase() === "_blank") { |
| 6342 |
anchor.rel = "noopener"; |
| 6343 |
} else { |
| 6344 |
anchor.removeAttribute("target"); |
| 6345 |
anchor.removeAttribute("rel"); |
| 6346 |
} |
| 6347 |
if (anchor.name && !anchor.id) { |
| 6348 |
anchor.id = anchor.name; |
| 6349 |
} |
| 6350 |
if (anchor.id && !anchor.ownerDocument.querySelector(`[href="#${anchor.id}"]`)) { |
| 6351 |
anchor.removeAttribute("id"); |
| 6352 |
} |
| 6353 |
} |
| 6354 |
} |
| 6355 |
|
| 6356 |
// packages/blocks/build-module/api/raw-handling/head-remover.mjs |
| 6357 |
function headRemover(node) { |
| 6358 |
if (node.nodeName !== "SCRIPT" && node.nodeName !== "NOSCRIPT" && node.nodeName !== "TEMPLATE" && node.nodeName !== "STYLE") { |
| 6359 |
return; |
| 6360 |
} |
| 6361 |
node.parentNode.removeChild(node); |
| 6362 |
} |
| 6363 |
|
| 6364 |
// packages/blocks/build-module/api/raw-handling/ms-list-ignore.mjs |
| 6365 |
function msListIgnore(node) { |
| 6366 |
if (node.nodeType !== node.ELEMENT_NODE) { |
| 6367 |
return; |
| 6368 |
} |
| 6369 |
const el = node; |
| 6370 |
const style = el.getAttribute("style"); |
| 6371 |
if (!style || !style.includes("mso-list")) { |
| 6372 |
return; |
| 6373 |
} |
| 6374 |
const rules = style.split(";").reduce( |
| 6375 |
(acc, rule) => { |
| 6376 |
const [key, value] = rule.split(":"); |
| 6377 |
if (key && value) { |
| 6378 |
acc[key.trim().toLowerCase()] = value.trim().toLowerCase(); |
| 6379 |
} |
| 6380 |
return acc; |
| 6381 |
}, |
| 6382 |
{} |
| 6383 |
); |
| 6384 |
if (rules["mso-list"] === "ignore") { |
| 6385 |
el.remove(); |
| 6386 |
} |
| 6387 |
} |
| 6388 |
|
| 6389 |
// packages/blocks/build-module/api/raw-handling/ms-list-converter.mjs |
| 6390 |
function isList2(node) { |
| 6391 |
return node.nodeName === "OL" || node.nodeName === "UL"; |
| 6392 |
} |
| 6393 |
function msListConverter(node, doc) { |
| 6394 |
if (node.nodeName !== "P") { |
| 6395 |
return; |
| 6396 |
} |
| 6397 |
const element = node; |
| 6398 |
const style = element.getAttribute("style"); |
| 6399 |
if (!style || !style.includes("mso-list")) { |
| 6400 |
return; |
| 6401 |
} |
| 6402 |
const prevNode = element.previousElementSibling; |
| 6403 |
if (!prevNode || !isList2(prevNode)) { |
| 6404 |
const type = element.textContent.trim().slice(0, 1); |
| 6405 |
const isNumeric = /[1iIaA]/.test(type); |
| 6406 |
const newListNode = doc.createElement(isNumeric ? "ol" : "ul"); |
| 6407 |
if (isNumeric) { |
| 6408 |
newListNode.setAttribute("type", type); |
| 6409 |
} |
| 6410 |
element.parentNode.insertBefore(newListNode, element); |
| 6411 |
} |
| 6412 |
const listNode = element.previousElementSibling; |
| 6413 |
const listType = listNode.nodeName; |
| 6414 |
const listItem = doc.createElement("li"); |
| 6415 |
let receivingNode = listNode; |
| 6416 |
listItem.innerHTML = deepFilterHTML(element.innerHTML, [msListIgnore]); |
| 6417 |
const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style); |
| 6418 |
let level = matches ? parseInt(matches[1], 10) - 1 || 0 : 0; |
| 6419 |
while (level--) { |
| 6420 |
receivingNode = receivingNode.lastChild || receivingNode; |
| 6421 |
if (isList2(receivingNode)) { |
| 6422 |
receivingNode = receivingNode.lastChild || receivingNode; |
| 6423 |
} |
| 6424 |
} |
| 6425 |
if (!isList2(receivingNode)) { |
| 6426 |
receivingNode = receivingNode.appendChild( |
| 6427 |
doc.createElement(listType) |
| 6428 |
); |
| 6429 |
} |
| 6430 |
receivingNode.appendChild(listItem); |
| 6431 |
element.parentNode.removeChild(element); |
| 6432 |
} |
| 6433 |
|
| 6434 |
// packages/blocks/build-module/api/raw-handling/image-corrector.mjs |
| 6435 |
var import_blob = __toESM(require_blob(), 1); |
| 6436 |
function imageCorrector(img) { |
| 6437 |
if (img.nodeName !== "IMG") { |
| 6438 |
return; |
| 6439 |
} |
| 6440 |
const node = img; |
| 6441 |
if (node.src.indexOf("file:") === 0) { |
| 6442 |
node.src = ""; |
| 6443 |
} |
| 6444 |
if (node.src.indexOf("data:") === 0) { |
| 6445 |
const [properties, data] = node.src.split(","); |
| 6446 |
const [type] = properties.slice(5).split(";"); |
| 6447 |
if (!data || !type) { |
| 6448 |
node.src = ""; |
| 6449 |
return; |
| 6450 |
} |
| 6451 |
let decoded; |
| 6452 |
try { |
| 6453 |
decoded = atob(data); |
| 6454 |
} catch { |
| 6455 |
node.src = ""; |
| 6456 |
return; |
| 6457 |
} |
| 6458 |
const uint8Array = new Uint8Array(decoded.length); |
| 6459 |
for (let i2 = 0; i2 < uint8Array.length; i2++) { |
| 6460 |
uint8Array[i2] = decoded.charCodeAt(i2); |
| 6461 |
} |
| 6462 |
const name = type.replace("/", "."); |
| 6463 |
const file = new window.File([uint8Array], name, { type }); |
| 6464 |
node.src = (0, import_blob.createBlobURL)(file); |
| 6465 |
} |
| 6466 |
if (node.height === 1 || node.width === 1) { |
| 6467 |
node.parentNode.removeChild(node); |
| 6468 |
} |
| 6469 |
} |
| 6470 |
|
| 6471 |
// packages/blocks/build-module/api/raw-handling/div-normaliser.mjs |
| 6472 |
function divNormaliser(div) { |
| 6473 |
if (div.nodeName !== "DIV") { |
| 6474 |
return; |
| 6475 |
} |
| 6476 |
const node = div; |
| 6477 |
node.innerHTML = normaliseBlocks(node.innerHTML); |
| 6478 |
} |
| 6479 |
|
| 6480 |
// node_modules/marked/lib/marked.esm.js |
| 6481 |
function z() { |
| 6482 |
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null }; |
| 6483 |
} |
| 6484 |
var T = z(); |
| 6485 |
function G(l4) { |
| 6486 |
T = l4; |
| 6487 |
} |
| 6488 |
var _ = { exec: () => null }; |
| 6489 |
function d2(l4, e2 = "") { |
| 6490 |
let t3 = typeof l4 == "string" ? l4 : l4.source, n2 = { replace: (s2, r2) => { |
| 6491 |
let i2 = typeof r2 == "string" ? r2 : r2.source; |
| 6492 |
return i2 = i2.replace(m2.caret, "$1"), t3 = t3.replace(s2, i2), n2; |
| 6493 |
}, getRegex: () => new RegExp(t3, e2) }; |
| 6494 |
return n2; |
| 6495 |
} |
| 6496 |
var Re = ((l4 = "") => { |
| 6497 |
try { |
| 6498 |
return !!new RegExp("(?<=1)(?<!1)" + l4); |
| 6499 |
} catch { |
| 6500 |
return false; |
| 6501 |
} |
| 6502 |
})(); |
| 6503 |
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)}}>`) }; |
| 6504 |
var Te = /^(?:[ \t]*(?:\n|$))+/; |
| 6505 |
var Oe = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/; |
| 6506 |
var we = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/; |
| 6507 |
var I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/; |
| 6508 |
var ye = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/; |
| 6509 |
var Q = / {0,3}(?:[*+-]|\d{1,9}[.)])/; |
| 6510 |
var ie = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/; |
| 6511 |
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(); |
| 6512 |
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(); |
| 6513 |
var j2 = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/; |
| 6514 |
var Se = /^[^\n]+/; |
| 6515 |
var F = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/; |
| 6516 |
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(); |
| 6517 |
var Le = d2(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Q).getRegex(); |
| 6518 |
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"; |
| 6519 |
var U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/; |
| 6520 |
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(); |
| 6521 |
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(); |
| 6522 |
var Me = d2(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ae).getRegex(); |
| 6523 |
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 }; |
| 6524 |
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(); |
| 6525 |
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() }; |
| 6526 |
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} *[^ |
| 6527 |
]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }; |
| 6528 |
var Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/; |
| 6529 |
var Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/; |
| 6530 |
var le = /^( {2,}|\\)\n(?!\s*$)/; |
| 6531 |
var Ie = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/; |
| 6532 |
var E = /[\p{P}\p{S}]/u; |
| 6533 |
var H2 = /[\s\p{P}\p{S}]/u; |
| 6534 |
var W = /[^\s\p{P}\p{S}]/u; |
| 6535 |
var Be = d2(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, H2).getRegex(); |
| 6536 |
var ue = /(?!~)[\p{P}\p{S}]/u; |
| 6537 |
var De = /(?!~)[\s\p{P}\p{S}]/u; |
| 6538 |
var qe = /(?:[^\s\p{P}\p{S}]|~)/u; |
| 6539 |
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(); |
| 6540 |
var pe = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/; |
| 6541 |
var He = d2(pe, "u").replace(/punct/g, E).getRegex(); |
| 6542 |
var Ze = d2(pe, "u").replace(/punct/g, ue).getRegex(); |
| 6543 |
var ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)"; |
| 6544 |
var Ge = d2(ce, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H2).replace(/punct/g, E).getRegex(); |
| 6545 |
var Ne = d2(ce, "gu").replace(/notPunctSpace/g, qe).replace(/punctSpace/g, De).replace(/punct/g, ue).getRegex(); |
| 6546 |
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(); |
| 6547 |
var je = d2(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, E).getRegex(); |
| 6548 |
var Fe = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)"; |
| 6549 |
var Ue = d2(Fe, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H2).replace(/punct/g, E).getRegex(); |
| 6550 |
var Ke = d2(/\\(punct)/, "gu").replace(/punct/g, E).getRegex(); |
| 6551 |
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(); |
| 6552 |
var Xe = d2(U).replace("(?:-->|$)", "-->").getRegex(); |
| 6553 |
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(); |
| 6554 |
var q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/; |
| 6555 |
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(); |
| 6556 |
var he = d2(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", F).getRegex(); |
| 6557 |
var ke = d2(/^!?\[(ref)\](?:\[\])?/).replace("ref", F).getRegex(); |
| 6558 |
var Ye = d2("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex(); |
| 6559 |
var se = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/; |
| 6560 |
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: _ }; |
| 6561 |
var et = { ...X, link: d2(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: d2(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() }; |
| 6562 |
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() }; |
| 6563 |
var tt = { ...N2, br: d2(le).replace("{2,}", "*").getRegex(), text: d2(N2.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }; |
| 6564 |
var B = { normal: K, gfm: ze, pedantic: Ee }; |
| 6565 |
var A = { normal: X, gfm: N2, breaks: tt, pedantic: et }; |
| 6566 |
var nt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }; |
| 6567 |
var de = (l4) => nt[l4]; |
| 6568 |
function O(l4, e2) { |
| 6569 |
if (e2) { |
| 6570 |
if (m2.escapeTest.test(l4)) return l4.replace(m2.escapeReplace, de); |
| 6571 |
} else if (m2.escapeTestNoEncode.test(l4)) return l4.replace(m2.escapeReplaceNoEncode, de); |
| 6572 |
return l4; |
| 6573 |
} |
| 6574 |
function J(l4) { |
| 6575 |
try { |
| 6576 |
l4 = encodeURI(l4).replace(m2.percentDecode, "%"); |
| 6577 |
} catch { |
| 6578 |
return null; |
| 6579 |
} |
| 6580 |
return l4; |
| 6581 |
} |
| 6582 |
function V(l4, e2) { |
| 6583 |
let t3 = l4.replace(m2.findPipe, (r2, i2, o3) => { |
| 6584 |
let u2 = false, a2 = i2; |
| 6585 |
for (; --a2 >= 0 && o3[a2] === "\\"; ) u2 = !u2; |
| 6586 |
return u2 ? "|" : " |"; |
| 6587 |
}), n2 = t3.split(m2.splitPipe), s2 = 0; |
| 6588 |
if (n2[0].trim() || n2.shift(), n2.length > 0 && !n2.at(-1)?.trim() && n2.pop(), e2) if (n2.length > e2) n2.splice(e2); |
| 6589 |
else for (; n2.length < e2; ) n2.push(""); |
| 6590 |
for (; s2 < n2.length; s2++) n2[s2] = n2[s2].trim().replace(m2.slashPipe, "|"); |
| 6591 |
return n2; |
| 6592 |
} |
| 6593 |
function $2(l4, e2, t3) { |
| 6594 |
let n2 = l4.length; |
| 6595 |
if (n2 === 0) return ""; |
| 6596 |
let s2 = 0; |
| 6597 |
for (; s2 < n2; ) { |
| 6598 |
let r2 = l4.charAt(n2 - s2 - 1); |
| 6599 |
if (r2 === e2 && !t3) s2++; |
| 6600 |
else if (r2 !== e2 && t3) s2++; |
| 6601 |
else break; |
| 6602 |
} |
| 6603 |
return l4.slice(0, n2 - s2); |
| 6604 |
} |
| 6605 |
function Y(l4) { |
| 6606 |
let e2 = l4.split(` |
| 6607 |
`), t3 = e2.length - 1; |
| 6608 |
for (; t3 >= 0 && m2.blankLine.test(e2[t3]); ) t3--; |
| 6609 |
return e2.length - t3 <= 2 ? l4 : e2.slice(0, t3 + 1).join(` |
| 6610 |
`); |
| 6611 |
} |
| 6612 |
function ge(l4, e2) { |
| 6613 |
if (l4.indexOf(e2[1]) === -1) return -1; |
| 6614 |
let t3 = 0; |
| 6615 |
for (let n2 = 0; n2 < l4.length; n2++) if (l4[n2] === "\\") n2++; |
| 6616 |
else if (l4[n2] === e2[0]) t3++; |
| 6617 |
else if (l4[n2] === e2[1] && (t3--, t3 < 0)) return n2; |
| 6618 |
return t3 > 0 ? -2 : -1; |
| 6619 |
} |
| 6620 |
function fe(l4, e2 = 0) { |
| 6621 |
let t3 = e2, n2 = ""; |
| 6622 |
for (let s2 of l4) if (s2 === " ") { |
| 6623 |
let r2 = 4 - t3 % 4; |
| 6624 |
n2 += " ".repeat(r2), t3 += r2; |
| 6625 |
} else n2 += s2, t3++; |
| 6626 |
return n2; |
| 6627 |
} |
| 6628 |
function me(l4, e2, t3, n2, s2) { |
| 6629 |
let r2 = e2.href, i2 = e2.title || null, o3 = l4[1].replace(s2.other.outputLinkReplace, "$1"); |
| 6630 |
n2.state.inLink = true; |
| 6631 |
let u2 = { type: l4[0].charAt(0) === "!" ? "image" : "link", raw: t3, href: r2, title: i2, text: o3, tokens: n2.inlineTokens(o3) }; |
| 6632 |
return n2.state.inLink = false, u2; |
| 6633 |
} |
| 6634 |
function rt(l4, e2, t3) { |
| 6635 |
let n2 = l4.match(t3.other.indentCodeCompensation); |
| 6636 |
if (n2 === null) return e2; |
| 6637 |
let s2 = n2[1]; |
| 6638 |
return e2.split(` |
| 6639 |
`).map((r2) => { |
| 6640 |
let i2 = r2.match(t3.other.beginningSpace); |
| 6641 |
if (i2 === null) return r2; |
| 6642 |
let [o3] = i2; |
| 6643 |
return o3.length >= s2.length ? r2.slice(s2.length) : r2; |
| 6644 |
}).join(` |
| 6645 |
`); |
| 6646 |
} |
| 6647 |
var w2 = class { |
| 6648 |
options; |
| 6649 |
rules; |
| 6650 |
lexer; |
| 6651 |
constructor(e2) { |
| 6652 |
this.options = e2 || T; |
| 6653 |
} |
| 6654 |
space(e2) { |
| 6655 |
let t3 = this.rules.block.newline.exec(e2); |
| 6656 |
if (t3 && t3[0].length > 0) return { type: "space", raw: t3[0] }; |
| 6657 |
} |
| 6658 |
code(e2) { |
| 6659 |
let t3 = this.rules.block.code.exec(e2); |
| 6660 |
if (t3) { |
| 6661 |
let n2 = this.options.pedantic ? t3[0] : Y(t3[0]), s2 = n2.replace(this.rules.other.codeRemoveIndent, ""); |
| 6662 |
return { type: "code", raw: n2, codeBlockStyle: "indented", text: s2 }; |
| 6663 |
} |
| 6664 |
} |
| 6665 |
fences(e2) { |
| 6666 |
let t3 = this.rules.block.fences.exec(e2); |
| 6667 |
if (t3) { |
| 6668 |
let n2 = t3[0], s2 = rt(n2, t3[3] || "", this.rules); |
| 6669 |
return { type: "code", raw: n2, lang: t3[2] ? t3[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t3[2], text: s2 }; |
| 6670 |
} |
| 6671 |
} |
| 6672 |
heading(e2) { |
| 6673 |
let t3 = this.rules.block.heading.exec(e2); |
| 6674 |
if (t3) { |
| 6675 |
let n2 = t3[2].trim(); |
| 6676 |
if (this.rules.other.endingHash.test(n2)) { |
| 6677 |
let s2 = $2(n2, "#"); |
| 6678 |
(this.options.pedantic || !s2 || this.rules.other.endingSpaceChar.test(s2)) && (n2 = s2.trim()); |
| 6679 |
} |
| 6680 |
return { type: "heading", raw: $2(t3[0], ` |
| 6681 |
`), depth: t3[1].length, text: n2, tokens: this.lexer.inline(n2) }; |
| 6682 |
} |
| 6683 |
} |
| 6684 |
hr(e2) { |
| 6685 |
let t3 = this.rules.block.hr.exec(e2); |
| 6686 |
if (t3) return { type: "hr", raw: $2(t3[0], ` |
| 6687 |
`) }; |
| 6688 |
} |
| 6689 |
blockquote(e2) { |
| 6690 |
let t3 = this.rules.block.blockquote.exec(e2); |
| 6691 |
if (t3) { |
| 6692 |
let n2 = $2(t3[0], ` |
| 6693 |
`).split(` |
| 6694 |
`), s2 = "", r2 = "", i2 = []; |
| 6695 |
for (; n2.length > 0; ) { |
| 6696 |
let o3 = false, u2 = [], a2; |
| 6697 |
for (a2 = 0; a2 < n2.length; a2++) if (this.rules.other.blockquoteStart.test(n2[a2])) u2.push(n2[a2]), o3 = true; |
| 6698 |
else if (!o3) u2.push(n2[a2]); |
| 6699 |
else break; |
| 6700 |
n2 = n2.slice(a2); |
| 6701 |
let c2 = u2.join(` |
| 6702 |
`), p2 = c2.replace(this.rules.other.blockquoteSetextReplace, ` |
| 6703 |
$1`).replace(this.rules.other.blockquoteSetextReplace2, ""); |
| 6704 |
s2 = s2 ? `${s2} |
| 6705 |
${c2}` : c2, r2 = r2 ? `${r2} |
| 6706 |
${p2}` : p2; |
| 6707 |
let k2 = this.lexer.state.top; |
| 6708 |
if (this.lexer.state.top = true, this.lexer.blockTokens(p2, i2, true), this.lexer.state.top = k2, n2.length === 0) break; |
| 6709 |
let h2 = i2.at(-1); |
| 6710 |
if (h2?.type === "code") break; |
| 6711 |
if (h2?.type === "blockquote") { |
| 6712 |
let R = h2, f2 = R.raw + ` |
| 6713 |
` + n2.join(` |
| 6714 |
`), S2 = this.blockquote(f2); |
| 6715 |
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; |
| 6716 |
break; |
| 6717 |
} else if (h2?.type === "list") { |
| 6718 |
let R = h2, f2 = R.raw + ` |
| 6719 |
` + n2.join(` |
| 6720 |
`), S2 = this.list(f2); |
| 6721 |
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(` |
| 6722 |
`); |
| 6723 |
continue; |
| 6724 |
} |
| 6725 |
} |
| 6726 |
return { type: "blockquote", raw: s2, tokens: i2, text: r2 }; |
| 6727 |
} |
| 6728 |
} |
| 6729 |
list(e2) { |
| 6730 |
let t3 = this.rules.block.list.exec(e2); |
| 6731 |
if (t3) { |
| 6732 |
let n2 = t3[1].trim(), s2 = n2.length > 1, r2 = { type: "list", raw: "", ordered: s2, start: s2 ? +n2.slice(0, -1) : "", loose: false, items: [] }; |
| 6733 |
n2 = s2 ? `\\d{1,9}\\${n2.slice(-1)}` : `\\${n2}`, this.options.pedantic && (n2 = s2 ? n2 : "[*+-]"); |
| 6734 |
let i2 = this.rules.other.listItemRegex(n2), o3 = false; |
| 6735 |
for (; e2; ) { |
| 6736 |
let a2 = false, c2 = "", p2 = ""; |
| 6737 |
if (!(t3 = i2.exec(e2)) || this.rules.block.hr.test(e2)) break; |
| 6738 |
c2 = t3[0], e2 = e2.substring(c2.length); |
| 6739 |
let k2 = fe(t3[2].split(` |
| 6740 |
`, 1)[0], t3[1].length), h2 = e2.split(` |
| 6741 |
`, 1)[0], R = !k2.trim(), f2 = 0; |
| 6742 |
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 + ` |
| 6743 |
`, e2 = e2.substring(h2.length + 1), a2 = true), !a2) { |
| 6744 |
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); |
| 6745 |
for (; e2; ) { |
| 6746 |
let Z = e2.split(` |
| 6747 |
`, 1)[0], C; |
| 6748 |
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; |
| 6749 |
if (C.search(this.rules.other.nonSpaceChar) >= f2 || !h2.trim()) p2 += ` |
| 6750 |
` + C.slice(f2); |
| 6751 |
else { |
| 6752 |
if (R || k2.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(k2) || ne.test(k2) || ee.test(k2)) break; |
| 6753 |
p2 += ` |
| 6754 |
` + h2; |
| 6755 |
} |
| 6756 |
R = !h2.trim(), c2 += Z + ` |
| 6757 |
`, e2 = e2.substring(Z.length + 1), k2 = C.slice(f2); |
| 6758 |
} |
| 6759 |
} |
| 6760 |
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; |
| 6761 |
} |
| 6762 |
let u2 = r2.items.at(-1); |
| 6763 |
if (u2) u2.raw = u2.raw.trimEnd(), u2.text = u2.text.trimEnd(); |
| 6764 |
else return; |
| 6765 |
r2.raw = r2.raw.trimEnd(); |
| 6766 |
for (let a2 of r2.items) { |
| 6767 |
this.lexer.state.top = false, a2.tokens = this.lexer.blockTokens(a2.text, []); |
| 6768 |
let c2 = a2.tokens[0]; |
| 6769 |
if (a2.task && (c2?.type === "text" || c2?.type === "paragraph")) { |
| 6770 |
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, ""); |
| 6771 |
for (let k2 = this.lexer.inlineQueue.length - 1; k2 >= 0; k2--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k2].src)) { |
| 6772 |
this.lexer.inlineQueue[k2].src = this.lexer.inlineQueue[k2].src.replace(this.rules.other.listReplaceTask, ""); |
| 6773 |
break; |
| 6774 |
} |
| 6775 |
let p2 = this.rules.other.listTaskCheckbox.exec(a2.raw); |
| 6776 |
if (p2) { |
| 6777 |
let k2 = { type: "checkbox", raw: p2[0] + " ", checked: p2[0] !== "[ ]" }; |
| 6778 |
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); |
| 6779 |
} |
| 6780 |
} else a2.task && (a2.task = false); |
| 6781 |
if (!r2.loose) { |
| 6782 |
let p2 = a2.tokens.filter((h2) => h2.type === "space"), k2 = p2.length > 0 && p2.some((h2) => this.rules.other.anyLine.test(h2.raw)); |
| 6783 |
r2.loose = k2; |
| 6784 |
} |
| 6785 |
} |
| 6786 |
if (r2.loose) for (let a2 of r2.items) { |
| 6787 |
a2.loose = true; |
| 6788 |
for (let c2 of a2.tokens) c2.type === "text" && (c2.type = "paragraph"); |
| 6789 |
} |
| 6790 |
return r2; |
| 6791 |
} |
| 6792 |
} |
| 6793 |
html(e2) { |
| 6794 |
let t3 = this.rules.block.html.exec(e2); |
| 6795 |
if (t3) { |
| 6796 |
let n2 = Y(t3[0]); |
| 6797 |
return { type: "html", block: true, raw: n2, pre: t3[1] === "pre" || t3[1] === "script" || t3[1] === "style", text: n2 }; |
| 6798 |
} |
| 6799 |
} |
| 6800 |
def(e2) { |
| 6801 |
let t3 = this.rules.block.def.exec(e2); |
| 6802 |
if (t3) { |
| 6803 |
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]; |
| 6804 |
return { type: "def", tag: n2, raw: $2(t3[0], ` |
| 6805 |
`), href: s2, title: r2 }; |
| 6806 |
} |
| 6807 |
} |
| 6808 |
table(e2) { |
| 6809 |
let t3 = this.rules.block.table.exec(e2); |
| 6810 |
if (!t3 || !this.rules.other.tableDelimiter.test(t3[2])) return; |
| 6811 |
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(` |
| 6812 |
`) : [], i2 = { type: "table", raw: $2(t3[0], ` |
| 6813 |
`), header: [], align: [], rows: [] }; |
| 6814 |
if (n2.length === s2.length) { |
| 6815 |
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); |
| 6816 |
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] }); |
| 6817 |
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] }))); |
| 6818 |
return i2; |
| 6819 |
} |
| 6820 |
} |
| 6821 |
lheading(e2) { |
| 6822 |
let t3 = this.rules.block.lheading.exec(e2); |
| 6823 |
if (t3) { |
| 6824 |
let n2 = t3[1].trim(); |
| 6825 |
return { type: "heading", raw: $2(t3[0], ` |
| 6826 |
`), depth: t3[2].charAt(0) === "=" ? 1 : 2, text: n2, tokens: this.lexer.inline(n2) }; |
| 6827 |
} |
| 6828 |
} |
| 6829 |
paragraph(e2) { |
| 6830 |
let t3 = this.rules.block.paragraph.exec(e2); |
| 6831 |
if (t3) { |
| 6832 |
let n2 = t3[1].charAt(t3[1].length - 1) === ` |
| 6833 |
` ? t3[1].slice(0, -1) : t3[1]; |
| 6834 |
return { type: "paragraph", raw: t3[0], text: n2, tokens: this.lexer.inline(n2) }; |
| 6835 |
} |
| 6836 |
} |
| 6837 |
text(e2) { |
| 6838 |
let t3 = this.rules.block.text.exec(e2); |
| 6839 |
if (t3) return { type: "text", raw: t3[0], text: t3[0], tokens: this.lexer.inline(t3[0]) }; |
| 6840 |
} |
| 6841 |
escape(e2) { |
| 6842 |
let t3 = this.rules.inline.escape.exec(e2); |
| 6843 |
if (t3) return { type: "escape", raw: t3[0], text: t3[1] }; |
| 6844 |
} |
| 6845 |
tag(e2) { |
| 6846 |
let t3 = this.rules.inline.tag.exec(e2); |
| 6847 |
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] }; |
| 6848 |
} |
| 6849 |
link(e2) { |
| 6850 |
let t3 = this.rules.inline.link.exec(e2); |
| 6851 |
if (t3) { |
| 6852 |
let n2 = t3[2].trim(); |
| 6853 |
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n2)) { |
| 6854 |
if (!this.rules.other.endAngleBracket.test(n2)) return; |
| 6855 |
let i2 = $2(n2.slice(0, -1), "\\"); |
| 6856 |
if ((n2.length - i2.length) % 2 === 0) return; |
| 6857 |
} else { |
| 6858 |
let i2 = ge(t3[2], "()"); |
| 6859 |
if (i2 === -2) return; |
| 6860 |
if (i2 > -1) { |
| 6861 |
let u2 = (t3[0].indexOf("!") === 0 ? 5 : 4) + t3[1].length + i2; |
| 6862 |
t3[2] = t3[2].substring(0, i2), t3[0] = t3[0].substring(0, u2).trim(), t3[3] = ""; |
| 6863 |
} |
| 6864 |
} |
| 6865 |
let s2 = t3[2], r2 = ""; |
| 6866 |
if (this.options.pedantic) { |
| 6867 |
let i2 = this.rules.other.pedanticHrefTitle.exec(s2); |
| 6868 |
i2 && (s2 = i2[1], r2 = i2[3]); |
| 6869 |
} else r2 = t3[3] ? t3[3].slice(1, -1) : ""; |
| 6870 |
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); |
| 6871 |
} |
| 6872 |
} |
| 6873 |
reflink(e2, t3) { |
| 6874 |
let n2; |
| 6875 |
if ((n2 = this.rules.inline.reflink.exec(e2)) || (n2 = this.rules.inline.nolink.exec(e2))) { |
| 6876 |
let s2 = (n2[2] || n2[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r2 = t3[s2.toLowerCase()]; |
| 6877 |
if (!r2) { |
| 6878 |
let i2 = n2[0].charAt(0); |
| 6879 |
return { type: "text", raw: i2, text: i2 }; |
| 6880 |
} |
| 6881 |
return me(n2, r2, n2[0], this.lexer, this.rules); |
| 6882 |
} |
| 6883 |
} |
| 6884 |
emStrong(e2, t3, n2 = "") { |
| 6885 |
let s2 = this.rules.inline.emStrongLDelim.exec(e2); |
| 6886 |
if (!s2 || !s2[1] && !s2[2] && !s2[3] && !s2[4] || s2[4] && n2.match(this.rules.other.unicodeAlphaNumeric)) return; |
| 6887 |
if (!(s2[1] || s2[3] || "") || !n2 || this.rules.inline.punctuation.exec(n2)) { |
| 6888 |
let i2 = [...s2[0]].length - 1, o3, u2, a2 = i2, c2 = 0, p2 = s2[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd; |
| 6889 |
for (p2.lastIndex = 0, t3 = t3.slice(-1 * e2.length + i2); (s2 = p2.exec(t3)) !== null; ) { |
| 6890 |
if (o3 = s2[1] || s2[2] || s2[3] || s2[4] || s2[5] || s2[6], !o3) continue; |
| 6891 |
if (u2 = [...o3].length, s2[3] || s2[4]) { |
| 6892 |
a2 += u2; |
| 6893 |
continue; |
| 6894 |
} else if ((s2[5] || s2[6]) && i2 % 3 && !((i2 + u2) % 3)) { |
| 6895 |
c2 += u2; |
| 6896 |
continue; |
| 6897 |
} |
| 6898 |
if (a2 -= u2, a2 > 0) continue; |
| 6899 |
u2 = Math.min(u2, u2 + a2 + c2); |
| 6900 |
let k2 = [...s2[0]][0].length, h2 = e2.slice(0, i2 + s2.index + k2 + u2); |
| 6901 |
if (Math.min(i2, u2) % 2) { |
| 6902 |
let f2 = h2.slice(1, -1); |
| 6903 |
return { type: "em", raw: h2, text: f2, tokens: this.lexer.inlineTokens(f2) }; |
| 6904 |
} |
| 6905 |
let R = h2.slice(2, -2); |
| 6906 |
return { type: "strong", raw: h2, text: R, tokens: this.lexer.inlineTokens(R) }; |
| 6907 |
} |
| 6908 |
} |
| 6909 |
} |
| 6910 |
codespan(e2) { |
| 6911 |
let t3 = this.rules.inline.code.exec(e2); |
| 6912 |
if (t3) { |
| 6913 |
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); |
| 6914 |
return s2 && r2 && (n2 = n2.substring(1, n2.length - 1)), { type: "codespan", raw: t3[0], text: n2 }; |
| 6915 |
} |
| 6916 |
} |
| 6917 |
br(e2) { |
| 6918 |
let t3 = this.rules.inline.br.exec(e2); |
| 6919 |
if (t3) return { type: "br", raw: t3[0] }; |
| 6920 |
} |
| 6921 |
del(e2, t3, n2 = "") { |
| 6922 |
let s2 = this.rules.inline.delLDelim.exec(e2); |
| 6923 |
if (!s2) return; |
| 6924 |
if (!(s2[1] || "") || !n2 || this.rules.inline.punctuation.exec(n2)) { |
| 6925 |
let i2 = [...s2[0]].length - 1, o3, u2, a2 = i2, c2 = this.rules.inline.delRDelim; |
| 6926 |
for (c2.lastIndex = 0, t3 = t3.slice(-1 * e2.length + i2); (s2 = c2.exec(t3)) !== null; ) { |
| 6927 |
if (o3 = s2[1] || s2[2] || s2[3] || s2[4] || s2[5] || s2[6], !o3 || (u2 = [...o3].length, u2 !== i2)) continue; |
| 6928 |
if (s2[3] || s2[4]) { |
| 6929 |
a2 += u2; |
| 6930 |
continue; |
| 6931 |
} |
| 6932 |
if (a2 -= u2, a2 > 0) continue; |
| 6933 |
u2 = Math.min(u2, u2 + a2); |
| 6934 |
let p2 = [...s2[0]][0].length, k2 = e2.slice(0, i2 + s2.index + p2 + u2), h2 = k2.slice(i2, -i2); |
| 6935 |
return { type: "del", raw: k2, text: h2, tokens: this.lexer.inlineTokens(h2) }; |
| 6936 |
} |
| 6937 |
} |
| 6938 |
} |
| 6939 |
autolink(e2) { |
| 6940 |
let t3 = this.rules.inline.autolink.exec(e2); |
| 6941 |
if (t3) { |
| 6942 |
let n2, s2; |
| 6943 |
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 }] }; |
| 6944 |
} |
| 6945 |
} |
| 6946 |
url(e2) { |
| 6947 |
let t3; |
| 6948 |
if (t3 = this.rules.inline.url.exec(e2)) { |
| 6949 |
let n2, s2; |
| 6950 |
if (t3[2] === "@") n2 = t3[0], s2 = "mailto:" + n2; |
| 6951 |
else { |
| 6952 |
let r2; |
| 6953 |
do |
| 6954 |
r2 = t3[0], t3[0] = this.rules.inline._backpedal.exec(t3[0])?.[0] ?? ""; |
| 6955 |
while (r2 !== t3[0]); |
| 6956 |
n2 = t3[0], t3[1] === "www." ? s2 = "http://" + t3[0] : s2 = t3[0]; |
| 6957 |
} |
| 6958 |
return { type: "link", raw: t3[0], text: n2, href: s2, tokens: [{ type: "text", raw: n2, text: n2 }] }; |
| 6959 |
} |
| 6960 |
} |
| 6961 |
inlineText(e2) { |
| 6962 |
let t3 = this.rules.inline.text.exec(e2); |
| 6963 |
if (t3) { |
| 6964 |
let n2 = this.lexer.state.inRawBlock; |
| 6965 |
return { type: "text", raw: t3[0], text: t3[0], escaped: n2 }; |
| 6966 |
} |
| 6967 |
} |
| 6968 |
}; |
| 6969 |
var x2 = class l2 { |
| 6970 |
tokens; |
| 6971 |
options; |
| 6972 |
state; |
| 6973 |
inlineQueue; |
| 6974 |
tokenizer; |
| 6975 |
constructor(e2) { |
| 6976 |
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 }; |
| 6977 |
let t3 = { other: m2, block: B.normal, inline: A.normal }; |
| 6978 |
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; |
| 6979 |
} |
| 6980 |
static get rules() { |
| 6981 |
return { block: B, inline: A }; |
| 6982 |
} |
| 6983 |
static lex(e2, t3) { |
| 6984 |
return new l2(t3).lex(e2); |
| 6985 |
} |
| 6986 |
static lexInline(e2, t3) { |
| 6987 |
return new l2(t3).inlineTokens(e2); |
| 6988 |
} |
| 6989 |
lex(e2) { |
| 6990 |
e2 = e2.replace(m2.carriageReturn, ` |
| 6991 |
`), this.blockTokens(e2, this.tokens); |
| 6992 |
for (let t3 = 0; t3 < this.inlineQueue.length; t3++) { |
| 6993 |
let n2 = this.inlineQueue[t3]; |
| 6994 |
this.inlineTokens(n2.src, n2.tokens); |
| 6995 |
} |
| 6996 |
return this.inlineQueue = [], this.tokens; |
| 6997 |
} |
| 6998 |
blockTokens(e2, t3 = [], n2 = false) { |
| 6999 |
this.tokenizer.lexer = this, this.options.pedantic && (e2 = e2.replace(m2.tabCharGlobal, " ").replace(m2.spaceLine, "")); |
| 7000 |
let s2 = 1 / 0; |
| 7001 |
for (; e2; ) { |
| 7002 |
if (e2.length < s2) s2 = e2.length; |
| 7003 |
else { |
| 7004 |
this.infiniteLoopError(e2.charCodeAt(0)); |
| 7005 |
break; |
| 7006 |
} |
| 7007 |
let r2; |
| 7008 |
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; |
| 7009 |
if (r2 = this.tokenizer.space(e2)) { |
| 7010 |
e2 = e2.substring(r2.raw.length); |
| 7011 |
let o3 = t3.at(-1); |
| 7012 |
r2.raw.length === 1 && o3 !== void 0 ? o3.raw += ` |
| 7013 |
` : t3.push(r2); |
| 7014 |
continue; |
| 7015 |
} |
| 7016 |
if (r2 = this.tokenizer.code(e2)) { |
| 7017 |
e2 = e2.substring(r2.raw.length); |
| 7018 |
let o3 = t3.at(-1); |
| 7019 |
o3?.type === "paragraph" || o3?.type === "text" ? (o3.raw += (o3.raw.endsWith(` |
| 7020 |
`) ? "" : ` |
| 7021 |
`) + r2.raw, o3.text += ` |
| 7022 |
` + r2.text, this.inlineQueue.at(-1).src = o3.text) : t3.push(r2); |
| 7023 |
continue; |
| 7024 |
} |
| 7025 |
if (r2 = this.tokenizer.fences(e2)) { |
| 7026 |
e2 = e2.substring(r2.raw.length), t3.push(r2); |
| 7027 |
continue; |
| 7028 |
} |
| 7029 |
if (r2 = this.tokenizer.heading(e2)) { |
| 7030 |
e2 = e2.substring(r2.raw.length), t3.push(r2); |
| 7031 |
continue; |
| 7032 |
} |
| 7033 |
if (r2 = this.tokenizer.hr(e2)) { |
| 7034 |
e2 = e2.substring(r2.raw.length), t3.push(r2); |
| 7035 |
continue; |
| 7036 |
} |
| 7037 |
if (r2 = this.tokenizer.blockquote(e2)) { |
| 7038 |
e2 = e2.substring(r2.raw.length), t3.push(r2); |
| 7039 |
continue; |
| 7040 |
} |
| 7041 |
if (r2 = this.tokenizer.list(e2)) { |
| 7042 |
e2 = e2.substring(r2.raw.length), t3.push(r2); |
| 7043 |
continue; |
| 7044 |
} |
| 7045 |
if (r2 = this.tokenizer.html(e2)) { |
| 7046 |
e2 = e2.substring(r2.raw.length), t3.push(r2); |
| 7047 |
continue; |
| 7048 |
} |
| 7049 |
if (r2 = this.tokenizer.def(e2)) { |
| 7050 |
e2 = e2.substring(r2.raw.length); |
| 7051 |
let o3 = t3.at(-1); |
| 7052 |
o3?.type === "paragraph" || o3?.type === "text" ? (o3.raw += (o3.raw.endsWith(` |
| 7053 |
`) ? "" : ` |
| 7054 |
`) + r2.raw, o3.text += ` |
| 7055 |
` + 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)); |
| 7056 |
continue; |
| 7057 |
} |
| 7058 |
if (r2 = this.tokenizer.table(e2)) { |
| 7059 |
e2 = e2.substring(r2.raw.length), t3.push(r2); |
| 7060 |
continue; |
| 7061 |
} |
| 7062 |
if (r2 = this.tokenizer.lheading(e2)) { |
| 7063 |
e2 = e2.substring(r2.raw.length), t3.push(r2); |
| 7064 |
continue; |
| 7065 |
} |
| 7066 |
let i2 = e2; |
| 7067 |
if (this.options.extensions?.startBlock) { |
| 7068 |
let o3 = 1 / 0, u2 = e2.slice(1), a2; |
| 7069 |
this.options.extensions.startBlock.forEach((c2) => { |
| 7070 |
a2 = c2.call({ lexer: this }, u2), typeof a2 == "number" && a2 >= 0 && (o3 = Math.min(o3, a2)); |
| 7071 |
}), o3 < 1 / 0 && o3 >= 0 && (i2 = e2.substring(0, o3 + 1)); |
| 7072 |
} |
| 7073 |
if (this.state.top && (r2 = this.tokenizer.paragraph(i2))) { |
| 7074 |
let o3 = t3.at(-1); |
| 7075 |
n2 && o3?.type === "paragraph" ? (o3.raw += (o3.raw.endsWith(` |
| 7076 |
`) ? "" : ` |
| 7077 |
`) + r2.raw, o3.text += ` |
| 7078 |
` + 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); |
| 7079 |
continue; |
| 7080 |
} |
| 7081 |
if (r2 = this.tokenizer.text(e2)) { |
| 7082 |
e2 = e2.substring(r2.raw.length); |
| 7083 |
let o3 = t3.at(-1); |
| 7084 |
o3?.type === "text" ? (o3.raw += (o3.raw.endsWith(` |
| 7085 |
`) ? "" : ` |
| 7086 |
`) + r2.raw, o3.text += ` |
| 7087 |
` + r2.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o3.text) : t3.push(r2); |
| 7088 |
continue; |
| 7089 |
} |
| 7090 |
if (e2) { |
| 7091 |
this.infiniteLoopError(e2.charCodeAt(0)); |
| 7092 |
break; |
| 7093 |
} |
| 7094 |
} |
| 7095 |
return this.state.top = true, t3; |
| 7096 |
} |
| 7097 |
inline(e2, t3 = []) { |
| 7098 |
return this.inlineQueue.push({ src: e2, tokens: t3 }), t3; |
| 7099 |
} |
| 7100 |
inlineTokens(e2, t3 = []) { |
| 7101 |
this.tokenizer.lexer = this; |
| 7102 |
let n2 = e2, s2 = null; |
| 7103 |
if (this.tokens.links) { |
| 7104 |
let a2 = Object.keys(this.tokens.links); |
| 7105 |
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)); |
| 7106 |
} |
| 7107 |
for (; (s2 = this.tokenizer.rules.inline.anyPunctuation.exec(n2)) !== null; ) n2 = n2.slice(0, s2.index) + "++" + n2.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex); |
| 7108 |
let r2; |
| 7109 |
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); |
| 7110 |
n2 = this.options.hooks?.emStrongMask?.call({ lexer: this }, n2) ?? n2; |
| 7111 |
let i2 = false, o3 = "", u2 = 1 / 0; |
| 7112 |
for (; e2; ) { |
| 7113 |
if (e2.length < u2) u2 = e2.length; |
| 7114 |
else { |
| 7115 |
this.infiniteLoopError(e2.charCodeAt(0)); |
| 7116 |
break; |
| 7117 |
} |
| 7118 |
i2 || (o3 = ""), i2 = false; |
| 7119 |
let a2; |
| 7120 |
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; |
| 7121 |
if (a2 = this.tokenizer.escape(e2)) { |
| 7122 |
e2 = e2.substring(a2.raw.length), t3.push(a2); |
| 7123 |
continue; |
| 7124 |
} |
| 7125 |
if (a2 = this.tokenizer.tag(e2)) { |
| 7126 |
e2 = e2.substring(a2.raw.length), t3.push(a2); |
| 7127 |
continue; |
| 7128 |
} |
| 7129 |
if (a2 = this.tokenizer.link(e2)) { |
| 7130 |
e2 = e2.substring(a2.raw.length), t3.push(a2); |
| 7131 |
continue; |
| 7132 |
} |
| 7133 |
if (a2 = this.tokenizer.reflink(e2, this.tokens.links)) { |
| 7134 |
e2 = e2.substring(a2.raw.length); |
| 7135 |
let p2 = t3.at(-1); |
| 7136 |
a2.type === "text" && p2?.type === "text" ? (p2.raw += a2.raw, p2.text += a2.text) : t3.push(a2); |
| 7137 |
continue; |
| 7138 |
} |
| 7139 |
if (a2 = this.tokenizer.emStrong(e2, n2, o3)) { |
| 7140 |
e2 = e2.substring(a2.raw.length), t3.push(a2); |
| 7141 |
continue; |
| 7142 |
} |
| 7143 |
if (a2 = this.tokenizer.codespan(e2)) { |
| 7144 |
e2 = e2.substring(a2.raw.length), t3.push(a2); |
| 7145 |
continue; |
| 7146 |
} |
| 7147 |
if (a2 = this.tokenizer.br(e2)) { |
| 7148 |
e2 = e2.substring(a2.raw.length), t3.push(a2); |
| 7149 |
continue; |
| 7150 |
} |
| 7151 |
if (a2 = this.tokenizer.del(e2, n2, o3)) { |
| 7152 |
e2 = e2.substring(a2.raw.length), t3.push(a2); |
| 7153 |
continue; |
| 7154 |
} |
| 7155 |
if (a2 = this.tokenizer.autolink(e2)) { |
| 7156 |
e2 = e2.substring(a2.raw.length), t3.push(a2); |
| 7157 |
continue; |
| 7158 |
} |
| 7159 |
if (!this.state.inLink && (a2 = this.tokenizer.url(e2))) { |
| 7160 |
e2 = e2.substring(a2.raw.length), t3.push(a2); |
| 7161 |
continue; |
| 7162 |
} |
| 7163 |
let c2 = e2; |
| 7164 |
if (this.options.extensions?.startInline) { |
| 7165 |
let p2 = 1 / 0, k2 = e2.slice(1), h2; |
| 7166 |
this.options.extensions.startInline.forEach((R) => { |
| 7167 |
h2 = R.call({ lexer: this }, k2), typeof h2 == "number" && h2 >= 0 && (p2 = Math.min(p2, h2)); |
| 7168 |
}), p2 < 1 / 0 && p2 >= 0 && (c2 = e2.substring(0, p2 + 1)); |
| 7169 |
} |
| 7170 |
if (a2 = this.tokenizer.inlineText(c2)) { |
| 7171 |
e2 = e2.substring(a2.raw.length), a2.raw.slice(-1) !== "_" && (o3 = a2.raw.slice(-1)), i2 = true; |
| 7172 |
let p2 = t3.at(-1); |
| 7173 |
p2?.type === "text" ? (p2.raw += a2.raw, p2.text += a2.text) : t3.push(a2); |
| 7174 |
continue; |
| 7175 |
} |
| 7176 |
if (e2) { |
| 7177 |
this.infiniteLoopError(e2.charCodeAt(0)); |
| 7178 |
break; |
| 7179 |
} |
| 7180 |
} |
| 7181 |
return t3; |
| 7182 |
} |
| 7183 |
infiniteLoopError(e2) { |
| 7184 |
let t3 = "Infinite loop on byte: " + e2; |
| 7185 |
if (this.options.silent) console.error(t3); |
| 7186 |
else throw new Error(t3); |
| 7187 |
} |
| 7188 |
}; |
| 7189 |
var y2 = class { |
| 7190 |
options; |
| 7191 |
parser; |
| 7192 |
constructor(e2) { |
| 7193 |
this.options = e2 || T; |
| 7194 |
} |
| 7195 |
space(e2) { |
| 7196 |
return ""; |
| 7197 |
} |
| 7198 |
code({ text: e2, lang: t3, escaped: n2 }) { |
| 7199 |
let s2 = (t3 || "").match(m2.notSpaceStart)?.[0], r2 = e2.replace(m2.endingNewline, "") + ` |
| 7200 |
`; |
| 7201 |
return s2 ? '<pre><code class="language-' + O(s2) + '">' + (n2 ? r2 : O(r2, true)) + `</code></pre> |
| 7202 |
` : "<pre><code>" + (n2 ? r2 : O(r2, true)) + `</code></pre> |
| 7203 |
`; |
| 7204 |
} |
| 7205 |
blockquote({ tokens: e2 }) { |
| 7206 |
return `<blockquote> |
| 7207 |
${this.parser.parse(e2)}</blockquote> |
| 7208 |
`; |
| 7209 |
} |
| 7210 |
html({ text: e2 }) { |
| 7211 |
return e2; |
| 7212 |
} |
| 7213 |
def(e2) { |
| 7214 |
return ""; |
| 7215 |
} |
| 7216 |
heading({ tokens: e2, depth: t3 }) { |
| 7217 |
return `<h${t3}>${this.parser.parseInline(e2)}</h${t3}> |
| 7218 |
`; |
| 7219 |
} |
| 7220 |
hr(e2) { |
| 7221 |
return `<hr> |
| 7222 |
`; |
| 7223 |
} |
| 7224 |
list(e2) { |
| 7225 |
let t3 = e2.ordered, n2 = e2.start, s2 = ""; |
| 7226 |
for (let o3 = 0; o3 < e2.items.length; o3++) { |
| 7227 |
let u2 = e2.items[o3]; |
| 7228 |
s2 += this.listitem(u2); |
| 7229 |
} |
| 7230 |
let r2 = t3 ? "ol" : "ul", i2 = t3 && n2 !== 1 ? ' start="' + n2 + '"' : ""; |
| 7231 |
return "<" + r2 + i2 + `> |
| 7232 |
` + s2 + "</" + r2 + `> |
| 7233 |
`; |
| 7234 |
} |
| 7235 |
listitem(e2) { |
| 7236 |
return `<li>${this.parser.parse(e2.tokens)}</li> |
| 7237 |
`; |
| 7238 |
} |
| 7239 |
checkbox({ checked: e2 }) { |
| 7240 |
return "<input " + (e2 ? 'checked="" ' : "") + 'disabled="" type="checkbox"> '; |
| 7241 |
} |
| 7242 |
paragraph({ tokens: e2 }) { |
| 7243 |
return `<p>${this.parser.parseInline(e2)}</p> |
| 7244 |
`; |
| 7245 |
} |
| 7246 |
table(e2) { |
| 7247 |
let t3 = "", n2 = ""; |
| 7248 |
for (let r2 = 0; r2 < e2.header.length; r2++) n2 += this.tablecell(e2.header[r2]); |
| 7249 |
t3 += this.tablerow({ text: n2 }); |
| 7250 |
let s2 = ""; |
| 7251 |
for (let r2 = 0; r2 < e2.rows.length; r2++) { |
| 7252 |
let i2 = e2.rows[r2]; |
| 7253 |
n2 = ""; |
| 7254 |
for (let o3 = 0; o3 < i2.length; o3++) n2 += this.tablecell(i2[o3]); |
| 7255 |
s2 += this.tablerow({ text: n2 }); |
| 7256 |
} |
| 7257 |
return s2 && (s2 = `<tbody>${s2}</tbody>`), `<table> |
| 7258 |
<thead> |
| 7259 |
` + t3 + `</thead> |
| 7260 |
` + s2 + `</table> |
| 7261 |
`; |
| 7262 |
} |
| 7263 |
tablerow({ text: e2 }) { |
| 7264 |
return `<tr> |
| 7265 |
${e2}</tr> |
| 7266 |
`; |
| 7267 |
} |
| 7268 |
tablecell(e2) { |
| 7269 |
let t3 = this.parser.parseInline(e2.tokens), n2 = e2.header ? "th" : "td"; |
| 7270 |
return (e2.align ? `<${n2} align="${e2.align}">` : `<${n2}>`) + t3 + `</${n2}> |
| 7271 |
`; |
| 7272 |
} |
| 7273 |
strong({ tokens: e2 }) { |
| 7274 |
return `<strong>${this.parser.parseInline(e2)}</strong>`; |
| 7275 |
} |
| 7276 |
em({ tokens: e2 }) { |
| 7277 |
return `<em>${this.parser.parseInline(e2)}</em>`; |
| 7278 |
} |
| 7279 |
codespan({ text: e2 }) { |
| 7280 |
return `<code>${O(e2, true)}</code>`; |
| 7281 |
} |
| 7282 |
br(e2) { |
| 7283 |
return "<br>"; |
| 7284 |
} |
| 7285 |
del({ tokens: e2 }) { |
| 7286 |
return `<del>${this.parser.parseInline(e2)}</del>`; |
| 7287 |
} |
| 7288 |
link({ href: e2, title: t3, tokens: n2 }) { |
| 7289 |
let s2 = this.parser.parseInline(n2), r2 = J(e2); |
| 7290 |
if (r2 === null) return s2; |
| 7291 |
e2 = r2; |
| 7292 |
let i2 = '<a href="' + e2 + '"'; |
| 7293 |
return t3 && (i2 += ' title="' + O(t3) + '"'), i2 += ">" + s2 + "</a>", i2; |
| 7294 |
} |
| 7295 |
image({ href: e2, title: t3, text: n2, tokens: s2 }) { |
| 7296 |
s2 && (n2 = this.parser.parseInline(s2, this.parser.textRenderer)); |
| 7297 |
let r2 = J(e2); |
| 7298 |
if (r2 === null) return O(n2); |
| 7299 |
e2 = r2; |
| 7300 |
let i2 = `<img src="${e2}" alt="${O(n2)}"`; |
| 7301 |
return t3 && (i2 += ` title="${O(t3)}"`), i2 += ">", i2; |
| 7302 |
} |
| 7303 |
text(e2) { |
| 7304 |
return "tokens" in e2 && e2.tokens ? this.parser.parseInline(e2.tokens) : "escaped" in e2 && e2.escaped ? e2.text : O(e2.text); |
| 7305 |
} |
| 7306 |
}; |
| 7307 |
var L = class { |
| 7308 |
strong({ text: e2 }) { |
| 7309 |
return e2; |
| 7310 |
} |
| 7311 |
em({ text: e2 }) { |
| 7312 |
return e2; |
| 7313 |
} |
| 7314 |
codespan({ text: e2 }) { |
| 7315 |
return e2; |
| 7316 |
} |
| 7317 |
del({ text: e2 }) { |
| 7318 |
return e2; |
| 7319 |
} |
| 7320 |
html({ text: e2 }) { |
| 7321 |
return e2; |
| 7322 |
} |
| 7323 |
text({ text: e2 }) { |
| 7324 |
return e2; |
| 7325 |
} |
| 7326 |
link({ text: e2 }) { |
| 7327 |
return "" + e2; |
| 7328 |
} |
| 7329 |
image({ text: e2 }) { |
| 7330 |
return "" + e2; |
| 7331 |
} |
| 7332 |
br() { |
| 7333 |
return ""; |
| 7334 |
} |
| 7335 |
checkbox({ raw: e2 }) { |
| 7336 |
return e2; |
| 7337 |
} |
| 7338 |
}; |
| 7339 |
var b2 = class l3 { |
| 7340 |
options; |
| 7341 |
renderer; |
| 7342 |
textRenderer; |
| 7343 |
constructor(e2) { |
| 7344 |
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(); |
| 7345 |
} |
| 7346 |
static parse(e2, t3) { |
| 7347 |
return new l3(t3).parse(e2); |
| 7348 |
} |
| 7349 |
static parseInline(e2, t3) { |
| 7350 |
return new l3(t3).parseInline(e2); |
| 7351 |
} |
| 7352 |
parse(e2) { |
| 7353 |
this.renderer.parser = this; |
| 7354 |
let t3 = ""; |
| 7355 |
for (let n2 = 0; n2 < e2.length; n2++) { |
| 7356 |
let s2 = e2[n2]; |
| 7357 |
if (this.options.extensions?.renderers?.[s2.type]) { |
| 7358 |
let i2 = s2, o3 = this.options.extensions.renderers[i2.type].call({ parser: this }, i2); |
| 7359 |
if (o3 !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(i2.type)) { |
| 7360 |
t3 += o3 || ""; |
| 7361 |
continue; |
| 7362 |
} |
| 7363 |
} |
| 7364 |
let r2 = s2; |
| 7365 |
switch (r2.type) { |
| 7366 |
case "space": { |
| 7367 |
t3 += this.renderer.space(r2); |
| 7368 |
break; |
| 7369 |
} |
| 7370 |
case "hr": { |
| 7371 |
t3 += this.renderer.hr(r2); |
| 7372 |
break; |
| 7373 |
} |
| 7374 |
case "heading": { |
| 7375 |
t3 += this.renderer.heading(r2); |
| 7376 |
break; |
| 7377 |
} |
| 7378 |
case "code": { |
| 7379 |
t3 += this.renderer.code(r2); |
| 7380 |
break; |
| 7381 |
} |
| 7382 |
case "table": { |
| 7383 |
t3 += this.renderer.table(r2); |
| 7384 |
break; |
| 7385 |
} |
| 7386 |
case "blockquote": { |
| 7387 |
t3 += this.renderer.blockquote(r2); |
| 7388 |
break; |
| 7389 |
} |
| 7390 |
case "list": { |
| 7391 |
t3 += this.renderer.list(r2); |
| 7392 |
break; |
| 7393 |
} |
| 7394 |
case "checkbox": { |
| 7395 |
t3 += this.renderer.checkbox(r2); |
| 7396 |
break; |
| 7397 |
} |
| 7398 |
case "html": { |
| 7399 |
t3 += this.renderer.html(r2); |
| 7400 |
break; |
| 7401 |
} |
| 7402 |
case "def": { |
| 7403 |
t3 += this.renderer.def(r2); |
| 7404 |
break; |
| 7405 |
} |
| 7406 |
case "paragraph": { |
| 7407 |
t3 += this.renderer.paragraph(r2); |
| 7408 |
break; |
| 7409 |
} |
| 7410 |
case "text": { |
| 7411 |
t3 += this.renderer.text(r2); |
| 7412 |
break; |
| 7413 |
} |
| 7414 |
default: { |
| 7415 |
let i2 = 'Token with "' + r2.type + '" type was not found.'; |
| 7416 |
if (this.options.silent) return console.error(i2), ""; |
| 7417 |
throw new Error(i2); |
| 7418 |
} |
| 7419 |
} |
| 7420 |
} |
| 7421 |
return t3; |
| 7422 |
} |
| 7423 |
parseInline(e2, t3 = this.renderer) { |
| 7424 |
this.renderer.parser = this; |
| 7425 |
let n2 = ""; |
| 7426 |
for (let s2 = 0; s2 < e2.length; s2++) { |
| 7427 |
let r2 = e2[s2]; |
| 7428 |
if (this.options.extensions?.renderers?.[r2.type]) { |
| 7429 |
let o3 = this.options.extensions.renderers[r2.type].call({ parser: this }, r2); |
| 7430 |
if (o3 !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r2.type)) { |
| 7431 |
n2 += o3 || ""; |
| 7432 |
continue; |
| 7433 |
} |
| 7434 |
} |
| 7435 |
let i2 = r2; |
| 7436 |
switch (i2.type) { |
| 7437 |
case "escape": { |
| 7438 |
n2 += t3.text(i2); |
| 7439 |
break; |
| 7440 |
} |
| 7441 |
case "html": { |
| 7442 |
n2 += t3.html(i2); |
| 7443 |
break; |
| 7444 |
} |
| 7445 |
case "link": { |
| 7446 |
n2 += t3.link(i2); |
| 7447 |
break; |
| 7448 |
} |
| 7449 |
case "image": { |
| 7450 |
n2 += t3.image(i2); |
| 7451 |
break; |
| 7452 |
} |
| 7453 |
case "checkbox": { |
| 7454 |
n2 += t3.checkbox(i2); |
| 7455 |
break; |
| 7456 |
} |
| 7457 |
case "strong": { |
| 7458 |
n2 += t3.strong(i2); |
| 7459 |
break; |
| 7460 |
} |
| 7461 |
case "em": { |
| 7462 |
n2 += t3.em(i2); |
| 7463 |
break; |
| 7464 |
} |
| 7465 |
case "codespan": { |
| 7466 |
n2 += t3.codespan(i2); |
| 7467 |
break; |
| 7468 |
} |
| 7469 |
case "br": { |
| 7470 |
n2 += t3.br(i2); |
| 7471 |
break; |
| 7472 |
} |
| 7473 |
case "del": { |
| 7474 |
n2 += t3.del(i2); |
| 7475 |
break; |
| 7476 |
} |
| 7477 |
case "text": { |
| 7478 |
n2 += t3.text(i2); |
| 7479 |
break; |
| 7480 |
} |
| 7481 |
default: { |
| 7482 |
let o3 = 'Token with "' + i2.type + '" type was not found.'; |
| 7483 |
if (this.options.silent) return console.error(o3), ""; |
| 7484 |
throw new Error(o3); |
| 7485 |
} |
| 7486 |
} |
| 7487 |
} |
| 7488 |
return n2; |
| 7489 |
} |
| 7490 |
}; |
| 7491 |
var P = class { |
| 7492 |
options; |
| 7493 |
block; |
| 7494 |
constructor(e2) { |
| 7495 |
this.options = e2 || T; |
| 7496 |
} |
| 7497 |
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]); |
| 7498 |
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]); |
| 7499 |
preprocess(e2) { |
| 7500 |
return e2; |
| 7501 |
} |
| 7502 |
postprocess(e2) { |
| 7503 |
return e2; |
| 7504 |
} |
| 7505 |
processAllTokens(e2) { |
| 7506 |
return e2; |
| 7507 |
} |
| 7508 |
emStrongMask(e2) { |
| 7509 |
return e2; |
| 7510 |
} |
| 7511 |
provideLexer(e2 = this.block) { |
| 7512 |
return e2 ? x2.lex : x2.lexInline; |
| 7513 |
} |
| 7514 |
provideParser(e2 = this.block) { |
| 7515 |
return e2 ? b2.parse : b2.parseInline; |
| 7516 |
} |
| 7517 |
}; |
| 7518 |
var D = class { |
| 7519 |
defaults = z(); |
| 7520 |
options = this.setOptions; |
| 7521 |
parse = this.parseMarkdown(true); |
| 7522 |
parseInline = this.parseMarkdown(false); |
| 7523 |
Parser = b2; |
| 7524 |
Renderer = y2; |
| 7525 |
TextRenderer = L; |
| 7526 |
Lexer = x2; |
| 7527 |
Tokenizer = w2; |
| 7528 |
Hooks = P; |
| 7529 |
constructor(...e2) { |
| 7530 |
this.use(...e2); |
| 7531 |
} |
| 7532 |
walkTokens(e2, t3) { |
| 7533 |
let n2 = []; |
| 7534 |
for (let s2 of e2) switch (n2 = n2.concat(t3.call(this, s2)), s2.type) { |
| 7535 |
case "table": { |
| 7536 |
let r2 = s2; |
| 7537 |
for (let i2 of r2.header) n2 = n2.concat(this.walkTokens(i2.tokens, t3)); |
| 7538 |
for (let i2 of r2.rows) for (let o3 of i2) n2 = n2.concat(this.walkTokens(o3.tokens, t3)); |
| 7539 |
break; |
| 7540 |
} |
| 7541 |
case "list": { |
| 7542 |
let r2 = s2; |
| 7543 |
n2 = n2.concat(this.walkTokens(r2.items, t3)); |
| 7544 |
break; |
| 7545 |
} |
| 7546 |
default: { |
| 7547 |
let r2 = s2; |
| 7548 |
this.defaults.extensions?.childTokens?.[r2.type] ? this.defaults.extensions.childTokens[r2.type].forEach((i2) => { |
| 7549 |
let o3 = r2[i2].flat(1 / 0); |
| 7550 |
n2 = n2.concat(this.walkTokens(o3, t3)); |
| 7551 |
}) : r2.tokens && (n2 = n2.concat(this.walkTokens(r2.tokens, t3))); |
| 7552 |
} |
| 7553 |
} |
| 7554 |
return n2; |
| 7555 |
} |
| 7556 |
use(...e2) { |
| 7557 |
let t3 = this.defaults.extensions || { renderers: {}, childTokens: {} }; |
| 7558 |
return e2.forEach((n2) => { |
| 7559 |
let s2 = { ...n2 }; |
| 7560 |
if (s2.async = this.defaults.async || s2.async || false, n2.extensions && (n2.extensions.forEach((r2) => { |
| 7561 |
if (!r2.name) throw new Error("extension name required"); |
| 7562 |
if ("renderer" in r2) { |
| 7563 |
let i2 = t3.renderers[r2.name]; |
| 7564 |
i2 ? t3.renderers[r2.name] = function(...o3) { |
| 7565 |
let u2 = r2.renderer.apply(this, o3); |
| 7566 |
return u2 === false && (u2 = i2.apply(this, o3)), u2; |
| 7567 |
} : t3.renderers[r2.name] = r2.renderer; |
| 7568 |
} |
| 7569 |
if ("tokenizer" in r2) { |
| 7570 |
if (!r2.level || r2.level !== "block" && r2.level !== "inline") throw new Error("extension level must be 'block' or 'inline'"); |
| 7571 |
let i2 = t3[r2.level]; |
| 7572 |
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])); |
| 7573 |
} |
| 7574 |
"childTokens" in r2 && r2.childTokens && (t3.childTokens[r2.name] = r2.childTokens); |
| 7575 |
}), s2.extensions = t3), n2.renderer) { |
| 7576 |
let r2 = this.defaults.renderer || new y2(this.defaults); |
| 7577 |
for (let i2 in n2.renderer) { |
| 7578 |
if (!(i2 in r2)) throw new Error(`renderer '${i2}' does not exist`); |
| 7579 |
if (["options", "parser"].includes(i2)) continue; |
| 7580 |
let o3 = i2, u2 = n2.renderer[o3], a2 = r2[o3]; |
| 7581 |
r2[o3] = (...c2) => { |
| 7582 |
let p2 = u2.apply(r2, c2); |
| 7583 |
return p2 === false && (p2 = a2.apply(r2, c2)), p2 || ""; |
| 7584 |
}; |
| 7585 |
} |
| 7586 |
s2.renderer = r2; |
| 7587 |
} |
| 7588 |
if (n2.tokenizer) { |
| 7589 |
let r2 = this.defaults.tokenizer || new w2(this.defaults); |
| 7590 |
for (let i2 in n2.tokenizer) { |
| 7591 |
if (!(i2 in r2)) throw new Error(`tokenizer '${i2}' does not exist`); |
| 7592 |
if (["options", "rules", "lexer"].includes(i2)) continue; |
| 7593 |
let o3 = i2, u2 = n2.tokenizer[o3], a2 = r2[o3]; |
| 7594 |
r2[o3] = (...c2) => { |
| 7595 |
let p2 = u2.apply(r2, c2); |
| 7596 |
return p2 === false && (p2 = a2.apply(r2, c2)), p2; |
| 7597 |
}; |
| 7598 |
} |
| 7599 |
s2.tokenizer = r2; |
| 7600 |
} |
| 7601 |
if (n2.hooks) { |
| 7602 |
let r2 = this.defaults.hooks || new P(); |
| 7603 |
for (let i2 in n2.hooks) { |
| 7604 |
if (!(i2 in r2)) throw new Error(`hook '${i2}' does not exist`); |
| 7605 |
if (["options", "block"].includes(i2)) continue; |
| 7606 |
let o3 = i2, u2 = n2.hooks[o3], a2 = r2[o3]; |
| 7607 |
P.passThroughHooks.has(i2) ? r2[o3] = (c2) => { |
| 7608 |
if (this.defaults.async && P.passThroughHooksRespectAsync.has(i2)) return (async () => { |
| 7609 |
let k2 = await u2.call(r2, c2); |
| 7610 |
return a2.call(r2, k2); |
| 7611 |
})(); |
| 7612 |
let p2 = u2.call(r2, c2); |
| 7613 |
return a2.call(r2, p2); |
| 7614 |
} : r2[o3] = (...c2) => { |
| 7615 |
if (this.defaults.async) return (async () => { |
| 7616 |
let k2 = await u2.apply(r2, c2); |
| 7617 |
return k2 === false && (k2 = await a2.apply(r2, c2)), k2; |
| 7618 |
})(); |
| 7619 |
let p2 = u2.apply(r2, c2); |
| 7620 |
return p2 === false && (p2 = a2.apply(r2, c2)), p2; |
| 7621 |
}; |
| 7622 |
} |
| 7623 |
s2.hooks = r2; |
| 7624 |
} |
| 7625 |
if (n2.walkTokens) { |
| 7626 |
let r2 = this.defaults.walkTokens, i2 = n2.walkTokens; |
| 7627 |
s2.walkTokens = function(o3) { |
| 7628 |
let u2 = []; |
| 7629 |
return u2.push(i2.call(this, o3)), r2 && (u2 = u2.concat(r2.call(this, o3))), u2; |
| 7630 |
}; |
| 7631 |
} |
| 7632 |
this.defaults = { ...this.defaults, ...s2 }; |
| 7633 |
}), this; |
| 7634 |
} |
| 7635 |
setOptions(e2) { |
| 7636 |
return this.defaults = { ...this.defaults, ...e2 }, this; |
| 7637 |
} |
| 7638 |
lexer(e2, t3) { |
| 7639 |
return x2.lex(e2, t3 ?? this.defaults); |
| 7640 |
} |
| 7641 |
parser(e2, t3) { |
| 7642 |
return b2.parse(e2, t3 ?? this.defaults); |
| 7643 |
} |
| 7644 |
parseMarkdown(e2) { |
| 7645 |
return (n2, s2) => { |
| 7646 |
let r2 = { ...s2 }, i2 = { ...this.defaults, ...r2 }, o3 = this.onError(!!i2.silent, !!i2.async); |
| 7647 |
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.")); |
| 7648 |
if (typeof n2 > "u" || n2 === null) return o3(new Error("marked(): input parameter is undefined or null")); |
| 7649 |
if (typeof n2 != "string") return o3(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n2) + ", string expected")); |
| 7650 |
if (i2.hooks && (i2.hooks.options = i2, i2.hooks.block = e2), i2.async) return (async () => { |
| 7651 |
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; |
| 7652 |
i2.walkTokens && await Promise.all(this.walkTokens(p2, i2.walkTokens)); |
| 7653 |
let h2 = await (i2.hooks ? await i2.hooks.provideParser(e2) : e2 ? b2.parse : b2.parseInline)(p2, i2); |
| 7654 |
return i2.hooks ? await i2.hooks.postprocess(h2) : h2; |
| 7655 |
})().catch(o3); |
| 7656 |
try { |
| 7657 |
i2.hooks && (n2 = i2.hooks.preprocess(n2)); |
| 7658 |
let a2 = (i2.hooks ? i2.hooks.provideLexer(e2) : e2 ? x2.lex : x2.lexInline)(n2, i2); |
| 7659 |
i2.hooks && (a2 = i2.hooks.processAllTokens(a2)), i2.walkTokens && this.walkTokens(a2, i2.walkTokens); |
| 7660 |
let p2 = (i2.hooks ? i2.hooks.provideParser(e2) : e2 ? b2.parse : b2.parseInline)(a2, i2); |
| 7661 |
return i2.hooks && (p2 = i2.hooks.postprocess(p2)), p2; |
| 7662 |
} catch (u2) { |
| 7663 |
return o3(u2); |
| 7664 |
} |
| 7665 |
}; |
| 7666 |
} |
| 7667 |
onError(e2, t3) { |
| 7668 |
return (n2) => { |
| 7669 |
if (n2.message += ` |
| 7670 |
Please report this to https://github.com/markedjs/marked.`, e2) { |
| 7671 |
let s2 = "<p>An error occurred:</p><pre>" + O(n2.message + "", true) + "</pre>"; |
| 7672 |
return t3 ? Promise.resolve(s2) : s2; |
| 7673 |
} |
| 7674 |
if (t3) return Promise.reject(n2); |
| 7675 |
throw n2; |
| 7676 |
}; |
| 7677 |
} |
| 7678 |
}; |
| 7679 |
var M2 = new D(); |
| 7680 |
function g2(l4, e2) { |
| 7681 |
return M2.parse(l4, e2); |
| 7682 |
} |
| 7683 |
g2.options = g2.setOptions = function(l4) { |
| 7684 |
return M2.setOptions(l4), g2.defaults = M2.defaults, G(g2.defaults), g2; |
| 7685 |
}; |
| 7686 |
g2.getDefaults = z; |
| 7687 |
g2.defaults = T; |
| 7688 |
g2.use = function(...l4) { |
| 7689 |
return M2.use(...l4), g2.defaults = M2.defaults, G(g2.defaults), g2; |
| 7690 |
}; |
| 7691 |
g2.walkTokens = function(l4, e2) { |
| 7692 |
return M2.walkTokens(l4, e2); |
| 7693 |
}; |
| 7694 |
g2.parseInline = M2.parseInline; |
| 7695 |
g2.Parser = b2; |
| 7696 |
g2.parser = b2.parse; |
| 7697 |
g2.Renderer = y2; |
| 7698 |
g2.TextRenderer = L; |
| 7699 |
g2.Lexer = x2; |
| 7700 |
g2.lexer = x2.lex; |
| 7701 |
g2.Tokenizer = w2; |
| 7702 |
g2.Hooks = P; |
| 7703 |
g2.parse = g2; |
| 7704 |
var jt = g2.options; |
| 7705 |
var Ft = g2.setOptions; |
| 7706 |
var Ut = g2.use; |
| 7707 |
var Kt = g2.walkTokens; |
| 7708 |
var Wt = g2.parseInline; |
| 7709 |
var Jt = b2.parse; |
| 7710 |
var Vt = x2.lex; |
| 7711 |
|
| 7712 |
// packages/blocks/build-module/api/raw-handling/markdown-converter.mjs |
| 7713 |
function escapeBodyText(value) { |
| 7714 |
return value.replace(/&(?!#?\w+;)/g, "&").replace(/</g, "<").replace(/>/g, ">"); |
| 7715 |
} |
| 7716 |
var converter = new D({ |
| 7717 |
gfm: true, |
| 7718 |
breaks: true, |
| 7719 |
renderer: { |
| 7720 |
// Match showdown's `omitExtraWLInCodeBlocks`: marked appends `\n` |
| 7721 |
// before `</code>`, which leaks into the Code block's content as a |
| 7722 |
// trailing blank line. |
| 7723 |
code({ text: text2, lang }) { |
| 7724 |
const language = (lang || "").match(/^\S*/)?.[0]; |
| 7725 |
const cls = language ? ` class="${language} language-${language}"` : ""; |
| 7726 |
return `<pre><code${cls}>${escapeBodyText( |
| 7727 |
text2 |
| 7728 |
)}</code></pre>`; |
| 7729 |
}, |
| 7730 |
text(token) { |
| 7731 |
if ("tokens" in token && token.tokens || "escaped" in token && token.escaped) { |
| 7732 |
return false; |
| 7733 |
} |
| 7734 |
return escapeBodyText(token.text); |
| 7735 |
} |
| 7736 |
} |
| 7737 |
}); |
| 7738 |
function slackMarkdownVariantCorrector(text2) { |
| 7739 |
return text2.replace( |
| 7740 |
/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, |
| 7741 |
(match, p1, p2, p3) => `${p1} |
| 7742 |
${p2} |
| 7743 |
${p3}` |
| 7744 |
); |
| 7745 |
} |
| 7746 |
function bulletsToAsterisks(text2) { |
| 7747 |
return text2.replace(/(^|\n)•( +)/g, "$1*$2"); |
| 7748 |
} |
| 7749 |
function escapeSingleLineOrderedListMarker(text2) { |
| 7750 |
if (text2.includes("\n")) { |
| 7751 |
return text2; |
| 7752 |
} |
| 7753 |
return text2.replace(/^(\d+)\.(\s)/, "$1\\.$2"); |
| 7754 |
} |
| 7755 |
var correctors = [ |
| 7756 |
escapeSingleLineOrderedListMarker, |
| 7757 |
bulletsToAsterisks, |
| 7758 |
slackMarkdownVariantCorrector |
| 7759 |
]; |
| 7760 |
function markdownConverter(text2) { |
| 7761 |
return converter.parse( |
| 7762 |
correctors.reduce( |
| 7763 |
(current, corrector) => corrector(current), |
| 7764 |
text2 |
| 7765 |
), |
| 7766 |
{ async: false } |
| 7767 |
); |
| 7768 |
} |
| 7769 |
|
| 7770 |
// packages/blocks/build-module/api/raw-handling/iframe-remover.mjs |
| 7771 |
function iframeRemover(iframe) { |
| 7772 |
if (iframe.nodeName === "IFRAME") { |
| 7773 |
const node = iframe; |
| 7774 |
const text2 = node.ownerDocument.createTextNode(node.src); |
| 7775 |
node.parentNode.replaceChild(text2, node); |
| 7776 |
} |
| 7777 |
} |
| 7778 |
|
| 7779 |
// packages/blocks/build-module/api/raw-handling/google-docs-uid-remover.mjs |
| 7780 |
var import_dom10 = __toESM(require_dom(), 1); |
| 7781 |
function googleDocsUIdRemover(node) { |
| 7782 |
const el = node; |
| 7783 |
if (!el.id || el.id.indexOf("docs-internal-guid-") !== 0) { |
| 7784 |
return; |
| 7785 |
} |
| 7786 |
if (el.tagName === "B") { |
| 7787 |
(0, import_dom10.unwrap)(node); |
| 7788 |
} else { |
| 7789 |
el.removeAttribute("id"); |
| 7790 |
} |
| 7791 |
} |
| 7792 |
|
| 7793 |
// packages/blocks/build-module/api/raw-handling/html-formatting-remover.mjs |
| 7794 |
function isFormattingSpace(character) { |
| 7795 |
return character === " " || character === "\r" || character === "\n" || character === " "; |
| 7796 |
} |
| 7797 |
function htmlFormattingRemover(node) { |
| 7798 |
if (node.nodeType !== node.TEXT_NODE) { |
| 7799 |
return; |
| 7800 |
} |
| 7801 |
let parent = node; |
| 7802 |
while (parent = parent.parentNode) { |
| 7803 |
if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === "PRE") { |
| 7804 |
return; |
| 7805 |
} |
| 7806 |
} |
| 7807 |
const textNode = node; |
| 7808 |
let newData = textNode.data.replace(/[ \r\n\t]+/g, " "); |
| 7809 |
if (newData[0] === " ") { |
| 7810 |
const previousSibling = getSibling(node, "previous"); |
| 7811 |
if (!previousSibling || previousSibling.nodeName === "BR" || previousSibling.textContent.slice(-1) === " ") { |
| 7812 |
newData = newData.slice(1); |
| 7813 |
} |
| 7814 |
} |
| 7815 |
if (newData[newData.length - 1] === " ") { |
| 7816 |
const nextSibling = getSibling(node, "next"); |
| 7817 |
if (!nextSibling || nextSibling.nodeName === "BR" || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) { |
| 7818 |
newData = newData.slice(0, -1); |
| 7819 |
} |
| 7820 |
} |
| 7821 |
if (!newData) { |
| 7822 |
node.parentNode.removeChild(node); |
| 7823 |
} else { |
| 7824 |
textNode.data = newData; |
| 7825 |
} |
| 7826 |
} |
| 7827 |
|
| 7828 |
// packages/blocks/build-module/api/raw-handling/format-space-corrector.mjs |
| 7829 |
var import_dom11 = __toESM(require_dom(), 1); |
| 7830 |
function moveEdgeSpace(node, doc, isLeading) { |
| 7831 |
const child = isLeading ? node.firstChild : node.lastChild; |
| 7832 |
if (!child || child.nodeType !== node.TEXT_NODE) { |
| 7833 |
return; |
| 7834 |
} |
| 7835 |
const text2 = child; |
| 7836 |
const edgeIndex = isLeading ? 0 : text2.data.length - 1; |
| 7837 |
if (text2.data[edgeIndex] !== " ") { |
| 7838 |
return; |
| 7839 |
} |
| 7840 |
text2.data = isLeading ? text2.data.slice(1) : text2.data.slice(0, -1); |
| 7841 |
if (!text2.data) { |
| 7842 |
node.removeChild(text2); |
| 7843 |
} |
| 7844 |
node.parentNode.insertBefore( |
| 7845 |
doc.createTextNode(" "), |
| 7846 |
isLeading ? node : node.nextSibling |
| 7847 |
); |
| 7848 |
} |
| 7849 |
function formatSpaceCorrector(node, doc) { |
| 7850 |
if (node.nodeType !== node.ELEMENT_NODE || !(0, import_dom11.isPhrasingContent)(node)) { |
| 7851 |
return; |
| 7852 |
} |
| 7853 |
moveEdgeSpace(node, doc, true); |
| 7854 |
moveEdgeSpace(node, doc, false); |
| 7855 |
} |
| 7856 |
|
| 7857 |
// packages/blocks/build-module/api/raw-handling/br-remover.mjs |
| 7858 |
function brRemover(node) { |
| 7859 |
if (node.nodeName !== "BR") { |
| 7860 |
return; |
| 7861 |
} |
| 7862 |
if (getSibling(node, "next")) { |
| 7863 |
return; |
| 7864 |
} |
| 7865 |
node.parentNode.removeChild(node); |
| 7866 |
} |
| 7867 |
|
| 7868 |
// packages/blocks/build-module/api/raw-handling/empty-paragraph-remover.mjs |
| 7869 |
function emptyParagraphRemover(node) { |
| 7870 |
if (node.nodeName !== "P") { |
| 7871 |
return; |
| 7872 |
} |
| 7873 |
if (node.hasChildNodes()) { |
| 7874 |
return; |
| 7875 |
} |
| 7876 |
node.parentNode.removeChild(node); |
| 7877 |
} |
| 7878 |
|
| 7879 |
// packages/blocks/build-module/api/raw-handling/slack-paragraph-corrector.mjs |
| 7880 |
function slackParagraphCorrector(node) { |
| 7881 |
if (node.nodeName !== "SPAN") { |
| 7882 |
return; |
| 7883 |
} |
| 7884 |
if (node.getAttribute("data-stringify-type") !== "paragraph-break") { |
| 7885 |
return; |
| 7886 |
} |
| 7887 |
const parentNode = node.parentNode; |
| 7888 |
parentNode.insertBefore(node.ownerDocument.createElement("br"), node); |
| 7889 |
parentNode.insertBefore(node.ownerDocument.createElement("br"), node); |
| 7890 |
parentNode.removeChild(node); |
| 7891 |
} |
| 7892 |
|
| 7893 |
// packages/blocks/build-module/api/raw-handling/latex-to-math.mjs |
| 7894 |
function isLatexMathMode(text2) { |
| 7895 |
const lettersRegex = /[\p{L}\s]+/gu; |
| 7896 |
let match; |
| 7897 |
while (match = lettersRegex.exec(text2)) { |
| 7898 |
if (text2[match.index - 1] === "{") { |
| 7899 |
continue; |
| 7900 |
} |
| 7901 |
let sequence = match[0]; |
| 7902 |
if (text2[match.index - 1] === "\\") { |
| 7903 |
sequence = sequence.replace(/^[a-zA-Z]+/, ""); |
| 7904 |
} |
| 7905 |
if (sequence.length < 6) { |
| 7906 |
continue; |
| 7907 |
} |
| 7908 |
return false; |
| 7909 |
} |
| 7910 |
if (/\\[a-zA-Z]+\s*\{/g.test(text2)) { |
| 7911 |
return true; |
| 7912 |
} |
| 7913 |
const softClues = [ |
| 7914 |
(t3) => t3.includes("^") && !t3.startsWith("^"), |
| 7915 |
(t3) => ["=", "+", "-", "/", "*"].some( |
| 7916 |
(operator) => t3.includes(operator) |
| 7917 |
), |
| 7918 |
(t3) => /\\[a-zA-Z]+/g.test(t3) |
| 7919 |
]; |
| 7920 |
if (softClues.filter((clue) => clue(text2)).length >= 2) { |
| 7921 |
return true; |
| 7922 |
} |
| 7923 |
return false; |
| 7924 |
} |
| 7925 |
|
| 7926 |
// packages/blocks/build-module/api/raw-handling/heading-transformer.mjs |
| 7927 |
function headingTransformer(node) { |
| 7928 |
if (node.nodeType !== node.ELEMENT_NODE) { |
| 7929 |
return; |
| 7930 |
} |
| 7931 |
const element = node; |
| 7932 |
if (element.tagName === "P" && element.getAttribute("role") === "heading" && element.hasAttribute("aria-level")) { |
| 7933 |
const level = parseInt(element.getAttribute("aria-level"), 10); |
| 7934 |
if (level >= 1 && level <= 6) { |
| 7935 |
const headingTag = `H${level}`; |
| 7936 |
const newHeading = element.ownerDocument.createElement(headingTag); |
| 7937 |
Array.from(element.attributes).forEach((attr2) => { |
| 7938 |
if (attr2.name !== "role" && attr2.name !== "aria-level") { |
| 7939 |
newHeading.setAttribute(attr2.name, attr2.value); |
| 7940 |
} |
| 7941 |
}); |
| 7942 |
while (element.firstChild) { |
| 7943 |
newHeading.appendChild(element.firstChild); |
| 7944 |
} |
| 7945 |
element.parentNode.replaceChild(newHeading, element); |
| 7946 |
} |
| 7947 |
} |
| 7948 |
} |
| 7949 |
|
| 7950 |
// packages/blocks/build-module/api/raw-handling/paste-handler.mjs |
| 7951 |
var log = (...args) => window?.console?.log?.(...args); |
| 7952 |
function filterInlineHTML(HTML) { |
| 7953 |
HTML = deepFilterHTML(HTML, [ |
| 7954 |
headRemover, |
| 7955 |
googleDocsUIdRemover, |
| 7956 |
msListIgnore, |
| 7957 |
phrasingContentReducer, |
| 7958 |
commentRemover |
| 7959 |
]); |
| 7960 |
HTML = (0, import_dom12.removeInvalidHTML)( |
| 7961 |
HTML, |
| 7962 |
(0, import_dom12.getPhrasingContentSchema)("paste"), |
| 7963 |
true |
| 7964 |
); |
| 7965 |
HTML = deepFilterHTML(HTML, [ |
| 7966 |
htmlFormattingRemover, |
| 7967 |
formatSpaceCorrector, |
| 7968 |
brRemover |
| 7969 |
]); |
| 7970 |
log("Processed inline HTML:\n\n", HTML); |
| 7971 |
return HTML; |
| 7972 |
} |
| 7973 |
function pasteHandler({ |
| 7974 |
HTML = "", |
| 7975 |
plainText = "", |
| 7976 |
mode = "AUTO", |
| 7977 |
tagName |
| 7978 |
}) { |
| 7979 |
log("Received HTML (pasteHandler):\n\n", HTML); |
| 7980 |
log("Received plain text (pasteHandler):\n\n", plainText); |
| 7981 |
HTML = HTML.replace(/<meta[^>]+>/g, ""); |
| 7982 |
HTML = HTML.replace( |
| 7983 |
/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, |
| 7984 |
"" |
| 7985 |
); |
| 7986 |
HTML = HTML.replace( |
| 7987 |
/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, |
| 7988 |
"" |
| 7989 |
); |
| 7990 |
if (mode !== "INLINE") { |
| 7991 |
const content = HTML ? HTML : plainText; |
| 7992 |
if (content.indexOf("<!-- wp:") !== -1) { |
| 7993 |
const parseResult = parse2(content); |
| 7994 |
const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === "core/freeform"; |
| 7995 |
if (!isSingleFreeFormBlock) { |
| 7996 |
return parseResult; |
| 7997 |
} |
| 7998 |
} |
| 7999 |
} |
| 8000 |
HTML = HTML.normalize(); |
| 8001 |
HTML = deepFilterHTML(HTML, [slackParagraphCorrector]); |
| 8002 |
const isPlainText = plainText && (!HTML || isPlain(HTML)); |
| 8003 |
if (isPlainText && isLatexMathMode(plainText)) { |
| 8004 |
return [createBlock("core/math", { latex: plainText })]; |
| 8005 |
} |
| 8006 |
if (isPlainText) { |
| 8007 |
HTML = plainText; |
| 8008 |
if (!/^\s+$/.test(plainText)) { |
| 8009 |
HTML = markdownConverter(HTML); |
| 8010 |
} |
| 8011 |
} |
| 8012 |
const pieces = shortcode_converter_default(HTML); |
| 8013 |
const hasShortcodes = pieces.length > 1; |
| 8014 |
if (isPlainText && !hasShortcodes) { |
| 8015 |
if (mode === "AUTO" && plainText.indexOf("\n") === -1 && plainText.indexOf("<p>") !== 0 && HTML.indexOf("<p>") === 0) { |
| 8016 |
mode = "INLINE"; |
| 8017 |
} |
| 8018 |
} |
| 8019 |
if (mode === "INLINE") { |
| 8020 |
return filterInlineHTML(HTML); |
| 8021 |
} |
| 8022 |
if (mode === "AUTO" && !hasShortcodes && isInlineContent(HTML, tagName)) { |
| 8023 |
return filterInlineHTML(HTML); |
| 8024 |
} |
| 8025 |
const phrasingContentSchema = (0, import_dom12.getPhrasingContentSchema)("paste"); |
| 8026 |
const blockContentSchema = getBlockContentSchema("paste"); |
| 8027 |
const blocks = pieces.map((piece) => { |
| 8028 |
if (typeof piece !== "string") { |
| 8029 |
return piece; |
| 8030 |
} |
| 8031 |
const filters = [ |
| 8032 |
googleDocsUIdRemover, |
| 8033 |
msListConverter, |
| 8034 |
headRemover, |
| 8035 |
listReducer, |
| 8036 |
imageCorrector, |
| 8037 |
phrasingContentReducer, |
| 8038 |
specialCommentConverter, |
| 8039 |
commentRemover, |
| 8040 |
iframeRemover, |
| 8041 |
figureContentReducer, |
| 8042 |
blockquoteNormaliser(), |
| 8043 |
divNormaliser, |
| 8044 |
headingTransformer |
| 8045 |
]; |
| 8046 |
const schema = { |
| 8047 |
...blockContentSchema, |
| 8048 |
// Keep top-level phrasing content, normalised by `normaliseBlocks`. |
| 8049 |
...phrasingContentSchema |
| 8050 |
}; |
| 8051 |
piece = deepFilterHTML(piece, filters, blockContentSchema); |
| 8052 |
piece = (0, import_dom12.removeInvalidHTML)(piece, schema, false); |
| 8053 |
piece = normaliseBlocks(piece); |
| 8054 |
piece = deepFilterHTML( |
| 8055 |
piece, |
| 8056 |
[ |
| 8057 |
htmlFormattingRemover, |
| 8058 |
formatSpaceCorrector, |
| 8059 |
brRemover, |
| 8060 |
emptyParagraphRemover |
| 8061 |
], |
| 8062 |
blockContentSchema |
| 8063 |
); |
| 8064 |
log("Processed HTML piece:\n\n", piece); |
| 8065 |
return htmlToBlocks(piece, pasteHandler); |
| 8066 |
}).flat().filter(Boolean); |
| 8067 |
if (mode === "AUTO" && blocks.length === 1 && hasBlockSupport(blocks[0].name, "__unstablePasteTextInline", false)) { |
| 8068 |
const trimRegex = /^[\n]+|[\n]+$/g; |
| 8069 |
const trimmedPlainText = plainText.replace(trimRegex, ""); |
| 8070 |
if (trimmedPlainText !== "" && trimmedPlainText.indexOf("\n") === -1) { |
| 8071 |
return (0, import_dom12.removeInvalidHTML)( |
| 8072 |
getBlockInnerHTML(blocks[0]), |
| 8073 |
phrasingContentSchema, |
| 8074 |
false |
| 8075 |
).replace(trimRegex, ""); |
| 8076 |
} |
| 8077 |
} |
| 8078 |
return blocks; |
| 8079 |
} |
| 8080 |
|
| 8081 |
// packages/blocks/build-module/api/raw-handling/index.mjs |
| 8082 |
function deprecatedGetPhrasingContentSchema(context) { |
| 8083 |
(0, import_deprecated10.default)("wp.blocks.getPhrasingContentSchema", { |
| 8084 |
since: "5.6", |
| 8085 |
alternative: "wp.dom.getPhrasingContentSchema" |
| 8086 |
}); |
| 8087 |
return (0, import_dom13.getPhrasingContentSchema)(context); |
| 8088 |
} |
| 8089 |
function rawHandler({ HTML = "" }) { |
| 8090 |
if (HTML.indexOf("<!-- wp:") !== -1) { |
| 8091 |
const parseResult = parse2(HTML); |
| 8092 |
const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === "core/freeform"; |
| 8093 |
if (!isSingleFreeFormBlock) { |
| 8094 |
return parseResult; |
| 8095 |
} |
| 8096 |
} |
| 8097 |
const pieces = shortcode_converter_default(HTML); |
| 8098 |
const blockContentSchema = getBlockContentSchema(); |
| 8099 |
return pieces.map((piece) => { |
| 8100 |
if (typeof piece !== "string") { |
| 8101 |
return piece; |
| 8102 |
} |
| 8103 |
const filters = [ |
| 8104 |
// Needed to adjust invalid lists. |
| 8105 |
listReducer, |
| 8106 |
// Needed to create more and nextpage blocks. |
| 8107 |
specialCommentConverter, |
| 8108 |
// Needed to create media blocks. |
| 8109 |
figureContentReducer, |
| 8110 |
// Needed to create the quote block, which cannot handle text |
| 8111 |
// without wrapper paragraphs. |
| 8112 |
blockquoteNormaliser({ raw: true }) |
| 8113 |
]; |
| 8114 |
piece = deepFilterHTML(piece, filters, blockContentSchema); |
| 8115 |
piece = normaliseBlocks(piece, { raw: true }); |
| 8116 |
return htmlToBlocks(piece, rawHandler); |
| 8117 |
}).flat().filter(Boolean); |
| 8118 |
} |
| 8119 |
|
| 8120 |
// packages/blocks/build-module/api/categories.mjs |
| 8121 |
var import_data6 = __toESM(require_data(), 1); |
| 8122 |
function getCategories2() { |
| 8123 |
return (0, import_data6.select)(store).getCategories(); |
| 8124 |
} |
| 8125 |
function setCategories2(categories2) { |
| 8126 |
(0, import_data6.dispatch)(store).setCategories(categories2); |
| 8127 |
} |
| 8128 |
function updateCategory2(slug, category) { |
| 8129 |
(0, import_data6.dispatch)(store).updateCategory(slug, category); |
| 8130 |
} |
| 8131 |
|
| 8132 |
// packages/blocks/build-module/api/templates.mjs |
| 8133 |
var import_element4 = __toESM(require_element(), 1); |
| 8134 |
function doBlocksMatchTemplate(blocks = [], template = []) { |
| 8135 |
return blocks.length === template.length && template.every(([name, , innerBlocksTemplate], index) => { |
| 8136 |
const block = blocks[index]; |
| 8137 |
return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate); |
| 8138 |
}); |
| 8139 |
} |
| 8140 |
var isHTMLAttribute = (attributeDefinition) => attributeDefinition?.source === "html"; |
| 8141 |
var isQueryAttribute = (attributeDefinition) => attributeDefinition?.source === "query"; |
| 8142 |
function normalizeAttributes(schema, values) { |
| 8143 |
if (!values) { |
| 8144 |
return {}; |
| 8145 |
} |
| 8146 |
return Object.fromEntries( |
| 8147 |
Object.entries(values).map(([key, value]) => [ |
| 8148 |
key, |
| 8149 |
normalizeAttribute(schema[key], value) |
| 8150 |
]) |
| 8151 |
); |
| 8152 |
} |
| 8153 |
function normalizeAttribute(definition, value) { |
| 8154 |
if (isHTMLAttribute(definition) && Array.isArray(value)) { |
| 8155 |
return (0, import_element4.renderToString)(value); |
| 8156 |
} |
| 8157 |
if (isQueryAttribute(definition) && value) { |
| 8158 |
return value.map( |
| 8159 |
(subValues) => { |
| 8160 |
return normalizeAttributes(definition.query, subValues); |
| 8161 |
} |
| 8162 |
); |
| 8163 |
} |
| 8164 |
return value; |
| 8165 |
} |
| 8166 |
function synchronizeBlocksWithTemplate(blocks = [], template) { |
| 8167 |
if (!template) { |
| 8168 |
return blocks; |
| 8169 |
} |
| 8170 |
return template.map( |
| 8171 |
([name, attributes, innerBlocksTemplate], index) => { |
| 8172 |
const block = blocks[index]; |
| 8173 |
if (block && block.name === name) { |
| 8174 |
const innerBlocks = synchronizeBlocksWithTemplate( |
| 8175 |
block.innerBlocks, |
| 8176 |
innerBlocksTemplate |
| 8177 |
); |
| 8178 |
return { ...block, innerBlocks }; |
| 8179 |
} |
| 8180 |
const blockType = getBlockType(name); |
| 8181 |
const normalizedAttributes = normalizeAttributes( |
| 8182 |
blockType?.attributes ?? {}, |
| 8183 |
attributes |
| 8184 |
); |
| 8185 |
const [blockName, blockAttributes] = convertLegacyBlockNameAndAttributes( |
| 8186 |
name, |
| 8187 |
normalizedAttributes |
| 8188 |
); |
| 8189 |
return createBlock( |
| 8190 |
blockName, |
| 8191 |
blockAttributes, |
| 8192 |
synchronizeBlocksWithTemplate([], innerBlocksTemplate) |
| 8193 |
); |
| 8194 |
} |
| 8195 |
); |
| 8196 |
} |
| 8197 |
|
| 8198 |
// packages/blocks/build-module/api/index.mjs |
| 8199 |
var fieldsKey = /* @__PURE__ */ Symbol("fields"); |
| 8200 |
var formKey = /* @__PURE__ */ Symbol("form"); |
| 8201 |
var privateApis = {}; |
| 8202 |
lock(privateApis, { |
| 8203 |
isContentBlock, |
| 8204 |
fieldsKey, |
| 8205 |
formKey, |
| 8206 |
parseRawBlock |
| 8207 |
}); |
| 8208 |
|
| 8209 |
// packages/blocks/build-module/deprecated.mjs |
| 8210 |
var import_deprecated11 = __toESM(require_deprecated(), 1); |
| 8211 |
function withBlockContentContext(OriginalComponent) { |
| 8212 |
(0, import_deprecated11.default)("wp.blocks.withBlockContentContext", { |
| 8213 |
since: "6.1" |
| 8214 |
}); |
| 8215 |
return OriginalComponent; |
| 8216 |
} |
| 8217 |
return __toCommonJS(index_exports); |
| 8218 |
})(); |
| 8219 |
/*! Bundled license information: |
| 8220 |
|
| 8221 |
react-is/cjs/react-is.development.js: |
| 8222 |
(** |
| 8223 |
* @license React |
| 8224 |
* react-is.development.js |
| 8225 |
* |
| 8226 |
* Copyright (c) Facebook, Inc. and its affiliates. |
| 8227 |
* |
| 8228 |
* This source code is licensed under the MIT license found in the |
| 8229 |
* LICENSE file in the root directory of this source tree. |
| 8230 |
*) |
| 8231 |
|
| 8232 |
is-plain-object/dist/is-plain-object.mjs: |
| 8233 |
(*! |
| 8234 |
* is-plain-object <https://github.com/jonschlinkert/is-plain-object> |
| 8235 |
* |
| 8236 |
* Copyright (c) 2014-2017, Jon Schlinkert. |
| 8237 |
* Released under the MIT License. |
| 8238 |
*) |
| 8239 |
*/ |
| 8240 |
//# sourceMappingURL=index.js.map |
| 8241 |
|