vendor: 5,745 bytes, lines 1-185
1var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 2 3function getDefaultExportFromCjs (x) { 4 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; 5} 6 7var prism = {exports: {}}; 8 9var hasRequiredPrism; 10 11function requirePrism () { 12 if (hasRequiredPrism) return prism.exports; 13 hasRequiredPrism = 1; 14 (function (module) { 15 /* ********************************************** 16 Begin prism-core.js 17 ********************************************** */ 18 19 /// <reference lib="WebWorker"/> 20 21 var _self = (typeof window !== 'undefined') 22 ? window // if in browser 23 : ( 24 (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) 25 ? self // if in worker 26 : {} // if in node js 27 ); 28 29 /** 30 * Prism: Lightweight, robust, elegant syntax highlighting 31 * 32 * @license MIT <https://opensource.org/licenses/MIT> 33 * @author Lea Verou <https://lea.verou.me> 34 * @namespace 35 * @public 36 */ 37 var Prism = (function (_self) { 38 39 // Private helper vars 40 var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i; 41 var uniqueId = 0; 42 43 // The grammar object for plaintext 44 var plainTextGrammar = {}; 45 46 47 var _ = { 48 /** 49 * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the 50 * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load 51 * additional languages or plugins yourself. 52 * 53 * By setting this value to `true`, Prism will not automatically highlight all code elements on the page. 54 * 55 * You obviously have to change this value before the automatic highlighting started. To do this, you can add an 56 * empty Prism object into the global scope before loading the Prism script like this: 57 * 58 * ```js 59 * window.Prism = window.Prism || {}; 60 * Prism.manual = true; 61 * // add a new <script> to load Prism's script 62 * ``` 63 * 64 * @default false 65 * @type {boolean} 66 * @memberof Prism 67 * @public 68 */ 69 manual: _self.Prism && _self.Prism.manual, 70 /** 71 * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses 72 * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your 73 * own worker, you don't want it to do this. 74 * 75 * By setting this value to `true`, Prism will not add its own listeners to the worker. 76 * 77 * You obviously have to change this value before Prism executes. To do this, you can add an 78 * empty Prism object into the global scope before loading the Prism script like this: 79 * 80 * ```js 81 * window.Prism = window.Prism || {}; 82 * Prism.disableWorkerMessageHandler = true; 83 * // Load Prism's script 84 * ``` 85 * 86 * @default false 87 * @type {boolean} 88 * @memberof Prism 89 * @public 90 */ 91 disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, 92 93 /** 94 * A namespace for utility methods. 95 * 96 * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may 97 * change or disappear at any time. 98 * 99 * @namespace 100 * @memberof Prism 101 */ 102 util: { 103 encode: function encode(tokens) { 104 if (tokens instanceof Token) { 105 return new Token(tokens.type, encode(tokens.content), tokens.alias); 106 } else if (Array.isArray(tokens)) { 107 return tokens.map(encode); 108 } else { 109 return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' '); 110 } 111 }, 112 113 /** 114 * Returns the name of the type of the given value. 115 * 116 * @param {any} o 117 * @returns {string} 118 * @example 119 * type(null) === 'Null' 120 * type(undefined) === 'Undefined' 121 * type(123) === 'Number' 122 * type('foo') === 'String' 123 * type(true) === 'Boolean' 124 * type([1, 2]) === 'Array' 125 * type({}) === 'Object' 126 * type(String) === 'Function' 127 * type(/abc+/) === 'RegExp' 128 */ 129 type: function (o) { 130 return Object.prototype.toString.call(o).slice(8, -1); 131 }, 132 133 /** 134 * Returns a unique number for the given object. Later calls will still return the same number. 135 * 136 * @param {Object} obj 137 * @returns {number} 138 */ 139 objId: function (obj) { 140 if (!obj['__id']) { 141 Object.defineProperty(obj, '__id', { value: ++uniqueId }); 142 } 143 return obj['__id']; 144 }, 145 146 /** 147 * Creates a deep clone of the given object. 148 * 149 * The main intended use of this function is to clone language definitions. 150 * 151 * @param {T} o 152 * @param {Record<number, any>} [visited] 153 * @returns {T} 154 * @template T 155 */ 156 clone: function deepClone(o, visited) { 157 visited = visited || {}; 158 159 var clone; var id; 160 switch (_.util.type(o)) { 161 case 'Object': 162 id = _.util.objId(o); 163 if (visited[id]) { 164 return visited[id]; 165 } 166 clone = /** @type {Record<string, any>} */ ({}); 167 visited[id] = clone; 168 169 for (var key in o) { 170 if (o.hasOwnProperty(key)) { 171 clone[key] = deepClone(o[key], visited); 172 } 173 } 174 175 return /** @type {any} */ (clone); 176 177 case 'Array': 178 id = _.util.objId(o); 179 if (visited[id]) { 180 return visited[id]; 181 } 182 clone = []; 183 visited[id] = clone; 184 185 (/** @type {Array} */(/** @type {any}
vendor: 4,983 bytes, lines 185-334
185 */(o))).forEach(function (v, i) { 186 clone[i] = deepClone(v, visited); 187 }); 188 189 return /** @type {any} */ (clone); 190 191 default: 192 return o; 193 } 194 }, 195 196 /** 197 * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class. 198 * 199 * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned. 200 * 201 * @param {Element} element 202 * @returns {string} 203 */ 204 getLanguage: function (element) { 205 while (element) { 206 var m = lang.exec(element.className); 207 if (m) { 208 return m[1].toLowerCase(); 209 } 210 element = element.parentElement; 211 } 212 return 'none'; 213 }, 214 215 /** 216 * Sets the Prism `language-xxxx` class of the given element. 217 * 218 * @param {Element} element 219 * @param {string} language 220 * @returns {void} 221 */ 222 setLanguage: function (element, language) { 223 // remove all `language-xxxx` classes 224 // (this might leave behind a leading space) 225 element.className = element.className.replace(RegExp(lang, 'gi'), ''); 226 227 // add the new `language-xxxx` class 228 // (using `classList` will automatically clean up spaces for us) 229 element.classList.add('language-' + language); 230 }, 231 232 /** 233 * Returns the script element that is currently executing. 234 * 235 * This does __not__ work for line script element. 236 * 237 * @returns {HTMLScriptElement | null} 238 */ 239 currentScript: function () { 240 if (typeof document === 'undefined') { 241 return null; 242 } 243 if (document.currentScript && document.currentScript.tagName === 'SCRIPT' && 1 < 2 /* hack to trip TS' flow analysis */) { 244 return /** @type {any} */ (document.currentScript); 245 } 246 247 // IE11 workaround 248 // we'll get the src of the current script by parsing IE11's error stack trace 249 // this will not work for inline scripts 250 251 try { 252 throw new Error(); 253 } catch (err) { 254 // Get file src url from stack. Specifically works with the format of stack traces in IE. 255 // A stack will look like this: 256 // 257 // Error 258 // at _.util.currentScript (http://localhost/components/prism-core.js:119:5) 259 // at Global code (http://localhost/components/prism-core.js:606:1) 260 261 var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1]; 262 if (src) { 263 var scripts = document.getElementsByTagName('script'); 264 for (var i in scripts) { 265 if (scripts[i].src == src) { 266 return scripts[i]; 267 } 268 } 269 } 270 return null; 271 } 272 }, 273 274 /** 275 * Returns whether a given class is active for `element`. 276 * 277 * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated 278 * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the 279 * given class is just the given class with a `no-` prefix. 280 * 281 * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is 282 * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its 283 * ancestors have the given class or the negated version of it, then the default activation will be returned. 284 * 285 * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated 286 * version of it, the class is considered active. 287 * 288 * @param {Element} element 289 * @param {string} className 290 * @param {boolean} [defaultActivation=false] 291 * @returns {boolean} 292 */ 293 isActive: function (element, className, defaultActivation) { 294 var no = 'no-' + className; 295 296 while (element) { 297 var classList = element.classList; 298 if (classList.contains(className)) { 299 return true; 300 } 301 if (classList.contains(no)) { 302 return false; 303 } 304 element = element.parentElement; 305 } 306 return !!defaultActivation; 307 } 308 }, 309 310 /** 311 * This namespace contains all currently loaded languages and the some helper functions to create and modify languages. 312 * 313 * @namespace 314 * @memberof Prism 315 * @public 316 */ 317 languages: { 318 /** 319 * The grammar for plain, unformatted text. 320 */ 321 plain: plainTextGrammar, 322 plaintext: plainTextGrammar, 323 text: plainTextGrammar, 324 txt: plainTextGrammar, 325 326 /** 327 * Creates a deep copy of the language with the given id and appends the given tokens. 328 * 329 * If a token in `redef` also appears in the copied language, then the existing token in the copied language 330 * will be overwritten at its original position. 331 * 332 * ## Best practices 333 * 334 * Since the position of overwriting tokens (token in `redef` that over
334write tokens in the copied language) 335 * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to 336 * understand the language definition because, normally, the order of tokens matters in Prism grammars. 337 * 338 * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens. 339 * Furthermore, all non-overwriting tokens should be placed after the overwriting ones. 340 * 341 * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`. 342 * @param {Grammar} redef The new tokens to append. 343 * @returns {Grammar} The new language created. 344 * @public 345 * @example 346 * Prism.languages['css-with-colors'] = Prism.languages.extend('css', { 347 * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token 348 * // at its original position 349 * 'comment': { ... }, 350 * // CSS doesn't have a 'color' token, so this token will be appended 351 * 'color': /\b(?:red|green|blue)\b/ 352 * }); 353 */ 354 extend: function (id, redef) { 355 var lang = _.util.clone(_.languages[id]); 356 357 for (var key in redef) { 358 lang[key] = redef[key]; 359 } 360 361 return lang; 362 }, 363 364 /** 365 * Inserts tokens _before_ another token in a language definition or any other grammar. 366 * 367 * ## Usage 368 * 369 * This helper method makes it easy to modify existing languages. For example, the CSS language definition 370 * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded 371 * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the 372 * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do 373 * this: 374 * 375 * ```js 376 * Prism.languages.markup.style = { 377 * // token 378 * }; 379 * ``` 380 * 381 * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens 382 * before existing tokens. For the CSS example above, you would use it like this: 383 * 384 * ```js 385 * Prism.languages.insertBefore('markup', 'cdata', { 386 * 'style': { 387 * // token 388 * } 389 * }); 390 * ``` 391 * 392 * ## Special cases 393 * 394 * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar 395 * will be ignored. 396 * 397 * This behavior can be used to insert tokens after `before`: 398 * 399 * ```js 400 * Prism.languages.insertBefore('markup', 'comment', { 401 * 'comment': Prism.languages.markup.comment, 402 * // tokens after 'comment' 403 * }); 404 * ``` 405 * 406 * ## Limitations 407 * 408 * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object 409 * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave 410 * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily 411 * deleting properties which is necessary to insert at arbitrary positions. 412 * 413 * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object. 414 * Instead, it will create a new object and replace all references to the target object with the new one. This 415 * can be done without temporarily deleting properties, so the iteration order is well-defined. 416 * 417 * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if 418 * you hold the target object in a variable, then the value of the variable will not change. 419 * 420 * ```js 421 * var oldMarkup = Prism.languages.markup; 422 * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... }); 423 * 424 * assert(oldMarkup !== Prism.languages.markup); 425 * assert(newMarkup === Prism.languages.markup); 426 * ``` 427 * 428 * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the 429 * object to be modified. 430 * @param {string} before The key to insert before. 431 * @param {Grammar}
vendor: 7,557 bytes, lines 431-653
431 insert An object containing the key-value pairs to be inserted. 432 * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the 433 * object to be modified. 434 * 435 * Defaults to `Prism.languages`. 436 * @returns {Grammar} The new grammar object. 437 * @public 438 */ 439 insertBefore: function (inside, before, insert, root) { 440 root = root || /** @type {any} */ (_.languages); 441 var grammar = root[inside]; 442 /** @type {Grammar} */ 443 var ret = {}; 444 445 for (var token in grammar) { 446 if (grammar.hasOwnProperty(token)) { 447 448 if (token == before) { 449 for (var newToken in insert) { 450 if (insert.hasOwnProperty(newToken)) { 451 ret[newToken] = insert[newToken]; 452 } 453 } 454 } 455 456 // Do not insert token which also occur in insert. See #1525 457 if (!insert.hasOwnProperty(token)) { 458 ret[token] = grammar[token]; 459 } 460 } 461 } 462 463 var old = root[inside]; 464 root[inside] = ret; 465 466 // Update references in other language definitions 467 _.languages.DFS(_.languages, function (key, value) { 468 if (value === old && key != inside) { 469 this[key] = ret; 470 } 471 }); 472 473 return ret; 474 }, 475 476 // Traverse a language definition with Depth First Search 477 DFS: function DFS(o, callback, type, visited) { 478 visited = visited || {}; 479 480 var objId = _.util.objId; 481 482 for (var i in o) { 483 if (o.hasOwnProperty(i)) { 484 callback.call(o, i, o[i], type || i); 485 486 var property = o[i]; 487 var propertyType = _.util.type(property); 488 489 if (propertyType === 'Object' && !visited[objId(property)]) { 490 visited[objId(property)] = true; 491 DFS(property, callback, null, visited); 492 } else if (propertyType === 'Array' && !visited[objId(property)]) { 493 visited[objId(property)] = true; 494 DFS(property, callback, i, visited); 495 } 496 } 497 } 498 } 499 }, 500 501 plugins: {}, 502 503 /** 504 * This is the most high-level function in Prismâs API. 505 * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on 506 * each one of them. 507 * 508 * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`. 509 * 510 * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}. 511 * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}. 512 * @memberof Prism 513 * @public 514 */ 515 highlightAll: function (async, callback) { 516 _.highlightAllUnder(document, async, callback); 517 }, 518 519 /** 520 * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls 521 * {@link Prism.highlightElement} on each one of them. 522 * 523 * The following hooks will be run: 524 * 1. `before-highlightall` 525 * 2. `before-all-elements-highlight` 526 * 3. All hooks of {@link Prism.highlightElement} for each element. 527 * 528 * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted. 529 * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers. 530 * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done. 531 * @memberof Prism 532 * @public 533 */ 534 highlightAllUnder: function (container, async, callback) { 535 var env = { 536 callback: callback, 537 container: container, 538 selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code' 539 }; 540 541 _.hooks.run('before-highlightall', env); 542 543 env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector)); 544 545 _.hooks.run('before-all-elements-highlight', env); 546 547 for (var i = 0, element; (element = env.elements[i++]);) { 548 _.highlightElement(element, async === true, env.callback); 549 } 550 }, 551 552 /** 553 * Highlights the code inside a single element. 554 * 555 * The following hooks will be run: 556 * 1. `before-sanity-check` 557 * 2. `before-highlight` 558 * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`. 559 * 4. `before-insert` 560 * 5. `after-highlight` 561 * 6. `complete` 562 * 563 * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for 564 * the element's language. 565 * 566 * @param {Element} element The element containing the code. 567 * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier. 568 * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers 569 * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is 570 * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default). 571 * 572 * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for 573 * asynchronous highlighting to work. You can build your own bundle on the 574 * [Download page](https://prismjs.com/download.html). 575 * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done. 576 * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously. 577 * @memberof Prism 578 * @public 579 */ 580 highlightElement: function (element, async, callback) { 581 // Find language 582 var language = _.util.getLanguage(element); 583 var grammar = _.languages[language]; 584 585 // Set language on the element, if not present 586 _.util.setLanguage(element, language); 587 588 // Set language on the parent, for styling 589 var parent = element.parentElement; 590 if (parent && parent.nodeName.toLowerCase() === 'pre') { 591 _.util.setLanguage(parent, language); 592 } 593 594 var code = element.textContent; 595 596 var env = { 597 element: element, 598 language: language, 599 grammar: grammar, 600 code: code 601 }; 602 603 function insertHighlightedCode(highlightedCode) { 604 env.highlightedCode = highlightedCode; 605 606 _.hooks.run('before-insert', env); 607 608 env.element.innerHTML = env.highlightedCode; 609 610 _.hooks.run('after-highlight', env); 611 _.hooks.run('complete', env); 612 callback && callback.call(env.element); 613 } 614 615 _.hooks.run('before-sanity-check', env); 616 617 // plugins may change/add the parent/element 618 parent = env.element.parentElement; 619 if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) { 620 parent.setAttribute('tabindex', '0'); 621 } 622 623 if (!env.code) { 624 _.hooks.run('complete', env); 625 callback && callback.call(env.element); 626 return; 627 } 628 629 _.hooks.run('before-highlight', env); 630 631 if (!env.grammar) { 632 insertHighlightedCode(_.util.encode(env.code)); 633 return; 634 } 635 636 if (async && _self.Worker) { 637 var worker = new Worker(_.filename); 638 639 worker.onmessage = function (evt) { 640 insertHighlightedCode(evt.data); 641 }; 642 643 worker.postMessage(JSON.stringify({ 644 language: env.language, 645 code: env.code, 646 immediateClose: true 647 })); 648 } else { 649 insertHighlightedCode(_.highlight(env.code, env.grammar, env.language)); 650 } 651 }, 652 653 /**
654 * Low-level function, only use if you know what youâre doing. It accepts a string of text as input 655 * and the language definitions to use, and returns a string with the HTML produced. 656 * 657 * The following hooks will be run: 658 * 1. `before-tokenize` 659 * 2. `after-tokenize` 660 * 3. `wrap`: On each {@link Token}. 661 * 662 * @param {string} text A string with the code to be highlighted. 663 * @param {Grammar} grammar An object containing the tokens to use. 664 * 665 * Usually a language definition like `Prism.languages.markup`. 666 * @param {string} language The name of the language definition passed to `grammar`. 667 * @returns {string} The highlighted HTML. 668 * @memberof Prism 669 * @public 670 * @example 671 * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript'); 672 */ 673 highlight: function (text, grammar, language) { 674 var env = { 675 code: text, 676 grammar: grammar, 677 language: language 678 }; 679 _.hooks.run('before-tokenize', env); 680 if (!env.grammar) { 681 throw new Error('The language "' + env.language + '" has no grammar.'); 682 } 683 env.tokens = _.tokenize(env.code, env.grammar); 684 _.hooks.run('after-tokenize', env); 685 return Token.stringify(_.util.encode(env.tokens), env.language); 686 }, 687 688 /** 689 * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input 690 * and the language definitions to use, and returns an array with the tokenized code. 691 * 692 * When the language definition includes nested tokens, the function is called recursively on each of these tokens. 693 * 694 * This method could be useful in other contexts as well, as a very crude parser. 695 * 696 * @param {string} text A string with the code to be highlighted. 697 * @param {Grammar} grammar An object containing the tokens to use. 698 * 699 * Usually a language definition like `Prism.languages.markup`. 700 * @returns {TokenStream} An array of strings and tokens, a token stream. 701 * @memberof Prism 702 * @public 703 * @example 704 * let code = `var foo = 0;`; 705 * let tokens = Prism.tokenize(code, Prism.languages.javascript); 706 * tokens.forEach(token => { 707 * if (token instanceof Prism.Token && token.type === 'number') { 708 * console.log(`Found numeric literal: ${token.content}`); 709 * } 710 * }); 711 */ 712 tokenize: function (text, grammar) { 713 var rest = grammar.rest; 714 if (rest) { 715 for (var token in rest) { 716 grammar[token] = rest[token]; 717 } 718 719 delete grammar.rest; 720 } 721 722 var tokenList = new LinkedList(); 723 addAfter(tokenList, tokenList.head, text); 724 725 matchGrammar(text, tokenList, grammar, tokenList.head, 0); 726 727 return toArray(tokenList); 728 }, 729 730 /** 731 * @namespace 732 * @memberof Prism 733 * @public 734 */ 735 hooks: { 736 all: {}, 737 738 /** 739 * Adds the given callback to the list of callbacks for the given hook. 740 * 741 * The callback will be invoked when the hook it is registered for is run. 742 * Hooks are usually directly run by a highlight function but you can also run hooks yourself. 743 * 744 * One callback function can be registered to multiple hooks and the same hook multiple times. 745 * 746 * @param {string} name The name of the hook. 747 * @param {HookCallback} callback The callback function which is given environment variables. 748 * @public 749 */ 750 add: function (name, callback) { 751 var hooks = _.hooks.all; 752 753 hooks[name] = hooks[name] || []; 754 755 hooks[name].push(callback); 756 }, 757 758 /** 759 * Runs a hook invoking all registered callbacks with the given environment variables. 760 * 761 * Callbacks will be invoked synchronously and in the order in which they were registered. 762 * 763 * @param {string} name The name of the hook. 764 * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered. 765 * @public 766 */ 767 run: function (name, env) { 768 var callbacks = _.hooks.all[name]; 769 770 if (!callbacks || !callbacks.length) { 771 return; 772 } 773 774 for (var i = 0, callback; (callback = callbacks[i++]);) { 775 callback(env); 776 } 777 } 778 }, 779 780 Token: Token 781 }; 782 _self.Prism = _; 783 784 785 // Typescript note: 786 // The following can be used to import the Token type in JSDoc: 787 // 788 // @typedef {InstanceType<import("./prism-core")["Token"]>} Token 789 790 /** 791 * Creates a new token. 792 * 793 * @param {string} type See {@link Token#type type} 794 * @param {string | TokenStream} content See {@link Token#content content} 795 * @param {string|string[]} [alias] The alias(es) of the token. 796 * @param {string} [matchedStr=""] A copy of the full string this token was created from. 797 * @class 798 * @global 799 * @public 800 */ 801 function Token(type, content, alias, matchedStr) { 802 /** 803 * The type of the token. 804 * 805 * This is usually the key of a pattern in a {@link Grammar}. 806 * 807 * @type {string} 808 * @see GrammarToken 809 * @public 810 */ 811 this.type = type; 812 /** 813 * The strings or tokens contained by this token. 814 * 815 * This will be a token stream if the pattern matched also defined an `inside` grammar. 816 * 817 * @type {string | TokenStream} 818 * @public 819 */ 820 this.content = content; 821 /** 822 * The alias(es) of the token. 823 * 824 * @type {string|string[]} 825 * @see GrammarToken 826 * @public 827 */ 828 this.alias = alias; 829 // Copy of the full string this token was created from 830 this.length = (matchedStr || '').length | 0; 831 } 832 833 /**
vendor: 4,762 bytes, lines 834-996
834 * A token stream is an array of strings and {@link Token Token} objects. 835 * 836 * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process 837 * them. 838 * 839 * 1. No adjacent strings. 840 * 2. No empty strings. 841 * 842 * The only exception here is the token stream that only contains the empty string and nothing else. 843 * 844 * @typedef {Array<string | Token>} TokenStream 845 * @global 846 * @public 847 */ 848 849 /** 850 * Converts the given token or token stream to an HTML representation. 851 * 852 * The following hooks will be run: 853 * 1. `wrap`: On each {@link Token}. 854 * 855 * @param {string | Token | TokenStream} o The token or token stream to be converted. 856 * @param {string} language The name of current language. 857 * @returns {string} The HTML representation of the token or token stream. 858 * @memberof Token 859 * @static 860 */ 861 Token.stringify = function stringify(o, language) { 862 if (typeof o == 'string') { 863 return o; 864 } 865 if (Array.isArray(o)) { 866 var s = ''; 867 o.forEach(function (e) { 868 s += stringify(e, language); 869 }); 870 return s; 871 } 872 873 var env = { 874 type: o.type, 875 content: stringify(o.content, language), 876 tag: 'span', 877 classes: ['token', o.type], 878 attributes: {}, 879 language: language 880 }; 881 882 var aliases = o.alias; 883 if (aliases) { 884 if (Array.isArray(aliases)) { 885 Array.prototype.push.apply(env.classes, aliases); 886 } else { 887 env.classes.push(aliases); 888 } 889 } 890 891 _.hooks.run('wrap', env); 892 893 var attributes = ''; 894 for (var name in env.attributes) { 895 attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"'; 896 } 897 898 return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>'; 899 }; 900 901 /** 902 * @param {RegExp} pattern 903 * @param {number} pos 904 * @param {string} text 905 * @param {boolean} lookbehind 906 * @returns {RegExpExecArray | null} 907 */ 908 function matchPattern(pattern, pos, text, lookbehind) { 909 pattern.lastIndex = pos; 910 var match = pattern.exec(text); 911 if (match && lookbehind && match[1]) { 912 // change the match to remove the text matched by the Prism lookbehind group 913 var lookbehindLength = match[1].length; 914 match.index += lookbehindLength; 915 match[0] = match[0].slice(lookbehindLength); 916 } 917 return match; 918 } 919 920 /** 921 * @param {string} text 922 * @param {LinkedList<string | Token>} tokenList 923 * @param {any} grammar 924 * @param {LinkedListNode<string | Token>} startNode 925 * @param {number} startPos 926 * @param {RematchOptions} [rematch] 927 * @returns {void} 928 * @private 929 * 930 * @typedef RematchOptions 931 * @property {string} cause 932 * @property {number} reach 933 */ 934 function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) { 935 for (var token in grammar) { 936 if (!grammar.hasOwnProperty(token) || !grammar[token]) { 937 continue; 938 } 939 940 var patterns = grammar[token]; 941 patterns = Array.isArray(patterns) ? patterns : [patterns]; 942 943 for (var j = 0; j < patterns.length; ++j) { 944 if (rematch && rematch.cause == token + ',' + j) { 945 return; 946 } 947 948 var patternObj = patterns[j]; 949 var inside = patternObj.inside; 950 var lookbehind = !!patternObj.lookbehind; 951 var greedy = !!patternObj.greedy; 952 var alias = patternObj.alias; 953 954 if (greedy && !patternObj.pattern.global) { 955 // Without the global flag, lastIndex won't work 956 var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0]; 957 patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g'); 958 } 959 960 /** @type {RegExp} */ 961 var pattern = patternObj.pattern || patternObj; 962 963 for ( // iterate the token list and keep track of the current token/string position 964 var currentNode = startNode.next, pos = startPos; 965 currentNode !== tokenList.tail; 966 pos += currentNode.value.length, currentNode = currentNode.next 967 ) { 968 969 if (rematch && pos >= rematch.reach) { 970 break; 971 } 972 973 var str = currentNode.value; 974 975 if (tokenList.length > text.length) { 976 // Something went terribly wrong, ABORT, ABORT! 977 return; 978 } 979 980 if (str instanceof Token) { 981 continue; 982 } 983 984 var removeCount = 1; // this is the to parameter of removeBetween 985 var match; 986 987 if (greedy) { 988 match = matchPattern(pattern, pos, text, lookbehind); 989 if (!match || match.index >= text.length) { 990 break; 991 } 992 993 var from = match.index; 994 var to = match.index + match[0].length; 995 var p = pos; 996
vendor: 6,526 bytes, lines 997-1236
997 // find the node that contains the match 998 p += currentNode.value.length; 999 while (from >= p) { 1000 currentNode = currentNode.next; 1001 p += currentNode.value.length; 1002 } 1003 // adjust pos (and p) 1004 p -= currentNode.value.length; 1005 pos = p; 1006 1007 // the current node is a Token, then the match starts inside another Token, which is invalid 1008 if (currentNode.value instanceof Token) { 1009 continue; 1010 } 1011 1012 // find the last node which is affected by this match 1013 for ( 1014 var k = currentNode; 1015 k !== tokenList.tail && (p < to || typeof k.value === 'string'); 1016 k = k.next 1017 ) { 1018 removeCount++; 1019 p += k.value.length; 1020 } 1021 removeCount--; 1022 1023 // replace with the new match 1024 str = text.slice(pos, p); 1025 match.index -= pos; 1026 } else { 1027 match = matchPattern(pattern, 0, str, lookbehind); 1028 if (!match) { 1029 continue; 1030 } 1031 } 1032 1033 // eslint-disable-next-line no-redeclare 1034 var from = match.index; 1035 var matchStr = match[0]; 1036 var before = str.slice(0, from); 1037 var after = str.slice(from + matchStr.length); 1038 1039 var reach = pos + str.length; 1040 if (rematch && reach > rematch.reach) { 1041 rematch.reach = reach; 1042 } 1043 1044 var removeFrom = currentNode.prev; 1045 1046 if (before) { 1047 removeFrom = addAfter(tokenList, removeFrom, before); 1048 pos += before.length; 1049 } 1050 1051 removeRange(tokenList, removeFrom, removeCount); 1052 1053 var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr); 1054 currentNode = addAfter(tokenList, removeFrom, wrapped); 1055 1056 if (after) { 1057 addAfter(tokenList, currentNode, after); 1058 } 1059 1060 if (removeCount > 1) { 1061 // at least one Token object was removed, so we have to do some rematching 1062 // this can only happen if the current pattern is greedy 1063 1064 /** @type {RematchOptions} */ 1065 var nestedRematch = { 1066 cause: token + ',' + j, 1067 reach: reach 1068 }; 1069 matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch); 1070 1071 // the reach might have been extended because of the rematching 1072 if (rematch && nestedRematch.reach > rematch.reach) { 1073 rematch.reach = nestedRematch.reach; 1074 } 1075 } 1076 } 1077 } 1078 } 1079 } 1080 1081 /** 1082 * @typedef LinkedListNode 1083 * @property {T} value 1084 * @property {LinkedListNode<T> | null} prev The previous node. 1085 * @property {LinkedListNode<T> | null} next The next node. 1086 * @template T 1087 * @private 1088 */ 1089 1090 /** 1091 * @template T 1092 * @private 1093 */ 1094 function LinkedList() { 1095 /** @type {LinkedListNode<T>} */ 1096 var head = { value: null, prev: null, next: null }; 1097 /** @type {LinkedListNode<T>} */ 1098 var tail = { value: null, prev: head, next: null }; 1099 head.next = tail; 1100 1101 /** @type {LinkedListNode<T>} */ 1102 this.head = head; 1103 /** @type {LinkedListNode<T>} */ 1104 this.tail = tail; 1105 this.length = 0; 1106 } 1107 1108 /** 1109 * Adds a new node with the given value to the list. 1110 * 1111 * @param {LinkedList<T>} list 1112 * @param {LinkedListNode<T>} node 1113 * @param {T} value 1114 * @returns {LinkedListNode<T>} The added node. 1115 * @template T 1116 */ 1117 function addAfter(list, node, value) { 1118 // assumes that node != list.tail && values.length >= 0 1119 var next = node.next; 1120 1121 var newNode = { value: value, prev: node, next: next }; 1122 node.next = newNode; 1123 next.prev = newNode; 1124 list.length++; 1125 1126 return newNode; 1127 } 1128 /** 1129 * Removes `count` nodes after the given node. The given node will not be removed. 1130 * 1131 * @param {LinkedList<T>} list 1132 * @param {LinkedListNode<T>} node 1133 * @param {number} count 1134 * @template T 1135 */ 1136 function removeRange(list, node, count) { 1137 var next = node.next; 1138 for (var i = 0; i < count && next !== list.tail; i++) { 1139 next = next.next; 1140 } 1141 node.next = next; 1142 next.prev = node; 1143 list.length -= i; 1144 } 1145 /** 1146 * @param {LinkedList<T>} list 1147 * @returns {T[]} 1148 * @template T 1149 */ 1150 function toArray(list) { 1151 var array = []; 1152 var node = list.head.next; 1153 while (node !== list.tail) { 1154 array.push(node.value); 1155 node = node.next; 1156 } 1157 return array; 1158 } 1159 1160 1161 if (!_self.document) { 1162 if (!_self.addEventListener) { 1163 // in Node.js 1164 return _; 1165 } 1166 1167 if (!_.disableWorkerMessageHandler) { 1168 // In worker 1169 _self.addEventListener('message', function (evt) { 1170 var message = JSON.parse(evt.data); 1171 var lang = message.language; 1172 var code = message.code; 1173 var immediateClose = message.immediateClose; 1174 1175 _self.postMessage(_.highlight(code, _.languages[lang], lang)); 1176 if (immediateClose) { 1177 _self.close(); 1178 } 1179 }, false); 1180 } 1181 1182 return _; 1183 } 1184 1185 // Get current script and highlight 1186 var script = _.util.currentScript(); 1187 1188 if (script) { 1189 _.filename = script.src; 1190 1191 if (script.hasAttribute('data-manual')) { 1192 _.manual = true; 1193 } 1194 } 1195 1196 function highlightAutomaticallyCallback() { 1197 if (!_.manual) { 1198 _.highlightAll(); 1199 } 1200 } 1201 1202 if (!_.manual) { 1203 // If the document state is "loading", then we'll use DOMContentLoaded. 1204 // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the 1205 // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they 1206 // might take longer one animation frame to execute which can create a race condition where only some plugins have 1207 // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded. 1208 // See https://github.com/PrismJS/prism/issues/2102 1209 var readyState = document.readyState; 1210 if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) { 1211 document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback); 1212 } else { 1213 if (window.requestAnimationFrame) { 1214 window.requestAnimationFrame(highlightAutomaticallyCallback); 1215 } else { 1216 window.setTimeout(highlightAutomaticallyCallback, 16); 1217 } 1218 } 1219 } 1220 1221 return _; 1222 1223 }(_self)); 1224 1225 if (module.exports) { 1226 module.exports = Prism; 1227 } 1228 1229 // hack for components to work correctly in node.js 1230 if (typeof commonjsGlobal !== 'undefined') { 1231 commonjsGlobal.Prism = Prism; 1232 } 1233 1234 // some additional documentation/types 1235 1236 /**
1237 * The expansion of a simple `RegExp` literal to support additional properties. 1238 * 1239 * @typedef GrammarToken 1240 * @property {RegExp} pattern The regular expression of the token. 1241 * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively) 1242 * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token. 1243 * @property {boolean} [greedy=false] Whether the token is greedy. 1244 * @property {string|string[]} [alias] An optional alias or list of aliases. 1245 * @property {Grammar} [inside] The nested grammar of this token. 1246 * 1247 * The `inside` grammar will be used to tokenize the text value of each token of this kind. 1248 * 1249 * This can be used to make nested and even recursive language definitions. 1250 * 1251 * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into 1252 * each another. 1253 * @global 1254 * @public 1255 */ 1256 1257 /** 1258 * @typedef Grammar 1259 * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>} 1260 * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar. 1261 * @global 1262 * @public 1263 */ 1264 1265 /** 1266 * A function which will invoked after an element was successfully highlighted. 1267 * 1268 * @callback HighlightCallback 1269 * @param {Element} element The element successfully highlighted. 1270 * @returns {void} 1271 * @global 1272 * @public 1273 */ 1274 1275 /** 1276 * @callback HookCallback 1277 * @param {Object<string, any>} env The environment variables of the hook. 1278 * @returns {void} 1279 * @global 1280 * @public 1281 */ 1282 1283 1284 /* ********************************************** 1285 Begin prism-markup.js 1286 ********************************************** */ 1287 1288 Prism.languages.markup = { 1289 'comment': { 1290 pattern: /<!--(?:(?!<!--)[\s\S])*?-->/, 1291 greedy: true 1292 }, 1293 'prolog': { 1294 pattern: /<\?[\s\S]+?\?>/, 1295 greedy: true 1296 }, 1297 'doctype': { 1298 // https://www.w3.org/TR/xml/#NT-doctypedecl 1299 pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i, 1300 greedy: true, 1301 inside: { 1302 'internal-subset': { 1303 pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/, 1304 lookbehind: true, 1305 greedy: true, 1306 inside: null // see below 1307 }, 1308 'string': { 1309 pattern: /"[^"]*"|'[^']*'/, 1310 greedy: true 1311 }, 1312 'punctuation': /^<!|>$|[[\]]/, 1313 'doctype-tag': /^DOCTYPE/i, 1314 'name': /[^\s<>'"]+/ 1315 } 1316 }, 1317 'cdata': { 1318 pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, 1319 greedy: true 1320 }, 1321 'tag': { 1322 pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/, 1323 greedy: true, 1324 inside: { 1325 'tag': { 1326 pattern: /^<\/?[^\s>\/]+/, 1327 inside: { 1328 'punctuation': /^<\/?/, 1329 'namespace': /^[^\s>\/:]+:/ 1330 } 1331 }, 1332 'special-attr': [], 1333 'attr-value': { 1334 pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/, 1335 inside: { 1336 'punctuation': [ 1337 { 1338 pattern: /^=/, 1339 alias: 'attr-equals' 1340 }, 1341 { 1342 pattern: /^(\s*)["']|["']$/, 1343 lookbehind: true 1344 } 1345 ] 1346 } 1347 }, 1348 'punctuation': /\/?>/, 1349 'attr-name': { 1350 pattern: /[^\s>\/]+/, 1351 inside: { 1352 'namespace': /^[^\s>\/:]+:/ 1353 } 1354 } 1355 1356 } 1357 }, 1358 'entity': [ 1359 { 1360 pattern: /&[\da-z]{1,8};/i, 1361 alias: 'named-entity' 1362 }, 1363 /&#x?[\da-f]{1,8};/i 1364 ] 1365 }; 1366 1367 Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = 1368 Prism.languages.markup['entity']; 1369 Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup; 1370 1371 // Plugin to make entity title show the real entity, idea by Roman Komarov 1372 Prism.hooks.add('wrap', function (env) { 1373 1374 if (env.type === 'entity') { 1375 env.attributes['title'] = env.content.replace(/&/, '&'); 1376 } 1377 }); 1378 1379 Object.defineProperty(Prism.languages.markup.tag, 'addInlined', { 1380 /** 1381 * Adds an inlined language to markup. 1382 * 1383 * An example of an inlined language is CSS with `<style>` tags. 1384 * 1385 * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as 1386 * case insensitive. 1387 * @param {string} lang The language key. 1388 * @example 1389 * addInlined('style', 'css'); 1390 */ 1391 value: function addInlined(tagName, lang) { 1392 var includedCdataInside = {};
vendor: 17,693 bytes, lines 1393-1949
1393 includedCdataInside['language-' + lang] = { 1394 pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i, 1395 lookbehind: true, 1396 inside: Prism.languages[lang] 1397 }; 1398 includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i; 1399 1400 var inside = { 1401 'included-cdata': { 1402 pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, 1403 inside: includedCdataInside 1404 } 1405 }; 1406 inside['language-' + lang] = { 1407 pattern: /[\s\S]+/, 1408 inside: Prism.languages[lang] 1409 }; 1410 1411 var def = {}; 1412 def[tagName] = { 1413 pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'), 1414 lookbehind: true, 1415 greedy: true, 1416 inside: inside 1417 }; 1418 1419 Prism.languages.insertBefore('markup', 'cdata', def); 1420 } 1421 }); 1422 Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', { 1423 /** 1424 * Adds an pattern to highlight languages embedded in HTML attributes. 1425 * 1426 * An example of an inlined language is CSS with `style` attributes. 1427 * 1428 * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as 1429 * case insensitive. 1430 * @param {string} lang The language key. 1431 * @example 1432 * addAttribute('style', 'css'); 1433 */ 1434 value: function (attrName, lang) { 1435 Prism.languages.markup.tag.inside['special-attr'].push({ 1436 pattern: RegExp( 1437 /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, 1438 'i' 1439 ), 1440 lookbehind: true, 1441 inside: { 1442 'attr-name': /^[^\s=]+/, 1443 'attr-value': { 1444 pattern: /=[\s\S]+/, 1445 inside: { 1446 'value': { 1447 pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/, 1448 lookbehind: true, 1449 alias: [lang, 'language-' + lang], 1450 inside: Prism.languages[lang] 1451 }, 1452 'punctuation': [ 1453 { 1454 pattern: /^=/, 1455 alias: 'attr-equals' 1456 }, 1457 /"|'/ 1458 ] 1459 } 1460 } 1461 } 1462 }); 1463 } 1464 }); 1465 1466 Prism.languages.html = Prism.languages.markup; 1467 Prism.languages.mathml = Prism.languages.markup; 1468 Prism.languages.svg = Prism.languages.markup; 1469 1470 Prism.languages.xml = Prism.languages.extend('markup', {}); 1471 Prism.languages.ssml = Prism.languages.xml; 1472 Prism.languages.atom = Prism.languages.xml; 1473 Prism.languages.rss = Prism.languages.xml; 1474 1475 1476 /* ********************************************** 1477 Begin prism-css.js 1478 ********************************************** */ 1479 1480 (function (Prism) { 1481 1482 var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/; 1483 1484 Prism.languages.css = { 1485 'comment': /\/\*[\s\S]*?\*\//, 1486 'atrule': { 1487 pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source), 1488 inside: { 1489 'rule': /^@[\w-]+/, 1490 'selector-function-argument': { 1491 pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/, 1492 lookbehind: true, 1493 alias: 'selector' 1494 }, 1495 'keyword': { 1496 pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/, 1497 lookbehind: true 1498 } 1499 // See rest below 1500 } 1501 }, 1502 'url': { 1503 // https://drafts.csswg.org/css-values-3/#urls 1504 pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'), 1505 greedy: true, 1506 inside: { 1507 'function': /^url/i, 1508 'punctuation': /^\(|\)$/, 1509 'string': { 1510 pattern: RegExp('^' + string.source + '$'), 1511 alias: 'url' 1512 } 1513 } 1514 }, 1515 'selector': { 1516 pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'), 1517 lookbehind: true 1518 }, 1519 'string': { 1520 pattern: string, 1521 greedy: true 1522 }, 1523 'property': { 1524 pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i, 1525 lookbehind: true 1526 }, 1527 'important': /!important\b/i, 1528 'function': { 1529 pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i, 1530 lookbehind: true 1531 }, 1532 'punctuation': /[(){};:,]/ 1533 }; 1534 1535 Prism.languages.css['atrule'].inside.rest = Prism.languages.css; 1536 1537 var markup = Prism.languages.markup; 1538 if (markup) { 1539 markup.tag.addInlined('style', 'css'); 1540 markup.tag.addAttribute('style', 'css'); 1541 } 1542 1543 }(Prism)); 1544 1545 1546 /* ********************************************** 1547 Begin prism-clike.js 1548 ********************************************** */ 1549 1550 Prism.languages.clike = { 1551 'comment': [ 1552 { 1553 pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, 1554 lookbehind: true, 1555 greedy: true 1556 }, 1557 { 1558 pattern: /(^|[^\\:])\/\/.*/, 1559 lookbehind: true, 1560 greedy: true 1561 } 1562 ], 1563 'string': { 1564 pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, 1565 greedy: true 1566 }, 1567 'class-name': { 1568 pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i, 1569 lookbehind: true, 1570 inside: { 1571 'punctuation': /[.\\]/ 1572 } 1573 }, 1574 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/, 1575 'boolean': /\b(?:false|true)\b/, 1576 'function': /\b\w+(?=\()/, 1577 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, 1578 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/, 1579 'punctuation': /[{}[\];(),.:]/ 1580 }; 1581 1582 1583 /* ********************************************** 1584 Begin prism-javascript.js 1585 ********************************************** */ 1586 1587 Prism.languages.javascript = Prism.languages.extend('clike', { 1588 'class-name': [ 1589 Prism.languages.clike['class-name'], 1590 { 1591 pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/, 1592 lookbehind: true 1593 } 1594 ], 1595 'keyword': [ 1596 { 1597 pattern: /((?:^|\})\s*)catch\b/, 1598 lookbehind: true 1599 }, 1600 { 1601 pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/, 1602 lookbehind: true 1603 }, 1604 ], 1605 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) 1606 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, 1607 'number': { 1608 pattern: RegExp( 1609 /(^|[^\w$])/.source + 1610 '(?:' + 1611 ( 1612 // constant 1613 /NaN|Infinity/.source + 1614 '|' + 1615 // binary integer 1616 /0[bB][01]+(?:_[01]+)*n?/.source + 1617 '|' + 1618 // octal integer 1619 /0[oO][0-7]+(?:_[0-7]+)*n?/.source + 1620 '|' + 1621 // hexadecimal integer 1622 /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + 1623 '|' + 1624 // decimal bigint 1625 /\d+(?:_\d+)*n/.source + 1626 '|' + 1627 // decimal number (integer or float) but no bigint 1628 /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source 1629 ) + 1630 ')' + 1631 /(?![\w$])/.source 1632 ), 1633 lookbehind: true 1634 }, 1635 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/ 1636 }); 1637 1638 Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/; 1639 1640 Prism.languages.insertBefore('javascript', 'keyword', { 1641 'regex': { 1642 pattern: RegExp( 1643 // lookbehind 1644 // eslint-disable-next-line regexp/no-dupe-characters-character-class 1645 /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + 1646 // Regex pattern: 1647 // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character 1648 // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible 1649 // with the only syntax, so we have to define 2 different regex patterns. 1650 /\//.source + 1651 '(?:' + 1652 /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + 1653 '|' + 1654 // `v` flag syntax. This supports 3 levels of nested character classes. 1655 /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + 1656 ')' + 1657 // lookahead 1658 /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source 1659 ), 1660 lookbehind: true, 1661 greedy: true, 1662 inside: { 1663 'regex-source': { 1664 pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/, 1665 lookbehind: true, 1666 alias: 'language-regex', 1667 inside: Prism.languages.regex 1668 }, 1669 'regex-delimiter': /^\/|\/$/, 1670 'regex-flags': /^[a-z]+$/, 1671 } 1672 }, 1673 // This must be declared before keyword because we use "function" inside the look-forward 1674 'function-variable': { 1675 pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/, 1676 alias: 'function' 1677 }, 1678 'parameter': [ 1679 { 1680 pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/, 1681 lookbehind: true, 1682 inside: Prism.languages.javascript 1683 }, 1684 { 1685 pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i, 1686 lookbehind: true, 1687 inside: Prism.languages.javascript 1688 }, 1689 { 1690 pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/, 1691 lookbehind: true, 1692 inside: Prism.languages.javascript 1693 }, 1694 { 1695 pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/, 1696 lookbehind: true, 1697 inside: Prism.languages.javascript 1698 } 1699 ], 1700 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/ 1701 }); 1702 1703 Prism.languages.insertBefore('javascript', 'string', { 1704 'hashbang': { 1705 pattern: /^#!.*/, 1706 greedy: true, 1707 alias: 'comment' 1708 }, 1709 'template-string': { 1710 pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/, 1711 greedy: true, 1712 inside: { 1713 'template-punctuation': { 1714 pattern: /^`|`$/, 1715 alias: 'string' 1716 }, 1717 'interpolation': { 1718 pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/, 1719 lookbehind: true, 1720 inside: { 1721 'interpolation-punctuation': { 1722 pattern: /^\$\{|\}$/, 1723 alias: 'punctuation' 1724 }, 1725 rest: Prism.languages.javascript 1726 } 1727 }, 1728 'string': /[\s\S]+/ 1729 } 1730 }, 1731 'string-property': { 1732 pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m, 1733 lookbehind: true, 1734 greedy: true, 1735 alias: 'property' 1736 } 1737 }); 1738 1739 Prism.languages.insertBefore('javascript', 'operator', { 1740 'literal-property': { 1741 pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m, 1742 lookbehind: true, 1743 alias: 'property' 1744 }, 1745 }); 1746 1747 if (Prism.languages.markup) { 1748 Prism.languages.markup.tag.addInlined('script', 'javascript'); 1749 1750 // add attribute support for all DOM events. 1751 // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events 1752 Prism.languages.markup.tag.addAttribute( 1753 /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, 1754 'javascript' 1755 ); 1756 } 1757 1758 Prism.languages.js = Prism.languages.javascript; 1759 1760 1761 /* ********************************************** 1762 Begin prism-file-highlight.js 1763 ********************************************** */ 1764 1765 (function () { 1766 1767 if (typeof Prism === 'undefined' || typeof document === 'undefined') { 1768 return; 1769 } 1770 1771 // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill 1772 if (!Element.prototype.matches) { 1773 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 1774 } 1775 1776 var LOADING_MESSAGE = 'Loadingâ¦'; 1777 var FAILURE_MESSAGE = function (status, message) { 1778 return 'â Error ' + status + ' while fetching file: ' + message; 1779 }; 1780 var FAILURE_EMPTY_MESSAGE = 'â Error: File does not exist or is empty'; 1781 1782 var EXTENSIONS = { 1783 'js': 'javascript', 1784 'py': 'python', 1785 'rb': 'ruby', 1786 'ps1': 'powershell', 1787 'psm1': 'powershell', 1788 'sh': 'bash', 1789 'bat': 'batch', 1790 'h': 'c', 1791 'tex': 'latex' 1792 }; 1793 1794 var STATUS_ATTR = 'data-src-status'; 1795 var STATUS_LOADING = 'loading'; 1796 var STATUS_LOADED = 'loaded'; 1797 var STATUS_FAILED = 'failed'; 1798 1799 var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])' 1800 + ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])'; 1801 1802 /** 1803 * Loads the given file. 1804 * 1805 * @param {string} src The URL or path of the source file to load. 1806 * @param {(result: string) => void} success 1807 * @param {(reason: string) => void} error 1808 */ 1809 function loadFile(src, success, error) { 1810 var xhr = new XMLHttpRequest(); 1811 xhr.open('GET', src, true); 1812 xhr.onreadystatechange = function () { 1813 if (xhr.readyState == 4) { 1814 if (xhr.status < 400 && xhr.responseText) { 1815 success(xhr.responseText); 1816 } else { 1817 if (xhr.status >= 400) { 1818 error(FAILURE_MESSAGE(xhr.status, xhr.statusText)); 1819 } else { 1820 error(FAILURE_EMPTY_MESSAGE); 1821 } 1822 } 1823 } 1824 }; 1825 xhr.send(null); 1826 } 1827 1828 /** 1829 * Parses the given range. 1830 * 1831 * This returns a range with inclusive ends. 1832 * 1833 * @param {string | null | undefined} range 1834 * @returns {[number, number | undefined] | undefined} 1835 */ 1836 function parseRange(range) { 1837 var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || ''); 1838 if (m) { 1839 var start = Number(m[1]); 1840 var comma = m[2]; 1841 var end = m[3]; 1842 1843 if (!comma) { 1844 return [start, start]; 1845 } 1846 if (!end) { 1847 return [start, undefined]; 1848 } 1849 return [start, Number(end)]; 1850 } 1851 return undefined; 1852 } 1853 1854 Prism.hooks.add('before-highlightall', function (env) { 1855 env.selector += ', ' + SELECTOR; 1856 }); 1857 1858 Prism.hooks.add('before-sanity-check', function (env) { 1859 var pre = /** @type {HTMLPreElement} */ (env.element); 1860 if (pre.matches(SELECTOR)) { 1861 env.code = ''; // fast-path the whole thing and go to complete 1862 1863 pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading 1864 1865 // add code element with loading message 1866 var code = pre.appendChild(document.createElement('CODE')); 1867 code.textContent = LOADING_MESSAGE; 1868 1869 var src = pre.getAttribute('data-src'); 1870 1871 var language = env.language; 1872 if (language === 'none') { 1873 // the language might be 'none' because there is no language set; 1874 // in this case, we want to use the extension as the language 1875 var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1]; 1876 language = EXTENSIONS[extension] || extension; 1877 } 1878 1879 // set language classes 1880 Prism.util.setLanguage(code, language); 1881 Prism.util.setLanguage(pre, language); 1882 1883 // preload the language 1884 var autoloader = Prism.plugins.autoloader; 1885 if (autoloader) { 1886 autoloader.loadLanguages(language); 1887 } 1888 1889 // load file 1890 loadFile( 1891 src, 1892 function (text) { 1893 // mark as loaded 1894 pre.setAttribute(STATUS_ATTR, STATUS_LOADED); 1895 1896 // handle data-range 1897 var range = parseRange(pre.getAttribute('data-range')); 1898 if (range) { 1899 var lines = text.split(/\r\n?|\n/g); 1900 1901 // the range is one-based and inclusive on both ends 1902 var start = range[0]; 1903 var end = range[1] == null ? lines.length : range[1]; 1904 1905 if (start < 0) { start += lines.length; } 1906 start = Math.max(0, Math.min(start - 1, lines.length)); 1907 if (end < 0) { end += lines.length; } 1908 end = Math.max(0, Math.min(end, lines.length)); 1909 1910 text = lines.slice(start, end).join('\n'); 1911 1912 // add data-start for line numbers 1913 if (!pre.hasAttribute('data-start')) { 1914 pre.setAttribute('data-start', String(start + 1)); 1915 } 1916 } 1917 1918 // highlight code 1919 code.textContent = text; 1920 Prism.highlightElement(code); 1921 }, 1922 function (error) { 1923 // mark as failed 1924 pre.setAttribute(STATUS_ATTR, STATUS_FAILED); 1925 1926 code.textContent = error; 1927 } 1928 ); 1929 } 1930 }); 1931 1932 Prism.plugins.fileHighlight = { 1933 /** 1934 * Executes the File Highlight plugin for all matching `pre` elements under the given container. 1935 * 1936 * Note: Elements which are already loaded or currently loading will not be touched by this method. 1937 * 1938 * @param {ParentNode} [container=document] 1939 */ 1940 highlight: function highlight(container) { 1941 var elements = (container || document).querySelectorAll(SELECTOR); 1942 1943 for (var i = 0, element; (element = elements[i++]);) { 1944 Prism.highlightElement(element); 1945 } 1946 } 1947 }; 1948 1949 var logged = false;
vendor: 4,199 bytes, lines 1950-2116
1950 /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */ 1951 Prism.fileHighlight = function () { 1952 if (!logged) { 1953 console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.'); 1954 logged = true; 1955 } 1956 Prism.plugins.fileHighlight.highlight.apply(this, arguments); 1957 }; 1958 1959 }()); 1960 } (prism)); 1961 return prism.exports; 1962} 1963 1964var prismExports = requirePrism(); 1965var Prism$1 = /*@__PURE__*/getDefaultExportFromCjs(prismExports); 1966 1967Prism$1.languages.clike = { 1968 'comment': [ 1969 { 1970 pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, 1971 lookbehind: true, 1972 greedy: true 1973 }, 1974 { 1975 pattern: /(^|[^\\:])\/\/.*/, 1976 lookbehind: true, 1977 greedy: true 1978 } 1979 ], 1980 'string': { 1981 pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, 1982 greedy: true 1983 }, 1984 'class-name': { 1985 pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i, 1986 lookbehind: true, 1987 inside: { 1988 'punctuation': /[.\\]/ 1989 } 1990 }, 1991 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/, 1992 'boolean': /\b(?:false|true)\b/, 1993 'function': /\b\w+(?=\()/, 1994 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, 1995 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/, 1996 'punctuation': /[{}[\];(),.:]/ 1997}; 1998 1999Prism$1.languages.markup = { 2000 'comment': { 2001 pattern: /<!--(?:(?!<!--)[\s\S])*?-->/, 2002 greedy: true 2003 }, 2004 'prolog': { 2005 pattern: /<\?[\s\S]+?\?>/, 2006 greedy: true 2007 }, 2008 'doctype': { 2009 // https://www.w3.org/TR/xml/#NT-doctypedecl 2010 pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i, 2011 greedy: true, 2012 inside: { 2013 'internal-subset': { 2014 pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/, 2015 lookbehind: true, 2016 greedy: true, 2017 inside: null // see below 2018 }, 2019 'string': { 2020 pattern: /"[^"]*"|'[^']*'/, 2021 greedy: true 2022 }, 2023 'punctuation': /^<!|>$|[[\]]/, 2024 'doctype-tag': /^DOCTYPE/i, 2025 'name': /[^\s<>'"]+/ 2026 } 2027 }, 2028 'cdata': { 2029 pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, 2030 greedy: true 2031 }, 2032 'tag': { 2033 pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/, 2034 greedy: true, 2035 inside: { 2036 'tag': { 2037 pattern: /^<\/?[^\s>\/]+/, 2038 inside: { 2039 'punctuation': /^<\/?/, 2040 'namespace': /^[^\s>\/:]+:/ 2041 } 2042 }, 2043 'special-attr': [], 2044 'attr-value': { 2045 pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/, 2046 inside: { 2047 'punctuation': [ 2048 { 2049 pattern: /^=/, 2050 alias: 'attr-equals' 2051 }, 2052 { 2053 pattern: /^(\s*)["']|["']$/, 2054 lookbehind: true 2055 } 2056 ] 2057 } 2058 }, 2059 'punctuation': /\/?>/, 2060 'attr-name': { 2061 pattern: /[^\s>\/]+/, 2062 inside: { 2063 'namespace': /^[^\s>\/:]+:/ 2064 } 2065 } 2066 2067 } 2068 }, 2069 'entity': [ 2070 { 2071 pattern: /&[\da-z]{1,8};/i, 2072 alias: 'named-entity' 2073 }, 2074 /&#x?[\da-f]{1,8};/i 2075 ] 2076}; 2077 2078Prism$1.languages.markup['tag'].inside['attr-value'].inside['entity'] = 2079 Prism$1.languages.markup['entity']; 2080Prism$1.languages.markup['doctype'].inside['internal-subset'].inside = Prism$1.languages.markup; 2081 2082// Plugin to make entity title show the real entity, idea by Roman Komarov 2083Prism$1.hooks.add('wrap', function (env) { 2084 2085 if (env.type === 'entity') { 2086 env.attributes['title'] = env.content.replace(/&/, '&'); 2087 } 2088}); 2089 2090Object.defineProperty(Prism$1.languages.markup.tag, 'addInlined', { 2091 /** 2092 * Adds an inlined language to markup. 2093 * 2094 * An example of an inlined language is CSS with `<style>` tags. 2095 * 2096 * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as 2097 * case insensitive. 2098 * @param {string} lang The language key. 2099 * @example 2100 * addInlined('style', 'css'); 2101 */ 2102 value: function addInlined(tagName, lang) { 2103 var includedCdataInside = {}; 2104 includedCdataInside['language-' + lang] = { 2105 pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i, 2106 lookbehind: true, 2107 inside: Prism$1.languages[lang] 2108 }; 2109 includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i; 2110 2111 var inside = { 2112 'included-cdata': { 2113 pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, 2114 inside: includedCdataInside 2115 } 2116 };
2117 inside['language-' + lang] = { 2118 pattern: /[\s\S]+/, 2119 inside: Prism$1.languages[lang] 2120 }; 2121 2122 var def = {}; 2123 def[tagName] = { 2124 pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'), 2125 lookbehind: true, 2126 greedy: true, 2127 inside: inside 2128 }; 2129 2130 Prism$1.languages.insertBefore('markup', 'cdata', def); 2131 } 2132}); 2133Object.defineProperty(Prism$1.languages.markup.tag, 'addAttribute', { 2134 /** 2135 * Adds an pattern to highlight languages embedded in HTML attributes. 2136 * 2137 * An example of an inlined language is CSS with `style` attributes. 2138 * 2139 * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as 2140 * case insensitive. 2141 * @param {string} lang The language key. 2142 * @example 2143 * addAttribute('style', 'css'); 2144 */ 2145 value: function (attrName, lang) { 2146 Prism$1.languages.markup.tag.inside['special-attr'].push({ 2147 pattern: RegExp( 2148 /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, 2149 'i' 2150 ), 2151 lookbehind: true, 2152 inside: { 2153 'attr-name': /^[^\s=]+/, 2154 'attr-value': { 2155 pattern: /=[\s\S]+/, 2156 inside: { 2157 'value': { 2158 pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/, 2159 lookbehind: true, 2160 alias: [lang, 'language-' + lang], 2161 inside: Prism$1.languages[lang] 2162 }, 2163 'punctuation': [ 2164 { 2165 pattern: /^=/, 2166 alias: 'attr-equals' 2167 }, 2168 /"|'/ 2169 ] 2170 } 2171 } 2172 } 2173 }); 2174 } 2175}); 2176 2177Prism$1.languages.html = Prism$1.languages.markup; 2178Prism$1.languages.mathml = Prism$1.languages.markup; 2179Prism$1.languages.svg = Prism$1.languages.markup; 2180 2181Prism$1.languages.xml = Prism$1.languages.extend('markup', {}); 2182Prism$1.languages.ssml = Prism$1.languages.xml; 2183Prism$1.languages.atom = Prism$1.languages.xml; 2184Prism$1.languages.rss = Prism$1.languages.xml; 2185 2186(function (Prism) { 2187 2188 /** 2189 * Returns the placeholder for the given language id and index. 2190 * 2191 * @param {string} language 2192 * @param {string|number} index 2193 * @returns {string} 2194 */ 2195 function getPlaceholder(language, index) { 2196 return '___' + language.toUpperCase() + index + '___'; 2197 } 2198 2199 Object.defineProperties(Prism.languages['markup-templating'] = {}, { 2200 buildPlaceholders: { 2201 /** 2202 * Tokenize all inline templating expressions matching `placeholderPattern`. 2203 * 2204 * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns 2205 * `true` will be replaced. 2206 * 2207 * @param {object} env The environment of the `before-tokenize` hook. 2208 * @param {string} language The language id. 2209 * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders. 2210 * @param {(match: string) => boolean} [replaceFilter] 2211 */ 2212 value: function (env, language, placeholderPattern, replaceFilter) { 2213 if (env.language !== language) { 2214 return; 2215 } 2216 2217 var tokenStack = env.tokenStack = []; 2218 2219 env.code = env.code.replace(placeholderPattern, function (match) { 2220 if (typeof replaceFilter === 'function' && !replaceFilter(match)) { 2221 return match; 2222 } 2223 var i = tokenStack.length; 2224 var placeholder; 2225 2226 // Check for existing strings 2227 while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) { 2228 ++i; 2229 } 2230 2231 // Create a sparse array 2232 tokenStack[i] = match; 2233 2234 return placeholder; 2235 }); 2236 2237 // Switch the grammar to markup 2238 env.grammar = Prism.languages.markup; 2239 } 2240 }, 2241 tokenizePlaceholders: { 2242 /** 2243 * Replace placeholders with proper tokens after tokenizing. 2244 * 2245 * @param {object} env The environment of the `after-tokenize` hook. 2246 * @param {string} language The language id. 2247 */ 2248 value: function (env, language) { 2249 if (env.language !== language || !env.tokenStack) { 2250 return; 2251 } 2252 2253 // Switch the grammar back 2254 env.grammar = Prism.languages[language]; 2255 2256 var j = 0; 2257 var keys = Object.keys(env.tokenStack); 2258 2259 function walkTokens(tokens) { 2260 for (var i = 0; i < tokens.length; i++) { 2261 // all placeholders are replaced already 2262 if (j >= keys.length) { 2263 break; 2264 } 2265 2266 var token = tokens[i]; 2267 if (typeof token === 'string' || (token.content && typeof token.content === 'string')) { 2268 var k = keys[j]; 2269 var t = env.tokenStack[k]; 2270 var s = typeof token === 'string' ? token : token.content; 2271 var placeholder = getPlaceholder(language, k); 2272 2273 var index = s.indexOf(placeholder); 2274 if (index > -1) { 2275 ++j; 2276 2277 var before = s.substring(0, index); 2278 var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t); 2279 var after = s.substring(index + placeholder.length); 2280 2281 var replacement = []; 2282 if (before) { 2283 replacement.push.apply(replacement, walkTokens([before])); 2284 } 2285 replacement.push(middle); 2286 if (after) { 2287 replacement.push.apply(replacement, walkTokens([after])); 2288 } 2289 2290 if (typeof token === 'string') { 2291 tokens.splice.apply(tokens, [i, 1].concat(replacement)); 2292 } else { 2293 token.content = replacement; 2294 } 2295 } 2296 } else if (token.content /* && typeof token.content !== 'string' */) { 2297 walkTokens(token.content); 2298 } 2299 } 2300 2301 return tokens; 2302 } 2303 2304 walkTokens(env.tokens); 2305 } 2306 } 2307 }); 2308 2309}(Prism$1)); 2310 2311var prismRuby = {}; 2312 2313var hasRequiredPrismRuby; 2314 2315function requirePrismRuby () { 2316 if (hasRequiredPrismRuby) return prismRuby; 2317 hasRequiredPrismRuby = 1; 2318 (function (Prism) { 2319 Prism.languages.ruby = Prism.languages.extend('clike', { 2320 'comment': { 2321 pattern: /#.*|^=begin\s[\s\S]*?^=end/m, 2322 greedy: true 2323 }, 2324 'class-name': { 2325 pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/, 2326 lookbehind: true, 2327 inside: { 2328 'punctuation': /[.\\]/ 2329 } 2330 }, 2331 'keyword': /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/, 2332 'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/, 2333 'punctuation': /[(){}[\].,;]/, 2334 }); 2335 2336 Prism.languages.insertBefore('ruby', 'operator', { 2337 'double-colon': { 2338 pattern: /::/, 2339 alias: 'punctuation' 2340 }, 2341 }); 2342 2343 var interpolation = { 2344 pattern: /((?:^|[^\\])(?:\\{2}
2344)*)#\{(?:[^{}]|\{[^{}]*\})*\}/, 2345 lookbehind: true, 2346 inside: { 2347 'content': { 2348 pattern: /^(#\{)[\s\S]+(?=\}$)/, 2349 lookbehind: true, 2350 inside: Prism.languages.ruby 2351 }, 2352 'delimiter': { 2353 pattern: /^#\{|\}$/, 2354 alias: 'punctuation' 2355 } 2356 } 2357 }; 2358 2359 delete Prism.languages.ruby.function; 2360 2361 var percentExpression = '(?:' + [ 2362 /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source, 2363 /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source, 2364 /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source, 2365 /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source, 2366 /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source 2367 ].join('|') + ')'; 2368 2369 var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source; 2370 2371 Prism.languages.insertBefore('ruby', 'keyword', { 2372 'regex-literal': [ 2373 { 2374 pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source), 2375 greedy: true, 2376 inside: { 2377 'interpolation': interpolation, 2378 'regex': /[\s\S]+/ 2379 } 2380 }, 2381 { 2382 pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/, 2383 lookbehind: true, 2384 greedy: true, 2385 inside: { 2386 'interpolation': interpolation, 2387 'regex': /[\s\S]+/ 2388 } 2389 } 2390 ], 2391 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/, 2392 'symbol': [ 2393 { 2394 pattern: RegExp(/(^|[^:]):/.source + symbolName), 2395 lookbehind: true, 2396 greedy: true 2397 }, 2398 { 2399 pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source), 2400 lookbehind: true, 2401 greedy: true 2402 }, 2403 ], 2404 'method-definition': { 2405 pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/, 2406 lookbehind: true, 2407 inside: { 2408 'function': /\b\w+$/, 2409 'keyword': /^self\b/, 2410 'class-name': /^\w+/, 2411 'punctuation': /\./ 2412 } 2413 } 2414 }); 2415 2416 Prism.languages.insertBefore('ruby', 'string', { 2417 'string-literal': [ 2418 { 2419 pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression), 2420 greedy: true, 2421 inside: { 2422 'interpolation': interpolation, 2423 'string': /[\s\S]+/ 2424 } 2425 }, 2426 { 2427 pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/, 2428 greedy: true, 2429 inside: { 2430 'interpolation': interpolation, 2431 'string': /[\s\S]+/ 2432 } 2433 }, 2434 { 2435 pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i, 2436 alias: 'heredoc-string', 2437 greedy: true, 2438 inside: { 2439 'delimiter': { 2440 pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i, 2441 inside: { 2442 'symbol': /\b\w+/, 2443 'punctuation': /^<<[-~]?/ 2444 } 2445 }, 2446 'interpolation': interpolation, 2447 'string': /[\s\S]+/ 2448 } 2449 }, 2450 { 2451 pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i, 2452 alias: 'heredoc-string', 2453 greedy: true, 2454 inside: { 2455 'delimiter': { 2456 pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i, 2457 inside: { 2458 'symbol': /\b\w+/, 2459 'punctuation': /^<<[-~]?'|'$/, 2460 } 2461 }, 2462 'string': /[\s\S]+/ 2463 } 2464 } 2465 ], 2466 'command-literal': [ 2467 { 2468 pattern: RegExp(/%x/.source + percentExpression), 2469 greedy: true, 2470 inside: { 2471 'interpolation': interpolation, 2472 'command': { 2473 pattern: /[\s\S]+/, 2474 alias: 'string' 2475 } 2476 } 2477 }, 2478 { 2479 pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/, 2480 greedy: true, 2481 inside: { 2482 'interpolation': interpolation, 2483 'command': { 2484 pattern: /[\s\S]+/, 2485 alias: 'string' 2486 } 2487 } 2488 } 2489 ] 2490 }); 2491 2492 delete Prism.languages.ruby.string; 2493 2494 Prism.languages.insertBefore('ruby', 'number', { 2495 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/, 2496 'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/ 2497 }); 2498 2499 Prism.languages.rb = Prism.languages.ruby; 2500 }(Prism$1)); 2501 return prismRuby; 2502} 2503 2504requirePrismRuby(); 2505 2506var prismPhp = {}; 2507 2508var hasRequiredPrismPhp; 2509 2510function requirePrismPhp () { 2511 if (hasRequiredPrismPhp) return prismPhp; 2512 hasRequiredPrismPhp = 1; 2513 (function (Prism) { 2514 var comment = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/; 2515 var constant = [ 2516 { 2517 pattern: /\b(?:false|true)\b/i, 2518 alias: 'boolean' 2519 }, 2520 { 2521 pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i, 2522 greedy: true, 2523 lookbehind: true, 2524 }, 2525 { 2526 pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i, 2527 greedy: true, 2528 lookbehind: true, 2529 }, 2530 /\b(?:null)\b/i, 2531 /\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/, 2532 ]; 2533 var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i; 2534 var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/; 2535 var punctuation = /[{}\[\](),:;]/; 2536 2537 Prism.languages.php = { 2538 'delimiter': { 2539 pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
2540 alias: 'important' 2541 }, 2542 'comment': comment, 2543 'variable': /\$+(?:\w+\b|(?=\{))/, 2544 'package': { 2545 pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i, 2546 lookbehind: true, 2547 inside: { 2548 'punctuation': /\\/ 2549 } 2550 }, 2551 'class-name-definition': { 2552 pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i, 2553 lookbehind: true, 2554 alias: 'class-name' 2555 }, 2556 'function-definition': { 2557 pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i, 2558 lookbehind: true, 2559 alias: 'function' 2560 }, 2561 'keyword': [ 2562 { 2563 pattern: /(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i, 2564 alias: 'type-casting', 2565 greedy: true, 2566 lookbehind: true 2567 }, 2568 { 2569 pattern: /([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i, 2570 alias: 'type-hint', 2571 greedy: true, 2572 lookbehind: true 2573 }, 2574 { 2575 pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i, 2576 alias: 'return-type', 2577 greedy: true, 2578 lookbehind: true 2579 }, 2580 { 2581 pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i, 2582 alias: 'type-declaration', 2583 greedy: true 2584 }, 2585 { 2586 pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i, 2587 alias: 'type-declaration', 2588 greedy: true, 2589 lookbehind: true 2590 }, 2591 { 2592 pattern: /\b(?:parent|self|static)(?=\s*::)/i, 2593 alias: 'static-context', 2594 greedy: true 2595 }, 2596 { 2597 // yield from 2598 pattern: /(\byield\s+)from\b/i, 2599 lookbehind: true 2600 }, 2601 // `class` is always a keyword unlike other keywords 2602 /\bclass\b/i, 2603 { 2604 // https://www.php.net/manual/en/reserved.keywords.php 2605 // 2606 // keywords cannot be preceded by "->" 2607 // the complex lookbehind means `(?<!(?:->|::)\s*)` 2608 pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i, 2609 lookbehind: true 2610 } 2611 ], 2612 'argument-name': { 2613 pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i, 2614 lookbehind: true 2615 }, 2616 'class-name': [ 2617 { 2618 pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i, 2619 greedy: true, 2620 lookbehind: true 2621 }, 2622 { 2623 pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i, 2624 greedy: true, 2625 lookbehind: true 2626 }, 2627 { 2628 pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i, 2629 greedy: true 2630 }, 2631 { 2632 pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i, 2633 alias: 'class-name-fully-qualified', 2634 greedy: true, 2635 lookbehind: true, 2636 inside: { 2637 'punctuation': /\\/ 2638 } 2639 }, 2640 { 2641 pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i, 2642 alias: 'class-name-fully-qualified', 2643 greedy: true, 2644 inside: { 2645 'punctuation': /\\/ 2646 } 2647 }, 2648 { 2649 pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i, 2650 alias: 'class-name-fully-qualified', 2651 greedy: true, 2652 lookbehind: true, 2653 inside: { 2654 'punctuation': /\\/ 2655 } 2656 }, 2657 { 2658 pattern: /\b[a-z_]\w*(?=\s*\$)/i, 2659 alias: 'type-declaration', 2660 greedy: true 2661 }, 2662 { 2663 pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i, 2664 alias: ['class-name-fully-qualified', 'type-declaration'], 2665 greedy: true, 2666 inside: { 2667 'punctuation': /\\/ 2668 } 2669 }, 2670 { 2671 pattern: /\b[a-z_]\w*(?=\s*::)/i, 2672 alias: 'static-context', 2673 greedy: true 2674 }, 2675 { 2676 pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,
2677 alias: ['class-name-fully-qualified', 'static-context'], 2678 greedy: true, 2679 inside: { 2680 'punctuation': /\\/ 2681 } 2682 }, 2683 { 2684 pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i, 2685 alias: 'type-hint', 2686 greedy: true, 2687 lookbehind: true 2688 }, 2689 { 2690 pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i, 2691 alias: ['class-name-fully-qualified', 'type-hint'], 2692 greedy: true, 2693 lookbehind: true, 2694 inside: { 2695 'punctuation': /\\/ 2696 } 2697 }, 2698 { 2699 pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i, 2700 alias: 'return-type', 2701 greedy: true, 2702 lookbehind: true 2703 }, 2704 { 2705 pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i, 2706 alias: ['class-name-fully-qualified', 'return-type'], 2707 greedy: true, 2708 lookbehind: true, 2709 inside: { 2710 'punctuation': /\\/ 2711 } 2712 } 2713 ], 2714 'constant': constant, 2715 'function': { 2716 pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i, 2717 lookbehind: true, 2718 inside: { 2719 'punctuation': /\\/ 2720 } 2721 }, 2722 'property': { 2723 pattern: /(->\s*)\w+/, 2724 lookbehind: true 2725 }, 2726 'number': number, 2727 'operator': operator, 2728 'punctuation': punctuation 2729 }; 2730 2731 var string_interpolation = { 2732 pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/, 2733 lookbehind: true, 2734 inside: Prism.languages.php 2735 }; 2736 2737 var string = [ 2738 { 2739 pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/, 2740 alias: 'nowdoc-string', 2741 greedy: true, 2742 inside: { 2743 'delimiter': { 2744 pattern: /^<<<'[^']+'|[a-z_]\w*;$/i, 2745 alias: 'symbol', 2746 inside: { 2747 'punctuation': /^<<<'?|[';]$/ 2748 } 2749 } 2750 } 2751 }, 2752 { 2753 pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i, 2754 alias: 'heredoc-string', 2755 greedy: true, 2756 inside: { 2757 'delimiter': { 2758 pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i, 2759 alias: 'symbol', 2760 inside: { 2761 'punctuation': /^<<<"?|[";]$/ 2762 } 2763 }, 2764 'interpolation': string_interpolation 2765 } 2766 }, 2767 { 2768 pattern: /`(?:\\[\s\S]|[^\\`])*`/, 2769 alias: 'backtick-quoted-string', 2770 greedy: true 2771 }, 2772 { 2773 pattern: /'(?:\\[\s\S]|[^\\'])*'/, 2774 alias: 'single-quoted-string', 2775 greedy: true 2776 }, 2777 { 2778 pattern: /"(?:\\[\s\S]|[^\\"])*"/, 2779 alias: 'double-quoted-string', 2780 greedy: true, 2781 inside: { 2782 'interpolation': string_interpolation 2783 } 2784 } 2785 ]; 2786 2787 Prism.languages.insertBefore('php', 'variable', { 2788 'string': string, 2789 'attribute': { 2790 pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im, 2791 greedy: true, 2792 inside: { 2793 'attribute-content': { 2794 pattern: /^(#\[)[\s\S]+(?=\]$)/, 2795 lookbehind: true, 2796 // inside can appear subset of php 2797 inside: { 2798 'comment': comment, 2799 'string': string, 2800 'attribute-class-name': [ 2801 { 2802 pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i, 2803 alias: 'class-name', 2804 greedy: true, 2805 lookbehind: true 2806 }, 2807 { 2808 pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i, 2809 alias: [ 2810 'class-name', 2811 'class-name-fully-qualified' 2812 ], 2813 greedy: true, 2814 lookbehind: true, 2815 inside: { 2816 'punctuation': /\\/ 2817 } 2818 } 2819 ], 2820 'constant': constant, 2821 'number': number, 2822 'operator': operator, 2823 'punctuation': punctuation 2824 } 2825 }, 2826 'delimiter': { 2827 pattern: /^#\[|\]$/, 2828 alias: 'punctuation' 2829 } 2830 } 2831 }, 2832 }); 2833 2834 Prism.hooks.add('before-tokenize', function (env) { 2835 if (!/<\?/.test(env.code)) { 2836 return; 2837 } 2838 2839 var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g; 2840 Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern); 2841 }); 2842 2843 Prism.hooks.add('after-tokenize', function (env) { 2844 Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php'); 2845 }); 2846 2847 }(Prism$1)); 2848 return prismPhp; 2849} 2850 2851requirePrismPhp(); 2852 2853Prism$1.languages.go = Prism$1.languages.extend('clike', { 2854 'string': { 2855 pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/, 2856 lookbehind: true, 2857 greedy: true 2858 }, 2859 'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/, 2860 'boolean': /\b(?:_|false|iota|nil|true)\b/, 2861 'number': [ 2862 // binary and octal integers 2863 /\b0(?:b[01_]+|o[0-7_]+)i?\b/i, 2864 // hexadecimal integers and floats 2865 /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i, 2866 // decimal integers and floats 2867 /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i 2868 ], 2869 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./, 2870 'builtin': /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/ 2871}); 2872 2873Prism$1.languages.insertBefore('go', 'string', { 2874 'char': { 2875 pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/, 2876 greedy: true 2877 } 2878}); 2879 2880delete Prism$1.languages.go['class-name']; 2881 2882(function (Prism) { 2883 // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|' 2884 // + LC_ALL, RANDOM, REPLY, SECONDS. 2885 // + make sure PS1..4 are here as they are not always set, 2886 // - some useless things. 2887 var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_
2887CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b'; 2888 2889 var commandAfterHeredoc = { 2890 pattern: /(^(["']?)\w+\2)[ \t]+\S.*/, 2891 lookbehind: true, 2892 alias: 'punctuation', // this looks reasonably well in all themes 2893 inside: null // see below 2894 }; 2895 2896 var insideString = { 2897 'bash': commandAfterHeredoc, 2898 'environment': { 2899 pattern: RegExp('\\$' + envVars), 2900 alias: 'constant' 2901 }, 2902 'variable': [ 2903 // [0]: Arithmetic Environment 2904 { 2905 pattern: /\$?\(\([\s\S]+?\)\)/, 2906 greedy: true, 2907 inside: { 2908 // If there is a $ sign at the beginning highlight $(( and )) as variable 2909 'variable': [ 2910 { 2911 pattern: /(^\$\(\([\s\S]+)\)\)/, 2912 lookbehind: true 2913 }, 2914 /^\$\(\(/ 2915 ], 2916 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/, 2917 // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic 2918 'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/, 2919 // If there is no $ sign at the beginning highlight (( and )) as punctuation 2920 'punctuation': /\(\(?|\)\)?|,|;/ 2921 } 2922 }, 2923 // [1]: Command Substitution 2924 { 2925 pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/, 2926 greedy: true, 2927 inside: { 2928 'variable': /^\$\(|^`|\)$|`$/ 2929 } 2930 }, 2931 // [2]: Brace expansion 2932 { 2933 pattern: /\$\{[^}]+\}/, 2934 greedy: true, 2935 inside: { 2936 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/, 2937 'punctuation': /[\[\]]/, 2938 'environment': { 2939 pattern: RegExp('(\\{)' + envVars), 2940 lookbehind: true, 2941 alias: 'constant' 2942 } 2943 } 2944 }, 2945 /\$(?:\w+|[#?*!@$])/ 2946 ], 2947 // Escape sequences from echo and printf's manuals, and escaped quotes. 2948 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/ 2949 }; 2950 2951 Prism.languages.bash = { 2952 'shebang': { 2953 pattern: /^#!\s*\/.*/, 2954 alias: 'important' 2955 }, 2956 'comment': { 2957 pattern: /(^|[^"{\\$])#.*/, 2958 lookbehind: true 2959 }, 2960 'function-name': [ 2961 // a) function foo { 2962 // b) foo() { 2963 // c) function foo() { 2964 // but not âfoo {â 2965 { 2966 // a) and c) 2967 pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/, 2968 lookbehind: true, 2969 alias: 'function' 2970 }, 2971 { 2972 // b) 2973 pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/, 2974 alias: 'function' 2975 } 2976 ], 2977 // Highlight variable names as variables in for and select beginnings. 2978 'for-or-select': { 2979 pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/, 2980 alias: 'variable', 2981 lookbehind: true 2982 }, 2983 // Highlight variable names as variables in the left-hand part 2984 // of assignments (â=â and â+=â). 2985 'assign-left': { 2986 pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/, 2987 inside: { 2988 'environment': { 2989 pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars), 2990 lookbehind: true, 2991 alias: 'constant' 2992 } 2993 }, 2994 alias: 'variable', 2995 lookbehind: true 2996 }, 2997 // Highlight parameter names as variables 2998 'parameter': { 2999 pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/, 3000 alias: 'variable', 3001 lookbehind: true 3002 }, 3003 'string': [ 3004 // Support for Here-documents https://en.wikipedia.org/wiki/Here_document 3005 { 3006 pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/, 3007 lookbehind: true, 3008 greedy: true, 3009 inside: insideString 3010 }, 3011 // Here-document with quotes around the tag 3012 // â No expansion (so no âinsideâ). 3013 { 3014 pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/, 3015 lookbehind: true, 3016 greedy: true, 3017 inside: { 3018 'bash': commandAfterHeredoc 3019 } 3020 }, 3021 // âNormalâ string 3022 { 3023 // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html 3024 pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/, 3025 lookbehind: true, 3026 greedy: true, 3027 inside: insideString 3028 }, 3029 { 3030 // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html 3031 pattern: /(^|[^$\\])'[^']*'/, 3032 lookbehind: true, 3033 greedy: true 3034 }, 3035 { 3036 // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html 3037 pattern: /\$'(?:[^'\\]|\\[\s\S])*'/, 3038 greedy: true, 3039 inside: { 3040 'entity': insideString.entity 3041 } 3042 } 3043 ], 3044 'environment': { 3045 pattern: RegExp('\\$?' + envVars), 3046 alias: 'constant' 3047 }, 3048 'variable': insideString.variable, 3049 'function': { 3050 pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|
3050ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/, 3051 lookbehind: true 3052 }, 3053 'keyword': { 3054 pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/, 3055 lookbehind: true 3056 }, 3057 // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html 3058 'builtin': { 3059 pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/, 3060 lookbehind: true, 3061 // Alias added to make those easier to distinguish from strings. 3062 alias: 'class-name' 3063 }, 3064 'boolean': { 3065 pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/, 3066 lookbehind: true 3067 }, 3068 'file-descriptor': { 3069 pattern: /\B&\d\b/, 3070 alias: 'important' 3071 }, 3072 'operator': { 3073 // Lots of redirections here, but not just that. 3074 pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/, 3075 inside: { 3076 'file-descriptor': { 3077 pattern: /^\d/, 3078 alias: 'important' 3079 } 3080 } 3081 }, 3082 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/, 3083 'number': { 3084 pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/, 3085 lookbehind: true 3086 } 3087 }; 3088 3089 commandAfterHeredoc.inside = Prism.languages.bash; 3090 3091 /* Patterns in command substitution. */ 3092 var toBeCopied = [ 3093 'comment', 3094 'function-name', 3095 'for-or-select', 3096 'assign-left', 3097 'parameter', 3098 'string', 3099 'environment', 3100 'function', 3101 'keyword', 3102 'builtin', 3103 'boolean', 3104 'file-descriptor', 3105 'operator', 3106 'punctuation', 3107 'number' 3108 ]; 3109 var inside = insideString.variable[1].inside; 3110 for (var i = 0; i < toBeCopied.length; i++) { 3111 inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]]; 3112 } 3113 3114 Prism.languages.sh = Prism.languages.bash; 3115 Prism.languages.shell = Prism.languages.bash; 3116}(Prism$1)); 3117 3118// https://www.json.org/json-en.html 3119Prism$1.languages.json = { 3120 'property': { 3121 pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/, 3122 lookbehind: true, 3123 greedy: true 3124 }, 3125 'string': { 3126 pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/, 3127 lookbehind: true, 3128 greedy: true 3129 }, 3130 'comment': { 3131 pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/, 3132 greedy: true 3133 }, 3134 'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i, 3135 'punctuation': /[{}[\],]/, 3136 'operator': /:/, 3137 'boolean': /\b(?:false|true)\b/, 3138 'null': { 3139 pattern: /\bnull\b/, 3140 alias: 'keyword' 3141 } 3142}; 3143 3144Prism$1.languages.webmanifest = Prism$1.languages.json; 3145 3146(function (Prism) { 3147 3148 Prism.languages.diff = { 3149 'coord': [ 3150 // Match all kinds of coord lines (prefixed by "+++", "---" or "***"). 3151 /^(?:\*{3}|-{3}|\+{3}).*$/m, 3152 // Match "@@ ... @@" coord lines in unified diff. 3153 /^@@.*@@$/m, 3154 // Match coord lines in normal diff (starts with a number). 3155 /^\d.*$/m 3156 ] 3157 3158 // deleted, inserted, unchanged, diff 3159 }; 3160 3161 /** 3162 * A map from the name of a block to its line prefix. 3163 * 3164 * @type {Object<string, string>} 3165 */ 3166 var PREFIXES = { 3167 'deleted-sign': '-', 3168 'deleted-arrow': '<', 3169 'inserted-sign': '+', 3170 'inserted-arrow': '>', 3171 'unchanged': ' ', 3172 'diff': '!', 3173 }; 3174 3175 // add a token for each prefix
vendor: 1,050 bytes, lines 3176-3216
3176 Object.keys(PREFIXES).forEach(function (name) { 3177 var prefix = PREFIXES[name]; 3178 3179 var alias = []; 3180 if (!/^\w+$/.test(name)) { // "deleted-sign" -> "deleted" 3181 alias.push(/\w+/.exec(name)[0]); 3182 } 3183 if (name === 'diff') { 3184 alias.push('bold'); 3185 } 3186 3187 Prism.languages.diff[name] = { 3188 pattern: RegExp('^(?:[' + prefix + '].*(?:\r\n?|\n|(?![\\s\\S])))+', 'm'), 3189 alias: alias, 3190 inside: { 3191 'line': { 3192 pattern: /(.)(?=[\s\S]).*(?:\r\n?|\n)?/, 3193 lookbehind: true 3194 }, 3195 'prefix': { 3196 pattern: /[\s\S]/, 3197 alias: /\w+/.exec(name)[0] 3198 } 3199 } 3200 }; 3201 3202 }); 3203 3204 // make prefixes available to Diff plugin 3205 Object.defineProperty(Prism.languages.diff, 'PREFIXES', { 3206 value: PREFIXES 3207 }); 3208 3209}(Prism$1)); 3210 3211// Configure Prism for manual highlighting mode 3212// This must be set before importing prismjs 3213window.Prism = window.Prism || {}; 3214window.Prism.manual = true; 3215 3216/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0
vendor: 17,189 bytes, lines 3216-3514
3216/LICENSE */ 3217 3218const { 3219 entries, 3220 setPrototypeOf, 3221 isFrozen, 3222 getPrototypeOf, 3223 getOwnPropertyDescriptor 3224} = Object; 3225let { 3226 freeze, 3227 seal, 3228 create 3229} = Object; // eslint-disable-line import/no-mutable-exports 3230let { 3231 apply, 3232 construct 3233} = typeof Reflect !== 'undefined' && Reflect; 3234if (!freeze) { 3235 freeze = function freeze(x) { 3236 return x; 3237 }; 3238} 3239if (!seal) { 3240 seal = function seal(x) { 3241 return x; 3242 }; 3243} 3244if (!apply) { 3245 apply = function apply(func, thisArg) { 3246 for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { 3247 args[_key - 2] = arguments[_key]; 3248 } 3249 return func.apply(thisArg, args); 3250 }; 3251} 3252if (!construct) { 3253 construct = function construct(Func) { 3254 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 3255 args[_key2 - 1] = arguments[_key2]; 3256 } 3257 return new Func(...args); 3258 }; 3259} 3260const arrayForEach = unapply(Array.prototype.forEach); 3261const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf); 3262const arrayPop = unapply(Array.prototype.pop); 3263const arrayPush = unapply(Array.prototype.push); 3264const arraySplice = unapply(Array.prototype.splice); 3265const stringToLowerCase = unapply(String.prototype.toLowerCase); 3266const stringToString = unapply(String.prototype.toString); 3267const stringMatch = unapply(String.prototype.match); 3268const stringReplace = unapply(String.prototype.replace); 3269const stringIndexOf = unapply(String.prototype.indexOf); 3270const stringTrim = unapply(String.prototype.trim); 3271const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty); 3272const regExpTest = unapply(RegExp.prototype.test); 3273const typeErrorCreate = unconstruct(TypeError); 3274/** 3275 * Creates a new function that calls the given function with a specified thisArg and arguments. 3276 * 3277 * @param func - The function to be wrapped and called. 3278 * @returns A new function that calls the given function with a specified thisArg and arguments. 3279 */ 3280function unapply(func) { 3281 return function (thisArg) { 3282 if (thisArg instanceof RegExp) { 3283 thisArg.lastIndex = 0; 3284 } 3285 for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { 3286 args[_key3 - 1] = arguments[_key3]; 3287 } 3288 return apply(func, thisArg, args); 3289 }; 3290} 3291/** 3292 * Creates a new function that constructs an instance of the given constructor function with the provided arguments. 3293 * 3294 * @param func - The constructor function to be wrapped and called. 3295 * @returns A new function that constructs an instance of the given constructor function with the provided arguments. 3296 */ 3297function unconstruct(Func) { 3298 return function () { 3299 for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { 3300 args[_key4] = arguments[_key4]; 3301 } 3302 return construct(Func, args); 3303 }; 3304} 3305/** 3306 * Add properties to a lookup table 3307 * 3308 * @param set - The set to which elements will be added. 3309 * @param array - The array containing elements to be added to the set. 3310 * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set. 3311 * @returns The modified set with added elements. 3312 */ 3313function addToSet(set, array) { 3314 let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase; 3315 if (setPrototypeOf) { 3316 // Make 'in' and truthy checks like Boolean(set.constructor) 3317 // independent of any properties defined on Object.prototype. 3318 // Prevent prototype setters from intercepting set as a this value. 3319 setPrototypeOf(set, null); 3320 } 3321 let l = array.length; 3322 while (l--) { 3323 let element = array[l]; 3324 if (typeof element === 'string') { 3325 const lcElement = transformCaseFunc(element); 3326 if (lcElement !== element) { 3327 // Config presets (e.g. tags.js, attrs.js) are immutable. 3328 if (!isFrozen(array)) { 3329 array[l] = lcElement; 3330 } 3331 element = lcElement; 3332 } 3333 } 3334 set[element] = true; 3335 } 3336 return set; 3337} 3338/** 3339 * Clean up an array to harden against CSPP 3340 * 3341 * @param array - The array to be cleaned. 3342 * @returns The cleaned version of the array 3343 */ 3344function cleanArray(array) { 3345 for (let index = 0; index < array.length; index++) { 3346 const isPropertyExist = objectHasOwnProperty(array, index); 3347 if (!isPropertyExist) { 3348 array[index] = null; 3349 } 3350 } 3351 return array; 3352} 3353/** 3354 * Shallow clone an object 3355 * 3356 * @param object - The object to be cloned. 3357 * @returns A new object that copies the original. 3358 */ 3359function clone(object) { 3360 const newObject = create(null); 3361 for (const [property, value] of entries(object)) { 3362 const isPropertyExist = objectHasOwnProperty(object, property); 3363 if (isPropertyExist) { 3364 if (Array.isArray(value)) { 3365 newObject[property] = cleanArray(value); 3366 } else if (value && typeof value === 'object' && value.constructor === Object) { 3367 newObject[property] = clone(value); 3368 } else { 3369 newObject[property] = value; 3370 } 3371 } 3372 } 3373 return newObject; 3374} 3375/** 3376 * This method automatically checks if the prop is function or getter and behaves accordingly. 3377 * 3378 * @param object - The object to look up the getter function in its prototype chain. 3379 * @param prop - The property name for which to find the getter function. 3380 * @returns The getter function found in the prototype chain or a fallback function. 3381 */ 3382function lookupGetter(object, prop) { 3383 while (object !== null) { 3384 const desc = getOwnPropertyDescriptor(object, prop); 3385 if (desc) { 3386 if (desc.get) { 3387 return unapply(desc.get); 3388 } 3389 if (typeof desc.value === 'function') { 3390 return unapply(desc.value); 3391 } 3392 } 3393 object = getPrototypeOf(object); 3394 } 3395 function fallbackValue() { 3396 return null; 3397 } 3398 return fallbackValue; 3399} 3400 3401const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); 3402const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); 3403const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); 3404// List of SVG elements that are disallowed by default. 3405// We still need to know them so that we can do namespace 3406// checks properly in case one wants to add them to 3407// allow-list. 3408const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); 3409const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); 3410// Similarly to SVG, we want to know all MathML elements, 3411// even those that we disallow by default. 3412const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); 3413const text = freeze(['#text']); 3414 3415const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']); 3416const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); 3417const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); 3418const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); 3419 3420// eslint-disable-next-line unicorn/better-regex 3421const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode 3422const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); 3423const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex 3424const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape 3425const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape 3426const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape 3427); 3428const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); 3429const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex 3430); 3431const DOCTYPE_NAME = seal(/^html$/i); 3432const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); 3433 3434var EXPRESSIONS = /*#__PURE__*/Object.freeze({ 3435 __proto__: null, 3436 ARIA_ATTR: ARIA_ATTR, 3437 ATTR_WHITESPACE: ATTR_WHITESPACE, 3438 CUSTOM_ELEMENT: CUSTOM_ELEMENT, 3439 DATA_ATTR: DATA_ATTR, 3440 DOCTYPE_NAME: DOCTYPE_NAME, 3441 ERB_EXPR: ERB_EXPR, 3442 IS_ALLOWED_URI: IS_ALLOWED_URI, 3443 IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA, 3444 MUSTACHE_EXPR: MUSTACHE_EXPR, 3445 TMPLIT_EXPR: TMPLIT_EXPR 3446}); 3447 3448/* eslint-disable @typescript-eslint/indent */ 3449// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType 3450const NODE_TYPE = { 3451 element: 1, 3452 text: 3, 3453 // Deprecated 3454 progressingInstruction: 7, 3455 comment: 8, 3456 document: 9}; 3457const getGlobal = function getGlobal() { 3458 return typeof window === 'undefined' ? null : window; 3459}; 3460/** 3461 * Creates a no-op policy for internal use only. 3462 * Don't export this function outside this module! 3463 * @param trustedTypes The policy factory. 3464 * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix). 3465 * @return The policy created (or null, if Trusted Types 3466 * are not supported or creating the policy failed). 3467 */ 3468const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) { 3469 if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') { 3470 return null; 3471 } 3472 // Allow the callers to control the unique policy name 3473 // by adding a data-tt-policy-suffix to the script element with the DOMPurify. 3474 // Policy creation with duplicate names throws in Trusted Types. 3475 let suffix = null; 3476 const ATTR_NAME = 'data-tt-policy-suffix'; 3477 if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) { 3478 suffix = purifyHostElement.getAttribute(ATTR_NAME); 3479 } 3480 const policyName = 'dompurify' + (suffix ? '#' + suffix : ''); 3481 try { 3482 return trustedTypes.createPolicy(policyName, { 3483 createHTML(html) { 3484 return html; 3485 }, 3486 createScriptURL(scriptUrl) { 3487 return scriptUrl; 3488 } 3489 }); 3490 } catch (_) { 3491 // Policy creation failed (most likely another DOMPurify script has 3492 // already run). Skip creating the policy, as this will only cause errors 3493 // if TT are enforced. 3494 console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); 3495 return null; 3496 } 3497}; 3498const _createHooksMap = function _createHooksMap() { 3499 return { 3500 afterSanitizeAttributes: [], 3501 afterSanitizeElements: [], 3502 afterSanitizeShadowDOM: [], 3503 beforeSanitizeAttributes: [], 3504 beforeSanitizeElements: [], 3505 beforeSanitizeShadowDOM: [], 3506 uponSanitizeAttribute: [], 3507 uponSanitizeElement: [], 3508 uponSanitizeShadowNode: [] 3509 }; 3510}; 3511function createDOMPurify() { 3512 let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); 3513 const DOMPurify = root => createDOMPurify(root); 3514 DOMPurify.version = '3.3.
35140
vendor: 7,668 bytes, lines 3514-3703
3514'; 3515 DOMPurify.removed = []; 3516 if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) { 3517 // Not running in a browser, provide a factory function 3518 // so that you can pass your own Window 3519 DOMPurify.isSupported = false; 3520 return DOMPurify; 3521 } 3522 let { 3523 document 3524 } = window; 3525 const originalDocument = document; 3526 const currentScript = originalDocument.currentScript; 3527 const { 3528 DocumentFragment, 3529 HTMLTemplateElement, 3530 Node, 3531 Element, 3532 NodeFilter, 3533 NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap, 3534 HTMLFormElement, 3535 DOMParser, 3536 trustedTypes 3537 } = window; 3538 const ElementPrototype = Element.prototype; 3539 const cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); 3540 const remove = lookupGetter(ElementPrototype, 'remove'); 3541 const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); 3542 const getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); 3543 const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); 3544 // As per issue #47, the web-components registry is inherited by a 3545 // new document created via createHTMLDocument. As per the spec 3546 // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) 3547 // a new empty registry is used when creating a template contents owner 3548 // document, so we use that as our parent document to ensure nothing 3549 // is inherited. 3550 if (typeof HTMLTemplateElement === 'function') { 3551 const template = document.createElement('template'); 3552 if (template.content && template.content.ownerDocument) { 3553 document = template.content.ownerDocument; 3554 } 3555 } 3556 let trustedTypesPolicy; 3557 let emptyHTML = ''; 3558 const { 3559 implementation, 3560 createNodeIterator, 3561 createDocumentFragment, 3562 getElementsByTagName 3563 } = document; 3564 const { 3565 importNode 3566 } = originalDocument; 3567 let hooks = _createHooksMap(); 3568 /** 3569 * Expose whether this browser supports running the full DOMPurify. 3570 */ 3571 DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined; 3572 const { 3573 MUSTACHE_EXPR, 3574 ERB_EXPR, 3575 TMPLIT_EXPR, 3576 DATA_ATTR, 3577 ARIA_ATTR, 3578 IS_SCRIPT_OR_DATA, 3579 ATTR_WHITESPACE, 3580 CUSTOM_ELEMENT 3581 } = EXPRESSIONS; 3582 let { 3583 IS_ALLOWED_URI: IS_ALLOWED_URI$1 3584 } = EXPRESSIONS; 3585 /** 3586 * We consider the elements and attributes below to be safe. Ideally 3587 * don't add any new ones but feel free to remove unwanted ones. 3588 */ 3589 /* allowed element names */ 3590 let ALLOWED_TAGS = null; 3591 const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]); 3592 /* Allowed attribute names */ 3593 let ALLOWED_ATTR = null; 3594 const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]); 3595 /* 3596 * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements. 3597 * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements) 3598 * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list) 3599 * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`. 3600 */ 3601 let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, { 3602 tagNameCheck: { 3603 writable: true, 3604 configurable: false, 3605 enumerable: true, 3606 value: null 3607 }, 3608 attributeNameCheck: { 3609 writable: true, 3610 configurable: false, 3611 enumerable: true, 3612 value: null 3613 }, 3614 allowCustomizedBuiltInElements: { 3615 writable: true, 3616 configurable: false, 3617 enumerable: true, 3618 value: false 3619 } 3620 })); 3621 /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ 3622 let FORBID_TAGS = null; 3623 /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ 3624 let FORBID_ATTR = null; 3625 /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */ 3626 const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, { 3627 tagCheck: { 3628 writable: true, 3629 configurable: false, 3630 enumerable: true, 3631 value: null 3632 }, 3633 attributeCheck: { 3634 writable: true, 3635 configurable: false, 3636 enumerable: true, 3637 value: null 3638 } 3639 })); 3640 /* Decide if ARIA attributes are okay */ 3641 let ALLOW_ARIA_ATTR = true; 3642 /* Decide if custom data attributes are okay */ 3643 let ALLOW_DATA_ATTR = true; 3644 /* Decide if unknown protocols are okay */ 3645 let ALLOW_UNKNOWN_PROTOCOLS = false; 3646 /* Decide if self-closing tags in attributes are allowed. 3647 * Usually removed due to a mXSS issue in jQuery 3.0 */ 3648 let ALLOW_SELF_CLOSE_IN_ATTR = true; 3649 /* Output should be safe for common template engines. 3650 * This means, DOMPurify removes data attributes, mustaches and ERB 3651 */ 3652 let SAFE_FOR_TEMPLATES = false; 3653 /* Output should be safe even for XML used within HTML and alike. 3654 * This means, DOMPurify removes comments when containing risky content. 3655 */ 3656 let SAFE_FOR_XML = true; 3657 /* Decide if document with <html>... should be returned */ 3658 let WHOLE_DOCUMENT = false; 3659 /* Track whether config is already set on this instance of DOMPurify. */ 3660 let SET_CONFIG = false; 3661 /* Decide if all elements (e.g. style, script) must be children of 3662 * document.body. By default, browsers might move them to document.head */ 3663 let FORCE_BODY = false; 3664 /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html 3665 * string (or a TrustedHTML object if Trusted Types are supported). 3666 * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead 3667 */ 3668 let RETURN_DOM = false; 3669 /* Decide if a DOM `DocumentFragment` should be returned, instead of a html 3670 * string (or a TrustedHTML object if Trusted Types are supported) */ 3671 let RETURN_DOM_FRAGMENT = false; 3672 /* Try to return a Trusted Type object instead of a string, return a string in 3673 * case Trusted Types are not supported */ 3674 let RETURN_TRUSTED_TYPE = false; 3675 /* Output should be free from DOM clobbering attacks? 3676 * This sanitizes markups named with colliding, clobberable built-in DOM APIs. 3677 */ 3678 let SANITIZE_DOM = true; 3679 /* Achieve full DOM Clobbering protection by isolating the namespace of named 3680 * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules. 3681 * 3682 * HTML/DOM spec rules that enable DOM Clobbering: 3683 * - Named Access on Window (§7.3.3) 3684 * - DOM Tree Accessors (§3.1.5) 3685 * - Form Element Parent-Child Relations (§4.10.3) 3686 * - Iframe srcdoc / Nested WindowProxies (§4.8.5) 3687 * - HTMLCollection (§4.2.10.2) 3688 * 3689 * Namespace isolation is implemented by prefixing `id` and `name` attributes 3690 * with a constant string, i.e., `user-content-` 3691 */ 3692 let SANITIZE_NAMED_PROPS = false; 3693 const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-'; 3694 /* Keep element content when removing element? */ 3695 let KEEP_CONTENT = true; 3696 /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead 3697 * of importing it into a new Document and returning a sanitized copy */ 3698 let IN_PLACE = false; 3699 /* Allow usage of profiles like html, svg and mathMl */ 3700 let USE_PROFILES = {}; 3701 /* Tags to ignore content of when KEEP_CONTENT is true */ 3702 let FORBID_CONTENTS = null; 3703 const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'n
vendor: 2,204 bytes, lines 3703-3745
3703oscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); 3704 /* Tags that are safe for data: URIs */ 3705 let DATA_URI_TAGS = null; 3706 const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); 3707 /* Attributes safe for values like "javascript:" */ 3708 let URI_SAFE_ATTRIBUTES = null; 3709 const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); 3710 const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; 3711 const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; 3712 const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; 3713 /* Document namespace */ 3714 let NAMESPACE = HTML_NAMESPACE; 3715 let IS_EMPTY_INPUT = false; 3716 /* Allowed XHTML+XML namespaces */ 3717 let ALLOWED_NAMESPACES = null; 3718 const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString); 3719 let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); 3720 let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']); 3721 // Certain elements are allowed in both SVG and HTML 3722 // namespace. We need to specify them explicitly 3723 // so that they don't get erroneously deleted from 3724 // HTML namespace. 3725 const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); 3726 /* Parsing of strict XHTML documents */ 3727 let PARSER_MEDIA_TYPE = null; 3728 const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; 3729 const DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; 3730 let transformCaseFunc = null; 3731 /* Keep a reference to config to pass to hooks */ 3732 let CONFIG = null; 3733 /* Ideally, do not touch anything below this line */ 3734 /* ______________________________________________ */ 3735 const formElement = document.createElement('form'); 3736 const isRegexOrFunction = function isRegexOrFunction(testValue) { 3737 return testValue instanceof RegExp || testValue instanceof Function; 3738 }; 3739 /** 3740 * _parseConfig 3741 * 3742 * @param cfg optional config literal 3743 */ 3744 // eslint-disable-next-line complexity 3745 const _parseConfig = function _parseConfig() {
vendor: 4,404 bytes, lines 3746-3809
3746 let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3747 if (CONFIG && CONFIG === cfg) { 3748 return; 3749 } 3750 /* Shield configuration object from tampering */ 3751 if (!cfg || typeof cfg !== 'object') { 3752 cfg = {}; 3753 } 3754 /* Shield configuration object from prototype pollution */ 3755 cfg = clone(cfg); 3756 PARSER_MEDIA_TYPE = 3757 // eslint-disable-next-line unicorn/prefer-includes 3758 SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE; 3759 // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. 3760 transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase; 3761 /* Set configuration parameters */ 3762 ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; 3763 ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; 3764 ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES; 3765 URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES; 3766 DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS; 3767 FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; 3768 FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({}); 3769 FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({}); 3770 USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false; 3771 ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true 3772 ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true 3773 ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false 3774 ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true 3775 SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false 3776 SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true 3777 WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false 3778 RETURN_DOM = cfg.RETURN_DOM || false; // Default false 3779 RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false 3780 RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false 3781 FORCE_BODY = cfg.FORCE_BODY || false; // Default false 3782 SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true 3783 SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false 3784 KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true 3785 IN_PLACE = cfg.IN_PLACE || false; // Default false 3786 IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI; 3787 NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; 3788 MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS; 3789 HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS; 3790 CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {}; 3791 if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { 3792 CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; 3793 } 3794 if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) { 3795 CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; 3796 } 3797 if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') { 3798 CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; 3799 } 3800 if (SAFE_FOR_TEMPLATES) { 3801 ALLOW_DATA_ATTR = false; 3802 } 3803 if (RETURN_DOM_FRAGMENT) { 3804 RETURN_DOM = true; 3805 } 3806 /* Parse profile info */ 3807 if (USE_PROFILES) { 3808 ALLOWED_TAGS = addToSet({}, text); 3809 ALLOWED_ATTR =
vendor: 1,583 bytes, lines 3809-3856
3809[]; 3810 if (USE_PROFILES.html === true) { 3811 addToSet(ALLOWED_TAGS, html$1); 3812 addToSet(ALLOWED_ATTR, html); 3813 } 3814 if (USE_PROFILES.svg === true) { 3815 addToSet(ALLOWED_TAGS, svg$1); 3816 addToSet(ALLOWED_ATTR, svg); 3817 addToSet(ALLOWED_ATTR, xml); 3818 } 3819 if (USE_PROFILES.svgFilters === true) { 3820 addToSet(ALLOWED_TAGS, svgFilters); 3821 addToSet(ALLOWED_ATTR, svg); 3822 addToSet(ALLOWED_ATTR, xml); 3823 } 3824 if (USE_PROFILES.mathMl === true) { 3825 addToSet(ALLOWED_TAGS, mathMl$1); 3826 addToSet(ALLOWED_ATTR, mathMl); 3827 addToSet(ALLOWED_ATTR, xml); 3828 } 3829 } 3830 /* Merge configuration parameters */ 3831 if (cfg.ADD_TAGS) { 3832 if (typeof cfg.ADD_TAGS === 'function') { 3833 EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS; 3834 } else { 3835 if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { 3836 ALLOWED_TAGS = clone(ALLOWED_TAGS); 3837 } 3838 addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); 3839 } 3840 } 3841 if (cfg.ADD_ATTR) { 3842 if (typeof cfg.ADD_ATTR === 'function') { 3843 EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR; 3844 } else { 3845 if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { 3846 ALLOWED_ATTR = clone(ALLOWED_ATTR); 3847 } 3848 addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); 3849 } 3850 } 3851 if (cfg.ADD_URI_SAFE_ATTR) { 3852 addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); 3853 } 3854 if (cfg.FORBID_CONTENTS) { 3855 if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { 3856 FORBID_CONTENTS = clone
vendor: 8,107 bytes, lines 3856-4065
3856(FORBID_CONTENTS); 3857 } 3858 addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); 3859 } 3860 /* Add #text in case KEEP_CONTENT is set to true */ 3861 if (KEEP_CONTENT) { 3862 ALLOWED_TAGS['#text'] = true; 3863 } 3864 /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ 3865 if (WHOLE_DOCUMENT) { 3866 addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); 3867 } 3868 /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ 3869 if (ALLOWED_TAGS.table) { 3870 addToSet(ALLOWED_TAGS, ['tbody']); 3871 delete FORBID_TAGS.tbody; 3872 } 3873 if (cfg.TRUSTED_TYPES_POLICY) { 3874 if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') { 3875 throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); 3876 } 3877 if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') { 3878 throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); 3879 } 3880 // Overwrite existing TrustedTypes policy. 3881 trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; 3882 // Sign local variables required by `sanitize`. 3883 emptyHTML = trustedTypesPolicy.createHTML(''); 3884 } else { 3885 // Uninitialized policy, attempt to initialize the internal dompurify policy. 3886 if (trustedTypesPolicy === undefined) { 3887 trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript); 3888 } 3889 // If creating the internal policy succeeded sign internal variables. 3890 if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') { 3891 emptyHTML = trustedTypesPolicy.createHTML(''); 3892 } 3893 } 3894 // Prevent further manipulation of configuration. 3895 // Not available in IE8, Safari 5, etc. 3896 if (freeze) { 3897 freeze(cfg); 3898 } 3899 CONFIG = cfg; 3900 }; 3901 /* Keep track of all possible SVG and MathML tags 3902 * so that we can perform the namespace checks 3903 * correctly. */ 3904 const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]); 3905 const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]); 3906 /** 3907 * @param element a DOM element whose namespace is being checked 3908 * @returns Return false if the element has a 3909 * namespace that a spec-compliant parser would never 3910 * return. Return true otherwise. 3911 */ 3912 const _checkValidNamespace = function _checkValidNamespace(element) { 3913 let parent = getParentNode(element); 3914 // In JSDOM, if we're inside shadow DOM, then parentNode 3915 // can be null. We just simulate parent in this case. 3916 if (!parent || !parent.tagName) { 3917 parent = { 3918 namespaceURI: NAMESPACE, 3919 tagName: 'template' 3920 }; 3921 } 3922 const tagName = stringToLowerCase(element.tagName); 3923 const parentTagName = stringToLowerCase(parent.tagName); 3924 if (!ALLOWED_NAMESPACES[element.namespaceURI]) { 3925 return false; 3926 } 3927 if (element.namespaceURI === SVG_NAMESPACE) { 3928 // The only way to switch from HTML namespace to SVG 3929 // is via <svg>. If it happens via any other tag, then 3930 // it should be killed. 3931 if (parent.namespaceURI === HTML_NAMESPACE) { 3932 return tagName === 'svg'; 3933 } 3934 // The only way to switch from MathML to SVG is via` 3935 // svg if parent is either <annotation-xml> or MathML 3936 // text integration points. 3937 if (parent.namespaceURI === MATHML_NAMESPACE) { 3938 return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); 3939 } 3940 // We only allow elements that are defined in SVG 3941 // spec. All others are disallowed in SVG namespace. 3942 return Boolean(ALL_SVG_TAGS[tagName]); 3943 } 3944 if (element.namespaceURI === MATHML_NAMESPACE) { 3945 // The only way to switch from HTML namespace to MathML 3946 // is via <math>. If it happens via any other tag, then 3947 // it should be killed. 3948 if (parent.namespaceURI === HTML_NAMESPACE) { 3949 return tagName === 'math'; 3950 } 3951 // The only way to switch from SVG to MathML is via 3952 // <math> and HTML integration points 3953 if (parent.namespaceURI === SVG_NAMESPACE) { 3954 return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; 3955 } 3956 // We only allow elements that are defined in MathML 3957 // spec. All others are disallowed in MathML namespace. 3958 return Boolean(ALL_MATHML_TAGS[tagName]); 3959 } 3960 if (element.namespaceURI === HTML_NAMESPACE) { 3961 // The only way to switch from SVG to HTML is via 3962 // HTML integration points, and from MathML to HTML 3963 // is via MathML text integration points 3964 if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { 3965 return false; 3966 } 3967 if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { 3968 return false; 3969 } 3970 // We disallow tags that are specific for MathML 3971 // or SVG and should never appear in HTML namespace 3972 return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); 3973 } 3974 // For XHTML and XML documents that support custom namespaces 3975 if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) { 3976 return true; 3977 } 3978 // The code should never reach this place (this means 3979 // that the element somehow got namespace that is not 3980 // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES). 3981 // Return false just in case. 3982 return false; 3983 }; 3984 /** 3985 * _forceRemove 3986 * 3987 * @param node a DOM node 3988 */ 3989 const _forceRemove = function _forceRemove(node) { 3990 arrayPush(DOMPurify.removed, { 3991 element: node 3992 }); 3993 try { 3994 // eslint-disable-next-line unicorn/prefer-dom-node-remove 3995 getParentNode(node).removeChild(node); 3996 } catch (_) { 3997 remove(node); 3998 } 3999 }; 4000 /** 4001 * _removeAttribute 4002 * 4003 * @param name an Attribute name 4004 * @param element a DOM node 4005 */ 4006 const _removeAttribute = function _removeAttribute(name, element) { 4007 try { 4008 arrayPush(DOMPurify.removed, { 4009 attribute: element.getAttributeNode(name), 4010 from: element 4011 }); 4012 } catch (_) { 4013 arrayPush(DOMPurify.removed, { 4014 attribute: null, 4015 from: element 4016 }); 4017 } 4018 element.removeAttribute(name); 4019 // We void attribute values for unremovable "is" attributes 4020 if (name === 'is') { 4021 if (RETURN_DOM || RETURN_DOM_FRAGMENT) { 4022 try { 4023 _forceRemove(element); 4024 } catch (_) {} 4025 } else { 4026 try { 4027 element.setAttribute(name, ''); 4028 } catch (_) {} 4029 } 4030 } 4031 }; 4032 /** 4033 * _initDocument 4034 * 4035 * @param dirty - a string of dirty markup 4036 * @return a DOM, filled with the dirty markup 4037 */ 4038 const _initDocument = function _initDocument(dirty) { 4039 /* Create a HTML document */ 4040 let doc = null; 4041 let leadingWhitespace = null; 4042 if (FORCE_BODY) { 4043 dirty = '<remove></remove>' + dirty; 4044 } else { 4045 /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ 4046 const matches = stringMatch(dirty, /^[\r\n\t ]+/); 4047 leadingWhitespace = matches && matches[0]; 4048 } 4049 if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) { 4050 // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict) 4051 dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>'; 4052 } 4053 const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; 4054 /* 4055 * Use the DOMParser API by default, fallback later if needs be 4056 * DOMParser not work for svg when has multiple root element. 4057 */ 4058 if (NAMESPACE === HTML_NAMESPACE) { 4059 try { 4060 doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); 4061 } catch (_) {} 4062 } 4063 /* Use createHTMLDocument in case DOMParser is not available */ 4064 if (!doc || !doc.documentElement) { 4065 doc = implementation.createDocument(NAMESPACE, 'template', null);
vendor: 4,359 bytes, lines 4066-4161
4066 try { 4067 doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload; 4068 } catch (_) { 4069 // Syntax error if dirtyPayload is invalid xml 4070 } 4071 } 4072 const body = doc.body || doc.documentElement; 4073 if (dirty && leadingWhitespace) { 4074 body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null); 4075 } 4076 /* Work on whole document or just its body */ 4077 if (NAMESPACE === HTML_NAMESPACE) { 4078 return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; 4079 } 4080 return WHOLE_DOCUMENT ? doc.documentElement : body; 4081 }; 4082 /** 4083 * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. 4084 * 4085 * @param root The root element or node to start traversing on. 4086 * @return The created NodeIterator 4087 */ 4088 const _createNodeIterator = function _createNodeIterator(root) { 4089 return createNodeIterator.call(root.ownerDocument || root, root, 4090 // eslint-disable-next-line no-bitwise 4091 NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null); 4092 }; 4093 /** 4094 * _isClobbered 4095 * 4096 * @param element element to check for clobbering attacks 4097 * @return true if clobbered, false if safe 4098 */ 4099 const _isClobbered = function _isClobbered(element) { 4100 return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function'); 4101 }; 4102 /** 4103 * Checks whether the given object is a DOM node. 4104 * 4105 * @param value object to check whether it's a DOM node 4106 * @return true is object is a DOM node 4107 */ 4108 const _isNode = function _isNode(value) { 4109 return typeof Node === 'function' && value instanceof Node; 4110 }; 4111 function _executeHooks(hooks, currentNode, data) { 4112 arrayForEach(hooks, hook => { 4113 hook.call(DOMPurify, currentNode, data, CONFIG); 4114 }); 4115 } 4116 /** 4117 * _sanitizeElements 4118 * 4119 * @protect nodeName 4120 * @protect textContent 4121 * @protect removeChild 4122 * @param currentNode to check for permission to exist 4123 * @return true if node was killed, false if left alive 4124 */ 4125 const _sanitizeElements = function _sanitizeElements(currentNode) { 4126 let content = null; 4127 /* Execute a hook if present */ 4128 _executeHooks(hooks.beforeSanitizeElements, currentNode, null); 4129 /* Check if element is clobbered or can clobber */ 4130 if (_isClobbered(currentNode)) { 4131 _forceRemove(currentNode); 4132 return true; 4133 } 4134 /* Now let's check the element's type and name */ 4135 const tagName = transformCaseFunc(currentNode.nodeName); 4136 /* Execute a hook if present */ 4137 _executeHooks(hooks.uponSanitizeElement, currentNode, { 4138 tagName, 4139 allowedTags: ALLOWED_TAGS 4140 }); 4141 /* Detect mXSS attempts abusing namespace confusion */ 4142 if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) { 4143 _forceRemove(currentNode); 4144 return true; 4145 } 4146 /* Remove any occurrence of processing instructions */ 4147 if (currentNode.nodeType === NODE_TYPE.progressingInstruction) { 4148 _forceRemove(currentNode); 4149 return true; 4150 } 4151 /* Remove any kind of possibly harmful comments */ 4152 if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) { 4153 _forceRemove(currentNode); 4154 return true; 4155 } 4156 /* Remove element if anything forbids its presence */ 4157 if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) { 4158 /* Check if we have a custom element to handle */ 4159 if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) { 4160 if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) { 4161 return false;
vendor: 9,812 bytes, lines 4162-4365
4162 } 4163 if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) { 4164 return false; 4165 } 4166 } 4167 /* Keep content except for bad-listed elements */ 4168 if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { 4169 const parentNode = getParentNode(currentNode) || currentNode.parentNode; 4170 const childNodes = getChildNodes(currentNode) || currentNode.childNodes; 4171 if (childNodes && parentNode) { 4172 const childCount = childNodes.length; 4173 for (let i = childCount - 1; i >= 0; --i) { 4174 const childClone = cloneNode(childNodes[i], true); 4175 childClone.__removalCount = (currentNode.__removalCount || 0) + 1; 4176 parentNode.insertBefore(childClone, getNextSibling(currentNode)); 4177 } 4178 } 4179 } 4180 _forceRemove(currentNode); 4181 return true; 4182 } 4183 /* Check whether element has a valid namespace */ 4184 if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { 4185 _forceRemove(currentNode); 4186 return true; 4187 } 4188 /* Make sure that older browsers don't get fallback-tag mXSS */ 4189 if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) { 4190 _forceRemove(currentNode); 4191 return true; 4192 } 4193 /* Sanitize element content to be template-safe */ 4194 if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { 4195 /* Get the element's text content */ 4196 content = currentNode.textContent; 4197 arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { 4198 content = stringReplace(content, expr, ' '); 4199 }); 4200 if (currentNode.textContent !== content) { 4201 arrayPush(DOMPurify.removed, { 4202 element: currentNode.cloneNode() 4203 }); 4204 currentNode.textContent = content; 4205 } 4206 } 4207 /* Execute a hook if present */ 4208 _executeHooks(hooks.afterSanitizeElements, currentNode, null); 4209 return false; 4210 }; 4211 /** 4212 * _isValidAttribute 4213 * 4214 * @param lcTag Lowercase tag name of containing element. 4215 * @param lcName Lowercase attribute name. 4216 * @param value Attribute value. 4217 * @return Returns true if `value` is valid, otherwise false. 4218 */ 4219 // eslint-disable-next-line complexity 4220 const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { 4221 /* Make sure attribute cannot clobber */ 4222 if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { 4223 return false; 4224 } 4225 /* Allow valid data-* attributes: At least one character after "-" 4226 (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) 4227 XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) 4228 We don't need to check the value; it's always URI safe. */ 4229 if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { 4230 if ( 4231 // First condition does a very basic check if a) it's basically a valid custom element tagname AND 4232 // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck 4233 // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck 4234 _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || 4235 // Alternative, second condition checks if it's an `is`-attribute, AND 4236 // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck 4237 lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else { 4238 return false; 4239 } 4240 /* Check value is safe. First, is attr inert? If so, is safe */ 4241 } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) { 4242 return false; 4243 } else ; 4244 return true; 4245 }; 4246 /** 4247 * _isBasicCustomElement 4248 * checks if at least one dash is included in tagName, and it's not the first char 4249 * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name 4250 * 4251 * @param tagName name of the tag of the node to sanitize 4252 * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false. 4253 */ 4254 const _isBasicCustomElement = function _isBasicCustomElement(tagName) { 4255 return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT); 4256 }; 4257 /** 4258 * _sanitizeAttributes 4259 * 4260 * @protect attributes 4261 * @protect nodeName 4262 * @protect removeAttribute 4263 * @protect setAttribute 4264 * 4265 * @param currentNode to sanitize 4266 */ 4267 const _sanitizeAttributes = function _sanitizeAttributes(currentNode) { 4268 /* Execute a hook if present */ 4269 _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null); 4270 const { 4271 attributes 4272 } = currentNode; 4273 /* Check if we have attributes; if not we might have a text node */ 4274 if (!attributes || _isClobbered(currentNode)) { 4275 return; 4276 } 4277 const hookEvent = { 4278 attrName: '', 4279 attrValue: '', 4280 keepAttr: true, 4281 allowedAttributes: ALLOWED_ATTR, 4282 forceKeepAttr: undefined 4283 }; 4284 let l = attributes.length; 4285 /* Go backwards over all attributes; safely remove bad ones */ 4286 while (l--) { 4287 const attr = attributes[l]; 4288 const { 4289 name, 4290 namespaceURI, 4291 value: attrValue 4292 } = attr; 4293 const lcName = transformCaseFunc(name); 4294 const initValue = attrValue; 4295 let value = name === 'value' ? initValue : stringTrim(initValue); 4296 /* Execute a hook if present */ 4297 hookEvent.attrName = lcName; 4298 hookEvent.attrValue = value; 4299 hookEvent.keepAttr = true; 4300 hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set 4301 _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent); 4302 value = hookEvent.attrValue; 4303 /* Full DOM Clobbering protection via namespace isolation, 4304 * Prefix id and name attributes with `user-content-` 4305 */ 4306 if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) { 4307 // Remove the attribute with this value 4308 _removeAttribute(name, currentNode); 4309 // Prefix the value and later re-create the attribute with the sanitized value 4310 value = SANITIZE_NAMED_PROPS_PREFIX + value; 4311 } 4312 /* Work around a security issue with comments inside attributes */ 4313 if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, value)) { 4314 _removeAttribute(name, currentNode); 4315 continue; 4316 } 4317 /* Make sure we cannot easily use animated hrefs, even if animations are allowed */ 4318 if (lcName === 'attributename' && stringMatch(value, 'href')) { 4319 _removeAttribute(name, currentNode); 4320 continue; 4321 } 4322 /* Did the hooks approve of the attribute? */ 4323 if (hookEvent.forceKeepAttr) { 4324 continue; 4325 } 4326 /* Did the hooks approve of the attribute? */ 4327 if (!hookEvent.keepAttr) { 4328 _removeAttribute(name, currentNode); 4329 continue; 4330 } 4331 /* Work around a security issue in jQuery 3.0 */ 4332 if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) { 4333 _removeAttribute(name, currentNode); 4334 continue; 4335 } 4336 /* Sanitize attribute content to be template-safe */ 4337 if (SAFE_FOR_TEMPLATES) { 4338 arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { 4339 value = stringReplace(value, expr, ' '); 4340 }); 4341 } 4342 /* Is `value` valid for this attribute? */ 4343 const lcTag = transformCaseFunc(currentNode.nodeName); 4344 if (!_isValidAttribute(lcTag, lcName, value)) { 4345 _removeAttribute(name, currentNode); 4346 continue; 4347 } 4348 /* Handle attributes that require Trusted Types */ 4349 if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') { 4350 if (namespaceURI) ; else { 4351 switch (trustedTypes.getAttributeType(lcTag, lcName)) { 4352 case 'TrustedHTML': 4353 { 4354 value = trustedTypesPolicy.createHTML(value); 4355 break; 4356 } 4357 case 'TrustedScriptURL': 4358 { 4359 value = trustedTypesPolicy.createScriptURL(value); 4360 break; 4361 } 4362 } 4363 } 4364 } 4365 /* Handle invalid data-* attribute set by try-catching it */
vendor: 1,684 bytes, lines 4366-4413
4366 if (value !== initValue) { 4367 try { 4368 if (namespaceURI) { 4369 currentNode.setAttributeNS(namespaceURI, name, value); 4370 } else { 4371 /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ 4372 currentNode.setAttribute(name, value); 4373 } 4374 if (_isClobbered(currentNode)) { 4375 _forceRemove(currentNode); 4376 } else { 4377 arrayPop(DOMPurify.removed); 4378 } 4379 } catch (_) { 4380 _removeAttribute(name, currentNode); 4381 } 4382 } 4383 } 4384 /* Execute a hook if present */ 4385 _executeHooks(hooks.afterSanitizeAttributes, currentNode, null); 4386 }; 4387 /** 4388 * _sanitizeShadowDOM 4389 * 4390 * @param fragment to iterate over recursively 4391 */ 4392 const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { 4393 let shadowNode = null; 4394 const shadowIterator = _createNodeIterator(fragment); 4395 /* Execute a hook if present */ 4396 _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null); 4397 while (shadowNode = shadowIterator.nextNode()) { 4398 /* Execute a hook if present */ 4399 _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null); 4400 /* Sanitize tags and elements */ 4401 _sanitizeElements(shadowNode); 4402 /* Check attributes next */ 4403 _sanitizeAttributes(shadowNode); 4404 /* Deep shadow DOM detected */ 4405 if (shadowNode.content instanceof DocumentFragment) { 4406 _sanitizeShadowDOM(shadowNode.content); 4407 } 4408 } 4409 /* Execute a hook if present */ 4410 _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null); 4411 }; 4412 // eslint-disable-next-line complexity 4413 DOMPurify.sanitize = function (dirty) {
vendor: 6,509 bytes, lines 4414-4584
4414 let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 4415 let body = null; 4416 let importedNode = null; 4417 let currentNode = null; 4418 let returnNode = null; 4419 /* Make sure we have a string to sanitize. 4420 DO NOT return early, as this will return the wrong type if 4421 the user has requested a DOM object rather than a string */ 4422 IS_EMPTY_INPUT = !dirty; 4423 if (IS_EMPTY_INPUT) { 4424 dirty = '<!-->'; 4425 } 4426 /* Stringify, in case dirty is an object */ 4427 if (typeof dirty !== 'string' && !_isNode(dirty)) { 4428 if (typeof dirty.toString === 'function') { 4429 dirty = dirty.toString(); 4430 if (typeof dirty !== 'string') { 4431 throw typeErrorCreate('dirty is not a string, aborting'); 4432 } 4433 } else { 4434 throw typeErrorCreate('toString is not a function'); 4435 } 4436 } 4437 /* Return dirty HTML if DOMPurify cannot run */ 4438 if (!DOMPurify.isSupported) { 4439 return dirty; 4440 } 4441 /* Assign config vars */ 4442 if (!SET_CONFIG) { 4443 _parseConfig(cfg); 4444 } 4445 /* Clean up removed elements */ 4446 DOMPurify.removed = []; 4447 /* Check if dirty is correctly typed for IN_PLACE */ 4448 if (typeof dirty === 'string') { 4449 IN_PLACE = false; 4450 } 4451 if (IN_PLACE) { 4452 /* Do some early pre-sanitization to avoid unsafe root nodes */ 4453 if (dirty.nodeName) { 4454 const tagName = transformCaseFunc(dirty.nodeName); 4455 if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { 4456 throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); 4457 } 4458 } 4459 } else if (dirty instanceof Node) { 4460 /* If dirty is a DOM element, append to an empty document to avoid 4461 elements being stripped by the parser */ 4462 body = _initDocument('<!---->'); 4463 importedNode = body.ownerDocument.importNode(dirty, true); 4464 if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') { 4465 /* Node is already a body, use as is */ 4466 body = importedNode; 4467 } else if (importedNode.nodeName === 'HTML') { 4468 body = importedNode; 4469 } else { 4470 // eslint-disable-next-line unicorn/prefer-dom-node-append 4471 body.appendChild(importedNode); 4472 } 4473 } else { 4474 /* Exit directly if we have nothing to do */ 4475 if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && 4476 // eslint-disable-next-line unicorn/prefer-includes 4477 dirty.indexOf('<') === -1) { 4478 return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; 4479 } 4480 /* Initialize the document to work on */ 4481 body = _initDocument(dirty); 4482 /* Check we have a DOM node from the data */ 4483 if (!body) { 4484 return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; 4485 } 4486 } 4487 /* Remove first element node (ours) if FORCE_BODY is set */ 4488 if (body && FORCE_BODY) { 4489 _forceRemove(body.firstChild); 4490 } 4491 /* Get node iterator */ 4492 const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body); 4493 /* Now start iterating over the created document */ 4494 while (currentNode = nodeIterator.nextNode()) { 4495 /* Sanitize tags and elements */ 4496 _sanitizeElements(currentNode); 4497 /* Check attributes next */ 4498 _sanitizeAttributes(currentNode); 4499 /* Shadow DOM detected, sanitize it */ 4500 if (currentNode.content instanceof DocumentFragment) { 4501 _sanitizeShadowDOM(currentNode.content); 4502 } 4503 } 4504 /* If we sanitized `dirty` in-place, return it. */ 4505 if (IN_PLACE) { 4506 return dirty; 4507 } 4508 /* Return sanitized string or DOM */ 4509 if (RETURN_DOM) { 4510 if (RETURN_DOM_FRAGMENT) { 4511 returnNode = createDocumentFragment.call(body.ownerDocument); 4512 while (body.firstChild) { 4513 // eslint-disable-next-line unicorn/prefer-dom-node-append 4514 returnNode.appendChild(body.firstChild); 4515 } 4516 } else { 4517 returnNode = body; 4518 } 4519 if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) { 4520 /* 4521 AdoptNode() is not used because internal state is not reset 4522 (e.g. the past names map of a HTMLFormElement), this is safe 4523 in theory but we would rather not risk another attack vector. 4524 The state that is cloned by importNode() is explicitly defined 4525 by the specs. 4526 */ 4527 returnNode = importNode.call(originalDocument, returnNode, true); 4528 } 4529 return returnNode; 4530 } 4531 let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; 4532 /* Serialize doctype if allowed */ 4533 if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { 4534 serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML; 4535 } 4536 /* Sanitize final string template-safe */ 4537 if (SAFE_FOR_TEMPLATES) { 4538 arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { 4539 serializedHTML = stringReplace(serializedHTML, expr, ' '); 4540 }); 4541 } 4542 return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; 4543 }; 4544 DOMPurify.setConfig = function () { 4545 let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4546 _parseConfig(cfg); 4547 SET_CONFIG = true; 4548 }; 4549 DOMPurify.clearConfig = function () { 4550 CONFIG = null; 4551 SET_CONFIG = false; 4552 }; 4553 DOMPurify.isValidAttribute = function (tag, attr, value) { 4554 /* Initialize shared config vars if necessary. */ 4555 if (!CONFIG) { 4556 _parseConfig({}); 4557 } 4558 const lcTag = transformCaseFunc(tag); 4559 const lcName = transformCaseFunc(attr); 4560 return _isValidAttribute(lcTag, lcName, value); 4561 }; 4562 DOMPurify.addHook = function (entryPoint, hookFunction) { 4563 if (typeof hookFunction !== 'function') { 4564 return; 4565 } 4566 arrayPush(hooks[entryPoint], hookFunction); 4567 }; 4568 DOMPurify.removeHook = function (entryPoint, hookFunction) { 4569 if (hookFunction !== undefined) { 4570 const index = arrayLastIndexOf(hooks[entryPoint], hookFunction); 4571 return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0]; 4572 } 4573 return arrayPop(hooks[entryPoint]); 4574 }; 4575 DOMPurify.removeHooks = function (entryPoint) { 4576 hooks[entryPoint] = []; 4577 }; 4578 DOMPurify.removeAllHooks = function () { 4579 hooks = _createHooksMap(); 4580 }; 4581 return DOMPurify; 4582} 4583var purify = createDOMPurify(); 4584
4585/** 4586 * Copyright (c) Meta Platforms, Inc. and affiliates. 4587 * 4588 * This source code is licensed under the MIT license found in the 4589 * LICENSE file in the root directory of this source tree. 4590 * 4591 */ 4592 4593function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);n.search=r.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,r=n&&"documentMode"in document?document.documentMode:null,i=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),o=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s$1=!(!n||!("InputEvent"in window)||r)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,a=n&&/Android/.test(navigator.userAgent),u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&a&&u,d$1=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!u;function h$1(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}const g$1=0,_$3=1,p=2,T$3=128,b$4=1,w$4=2,E$4=3,O$2=4,M$5=5,A$3=6,P$3=l||c||d$1?" ":"â",D$4="\n\n",F$5=o?" ":P$3,L$3="Ö-ß¿ï¬-﷽ﹰ-ﻼ",I$4="A-Za-zÃ-ÃÃ-öø-ʸÌ-Öà -á¿¿ââ°-ï¬ï¸-﹯﻽-ï¿¿",K$5=new RegExp("^[^"+I$4+"]*["+L$3+"]"),z$5=new RegExp("^[^"+L$3+"]*["+I$4+"]"),R$6={bold:1,capitalize:1024,code:16,highlight:T$3,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},B$4={directionless:1,unmergeable:2},W$7={center:2,end:6,justify:4,left:1,right:3,start:5},J$5={[w$4]:"center",[A$3]:"end",[O$2]:"justify",[b$4]:"left",[E$4]:"right",[M$5]:"start"},j$4={normal:0,segmented:2,token:1},$$4={[g$1]:"normal",[p]:"segmented",[_$3]:"token"},V$6="$config";function Y$4(t,e,n,r,i,o){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Si(s)&&Y$4(s,t,n,r,i,o),n.has(t)||o.delete(t),i.push(t)),s=s.getNextSibling();}}let q$5=false,H$3=0;function G$4(t){H$3=t.timeStamp;}function X$4(t,e,n){const r="BR"===t.nodeName,i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&void 0!==So(t,n)}function Q$5(t,e,n){const r=ps(ss(n));let i=null,o=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,o=r.focusOffset);const s=t.nodeValue;null!==s&&Fo(e,s,i,o,false);}function Z$4(t,e,n){if(yr(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return false}return co(e)&&n.isAttached()}function tt$4(t,e,n,r){for(let i=t;i&&!Fs(i);i=Zo(i)){const t=So(i,e);if(void 0!==t){const e=xo(t,n);if(e)return Ti(e)||!Cs(i)?void 0:[i,e]}else if(i===r)return [r,bo(n)]}}function et$4(t,e,n){q$5=true;const r=performance.now()-H$3>100;try{yi(t,()=>{const i=Lr()||function(t){return t.getEditorState().read(()=>{const t=Lr();return null!==t?t.clone():null})}(t),s=new Map,l=t.getRootElement(),c=t._editorState,a=t._blockCursorElement;let u=!1,f="";for(let n=0;n<e.length;n++){const d=e[n],h=d.type,g=d.target,_=tt$4(g,t,c,l);if(!_)continue;const[p,y]=_;if("characterData"===h)r&&lr(y)&&co(g)&&Z$4(i,g,y)&&Q$5(g,y,t);else if("childList"===h){u=!0;const e=d.addedNodes;for(let n=0;n<e.length;n++){const r=e[n],i=Co(r),s=r.parentNode;if(null!=s&&r!==a&&null===i&&!X$4(r,s,t)){if(o){const t=(Cs(r)?r.innerText:null)||r.nodeValue;t&&(f+=t);}s.removeChild(r);}}const n=d.removedNodes,r=n.length;if(r>0){let e=0;for(let i=0;i<r;i++){const r=n[i];(X$4(r,g,t)||a===r)&&(g.appendChild(r),e++);}r!==e&&s.set(p,y);}}}if(s.size>0)for(const[e,n]of s)n.reconcileObservedMutation(e,t);const d=n.takeRecords();if(d.length>0){for(let e=0;e<d.length;e++){const n=d[e],r=n.addedNodes,i=n.target;for(let e=0;e<r.length;e++){const n=r[e],o=n.parentNode;null==o||"BR"!==n.nodeName||X$4(n,i,t)||o.removeChild(n);}}n.takeRecords();}null!==i&&(u&&wo(i),o&&Ho(t)&&i.insertRawText(f));});}finally{q$5=false;}}function nt$4(t){const e=t._observer;if(null!==e){et$4(t,e.takeRecords(),e);}}function rt$3(t){!function(t){0===H$3&&ss(t).addEventListener("textInput",G$4,true);}(t),t._observer=new MutationObserver((e,n)=>{et$4(t,e,n);});}let it$4 = class it{key;parse;unparse;isEqual;defaultValue;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||gt$4).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0);}};function ot$5(t,e){return new it$4(t,e)}function st$4(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function ct$5(t,e,n){let r;if(ei(),"function"==typeof n){const i=t.getLatest(),o=st$4(i,e);if(r=n(o),e.isEqual(o,r))return i}else r=n;const i=t.getWritable();return ft$3(i).updateFromKnown(e,r),i}function at$3(t){const e=new Map,n=new Set;for(let r="function"==typeof t?t:t.replace;r.prototype&&void 0!==r.prototype.getType;r=Object.getPrototypeOf(r)){const{ownNodeConfig:t}=Is(r);if(t&&t.stateConfigs)for(const r of t.stateConfigs){let t;"stateConfig"in r?(t=r.stateConfig,r.flat&&n.add(t.key)):t=r,e.set(t.key,t);}}return {flatKeys:n,sharedConfigMap:e}}let ut$4 = class ut{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,r=new Map,i=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=r;const{sharedConfigMap:o}=this.sharedNodeState,s=void 0!==i?i:function(t,e,n){let r=n.size;if(e)for(const i in e){const e=t.get(i);e&&n.has(e)||r++;}return r}(o,n,r);this.size=s;}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n);}return n}getInternalState(){return [this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return ht$4(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,r=new Map(this.knownState);return new ut(t,e,function(t,e,n){let r;if(n)for(const[i,o]of Object.entries(n)){const n=t.get(i);n?e.has(n)||e.set(n,n.parse(o)):(r=r||{},r[i]=o);}return r}(e.sharedConfigMap,r,n),r,this.size)}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:r,unknownState:i}=this;r.has(t)||i&&n in i||(i&&(delete i[n],this.unknownState=ht$4(i)),this.size++),r.set(t,e);}updateFromUnknown(t,e){const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e);}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n);}};function ft$3(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new ut$4(e,dt$4(e));return e.__state=n,n}function dt$4(t){return t.__state?t.__state.sharedNodeState:Gi(bs(),t.getType()).sharedNodeState}function ht$4(t){if(t)for(const e in t)return t}function gt$4(t){return t}function _t$5(t,e,n){for(const[r,i]of e.knownState){if(t.has(r.key))continue;t.add(r.key);const e=n?n.getValue(r):r.defaultValue;
4593if(e!==i&&!r.isEqual(e,i))return true}return false}function pt$4(t,e,n){const{unknownState:r}=e,i=n?n.unknownState:void 0;if(r)for(const[e,n]of Object.entries(r)){if(t.has(e))continue;t.add(e);if(n!==(i?i[e]:void 0))return true}return false}function yt$4(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function mt$2(t,e){const n=t.__mode,r=t.__format,i=t.__style,o=e.__mode,s=e.__format,l=e.__style,c=t.__state,a=e.__state;return (null===n||n===o)&&(null===r||r===s)&&(null===i||i===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return true;if(t&&e&&t.size!==e.size)return false;const n=new Set;return !(t&&_t$5(n,t,e)||e&&_t$5(n,e,t)||t&&pt$4(n,t,e)||e&&pt$4(n,e,t))}(c,a))}function xt$6(t,e){const n=t.mergeWithSibling(e),r=ii()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function Ct$6(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&lr(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(mt$2(e,r)){r=xt$6(e,r);break}break}e.remove();}for(;null!==(n=r.getNextSibling())&&lr(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(mt$2(r,n)){r=xt$6(r,n);break}break}n.remove();}}else r.remove();}function St$6(t){return vt$4(t.anchor),vt$4(t.focus),t}function vt$4(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let r,i;if(n===e.getChildrenSize()?(r=e.getChildAtIndex(n-1),i=true):(r=e.getChildAtIndex(n),i=false),lr(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",true);break}if(!Si(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",true);}}let kt$7,Tt$5,Nt$6,bt$7,wt$6,Et$5,Ot$5,Mt$4,At$6,Pt$5,Dt$4="",Ft$3=null,Lt$5="",It$4="",Kt$4=false,zt$3=false;function Rt$3(t,e){const n=Ot$5.get(t);if(null!==e){const n=ne$1(t);n.parentNode===e&&e.removeChild(n);}if(Mt$4.has(t)||Tt$5._keyToDOMMap.delete(t),Si(n)){const t=Xt$1(n,Ot$5);Bt$4(t,0,t.length-1,null);} void 0!==n&&Uo(Pt$5,Nt$6,bt$7,n,"destroyed");}function Bt$4(t,e,n,r){let i=e;for(;i<=n;++i){const e=t[i];void 0!==e&&Rt$3(e,r);}}function Wt$3(t,e){t.setProperty("text-align",e);}const Jt$2="40px";function jt$4(t,e){const n=kt$7.theme.indent;if("string"==typeof n){const r=t.classList.contains(n);e>0&&!r?t.classList.add(n):e<1&&r&&t.classList.remove(n);}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||Jt$2;t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * ${r})`);}function $t$4(t,e){const n=t.style;0===e?Wt$3(n,""):1===e?Wt$3(n,"left"):2===e?Wt$3(n,"center"):3===e?Wt$3(n,"right"):4===e?Wt$3(n,"justify"):5===e?Wt$3(n,"start"):6===e&&Wt$3(n,"end");}function Ut$3(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(bi(t))return null;const n=t.getParentOrThrow();return bi(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir");}function Vt$1(e,n){const r=Mt$4.get(e);void 0===r&&t(60);const i=r.createDOM(kt$7,Tt$5);if(function(t,e,n){const r=n._keyToDOMMap;((function(t,e,n){const r=`__lexicalKey_${e._key}`;t[r]=n;}))(e,n,t),r.set(t,e);}(e,i,Tt$5),lr(r)?i.setAttribute("data-lexical-text","true"):Ti(r)&&i.setAttribute("data-lexical-decorator","true"),Si(r)){const t=r.__indent,e=r.__size;if(Ut$3(i,r),0!==t&&jt$4(i,t),0!==e){const t=e-1;Yt$1(Xt$1(r,Mt$4),r,0,t,r.getDOMSlot(i));}const n=r.__format;0!==n&&$t$4(i,n),r.isInline()||Ht$2(null,r,i),Xo(r)&&(Dt$4+=D$4,It$4+=D$4);}else {const t=r.getTextContent();if(Ti(r)){const t=r.decorate(Tt$5,kt$7);null!==t&&Zt$1(e,t),i.contentEditable="false";}Dt$4+=t,It$4+=t;}return null!==n&&n.insertChild(i),Uo(Pt$5,Nt$6,bt$7,r,"created"),i}function Yt$1(t,e,n,r,i){const o=Dt$4;Dt$4="";let s=n;for(;s<=r;++s){Vt$1(t[s],i);const e=Mt$4.get(t[s]);null!==e&&lr(e)&&(null===Ft$3&&(Ft$3=e.getFormat()),""===Lt$5&&(Lt$5=e.getStyle()));}Xo(e)&&(Dt$4+=D$4);i.element.__lexicalTextContent=Dt$4,Dt$4=o+Dt$4;}function qt$1(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return jn(t)?"line-break":Ti(t)&&t.isInline()?"decorator":null}return "empty"}return null}function Ht$2(t,e,n){const r=qt$1(t,Ot$5),i=qt$1(e,Mt$4);r!==i&&e.getDOMSlot(n).setManagedLineBreak(i);}function Gt$2(e,n,r){var i;Ft$3=null,Lt$5="",function(e,n,r){const i=Dt$4,o=e.__size,s=n.__size;Dt$4="";const l=r.element;if(1===o&&1===s){const t=e.__first,r=n.__first;if(t===r)Qt$1(t,l);else {const e=ne$1(t),n=Vt$1(r,null);try{l.replaceChild(n,e);}catch(i){if("object"==typeof i&&null!=i){const o=`${i.toString()} Parent: ${l.tagName}, new child: {tag: ${n.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${t}}.`;throw new Error(o)}throw i}Rt$3(t,null);}const i=Mt$4.get(r);lr(i)&&(null===Ft$3&&(Ft$3=i.getFormat()),""===Lt$5&&(Lt$5=i.getStyle()));}else {const i=Xt$1(e,Ot$5),c=Xt$1(n,Mt$4);if(i.length!==o&&t(227),c.length!==s&&t(228),0===o)0!==s&&Yt$1(c,n,0,s-1,r);
4593else if(0===s){if(0!==o){const t=null==r.after&&null==r.before&&null==r.element.__lexicalLineBreak;Bt$4(i,0,o-1,t?null:l),t&&(l.textContent="");}}else !function(t,e,n,r,i,o){const s=r-1,l=i-1;let c,a,u=o.getFirstChild(),f=0,d=0;for(;f<=s&&d<=l;){const t=e[f],r=n[d];if(t===r)u=te$1(Qt$1(r,o.element)),f++,d++;else { void 0===c&&(c=new Set(e)),void 0===a&&(a=new Set(n));const i=a.has(t),s=c.has(r);if(i)if(s){const t=Qo(Tt$5,r);t===u?u=te$1(Qt$1(r,o.element)):(o.withBefore(u).insertChild(t),Qt$1(r,o.element)),f++,d++;}else Vt$1(r,o.withBefore(u)),d++;else u=te$1(ne$1(t)),Rt$3(t,o.element),f++;}const i=Mt$4.get(r);null!==i&&lr(i)&&(null===Ft$3&&(Ft$3=i.getFormat()),""===Lt$5&&(Lt$5=i.getStyle()));}const h=f>s,g=d>l;if(h&&!g){const e=n[l+1],r=void 0===e?null:Tt$5.getElementByKey(e);Yt$1(n,t,d,l,o.withBefore(r));}else g&&!h&&Bt$4(e,f,s,o.element);}(n,i,c,o,s,r);}Xo(n)&&(Dt$4+=D$4);l.__lexicalTextContent=Dt$4,Dt$4=i+Dt$4;}(e,n,n.getDOMSlot(r)),i=n,null==Ft$3||Ft$3===i.__textFormat||zt$3||i.setTextFormat(Ft$3),function(t){""===Lt$5||Lt$5===t.__textStyle||zt$3||t.setTextStyle(Lt$5);}(n);}function Xt$1(e,n){const r=[];let i=e.__first;for(;null!==i;){const e=n.get(i);void 0===e&&t(101),r.push(i),i=e.__next;}return r}function Qt$1(e,n){const r=Ot$5.get(e);let i=Mt$4.get(e);void 0!==r&&void 0!==i||t(61);const o=Kt$4||Et$5.has(e)||wt$6.has(e),s=Qo(Tt$5,e);if(r===i&&!o){if(Si(r)){const t=s.__lexicalTextContent;void 0!==t&&(Dt$4+=t,It$4+=t);}else {const t=r.getTextContent();It$4+=t,Dt$4+=t;}return s}if(r!==i&&o&&Uo(Pt$5,Nt$6,bt$7,i,"updated"),i.updateDOM(r,s,kt$7)){const r=Vt$1(e,null);return null===n&&t(62),n.replaceChild(r,s),Rt$3(e,null),r}if(Si(r)&&Si(i)){const t=i.__indent;(Kt$4||t!==r.__indent)&&jt$4(s,t);const e=i.__format;if((Kt$4||e!==r.__format)&&$t$4(s,e),o&&(Gt$2(r,i,s),bi(i)||i.isInline()||Ht$2(r,i,s)),Xo(i)&&(Dt$4+=D$4,It$4+=D$4),(Kt$4||i.__dir!==r.__dir)&&(Ut$3(s,i),bi(i)&&!Kt$4))for(const t of i.getChildren())if(Si(t)){Ut$3(Qo(Tt$5,t.getKey()),t);}}else {const t=i.getTextContent();if(Ti(i)){const t=i.decorate(Tt$5,kt$7);null!==t&&Zt$1(e,t);}Dt$4+=t,It$4+=t;}if(!zt$3&&bi(i)&&i.__cachedText!==It$4){const t=i.getWritable();t.__cachedText=It$4,i=t;}return s}function Zt$1(t,e){let n=Tt$5._pendingDecorators;const r=Tt$5._decorators;if(null===n){if(r[t]===e)return;n=ko(Tt$5);}n[t]=e;}function te$1(t){let e=t.nextSibling;return null!==e&&e===Tt$5._blockCursorElement&&(e=e.nextSibling),e}function ee$1(t,e,n,r,i,o){Dt$4="",It$4="",Kt$4=2===r,Tt$5=n,kt$7=n._config,Nt$6=n._nodes,bt$7=Tt$5._listeners.mutation,wt$6=i,Et$5=o,Ot$5=t._nodeMap,Mt$4=e._nodeMap,zt$3=e._readOnly,At$6=new Map(n._keyToDOMMap);const s=new Map;return Pt$5=s,Qt$1("root",null),Tt$5=void 0,Nt$6=void 0,wt$6=void 0,Et$5=void 0,Ot$5=void 0,Mt$4=void 0,kt$7=void 0,At$6=void 0,Pt$5=void 0,s}function ne$1(e){const n=At$6.get(e);return void 0===n&&t(75,e),n}function re$1(t){return {type:t}}const ie$1=re$1("SELECTION_CHANGE_COMMAND"),oe$2=re$1("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),se$1=re$1("CLICK_COMMAND"),le$2=re$1("DELETE_CHARACTER_COMMAND"),ce$1=re$1("INSERT_LINE_BREAK_COMMAND"),ae$1=re$1("INSERT_PARAGRAPH_COMMAND"),ue$1=re$1("CONTROLLED_TEXT_INSERTION_COMMAND"),fe$1=re$1("PASTE_COMMAND"),de$1=re$1("REMOVE_TEXT_COMMAND"),he$1=re$1("DELETE_WORD_COMMAND"),ge$1=re$1("DELETE_LINE_COMMAND"),_e$1=re$1("FORMAT_TEXT_COMMAND"),pe$1=re$1("UNDO_COMMAND"),ye$1=re$1("REDO_COMMAND"),me$1=re$1("KEYDOWN_COMMAND"),xe$1=re$1("KEY_ARROW_RIGHT_COMMAND"),Ce$1=re$1("MOVE_TO_END"),Se$1=re$1("KEY_ARROW_LEFT_COMMAND"),ve$2=re$1("MOVE_TO_START"),ke$2=re$1("KEY_ARROW_UP_COMMAND"),Te$2=re$1("KEY_ARROW_DOWN_COMMAND"),Ne$2=re$1("KEY_ENTER_COMMAND"),be$1=re$1("KEY_SPACE_COMMAND"),we$1=re$1("KEY_BACKSPACE_COMMAND"),Ee$2=re$1("KEY_ESCAPE_COMMAND"),Oe$2=re$1("KEY_DELETE_COMMAND"),Me$2=re$1("KEY_TAB_COMMAND"),Ae$2=re$1("INSERT_TAB_COMMAND"),Pe$2=re$1("INDENT_CONTENT_COMMAND"),De$2=re$1("OUTDENT_CONTENT_COMMAND"),Fe$2=re$1("DROP_COMMAND"),Le$2=re$1("FORMAT_ELEMENT_COMMAND"),Ie$2=re$1("DRAGSTART_COMMAND"),Ke$2=re$1("DRAGOVER_COMMAND"),ze$2=re$1("DRAGEND_COMMAND"),Re$2=re$1("COPY_COMMAND"),Be$2=re$1("CUT_COMMAND"),We$2=re$1("SELECT_ALL_COMMAND"),Je$1=re$1("CLEAR_EDITOR_COMMAND"),je$2=re$1("CLEAR_HISTORY_COMMAND"),$e$2=re$1("CAN_REDO_COMMAND"),Ue$2=re$1("CAN_UNDO_COMMAND"),Ve$1=re$1("FOCUS_COMMAND"),Ye=re$1("BLUR_COMMAND"),qe$2=re$1("KEY_MODIFIER_COMMAND"),He$2=Object.freeze({}),Ge$2=[["keydown",function(t,e){if(Xe$1=t.timeStamp,Qe$1=t.key,e.isComposing())return;if(Go(e,me$1,t))return;if(null==t.key)return;if(cn$1&&Wo(t))return yi(e,()=>{mn$1(e,an$1);}),cn$1=false,void(an$1="");if(function(t){return zo(t,"ArrowRight",{shiftKey:"any"})}(t))Go(e,xe$1,t);else if(function(t){return zo(t,"ArrowRight",Ro)}(t))Go(e,Ce$1,t);else if(function(t){return zo(t,"ArrowLeft",{shiftKey:"any"})}(t))Go(e,Se$1,t);else if(function(t){return zo(t,"ArrowLeft",Ro)}(t))Go(e,ve$2,t);else if(function(t){return zo(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Go(e,ke$2,t);else if(function(t){return zo(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Go(e,Te$2,t);else if(function(t){return zo(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:true})}(t))sn$1=true,Go(e,Ne$2,t);else if(function(t){return " "===t.key}(t))Go(e,be$1,t);else if(function(t){return i&&zo(t,"o",{ctrlKey:true})}(t))t.preventDefault(),sn$1=true,Go(e,ce$1,true);else if(function(t){return zo(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))sn$1=false,Go(e,Ne$2,t);else if(function(t){return zo(t,"Backspace",{shiftKey:"any"})||i&&zo(t,"h",{ctrlKey:true})}(t))Wo(t)?Go(e,we$1,t):(t.preventDefault(),Go(e,le$2,true));
4593else if(function(t){return "Escape"===t.key}(t))Go(e,Ee$2,t);else if(function(t){return zo(t,"Delete",{})||i&&zo(t,"d",{ctrlKey:true})}(t))!function(t){return "Delete"===t.key}(t)?(t.preventDefault(),Go(e,le$2,false)):Go(e,Oe$2,t);else if(function(t){return zo(t,"Backspace",Bo)}(t))t.preventDefault(),Go(e,he$1,true);else if(function(t){return zo(t,"Delete",Bo)}(t))t.preventDefault(),Go(e,he$1,false);else if(function(t){return i&&zo(t,"Backspace",{metaKey:true})}(t))t.preventDefault(),Go(e,ge$1,true);else if(function(t){return i&&(zo(t,"Delete",{metaKey:true})||zo(t,"k",{ctrlKey:true}))}(t))t.preventDefault(),Go(e,ge$1,false);else if(function(t){return zo(t,"b",Ro)}(t))t.preventDefault(),Go(e,_e$1,"bold");else if(function(t){return zo(t,"u",Ro)}(t))t.preventDefault(),Go(e,_e$1,"underline");else if(function(t){return zo(t,"i",Ro)}(t))t.preventDefault(),Go(e,_e$1,"italic");else if(function(t){return zo(t,"Tab",{shiftKey:"any"})}(t))Go(e,Me$2,t);else if(function(t){return zo(t,"z",Ro)}(t))t.preventDefault(),Go(e,pe$1,void 0);else if(function(t){if(i)return zo(t,"z",{metaKey:true,shiftKey:true});return zo(t,"y",{ctrlKey:true})||zo(t,"z",{ctrlKey:true,shiftKey:true})}(t))t.preventDefault(),Go(e,ye$1,void 0);else {const n=e._editorState._selection;null===n||yr(n)?Jo(t)&&(t.preventDefault(),Go(e,We$2,t)):!function(t){return zo(t,"c",Ro)}(t)?!function(t){return zo(t,"x",Ro)}(t)?Jo(t)&&(t.preventDefault(),Go(e,We$2,t)):(t.preventDefault(),Go(e,Be$2,t)):(t.preventDefault(),Go(e,Re$2,t));}(function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey})(t)&&Go(e,qe$2,t);}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Ss(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&yi(e,()=>{Zi(n)||(on$1=true);});}],["compositionstart",function(t,e){yi(e,()=>{const n=Lr();if(yr(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();yo(r.key),(t.timeStamp<Xe$1+30||"element"===r.type||!n.isCollapsed()||i.getFormat()!==n.format||lr(i)&&i.getStyle()!==n.style)&&Go(e,ue$1,F$5);}});}],["compositionend",function(t,e){o?ln$1=true:c||!l&&!d$1?yi(e,()=>{mn$1(e,t.data);}):(cn$1=true,an$1=t.data);}],["input",function(t,e){t.stopPropagation(),yi(e,()=>{if(Cs(t.target)&&Zi(t.target))return;const n=Lr(),r=t.data,i=yn$1(t);if(null!=r&&yr(n)&&dn$1(n,i,r,t.timeStamp,false)){ln$1&&(mn$1(e,r),ln$1=false);const i=n.anchor.getNode(),a=ps(ss(e));if(null===a)return;const u=n.isBackward(),f=u?n.anchor.offset:n.focus.offset,h=u?n.focus.offset:n.anchor.offset;s$1&&!n.isCollapsed()&&lr(i)&&null!==a.anchorNode&&i.getTextContent().slice(0,f)+r+i.getTextContent().slice(f+h)===Po(a.anchorNode)||Go(e,ue$1,r);const g=r.length;o&&g>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=g),l||c||d$1||!e.isComposing()||(Xe$1=0,yo(null));}else {Do(false,e,null!==r?r:void 0),ln$1&&(mn$1(e,r||void 0),ln$1=false);}!function(){ei();const t=ii();nt$4(t);}();},{event:t}),tn$1=null;}],["click",function(t,e){yi(e,()=>{const n=Lr(),r=ps(ss(e)),i=Ir();if(r)if(yr(n)){const e=n.anchor,o=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!bi(o)&&1===No().getChildrenSize()&&o.getTopLevelElementOrThrow().isEmpty()&&null!==i&&n.is(i))r.removeAllRanges(),n.dirty=true;else if(3===t.detail&&!n.isCollapsed()){if(o!==n.focus.getNode()){const t=zs(o,t=>Si(t)&&!t.isInline());Si(t)&&t.select(0);}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Cs(n)||co(n)){wo(Fr(i,r,e,t));}}Go(e,se$1,t);});}],["cut",He$2],["copy",He$2],["dragstart",He$2],["dragover",He$2],["dragend",He$2],["paste",He$2],["focus",He$2],["blur",He$2],["drop",He$2]];s$1&&Ge$2.push(["beforeinput",(e,n)=>function(e,n){const r=e.inputType,i=yn$1(e);if("deleteCompositionText"===r||o&&Ho(n))return;if("insertCompositionText"===r)return;yi(n,()=>{const o=Lr();if("deleteContentBackward"===r){if(null===o){const t=Ir();if(!yr(t))return;wo(t.clone());}if(yr(o)){const r=o.anchor.key===o.focus.key;if(s=e.timeStamp,"MediaLast"===Qe$1&&s<Xe$1+30&&n.isComposing()&&r){if(yo(null),Xe$1=0,setTimeout(()=>{yi(n,()=>{yo(null);});},30),yr(o)){const e=o.anchor.getNode();e.markDirty(),lr(e)||t(142),pn$1(o,e);}}else {yo(null),e.preventDefault();const t=o.anchor.getNode(),i=t.getTextContent(),s=t.canInsertTextAfter(),l=0===o.anchor.offset&&o.focus.offset===i.length;let c=f&&r&&!l&&s;if(c&&o.isCollapsed()&&(c=!Ti(qo(o.anchor,true))),!c){Go(n,le$2,true);const t=Lr();f&&yr(t)&&t.isCollapsed()&&(un$1=t,setTimeout(()=>un$1=null));}}return}}var s;if(!yr(o))return;const l=e.data;null!==tn$1&&Do(false,n,tn$1),o.dirty&&null===tn$1||!o.isCollapsed()||bi(o.anchor.getNode())||null===i||o.applyDOMRange(i),tn$1=null;const a=o.anchor,u=o.focus,d=a.getNode(),h=u.getNode();if("insertText"!==r&&"insertTranspose"!==r)switch(e.preventDefault(),r){case "insertFromYank":case "insertFromDrop":case "insertReplacementText":Go(n,ue$1,e);break;case "insertFromComposition":yo(null),Go(n,ue$1,e);break;case "insertLineBreak":yo(null),Go(n,ce$1,false);break;case "insertParagraph":yo(null),sn$1&&!c?(sn$1=false,Go(n,ce$1,false)):Go(n,ae$1,void 0);break;case "insertFromPaste":case "insertFromPasteAsQuotation":Go(n,fe$1,e);break;case "deleteByComposition":(function(t,e){return t!==e||Si(t)||Si(e)||!so(t)||!so(e)})(d,h)&&Go(n,de$1,e);break;case "deleteByDrag":case "deleteByCut":Go(n,de$1,e);break;case "deleteContent":Go(n,le$2,false);break;case "deleteWordBackward":Go(n,he$1,true);break;
4593case "deleteWordForward":Go(n,he$1,false);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":Go(n,ge$1,true);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":Go(n,ge$1,false);break;case "formatStrikeThrough":Go(n,_e$1,"strikethrough");break;case "formatBold":Go(n,_e$1,"bold");break;case "formatItalic":Go(n,_e$1,"italic");break;case "formatUnderline":Go(n,_e$1,"underline");break;case "historyUndo":Go(n,pe$1,void 0);break;case "historyRedo":Go(n,ye$1,void 0);}else {if("\n"===l)e.preventDefault(),Go(n,ce$1,false);else if(l===D$4)e.preventDefault(),Go(n,ae$1,void 0);else if(null==l&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),o.insertRawText(t);}else null!=l&&dn$1(o,i,l,e.timeStamp,true)?(e.preventDefault(),Go(n,ue$1,l)):tn$1=l;Ze$2=e.timeStamp;}});}(e,n)]);let Xe$1=0,Qe$1=null,Ze$2=0,tn$1=null;const en$1=new WeakMap,nn$1=new WeakMap;let rn$1=false,on$1=false,sn$1=false,ln$1=false,cn$1=false,an$1="",un$1=null,fn$1=[0,"",0,"root",0];function dn$1(t,e,n,r,i){const o=t.anchor,l=t.focus,c=o.getNode(),a=ii(),u=ps(ss(a)),f=null!==u?u.anchorNode:null,d=o.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!lr(c)||(!i&&(!s$1||Ze$2<r+50)||c.isDirty()&&g<2||Oo(n))&&o.offset!==l.offset&&!c.isComposing()||lo(c)||c.isDirty()&&g>1||(i||!s$1)&&null!==h&&!c.isComposing()&&f!==uo(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||c.getFormat()!==t.format||c.getStyle()!==t.style||function(t,e){if(e.isSegmented())return true;if(!t.isCollapsed())return false;const n=t.anchor.offset,r=e.getParentOrThrow(),i=so(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return (lr(e)||Si(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}(t,c)}function hn$1(t,e){return co(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function gn$1(e,n,r){const{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:l}=e;rn$1&&(rn$1=false,hn$1(i,o)&&hn$1(s,l)&&!un$1)||yi(n,()=>{if(!r)return void wo(null);if(!eo(n,i,s))return;let c=Lr();if(un$1&&yr(c)&&c.isCollapsed()){const t=c.anchor,e=un$1.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=un$1.clone(),wo(c));}if(un$1=null,yr(c)){const r=c.anchor,i=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=true);const o=ss(n).event,s=o?o.timeStamp:performance.now(),[l,a,u,f,d]=fn$1,h=No(),g=false===n.isComposing()&&""===h.getTextContent();if(s<d+200&&r.offset===u&&r.key===f)_n$1(c,l,a);else if("text"===r.type)lr(i)||t(141),pn$1(c,i);else if("element"===r.type&&!g){Si(i)||t(259);const e=r.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),r=e.getTextStyle();_n$1(t,n,r);}(c,e):_n$1(c,0,"");}}else {const t=r.key,e=c.focus.key,n=c.getNodes(),i=n.length,s=c.isBackward(),a=s?l:o,u=s?o:l,f=s?e:t,d=s?t:e;let h=2047,g=false;for(let t=0;t<i;t++){const e=n[t],r=e.getTextContentSize();if(lr(e)&&0!==r&&!(0===t&&e.__key===f&&a===r||t===i-1&&e.__key===d&&0===u)&&(g=true,h&=e.getFormat(),0===h))break}c.format=g?h:0;}}Go(n,ie$1,void 0);});}function _n$1(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=true);}function pn$1(t,e){_n$1(t,e.getFormat(),e.getStyle());}function yn$1(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function mn$1(t,e){const n=t._compositionKey;if(yo(null),null!==n&&null!=e){if(""===e){const e=xo(n),r=uo(t.getElementByKey(n));return void(null!==r&&null!==r.nodeValue&&lr(e)&&Fo(e,r.nodeValue,null,null,true))}if("\n"===e[e.length-1]){const e=Lr();if(yr(e)){const n=e.focus;return e.anchor.set(n.key,n.offset,n.type),void Go(t,Ne$2,null)}}}Do(true,t,e);}function xn(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const Cn$1=new Map;function Sn$1(t){const e=ys(t.target);if(null===e)return;const n=ro(e.anchorNode);
4593if(null===n)return;on$1&&(on$1=false,yi(n,()=>{const r=Ir(),i=e.anchorNode;if(Cs(i)||co(i)){wo(Fr(r,e,n,t));}}));const r=Mo(n),i=r[r.length-1],o=i._key,s=Cn$1.get(o),l=s||i;l!==n&&gn$1(e,l,false),gn$1(e,n,true),n!==i?Cn$1.set(o,n):s&&Cn$1.delete(o);}function vn(t){t._lexicalHandled=true;}function kn(t){return true===t._lexicalHandled}function Nn$1(e){const n=en$1.get(e);if(void 0===n)return void 0;const r=nn$1.get(n);if(void 0===r)return void 0;const i=r-1;i>=0||t(164),en$1.delete(e),nn$1.set(n,i),0===i&&n.removeEventListener("selectionchange",Sn$1);const o=io(e);no(o)?(!function(t){if(null!==t._parentEditor){const e=Mo(t),n=e[e.length-1]._key;Cn$1.get(n)===t&&Cn$1.delete(n);}else Cn$1.delete(t._key);}(o),e.__lexicalEditor=null):o&&t(198);const s=xn(e);for(let t=0;t<s.length;t++)s[t]();e.__lexicalEventHandles=[];}function bn(t,e,n){ei();const r=t.__key,i=t.getParent();if(null===i)return;const o=function(t){const e=Lr();if(!yr(e)||!Si(t))return e;const{anchor:n,focus:r}=e,i=n.getNode(),o=r.getNode();is(i,t)&&n.set(t.__key,0,"element");is(o,t)&&r.set(t.__key,0,"element");return e}(t);let s=false;if(yr(o)&&e){const e=o.anchor,n=o.focus;e.key===r&&(Rr(e,t,i,t.getPreviousSibling(),t.getNextSibling()),s=true),n.key===r&&(Rr(n,t,i,t.getPreviousSibling(),t.getNextSibling()),s=true);}else xr(o)&&e&&t.isSelected()&&t.selectPrevious();if(yr(o)&&e&&!s){const e=t.getIndexWithinParent();_o(t),Kr(o,i,e,-1);}else _o(t);n||as(i)||i.canBeEmpty()||!i.isEmpty()||bn(i,e),e&&o&&bi(i)&&i.isEmpty()&&i.selectEnd();}function wn$1(t){return t}const En=Symbol.for("ephemeral");function On(t){return t[En]||false}class Mn{__type;__key;__parent;__prev;__next;__state;static getType(){const{ownNodeType:e}=Is(this);return void 0===e&&t(64,this.name),e}static clone(e){t(65,this.name);}$config(){return {}}config(t,e){const n=e.extends||Object.getPrototypeOf(this.constructor);return Object.assign(e,{extends:n,type:t}),{[t]:e}}afterCloneFrom(t){this.__key===t.__key?(this.__parent=t.__parent,this.__next=t.__next,this.__prev=t.__prev,this.__state=t.__state):t.__state&&(this.__state=t.__state.getWritable(this));}static importDOM;constructor(t){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Object.defineProperty(this,"__state",{configurable:true,enumerable:false,value:void 0,writable:true}),go(this,t);}getType(){return this.__type}isInline(){t(137,this.constructor.name);}isAttached(){let t=this.__key;for(;null!==t;){if("root"===t)return true;const e=xo(t);if(null===e)break;t=e.__parent;}return false}isSelected(t){const e=t||Lr();if(null==e)return false;const n=e.getNodes().some(t=>t.__key===this.__key);if(lr(this))return n;if(yr(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return false;const t=this.getParent();if(Ti(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return false}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return -1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling();}return -1}getParent(){const t=this.getLatest().__parent;return null===t?null:xo(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(as(n))return Si(e)||e===this&&Ti(e)||t(194),e;e=n;}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:xo(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:xo(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Si(this)?this:this.getParent(),n=Si(t)?t:t.getParent(),r=e&&n?ml(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=ml(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===_l(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),false)))}isParentOf(t){const e=ml(this,t);return null!==e&&"ancestor"===e.type}getNodesBetween(e){const n=this.isBefore(e),r=[],i=new Set;let o=this;for(;null!==o;){const s=o.__key;if(i.has(s)||(i.add(s),r.push(o)),o===e)break;const l=Si(o)?n?o.getFirstChild():o.getLastChild():null;if(null!==l){o=l;continue}const c=n?o.getNextSibling():o.getPreviousSibling();if(null!==c){o=c;continue}const a=o.getParentOrThrow();if(i.has(a.__key)||r.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||i.has(f.__key)||r.push(f);}while(null===u);o=u;}return n||r.reverse(),r}isDirty(){const t=ii()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(On(this))return this;const e=xo(this.__key);return null===e&&t(113),e}getWritable(){if(On(this))return this;ei();const t=ri(),e=ii(),n=t._nodeMap,r=this.__key,i=this.getLatest(),o=e._cloneNotNeeded,s=Lr();if(null!==s&&s.setCachedNodes(null),o.has(r))return po(i),i;const l=Ms(i);return o.add(r),po(l),n.set(r,l),l}getTextContent(){return ""}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70);}updateDOM(e,n,r){t(71);}exportDOM(t){return {element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return {type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name);}updateFromJSON(t){return function(t,e){const n=t.getWritable(),r=e.$;let i=r;for(const t of dt$4(n).flatKeys)t in e&&(void 0!==i&&i!==r||(i={...r}),i[t]=e[t]);return (n.__state||i)&&ft$3(t).updateFromJSON(i),n}(this,t)}static transform(){return null}remove(t){bn(this,true,t);}replace(e,n){ei();let r=Lr();null!==r&&(r=r.clone()),ds(this,e);const i=this.getLatest(),o=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;_o(l);const u=i.getPreviousSibling(),f=i.getNextSibling(),d=i.__prev,h=i.__next,g=i.__parent;if(bn(i,false,true),null===u)c.__first=s;else {u.getWritable().__next=s;}if(l.__prev=d,null===f)c.__last=s;else {f.getWritable().__prev=s;}if(l.__next=h,l.__parent=g,c.__size=a,n&&(Si(this)&&Si(l)||t(139),this.getChildren().forEac
4593h(t=>{l.append(t);})),yr(r)){wo(r);const t=r.anchor,e=r.focus;t.key===o&&_r(t,l),e.key===o&&_r(e,l);}return mo()===o&&yo(s),l}insertAfter(t,e=true){ei(),ds(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),o=Lr();let s=false,l=false;if(null!==i){const e=t.getIndexWithinParent();if(_o(r),yr(o)){const t=i.__key,n=o.anchor,r=o.focus;s="element"===n.type&&n.key===t&&n.offset===e+1,l="element"===r.type&&r.key===t&&r.offset===e+1;}}const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=r.__key,f=n.__next;if(null===c)a.__last=u;else {c.getWritable().__prev=u;}if(a.__size++,n.__next=u,r.__next=f,r.__prev=n.__key,r.__parent=n.__parent,e&&yr(o)){const t=this.getIndexWithinParent();Kr(o,a,t+1);const e=a.__key;s&&o.anchor.set(e,t+2,"element"),l&&o.focus.set(e,t+2,"element");}return t}insertBefore(t,e=true){ei(),ds(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;_o(r);const o=this.getPreviousSibling(),s=this.getParentOrThrow().getWritable(),l=n.__prev,c=this.getIndexWithinParent();if(null===o)s.__first=i;else {o.getWritable().__next=i;}s.__size++,n.__prev=i,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const a=Lr();if(e&&yr(a)){Kr(a,this.getParentOrThrow(),c);}return t}isParentRequired(){return false}createParentElementNode(){return Li()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){ei();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Si(n))return n.select();if(!lr(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){ei();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Si(n))return n.select(0,0);if(!lr(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable();}reconcileObservedMutation(t,e){this.markDirty();}}const An="historic",Pn="history-push",Dn="history-merge",Fn="paste",Ln="collaboration",Kn="skip-scroll-into-view",zn="skip-dom-selection",Rn="skip-selection-focus";class Bn extends Mn{static getType(){return "linebreak"}static clone(t){return new Bn(t.__key)}constructor(t){super(t);}getTextContent(){return "\n"}createDOM(){return document.createElement("br")}updateDOM(){return false}isInline(){return true}static importDOM(){return {br:t=>function(t){const e=t.parentElement;if(null!==e&&Ts(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&$n(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&$n(n))return true}}return false}(t)||function(t){const e=t.parentElement;if(null!==e&&Ts(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&$n(n))return false;const r=e.lastChild;if(r===t||r.previousSibling===t&&$n(r))return true}return false}(t)?null:{conversion:Wn,priority:0}}}static importJSON(t){return Jn().updateFromJSON(t)}}function Wn(t){return {node:Jn()}}function Jn(){return fs(new Bn)}function jn(t){return t instanceof Bn}function $n(t){return co(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function Un(t,e){return 16&e?"code":e&T$3?"mark":32&e?"sub":64&e?"sup":null}function Vn(t,e){return 1&e?"strong":2&e?"em":"span"}function Yn(t,e,n,r,i){const o=r.classList;let s=$o(i,"base");void 0!==s&&o.add(...s),s=$o(i,"underlineStrikethrough");let l=false;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=true,c||o.add(...s)):c&&o.remove(...s));for(const t in R$6){const r=R$6[t];if(s=$o(i,t),void 0!==s)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&o.remove(...s);continue}(0===(e&r)||c&&"underline"===t||"strikethrough"===t)&&o.add(...s);}else e&r&&o.remove(...s);}}function qn(t,e,n){const r=e.firstChild,i=n.isComposing(),s=t+(i?P$3:"");if(null==r)e.textContent=s;else {const t=r.nodeValue;if(t!==s)if(i||o){const[e,n,i]=function(t,e){const n=t.length,r=e.length;let i=0,o=0;for(;i<n&&i<r&&t[i]===e[i];)i++;for(;o+i<n&&o+i<r&&t[n-o-1]===e[r-o-1];)o++;return [i,n-i-o,e.slice(i,r-o)]}(t,s);0!==n&&r.deleteData(e,n),r.insertData(e,i);}else r.nodeValue=s;}}function Hn(t,e,n,r,i,o){qn(i,t,e);const s=o.theme.text;void 0!==s&&Yn(0,0,r,t,s);}function Gn(t,e){const n=document.createElement(e);return n.appendChild(t),n}class Xn extends Mn{__text;__format;__style;__mode;__detail;static getType(){return "text"}static clone(t){return new Xn(t.__text,t.__key)}afterCloneFrom(t){super.afterCloneFrom(t),this.__text=t.__text,this.__format=t.__format,this.__style=t.__style,this.__mode=t.__mode,this.__detail=t.__detail;}constructor(t="",e){super(e),this.__text=t,this.__format=0,this.__style="",this.__mode=0,this.__detail=0;}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const t=this.getLatest();return $$4[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===mo()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return !!(1&this.getLatest().__detail)}isUnmergeable(){return !!(2&this.getLatest().__detail)}hasFormat(t){const e=R$6[t];return 0!==(this.getFormat()&e)}isSimpleText(){return "text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return fo(this.getLatest().__format,t,e)}canHaveFormat(){return true}isInline(){return true}createDOM(t,e){const n=this.__format,r=Un(0,n),i=Vn(0,n),o=null===r?i:r,s=document.createElement(o);let l=s;
4593this.hasFormat("code")&&s.setAttribute("spellcheck","false"),null!==r&&(l=document.createElement(i),s.appendChild(l));Hn(l,this,0,n,this.__text,t);const c=this.__style;return ""!==c&&(s.style.cssText=c),s}updateDOM(e,n,r){const i=this.__text,o=e.__format,s=this.__format,l=Un(0,o),c=Un(0,s),a=Vn(0,o),u=Vn(0,s);if((null===l?a:l)!==(null===c?u:c))return true;if(l===c&&a!==u){const e=n.firstChild;null==e&&t(48);const o=document.createElement(u);return Hn(o,this,0,s,i,r),n.replaceChild(o,e),false}let f=n;null!==c&&null!==l&&(f=n.firstChild,null==f&&t(49)),qn(i,f,this);const d=r.theme.text;void 0!==d&&o!==s&&Yn(0,o,s,f,d);const h=e.__style,g=this.__style;return h!==g&&(n.style.cssText=g),false}static importDOM(){return {"#text":()=>({conversion:nr,priority:0}),b:()=>({conversion:Zn,priority:0}),code:()=>({conversion:or,priority:0}),em:()=>({conversion:or,priority:0}),i:()=>({conversion:or,priority:0}),mark:()=>({conversion:or,priority:0}),s:()=>({conversion:or,priority:0}),span:()=>({conversion:Qn,priority:0}),strong:()=>({conversion:or,priority:0}),sub:()=>({conversion:or,priority:0}),sup:()=>({conversion:or,priority:0}),u:()=>({conversion:or,priority:0})}}static importJSON(t){return sr().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return Cs(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=Gn(n,"b")),this.hasFormat("italic")&&(n=Gn(n,"i")),this.hasFormat("strikethrough")&&(n=Gn(n,"s")),this.hasFormat("underline")&&(n=Gn(n,"u")),{element:n}}exportJSON(){return {detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?R$6[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?B$4[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=fo(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=j$4[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){ei();let n=t,r=e;const i=Lr(),o=this.getTextContent(),s=this.__key;if("string"==typeof o){const t=o.length;void 0===n&&(n=t),void 0===r&&(r=t);}else n=0,r=0;if(!yr(i))return Mr(s,n,s,r,"text","text");{const t=mo();t!==i.anchor.key&&t!==i.focus.key||yo(s),i.setTextNodeRange(this,n,this,r);}return i}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,r){const i=this.getWritable(),o=i.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=Lr();if(r&&yr(c)){const e=t+s;c.setTextNodeRange(i,e,i,e);}const a=o.slice(0,l)+n+o.slice(l+e);return i.__text=a,i}canInsertTextBefore(){return true}canInsertTextAfter(){return true}splitText(...t){ei();const e=this.getLatest(),n=e.getTextContent();if(""===n)return [];const r=e.__key,i=mo(),o=n.length;t.sort((t,e)=>t-e),t.push(o);const s=[],l=t.length;for(let e=0,r=0;e<o&&r<=l;r++){const i=t[r];i>e&&(s.push(n.slice(e,i)),e=i);}const c=s.length;if(1===c)return [e];const a=s[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=false,p=null,y=null;const m=Lr();if(yr(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===r&&(p=t),"text"===e.type&&e.key===r&&(y=e);}e.isSegmented()?(f=sr(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=yt$4(e,f),_=true):f=e.setTextContent(a);const x=[f];for(let t=1;t<c;t++){const n=sr(s[t]);n.__format=d,n.__style=h,n.__detail=g,n.__state=yt$4(e,n);const o=n.__key;i===r&&yo(o),x.push(n);}const C=p?p.offset:null,S=y?y.offset:null;let v=0;for(const t of x){if(!p&&!y)break;const e=v+t.getTextContentSize();if(null!==p&&null!==C&&C<=e&&C>=v&&(p.set(t.getKey(),C-v,"text"),C<e&&(p=null)),null!==y&&null!==S&&S<=e&&S>=v){y.set(t.getKey(),S-v,"text");break}v=e;}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&po(e);null!==n&&po(n);}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),yr(m)&&Kr(m,u,e,c-1);}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const r=this.__key,i=e.__key,o=this.__text,s=o.length;mo()===i&&yo(r);const l=Lr();if(yr(l)){const t=l.anchor,o=l.focus;null!==t&&t.key===i&&Br(t,n,r,e,s),null!==o&&o.key===i&&Br(o,n,r,e,s);}const c=e.__text,a=n?c+o:o+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return false}}function Qn(t){return {forChild:cr(t.style),node:null}}function Zn(t){const e=t,n="normal"===e.style.fontWeight;return {forChild:cr(e.style,n?void 0:"bold"),node:null}}const tr=new WeakMap;function er(t){if(!Cs(t))return false;if("PRE"===t.nodeName)return true;const e=t.style.whiteSpace;return "string"==typeof e&&e.startsWith("pre")}function nr(e){const n=e;null===e.parentElement&&t(129);let r=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const r=[t];for(;null!==n&&void 0===(e=tr.get(n))&&!er(n);)r.push(n),n=n.parentNode;const i=void 0===e?n:e;for(let t=0;t<r.length;t++)tr.set(r[t],i);return i}(n)){const t=r.split(/(\r?\n|\t)/),e=[],n=t.length;for(let r=0;r<n;r++){const n=t[r];"\n"===n||"\r\n"===n?e.push(Jn()):"\t"===n?e.push(ur()):""!==n&&e.push(sr(n));}return {node:e}}if(r=r.replace(/\r/g,"").replace(/[ \t\n]+/g," "),""===r)return {node:null};if(" "===r[0]){let t=n,e=true;for(;null!==t&&null!==(t=rr(t,false));){const n=t.textContent||"";if(n.length>0){/[ \t\n]$/.test(n)&&(r=r.slice(1)),e=false;break}}e&&(r=r.slice(1));}if(" "===r[r.length-1]){let t=n,e=true;for(;null!==t&&null!==(t=rr(t,true));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=false;break}}e&&(r=r.slice(0,r.length-1));}return ""===r?{node:null}
4593:{node:sr(r)}}function rr(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t;}if(n=t,Cs(n)){const t=n.style.display;if(""===t&&!ks(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(co(n))return n;if("BR"===n.nodeName)return null}}const ir={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function or(t){const e=ir[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:cr(t.style,e),node:null}}function sr(t=""){return fs(new Xn(t))}function lr(t){return t instanceof Xn}function cr(t,e){const n=t.fontWeight,r=t.textDecoration.split(" "),i="700"===n||"bold"===n,o=r.includes("line-through"),s="italic"===t.fontStyle,l=r.includes("underline"),c=t.verticalAlign;return t=>lr(t)?(i&&!t.hasFormat("bold")&&t.toggleFormat("bold"),o&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),s&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class ar extends Xn{static getType(){return "tab"}static clone(t){return new ar(t.__key)}constructor(t){super("\t",t),this.__detail=2;}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=$o(t.theme,"tab");if(void 0!==n){e.classList.add(...n);}return e}static importJSON(t){return ur().updateFromJSON(t)}setTextContent(t){return "\t"!==t&&""!==t&&e(126),super.setTextContent("\t")}spliceText(e,n,r,i){return ""===r&&0===n||"\t"===r&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return "normal"!==e&&t(128),this}canInsertTextBefore(){return false}canInsertTextAfter(){return false}}function ur(){return fs(new ar)}function fr(t){return t instanceof ar}class dr{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n;}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offset<t.offset;return gl(El(xl(this,"next")),El(xl(t,"next")))<0}getNode(){const e=xo(this.key);return null===e&&t(20),e}set(t,e,n,r){const i=this._selection,o=this.key;r&&this.key===t&&this.offset===e&&this.type===n||(this.key=t,this.offset=e,this.type=n,ti()||(mo()===o&&yo(t),null!==i&&(i.setCachedNodes(null),i.dirty=true)));}}function hr(t,e,n){return new dr(t,e,n)}function gr(t,e){let n=e.__key,r=t.offset,i="element";if(lr(e)){i="text";const t=e.getTextContentSize();r>t&&(r=t);}else if(!Si(e)){const t=e.getNextSibling();if(lr(t))n=t.__key,r=0,i="text";else {const t=e.getParent();t&&(n=t.__key,r=e.getIndexWithinParent()+1);}}t.set(n,r,i);}function _r(t,e){if(Si(e)){const n=e.getLastDescendant();Si(n)||lr(n)?gr(t,n):gr(t,e);}else gr(t,e);}class pr{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=false;}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t;}is(t){if(!xr(t))return false;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return false}isBackward(){return false}getStartEndPoints(){return null}add(t){this.dirty=true,this._nodes.add(t),this._cachedNodes=null;}delete(t){this.dirty=true,this._nodes.delete(t),this._cachedNodes=null;}clear(){this.dirty=true,this._nodes.clear(),this._cachedNodes=null;}has(t){return this._nodes.has(t)}clone(){return new pr(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes(),n=e.length,r=e[n-1];let i;if(lr(r))i=r.select();else {const t=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(t,t);}i.insertNodes(t);for(let t=0;t<n;t++)e[t].remove();}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=this._nodes,n=[];for(const t of e){const e=xo(t);null!==e&&n.push(e);}return ti()||(this._cachedNodes=n),n}getTextContent(){const t=this.getNodes();let e="";for(let n=0;n<t.length;n++)e+=t[n].getTextContent();return e}deleteNodes(){const t=this.getNodes();if((Lr()||Ir())===this&&t[0]){const e=tl(t[0],"next");Sl(dl(e,e));}for(const e of t)e.remove();}}function yr(t){return t instanceof mr}class mr{format;style;anchor;focus;_cachedNodes;dirty;constructor(t,e,n,r){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this.format=n,this.style=r,this.dirty=false;}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t;}is(t){return !!yr(t)&&(this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=function(t){const e=[],[n,r]=t.getTextSlices();n&&e.push(n.caret.origin);const i=new Set,o=new Set;for(const n of t)if(Gs(n)){const{origin:t}=n;
45930===e.length?i.add(t):(o.add(t),e.push(t));}else {const{origin:t}=n;Si(t)&&o.has(t)||e.push(t);}r&&e.push(r.caret.origin);if(Hs(t.focus)&&Si(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=il(t.focus.origin,"previous");Gs(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=sl(n))i.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!Si(t)||o.has(t)||t.isEmpty()||i.has(t))break;e.pop();}if(0===e.length&&t.isCollapsed()){const n=El(t.anchor),r=El(t.anchor.getFlipped()),i=t=>Ys(t)?t.origin:t.getNodeAtCaret(),o=i(n)||i(r)||(t.anchor.getNodeAtCaret()?n.origin:r.origin);e.push(o);}return e}(Al(kl(this),"next"));return ti()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,r){this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,r,"text");}getTextContent(){const t=this.getNodes();if(0===t.length)return "";const e=t[0],n=t[t.length-1],r=this.anchor,i=this.focus,o=r.isBefore(i),[s,l]=Sr(this);let c="",a=true;for(let u=0;u<t.length;u++){const f=t[u];if(Si(f)&&!f.isInline())a||(c+="\n"),a=!f.isEmpty();else if(a=false,lr(f)){let t=f.getTextContent();f===e?f===n?"element"===r.type&&"element"===i.type&&i.offset!==r.offset||(t=s<l?t.slice(s,l):t.slice(l,s)):t=o?t.slice(s):t.slice(l):f===n&&(t=o?t.slice(0,l):t.slice(0,s)),c+=t;}else !Ti(f)&&!jn(f)||f===n&&this.isCollapsed()||(c+=f.getTextContent());}return c}applyDOMRange(t){const e=ii(),n=e.getEditorState()._selection,r=Er(t.startContainer,t.startOffset,t.endContainer,t.endOffset,e,n);if(null===r)return;const[i,o]=r;this.anchor.set(i.key,i.offset,i.type,true),this.focus.set(o.key,o.offset,o.type,true),St$6(this);}clone(){const t=this.anchor,e=this.focus;return new mr(hr(t.key,t.offset,t.type),hr(e.key,e.offset,e.type),this.format,this.style)}toggleFormat(t){this.format=fo(this.format,t,null),this.dirty=true;}setFormat(t){this.format=t,this.dirty=true;}setStyle(t){this.style=t,this.dirty=true;}hasFormat(t){const e=R$6[t];return 0!==(this.format&e)}insertRawText(t){const e=t.split(/(\r?\n|\t)/),n=[],r=e.length;for(let t=0;t<r;t++){const r=e[t];"\n"===r||"\r\n"===r?n.push(Jn()):"\t"===r?n.push(ur()):n.push(sr(r));}this.insertNodes(n);}insertText(e){const n=this.anchor,r=this.focus,i=this.format,o=this.style;let s=n,l=r;!this.isCollapsed()&&r.isBefore(n)&&(s=r,l=n),"element"===s.type&&function(t,e,n,r){const i=t.getNode(),o=i.getChildAtIndex(t.offset),s=sr();if(s.setFormat(n),s.setStyle(r),Ii(o))o.splice(0,0,[s]);else {const t=bi(i)?Li().append(s):s;null===o?i.append(t):o.insertBefore(t);}t.is(e)&&e.set(s.__key,0,"text"),t.set(s.__key,0,"text");}(s,l,i,o),"element"===l.type&&Cl(l,El(xl(l,"next")));const c=s.offset;let a=l.offset;const u=this.getNodes(),f=u.length;let d=u[0];lr(d)||t(26);const h=d.getTextContent().length,g=d.getParentOrThrow();let _=u[f-1];if(1===f&&"element"===l.type&&(a=h,l.set(s.key,a,"text")),this.isCollapsed()&&c===h&&(lo(d)||!d.canInsertTextAfter()||!g.canInsertTextAfter()&&null===d.getNextSibling())){let t=d.getNextSibling();if(lr(t)&&t.canInsertTextBefore()&&!lo(t)||(t=sr(),t.setFormat(i),t.setStyle(o),g.canInsertTextAfter()?d.insertAfter(t):g.insertAfter(t)),t.select(0,0),d=t,""!==e)return void this.insertText(e)}else if(this.isCollapsed()&&0===c&&(lo(d)||!d.canInsertTextBefore()||!g.canInsertTextBefore()&&null===d.getPreviousSibling())){let t=d.getPreviousSibling();if(lr(t)&&!lo(t)||(t=sr(),t.setFormat(i),g.canInsertTextBefore()?d.insertBefore(t):g.insertBefore(t)),t.select(),d=t,""!==e)return void this.insertText(e)}else if(d.isSegmented()&&c!==h){const t=sr(d.getTextContent());t.setFormat(i),d.replace(t),d=t;}else if(!this.isCollapsed()&&""!==e){const t=_.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||Si(t)&&(!t.canInsertTextBefore()||!t.canInsertTextAfter()))return this.insertText(""),wr(this.anchor,this.focus,null),void this.insertText(e)}if(1===f){if(so(d)){const t=sr(e);return t.select(),void d.replace(t)}const t=d.getFormat(),n=d.getStyle();if(c!==a||t===i&&n===o){if(fr(d)){const t=sr(e);return t.setFormat(i),t.setStyle(o),t.select(),void d.replace(t)}}else {if(""!==d.getTextContent()){const t=sr(e);
4593if(t.setFormat(i),t.setStyle(o),t.select(),0===c)d.insertBefore(t,false);else {const[e]=d.splitText(c);e.insertAfter(t,false);}return void(t.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length))}d.setFormat(i),d.setStyle(o);}const r=a-c;d=d.spliceText(c,r,e,true),""===d.getTextContent()?d.remove():"text"===this.anchor.type&&(d.isComposing()?this.anchor.offset-=e.length:(this.format=t,this.style=n));}else {const t=new Set([...d.getParentKeys(),..._.getParentKeys()]),n=Si(d)?d:d.getParentOrThrow();let r=Si(_)?_:_.getParentOrThrow(),i=_;if(!n.is(r)&&r.isInline())do{i=r,r=r.getParentOrThrow();}while(r.isInline());if("text"===l.type&&(0!==a||""===_.getTextContent())||"element"===l.type&&_.getIndexWithinParent()<a)if(lr(_)&&!so(_)&&a!==_.getTextContentSize()){if(_.isSegmented()){const t=sr(_.getTextContent());_.replace(t),_=t;}bi(l.getNode())||"text"!==l.type||(_=_.spliceText(0,a,"")),t.add(_.__key);}else {const t=_.getParentOrThrow();t.canBeEmpty()||1!==t.getChildrenSize()?_.remove():t.remove();}else t.add(_.__key);const o=r.getChildren(),s=new Set(u),g=n.is(r),p=n.isInline()&&null===d.getNextSibling()?n:d;for(let t=o.length-1;t>=0;t--){const e=o[t];
4593if(e.is(d)||Si(e)&&e.isParentOf(d))break;e.isAttached()&&(!s.has(e)||e.is(i)?g||p.insertAfter(e,false):e.remove());}if(!g){let e=r,n=null;for(;null!==e;){const r=e.getChildren(),i=r.length;(0===i||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent();}}if(so(d))if(c===h)d.select();else {const t=sr(e);t.select(),d.replace(t);}else d=d.spliceText(c,h-c,e,true),""===d.getTextContent()?d.remove():d.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length);for(let e=1;e<f;e++){const n=u[e],r=n.__key;t.has(r)||n.remove();}}}removeText(){const t=Lr()===this;vl(this,wl(kl(this))),t&&Lr()!==this&&wo(this);}formatText(t,e=null){if(this.isCollapsed())return this.toggleFormat(t),void yo(null);const n=this.getNodes(),r=[];for(const t of n)lr(t)&&r.push(t);const i=e=>{n.forEach(n=>{if(Si(n)){const r=n.getFormatFlags(t,e);n.setTextFormat(r);}});},o=r.length;if(0===o)return this.toggleFormat(t),yo(null),void i(e);const s=this.anchor,l=this.focus,c=this.isBackward(),a=c?l:s,u=c?s:l;let f=0,d=r[0],h="element"===a.type?0:a.offset;if("text"===a.type&&h===d.getTextContentSize()&&(f=1,d=r[1],h=0),null==d)return;const g=d.getFormatFlags(t,e);i(g);const _=o-1;let p=r[_];const y="text"===u.type?u.offset:p.getTextContentSize();if(d.is(p)){if(h===y)return;if(lo(d)||0===h&&y===d.getTextContentSize())d.setFormat(g);else {const t=d.splitText(h,y),e=0===h?t[0]:t[1];e.setFormat(g),"text"===a.type&&a.set(e.__key,0,"text"),"text"===u.type&&u.set(e.__key,y-h,"text");}return void(this.format=g)}0===h||lo(d)||([,d]=d.splitText(h),h=0),d.setFormat(g);const m=p.getFormatFlags(t,g);y>0&&(y===p.getTextContentSize()||lo(p)||([p]=p.splitText(y)),p.setFormat(m));for(let e=f+1;e<_;e++){const n=r[e],i=n.getFormatFlags(t,m);n.setFormat(i);}"text"===a.type&&a.set(d.__key,h,"text"),"text"===u.type&&u.set(p.__key,y,"text"),this.format=g|m;}insertNodes(e){if(0===e.length)return;if(this.isCollapsed()||this.removeText(),"root"===this.anchor.key){this.insertParagraph();const n=Lr();return yr(n)||t(134),n.insertNodes(e)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=zs(n,Ns),i=e[e.length-1];if(Si(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else {const t=Ur(this);r.splice(t,0,e),i.selectEnd();}return}if(!e.some(t=>(Si(t)||Ti(t))&&!t.isInline())){Si(r)||t(211,n.constructor.name,n.getType());const o=Ur(this);return r.splice(o,0,e),void i.selectEnd()}const o=function(t){const e=Li();let n=null;for(let r=0;r<t.length;r++){const i=t[r],o=jn(i);if(o||Ti(i)&&i.isInline()||Si(i)&&i.isInline()||lr(i)||i.isParentRequired()){if(null===n&&(n=i.createParentElementNode(),e.append(n),o))continue;null!==n&&n.append(i);}else e.append(i),n=null;}return e}(e),s=o.getLastDescendant(),l=o.getChildren(),c=!Si(r)||!r.isEmpty()?this.insertParagraph():null,a=l[l.length-1];let u=l[0];var f;Si(f=u)&&Ns(f)&&!f.isEmpty()&&Si(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(Si(r)||t(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=l[1]),u&&(null===r&&t(212,n.constructor.name,n.getType()),function(e,n){const r=n.getParentOrThrow().getLastChild();let i=n;const o=[n];for(;i!==r;)i.getNextSibling()||t(140),i=i.getNextSibling(),o.push(i);let s=e;for(const t of o)s=s.insertAfter(t);}(r,u));const d=zs(s,Ns);c&&Si(d)&&(c.canMergeWhenEmpty()||Ns(a))&&(d.append(...c.getChildren()),c.remove()),Si(r)&&r.isEmpty()&&r.remove(),s.selectEnd();const h=Si(r)?r.getLastChild():null;jn(h)&&d!==r&&h.remove();}insertParagraph(){if("root"===this.anchor.key){const t=Li();return No().splice(this.anchor.offset,0,[t]),t.select(),t}const e=Ur(this),n=zs(this.anchor.getNode(),Ns);Si(n)||t(213);const r=n.getChildAtIndex(e),i=r?[r,...r.getNextSiblings()]:[],o=n.insertNewAfter(this,false);return o?(o.append(...i),o.selectStart(),o):null}insertLineBreak(t){const e=Jn();if(this.insertNodes([e]),t){const t=e.getParentOrThrow(),n=e.getIndexWithinParent();t.select(n,n);}}extract(){const t=[...this.getNodes()],e=t.length;let n=t[0],r=t[e-1];const[i,o]=Sr(this),s=this.isBackward(),[l,c]=s?[this.focus,this.anchor]:[this.anchor,this.focus],[a,u]=s?[o,i]:[i,o];if(0===e)return [];if(1===e){if(lr(n)&&!this.isCollapsed()){const t=n.splitText(a,u),e=0===a?t[0]:t[1];return e?(l.set(e.getKey(),0,"text"),c.set(e.getKey(),e.getTextContentSize(),"text"),[e]):[]}return [n]}if(lr(n)&&(a===n.getTextContentSize()?t.shift():0!==a&&([,n]=n.splitText(a),t[0]=n,l.set(n.getKey(),0,"text"))),lr(r)){const e=r.getTextContent().length;0===u?t.pop():u!==e&&([r]=r.splitText(u),t[t.length-1]=r,c.set(r.getKey(),r.getTextContentSize(),"text"));}return t}modify(t,e,n){if(Yr(this,t,e,n))return;const r="move"===t,i=ii(),o=ps(ss(i));if(!o)return;const s=i._blockCursorElement,l=i._rootElement,c=this.focus.getNode();if(null===l||null===s||!Si(c)||c.isInline()||c.canBeEmpty()||_s(s,i,l),this.dirty){let t=Qo(i,this.anchor.key),e=Qo(i,this.focus.key);"text"===this.anchor.type&&(t=uo(t)),"text"===this.focus.type&&(e=uo(e)),t&&e&&Wr(o,t,this.anchor.offset,e,this.focus.offset);}if(function(t,e,n,r){t.modify(e,n,r);}(o,t,e?"backward":"forward",n),o.rangeCount>0){const t=o.getRangeAt(0),n=this.anchor.getNode(),i=bi(n)?n:cs(n);if(this.applyDOMRange(t),this.dirty=true,!r){const n=this.getNodes(),r=[];let s=false;for(let t=0;t<n.length;t++){const e=n[t];is(e,i)?r.push(e):s=true;}if(s&&r.length>0)if(e){const t=r[0];Si(t)?t.selectStart():t.getParentOrThrow().selectStart();}else {const t=r[r.length-1];Si(t)?t.selectEnd():t.getParentOrThrow().selectEnd();}
4593o.anchorNode===t.startContainer&&o.anchorOffset===t.startOffset||function(t){const e=t.focus,n=t.anchor,r=n.key,i=n.offset,o=n.type;n.set(e.key,e.offset,e.type,true),e.set(r,i,o,true);}(this);}}"lineboundary"===n&&Yr(this,t,e,n,"decorators");}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Si(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(Si(n)&&n.isShadowRoot())return true}return false}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const r=ul(xl(e,t?"previous":"next"));if(r.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of r.iterNodeCarets("shadowRoot"))if(Gs(e))if(e.origin.isInline());else {if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Si(r.anchor.origin)&&r.anchor.origin.isEmpty()){const t=El(e);vl(this,dl(t,t)),r.anchor.origin.remove();}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"});}else {if("merge-block"===t.type)break;if(Hs(e)){if(Si(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(r.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(Ti(e.origin)){if(e.origin.isIsolated());else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Si(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const t=Pr();t.add(e.origin.getKey()),wo(t);}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;return vl(this,dl(!e.origin.isEmpty()&&n.isEmpty()?Tl(tl(n,e.direction)):r.anchor,e)),this.removeText()}}const i=this.focus;if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&0===e.offset&&vr(this,e.getNode()))return}else {const r="text"===i.type?i.getNode():null;if(n="text"===e.type?e.getNode():null,null!==r&&r.isSegmented()){const e=i.offset,o=r.getTextContentSize();if(r.is(n)||t&&e!==o||!t&&0!==e)return void Tr(r,t,e)}else if(null!==n&&n.isSegmented()){const i=e.offset,o=n.getTextContentSize();if(n.is(r)||t&&0!==i||!t&&i!==o)return void Tr(n,t,i)}!function(t,e){const n=t.anchor,r=t.focus,i=n.getNode(),o=r.getNode();if(i===o&&"text"===n.type&&"text"===r.type){const t=n.offset,o=r.offset,s=t<o,l=s?t:o,c=s?o:t,a=c-1;if(l!==a){(function(t){return !(Oo(t)||kr(t))})(i.getTextContent().slice(l,c))&&(e?r.set(r.key,a,r.type):n.set(n.key,a,n.type));}}}(this,t);}}if(this.removeText(),t&&!e&&this.isCollapsed()&&"element"===this.anchor.type&&0===this.anchor.offset){const t=this.anchor.getNode();t.isEmpty()&&bi(t.getParent())&&null===t.getPreviousSibling()&&vr(this,t);}}deleteLine(t){this.isCollapsed()&&this.modify("extend",t,"lineboundary"),this.isCollapsed()?this.deleteCharacter(t):this.removeText();}deleteWord(t){if(this.isCollapsed()){const e=this.anchor,n=e.getNode();if(this.forwardDeletion(e,n,t))return;this.modify("extend",t,"word");}this.removeText();}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return [this.anchor,this.focus]}}function xr(t){return t instanceof pr}function Cr(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function Sr(t){const e=t.getStartEndPoints();if(null===e)return [0,0];const[n,r]=e;return "element"===n.type&&"element"===r.type&&n.key===r.key&&n.offset===r.offset?[0,0]:[Cr(n),Cr(r)]}function vr(t,e){for(let n=e;n;n=n.getParent()){if(Si(n)){if(n.collapseAtStart(t))return true;if(as(n))break}if(n.getPreviousSibling())break}return false}const kr=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("â¤ï¸")&&e("#ï¸â£")&&e("ð"))return e}catch(t){}return ()=>false})();function Tr(t,e,n){const r=t,i=r.getTextContent().split(/(?=\s)/g),o=i.length;let s=0,l=0;for(let t=0;t<o;t++){const r=t===o-1;if(l=s,s+=i[t].length,e&&s===n||s>n||r){i.splice(t,1),r&&(l=void 0);break}}const c=i.join("").trim();""===c?r.remove():(r.setTextContent(c),r.select(l,l));}function Nr(e,n,r,i){let o,s=n;if(Cs(e)){let l=false;const c=e.childNodes,a=c.length,u=i._blockCursorElement;s===a&&(l=true,s=a-1);let f=c[s],d=false;if(f===u)f=c[s+1],d=true;else if(null!==u){const t=u.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,u)&&s--;}}if(o=Eo(f),lr(o))s=nl(o,l?"next":"previous");else {let c=Eo(e);if(null===c)return null;if(Si(c)){const a=i.getElementByKey(c.getKey());null===a&&t(214);const u=c.getDOMSlot(a);
4593[c,s]=u.resolveChildIndex(c,a,e,n),Si(c)||t(215),l&&s>=c.getChildrenSize()&&(s=Math.max(0,c.getChildrenSize()-1));let f=c.getChildAtIndex(s);if(Si(f)&&function(t,e,n){const r=t.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(f,0,r)){const t=l?f.getLastDescendant():f.getFirstDescendant();null===t?c=f:(f=t,c=Si(f)?f:f.getParentOrThrow()),s=0;}lr(f)?(o=f,c=null,s=nl(f,l?"next":"previous")):f!==c&&l&&!d&&(Si(c)||t(216),s=Math.min(c.getChildrenSize(),s+1));}else {const t=c.getIndexWithinParent();s=0===n&&Ti(c)&&Eo(e)===c?t:t+1,c=c.getParentOrThrow();}if(Si(c))return hr(c.__key,s,"element")}}else o=Eo(e);return lr(o)?hr(o.__key,nl(o,s,"clamp"),"text"):null}function br(t,e,n){const r=t.offset,i=t.getNode();if(0===r){const r=i.getPreviousSibling(),o=i.getParent();if(e){if((n||!e)&&null===r&&Si(o)&&o.isInline()){const e=o.getPreviousSibling();lr(e)&&t.set(e.__key,e.getTextContent().length,"text");}}else Si(r)&&!n&&r.isInline()?t.set(r.__key,r.getChildrenSize(),"element"):lr(r)&&t.set(r.__key,r.getTextContent().length,"text");}else if(r===i.getTextContent().length){const r=i.getNextSibling(),o=i.getParent();if(e&&Si(r)&&r.isInline())t.set(r.__key,0,"element");else if((n||e)&&null===r&&Si(o)&&o.isInline()&&!o.canInsertTextAfter()){const e=o.getNextSibling();lr(e)&&t.set(e.__key,0,"text");}}}function wr(t,e,n){if("text"===t.type&&"text"===e.type){const r=t.isBefore(e),i=t.is(e);br(t,r,i),br(e,!r,i),i&&e.set(t.key,t.offset,t.type);const o=ii();if(o.isComposing()&&o._compositionKey!==t.key&&yr(n)){const r=n.anchor,i=n.focus;t.set(r.key,r.offset,r.type,true),e.set(i.key,i.offset,i.type,true);}}}function Er(t,e,n,r,i,o){if(null===t||null===n||!eo(i,t,n))return null;const s=Nr(t,e,yr(o)?o.anchor:null,i);if(null===s)return null;const l=Nr(n,r,yr(o)?o.focus:null,i);if(null===l)return null;if("element"===s.type&&"element"===l.type){const e=Eo(t),r=Eo(n);if(Ti(e)&&Ti(r))return null}return wr(s,l,o),[s,l]}function Or(t){return Si(t)&&!t.isInline()}function Mr(t,e,n,r,i,o){const s=ri(),l=new mr(hr(t,e,i),hr(n,r,o),0,"");return l.dirty=true,s._selection=l,l}function Ar(){const t=hr("root",0,"element"),e=hr("root",0,"element");return new mr(t,e,0,"")}function Pr(){return new pr(new Set)}function Dr(t,e){return Fr(null,t,e,null)}function Fr(t,e,n,r){const i=n._window;if(null===i)return null;const o=r||i.event,s=o?o.type:void 0,l="selectionchange"===s,c=!q$5&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&o&&3===o.detail||"drop"===s||void 0===s);let a,u,f,d;if(yr(t)&&!c)return t.clone();if(null===e)return null;if(a=e.anchorNode,u=e.focusNode,f=e.anchorOffset,d=e.focusOffset,(l||void 0===s)&&yr(t)&&!eo(n,a,u))return t.clone();const h=Er(a,f,u,d,n,t);if(null===h)return null;const[g,_]=h;return new mr(g,_,yr(t)?t.format:0,yr(t)?t.style:"")}function Lr(){return ri()._selection}function Ir(){return ii()._editorState._selection}function Kr(t,e,n,r=1){const i=t.anchor,o=t.focus,s=i.getNode(),l=o.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=i.offset;if(n<=e&&r>0||n<e&&r<0){const n=Math.max(0,e+r);i.set(c,n,"element"),o.set(c,n,"element"),zr(t);}}else {const s=t.isBackward(),l=s?o:i,a=l.getNode(),u=s?i:o,f=u.getNode();if(e.is(a)){const t=l.offset;(n<=t&&r>0||n<t&&r<0)&&l.set(c,Math.max(0,t+r),"element");}if(e.is(f)){const t=u.offset;(n<=t&&r>0||n<t&&r<0)&&u.set(c,Math.max(0,t+r),"element");}}zr(t);}function zr(t){const e=t.anchor,n=e.offset,r=t.focus,i=r.offset,o=e.getNode(),s=r.getNode();if(t.isCollapsed()){if(!Si(o))return;const t=o.getChildrenSize(),i=n>=t,s=i?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(lr(s)){let t=0;i&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),r.set(s.__key,t,"text");}return}if(Si(o)){const t=o.getChildrenSize(),r=n>=t,i=r?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(lr(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text");}}if(Si(s)){const t=s.getChildrenSize(),e=i>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(i);if(lr(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text");}}}function Rr(t,e,n,r,i){let o=null,s=0,l=null;null!==r?(o=r.__key,lr(r)?(s=r.getTextContentSize(),l="text"):Si(r)&&(s=r.getChildrenSize(),l="element")):null!==i&&(o=i.__key,lr(i)?l="text":Si(i)&&(l="element")),null!==o&&null!==l?t.set(o,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"));}function Br(t,e,n,r,i){"text"===t.type?t.set(n,t.offset+(e?0:i),"text"):t.offset>r.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element");}function Wr(t,e,n,r,i){try{t.setBaseAndExtent(e,n,r,i);}catch(t){}}function Jr(t,e,n,r,i,o,s){const l=r.anchorNode,c=r.focusNode,a=r.anchorOffset,u=r.focusOffset,f=document.activeElement;if(i.has(Ln)&&f!==o||null!==f&&to(f))return;if(!yr(e))return void(null!==t&&eo(n,l,c)&&r.removeAllRanges());const d=e.anchor,h=e.focus,g=d.key,_=h.key,p=Qo(n,g),y=Qo(n,_),m=d.offset,x=h.offset,C=e.format,S=e.style,v=e.isCollapsed();let k=p,T=y,N=false;if("text"===d.type){k=uo(p);const t=d.getNode();N=t.getFormat()!==C||t.getStyle()!==S;}else yr(t)&&"text"===t.anchor.type&&(N=true);var b,w,E,O,M;if(("text"===h.type&&(T=uo(y)),null!==k&&null!==T)&&(v&&(null===t||N||yr(t)&&(t.format!==C||t.style!==S))&&(b=C,w=S,E=m,O=g,M=performance.now(),fn$1=[b,w,E,O,M]),a!==m||u!==x||l!==k||c!==T||"Range"===r.type&&v||(null!==f&&o.contains(f)||i.has(Rn)||o.focus({preventScroll:true}),"element"===d.type))){if(Wr(r,k,m,T,x),!i.has(Kn)&&e.isCollapsed()&&null!==o&&o===document.activeElement){const t=yr(e)&&"element"===e.anchor.type?k.childNodes[m]||null:r.rangeCount>0?r.getRangeAt(0):null;if(null!==t){let e;if(t instanceof Text){const n=document.createRange();n.selectNode(t),e=n.getBoundingClientRect();}else e=t.getBoundingClientRect();!function(t,e,n){const r=ts(n),i=os(r);if(null===r||null===i)return;let{top:o,bottom:s}=e,l=0,c=0,a=n;for(;null!==a;){const e=a===r.body;if(e)l=0,c=ss(t).innerHeight;else {const t=a.getBoundingClientRect();l=t.top,c=t.bottom;}let n=0;if(o<l?n=-(l-o):s>c&&(n=s-c),0!==n)if(e)i.scrollBy(0,n);else {const t=a.scrollTop;a.scrollTop+=n;const e=a.scrollTop-t;o-=e,s-=e;}if(e)break;a=Zo(a);}}(n,e,o);}}rn$1=true;}}function jr(t){let e=Lr()||Ir();
4593null===e&&(e=No().selectEnd()),e.insertNodes(t);}function Ur(e){let n=e;e.isCollapsed()||n.removeText();const r=Lr();yr(r)&&(n=r),yr(n)||t(161);const i=n.anchor;let o=i.getNode(),s=i.offset;for(;!Ns(o);){const t=o;if([o,s]=Vr(o,s),t.is(o))break}return s}function Vr(t,e){const n=t.getParent();if(!n){const t=Li();return No().append(t),t.select(),[No(),0]}if(lr(t)){const r=t.splitText(e);if(0===r.length)return [n,t.getIndexWithinParent()];const i=0===e?0:1;return [n,r[0].getIndexWithinParent()+i]}if(!Si(t)||0===e)return [n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new mr(hr(t.__key,e,"element"),hr(t.__key,e,"element"),0,""),i=t.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings());}return [n,t.getIndexWithinParent()+1]}function Yr(t,e,n,r,i="decorators-and-blocks"){if("move"===e&&"character"===r&&!t.isCollapsed()){const[e,r]=n===t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];return r.set(e.key,e.offset,e.type),true}const o=xl(t.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===e;let c=o,a="decorators-and-blocks"===i;if(!Ol(c)){for(const t of c){a=false;const{origin:e}=t;if(!Ti(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of ul(o).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(Gs(t))t.origin.isInline()||(c=t);else {if(Si(t.origin))continue;Ti(t.origin)&&!t.origin.isInline()&&(c=t);}break}}if(c===o)return false;if(l&&!s&&Ti(c.origin)&&c.origin.isKeyboardSelectable()){const t=Pr();return t.add(c.origin.getKey()),wo(t),true}return c=El(c),l&&Cl(t.anchor,c),Cl(t.focus,c),a||!s}let qr=null,Hr=null,Gr=false,Xr=false,Qr=0;const Zr={characterData:true,childList:true,subtree:true};function ti(){return Gr||null!==qr&&qr._readOnly}function ei(){Gr&&t(13);}function ni(){Qr>99&&t(14);}function ri(){return null===qr&&t(195,oi()),qr}function ii(){return null===Hr&&t(196,oi()),Hr}function oi(){let t=0;const e=new Set,n=Ui.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const i=io(r);if(no(i))t++;else if(i){let t=String(i.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t);}}let r=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(r+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),r}function si(){return Hr}function li(t,e,n){const r=e.__type,i=Gi(t,r);let o=n.get(r);void 0===o&&(o=Array.from(i.transforms),n.set(r,o));const s=o.length;for(let t=0;t<s&&(o[t](e),e.isAttached());t++);}function ci(t,e){return void 0!==t&&t.__key!==e&&t.isAttached()}function ai(t,e){if(!e)return;const n=t._updateTags;let r=e;Array.isArray(e)||(r=[e]);for(const t of r)n.add(t);}function ui(t){return fi(t,ii()._nodes)}function fi(e,n){const r=e.type,i=n.get(r);void 0===i&&t(17,r);const o=i.klass;e.type!==o.getType()&&t(18,o.name);const s=o.importJSON(e),l=e.children;if(Si(s)&&Array.isArray(l))for(let t=0;t<l.length;t++){const e=fi(l[t],n);s.append(e);}return s}function di(t,e,n){const r=qr,i=Gr,o=Hr;qr=e,Gr=true,Hr=t;try{return n()}finally{qr=r,Gr=i,Hr=o;}}function hi(t,e){const n=t._pendingEditorState,r=t._rootElement,i=t._headless||null===r;if(null===n)return;const o=t._editorState,s=o._selection,l=n._selection,c=0!==t._dirtyType,a=qr,u=Gr,f=Hr,d=t._updating,g=t._observer;let _=null;if(t._pendingEditorState=null,t._editorState=n,!i&&c&&null!==g){Hr=t,qr=n,Gr=false,t._updating=true;try{const e=t._dirtyType,r=t._dirtyElements,i=t._dirtyLeaves;g.disconnect(),_=ee$1(o,n,t,e,r,i);}catch(e){if(e instanceof Error&&t._onError(e),Xr)throw e;return Ji(t,null,r,n),rt$3(t),t._dirtyType=2,Xr=true,hi(t,o),void(Xr=false)}finally{g.observe(r,Zr),t._updating=d,qr=a,Gr=u,Hr=f;}}n._readOnly||(n._readOnly=true);const p=t._dirtyLeaves,y=t._dirtyElements,m=t._normalizedNodes,x=t._updateTags,C=t._deferred;c&&(t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements=new Map,t._normalizedNodes=new Set,t._updateTags=new Set),function(t,e){const n=t._decorators;let r=t._pendingDecorators||n;const i=e._nodeMap;let o;
4593for(o in r)i.has(o)||(r===n&&(r=ko(t)),delete r[o]);}(t,n);const S=i?null:ps(ss(t));if(t._editable&&null!==S&&(c||null===l||l.dirty||!l.is(s))&&null!==r&&!x.has(zn)){Hr=t,qr=n;try{if(null!==g&&g.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&_s(e,t,r),Jr(s,l,t,S,x,r);}!function(t,e,n){let r=t._blockCursorElement;if(yr(n)&&n.isCollapsed()&&"element"===n.anchor.type&&e.contains(document.activeElement)){const i=n.anchor,o=i.getNode(),s=i.offset;let l=!1,c=null;if(s===o.getChildrenSize()){gs(o.getChildAtIndex(s-1))&&(l=!0);}else {const e=o.getChildAtIndex(s);if(null!==e&&gs(e)){const n=e.getPreviousSibling();(null===n||gs(n))&&(l=!0,c=t.getElementByKey(e.__key));}}if(l){const n=t.getElementByKey(o.__key);return null===r&&(t._blockCursorElement=r=function(t){const e=t.theme,n=document.createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let r=e.blockCursor;if(void 0!==r){if("string"==typeof r){const t=h$1(r);r=e.blockCursor=t;}void 0!==r&&n.classList.add(...r);}return n}(t._config)),e.style.caretColor="transparent",void(null===c?n.appendChild(r):n.insertBefore(r,c))}}null!==r&&_s(r,t,e);}(t,r,l);}finally{null!==g&&g.observe(r,Zr),Hr=f,qr=a;}}null!==_&&function(t,e,n,r,i){const o=Array.from(t._listeners.mutation),s=o.length;for(let t=0;t<s;t++){const[s,l]=o[t];for(const t of l){const o=e.get(t);void 0!==o&&s(o,{dirtyLeaves:r,prevEditorState:i,updateTags:n});}}}(t,_,x,p,o),yr(l)||null===l||null!==s&&s.is(l)||t.dispatchCommand(ie$1,void 0);const v=t._pendingDecorators;null!==v&&(t._decorators=v,t._pendingDecorators=null,gi("decorator",t,true,v)),function(t,e,n){const r=To(e),i=To(n);r!==i&&gi("textcontent",t,true,i);}(t,e||o,n),gi("update",t,true,{dirtyElements:y,dirtyLeaves:p,editorState:n,mutatedNodes:_,normalizedNodes:m,prevEditorState:e||o,tags:x}),function(t,e){if(t._deferred=[],0!==e.length){const n=t._updating;t._updating=true;try{for(let t=0;t<e.length;t++)e[t]();}finally{t._updating=n;}}}(t,C),function(t){const e=t._updates;if(0!==e.length){const n=e.shift();if(n){const[e,r]=n;pi(t,e,r);}}}(t);}function gi(t,e,n,...r){const i=e._updating;e._updating=n;try{const n=Array.from(e._listeners[t]);for(let t=0;t<n.length;t++)n[t].apply(null,r);}finally{e._updating=i;}}function _i(e,n){const r=e._updates;let i=n||false;for(;0!==r.length;){const n=r.shift();if(n){const[r,o]=n,s=e._pendingEditorState;let l;void 0!==o&&(l=o.onUpdate,o.skipTransforms&&(i=true),o.discrete&&(null===s&&t(191),s._flushSync=true),l&&e._deferred.push(l),ai(e,o.tag)),null==s?pi(e,r,o):r();}}return i}function pi(e,n,r){const i=e._updateTags;let o,s=false,l=false;void 0!==r&&(o=r.onUpdate,ai(e,r.tag),s=r.skipTransforms||false,l=r.discrete||false),o&&e._deferred.push(o);const c=e._editorState;let a=e._pendingEditorState,u=false;(null===a||a._readOnly)&&(a=e._pendingEditorState=wi(a||c),u=true),a._flushSync=l;const f=qr,d=Gr,h=Hr,g=e._updating;qr=a,Gr=false,e._updating=true,Hr=e;const _=e._headless||null===e.getRootElement();Yi(null);try{u&&(_?null!==c._selection&&(a._selection=c._selection.clone()):a._selection=function(t,e){const n=t.getEditorState()._selection,r=ps(ss(t));return yr(n)||null==n?Fr(n,r,t,e):n.clone()}(e,r&&r.event||null));const i=e._compositionKey;n(),s=_i(e,s),function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(yr(r)){const t=r.anchor,e=r.focus;let i;if("text"===t.type&&(i=t.getNode(),i.selectionTransform(n,r)),"text"===e.type){const t=e.getNode();i!==t&&t.selectionTransform(n,r);}}}(a,e),0!==e._dirtyType&&(s?function(t,e){const n=e._dirtyLeaves,r=t._nodeMap;for(const t of n){const e=r.get(t);lr(e)&&e.isAttached()&&e.isSimpleText()&&!e.isUnmergeable()&&Ct$6(e);}}(a,e):function(t,e){const n=e._dirtyLeaves,r=e._dirtyElements,i=t._nodeMap,o=mo(),s=new Map;let l=n,c=l.size,a=r,u=a.size;for(;c>0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const r=i.get(t);lr(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&Ct$6(r),void 0!==r&&ci(r,o)&&li(e,r,s),n.add(t);}if(l=e._dirtyLeaves,c=l.size,c>0){Qr++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(r.set(n,l),!l)continue;const c=i.get(n);void 0!==c&&ci(c,o)&&li(e,c,s);}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,Qr++;}e._dirtyLeaves=n,e._dirtyElements=r;}(a,e),_i(e),function(t,e,n,r){const i=t._nodeMap,o=e._nodeMap,s=[];for(const[t]of r){const e=o.get(t);void 0!==e&&(e.isAttached()||(Si(e)&&Y$4(e,t,i,o,s,r),i.has(t)||r.delete(t),s.push(t)));}for(const t of s)o.delete(t);for(const t of n){const e=o.get(t);void 0===e||e.isAttached()||(i.has(t)||n.delete(t),o.delete(t));}}(c,a,e._dirtyLeaves,e._dirtyElements));i!==e._compositionKey&&(a._flushSync=!0);const o=a._selection;if(yr(o)){const e=a._nodeMap,n=o.anchor.key,r=o.focus.key;void 0!==e.get(n)&&void 0!==e.get(r)||t(19);}else xr(o)&&0===o._nodes.size&&(a._selection=null);}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void hi(e)}finally{qr=f,Gr=d,Hr=h,e._updating=g,Qr=0;}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(null!==r){if(r.dirty||!r.is(n))return true}else if(null!==n)return true;return false}(a,e);p?a._flushSync?(a._flushSync=false,hi(e)):u&&Qi(()=>{hi(e);}):(a._flushSync=false,u&&(i.clear(),e._deferred=[],e._pendingEditorState=null));}function yi(t,e,n){Hr===t&&void 0===n?e():pi(t,e,n);}class mi{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null;}withBefore(t){return new mi(this.element,t,this.after)}withAfter(t){return new mi(this.element,this.before,t)}withElement(t){return this.element===t?this:new mi(t,this.before,this.after)}insertChild(e){const n=this.before||this.getManagedLineBreak();return null!==n&&n.parentElement!==this.element&&t(222),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(223),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(224),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.after?this.after.nextSibling:this.element.firstChild;return t===this.before||t===this.getManagedLineBreak()?null:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(null===t)this.removeManagedLineBreak();else {const e="decorator"===t&&(d$1||c||l);this.insertManagedLineBreak(e);}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,n="IMG"===t.nodeName?t.nextSibling:null;n&&e.removeChild(n),e.removeChild(t),e.__lexicalLineBreak=void 0;}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===("IMG"===e.nodeName))return;this.removeManagedLineBreak();}const n=this.element,r=this.before,i=document.createElement("br");if(n.insertBefore(i,r),t){const t=document.createElement("img");t.setAttribute("data-lexical-linebreak","true"),t.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",t.alt="",n.insertBefore(t,i),n.__lexicalLineBreak=t;}else n.__lexicalLineBreak=i;}getFirstChildOffset(){let t=0;for(let e=this.after;null!==e;e=e.previousSibling)t++;return t}resolveChildIndex(t,e,n,r){if(n===this.element){const e=this.getFirstChildOffset();return [t,Math.min(e+t.getChildrenSize(),Math.max(e,r))]}const i=xi(e,n);i.push(r);const o=xi(e,this.element);let s=t.getIndexWithinParent();for(let t=0;t<o.length;t++){const e=i[t],n=o[t];if(void 0===e||e<n)break;if(e>n){s+=1;break}}return [t.getParentOrThrow(),s]}}function xi(e,n){const r=[];let i=n;for(;i!==e&&null!==i;i=i.parentNode){let t=0;for(let e=i.previousSibling;null!==e;e=e.previousSibling)t++;r.push(t);}return i!==e&&t(225),r.reverse()}class Ci extends Mn{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle="";}afterCloneFrom(t){super.afterCloneFrom(t),this.__key===t.__key&&(this.__first=t.__first,this.__last=t.__last,this.__size=t.__size),this.__indent=t.__indent,this.__format=t.__format,this.__style=t.__style,this.__dir=t.__dir,this.__textFormat=t.__textFormat,this.__textStyle=t.__textStyle;}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return J$5[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const t=ii()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];let e=this.getFirstChild();for(;null!==e;){if(lr(e)&&t.push(e),Si(e)){const n=e.getAllTextNodes();t.push(...n);}e=e.getNextSibling();}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Si(t);){const e=t.getFirstChild();if(null===e)break;t=e;}return t}getLastDescendant(){let t=this.getLastChild();for(;Si(t);){const e=t.getLastChild();if(null===e)break;t=e;}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>
vendor: 2,106 bytes, line 4593
4593=n){const t=e[n-1];return Si(t)&&t.getLastDescendant()||t||null}const r=e[t];return Si(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:xo(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:xo(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,r;if(t<e/2){for(n=this.getFirstChild(),r=0;null!==n&&r<=t;){if(r===t)return n;n=n.getNextSibling(),r++;}return null}for(n=this.getLastChild(),r=e-1;null!==n&&r>=t;){if(r===t)return n;n=n.getPreviousSibling(),r--;}return null}getTextContent(){let t="";const e=this.getChildren(),n=e.length;for(let r=0;r<n;r++){const i=e[r];t+=i.getTextContent(),Si(i)&&r!==n-1&&!i.isInline()&&(t+=D$4);}return t}getTextContentSize(){let t=0;const e=this.getChildren(),n=e.length;for(let r=0;r<n;r++){const i=e[r];t+=i.getTextContentSize(),Si(i)&&r!==n-1&&!i.isInline()&&(t+=2);}return t}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(t){if(""!==t){const e=W$7[t];return 0!==(this.getFormat()&e)}return false}hasTextFormat(t){const e=R$6[t];return 0!==(this.getTextFormat()&e)}getFormatFlags(t,e){return fo(this.getLatest().__textFormat,t,e)}getTextStyle(){return this.getLatest().__textStyle}select(t,e){ei();const n=Lr();let r=t,i=e;const o=this.getChildrenSize();if(!this.canBeEmpty())if(0===t&&0===e){const t=this.getFirstChild();if(lr(t)||Si(t))return t.select(0,0)}else if(!(void 0!==t&&t!==o||void 0!==e&&e!==o)){const t=this.getLastChild();if(lr(t)||Si(t))return t.select()} void 0===r&&(r=o),void 0===i&&(i=o);const s=this.__key;return yr(n)?(n.anchor.set(s,r,"element"),n.focus.set(s,i,"element"),n.dirty=true,n):Mr(s,r,s,i,"element","element")}selectStart(){const t=this.getFirstDescendant();return t?t.selectStart():this.select()}selectEnd(){const t=this.getLastDescendant();return t?t.selectEnd():this.select()}clear(){const t=this.getWritable();
4593return this.getChildren().forEach(t=>t.remove()),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t?W$7[t]:0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,r){On(this)&&t(324,this.__key,this.__type);const i=this.getChildrenSize(),o=this.getWritable();e+n<=i||t(226,String(e),String(n),String(i));const s=o.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=i-n+r.length;if(0!==e)if(e===i)u=this.getLastChild();else {const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling());}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let r=0;r<n;r++){null===e&&t(100);const n=e.getNextSibling(),r=e.__key;_o(e.getWritable()),c.push(r),e=n;}}let d=u;for(const e of r){null!==d&&e.is(d)&&(u=d=d.getPreviousSibling());const n=e.getWritable();n.__parent===s&&f--,_o(n);const r=e.__key;if(null===d)o.__first=r,n.__prev=null;else {const t=d.getWritable();t.__next=r,n.__prev=t.__key;}e.__key===s&&t(76),n.__parent=s,l.push(r),d=e;}if(e+n===i){if(null!==d){d.getWritable().__next=null,o.__last=d.__key;}}else if(null!==a){const t=a.getWritable();if(null!==d){const e=d.getWritable();t.__prev=d.__key,e.__next=a.__key;}else t.__prev=null;}if(o.__size=f,c.length){const t=Lr();if(yr(t)){const e=new Set(c),n=new Set(l),{anchor:r,focus:i}=t;vi(r,e,n)&&Rr(r,r.getNode(),this,u,a),vi(i,e,n)&&Rr(i,i.getNode(),this,u,a),0!==f||this.canBeEmpty()||as(this)||this.remove();}}return o}getDOMSlot(t){return new mi(t)}exportDOM(t){const{element:e}=super.exportDOM(t);if(Cs(e)){const t=this.getIndent();t>0&&(e.style.paddingInlineStart=40*t+"px");const n=this.getDirection();n&&(e.dir=n);}return {element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return true}collapseAtStart(t){return false}excludeFromCopy(t){return false}canReplaceWith(t){return true}canInsertAfter(t){return true}canBeEmpty(){return true}canInsertTextBefore(){return true}canInsertTextAfter(){return true}isInline(){return false}isShadowRoot(){return false}canMergeWith(t){return false}extractWithChild(t,e,n){return false}canMergeWhenEmpty(){return false}reconcileObservedMutation(t,e){const n=this.getDOMSlot(t);let r=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const i=e.getElementByKey(t.getKey());null!==i&&(null==r?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling);}}}function Si(t){return t instanceof Ci}function vi(t,e,n){let r=t.getNode();for(;r;){const t=r.__key;if(e.has(t)&&!n.has(t))return true;r=r.getParent();}return false}class ki extends Mn{decorate(t,e){return null}isIsolated(){return false}isInline(){return true}isKeyboardSelectable(){return true}}function Ti(t){return t instanceof ki}class Ni extends Ci{__cachedText;static getType(){return "root"}static clone(){return new Ni}constructor(){super("root"),this.__cachedText=null;}getTopLevelElementOrThrow(){t(51);}getTextContent(){const t=this.__cachedText;return !ti()&&0!==ii()._dirtyType||null===t?super.getTextContent():t}remove(){t(52);}replace(e){t(53);}insertBefore(e){t(54);}insertAfter(e){t(55);}updateDOM(t,e){return false}splice(e,n,r){for(const e of r)Si(e)||Ti(e)||t(282);return super.splice(e,n,r)}static importJSON(t){return No().updateFromJSON(t)}collapseAtStart(){return true}}function bi(t){return t instanceof Ni}function wi(t){return new Ai(new Map(t._nodeMap))}
4593function Ei(){return new Ai(new Map([["root",new Ni]]))}function Oi(e){const n=e.exportJSON(),r=e.constructor;if(n.type!==r.getType()&&t(130,r.name),Si(e)){const i=n.children;Array.isArray(i)||t(59,r.name);const o=e.getChildren();for(let t=0;t<o.length;t++){const e=Oi(o[t]);i.push(e);}}return n}function Mi(t){return t instanceof Ai}class Ai{_nodeMap;_selection;_flushSync;_readOnly;constructor(t,e){this._nodeMap=t,this._selection=e||null,this._flushSync=false,this._readOnly=false;}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(t,e){return di(e&&e.editor||null,this,t)}clone(t){const e=new Ai(this._nodeMap,void 0===t?this._selection:t);return e._readOnly=true,e}toJSON(){return di(null,this,()=>({root:Oi(No())}))}}class Pi extends Ci{static getType(){return "artificial"}createDOM(t){return document.createElement("div")}}class Di extends Ci{static getType(){return "paragraph"}static clone(t){return new Di(t.__key)}createDOM(t){const e=document.createElement("p"),n=$o(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n);}return e}updateDOM(t,e,n){return false}static importDOM(){return {p:t=>({conversion:Fi,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Cs(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);}return {element:e}}static importJSON(t){return Li().updateFromJSON(t)}exportJSON(){return {...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle()}}insertNewAfter(t,e){const n=Li();n.setTextFormat(t.format),n.setTextStyle(t.style);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||lr(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),true;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),true}return false}}function Fi(t){const e=Li();return t.style&&(e.setFormat(t.style.textAlign),Ps(t,e)),{node:e}}function Li(){return fs(new Di)}function Ii(t){return t instanceof Di}const Ki=0,zi=1,Ri=2,Bi=3,Wi=4;function Ji(t,e,n,r){const i=t._keyToDOMMap;i.clear(),t._editorState=Ei(),t._pendingEditorState=r,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,t._updateTags=new Set,t._updates=[],t._blockCursorElement=null;const o=t._observer;null!==o&&(o.disconnect(),t._observer=null),null!==e&&(e.textContent=""),null!==n&&(n.textContent="",i.set("root",n));}function ji(t){const e=new Set,n=new Set;let r=t;for(;r;){const{ownNodeConfig:t}=Is(r),i=r.transform;if(!n.has(i)){n.add(i);const t=r.transform();t&&e.add(t);}if(t){const n=t.$transform;n&&e.add(n),r=t.extends;}else {const t=Object.getPrototypeOf(r);r=t.prototype instanceof Mn&&t!==Mn?t:void 0;}}return e}function $i(t){const e=t||{},n=si(),r=e.theme||{},i=void 0===t?n:e.parentEditor||null,o=e.disableEvents||false,s=Ei(),l=e.namespace||(null!==i?i._config.namespace:Ao()),c=e.editorState,a=[Ni,Xn,Bn,ar,Di,Pi,...e.nodes||[]],{onError:u,html:f}=e,d=void 0===e.editable||e.editable;let h;if(void 0===t&&null!==n)h=n._nodes;else {h=new Map;for(let t=0;t<a.length;t++){let e=a[t],n=null,r=null;if("function"!=typeof e){const t=e;e=t.replace,n=t.with,r=t.withKlass||null;}Is(e);const i=e.getType(),o=ji(e);h.set(i,{exportDOM:f&&f.export?f.export.get(e):void 0,klass:e,replace:n,replaceWithKlass:r,sharedNodeState:at$3(a[t]),transforms:o});}}const g=new Ui(s,i,h,{disableEvents:o,namespace:l,theme:r},u||console.error,function(t,e){const n=new Map,r=new Set,i=t=>{Object.keys(t).forEach(e=>{let r=n.get(e);void 0===r&&(r=[],n.set(e,r)),r.push(t[e]);});};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||r.has(e))return;r.add(e);const n=e.call(t.klass);null!==n&&i(n);}),e&&i(e),n}(h,f?f.import:void 0),d,t);return void 0!==c&&(g._pendingEditorState=c,g._dirtyType=2),g}class Ui{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(t,e,n,r,i,o,s,l){this._createEditorArgs=l,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=false,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Ao(),this._onError=i,this._htmlConversions=o,this._editable=s,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null;}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){const e=this._listeners.update;return e.add(t),()=>{e.delete(t);}}
4593registerEditableListener(t){const e=this._listeners.editable;return e.add(t),()=>{e.delete(t);}}registerDecoratorListener(t){const e=this._listeners.decorator;return e.add(t),()=>{e.delete(t);}}registerTextContentListener(t){const e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t);}}registerRootListener(t){const e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t);}}registerCommand(e,n,r){ void 0===r&&t(35);const i=this._commands;i.has(e)||i.set(e,[new Set,new Set,new Set,new Set,new Set]);const o=i.get(e);void 0===o&&t(36,String(e));const s=o[r];return s.add(n),()=>{s.delete(n),o.every(t=>0===t.size)&&i.delete(e);}}registerMutationListener(t,e,n){const r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,i=this._listeners.mutation;let o=i.get(e);void 0===o&&(o=new Set,i.set(e,o)),o.add(r);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(e,r),()=>{o.delete(r),0===o.size&&i.delete(e);}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,r=Os(n).get(e.getType());if(!r)return;const i=new Map;for(const t of r.keys())i.set(t,"created");i.size>0&&t(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])});}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),r=[n],i=n.replaceWithKlass;if(null!=i){const t=this.registerNodeTransformToKlass(i,e);r.push(t);}return function(t,e){const n=Os(t.getEditorState()),r=[];for(const t of e){const e=n.get(t);e&&r.push(e);}if(0===r.length)return;t.update(()=>{for(const t of r)for(const e of t.keys()){const t=xo(e);t&&t.markDirty();}},null===t._pendingEditorState?{tag:Dn}:void 0);}(this,r.map(t=>t.klass.getType())),()=>{r.forEach(t=>t.transforms.delete(e));}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return Go(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=$o(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,Ji(this,e,t,r),null!==e&&(this._config.disableEvents||Nn$1(e),null!=n&&e.classList.remove(...n)),null!==t){const e=os(t),r=t.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,rt$3(this),this._updateTags.add(Dn),hi(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;en$1.set(t,n);const r=nn$1.get(n)??0;r<1&&n.addEventListener("selectionchange",Sn$1),nn$1.set(n,r+1),t.__lexicalEditor=e;const i=xn(t);for(let n=0;n<Ge$2.length;n++){const[r,o]=Ge$2[n],s="function"==typeof o?t=>{kn(t)||(vn(t),(e.isEditable()||"click"===r)&&o(t,e));}:t=>{if(kn(t))return;vn(t);const n=e.isEditable();switch(r){case "cut":return n&&Go(e,Be$2,t);case "copy":return Go(e,Re$2,t);case "paste":return n&&Go(e,fe$1,t);case "dragstart":return n&&Go(e,Ie$2,t);case "dragover":return n&&Go(e,Ke$2,t);case "dragend":return n&&Go(e,ze$2,t);case "focus":return n&&Go(e,Ve$1,t);case "blur":return n&&Go(e,Ye,t);case "drop":return n&&Go(e,Fe$2,t)}};t.addEventListener(r,s),i.push(()=>{t.removeEventListener(r,s);});}}(t,this),null!=n&&t.classList.add(...n);}else this._window=null,this._updateTags.add(Dn),hi(this);gi("root",this,false,t,e);}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let r=e;r._readOnly&&(r=wi(e),r._selection=e._selection?e._selection.clone():null),nt$4(this);const i=this._pendingEditorState,o=this._updateTags,s=void 0!==n?n.tag:null;null===i||i.isEmpty()||(null!=s&&o.add(s),hi(this)),this._pendingEditorState=r,this._dirtyType=2,this._dirtyElements.set("root",false),this._compositionKey=null,null!=s&&o.add(s),this._updating||hi(this);}parseEditorState(t,e){return function(t,e,n){const r=Ei(),i=qr,o=Gr,s=Hr,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,qr=r,Gr=false,Hr=e,Yi(null);try{const i=e._nodes;fi(t.root,i),n&&n(),r._readOnly=!0;}catch(t){t instanceof Error&&e._onError(t);}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,qr=i,Gr=o,Hr=s;}return r}("string"==typeof t?JSON.parse(t):t,this,e)}read(t){return hi(this),this.getEditorState().read(t,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):pi(t,e,n);}(this,t,e);}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),yi(this,()=>{const r=Lr(),i=No();null!==r?r.dirty||wo(r.clone()):0!==i.getChildrenSize()&&("rootStart"===e.defaultSelection?i.selectStart():i.selectEnd()),ns("focus"),rs(()=>{n.removeAttribute("autocapitalize"),t&&t();});}
4593),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"));}blur(){const t=this._rootElement;null!==t&&t.blur();const e=ps(this._window);null!==e&&e.removeAllRanges();}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,gi("editable",this,true,t));}toJSON(){return {editorState:this._editorState.toJSON()}}}Ui.version="0.38.2+prod.esm";let Vi=null;function Yi(t){Vi=t;}let qi=1;function Gi(e,n){const r=Xi(e,n);return void 0===r&&t(30,n),r}function Xi(t,e){return t._nodes.get(e)}const Qi="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t);};function Zi(t){return Ti(vo(t))}function to(t){const e=document.activeElement;if(!Cs(e))return false;const n=e.nodeName;return Ti(vo(t))&&("INPUT"===n||"TEXTAREA"===n||"true"===e.contentEditable&&null==io(e))}function eo(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!to(e)&&ro(e)===t}catch(t){return false}}function no(t){return t instanceof Ui}function ro(t){let e=t;for(;null!=e;){const t=io(e);if(no(t))return t;e=Zo(e);}return null}function io(t){return t?t.__lexicalEditor:null}function oo(t){return K$5.test(t)?"rtl":z$5.test(t)?"ltr":null}function so(t){return fr(t)||t.isToken()}function lo(t){return so(t)||t.isSegmented()}function co(t){return Ss(t)&&3===t.nodeType}function ao(t){return Ss(t)&&9===t.nodeType}function uo(t){let e=t;for(;null!=e;){if(co(e))return e;e=e.firstChild;}return null}function fo(t,e,n){const r=R$6[e];if(null!==n&&(t&r)===(n&r))return t;let i=t^r;return "subscript"===e?i&=-65:"superscript"===e?i&=-33:"lowercase"===e?(i&=-513,i&=-1025):"uppercase"===e?(i&=-257,i&=-1025):"capitalize"===e&&(i&=-257,i&=-513),i}function ho(t){return lr(t)||jn(t)||Ti(t)}function go(t,e){const n=function(){const t=Vi;return Vi=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);ei(),ni();const r=ii(),i=ri(),o=""+qi++;i._nodeMap.set(o,t),Si(t)?r._dirtyElements.set(o,true):r._dirtyLeaves.add(o),r._cloneNotNeeded.add(o),r._dirtyType=1,t.__key=o;}function _o(t){const e=t.getParent();if(null!==e){const n=t.getWritable(),r=e.getWritable(),i=t.getPreviousSibling(),o=t.getNextSibling(),s=null!==o?o.__key:null,l=null!==i?i.__key:null,c=null!==i?i.getWritable():null,a=null!==o?o.getWritable():null;null===i&&(r.__first=s),null===o&&(r.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),n.__prev=null,n.__next=null,n.__parent=null,r.__size--;}}function po(e){ni(),On(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),r=n.__parent,i=ri(),o=ii(),s=i._nodeMap,l=o._dirtyElements;null!==r&&function(t,e,n){let r=t;for(;null!==r;){if(n.has(r))return;const t=e.get(r);if(void 0===t)break;n.set(r,false),r=t.__parent;}}(r,s,l);const c=n.__key;o._dirtyType=1,Si(e)?l.set(c,true):o._dirtyLeaves.add(c);}function yo(t){ei();const e=ii(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=xo(n);null!==t&&t.getWritable();}if(null!==t){const e=xo(t);null!==e&&e.getWritable();}}}function mo(){if(ti())return null;return ii()._compositionKey}function xo(t,e){const n=(e||ri())._nodeMap.get(t);return void 0===n?null:n}function Co(t,e){const n=So(t,ii());return void 0!==n?xo(n,e):null}function So(t,e){return t[`__lexicalKey_${e._key}`]}function vo(t,e){let n=t;for(;null!=n;){const t=Co(n,e);if(null!==t)return t;n=Zo(n);}return null}function ko(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function To(t){return t.read(()=>No().getTextContent())}function No(){return bo(ri())}function bo(t){return t._nodeMap.get("root")}function wo(t){ei();const e=ri();null!==t&&(t.dirty=true,t.setCachedNodes(null)),e._selection=t;}function Eo(t){const e=ii(),n=function(t,e){let n=t;for(;null!=n;){const t=So(n,e);if(void 0!==t)return t;n=Zo(n);}return null}(t,e);if(null===n){return t===e.getRootElement()?xo("root"):null}return xo(n)}function Oo(t){return /[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function Mo(t){const e=[];let n=t;for(;null!==n;)e.push(n),n=n._parentEditor;return e}function Ao(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function Po(t){return co(t)?t.nodeValue:null}function Do(t,e,n){const r=ps(ss(e));if(null===r)return;const i=r.anchorNode;let{anchorOffset:o,focusOffset:s}=r;if(null!==i){let e=Po(i);const r=vo(i);if(null!==e&&lr(r)){if(e===P$3&&n){const t=n.length;e=n,o=t,s=t;}null!==e&&Fo(r,e,o,s,t);}}}function Fo(t,e,n,r,i){let o=t;if(o.isAttached()&&(i||!o.isDirty())){const s=o.isComposing();let a=e;(s||i)&&e[e.length-1]===P$3&&(a=e.slice(0,-1));const u=o.getTextContent();if(i||a!==u){if(""===a){if(yo(null),l||c||d$1)o.remove();else {const t=ii();setTimeout(()=>{t.update(()=>{o.isAttached()&&o.remove();});},20);}return}const e=o.getParent(),i=Ir(),u=o.getTextContentSize(),f=mo(),h=o.getKey();if(o.isToken()||null!==f&&h===f&&!s||yr(i)&&(null!==e&&!e.canInsertTextBefore()&&0===i.anchor.offset||i.anchor.key===t.__key&&0===i.anchor.offset&&!o.canInsertTextBefore()&&!s||i.focus.key===t.__key&&i.focus.offset===u&&!o.canInsertTextAfter()&&!s))return void o.markDirty();const g=Lr();if(!yr(g)||null===n||null===r)return void Lo(o,a,g);if(g.setTextNodeRange(o,n,o,r),o.isSegmented()){const t=sr(o.getTextContent());o.replace(t),o=t;}Lo(o,a,g);}}}function Lo(t,e,n){if(t.setTextContent(e),yr(n)){const e=t.getKey();for(const r of ["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===e&&(i.offset=nl(t,i.offset,"clamp"));}}}function Io(t,e,n){const r=e[n]||false;return "any"===r||r===t[n]}function Ko(t,e){return Io(t,e,"altKey")&&Io(t,e,"ctrlKey")&&Io(t,e,"shiftKey")&&Io(t,e,"metaKey")}function zo(t,e,n){return Ko(t,n)&&t.key.toLowerCase()===e.toLowerCase()}const Ro={ctrlKey:!i,metaKey:i},Bo={altKey:i,ctrlKey:!i};function Wo(t){return "Backspace"===t.key}function Jo(t){return zo(t,"a",Ro)}function jo(t){const e=No();if(yr(t)){const e=t.anchor,n=t.focus,r=e.getNode().getTopLevelElementOrThrow().getParentOrThrow();return e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),St$6(t),t}{const t=e.select(0,e.getChildrenSize());return wo(St$6(t)),t}}
4593function $o(t,e){ void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,r=n[e];if(void 0!==r)return r;const i=t[e];if("string"==typeof i){const t=h$1(i);return n[e]=t,t}return i}function Uo(e,n,r,i,o){if(0===r.size)return;const s=i.__type,l=i.__key,c=n.get(s);void 0===c&&t(33,s);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===o;(void 0===f||d)&&u.set(l,d?"updated":o);}function Yo(t,e,n){const r=t.getParent();let i=n,o=t;return null!==r&&(e&&0===n?(i=o.getIndexWithinParent(),o=r):e||n!==o.getChildrenSize()||(i=o.getIndexWithinParent()+1,o=r)),o.getChildAtIndex(e?i-1:i)}function qo(t,e){const n=t.offset;if("element"===t.type){return Yo(t.getNode(),e,n)}{const r=t.getNode();if(e&&0===n||!e&&n===r.getTextContentSize()){const t=e?r.getPreviousSibling():r.getNextSibling();return null===t?Yo(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function Ho(t){const e=ss(t).event,n=e&&e.inputType;return "insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Go(t,e,n){return function(t,e,n){const r=Mo(t);for(let i=4;i>=0;i--)for(let o=0;o<r.length;o++){const s=r[o],l=s._commands.get(e);if(void 0!==l){const e=l[i];if(void 0!==e){const r=Array.from(e),i=r.length;let o=false;if(yi(s,()=>{for(let e=0;e<i;e++)if(r[e](n,t))return void(o=true)}),o)return o}}}return false}(t,e,n)}function Xo(t){return !bi(t)&&!t.isLastChild()&&!t.isInline()}function Qo(e,n){const r=e._keyToDOMMap.get(n);return void 0===r&&t(75,n),r}function Zo(t){const e=t.assignedSlot||t.parentElement;return vs(e)?e.host:e}function ts(t){return ao(t)?t:Cs(t)?t.ownerDocument:null}function es(t){return ii()._updateTags.has(t)}function ns(t){ei();ii()._updateTags.add(t);}function rs(t){ei();ii()._deferred.push(t);}function is(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return true;n=n.getParent();}return false}function os(t){const e=ts(t);return e?e.defaultView:null}function ss(e){const n=e._window;return null===n&&t(78),n}function ls(t){return Si(t)&&t.isInline()||Ti(t)&&t.isInline()}function cs(t){let e=t.getParentOrThrow();for(;null!==e;){if(as(e))return e;e=e.getParentOrThrow();}return e}function as(t){return bi(t)||Si(t)&&t.isShadowRoot()}function us(t){const e=t.constructor.clone(t);return go(e,null),e.afterCloneFrom(t),e}function fs(e){const n=ii(),r=e.getType(),i=Xi(n,r);void 0===i&&t(200,e.constructor.name,r);const{replace:o,replaceWithKlass:s}=i;if(null!==o){const n=o(e),i=n.constructor;return null!==s?n instanceof s||t(201,s.name,s.getType(),i.name,i.getType(),e.constructor.name,r):n instanceof e.constructor&&i!==e.constructor||t(202,i.name,i.getType(),e.constructor.name,r),n.__key===e.__key&&t(203,e.constructor.name,r,i.name,i.getType()),n}return e}function ds(e,n){!bi(e.getParent())||Si(n)||Ti(n)||t(99);}function hs(e){const n=xo(e);return null===n&&t(63,e),n}function gs(t){return (Ti(t)||Si(t)&&!t.canBeEmpty())&&!t.isInline()}function _s(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null;const r=t.parentElement;null!==r&&r.removeChild(t);}function ps(t){return n?(t||window).getSelection():null}function ys(t){const e=os(t);return e?e.getSelection():null}function ms(e,n){let r=e.getChildAtIndex(n);null==r&&(r=e),as(e)&&t(102);const i=e=>{const n=e.getParentOrThrow(),o=as(n),s=e!==r||o?us(e):e;if(o)return Si(e)&&Si(s)||t(133),e.insertAfter(s),[e,s,s];{const[t,r,o]=i(n),l=e.getNextSiblings();return o.append(s,...l),[t,r,s]}},[o,s]=i(r);return [o,s]}function xs(t){return Cs(t)&&"A"===t.tagName}function Cs(t){return Ss(t)&&1===t.nodeType}function Ss(t){return "object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function vs(t){return Ss(t)&&11===t.nodeType}function ks(t){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return null!==t.nodeName.match(e)}function Ts(t){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return null!==t.nodeName.match(e)}function Ns(t){if(Ti(t)&&!t.isInline())return true;if(!Si(t)||as(t))return false;
4593const e=t.getFirstChild(),n=null===e||jn(e)||lr(e)||e.isInline();return !t.isInline()&&false!==t.canBeEmpty()&&n}function bs(){return ii()}const ws=new WeakMap,Es=new Map;function Os(e){if(!e._readOnly&&e.isEmpty())return Es;e._readOnly||t(192);let n=ws.get(e);return n||(n=function(t){const e=new Map;for(const[n,r]of t._nodeMap){const t=r.__type;let i=e.get(t);i||(i=new Map,e.set(t,i)),i.set(n,r);}return e}(e),ws.set(e,n)),n}function Ms(t){const e=t.constructor.clone(t);return e.afterCloneFrom(t),e}function As(t){return (e=Ms(t))[En]=true,e;var e;}function Ps(t,e){const n=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(n/40);e.setIndent(r);}function Ds(t){t.__lexicalUnmanaged=true;}function Fs(t){return true===t.__lexicalUnmanaged}function Ls(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==Mn[e]}function Is(e){const n=V$6 in e.prototype?e.prototype[V$6]():void 0,r=function(e){if(!(e===Mn||e.prototype instanceof Mn)){let n="<unknown>",r="<unknown>";try{n=e.getType();}catch(t){}try{Ui.version&&(r=JSON.parse(Ui.version));}catch(t){}t(290,e.name,n,r);}return e===ki||e===Ci||e===Mn}(e),i=!r&&Ls(e,"getType")?e.getType():void 0;let o,s=i;if(n)if(i)o=n[i];else for(const[t,e]of Object.entries(n))s=t,o=e;if(!r&&s&&(Ls(e,"getType")||(e.getType=()=>s),Ls(e,"clone")||(e.clone=t=>(Yi(t),new e)),Ls(e,"importJSON")||(e.importJSON=o&&o.$importJSON||(t=>(new e).updateFromJSON(t))),!Ls(e,"importDOM")&&o)){const{importDOM:t}=o;t&&(e.importDOM=()=>t);}return {ownNodeConfig:o,ownNodeType:s}}function Ks(t){const e=bs();ei();return new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)}const zs=(t,e)=>{let n=t;for(;null!=n&&!bi(n);){if(e(n))return n;n=n.getParent();}return null},Rs={next:"previous",previous:"next"};class Bs{origin;constructor(t){this.origin=t;}[Symbol.iterator](){return hl({hasNext:Hs,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return tl(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return tl(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,r="next"){const i=r===this.direction?n:Array.from(n).reverse();let o=this;const s=this.getParentAtCaret(),l=new Map;for(let t=o.getAdjacentCaret();null!==t&&l.size<e;t=t.getAdjacentCaret()){const e=t.origin.getWritable();l.set(e.getKey(),e);}for(const e of i){if(l.size>0){const n=o.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||o.origin.is(e));else {const t=e.getParent();t&&t.is(s)&&e.remove(),n.replace(e);}else null===n&&t(263,Array.from(l).join(" "));}else o.insert(e);o=tl(e,this.direction);}for(const t of l.values())t.remove();return this}}class Ws extends Bs{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:il(t,this.direction)}getParentCaret(t="root"){return tl($s(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=js(this.direction);return tl(this.getNodeAtCaret(),t)||il(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof Ws&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const Js={root:bi,shadowRoot:as};function js(t){return Rs[t]}function $s(t,e="root"){return Js[e](t)?null:t}class Us extends Bs{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:tl(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Si(this.origin)?il(this.origin,this.direction):null}getParentCaret(t="root"){return tl($s(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=js(this.direction);return tl(this.getNodeAtCaret(),t)||il(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Us&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return (t instanceof Us||t instanceof Vs)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Vs extends Bs{type="text";offset;constructor(t,e){super(t),this.offset=e;}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:el(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return tl($s(this.getParentAtCaret(),t),this.direction)}getFlipped(){return el(this.origin,js(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Vs&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return (t instanceof Us||t instanceof Vs)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return tl(this.origin,this.direction)}}function Ys(t){return t instanceof Vs}function Hs(t){return t instanceof Us}function Gs(t){return t instanceof Ws}const Xs={next:class extends Vs{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Vs{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Qs={next:class extends Us{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Us{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Zs={next:class extends Ws{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends Ws{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function tl(t,e){return t?new Qs[e](t):null}function el(t,e,n){return t?new Xs[e](t,nl(t,n)):null}function nl(t,n,r="error"){const i=t.getTextContentSize();let o="next"===n?i:"previous"===n?0:n;return (o<0||o>i)&&("clamp"!==r&&e(284,String(n),String(i),t.getKey()),o=o<0?0:i),o}function rl(t,e){return new cl(t,e)}function il(t,e){return Si(t)?new Zs[e](t):null}function ol(t){return t&&t.getChildCaret()||t}function sl(t){return t&&ol(t.getAdjacentCaret())}class ll{type="node-caret-range";direction;anchor;focus;constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n;}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new ll(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return Ys(e)?function(t,e){const{direction:n,origin:r}=t,i=nl(r,"focus"===e?js(n):n);return rl(t,i-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:r}=n;if(t.isSameNodeCaret(r))return [rl(t,r.offset-t.offset),null]}return [e,n]}
vendor: 4,756 bytes, line 4593
4593iterNodeCarets(t="root"){const e=Ys(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=Ys(n),i=e=>e.isSameNodeCaret(n)?null:sl(e)||e.getParentCaret(t);return hl({hasNext:t=>null!==t&&!(r&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:i(e),map:t=>t,step:i})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class cl{type="slice";caret;distance;constructor(t,e){this.caret=t,this.distance=e;}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n<e?[n,e]:[e,n]}getTextContent(){const[t,e]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(t,e)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){const{caret:{origin:t,direction:e}}=this,[n,r]=this.getSliceIndices(),i=t.getTextContent();return el(t.setTextContent(i.slice(0,n)+i.slice(r)),e,n)}}function ul(t){return dl(t,tl(No(),t.direction))}function fl(t){return dl(t,t)}function dl(e,n){return e.direction!==n.direction&&t(265),new ll(e,n,e.direction)}function hl(t){const{initial:e,hasNext:n,step:r,map:i}=t;let o=e;return {[Symbol.iterator](){return this},next(){if(!n(o))return {done:true,value:void 0};const t={done:false,value:i(o)};return o=r(o),t}}}function gl(e,n){const r=ml(e.origin,n.origin);switch(null===r&&t(275,e.origin.getKey(),n.origin.getKey()),r.type){case "same":{const t="text"===e.type,r="text"===n.type;return t&&r?function(t,e){return Math.sign(t-e)}(e.offset,n.offset):e.type===n.type?0:t?-1:r?1:"child"===e.type?-1:1}case "ancestor":return "child"===e.type?-1:1;case "descendant":return "child"===n.type?1:-1;case "branch":return _l(r)}}function _l(t){const{a:e,b:n}=t,r=e.__key,i=n.__key;let o=e,s=n;for(;o&&s;o=o.getNextSibling(),s=s.getNextSibling()){if(o.__key===i)return -1;if(s.__key===r)return 1}return null===o?1:-1}function pl(t,e){return e.is(t)}function yl(t){return Si(t)?[t.getLatest(),null]:[t.getParent(),t.getLatest()]}function ml(e,n){if(e.is(n))return {commonAncestor:e,type:"same"};const r=new Map;for(let[t,n]=yl(e);t;n=t,t=t.getParent())r.set(t,n);for(let[i,o]=yl(n);i;o=i,i=i.getParent()){const s=r.get(i);if(void 0!==s)return null===s?(pl(e,i)||t(276),{commonAncestor:i,type:"ancestor"}):null===o?(pl(n,i)||t(277),{commonAncestor:i,type:"descendant"}):((Si(s)||pl(e,s))&&(Si(o)||pl(n,o))&&i.is(s.getParent())&&i.is(o.getParent())||t(278),{a:s,b:o,commonAncestor:i,type:"branch"})}return null}function xl(e,n){const{type:r,key:i,offset:o}=e,s=hs(e.key);return "text"===r?(lr(s)||t(266,s.getType(),i),el(s,n,o)):(Si(s)||t(267,s.getType(),i),Pl(s,e.offset,n))}function Cl(e,n){const{origin:r,direction:i}=n,o="next"===i;Ys(n)?e.set(r.getKey(),n.offset,"text"):Hs(n)?lr(r)?e.set(r.getKey(),nl(r,i),"text"):e.set(r.getParentOrThrow().getKey(),r.getIndexWithinParent()+(o?1:0),"element"):(Gs(n)&&Si(r)||t(268),e.set(r.getKey(),o?0:r.getChildrenSize(),"element"));}function Sl(t){const e=Lr(),n=yr(e)?e:Ar();return vl(n,t),wo(n),n}function vl(t,e){Cl(t.anchor,e.anchor),Cl(t.focus,e.focus);}function kl(t){const{anchor:e,focus:n}=t,r=xl(e,"next"),i=xl(n,"next"),o=gl(r,i)<=0?"next":"previous";return dl(Ml(r,o),Ml(i,o))}function Tl(t){const{direction:e,origin:n}=t,r=tl(n,js(e)).getNodeAtCaret();return r?tl(r,e):il(n.getParentOrThrow(),e)}function Nl(t,e="root"){const n=[t];for(let r=Gs(t)?t.getParentCaret(e):t.getSiblingCaret();null!==r;r=r.getParentCaret(e))n.push(Tl(r));return n}function bl(t){return !!t&&t.origin.isAttached()}function wl(e,n="removeEmptySlices"){if(e.isCollapsed())return e;const r="root",i="next";let o=n;const s=Al(e,i),l=Nl(s.anchor,r),c=Nl(s.focus.getFlipped(),r),a=new Set,u=[];for(const t of s.iterNodeCarets(r))if(Gs(t))a.add(t.origin.getKey());else if(Hs(t)){const{origin:e}=t;Si(e)&&!a.has(e.getKey())||u.push(e);}for(const t of u)t.remove();for(const t of s.getTextSlices()){if(!t)continue;const{origin:e}=t.caret,n=e.getTextContentSize(),r=Tl(tl(e,i)),s=e.getMode();if(Math.abs(t.distance)===n&&"removeEmptySlices"===o||"token"===s&&0!==t.distance)r.remove();else if(0!==t.distance){o="removeEmptySlices";let e=t.removeTextSlice();const n=t.caret.origin;if("segmented"===s){const t=e.origin,n=sr(t.getTextContent()).setStyle(t.getStyle()).setFormat(t.getFormat());r.replaceOrInsert(n),e=el(n,i,e.offset);}n.is(l[0].origin)&&(l[0]=e),n.is(c[0].origin)&&(c[0]=e.getFlipped());}}let f,d;for(const t of l)if(bl(t)){f=El(t);break}for(const t of c)if(bl(t)){d=El(t);break}const h=function(t,e,n){if(!t||!e)return null;const r=t.getParentAtCaret(),i=e.getParentAtCaret();if(!r||!i)return null;const o=r.getParents().reverse();o.push(r);const s=i.getParents().reverse();s.push(i);const l=Math.min(o.length,s.length);let c;for(c=0;c<l&&o[c]===s[c];c++);const a=(t,e)=>{let n;for(let r=c;r<t.length;r++){const i=t[r];
4593if(as(i))return;!n&&e(i)&&(n=i);}return n},u=a(o,Ns),f=u&&a(s,t=>n.has(t.getKey())&&Ns(t));return u&&f?[u,f]:null}(f,d,a);if(h){const[t,e]=h;il(t,"previous").splice(0,e.getChildren()),e.remove();}const g=[f,d,...l,...c].find(bl);if(g){return fl(Ml(El(g),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)));}function El(t){const e=function(t){let e=t;for(;Gs(e);){const t=sl(e);if(!Gs(t))break;e=t;}return e}(t.getLatest()),{direction:n}=e;if(lr(e.origin))return Ys(e)?e:el(e.origin,n,n);const r=e.getAdjacentCaret();return Hs(r)&&lr(r.origin)?el(r.origin,n,js(n)):e}function Ol(t){return Ys(t)&&t.offset!==nl(t.origin,t.direction)}function Ml(t,e){return t.direction===e?t:t.getFlipped()}function Al(t,e){return t.direction===e?t:dl(Ml(t.focus,e),Ml(t.anchor,e))}function Pl(t,e,n){let r=il(t,"next");for(let t=0;t<e;t++){const t=r.getAdjacentCaret();if(null===t)break;r=t;}return Ml(r,n)}function Fl(e){const{origin:n,offset:r,direction:i}=e;if(r===nl(n,i))return e.getSiblingCaret();if(r===nl(n,js(i)))return Tl(e.getSiblingCaret());const[o]=n.splitText(r);return lr(o)||t(281),Ml(tl(o,"next"),i)}function Ll(t,e){return true}function Il(t,{$copyElementNode:e=us,$splitTextPointCaretNext:n=Fl,rootMode:r="shadowRoot",$shouldSplit:i=Ll}={}){if(Ys(t))return n(t);const o=t.getParentCaret(r);if(o){const{origin:n}=o;if(Gs(t)&&(!n.canBeEmpty()||!i(n,"first")))return Tl(o);const r=function(t){const e=[];for(let n=t.getAdjacentCaret();n;n=n.getAdjacentCaret())e.push(n.origin);return e}(t);(r.length>0||n.canBeEmpty()&&i(n,"last"))&&o.insert(e(n).splice(0,0,r));}return o}function Kl(t){return t}function zl(...t){return t}function Bl(t){return t}function Wl(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return {...t,...e};return t} 4594 4595/** 4596 * Copyright (c) Meta Platforms, Inc. and affiliates. 4597 * 4598 * This source code is licensed under the MIT license found in the 4599 * LICENSE file in the root directory of this source tree. 4600 * 4601 */ 4602 4603function K$4(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const P$2=new Map;function F$4(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim());}return t}function b$3(e){let t=P$2.get(e);return void 0===t&&(t=F$4(e),P$2.set(e,t)),t}function R$5(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function O$1(e){const n=bs().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function z$4(e){return O$1(bi(e)?e:e.getParentOrThrow())}function A$2(e){const t=z$4(e);return null!==t&&"rtl"===t.direction}function M$4(e,t,n="self"){const o=e.getStartEndPoints();if(t.isSelected(e)&&!lo(t)&&null!==o){const[l,r]=o,s=e.isBackward(),i=l.getNode(),c=r.getNode(),f=t.is(i),u=t.is(c);if(f||u){const[o,l]=Sr(e),r=i.is(c),f=t.is(s?c:i),u=t.is(s?i:c);let d,p=0;if(r)p=o>l?l:o,d=o>l?o:l;else if(f){p=s?l:o,d=void 0;}else if(u){p=0,d=s?o:l;}const h=t.__text.slice(p,d);h!==t.__text&&("clone"===n&&(t=As(t)),t.__text=h);}}return t}function _$2(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return Si(t)||K$4(177),e.offset===t.getChildrenSize()}function $$3(e){const t=e.getStyle(),n=F$4(t);P$2.set(t,n);}function D$3(t,n){(yr(t)?t.isCollapsed():lr(t)||Si(t))||K$4(280);const l=b$3(yr(t)?t.style:lr(t)?t.getStyle():t.getTextStyle()),r=Object.entries(n).reduce((e,[n,o])=>("function"==typeof o?e[n]=o(l[n],t):null===o?delete e[n]:e[n]=o,e),{...l}),s=R$5(r);yr(t)||lr(t)?t.setStyle(s):t.setTextStyle(s),P$2.set(s,r);}function U$5(e,t){if(yr(e)&&e.isCollapsed()){D$3(e,t);const n=e.anchor.getNode();Si(n)&&n.isEmpty()&&D$3(n,t);}j$3(e=>{D$3(e,t);});}function j$3(t){const n=Lr();if(!n)return;const o=new Map,l=e=>o.get(e.getKey())||[0,e.getTextContentSize()];if(yr(n))for(const e of kl(n).getTextSlices())e&&o.set(e.caret.origin.getKey(),e.getSliceIndices());const r=n.getNodes();for(const n of r){if(!lr(n)||!n.canHaveFormat())continue;const[o,r]=l(n);if(r!==o)if(lo(n)||0===o&&r===n.getTextContentSize())t(n);else {t(n.splitText(o,r)[0===o?0:1]);}}yr(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&H$2(n);}function H$2(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:l,type:r}=t;t.set(n.key,n.offset,n.type),n.set(o,l,r);}}function Q$4(e){const t=Y$3(e);return null!==t&&"vertical-rl"===t.writingMode}function Y$3(e){const t=e.anchor.getNode();return Si(t)?O$1(t):z$4(t)}function Z$3(e,t){let n=Q$4(e)?!t:t;te(e)&&(n=!n);
4603const l=xl(e.focus,n?"previous":"next");if(Ol(l))return false;for(const e of ul(l)){if(Gs(e))return !e.origin.isInline();if(!Si(e.origin)){if(Ti(e.origin))return true;break}}return false}function ee(e,t,n,o){e.modify(t?"extend":"move",n,o);}function te(e){const t=Y$3(e);return null!==t&&"rtl"===t.direction}function ne(e,t,n){const o=te(e);let l;l=Q$4(e)||o?!n:n,ee(e,t,l,"character");}function oe$1(e,t,n){const o=b$3(e.getStyle());return null!==o&&o[t]||n}function le$1(t,n,o=""){let l=null;const r=t.getNodes(),s=t.anchor,c=t.focus,f=t.isBackward(),u=f?c.offset:s.offset,g=f?c.getNode():s.getNode();if(yr(t)&&t.isCollapsed()&&""!==t.style){const e=b$3(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t<r.length;t++){const s=r[t];if((0===t||0!==u||!s.is(g))&&lr(s)){const e=oe$1(s,n,o);if(null===l)l=e;else if(l!==e){l="";break}}}return null===l?o:l} 4604 4605function deepMerge(target, source) { 4606 const result = { ...target, ...source }; 4607 for (const [ key, value ] of Object.entries(source)) { 4608 if (arePlainHashes(target[key], value)) { 4609 result[key] = deepMerge(target[key], value); 4610 } 4611 } 4612 4613 return result 4614} 4615 4616function arePlainHashes(...values) { 4617 return values.every(value => value && value.constructor == Object) 4618} 4619 4620class Configuration { 4621 #tree = {} 4622 4623 constructor(...configs) { 4624 this.merge(...configs); 4625 } 4626 4627 merge(...configs) { 4628 return this.#tree = configs.reduce(deepMerge, this.#tree) 4629 } 4630 4631 get(path) { 4632 const keys = path.split("."); 4633 return keys.reduce((node, key) => node[key], this.#tree) 4634 } 4635} 4636 4637function range(from, to) { 4638 return [ ...Array(1 + to - from).keys() ].map(i => i + from) 4639} 4640 4641const global$1 = new Configuration({ 4642 attachmentTagName: "action-text-attachment", 4643 attachmentContentTypeNamespace: "actiontext", 4644 authenticatedUploads: false, 4645 extensions: [] 4646}); 4647 4648const presets = new Configuration({ 4649 default: { 4650 attachments: true, 4651 markdown: true, 4652 multiLine: true, 4653 richText: true, 4654 toolbar: true, 4655 highlight: { 4656 buttons: { 4657 color: range(1, 9).map(n => `var(--highlight-${n})`), 4658 "background-color": range(1, 9).map(n => `var(--highlight-bg-${n})`), 4659 }, 4660 permit: { 4661 color: [], 4662 "background-color": [] 4663 } 4664 } 4665 } 4666}); 4667 4668var Lexxy = { 4669 global: global$1, 4670 presets, 4671 configure({ global: newGlobal, ...newPresets }) { 4672 if (newGlobal) { 4673 global$1.merge(newGlobal); 4674 } 4675 presets.merge(newPresets); 4676 } 4677}; 4678 4679const ALLOWED_HTML_TAGS = [ "a", "b", "blockquote", "br", "code", "div", "em", 4680 "figcaption", "figure", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "i", "img", "li", "mark", "ol", "p", "pre", "q", "s", "strong", "ul", "table", "tbody", "tr", "th", "td" ]; 4681 4682const ALLOWED_HTML_ATTRIBUTES = [ "alt", "caption", "class", "content", "content-type", "contenteditable", 4683 "data-direct-upload-id", "data-sgid", "filename", "filesize", "height", "href", "presentation", 4684 "previewable", "sgid", "src", "style", "title", "url", "width" ]; 4685 4686const ALLOWED_STYLE_PROPERTIES = [ "color", "background-color" ]; 4687 4688function styleFilterHook(_currentNode, hookEvent) { 4689 if (hookEvent.attrName === "style" && hookEvent.attrValue) { 4690 const styles = { ...b$3(hookEvent.attrValue) }; 4691 const sanitizedStyles = { }; 4692 4693 for (const property in styles) { 4694 if (ALLOWED_STYLE_PROPERTIES.includes(property)) { 4695 sanitizedStyles[property] = styles[property]; 4696 } 4697 } 4698 4699 if (Object.keys(sanitizedStyles).length) { 4700 hookEvent.attrValue = R$5(sanitizedStyles); 4701 } else { 4702 hookEvent.keepAttr = false; 4703 } 4704 } 4705} 4706 4707purify.addHook("uponSanitizeAttribute", styleFilterHook); 4708 4709purify.addHook("uponSanitizeElement", (node, data) => { 4710 if (data.tagName === "strong" || data.tagName === "em") { 4711 node.removeAttribute("class"); 4712 } 4713}); 4714 4715function buildConfig() { 4716 return { 4717 ALLOWED_TAGS: ALLOWED_HTML_TAGS.concat(Lexxy.global.get("attachmentTagName")), 4718 ALLOWED_ATTR: ALLOWED_HTML_ATTRIBUTES, 4719 ADD_URI_SAFE_ATTR: [ "caption", "filename" ], 4720 SAFE_FOR_XML: false // So that it does not strip attributes that contains serialized HTML (like content) 4721 } 4722} 4723 4724function getNonce() { 4725 const element = document.head.querySelector("meta[name=csp-nonce]"); 4726 return element?.content 4727} 4728 4729function handleRollingTabIndex(elements, event) { 4730 const previousActiveElement = document.activeElement; 4731 4732 if (elements.includes(previousActiveElement)) { 4733 const finder = new NextElementFinder(elements, event.key); 4734 4735 if (finder.selectNext(previousActiveElement)) { 4736 event.preventDefault(); 4737 } 4738 } 4739} 4740 4741class NextElementFinder { 4742 constructor(elements, key) { 4743 this.elements = elements; 4744 this.key = key; 4745 } 4746 4747 selectNext(fromElement) { 4748 const nextElement = this.#findNextElement(fromElement); 4749 4750 if (nextElement) { 4751 const inactiveElements = this.elements.filter(element => element !== nextElement); 4752 this.#unsetTabIndex(inactiveElements); 4753 this.#focusWithActiveTabIndex(nextElement); 4754 return true 4755 } 4756 4757 return false 4758 } 4759 4760 #findNextElement(fromElement) { 4761 switch (this.key) { 4762 case "ArrowRight": 4763 case "ArrowDown": 4764 return this.#findNextSibling(fromElement) 4765 4766 case "ArrowLeft": 4767 case "ArrowUp": 4768 return this.#findPreviousSibling(fromElement) 4769 4770 case "Home": 4771 return this.#findFirst() 4772 4773 case "End": 4774 return this.#findLast() 4775 } 4776 } 4777 4778 #findFirst(elements = this.elements) { 4779 return elements.find(isActiveAndVisible) 4780 } 4781 4782 #findLast(elements = this.elements) { 4783 return elements.findLast(isActiveAndVisible) 4784 } 4785 4786 #findNextSibling(element) { 4787 const afterElements = this.elements.slice(this.#indexOf(element) + 1); 4788 return this.#findFirst(afterElements) 4789 } 4790 4791 #findPreviousSibling(element) { 4792 const beforeElements = this.elements.slice(0, this.#indexOf(element)); 4793 return this.#findLast(beforeElements) 4794 } 4795 4796 #indexOf(element) { 4797 return this.elements.indexOf(element) 4798 } 4799 4800 #focusWithActiveTabIndex(element) { 4801 if (isActiveAndVisible(element)) { 4802 element.tabIndex = 0; 4803 element.focus(); 4804 } 4805 } 4806 4807 #unsetTabIndex(elements) {
4808 elements.forEach(element => element.tabIndex = -1); 4809 } 4810} 4811 4812function isActiveAndVisible(element) { 4813 return element && !element.disabled && element.checkVisibility() 4814} 4815 4816var ToolbarIcons = { 4817 "bold": 4818 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4819 <path fill-rule="evenodd" clip-rule="evenodd" d="M9.05273 1.88232C10.6866 1.88237 12.0033 2.20353 12.9529 2.89673L13.1272 3.0293C13.974 3.70864 14.4008 4.63245 14.4009 5.76562C14.4008 6.49354 14.2316 7.15281 13.8845 7.73145C13.6683 8.09188 13.3997 8.40162 13.0818 8.66016C13.5902 8.92606 14.0196 9.28599 14.3635 9.74121C14.8586 10.3834 15.0945 11.1743 15.0945 12.0879C15.0944 13.3698 14.5922 14.3931 13.5879 15.1106L13.5857 15.1128C12.5967 15.805 11.196 16.125 9.43799 16.125H3.10547V1.88232L9.05273 1.88232ZM6.36108 13.4084H9.28418C10.224 13.4084 10.8634 13.2491 11.2581 12.9851C11.6259 12.7389 11.8198 12.3768 11.8198 11.8367C11.8197 11.2968 11.6259 10.9351 11.2581 10.689C10.8634 10.425 10.2241 10.2649 9.28418 10.2649H6.36108V13.4084ZM6.36108 7.56812H8.78247C9.5163 7.56809 10.0547 7.45371 10.429 7.25757L10.5791 7.16895C10.9438 6.92178 11.1255 6.57934 11.1255 6.09302C11.1254 5.59017 10.9414 5.25227 10.5835 5.02002L10.5784 5.01636L10.5732 5.01343C10.1994 4.75387 9.61878 4.59818 8.78247 4.59814H6.36108V7.56812Z"/> 4820 </svg>`, 4821 4822 "italic": 4823 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4824 <path d="M14.1379 3.91187L14.1086 4.06421H11.4668L9.49805 13.9431H12.0981L11.7473 15.7852L11.7188 15.9375H4.16675L4.51758 14.0955L4.54614 13.9431H7.18799L9.17505 4.06421H6.55664L6.90747 2.22217L6.93677 2.06982H14.4888L14.1379 3.91187Z"/> 4825 </svg>`, 4826 4827 "strikethrough": 4828 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4829 <path d="M14.3723 11.8015C14.3771 11.8858 14.3811 11.9756 14.3811 12.0681C14.3811 12.811 14.1777 13.4959 13.7725 14.1174L13.7717 14.1189C13.3624 14.7329 12.7463 15.2162 11.9377 15.5742L11.9348 15.5757C11.1214 15.9223 10.1306 16.092 8.96997 16.092C7.9356 16.092 6.93308 15.9348 5.96338 15.6204L5.96045 15.6189C5.00593 15.292 4.24112 14.8699 3.67676 14.3459L3.57568 14.2522L3.63501 14.1277L4.45605 12.397L4.64282 12.5654C5.13492 13.0083 5.76733 13.3759 6.54492 13.6648C7.33475 13.9406 8.14322 14.0786 8.96997 14.0786C10.0731 14.0786 10.8638 13.8932 11.3708 13.5513C11.8757 13.1982 12.1172 12.7464 12.1172 12.1838C12.1172 12.0662 12.1049 11.9556 12.0828 11.8513L12.0344 11.625H14.3621L14.3723 11.8015Z"/> 4830 <path d="M9.2981 1.91602C10.111 1.91604 10.9109 2.02122 11.6975 2.23096C12.4855 2.44111 13.1683 2.74431 13.7417 3.14429L13.8655 3.23071L13.8083 3.36987L13.1726 4.91235L13.0869 5.1189L12.8987 4.99878C12.3487 4.64881 11.761 4.38633 11.1365 4.21143L11.1328 4.20996C10.585 4.04564 10.0484 3.95419 9.52295 3.93384L9.2981 3.92944C8.22329 3.92944 7.44693 4.12611 6.94043 4.49121C6.44619 4.85665 6.20874 5.31616 6.20874 5.88135L6.21533 6.03296C6.24495 6.37662 6.37751 6.65526 6.61011 6.87964L6.72144 6.97632C6.98746 7.19529 7.30625 7.37584 7.68018 7.51538L8.05151 7.63184C8.45325 7.75061 8.94669 7.87679 9.53247 8.01123L9.53467 8.01196C10.1213 8.15305 10.6426 8.29569 11.0991 8.4375H15C15.5178 8.4375 15.9375 8.85723 15.9375 9.375C15.9375 9.89277 15.5178 10.3125 15 10.3125H3C2.48223 10.3125 2.0625 9.89277 2.0625 9.375C2.0625 8.85723 2.48223 8.4375 3 8.4375H4.93726C4.83783 8.34526 4.74036 8.24896 4.64795 8.146L4.64502 8.14233C4.1721 7.58596 3.94482 6.85113 3.94482 5.95825C3.94483 5.20441 4.14059 4.51965 4.53369 3.90967L4.53516 3.90747C4.94397 3.29427 5.55262 2.81114 6.34863 2.45288C7.15081 2.0919 8.13683 1.91602 9.2981 1.91602Z"/> 4831 </svg>`, 4832 4833 "heading": 4834 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4835 <path d="M11.5 2C12.0523 2 12.5 2.44772 12.5 3V3.5C12.5 4.05228 12.0523 4.5 11.5 4.5H8V15C8 15.5523 7.55228 16 7 16H6.5C5.94772 16 5.5 15.5523 5.5 15V4.5H2C1.44772 4.5 1 4.05228 1 3.5V3C1 2.44772 1.44772 2 2 2H11.5ZM16 7C16.5523 7 17 7.44772 17 8V8.5C17 9.05228 16.5523 9.5 16 9.5H15V15C15 15.5523 14.5523 16 14 16H13.5C12.9477 16 12.5 15.5523 12.5 15V9.5H11.5C10.9477 9.5 10.5 9.05228 10.5 8.5V8C10.5 7.44772 10.9477 7 11.5 7H16Z"/> 4836 </svg>`, 4837 4838 "highlight": 4839 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4840 <path d="M16.4564 14.4272C17.1356 15.5592 16.3204 17.0002 15.0003 17.0004C13.68 17.0004 12.864 15.5593 13.5433 14.4272L15.0003 12.0004L16.4564 14.4272ZM5.1214 1.70746C5.51192 1.31693 6.14494 1.31693 6.53546 1.70746L9.7171 4.8891L13.2532 8.42426C14.2295 9.40056 14.2295 10.9841 13.2532 11.9604L9.7171 15.4955C8.74078 16.4718 7.15822 16.4718 6.18195 15.4955L2.64679 11.9604C1.67048 10.9841 1.67048 9.40057 2.64679 8.42426L6.18195 4.8891C6.30299 4.76805 6.43323 4.66177 6.57062 4.57074L5.1214 3.12152C4.73091 2.73104 4.73099 2.09799 5.1214 1.70746ZM8.30304 6.30316C8.10776 6.10815 7.79119 6.10799 7.59601 6.30316L4.06085 9.83929L3.9964 9.91742C3.88661 10.0838 3.88645 10.3019 3.9964 10.4682L4.02277 10.5004H11.8763C12.0312 10.3043 12.02 10.0205 11.8392 9.83929L8.30304 6.30316Z"/> 4841 </svg>`, 4842 4843 "link": 4844 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4845 <path d="M12.8885 7.23091L13.9479 6.17155C14.5337 5.58576 14.5337 4.63602 13.9479 4.05023C13.3621 3.46444 12.4124 3.46444 11.8266 4.05023L8.29235 7.58446C7.9263 7.95051 7.90312 8.52994 8.2233 8.92271L8.36141 9.07463C8.68158 9.4674 8.65841 10.0468 8.29235 10.4129C7.90183 10.8034 7.26866 10.8034 6.87814 10.4129C5.70657 9.24131 5.70657 7.34182 6.87814 6.17025L10.4124 2.63602C11.7792 1.26918 13.9953 1.26918 15.3621 2.63602C16.729 4.00285 16.729 6.21893 15.3621 7.58576L14.3028 8.64512C13.9122 9.03564 13.2791 9.03564 12.8885 8.64512C12.498 8.2546 12.498 7.62143 12.8885 7.23091Z"/> 4846 <path d="M5.11038 10.7664L4.04843 11.8284C3.46264 12.4142 3.46264 13.3639 4.04842 13.9497C4.63421 14.5355 5.58396 14.5355 6.16975 13.9497L9.70657 10.4129C10.0726 10.0468 10.0958 9.46741 9.77563 9.07464L9.63752 8.92272C9.31734 8.52995 9.34052 7.95052 9.70657 7.58446C10.0971 7.19394 10.7303 7.19394 11.1208 7.58446C12.2924 8.75604 12.2924 10.6555 11.12
484608 11.8271L7.58396 15.3639C6.21712 16.7308 4.00105 16.7308 2.63421 15.3639C1.26738 13.9971 1.26738 11.781 2.63421 10.4142L3.69617 9.35223C4.08669 8.96171 4.71986 8.96171 5.11038 9.35223C5.5009 9.74275 5.5009 10.3759 5.11038 10.7664Z"/> 4847 </svg>`, 4848 4849 "quote": 4850 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4851 <path d="M4.96387 4.23438C6.8769 4.23438 8.42767 5.78522 8.42773 7.69824C8.42773 8.32925 8.25769 8.92015 7.96289 9.42969L7.96387 9.43066L5.11816 14.3584C4.77659 14.95 4.02038 15.153 3.42871 14.8115C2.83701 14.4699 2.63397 13.7128 2.97559 13.1211L4.16113 11.0674C2.63532 10.7052 1.5 9.33485 1.5 7.69824C1.50006 5.78524 3.05086 4.2344 4.96387 4.23438ZM13.0361 4.23438C14.9491 4.23449 16.4999 5.7853 16.5 7.69824C16.5 8.32921 16.3299 8.92017 16.0352 9.42969L16.0361 9.43066L13.1904 14.3584C12.8488 14.9501 12.0917 15.1531 11.5 14.8115C10.9085 14.4698 10.7063 13.7127 11.0479 13.1211L12.2324 11.0674C10.7069 10.7049 9.57227 9.33461 9.57227 7.69824C9.57233 5.78522 11.1231 4.23438 13.0361 4.23438Z"/> 4852 </svg>`, 4853 4854 "code": 4855 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4856 <path d="M6.29289 3.79295C6.68342 3.40243 7.31643 3.40243 7.70696 3.79295C8.09748 4.18348 8.09748 4.81649 7.70696 5.20702L3.91399 8.99999L7.70696 12.793C8.09748 13.1835 8.09748 13.8165 7.70696 14.207C7.31643 14.5975 6.68342 14.5975 6.29289 14.207L1.79289 9.70702C1.40237 9.31649 1.40237 8.68348 1.79289 8.29295L6.29289 3.79295Z"/> 4857 <path d="M11.707 3.79295C11.3164 3.40243 10.6834 3.40243 10.2929 3.79295C9.90237 4.18348 9.90237 4.81649 10.2929 5.20702L14.0859 8.99999L10.2929 12.793C9.90237 13.1835 9.90237 13.8165 10.2929 14.207C10.6834 14.5975 11.3164 14.5975 11.707 14.207L16.207 9.70702C16.5975 9.31649 16.5975 8.68348 16.207 8.29295L11.707 3.79295Z"/> 4858 </svg>`, 4859 4860 "ul": 4861 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4862 <path d="M3 12.5C3.82843 12.5 4.5 13.1716 4.5 14C4.5 14.8284 3.82843 15.5 3 15.5C2.17157 15.5 1.5 14.8284 1.5 14C1.5 13.1716 2.17157 12.5 3 12.5ZM15.5 13C16.0523 13 16.5 13.4477 16.5 14C16.5 14.5523 16.0523 15 15.5 15H7C6.44772 15 6 14.5523 6 14C6 13.4477 6.44772 13 7 13H15.5ZM3 7.5C3.82843 7.5 4.5 8.17157 4.5 9C4.5 9.82843 3.82843 10.5 3 10.5C2.17157 10.5 1.5 9.82843 1.5 9C1.5 8.17157 2.17157 7.5 3 7.5ZM15.5 8C16.0523 8 16.5 8.44772 16.5 9C16.5 9.55228 16.0523 10 15.5 10H7C6.44772 10 6 9.55228 6 9C6 8.44772 6.44772 8 7 8H15.5ZM3 2.5C3.82843 2.5 4.5 3.17157 4.5 4C4.5 4.82843 3.82843 5.5 3 5.5C2.17157 5.5 1.5 4.82843 1.5 4C1.5 3.17157 2.17157 2.5 3 2.5ZM15.5 3C16.0523 3 16.5 3.44772 16.5 4C16.5 4.55228 16.0523 5 15.5 5H7C6.44772 5 6 4.55228 6 4C6 3.44772 6.44772 3 7 3H15.5Z"/> 4863 </svg>`, 4864 4865 "ol": 4866 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4867 <path d="M15.5 13C16.0523 13 16.5 13.4477 16.5 14C16.5 14.5523 16.0523 15 15.5 15H7C6.44772 15 6 14.5523 6 14C6 13.4477 6.44772 13 7 13H15.5ZM15.5 8C16.0523 8 16.5 8.44772 16.5 9C16.5 9.55228 16.0523 10 15.5 10H7C6.44772 10 6 9.55228 6 9C6 8.44772 6.44772 8 7 8H15.5ZM15.5 3C16.0523 3 16.5 3.44772 16.5 4C16.5 4.55228 16.0523 5 15.5 5H7C6.44772 5 6 4.55228 6 4C6 3.44772 6.44772 3 7 3H15.5Z"/> 4868 <path d="M2.98657 16.0967C2.68042 16.0967 2.41187 16.0465 2.18091 15.9463C1.95174 15.846 1.77002 15.7046 1.63574 15.522C1.50146 15.3376 1.42448 15.1227 1.40479 14.8774L1.4021 14.8452H2.34204L2.34741 14.8748C2.35815 14.9589 2.39038 15.035 2.44409 15.103C2.49959 15.1711 2.5721 15.2248 2.66162 15.2642C2.75293 15.3035 2.86035 15.3232 2.98389 15.3232C3.10563 15.3232 3.21037 15.3027 3.2981 15.2615C3.38761 15.2185 3.45654 15.1603 3.50488 15.0869C3.55322 15.0135 3.57739 14.9294 3.57739 14.8345V14.8291C3.57739 14.6715 3.51921 14.5516 3.40283 14.4692C3.28646 14.3869 3.12085 14.3457 2.90601 14.3457H2.48706V13.677H2.90063C3.02775 13.677 3.13607 13.6582 3.22559 13.6206C3.31689 13.583 3.38672 13.5302 3.43506 13.4622C3.48519 13.3941 3.51025 13.3153 3.51025 13.2258V13.2205C3.51025 13.1256 3.48877 13.0441 3.4458 12.9761C3.40462 12.9062 3.34375 12.8534 3.26318 12.8176C3.18441 12.78 3.08952 12.7612 2.97852 12.7612C2.86572 12.7612 2.76636 12.7809 2.68042 12.8203C2.59627 12.8579 2.52913 12.9125 2.479 12.9841C2.43066 13.054 2.40112 13.1363 2.39038 13.2312L2.3877 13.2581H1.49341L1.49609 13.2205C1.514 12.977 1.58561 12.7666 1.71094 12.5894C1.83805 12.4103 2.00903 12.2725 2.22388 12.1758C2.44051 12.0773 2.69206 12.0281 2.97852 12.0281C3.27393 12.0281 3.52995 12.0728 3.74658 12.1624C3.96322 12.2501 4.13062 12.3727 4.24878 12.5303C4.36694 12.6878 4.42603 12.8722 4.42603 13.0835V13.0889C4.42603 13.2518 4.38932 13.3941 4.31592 13.5159C4.2443 13.6358 4.14762 13.7343 4.02588 13.8113C3.90592 13.8883 3.77254 13.942 3.62573 13.9724V13.9912C3.91756 14.0199 4.14941 14.1121 4.32129 14.2678C4.49316 14.4236 4.5791 14.6295 4.5791 14.8855V14.8909C4.5791 15.1344 4.51375 15.3474 4.38306 15.53C4.25236 15.7109 4.06795 15.8505 3.82983 15.949C3.59172 16.0474 3.31063 16.0967 2.98657 16.0967Z"/> 4869 <path d="M1.54443 11V10.342L2.76099 9.20874C2.95076 9.03507 3.09757 8.89274 3.20142 8.78174C3.30705 8.66895 3.37956 8.57316 3.41895 8.49438C3.46012 8.41382 3.48071 8.33415 3.48071 8.25537V8.24463C3.48071 8.14795 3.46012 8.0638 3.41895 7.99219C3.37777 7.92057 3.31779 7.86507 3.23901 7.82568C3.16024 7.7863 3.06714 7.7666 2.95972 7.7666C2.84692 7.7666 2.74756 7.78988 2.66162 7.83643C2.57747 7.88298 2.51123 7.94743 2.46289 8.02979C2.41455 8.11035 2.39038 8.20345 2.39038 8.30908V8.33057L1.48804 8.32788V8.31177C1.48804 8.05396 1.5507 7.82837 1.67603 7.63501C1.80314 7.44165 1.97949 7.29126 2.20508 7.18384C2.43245 7.07463 2.69653 7.02002 2.99731 7.02002C3.28556 7.02002 3.53711 7.06836 3.75195 7.16504C3.96859 7.25993 4.13688 7.39331 4.25684 7.56519C4.37858 7.73706 4.43945 7.93758 4.43945 8.16675V8.18018C4.43945 8.3252 4.40902 8.46932 4.34814 8.61255C4.28727 8.75578 4.18701 8.90885 4.04736 9.07178C3.90771 9.23291 3.71883 9.41642 3.48071 9.62231L2.58374 10.4092L2.85498 9.98486V10.4092L2.58374 10.2319H4.49048V11H1.54443Z"/> 4870 <path d="M2.84155 6V3.01367H2.79053L1.85596 3.64478V2.79614L2.84155 2.12476H3.82715V6H2.84155Z"/> 4871 </svg>`, 4872 4873 "attachment": 4874 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4875 <path d="M13 13.5V6C13 4.067 11.433 2.5 9.5 2.5C7.567 2.5 6 4.067 6 6V13.5C6 14.6046 6.89543 15.5 8 15.5H8.23047C9.20759 15.5 10 14.7076 10 13.7305V7C10 6.72386 9.77614 6.5 9.5 6.5C9.22386 6.5 9 6.72386 9 7V12.5C9 13.0523 8.55228 13.5 8 13.5C7.44772 13.5 7 13.0523 7 12.5V7C7 5.61929 8.11929 4.5 9.5 4.5C10.8807 4.5 12 5.61929 12 7V13.7305C12 15.8122 10.3122 17.5 8.23047 17.5H8C5.79086 17.5 4 15.7091 4 13.5V6C4 2.96243 6.46243 0.5 9.5 0.5C12.5376 0.5 15 2.96243 15 6V13.5C15 14.0523 14.5523 14.5 14 14.5C13.4477 14.5 13 14.0523 13 13.5Z"/> 4876 </svg>`, 4877 4878 "table": 4879 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4880 <path d="M15 1C16.1046 1 17 1.89543 17 3V15C17 16.1046 16.1046 17 15 17H3C1.89543 17 1 16.1046 1 15V3C1 1.89543 1.89543 1 3 1H15ZM3 15H8V10H3V15ZM10 10V15H15V10H10ZM10 8H15V3H10V8ZM3 8H8V3H3V8Z"/> 4881 </svg>`, 4882 4883 "hr": 4884 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4885 <path d="M12.75 12C13.1642 12 13.5 12.3358 13.5 12.75V14.25C13.5 14.6642 13.1642 15 12.75 15H5.25C4.83579 15 4.5 14.6642 4.5 14.25V12.75C4.5 12.3358 4.83579 12 5.25 12H12.75ZM15.4863 8C16.0461 8 16.5 8.44771 16.5 9C16.5 9.55229 16.0461 10 15.4863 10H2.51367C1.95392 10 1.5 9.55229 1.5 9C1.5 8.44771 1.95392 8 2.51367 8H15.4863ZM12.75 3C13.1642 3 13.5 3.33579 13.5 3.75V5.25C13.5 5.66421 13.1642 6 12.75 6H5.25C4.83579 6 4.5 5.66421 4.5 5.25V3.75C4.5 3.33579 4.83579 3 5.25 3H12.75Z"/> 4886 </svg>`, 4887 4888 "undo": 4889 `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 4890 <path d="M8.36612 5.36612C8.85427 4.87796 9.64554 4.87796 10.1337 5.36612C10.6218 5.85428 10.6218 6.64557 10.1337 7.13369L7.26748 9.9999H15.2499C18.1494 9.99996 20.4999 12.3504 20.4999 15.2499
4890V19.2499C20.4999 19.9402 19.9402 20.4999 19.2499 20.4999C18.5596 20.4999 18 19.9402 17.9999 19.2499V15.2499C17.9999 13.7312 16.7686 12.5 15.2499 12.4999H7.26748L10.1337 15.3661C10.6218 15.8543 10.6218 16.6456 10.1337 17.1337C9.64557 17.6218 8.85428 17.6218 8.36612 17.1337L3.36612 12.1337C2.87796 11.6455 2.87796 10.8543 3.36612 10.3661L8.36612 5.36612Z"/> 4891 </svg>`, 4892 4893 "redo": 4894 `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 4895 <path d="M15.6338 5.1163C15.1456 4.62814 14.3543 4.62814 13.8662 5.1163C13.3781 5.60446 13.3781 6.39575 13.8662 6.88388L16.7324 9.75009H8.74997C5.85052 9.75014 3.49997 12.1006 3.49997 15.0001V19.0001C3.50002 19.6904 4.05969 20.25 4.74997 20.2501C5.4403 20.2501 5.99992 19.6904 5.99997 19.0001V15.0001C5.99997 13.4813 7.23123 12.2501 8.74997 12.2501H16.7324L13.8662 15.1163C13.3781 15.6045 13.3781 16.3958 13.8662 16.8839C14.3543 17.372 15.1456 17.3719 15.6338 16.8839L20.6338 11.8839C21.1219 11.3957 21.1219 10.6045 20.6338 10.1163L15.6338 5.1163Z" /> 4896 </svg>`, 4897 4898 "overflow": 4899 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 4900 <path d="M3 6.75C4.24264 6.75 5.25 7.75736 5.25 9C5.25 10.2426 4.24264 11.25 3 11.25C1.75736 11.25 0.75 10.2426 0.75 9C0.75 7.75736 1.75736 6.75 3 6.75ZM9 6.75C10.2426 6.75 11.25 7.75736 11.25 9C11.25 10.2426 10.2426 11.25 9 11.25C7.75736 11.25 6.75 10.2426 6.75 9C6.75 7.75736 7.75736 6.75 9 6.75ZM15 6.75C16.2426 6.75 17.25 7.75736 17.25 9C17.25 10.2426 16.2426 11.25 15 11.25C13.7574 11.25 12.75 10.2426 12.75 9C12.75 7.75736 13.7574 6.75 15 6.75Z"/> 4901 </svg>` 4902}; 4903 4904class LexicalToolbarElement extends HTMLElement { 4905 static observedAttributes = [ "connected" ] 4906 4907 constructor() { 4908 super(); 4909 this.internals = this.attachInternals(); 4910 this.internals.role = "toolbar"; 4911 4912 this.#createEditorPromise(); 4913 } 4914 4915 connectedCallback() { 4916 requestAnimationFrame(() => this.#refreshToolbarOverflow()); 4917 this.setAttribute("role", "toolbar"); 4918 this.#installResizeObserver(); 4919 } 4920 4921 disconnectedCallback() { 4922 this.#uninstallResizeObserver(); 4923 this.#unbindHotkeys(); 4924 this.#unbindFocusListeners(); 4925 } 4926 4927 attributeChangedCallback(name, oldValue, newValue) { 4928 if (name === "connected" && this.isConnected && oldValue != null && oldValue !== newValue) { 4929 requestAnimationFrame(() => this.#reconnect()); 4930 } 4931 } 4932 4933 setEditor(editorElement) { 4934 this.editorElement = editorElement; 4935 this.editor = editorElement.editor; 4936 this.selection = editorElement.selection; 4937 this.#bindButtons(); 4938 this.#bindHotkeys(); 4939 this.#resetTabIndexValues(); 4940 this.#setItemPositionValues(); 4941 this.#monitorSelectionChanges(); 4942 this.#monitorHistoryChanges(); 4943 this.#refreshToolbarOverflow(); 4944 this.#bindFocusListeners(); 4945 4946 this.resolveEditorPromise(editorElement); 4947 4948 this.toggleAttribute("connected", true); 4949 } 4950 4951 async getEditorElement() { 4952 return this.editorElement || await this.editorPromise 4953 } 4954 4955 #reconnect() { 4956 this.disconnectedCallback(); 4957 this.connectedCallback(); 4958 } 4959 4960 #createEditorPromise() { 4961 this.editorPromise = new Promise((resolve) => { 4962 this.resolveEditorPromise = resolve; 4963 }); 4964 } 4965 4966 #installResizeObserver() { 4967 this.resizeObserver = new ResizeObserver(() => this.#refreshToolbarOverflow()); 4968 this.resizeObserver.observe(this); 4969 } 4970 4971 #uninstallResizeObserver() { 4972 if (this.resizeObserver) { 4973 this.resizeObserver.disconnect(); 4974 this.resizeObserver = null; 4975 } 4976 } 4977 4978 #bindButtons() { 4979 this.addEventListener("click", this.#handleButtonClicked.bind(this)); 4980 } 4981 4982 #handleButtonClicked(event) { 4983 this.#handleTargetClicked(event, "[data-command]", this.#dispatchButtonCommand.bind(this)); 4984 } 4985 4986 #handleTargetClicked(event, selector, callback) { 4987 const button = event.target.closest(selector); 4988 if (button) { 4989 callback(event, button); 4990 } 4991 } 4992 4993 #dispatchButtonCommand(event, { dataset: { command, payload } }) { 4994 const isKeyboard = event instanceof PointerEvent && event.pointerId === -1; 4995 4996 this.editor.update(() => { 4997 this.editor.dispatchCommand(command, payload); 4998 }, { tag: isKeyboard ? zn : undefined }); 4999 } 5000 5001 #bindHotkeys() { 5002 this.editorElement.addEventListener("keydown", this.#handleHotkey); 5003 } 5004 5005 #unbindHotkeys() { 5006 this.editorElement?.removeEventListener("keydown", this.#handleHotkey); 5007 } 5008 5009 #handleHotkey = (event) => { 5010 const buttons = this.querySelectorAll("[data-hotkey]"); 5011 buttons.forEach((button) => { 5012 const hotkeys = button.dataset.hotkey.toLowerCase().split(/\s+/); 5013 if (hotkeys.includes(this.#keyCombinationFor(event))) { 5014 event.preventDefault(); 5015 event.stopPropagation(); 5016 button.click(); 5017 } 5018 }); 5019 } 5020 5021 #keyCombinationFor(event) { 5022 const pressedKey = event.key.toLowerCase(); 5023 const modifiers = [ 5024 event.ctrlKey ? "ctrl" : null, 5025 event.metaKey ? "cmd" : null, 5026 event.altKey ? "alt" : null, 5027 event.shiftKey ? "shift" : null,
5028 ].filter(Boolean); 5029 5030 return [ ...modifiers, pressedKey ].join("+") 5031 } 5032 5033 #bindFocusListeners() { 5034 this.editorElement.addEventListener("lexxy:focus", this.#handleEditorFocus); 5035 this.editorElement.addEventListener("lexxy:blur", this.#handleEditorBlur); 5036 this.addEventListener("keydown", this.#handleKeydown); 5037 } 5038 5039 #unbindFocusListeners() { 5040 this.editorElement.removeEventListener("lexxy:focus", this.#handleEditorFocus); 5041 this.editorElement.removeEventListener("lexxy:blur", this.#handleEditorBlur); 5042 this.removeEventListener("keydown", this.#handleKeydown); 5043 } 5044 5045 #handleEditorFocus = () => { 5046 this.#focusableItems[0].tabIndex = 0; 5047 } 5048 5049 #handleEditorBlur = () => { 5050 this.#resetTabIndexValues(); 5051 this.#closeDropdowns(); 5052 } 5053 5054 #handleKeydown = (event) => { 5055 handleRollingTabIndex(this.#focusableItems, event); 5056 } 5057 5058 #resetTabIndexValues() { 5059 this.#focusableItems.forEach((button) => { 5060 button.tabIndex = -1; 5061 }); 5062 } 5063 5064 #monitorSelectionChanges() { 5065 this.editor.registerUpdateListener(() => { 5066 this.editor.getEditorState().read(() => { 5067 this.#updateButtonStates(); 5068 this.#closeDropdowns(); 5069 }); 5070 }); 5071 } 5072 5073 #monitorHistoryChanges() { 5074 this.editor.registerUpdateListener(() => { 5075 this.#updateUndoRedoButtonStates(); 5076 }); 5077 } 5078 5079 #updateUndoRedoButtonStates() { 5080 this.editor.getEditorState().read(() => { 5081 const historyState = this.editorElement.historyState; 5082 if (historyState) { 5083 this.#setButtonDisabled("undo", historyState.undoStack.length === 0); 5084 this.#setButtonDisabled("redo", historyState.redoStack.length === 0); 5085 } 5086 }); 5087 } 5088 5089 #updateButtonStates() { 5090 const selection = Lr(); 5091 if (!yr(selection)) return 5092 5093 const anchorNode = selection.anchor.getNode(); 5094 if (!anchorNode.getParent()) { return } 5095 5096 const { isBold, isItalic, isStrikethrough, isHighlight, isInLink, isInQuote, isInHeading, 5097 isInCode, isInList, listType, isInTable } = this.selection.getFormat(); 5098 5099 this.#setButtonPressed("bold", isBold); 5100 this.#setButtonPressed("italic", isItalic); 5101 this.#setButtonPressed("strikethrough", isStrikethrough); 5102 this.#setButtonPressed("highlight", isHighlight); 5103 this.#setButtonPressed("link", isInLink); 5104 this.#setButtonPressed("quote", isInQuote); 5105 this.#setButtonPressed("heading", isInHeading); 5106 this.#setButtonPressed("code", isInCode); 5107 this.#setButtonPressed("unordered-list", isInList && listType === "bullet"); 5108 this.#setButtonPressed("ordered-list", isInList && listType === "number"); 5109 this.#setButtonPressed("table", isInTable); 5110 5111 this.#updateUndoRedoButtonStates(); 5112 } 5113 5114 #setButtonPressed(name, isPressed) { 5115 const button = this.querySelector(`[name="${name}"]`); 5116 if (button) { 5117 button.setAttribute("aria-pressed", isPressed.toString()); 5118 } 5119 } 5120 5121 #setButtonDisabled(name, isDisabled) { 5122 const button = this.querySelector(`[name="${name}"]`); 5123 if (button) { 5124 button.disabled = isDisabled; 5125 button.setAttribute("aria-disabled", isDisabled.toString()); 5126 } 5127 } 5128 5129 #toolbarIsOverflowing() { 5130 // Safari can report inconsistent clientWidth values on more than 100% window zoom level, 5131 // that was affecting the toolbar overflow calculation. We're adding +1 to get around this issue. 5132 return (this.scrollWidth - this.#overflow.clientWidth) > this.clientWidth + 1 5133 } 5134 5135 #refreshToolbarOverflow = () => { 5136 this.#resetToolbarOverflow(); 5137 this.#compactMenu(); 5138 5139 this.#overflow.style.display = this.#overflowMenu.children.length ? "block" : "none"; 5140 this.#overflow.setAttribute("nonce", getNonce()); 5141 5142 const isOverflowing = this.#overflowMenu.children.length > 0; 5143 this.toggleAttribute("overflowing", isOverflowing); 5144 this.#overflowMenu.toggleAttribute("disabled", !isOverflowing); 5145 } 5146 5147 #compactMenu() { 5148 const buttons = this.#buttons.reverse(); 5149 let movedToOverflow = false; 5150 5151 for (const button of buttons) { 5152 if (this.#toolbarIsOverflowing()) { 5153 this.#overflowMenu.prepend(button); 5154 movedToOverflow = true; 5155 } else { 5156 if (movedToOverflow) this.#overflowMenu.prepend(button); 5157 break 5158 } 5159 } 5160 } 5161 5162 #resetToolbarOverflow() { 5163 const items = Array.from(this.#overflowMenu.children); 5164 items.sort((a, b) => this.#itemPosition(b) - this.#itemPosition(a)); 5165
5166 items.forEach((item) => { 5167 const nextItem = this.querySelector(`[data-position="${this.#itemPosition(item) + 1}"]`) ?? this.#overflow; 5168 this.insertBefore(item, nextItem); 5169 }); 5170 } 5171 5172 #itemPosition(item) { 5173 return parseInt(item.dataset.position ?? "999") 5174 } 5175 5176 #setItemPositionValues() { 5177 this.#toolbarItems.forEach((item, index) => { 5178 if (item.dataset.position === undefined) { 5179 item.dataset.position = index; 5180 } 5181 }); 5182 } 5183 5184 #closeDropdowns() { 5185 this.#dropdowns.forEach((details) => { 5186 details.open = false; 5187 }); 5188 } 5189 5190 get #dropdowns() { 5191 return this.querySelectorAll("details") 5192 } 5193 5194 get #overflow() { 5195 return this.querySelector(".lexxy-editor__toolbar-overflow") 5196 } 5197 5198 get #overflowMenu() { 5199 return this.querySelector(".lexxy-editor__toolbar-overflow-menu") 5200 } 5201 5202 get #buttons() { 5203 return Array.from(this.querySelectorAll(":scope > button")) 5204 } 5205 5206 get #focusableItems() { 5207 return Array.from(this.querySelectorAll(":scope button, :scope > details > summary")) 5208 } 5209 5210 get #toolbarItems() { 5211 return Array.from(this.querySelectorAll(":scope > *:not(.lexxy-editor__toolbar-overflow)")) 5212 } 5213 5214 static get defaultTemplate() { 5215 return ` 5216 <button class="lexxy-editor__toolbar-button" type="button" name="bold" data-command="bold" title="Bold"> 5217 ${ToolbarIcons.bold} 5218 </button> 5219 5220 <button class="lexxy-editor__toolbar-button" type="button" name="italic" data-command="italic" title="Italic"> 5221 ${ToolbarIcons.italic} 5222 </button> 5223 5224 <button class="lexxy-editor__toolbar-button lexxy-editor__toolbar-group-end" type="button" name="strikethrough" data-command="strikethrough" title="Strikethrough"> 5225 ${ToolbarIcons.strikethrough} 5226 </button> 5227 5228 <button class="lexxy-editor__toolbar-button" type="button" name="heading" data-command="rotateHeadingFormat" title="Heading"> 5229 ${ToolbarIcons.heading} 5230 </button> 5231 5232 <details class="lexxy-editor__toolbar-dropdown" name="lexxy-dropdown"> 5233 <summary class="lexxy-editor__toolbar-button" name="highlight" title="Color highlight"> 5234 ${ToolbarIcons.highlight} 5235 </summary> 5236 <lexxy-highlight-dropdown class="lexxy-editor__toolbar-dropdown-content"> 5237 <div class="lexxy-highlight-colors"></div> 5238 <button data-command="removeHighlight" class="lexxy-editor__toolbar-button lexxy-editor__toolbar-dropdown-reset">Remove all coloring</button> 5239 </lexxy-highlight-dropdown> 5240 </details> 5241 5242 <details class="lexxy-editor__toolbar-dropdown" name="lexxy-dropdown"> 5243 <summary class="lexxy-editor__toolbar-button" name="link" title="Link" data-hotkey="cmd+k ctrl+k"> 5244 ${ToolbarIcons.link} 5245 </summary> 5246 <lexxy-link-dropdown class="lexxy-editor__toolbar-dropdown-content"> 5247 <form method="dialog"> 5248 <input type="url" placeholder="Enter a URLâ¦" class="input"> 5249 <div class="lexxy-editor__toolbar-dropdown-actions"> 5250 <button type="submit" class="lexxy-editor__toolbar-button" value="link">Link</button> 5251 <button type="button" class="lexxy-editor__toolbar-button" value="unlink">Unlink</button> 5252 </div> 5253 </form> 5254 </lexxy-link-dropdown> 5255 </details> 5256 5257 <button class="lexxy-editor__toolbar-button" type="button" name="quote" data-command="insertQuoteBlock" title="Quote"> 5258 ${ToolbarIcons.quote} 5259 </button> 5260 5261 <button class="lexxy-editor__toolbar-button lexxy-editor__toolbar-group-end" type="button" name="code" data-command="insertCodeBlock" title="Code"> 5262 ${ToolbarIcons.code} 5263 </button> 5264 5265 <button class="lexxy-editor__toolbar-button" type="button" name="unordered-list" data-command="insertUnorderedList" title="Bullet list"> 5266 ${ToolbarIcons.ul} 5267 </button> 5268 5269 <button class="lexxy-editor__toolbar-button lexxy-editor__toolbar-group-end" type="button" name="ordered-list" data-command="insertOrderedList" title="Numbered list"> 5270 ${ToolbarIcons.ol} 5271 </button> 5272 5273 <button class="lexxy-editor__toolbar-button" type="button" name="upload" data-command="uploadAttachments" title="Upload file"> 5274 ${ToolbarIcons.attachment} 5275 </button> 5276 5277 <button class="lexxy-editor__toolbar-button" type="button" name="table" data-command="insertTable" title="Insert a table"> 5278 ${ToolbarIcons.table} 5279 </button> 5280 5281 <button class="lexxy-editor__toolbar-button" type="button" name="divider" data-command="insertHorizontalDivider" title="Insert a divider"> 5282 ${ToolbarIcons.hr} 5283 </button> 5284 5285 <div class="lexxy-editor__toolbar-spacer" role="separator"></div> 5286 5287 <button class="lexxy-editor__toolbar-button" type="button" name="undo" data-command="und
5287o" title="Undo"> 5288 ${ToolbarIcons.undo} 5289 </button> 5290 5291 <button class="lexxy-editor__toolbar-button" type="button" name="redo" data-command="redo" title="Redo"> 5292 ${ToolbarIcons.redo} 5293 </button> 5294 5295 <details class="lexxy-editor__toolbar-dropdown lexxy-editor__toolbar-overflow" name="lexxy-dropdown"> 5296 <summary class="lexxy-editor__toolbar-button" aria-label="Show more toolbar buttons">${ToolbarIcons.overflow}</summary> 5297 <div class="lexxy-editor__toolbar-dropdown-content lexxy-editor__toolbar-overflow-menu" aria-label="More toolbar buttons"></div> 5298 </details> 5299 ` 5300 } 5301} 5302 5303/** 5304 * Copyright (c) Meta Platforms, Inc. and affiliates. 5305 * 5306 * This source code is licensed under the MIT license found in the 5307 * LICENSE file in the root directory of this source tree. 5308 * 5309 */ 5310 5311function R$4(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const T$2="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,B$3=T$2&&"documentMode"in document?document.documentMode:null;!(!T$2||!("InputEvent"in window)||B$3)&&"getTargetRanges"in new window.InputEvent("input");function F$3(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function U$4(...t){return ()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0;}}function lt$4(t,...e){const n=F$3(...e);n.length>0&&t.classList.add(...n);}function ut$3(t,...e){const n=F$3(...e);n.length>0&&t.classList.remove(...n);}function ft$2(t){return t?t.getAdjacentCaret():null}function wt$5(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent();}return null}function xt$5(t){const e=zs(t,t=>Si(t)&&!t.isInline());return Si(e)||R$4(4,t.__key),e}function At$5(t){const o=Lr()||Ir();let r;if(yr(o))r=xl(o.focus,"next");else {if(null!=o){const t=o.getNodes(),e=t[t.length-1];e&&(r=tl(e,"next"));}r=r||il(No(),"previous").getFlipped().insert(Li());}const i=Ct$5(t,r),u=sl(i),s=Gs(u)?El(u):i;return Sl(fl(s)),t.getLatest()}function Ct$5(t,e,n){let o=Ml(e,"next");for(let t=o;t;t=Il(t,n))o=t;return Ys(o)&&R$4(283),o.insert(t.isInline()?Li().append(t):t),Ml(tl(t.getLatest(),"next"),e.direction)}function bt$6(t,e){const n=e();return t.replace(n),n.append(t),n}function Lt$4(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function Nt$5(t,e){il(t,"next").insert(e);}function Bt$3(t,e){return _t$4(t,e,null)}function _t$4(t,e,n){let r=false;for(const i of Kt$3(t))e(i)?null!==n&&n(i):(r=true,Si(i)&&_t$4(i,e,n||(t=>i.insertAfter(t))),i.remove());return r}function kt$6(t,e){const n=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(e(t))n.push(t);else if(Si(t))for(const e of Kt$3(t))r.push(e);return n}function $t$3(t){return Ot$4(il(t,"next"))}function Kt$3(t){return Ot$4(il(t,"previous"))}function Ot$4(t){return hl({hasNext:Hs,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})} 5312 5313/** 5314 * Copyright (c) Meta Platforms, Inc. and affiliates. 5315 * 5316 * This source code is licensed under the MIT license found in the 5317 * LICENSE file in the root directory of this source tree. 5318 * 5319 */ 5320 5321const T$1=Symbol.for("preact-signals");function B$2(){if(Z$2>1)return void Z$2--;let t,e=false;for(;void 0!==V$5;){let n=V$5;for(V$5=void 0,J$4++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Y$2(n))try{n.c();}catch(n){e||(t=n,e=true);}n=i;}}if(J$4=0,Z$2--,e)throw t}function F$2(t){if(Z$2>0)return t();Z$2++;try{return t()}finally{B$2();}}let G$3,V$5;function W$6(t){const e=G$3;G$3=void 0;try{return t()}finally{G$3=e;}}let Z$2=0,J$4=0,H$1=0;function q$4(t){if(void 0===G$3)return;let e=t.n;return void 0===e||e.t!==G$3?(e={i:0,S:t,p:G$3.s,n:void 0,t:G$3,e:void 0,x:void 0,r:e},void 0!==G$3.s&&(G$3.s.n=e),G$3.s=e,t.n=e,32&G$3.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=G$3.s,e.n=void 0,G$3.s.n=e,G$3.s=e),e):void 0}function Q$3(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name;}function X$3(t,e){return new Q$3(t,e)}function Y$2(t){for(let e=t.s;void 0!==e;
5321e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function tt$3(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function et$3(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t;}t.s=e;}function nt$3(t,e){Q$3.call(this,void 0),this.x=t,this.s=void 0,this.g=H$1-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name;}function ot$4(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Z$2++;const n=G$3;G$3=void 0;try{e();}catch(e){throw t.f&=-2,t.f|=8,st$3(t),e}finally{G$3=n,B$2();}}}function st$3(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ot$4(t);}function rt$2(t){if(G$3!==this)throw new Error("Out-of-order effect");et$3(this),G$3=t,this.f&=-2,8&this.f&&st$3(this),B$2();}function ct$4(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name;}function dt$3(t,e){const n=new ct$4(t,e);try{n.c();}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function at$2(t,e={}){const n={};for(const i in t){const o=e[i],s=X$3(void 0===o?t[i]:o);n[i]=s;}return n}Q$3.prototype.brand=T$1,Q$3.prototype.h=function(){return true},Q$3.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:W$6(()=>{var t;null==(t=this.W)||t.call(this);}));},Q$3.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&W$6(()=>{var t;null==(t=this.Z)||t.call(this);}));}},Q$3.prototype.subscribe=function(t){return dt$3(()=>{const e=this.value,n=G$3;G$3=void 0;try{t(e);}finally{G$3=n;}},{name:"sub"})},Q$3.prototype.valueOf=function(){return this.value},Q$3.prototype.toString=function(){return this.value+""},Q$3.prototype.toJSON=function(){return this.value},Q$3.prototype.peek=function(){const t=G$3;G$3=void 0;try{return this.value}finally{G$3=t;}},Object.defineProperty(Q$3.prototype,"value",{get(){const t=q$4(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(J$4>100)throw new Error("Cycle detected");this.v=t,this.i++,H$1++,Z$2++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N();}finally{B$2();}}}}),nt$3.prototype=new Q$3,nt$3.prototype.h=function(){if(this.f&=-3,1&this.f)return false;if(32==(36&this.f))return true;if(this.f&=-5,this.g===H$1)return true;if(this.g=H$1,this.f|=1,this.i>0&&!Y$2(this))return this.f&=-2,true;const t=G$3;try{tt$3(this),G$3=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++);}catch(t){this.v=t,this.f|=16,this.i++;}return G$3=t,et$3(this),this.f&=-2,true},nt$3.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t);}Q$3.prototype.S.call(this,t);},nt$3.prototype.U=function(t){if(void 0!==this.t&&(Q$3.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t);}},nt$3.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N();}}
5321,Object.defineProperty(nt$3.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=q$4(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),ct$4.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t);}finally{t();}},ct$4.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ot$4(this),tt$3(this),Z$2++;const t=G$3;return G$3=this,rt$2.bind(this,t)},ct$4.prototype.N=function(){2&this.f||(this.f|=2,this.o=V$5,V$5=this);},ct$4.prototype.d=function(){this.f|=8,1&this.f||st$3(this);},ct$4.prototype.dispose=function(){this.d();};function pt$3(t){return ("function"==typeof t.nodes?t.nodes():t.nodes)||[]}function xt$4(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function yt$3(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=yt$3(n[t],i[t]);return t}return e}const St$5=0,Et$4=1,bt$5=2,wt$4=3,Nt$4=4,Ot$3=5,Rt$2=6,Mt$3=7;function Ct$4(t){return t.id===St$5}function Dt$3(t){return t.id===bt$5}function _t$3(t){return function(t){return t.id===Et$4}(t)||xt$4(305,String(t.id),String(Et$4)),Object.assign(t,{id:bt$5})}const It$3=new Set;let jt$3 = class jt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:St$5};}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):Wl;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Dt$3(e)||xt$4(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:wt$4,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:Nt$4,initResult:e,registerState:n})}(o,s,i);}build(t){const e=this.state;let n;e.id!==Nt$4&&xt$4(307,String(e.id),String(Ot$3)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:Ot$3,output:e,registerState:n})}(e,n,i);}register(t,e){this._signal=e;const n=this.state;n.id!==Ot$3&&xt$4(308,String(n.id),String(Ot$3));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Rt$2})}(n),()=>{const t=this.state;t.id!==Mt$3&&xt$4(309,String(n.id),String(Mt$3)),this.state=function(t){return Object.assign(t,{id:Ot$3})}(t),i&&i();}}afterRegistration(t){const e=this.state;let n;return e.id!==Rt$2&&xt$4(310,String(e.id),String(Rt$2)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Mt$3})}(e),n}getSignal(){return void 0===this._signal&&xt$4(311),this._signal}getInitResult(){ void 0===this.extension.init&&xt$4(312,this.extension.name);const t=this.state;return function(t){return t.id>=Nt$4}(t)||xt$4(313,String(t.id),String(Nt$4)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=wt$4}(t)||xt$4(314,String(t.id),String(wt$4)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&xt$4(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&xt$4(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Mt$3}(t)||xt$4(316,String(t.id),String(Mt$3)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||It$3}getPeerNameSet(){let t=this._peerNameSet;
5321return t||(t=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;((function(t){return t.id>=Ot$3}))(t)||xt$4(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output};}return this._dependency}};const At$4={tag:Dn};function Pt$4(){const t=No();t.isEmpty()&&t.append(Li());}const Kt$2=Kl({config:Bl({setOptions:At$4,updateOptions:At$4}),init:({$initialEditorState:t=Pt$4})=>({$initialEditorState:t,initialized:false}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=true;const{$initialEditorState:i}=o;if(Mi(i))t.setEditorState(i,n);else if("function"==typeof i)t.update(()=>{i(t);},e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n);}}return ()=>{}},name:"@lexical/extension/InitialState",nodes:[Ni,Xn,Bn,ar,Di]}),kt$5=Symbol.for("@lexical/extension/LexicalBuilder");function $t$2(...t){return Bt$2.fromExtensions(t).buildEditor()}function zt$2(){}function Ut$2(t){throw t}function Lt$3(t){return Array.isArray(t)?t:[t]}const Tt$4="0.38.2+prod.esm";let Bt$2 = class Bt{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=Tt$4,this.roots=t;for(const e of t)this.addExtension(e);}static fromExtensions(t){const e=[Lt$3(Kt$2)];for(const n of t)e.push(Lt$3(n));return new Bt(e)}static maybeFromEditor(t){const e=t[kt$5];return e&&(e.PACKAGE_VERSION!==Tt$4&&xt$4(292,e.PACKAGE_VERSION,Tt$4),e instanceof Bt||xt$4(293)),e}static fromEditor(t){const e=Bt.maybeFromEditor(t);return void 0===e&&xt$4(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign($i({...n,...e?{onError:t=>{e(t,i);}}:{}}),{[kt$5]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=zt$2;function e(){try{t();}finally{t=zt$2;}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});
5321return t=U$4(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&xt$4(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]));}addExtension(t){ void 0!==this._sortedExtensionReps&&xt$4(296);const e=Lt$3(t),[n]=e;"string"!=typeof n.name&&xt$4(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&xt$4(298,n.name),!i){i=new jt$3(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&xt$4(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&xt$4(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=Lt$3(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e);}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[]);}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(Dt$3(o))return;const s=n.extension.name;var r;Ct$4(o)||xt$4(300,s,i||"[unknown]"),Ct$4(r=o)||xt$4(304,String(r.id),String(St$5)),o=Object.assign(r,{id:Et$4}),n.state=o;const c=this.outgoingConfigEdges.get(s);if(c)for(const t of c.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s);}o=_t$3(o),n.state=o,t.push(n);};for(const t of this.extensionNameMap.values())Ct$4(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t);}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&xt$4(301,t.name);for(const t of e)n.configs.add(t);}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),n=new AbortController,i=[()=>n.abort()],o=n.signal;for(const n of e){const e=n.register(t,o);e&&i.push(e);}for(const n of e){const e=n.afterRegistration(t);e&&i.push(e);}return U$4(...i)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of pt$3(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&xt$4(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c);}e.add(t);}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import);}r.theme&&yt$3(s,r.theme);}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,d=i.size>0;(c||d)&&(t.html={},c&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=Ut$2),t}};function Gt$1(t,e){const n=Bt$2.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0} 5322 5323/** 5324 * Copyright (c) Meta Platforms, Inc. and affiliates. 5325 * 5326 * This source code is licensed under the MIT license found in the 5327 * LICENSE file in the root directory of this source tree. 5328 * 5329 */ 5330 5331function K$3(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function W$5(t){let e=1,n=t.getParent();for(;null!=n;){if(ot$3(n)){const t=n.getParent();if(dt$2(t)){e++,n=t.getParent();continue}K$3(40);}return e}return e}function J$3(t){let e=t.getParent();dt$2(e)||K$3(40);let n=e;for(;null!==n;)n=n.getParent(),dt$2(n)&&(e=n);return e}function U$3(t){let e=[];const n=t.getChildren().filter(ot$3);for(let t=0;t<n.length;t++){const r=n[t],i=r.getFirstChild();dt$2(i)?e=e.concat(U$3(i)):e.push(r);}return e}function $$2(t){return ot$3(t)&&dt$2(t.getFirstChild())}function V$4(t){return st$2().append(t)}function z$3(t,e){return ot$3(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function j$2(t){const e=Lr();if(null!==e){let n=e.getNodes();if(yr(e)){const r=e.getStartEndPoints();null===r&&K$3(143);const[i]=r,s=i.getNode(),o=s.getParent();if(as(s)){const t=s.getFirstChild();if(t)n=t.selectStart().getNodes();else {const t=Li();s.append(t),n=t.select().getNodes();}}else if(z$3(s,n)){const e=ht$3(t);if(as(o)){s.replace(e);const t=st$2();Si(s)&&(t.setFormat(s.getFormatType()),t.setIndent(s.getIndent())),e.append(t);}else if(ot$3(s)){const t=s.getParentOrThrow();q$3(e,t.getChildren()),t.replace(e);}return}}const r=new Set;for(let e=0;e<n.length;e++){const i=n[e];if(Si(i)&&i.isEmpty()&&!ot$3(i)&&!r.has(i.getKey())){H(i,t);continue}let s=ho(i)?i.getParent():ot$3(i)&&i.isEmpty()?i:null;for(;null!=s;){const e=s.getKey();if(dt$2(s)){if(!r.has(e)){const n=ht$3(t);q$3(n,s.getChildren()),s.replace(n),r.add(e);}break}{const n=s.getParent();if(as(n)&&!r.has(e)){r.add(e),H(s,t);break}s=n;}}}}}function q$3(t,e){t.splice(t.getChildrenSize(),0,e);}function H(t,e){if(dt$2(t))return t;const n=t.getPreviousSibling(),r=t.getNextSibling(),i=st$2();let s;if(q$3(i,t.getChildren()),dt$2(n)&&e===n.getListType())n.append(i),dt$2(r)&&e===r.getListType()&&(q$3(n,r.getChildren()),r.remove()),s=n;else if(dt$2(r)&&e===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else {const n=ht$3(e);n.append(i),t.replace(n),s=n;}return i.setFormat(t.getFormatType()),i.setIndent(t.getIndent()),t.remove(),s}function X$2(t,e){const n=t.getLastChild(),r=e.getFirstChild();n&&r&&$$2(n)&&$$2(r)&&(X$2(n.getFirstChild(),r.getFirstChild()),r.remove());const i=e.getChildren();i.length>0&&t.append(...i),e.remove();}function G$2(){const t=Lr();if(yr(t)){const e=new Set,r=t.getNodes(),i=t.anchor.getNode();if(z$3(i,r))e.add(J$3(i));else for(let t=0;t<r.length;t++){const i=r[t];if(ho(i)){const t=wt$5(i,nt$2);null!=t&&e.add(J$3(t));}}for(const n of e){let e=n;const r=U$3(n);for(const n of r){const r=Li().setTextStyle(t.style).setTextFormat(t.format);
5331q$3(r,n.getChildren()),e.insertAfter(r),e=r,n.__key===t.anchor.key&&Cl(t.anchor,El(il(r,"next"))),n.__key===t.focus.key&&Cl(t.focus,El(il(r,"next"))),n.remove();}n.remove();}}}function Q$2(t){const e="check"!==t.getListType();let n=t.getStart();for(const r of t.getChildren())ot$3(r)&&(r.getValue()!==n&&r.setValue(n),e&&null!=r.getLatest().__checked&&r.setChecked(void 0),dt$2(r.getFirstChild())||n++);}function Y$1(t){const e=new Set;if($$2(t)||e.has(t.getKey()))return;const n=t.getParent(),r=t.getNextSibling(),i=t.getPreviousSibling();if($$2(r)&&$$2(i)){const n=i.getFirstChild();if(dt$2(n)){n.append(t);const i=r.getFirstChild();if(dt$2(i)){q$3(n,i.getChildren()),r.remove(),e.add(r.getKey());}}}else if($$2(r)){const e=r.getFirstChild();if(dt$2(e)){const n=e.getFirstChild();null!==n&&n.insertBefore(t);}}else if($$2(i)){const e=i.getFirstChild();dt$2(e)&&e.append(t);}else if(dt$2(n)){const e=st$2().setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle()),s=ht$3(n.getListType()).setTextFormat(n.getTextFormat()).setTextStyle(n.getTextStyle());e.append(s),s.append(t),i?i.insertAfter(e):r?r.insertBefore(e):n.append(e);}}function Z$1(t){if($$2(t))return;const e=t.getParent(),n=e?e.getParent():void 0;if(dt$2(n?n.getParent():void 0)&&ot$3(n)&&dt$2(e)){const r=e?e.getFirstChild():void 0,i=e?e.getLastChild():void 0;if(t.is(r))n.insertBefore(t),e.isEmpty()&&n.remove();else if(t.is(i))n.insertAfter(t),e.isEmpty()&&n.remove();else {const r=e.getListType(),i=st$2(),s=ht$3(r);
5331i.append(s),t.getPreviousSiblings().forEach(t=>s.append(t));const o=st$2(),l=ht$3(r);o.append(l),q$3(l,t.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(t);}}}function tt$2(){const t=Lr();if(!yr(t)||!t.isCollapsed())return false;const e=t.anchor.getNode();if(!ot$3(e)||0!==e.getChildrenSize())return false;const n=J$3(e),r=e.getParent();dt$2(r)||K$3(40);const i=r.getParent();let s;if(as(i))s=Li(),n.insertAfter(s);else {if(!ot$3(i))return false;s=st$2(),i.insertAfter(s);}s.setTextStyle(t.style).setTextFormat(t.format).select();const o=e.getNextSiblings();if(o.length>0){const t=ht$3(r.getListType());if(ot$3(s)){const e=st$2();e.append(t),s.insertAfter(e);}else s.insertAfter(t);t.append(...o);}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!ot$3(t)&&!dt$2(t))break;e=t;}e.remove();}(e),true}function et$2(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}let nt$2 = class nt extends Ci{__value;__checked;$config(){return this.config("listitem",{$transform:t=>{if(null==t.__checked)return;const e=t.getParent();dt$2(e)&&"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0);},extends:Ci,importDOM:wn$1({li:()=>({conversion:rt$1,priority:0})})})}constructor(t=1,e=void 0,n){super(n),this.__value=void 0===t?1:t,this.__checked=e;}afterCloneFrom(t){super.afterCloneFrom(t),this.__value=t.__value,this.__checked=t.__checked;}createDOM(t){const e=document.createElement("li");return this.updateListItemDOM(null,e,t),e}updateListItemDOM(t,e,n){!function(t,e,n){const r=e.getParent();!dt$2(r)||"check"!==r.getListType()||dt$2(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),n&&e.__checked===n.__checked||t.setAttribute("aria-checked",e.getChecked()?"true":"false"));}(e,this,t),e.value=this.__value,function(t,e,n){const s=[],o=[],l=e.list,c=l?l.listitem:void 0;let a;l&&l.nested&&(a=l.nested.listitem);void 0!==c&&s.push(...et$2(c));if(l){const t=n.getParent(),e=dt$2(t)&&"check"===t.getListType(),r=n.getChecked();e&&!r||o.push(l.listitemUnchecked),e&&r||o.push(l.listitemChecked),e&&s.push(r?l.listitemChecked:l.listitemUnchecked);}if(void 0!==a){const t=et$2(a);n.getChildren().some(t=>dt$2(t))?s.push(...t):o.push(...t);}o.length>0&&ut$3(t,...o);s.length>0&<$4(t,...s);}(e,n.theme,this);const s=t?t.__style:"",o=this.__style;s!==o&&(""===o?e.removeAttribute("style"):e.style.cssText=o),function(t,e,n){const r=b$3(e.__textStyle);for(const e in r)t.style.setProperty(`--listitem-marker-${e}`,r[e]);if(n)for(const e in b$3(n.__textStyle))e in r||t.style.removeProperty(`--listitem-marker-${e}`);}(e,this,t);}updateDOM(t,e,n){const r=e;return this.updateListItemDOM(t,r,n),false}updateFromJSON(t){return super.updateFromJSON(t).setValue(t.value).setChecked(t.checked)}exportDOM(t){const e=this.createDOM(t._config),n=this.getFormatType();n&&(e.style.textAlign=n);const r=this.getDirection();return r&&(e.dir=r),{element:e}}exportJSON(){return {...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...t){for(let e=0;e<t.length;e++){const n=t[e];if(Si(n)&&this.canMergeWith(n)){const t=n.getChildren();this.append(...t),n.remove();}else super.append(n);}return this}replace(t,e){if(ot$3(t))return super.replace(t);this.setIndent(0);const n=this.getParentOrThrow();if(!dt$2(n))return t;if(n.__first===this.getKey())n.insertBefore(t);else if(n.__last===this.getKey())n.insertAfter(t);else {const e=ht$3(n.getListType());let r=this.getNextSibling();for(;r;){const t=r;r=r.getNextSibling(),e.append(t);}n.insertAfter(t),t.insertAfter(e);}
5331return e&&(Si(t)||K$3(139),this.getChildren().forEach(e=>{t.append(e);})),this.remove(),0===n.getChildrenSize()&&n.remove(),t}insertAfter(t,e=true){const n=this.getParentOrThrow();if(dt$2(n)||K$3(39),ot$3(t))return super.insertAfter(t,e);const r=this.getNextSiblings();if(n.insertAfter(t,e),0!==r.length){const i=ht$3(n.getListType());r.forEach(t=>i.append(t)),t.insertAfter(i,e);}return t}remove(t){const e=this.getPreviousSibling(),n=this.getNextSibling();super.remove(t),e&&n&&$$2(e)&&$$2(n)&&(X$2(e.getFirstChild(),n.getFirstChild()),n.remove());}insertNewAfter(t,e=true){const n=st$2().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(n,e),n}collapseAtStart(t){const e=Li();this.getChildren().forEach(t=>e.append(t));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=ot$3(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else {n.insertBefore(e),n.remove();const r=t.anchor,i=t.focus,s=e.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(s,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element");}else n.insertBefore(e),this.remove();return true}getValue(){return this.getLatest().__value}setValue(t){const e=this.getWritable();return e.__value=t,e}getChecked(){const t=this.getLatest();let e;const n=this.getParent();return dt$2(n)&&(e=n.getListType()),"check"===e?Boolean(t.__checked):void 0}setChecked(t){const e=this.getWritable();return e.__checked=t,e}toggleChecked(){const t=this.getWritable();return t.setChecked(!t.__checked)}getIndent(){const t=this.getParent();if(null===t||!this.isAttached())return this.getLatest().__indent;let e=t.getParentOrThrow(),n=0;for(;ot$3(e);)e=e.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(t){"number"!=typeof t&&K$3(117),(t=Math.floor(t))>=0||K$3(199);let e=this.getIndent();for(;e!==t;)e<t?(Y$1(this),e++):(Z$1(this),e--);return this}canInsertAfter(t){return ot$3(t)}canReplaceWith(t){return ot$3(t)}canMergeWith(t){return ot$3(t)||Ii(t)}extractWithChild(t,e){if(!yr(e))return false;const n=e.anchor.getNode(),r=e.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return true}createParentElementNode(){return ht$3("bullet")}canMergeWhenEmpty(){return true}};function rt$1(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return it$3(e);if(t.classList.contains("joplin-checkbox"))for(const e of t.children)if(e.classList.contains("checkbox-wrapper")&&e.children.length>0&&"INPUT"===e.children[0].tagName)return it$3(e.children[0]);const e=t.getAttribute("aria-checked");return {node:st$2("true"===e||"false"!==e&&void 0)}}function it$3(t){if(!("checkbox"===t.getAttribute("type")))return {node:null};return {node:st$2(t.hasAttribute("checked"))}}function st$2(t){return fs(new nt$2(void 0,t))}function ot$3(t){return t instanceof nt$2}let lt$3 = class lt extends Ci{__tag;__start;__listType;$config(){return this.config("list",{$transform:t=>{!function(t){const e=t.getNextSibling();dt$2(e)&&t.getListType()===e.getListType()&&X$2(t,e);}(t),Q$2(t);},extends:Ci,importDOM:wn$1({ol:()=>({conversion:gt$3,priority:0}),ul:()=>({conversion:gt$3,priority:0})})})}constructor(t="number",e=1,n){super(n);const r=ut$2[t]||t;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=e;}afterCloneFrom(t){super.afterCloneFrom(t),this.__listType=t.__listType,this.__tag=t.__tag,this.__start=t.__start;}getTag(){return this.getLatest().__tag}setListType(t){const e=this.getWritable();return e.__listType=t,e.__tag="number"===t?"ol":"ul",e}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(t){const e=this.getWritable();return e.__start=t,e}createDOM(t,e){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,ct$3(r,t.theme,this),r}updateDOM(t,e,n){return t.__tag!==this.__tag||t.__listType!==this.__listType||(ct$3(e,n.theme,this),false)}updateFromJSON(t){return super.updateFromJSON(t).setListType(t.listType).setStart(t.start)}exportDOM(t){const e=this.createDOM(t._config,t);return Cs(e)&&(1!==this.__start&&e.setAttribute("start",String(this.__start)),"check"===this.__listType&&e.setAttribute("__lexicalListType","check")),{element:e}}exportJSON(){return {...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return false}canIndent(){return false}splice(t,e,n){let r=n;for(let t=0;t<n.length;t++){const e=n[t];ot$3(e)||(r===n&&(r=[...n]),r[t]=st$2().append(!Si(e)||dt$2(e)||e.isInline()?e:sr(e.getTextContent())));}return super.splice(t,e,r)}extractWithChild(t){return ot$3(t)}};function ct$3(t,e,n){const s=[],o=[],l=e.list;if(void 0!==l){const t=l[`${n.__tag}Depth`]||[],e=W$5(n)-1,r=e%t.length,i=t[r],c=l[n.__tag];let a;const g=l.nested,u=l.checklist;if(void 0!==g&&g.list&&(a=g.list),void 0!==c&&s.push(c),void 0!==u&&"check"===n.__listType&&s.push(u),void 0!==i){s.push(...et$2(i));for(let e=0;e<t.length;e++)e!==r&&o.push(n.__tag+e);}if(void 0!==a){const t=et$2(a);e>1?s.push(...t):o.push(...t);}}o.length>0&&ut$3(t,...o),s.length>0&<$4(t,...s);}function at$1(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(ot$3(r)){e.push(r);const t=r.getChildren();t.length>1&&t.forEach(t=>{dt$2(t)&&e.push(V$4(t));});}else e.push(V$4(r));}return e}function gt$3(t){const e=t.nodeName.toLowerCase();let n=null;if("ol"===e){n=ht$3("number",t.start);}else "ul"===e&&(n=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list")||"1"===t.getAttribute("data-is-checklist"))return true;for(const e of t.childNodes)if(Cs(e)&&e.hasAttribute("aria-checked"))return true;return false}(t)?ht$3("check"):ht$3("bullet"));return {after:at$1,node:n}}
5331const ut$2={ol:"number",ul:"bullet"};function ht$3(t="number",e=1){return fs(new lt$3(t,e))}function dt$2(t){return t instanceof lt$3}const vt$3=re$1("UPDATE_LIST_START_COMMAND"),St$4=re$1("INSERT_UNORDERED_LIST_COMMAND"),xt$3=re$1("INSERT_ORDERED_LIST_COMMAND"),kt$4=re$1("REMOVE_LIST_COMMAND");function bt$4(t){return U$4(t.registerCommand(xt$3,()=>(j$2("number"),true),zi),t.registerCommand(vt$3,t=>{const{listNodeKey:e,newStart:n}=t,r=xo(e);return !!dt$2(r)&&("number"===r.getListType()&&(r.setStart(n),Q$2(r)),true)},zi),t.registerCommand(St$4,()=>(j$2("bullet"),true),zi),t.registerCommand(kt$4,()=>(G$2(),true),zi),t.registerCommand(ae$1,()=>tt$2(),zi),t.registerNodeTransform(nt$2,t=>{const e=t.getFirstChild();if(e){if(lr(e)){const n=e.getStyle(),r=e.getFormat();t.getTextStyle()!==n&&t.setTextStyle(n),t.getTextFormat()!==r&&t.setTextFormat(r);}}else {const e=Lr();yr(e)&&(e.style!==t.getTextStyle()||e.format!==t.getTextFormat())&&e.isCollapsed()&&t.is(e.anchor.getNode())&&t.setTextStyle(e.style).setTextFormat(e.format);}}),t.registerNodeTransform(Xn,t=>{const e=t.getParent();if(ot$3(e)&&t.is(e.getFirstChild())){const n=t.getStyle(),r=t.getFormat();n===e.getTextStyle()&&r===e.getTextFormat()||e.setTextStyle(n).setTextFormat(r);}}))} 5332 5333/** 5334 * Copyright (c) Meta Platforms, Inc. and affiliates. 5335 * 5336 * This source code is licensed under the MIT license found in the 5337 * LICENSE file in the root directory of this source tree. 5338 * 5339 */ 5340 5341const R$3=new Set(["http:","https:","mailto:","sms:","tel:"]);let y$2 = class y extends Ci{__url;__target;__rel;__title;static getType(){return "link"}static clone(t){return new y(t.__url,{rel:t.__rel,target:t.__target,title:t.__title},t.__key)}constructor(t="",e={},n){super(n);const{target:r=null,rel:i=null,title:l=null}=e;this.__url=t,this.__target=r,this.__rel=i,this.__title=l;}createDOM(e){const n=document.createElement("a");return this.updateLinkDOM(null,n,e),lt$4(n,e.theme.link),n}updateLinkDOM(t,n,r){if(xs(n)){t&&t.__url===this.__url||(n.href=this.sanitizeUrl(this.__url));for(const e of ["target","rel","title"]){const r=`__${e}`,i=this[r];t&&t[r]===i||(i?n[e]=i:n.removeAttribute(e));}}}updateDOM(t,e,n){return this.updateLinkDOM(t,e,n),false}static importDOM(){return {a:t=>({conversion:N$2,priority:1})}}static importJSON(t){return D$2().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setURL(t.url).setRel(t.rel||null).setTarget(t.target||null).setTitle(t.title||null)}sanitizeUrl(t){t=W$4(t);try{const e=new URL(W$4(t));if(!R$3.has(e.protocol))return "about:blank"}catch(e){return t}return t}exportJSON(){return {...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(t){const e=this.getWritable();return e.__url=t,e}getTarget(){return this.getLatest().__target}setTarget(t){const e=this.getWritable();return e.__target=t,e}getRel(){return this.getLatest().__rel}setRel(t){const e=this.getWritable();return e.__rel=t,e}getTitle(){return this.getLatest().__title}setTitle(t){const e=this.getWritable();return e.__title=t,e}insertNewAfter(t,e=true){const n=D$2(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,e),n}canInsertTextBefore(){return false}canInsertTextAfter(){return false}canBeEmpty(){return false}isInline(){return true}extractWithChild(t,e,n){if(!yr(e))return false;const r=e.anchor.getNode(),i=e.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&e.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}};function N$2(t){let n=null;if(xs(t)){const e=t.textContent;(null!==e&&""!==e||t.children.length>0)&&(n=D$2(t.getAttribute("href")||"",{rel:t.getAttribute("rel"),target:t.getAttribute("target"),title:t.getAttribute("title")}));}return {node:n}}function D$2(t="",e){return fs(new y$2(t,e))}function w$3(t){return t instanceof y$2}let A$1 = class A extends y$2{__isUnlinked;constructor(t="",e={},n){super(t,e,n),this.__isUnlinked=void 0!==e.isUnlinked&&null!==e.isUnlinked&&e.isUnlinked;}static getType(){return "autolink"}static clone(t){return new A(t.__url,{isUnlinked:t.__isUnlinked,rel:t.__rel,target:t.__target,title:t.__title},t.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(t){const e=this.getWritable();return e.__isUnlinked=t,e}createDOM(t){return this.__isUnlinked?document.createElement("span"):super.createDOM(t)}updateDOM(t,e,n){return super.updateDOM(t,e,n)||t.__isUnlinked!==this.__isUnlinked}static importJSON(t){return I$3().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setIsUnlinked(t.isUnlinked||false)}static importDOM(){return null}exportJSON(){return {...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(t,e=true){const n=this.getParentOrThrow().insertNewAfter(t,e);if(Si(n)){const t=I$3(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(t),t}return null}};function I$3(t="",e){return fs(new A$1(t,e))}function E$3(t){return t instanceof A$1}function M$3(t,e){if("element"===t.type){const n=t.getNode();Si(n)||function(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(252);return n.getChildren()[t.offset+e]||null}return null}function J$2(t,e={}){let r;if(t&&"object"==typeof t){const{url:n,...i}=t;r=n,e={...i,...e};}else r=t;const{target:i,title:l}=e,s=void 0===e.rel?"noreferrer":e.rel,u=Lr();if(null===u||!yr(u)&&!xr(u))return;if(xr(u)){const t=u.getNodes();if(0===t.length)return;return void t.forEach(t=>{if(null===r){const e=zs(t,t=>!E$3(t)&&w$3(t));e&&(e.insertBefore(t),0===e.getChildren().length&&e.remove());}else {const e=zs(t,t=>!E$3(t)&&w$3(t));if(e)e.setURL(r),void 0!==i&&e.setTarget(i),void 0!==s&&e.setRel(s);else {const e=D$2(r,{rel:s,target:i});t.insertBefore(e),e.append(t);}}})}const h=u.extract();if(null===r){const t=new Set;
5341return void h.forEach(e=>{const n=e.getParent();if(w$3(n)&&!E$3(n)){const e=n.getKey();if(t.has(e))return;!function(t,e){const n=new Set(e.filter(e=>t.isParentOf(e)).map(t=>t.getKey())),r=t.getChildren(),i=r.filter(t=>n.has(t.getKey()));if(i.length===r.length)return r.forEach(e=>t.insertBefore(e)),void t.remove();const l=r.findIndex(t=>n.has(t.getKey())),s=r.findLastIndex(t=>n.has(t.getKey())),o=0===l,u=s===r.length-1;if(o)i.forEach(e=>t.insertBefore(e));else if(u)for(let e=i.length-1;e>=0;e--)t.insertAfter(i[e]);else {for(let e=i.length-1;e>=0;e--)t.insertAfter(i[e]);const e=r.slice(s+1);if(e.length>0){const n=D$2(t.getURL(),{rel:t.getRel(),target:t.getTarget(),title:t.getTitle()});i[i.length-1].insertAfter(n),e.forEach(t=>n.append(t));}}}(n,h),t.add(e);}})}const p=new Set,_=t=>{p.has(t.getKey())||(p.add(t.getKey()),t.setURL(r),void 0!==i&&t.setTarget(i),void 0!==s&&t.setRel(s),void 0!==l&&t.setTitle(l));};if(1===h.length){const t=h[0],e=zs(t,w$3);if(null!==e)return _(e)}!function(t){const e=Lr();if(!yr(e))return t();const n=St$6(e),r=n.isBackward(),i=M$3(n.anchor,r?-1:0),l=M$3(n.focus,r?0:-1);t();if(i||l){const t=Lr();if(yr(t)){const e=t.clone();if(i){const t=i.getParent();t&&e.anchor.set(t.getKey(),i.getIndexWithinParent()+(r?1:0),"element");}if(l){const t=l.getParent();t&&e.focus.set(t.getKey(),l.getIndexWithinParent()+(r?0:1),"element");}wo(St$6(e));}}}(()=>{let t=null;for(const e of h){if(!e.isAttached())continue;const o=zs(e,w$3);if(o){_(o);continue}if(Si(e)){if(!e.isInline())continue;if(w$3(e)){if(!(E$3(e)||null!==t&&t.getParentOrThrow().isParentOf(e))){_(e),t=e;continue}for(const t of e.getChildren())e.insertBefore(t);e.remove();continue}}const u=e.getPreviousSibling();w$3(u)&&u.is(t)?u.append(e):(t=D$2(r,{rel:s,target:i,title:l}),e.insertAfter(t),t.append(e));}});}const K$2=/^\+?[0-9\s()-]{5,}$/;function W$4(t){return t.match(/^[a-z][a-z0-9+.-]*:/i)||t.match(/^[/#.]/)?t:t.includes("@")?`mailto:${t}`:K$2.test(t)?`tel:${t}`:`https://${t}`} 5342 5343/** 5344 * Copyright (c) Meta Platforms, Inc. and affiliates. 5345 * 5346 * This source code is licensed under the MIT license found in the 5347 * LICENSE file in the root directory of this source tree. 5348 * 5349 */ 5350 5351function m$1(e,n){const t=ao(n)?n.body.childNodes:n.childNodes;let l=[];const r=[];for(const n of t)if(!w$2.has(n.nodeName)){const t=y$1(n,e,r,false);null!==t&&(l=l.concat(t));}return function(e){for(const n of e)n.getNextSibling()instanceof Pi&&n.insertAfter(Jn());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove();}}(r),l}function g(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),o=No().getChildren();for(let l=0;l<o.length;l++){x$2(e,o[l],t,n);}return t.innerHTML}function x$2(t,o,l,u=null){let f=null===u||o.isSelected(u);const a=Si(o)&&o.excludeFromCopy("html");let d=o;null!==u&&lr(o)&&(d=M$4(u,o,"clone"));const p=Si(d)?d.getChildren():[],h=Xi(t,d.getType());let m;m=h&&void 0!==h.exportDOM?h.exportDOM(t,d):d.exportDOM(t);const{element:g,after:w}=m;if(!g)return false;const y=document.createDocumentFragment();for(let e=0;e<p.length;e++){const n=p[e],l=x$2(t,n,y,u);!f&&Si(o)&&l&&o.extractWithChild(n,u,"html")&&(f=true);}if(f&&!a){if((Cs(g)||vs(g))&&g.append(y),l.append(g),w){const e=w.call(d,g);e&&(vs(g)?g.replaceChildren(e):g.replaceWith(e));}}else l.append(y);return f}const w$2=new Set(["STYLE","SCRIPT"]);function y$1(e,n,o,l,i=new Map,s){let c=[];if(w$2.has(e.nodeName))return c;let m=null;const g=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<=(t.priority||0))&&(l=t);}return null!==l?l.conversion:null}(e,n),x=g?g(e):null;let b=null;if(null!==x){b=x.after;const n=x.node;if(m=Array.isArray(n)?n[n.length-1]:n,null!==m){for(const[,e]of i)if(m=e(m,s),!m)break;m&&c.push(...Array.isArray(n)?n:[m]);}null!=x.forChild&&i.set(e.nodeName,x.forChild);}const S=e.childNodes;let v=[];const N=(null==m||!as(m))&&(null!=m&&Or(m)||l);for(let e=0;e<S.length;
5351e++)v.push(...y$1(S[e],n,o,N,new Map(i),m));return null!=b&&(v=b(v)),Ts(e)&&(v=C$2(e,v,N?()=>{const e=new Pi;return o.push(e),e}:Li)),null==m?v.length>0?c=c.concat(v):Ts(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return false;return ks(e.nextSibling)&&ks(e.previousSibling)}(e)&&(c=c.concat(Jn())):Si(m)&&m.append(...v),c}function C$2(e,n,t){const o=e.style.textAlign,l=[];let r=[];for(let e=0;e<n.length;e++){const i=n[e];if(Or(i))o&&!i.getFormat()&&i.setFormat(o),l.push(i);else if(r.push(i),e===n.length-1||e<n.length-1&&Or(n[e+1])){const e=t();e.setFormat(o),e.append(...r),l.push(e),r=[];}}return l} 5352 5353/** 5354 * Copyright (c) Meta Platforms, Inc. and affiliates. 5355 * 5356 * This source code is licensed under the MIT license found in the 5357 * LICENSE file in the root directory of this source tree. 5358 * 5359 */ 5360 5361function v$2(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function D$1(e,n=Lr()){return null==n&&v$2(166),yr(n)&&n.isCollapsed()||0===n.getNodes().length?"":g(e,n)}function S$2(t,e=Lr()){return null==e&&v$2(166),yr(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(E$2(t,e))}function N$1(t,e){const n=t.getData("text/plain")||t.getData("text/uri-list");null!=n&&e.insertRawText(n);}function R$2(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return A(o,L$2(t.nodes),n)}}catch(t){console.error(t);}const c=t.getData("text/html"),a=t.getData("text/plain");if(c&&a!==c)try{const t=(new DOMParser).parseFromString(function(t){if(window.trustedTypes&&window.trustedTypes.createPolicy){return window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(t)}return t}(c),"text/html");return A(o,m$1(o,t),n)}catch(t){console.error(t);}const u=a||t.getData("text/uri-list");if(null!=u)if(yr(n)){const t=u.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e<t.length;e++){const n=Lr();if(yr(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([ur()]):n.insertText(o);}}}else n.insertRawText(u);}function A(t,e,n){t.dispatchCommand(oe$2,{nodes:e,selection:n})||(n.insertNodes(e),function(t){if(yr(t)&&t.isCollapsed()){const e=t.anchor;let n=null;const o=xl(e,"previous");if(o)if(Ys(o))n=o.origin;else {const t=dl(o,il(No(),"next").getFlipped());for(const e of t){if(lr(e.origin)){n=e.origin;break}if(Si(e.origin)&&!e.origin.isInline())break}}if(n&&lr(n)){const e=n.getFormat(),o=n.getStyle();t.format===e&&t.style===o||(t.format=e,t.style=o,t.dirty=true);}}}(n));}function P$1(t,e,n,r=[]){let i=null===e||n.isSelected(e);const l=Si(n)&&n.excludeFromCopy("html");let s=n;null!==e&&lr(s)&&(s=M$4(e,s,"clone"));const c=Si(s)?s.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&v$2(58,n.name),Si(t)){const t=e.children;Array.isArray(t)||v$2(59,n.name);}return e}(s);lr(s)&&0===s.getTextContentSize()&&(i=false);for(let o=0;o<c.length;o++){const r=c[o],l=P$1(t,e,r,a.children);!i&&Si(n)&&l&&n.extractWithChild(r,e,"clone")&&(i=true);}if(i&&!l)r.push(a);else if(Array.isArray(a.children))for(let t=0;t<a.children.length;t++){const e=a.children[t];r.push(e);}return i}function E$2(t,e){const n=[],o=No().getChildren();for(let r=0;r<o.length;r++){P$1(t,e,o[r],n);}return {namespace:t._config.namespace,nodes:n}}function L$2(t){const e=[];for(let o=0;o<t.length;o++){const r=t[o],i=ui(r);lr(i)&&$$3(i),e.push(i);}return e}let b$2=null;async function F$1(t,e,n){if(null!==b$2)return false;if(null!==e)return new Promise((o,r)=>{t.update(()=>{o(M$2(t,e,n));});});const o=t.getRootElement(),i=t._window||window,l=i.document,s=ps(i);if(null===o||null===s)return false;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const a=new Range;return a.setStart(c,0),a.setEnd(c,1),s.removeAllRanges(),s.addRange(a),new Promise((e,o)=>{const s=t.registerCommand(Re$2,o=>(Lt$4(o,ClipboardEvent)&&(s(),null!==b$2&&(i.clearTimeout(b$2),b$2=null),e(M$2(t,o,n))),true),Wi);b$2=i.setTimeout(()=>{s(),b$2=null,e(false);},50),l.execCommand("copy"),c.remove();})}function M$2(t,e,n){if(void 0===n){const e=ps(t._window),o=Lr();if(!o||o.isCollapsed())return false;if(!e)return false;
5361const r=e.anchorNode,l=e.focusNode;if(null!==r&&null!==l&&!eo(t,r,l))return false;n=_$1(o);}e.preventDefault();const o=e.clipboardData;return null!==o&&(J$1(o,n),true)}const O=[["text/html",D$1],["application/x-lexical-editor",S$2]];function _$1(t=Lr()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=bs();for(const[o,r]of O){const i=r(n,t);null!==i&&(e[o]=i);}}return e}function J$1(t,e){for(const[n]of O) void 0===e[n]&&t.setData(n,"");for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o);}} 5362 5363/** 5364 * Copyright (c) Meta Platforms, Inc. and affiliates. 5365 * 5366 * This source code is licensed under the MIT license found in the 5367 * LICENSE file in the root directory of this source tree. 5368 * 5369 */ 5370 5371function s(e){const t=window.location.origin,n=n=>{if(n.origin!==t)return;const o=e.getRootElement();if(document.activeElement!==o)return;const s=n.data;if("string"==typeof s){let t;try{t=JSON.parse(s);}catch(e){return}if(t&&"nuanria_messaging"===t.protocol&&"request"===t.type){const o=t.payload;if(o&&"makeChanges"===o.functionId){const t=o.args;if(t){const[o,s,d,c,g]=t;e.update(()=>{const e=Lr();if(yr(e)){const t=e.anchor;let i=t.getNode(),a=0,l=0;if(lr(i)&&o>=0&&s>=0&&(a=o,l=o+s,e.setTextNodeRange(i,a,i,l)),a===l&&""===d||(e.insertRawText(d),i=t.getNode()),lr(i)){a=c,l=c+g;const t=i.getTextContentSize();a=a>t?t:a,l=l>t?t:l,e.setTextNodeRange(i,a,i,l);}n.stopImmediatePropagation();}});}}}}};return window.addEventListener("message",n,true),()=>{window.removeEventListener("message",n,true);}}const d=Kl({build:(e,n,o)=>at$2(n),config:Bl({disabled:"undefined"==typeof window}),name:"@lexical/dragon",register:(t,n,o)=>dt$3(()=>o.getOutput().disabled.value?void 0:s(t))}); 5372 5373/** 5374 * Copyright (c) Meta Platforms, Inc. and affiliates. 5375 * 5376 * This source code is licensed under the MIT license found in the 5377 * LICENSE file in the root directory of this source tree. 5378 * 5379 */ 5380 5381const L$1="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,S$1=L$1&&"documentMode"in document?document.documentMode:null,W$3=L$1&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),B$1=!(!L$1||!("InputEvent"in window)||S$1)&&"getTargetRanges"in new window.InputEvent("input"),I$2=L$1&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),R$1=L$1&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,V$3=L$1&&/^(?=.*Chrome).*/i.test(navigator.userAgent),j$1=L$1&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&W$3&&!V$3;function q$2(e,n){n.update(()=>{if(null!==e){const r=Lt$4(e,KeyboardEvent)?null:e.clipboardData,o=Lr();if(null!==o&&!o.isCollapsed()&&null!=r){e.preventDefault();const i=D$1(n);null!==i&&r.setData("text/html",i),r.setData("text/plain",o.getTextContent());}}});}function z$2(t){return U$4(t.registerCommand(le$2,e=>{const t=Lr();return !!yr(t)&&(t.deleteCharacter(e),true)},Ki),t.registerCommand(he$1,e=>{const t=Lr();return !!yr(t)&&(t.deleteWord(e),true)},Ki),t.registerCommand(ge$1,e=>{const t=Lr();return !!yr(t)&&(t.deleteLine(e),true)},Ki),t.registerCommand(ue$1,t=>{const n=Lr();if(!yr(n))return false;if("string"==typeof t)n.insertText(t);else {const r=t.dataTransfer;if(null!=r)N$1(r,n);else {const e=t.data;e&&n.insertText(e);}}return true},Ki),t.registerCommand(de$1,()=>{const e=Lr();return !!yr(e)&&(e.removeText(),true)},Ki),t.registerCommand(ce$1,e=>{const t=Lr();return !!yr(t)&&(t.insertLineBreak(e),true)},Ki),t.registerCommand(ae$1,()=>{const e=Lr();return !!yr(e)&&(e.insertLineBreak(),true)},Ki),t.registerCommand(Se$1,e=>{const t=Lr();if(!yr(t))return false;const n=e,i=n.shiftKey;return !!Z$3(t,true)&&(n.preventDefault(),ne(t,i,true),true)},Ki),t.registerCommand(xe$1,e=>{const t=Lr();if(!yr(t))return false;const n=e,i=n.shiftKey;return !!Z$3(t,false)&&(n.preventDefault(),ne(t,i,false),true)},Ki),t.registerCommand(we$1,e=>{const n=Lr();return !!yr(n)&&((!R$1||"ko-KR"!==navigator.language)&&(e.preventDefault(),t.dispatchCommand(le$2,true)))},Ki),t.registerCommand(Oe$2,e=>{const n=Lr();return !!yr(n)&&(e.preventDefault(),t.dispatchCommand(le$2,false))},Ki),t.registerCommand(Ne$2,e=>{const n=Lr();if(!yr(n))return false;if(null!==e){if((R$1||I$2||j$1)&&B$1)return false;e.preventDefault();}return t.dispatchCommand(ce$1,false)},Ki),t.registerCommand(We$2,()=>(jo(),true),Ki),t.registerCommand(Re$2,e=>{const n=Lr();return !!yr(n)&&(q$2(e,t),true)},Ki),t.registerCommand(Be$2,e=>{const n=Lr();return !!yr(n)&&(function(e,t){q$2(e,t),t.update(()=>{const e=Lr();yr(e)&&e.removeText();});}(e,t),true)},Ki),t.registerCommand(fe$1,n=>{const r=Lr();return !!yr(r)&&(function(t,n){t.preventDefault(),n.update(()=>{const n=Lr(),r=Lt$4(t,ClipboardEvent)?t.clipboardData:null;null!=r&&yr(n)&&N$1(r,n);},{tag:Fn});}(n,t),true)},Ki),t.registerCommand(Fe$2,e=>{const t=Lr();return !!yr(t)&&(e.preventDefault(),true)},Ki),t.registerCommand(Ie$2,e=>{const t=Lr();return !!yr(t)&&(e.preventDefault(),true)},Ki))} 5382
5383/** 5384 * Copyright (c) Meta Platforms, Inc. and affiliates. 5385 * 5386 * This source code is licensed under the MIT license found in the 5387 * LICENSE file in the root directory of this source tree. 5388 * 5389 */ 5390 5391function gt$2(t,e){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(t,e);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(t,e);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const pt$2="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,ht$2=pt$2&&"documentMode"in document?document.documentMode:null,vt$2=pt$2&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ct$3=!(!pt$2||!("InputEvent"in window)||ht$2)&&"getTargetRanges"in new window.InputEvent("input"),yt$2=pt$2&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),xt$2=pt$2&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Dt$2=pt$2&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Nt$3=pt$2&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&vt$2&&!Dt$2,wt$3=re$1("DRAG_DROP_PASTE_FILE");let Et$3 = class Et extends Ci{static getType(){return "quote"}static clone(t){return new Et(t.__key)}createDOM(t){const e=document.createElement("blockquote");return lt$4(e,t.theme.quote),e}updateDOM(t,e){return false}static importDOM(){return {blockquote:t=>({conversion:Ft$2,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Cs(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return _t$2().updateFromJSON(t)}insertNewAfter(t,e){const n=Li(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=Li();
5391return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}canMergeWhenEmpty(){return true}};function _t$2(){return fs(new Et$3)}function Ot$2(t){return t instanceof Et$3}let Pt$3 = class Pt extends Ci{__tag;static getType(){return "heading"}static clone(t){return new Pt(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t;}getTag(){return this.__tag}setTag(t){const e=this.getWritable();return this.__tag=t,e}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];lt$4(n,t);}return n}updateDOM(t,e,n){return t.__tag!==this.__tag}static importDOM(){return {h1:t=>({conversion:At$3,priority:0}),h2:t=>({conversion:At$3,priority:0}),h3:t=>({conversion:At$3,priority:0}),h4:t=>({conversion:At$3,priority:0}),h5:t=>({conversion:At$3,priority:0}),h6:t=>({conversion:At$3,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&Tt$3(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>Tt$3(t)?{conversion:t=>({node:St$3("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Cs(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return St$3(t.tag).updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTag(t.tag)}exportJSON(){return {...super.exportJSON(),tag:this.getTag()}}insertNewAfter(t,e=true){const n=t?t.anchor.offset:0,r=this.getLastDescendant(),o=!r||t&&t.anchor.key===r.getKey()&&n===r.getTextContentSize()||!t?Li():St$3(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,e),0===n&&!this.isEmpty()&&t){const t=Li();t.select(),this.replace(t,true);}return o}collapseAtStart(){const t=this.isEmpty()?Li():St$3(this.getTag());
5391return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}extractWithChild(){return true}};function Tt$3(t){return "span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function At$3(t){const e=t.nodeName.toLowerCase();let n=null;return "h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=St$3(e),null!==t.style&&(Ps(t,n),n.setFormat(t.style.textAlign))),{node:n}}function Ft$2(t){const e=_t$2();return null!==t.style&&(e.setFormat(t.style.textAlign),Ps(t,e)),{node:e}}function St$3(t="h1"){return fs(new Pt$3(t))}function It$2(t){return t instanceof Pt$3}function Mt$2(t){let e=null;if(Lt$4(t,DragEvent)?e=t.dataTransfer:Lt$4(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return [false,[],false];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return [r,Array.from(e.files),o]}function bt$3(t){const e=Lr();if(!yr(e))return false;const n=new Set,r=e.getNodes();for(let e=0;e<r.length;e++){const o=r[e],i=o.getKey();if(n.has(i))continue;const s=zs(o,t=>Si(t)&&!t.isInline());if(null===s)continue;const c=s.getKey();s.canIndent()&&!n.has(c)&&(n.add(c),t(s));}return n.size>0}function Kt$1(t){const e=vo(t);return Ti(e)}function kt$3(t){for(const e of ["lowercase","uppercase","capitalize"])t.hasFormat(e)&&t.toggleFormat(e);}function Jt$1(n){return U$4(n.registerCommand(se$1,t=>{const e=Lr();return !!xr(e)&&(e.clear(),true)},Ki),n.registerCommand(le$2,t=>{const e=Lr();return yr(e)?(e.deleteCharacter(t),true):!!xr(e)&&(e.deleteNodes(),true)},Ki),n.registerCommand(he$1,t=>{const e=Lr();return !!yr(e)&&(e.deleteWord(t),true)},Ki),n.registerCommand(ge$1,t=>{const e=Lr();return !!yr(e)&&(e.deleteLine(t),true)},Ki),n.registerCommand(ue$1,e=>{const r=Lr();if("string"==typeof e)null!==r&&r.insertText(e);else {if(null===r)return false;const o=e.dataTransfer;if(null!=o)R$2(o,r,n);else if(yr(r)){const t=e.data;return t&&r.insertText(t),true}}return true},Ki),n.registerCommand(de$1,()=>{const t=Lr();return !!yr(t)&&(t.removeText(),true)},Ki),n.registerCommand(_e$1,t=>{const e=Lr();return !!yr(e)&&(e.formatText(t),true)},Ki),n.registerCommand(Le$2,t=>{const e=Lr();if(!yr(e)&&!xr(e))return false;const n=e.getNodes();for(const e of n){const n=zs(e,t=>Si(t)&&!t.isInline());null!==n&&n.setFormat(t);}return true},Ki),n.registerCommand(ce$1,t=>{const e=Lr();return !!yr(e)&&(e.insertLineBreak(t),true)},Ki),n.registerCommand(ae$1,()=>{const t=Lr();return !!yr(t)&&(t.insertParagraph(),true)},Ki),n.registerCommand(Ae$2,()=>(jr([ur()]),true),Ki),n.registerCommand(Pe$2,()=>bt$3(t=>{const e=t.getIndent();t.setIndent(e+1);}),Ki),n.registerCommand(De$2,()=>bt$3(t=>{const e=t.getIndent();e>0&&t.setIndent(Math.max(0,e-1));}),Ki),n.registerCommand(ke$2,t=>{const e=Lr();if(xr(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectPrevious(),true}else if(yr(e)){const n=qo(e.focus,true);if(!t.shiftKey&&Ti(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),true}return false},Ki),n.registerCommand(Te$2,t=>{const e=Lr();if(xr(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectNext(0,0),true}else if(yr(e)){if(function(t){const e=t.focus;return "root"===e.key&&e.offset===No().getChildrenSize()}(e))return t.preventDefault(),true;const n=qo(e.focus,false);if(!t.shiftKey&&Ti(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),true}return false},Ki),n.registerCommand(Se$1,t=>{const e=Lr();if(xr(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),A$2(n[0])?n[0].selectNext(0,0):n[0].selectPrevious(),true}if(!yr(e))return false;if(Z$3(e,true)){const n=t.shiftKey;return t.preventDefault(),ne(e,n,true),true}return false},Ki),n.registerCommand(xe$1,t=>{const e=Lr();if(xr(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),A$2(n[0])?n[0].selectPrevious():n[0].selectNext(0,0),true}if(!yr(e))return false;const n=t.shiftKey;return !!Z$3(e,false)&&(t.preventDefault(),ne(e,n,false),true)},Ki),n.registerCommand(we$1,t=>{if(Kt$1(t.target))return false;const e=Lr();if(yr(e)){if(function(t){if(!t.isCollapsed())return false;
5391const{anchor:e}=t;if(0!==e.offset)return false;const n=e.getNode();if(bi(n))return false;const r=xt$5(n);return r.getIndent()>0&&(r.is(n)||n.is(r.getFirstDescendant()))}(e))return t.preventDefault(),n.dispatchCommand(De$2,void 0);if(xt$2&&"ko-KR"===navigator.language)return false}else if(!xr(e))return false;return t.preventDefault(),n.dispatchCommand(le$2,true)},Ki),n.registerCommand(Oe$2,t=>{if(Kt$1(t.target))return false;const e=Lr();return !(!yr(e)&&!xr(e))&&(t.preventDefault(),n.dispatchCommand(le$2,false))},Ki),n.registerCommand(Ne$2,t=>{const e=Lr();if(!yr(e))return false;if(kt$3(e),null!==t){if((xt$2||yt$2||Nt$3)&&Ct$3)return false;if(t.preventDefault(),t.shiftKey)return n.dispatchCommand(ce$1,false)}return n.dispatchCommand(ae$1,void 0)},Ki),n.registerCommand(Ee$2,()=>{const t=Lr();return !!yr(t)&&(n.blur(),true)},Ki),n.registerCommand(Fe$2,t=>{const[,e]=Mt$2(t);if(e.length>0){const r=gt$2(t.clientX,t.clientY);if(null!==r){const{offset:t,node:o}=r,i=vo(o);if(null!==i){const e=Ar();if(lr(i))e.anchor.set(i.getKey(),t,"text"),e.focus.set(i.getKey(),t,"text");else {const t=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element");}const n=St$6(e);wo(n);}n.dispatchCommand(wt$3,e);}return t.preventDefault(),true}const r=Lr();return !!yr(r)},Ki),n.registerCommand(Ie$2,t=>{const[e]=Mt$2(t),n=Lr();return !(e&&!yr(n))},Ki),n.registerCommand(Ke$2,t=>{const[e]=Mt$2(t),n=Lr();if(e&&!yr(n))return false;const r=gt$2(t.clientX,t.clientY);if(null!==r){const e=vo(r.node);Ti(e)&&t.preventDefault();}return true},Ki),n.registerCommand(We$2,()=>(jo(),true),Ki),n.registerCommand(Re$2,t=>(F$1(n,Lt$4(t,ClipboardEvent)?t:null),true),Ki),n.registerCommand(Be$2,t=>(async function(t,n){await F$1(n,Lt$4(t,ClipboardEvent)?t:null),n.update(()=>{const t=Lr();yr(t)?t.removeText():xr(t)&&t.getNodes().forEach(t=>t.remove());});}(t,n),true),Ki),n.registerCommand(fe$1,e=>{const[,r,o]=Mt$2(e);if(r.length>0&&!o)return n.dispatchCommand(wt$3,r),true;if(Ss(e.target)&&to(e.target))return false;return null!==Lr()&&(function(e,n){e.preventDefault(),n.update(()=>{const r=Lr(),o=Lt$4(e,InputEvent)||Lt$4(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&R$2(o,r,n);},{tag:Fn});}(e,n),true)},Ki),n.registerCommand(be$1,t=>{const e=Lr();return yr(e)&&kt$3(e),false},Ki),n.registerCommand(Me$2,t=>{const e=Lr();return yr(e)&&kt$3(e),false},Ki))}const Wt$2=Kl({conflictsWith:["@lexical/plain-text"],dependencies:[d],name:"@lexical/rich-text",nodes:[Pt$3,Et$3],register:Jt$1}); 5392 5393Prism$1.languages.javascript = Prism$1.languages.extend('clike', { 5394 'class-name': [ 5395 Prism$1.languages.clike['class-name'], 5396 { 5397 pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/, 5398 lookbehind: true 5399 } 5400 ], 5401 'keyword': [ 5402 { 5403 pattern: /((?:^|\})\s*)catch\b/, 5404 lookbehind: true 5405 }, 5406 { 5407 pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/, 5408 lookbehind: true 5409 }, 5410 ], 5411 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) 5412 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, 5413 'number': { 5414 pattern: RegExp( 5415 /(^|[^\w$])/.source + 5416 '(?:' + 5417 ( 5418 // constant 5419 /NaN|Infinity/.source + 5420 '|' + 5421 // binary integer 5422 /0[bB][01]+(?:_[01]+)*n?/.source + 5423 '|' + 5424 // octal integer 5425 /0[oO][0-7]+(?:_[0-7]+)*n?/.source + 5426 '|' + 5427 // hexadecimal integer 5428 /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + 5429 '|' + 5430 // decimal bigint 5431 /\d+(?:_\d+)*n/.source + 5432 '|' + 5433 // decimal number (integer or float) but no bigint
vendor: 4,609 bytes, lines 5434-5559
5434 /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source 5435 ) + 5436 ')' + 5437 /(?![\w$])/.source 5438 ), 5439 lookbehind: true 5440 }, 5441 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/ 5442}); 5443 5444Prism$1.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/; 5445 5446Prism$1.languages.insertBefore('javascript', 'keyword', { 5447 'regex': { 5448 pattern: RegExp( 5449 // lookbehind 5450 // eslint-disable-next-line regexp/no-dupe-characters-character-class 5451 /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + 5452 // Regex pattern: 5453 // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character 5454 // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible 5455 // with the only syntax, so we have to define 2 different regex patterns. 5456 /\//.source + 5457 '(?:' + 5458 /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + 5459 '|' + 5460 // `v` flag syntax. This supports 3 levels of nested character classes. 5461 /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + 5462 ')' + 5463 // lookahead 5464 /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source 5465 ), 5466 lookbehind: true, 5467 greedy: true, 5468 inside: { 5469 'regex-source': { 5470 pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/, 5471 lookbehind: true, 5472 alias: 'language-regex', 5473 inside: Prism$1.languages.regex 5474 }, 5475 'regex-delimiter': /^\/|\/$/, 5476 'regex-flags': /^[a-z]+$/, 5477 } 5478 }, 5479 // This must be declared before keyword because we use "function" inside the look-forward 5480 'function-variable': { 5481 pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/, 5482 alias: 'function' 5483 }, 5484 'parameter': [ 5485 { 5486 pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/, 5487 lookbehind: true, 5488 inside: Prism$1.languages.javascript 5489 }, 5490 { 5491 pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i, 5492 lookbehind: true, 5493 inside: Prism$1.languages.javascript 5494 }, 5495 { 5496 pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/, 5497 lookbehind: true, 5498 inside: Prism$1.languages.javascript 5499 }, 5500 { 5501 pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/, 5502 lookbehind: true, 5503 inside: Prism$1.languages.javascript 5504 } 5505 ], 5506 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/ 5507}); 5508 5509Prism$1.languages.insertBefore('javascript', 'string', { 5510 'hashbang': { 5511 pattern: /^#!.*/, 5512 greedy: true, 5513 alias: 'comment' 5514 }, 5515 'template-string': { 5516 pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/, 5517 greedy: true, 5518 inside: { 5519 'template-punctuation': { 5520 pattern: /^`|`$/, 5521 alias: 'string' 5522 }, 5523 'interpolation': { 5524 pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/, 5525 lookbehind: true, 5526 inside: { 5527 'interpolation-punctuation': { 5528 pattern: /^\$\{|\}$/, 5529 alias: 'punctuation' 5530 }, 5531 rest: Prism$1.languages.javascript 5532 } 5533 }, 5534 'string': /[\s\S]+/ 5535 } 5536 }, 5537 'string-property': { 5538 pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m, 5539 lookbehind: true, 5540 greedy: true, 5541 alias: 'property' 5542 } 5543}); 5544 5545Prism$1.languages.insertBefore('javascript', 'operator', { 5546 'literal-property': { 5547 pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m, 5548 lookbehind: true, 5549 alias: 'property' 5550 }, 5551}); 5552 5553if (Prism$1.languages.markup) { 5554 Prism$1.languages.markup.tag.addInlined('script', 'javascript'); 5555 5556 // add attribute support for all DOM events. 5557 // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events 5558 Prism$1.languages.markup.tag.addAttribute( 5559 /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?
5559:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, 5560 'javascript' 5561 ); 5562} 5563 5564Prism$1.languages.js = Prism$1.languages.javascript; 5565 5566(function (Prism) { 5567 5568 // Allow only one line break 5569 var inner = /(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source; 5570 5571 /** 5572 * This function is intended for the creation of the bold or italic pattern. 5573 * 5574 * This also adds a lookbehind group to the given pattern to ensure that the pattern is not backslash-escaped. 5575 * 5576 * _Note:_ Keep in mind that this adds a capturing group. 5577 * 5578 * @param {string} pattern 5579 * @returns {RegExp} 5580 */ 5581 function createInline(pattern) { 5582 pattern = pattern.replace(/<inner>/g, function () { return inner; }); 5583 return RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + '(?:' + pattern + ')'); 5584 } 5585 5586 5587 var tableCell = /(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source; 5588 var tableRow = /\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g, function () { return tableCell; }); 5589 var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source; 5590 5591 5592 Prism.languages.markdown = Prism.languages.extend('markup', {}); 5593 Prism.languages.insertBefore('markdown', 'prolog', { 5594 'front-matter-block': { 5595 pattern: /(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/, 5596 lookbehind: true, 5597 greedy: true, 5598 inside: { 5599 'punctuation': /^---|---$/, 5600 'front-matter': { 5601 pattern: /\S+(?:\s+\S+)*/, 5602 alias: ['yaml', 'language-yaml'], 5603 inside: Prism.languages.yaml 5604 } 5605 } 5606 }, 5607 'blockquote': { 5608 // > ... 5609 pattern: /^>(?:[\t ]*>)*/m, 5610 alias: 'punctuation' 5611 }, 5612 'table': { 5613 pattern: RegExp('^' + tableRow + tableLine + '(?:' + tableRow + ')*', 'm'), 5614 inside: { 5615 'table-data-rows': { 5616 pattern: RegExp('^(' + tableRow + tableLine + ')(?:' + tableRow + ')*$'), 5617 lookbehind: true, 5618 inside: { 5619 'table-data': { 5620 pattern: RegExp(tableCell), 5621 inside: Prism.languages.markdown 5622 }, 5623 'punctuation': /\|/ 5624 } 5625 }, 5626 'table-line': { 5627 pattern: RegExp('^(' + tableRow + ')' + tableLine + '$'), 5628 lookbehind: true, 5629 inside: { 5630 'punctuation': /\||:?-{3,}:?/ 5631 } 5632 }, 5633 'table-header-row': { 5634 pattern: RegExp('^' + tableRow + '$'), 5635 inside: { 5636 'table-header': { 5637 pattern: RegExp(tableCell), 5638 alias: 'important', 5639 inside: Prism.languages.markdown 5640 }, 5641 'punctuation': /\|/ 5642 } 5643 } 5644 } 5645 }, 5646 'code': [ 5647 { 5648 // Prefixed by 4 spaces or 1 tab and preceded by an empty line 5649 pattern: /((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/, 5650 lookbehind: true, 5651 alias: 'keyword' 5652 }, 5653 { 5654 // ```optional language 5655 // code block 5656 // ``` 5657 pattern: /^```[\s\S]*?^```$/m, 5658 greedy: true, 5659 inside: { 5660 'code-block': { 5661 pattern: /^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m, 5662 lookbehind: true 5663 }, 5664 'code-language': { 5665 pattern: /^(```).+/, 5666 lookbehind: true 5667 }, 5668 'punctuation': /```/ 5669 } 5670 } 5671 ], 5672 'title': [ 5673 { 5674 // title 1 5675 // ======= 5676 5677 // title 2 5678 // ------- 5679 pattern: /\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m, 5680 alias: 'important', 5681 inside: { 5682 punctuation: /==+$|--+$/ 5683 } 5684 }, 5685 { 5686 // # title 1 5687 // ###### title 6 5688 pattern: /(^\s*)#.+/m, 5689 lookbehind: true, 5690 alias: 'important', 5691 inside: { 5692 punctuation: /^#+|#+$/ 5693 } 5694 } 5695 ], 5696 'hr': { 5697 // *** 5698 // --- 5699 // * * * 5700 // ----------- 5701 pattern: /(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m, 5702 lookbehind: true, 5703 alias: 'punctuation' 5704 }, 5705 'list': { 5706 // * item 5707 // + item 5708 // - item 5709 // 1. item 5710 pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m, 5711 lookbehind: true, 5712 alias: 'punctuation' 5713 }, 5714 'url-reference': { 5715 // [id]: http://example.com "Optional title" 5716 // [id]: http://example.com 'Optional title' 5717 // [id]: http://example.com (Optional title) 5718 // [id]: <http://example.com> "Optional title" 5719 pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/, 5720 inside: { 5721 'variable': { 5722 pattern: /^(!?\[)[^\]]+/, 5723 lookbehind: true 5724 }, 5725 'string': /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/, 5726 'punctuation': /^[\[\]!:]|[<>]/ 5727 }, 5728 alias: 'url' 5729 }, 5730 'bold': { 5731 // **strong** 5732 // __strong__ 5733 5734 // allow one nested instance of italic text using the same delimiter 5735 pattern: createInline(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source), 5736 lookbehind: true, 5737 greedy: true, 5738 inside: { 5739 'content': { 5740 pattern: /(^..)[\s\S]+(?=..$)/, 5741 lookbehind: true, 5742 inside: {} // see below 5743 }, 5744 'punctuation': /\*\*|__/ 5745 } 5746 }, 5747 'italic': { 5748 // *em* 5749 // _em_ 5750 5751 // allow one nested instance of bold text using the same delimiter 5752 pattern: createInline(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source), 5753 lookbehind: true, 5754 greedy: true, 5755 inside: { 5756 'content': { 5757 pattern: /(^.)[\s\S]+(?=.$)/, 5758 lookbehind: true, 5759 inside: {} // see below 5760 }, 5761 'punctuation': /[*_]/ 5762 } 5763 }, 5764 'strike': { 5765 // ~~strike through~~ 5766 // ~strike~ 5767 // eslint-disable-next-line regexp/strict 5768 pattern: createInline(/(~~?)(?:(?!~)<inner>)+\2/.source), 5769 lookbehind: true, 5770 greedy: true, 5771 inside: { 5772 'content': { 5773 pattern: /(^~~?)[\s\S]+(?=\1$)/, 5774 lookbehind: true, 5775 inside: {} // see below 5776 }, 5777 'punctuation': /~~?/ 5778 } 5779 }, 5780 'code-snippet': { 5781 // `code` 5782 // ``code`` 5783 pattern: /(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/, 5784 lookbehind: true, 5785 greedy: true, 5786 alias: ['code', 'keyword'] 5787 }, 5788 'url': { 5789 // [example](http://example.com "Optional title") 5790 // [example][id] 5791 // [example] [id] 5792 pattern: createInline(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source), 5793 lookbehind: true, 5794 greedy: true, 5795 inside: { 5796 'operator': /^!/, 5797 'content': { 5798 pattern: /(^\[)[^\]]+(?=\])/, 5799 lookbehind: true, 5800 inside: {} // see below 5801 }, 5802 'variable': { 5803 pattern: /(^\][ \t]?\[)[^\]]+(?=\]$)/, 5804 lookbehind: true 5805 }, 5806 'url': { 5807 pattern: /(^\]\()[^\s)]+/, 5808 lookbehind: true 5809 }, 5810 'string': { 5811 pattern: /(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/, 5812 lookbehind: true 5813 } 5814 } 5815 } 5816 }); 5817 5818 ['url', 'bold', 'italic', 'strike'].forEach(function (token) { 5819 ['url', 'bold', 'italic', 'strike', 'code-snippet'].forEach(function (inside) { 5820 if (token !== inside) { 5821 Prism.languages.markdown[token].inside.content.inside[inside] = Prism.languages.markdown[inside]; 5822 } 5823 }); 5824 }); 5825 5826 Prism.hooks.add('after-tokenize', function (env) { 5827 if (env.language !== 'markdown' && env.language !== 'md') { 5828 return; 5829 } 5830 5831 function walkTokens(tokens) { 5832 if (!tokens || typeof tokens === 'string') { 5833 return; 5834 } 5835 5836 for (var i = 0, l = tokens.length; i < l; i++) { 5837 var token = tokens[i]; 5838 5839 if (token.type !== 'code') { 5840 walkTokens(token.content); 5841 continue; 5842 } 5843 5844 /* 5845 * Add the correct `language-xxxx` class to this code block. Keep in mind that the `code-language` token 5846 * is optional. But the grammar is defined so that there is only one case we have to handle: 5847 * 5848 * token.content = [ 5849 * <span class="punctuation">```</span>, 5850 * <span class="code-language">xxxx</span>, 5851 * '\n', // exactly one new lines (\r or \n or \r\n) 5852 * <span class="code-block">...</span>, 5853 * '\n', // exactly one new lines again 5854 * <span class="punctuation">```</span> 5855 * ]; 5856 */ 5857 5858 var codeLang = token.content[1]; 5859 var codeBlock = token.content[3]; 5860 5861 if (codeLang && codeBlock && 5862 codeLang.type === 'code-language' && codeBlock.type === 'code-block' && 5863 typeof codeLang.content === 'string') { 5864 5865 // this might be a language that Prism does not support 5866
5867 // do some replacements to support C++, C#, and F# 5868 var lang = codeLang.content.replace(/\b#/g, 'sharp').replace(/\b\+\+/g, 'pp'); 5869 // only use the first word 5870 lang = (/[a-z][\w-]*/i.exec(lang) || [''])[0].toLowerCase(); 5871 var alias = 'language-' + lang; 5872 5873 // add alias 5874 if (!codeBlock.alias) { 5875 codeBlock.alias = [alias]; 5876 } else if (typeof codeBlock.alias === 'string') { 5877 codeBlock.alias = [codeBlock.alias, alias]; 5878 } else { 5879 codeBlock.alias.push(alias); 5880 } 5881 } 5882 } 5883 } 5884 5885 walkTokens(env.tokens); 5886 }); 5887 5888 Prism.hooks.add('wrap', function (env) { 5889 if (env.type !== 'code-block') { 5890 return; 5891 } 5892 5893 var codeLang = ''; 5894 for (var i = 0, l = env.classes.length; i < l; i++) { 5895 var cls = env.classes[i]; 5896 var match = /language-(.+)/.exec(cls); 5897 if (match) { 5898 codeLang = match[1]; 5899 break; 5900 } 5901 } 5902 5903 var grammar = Prism.languages[codeLang]; 5904 5905 if (!grammar) { 5906 if (codeLang && codeLang !== 'none' && Prism.plugins.autoloader) { 5907 var id = 'md-' + new Date().valueOf() + '-' + Math.floor(Math.random() * 1e16); 5908 env.attributes['id'] = id; 5909 5910 Prism.plugins.autoloader.loadLanguages(codeLang, function () { 5911 var ele = document.getElementById(id); 5912 if (ele) { 5913 ele.innerHTML = Prism.highlight(ele.textContent, Prism.languages[codeLang], codeLang); 5914 } 5915 }); 5916 } 5917 } else { 5918 env.content = Prism.highlight(textContent(env.content), grammar, codeLang); 5919 } 5920 }); 5921 5922 var tagPattern = RegExp(Prism.languages.markup.tag.pattern.source, 'gi'); 5923 5924 /** 5925 * A list of known entity names. 5926 * 5927 * This will always be incomplete to save space. The current list is the one used by lowdash's unescape function. 5928 * 5929 * @see {@link https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/unescape.js#L2} 5930 */ 5931 var KNOWN_ENTITY_NAMES = { 5932 'amp': '&', 5933 'lt': '<', 5934 'gt': '>', 5935 'quot': '"', 5936 }; 5937 5938 // IE 11 doesn't support `String.fromCodePoint` 5939 var fromCodePoint = String.fromCodePoint || String.fromCharCode; 5940 5941 /** 5942 * Returns the text content of a given HTML source code string. 5943 * 5944 * @param {string} html 5945 * @returns {string} 5946 */ 5947 function textContent(html) { 5948 // remove all tags 5949 var text = html.replace(tagPattern, ''); 5950 5951 // decode known entities 5952 text = text.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi, function (m, code) { 5953 code = code.toLowerCase(); 5954 5955 if (code[0] === '#') { 5956 var value; 5957 if (code[1] === 'x') { 5958 value = parseInt(code.slice(2), 16); 5959 } else { 5960 value = Number(code.slice(1)); 5961 } 5962 5963 return fromCodePoint(value); 5964 } else { 5965 var known = KNOWN_ENTITY_NAMES[code]; 5966 if (known) { 5967 return known; 5968 } 5969 5970 // unable to decode 5971 return m; 5972 } 5973 }); 5974 5975 return text; 5976 } 5977 5978 Prism.languages.md = Prism.languages.markdown; 5979 5980}(Prism$1)); 5981 5982Prism$1.languages.c = Prism$1.languages.extend('clike', { 5983 'comment': { 5984 pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/, 5985 greedy: true 5986 }, 5987 'string': { 5988 // https://en.cppreference.com/w/c/language/string_literal 5989 pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/, 5990 greedy: true 5991 }, 5992 'class-name': { 5993 pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/, 5994 lookbehind: true 5995 }, 5996 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/, 5997 'function': /\b[a-z_]\w*(?=\s*\()/i, 5998 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i, 5999 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/ 6000}); 6001 6002Prism$1.languages.insertBefore('c', 'string', { 6003 'char': { 6004 // https://en.cppreference.com/w/c/language/character_constant 6005 pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/, 6006 greedy: true 6007 } 6008}); 6009 6010Prism$1.languages.insertBefore('c', 'string', { 6011 'macro': { 6012 // allow for multiline macro definitions 6013 // spaces after the # character compile fine with gcc 6014 pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im, 6015 lookbehind: true, 6016 greedy: true, 6017 alias: 'property', 6018 inside: { 6019 'string': [ 6020 { 6021 // highlight the path of the include statement as a string 6022 pattern: /^(#\s*include\s*)<[^>]+>/, 6023 lookbehind: true 6024 }, 6025 Prism$1.languages.c['string'] 6026 ], 6027 'char': Prism$1.languages.c['char'], 6028 'comment': Prism$1.languages.c['comment'], 6029 'macro-name': [ 6030 { 6031 pattern: /(^#\s*define\s+)\w+\b(?!\()/i, 6032 lookbehind: true 6033 }, 6034 { 6035 pattern: /(^#\s*define\s+)\w+\b(?=\()/i, 6036 lookbehind: true,
6037 alias: 'function' 6038 } 6039 ], 6040 // highlight macro directives as keywords 6041 'directive': { 6042 pattern: /^(#\s*)[a-z]+/, 6043 lookbehind: true, 6044 alias: 'keyword' 6045 }, 6046 'directive-hash': /^#/, 6047 'punctuation': /##|\\(?=[\r\n])/, 6048 'expression': { 6049 pattern: /\S[\s\S]*/, 6050 inside: Prism$1.languages.c 6051 } 6052 } 6053 } 6054}); 6055 6056Prism$1.languages.insertBefore('c', 'function', { 6057 // highlight predefined macros as constants 6058 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/ 6059}); 6060 6061delete Prism$1.languages.c['boolean']; 6062 6063(function (Prism) { 6064 6065 var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/; 6066 6067 Prism.languages.css = { 6068 'comment': /\/\*[\s\S]*?\*\//, 6069 'atrule': { 6070 pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source), 6071 inside: { 6072 'rule': /^@[\w-]+/, 6073 'selector-function-argument': { 6074 pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/, 6075 lookbehind: true, 6076 alias: 'selector' 6077 }, 6078 'keyword': { 6079 pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/, 6080 lookbehind: true 6081 } 6082 // See rest below 6083 } 6084 }, 6085 'url': { 6086 // https://drafts.csswg.org/css-values-3/#urls 6087 pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'), 6088 greedy: true, 6089 inside: { 6090 'function': /^url/i, 6091 'punctuation': /^\(|\)$/, 6092 'string': { 6093 pattern: RegExp('^' + string.source + '$'), 6094 alias: 'url' 6095 } 6096 } 6097 }, 6098 'selector': { 6099 pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'), 6100 lookbehind: true 6101 }, 6102 'string': { 6103 pattern: string, 6104 greedy: true 6105 }, 6106 'property': { 6107 pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i, 6108 lookbehind: true 6109 }, 6110 'important': /!important\b/i, 6111 'function': { 6112 pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i, 6113 lookbehind: true 6114 }, 6115 'punctuation': /[(){};:,]/ 6116 }; 6117 6118 Prism.languages.css['atrule'].inside.rest = Prism.languages.css; 6119 6120 var markup = Prism.languages.markup; 6121 if (markup) { 6122 markup.tag.addInlined('style', 'css'); 6123 markup.tag.addAttribute('style', 'css'); 6124 } 6125 6126}(Prism$1)); 6127 6128Prism$1.languages.objectivec = Prism$1.languages.extend('c', { 6129 'string': { 6130 pattern: /@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/, 6131 greedy: true 6132 }, 6133 'keyword': /\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/, 6134 'operator': /-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/ 6135}); 6136 6137delete Prism$1.languages.objectivec['class-name']; 6138 6139Prism$1.languages.objc = Prism$1.languages.objectivec; 6140 6141Prism$1.languages.sql = { 6142 'comment': { 6143 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/, 6144 lookbehind: true 6145 }, 6146 'variable': [ 6147 { 6148 pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/, 6149 greedy: true 6150 }, 6151 /@[\w.$]+/ 6152 ], 6153 'string': { 6154 pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/, 6155 greedy: true, 6156 lookbehind: true 6157 }, 6158 'identifier': { 6159 pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/, 6160 greedy: true, 6161 lookbehind: true, 6162 inside: { 6163 'punctuation': /^`|`$/ 6164 } 6165 }, 6166 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, // Should we highlight user defined functions too? 6167 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECI
6167MAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i, 6168 'boolean': /\b(?:FALSE|NULL|TRUE)\b/i, 6169 'number': /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i, 6170 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i, 6171 'punctuation': /[;[\]()`,.]/ 6172}; 6173 6174(function (Prism) { 6175 6176 var powershell = Prism.languages.powershell = { 6177 'comment': [ 6178 { 6179 pattern: /(^|[^`])<#[\s\S]*?#>/, 6180 lookbehind: true 6181 }, 6182 { 6183 pattern: /(^|[^`])#.*/, 6184 lookbehind: true 6185 } 6186 ], 6187 'string': [ 6188 { 6189 pattern: /"(?:`[\s\S]|[^`"])*"/, 6190 greedy: true, 6191 inside: null // see below 6192 }, 6193 { 6194 pattern: /'(?:[^']|'')*'/, 6195 greedy: true 6196 } 6197 ], 6198 // Matches name spaces as well as casts, attribute decorators. Force starting with letter to avoid matching array indices 6199 // Supports two levels of nested brackets (e.g. `[OutputType([System.Collections.Generic.List[int]])]`) 6200 'namespace': /\[[a-z](?:\[(?:\[[^\]]*\]|[^\[\]])*\]|[^\[\]])*\]/i, 6201 'boolean': /\$(?:false|true)\b/i, 6202 'variable': /\$\w+\b/, 6203 // Cmdlets and aliases. Aliases should come last, otherwise "write" gets preferred over "write-host" for example 6204 // Get-Command | ?{ $_.ModuleName -match "Microsoft.PowerShell.(Util|Core|Management)" } 6205 // Get-Alias | ?{ $_.ReferencedCommand.Module.Name -match "Microsoft.PowerShell.(Util|Core|Management)" } 6206 'function': [ 6207 /\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i,
6208 /\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i 6209 ], 6210 // per http://technet.microsoft.com/en-us/library/hh847744.aspx 6211 'keyword': /\b(?:Begin|Break|Catch|Class|Continue|Data|Define|Do|DynamicParam|Else|ElseIf|End|Exit|Filter|Finally|For|ForEach|From|Function|If|InlineScript|Parallel|Param|Process|Return|Sequence|Switch|Throw|Trap|Try|Until|Using|Var|While|Workflow)\b/i, 6212 'operator': { 6213 pattern: /(^|\W)(?:!|-(?:b?(?:and|x?or)|as|(?:Not)?(?:Contains|In|Like|Match)|eq|ge|gt|is(?:Not)?|Join|le|lt|ne|not|Replace|sh[lr])\b|-[-=]?|\+[+=]?|[*\/%]=?)/i, 6214 lookbehind: true 6215 }, 6216 'punctuation': /[|{}[\];(),.]/ 6217 }; 6218 6219 // Variable interpolation inside strings, and nested expressions 6220 powershell.string[0].inside = { 6221 'function': { 6222 // Allow for one level of nesting 6223 pattern: /(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/, 6224 lookbehind: true, 6225 inside: powershell 6226 }, 6227 'boolean': powershell.boolean, 6228 'variable': powershell.variable, 6229 }; 6230 6231}(Prism$1)); 6232 6233var prismPython = {}; 6234 6235var hasRequiredPrismPython; 6236 6237function requirePrismPython () { 6238 if (hasRequiredPrismPython) return prismPython; 6239 hasRequiredPrismPython = 1; 6240 Prism$1.languages.python = { 6241 'comment': { 6242 pattern: /(^|[^\\])#.*/, 6243 lookbehind: true, 6244 greedy: true 6245 }, 6246 'string-interpolation': { 6247 pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i, 6248 greedy: true, 6249 inside: { 6250 'interpolation': { 6251 // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}" 6252 pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/, 6253 lookbehind: true, 6254 inside: { 6255 'format-spec': { 6256 pattern: /(:)[^:(){}]+(?=\}$)/, 6257 lookbehind: true 6258 }, 6259 'conversion-option': { 6260 pattern: //, 6261 alias: 'punctuation' 6262 }, 6263 rest: null 6264 } 6265 }, 6266 'string': /[\s\S]+/ 6267 } 6268 }, 6269 'triple-quoted-string': { 6270 pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i, 6271 greedy: true, 6272 alias: 'string' 6273 }, 6274 'string': { 6275 pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i, 6276 greedy: true 6277 }, 6278 'function': { 6279 pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g, 6280 lookbehind: true 6281 }, 6282 'class-name': { 6283 pattern: /(\bclass\s+)\w+/i, 6284 lookbehind: true 6285 }, 6286 'decorator': { 6287 pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m, 6288 lookbehind: true, 6289 alias: ['annotation', 'punctuation'], 6290 inside: { 6291 'punctuation': /\./ 6292 } 6293 }, 6294 'keyword': /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/, 6295 'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/, 6296 'boolean': /\b(?:False|None|True)\b/, 6297 'number': /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i, 6298 'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/, 6299 'punctuation': /[{}[\];(),.:]/ 6300 }; 6301 6302 Prism$1.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism$1.languages.python; 6303 6304 Prism$1.languages.py = Prism$1.languages.python; 6305 return prismPython; 6306} 6307 6308requirePrismPython(); 6309 6310var prismRust = {}; 6311 6312var hasRequiredPrismRust; 6313 6314function requirePrismRust () { 6315 if (hasRequiredPrismRust) return prismRust; 6316 hasRequiredPrismRust = 1; 6317 (function (Prism) { 6318 6319 var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source; 6320 for (var i = 0; i < 2; i++) { 6321 // support 4 levels of nested comments 6322 multilineComment = multilineComment.replace(/<self>/g, function () { return multilineComment; }); 6323 } 6324 multilineComment = multilineComment.replace(/<self>/g, function () { return /[^\s\S]/.source; }); 6325 6326 6327 Prism.languages.rust = { 6328 'comment': [ 6329 { 6330 pattern: RegExp(/(^|[^\\])/.source + multilineComment), 6331 lookbehind: true, 6332 greedy: true 6333 }, 6334 { 6335 pattern: /(^|[^\\:])\/\/.*/, 6336 lookbehind: true, 6337 greedy: true 6338 } 6339 ], 6340 'string': {
6341 pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/, 6342 greedy: true 6343 }, 6344 'char': { 6345 pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/, 6346 greedy: true 6347 }, 6348 'attribute': { 6349 pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/, 6350 greedy: true, 6351 alias: 'attr-name', 6352 inside: { 6353 'string': null // see below 6354 } 6355 }, 6356 6357 // Closure params should not be confused with bitwise OR | 6358 'closure-params': { 6359 pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/, 6360 lookbehind: true, 6361 greedy: true, 6362 inside: { 6363 'closure-punctuation': { 6364 pattern: /^\||\|$/, 6365 alias: 'punctuation' 6366 }, 6367 rest: null // see below 6368 } 6369 }, 6370 6371 'lifetime-annotation': { 6372 pattern: /'\w+/, 6373 alias: 'symbol' 6374 }, 6375 6376 'fragment-specifier': { 6377 pattern: /(\$\w+:)[a-z]+/, 6378 lookbehind: true, 6379 alias: 'punctuation' 6380 }, 6381 'variable': /\$\w+/, 6382 6383 'function-definition': { 6384 pattern: /(\bfn\s+)\w+/, 6385 lookbehind: true, 6386 alias: 'function' 6387 }, 6388 'type-definition': { 6389 pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/, 6390 lookbehind: true, 6391 alias: 'class-name' 6392 }, 6393 'module-declaration': [ 6394 { 6395 pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/, 6396 lookbehind: true, 6397 alias: 'namespace' 6398 }, 6399 { 6400 pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/, 6401 lookbehind: true, 6402 alias: 'namespace', 6403 inside: { 6404 'punctuation': /::/ 6405 } 6406 } 6407 ], 6408 'keyword': [ 6409 // https://github.com/rust-lang/reference/blob/master/src/keywords.md 6410 /\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/, 6411 // primitives and str 6412 // https://doc.rust-lang.org/stable/rust-by-example/primitives.html 6413 /\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/ 6414 ], 6415 6416 // functions can technically start with an upper-case letter, but this will introduce a lot of false positives 6417 // and Rust's naming conventions recommend snake_case anyway. 6418 // https://doc.rust-lang.org/1.0.0/style/style/naming/README.html 6419 'function': /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/, 6420 'macro': { 6421 pattern: /\b\w+!/, 6422 alias: 'property' 6423 }, 6424 'constant': /\b[A-Z_][A-Z_\d]+\b/, 6425 'class-name': /\b[A-Z]\w*\b/, 6426 6427 'namespace': { 6428 pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/, 6429 inside: { 6430 'punctuation': /::/ 6431 } 6432 }, 6433 6434 // Hex, oct, bin, dec numbers with visual separators and type suffix 6435 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/, 6436 'boolean': /\b(?:false|true)\b/, 6437 'punctuation': /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/, 6438 'operator': /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/ 6439 }; 6440 6441 Prism.languages.rust['closure-params'].inside.rest = Prism.languages.rust; 6442 Prism.languages.rust['attribute'].inside['string'] = Prism.languages.rust['string']; 6443 6444 }(Prism$1)); 6445 return prismRust; 6446} 6447 6448requirePrismRust(); 6449 6450Prism$1.languages.swift = { 6451 'comment': { 6452 // Nested comments are supported up to 2 levels 6453 pattern: /(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/, 6454 lookbehind: true, 6455 greedy: true 6456 }, 6457 'string-literal': [ 6458 // https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html 6459 { 6460 pattern: RegExp( 6461 /(^|[^"#])/.source 6462 + '(?:' 6463 // single-line string
6464 + /"(?:\\(?:\((?:[^()]|\([^()]*\))*\)|\r\n|[^(])|[^\\\r\n"])*"/.source 6465 + '|' 6466 // multi-line string 6467 + /"""(?:\\(?:\((?:[^()]|\([^()]*\))*\)|[^(])|[^\\"]|"(?!""))*"""/.source 6468 + ')' 6469 + /(?!["#])/.source 6470 ), 6471 lookbehind: true, 6472 greedy: true, 6473 inside: { 6474 'interpolation': { 6475 pattern: /(\\\()(?:[^()]|\([^()]*\))*(?=\))/, 6476 lookbehind: true, 6477 inside: null // see below 6478 }, 6479 'interpolation-punctuation': { 6480 pattern: /^\)|\\\($/, 6481 alias: 'punctuation' 6482 }, 6483 'punctuation': /\\(?=[\r\n])/, 6484 'string': /[\s\S]+/ 6485 } 6486 }, 6487 { 6488 pattern: RegExp( 6489 /(^|[^"#])(#+)/.source 6490 + '(?:' 6491 // single-line string 6492 + /"(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|\r\n|[^#])|[^\\\r\n])*?"/.source 6493 + '|' 6494 // multi-line string 6495 + /"""(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|[^#])|[^\\])*?"""/.source 6496 + ')' 6497 + '\\2' 6498 ), 6499 lookbehind: true, 6500 greedy: true, 6501 inside: { 6502 'interpolation': { 6503 pattern: /(\\#+\()(?:[^()]|\([^()]*\))*(?=\))/, 6504 lookbehind: true, 6505 inside: null // see below 6506 }, 6507 'interpolation-punctuation': { 6508 pattern: /^\)|\\#+\($/, 6509 alias: 'punctuation' 6510 }, 6511 'string': /[\s\S]+/ 6512 } 6513 }, 6514 ], 6515 6516 'directive': { 6517 // directives with conditions 6518 pattern: RegExp( 6519 /#/.source 6520 + '(?:' 6521 + ( 6522 /(?:elseif|if)\b/.source 6523 + '(?:[ \t]*' 6524 // This regex is a little complex. It's equivalent to this: 6525 // (?:![ \t]*)?(?:\b\w+\b(?:[ \t]*<round>)?|<round>)(?:[ \t]*(?:&&|\|\|))? 6526 // where <round> is a general parentheses expression. 6527 + /(?:![ \t]*)?(?:\b\w+\b(?:[ \t]*\((?:[^()]|\([^()]*\))*\))?|\((?:[^()]|\([^()]*\))*\))(?:[ \t]*(?:&&|\|\|))?/.source 6528 + ')+' 6529 ) 6530 + '|' 6531 + /(?:else|endif)\b/.source 6532 + ')' 6533 ), 6534 alias: 'property', 6535 inside: { 6536 'directive-name': /^#\w+/, 6537 'boolean': /\b(?:false|true)\b/, 6538 'number': /\b\d+(?:\.\d+)*\b/, 6539 'operator': /!|&&|\|\||[<>]=?/, 6540 'punctuation': /[(),]/ 6541 } 6542 }, 6543 'literal': { 6544 pattern: /#(?:colorLiteral|column|dsohandle|file(?:ID|Literal|Path)?|function|imageLiteral|line)\b/, 6545 alias: 'constant' 6546 }, 6547 'other-directive': { 6548 pattern: /#\w+\b/, 6549 alias: 'property' 6550 }, 6551 6552 'attribute': { 6553 pattern: /@\w+/, 6554 alias: 'atrule' 6555 }, 6556 6557 'function-definition': { 6558 pattern: /(\bfunc\s+)\w+/, 6559 lookbehind: true, 6560 alias: 'function' 6561 }, 6562 'label': { 6563 // https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID141 6564 pattern: /\b(break|continue)\s+\w+|\b[a-zA-Z_]\w*(?=\s*:\s*(?:for|repeat|while)\b)/, 6565 lookbehind: true, 6566 alias: 'important' 6567 }, 6568 6569 'keyword': /\b(?:Any|Protocol|Self|Type|actor|as|assignment|associatedtype|associativity|async|await|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|higherThan|if|import|in|indirect|infix|init|inout|internal|is|isolated|lazy|left|let|lowerThan|mutating|none|nonisolated|nonmutating|open|operator|optional|override|postfix|precedencegroup|prefix|private|protocol|public|repeat|required|rethrows|return|right|safe|self|set|some|static|struct|subscript|super|switch|throw|throws|try|typealias|unowned|unsafe|var|weak|where|while|willSet)\b/, 6570 'boolean': /\b(?:false|true)\b/, 6571 'nil': { 6572 pattern: /\bnil\b/, 6573 alias: 'constant' 6574 }, 6575 6576 'short-argument': /\$\d+\b/, 6577 'omit': { 6578 pattern: /\b_\b/, 6579 alias: 'keyword' 6580 }, 6581 'number': /\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i, 6582 6583 // A class name must start with an upper-case letter and be either 1 letter long or contain a lower-case letter. 6584 'class-name': /\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/, 6585 'function': /\b[a-z_]\w*(?=\s*\()/i, 6586 'constant': /\b(?:[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/, 6587 6588 // Operators are generic in Swift. Developers can even create new operators (e.g. +++). 6589 // https://docs.swift.org/swift-book/ReferenceManual/zzSummaryOfTheGrammar.html#ID481 6590 // This regex only supports ASCII operators. 6591 'operator': /[-+*/%=!<>&|^~?]+|\.[.\-+*/%=!<>&|^~?]+/, 6592 'punctuation': /[{}[\]();,.:\\]/ 6593}; 6594 6595Prism$1.languages.swift['string-literal'].forEach(function (rule) {
6596 rule.inside['interpolation'].inside = Prism$1.languages.swift; 6597}); 6598 6599var prismTypescript = {}; 6600 6601var hasRequiredPrismTypescript; 6602 6603function requirePrismTypescript () { 6604 if (hasRequiredPrismTypescript) return prismTypescript; 6605 hasRequiredPrismTypescript = 1; 6606 (function (Prism) { 6607 6608 Prism.languages.typescript = Prism.languages.extend('javascript', { 6609 'class-name': { 6610 pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/, 6611 lookbehind: true, 6612 greedy: true, 6613 inside: null // see below 6614 }, 6615 'builtin': /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/, 6616 }); 6617 6618 // The keywords TypeScript adds to JavaScript 6619 Prism.languages.typescript.keyword.push( 6620 /\b(?:abstract|declare|is|keyof|readonly|require)\b/, 6621 // keywords that have to be followed by an identifier 6622 /\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/, 6623 // This is for `import type *, {}` 6624 /\btype\b(?=\s*(?:[\{*]|$))/ 6625 ); 6626 6627 // doesn't work with TS because TS is too complex 6628 delete Prism.languages.typescript['parameter']; 6629 delete Prism.languages.typescript['literal-property']; 6630 6631 // a version of typescript specifically for highlighting types 6632 var typeInside = Prism.languages.extend('typescript', {}); 6633 delete typeInside['class-name']; 6634 6635 Prism.languages.typescript['class-name'].inside = typeInside; 6636 6637 Prism.languages.insertBefore('typescript', 'function', { 6638 'decorator': { 6639 pattern: /@[$\w\xA0-\uFFFF]+/, 6640 inside: { 6641 'at': { 6642 pattern: /^@/, 6643 alias: 'operator' 6644 }, 6645 'function': /^[\s\S]+/ 6646 } 6647 }, 6648 'generic-function': { 6649 // e.g. foo<T extends "bar" | "baz">( ... 6650 pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/, 6651 greedy: true, 6652 inside: { 6653 'function': /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/, 6654 'generic': { 6655 pattern: /<[\s\S]+/, // everything after the first < 6656 alias: 'class-name', 6657 inside: typeInside 6658 } 6659 } 6660 } 6661 }); 6662 6663 Prism.languages.ts = Prism.languages.typescript; 6664 6665 }(Prism$1)); 6666 return prismTypescript; 6667} 6668 6669requirePrismTypescript(); 6670 6671var prismJava = {}; 6672 6673var hasRequiredPrismJava; 6674 6675function requirePrismJava () { 6676 if (hasRequiredPrismJava) return prismJava; 6677 hasRequiredPrismJava = 1; 6678 (function (Prism) { 6679 6680 var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/; 6681 6682 // full package (optional) + parent classes (optional) 6683 var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source; 6684 6685 // based on the java naming conventions 6686 var className = { 6687 pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source), 6688 lookbehind: true, 6689 inside: { 6690 'namespace': { 6691 pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/, 6692 inside: { 6693 'punctuation': /\./ 6694 } 6695 }, 6696 'punctuation': /\./ 6697 } 6698 }; 6699 6700 Prism.languages.java = Prism.languages.extend('clike', { 6701 'string': { 6702 pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/, 6703 lookbehind: true, 6704 greedy: true 6705 }, 6706 'class-name': [ 6707 className, 6708 { 6709 // variables, parameters, and constructor references 6710 // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods) 6711 pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source), 6712 lookbehind: true, 6713 inside: className.inside 6714 }, 6715 {
6716 // class names based on keyword 6717 // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods) 6718 pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source), 6719 lookbehind: true, 6720 inside: className.inside 6721 } 6722 ], 6723 'keyword': keywords, 6724 'function': [ 6725 Prism.languages.clike.function, 6726 { 6727 pattern: /(::\s*)[a-z_]\w*/, 6728 lookbehind: true 6729 } 6730 ], 6731 'number': /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i, 6732 'operator': { 6733 pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m, 6734 lookbehind: true 6735 }, 6736 'constant': /\b[A-Z][A-Z_\d]+\b/ 6737 }); 6738 6739 Prism.languages.insertBefore('java', 'string', { 6740 'triple-quoted-string': { 6741 // http://openjdk.java.net/jeps/355#Description 6742 pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/, 6743 greedy: true, 6744 alias: 'string' 6745 }, 6746 'char': { 6747 pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/, 6748 greedy: true 6749 } 6750 }); 6751 6752 Prism.languages.insertBefore('java', 'class-name', { 6753 'annotation': { 6754 pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/, 6755 lookbehind: true, 6756 alias: 'punctuation' 6757 }, 6758 'generics': { 6759 pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/, 6760 inside: { 6761 'class-name': className, 6762 'keyword': keywords, 6763 'punctuation': /[<>(),.:]/, 6764 'operator': /[?&|]/ 6765 } 6766 }, 6767 'import': [ 6768 { 6769 pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source), 6770 lookbehind: true, 6771 inside: { 6772 'namespace': className.inside.namespace, 6773 'punctuation': /\./, 6774 'operator': /\*/, 6775 'class-name': /\w+/ 6776 } 6777 }, 6778 { 6779 pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source), 6780 lookbehind: true, 6781 alias: 'static', 6782 inside: { 6783 'namespace': className.inside.namespace, 6784 'static': /\b\w+$/, 6785 'punctuation': /\./, 6786 'operator': /\*/, 6787 'class-name': /\w+/ 6788 } 6789 } 6790 ], 6791 'namespace': { 6792 pattern: RegExp( 6793 /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/ 6794 .source.replace(/<keyword>/g, function () { return keywords.source; })), 6795 lookbehind: true, 6796 inside: { 6797 'punctuation': /\./, 6798 } 6799 } 6800 }); 6801 }(Prism$1)); 6802 return prismJava; 6803} 6804 6805requirePrismJava(); 6806 6807var prismCpp = {}; 6808 6809var hasRequiredPrismCpp; 6810 6811function requirePrismCpp () { 6812 if (hasRequiredPrismCpp) return prismCpp; 6813 hasRequiredPrismCpp = 1; 6814 (function (Prism) { 6815 6816 var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/; 6817 var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () { return keyword.source; }); 6818 6819 Prism.languages.cpp = Prism.languages.extend('c', { 6820 'class-name': [ 6821 { 6822 pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source 6823 .replace(/<keyword>/g, function () { return keyword.source; })), 6824 lookbehind: true 6825 }, 6826 // This is intended to capture the class name of method implementations like: 6827 // void foo::bar() const {} 6828 // However! The `foo` in the above example could also be a namespace, so we only capture the class name if 6829 // it starts with an uppercase letter. This approximation should give decent results.
6830 /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/, 6831 // This will capture the class name before destructors like: 6832 // Foo::~Foo() {} 6833 /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i, 6834 // This also intends to capture the class name of method implementations but here the class has template 6835 // parameters, so it can't be a namespace (until C++ adds generic namespaces). 6836 /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/ 6837 ], 6838 'keyword': keyword, 6839 'number': { 6840 pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i, 6841 greedy: true 6842 }, 6843 'operator': />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/, 6844 'boolean': /\b(?:false|true)\b/ 6845 }); 6846 6847 Prism.languages.insertBefore('cpp', 'string', { 6848 'module': { 6849 // https://en.cppreference.com/w/cpp/language/modules 6850 pattern: RegExp( 6851 /(\b(?:import|module)\s+)/.source + 6852 '(?:' + 6853 // header-name 6854 /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source + 6855 '|' + 6856 // module name or partition or both 6857 /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function () { return modName; }) + 6858 ')' 6859 ), 6860 lookbehind: true, 6861 greedy: true, 6862 inside: { 6863 'string': /^[<"][\s\S]+/, 6864 'operator': /:/, 6865 'punctuation': /\./ 6866 } 6867 }, 6868 'raw-string': { 6869 pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/, 6870 alias: 'string', 6871 greedy: true 6872 } 6873 }); 6874 6875 Prism.languages.insertBefore('cpp', 'keyword', { 6876 'generic-function': { 6877 pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i, 6878 inside: { 6879 'function': /^\w+/, 6880 'generic': { 6881 pattern: /<[\s\S]+/, 6882 alias: 'class-name', 6883 inside: Prism.languages.cpp 6884 } 6885 } 6886 } 6887 }); 6888 6889 Prism.languages.insertBefore('cpp', 'operator', { 6890 'double-colon': { 6891 pattern: /::/, 6892 alias: 'punctuation' 6893 } 6894 }); 6895 6896 Prism.languages.insertBefore('cpp', 'class-name', { 6897 // the base clause is an optional list of parent classes 6898 // https://en.cppreference.com/w/cpp/language/class 6899 'base-clause': { 6900 pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/, 6901 lookbehind: true, 6902 greedy: true, 6903 inside: Prism.languages.extend('cpp', {}) 6904 } 6905 }); 6906 6907 Prism.languages.insertBefore('inside', 'double-colon', { 6908 // All untokenized words that are not namespaces should be class names 6909 'class-name': /\b[a-z_]\w*\b(?!\s*::)/i 6910 }, Prism.languages.cpp['base-clause']); 6911 6912 }(Prism$1)); 6913 return prismCpp; 6914} 6915 6916requirePrismCpp(); 6917 6918/** 6919 * Copyright (c) Meta Platforms, Inc. and affiliates. 6920 * 6921 * This source code is licensed under the MIT license found in the 6922 * LICENSE file in the root directory of this source tree. 6923 * 6924 */ 6925 6926function I$1(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const M$1="javascript";function R(e,n){for(const r of e.childNodes){if(Cs(r)&&r.tagName===n)return true;R(r,n);}return false}const K$1="data-language",$$1="data-highlight-language",W$2="data-theme";let q$1 = class q extends Ci{__language;__theme;__isSyntaxHighlightSupported;static getType(){return "code"}static clone(t){return new q(t.__language,t.__key)}constructor(t,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=false,this.__theme=void 0;}afterCloneFrom(t){super.afterCloneFrom(t),this.__language=t.__language,this.__theme=t.__theme,this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported;}createDOM(t){const n=document.createElement("code");lt$4(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(K$1,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute($$1,r));const i=this.getTheme();i&&n.setAttribute(W$2,i);const o=this.getStyle();return o&&n.setAttribute("style",o),n}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(K$1,r):i&&e.removeAttribute(K$1);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute($$1,r):e.removeAttribute($$1):o&&r&&e.setAttribute($$1,r);const s=this.__theme,l=t.__theme;s?s!==l&&e.setAttribute(W$2,s):l&&e.removeAttribute(W$2);const u=this.__style,c=t.__style;return u?u!==c&&e.setAttribute("style",u):c&&e.removeAttribute("style"),false}exportDOM(t){const n=document.createElement("pre");
6926lt$4(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(K$1,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute($$1,r));const i=this.getTheme();i&&n.setAttribute(W$2,i);const o=this.getStyle();return o&&n.setAttribute("style",o),{element:n}}static importDOM(){return {code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||R(t,"BR"))?{conversion:Q$1,priority:1}:null,div:()=>({conversion:G$1,priority:1}),pre:()=>({conversion:Q$1,priority:0}),table:t=>tt$1(t)?{conversion:V$2,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&tt$1(n)?{conversion:Y,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&tt$1(e)?{conversion:Y,priority:3}:null}}}static importJSON(t){return U$2().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setLanguage(t.language).setTheme(t.theme)}exportJSON(){return {...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(t,e=true){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const t=Li();return this.insertAfter(t,e),t}const{anchor:i,focus:o}=t,a=(i.isBefore(o)?i:o).getNode();if(lr(a)){let t=st$1(a);const e=[];for(;;)if(fr(t))e.push(ur()),t=t.getNextSibling();else {if(!it$2(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(rt(" ".repeat(n))),n!==i)break;t=t.getNextSibling();}}const n=a.splitText(i.offset)[0],r=0===i.offset?0:1,o=n.getIndexWithinParent()+r,s=a.getParentOrThrow(),l=[Jn(),...e];s.splice(o,0,l);const f=e[e.length-1];f?f.select():0===i.offset?n.selectPrevious():n.getNextSibling().selectNext(0,0);}if(X$1(a)){const{offset:e}=t.anchor;a.splice(e,0,[Jn()]),a.select(e+1,e+1);}return null}canIndent(){return false}collapseAtStart(){const t=Li();
6926return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}setLanguage(t){const e=this.getWritable();return e.__language=t||void 0,e}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(t){const e=this.getWritable();return e.__isSyntaxHighlightSupported=t,e}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(t){const e=this.getWritable();return e.__theme=t||void 0,e}getTheme(){return this.getLatest().__theme}};function U$2(t,e){return Ks(q$1).setLanguage(t).setTheme(e)}function X$1(t){return t instanceof q$1}function Q$1(t){return {node:U$2(t.getAttribute(K$1))}}function G$1(t){const e=t,n=Z(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(Z(e))return true;e=e.parentElement;}return false}(e)?{node:n?U$2():null}:{node:null}}function V$2(){return {node:U$2()}}function Y(){return {node:null}}function Z(t){return null!==t.style.fontFamily.match("monospace")}function tt$1(t){return t.classList.contains("js-file-line-container")}let et$1 = class et extends Xn{__highlightType;constructor(t="",e,n){super(t,n),this.__highlightType=e;}static getType(){return "code-highlight"}static clone(t){return new et(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return false}createDOM(t){const n=super.createDOM(t),r=nt$1(t.theme,this.__highlightType);return lt$4(n,r),n}updateDOM(t,r,i){const o=super.updateDOM(t,r,i),s=nt$1(i.theme,t.__highlightType),l=nt$1(i.theme,this.__highlightType);return s!==l&&(s&&ut$3(r,s),l&<$4(r,l)),o}static importJSON(t){return rt().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setHighlightType(t.highlightType)}exportJSON(){return {...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(t){return this}isParentRequired(){return true}createParentElementNode(){return U$2()}};function nt$1(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function rt(t="",e){return fs(new et$1(t,e))}function it$2(t){return t instanceof et$1}function ot$2(t,e){let n=t;for(let i=tl(t,e);i&&(it$2(i.origin)||fr(i.origin));i=ft$2(i))n=i.origin;return n}function st$1(t){return ot$2(t,"previous")}function lt$2(t){return ot$2(t,"next")}function ut$1(t){const e=st$1(t),n=lt$2(t);let r=e;for(;null!==r;){if(it$2(r)){const t=oo(r.getTextContent());if(null!==t)return t}if(r===n)break;r=r.getNextSibling();}const i=e.getParent();if(Si(i)){const t=i.getDirection();if("ltr"===t||"rtl"===t)return t}return null}function ct$2(t,e){let n=null,r=null,i=t,o=e,s=t.getTextContent();for(;;){if(0===o){if(i=i.getPreviousSibling(),null===i)break;if(it$2(i)||fr(i)||jn(i)||I$1(167),jn(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent();}else o--;const t=s[o];it$2(i)&&" "!==t&&(r={node:i,offset:o});}if(null!==r)return r;let l=null;if(e<t.getTextContentSize())it$2(t)&&(l=t.getTextContent()[e]);else {const e=t.getNextSibling();it$2(e)&&(l=e.getTextContent()[0]);}if(null!==l&&" "!==l)return n;{const r=function(t,e){let n=t,r=e,i=t.getTextContent(),o=t.getTextContentSize();for(;;){if(!it$2(n)||r===o){if(n=n.getNextSibling(),null===n||jn(n))return null;it$2(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize());}if(it$2(n)){if(" "!==i[r])return {node:n,offset:r};r++;}}}(t,e);return null!==r?r:n}}function gt$1(t){const e=lt$2(t);return jn(e)&&I$1(168),e}!function(t){t.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var e={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(e).forEach(function(n){var r=e[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),t.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:true},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}};}),Object.defineProperty(t.languages.diff,"PREFIXES",{value:e});}(Prism);const ft$1=globalThis.Prism||window.Prism,pt$1={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},ht$1={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function dt$1(t){return ht$1[t]||t}function St$2(t){return "string"==typeof t?t:Array.isArray(t)?t.map(St$2).join(""):St$2(t.content)}function vt$1(t,e){const n=/^diff-([\w-]+)/i.exec(e),r=t.getTextContent();let i=ft$1.tokenize(r,ft$1.languages[n?"diff":e]);return n&&(i=function(t,e){const n=e,r=ft$1.languages[n],i={tokens:t},o=ft$1.languages.diff.PREFIXES;for(const t of i.tokens){if("string"==typeof t||!(t.type in o)||!Array.isArray(t.content))continue;const e=t.type;let n=0;const i=()=>(n++,new ft$1.Token("prefix",o[e],e.replace(/^(\w+).*/,"$1"))),s=t.content.filter(t=>"string"==typeof t||"prefix"!==t.type),l=t.content.length-s.length,u=ft$1.tokenize(St$2(s),r);u.unshift(i());const c=/\r\n|\n/g,g=t=>{const e=[];c.lastIndex=0;let r,o=0;for(;n<l&&(r=c.exec(t));){const n=r.index+r[0].length;e.push(t.slice(o,n)),o=n,e.push(i());}if(0!==e.length)return o<t.length&&e.push(t.slice(o)),e},a=t=>{for(let e=0;e<t.length&&n<l;e++){const n=t[e];if("string"==typeof n){const r=g(n);r&&(t.splice(e,1,...r),e+=r.length-1);}else if("string"==typeof n.content){const t=g(n.content);t&&(n.content=t);}else Array.isArray(n.content)?a(n.content):a([n.content]);}};a(u),n<l&&u.push(i()),t.content=u;}return i.tokens}(i,n[1])),Tt$2(i)}function Tt$2(t,e){const n=[];for(const r of t)if("string"==typeof r){const t=r.split(/(\n|\t)/),i=t.length;for(let r=0;r<i;r++){const i=t[r];"\n"===i||"\r\n"===i?n.push(Jn()):"\t"===i?n.push(ur()):i.length>0&&n.push(rt(i,e));}}else {const{content:t,alias:e}=r;"string"==typeof t?n.push(...Tt$2([t],"prefix"===r.type&&"string"==typeof e?e:r.type)):Array.isArray(t)&&n.push(...Tt$2(t,"unchanged"===r.type?void 0:r.type));}return n}const bt$2={$tokenize(t,e){return vt$1(t,e||this.defaultLanguage)},defaultLanguage:M$1,tokenize(t,e){return ft$1.tokenize(t,ft$1.languages[e||""]||ft$1.languages[this.defaultLanguage])}};function Ct$2(t,e,n){const r=t.getParent();X$1(r)?wt$2(r,e,n):it$2(t)&&t.replace(sr(t.__text));}function Nt$2(t,e){const n=e.getElementByKey(t.getKey());if(null===n)return;const r=t.getChildren(),i=r.length;if(i===n.__cachedChildrenLength)return;n.__cachedChildrenLength=i;let o="1",s=1;for(let t=0;t<i;t++)jn(r[t])&&(o+="\n"+ ++s);n.setAttribute("data-gutter",o);}const jt$2=new Set;function wt$2(t,e,n){const r=t.getKey();void 0===t.getLanguage()&&t.setLanguage(n.defaultLanguage);const i=t.getLanguage()||n.defaultLanguage;if(!function(t){const e=function(t){const e=/^diff-([\w-]+)/i.exec(t);return e?e[1]:null}(t),n=e||t;try{return !!n&&ft$1.languages.hasOwnProperty(n)}catch(t){return false}}(i))return t.getIsSyntaxHighlightSupported()&&t.setIsSyntaxHighlightSupported(false),void async function(){}();t.getIsSyntaxHighlightSupported()||t.setIsSyntaxHighlightSupported(true),jt$2.has(r)||(jt$2.add(r),e.update(()=>{!function(t,e){const n=xo(t);if(!X$1(n)||!n.isAttached())return;const r=Lr();if(!yr(r))return void e();const i=r.anchor,o=i.offset,s="element"===i.type&&jn(n.getChildAtIndex(i.offset-1));let u=0;if(!s){const t=i.getNode();u=o+t.getPreviousSiblings().reduce((t,e)=>t+e.getTextContentSize(),0);}if(!e())return;if(s)return void i.getNode().select(o,o);n.getChildren().some(t=>{const e=lr(t);if(e||jn(t)){const n=t.getTextContentSize();if(e&&n>=u)return t.select(u,u),true;u-=n;}return false});}(r,()=>{const e=xo(r);if(!X$1(e)||!e.isAttached())return false;
6926const i=e.getLanguage()||n.defaultLanguage,o=n.$tokenize(e,i),s=function(t,e){let n=0;for(;n<t.length&&kt$2(t[n],e[n]);)n++;const r=t.length,i=e.length,o=Math.min(r,i)-n;let s=0;for(;s<o;)if(s++,!kt$2(t[r-s],e[i-s])){s--;break}const l=n,u=r-s,c=e.slice(n,i-s);return {from:l,nodesForReplacement:c,to:u}}(e.getChildren(),o),{from:l,to:u,nodesForReplacement:c}=s;return !(l===u&&!c.length)&&(t.splice(l,u-l,c),true)});},{onUpdate:()=>{jt$2.delete(r);},skipTransforms:true}));}function kt$2(t,e){return it$2(t)&&it$2(e)&&t.__text===e.__text&&t.__highlightType===e.__highlightType||fr(t)&&fr(e)||jn(t)&&jn(e)}function At$2(t){if(!yr(t))return false;const e=t.anchor.getNode(),n=X$1(e)?e:e.getParent(),r=t.focus.getNode(),i=X$1(r)?r:r.getParent();return X$1(n)&&n.is(i)}function Pt$2(t){const e=t.getNodes(),n=[];if(1===e.length&&X$1(e[0]))return n;let r=[];for(let t=0;t<e.length;t++){const i=e[t];it$2(i)||fr(i)||jn(i)||I$1(169),jn(i)?r.length>0&&(n.push(r),r=[]):r.push(i);}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=hr(r[0].getKey(),0,"text");e.is(i)||n.push(r);}return n}function Lt$2(t){const e=Lr();if(!yr(e)||!At$2(e))return false;const n=Pt$2(e),r=n.length;if(0===r&&e.isCollapsed())return t===Pe$2&&e.insertNodes([ur()]),true;if(0===r&&t===Pe$2&&"\n"===e.getTextContent()){const t=ur(),n=Jn(),r=e.isBackward()?"previous":"next";return e.insertNodes([t,n]),Sl(Al(dl(el(t,"next",0),El(tl(n,"next"))),r)),true}for(let i=0;i<r;i++){const r=n[i];if(r.length>0){let n=r[0];if(0===i&&(n=st$1(n)),t===Pe$2){const t=ur();if(n.insertBefore(t),0===i){const r=e.isBackward()?"focus":"anchor",i=hr(n.getKey(),0,"text");e[r].is(i)&&e[r].set(t.getKey(),0,"text");}}else fr(n)&&n.remove();}}return true}function Ot$1(t,e){const n=Lr();if(!yr(n))return false;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),c=i.getNode(),g=t===ke$2;if(!At$2(n)||!it$2(l)&&!fr(l)||!it$2(c)&&!fr(c))return false;if(!e.altKey){if(n.isCollapsed()){const t=l.getParentOrThrow();if(g&&0===o&&null===l.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),true}else if(!g&&o===l.getTextContentSize()&&null===l.getNextSibling()){if(null===t.getNextSibling())return t.selectNext(),e.preventDefault(),true}}return false}let a,f;if(l.isBefore(c)?(a=st$1(l),f=lt$2(c)):(a=st$1(c),f=lt$2(l)),null==a||null==f)return false;const p=a.getNodesBetween(f);for(let t=0;t<p.length;t++){const e=p[t];if(!it$2(e)&&!fr(e)&&!jn(e))return false}e.preventDefault(),e.stopPropagation();const h=g?a.getPreviousSibling():f.getNextSibling();if(!jn(h))return true;const d=g?h.getPreviousSibling():h.getNextSibling();if(null==d)return true;const m=it$2(d)||fr(d)||jn(d)?g?st$1(d):lt$2(d):null;let x=null!=m?m:d;return h.remove(),p.forEach(t=>t.remove()),t===ke$2?(p.forEach(t=>x.insertBefore(t)),x.insertBefore(h)):(x.insertAfter(h),x=h,p.forEach(t=>{x.insertAfter(t),x=t;})),n.setTextNodeRange(l,o,c,s),true}function Ht$1(t,e){const n=Lr();if(!yr(n))return false;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=t===ve$2;if(!At$2(n)||!it$2(o)&&!fr(o)||!it$2(s)&&!fr(s))return false;const c=s;if("rtl"===ut$1(c)?!l:l){const t=ct$2(c,i.offset);if(null!==t){const{node:e,offset:r}=t;jn(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r);}else c.getParentOrThrow().selectStart();}else {gt$1(c).select();}return e.preventDefault(),e.stopPropagation(),true}function Et$2(t,e){if(!t.hasNodes([q$1,et$1]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==e&&(e=bt$2);const n=[];return true!==t._headless&&n.push(t.registerMutationListener(q$1,e=>{t.getEditorState().read(()=>{for(const[n,r]of e)if("destroyed"!==r){const e=xo(n);null!==e&&Nt$2(e,t);}});},{skipInitialization:false})),n.push(t.registerNodeTransform(q$1,n=>wt$2(n,t,e)),t.registerNodeTransform(Xn,n=>Ct$2(n,t,e)),t.registerNodeTransform(et$1,n=>Ct$2(n,t,e)),t.registerCommand(Me$2,e=>{const n=function(t){const e=Lr();if(!yr(e)||!At$2(e))return null;const n=t?De$2:Pe$2,r=t?De$2:Ae$2,i=e.anchor,o=e.focus;if(i.is(o))return r;const s=Pt$2(e);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&I$1(285),e.isBackward()?(u=o,c=i):(u=i,c=o);const g=st$1(l[0]),a=lt$2(l[0]),f=hr(g.getKey(),0,"text"),p=hr(a.getKey(),a.getTextContentSize(),"text");return u.isBefore(f)||p.isBefore(c)?n:f.isBefore(u)||c.isBefore(p)?r:n}(e.shiftKey);
6926return null!==n&&(e.preventDefault(),t.dispatchCommand(n,void 0),true)},zi),t.registerCommand(Ae$2,()=>!!At$2(Lr())&&(jr([ur()]),true),zi),t.registerCommand(Pe$2,t=>Lt$2(Pe$2),zi),t.registerCommand(De$2,t=>Lt$2(De$2),zi),t.registerCommand(ke$2,t=>{const e=Lr();if(!yr(e))return false;const{anchor:n}=e,r=n.getNode();return !!At$2(e)&&(e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&X$1(r.getParentOrThrow())?(t.preventDefault(),true):Ot$1(ke$2,t))},zi),t.registerCommand(Te$2,t=>{const e=Lr();if(!yr(e))return false;const{anchor:n}=e,r=n.getNode();return !!At$2(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&X$1(r.getParentOrThrow())?(t.preventDefault(),true):Ot$1(Te$2,t))},zi),t.registerCommand(ve$2,t=>Ht$1(ve$2,t),zi),t.registerCommand(Ce$1,t=>Ht$1(Ce$1,t),zi)),U$4(...n)} 6927 6928/** 6929 * Copyright (c) Meta Platforms, Inc. and affiliates. 6930 * 6931 * This source code is licensed under the MIT license found in the 6932 * LICENSE file in the root directory of this source tree. 6933 * 6934 */ 6935 6936function z$1(t,e){const n={};for(const o of t){const t=e(o);t&&(n[t]?n[t].push(o):n[t]=[o]);}return n}function U$1(t){const e=z$1(t,t=>t.type);return {element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const W$1=/[!-/:-@[-`{-~\s]/;function V$1(t){return lr(t)&&!t.hasFormat("code")}function et(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const nt=/^(\s*)(\d{1,})\.\s/,ot$1=/^(\s*)[-*+]\s/,it$1=/^(#{1,6})\s/,st=/^>\s/,lt$1=/^[ \t]*```([\w-]+)?/,ct$1=/[ \t]*```$/,mt$1=ot$5("mdListMarker",{parse:t=>"string"==typeof t&&/^[-*+]$/.test(t)?t:"-"}),ht=t=>(e,n,o,r)=>{const i=t(o);i.append(...n),e.replace(i),r||i.select(0,0);};const xt$1=t=>(e,n,o,r)=>{const i=e.getPreviousSibling(),s=e.getNextSibling(),l=st$2("check"===t?"x"===o[3]:void 0),c=o[0].trim()[0],f="bullet"!==t&&"check"!==t||c!==mt$1.parse(c)?void 0:c;if(dt$2(s)&&s.getListType()===t){f&&ct$5(s,mt$1,f);const t=s.getFirstChild();null!==t?t.insertBefore(l):s.append(l),e.remove();}else if(dt$2(i)&&i.getListType()===t)f&&ct$5(i,mt$1,f),i.append(l),e.remove();else {const n=ht$3(t,"number"===t?Number(o[2]):void 0);f&&ct$5(n,mt$1,f),n.append(l),e.replace(n);}l.append(...n),r||l.select(0,0);const a=function(t){const e=t.match(/\t/g),n=t.match(/ /g);let o=0;return e&&(o+=e.length),n&&(o+=Math.floor(n.length/4)),o}(o[1]);a&&l.setIndent(a);},Tt$1=(t,e,n)=>{const o=[],r=t.getChildren();let i=0;for(const s of r)if(ot$3(s)){if(1===s.getChildrenSize()){const t=s.getFirstChild();if(dt$2(t)){o.push(Tt$1(t,e,n+1));continue}}const r=" ".repeat(4*n),l=t.getListType(),c=st$4(t,mt$1),f="number"===l?`${t.getStart()+i}. `:"check"===l?`${c} [${s.getChecked()?"x":" "}] `:c+" ";o.push(r+f+e(s)),i++;}return o.join("\n")},Et$1={dependencies:[Pt$3],export:(t,e)=>{if(!It$2(t))return null;const n=Number(t.getTag().slice(1));return "#".repeat(n)+" "+e(t)},regExp:it$1,replace:ht(t=>{const e="h"+t[1].length;return St$3(e)}),type:"element"},Ct$1={dependencies:[Et$3],export:(t,e)=>{if(!Ot$2(t))return null;const n=e(t).split("\n"),o=[];for(const t of n)o.push("> "+t);return o.join("\n")},regExp:st,replace:(t,e,n,o)=>{if(o){const n=t.getPreviousSibling();if(Ot$2(n))return n.splice(n.getChildrenSize(),0,[Jn(),...e]),void t.remove()}const r=_t$2();r.append(...e),t.replace(r),o||r.select(0,0);},type:"element"},yt$1={dependencies:[q$1],export:t=>
6936{if(!X$1(t))return null;const e=t.getTextContent();return "```"+(t.getLanguage()||"")+(e?"\n"+e:"")+"\n```"},regExpEnd:{optional:true,regExp:ct$1},regExpStart:lt$1,replace:(t,e,n,o,r,i)=>{let s,c;if(!e&&r){if(1===r.length)o?(s=U$2(),c=n[1]+r[0]):(s=U$2(n[1]),c=r[0].startsWith(" ")?r[0].slice(1):r[0]);else {if(s=U$2(n[1]),0===r[0].trim().length)for(;r.length>0&&!r[0].length;)r.shift();else r[0]=r[0].startsWith(" ")?r[0].slice(1):r[0];for(;r.length>0&&!r[r.length-1].length;)r.pop();c=r.join("\n");}const e=sr(c);s.append(e),t.append(s);}else e&&ht(t=>U$2(t?t[1]:void 0))(t,e,n,i);},type:"multiline-element"},$t$1={dependencies:[lt$3,nt$2],export:(t,e)=>dt$2(t)?Tt$1(t,e,0):null,regExp:ot$1,replace:xt$1("bullet"),type:"element"},St$1={dependencies:[lt$3,nt$2],export:(t,e)=>dt$2(t)?Tt$1(t,e,0):null,regExp:nt,replace:xt$1("number"),type:"element"},bt$1={format:["code"],tag:"`",type:"text-format"},Ft$1={format:["highlight"],tag:"==",type:"text-format"},It$1={format:["bold","italic"],tag:"***",type:"text-format"},wt$1={format:["bold","italic"],intraword:false,tag:"___",type:"text-format"},Nt$1={format:["bold"],tag:"**",type:"text-format"},kt$1={format:["bold"],intraword:false,tag:"__",type:"text-format"},Rt$1={format:["strikethrough"],tag:"~~",type:"text-format"},Lt$1={format:["italic"],tag:"*",type:"text-format"},_t$1={format:["italic"],intraword:false,tag:"_",type:"text-format"},Pt$1={dependencies:[y$2],export:(t,e,n)=>{if(!w$3(t)||E$3(t))return null;const o=t.getTitle(),r=e(t);return o?`[${r}](${t.getURL()} "${o}")`:`[${r}](${t.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,e)=>{const[,n,o,r]=e,i=D$2(o,{title:r}),s=n.split("[").length-1,c=n.split("]").length-1;let f=n,a="";if(s<c)return;if(s>c){const t=n.split("[");a="["+t[0],f=t.slice(1).join("[");}const u=sr(f);return u.setFormat(t.getFormat()),i.append(u),t.replace(i),a&&i.insertBefore(sr(a)),u},trigger:")",type:"text-match"},Bt$1=[Et$1,Ct$1,$t$1,St$1],Mt$1=[yt$1],jt$1=[bt$1,It$1,wt$1,Nt$1,kt$1,Ft$1,Lt$1,_t$1,Rt$1],At$1=[Pt$1],zt$1=[...Bt$1,...Mt$1,...jt$1,...At$1];function Ut$1(t,e,n){const o=n.length;for(let r=e;r>=o;r--){const e=r-o;if(Wt$1(t,e,n,0,o)&&" "!==t[e+o])return e}return -1}function Wt$1(t,e,n,o,r){for(let i=0;i<r;i++)if(t[e+i]!==n[o+i])return false;return true}function Dt$1(t,n=zt$1){const o=U$1(n),r=z$1(o.textFormat,({tag:t})=>t[t.length-1]),l=z$1(o.textMatch,({trigger:t})=>t);for(const e of n){const n=e.type;if("element"===n||"text-match"===n||"multiline-element"===n){const n=e.dependencies;for(const e of n)t.hasNode(e)||et(173,e.getType());}}const c=(t,n,c)=>{(function(t,e,n,o){const r=t.getParent();if(!as(r)||t.getFirstChild()!==e)return false;const i=e.getTextContent();if(" "!==i[n-1])return false;for(const{regExp:r,replace:s}of o){const o=i.match(r);if(o&&o[0].length===(o[0].endsWith(" ")?n:n-1)){const r=e.getNextSiblings(),[i,l]=e.splitText(n);if(false!==s(t,l?[l,...r]:r,o,false))return i.remove(),true}}return false})(t,n,c,o.element)||function(t,e,n,o){const r=t.getParent();if(!as(r)||t.getFirstChild()!==e)return false;const i=e.getTextContent();if(" "!==i[n-1])return false;for(const{regExpStart:r,replace:s,regExpEnd:l}of o){if(l&&!("optional"in l)||l&&"optional"in l&&!l.optional)continue;const o=i.match(r);if(o&&o[0].length===(o[0].endsWith(" ")?n:n-1)){const r=e.getNextSiblings(),[i,l]=e.splitText(n);if(false!==s(t,l?[l,...r]:r,o,null,null,false))return i.remove(),true}}return false}(t,n,c,o.multilineElement)||function(t,e,n){let o=t.getTextContent();const r=n[o[e-1]];if(null==r)return false;e<o.length&&(o=o.slice(0,e));for(const e of r){if(!e.replace||!e.regExp)continue;const n=o.match(e.regExp);if(null===n)continue;const r=n.index||0,i=r+n[0].length;let s;return 0===r?[s]=t.splitText(i):[,s]=t.splitText(r,i),s.selectNext(0,0),e.replace(s,n),true}return false}(n,c,l)||function(t,n,o){const r=t.getTextContent(),l=n-1,c=r[l],f=o[c];if(!f)return false;for(const n of f){const{tag:o}=n,f=o.length,a=l-f+1;if(f>1&&!Wt$1(r,a,o,0,f))continue;if(" "===r[a-1])continue;const u=r[l+1];if(false===n.intraword&&u&&!W$1.test(u))continue;const g=t;let p=g,d=Ut$1(r,a,o),h=p;for(;d<0&&(h=h.getPreviousSibling())&&!jn(h);)if(lr(h)){if(h.hasFormat("code"))continue;const t=h.getTextContent();p=h,d=Ut$1(t,t.length,o);}if(d<0)continue;if(p===g&&d+f===a)continue;const E=p.getTextContent();if(d>0&&E[d-1]===c)continue;const C=E[d-1];if(false===n.intraword&&C&&!W$1.test(C))continue;const y=g.getTextContent(),$=y.slice(0,a)+y.slice(l+1);g.setTextContent($);const v=p===g?$:E;p.setTextContent(v.slice(0,d)+v.slice(d+f));const S=Lr(),b=Ar();wo(b);const F=l-f*(p===g?2:1)+1;b.anchor.set(p.__key,d,"text"),b.focus.set(g.__key,F,"text");for(const t of n.format)b.hasFormat(t)||b.formatText(t);
6936b.anchor.set(b.focus.key,b.focus.offset,b.focus.type);for(const t of n.format)b.hasFormat(t)&&b.toggleFormat(t);return yr(S)&&(b.format=S.format),true}}(n,c,r);};return t.registerUpdateListener(({tags:n,dirtyLeaves:o,editorState:r,prevEditorState:i})=>{if(n.has(Ln)||n.has(An))return;if(t.isComposing())return;const l=r.read(Lr),f=i.read(Lr);if(!yr(f)||!yr(l)||!l.isCollapsed()||l.is(f))return;const a=l.anchor.key,u=l.anchor.offset,g=r._nodeMap.get(a);!lr(g)||!o.has(a)||1!==u&&u>f.anchor.offset+1||t.update(()=>{if(!V$1(g))return;const t=g.getParent();null===t||X$1(t)||c(t,g,l.anchor.offset);});})} 6937 6938/** 6939 * Copyright (c) Meta Platforms, Inc. and affiliates. 6940 * 6941 * This source code is licensed under the MIT license found in the 6942 * LICENSE file in the root directory of this source tree. 6943 * 6944 */ 6945 6946function x$1(t,e,n,r,o){if(null===t||0===n.size&&0===r.size&&!o)return 0;const i=e._selection,a=t._selection;if(o)return 1;if(!(yr(i)&&yr(a)&&a.isCollapsed()&&i.isCollapsed()))return 0;const s=function(t,e,n){const r=t._nodeMap,o=[];for(const t of e){const e=r.get(t);void 0!==e&&o.push(e);}for(const[t,e]of n){if(!e)continue;const n=r.get(t);void 0===n||bi(n)||o.push(n);}return o}(e,n,r);if(0===s.length)return 0;if(s.length>1){const n=e._nodeMap,r=n.get(i.anchor.key),o=n.get(a.anchor.key);return r&&o&&!t._nodeMap.has(r.__key)&&lr(r)&&1===r.__text.length&&1===i.anchor.offset?2:0}const c=s[0],d=t._nodeMap.get(c.__key);if(!lr(d)||!lr(c)||d.__mode!==c.__mode)return 0;const u=d.__text,l=c.__text;if(u===l)return 0;const f=i.anchor,p=a.anchor;if(f.key!==p.key||"text"!==f.type)return 0;const h=f.offset,m=p.offset,y=l.length-u.length;return 1===y&&m===h-1?2:-1===y&&m===h+1?3:-1===y&&m===h?4:0}function C$1(t,e){let n=Date.now(),r=0;return (o,i,a,s,c,d)=>{const u=Date.now();if(d.has(An))return r=0,n=u,2;const l=x$1(o,i,s,c,t.isComposing()),f=(()=>{const f=null===a||a.editor===t,p=d.has(Pn);if(!p&&f&&d.has(Dn))return 0;if(null===o)return 1;const h=i._selection;if(!(s.size>0||c.size>0))return null!==h?0:2;const m="number"==typeof e?e:e.peek();if(false===p&&0!==l&&l===r&&u<n+m&&f)return 0;if(1===s.size){if(function(t,e,n){const r=e._nodeMap.get(t),o=n._nodeMap.get(t),i=e._selection,a=n._selection;return !(yr(i)&&yr(a)&&"element"===i.anchor.type&&"element"===i.focus.type&&"text"===a.anchor.type&&"text"===a.focus.type||!lr(r)||!lr(o)||r.__parent!==o.__parent)&&JSON.stringify(e.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>o.exportJSON()))}(Array.from(s)[0],o,i))return 0}return 1})();return n=u,r=l,f}}function v$1(t){t.undoStack=[],t.redoStack=[],t.current=null;}function b$1(t,e,n){const r=C$1(t,n),i=U$4(t.registerCommand(pe$1,()=>(function(t,e){const n=e.redoStack,r=e.undoStack;if(0!==r.length){const o=e.current,i=r.pop();null!==o&&(n.push(o),t.dispatchCommand($e$2,true)),0===r.length&&t.dispatchCommand(Ue$2,false),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:An});}}(t,e),true),Ki),t.registerCommand(ye$1,()=>(function(t,e){const n=e.redoStack,r=e.undoStack;if(0!==n.length){const o=e.current;null!==o&&(r.push(o),t.dispatchCommand(Ue$2,true));const i=n.pop();0===n.length&&t.dispatchCommand($e$2,false),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:An});}}(t,e),true),Ki),t.registerCommand(Je$1,()=>(v$1(e),false),Ki),t.registerCommand(je$2,()=>(v$1(e),t.dispatchCommand($e$2,false),t.dispatchCommand(Ue$2,false),true),Ki),t.registerUpdateListener(({editorState:n,prevEditorState:o,dirtyLeaves:i,dirtyElements:a,tags:s})=>{const c=e.current,d=e.redoStack,u=e.undoStack,l=null===c?null:c.editorState;if(null!==c&&n===l)return;const f=r(o,n,c,i,a,s);if(1===f)0!==d.length&&(e.redoStack=[],t.dispatchCommand($e$2,false)),null!==c&&(u.push({...c}),t.dispatchCommand(Ue$2,true));else if(2===f)return;e.current={editor:t,editorState:n};}));return i}function w$1(){return {current:null,redoStack:[],undoStack:[]}}const E$1=Kl({build:(e,{delay:n,createInitialHistoryState:r,disabled:o})=>at$2({delay:n,disabled:o,historyState:r(e)}),config:Bl({createInitialHistoryState:w$1,delay:300,disabled:"undefined"==typeof window}),name:"@lexical/history/History",register:(t,n,r)=>{const o=r.getOutput();return dt$3(()=>o.disabled.value?void 0:b$1(t,o.historyState.value,o.delay))}});Kl({dependencies:[zl(E$1,{createInitialHistoryState:()=>{throw new Error("SharedHistory did not inherit parent history")},disabled:true})],name:"@lexical/history/SharedHistory",register(t,o,i){const{output:a}=i.getDependency(E$1),s=function(t){return t?Gt$1(t,E$1.name):null}(t._parentEditor);if(!s)return ()=>{};const c=s.output;return dt$3(()=>F$2(()=>{a.delay.value=c.delay.value,a.historyState.value=c.historyState.value,a.disabled.value=c.disabled.value;}))}}); 6947 6948var theme = { 6949 text: { 6950 bold: "lexxy-content__bold", 6951 italic: "lexxy-content__italic", 6952 strikethrough: "lexxy-content__strikethrough", 6953 underline: "lexxy-content__underline", 6954 highlight: "lexxy-content__highlight" 6955 }, 6956 tableCellHeader: "lexxy-content__table-cell--header", 6957 tableCellSelected: "lexxy-content__table-cell--selected", 6958 tableSelection: "lexxy-content__table--selection", 6959 tableScrollableWrapper: "lexxy-content__table-wrapper", 6960 tableCellHighlight: "lexxy-content__table-cell--highlight", 6961 tableCellFocus: "lexxy-content__table-cell--focus", 6962 list: { 6963 nested: { 6964 listitem: "lexxy-nested-listitem", 6965 } 6966 }, 6967 codeHighlight: { 6968 addition: "code-token__selector", 6969 atrule: "code-token__attr", 6970 attr: "code-token__attr", 6971 "attr-name": "code-token__attr", 6972 "attr-value": "code-token__selector", 6973 boolean: "code-token__property", 6974 bold: "code-token__variable", 6975 builtin: "code-token__selector", 6976 cdata: "code-token__comment", 6977 char: "code-token__selector", 6978 class: "code-token__function", 6979 "class-name": "code-token__function", 6980 color: "code-token__property", 6981 comment: "code-token__comment", 6982 constant: "code-token__property", 6983 coord: "code-token__comment", 6984 decorator: "code-token__function", 6985 deleted: "code-token__operator",
6986 deletion: "code-token__operator", 6987 directive: "code-token__attr", 6988 "directive-hash": "code-token__property", 6989 doctype: "code-token__comment", 6990 entity: "code-token__operator", 6991 function: "code-token__function", 6992 hexcode: "code-token__property", 6993 important: "code-token__function", 6994 inserted: "code-token__selector", 6995 italic: "code-token__comment", 6996 keyword: "code-token__attr", 6997 line: "code-token__selector", 6998 namespace: "code-token__variable", 6999 number: "code-token__property", 7000 macro: "code-token__function", 7001 operator: "code-token__operator", 7002 parameter: "code-token__variable", 7003 prolog: "code-token__comment", 7004 property: "code-token__property", 7005 punctuation: "code-token__punctuation", 7006 "raw-string": "code-token__operator", 7007 regex: "code-token__variable", 7008 script: "code-token__function", 7009 selector: "code-token__selector", 7010 string: "code-token__selector", 7011 style: "code-token__function", 7012 symbol: "code-token__property", 7013 tag: "code-token__property", 7014 title: "code-token__function", 7015 "type-definition": "code-token__function", 7016 url: "code-token__operator", 7017 variable: "code-token__variable", 7018 } 7019}; 7020 7021function createElement(name, properties, content = "") { 7022 const element = document.createElement(name); 7023 for (const [ key, value ] of Object.entries(properties || {})) { 7024 if (key in element) { 7025 element[key] = value; 7026 } else if (value !== null && value !== undefined) { 7027 element.setAttribute(key, value); 7028 } 7029 } 7030 if (content) { 7031 element.innerHTML = content; 7032 } 7033 return element 7034} 7035 7036function parseHtml(html) { 7037 const parser = new DOMParser(); 7038 return parser.parseFromString(html, "text/html") 7039} 7040 7041function createAttachmentFigure(contentType, isPreviewable, fileName) { 7042 const extension = fileName ? fileName.split(".").pop().toLowerCase() : "unknown"; 7043 return createElement("figure", { 7044 className: `attachment attachment--${isPreviewable ? "preview" : "file"} attachment--${extension}`, 7045 "data-content-type": contentType 7046 }) 7047} 7048 7049function isPreviewableImage(contentType) { 7050 return contentType.startsWith("image/") && !contentType.includes("svg") 7051} 7052 7053function dispatch(element, eventName, detail = null, cancelable = false) { 7054 return element.dispatchEvent(new CustomEvent(eventName, { bubbles: true, detail, cancelable })) 7055} 7056 7057function addBlockSpacing(doc) { 7058 const blocks = doc.querySelectorAll("body > :not(h1, h2, h3, h4, h5, h6) + *"); 7059 for (const block of blocks) { 7060 const spacer = doc.createElement("p"); 7061 spacer.appendChild(doc.createElement("br")); 7062 block.before(spacer); 7063 } 7064} 7065 7066function generateDomId(prefix) { 7067 const randomPart = Math.random().toString(36).slice(2, 10); 7068 return `${prefix}-${randomPart}` 7069} 7070 7071class HorizontalDividerNode extends ki { 7072 static getType() { 7073 return "horizontal_divider" 7074 } 7075 7076 static clone(node) { 7077 return new HorizontalDividerNode(node.__key) 7078 } 7079 7080 static importJSON(serializedNode) { 7081 return new HorizontalDividerNode() 7082 } 7083 7084 static importDOM() { 7085 return { 7086 "hr": (hr) => { 7087 return { 7088 conversion: () => ({ 7089 node: new HorizontalDividerNode() 7090 }), 7091 priority: 1 7092 } 7093 } 7094 } 7095 } 7096 7097 constructor(key) { 7098 super(key); 7099 } 7100 7101 createDOM() { 7102 const figure = createElement("figure", { className: "horizontal-divider" }); 7103 const hr = createElement("hr"); 7104 7105 figure.appendChild(hr); 7106 7107 const deleteButton = createElement("lexxy-node-delete-button"); 7108 figure.appendChild(deleteButton); 7109 7110 return figure 7111 } 7112 7113 updateDOM() { 7114 return true 7115 } 7116 7117 getTextContent() { 7118 return "â\n\n" 7119 } 7120 7121 isInline() { 7122 return false 7123 } 7124 7125 exportDOM() { 7126 const hr = createElement("hr"); 7127 return { element: hr } 7128 } 7129 7130 exportJSON() { 7131 return { 7132 type: "horizontal_divider", 7133 version: 1 7134 } 7135 } 7136 7137 decorate() { 7138 return null 7139 } 7140} 7141 7142/** 7143 * Copyright (c) Meta Platforms, Inc. and affiliates. 7144 * 7145 * This source code is licensed under the MIT license found in the 7146 * LICENSE file in the root directory of this source tree. 7147 * 7148 */ 7149 7150const Ne$1=/^(\d+(?:\.\d+)?)px$/,ve$1={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class xe extends Ci{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return "tablecell"}static clone(e){return new xe(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign;}static importDOM(){return {td:e=>({conversion:Re$1,priority:0}),th:e=>({conversion:Re$1,priority:0})}}static importJSON(e){return Fe$1().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroun
7150dColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=ve$1.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0;}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),Te$1(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),lt$4(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(Cs(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5");}return t}exportJSON(){return {...super.exportJSON(),...Te$1(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ve$1.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return (t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return (this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ve$1.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return true}collapseAtStart(){return true}canBeEmpty(){return false}canIndent(){return false}}function Te$1(e){return "middle"===e||"bottom"===e}function Re$1(e){const t=e,n=e.nodeName.toLowerCase();let o;Ne$1.test(t.style.width)&&(o=parseFloat(t.style.width));const r=Fe$1("th"===n?ve$1.ROW:ve$1.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style.verticalAlign;Te$1(s)&&(r.__verticalAlign=s);const i=t.style,c=(i&&i.textDecoration||"").split(" "),a="700"===i.fontWeight||"bold"===i.fontWeight,u=c.includes("line-through"),h="italic"===i.fontStyle,p=c.includes("underline");return {after:e=>{const t=[];let n=null;const o=()=>{if(n){const e=n.getFirstChild();jn(e)&&1===n.getChildrenSize()&&e.remove();}};for(const r of e)ls(r)||lr(r)||jn(r)?(lr(r)&&(a&&r.toggleFormat("bold"),u&&r.toggleFormat("strikethrough"),h&&r.toggleFormat("italic"),p&&r.toggleFormat("underline")),n?n.append(r):(n=Li().append(r),t.push(n))):(t.push(r),o(),n=null);return o(),0===t.length&&t.push(Li()),t},node:r}}function Fe$1(e=ve$1.NO_STATUS,t=1,n){return fs(new xe(e,t,n))}function Oe$1(e){return e instanceof xe}const Ae$1=re$1("INSERT_TABLE_COMMAND");function Ke$1(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let Ee$1 = class Ee extends Ci{__height;static getType(){return "tablerow"}static clone(e){return new Ee(e.__height,e.__key)}static importDOM(){return {tr:e=>({conversion:ke$1,priority:0})}}static importJSON(e){return Me$1().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e;}exportJSON(){const e=this.getHeight();return {...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),lt$4(n,t.theme.tableRow),n}extractWithChild(e,t,n){return "html"===n}isShadowRoot(){return true}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return false}canIndent(){return false}};function ke$1(e){const n=e;let o;return Ne$1.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>kt$6(e,Oe$1),node:Me$1(o)}}function Me$1(e){return fs(new Ee$1(e))}function $e$1(e){return e instanceof Ee$1}const ze$1="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,We$1=ze$1&&"documentMode"in document?document.documentMode:null,He$1=ze$1&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function Le$1(e,t,n=true){const o=gn();for(let r=0;r<e;r++){const e=Me$1();for(let o=0;o<t;o++){let t=ve$1.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=ve$1.ROW),0===o&&n.columns&&(t|=ve$1.COLUMN)):n&&(0===r&&(t|=ve$1.ROW),0===o&&(t|=ve$1.COLUMN));const l=Fe$1(t),s=Li();s.append(sr()),l.append(s),e.append(l);}o.append(e);}return o}function Be$1(e){const t=zs(e,e=>Oe$1(e));return Oe$1(t)?t:null}function Pe$1(e){const t=zs(e,e=>$e$1(e));if($e$1(t))return t;throw new Error("Expected table cell to be inside of table row.")}function De$1(e){const t=zs(e,e=>mn(e));if(mn(t))return t;throw new Error("Expected table cell to be inside of table.")}function Ie$1(e){const t=Pe$1(e);return De$1(t).getChildren().findIndex(e=>e.is(t))}function Ue$1(e){return Pe$1(e).getChildren().findIndex(t=>t.is(e))}ze$1&&"InputEvent"in window&&!We$1&&new window.InputEvent("input");const qe$1=(e,t)=>e===ve$1.BOTH||e===t?t:ve$1.NO_STATUS;function je$1(e=true){const t=Lr();yr(t)||wt(t)||Ke$1(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=mt(n),[l,,s]=mt(o),[,i,c]=ft(s,l,r),{startRow:a}=c,{startRow:u}=i;return e?Ge$1(a+r.__rowSpan>u+l.__rowSpan?r:l,true):Ge$1(u<a?l:r,false)}function Ge$1(e,t=true){const[,,n]=mt(e),[o,r]=ft(n,e,e),l=o[0].length,{startRow:s}=r;let i=null;if(t){const t=s+e.__rowSpan-1,r=o[t],c=Me$1();for(let e=0;e<l;e++){const{cell:n,startRow:o}=r[e];if(o+n.__rowSpan-1<=t){const t=r[e].cell.__headerState,n=qe$1(t,ve$1.COLUMN);c.append(Fe$1(n).append(Li()));}else n.setRowSpan(n.__rowSpan+1);}const a=n.getChildAtIndex(t);$e$1(a)||Ke$1(256),a.insertAfter(c),i=c;}else {const e=s,t=o[e],r=Me$1();for(let n=0;n<l;n++){const{cell:o,startRow:l}=t[n];if(l===e){const e=t[n].cell.__headerState,o=qe$1(e,ve$1.COLUMN);r.append(Fe$1(o).append(Li()));}else o.setRowSpan(o.__rowSpan+1);}const c=n.getChildAtIndex(e);$e$1(c)||Ke$1(257),c.insertBefore(r),i=r;}return i}function Ze$1(e=true){const t=Lr();yr(t)||wt(t)||Ke$1(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=mt(n),[l,,s]=mt(o),[,i,c]=ft(s,l,r),{startColumn:a}=c,{startColumn:u}=i;return e?tt(a+r.__colSpan>u+l.__colSpan?r:l,true):tt(u<a?l:r,false)}function tt(e,t=true,n=true){const[,,o]=mt(e),[r,l]=ft(o,e,e),s=r.length,{startColumn:i}=l,c=t?i+e.__colSpan-1:i-1,a=o.getFirstChild();$e$1(a)||Ke$1(120);let u=null;function h(e=ve$1.NO_STATUS){const t=Fe$1(e).append(Li());return null===u&&(u=t),t}let d=a;e:for(let e=0;e<s;e++){if(0!==e){const e=d.getNextSibling();$e$1(e)||Ke$1(121),d=e;}const t=r[e],n=t[c<0?0:c].cell.__headerState,o=qe$1(n,ve$1.ROW);if(c<0){ct(d,h(o));continue}const{cell:l,startColumn:s,startRow:i}=t[c];if(s+l.__colSpan-1<=c){let n=l,r=i,s=c;for(;r!==e&&n.__rowSpan>1;){if(s-=l.__colSpan,!(s>=0)){d.append(h(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o;}}n.insertAfter(h(o));}else l.setColSpan(l.__colSpan+1);}null!==u&&n&&it(u);const f=o.getColWidths();if(f){const e=[...f],t=c<0?0:c,n=e[t];e.splice(t,0,n),o.setColWidths(e);}return u}function ot(){const e=Lr();yr(e)||wt(e)||Ke$1(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=mt(t),[l]=mt(n),[s,i,c]=ft(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;
7150if(s.length===h-a+1)return void r.remove();const d=s[0].length,f=s[h+1],g=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(o<a||o+n.__rowSpan-1>h){const e=Math.max(o,a),t=Math.min(n.__rowSpan+o-1,h),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r);}if(o>=a&&o+n.__rowSpan-1>h&&e===h){null===g&&Ke$1(122);let o=null;for(let n=0;n<t;n++){const t=f[n],r=t.cell;t.startRow===e+1&&(o=r),r.__colSpan>1&&(n+=r.__colSpan-1);}null===o?ct(g,n):o.insertAfter(n);}}}const t=r.getChildAtIndex(e);$e$1(t)||Ke$1(206,String(e)),t.remove();}if(void 0!==f){const{cell:e}=f[0];it(e);}else {const e=s[a-1],{cell:t}=e[0];it(t);}}function lt(){const e=Lr();yr(e)||wt(e)||Ke$1(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=mt(t),[l]=mt(n),[s,i,c]=ft(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),f=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),g=f-d+1;if(s[0].length===f-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;e<m;e++)for(let t=d;t<=f;t++){const{cell:n,startColumn:o}=s[e][t];if(o<d){if(t===d){const e=d-o;n.setColSpan(n.__colSpan-Math.min(g,n.__colSpan-e));}}else if(o+n.__colSpan-1>f){if(t===f){const e=f-o+1;n.setColSpan(n.__colSpan-e);}}else n.remove();}const p=s[u],C=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==C){const{cell:e}=C;it(e);}else {const e=h<a?p[h-1]:p[a-1],{cell:t}=e;it(t);}const _=r.getColWidths();if(_){const e=[..._];e.splice(d,g),r.setColWidths(e);}}function it(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart();}function ct(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t);}function at(e){if(0===e.length)return null;const t=De$1(e[0]),[n]=gt(t,null,null);let o=1/0,r=-1/0,l=1/0,s=-1/0;const i=new Set;for(const t of n)for(const n of t){if(!n||!n.cell)continue;const t=n.cell.getKey();if(!i.has(t)&&e.some(e=>e.is(n.cell))){i.add(t);const e=n.startRow,c=n.startColumn,a=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;o=Math.min(o,e),r=Math.max(r,e+a-1),l=Math.min(l,c),s=Math.max(s,c+u-1);}}if(o===1/0||l===1/0)return null;const c=r-o+1,a=s-l+1,u=n[o][l];if(!u.cell)return null;const h=u.cell;h.setColSpan(a),h.setRowSpan(c);const d=new Set([h.getKey()]);for(let e=o;e<=r;e++)for(let t=l;t<=s;t++){const o=n[e][t];if(!o.cell)continue;const r=o.cell,l=r.getKey();if(!d.has(l)){d.add(l);ut(r)||h.append(...r.getChildren()),r.remove();}}return 0===h.getChildrenSize()&&h.append(Li()),h}function ut(e){if(1!==e.getChildrenSize())return false;const t=e.getFirstChildOrThrow();return !(!Ii(t)||!t.isEmpty())}function dt(e){const[t,n,o]=mt(e),r=t.__colSpan,l=t.__rowSpan;if(1===r&&1===l)return;const[s,i]=ft(o,t,t),{startColumn:c,startRow:a}=i,u=t.__headerState&ve$1.COLUMN,h=Array.from({length:r},(e,t)=>{let n=u;for(let e=0;0!==n&&e<s.length;e++)n&=s[e][t+c].cell.__headerState;return n}),d=t.__headerState&ve$1.ROW,f=Array.from({length:l},(e,t)=>{let n=d;for(let e=0;0!==n&&e<s[0].length;e++)n&=s[t+a][e].cell.__headerState;return n});if(r>1){for(let e=1;e<r;e++)t.insertAfter(Fe$1(h[e]|f[0]).append(Li()));t.setColSpan(1);}if(l>1){let e;for(let t=1;t<l;t++){const o=a+t,l=s[o];e=(e||n).getNextSibling(),$e$1(e)||Ke$1(125);let i=null;for(let e=0;e<c;e++){const t=l[e],n=t.cell;t.startRow===o&&(i=n),n.__colSpan>1&&(e+=n.__colSpan-1);}if(null===i)for(let n=r-1;n>=0;n--)ct(e,Fe$1(h[n]|f[t]).append(Li()));else for(let e=r-1;e>=0;e--)i.insertAfter(Fe$1(h[e]|f[t]).append(Li()));}t.setRowSpan(1);}}function ft(e,t,n){const[o,r,l]=gt(e,t,n);return null===r&&Ke$1(207),null===l&&Ke$1(208),[o,r,l]}function gt(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];$e$1(o)||Ke$1(209);const c=s(e);for(let a=o.getFirstChild(),u=0;null!=a;a=a.getNextSibling()){for(Oe$1(a)||Ke$1(147);void 0!==c[u];)u++;const o={cell:a,startColumn:u,startRow:e},{__rowSpan:h,__colSpan:d}=a;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[u+e]=o;}null!==t&&null===r&&t.is(a)&&(r=o),null!==n&&null===l&&n.is(a)&&(l=o);}}return [o,r,l]}function mt(e){let t;if(e instanceof xe)t=e;else if("__type"in e){const o=zs(e,Oe$1);
7150Oe$1(o)||Ke$1(148),t=o;}else {const o=zs(e.getNode(),Oe$1);Oe$1(o)||Ke$1(148),t=o;}const o=t.getParent();$e$1(o)||Ke$1(149);const r=o.getParent();return mn(r)||Ke$1(210),[t,o,r]}function pt(e,t,n){let o,r=Math.min(t.startColumn,n.startColumn),l=Math.min(t.startRow,n.startRow),s=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),i=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1);do{o=false;for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const c=e[t][n];if(!c)continue;const a=c.startColumn+c.cell.__colSpan-1,u=c.startRow+c.cell.__rowSpan-1,h=c.startColumn<=s&&a>=r,d=c.startRow<=i&&u>=l;if(h&&d){const e=Math.min(r,c.startColumn),t=Math.max(s,a),n=Math.min(l,c.startRow),h=Math.max(i,u);e===r&&t===s&&n===l&&h===i||(r=e,s=t,l=n,i=h,o=true);}}}while(o);return {maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function Ct(e){const[t,,n]=mt(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,c=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][r+n]=l;if(t===l)return {colSpan:c,columnIndex:r,rowIndex:e,rowSpan:i};r+=c;}}return null}function _t(e){const[[t,o,r,l],[s,i,c,a]]=["anchor","focus"].map(t=>{const o=e[t].getNode(),r=zs(o,Oe$1);Oe$1(r)||Ke$1(238,t,o.getKey(),o.getType());const l=r.getParent();$e$1(l)||Ke$1(239,t);const s=l.getParent();return mn(s)||Ke$1(240,t),[o,r,l,s]});return l.is(a)||Ke$1(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class St{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=false,this.tableKey=e;}getStartEndPoints(){return [this.anchor,this.focus]}isValid(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return false;const e=xo(this.tableKey),t=xo(this.anchor.key),n=xo(this.focus.key);return null!==e&&null!==t&&null!==n}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e;}is(e){return wt(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null;}clone(){return new St(this.tableKey,hr(this.anchor.key,this.anchor.offset,this.anchor.type),hr(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return false}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(Oe$1).forEach(e=>{const n=e.getFirstChild();Ii(n)&&(t|=n.getTextFormat());});const n=R$6[e];return 0!==(t&n)}insertNodes(e){const t=this.focus.getNode();Si(t)||Ke$1(151);St$6(t.select(0,t.getChildrenSize())).insertNodes(e);}getShape(){const{anchorCell:e,focusCell:t}=_t(this),n=Ct(e);null===n&&Ke$1(153);const o=Ct(t);null===o&&Ke$1(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return {fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return [];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=_t(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&Ke$1(159),this.set(this.tableKey,o.getKey(),e.getKey());}else {const e=t.getParent();null==e&&Ke$1(158),this.set(this.tableKey,e.getKey(),o.getKey());}return this.getNodes()}const[l,s,i]=ft(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=pt(l,s,i),d=new Map([[t.getKey(),t]]);let f=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();$e$1(o)||Ke$1(160),o!==f&&(d.set(o.getKey(),o),f=o),d.has(n.getKey())||Nt(n,e=>{d.set(e.getKey(),e);});}const g=Array.from(d.values());return ti()||(this._cachedNodes=g),g}getTextContent(){const e=this.getNodes().filter(e=>Oe$1(e));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t");}return t}}function wt(e){return e instanceof St}function bt(){const e=hr("root",0,"element"),t=hr("root",0,"element");return new St("root",e,t)}function yt(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=Lr(),r=wt(o)?o.clone():bt();return r.set(e.getKey(),t.getKey(),n.getKey()),r}function Nt(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():false!==t(o)&&Si(o)&&n.push(o.getChildren());}}
7150function vt(e,t=bs()){const n=xo(e);mn(n)||Ke$1(231,e);const o=Ft(n,t.getElementByKey(e));return null===o&&Ke$1(232,e),{tableElement:o,tableNode:n}}class xt{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=false,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=false,this.isSelecting=false,this.pointerType=null,this.shouldCheckSelection=false,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable();}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear();}$lookup(){return vt(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver(e=>{this.editor.getEditorState().read(()=>{let t=false;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=true;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=Ht(n,o);},{editor:this.editor});});this.editor.getEditorState().read(()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Ht(t,n),e.observe(n,{attributes:true,childList:true,subtree:true});},{editor:this.editor});}$clearHighlight(){const e=this.editor;this.isHighlightingCells=false,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=false,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();Lt(e,Ht(t,n),null),null!==Lr()&&(wo(null),e.dispatchCommand(ie$1,void 0));}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();ut$3(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=false;}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();lt$4(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=true;}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&Ke$1(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=true,this.$disableHighlightStyle(),this.updateDOMSelection(),Lt(t,this.table,this.tableSelection);}else this.$clearHighlight();}setShouldCheckSelection(){this.shouldCheckSelection=true;}getAndClearShouldCheckSelection(){return !!this.shouldCheckSelection&&(this.shouldCheckSelection=false,true)}setNextFocus(e){this.nextFocus=e;}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=ps(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges();}}$setFocusCellForSelection(e,t=false){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return false}else this.isHighlightingCells=true,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=ln(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=yt(o,this.$getAnchorTableCellOrThrow(),t),wo(this.tableSelection),n.dispatchCommand(ie$1,void 0),Lt(n,this.table,this.tableSelection),true}return false}$getAnchorTableCell(){return this.anchorCellNodeKey?xo(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Ke$1(234),e}$getFocusTableCell(){return this.focusCellNodeKey?xo(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Ke$1(235),e}
7150$setAnchorCellForSelection(e){this.isHighlightingCells=false,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=ln(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():bt(),this.anchorCellNodeKey=e;}}$formatCells(e){const t=Lr();wt(t)||Ke$1(236);const n=Ar(),o=n.anchor,r=n.focus,l=t.getNodes().filter(Oe$1);l.length>0||Ke$1(237);const s=l[0].getFirstChild(),i=Ii(s)?s.getFormatFlags(e,null):null;l.forEach(t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i);}),wo(t),this.editor.dispatchCommand(ie$1,void 0);}$clearText(){const{editor:e}=this,t=xo(this.tableNodeKey);if(!mn(t))throw new Error("Expected TableNode.");const n=Lr();wt(n)||Ke$1(253);const o=n.getNodes().filter(Oe$1),r=t.getFirstChild(),l=t.getLastChild();if(o.length>0&&null!==r&&null!==l&&$e$1(r)&&$e$1(l)&&o[0]===r.getFirstChild()&&o[o.length-1]===l.getLastChild()){t.selectPrevious();const n=t.getParent();return t.remove(),void(bi(n)&&n.isEmpty()&&e.dispatchCommand(ae$1,void 0))}o.forEach(e=>{if(Si(e)){const t=Li(),n=sr();
7150t.append(n),e.append(t),e.getChildren().forEach(e=>{e!==t&&e.remove();});}}),Lt(e,this.table,null),wo(null),e.dispatchCommand(ie$1,void 0);}}const Tt="__lexicalTableSelection";function Rt(e){return Cs(e)&&"TABLE"===e.nodeName}function Ft(e,t){if(!t)return t;const n=Rt(t)?t:e.getDOMSlot(t).element;return "TABLE"!==n.nodeName&&Ke$1(245,t.nodeName),n}function Ot(e){return e._window}function At(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;Oe$1(n)&&(o=n);}return null}const Kt=[[Te$2,"down"],[ke$2,"up"],[Se$1,"backward"],[xe$1,"forward"]],Et=[he$1,ge$1,le$2],kt=[we$1,Oe$2];function Mt(e,t,o,l){const s=o.getRootElement(),i=Ot(o);null!==s&&null!==i||Ke$1(246);const c=new xt(o,e.getKey()),a=Ft(e,t);!function(e,t){null!==$t(e)&&Ke$1(205);e[Tt]=t;}(a,c),c.listenersToRemove.add(()=>function(e,t){$t(e)===t&&delete e[Tt];}(a,c));const u=t=>{if(c.pointerType=t.pointerType,0!==t.button||!Ss(t.target)||!i)return;const n=zt(t.target);null!==n&&o.update(()=>{const o=Ir();if(He$1&&t.shiftKey&&Xt(o,e)&&(yr(o)||wt(o))){const r=o.anchor.getNode(),l=At(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(rn(c,l)),c.$setFocusCellForSelection(n),tn(t);else {(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type);}}else "touch"!==t.pointerType&&c.$setAnchorCellForSelection(n);}),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=false,i.removeEventListener("pointerup",e),i.removeEventListener("pointermove",t);},t=n=>{if(1&~n.buttons&&c.isSelecting)return c.isSelecting=false,i.removeEventListener("pointerup",e),void i.removeEventListener("pointermove",t);if(!Ss(n.target))return;let r=null;const l=!(He$1||a.contains(n.target));if(l)r=Wt(a,n.target);else for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(r=Wt(a,e),r)break;!r||null!==c.focusCell&&r.elem===c.focusCell.elem||(c.setNextFocus({focusCell:r,override:l}),o.dispatchCommand(ie$1,void 0));};c.isSelecting=true,i.addEventListener("pointerup",e,c.listenerOptions),i.addEventListener("pointermove",t,c.listenerOptions);})();};a.addEventListener("pointerdown",u,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("pointerdown",u);});const h=e=>{if(e.detail>=3&&Ss(e.target)){null!==zt(e.target)&&e.preventDefault();}};a.addEventListener("mousedown",h,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("mousedown",h);});const d=e=>{const t=e.target;0===e.button&&Ss(t)&&o.update(()=>{const e=Lr();wt(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight();});};i.addEventListener("pointerdown",d,c.listenerOptions),c.listenersToRemove.add(()=>{i.removeEventListener("pointerdown",d);});for(const[t,n]of Kt)c.listenersToRemove.add(o.registerCommand(t,t=>en(o,t,n,e,c),Bi));c.listenersToRemove.add(o.registerCommand(Ee$2,t=>{const n=Lr();if(wt(n)){const o=At(e,n.focus.getNode());if(null!==o)return tn(t),o.selectEnd(),true}return false},Bi));const g=t=>()=>{const o=Lr();if(!Xt(o,e))return false;if(wt(o))return c.$clearText(),true;if(yr(o)){if(!Oe$1(At(e,o.anchor.getNode())))return false;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),i=e.isParentOf(l);if(s&&!i||i&&!s)return c.$clearText(),true;const a=zs(o.anchor.getNode(),e=>Si(e)),u=a&&zs(a,e=>Si(e)&&Oe$1(e.getParent()));if(!Si(u)||!Si(a))return false;if(t===ge$1&&null===u.getPreviousSibling())return true}return false};for(const e of Et)c.listenersToRemove.add(o.registerCommand(e,g(e),Bi));const p=t=>{const n=Lr();if(!wt(n)&&!yr(n))return false;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),false}return !!Xt(n,e)&&(!!wt(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),true))};for(const e of kt)c.listenersToRemove.add(o.registerCommand(e,p,Bi));return c.listenersToRemove.add(o.registerCommand(Be$2,e=>{const t=Lr();if(t){if(!wt(t)&&!yr(t))return false;F$1(o,Lt$4(e,ClipboardEvent)?e:null,_$1(t));const n=p(e);return yr(t)?(t.removeText(),true):n}return false},Bi)),c.listenersToRemove.add(o.registerCommand(_e$1,t=>{const o=Lr();if(!Xt(o,e))return false;if(wt(o))return c.$formatCells(t),true;if(yr(o)){const e=zs(o.anchor.getNode(),e=>Oe$1(e));if(!Oe$1(e))return false}return false},Bi)),c.listenersToRemove.add(o.registerCommand(Le$2,t=>{const n=Lr();if(!wt(n)||!Xt(n,e))return false;
7150const o=n.anchor.getNode(),r=n.focus.getNode();if(!Oe$1(o)||!Oe$1(r))return false;if(function(e,t){if(wt(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=ft(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return false}(n,e))return e.setFormat(t),true;const[l,s,i]=ft(e,o,r),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),h=Math.min(s.startColumn,i.startColumn),d=new Set;for(let e=u;e<=c;e++)for(let n=h;n<=a;n++){const o=l[e][n].cell;if(d.has(o))continue;d.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];Si(n)&&!n.isInline()&&n.setFormat(t);}}return true},Bi)),c.listenersToRemove.add(o.registerCommand(ue$1,t=>{const r=Lr();if(!Xt(r,e))return false;if(wt(r))return c.$clearHighlight(),false;if(yr(r)){const l=zs(r.anchor.getNode(),e=>Oe$1(e));if(!Oe$1(l))return false;if("string"==typeof t){const n=on(o,r,e);if(n)return nn(n,e,[sr(t)]),true}}return false},Bi)),l&&c.listenersToRemove.add(o.registerCommand(Me$2,t=>{const o=Lr();if(!yr(o)||!o.isCollapsed()||!Xt(o,e))return false;const r=Gt(o.anchor.getNode());return !(null===r||!e.is(Qt(r)))&&(tn(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(Si(l))return l.selectEnd();const s=zs(e,$e$1);null===s&&Ke$1(247);for(let e=s[o]();$e$1(e);e=e[o]()){const t=e[r]();if(Si(t))return t.selectEnd()}const i=zs(s,mn);null===i&&Ke$1(248);"next"===t?i.selectNext():i.selectPrevious();}(r,t.shiftKey?"previous":"next"),true)},Bi)),c.listenersToRemove.add(o.registerCommand(Ve$1,t=>e.isSelected(),Bi)),c.listenersToRemove.add(o.registerCommand(oe$2,(e,t)=>{if(o!==t)return false;const{nodes:r,selection:l}=e,s=l.getStartEndPoints(),i=wt(l),c=yr(l)&&null!==zs(l.anchor.getNode(),e=>Oe$1(e))&&null!==zs(l.focus.getNode(),e=>Oe$1(e))||i;if(1!==r.length||!mn(r[0])||!c||null===s)return false;const[a,u]=s,[h,d,g]=mt(a),p=zs(u.getNode(),e=>Oe$1(e));if(!(Oe$1(h)&&Oe$1(p)&&$e$1(d)&&mn(g)))return false;const C=r[0],[_,S,b]=ft(g,h,p),[y]=gt(C,null,null),N=_.length,v=N>0?_[0].length:0;let x=S.startRow,T=S.startColumn,R=y.length,F=R>0?y[0].length:0;if(i){const e=pt(_,S,b),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;x=e.minRow,T=e.minColumn,R=Math.min(R,t),F=Math.min(F,n);}let O=false;const A=Math.min(N,x+R)-1,K=Math.min(v,T+F)-1,E=new Set;for(let e=x;e<=A;e++)for(let t=T;t<=K;t++){const n=_[e][t];E.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(dt(n.cell),E.add(n.cell.getKey()),O=true));}let[k]=gt(g.getWritable(),null,null);const M=R-N+x;for(let e=0;e<M;e++){Ge$1(k[N-1][0].cell);}const $=F-v+T;for(let e=0;e<$;e++){tt(k[0][v-1].cell,true,false);}[k]=gt(g.getWritable(),null,null);for(let e=x;e<x+R;e++)for(let t=T;t<T+F;t++){const n=e-x,o=t-T,r=y[n][o];if(r.startRow!==n||r.startColumn!==o)continue;const l=r.cell;if(1!==l.__rowSpan||1!==l.__colSpan){const n=[],o=Math.min(e+l.__rowSpan,x+R)-1,r=Math.min(t+l.__colSpan,T+F)-1;for(let l=e;l<=o;l++)for(let e=t;e<=r;e++){const t=k[l][e];n.push(t.cell);}at(n),O=true;}const{cell:s}=k[e][t],i=s.getChildren();
7150l.getChildren().forEach(e=>{if(lr(e)){Li().append(e),s.append(e);}else s.append(e);}),i.forEach(e=>e.remove());}if(i&&O){const[e]=gt(g.getWritable(),null,null);e[S.startRow][S.startColumn].cell.selectEnd();}return true},Bi)),c.listenersToRemove.add(o.registerCommand(ie$1,()=>{const t=Lr(),r=Ir(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(wt(t)&&t.tableKey===c.tableNodeKey)return (n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),true);if(n!==c.anchorCell&&Xt(t,e))return c.$setFocusCellForSelection(n),true}if(c.getAndClearShouldCheckSelection()&&yr(r)&&yr(t)&&t.isCollapsed()){const o=t.anchor.getNode(),r=e.getFirstChild(),l=Gt(o);if(null!==l&&$e$1(r)){const t=r.getFirstChild();if(Oe$1(t)&&e.is(zs(l,n=>n.is(e)||n.is(t))))return t.selectStart(),true}}if(yr(t)){const{anchor:n,focus:l}=t,s=n.getNode(),i=l.getNode(),a=Gt(s),u=Gt(i),h=!(!a||!e.is(Qt(a))),d=!(!u||!e.is(Qt(u))),f=h!==d,g=h&&d,m=t.isBackward();if(f){const n=t.clone();if(d){const[t]=ft(e,u,u),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(m?o.getKey():r.getKey(),m?o.getChildrenSize():r.getChildrenSize(),"element");}else if(h){const[t]=ft(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(m?r.getKey():o.getKey(),m?r.getChildrenSize():0,"element");}wo(n),Pt(o,c);}else if(g&&(a.is(u)||(c.$setAnchorCellForSelection(rn(c,a)),c.$setFocusCellForSelection(rn(c,u),true)),"touch"===c.pointerType&&c.isSelecting&&t.isCollapsed()&&yr(r)&&r.isCollapsed())){const e=Gt(r.anchor.getNode());e&&!e.is(u)&&(c.$setAnchorCellForSelection(rn(c,e)),c.$setFocusCellForSelection(rn(c,u),true),c.pointerType=null);}}else if(t&&wt(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=ps(i);if(n&&n.anchorNode&&n.focusNode){const r=vo(n.focusNode),l=r&&!e.isParentOf(r),s=vo(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=Dr(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),wo(r));}}}return t&&!t.is(r)&&(wt(t)||wt(r))&&c.tableSelection&&!c.tableSelection.is(r)?(wt(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!wt(t)&&wt(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),false):(c.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),Bt(t.table,t=>{const n=t.elem;t.highlighted=false,Vt(e,t),n.getAttribute("style")||n.removeAttribute("style");});}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&Pt(o,c),false)},Bi)),c.listenersToRemove.add(o.registerCommand(ae$1,()=>{const t=Lr();if(!yr(t)||!t.isCollapsed()||!Xt(t,e))return false;const n=on(o,t,e);return !!n&&(nn(n,e),true)},Bi)),c}function $t(e){return e[Tt]||null}function zt(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode;}return null}function Wt(e,t){if(!e.contains(t))return null;let n=null;for(let o=t;null!=o;o=o.parentNode){if(o===e)return n;const t=o.nodeName;"TD"!==t&&"TH"!==t||(n=o._cell||null);}return null}function Ht(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=Ft(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:false,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e;}else {const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e;}}return o.columns=l+1,o.rows=s+1,o}function Lt(e,t,n){const o=new Set(n?n.getNodes():[]);Bt(t,(t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=true,jt(e,t)):(t.highlighted=false,Vt(e,t),r.getAttribute("style")||r.removeAttribute("style"));});}function Bt(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=vo(r.elem);null!==l&&t(r,l,{x:n,y:e});}}}function Pt(e,t){t.$disableHighlightStyle(),Bt(t.table,t=>{t.highlighted=true,jt(e,t);});}const Dt=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case "backward":case "forward":return n!==(l?e.table.columns-1:0)?qt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?qt(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),true;case "up":return 0!==o?qt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),false):t.selectPrevious(),true;case "down":return o!==e.table.rows-1?qt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),true):t.selectNext(),true;default:return false}};function It(e,t){let n,o;
7150if(t.startColumn===e.minColumn)n="minColumn";else {if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn";}if(t.startRow===e.minRow)o="minRow";else {if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow";}return [n,o]}function Ut([e,t]){return ["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function Jt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&Ke$1(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&Ke$1(250,n,String(s)),i}function Yt(e,t,n,o,r){const l=pt(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return {bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=It(e,t);return null===n&&Ke$1(249,t.cell.getKey()),n}(l,n),[d,f]=Ut(h);let g=l[d],m=l[f];"forward"===r?g+="maxColumn"===d?1:c:"backward"===r?g-="minColumn"===d?1:u:"down"===r?m+="maxRow"===f?1:i:"up"===r&&(m-="minRow"===f?1:a);const p=t[m];if(void 0===p)return false;const C=p[g];if(void 0===C)return false;const[_,S]=function(e,t,n){const o=pt(e,t,n),r=It(o,t);if(r)return [Jt(e,o,r),Jt(e,o,Ut(r))];const l=It(o,n);if(l)return [Jt(e,o,Ut(l)),Jt(e,o,l)];const s=["minColumn","minRow"];return [Jt(e,o,s),Jt(e,o,Ut(s))]}(t,n,C),w=rn(e,_.cell),b=rn(e,S.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,true),true}function Xt(e,t){if(yr(e)||wt(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return false}function qt(e,t){t?e.selectStart():e.selectEnd();}function jt(t,n){const o=n.elem,r=t._config.theme;Oe$1(vo(o))||Ke$1(131),lt$4(o,r.tableCellSelected);}function Vt(e,t){const n=t.elem;Oe$1(vo(n))||Ke$1(131);const r=e._config.theme;ut$3(n,r.tableCellSelected);}function Gt(e){const t=zs(e,Oe$1);return Oe$1(t)?t:null}function Qt(e){const t=zs(e,mn);return mn(t)?t:null}function Zt(e,t,o,r,l,s,i){const c=xl(o.focus,l?"previous":"next");if(Ol(c))return false;let a=c;for(const e of ul(c).iterNodeCarets("shadowRoot")){if(!Hs(e)||!Si(e.origin))return false;a=e;}const u=a.getParentAtCaret();if(!Oe$1(u))return false;const h=u,d=function(e){for(const t of ul(e).iterNodeCarets("root")){const{origin:n}=t;if(Oe$1(n)){if(Gs(t))return il(n,e.direction)}else if(!$e$1(n))break}return null}(tl(h,a.direction)),f=zs(h,mn);if(!f||!f.is(s))return false;const g=e.getElementByKey(h.getKey()),m=zt(g);if(!g||!m)return false;const p=dn(e,f);if(i.table=p,d)if("extend"===r){const t=zt(e.getElementByKey(d.origin.getKey()));if(!t)return false;i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(t,true);}else {const e=El(d);Cl(o.anchor,e),Cl(o.focus,e);}else if("extend"===r)i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(m,true);else {const e=function(e){const t=sl(e);return Gs(t)?El(t):e}(tl(f,c.direction));Cl(o.anchor,e),Cl(o.focus,e);}return tn(t),true}function en(e,t,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return false;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return false;const s=Lr();if(!Xt(s,r)){if(yr(s)){if("backward"===o){if(s.focus.offset>0)return false;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(Si(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return false;const n=e.getPreviousSibling();return !!mn(n)&&(tn(t),t.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),true)}if(t.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=zs(e,e=>mn(e));if(Oe$1(l)&&(l=zs(l,mn)),l!==r)return false;if(!l)return false;const i="down"===o?l.getNextSibling():l.getPreviousSibling();if(!i)return false;let c=0;"up"===o&&Si(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&Si(i)){const e=i.getLastChild();a=e||i,c=lr(a)?a.getTextContentSize():0;}const u=s.clone();return u.focus.set(a.getKey(),c,lr(a)?"text":"element"),wo(u),tn(t),true}if(as(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==At(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return false;
7150const[n]=mt(e),[o]=mt(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),c=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,true),true}}return false}{let r=zs(e,e=>Si(e)&&!e.isInline());if(Oe$1(r)&&(r=zs(r,mn)),!r)return false;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(mn(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return false;const[r]=mt(e),[l]=mt(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),tn(t),wo(c),true}}}}return "down"===o&&an(e)&&l.setShouldCheckSelection(),false}if(yr(s)){if("backward"===o||"forward"===o){return Zt(e,t,s,t.shiftKey?"extend":"move","backward"===o,r,l)}if(s.isCollapsed()){const{anchor:i,focus:c}=s,a=zs(i.getNode(),Oe$1),u=zs(c.getNode(),Oe$1);if(!Oe$1(a)||!a.is(u))return false;const h=Qt(a);if(h!==r&&null!=h){const n=Ft(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=Ht(h,n),en(e,t,o,h,l)}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return false;let g;if("element"===i.type)g=f.getBoundingClientRect();else {const t=ps(Ot(e));if(null===t||0===t.rangeCount)return false;g=t.getRangeAt(0).getBoundingClientRect();}const m="up"===o?a.getFirstChild():a.getLastChild();if(null==m)return false;const p=e.getElementByKey(m.__key);if(null==p)return false;const C=p.getBoundingClientRect();if("up"===o?C.top>g.top-g.height:g.bottom+g.height>C.bottom){tn(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return Dt(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,true);}return true}}}else if(wt(s)){const{anchor:i,focus:c}=s,a=zs(i.getNode(),Oe$1),u=zs(c.getNode(),Oe$1),[h]=s.getNodes();mn(h)||Ke$1(251);const d=Ft(h,e.getElementByKey(h.getKey()));if(!Oe$1(a)||!Oe$1(u)||!mn(h)||null==d)return false;l.$updateTableTableSelection(s);const f=Ht(h,d),g=r.getCordsFromCellNode(a,f),m=r.getDOMCellFromCordsOrThrow(g.x,g.y,f);
7150if(l.$setAnchorCellForSelection(m),tn(t),t.shiftKey){const[e,t,n]=ft(r,a,u);return Yt(l,e,t,n,o)}return u.selectEnd(),true}return false}function tn(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation();}function nn(e,t,n){const o=Li();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd();}function on(e,t,o){const r=o.getParent();if(!r)return;const l=ps(Ot(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=Ft(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=zs(t.anchor.getNode(),e=>Oe$1(e));if(!a)return;const u=zs(a,e=>mn(e));if(!mn(u)||!u.is(o))return;const[h,d]=ft(o,a,a),f=h[0][0],g=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,C=m===f.startRow&&p===f.startColumn,_=m===g.startRow&&p===g.startColumn;return C?"first":_?"last":void 0}function rn(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function ln(e,t,n){return At(e,vo(t,n))}function sn(t,n,r){if(!n.theme.tableAlignment)return;const l=[],s=[];for(const e of ["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===r?s:l).push(t);}ut$3(t,...l),lt$4(t,...s);}const cn=new WeakSet;function an(e=bs()){return cn.has(e)}function un(e,t){cn.add(e);}class hn extends Ci{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return "table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new hn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount;}static importDOM(){return {table:e=>({conversion:fn,priority:1})}}static importJSON(e){return gn().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||false).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=false,this.__frozenColumnCount=0,this.__frozenRowCount=0,this.__colWidths=void 0;}exportJSON(){return {...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return "html"===n}getDOMSlot(e){const t=Rt(e)?e:e.querySelector("table");return Rt(t)||Ke$1(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table");this.__style&&(o.style.cssText=this.__style);const r=document.createElement("colgroup");if(o.appendChild(r),Ds(r),lt$4(o,t.theme.table),this.updateTableElement(null,o,t),an(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?lt$4(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),this.updateTableWrapper(null,n,o,t),n}return o}updateTableWrapper(t,n,r,l){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,r,l){l>0?(lt$4(t,r.theme.tableFrozenColumn),n.setAttribute("data-lexical-frozen-column","true")):(ut$3(t,r.theme.tableFrozenColumn),n.removeAttribute("data-lexical-frozen-column"));}(n,r,l,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,r,l){l>0?(lt$4(t,r.theme.tableFrozenRow),n.setAttribute("data-lexical-frozen-row","true")):(ut$3(t,r.theme.tableFrozenRow),n.removeAttribute("data-lexical-frozen-row"));}(n,r,l,this.__frozenRowCount);}updateTableElement(t,n,r){this.__style!==(t?t.__style:"")&&(n.style.cssText=this.__style),this.__rowStriping!==(!!t&&t.__rowStriping)&&function(t,n,r){r?(lt$4(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(ut$3(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"));}(n,r,this.__rowStriping),function(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t);}r.replaceChildren(...l);}(n,0,this.getColumnCount(),this.getColWidths()),sn(n,r,this.getFormatType());}updateDOM(e,t,n){const o=this.getDOMSlot(t).element;return t===o===an()||(Cs(r=t)&&"DIV"===r.nodeName&&this.updateTableWrapper(e,t,o,n),this.updateTableElement(e,o,n),false);var r;}exportDOM(e){const t=super.exportDOM(e),{element:n}=t;return {after:n=>{if(t.after&&(n=t.after(n)),!Rt(n)&&Cs(n)&&(n=n.querySelector("table")),!Rt(n))return null;sn(n,e._config,this.getFormatType());const[o]=gt(this,null,null),r=new Map;for(const e of o)for(const t of e){const e=t.cell.getKey();r.has(e)||r.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn});}const s=new Set;for(const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=r.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){r.delete(t);for(let e=0;e<n.colSpan;e++)s.add(e+n.startColumn);}}}const i=n.querySelector(":scope > colgroup");if(i){const e=Array.from(n.querySelectorAll(":scope > colgroup > col")).filter((e,t)=>
7150s.has(t));i.replaceChildren(...e);}const c=n.querySelectorAll(":scope > tr");if(c.length>0){const e=document.createElement("tbody");for(const t of c)e.appendChild(t);n.append(e);}return n},element:!Rt(n)&&Cs(n)?n.querySelector("table"):n}}canBeEmpty(){return false}isShadowRoot(){return true}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=ln(this,l);if(null!==s&&e.is(s))return {x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=vo(o.elem);return Oe$1(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){const t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return true}canIndent(){return false}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;
7150return e.getChildren().forEach(e=>{Oe$1(e)&&(t+=e.getColSpan());}),t}}function dn(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Ke$1(230),Ht(t,n)}function fn(e){const n=gn();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(true),e.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!Ne$1.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n));}e&&n.setColWidths(e);}return {after:e=>kt$6(e,$e$1),node:n}}function gn(){return fs(new hn)}function mn(e){return e instanceof hn}function pn({rows:e,columns:t,includeHeaders:n}){const o=Lr()||Ir();if(!o||!yr(o))return false;if(Qt(o.anchor.getNode()))return false;const r=Le$1(Number(e),Number(t),n);At$5(r);const l=r.getFirstDescendant();return lr(l)&&l.select(),true}function Cn(e){$e$1(e.getParent())?e.isEmpty()&&e.append(Li()):e.remove();}function _n(e){mn(e.getParent())?Bt$3(e,Oe$1):e.remove();}function Sn(e){Bt$3(e,$e$1);const[t]=gt(e,null,null),n=t.reduce((e,t)=>Math.max(e,t.length),0),o=e.getChildren();for(let e=0;e<t.length;++e){const r=o[e];if(!r)continue;$e$1(r)||Ke$1(254,r.constructor.name,r.getType());const l=t[e].reduce((e,t)=>t?1+e:e,0);if(l!==n)for(let e=l;e<n;++e){const e=Fe$1();e.append(Li()),r.append(e);}}}function wn(e){if(e.detail<3||!Ss(e.target))return false;const t=vo(e.target);if(null===t)return false;const o=zs(t,e=>Si(e)&&!e.isInline());if(null===o)return false;return !!Oe$1(o.getParent())&&(o.select(0),true)}function yn(e,t=true){const n=new Map,o=(o,r,l)=>{const s=Ft(o,l),i=Mt(o,s,e,t);n.set(r,[i,s]);},r=e.registerMutationListener(hn,t=>{e.getEditorState().read(()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=vt(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l));}else "destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e));}},{editor:e});},{skipInitialization:false});return ()=>{r();for(const[,[e]]of n)e.removeListeners();}}function Nn(e){return e.hasNodes([hn])||Ke$1(255),U$4(e.registerCommand(Ae$1,pn,Ki),e.registerCommand(oe$2,({nodes:t,selection:n},o)=>{if(e!==o||!yr(n))return false;return null!==Qt(n.anchor.getNode())&&t.some(mn)},Ki),e.registerCommand(se$1,wn,Ki),e.registerNodeTransform(hn,Sn),e.registerNodeTransform(Ee$1,_n),e.registerNodeTransform(xe,Cn))} 7151 7152const SILENT_UPDATE_TAGS = [ Dn, Kn ]; 7153 7154function $createNodeSelectionWith(...nodes) { 7155 const selection = Pr(); 7156 nodes.forEach(node => selection.add(node.getKey())); 7157 return selection 7158} 7159 7160function $makeSafeForRoot(node) { 7161 if (lr(node)) { 7162 return bt$6(node, Li) 7163 } else if (node.isParentRequired()) { 7164 const parent = node.createRequiredParent(); 7165 return bt$6(node, parent) 7166 } else { 7167 return node 7168 } 7169} 7170 7171function getListType(node) { 7172 const list = wt$5(node, lt$3); 7173 return list?.getListType() ?? null 7174} 7175 7176function $isAtNodeEdge(point, atStart = null) { 7177 if (atStart === null) { 7178 return $isAtNodeEdge(point, true) || $isAtNodeEdge(point, false) 7179 } else { 7180 return atStart ? $isAtNodeStart(point) : _$2(point) 7181 } 7182} 7183 7184function $isAtNodeStart(point) { 7185 return point.offset === 0 7186} 7187 7188function extendTextNodeConversion(conversionName, ...callbacks) { 7189 return extendConversion(Xn, conversionName, (conversionOutput, element) => ({ 7190 ...conversionOutput, 7191 forChild: (lexicalNode, parentNode) => { 7192 const originalForChild = conversionOutput?.forChild ?? (x => x); 7193 let childNode = originalForChild(lexicalNode, parentNode); 7194 7195 7196 if (lr(childNode)) { 7197 childNode = callbacks.reduce( 7198 (childNode, callback) => callback(childNode, element) ?? childNode, 7199 childNode 7200 ); 7201 return childNode 7202 } 7203 } 7204 })) 7205} 7206 7207function extendConversion(nodeKlass, conversionName, callback = (output => output)) { 7208 return (element) => { 7209 const converter = nodeKlass.importDOM()?.[conversionName]?.(element); 7210 if (!converter) return null 7211 7212 const conversionOutput = converter.conversion(element); 7213 if (!conversionOutput) return conversionOutput 7214 7215 return callback(conversionOutput, element) ?? conversionOutput 7216 } 7217} 7218 7219function isSelectionHighlighted(selection) { 7220 if (!yr(selection)) return false 7221 7222 if (selection.isCollapsed()) { 7223 return hasHighlightStyles(selection.style) 7224 } else { 7225 return selection.hasFormat("highlight") 7226 } 7227} 7228 7229function hasHighlightStyles(cssOrStyles) { 7230 const styles = typeof cssOrStyles === "string" ? b$3(cssOrStyles) : cssOrStyles; 7231 return !!(styles.color || styles["background-color"]) 7232} 7233 7234function applyCanonicalizers(styles, canonicalizers = []) {
7235 return canonicalizers.reduce((css, canonicalizer) => { 7236 return canonicalizer.applyCanonicalization(css) 7237 }, styles) 7238} 7239 7240class StyleCanonicalizer { 7241 constructor(property, allowedValues= []) { 7242 this._property = property; 7243 this._allowedValues = allowedValues; 7244 this._canonicalValues = this.#allowedValuesIdentityObject; 7245 } 7246 7247 applyCanonicalization(css) { 7248 const styles = { ...b$3(css) }; 7249 7250 styles[this._property] = this.getCanonicalAllowedValue(styles[this._property]); 7251 if (!styles[this._property]) { 7252 delete styles[this._property]; 7253 } 7254 7255 return R$5(styles) 7256 } 7257 7258 getCanonicalAllowedValue(value) { 7259 return this._canonicalValues[value] ||= this.#resolveCannonicalValue(value) 7260 } 7261 7262 // Private 7263 7264 get #allowedValuesIdentityObject() { 7265 return this._allowedValues.reduce((object, value) => ({ ...object, [value]: value }), {}) 7266 } 7267 7268 #resolveCannonicalValue(value) { 7269 let index = this.#computedAllowedValues.indexOf(value); 7270 index ||= this.#computedAllowedValues.indexOf(getComputedStyleForProperty(this._property, value)); 7271 return index === -1 ? null : this._allowedValues[index] 7272 } 7273 7274 get #computedAllowedValues() { 7275 return this._computedAllowedValues ||= this._allowedValues.map( 7276 value => getComputedStyleForProperty(this._property, value) 7277 ) 7278 } 7279} 7280 7281function getComputedStyleForProperty(property, value) { 7282 const style = `${property}: ${value};`; 7283 7284 // the element has to be attached to the DOM have computed styles 7285 const element = document.body.appendChild(createElement("span", { style: "display: none;" + style })); 7286 const computedStyle = window.getComputedStyle(element).getPropertyValue(property); 7287 element.remove(); 7288 7289 return computedStyle 7290} 7291 7292class LexxyExtension { 7293 #editorElement 7294 7295 constructor(editorElement) { 7296 this.#editorElement = editorElement; 7297 } 7298 7299 get editorElement() { 7300 return this.#editorElement 7301 } 7302 7303 get editorConfig() { 7304 return this.#editorElement.config 7305 } 7306 7307 // optional: defaults to true 7308 get enabled() { 7309 return true 7310 } 7311 7312 get lexicalExtension() { 7313 return null 7314 } 7315 7316 initializeToolbar(_lexxyToolbar) { 7317 7318 } 7319} 7320 7321const TOGGLE_HIGHLIGHT_COMMAND = re$1(); 7322const REMOVE_HIGHLIGHT_COMMAND = re$1(); 7323const BLANK_STYLES = { "color": null, "background-color": null }; 7324 7325const hasPastedStylesState = ot$5("hasPastedStyles", { 7326 parse: (value) => value || false 7327}); 7328 7329class HighlightExtension extends LexxyExtension { 7330 get enabled() { 7331 return this.editorElement.supportsRichText 7332 } 7333 7334 get lexicalExtension() { 7335 const extension = Kl({ 7336 dependencies: [ Wt$2 ], 7337 name: "lexxy/highlight", 7338 config: { 7339 color: { buttons: [], permit: [] }, 7340 "background-color": { buttons: [], permit: [] } 7341 }, 7342 html: { 7343 import: { 7344 mark: $markConversion 7345 } 7346 }, 7347 register(editor, config) { 7348 // keep the ref to the canonicalizers for optimized css conversion 7349 const canonicalizers = buildCanonicalizers(config); 7350 7351 return U$4( 7352 editor.registerCommand(TOGGLE_HIGHLIGHT_COMMAND, $toggleSelectionStyles, Ri), 7353 editor.registerCommand(REMOVE_HIGHLIGHT_COMMAND, () => $toggleSelectionStyles(BLANK_STYLES), Ri), 7354 editor.registerNodeTransform(Xn, $syncHighlightWithStyle), 7355 editor.registerNodeTransform(Xn, (textNode) => $canonicalizePastedStyles(textNode, canonicalizers)) 7356 ) 7357 } 7358 }); 7359 7360 return [ extension, this.editorConfig.get("highlight") ] 7361 } 7362} 7363 7364function $applyHighlightStyle(textNode, element) { 7365 const elementStyles = { 7366 color: element.style?.color, 7367 "background-color": element.style?.backgroundColor 7368 }; 7369 7370 if (es(Fn)) { $setPastedStyles(textNode); } 7371 const highlightStyle = R$5(elementStyles); 7372 7373 if (highlightStyle.length) { 7374 return textNode.setStyle(textNode.getStyle() + highlightStyle) 7375 } 7376} 7377 7378function $markConversion() { 7379 return { 7380 conversion: extendTextNodeConversion("mark", $applyHighlightStyle), 7381 priority: 1 7382 } 7383} 7384 7385function buildCanonicalizers(config) { 7386 return [ 7387 new StyleCanonicalizer("color", [ ...config.buttons.color, ...config.permit.color ]), 7388 new StyleCanonicalizer("background-color", [ ...config.buttons["background-color"], ...config.permit["background-color"] ]) 7389 ] 7390} 7391 7392function $toggleSelectionStyles(styles) { 7393 const selection = Lr(); 7394 if (!yr(selection)) return 7395 7396 const patch = {}; 7397 for (const property in styles) { 7398 const oldValue = le$1(selection, property); 7399 patch[property] = toggleOrReplace(oldValue, styles[property]); 7400 } 7401 7402 U$5(selection, patch); 7403} 7404 7405function toggleOrReplace(oldValue, newValue) { 7406 return oldValue === newValue ? null : newValue 7407} 7408 7409function $syncHighlightWithStyle(textNode) { 7410 if (hasHighlightStyles(textNode.getStyle()) !== textNode.hasFormat("highlight")) { 7411 textNode.toggleFormat("highlight"); 7412 } 7413} 7414 7415function $canonicalizePastedStyles(textNode, canonicalizers = []) { 7416 if ($hasPastedStyles(textNode)) { 7417 $setPastedStyles(textNode, false); 7418 7419 const canonicalizedCSS = applyCanonicalizers(textNode.getStyle(), canonicalizers); 7420 textNode.setStyle(canonicalizedCSS); 7421 7422 const selection = Lr(); 7423 if (textNode.isSelected(selection)) { 7424 selection.setStyle(textNode.getStyle()); 7425 selection.setFormat(textNode.getFormat()); 7426 } 7427 } 7428} 7429 7430function $setPastedStyles(textNode, value = true) { 7431 ct$5(textNode, hasPastedStylesState, value); 7432} 7433 7434function $hasPastedStyles(textNode) { 7435 return st$4(textNode, hasPastedStylesState) 7436} 7437 7438const COMMANDS = [ 7439 "bold", 7440 "italic", 7441 "strikethrough", 7442 "link", 7443 "unlink", 7444 "toggleHighlight", 7445 "removeHighlight", 7446 "rotateHeadingFormat", 7447 "insertUnorderedList", 7448 "insertOrderedList", 7449 "insertQuoteBlock", 7450 "insertCodeBlock", 7451 "insertHorizontalDivider", 7452 "uploadAttachments", 7453 7454 "insertTable", 7455 7456 "undo", 7457 "redo" 7458]; 7459
7460class CommandDispatcher { 7461 static configureFor(editorElement) { 7462 new CommandDispatcher(editorElement); 7463 } 7464 7465 constructor(editorElement) { 7466 this.editorElement = editorElement; 7467 this.editor = editorElement.editor; 7468 this.selection = editorElement.selection; 7469 this.contents = editorElement.contents; 7470 this.clipboard = editorElement.clipboard; 7471 7472 this.#registerCommands(); 7473 this.#registerKeyboardCommands(); 7474 this.#registerDragAndDropHandlers(); 7475 } 7476 7477 dispatchPaste(event) { 7478 return this.clipboard.paste(event) 7479 } 7480 7481 dispatchBold() { 7482 this.editor.dispatchCommand(_e$1, "bold"); 7483 } 7484 7485 dispatchItalic() { 7486 this.editor.dispatchCommand(_e$1, "italic"); 7487 } 7488 7489 dispatchStrikethrough() { 7490 this.editor.dispatchCommand(_e$1, "strikethrough"); 7491 } 7492 7493 dispatchToggleHighlight(styles) { 7494 this.editor.dispatchCommand(TOGGLE_HIGHLIGHT_COMMAND, styles); 7495 } 7496 7497 dispatchRemoveHighlight() { 7498 this.editor.dispatchCommand(REMOVE_HIGHLIGHT_COMMAND); 7499 } 7500 7501 dispatchLink(url) { 7502 this.editor.update(() => { 7503 const selection = Lr(); 7504 if (!yr(selection)) return 7505 7506 if (selection.isCollapsed()) { 7507 const autoLinkNode = I$3(url); 7508 const textNode = sr(url); 7509 autoLinkNode.append(textNode); 7510 selection.insertNodes([ autoLinkNode ]); 7511 } else { 7512 J$2(url); 7513 } 7514 }); 7515 } 7516 7517 dispatchUnlink() { 7518 this.#toggleLink(null); 7519 } 7520 7521 dispatchInsertUnorderedList() { 7522 const selection = Lr(); 7523 if (!selection) return 7524 7525 const anchorNode = selection.anchor.getNode(); 7526 7527 if (this.selection.isInsideList && anchorNode && getListType(anchorNode) === "bullet") { 7528 this.contents.unwrapSelectedListItems(); 7529 } else { 7530 this.editor.dispatchCommand(St$4, undefined); 7531 } 7532 } 7533 7534 dispatchInsertOrderedList() { 7535 const selection = Lr(); 7536 if (!selection) return 7537 7538 const anchorNode = selection.anchor.getNode(); 7539 7540 if (this.selection.isInsideList && anchorNode && getListType(anchorNode) === "number") { 7541 this.contents.unwrapSelectedListItems(); 7542 } else { 7543 this.editor.dispatchCommand(xt$3, undefined); 7544 } 7545 } 7546 7547 dispatchInsertQuoteBlock() { 7548 this.contents.toggleNodeWrappingAllSelectedNodes((node) => Ot$2(node), () => _t$2()); 7549 } 7550 7551 dispatchInsertCodeBlock() { 7552 this.editor.update(() => { 7553 if (this.selection.hasSelectedWordsInSingleLine) { 7554 this.editor.dispatchCommand(_e$1, "code"); 7555 } else { 7556 this.contents.toggleNodeWrappingAllSelectedLines((node) => X$1(node), () => new q$1("plain")); 7557 } 7558 }); 7559 } 7560 7561 dispatchInsertHorizontalDivider() { 7562 this.contents.insertAtCursorEnsuringLineBelow(new HorizontalDividerNode()); 7563 this.editor.focus(); 7564 } 7565 7566 dispatchRotateHeadingFormat() { 7567 const selection = Lr(); 7568 if (!yr(selection)) return 7569 7570 if (as(selection.anchor.getNode())) { 7571 selection.insertNodes([ St$3("h2") ]); 7572 return 7573 } 7574 7575 const topLevelElement = selection.anchor.getNode().getTopLevelElementOrThrow(); 7576 let nextTag = "h2"; 7577 if (It$2(topLevelElement)) { 7578 const currentTag = topLevelElement.getTag(); 7579 if (currentTag === "h2") { 7580 nextTag = "h3"; 7581 } else if (currentTag === "h3") { 7582 nextTag = "h4"; 7583 } else if (currentTag === "h4") { 7584 nextTag = null; 7585 } else { 7586 nextTag = "h2"; 7587 } 7588 } 7589 7590 if (nextTag) { 7591 this.contents.insertNodeWrappingEachSelectedLine(() => St$3(nextTag)); 7592 } else { 7593 this.contents.removeFormattingFromSelectedLines(); 7594 } 7595 } 7596 7597 dispatchUploadAttachments() { 7598 const input = createElement("input", { 7599 type: "file", 7600 multiple: true, 7601 style: "display: none;", 7602 onchange: ({ target: { files } }) => { 7603 this.contents.uploadFiles(files, { selectLast: true }); 7604 } 7605 }); 7606 7607 // Append and remove to make testable 7608 this.editorElement.appendChild(input); 7609 input.click(); 7610 setTimeout(() => input.remove(), 1000); 7611 } 7612 7613 dispatchInsertTable() { 7614 this.editor.dispatchCommand(Ae$1, { "rows": 3, "columns": 3, "includeHeaders": true }); 7615 } 7616 7617 dispatchUndo() { 7618 this.editor.dispatchCommand(pe$1, undefined); 7619 } 7620 7621 dispatchRedo() { 7622 this.editor.dispatchCommand(ye$1, undefined); 7623 } 7624 7625 #registerCommands() { 7626 for (const command of COMMANDS) { 7627 const methodName = `dispatch${capitalize(command)}`; 7628 this.#registerCommandHandler(command, 0, this[methodName].bind(this)); 7629 } 7630 7631 this.#registerCommandHandler(fe$1, zi, this.dispatchPaste.bind(this)); 7632 } 7633 7634 #registerCommandHandler(command, priority, handler) { 7635 this.editor.registerCommand(command, handler, priority); 7636 } 7637 7638 #registerKeyboardCommands() { 7639 this.editor.registerCommand(Me$2, this.#handleTabKey.bind(this), Ri); 7640 } 7641 7642 #registerDragAndDropHandlers() { 7643 if (this.editorElement.supportsAttachments) { 7644 this.dragCounter = 0; 7645 this.editor.getRootElement().addEventListener("dragover", this.#handleDragOver.bind(this)); 7646 this.editor.getRootElement().addEventListener("drop", this.#handleDrop.bind(this)); 7647 this.editor.getRootElement().addEventListener("dragenter", this.#handleDragEnter.bind(this)); 7648 this.editor.getRootElement().addEventListener("dragleave", this.#handleDragLeave.bind(this)); 7649 } 7650 } 7651 7652 #handleDragEnter(event) { 7653 this.dragCounter++; 7654 if (this.dragCounter === 1) { 7655 this.editor.getRootElement().classList.add("lexxy-editor--drag-over"); 7656 } 7657 } 7658 7659 #handleDragLeave(event) { 7660 this.dragCounter--; 7661 if (this.dragCounter === 0) { 7662 this.editor.getRootElement().classList.remove("lexxy-editor--drag-over"); 7663 } 7664 } 7665 7666 #handleDragOver(event) { 7667 event.preventDefault(); 7668 } 7669 7670 #handleDrop(event) { 7671 event.preventDefault(); 7672 7673 this.dragCounter = 0; 7674 this.editor.getRootElement().classList.remove("lexxy-editor--drag-over"); 7675 7676 const dataTransfer = event.dataTransfer; 7677 if (!dataTransfer) return 7678 7679 const files = Array.from(dataTransfer.files); 7680 if (!files.length) return 7681 7682 this.contents.uploadFiles(files, { selectLast: true }); 7683 7684 this.editor.focus(); 7685 } 7686 7687 #handleTabKey(event) { 7688 if (this.selection.isInsideList) { 7689 return this.#handleTabForList(event) 7690 } else if (this.selection.isInsideCodeBlock) { 7691 return this.#handleTabForCode() 7692 } 7693 return false 7694 } 7695 7696 #handleTabForList(event) { 7697 if (event.shiftKey && !this.selection.isIndentedList) return false 7698 7699 event.preventDefault(); 7700 const command = event.shiftKey? De$2 : Pe$2; 7701 return this.editor.dispatchCommand(command) 7702 } 7703 7704 #handleTabForCode() { 7705 const selection = Lr(); 7706 return yr(selection) && selection.isCollapsed() 7707 } 7708 7709 // Not using TOGGLE_LINK_COMMAND because it's not handled unless you use React/LinkPlugin 7710 #toggleLink(url) { 7711 this.editor.update(() => { 7712 if (url === null) { 7713 J$2(null); 7714 } else { 7715 J$2(url); 7716 } 7717 }); 7718 } 7719} 7720 7721function capitalize(str) { 7722 return str.charAt(0).toUpperCase() + str.slice(1) 7723} 7724 7725function debounceAsync(fn, wait) { 7726 let timeout; 7727 7728 return (...args) => { 7729 clearTimeout(timeout); 7730 7731 return new Promise((resolve, reject) => { 7732 timeout = setTimeout(async () => { 7733 try { 7734 const result = await fn(...args); 7735 resolve(result); 7736 } catch (err) { 7737 reject(err); 7738 } 7739 }, wait); 7740 }) 7741 } 7742} 7743 7744function nextFrame() { 7745 return new Promise(requestAnimationFrame) 7746} 7747 7748function bytesToHumanSize(bytes) { 7749 if (bytes === 0) return "0 B" 7750 const sizes = [ "B", "KB", "MB", "GB", "TB", "PB" ]; 7751 const i = Math.floor(Math.log(bytes) / Math.log(1024)); 7752 const value = bytes / Math.pow(1024, i); 7753 return `${ value.toFixed(2) } ${ sizes[i] }` 7754} 7755 7756function extractFileName(string) { 7757 return string.split("/").pop() 7758} 7759 7760class ActionTextAttachmentNode extends ki { 7761 static getType() { 7762 return "action_text_attachment" 7763 } 7764 7765 static clone(node) { 7766 return new ActionTextAttachmentNode({ ...node }, node.__key) 7767 } 7768 7769 static importJSON(serializedNode) { 7770 return new ActionTextAttachmentNode({ ...serializedNode }) 7771 } 7772 7773 static importDOM() { 7774 return { 7775 [this.TAG_NAME]: () => { 7776 return { 7777 conversion: (attachment) => ({ 7778 node: new ActionTextAttachmentNode({ 7779 sgid: attachment.getAttribute("sgid"), 7780 src: attachment.getAttribute("url"), 7781 previewable: attachment.getAttribute("previewable"), 7782 altText: attachment.getAttribute("alt"), 7783 caption: attachment.getAttribute("caption"), 7784 contentType: attachment.getAttribute("content-type"), 7785 fileName: attachment.getAttribute("filename"), 7786 fileSize: attachment.getAttribute("filesize"), 7787 width: attachment.getAttribute("width"), 7788 height: attachment.getAttribute("height") 7789 }) 7790 }), priority: 1 7791 } 7792 }, 7793 "img": () => { 7794 return { 7795 conversion: (img) => { 7796 const fileName = extractFileName(img.getAttribute("src") ?? ""); 7797 return { 7798 node: new ActionTextAttachmentNode({ 7799 src: img.getAttribute("src"), 7800 fileName: fileName, 7801 caption: img.getAttribute("alt") || "", 7802 contentType: "image/*", 7803 width: img.getAttribute("width"), 7804 height: img.getAttribute("height") 7805 }) 7806 } 7807 }, priority: 1 7808 } 7809 }, 7810 "video": () => { 7811 return { 7812 conversion: (video) => { 7813 const videoSource = video.getAttribute("src") || video.querySelector("source")?.src; 7814 const fileName = videoSource?.split("/")?.pop(); 7815 const contentType = video.querySelector("source")?.getAttribute("content-type") || "video/*"; 7816 7817 return { 7818 node: new ActionTextAttachmentNode({ 7819 src: videoSource, 7820 fileName: fileName, 7821 contentType: contentType 7822 }) 7823 } 7824 }, priority: 1 7825 } 7826 } 7827 } 7828 } 7829 7830 static get TAG_NAME() { 7831 return Lexxy.global.get("attachmentTagName") 7832 } 7833 7834 constructor({ tagName, sgid, src, previewable, altText, caption, contentType, fileName, fileSize, width, height }, key) { 7835 super(key); 7836 7837 this.tagName = tagName || ActionTextAttachmentNode.TAG_NAME; 7838 this.sgid = sgid; 7839 this.src = src; 7840 this.previewable = previewable; 7841 this.altText = altText || ""; 7842 this.caption = caption || ""; 7843 this.contentType = contentType || ""; 7844 this.fileName = fileName || ""; 7845 this.fileSize = fileSize; 7846 this.width = width; 7847 this.height = height; 7848 7849 this.editor = bs(); 7850 } 7851 7852 createDOM() { 7853 const figure = this.createAttachmentFigure(); 7854 7855 if (this.isPreviewableAttachment) { 7856 figure.appendChild(this.#createDOMForImage()); 7857 figure.appendChild(this.#createEditableCaption()); 7858 } else { 7859 figure.appendChild(this.#createDOMForFile()); 7860 figure.appendChild(this.#createDOMForNotImage()); 7861 } 7862 7863 return figure 7864 } 7865 7866 updateDOM(_prevNode, dom) { 7867 const caption = dom.querySelector("figcaption textarea"); 7868 if (caption && this.caption) { 7869 caption.value = this.caption; 7870 } 7871 7872 return false 7873 } 7874 7875 getTextContent() { 7876 return `[${this.caption || this.fileName}]\n\n` 7877 } 7878 7879 isInline() { 7880 return this.isAttached() && !this.getParent().is(cs(this)) 7881 } 7882 7883 exportDOM() { 7884 const attachment = createElement(this.tagName, { 7885 sgid: this.sgid, 7886 previewable: this.previewable || null, 7887 url: this.src, 7888 alt: this.altText, 7889 caption: this.caption, 7890 "content-type": this.contentType, 7891 filename: this.fileName, 7892 filesize: this.fileSize, 7893 width: this.width, 7894 height: this.height, 7895 presentation: "gallery" 7896 }); 7897 7898 return { element: attachment } 7899 } 7900 7901 exportJSON() { 7902 return { 7903 type: "action_text_attachment", 7904 version: 1, 7905 tagName: this.tagName, 7906 sgid: this.sgid, 7907 src: this.src, 7908 previewable: this.previewable, 7909 altText: this.altText, 7910 caption: this.caption, 7911 contentType: this.contentType, 7912 fileName: this.fileName, 7913 fileSize: this.fileSize, 7914 width: this.width, 7915 height: this.height 7916 } 7917 } 7918 7919 decorate() { 7920 return null 7921 } 7922 7923 createAttachmentFigure() { 7924 const figure = createAttachmentFigure(this.contentType, this.isPreviewableAttachment, this.fileName); 7925 7926 const deleteButton = createElement("lexxy-node-delete-button"); 7927 figure.appendChild(deleteButton); 7928 7929 return figure 7930 } 7931 7932 get isPreviewableAttachment() { 7933 return this.isPreviewableImage || this.previewable 7934 } 7935 7936 get isPreviewableImage() { 7937 return isPreviewableImage(this.contentType) 7938 } 7939 7940 #createDOMForImage(options = {}) { 7941 const img = createElement("img", { src: this.src, draggable: false, alt: this.altText, ...this.#imageDimensions, ...options }); 7942 const container = createElement("div", { className: "attachment__container" }); 7943 container.appendChild(img); 7944 return container 7945 } 7946 7947 get #imageDimensions() { 7948 if (this.width && this.height) { 7949 return { width: this.width, height: this.height } 7950 } else { 7951 return {} 7952 } 7953 } 7954 7955 #createDOMForFile() { 7956 const extension = this.fileName ? this.fileName.split(".").pop().toLowerCase() : "unknown"; 7957 return createElement("span", { className: "attachment__icon", textContent: `${extension}` }) 7958 } 7959 7960 #createDOMForNotImage() { 7961 const figcaption = createElement("figcaption", { className: "attachment__caption" }); 7962 7963 const nameTag = createElement("strong", { className: "attachment__name", textContent: this.caption || this.fileName }); 7964 7965 figcaption.appendChild(nameTag); 7966 7967 if (this.fileSize) { 7968 const sizeSpan = createElement("span", { className: "attachment__size", textContent: bytesToHumanSize(this.fileSize) }); 7969 figcaption.appendChild(sizeSpan); 7970 } 7971 7972 return figcaption 7973 } 7974 7975 #createEditableCaption() { 7976 const caption = createElement("figcaption", { className: "attachment__caption" }); 7977 const input = createElement("textarea", { 7978 value: this.caption, 7979 placeholder: this.fileName, 7980 rows: "1" 7981 }); 7982 7983 input.addEventListener("focusin", () => input.placeholder = "Add caption..."); 7984 input.addEventListener("blur", (event) => this.#handleCaptionInputBlurred(event)); 7985 input.addEventListener("keydown", (event) => this.#handleCaptionInputKeydown(event)); 7986 7987 caption.appendChild(input); 7988 7989 return caption 7990 } 7991 7992 #handleCaptionInputBlurred(event) { 7993 this.#updateCaptionValueFromInput(event.target); 7994 } 7995 7996 #updateCaptionValueFromInput(input) { 7997 input.placeholder = this.fileName; 7998 this.editor.update(() => { 7999 this.getWritable().caption = input.value; 8000 }); 8001 } 8002 8003 #handleCaptionInputKeydown(event) { 8004 if (event.key === "Enter") { 8005 event.preventDefault(); 8006 event.stopPropagation(); 8007 event.target.blur(); 8008 8009 this.editor.update(() => { 8010 // Place the cursor after the current image 8011 this.selectNext(0, 0); 8012 }, { 8013 tag: Dn 8014 }); 8015 } 8016 8017 } 8018} 8019 8020function $createActionTextAttachmentNode(...args) { 8021 return new ActionTextAttachmentNode(...args) 8022} 8023 8024function $isActionTextAttachmentNode(node) { 8025 return node instanceof ActionTextAttachmentNode 8026} 8027 8028class Selection { 8029 constructor(editorElement) { 8030 this.editorElement = editorElement; 8031 this.editorContentElement = editorElement.editorContentElement; 8032 this.editor = this.editorElement.editor; 8033 this.previouslySelectedKeys = new Set(); 8034 8035 this.#listenForNodeSelections(); 8036 this.#processSelectionChangeCommands(); 8037 this.#containEditorFocus(); 8038 } 8039 8040 set current(selection) { 8041 this.editor.update(() => { 8042 this.#syncSelectedClasses(); 8043 }); 8044 } 8045 8046 get hasNodeSelection() { 8047 return this.editor.getEditorState().read(() => { 8048 const selection = Lr(); 8049 return selection !== null && xr(selection) 8050 }) 8051 } 8052 8053 get cursorPosition() { 8054 let position = { x: 0, y: 0 }; 8055 8056 this.editor.getEditorState().read(() => { 8057 const range = this.#getValidSelectionRange(); 8058 if (!range) return 8059 8060 const rect = this.#getReliableRectFromRange(range); 8061 if (!rect) return 8062 8063 position = this.#calculateCursorPosition(rect, range); 8064 }); 8065 8066 return position 8067 } 8068 8069 placeCursorAtTheEnd() { 8070 this.editor.update(() => { 8071 const root = No(); 8072 const lastDescendant = r
8072oot.getLastDescendant(); 8073 8074 if (lastDescendant && lr(lastDescendant)) { 8075 lastDescendant.selectEnd(); 8076 } else { 8077 root.selectEnd(); 8078 } 8079 }); 8080 } 8081 8082 selectedNodeWithOffset() { 8083 const selection = Lr(); 8084 if (!selection) return { node: null, offset: 0 } 8085 8086 if (yr(selection)) { 8087 return { 8088 node: selection.anchor.getNode(), 8089 offset: selection.anchor.offset 8090 } 8091 } else if (xr(selection)) { 8092 const [ node ] = selection.getNodes(); 8093 return { 8094 node, 8095 offset: 0 8096 } 8097 } 8098 8099 return { node: null, offset: 0 } 8100 } 8101 8102 preservingSelection(fn) { 8103 let selectionState = null; 8104 8105 this.editor.getEditorState().read(() => { 8106 const selection = Lr(); 8107 if (selection && yr(selection)) { 8108 selectionState = { 8109 anchor: { key: selection.anchor.key, offset: selection.anchor.offset }, 8110 focus: { key: selection.focus.key, offset: selection.focus.offset } 8111 }; 8112 } 8113 }); 8114 8115 fn(); 8116 8117 if (selectionState) { 8118 this.editor.update(() => { 8119 const selection = Lr(); 8120 if (selection && yr(selection)) { 8121 selection.anchor.set(selectionState.anchor.key, selectionState.anchor.offset, "text"); 8122 selection.focus.set(selectionState.focus.key, selectionState.focus.offset, "text"); 8123 } 8124 }); 8125 } 8126 } 8127 8128 getFormat() { 8129 const selection = Lr(); 8130 if (!yr(selection)) return {} 8131 8132 const anchorNode = selection.anchor.getNode(); 8133 if (!anchorNode.getParent()) return {} 8134 8135 const topLevelElement = anchorNode.getTopLevelElementOrThrow(); 8136 const listType = getListType(anchorNode); 8137 8138 return { 8139 isBold: selection.hasFormat("bold"), 8140 isItalic: selection.hasFormat("italic"), 8141 isStrikethrough: selection.hasFormat("strikethrough"), 8142 isHighlight: isSelectionHighlighted(selection), 8143 isInLink: wt$5(anchorNode, y$2) !== null, 8144 isInQuote: Ot$2(topLevelElement), 8145 isInHeading: It$2(topLevelElement), 8146 isInCode: selection.hasFormat("code") || wt$5(anchorNode, q$1) !== null, 8147 isInList: listType !== null, 8148 listType, 8149 isInTable: Be$1(anchorNode) !== null 8150 } 8151 } 8152 8153 nearestNodeOfType(nodeType) { 8154 const anchorNode = Lr()?.anchor?.getNode(); 8155 return wt$5(anchorNode, nodeType) 8156 } 8157 8158 get hasSelectedWordsInSingleLine() { 8159 const selection = Lr(); 8160 if (!yr(selection)) return false 8161 8162 if (selection.isCollapsed()) return false 8163 8164 const anchorNode = selection.anchor.getNode(); 8165 const focusNode = selection.focus.getNode(); 8166 8167 if (anchorNode.getTopLevelElement() !== focusNode.getTopLevelElement()) { 8168 return false 8169 } 8170 8171 const anchorElement = anchorNode.getTopLevelElement(); 8172 if (!anchorElement) return false 8173 8174 const nodes = selection.getNodes(); 8175 for (const node of nodes) { 8176 if (jn(node)) { 8177 return false 8178 } 8179 } 8180 8181 return true 8182 } 8183 8184 get isInsideList() { 8185 return this.nearestNodeOfType(nt$2) 8186 } 8187 8188 get isIndentedList() { 8189 const closestListNode = this.nearestNodeOfType(lt$3); 8190 return closestListNode && (W$5(closestListNode) > 1) 8191 } 8192 8193 get isInsideCodeBlock() { 8194 return this.nearestNodeOfType(q$1) !== null 8195 } 8196 8197 get isTableCellSelected() { 8198 return this.nearestNodeOfType(xe) !== null 8199 } 8200 8201 get isOnPreviewableImage() { 8202 const selection = Lr(); 8203 const firstNode = selection?.getNodes().at(0); 8204 return $isActionTextAttachmentNode(firstNode) && firstNode.isPreviewableImage 8205 } 8206 8207 get nodeAfterCursor() { 8208 const { anchorNode, offset } = this.#getCollapsedSelectionData(); 8209 if (!anchorNode) return null 8210 8211 if (lr(anchorNode)) { 8212 return this.#getNodeAfterTextNode(anchorNode, offset) 8213 } 8214 8215 if (Si(anchorNode)) { 8216 return this.#getNodeAfterElementNode(anchorNode, offset) 8217 } 8218 8219 return this.#findNextSiblingUp(anchorNode) 8220 } 8221 8222 get topLevelNodeAfterCursor() { 8223 const { anchorNode, offset } = this.#getCollapsedSelectionData(); 8224 if (!anchorNode) return null 8225 8226 if (lr(anchorNode)) { 8227 return this.#getNextNodeFromTextEnd(anchorNode) 8228 } 8229 8230 if (Si(anchorNode)) { 8231 return this.#getNodeAfterElementNode(anchorNode, offset) 8232 } 8233 8234 return this.#findNextSiblingUp(anchorNode) 8235 } 8236
8237 get nodeBeforeCursor() { 8238 const { anchorNode, offset } = this.#getCollapsedSelectionData(); 8239 if (!anchorNode) return null 8240 8241 if (lr(anchorNode)) { 8242 return this.#getNodeBeforeTextNode(anchorNode, offset) 8243 } 8244 8245 if (Si(anchorNode)) { 8246 return this.#getNodeBeforeElementNode(anchorNode, offset) 8247 } 8248 8249 return this.#findPreviousSiblingUp(anchorNode) 8250 } 8251 8252 get topLevelNodeBeforeCursor() { 8253 const { anchorNode, offset } = this.#getCollapsedSelectionData(); 8254 if (!anchorNode) return null 8255 8256 if (lr(anchorNode)) { 8257 return this.#getPreviousNodeFromTextStart(anchorNode) 8258 } 8259 8260 if (Si(anchorNode)) { 8261 return this.#getNodeBeforeElementNode(anchorNode, offset) 8262 } 8263 8264 return this.#findPreviousSiblingUp(anchorNode) 8265 } 8266 8267 get #currentlySelectedKeys() { 8268 if (this.currentlySelectedKeys) { return this.currentlySelectedKeys } 8269 8270 this.currentlySelectedKeys = new Set(); 8271 8272 const selection = Lr(); 8273 if (selection && xr(selection)) { 8274 for (const node of selection.getNodes()) { 8275 this.currentlySelectedKeys.add(node.getKey()); 8276 } 8277 } 8278 8279 return this.currentlySelectedKeys 8280 } 8281 8282 #processSelectionChangeCommands() { 8283 this.editor.registerCommand(Se$1, this.#selectPreviousNode.bind(this), zi); 8284 this.editor.registerCommand(xe$1, this.#selectNextNode.bind(this), zi); 8285 this.editor.registerCommand(ke$2, this.#selectPreviousTopLevelNode.bind(this), zi); 8286 this.editor.registerCommand(Te$2, this.#selectNextTopLevelNode.bind(this), zi); 8287 8288 this.editor.registerCommand(le$2, this.#selectDecoratorNodeBeforeDeletion.bind(this), zi); 8289 8290 this.editor.registerCommand(ie$1, () => { 8291 this.current = Lr(); 8292 }, zi); 8293 } 8294 8295 #listenForNodeSelections() { 8296 this.editor.registerCommand(se$1, ({ target }) => { 8297 if (!Ss(target)) return false 8298 8299 const targetNode = vo(target); 8300 return Ti(targetNode) && this.#selectInLexical(targetNode) 8301 }, zi); 8302 8303 this.editor.getRootElement().addEventListener("lexxy:internal:move-to-next-line", (event) => { 8304 this.#selectOrAppendNextLine(); 8305 }); 8306 } 8307 8308 #containEditorFocus() { 8309 // Workaround for a bizarre Chrome bug where the cursor abandons the editor to focus on not-focusable elements 8310 // above when navigating UP/DOWN when Lexical shows its fake cursor on custom decorator nodes. 8311 this.editorContentElement.addEventListener("keydown", (event) => { 8312 if (event.key === "ArrowUp") { 8313 const lexicalCursor = this.editor.getRootElement().querySelector("[data-lexical-cursor]"); 8314 8315 if (lexicalCursor) { 8316 let currentElement = lexicalCursor.previousElementSibling; 8317 while (currentElement && currentElement.hasAttribute("data-lexical-cursor")) { 8318 currentElement = currentElement.previousElementSibling; 8319 } 8320 8321 if (!currentElement) { 8322 event.preventDefault(); 8323 } 8324 } 8325 } 8326 8327 if (event.key === "ArrowDown") { 8328 const lexicalCursor = this.editor.getRootElement().querySelector("[data-lexical-cursor]"); 8329 8330 if (lexicalCursor) { 8331 let currentElement = lexicalCursor.nextElementSibling; 8332 while (currentElement && currentElement.hasAttribute("data-lexical-cursor")) { 8333 currentElement = currentElement.nextElementSibling; 8334 } 8335 8336 if (!currentElement) { 8337 event.preventDefault(); 8338 } 8339 } 8340 } 8341 }, true); 8342 } 8343 8344 #syncSelectedClasses() { 8345 this.#clearPreviouslyHighlightedItems(); 8346 this.#highlightNewItems(); 8347 8348 this.previouslySelectedKeys = this.#currentlySelectedKeys; 8349 this.currentlySelectedKeys = null; 8350 } 8351 8352 #clearPreviouslyHighlightedItems() { 8353 for (const key of this.previouslySelectedKeys) { 8354 if (!this.#currentlySelectedKeys.has(key)) { 8355 const dom = this.editor.getElementByKey(key); 8356 if (dom) dom.classList.remove("node--selected"); 8357 } 8358 } 8359 } 8360 8361 #highlightNewItems() { 8362 for (const key of this.#currentlySelectedKeys) { 8363 if (!this.previouslySelectedKeys.has(key)) { 8364 const nodeElement = this.editor.getElementByKey(key); 8365 if (nodeElement) nodeElement.classList.add("node--selected"); 8366 } 8367 } 8368 } 8369 8370 async #selectPreviousNode() { 8371 if (this.hasNodeSelection) { 8372 return await this.#withCurrentNode((currentNode) => currentNode.selectPrevious()) 8373 } else { 8374 return this.#selectInLexical(this.nodeBeforeCursor) 8375 } 8376 } 8377 8378 async #selectNextNode() { 8379 if (this.hasNodeSelection) { 8380 return await this.#withCurrentNode((currentNode) => currentNode.selectNext(0, 0)) 8381 } else { 8382 return this.#selectInLexical(this.nodeAfterCursor) 8383 } 8384 } 8385 8386 async #selectPreviousTopLevelNode() { 8387 if (this.hasNodeSelection) { 8388 return await this.#withCurrentNode((currentNode) => currentNode.getTopLevelElement().selectPrevious()) 8389 } else { 8390 return this.#selectInLexical(this.topLevelNodeBeforeCursor) 8391 } 8392 } 8393 8394 async #selectNextTopLevelNode() { 8395 if (this.hasNodeSelection) { 8396 return await this.#withCurrentNode((currentNode) => currentNode.getTopLevelElement().selectNext(0, 0)) 8397 } else { 8398 return this.#selectInLexical(this.topLevelNodeAfterCursor) 8399 } 8400 } 8401 8402 async #withCurrentNode(fn) { 8403 await nextFrame(); 8404 if (this.hasNodeSelection) { 8405 this.editor.update(() => { 8406 fn(Lr().getNodes()[0]); 8407 this.editor.focus(); 8408 }); 8409 } 8410 } 8411 8412 async #selectOrAppendNextLine() { 8413 this.editor.update(() => { 8414 const topLevelElement = this.#getTopLevelElementFromSelection(); 8415 if (!topLevelElement) return 8416 8417 this.#moveToOrCreateNextLine(topLevelElement); 8418 }); 8419 } 8420 8421 #getTopLevelElementFromSelection() { 8422 const selection = Lr(); 8423 if (!selection) return null 8424 8425 if (xr(selection)) { 8426 return this.#getTopLevelFromNodeSelection(selection) 8427 } 8428 8429 if (yr(selection)) { 8430 return this.#getTopLevelFromRangeSelection(selection) 8431 } 8432 8433 return null 8434 } 8435 8436 #getTopLevelFromNodeSelection(selection) { 8437 const nodes = selection.getNodes(); 8438 return nodes.length > 0 ? nodes[0].getTopLevelElement() : null 8439 } 8440 8441 #getTopLevelFromRangeSelection(selection) { 8442 const anchorNode = selection.anchor.getNode(); 8443 return anchorNode.getTopLevelElement() 8444 } 8445 8446 #moveToOrCreateNextLine(topLevelElement) { 8447 const nextSibling = topLevelElement.getNextSibling(); 8448 8449 if (nextSibling) { 8450 nextSibling.selectStart(); 8451 } else { 8452 this.#createAndSelectNewParagraph(); 8453 } 8454 } 8455 8456 #createAndSelectNewParagraph() { 8457 const root = No(); 8458 const newParagraph = Li(); 8459 root.append(newParagraph); 8460 newParagraph.selectStart(); 8461 } 8462 8463 #selectInLexical(node) { 8464 if (Ti(node)) { 8465 const selection = $createNodeSelectionWith(node); 8466 wo(selection); 8467 return selection 8468 } else { 8469 return false 8470 } 8471 } 8472 8473 #selectDecoratorNodeBeforeDeletion(backwards) { 8474 const node = backwards ? this.nodeBeforeCursor : this.nodeAfterCursor; 8475 if (!Ti(node)) return false 8476 8477 this.#removeEmptyElementAnchorNode(); 8478 8479 const selection = this.#selectInLexical(node); 8480 return Boolean(selection) 8481 } 8482 8483 #removeEmptyElementAnchorNode(anchor = Lr()?.anchor) { 8484 const anchorNode = anchor?.getNode(); 8485 if (Si(anchorNode) && anchorNode?.isEmpty()) anchorNode.remove(); 8486 } 8487 8488 #getValidSelectionRange() { 8489 const lexicalSelection = Lr(); 8490 if (!lexicalSelection || !lexicalSelection.isCollapsed()) return null 8491 8492 const nativeSelection = window.getSelection(); 8493 if (!nativeSelection || nativeSelection.rangeCount === 0) return null 8494 8495 return nativeSelection.getRangeAt(0) 8496 } 8497 8498 #getReliableRectFromRange(range) { 8499 let rect = range.getBoundingClientRect(); 8500 8501 if (this.#isRectUnreliable(rect)) { 8502 const marker = this.#createAndInsertMarker(range); 8503 rect = marker.getBoundingClientRect(); 8504 this.#restoreSelectionAfterMarker(marker); 8505 marker.remove(); 8506 } 8507 8508 return rect 8509 } 8510 8511 #isRectUnreliable(rect) { 8512 return rect.width === 0 && rect.height === 0 || rect.top === 0 && rect.left === 0 8513 } 8514 8515 #createAndInsertMarker(range) { 8516 const marker = this.#createMarker();
8517 range.insertNode(marker); 8518 return marker 8519 } 8520 8521 #createMarker() { 8522 const marker = document.createElement("span"); 8523 marker.textContent = "\u200b"; 8524 marker.style.display = "inline-block"; 8525 marker.style.width = "1px"; 8526 marker.style.height = "1em"; 8527 marker.style.lineHeight = "normal"; 8528 marker.setAttribute("nonce", getNonce()); 8529 return marker 8530 } 8531 8532 #restoreSelectionAfterMarker(marker) { 8533 const nativeSelection = window.getSelection(); 8534 nativeSelection.removeAllRanges(); 8535 const newRange = document.createRange(); 8536 newRange.setStartAfter(marker); 8537 newRange.collapse(true); 8538 nativeSelection.addRange(newRange); 8539 } 8540 8541 #calculateCursorPosition(rect, range) { 8542 const rootRect = this.editor.getRootElement().getBoundingClientRect(); 8543 const x = rect.left - rootRect.left; 8544 let y = rect.top - rootRect.top; 8545 8546 const fontSize = this.#getFontSizeForCursor(range); 8547 if (!isNaN(fontSize)) { 8548 y += fontSize; 8549 } 8550 8551 return { x, y, fontSize } 8552 } 8553 8554 #getFontSizeForCursor(range) { 8555 const nativeSelection = window.getSelection(); 8556 const anchorNode = nativeSelection.anchorNode; 8557 const parentElement = this.#getElementFromNode(anchorNode); 8558 8559 if (parentElement instanceof HTMLElement) { 8560 const computed = window.getComputedStyle(parentElement); 8561 return parseFloat(computed.fontSize) 8562 } 8563 8564 return 0 8565 } 8566 8567 #getElementFromNode(node) { 8568 return node?.nodeType === Node.TEXT_NODE ? node.parentElement : node 8569 } 8570 8571 #getCollapsedSelectionData() { 8572 const selection = Lr(); 8573 if (!yr(selection) || !selection.isCollapsed()) { 8574 return { anchorNode: null, offset: 0 } 8575 } 8576 8577 const { anchor } = selection; 8578 return { anchorNode: anchor.getNode(), offset: anchor.offset } 8579 } 8580 8581 #getNodeAfterTextNode(anchorNode, offset) { 8582 if (offset === anchorNode.getTextContentSize()) { 8583 return this.#getNextNodeFromTextEnd(anchorNode) 8584 } 8585 return null 8586 } 8587 8588 #getNextNodeFromTextEnd(anchorNode) { 8589 if (anchorNode.getNextSibling() instanceof ki) { 8590 return anchorNode.getNextSibling() 8591 } 8592 const parent = anchorNode.getParent(); 8593 return parent ? parent.getNextSibling() : null 8594 } 8595 8596 #getNodeAfterElementNode(anchorNode, offset) { 8597 if (offset < anchorNode.getChildrenSize()) { 8598 return anchorNode.getChildAtIndex(offset) 8599 } 8600 return this.#findNextSiblingUp(anchorNode) 8601 } 8602 8603 #getNodeBeforeTextNode(anchorNode, offset) { 8604 if (offset === 0) { 8605 return this.#getPreviousNodeFromTextStart(anchorNode) 8606 } 8607 return null 8608 } 8609 8610 #getPreviousNodeFromTextStart(anchorNode) { 8611 if (anchorNode.getPreviousSibling() instanceof ki) { 8612 return anchorNode.getPreviousSibling() 8613 } 8614 const parent = anchorNode.getParent(); 8615 return parent.getPreviousSibling() 8616 } 8617 8618 #getNodeBeforeElementNode(anchorNode, offset) { 8619 if (offset > 0) { 8620 return anchorNode.getChildAtIndex(offset - 1) 8621 } 8622 return this.#findPreviousSiblingUp(anchorNode) 8623 } 8624 8625 #findNextSiblingUp(node) { 8626 let current = node; 8627 while (current && current.getNextSibling() == null) { 8628 current = current.getParent(); 8629 } 8630 return current ? current.getNextSibling() : null 8631 } 8632 8633 #findPreviousSiblingUp(node) { 8634 let current = node; 8635 while (current && current.getPreviousSibling() == null) { 8636 current = current.getParent(); 8637 } 8638 return current ? current.getPreviousSibling() : null 8639 } 8640} 8641 8642function sanitize(html) { 8643 return purify.sanitize(html, buildConfig()) 8644} 8645 8646function dasherize(value) { 8647 return value.replace(/([A-Z])/g, (_, char) => `-${char.toLowerCase()}`) 8648} 8649 8650function isUrl(string) { 8651 try { 8652 new URL(string); 8653 return true 8654 } catch { 8655 return false 8656 } 8657} 8658 8659function normalizeFilteredText(string) { 8660 return string 8661 .toLowerCase() 8662 .normalize("NFD").replace(/[\u0300-\u036f]/g, "") // Remove diacritics 8663} 8664 8665function filterMatches(text, potentialMatch) { 8666 return normalizeFilteredText(text).includes(normalizeFilteredText(potentialMatch)) 8667} 8668 8669function upcaseFirst(string) { 8670 return string.charAt(0).toUpperCase() + string.slice(1) 8671} 8672 8673class EditorConfiguration { 8674 #editorElement 8675 #config 8676 8677 constructor(editorElement) { 8678 this.#editorElement = editorElement; 8679 this.#config = new Configuration( 8680 Lexxy.presets.get("default"), 8681 Lexxy.presets.get(editorElement.preset), 8682 this.#overrides 8683 ); 8684 } 8685 8686 get(path) { 8687 return this.#config.get(path) 8688 } 8689 8690 get #overrides() { 8691 const overrides = {}; 8692 for (const option of this.#defaultOptions) { 8693 const attribute = dasherize(option); 8694 if (this.#editorElement.hasAttribute(attribute)) { 8695 overrides[option] = this.#parseAttribute(attribute); 8696 } 8697 } 8698 return overrides 8699 } 8700 8701 get #defaultOptions() { 8702 return Object.keys(Lexxy.presets.get("default")) 8703 } 8704 8705 #parseAttribute(attribute) { 8706 const value = this.#editorElement.getAttribute(attribute); 8707 try { 8708 return JSON.parse(value) 8709 } catch { 8710 return value 8711 } 8712 } 8713} 8714 8715class CustomActionTextAttachmentNode extends ki { 8716 static getType() { 8717 return "custom_action_text_attachment" 8718 } 8719 8720 static clone(node) { 8721 return new CustomActionTextAttachmentNode({ ...node }, node.__key) 8722 } 8723 8724 static importJSON(serializedNode) { 8725 return new CustomActionTextAttachmentNode({ ...serializedNode }) 8726 } 8727 8728 static importDOM() { 8729 8730 return { 8731 [this.TAG_NAME]: (element) => { 8732 if (!element.getAttribute("content")) { 8733 return null 8734 } 8735 8736 return { 8737 conversion: (attachment) => { 8738 // Preserve initial space if present since Lexical removes it 8739 const nodes = []; 8740 const previousSibling = attachment.previousSibling; 8741 if (previousSibling && previousSibling.nodeType === Node.TEXT_NODE && /\s$/.test(previousSibling.textContent)) { 8742 nodes.push(sr(" ")); 8743 } 8744 8745 nodes.push(new CustomActionTextAttachmentNode({ 8746 sgid: attachment.getAttribute("sgid"), 8747 innerHtml: JSON.parse(attachment.getAttribute("content")), 8748 contentType: attachment.getAttribute("content-type") 8749 })); 8750 8751 nodes.push(sr(" ")); 8752 8753 return { node: nodes } 8754 }, 8755 priority: 2 8756 } 8757 } 8758 } 8759 } 8760 8761 static get TAG_NAME() { 8762 return Lexxy.global.get("attachmentTagName") 8763 } 8764 8765 constructor({ tagName, sgid, contentType, innerHtml }, key) { 8766 super(key); 8767 8768 const contentTypeNamespace = Lexxy.global.get("attachmentContentTypeNamespace"); 8769 8770 this.tagName = tagName || CustomActionTextAttachmentNode.TAG_NAME; 8771 this.sgid = sgid; 8772 this.contentType = contentType || `application/vnd.${contentTypeNamespace}.unknown`; 8773 this.innerHtml = innerHtml; 8774 } 8775 8776 createDOM() { 8777 const figure = createElement(this.tagName, { "content-type": this.contentType, "data-lexxy-decorator": true }); 8778 8779 figure.insertAdjacentHTML("beforeend", this.innerHtml); 8780 8781 const deleteButton = createElement("lexxy-node-delete-button"); 8782 figure.appendChild(deleteButton); 8783 8784 return figure 8785 } 8786 8787 updateDOM() { 8788 return false 8789 } 8790 8791 getTextContent() { 8792 return this.createDOM().textContent.trim() || `[${this.contentType}]` 8793 } 8794 8795 isInline() { 8796 return true 8797 } 8798 8799 exportDOM() { 8800 const attachment = createElement(this.tagName, { 8801 sgid: this.sgid, 8802 content: JSON.stringify(this.innerHtml), 8803 "content-type": this.contentType 8804 }); 8805 8806 return { element: attachment } 8807 } 8808 8809 exportJSON() { 8810 return { 8811 type: "custom_action_text_attachment", 8812 version: 1, 8813 tagName: this.tagName, 8814 sgid: this.sgid, 8815 contentType: this.contentType, 8816 innerHtml: this.innerHtml 8817 } 8818 } 8819 8820 decorate() { 8821 return null 8822 } 8823} 8824 8825class FormatEscaper { 8826 constructor(editorElement) { 8827 this.editorElement = editorElement; 8828 this.editor = editorElement.editor; 8829 } 8830 8831 monitor() { 8832 this.editor.registerCommand( 8833 Ne$2, 8834 (event) => this.#handleEnterKey(event), 8835 Bi 8836 ); 8837 } 8838 8839 #handleEnterKey(event) { 8840 const selection = Lr(); 8841 if (!yr(selection)) return false 8842 8843 const anchorNode = selection.anchor.getNode(); 8844 8845 if (!this.#isInsideBlockquote(anchorNode)) return false 8846
8847 return this.#handleLists(event, anchorNode) 8848 || this.#handleBlockquotes(event, anchorNode) 8849 } 8850 8851 #handleLists(event, anchorNode) { 8852 if (this.#shouldEscapeFromEmptyListItem(anchorNode) || this.#shouldEscapeFromEmptyParagraphInListItem(anchorNode)) { 8853 event.preventDefault(); 8854 this.#escapeFromList(anchorNode); 8855 return true 8856 } 8857 8858 return false 8859 } 8860 8861 #handleBlockquotes(event, anchorNode) { 8862 if (this.#shouldEscapeFromEmptyParagraphInBlockquote(anchorNode)) { 8863 event.preventDefault(); 8864 this.#escapeFromBlockquote(anchorNode); 8865 return true 8866 } 8867 8868 return false 8869 } 8870 8871 #isInsideBlockquote(node) { 8872 let currentNode = node; 8873 8874 while (currentNode) { 8875 if (Ot$2(currentNode)) { 8876 return true 8877 } 8878 currentNode = currentNode.getParent(); 8879 } 8880 8881 return false 8882 } 8883 8884 #shouldEscapeFromEmptyListItem(node) { 8885 const listItem = this.#getListItemNode(node); 8886 if (!listItem) return false 8887 8888 return this.#isNodeEmpty(listItem) 8889 } 8890 8891 #shouldEscapeFromEmptyParagraphInListItem(node) { 8892 const paragraph = this.#getParagraphNode(node); 8893 if (!paragraph) return false 8894 8895 if (!this.#isNodeEmpty(paragraph)) return false 8896 8897 const parent = paragraph.getParent(); 8898 return parent && ot$3(parent) 8899 } 8900 8901 #isNodeEmpty(node) { 8902 if (node.getTextContent().trim() !== "") return false 8903 8904 const children = node.getChildren(); 8905 if (children.length === 0) return true 8906 8907 return children.every(child => { 8908 if (jn(child)) return true 8909 return this.#isNodeEmpty(child) 8910 }) 8911 } 8912 8913 #getListItemNode(node) { 8914 let currentNode = node; 8915 8916 while (currentNode) { 8917 if (ot$3(currentNode)) { 8918 return currentNode 8919 } 8920 currentNode = currentNode.getParent(); 8921 } 8922 8923 return null 8924 } 8925 8926 #escapeFromList(anchorNode) { 8927 const listItem = this.#getListItemNode(anchorNode); 8928 if (!listItem) return 8929 8930 const parentList = listItem.getParent(); 8931 if (!parentList || !dt$2(parentList)) return 8932 8933 const blockquote = parentList.getParent(); 8934 const isInBlockquote = blockquote && Ot$2(blockquote); 8935 8936 if (isInBlockquote) { 8937 const listItemsAfter = this.#getListItemSiblingsAfter(listItem); 8938 const nonEmptyListItems = listItemsAfter.filter(item => !this.#isNodeEmpty(item)); 8939 8940 if (nonEmptyListItems.length > 0) { 8941 this.#splitBlockquoteWithList(blockquote, parentList, listItem, nonEmptyListItems); 8942 return 8943 } 8944 } 8945 8946 const paragraph = Li(); 8947 parentList.insertAfter(paragraph); 8948 8949 listItem.remove(); 8950 paragraph.selectStart(); 8951 } 8952 8953 #shouldEscapeFromEmptyParagraphInBlockquote(node) { 8954 const paragraph = this.#getParagraphNode(node); 8955 if (!paragraph) return false 8956 8957 if (!this.#isNodeEmpty(paragraph)) return false 8958 8959 const parent = paragraph.getParent(); 8960 return parent && Ot$2(parent) 8961 } 8962 8963 #getParagraphNode(node) { 8964 let currentNode = node; 8965 8966 while (currentNode) { 8967 if (Ii(currentNode)) { 8968 return currentNode 8969 } 8970 currentNode = currentNode.getParent(); 8971 } 8972 8973 return null 8974 } 8975 8976 #escapeFromBlockquote(anchorNode) { 8977 const paragraph = this.#getParagraphNode(anchorNode); 8978 if (!paragraph) return 8979 8980 const blockquote = paragraph.getParent(); 8981 if (!blockquote || !Ot$2(blockquote)) return 8982 8983 const siblingsAfter = this.#getSiblingsAfter(paragraph); 8984 const nonEmptySiblings = siblingsAfter.filter(sibling => !this.#isNodeEmpty(sibling)); 8985 8986 if (nonEmptySiblings.length > 0) { 8987 this.#splitBlockquote(blockquote, paragraph, nonEmptySiblings); 8988 } else { 8989 const newParagraph = Li(); 8990 blockquote.insertAfter(newParagraph); 8991 paragraph.remove(); 8992 newParagraph.selectStart(); 8993 } 8994 } 8995 8996 #getSiblingsAfter(node) { 8997 const siblings = []; 8998 let sibling = node.getNextSibling(); 8999 9000 while (sibling) { 9001 siblings.push(sibling); 9002 sibling = sibling.getNextSibling(); 9003 } 9004 9005 return siblings 9006 } 9007 9008 #getListItemSiblingsAfter(listItem) { 9009 const siblings = []; 9010 let sibling = listItem.getNextSibling(); 9011 9012 while (sibling) { 9013 if (ot$3(sibling)) { 9014 siblings.push(sibling); 9015 } 9016 sibling = sibling.getNextSibling(); 9017 } 9018 9019 return siblings 9020 } 9021 9022 #splitBlockquoteWithList(blockquote, parentList, emptyListItem, listItemsAfter) { 9023 const blockquoteSiblingsAfterList = this.#getSiblingsAfter(parentList); 9024 const nonEmptyBlockquoteSiblings = blockquoteSiblingsAfterList.filter(sibling => !this.#isNodeEmpty(sibling)); 9025 9026 const middleParagraph = Li(); 9027 blockquote.insertAfter(middleParagraph); 9028 9029 const newList = ht$3(parentList.getListType()); 9030 9031 const newBlockquote = _t$2(); 9032 middleParagraph.insertAfter(newBlockquote); 9033 newBlockquote.append(newList); 9034 9035 listItemsAfter.forEach(item => { 9036 newList.append(item); 9037 }); 9038
9039 nonEmptyBlockquoteSiblings.forEach(sibling => { 9040 newBlockquote.append(sibling); 9041 }); 9042 9043 emptyListItem.remove(); 9044 9045 this.#removeTrailingEmptyListItems(parentList); 9046 this.#removeTrailingEmptyNodes(newBlockquote); 9047 9048 if (parentList.getChildrenSize() === 0) { 9049 parentList.remove(); 9050 9051 if (blockquote.getChildrenSize() === 0) { 9052 blockquote.remove(); 9053 } 9054 } else { 9055 this.#removeTrailingEmptyNodes(blockquote); 9056 } 9057 9058 middleParagraph.selectStart(); 9059 } 9060 9061 #removeTrailingEmptyListItems(list) { 9062 const items = list.getChildren(); 9063 for (let i = items.length - 1; i >= 0; i--) { 9064 const item = items[i]; 9065 if (ot$3(item) && this.#isNodeEmpty(item)) { 9066 item.remove(); 9067 } else { 9068 break 9069 } 9070 } 9071 } 9072 9073 #removeTrailingEmptyNodes(blockquote) { 9074 const children = blockquote.getChildren(); 9075 for (let i = children.length - 1; i >= 0; i--) { 9076 const child = children[i]; 9077 if (this.#isNodeEmpty(child)) { 9078 child.remove(); 9079 } else { 9080 break 9081 } 9082 } 9083 } 9084 9085 #splitBlockquote(blockquote, emptyParagraph, siblingsAfter) { 9086 const newParagraph = Li(); 9087 blockquote.insertAfter(newParagraph); 9088 9089 const newBlockquote = _t$2(); 9090 newParagraph.insertAfter(newBlockquote); 9091 9092 siblingsAfter.forEach(sibling => { 9093 newBlockquote.append(sibling); 9094 }); 9095 9096 emptyParagraph.remove(); 9097 9098 this.#removeTrailingEmptyNodes(blockquote); 9099 this.#removeTrailingEmptyNodes(newBlockquote); 9100 9101 newParagraph.selectStart(); 9102 } 9103} 9104 9105async function loadFileIntoImage(file, image) { 9106 return new Promise((resolve) => { 9107 const reader = new FileReader(); 9108 9109 image.addEventListener("load", () => { 9110 resolve(image); 9111 }); 9112 9113 reader.onload = (event) => { 9114 image.src = event.target.result || null; 9115 }; 9116 9117 reader.readAsDataURL(file); 9118 }) 9119} 9120 9121class ActionTextAttachmentUploadNode extends ActionTextAttachmentNode { 9122 static getType() { 9123 return "action_text_attachment_upload" 9124 } 9125 9126 static clone(node) { 9127 return new ActionTextAttachmentUploadNode({ ...node }, node.__key) 9128 } 9129 9130 static importJSON(serializedNode) { 9131 return new ActionTextAttachmentUploadNode({ ...serializedNode }) 9132 } 9133 9134 // Should never run since this is a transient node. Defined to remove console warning. 9135 static importDOM() { 9136 return null 9137 } 9138 9139 constructor(node, key) { 9140 const { file, uploadUrl, blobUrlTemplate, progress, width, height, uploadError } = node; 9141 super({ ...node, contentType: file.type }, key); 9142 this.file = file; 9143 this.uploadUrl = uploadUrl; 9144 this.blobUrlTemplate = blobUrlTemplate; 9145 this.progress = progress ?? null; 9146 this.width = width; 9147 this.height = height; 9148 this.uploadError = uploadError; 9149 } 9150 9151 createDOM() { 9152 if (this.uploadError) return this.#createDOMForError() 9153 9154 // This side-effect is trigged on DOM load to fire only once and avoid multiple 9155 // uploads through cloning. The upload is guarded from restarting in case the 9156 // node is reloaded from saved state such as from history. 9157 this.#startUploadIfNeeded(); 9158 9159 const figure = this.createAttachmentFigure(); 9160 9161 if (this.isPreviewableAttachment) { 9162 const img = figure.appendChild(this.#createDOMForImage()); 9163 9164 // load file locally to set dimensions and prevent vertical shifting 9165 loadFileIntoImage(this.file, img).then(img => this.#setDimensionsFromImage(img)); 9166 } else { 9167 figure.appendChild(this.#createDOMForFile()); 9168 } 9169 9170 figure.appendChild(this.#createCaption()); 9171 figure.appendChild(this.#createProgressBar()); 9172 9173 return figure 9174 } 9175 9176 updateDOM(prevNode, dom) { 9177 if (this.uploadError !== prevNode.uploadError) return true 9178 9179 if (prevNode.progress !== this.progress) { 9180 const progress = dom.querySelector("progress"); 9181 progress.value = this.progress ?? 0; 9182 } 9183 9184 return false 9185 } 9186 9187 exportDOM() { 9188 return { element: null } 9189 } 9190 9191 exportJSON() { 9192 return { 9193 ...super.exportJSON(), 9194 type: "action_text_attachment_upload", 9195 version: 1, 9196 uploadUrl: this.uploadUrl, 9197 blobUrlTemplate: this.blobUrlTemplate, 9198 progress: this.progress, 9199 width: this.width, 9200 height: this.height, 9201 uploadError: this.uploadError 9202 } 9203 } 9204 9205 get #uploadStarted() { 9206 return this.progress !== null 9207 } 9208 9209 #createDOMForError() { 9210 const figure = this.createAttachmentFigure(); 9211 figure.classList.add("attachment--error"); 9212 figure.appendChild(createElement("div", { innerText: `Error uploading ${this.file?.name ?? "file"}` })); 9213 return figure 9214 } 9215 9216 #createDOMForImage() { 9217 return createElement("img") 9218 } 9219 9220 #createDOMForFile() { 9221 const extension = this.#getFileExtension(); 9222 const span = createElement("span", { className: "attachment__icon", textContent: extension }); 9223 return span 9224 } 9225 9226 #getFileExtension() { 9227 return this.file.name.split(".").pop().toLowerCase() 9228 } 9229 9230 #createCaption() { 9231 const figcaption = createElement("figcaption", { className: "attachment__caption" }); 9232 9233 const nameSpan = createElement("span", { className: "attachment__name", textContent: this.file.name || "" }); 9234 const sizeSpan = createElement("span", { className: "attachment__size", textContent: bytesToHumanSize(this.file.size) }); 9235 figcaption.appendChild(nameSpan); 9236 figcaption.appendChild(sizeSpan); 9237 9238 return figcaption 9239 } 9240 9241 #createProgressBar() { 9242 return createElement("progress", { value: this.progress ?? 0, max: 100 }) 9243 } 9244 9245 #setDimensionsFromImage({ width, height }) { 9246 if (this.#hasDimensions) return 9247 9248 this.editor.update(() => { 9249 const writable = this.getWritable(); 9250 writable.width = width; 9251 writable.height = height; 9252 }, { tag: SILENT_UPDATE_TAGS }); 9253 } 9254 9255 get #hasDimensions() { 9256 return Boolean(this.width && this.height) 9257 } 9258 9259 async #startUploadIfNeeded() { 9260 if (this.#uploadStarted) return 9261 9262 this.#setUploadStarted(); 9263 9264 const { DirectUpload } = await import('@rails/activestorage'); 9265 9266 const upload = new DirectUpload(this.file, this.uploadUrl, this); 9267 upload.delegate = this.#createUploadDelegate(); 9268 9269 this.#dispatchEvent("lexxy:upload-start", { file: this.file }); 9270 9271 upload.create((error, blob) => { 9272 if (error) { 9273 this.#dispatchEvent("lexxy:upload-end", { file: this.file, error }); 9274 this.#handleUploadError(error); 9275 } else { 9276 this.#dispatchEvent("lexxy:upload-end", { file: this.file, error: null }); 9277 this.#showUploadedAttachment(blob); 9278 } 9279 }); 9280 } 9281 9282 #createUploadDelegate() { 9283 const shouldAuthenticateUploads = Lexxy.global.get("authenticatedUploads"); 9284 9285 return { 9286 directUploadWillCreateBlobWithXHR: (request) => { 9287 if (shouldAuthenticateUploads) request.withCredentials = true; 9288 }, 9289 directUploadWillStoreFileWithXHR: (request) => { 9290 if (shouldAuthenticateUploads) request.withCredentials = true; 9291 9292 const uploadProgressHandler = (event) => this.#handleUploadProgress(event); 9293 request.upload.addEventListener("progress", uploadProgressHandler); 9294 } 9295 } 9296 } 9297 9298 #setUploadStarted() { 9299 this.#setProgress(1); 9300 } 9301 9302 #handleUploadProgress(event) { 9303 const progress = Math.round(event.loaded / event.total * 100); 9304 this.#setProgress(progress); 9305 this.#dispatchEvent("lexxy:upload-progress", { file: this.file, progress }); 9306 } 9307 9308 #setProgress(progress) { 9309 this.editor.update(() => { 9310 this.getWritable().progress = progress; 9311 }, { tag: SILENT_UPDATE_TAGS }); 9312 } 9313 9314 #handleUploadError(error) { 9315 console.warn(`Upload error for ${this.file?.name ?? "file"}: ${error}`); 9316 this.editor.update(() => { 9317 this.getWritable().uploadError = true; 9318 }, { tag: SILENT_UPDATE_TAGS }); 9319 } 9320 9321 #showUploadedAttachment(blob) { 9322 this.editor.update(() => { 9323 this.replace(this.#toActionTextAttachmentNodeWith(blob)); 9324 }, { tag: SILENT_UPDATE_TAGS }); 9325 } 9326 9327 #toActionTextAttachmentNodeWith(blob) { 9328 const conversion = new AttachmentNodeConversion(this, blob); 9329 return conversion.toAttachmentNode() 9330 } 9331 9332 #dispatchEvent(name, detail) { 9333 const figure = this.editor.getElementByKey(this.getKey()); 9334 if (figure) dispatch(figure, name, detail); 9335 } 9336} 9337 9338class AttachmentNodeConversion { 9339 constructor(uploadNode, blob) { 9340 this.uploadNode = uploadNode; 9341 this.blob = blob; 9342 } 9343 9344 toAttachmentNode() { 9345 return new ActionTextAttachmentNode({ 9346 ...this.uploadNode, 9347 ...this.#propertiesFromBlob, 9348 src: this.#src 9349 }) 9350 } 9351 9352 get #propertiesFromBlob() { 9353 const { blob } = this; 9354 return { 9355 sgid: blob.attachable_sgid, 9356 altText: blob.filename, 9357 contentType: blob.content_type, 9358 fileName: blob.filename, 9359 fileSize: blob.byte_size, 9360 previewable: blob.previewable, 9361 } 9362 } 9363 9364 get #src() { 9365 return this.blob.previewable ? this.blob.url : this.#blobSrc 9366 } 9367 9368 get #blobSrc() { 9369 return this.uploadNode.blobUrlTemplate 9370 .replace(":signed_id", this.blob.signed_id) 9371 .replace(":filename", encodeURIComponent(this.blob.filename)) 9372 } 9373} 9374 9375function $createActionTextAttachmentUploadNode(...args) { 9376 return new ActionTextAttachmentUploadNode(...args) 9377} 9378 9379class ImageGalleryNode extends Ci { 9380 $config() { 9381 return this.config("image_gallery", { 9382 extends: Ci, 9383 }) 9384 } 9385 9386 static transform() { 9387 return (gallery) => { 9388 gallery.unwrapEmptyNode() 9389 || gallery.replaceWithSingularChild() 9390 || gallery.splitAroundInvalidChild(); 9391 } 9392 } 9393 9394 static importDOM() { 9395 return { 9396 div: (element) => { 9397 const containsAttachment = element.querySelector(`:scope > :is(${this.#attachmentTags.join()})`); 9398 if (!containsAttachment) return null 9399 9400 return { 9401 conversion: () => { 9402 return { 9403 node: $createImageGalleryNode(), 9404 after: children => kt$6(children, this.isValidChild) 9405 } 9406 }, 9407 priority: 2 9408 } 9409 } 9410 } 9411 } 9412 9413 static canCollapseWith(node) { 9414 return $isImageGalleryNode(node) || this.isValidChild(node) 9415 } 9416 9417 static isValidChild(node) { 9418 return $isActionTextAttachmentNode(node) && node.isPreviewableImage 9419 } 9420 9421 static get #attachmentTags() { 9422 return Object.keys(ActionTextAttachmentNode.importDOM()) 9423 } 9424 9425 createDOM() { 9426 const div = document.createElement("div"); 9427 div.className = this.#galleryClassNames; 9428 return div 9429 } 9430 9431 updateDOM(_prevNode, dom) { 9432 dom.className = this.#galleryClassNames; 9433 return false 9434 } 9435 9436 canBeEmpty() { 9437 // Return `true` to conform to `$isBlock(node)` 9438 // We clean-up empty galleries with a transform 9439 return true 9440 } 9441 9442 collapseAtStart(_selection) { 9443 return true 9444 } 9445 9446 insertNewAfter(selection, restoreSelection) { 9447 const selectionBeforeLastChild = selection.anchor.getNode().is(this) && selection.anchor.offset == this.getChildrenSize() - 1; 9448 if (selectionBeforeLastChild) { 9449 const paragraph = Li(); 9450 this.insertAfter(paragraph, false); 9451 paragraph.insertAfter(this.getLastChild(), false); 9452 paragraph.selectEnd(); 9453 9454 // return null as selection has been managed 9455 return null 9456 } 9457 9458 const newNode = $createImageGalleryNode(); 9459 this.insertAfter(newNode, restoreSelection); 9460 return newNode 9461 } 9462 9463 getImageAttachments() { 9464 const children = this.getChildren(); 9465 return children.filter($isActionTextAttachmentNode) 9466 } 9467 9468 exportDOM() { 9469 const div = document.createElement("div"); 9470 div.className = this.#galleryClassNames; 9471 return { element: div } 9472 } 9473 9474 collapseWith(node, backwards) { 9475 if (!ImageGalleryNode.canCollapseWith(node)) return false 9476 9477 if (backwards) { 9478 Nt$5(this, node); 9479 } else { 9480 this.append(node); 9481 } 9482 9483 Bt$3(this, ImageGalleryNode.isValidChild); 9484 9485 return true 9486 } 9487 9488 unwrapEmptyNode() { 9489 if (this.isEmpty()) { 9490 const paragraph = Li(); 9491 return this.replace(paragraph) 9492 } 9493 } 9494 9495 replaceWithSingularChild() { 9496 if (this.#hasSingularChild) { 9497 const child = this.getFirstChild(); 9498 return this.replace(child) 9499 } 9500 } 9501 9502 splitAroundInvalidChild() { 9503 for (const child of $t$3(this)) { 9504 if (ImageGalleryNode.isValidChild(child)) continue 9505 9506 const poppedNode = $makeSafeForRoot(child); 9507 const [ topGallery, secondGallery ] = this.splitAtIndex(poppedNode.getIndexWithinParent()); 9508 topGallery.insertAfter(poppedNode); 9509 poppedNode.selectEnd(); 9510 9511 // remove an empty gallery rather than let it unwrap to a paragraph 9512 if (secondGallery.isEmpty()) secondGallery.remove(); 9513 9514 break 9515 } 9516 } 9517 9518 splitAtIndex(index) { 9519 return ms(this, index) 9520 } 9521 9522 get #hasSingularChild() { 9523 return this.getChildrenSize() === 1 9524 } 9525 9526 get #galleryClassNames() { 9527 return `attachment-gallery attachment-gallery--${this.getChildrenSize()}` 9528 } 9529} 9530 9531function $createImageGalleryNode() { 9532 return new ImageGalleryNode() 9533} 9534 9535function $isImageGalleryNode(node) { 9536 return node instanceof ImageGalleryNode 9537} 9538 9539function $findOrCreateGalleryForImage(node) { 9540 if (!ImageGalleryNode.canCollapseWith(node)) return null 9541 9542 const existingGallery = wt$5(node, ImageGalleryNode); 9543 return existingGallery ?? bt$6(node, $createImageGalleryNode) 9544} 9545 9546class Uploader { 9547 #files 9548 9549 static for(editorElement, files) { 9550 const UploaderKlass = GalleryUploader.handle(editorElement, files) ? GalleryUploader : Uploader; 9551 return new UploaderKlass(editorElement, files) 9552 } 9553 9554 constructor(editorElement, files) { 9555 this.#files = files; 9556 9557 this.editorElement = editorElement; 9558 this.contents = editorElement.contents; 9559 this.selection = editorElement.selection; 9560 } 9561 9562 get files() { 9563 return Array.from(this.#files) 9564 } 9565 9566 $uploadFiles() { 9567 this.$createUploadNodes(); 9568 this.$insertUploadNodes(); 9569 } 9570 9571 $createUploadNodes() { 9572 this.nodes = this.files.map(file => 9573 $createActionTextAttachmentUploadNode({ 9574 ...this.#nodeUrlProperties, 9575 file: file, 9576 contentType: file.type 9577 }) 9578 ); 9579 } 9580 9581 $insertUploadNodes() {
9582 this.nodes.forEach(this.contents.insertAtCursor); 9583 } 9584 9585 get #nodeUrlProperties() { 9586 return { 9587 uploadUrl: this.editorElement.directUploadUrl, 9588 blobUrlTemplate: this.editorElement.blobUrlTemplate 9589 } 9590 } 9591} 9592 9593class GalleryUploader extends Uploader { 9594 #gallery 9595 9596 static handle(editorElement, files) { 9597 return this.#isMultipleImageUpload(files) || this.#gallerySelection(editorElement.selection) 9598 } 9599 9600 static #isMultipleImageUpload(files) { 9601 let imageFileCount = 0; 9602 for (const file of files) { 9603 if (isPreviewableImage(file.type)) imageFileCount++; 9604 if (imageFileCount > 1) return true 9605 } 9606 return false 9607 } 9608 9609 static #gallerySelection(selection) { 9610 if (selection.isOnPreviewableImage) return true 9611 9612 const { node: selectedNode } = selection.selectedNodeWithOffset(); 9613 return wt$5(selectedNode, ImageGalleryNode) !== null 9614 } 9615 9616 $insertUploadNodes() { 9617 this.#findOrCreateGallery(); 9618 this.#insertImagesInGallery(); 9619 this.#insertNonImagesAfterGallery(); 9620 } 9621 9622 #findOrCreateGallery() { 9623 if (this.selection.isOnPreviewableImage) { 9624 this.#gallery = $findOrCreateGalleryForImage(this.#selectedNode); 9625 } else { 9626 this.#gallery = $createImageGalleryNode(); 9627 this.contents.insertAtCursor(this.#gallery); 9628 } 9629 } 9630 9631 get #selectedNode() { 9632 const { node } = this.selection.selectedNodeWithOffset(); 9633 return node 9634 } 9635 9636 get #galleryInsertPosition() { 9637 const anchor = Lr()?.anchor; 9638 const galleryHasElementSelection = anchor?.getNode().is(this.#gallery); 9639 if (galleryHasElementSelection) return anchor.offset 9640 9641 const selectedNode = this.#selectedNode; 9642 const childIndex = this.#gallery.isParentOf(selectedNode) && selectedNode.getIndexWithinParent(); 9643 return childIndex !== false ? (childIndex + 1) : 0 9644 } 9645 9646 get #imageNodes() { 9647 return this.nodes.filter(node => ImageGalleryNode.isValidChild(node)) 9648 } 9649 9650 get #nonImageNodes() { 9651 return this.nodes.filter(node => !ImageGalleryNode.isValidChild(node)) 9652 } 9653 9654 #insertImagesInGallery() { 9655 this.#gallery.splice(this.#galleryInsertPosition, 0, this.#imageNodes); 9656 } 9657 9658 #insertNonImagesAfterGallery() { 9659 let beforeNode = this.#gallery; 9660 9661 for (const node of this.#nonImageNodes) { 9662 beforeNode.insertAfter(node); 9663 beforeNode = node; 9664 } 9665 } 9666} 9667 9668class Contents { 9669 constructor(editorElement) { 9670 this.editorElement = editorElement; 9671 this.editor = editorElement.editor; 9672 9673 new FormatEscaper(editorElement).monitor(); 9674 } 9675 9676 insertHtml(html, { tag } = {}) { 9677 this.insertDOM(parseHtml(html), { tag }); 9678 } 9679 9680 insertDOM(doc, { tag } = {}) { 9681 this.editor.update(() => { 9682 const selection = Lr(); 9683 if (!yr(selection)) return 9684 9685 const nodes = m$1(this.editor, doc); 9686 if (!this.#insertUploadNodes(nodes)) { 9687 selection.insertNodes(nodes); 9688 } 9689 }, { tag }); 9690 } 9691 9692 insertAtCursor(node) { 9693 const selection = Lr() ?? No().selectEnd(); 9694 const selectedNodes = selection?.getNodes(); 9695 9696 if (yr(selection)) { 9697 selection.insertNodes([ node ]); 9698 } else if (xr(selection) && selectedNodes.length > 0) { 9699 // Overrides Lexical's default behavior of _removing_ the currently selected nodes 9700 // https://github.com/facebook/lexical/blob/v0.38.2/packages/lexical/src/LexicalSelection.ts#L412 9701 const lastNode = selectedNodes.at(-1); 9702 lastNode.insertAfter(node); 9703 } 9704} 9705 9706 insertAtCursorEnsuringLineBelow(node) { 9707 this.insertAtCursor(node); 9708 this.#insertLineBelowIfLastNode(node); 9709 } 9710 9711 insertNodeWrappingEachSelectedLine(newNodeFn) { 9712 this.editor.update(() => { 9713 const selection = Lr(); 9714 if (!yr(selection)) return 9715 9716 const selectedNodes = selection.extract(); 9717 9718 selectedNodes.forEach((node) => { 9719 const parent = node.getParent(); 9720 if (!parent) { return } 9721 9722 const topLevelElement = node.getTopLevelElementOrThrow(); 9723 const wrappingNode = newNodeFn(); 9724 wrappingNode.append(...topLevelElement.getChildren()); 9725 topLevelElement.replace(wrappingNode); 9726 }); 9727 }); 9728 } 9729 9730 toggleNodeWrappingAllSelectedLines(isFormatAppliedFn, newNodeFn) { 9731 this.editor.update(() => { 9732 const selection = Lr(); 9733 if (!yr(selection)) return 9734 9735 const topLevelElement = selection.anchor.getNode().getTopLevelElementOrThrow(); 9736 9737 // Check if format is already applied 9738 if (isFormatAppliedFn(topLevelElement)) { 9739 this.removeFormattingFromSelectedLines(); 9740 } else {
9741 this.#insertNodeWrappingAllSelectedLines(newNodeFn); 9742 } 9743 }); 9744 } 9745 9746 toggleNodeWrappingAllSelectedNodes(isFormatAppliedFn, newNodeFn) { 9747 this.editor.update(() => { 9748 const selection = Lr(); 9749 if (!yr(selection)) return 9750 9751 const topLevelElement = selection.anchor.getNode().getTopLevelElement(); 9752 9753 // Check if format is already applied 9754 if (topLevelElement && isFormatAppliedFn(topLevelElement)) { 9755 this.#unwrap(topLevelElement); 9756 } else { 9757 this.#insertNodeWrappingAllSelectedNodes(newNodeFn); 9758 } 9759 }); 9760 } 9761 9762 removeFormattingFromSelectedLines() { 9763 this.editor.update(() => { 9764 const selection = Lr(); 9765 if (!yr(selection)) return 9766 9767 const topLevelElement = selection.anchor.getNode().getTopLevelElementOrThrow(); 9768 const paragraph = Li(); 9769 paragraph.append(...topLevelElement.getChildren()); 9770 topLevelElement.replace(paragraph); 9771 }); 9772 } 9773 9774 hasSelectedText() { 9775 let result = false; 9776 9777 this.editor.read(() => { 9778 const selection = Lr(); 9779 result = yr(selection) && !selection.isCollapsed(); 9780 }); 9781 9782 return result 9783 } 9784 9785 unwrapSelectedListItems() { 9786 this.editor.update(() => { 9787 const selection = Lr(); 9788 if (!yr(selection)) return 9789 9790 const { listItems, parentLists } = this.#collectSelectedListItems(selection); 9791 if (listItems.size > 0) { 9792 const newParagraphs = this.#convertListItemsToParagraphs(listItems); 9793 this.#removeEmptyParentLists(parentLists); 9794 this.#selectNewParagraphs(newParagraphs); 9795 } 9796 }); 9797 } 9798 9799 createLink(url) { 9800 let linkNodeKey = null; 9801 9802 this.editor.update(() => { 9803 const textNode = sr(url); 9804 const linkNode = D$2(url); 9805 linkNode.append(textNode); 9806 9807 const selection = Lr(); 9808 if (yr(selection)) { 9809 selection.insertNodes([ linkNode ]); 9810 linkNodeKey = linkNode.getKey(); 9811 } 9812 }); 9813 9814 return linkNodeKey 9815 } 9816 9817 createLinkWithSelectedText(url) { 9818 if (!this.hasSelectedText()) return 9819 9820 this.editor.update(() => { 9821 J$2(null); 9822 J$2(url); 9823 }); 9824 } 9825 9826 textBackUntil(string) { 9827 let result = ""; 9828 9829 this.editor.getEditorState().read(() => { 9830 const selection = Lr(); 9831 if (!selection || !selection.isCollapsed()) return 9832 9833 const anchor = selection.anchor; 9834 const anchorNode = anchor.getNode(); 9835 9836 if (!lr(anchorNode)) return 9837 9838 const fullText = anchorNode.getTextContent(); 9839 const offset = anchor.offset; 9840 9841 const textBeforeCursor = fullText.slice(0, offset); 9842 9843 const lastIndex = textBeforeCursor.lastIndexOf(string); 9844 if (lastIndex !== -1) { 9845 result = textBeforeCursor.slice(lastIndex + string.length); 9846 } 9847 }); 9848 9849 return result 9850 } 9851 9852 containsTextBackUntil(string) { 9853 let result = false;
9854 9855 this.editor.getEditorState().read(() => { 9856 const selection = Lr(); 9857 if (!selection || !selection.isCollapsed()) return 9858 9859 const anchor = selection.anchor; 9860 const anchorNode = anchor.getNode(); 9861 9862 if (!lr(anchorNode)) return 9863 9864 const fullText = anchorNode.getTextContent(); 9865 const offset = anchor.offset; 9866 9867 const textBeforeCursor = fullText.slice(0, offset); 9868 9869 result = textBeforeCursor.includes(string); 9870 }); 9871 9872 return result 9873 } 9874 9875 replaceTextBackUntil(stringToReplace, replacementNodes) { 9876 replacementNodes = Array.isArray(replacementNodes) ? replacementNodes : [ replacementNodes ]; 9877 9878 this.editor.update(() => { 9879 const { anchorNode, offset } = this.#getTextAnchorData(); 9880 if (!anchorNode) return 9881 9882 const lastIndex = this.#findLastIndexBeforeCursor(anchorNode, offset, stringToReplace); 9883 if (lastIndex === -1) return 9884 9885 this.#performTextReplacement(anchorNode, offset, lastIndex, replacementNodes); 9886 }); 9887 } 9888 9889 createParagraphAfterNode(node, text) { 9890 const newParagraph = Li(); 9891 node.insertAfter(newParagraph); 9892 newParagraph.selectStart(); 9893 9894 // Insert the typed text 9895 if (text) { 9896 newParagraph.append(sr(text)); 9897 newParagraph.select(1, 1); // Place cursor after the text 9898 } 9899 } 9900 9901 createParagraphBeforeNode(node, text) { 9902 const newParagraph = Li(); 9903 node.insertBefore(newParagraph); 9904 newParagraph.selectStart(); 9905 9906 // Insert the typed text 9907 if (text) { 9908 newParagraph.append(sr(text)); 9909 newParagraph.select(1, 1); // Place cursor after the text 9910 } 9911 } 9912 9913 uploadFiles(files, { selectLast } = {}) { 9914 if (!this.editorElement.supportsAttachments) { 9915 console.warn("This editor does not supports attachments (it's configured with [attachments=false])"); 9916 return 9917 } 9918 const validFiles = Array.from(files).filter(this.#shouldUploadFile.bind(this)); 9919 9920 this.editor.update(() => { 9921 const uploader = Uploader.for(this.editorElement, validFiles); 9922 uploader.$uploadFiles(); 9923 9924 if (selectLast && uploader.nodes?.length) { 9925 const lastNode = uploader.nodes.at(-1); 9926 lastNode.selectEnd(); 9927 } 9928 }); 9929 } 9930 9931 replaceNodeWithHTML(nodeKey, html, options = {}) { 9932 this.editor.update(() => { 9933 const node = xo(nodeKey); 9934 if (!node) return 9935 9936 const selection = Lr(); 9937 let wasSelected = false; 9938 9939 if (yr(selection)) { 9940 const selectedNodes = selection.getNodes(); 9941 wasSelected = selectedNodes.includes(node) || selectedNodes.some(n => n.getParent() === node); 9942 9943 if (wasSelected) { 9944 wo(null); 9945 } 9946 } 9947 9948 const replacementNode = options.attachment ? this.#createCustomAttachmentNodeWithHtml(html, options.attachment) : this.#createHtmlNodeWith(html); 9949 node.replace(replacementNode); 9950 9951 if (wasSelected) { 9952 replacementNode.selectEnd(); 9953 } 9954 }); 9955 } 9956 9957 insertHTMLBelowNode(nodeKey, html, options = {}) { 9958 this.editor.update(() => { 9959 const node = xo(nodeKey); 9960 if (!node) return 9961 9962 const previousNode = node.getTopLevelElement() || node; 9963 9964 const newNode = options.attachment ? this.#createCustomAttachmentNodeWithHtml(html, options.attachment) : this.#createHtmlNodeWith(html); 9965 previousNode.insertAfter(newNode); 9966 }); 9967 } 9968 9969 #insertUploadNodes(nodes) { 9970 if (nodes.every($isActionTextAttachmentNode)) { 9971 const uploader = Uploader.for(this.editorElement, []); 9972 uploader.nodes = nodes; 9973 uploader.$insertUploadNodes(); 9974 return true 9975 } 9976 } 9977 9978 #insertLineBelowIfLastNode(node) { 9979 this.editor.update(() => { 9980 const nextSibling = node.getNextSibling(); 9981 if (!nextSibling) { 9982 const newParagraph = Li(); 9983 node.insertAfter(newParagraph); 9984 newParagraph.selectStart(); 9985 } 9986 }); 9987 } 9988 9989 #unwrap(node) { 9990 const children = node.getChildren(); 9991 9992 if (children.length == 0) { 9993 node.insertBefore(Li()); 9994 } else { 9995 children.forEach((child) => { 9996 if (lr(child) && child.getTextContent().trim() !== "") { 9997 const newParagraph = Li(); 9998 newParagraph.append(child); 9999 node.insertBefore(newParagraph); 10000 } else if (!jn(child)) { 10001 node.insertBefore(child); 10002 } 10003 }); 10004 } 10005 10006 node.remove(); 10007 } 10008
10009 #insertNodeWrappingAllSelectedNodes(newNodeFn) { 10010 this.editor.update(() => { 10011 const selection = Lr(); 10012 if (!yr(selection)) return 10013 10014 const selectedNodes = selection.extract(); 10015 if (selectedNodes.length === 0) { 10016 return 10017 } 10018 10019 const topLevelElements = new Set(); 10020 selectedNodes.forEach((node) => { 10021 const topLevel = node.getTopLevelElementOrThrow(); 10022 topLevelElements.add(topLevel); 10023 }); 10024 10025 const elements = this.#withoutTrailingEmptyParagraphs(Array.from(topLevelElements)); 10026 if (elements.length === 0) { 10027 this.#removeStandaloneEmptyParagraph(); 10028 this.insertAtCursor(newNodeFn()); 10029 return 10030 } 10031 10032 const wrappingNode = newNodeFn(); 10033 elements[0].insertBefore(wrappingNode); 10034 elements.forEach((element) => { 10035 wrappingNode.append(element); 10036 }); 10037 }); 10038 } 10039 10040 #withoutTrailingEmptyParagraphs(elements) { 10041 let lastNonEmptyIndex = elements.length - 1; 10042 10043 // Find the last non-empty paragraph 10044 while (lastNonEmptyIndex >= 0) { 10045 const element = elements[lastNonEmptyIndex]; 10046 if (!Ii(element) || !this.#isElementEmpty(element)) { 10047 break 10048 } 10049 lastNonEmptyIndex--; 10050 } 10051 10052 return elements.slice(0, lastNonEmptyIndex + 1) 10053 } 10054 10055 #isElementEmpty(element) { 10056 // Check text content first 10057 if (element.getTextContent().trim() !== "") return false 10058 10059 // Check if it only contains line breaks 10060 const children = element.getChildren(); 10061 return children.length === 0 || children.every(child => jn(child)) 10062 } 10063 10064 #removeStandaloneEmptyParagraph() { 10065 const root = No(); 10066 if (root.getChildrenSize() === 1) { 10067 const firstChild = root.getFirstChild(); 10068 if (firstChild && Ii(firstChild) && this.#isElementEmpty(firstChild)) { 10069 firstChild.remove(); 10070 } 10071 } 10072 } 10073 10074 #insertNodeWrappingAllSelectedLines(newNodeFn) { 10075 this.editor.update(() => { 10076 const selection = Lr(); 10077 if (!yr(selection)) return 10078 10079 if (selection.isCollapsed()) { 10080 this.#wrapCurrentLine(selection, newNodeFn); 10081 } else { 10082 this.#wrapMultipleSelectedLines(selection, newNodeFn); 10083 } 10084 }); 10085 } 10086 10087 #wrapCurrentLine(selection, newNodeFn) { 10088 const anchorNode = selection.anchor.getNode(); 10089 10090 const topLevelElement = anchorNode.getTopLevelElementOrThrow(); 10091 10092 if (topLevelElement.getTextContent()) { 10093 const wrappingNode = newNodeFn(); 10094 wrappingNode.append(...topLevelElement.getChildren()); 10095 topLevelElement.replace(wrappingNode); 10096 } else { 10097 selection.insertNodes([ newNodeFn() ]); 10098 } 10099 } 10100 10101 #wrapMultipleSelectedLines(selection, newNodeFn) { 10102 const selectedParagraphs = this.#extractSelectedParagraphs(selection); 10103 if (selectedParagraphs.length === 0) return 10104 10105 const { lineSet, nodesToDelete } = this.#extractUniqueLines(selectedParagraphs); 10106 if (lineSet.size === 0) return 10107 10108 const wrappingNode = this.#createWrappingNodeWithLines(newNodeFn, lineSet); 10109 this.#replaceWithWrappingNode(selection, wrappingNode); 10110 this.#removeNodes(nodesToDelete); 10111 } 10112 10113 #extractSelectedParagraphs(selection) { 10114 const selectedNodes = selection.extract(); 10115 const selectedParagraphs = selectedNodes 10116 .map((node) => this.#getParagraphFromNode(node)) 10117 .filter(Boolean); 10118 10119 wo(null); 10120 return selectedParagraphs 10121 } 10122 10123 #getParagraphFromNode(node) { 10124 if (Ii(node)) return node 10125 if (lr(node) && node.getParent() && Ii(node.getParent())) { 10126 return node.getParent() 10127 } 10128 return null 10129 } 10130 10131 #extractUniqueLines(selectedParagraphs) { 10132 const lineSet = new Set(); 10133 const nodesToDelete = new Set(); 10134 10135 selectedParagraphs.forEach((paragraphNode) => { 10136 const textContent = paragraphNode.getTextContent(); 10137 if (textContent) { 10138 textContent.split("\n").forEach((line) => { 10139 if (line.trim()) lineSet.add(line); 10140 }); 10141 } 10142 nodesToDelete.add(paragraphNode); 10143 }); 10144 10145 return { lineSet, nodesToDelete } 10146 } 10147 10148 #createWrappingNodeWithLines(newNodeFn, lineSet) { 10149 const wrappingNode = newNodeFn(); 10150 const lines = Array.from(lineSet); 10151
10152 lines.forEach((lineText, index) => { 10153 wrappingNode.append(sr(lineText)); 10154 if (index < lines.length - 1) { 10155 wrappingNode.append(Jn()); 10156 } 10157 }); 10158 10159 return wrappingNode 10160 } 10161 10162 #replaceWithWrappingNode(selection, wrappingNode) { 10163 const anchorNode = selection.anchor.getNode(); 10164 const parent = anchorNode.getParent(); 10165 if (parent) { 10166 parent.replace(wrappingNode); 10167 } 10168 } 10169 10170 #removeNodes(nodesToDelete) { 10171 nodesToDelete.forEach((node) => node.remove()); 10172 } 10173 10174 #collectSelectedListItems(selection) { 10175 const nodes = selection.getNodes(); 10176 const listItems = new Set(); 10177 const parentLists = new Set(); 10178 10179 for (const node of nodes) { 10180 const listItem = wt$5(node, nt$2); 10181 if (listItem) { 10182 listItems.add(listItem); 10183 const parentList = listItem.getParent(); 10184 if (parentList && dt$2(parentList)) { 10185 parentLists.add(parentList); 10186 } 10187 } 10188 } 10189 10190 return { listItems, parentLists } 10191 } 10192 10193 #convertListItemsToParagraphs(listItems) { 10194 const newParagraphs = []; 10195 10196 for (const listItem of listItems) { 10197 const paragraph = this.#convertListItemToParagraph(listItem); 10198 if (paragraph) { 10199 newParagraphs.push(paragraph); 10200 } 10201 } 10202 10203 return newParagraphs 10204 } 10205 10206 #convertListItemToParagraph(listItem) { 10207 const parentList = listItem.getParent(); 10208 if (!parentList || !dt$2(parentList)) return null 10209 10210 const paragraph = Li(); 10211 const sublists = this.#extractSublistsAndContent(listItem, paragraph); 10212 10213 listItem.insertAfter(paragraph); 10214 this.#insertSublists(paragraph, sublists); 10215 listItem.remove(); 10216 10217 return paragraph 10218 } 10219 10220 #extractSublistsAndContent(listItem, paragraph) { 10221 const sublists = []; 10222
10223 listItem.getChildren().forEach((child) => { 10224 if (dt$2(child)) { 10225 sublists.push(child); 10226 } else { 10227 paragraph.append(child); 10228 } 10229 }); 10230 10231 return sublists 10232 } 10233 10234 #insertSublists(paragraph, sublists) { 10235 sublists.forEach((sublist) => { 10236 paragraph.insertAfter(sublist); 10237 }); 10238 } 10239 10240 #removeEmptyParentLists(parentLists) { 10241 for (const parentList of parentLists) { 10242 if (dt$2(parentList) && parentList.getChildrenSize() === 0) { 10243 parentList.remove(); 10244 } 10245 } 10246 } 10247 10248 #selectNewParagraphs(newParagraphs) { 10249 if (newParagraphs.length === 0) return 10250 10251 const firstParagraph = newParagraphs[0]; 10252 const lastParagraph = newParagraphs[newParagraphs.length - 1]; 10253 10254 if (newParagraphs.length === 1) { 10255 firstParagraph.selectEnd(); 10256 } else { 10257 this.#selectParagraphRange(firstParagraph, lastParagraph); 10258 } 10259 } 10260 10261 #selectParagraphRange(firstParagraph, lastParagraph) { 10262 firstParagraph.selectStart(); 10263 const currentSelection = Lr(); 10264 if (currentSelection && yr(currentSelection)) { 10265 currentSelection.anchor.set(firstParagraph.getKey(), 0, "element"); 10266 currentSelection.focus.set(lastParagraph.getKey(), lastParagraph.getChildrenSize(), "element"); 10267 } 10268 } 10269 10270 #getTextAnchorData() { 10271 const selection = Lr(); 10272 if (!selection || !selection.isCollapsed()) return { anchorNode: null, offset: 0 } 10273 10274 const anchor = selection.anchor; 10275 const anchorNode = anchor.getNode(); 10276 10277 if (!lr(anchorNode)) return { anchorNode: null, offset: 0 } 10278 10279 return { anchorNode, offset: anchor.offset } 10280 } 10281 10282 #findLastIndexBeforeCursor(anchorNode, offset, stringToReplace) { 10283 const fullText = anchorNode.getTextContent(); 10284 const textBeforeCursor = fullText.slice(0, offset); 10285 return textBeforeCursor.lastIndexOf(stringToReplace) 10286 } 10287 10288 #performTextReplacement(anchorNode, offset, lastIndex, replacementNodes) { 10289 const fullText = anchorNode.getTextContent(); 10290 const textBeforeString = fullText.slice(0, lastIndex); 10291 const textAfterCursor = fullText.slice(offset); 10292 10293 const textNodeBefore = sr(textBeforeString); 10294 const textNodeAfter = sr(textAfterCursor || " "); 10295 10296 anchorNode.replace(textNodeBefore); 10297 10298 const lastInsertedNode = this.#insertReplacementNodes(textNodeBefore, replacementNodes); 10299 lastInsertedNode.insertAfter(textNodeAfter); 10300 10301 this.#appendLineBreakIfNeeded(textNodeAfter.getParentOrThrow()); 10302 const cursorOffset = textAfterCursor ? 0 : 1; 10303 textNodeAfter.select(cursorOffset, cursorOffset); 10304 } 10305 10306 #insertReplacementNodes(startNode, replacementNodes) { 10307 let previousNode = startNode; 10308 for (const node of replacementNodes) { 10309 previousNode.insertAfter(node); 10310 previousNode = node; 10311 } 10312 return previousNode 10313 } 10314 10315 #appendLineBreakIfNeeded(paragraph) { 10316 if (Ii(paragraph) && this.editorElement.supportsMultiLine) { 10317 const children = paragraph.getChildren(); 10318 const last = children[children.length - 1]; 10319 const beforeLast = children[children.length - 2]; 10320 10321 if (lr(last) && last.getTextContent() === "" && (beforeLast && !lr(beforeLast))) { 10322 paragraph.append(Jn()); 10323 } 10324 } 10325 } 10326 10327 #createCustomAttachmentNodeWithHtml(html, options = {}) { 10328 const attachmentConfig = typeof options === "object" ? options : {}; 10329 10330 return new CustomActionTextAttachmentNode({ 10331 sgid: attachmentConfig.sgid || null, 10332 contentType: "text/html", 10333 innerHtml: html 10334 }) 10335 } 10336 10337 #createHtmlNodeWith(html) { 10338 const htmlNodes = m$1(this.editor, parseHtml(html)); 10339 return htmlNodes[0] || Li() 10340 } 10341 10342 #shouldUploadFile(file) { 10343 return dispatch(this.editorElement, "lexxy:file-accept", { file }, true) 10344 } 10345} 10346 10347/** 10348 * marked v16.4.1 - a markdown parser 10349 * Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed) 10350 * https://github.com/markedjs/marked 10351 */ 10352 10353/** 10354 * DO NOT EDIT THIS FILE 10355 * The code in this file is generated from files in ./src/ 10356 */ 10357 10358function L(){return {async:false,breaks:false,extensions:null,gfm:true,hooks:null,pedantic:false,renderer:null,silent:false,tokenizer:null,walkTokens:null}}var T=L();function G(u){T=u;}var I={exec:()=>null};function h(u,e=""){let t=typeof u=="string"?u:u.source,n={replace:(r,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(m.caret,"$1"),t=t.replace(r,s),n},getRegex:()=>new RegExp(t,e)};return n}var m={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,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine
vendor: 4,627 bytes, line 10358
10358:/\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,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:u=>new RegExp(`^( {0,3}${u})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}#`),htmlBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}<(?:[a-z].*>|!--)`,"i")},be=/^(?:[ \t]*(?:\n|$))+/,Re=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Te=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,E=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Oe=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,F=/(?:[*+-]|\d{1,9}[.)])/,ie=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oe=h(ie).replace(/bull/g,F).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(),we=h(ie).replace(/bull/g,F).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(),j=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ye=/^[^\n]+/,Q=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Pe=h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Q).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Se=h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,F).getRegex(),v="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",U=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$e=h("^ {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",v).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ae=h(j).replace("hr",E).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),_e=h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ae).getRegex(),K={blockquote:_e,code:Re,def:Pe,fences:Te,heading:Oe,hr:E,html:$e,lheading:oe,list:Se,newline:be,paragraph:ae,table:I,text:ye},re=h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",E
vendor: 7,033 bytes, lines 10358-10360
10358).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),Le={...K,lheading:we,table:re,paragraph:h(j).replace("hr",E).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex()},Me={...K,html:h(`^ *(?: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:I,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:h(j).replace("hr",E).replace("heading",` *#{1,6} *[^ 10359]`).replace("lheading",oe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ze=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ae=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,le=/^( {2,}|\\)\n(?!\s*$)/,Ie=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,D=/[\p{P}\p{S}]/u,W=/[\s\p{P}\p{S}]/u,ue=/[^\s\p{P}\p{S}]/u,Ee=h(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,W).getRegex(),pe=/(?!~)[\p{P}\p{S}]/u,Ce=/(?!~)[\s\p{P}\p{S}]/u,Be=/(?:[^\s\p{P}\p{S}]|~)/u,qe=h(/link|code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<!`)(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("code",/(?<!`)(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ce=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ve=h(ce,"u").replace(/punct/g,D).getRegex(),De=h(ce,"u").replace(/punct/g,pe).getRegex(),he="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",He=h(he,"gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ze=h(he,"gu").replace(/notPunctSpace/g,Be).replace(/punctSpace/g,Ce).replace(/punct/g,pe).getRegex(),Ge=h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ne=h(/\\(punct)/,"gu").replace(/punct/g,D).getRegex(),Fe=h(/^<(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(),je=h(U).replace("(?:-->|$)","-->").getRegex(),Qe=h("^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",je).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Ue=h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),de=h(/^!?\[(label)\]\[(ref)\]/).replace("label",q).replace("ref",Q).getRegex(),ke=h(/^!?\[(ref)\](?:\[\])?/).replace("ref",Q).getRegex(),Ke=h("reflink|nolink(?!\\()","g").replace("reflink",de).replace("nolink",ke).getRegex(),se=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,X={_backpedal:I,anyPunctuation:Ne,autolink:Fe,blockSkip:qe,br:le,code:Ae,del:I,emStrongLDelim:ve,emStrongRDelimAst:He,emStrongRDelimUnd:Ge,escape:ze,link:Ue,nolink:ke,punctuation:Ee,reflink:de,reflinkSearch:Ke,tag:Qe,text:Ie,url:I},We={...X,link:h(/^!?\[(label)\]\((.*?)\)/).replace("label",q).getRegex(),reflink:h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q).getRegex()},N={...X,emStrongRDelimAst:Ze,emStrongLDelim:De,url:h(/^((?: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:h(/^([`~]+|[^`~])(?:(?= {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()},Xe={...N,br:h(le).replace("{2,}","*").getRegex(),text:h(N.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},C={normal:K,gfm:Le,pedantic:Me},M={normal:X,gfm:N,breaks:Xe,pedantic:We};var Je={"&":"&","<":"<",">":">",'"':""","'":"'"},ge=u=>Je[u];function w(u,e){if(e){if(m.escapeTest.test(u))return u.replace(m.escapeReplace,ge)}else if(m.escapeTestNoEncode.test(u))return u.replace(m.escapeReplaceNoEncode,ge);return u}function J(u){try{u=encodeURI(u).replace(m.percentDecode,"%");}catch{return null}return u}function V(u,e){let t=u.replace(m.findPipe,(i,s,o)=>{let a=false,l=s;for(;--l>=0&&o[l]==="\\";)a=!a;return a?"|":" |"}),n=t.split(m.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(m.slashPipe,"|");return n}function z(u,e,t){let n=u.length;if(n===0)return "";let r=0;for(;r<n;){let i=u.charAt(n-r-1);if(i===e&&true)r++;else break}return u.slice(0,n-r)}function fe(u,e){if(u.indexOf(e[1])===-1)return -1;let t=0;for(let n=0;n<u.length;n++)if(u[n]==="\\")n++;else if(u[n]===e[0])t++;else if(u[n]===e[1]&&(t--,t<0))return n;return t>0?-2:-1}function me(u,e,t,n,r){let i=e.href,s=e.title||null,o=u[1].replace(r.other.outputLinkReplace,"$1");n.state.inLink=true;let a={type:u[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:s,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=false,a}function Ve(u,e,t){let n=u.match(t.other.indentCodeCompensation);if(n===null)return e;let r=n[1];return e.split(` 10360`).map(i=>{let s=i.match(t.other.beginningSpace);if(s===null)return i;let[o]=s;return o.length>
vendor: 6,982 bytes, lines 10360-10383
10360=r.length?i.slice(r.length):i}).join(` 10361`)}var y=class{options;rules;lexer;constructor(e){this.options=e||T;}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return {type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return {type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:z(n,` 10362`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Ve(n,t[3]||"",this.rules);return {type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=z(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim());}return {type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return {type:"hr",raw:z(t[0],` 10363`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=z(t[0],` 10364`).split(` 10365`),r="",i="",s=[];for(;n.length>0;){let o=false,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=true;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(` 10366`),p=c.replace(this.rules.other.blockquoteSetextReplace,` 10367 $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r} 10368${c}`:c,i=i?`${i} 10369${p}`:p;let g=this.lexer.state.top;if(this.lexer.state.top=true,this.lexer.blockTokens(p,s,true),this.lexer.state.top=g,n.length===0)break;let d=s.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let R=d,f=R.raw+` 10370`+n.join(` 10371`),O=this.blockquote(f);s[s.length-1]=O,r=r.substring(0,r.length-R.raw.length)+O.raw,i=i.substring(0,i.length-R.text.length)+O.text;break}else if(d?.type==="list"){let R=d,f=R.raw+` 10372`+n.join(` 10373`),O=this.list(f);s[s.length-1]=O,r=r.substring(0,r.length-d.raw.length)+O.raw,i=i.substring(0,i.length-R.raw.length)+O.raw,n=f.substring(s.at(-1).raw.length).split(` 10374`);continue}}return {type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:false,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=false;for(;e;){let l=false,c="",p="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let g=t[2].split(` 10375`,1)[0].replace(this.rules.other.listReplaceTabs,H=>" ".repeat(3*H.length)),d=e.split(` 10376`,1)[0],R=!g.trim(),f=0;if(this.options.pedantic?(f=2,p=g.trimStart()):R?f=t[1].length+1:(f=t[2].search(this.rules.other.nonSpaceChar),f=f>4?1:f,p=g.slice(f),f+=t[1].length),R&&this.rules.other.blankLine.test(d)&&(c+=d+` 10377`,e=e.substring(d.length+1),l=true),!l){let H=this.rules.other.nextBulletRegex(f),ee=this.rules.other.hrRegex(f),te=this.rules.other.fencesBeginRegex(f),ne=this.rules.other.headingBeginRegex(f),xe=this.rules.other.htmlBeginRegex(f);for(;e;){let Z=e.split(` 10378`,1)[0],A;if(d=Z,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),A=d):A=d.replace(this.rules.other.tabCharGlobal," "),te.test(d)||ne.test(d)||xe.test(d)||H.test(d)||ee.test(d))break;if(A.search(this.rules.other.nonSpaceChar)>=f||!d.trim())p+=` 10379`+A.slice(f);else {if(R||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||te.test(g)||ne.test(g)||ee.test(g))break;p+=` 10380`+d;}!R&&!d.trim()&&(R=true),c+=Z+` 10381`,e=e.substring(Z.length+1),g=A.slice(f);}}i.loose||(o?i.loose=true:this.rules.other.doubleBlankLine.test(c)&&(o=true));let O=null,Y;this.options.gfm&&(O=this.rules.other.listIsTask.exec(p),O&&(Y=O[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:c,task:!!O,checked:Y,loose:false,text:p,tokens:[]}),i.raw+=c;}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l=0;l<i.items.length;l++)if(this.lexer.state.top=false,i.items[l].tokens=this.lexer.blockTokens(i.items[l].text,[]),!i.loose){let c=i.items[l].tokens.filter(g=>g.type==="space"),p=c.length>0&&c.some(g=>this.rules.other.anyLine.test(g.raw));i.loose=p;}if(i.loose)for(let l=0;l<i.items.length;l++)i.items[l].loose=true;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return {type:"html",block:true,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return {type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=V(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(` 10382`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:true,align:s.align[o]});for(let o of i)s.rows.push(V(o,s.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:false,align:s.align[l]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return {type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===` 10383`?t[1].slice(0,-1):t[1];return {type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return {type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return {type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return !this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=true:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=false),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=true:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=false),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:false,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if
vendor: 19,520 bytes, lines 10383-10417
10383(!this.rules.other.endAngleBracket.test(n))return;let s=z(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else {let s=fe(t[2],"()");if(s===-2)return;if(s>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,a).trim(),t[3]="";}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3]);}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),me(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return {type:"text",raw:s,text:s}}return me(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){let s=[...r[0]].length-1,o,a,l=s,c=0,p=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+s);(r=p.exec(t))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){l+=a;continue}else if((r[5]||r[6])&&s%3&&!((s+a)%3)){c+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+c);let g=[...r[0]][0].length,d=e.slice(0,s+r.index+g+a);if(Math.min(s,a)%2){let f=d.slice(1,-1);return {type:"em",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}let R=d.slice(2,-2);return {type:"strong",raw:d,text:R,tokens:this.lexer.inlineTokens(R)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return {type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return {type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else {let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0];}return {type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return {type:"text",raw:t[0],text:t[0],escaped:n}}}};var x=class u{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||T,this.options.tokenizer=this.options.tokenizer||new y,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:false,inRawBlock:false,top:true};let t={other:m,block:C.normal,inline:M.normal};this.options.pedantic?(t.block=C.pedantic,t.inline=M.pedantic):this.options.gfm&&(t.block=C.gfm,this.options.breaks?t.inline=M.breaks:t.inline=M.gfm),this.tokenizer.rules=t;}static get rules(){return {block:C,inline:M}}static lex(e,t){return new u(t).lex(e)}static lexInline(e,t){return new u(t).inlineTokens(e)}lex(e){e=e.replace(m.carriageReturn,` 10384`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens);}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=false){for(this.options.pedantic&&(e=e.replace(m.tabCharGlobal," ").replace(m.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(s=>(r=s.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),true):false))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let s=t.at(-1);r.raw.length===1&&s!==void 0?s.raw+=` 10385`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(` 10386`)?"":` 10387`)+r.raw,s.text+=` 10388`+r.text,this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(` 10389`)?"":` 10390`)+r.raw,s.text+=` 10391`+r.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let s=1/0,o=e.slice(1),a;this.options.extensions.startBlock.forEach(l=>{a=l.call({lexer:this},o),typeof a=="number"&&a>=0&&(s=Math.min(s,a));}),s<1/0&&s>=0&&(i=e.substring(0,s+1));}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let s=t.at(-1);n&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(` 10392`)?"":` 10393`)+r.raw,s.text+=` 10394`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(` 10395`)?"":` 10396`)+r.raw,s.text+=` 10397`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(e){let s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=true,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)o.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=false,s="";for(;e;){i||(s=""),i=false;let o;if(this.options.extensions?.inline?.some(l=>(o=l.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),true):false))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let l=t.at(-1);o.type==="text"&&l?.type==="text"?(l.raw+=o.raw,l.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,s)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(this.options.extensions?.startInline){let l=1/0,c=e.slice(1),p;this.options.extensions.startInline.forEach(g=>{p=g.call({lexer:this},c),typeof p=="number"&&p>=0&&(l=Math.min(l,p));}),l<1/0&&l>=0&&(a=e.substring(0,l+1));}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(s=o.raw.slice(-1)),i=true;let l=t.at(-1);l?.type==="text"?(l.raw+=o.raw,l.text+=o.text):t.push(o);continue}if(e){let l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return t}};var P=class{options;parser;constructor(e){this.options=e||T;}space(e){return ""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(m.notSpaceStart)?.[0],i=e.replace(m.endingNewline,"")+` 10398`;return r?'<pre><code class="language-'+w(r)+'">'+(n?i:w(i,true))+`</code></pre> 10399`:"<pre><code>"+(n?i:w(i,true))+`</code></pre> 10400`}blockquote({tokens:e}){return `<blockquote> 10401${this.parser.parse(e)}</blockquote> 10402`}html({text:e}){return e}def(e){return ""}heading({tokens:e,depth:t}){return `<h${t}>${this.parser.parseInline(e)}</h${t}> 10403`}hr(e){return `<hr> 10404`}list(e){let t=e.ordered,n=e.start,r="";for(let o=0;o<e.items.length;o++){let a=e.items[o];r+=this.listitem(a);}let i=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return "<"+i+s+`> 10405`+r+"</"+i+`> 10406`}listitem(e){let t="";if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type==="paragraph"?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=n+" "+w(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=true)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:true}):t+=n+" ";}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li> 10407`}checkbox({checked:e}){return "<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return `<p>${this.parser.parseInline(e)}</p> 10408`}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let s=e.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n});}return r&&(r=`<tbody>${r}</tbody>`),`<table> 10409<thead> 10410`+t+`</thead> 10411`+r+`</table> 10412`}tablerow({text:e}){return `<tr> 10413${e}</tr> 10414`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return (e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}> 10415`}strong({tokens:e}){return `<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return `<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return `<code>${w(e,true)}</code>`}br(e){return "<br>"}del({tokens:e}){return `<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=J(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+w(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=J(e);if(i===null)return w(n);e=i;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${w(t)}"`),s+=">",s}text(e){return "tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:w(e.text)}};var $=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return ""+e}image({text:e}){return ""+e}br(){return ""}};var b=class u{options;renderer;textRenderer;constructor(e){this.options=e||T,this.options.renderer=this.options.renderer||new P,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $;}static parse(e,t){return new u(t).parse(e)}static parseInline(e,t){return new u(t).parseInline(e)}parse(e,t=true){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==false||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=a||"";continue}}let s=i;switch(s.type){case "space":{n+=this.renderer.space(s);continue}case "hr":{n+=this.renderer.hr(s);continue}case "heading":{n+=this.renderer.heading(s);continue}case "code":{n+=this.renderer.code(s);continue}case "table":{n+=this.renderer.table(s);continue}case "blockquote":{n+=this.renderer.blockquote(s);continue}case "list":{n+=this.renderer.list(s);continue}case "html":{n+=this.renderer.html(s);continue}case "def":{n+=this.renderer.def(s);continue}case "paragraph":{n+=this.renderer.paragraph(s);continue}case "text":{let o=s,a=this.renderer.text(o);for(;r+1<e.length&&e[r+1].type==="text";)o=e[++r],a+=` 10416`+this.renderer.text(o);t?n+=this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:true}]}):n+=a;continue}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=o||"";continue}}let s=i;switch(s.type){case "escape":{n+=t.text(s);break}case "html":{n+=t.html(s);break}case "link":{n+=t.link(s);break}case "image":{n+=t.image(s);break}case "strong":{n+=t.strong(s);break}case "em":{n+=t.em(s);break}case "codespan":{n+=t.codespan(s);break}case "br":{n+=t.br(s);break}case "del":{n+=t.del(s);break}case "text":{n+=t.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}};var S=class{options;block;constructor(e){this.options=e||T;}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?x.lex:x.lexInline}provideParser(){return this.block?b.parse:b.parseInline}};var B=class{defaults=L();options=this.setOptions;parse=this.parseMarkdown(true);parseInline=this.parseMarkdown(false);Parser=b;Renderer=P;TextRenderer=$;Lexer=x;Tokenizer=y;Hooks=S;constructor(...e){this.use(...e);}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case "table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let o of s)n=n.concat(this.walkTokens(o.tokens,t));break}case "list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,t));}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)));}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||false,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===false&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer;}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]));}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens);}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new P(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.renderer[o],l=i[o];i[o]=(...c)=>{let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p||""};}r.renderer=i;}if(n.tokenizer){let i=this.defaults.tokenizer||new y(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.tokenizer[o],l=i[o];i[o]=(...c)=>{let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p};}r.tokenizer=i;}if(n.hooks){let i=this.defaults.hooks||new S;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],l=i[o];S.passThroughHooks.has(s)?i[o]=c=>{if(this.defaults.async&&S.passThroughHooksRespectAsync.has(s))return (async()=>{let g=await a.call(i,c);return l.call(i,g)})();let p=a.call(i,c);return l.call(i,p)}:i[o]=(...c)=>{if(this.defaults.async)return (async()=>{let g=await a.apply(i,c);return g===false&&(g=await l.apply(i,c)),g})();let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p};}r.hooks=i;}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a};}this.defaults={...this.defaults,...r};}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return x.lex(e,t??this.defaults)}parser(e,t){return b.parse(e,t??this.defaults)}parseMarkdown(e){return (n,r)=>{let i={...r},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===true&&i.async===false)return o(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."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return (async()=>{let a=s.hooks?await s.hooks.preprocess(n):n,c=await(s.hooks?await s.hooks.provideLexer():e?x.lex:x.lexInline)(a,s),p=s.hooks?await s.hooks.processAllTokens(c):c;s.walkTokens&&await Promise.all(this.walkTokens(p,s.walkTokens));let d=await(s.hooks?await s.hooks.provideParser():e?b.parse:b.parseInline)(p,s);return s.hooks?await s.hooks.postprocess(d):d})().catch(o);try{s.hooks&&(n=s.hooks.preprocess(n));let l=(s.hooks?s.hooks.provideLexer():e?x.lex:x.lexInline)(n,s);s.hooks&&(l=s.hooks.processAllTokens(l)),s.walkTokens&&this.walkTokens(l,s.walkTokens);let p=(s.hooks?s.hooks.provideParser():e?b.parse:b.parseInline)(l,s);return s.hooks&&(p=s.hooks.postprocess(p)),p}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=` 10417Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+w(n.message+"",true)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}};var _=new B;function k(u,e){return _.parse(u,e)}
10417k.options=k.setOptions=function(u){return _.setOptions(u),k.defaults=_.defaults,G(k.defaults),k};k.getDefaults=L;k.defaults=T;k.use=function(...u){return _.use(...u),k.defaults=_.defaults,G(k.defaults),k};k.walkTokens=function(u,e){return _.walkTokens(u,e)};k.parseInline=_.parseInline;k.Parser=b;k.parser=b.parse;k.Renderer=P;k.TextRenderer=$;k.Lexer=x;k.lexer=x.lex;k.Tokenizer=y;k.Hooks=S;k.parse=k;k.options;k.setOptions;k.use;k.walkTokens;k.parseInline;b.parse;x.lex; 10418 10419class Clipboard { 10420 constructor(editorElement) { 10421 this.editorElement = editorElement; 10422 this.editor = editorElement.editor; 10423 this.contents = editorElement.contents; 10424 } 10425 10426 paste(event) { 10427 const clipboardData = event.clipboardData; 10428 10429 if (!clipboardData || this.#isPastingIntoCodeBlock()) return false 10430 10431 if (this.#isPlainTextOrURLPasted(clipboardData)) { 10432 this.#pastePlainText(clipboardData); 10433 event.preventDefault(); 10434 return true 10435 } 10436 10437 return this.#handlePastedFiles(clipboardData) 10438 } 10439 10440 #isPlainTextOrURLPasted(clipboardData) { 10441 return this.#isOnlyPlainTextPasted(clipboardData) || this.#isOnlyURLPasted(clipboardData) 10442 } 10443 10444 #isOnlyPlainTextPasted(clipboardData) { 10445 const types = Array.from(clipboardData.types); 10446 return types.length === 1 && types[0] === "text/plain" 10447 } 10448 10449 #isOnlyURLPasted(clipboardData) { 10450 // Safari URLs are copied as a text/plain + text/uri-list object 10451 const types = Array.from(clipboardData.types); 10452 return types.length === 2 && types.includes("text/uri-list") && types.includes("text/plain") 10453 } 10454 10455 #isPastingIntoCodeBlock() { 10456 let result = false;
10457 10458 this.editor.getEditorState().read(() => { 10459 const selection = Lr(); 10460 if (!yr(selection)) return 10461 10462 let currentNode = selection.anchor.getNode(); 10463 10464 while (currentNode) { 10465 if (X$1(currentNode)) { 10466 result = true; 10467 return 10468 } 10469 currentNode = currentNode.getParent(); 10470 } 10471 }); 10472 10473 return result 10474 } 10475 10476 #pastePlainText(clipboardData) { 10477 const item = clipboardData.items[0]; 10478 item.getAsString((text) => { 10479 if (isUrl(text) && this.contents.hasSelectedText()) { 10480 this.contents.createLinkWithSelectedText(text); 10481 } else if (isUrl(text)) { 10482 const nodeKey = this.contents.createLink(text); 10483 this.#dispatchLinkInsertEvent(nodeKey, { url: text }); 10484 } else if (this.editorElement.supportsMarkdown) { 10485 this.#pasteMarkdown(text); 10486 } else { 10487 this.#pasteRichText(clipboardData); 10488 } 10489 }); 10490 } 10491 10492 #dispatchLinkInsertEvent(nodeKey, payload) { 10493 const linkManipulationMethods = { 10494 replaceLinkWith: (html, options) => this.contents.replaceNodeWithHTML(nodeKey, html, options), 10495 insertBelowLink: (html, options) => this.contents.insertHTMLBelowNode(nodeKey, html, options) 10496 }; 10497 10498 dispatch(this.editorElement, "lexxy:insert-link", { 10499 ...payload, 10500 ...linkManipulationMethods 10501 }); 10502 } 10503 10504 #pasteMarkdown(text) { 10505 const html = k(text); 10506 const doc = parseHtml(html); 10507 const detail = Object.freeze({ 10508 markdown: text, 10509 document: doc, 10510 addBlockSpacing: () => addBlockSpacing(doc) 10511 }); 10512 10513 dispatch(this.editorElement, "lexxy:insert-markdown", detail); 10514 this.contents.insertDOM(doc, { tag: Fn }); 10515 } 10516 10517 #pasteRichText(clipboardData) { 10518 this.editor.update(() => { 10519 const selection = Lr(); 10520 R$2(clipboardData, selection, this.editor); 10521 }, { tag: Fn }); 10522 } 10523 10524 #handlePastedFiles(clipboardData) { 10525 if (!this.editorElement.supportsAttachments) return false 10526 10527 const html = clipboardData.getData("text/html"); 10528 if (html) { 10529 this.contents.insertHtml(html, { tag: Fn }); 10530 return true 10531 } 10532 10533 this.#preservingScrollPosition(() => { 10534 const files = clipboardData.files; 10535 if (files.length) { 10536 this.contents.uploadFiles(files, { selectLast: true }); 10537 } 10538 }); 10539 10540 return true 10541 } 10542 10543 // Deals with an issue in Safari where it scrolls to the tops after pasting attachments 10544 async #preservingScrollPosition(callback) { 10545 const scrollY = window.scrollY; 10546 const scrollX = window.scrollX; 10547 10548 callback(); 10549 10550 await nextFrame(); 10551 10552 window.scrollTo(scrollX, scrollY); 10553 this.editor.focus(); 10554 } 10555} 10556 10557class Extensions { 10558 10559 constructor(lexxyElement) { 10560 this.lexxyElement = lexxyElement; 10561 10562 this.enabledExtensions = this.#initializeExtensions(); 10563 } 10564 10565 get lexicalExtensions() { 10566 return this.enabledExtensions.map(ext => ext.lexicalExtension).filter(Boolean) 10567 } 10568 10569 initializeToolbars() { 10570 if (this.#lexxyToolbar) { 10571 this.enabledExtensions.forEach(ext => ext.initializeToolbar(this.#lexxyToolbar)); 10572 } 10573 } 10574 10575 get #lexxyToolbar() { 10576 return this.lexxyElement.toolbar 10577 } 10578 10579 get #baseExtensions() { 10580 return this.lexxyElement.baseExtensions 10581 } 10582 10583 get #configuredExtensions() { 10584 return Lexxy.global.get("extensions") 10585 } 10586 10587 #initializeExtensions() { 10588 const extensionDefinitions = this.#baseExtensions.concat(this.#configuredExtensions); 10589 10590 return extensionDefinitions.map( 10591 extension => new extension(this.lexxyElement) 10592 ).filter(extension => extension.enabled) 10593 } 10594} 10595 10596class ProvisionalParagraphNode extends Di { 10597 $config() { 10598 return this.config("provisonal_paragraph", { 10599 extends: Di, 10600 importDOM: () => null, 10601 $transform: (node) => { 10602 node.concretizeIfEdited(node); 10603 node.removeUnlessRequired(node); 10604 } 10605 }) 10606 } 10607 10608 static neededBetween(nodeBefore, nodeAfter) { 10609 return !$isSelectableElement(nodeBefore, "next") 10610 && !$isSelectableElement(nodeAfter, "previous") 10611 } 10612 10613 createDOM(editor) { 10614 const p = super.createDOM(editor); 10615 const selected = this.isSelected(Lr()); 10616 p.classList.add("provisional-paragraph"); 10617 p.classList.toggle("hidden", !selected); 10618 return p 10619 } 10620 10621 updateDOM(_prevNode, dom) { 10622 const selected = this.isSelected(Lr()); 10623 dom.classList.toggle("hidden", !selected); 10624 return false 10625 } 10626 10627 getTextContent() { 10628 return "" 10629 } 10630 10631 exportDOM() { 10632 return { 10633 element: null 10634 } 10635 } 10636
10637 // override as Lexical has an interesting view of collapsed selection in ElementNodes 10638 // https://github.com/facebook/lexical/blob/f1e4f66014377b1f2595aec2b0ee17f5b7ef4dfc/packages/lexical/src/LexicalNode.ts#L646 10639 isSelected(selection = null) { 10640 const targetSelection = selection || Lr(); 10641 return targetSelection?.getNodes().some(node => node.is(this) || this.isParentOf(node)) 10642 } 10643 10644 removeUnlessRequired(self = this.getLatest()) { 10645 if (!self.required) self.remove(); 10646 } 10647 10648 concretizeIfEdited(self = this.getLatest()) { 10649 if (self.getTextContentSize() > 0) { 10650 self.replace(Li(), true); 10651 } 10652 } 10653 10654 10655 get required() { 10656 return this.isDirectRootChild && ProvisionalParagraphNode.neededBetween(...this.immediateSiblings) 10657 } 10658 10659 get isDirectRootChild() { 10660 const parent = this.getParent(); 10661 return as(parent) 10662 } 10663 10664 get immediateSiblings() { 10665 return [ this.getPreviousSibling(), this.getNextSibling() ] 10666 } 10667} 10668 10669function $isProvisionalParagraphNode(node) { 10670 return node instanceof ProvisionalParagraphNode 10671} 10672 10673function $isSelectableElement(node, direction) { 10674 return Si(node) && (direction === "next" ? node.canInsertTextBefore() : node.canInsertTextAfter()) 10675} 10676 10677class ProvisionalParagraphExtension extends LexxyExtension { 10678 get lexicalExtension() { 10679 return Kl({ 10680 name: "lexxy/provisional-paragraph", 10681 nodes: [ 10682 ProvisionalParagraphNode 10683 ], 10684 register(editor) { 10685 return U$4( 10686 // Process Provisional Paragraph Nodes on RootNode changes as sibling status influences whether 10687 // they are required and their visible/hidden status 10688 editor.registerNodeTransform(Ni, $insertRequiredProvisionalParagraphs), 10689 editor.registerNodeTransform(Ni, $removeUnneededProvisionalParagraphs), 10690 editor.registerCommand(ie$1, $markAllProvisionalParagraphsDirty, Bi) 10691 ) 10692 } 10693 }) 10694 } 10695} 10696 10697function $insertRequiredProvisionalParagraphs(rootNode) { 10698 const firstNode = rootNode.getFirstChild(); 10699 if (ProvisionalParagraphNode.neededBetween(null, firstNode)) { 10700 Nt$5(rootNode, new ProvisionalParagraphNode); 10701 } 10702 10703 for (const node of $t$3(rootNode)) { 10704 const nextNode = node.getNextSibling(); 10705 if (ProvisionalParagraphNode.neededBetween(node, nextNode)) { 10706 node.insertAfter(new ProvisionalParagraphNode); 10707 } 10708 } 10709} 10710 10711function $removeUnneededProvisionalParagraphs(rootNode) { 10712 for (const provisionalParagraph of $getAllProvisionalParagraphs(rootNode)) { 10713 provisionalParagraph.removeUnlessRequired(); 10714 } 10715} 10716 10717function $markAllProvisionalParagraphsDirty() { 10718 for (const provisionalParagraph of $getAllProvisionalParagraphs()) { 10719 provisionalParagraph.markDirty(); 10720 } 10721} 10722 10723function $getAllProvisionalParagraphs(rootNode = No()) { 10724 return kt$6(rootNode.getChildren(), $isProvisionalParagraphNode) 10725} 10726 10727const TRIX_LANGUAGE_ATTR = "language"; 10728 10729class TrixContentExtension extends LexxyExtension { 10730 10731 get enabled() { 10732 return this.editorElement.supportsRichText 10733 } 10734 10735 get lexicalExtension() { 10736 return Kl({ 10737 name: "lexxy/trix-content", 10738 html: { 10739 import: { 10740 em: (element) => onlyStyledElements(element, { 10741 conversion: extendTextNodeConversion("i", $applyHighlightStyle), 10742 priority: 1 10743 }), 10744 span: (element) => onlyStyledElements(element, { 10745 conversion: extendTextNodeConversion("mark", $applyHighlightStyle), 10746 priority: 1 10747 }), 10748 strong: (element) => onlyStyledElements(element, { 10749 conversion: extendTextNodeConversion("b", $applyHighlightStyle), 10750 priority: 1 10751 }), 10752 del: () => ({ 10753 conversion: extendTextNodeConversion("s", $applyStrikethrough, $applyHighlightStyle), 10754 priority: 1 10755 }), 10756 pre: (element) => onlyPreLanguageElements(element, { 10757 conversion: extendConversion(q$1, "pre", $applyLanguage), 10758 priority: 1 10759 }) 10760 } 10761 } 10762 }) 10763 } 10764} 10765 10766function onlyStyledElements(element, conversion) { 10767 const elementHighlighted = element.style.color !== "" || element.style.backgroundColor !== ""; 10768 return elementHighlighted ? conversion : null 10769} 10770 10771function $applyStrikethrough(textNode) { 10772 if (!textNode.hasFormat("strikethrough")) textNode.toggleFormat("strikethrough"); 10773 return textNode 10774} 10775 10776function onlyPreLanguageElements(element, conversion) { 10777 return element.hasAttribute(TRIX_LANGUAGE_ATTR) ? conversion : null 10778} 10779 10780function $applyLanguage(conversionOutput, element) { 10781 const language = dt$1(element.getAttribute(TRIX_LANGUAGE_ATTR)); 10782 conversionOutput.node.setLanguage(language); 10783} 10784 10785class WrappedTableNode extends hn { 10786 $config() { 10787 return this.config("wrapped_table_node", { extends: hn }) 10788 } 10789 10790 static importDOM() { 10791 return super.importDOM() 10792 } 10793 10794 exportDOM(editor) { 10795 const superExport = super.exportDOM(editor); 10796 10797 return { 10798 ...superExport, 10799 after: (tableElement) => { 10800 if (superExport.after) { 10801 tableElement = superExport.after(tableElement); 10802 const clonedTable = tableElement.cloneNode(true); 10803 const wrappedTable = createElement("figure", { className: "lexxy-content__table-wrapper" }, clonedTable.outerHTML); 10804 return wrappedTable 10805 } 10806 10807 return tableElement 10808 } 10809 } 10810 } 10811} 10812 10813class TablesExtension extends LexxyExtension { 10814 10815 get enabled() { 10816 return this.editorElement.supportsRichText 10817 } 10818 10819 get lexicalExtension() { 10820 return Kl({ 10821 name: "lexxy/tables", 10822 nodes: [ 10823 WrappedTableNode, 10824 { 10825 replace: hn, 10826 with: () => new WrappedTableNode(), 10827 withKlass: WrappedTableNode 10828 }, 10829 xe, 10830 Ee$1 10831 ], 10832 register(editor) { 10833 return U$4( 10834 // Register Lexical table plugins 10835 Nn(editor), 10836 yn(editor, true), 10837 un(editor), 10838 10839 // Bug fix: Prevent hardcoded background color (Lexical #8089) 10840 editor.registerNodeTransform(xe, (node) => {
10841 if (node.getBackgroundColor() === null) { 10842 node.setBackgroundColor(""); 10843 } 10844 }), 10845 10846 // Bug fix: Fix column header states (Lexical #8090) 10847 editor.registerNodeTransform(xe, (node) => { 10848 const headerState = node.getHeaderStyles(); 10849 10850 if (headerState !== ve$1.ROW) return 10851 10852 const rowParent = node.getParent(); 10853 const tableNode = rowParent?.getParent(); 10854 if (!tableNode) return 10855 10856 const rows = tableNode.getChildren(); 10857 const cellIndex = rowParent.getChildren().indexOf(node); 10858 10859 const cellsInRow = rowParent.getChildren(); 10860 const isHeaderRow = cellsInRow.every(cell => 10861 cell.getHeaderStyles() !== ve$1.NO_STATUS 10862 ); 10863 10864 const isHeaderColumn = rows.every(row => { 10865 const cell = row.getChildren()[cellIndex]; 10866 return cell && cell.getHeaderStyles() !== ve$1.NO_STATUS 10867 }); 10868 10869 let newHeaderState = ve$1.NO_STATUS; 10870 10871 if (isHeaderRow) newHeaderState |= ve$1.ROW; 10872 if (isHeaderColumn) newHeaderState |= ve$1.COLUMN; 10873 10874 if (newHeaderState !== headerState) { 10875 node.setHeaderStyles(newHeaderState, ve$1.BOTH); 10876 } 10877 }), 10878 10879 editor.registerCommand("insertTableRowAfter", () => { 10880 je$1(true); 10881 }, Ri), 10882 10883 editor.registerCommand("insertTableRowBefore", () => { 10884 je$1(false); 10885 }, Ri), 10886 10887 editor.registerCommand("insertTableColumnAfter", () => { 10888 Ze$1(true); 10889 }, Ri), 10890 10891 editor.registerCommand("insertTableColumnBefore", () => { 10892 Ze$1(false); 10893 }, Ri), 10894 10895 editor.registerCommand("deleteTableRow", () => { 10896 ot(); 10897 }, Ri), 10898 10899 editor.registerCommand("deleteTableColumn", () => { 10900 lt(); 10901 }, Ri), 10902 10903 editor.registerCommand("deleteTable", () => { 10904 const selection = Lr(); 10905 if (!yr(selection)) return false 10906 Qt(selection.anchor.getNode())?.remove(); 10907 }, Ri) 10908 ) 10909 } 10910 }) 10911 } 10912} 10913 10914class AttachmentsExtension extends LexxyExtension { 10915 get enabled() { 10916 return this.editorElement.supportsAttachments 10917 } 10918 10919 get lexicalExtension() { 10920 return Kl({ 10921 name: "lexxy/action-text-attachments", 10922 nodes: [ 10923 ActionTextAttachmentNode, 10924 ActionTextAttachmentUploadNode, 10925 ImageGalleryNode 10926 ], 10927 register(editor) { 10928 return U$4( 10929 editor.registerCommand(le$2, $collapseIntoGallery, Ri) 10930 ) 10931 } 10932 }) 10933 } 10934} 10935 10936function $collapseIntoGallery(backwards) { 10937 const anchor = Lr()?.anchor; 10938 if (!anchor) return false 10939 10940 if ($collapseAtGalleryEdge(anchor, backwards)) { 10941 return true 10942 } else if (backwards) { 10943 return $collapseAroundEmptyParagraph(anchor) 10944 || $moveSelectionBeforeGallery(anchor) 10945 } 10946 10947 return false 10948} 10949 10950function $collapseAroundEmptyParagraph(anchor) { 10951 const anchorNode = anchor.getNode(); 10952 if (!anchorNode) return false 10953 10954 const isWithinEmptyParagraph = Ii(anchorNode) && anchorNode.isEmpty(); 10955 const previousSibling = anchorNode.getPreviousSibling(); 10956 const topGallery = $findOrCreateGalleryForImage(previousSibling); 10957 const selectionIndex = topGallery?.getChildrenSize(); 10958 10959 if (isWithinEmptyParagraph && topGallery?.collapseWith(anchorNode.getNextSibling())) { 10960 topGallery.select(selectionIndex, selectionIndex); 10961 anchorNode.remove(); 10962 return true 10963 } else { 10964 return false 10965 } 10966} 10967 10968function $collapseAtGalleryEdge(anchor, backwards) { 10969 const anchorNode = anchor.getNode(); 10970 if (!$isImageGalleryNode(anchorNode)) return false 10971 10972 const isAtGalleryEdge = $isAtNodeEdge(anchor, backwards); 10973 const sibling = backwards ? anchorNode.getPreviousSibling() : anchorNode.getNextSibling(); 10974 10975 if (isAtGalleryEdge && anchorNode.collapseWith(sibling, backwards)) { 10976 const selectionOffset = backwards ? 1 : anchorNode.getChildrenSize() - 1; 10977 anchorNode.select(selectionOffset, selectionOffset); 10978 return true 10979 } else { 10980 return false 10981 } 10982} 10983 10984// Manual selection handling to prevent Lexical merging the gallery with a <p> and unwrapping it 10985function $moveSelectionBeforeGallery(anchor) { 10986 const previousNode = anchor.getNode().getPreviousSibling(); 10987 if (!$isImageGalleryNode(anchor.getNode()) || !$isAtNodeEdge(anchor, true) || !previousNode) return false 10988 10989 if (Ti(previousNode)) { 10990 // Handled by Lexxy decorator selection behavior 10991 return false 10992 } else if (previousNode.isEmpty()) { 10993 previousNode.remove(); 10994 } else { 10995 previousNode.selectEnd(); 10996 } 10997 10998 return true 10999} 11000 11001class LexicalEditorElement extends HTMLElement { 11002 static formAssociated = true 11003 static debug = false 11004 static commands = [ "bold", "italic", "strikethrough" ] 11005 11006 static observedAttributes = [ "connected", "required" ] 11007 11008 #initialValue = "" 11009 #validationTextArea = document.createElement("textarea") 11010 11011 constructor() { 11012 super(); 11013 this.internals = this.attachInternals(); 11014 this.internals.role = "presentation"; 11015 } 11016 11017 connectedCallback() { 11018 this.id ??= generateDomId("lexxy-editor"); 11019 this.config = new EditorConfiguration(this); 11020 this.extensions = new Extensions(this); 11021 11022 this.editor = this.#createEditor(); 11023 11024 this.contents = new Contents(this); 11025 this.selection = new Selection(this); 11026 this.clipboard = new Clipboard(this); 11027
11028 CommandDispatcher.configureFor(this); 11029 this.#initialize(); 11030 11031 requestAnimationFrame(() => dispatch(this, "lexxy:initialize")); 11032 this.toggleAttribute("connected", true); 11033 11034 this.#handleAutofocus(); 11035 11036 this.valueBeforeDisconnect = null; 11037 } 11038 11039 disconnectedCallback() { 11040 this.valueBeforeDisconnect = this.value; 11041 this.#reset(); // Prevent hangs with Safari when morphing 11042 } 11043 11044 attributeChangedCallback(name, oldValue, newValue) { 11045 if (name === "connected" && this.isConnected && oldValue != null && oldValue !== newValue) { 11046 requestAnimationFrame(() => this.#reconnect()); 11047 } 11048 11049 if (name === "required" && this.isConnected) { 11050 this.#validationTextArea.required = this.hasAttribute("required"); 11051 this.#setValidity(); 11052 } 11053 } 11054 11055 formResetCallback() { 11056 this.value = this.#initialValue; 11057 this.editor.dispatchCommand(je$2, undefined); 11058 } 11059 11060 toString() { 11061 if (!this.cachedStringValue) { 11062 this.editor?.getEditorState().read(() => { 11063 this.cachedStringValue = No().getTextContent(); 11064 }); 11065 } 11066 11067 return this.cachedStringValue 11068 } 11069 11070 get form() { 11071 return this.internals.form 11072 } 11073 11074 get name() { 11075 return this.getAttribute("name") 11076 } 11077 11078 get toolbarElement() { 11079 if (!this.#hasToolbar) return null 11080 11081 this.toolbar = this.toolbar || this.#findOrCreateDefaultToolbar(); 11082 return this.toolbar 11083 } 11084 11085 get baseExtensions() { 11086 return [ 11087 ProvisionalParagraphExtension, 11088 HighlightExtension, 11089 TrixContentExtension, 11090 TablesExtension, 11091 AttachmentsExtension 11092 ] 11093 } 11094 11095 get directUploadUrl() { 11096 return this.dataset.directUploadUrl 11097 } 11098 11099 get blobUrlTemplate() { 11100 return this.dataset.blobUrlTemplate 11101 } 11102 11103 get isEmpty() { 11104 return [ "<p><br></p>", "<p></p>", "" ].includes(this.value.trim()) 11105 } 11106 11107 get isBlank() { 11108 return this.isEmpty || this.toString().match(/^\s*$/g) !== null 11109 } 11110 11111 get hasOpenPrompt() { 11112 return this.querySelector(".lexxy-prompt-menu.lexxy-prompt-menu--visible") !== null 11113 } 11114 11115 get preset() { 11116 return this.getAttribute("preset") || "default" 11117 } 11118 11119 get supportsAttachments() { 11120 return this.config.get("attachments") 11121 } 11122 11123 get supportsMarkdown() { 11124 return this.supportsRichText && this.config.get("markdown") 11125 } 11126 11127 get supportsMultiLine() { 11128 return this.config.get("multiLine") && !this.isSingleLineMode 11129 } 11130 11131 get supportsRichText() { 11132 return this.config.get("richText") 11133 } 11134 11135 // TODO: Deprecate `single-line` attribute 11136 get isSingleLineMode() { 11137 return this.hasAttribute("single-line") 11138 } 11139 11140 get contentTabIndex() { 11141 return parseInt(this.editorContentElement?.getAttribute("tabindex") ?? "0") 11142 } 11143 11144 focus() { 11145 this.editor.focus(() => this.#onFocus()); 11146 } 11147 11148 get value() { 11149 if (!this.cachedValue) { 11150 this.editor?.getEditorState().read(() => { 11151 this.cachedValue = sanitize(g(this.editor, null)); 11152 }); 11153 } 11154 11155 return this.cachedValue 11156 } 11157 11158 set value(html) { 11159 this.editor.update(() => { 11160 ns(zn); 11161 const root = No(); 11162 root.clear(); 11163 root.append(...this.#parseHtmlIntoLexicalNodes(html)); 11164 root.selectEnd(); 11165 11166 this.#toggleEmptyStatus(); 11167 11168 // The first time you set the value, when the editor is empty, it seems to leave Lexical 11169 // in an inconsistent state until, at least, you focus. You can type but adding attachments 11170 // fails because no root node detected. This is a workaround to deal with the issue. 11171 requestAnimationFrame(() => this.editor?.update(() => { })); 11172 }); 11173 } 11174 11175 #parseHtmlIntoLexicalNodes(html) { 11176 if (!html) html = "<p></p>"; 11177 const nodes = m$1(this.editor, parseHtml(`${html}`)); 11178 11179 return nodes 11180 .map(this.#wrapTextNode) 11181 .map(this.#unwrapDecoratorNode) 11182 } 11183 11184 // Raw string values produce TextNodes which cannot be appended directly to the RootNode. 11185 // We wrap those in <p> 11186 #wrapTextNode(node) { 11187 if (!lr(node)) return node 11188 11189 const paragraph = Li(); 11190 paragraph.append(node); 11191 return paragraph 11192 } 11193 11194 // Custom decorator block elements such as action-text-attachments get wrapped into <p> automatically by Lexical. 11195 // We unwrap those. 11196 #unwrapDecoratorNode(node) { 11197 if (Ii(node) && node.getChildrenSize() === 1) { 11198 const child = node.getFirstChild(); 11199 if (Ti(child) && !child.isInline()) { 11200 return child 11201 } 11202 } 11203 return node 11204 } 11205 11206 #initialize() { 11207 this.#synchronizeWithChanges(); 11208 this.#registerComponents(); 11209 this.#handleEnter(); 11210 this.#registerFocusEvents(); 11211 this.#attachDebugHooks(); 11212 this.#attachToolbar(); 11213 this.#loadInitialValue(); 11214 this.#resetBeforeTurboCaches(); 11215 } 11216 11217 #createEditor() { 11218 this.editorContentElement ||= this.#createEditorContentElement(); 11219 11220 const editor = $t$2({ 11221 name: "lexxy/core", 11222 namespace: "Lexxy", 11223 theme: theme, 11224 nodes: this.#lexicalNodes 11225 }, 11226 ...this.extensions.lexicalExtensions 11227 ); 11228 11229 editor.setRootElement(this.editorContentElement); 11230 11231 return editor 11232 } 11233 11234 get #lexicalNodes() { 11235 const nodes = [ CustomActionTextAttachmentNode ]; 11236 11237 if (this.supportsRichText) { 11238 nodes.push( 11239 Et$3, 11240 Pt$3, 11241 lt$3, 11242 nt$2, 11243 q$1, 11244 et$1, 11245 y$2, 11246 A$1, 11247 HorizontalDividerNode 11248 ); 11249 } 11250 11251 return nodes 11252 } 11253 11254 #createEditorContentElement() { 11255 const editorContentElement = createElement("div", { 11256 classList: "lexxy-editor__content", 11257 contenteditable: true, 11258 role: "textbox", 11259 "aria-multiline": true, 11260 "aria-label": this.#labelText, 11261 placeholder: this.getAttribute("placeholder") 11262 }); 11263 editorContentElement.id = `${this.id}-content`;
11264 this.#ariaAttributes.forEach(attribute => editorContentElement.setAttribute(attribute.name, attribute.value)); 11265 this.appendChild(editorContentElement); 11266 11267 if (this.getAttribute("tabindex")) { 11268 editorContentElement.setAttribute("tabindex", this.getAttribute("tabindex")); 11269 this.removeAttribute("tabindex"); 11270 } else { 11271 editorContentElement.setAttribute("tabindex", 0); 11272 } 11273 11274 return editorContentElement 11275 } 11276 11277 get #labelText() { 11278 return Array.from(this.internals.labels).map(label => label.textContent).join(" ") 11279 } 11280 11281 get #ariaAttributes() { 11282 return Array.from(this.attributes).filter(attribute => attribute.name.startsWith("aria-")) 11283 } 11284 11285 set #internalFormValue(html) { 11286 const changed = this.#internalFormValue !== undefined && this.#internalFormValue !== this.value; 11287 11288 this.internals.setFormValue(html); 11289 this._internalFormValue = html; 11290 this.#validationTextArea.value = this.isEmpty ? "" : html; 11291 11292 if (changed) { 11293 dispatch(this, "lexxy:change"); 11294 } 11295 } 11296 11297 get #internalFormValue() { 11298 return this._internalFormValue 11299 } 11300 11301 #loadInitialValue() { 11302 const initialHtml = this.valueBeforeDisconnect || this.getAttribute("value") || "<p></p>"; 11303 this.value = this.#initialValue = initialHtml; 11304 } 11305 11306 #resetBeforeTurboCaches() { 11307 document.addEventListener("turbo:before-cache", this.#handleTurboBeforeCache); 11308 } 11309 11310 #handleTurboBeforeCache = (event) => { 11311 this.#reset(); 11312 } 11313 11314 #synchronizeWithChanges() { 11315 this.#addUnregisterHandler(this.editor.registerUpdateListener(({ editorState }) => { 11316 this.#clearCachedValues(); 11317 this.#internalFormValue = this.value; 11318 this.#toggleEmptyStatus(); 11319 this.#setValidity(); 11320 })); 11321 } 11322 11323 #clearCachedValues() { 11324 this.cachedValue = null; 11325 this.cachedStringValue = null; 11326 } 11327 11328 #addUnregisterHandler(handler) { 11329 this.unregisterHandlers = this.unregisterHandlers || []; 11330 this.unregisterHandlers.push(handler); 11331 } 11332 11333 #unregisterHandlers() { 11334 this.unregisterHandlers?.forEach((handler) => { 11335 handler(); 11336 }); 11337 this.unregisterHandlers = null; 11338 } 11339 11340 #registerComponents() { 11341 if (this.supportsRichText) { 11342 Jt$1(this.editor); 11343 bt$4(this.editor); 11344 this.#registerTableComponents(); 11345 this.#registerCodeHiglightingComponents(); 11346 if (this.supportsMarkdown) { 11347 Dt$1(this.editor, zt$1); 11348 } 11349 } else { 11350 z$2(this.editor); 11351 } 11352 this.historyState = w$1(); 11353 b$1(this.editor, this.historyState, 20); 11354 } 11355 11356 #registerTableComponents() { 11357 this.tableTools = createElement("lexxy-table-tools"); 11358 this.append(this.tableTools); 11359 } 11360 11361 #registerCodeHiglightingComponents() { 11362 Et$2(this.editor); 11363 this.codeLanguagePicker = createElement("lexxy-code-language-picker"); 11364 this.append(this.codeLanguagePicker); 11365 } 11366 11367 #handleEnter() { 11368 // We can't prevent these externally using regular keydown because Lexical handles it first. 11369 this.editor.registerCommand( 11370 Ne$2, 11371 (event) => { 11372 // Prevent CTRL+ENTER 11373 if (event.ctrlKey || event.metaKey) { 11374 event.preventDefault(); 11375 return true 11376 } 11377 11378 // In single line mode, prevent ENTER 11379 if (!this.supportsMultiLine) { 11380 event.preventDefault(); 11381 return true 11382 } 11383 11384 return false 11385 }, 11386 Ri 11387 ); 11388 } 11389 11390 #registerFocusEvents() { 11391 this.addEventListener("focusin", this.#handleFocusIn); 11392 this.addEventListener("focusout", this.#handleFocusOut); 11393 } 11394 11395 #handleFocusIn(event) { 11396 if (this.#elementInEditorOrToolbar(event.target) && !this.currentlyFocused) { 11397 dispatch(this, "lexxy:focus"); 11398 this.currentlyFocused = true; 11399 } 11400 } 11401 11402 #handleFocusOut(event) { 11403 if (!this.#elementInEditorOrToolbar(event.relatedTarget)) { 11404 dispatch(this, "lexxy:blur"); 11405 this.currentlyFocused = false; 11406 } 11407 } 11408 11409 #elementInEditorOrToolbar(element) { 11410 return this.contains(element) || this.toolbarElement?.contains(element) 11411 } 11412 11413 #onFocus() { 11414 if (this.isEmpty) { 11415 this.selection.placeCursorAtTheEnd(); 11416 } 11417 } 11418 11419 #handleAutofocus() { 11420 if (!document.querySelector(":focus")) { 11421 if (this.hasAttribute("autofocus") && document.querySelector("[autofocus]") === this) { 11422 this.focus(); 11423 } 11424 } 11425 } 11426 11427 11428 #attachDebugHooks() { 11429 return 11430 } 11431 11432 #attachToolbar() { 11433 if (this.#hasToolbar) { 11434 this.toolbarElement.setEditor(this); 11435 this.extensions.initializeToolbars(); 11436 } 11437 } 11438 11439 #findOrCreateDefaultToolbar() { 11440 const toolbarId = this.config.get("toolbar"); 11441 if (toolbarId && toolbarId !== true) { 11442 return document.getElementById(toolbarId) 11443 } else { 11444 return this.#createDefaultToolbar() 11445 } 11446 } 11447 11448 get #hasToolbar() { 11449 return this.supportsRichText && this.config.get("toolbar") 11450 } 11451 11452 #createDefaultToolbar() { 11453 const toolbar = createElement("lexxy-toolbar"); 11454 toolbar.innerHTML = LexicalToolbarElement.defaultTemplate; 11455 toolbar.setAttribute("data-attachments", this.supportsAttachments); // Drives toolbar CSS styles 11456 this.prepend(toolbar); 11457 return toolbar 11458 } 11459 11460 #toggleEmptyStatus() { 11461 this.classList.toggle("lexxy-editor--empty", this.isEmpty); 11462 } 11463 11464 #setValidity() { 11465 if (this.#validationTextArea.validity.valid) { 11466 this.internals.setValidity({}); 11467 } else { 11468 this.internals.setValidity(this.#validationTextArea.validity, this.#validationTextArea.validationMessage, this.editorContentElement); 11469 } 11470 } 11471 11472 #reset() { 11473 this.#unregisterHandlers(); 11474 11475 if (this.editorContentElement) { 11476 this.editorContentElement.remove(); 11477 this.editorContentElement = null; 11478 } 11479 11480 this.contents = null; 11481 this.editor = null; 11482 11483 if (this.toolbar) { 11484 if (!this.getAttribute("toolbar")) { this.toolbar.remove(); } 11485 this.toolbar = null; 11486 } 11487 11488 if (this.codeLanguagePicker) { 11489 this.codeLanguagePicker.remove(); 11490 this.codeLanguagePicker = null; 11491 } 11492 11493 if (this.tableHandler) { 11494 this.tableHandler.remove(); 11495 this.tableHandler = null; 11496 } 11497 11498 this.selection = null; 11499 11500 document.removeEventListener("turbo:before-cache", this.#handleTurboBeforeCache); 11501 } 11502 11503 #reconnect() { 11504 this.disconnectedCallback(); 11505 this.valueBeforeDisconnect = null; 11506 this.connectedCallback(); 11507 } 11508} 11509 11510class ToolbarDropdown extends HTMLElement { 11511 connectedCallback() { 11512 this.container = this.closest("details"); 11513 11514 this.container.addEventListener("toggle", this.#handleToggle.bind(this)); 11515 this.container.addEventListener("keydown", this.#handleKeyDown.bind(this)); 11516 11517 this.#onToolbarEditor(this.initialize.bind(this)); 11518 } 11519 11520 disconnectedCallback() { 11521 this.container.removeEventListener("keydown", this.#handleKeyDown.bind(this)); 11522 } 11523 11524 get toolbar() { 11525 return this.closest("lexxy-toolbar") 11526 } 11527 11528 get editorElement() { 11529 return this.toolbar.editorElement 11530 } 11531 11532 get editor() { 11533 return this.toolbar.editor 11534 } 11535 11536 initialize() { 11537 // Any post-editor initialization 11538 } 11539 11540 close() { 11541 this.editor.focus(); 11542 this.container.open = false;
11543 } 11544 11545 async #onToolbarEditor(callback) { 11546 await this.toolbar.editorConnected; 11547 callback(); 11548 } 11549 11550 #handleToggle() { 11551 if (this.container.open) { 11552 this.#handleOpen(); 11553 } 11554 } 11555 11556 async #handleOpen() { 11557 this.#interactiveElements[0].focus(); 11558 this.#resetTabIndexValues(); 11559 } 11560 11561 #handleKeyDown(event) { 11562 if (event.key === "Escape") { 11563 event.stopPropagation(); 11564 this.close(); 11565 } 11566 } 11567 11568 async #resetTabIndexValues() { 11569 await nextFrame(); 11570 this.#buttons.forEach((element, index) => { 11571 element.setAttribute("tabindex", index === 0 ? 0 : "-1"); 11572 }); 11573 } 11574 11575 get #interactiveElements() { 11576 return Array.from(this.querySelectorAll("button, input")) 11577 } 11578 11579 get #buttons() { 11580 return Array.from(this.querySelectorAll("button")) 11581 } 11582} 11583 11584class LinkDropdown extends ToolbarDropdown { 11585 connectedCallback() { 11586 super.connectedCallback(); 11587 this.input = this.querySelector("input"); 11588 11589 this.#registerHandlers(); 11590 } 11591 11592 #registerHandlers() { 11593 this.container.addEventListener("toggle", this.#handleToggle.bind(this)); 11594 this.addEventListener("submit", this.#handleSubmit.bind(this)); 11595 this.querySelector("[value='unlink']").addEventListener("click", this.#handleUnlink.bind(this)); 11596 } 11597 11598 #handleToggle({ newState }) { 11599 this.input.value = this.#selectedLinkUrl; 11600 this.input.required = newState === "open"; 11601 } 11602 11603 #handleSubmit(event) { 11604 const command = event.submitter?.value; 11605 this.editor.dispatchCommand(command, this.input.value); 11606 this.close(); 11607 } 11608 11609 #handleUnlink() { 11610 this.editor.dispatchCommand("unlink"); 11611 this.close(); 11612 } 11613 11614 get #selectedLinkUrl() { 11615 let url = ""; 11616 11617 this.editor.getEditorState().read(() => { 11618 const selection = Lr(); 11619 if (!yr(selection)) return 11620 11621 let node = selection.getNodes()[0]; 11622 while (node && node.getParent()) { 11623 if (w$3(node)) { 11624 url = node.getURL(); 11625 break 11626 } 11627 node = node.getParent(); 11628 } 11629 }); 11630 11631 return url 11632 } 11633} 11634 11635const APPLY_HIGHLIGHT_SELECTOR = "button.lexxy-highlight-button"; 11636const REMOVE_HIGHLIGHT_SELECTOR = "[data-command='removeHighlight']"; 11637 11638// Use Symbol instead of null since $getSelectionStyleValueForProperty 11639// responds differently for backward selections if null is the default 11640// see https://github.com/facebook/lexical/issues/8013 11641const NO_STYLE = Symbol("no_style"); 11642 11643class HighlightDropdown extends ToolbarDropdown { 11644 connectedCallback() { 11645 super.connectedCallback(); 11646 this.#registerToggleHandler(); 11647 } 11648 11649 initialize() { 11650 this.#setUpButtons(); 11651 this.#registerButtonHandlers(); 11652 } 11653 11654 #registerToggleHandler() { 11655 this.container.addEventListener("toggle", this.#handleToggle.bind(this)); 11656 } 11657 11658 #registerButtonHandlers() { 11659 this.#colorButtons.forEach(button => button.addEventListener("click", this.#handleColorButtonClick.bind(this))); 11660 this.querySelector(REMOVE_HIGHLIGHT_SELECTOR).addEventListener("click", this.#handleRemoveHighlightClick.bind(this)); 11661 } 11662 11663 #setUpButtons() { 11664 const colorGroups = this.editorElement.config.get("highlight.buttons"); 11665 11666 this.#populateButtonGroup("color", colorGroups.color); 11667 this.#populateButtonGroup("background-color", colorGroups["background-color"]); 11668 11669 const maxNumberOfColors = Math.max(colorGroups.color.length, colorGroups["background-color"].length); 11670 this.style.setProperty("--max-colors", maxNumberOfColors); 11671 } 11672 11673 #populateButtonGroup(attribute, values) { 11674 values.forEach((value, index) => { 11675 this.#buttonContainer.appendChild(this.#createButton(attribute, value, index)); 11676 }); 11677 } 11678 11679 #createButton(attribute, value, index) { 11680 const button = document.createElement("button"); 11681 button.dataset.style = attribute; 11682 button.style.setProperty(attribute, value); 11683 button.dataset.value = value; 11684 button.classList.add("lexxy-editor__toolbar-button", "lexxy-highlight-button"); 11685 button.name = attribute + "-" + index; 11686 return button 11687 } 11688 11689 #handleToggle({ newState }) { 11690 if (newState === "open") { 11691 this.editor.getEditorState().read(() => { 11692 this.#updateColorButtonStates(Lr()); 11693 }); 11694 } 11695 } 11696 11697 #handleColorButtonClick(event) { 11698 event.preventDefault(); 11699 11700 const button = event.target.closest(APPLY_HIGHLIGHT_SELECTOR); 11701 if (!button) return 11702 11703 const attribute = button.dataset.style; 11704 const value = button.dataset.value; 11705 11706 this.editor.dispatchCommand("toggleHighlight", { [attribute]: value }); 11707 this.close(); 11708 } 11709 11710 #handleRemoveHighlightClick(event) { 11711 event.preventDefault(); 11712 11713 this.editor.dispatchCommand("removeHighlight"); 11714 this.close(); 11715 } 11716 11717 #updateColorButtonStates(selection) { 11718 if (!yr(selection)) { return } 11719 11720 // Use non-"" default, so "" indicates mixed highlighting 11721 const textColor = le$1(selection, "color", NO_STYLE); 11722 const backgroundColor = le$1(selection, "background-color", NO_STYLE); 11723 11724 this.#colorButtons.forEach(button => { 11725 const matchesSelection = button.dataset.value === textColor || button.dataset.value === backgroundColor; 11726 button.setAttribute("aria-pressed", matchesSelection); 11727 }); 11728 11729 const hasHighlight = textColor !== NO_STYLE || backgroundColor !== NO_STYLE; 11730 this.querySelector(REMOVE_HIGHLIGHT_SELECTOR).disabled = !hasHighlight; 11731 } 11732 11733 get #buttonContainer() { 11734 return this.querySelector(".lexxy-highlight-colors") 11735 } 11736 11737 get #colorButtons() { 11738 return Array.from(this.querySelectorAll(APPLY_HIGHLIGHT_SELECTOR)) 11739 } 11740} 11741 11742class BaseSource { 11743 // Template method to override 11744 async buildListItems(filter = "") { 11745 return Promise.resolve([]) 11746 } 11747 11748 // Template method to override 11749 promptItemFor(listItem) { 11750 return null 11751 } 11752 11753 // Protected 11754 11755 buildListItemElementFor(promptItemElement) { 11756 const template = promptItemElement.querySelector("template[type='menu']"); 11757 const fragment = template.content.cloneNode(true); 11758 const listItemElement = createElement("li", { role: "option", id: generateDomId("prompt-item"), tabindex: "0" }); 11759 listItemElement.classList.add("lexxy-prompt-menu__item"); 11760 listItemElement.appendChild(fragment); 11761 return listItemElement 11762 } 11763 11764 async loadPromptItemsFromUrl(url) { 11765 try { 11766 const response = await fetch(url); 11767 const html = await response.text(); 11768 const promptItems = parseHtml(html).querySelectorAll("lexxy-prompt-item"); 11769 return Promise.resolve(Array.from(promptItems)) 11770 } catch (error) { 11771 return Promise.reject(error) 11772 } 11773 } 11774} 11775
11776class LocalFilterSource extends BaseSource { 11777 async buildListItems(filter = "") { 11778 const promptItems = await this.fetchPromptItems(); 11779 return this.#buildListItemsFromPromptItems(promptItems, filter) 11780 } 11781 11782 // Template method to override 11783 async fetchPromptItems(filter) { 11784 return Promise.resolve([]) 11785 } 11786 11787 promptItemFor(listItem) { 11788 return this.promptItemByListItem.get(listItem) 11789 } 11790 11791 #buildListItemsFromPromptItems(promptItems, filter) { 11792 const listItems = []; 11793 this.promptItemByListItem = new WeakMap(); 11794 promptItems.forEach((promptItem) => { 11795 const searchableText = promptItem.getAttribute("search"); 11796 11797 if (!filter || filterMatches(searchableText, filter)) { 11798 const listItem = this.buildListItemElementFor(promptItem); 11799 this.promptItemByListItem.set(listItem, promptItem); 11800 listItems.push(listItem); 11801 } 11802 }); 11803 11804 return listItems 11805 } 11806} 11807 11808class InlinePromptSource extends LocalFilterSource { 11809 constructor(inlinePromptItems) { 11810 super(); 11811 this.inlinePromptItemElements = Array.from(inlinePromptItems); 11812 } 11813 11814 async fetchPromptItems() { 11815 return Promise.resolve(this.inlinePromptItemElements) 11816 } 11817} 11818 11819class DeferredPromptSource extends LocalFilterSource { 11820 constructor(url) { 11821 super(); 11822 this.url = url; 11823 11824 this.fetchPromptItems(); 11825 } 11826 11827 async fetchPromptItems() { 11828 this.promptItems ??= await this.loadPromptItemsFromUrl(this.url); 11829 11830 return Promise.resolve(this.promptItems) 11831 } 11832} 11833 11834const DEBOUNCE_INTERVAL = 200; 11835 11836class RemoteFilterSource extends BaseSource { 11837 constructor(url) { 11838 super(); 11839 11840 this.baseURL = url; 11841 this.loadAndFilterListItems = debounceAsync(this.fetchFilteredListItems.bind(this), DEBOUNCE_INTERVAL); 11842 } 11843 11844 async buildListItems(filter = "") { 11845 return await this.loadAndFilterListItems(filter) 11846 } 11847 11848 promptItemFor(listItem) { 11849 return this.promptItemByListItem.get(listItem) 11850 } 11851 11852 async fetchFilteredListItems(filter) { 11853 const promptItems = await this.loadPromptItemsFromUrl(this.#urlFor(filter)); 11854 return this.#buildListItemsFromPromptItems(promptItems) 11855 } 11856 11857 #urlFor(filter) { 11858 const url = new URL(this.baseURL, window.location.origin); 11859 url.searchParams.append("filter", filter); 11860 return url.toString() 11861 } 11862 11863 #buildListItemsFromPromptItems(promptItems) { 11864 const listItems = []; 11865 this.promptItemByListItem = new WeakMap(); 11866 11867 for (const promptItem of promptItems) { 11868 const listItem = this.buildListItemElementFor(promptItem); 11869 this.promptItemByListItem.set(listItem, promptItem); 11870 listItems.push(listItem); 11871 } 11872 11873 return listItems 11874 } 11875} 11876 11877const NOTHING_FOUND_DEFAULT_MESSAGE = "Nothing found"; 11878 11879class LexicalPromptElement extends HTMLElement { 11880 constructor() { 11881 super(); 11882 this.keyListeners = []; 11883 } 11884 11885 static observedAttributes = [ "connected" ] 11886 11887 connectedCallback() { 11888 this.source = this.#createSource(); 11889 11890 this.#addTriggerListener(); 11891 this.toggleAttribute("connected", true); 11892 } 11893 11894 disconnectedCallback() { 11895 this.source = null; 11896 this.popoverElement = null; 11897 } 11898 11899 11900 attributeChangedCallback(name, oldValue, newValue) { 11901 if (name === "connected" && this.isConnected && oldValue != null && oldValue !== newValue) { 11902 requestAnimationFrame(() => this.#reconnect()); 11903 } 11904 } 11905 11906 get name() { 11907 return this.getAttribute("name") 11908 } 11909 11910 get trigger() { 11911 return this.getAttribute("trigger") 11912 } 11913 11914 get supportsSpaceInSearches() { 11915 return this.hasAttribute("supports-space-in-searches") 11916 } 11917 11918 get open() { 11919 return this.popoverElement?.classList?.contains("lexxy-prompt-menu--visible") 11920 } 11921 11922 get closed() { 11923 return !this.open 11924 } 11925 11926 get #doesSpaceSelect() { 11927 return !this.supportsSpaceInSearches 11928 } 11929 11930 #createSource() { 11931 const src = this.getAttribute("src"); 11932 if (src) { 11933 if (this.hasAttribute("remote-filtering")) { 11934 return new RemoteFilterSource(src) 11935 } else { 11936 return new DeferredPromptSource(src) 11937 } 11938 } else { 11939 return new InlinePromptSource(this.querySelectorAll("lexxy-prompt-item")) 11940 } 11941 } 11942 11943 #addTriggerListener() { 11944 const unregister = this.#editor.registerUpdateListener(({ editorState }) => { 11945 editorState.read(() => { 11946 const { node, offset } = this.#selection.selectedNodeWithOffset(); 11947 if (!node) return 11948 11949 if (lr(node)) { 11950 const fullText = node.getTextContent(); 11951 const triggerLength = this.trigger.length; 11952 11953 // Check if we have enough characters for the trigger 11954 if (offset >= triggerLength) { 11955 const textBeforeCursor = fullText.slice(offset - triggerLength, offset); 11956 11957 // Check if trigger is at the start of the text node (new line case) or preceded by space or newline 11958 if (textBeforeCursor === this.trigger) { 11959 const isAtStart = offset === triggerLength; 11960 11961 const charBeforeTrigger = offset > triggerLength ? fullText[offset - triggerLength - 1] : null; 11962 const isPrecededBySpaceOrNewline = charBeforeTrigger === " " || charBeforeTrigger === "\n"; 11963 11964 if (isAtStart || isPrecededBySpaceOrNewline) { 11965 unregister(); 11966 this.#showPopover(); 11967 } 11968 } 11969 } 11970 } 11971 }); 11972 }); 11973 } 11974 11975 #addCursorPositionListener() { 11976 this.cursorPositionListener = this.#editor.registerUpdateListener(() => { 11977 if (this.closed) return 11978 11979 this.#editor.read(() => { 11980 const { node, offset } = this.#selection.selectedNodeWithOffset(); 11981 if (!node) return 11982 11983 if (lr(node) && offset > 0) { 11984 const fullText = node.getTextContent(); 11985 const textBeforeCursor = fullText.slice(0, offset); 11986 const lastTriggerIndex = textBeforeCursor.lastIndexOf(this.trigger); 11987 const triggerEndIndex = lastTriggerIndex + this.trigger.length - 1; 11988 11989 // If trigger is not found, or cursor is at or before the trigger end position, hide popover 11990 if (lastTriggerIndex === -1 || offset <= triggerEndIndex) { 11991 this.#hidePopover(); 11992 } 11993 } else { 11994 // Cursor is not in a text node or at offset 0, hide popover 11995 this.#hidePopover(); 11996 } 11997 }); 11998 }); 11999 } 12000 12001 #removeCursorPositionListener() { 12002 if (this.cursorPositionListener) { 12003 this.cursorPositionListener(); 12004 this.cursorPositionListener = null; 12005 } 12006 } 12007 12008 get #editor() { 12009 return this.#editorElement.editor 12010 } 12011 12012 get #editorElement() { 12013 return this.closest("lexxy-editor") 12014 } 12015 12016 get #selection() { 12017 return this.#editorElement.selection 12018 } 12019 12020 async #showPopover() { 12021 this.popoverElement ??= await this.#buildPopover(); 12022 this.#resetPopoverPosition(); 12023 await this.#filterOptions(); 12024 this.popoverElement.classList.toggle("lexxy-prompt-menu--visible", true); 12025 this.#selectFirstOption(); 12026 12027 this.#editorElement.addEventListener("keydown", this.#handleKeydownOnPopover); 12028 this.#editorElement.addEventListener("lexxy:change", this.#filterOptions); 12029 12030 this.#registerKeyListeners(); 12031 this.#addCursorPositionListener(); 12032 } 12033 12034 #registerKeyListeners() {
12035 // We can't use a regular keydown for Enter as Lexical handles it first 12036 this.keyListeners.push(this.#editor.registerCommand(Ne$2, this.#handleSelectedOption.bind(this), Wi)); 12037 this.keyListeners.push(this.#editor.registerCommand(Me$2, this.#handleSelectedOption.bind(this), Wi)); 12038 12039 if (this.#doesSpaceSelect) { 12040 this.keyListeners.push(this.#editor.registerCommand(be$1, this.#handleSelectedOption.bind(this), Wi)); 12041 } 12042 12043 // Register arrow keys with CRITICAL priority to prevent Lexical's selection handlers from running 12044 this.keyListeners.push(this.#editor.registerCommand(ke$2, this.#handleArrowUp.bind(this), Wi)); 12045 this.keyListeners.push(this.#editor.registerCommand(Te$2, this.#handleArrowDown.bind(this), Wi)); 12046 } 12047 12048 #handleArrowUp(event) { 12049 this.#moveSelectionUp(); 12050 event.preventDefault(); 12051 return true 12052 } 12053 12054 #handleArrowDown(event) { 12055 this.#moveSelectionDown(); 12056 event.preventDefault(); 12057 return true 12058 } 12059 12060 #selectFirstOption() { 12061 const firstOption = this.#listItemElements[0]; 12062 12063 if (firstOption) { 12064 this.#selectOption(firstOption); 12065 } 12066 } 12067 12068 get #listItemElements() { 12069 return Array.from(this.popoverElement.querySelectorAll(".lexxy-prompt-menu__item")) 12070 } 12071 12072 #selectOption(listItem) { 12073 this.#clearSelection(); 12074 listItem.toggleAttribute("aria-selected", true); 12075 listItem.scrollIntoView({ block: "nearest", behavior: "smooth" }); 12076 listItem.focus(); 12077 12078 // Preserve selection to prevent cursor jump 12079 this.#selection.preservingSelection(() => { 12080 this.#editorElement.focus(); 12081 }); 12082 12083 this.#editorContentElement.setAttribute("aria-controls", this.popoverElement.id); 12084 this.#editorContentElement.setAttribute("aria-activedescendant", listItem.id); 12085 this.#editorContentElement.setAttribute("aria-haspopup", "listbox"); 12086 } 12087 12088 #clearSelection() { 12089 this.#listItemElements.forEach((item) => { item.toggleAttribute("aria-selected", false); }); 12090 this.#editorContentElement.removeAttribute("aria-controls"); 12091 this.#editorContentElement.removeAttribute("aria-activedescendant"); 12092 this.#editorContentElement.removeAttribute("aria-haspopup"); 12093 } 12094 12095 #positionPopover() { 12096 const { x, y, fontSize } = this.#selection.cursorPosition; 12097 const editorRect = this.#editorElement.getBoundingClientRect(); 12098 const contentRect = this.#editorContentElement.getBoundingClientRect(); 12099 const verticalOffset = contentRect.top - editorRect.top; 12100 12101 if (!this.popoverElement.hasAttribute("data-anchored")) { 12102 this.popoverElement.style.left = `${x}px`; 12103 this.popoverElement.toggleAttribute("data-anchored", true); 12104 } 12105 12106 this.popoverElement.style.top = `${y + verticalOffset}px`; 12107 this.popoverElement.style.bottom = "auto"; 12108 12109 const popoverRect = this.popoverElement.getBoundingClientRect(); 12110 const isClippedAtBottom = popoverRect.bottom > window.innerHeight; 12111 12112 if (isClippedAtBottom || this.popoverElement.hasAttribute("data-clipped-at-bottom")) { 12113 this.popoverElement.style.top = `${y + verticalOffset - popoverRect.height - fontSize}px`; 12114 this.popoverElement.style.bottom = "auto"; 12115 this.popoverElement.toggleAttribute("data-clipped-at-bottom", true); 12116 } 12117 } 12118 12119 #resetPopoverPosition() { 12120 this.popoverElement.removeAttribute("data-clipped-at-bottom"); 12121 this.popoverElement.removeAttribute("data-anchored"); 12122 } 12123 12124 async #hidePopover() { 12125 this.#clearSelection(); 12126 this.popoverElement.classList.toggle("lexxy-prompt-menu--visible", false); 12127 this.#editorElement.removeEventListener("lexxy:change", this.#filterOptions); 12128 this.#editorElement.removeEventListener("keydown", this.#handleKeydownOnPopover); 12129 12130 this.#unregisterKeyListeners(); 12131 this.#removeCursorPositionListener(); 12132 12133 await nextFrame(); 12134 this.#addTriggerListener(); 12135 } 12136 12137 #unregisterKeyListeners() { 12138 this.keyListeners.forEach((unregister) => unregister()); 12139 this.keyListeners = []; 12140 } 12141 12142 #filterOptions = async () => { 12143 if (this.initialPrompt) { 12144 this.initialPrompt = false; 12145 return 12146 } 12147 12148 if (this.#editorContents.containsTextBackUntil(this.trigger)) { 12149 await this.#showFilteredOptions(); 12150 await nextFrame(); 12151 this.#positionPopover(); 12152 } else { 12153 this.#hidePopover(); 12154 } 12155 } 12156 12157 async #showFilteredOptions() { 12158 const filter = this.#editorContents.textBackUntil(this.trigger); 12159 const filteredListItems = await this.source.buildListItems(filter); 12160 this.popoverElement.innerHTML = ""; 12161 12162 if (filteredListItems.length > 0) { 12163 this.#showResults(filteredListItems); 12164 } else { 12165 this.#showEmptyResults(); 12166 } 12167 this.#selectFirstOption(); 12168 } 12169 12170 #showResults(filteredListItems) { 12171 this.popoverElement.classList.remove("lexxy-prompt-menu--empty"); 12172 this.popoverElement.append(...filteredListItems); 12173 } 12174 12175 #showEmptyResults() { 12176 this.popoverElement.classList.add("lexxy-prompt-menu--empty"); 12177 const el = createElement("li", { innerHTML: this.#emptyResultsMessage }); 12178 el.classList.add("lexxy-prompt-menu__item--empty"); 12179 this.popoverElement.append(el); 12180 } 12181 12182 get #emptyResultsMessage() { 12183 return this.getAttribute("empty-results") || NOTHING_FOUND_DEFAULT_MESSAGE 12184 } 12185 12186 #handleKeydownOnPopover = (event) => { 12187 if (event.key === "Escape") { 12188 this.#hidePopover(); 12189 this.#editorElement.focus(); 12190 event.stopPropagation(); 12191 } 12192 // Arrow keys are now handled via Lexical commands with HIGH priority 12193 } 12194 12195 #moveSelectionDown() { 12196 const nextIndex = this.#selectedIndex + 1; 12197 if (nextIndex < this.#listItemElements.length) this.#selectOption(this.#listItemElements[nextIndex]); 12198 } 12199 12200 #moveSelectionUp() { 12201 const previousIndex = this.#selectedIndex - 1; 12202 if (previousIndex >= 0) this.#selectOption(this.#listItemElements[previousIndex]); 12203 } 12204 12205 get #selectedIndex() { 12206 return this.#listItemElements.findIndex((item) => item.hasAttribute("aria-selected")) 12207 } 12208 12209 get #selectedListItem() { 12210 return this.#listItemElements[this.#selectedIndex] 12211 } 12212 12213 #handleSelectedOption(event) { 12214 event.preventDefault(); 12215 event.stopPropagation(); 12216 this.#optionWasSelected(); 12217 return true 12218 } 12219 12220 #optionWasSelected() { 12221 this.#replaceTriggerWithSelectedItem(); 12222 this.#hidePopover(); 12223 this.#editorElement.focus(); 12224 } 12225 12226 #replaceTriggerWithSelectedItem() { 12227 const promptItem = this.source.promptItemFor(this.#selectedListItem); 12228 12229 if (!promptItem) { return } 12230 12231 const templates = Array.from(promptItem.querySelectorAll("template[type='editor']")); 12232 const stringToReplace = `${this.trigger}${this.#editorContents.textBackUntil(this.trigger)}`; 12233 12234 if (this.hasAttribute("insert-editable-text")) { 12235 this.#insertTemplatesAsEditableText(templates, stringToReplace); 12236 } else { 12237 this.#insertTemplatesAsAttachments(templates, stringToReplace, promptItem.getAttribute("sgid")); 12238 } 12239 } 12240 12241 #insertTemplatesAsEditableText(templates, stringToReplace) { 12242 this.#editor.update(() => { 12243 const nodes = templates.flatMap(template => this.#buildEditableTextNodes(template)); 12244 this.#editorContents.replaceTextBackUntil(stringToReplace, nodes); 12245 }); 12246 } 12247 12248 #buildEditableTextNodes(template) { 12249 return m$1(this.#editor, parseHtml(`${template.innerHTML}`)) 12250 } 12251 12252 #insertTemplatesAsAttachments(templates, stringToReplace, fallbackSgid = null) { 12253 this.#editor.update(() => { 12254 const attachmentNodes = this.#buildAttachmentNodes(templates, fallbackSgid); 12255 const spacedAttachmentNodes = attachmentNodes.flatMap(node => [ node, this.#getSpacerTextNode() ]).slice(0, -1); 12256 this.#editorContents.replaceTextBackUntil(stringToReplace, spacedAttachmentNodes); 12257 }); 12258 } 12259 12260 #buildAttachmentNodes(templates, fallbackSgid = null) { 12261 return templates.map( 12262 template => this.#buildAttachmentNode( 12263 template.innerHTML, 12264 template.getAttribute("content-type") || this.#defaultPromptContentType, 12265 template.getAttribute("sgid") || fallbackSgid 12266 )) 12267 } 12268 12269 #getSpacerTextNode() { 12270 return sr(" ") 12271 } 12272 12273 get #defaultPromptContentType() { 12274 const attachmentContentTypeNamespace = Lexxy.global.get("attachmentContentTypeNamespace"); 12275 return `application/vnd.${attachmentContentTypeNamespace}.${this.name}` 12276 } 12277 12278 #buildAttachmentNode(innerHtml, contentType, sgid) { 12279 return new CustomActionTextAttachmentNode({ sgid, contentType, innerHtml }) 12280 } 12281 12282 get #editorContents() { 12283 return this.#editorElement.contents 12284 } 12285 12286 get #editorContentElement() { 12287 return this.#editorElement.editorContentElement 12288 } 12289 12290 async #buildPopover() { 12291 const popoverContainer = createElement("ul", { role: "listbox", id: generateDomId("prompt-popover") }); // Avoiding [popover] due to not being able to position at an arbitrary X, Y position. 12292 popoverContainer.classList.add("lexxy-prompt-menu"); 12293 popoverContainer.style.position = "absolute"; 12294 popoverContainer.setAttribute("nonce", getNonce()); 12295 popoverContainer.append(...await this.source.buildListItems()); 12296 popoverContainer.addEventListener("click", this.#handlePopoverClick);
12297 this.#editorElement.appendChild(popoverContainer); 12298 return popoverContainer 12299 } 12300 12301 #handlePopoverClick = (event) => { 12302 const listItem = event.target.closest(".lexxy-prompt-menu__item"); 12303 if (listItem) { 12304 this.#selectOption(listItem); 12305 this.#optionWasSelected(); 12306 } 12307 } 12308 12309 #reconnect() { 12310 this.disconnectedCallback(); 12311 this.connectedCallback(); 12312 } 12313} 12314 12315class CodeLanguagePicker extends HTMLElement { 12316 connectedCallback() { 12317 this.editorElement = this.closest("lexxy-editor"); 12318 this.editor = this.editorElement.editor; 12319 this.classList.add("lexxy-floating-controls"); 12320 12321 this.#attachLanguagePicker(); 12322 this.#hide(); 12323 this.#monitorForCodeBlockSelection(); 12324 } 12325 12326 disconnectedCallback() { 12327 this.unregisterUpdateListener?.(); 12328 this.unregisterUpdateListener = null; 12329 } 12330 12331 #attachLanguagePicker() { 12332 this.languagePickerElement = this.#createLanguagePicker(); 12333 12334 this.languagePickerElement.addEventListener("change", () => { 12335 this.#updateCodeBlockLanguage(this.languagePickerElement.value); 12336 }); 12337 12338 this.languagePickerElement.setAttribute("nonce", getNonce()); 12339 this.appendChild(this.languagePickerElement); 12340 } 12341 12342 #createLanguagePicker() { 12343 const selectElement = createElement("select", { className: "lexxy-code-language-picker", "aria-label": "Pick a languageâ¦", name: "lexxy-code-language" }); 12344 12345 for (const [ value, label ] of Object.entries(this.#languages)) { 12346 const option = document.createElement("option"); 12347 option.value = value; 12348 option.textContent = label; 12349 selectElement.appendChild(option); 12350 } 12351 12352 return selectElement 12353 } 12354 12355 get #languages() { 12356 const languages = { ...pt$1 }; 12357 12358 if (!languages.ruby) languages.ruby = "Ruby"; 12359 if (!languages.php) languages.php = "PHP"; 12360 if (!languages.go) languages.go = "Go"; 12361 if (!languages.bash) languages.bash = "Bash"; 12362 if (!languages.json) languages.json = "JSON"; 12363 if (!languages.diff) languages.diff = "Diff"; 12364 12365 const sortedEntries = Object.entries(languages) 12366 .sort(([ , a ], [ , b ]) => a.localeCompare(b)); 12367 12368 // Place the "plain" entry first, then the rest of language sorted alphabetically 12369 const plainIndex = sortedEntries.findIndex(([ key ]) => key === "plain"); 12370 const plainEntry = sortedEntries.splice(plainIndex, 1)[0]; 12371 return Object.fromEntries([ plainEntry, ...sortedEntries ]) 12372 } 12373 12374 #updateCodeBlockLanguage(language) { 12375 this.editor.update(() => { 12376 const codeNode = this.#getCurrentCodeNode(); 12377 12378 if (codeNode) { 12379 codeNode.setLanguage(language); 12380 } 12381 }); 12382 } 12383 12384 #monitorForCodeBlockSelection() { 12385 this.unregisterUpdateListener = this.editor.registerUpdateListener(() => { 12386 this.editor.getEditorState().read(() => { 12387 const codeNode = this.#getCurrentCodeNode(); 12388 12389 if (codeNode) { 12390 this.#codeNodeWasSelected(codeNode); 12391 } else { 12392 this.#hide(); 12393 } 12394 }); 12395 }); 12396 } 12397 12398 #getCurrentCodeNode() { 12399 const selection = Lr(); 12400 12401 if (!yr(selection)) { 12402 return null 12403 } 12404 12405 const anchorNode = selection.anchor.getNode(); 12406 const parentNode = anchorNode.getParent(); 12407 12408 if (X$1(anchorNode)) { 12409 return anchorNode 12410 } else if (X$1(parentNode)) { 12411 return parentNode 12412 } 12413 12414 return null 12415 } 12416 12417 #codeNodeWasSelected(codeNode) { 12418 const language = codeNode.getLanguage(); 12419 12420 this.#updateLanguagePickerWith(language); 12421 this.#show(); 12422 this.#positionLanguagePicker(codeNode); 12423 } 12424 12425 #updateLanguagePickerWith(language) { 12426 if (this.languagePickerElement && language) { 12427 const normalizedLanguage = dt$1(language); 12428 this.languagePickerElement.value = normalizedLanguage; 12429 } 12430 } 12431 12432 #positionLanguagePicker(codeNode) { 12433 const codeElement = this.editor.getElementByKey(codeNode.getKey()); 12434 if (!codeElement) return 12435 12436 const codeRect = codeElement.getBoundingClientRect(); 12437 const editorRect = this.editorElement.getBoundingClientRect(); 12438 const relativeTop = codeRect.top - editorRect.top; 12439 const relativeRight = editorRect.right - codeRect.right; 12440 12441 this.style.top = `${relativeTop}px`; 12442 this.style.right = `${relativeRight}px`; 12443 } 12444 12445 #show() { 12446 this.hidden = false;
12447 } 12448 12449 #hide() { 12450 this.hidden = true; 12451 } 12452} 12453 12454const DELETE_ICON = `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12455 <path d="M11.2041 1.01074C12.2128 1.113 13 1.96435 13 3V4H15L15.1025 4.00488C15.6067 4.05621 16 4.48232 16 5C16 5.55228 15.5523 6 15 6H14.8457L14.1416 15.1533C14.0614 16.1953 13.1925 17 12.1475 17H5.85254L5.6582 16.9902C4.76514 16.9041 4.03607 16.2296 3.88184 15.3457L3.8584 15.1533L3.1543 6H3C2.44772 6 2 5.55228 2 5C2 4.44772 2.44772 4 3 4H5V3C5 1.89543 5.89543 1 7 1H11L11.2041 1.01074ZM5.85254 15H12.1475L12.8398 6H5.16016L5.85254 15ZM7 4H11V3H7V4Z"/> 12456</svg>`; 12457 12458class NodeDeleteButton extends HTMLElement { 12459 connectedCallback() { 12460 this.editorElement = this.closest("lexxy-editor"); 12461 this.editor = this.editorElement.editor; 12462 this.classList.add("lexxy-floating-controls"); 12463 12464 if (!this.deleteButton) { 12465 this.#attachDeleteButton(); 12466 } 12467 } 12468 12469 disconnectedCallback() { 12470 if (this.deleteButton && this.handleDeleteClick) { 12471 this.deleteButton.removeEventListener("click", this.handleDeleteClick); 12472 } 12473 12474 this.handleDeleteClick = null; 12475 this.deleteButton = null; 12476 this.editor = null; 12477 this.editorElement = null; 12478 } 12479 #attachDeleteButton() { 12480 const container = createElement("div", { className: "lexxy-floating-controls__group" }); 12481 12482 this.deleteButton = createElement("button", { 12483 className: "lexxy-node-delete", 12484 type: "button", 12485 "aria-label": "Remove" 12486 }); 12487 this.deleteButton.tabIndex = -1; 12488 this.deleteButton.innerHTML = DELETE_ICON; 12489 12490 this.handleDeleteClick = () => this.#deleteNode(); 12491 this.deleteButton.addEventListener("click", this.handleDeleteClick); 12492 container.appendChild(this.deleteButton); 12493 12494 this.appendChild(container); 12495 } 12496 12497 #deleteNode() { 12498 this.editor.update(() => { 12499 const node = vo(this); 12500 node?.remove(); 12501 }); 12502 } 12503} 12504 12505class TableController { 12506 constructor(editorElement) { 12507 this.editor = editorElement.editor; 12508 this.contents = editorElement.contents; 12509 this.selection = editorElement.selection; 12510 12511 this.currentTableNodeKey = null; 12512 this.currentCellKey = null; 12513 12514 this.#registerKeyHandlers(); 12515 } 12516 12517 destroy() { 12518 this.currentTableNodeKey = null; 12519 this.currentCellKey = null; 12520 12521 this.#unregisterKeyHandlers(); 12522 } 12523 12524 get currentCell() { 12525 if (!this.currentCellKey) return null 12526 12527 return this.editor.getEditorState().read(() => { 12528 const cell = xo(this.currentCellKey); 12529 return (cell instanceof xe) ? cell : null 12530 }) 12531 } 12532 12533 get currentTableNode() { 12534 if (!this.currentTableNodeKey) return null 12535 12536 return this.editor.getEditorState().read(() => { 12537 const tableNode = xo(this.currentTableNodeKey); 12538 return (tableNode instanceof hn) ? tableNode : null 12539 }) 12540 } 12541 12542 get currentRowCells() { 12543 const currentRowIndex = this.currentRowIndex; 12544 12545 const rows = this.tableRows; 12546 if (!rows) return null 12547 12548 return this.editor.getEditorState().read(() => { 12549 return rows[currentRowIndex]?.getChildren() ?? null 12550 }) ?? null 12551 } 12552 12553 get currentRowIndex() { 12554 const currentCell = this.currentCell; 12555 if (!currentCell) return 0 12556 12557 return this.editor.getEditorState().read(() => { 12558 return Ie$1(currentCell) 12559 }) ?? 0 12560 } 12561 12562 get currentColumnCells() { 12563 const columnIndex = this.currentColumnIndex; 12564 12565 const rows = this.tableRows; 12566 if (!rows) return null 12567 12568 return this.editor.getEditorState().read(() => { 12569 return rows.map(row => row.getChildAtIndex(columnIndex)) 12570 }) ?? null 12571 } 12572 12573 get currentColumnIndex() { 12574 const currentCell = this.currentCell; 12575 if (!currentCell) return 0 12576 12577 return this.editor.getEditorState().read(() => { 12578 return Ue$1(currentCell) 12579 }) ?? 0 12580 } 12581 12582 get tableRows() { 12583 return this.editor.getEditorState().read(() => { 12584 return this.currentTableNode?.getChildren() 12585 }) ?? null 12586 } 12587 12588 updateSelectedTable() {
12589 let cellNode = null; 12590 let tableNode = null; 12591 12592 this.editor.getEditorState().read(() => { 12593 const selection = Lr(); 12594 if (!selection || !this.selection.isTableCellSelected) return 12595 12596 const node = selection.getNodes()[0]; 12597 12598 cellNode = Gt(node); 12599 tableNode = Qt(node); 12600 }); 12601 12602 this.currentCellKey = cellNode?.getKey() ?? null; 12603 this.currentTableNodeKey = tableNode?.getKey() ?? null; 12604 } 12605 12606 executeTableCommand(command, customIndex = null) { 12607 if (command.action === "delete" && command.childType === "table") { 12608 this.#deleteTable(); 12609 return 12610 } 12611 12612 if (command.action === "toggle") { 12613 this.#executeToggleStyle(command); 12614 return 12615 } 12616 12617 this.#executeCommand(command, customIndex); 12618 } 12619 12620 #executeCommand(command, customIndex = null) { 12621 this.#selectCellAtSelection(); 12622 this.editor.dispatchCommand(this.#commandName(command)); 12623 this.#selectNextBestCell(command, customIndex); 12624 } 12625 12626 #executeToggleStyle(command) { 12627 const childType = command.childType; 12628 12629 let cells = null; 12630 let headerState = null; 12631 12632 if (childType === "row") { 12633 cells = this.currentRowCells; 12634 headerState = ve$1.ROW; 12635 } else if (childType === "column") { 12636 cells = this.currentColumnCells; 12637 headerState = ve$1.COLUMN; 12638 } 12639 12640 if (!cells || cells.length === 0) return 12641 12642 this.editor.update(() => { 12643 const firstCell = Be$1(cells[0]); 12644 if (!firstCell) return 12645 12646 const currentStyle = firstCell.getHeaderStyles(); 12647 const newStyle = currentStyle ^ headerState; 12648 12649 cells.forEach(cell => { 12650 this.#setHeaderStyle(cell, newStyle, headerState); 12651 }); 12652 }); 12653 } 12654 12655 #deleteTable() { 12656 this.#selectCellAtSelection(); 12657 this.editor.dispatchCommand("deleteTable"); 12658 } 12659 12660 #selectCellAtSelection() { 12661 this.editor.update(() => { 12662 const selection = Lr(); 12663 if (!selection) return 12664 12665 const node = selection.getNodes()[0]; 12666 12667 Gt(node)?.selectEnd(); 12668 }); 12669 } 12670 12671 #commandName(command) { 12672 const { action, childType, direction } = command; 12673 12674 const childTypeSuffix = upcaseFirst(childType); 12675 const directionSuffix = action == "insert" ? upcaseFirst(direction) : ""; 12676 return `${action}Table${childTypeSuffix}${directionSuffix}` 12677 } 12678 12679 #setHeaderStyle(cell, newStyle, headerState) { 12680 const tableCellNode = Be$1(cell); 12681 tableCellNode?.setHeaderStyles(newStyle, headerState); 12682 } 12683 12684 async #selectCellAtIndex(rowIndex, columnIndex) { 12685 // We wait for next frame, otherwise table operations might not have completed yet. 12686 await nextFrame(); 12687 12688 if (!this.currentTableNode) return 12689 12690 const rows = this.tableRows; 12691 if (!rows) return 12692 12693 const row = rows[rowIndex]; 12694 if (!row) return 12695 12696 this.editor.update(() => { 12697 const cell = Be$1(row.getChildAtIndex(columnIndex)); 12698 cell?.selectEnd(); 12699 }); 12700 } 12701 12702 #selectNextBestCell(command, customIndex = null) { 12703 const { childType, direction } = command; 12704 12705 let rowIndex = this.currentRowIndex; 12706 let columnIndex = customIndex !== null ? customIndex : this.currentColumnIndex; 12707 12708 const deleteOffset = command.action === "delete" ? -1 : 0; 12709 const offset = direction === "after" ? 1 : deleteOffset; 12710 12711 if (childType === "row") { 12712 rowIndex += offset; 12713 } else if (childType === "column") { 12714 columnIndex += offset; 12715 } 12716 12717 this.#selectCellAtIndex(rowIndex, columnIndex); 12718 } 12719 12720 #selectNextRow() { 12721 const rows = this.tableRows; 12722 if (!rows) return 12723 12724 const nextRow = rows.at(this.currentRowIndex + 1); 12725 if (!nextRow) return 12726 12727 this.editor.update(() => { 12728 nextRow.getChildAtIndex(this.currentColumnIndex)?.selectEnd(); 12729 }); 12730 } 12731 12732 #selectPreviousCell() { 12733 const cell = this.currentCell; 12734 if (!cell) return 12735 12736 this.editor.update(() => { 12737 cell.selectPrevious(); 12738 }); 12739 } 12740 12741 #insertRowAndSelectFirstCell() { 12742 this.executeTableCommand({ action: "insert", childType: "row", direction: "after" }, 0); 12743 } 12744 12745 #deleteRowAndSelectLastCell() { 12746 this.executeTableCommand({ action: "delete", childType: "row" }, -1); 12747 } 12748 12749 #deleteRowAndSelectNextNode() { 12750 const tableNode = this.currentTableNode; 12751 this.executeTableCommand({ action: "delete", childType: "row" }); 12752 12753 this.editor.update(() => { 12754 const next = tableNode?.getNextSibling(); 12755 if (Ii(next)) { 12756 next.selectStart(); 12757 } else { 12758 const newParagraph = Li(); 12759 this.currentTableNode.insertAfter(newParagraph); 12760 newParagraph.selectStart(); 12761 } 12762 }); 12763 } 12764 12765 #isCurrentCellEmpty() { 12766 if (!this.currentTableNode) return false 12767 12768 const cell = this.currentCell; 12769 if (!cell) return false 12770 12771 return cell.getTextContent().trim() === "" 12772 } 12773 12774 #isCurrentRowLast() { 12775 if (!this.currentTableNode) return false 12776 12777 const rows = this.tableRows; 12778 if (!rows) return false 12779 12780 return rows.length === this.currentRowIndex + 1 12781 } 12782 12783 #isCurrentRowEmpty() { 12784 if (!this.currentTableNode) return false 12785 12786 const cells = this.currentRowCells; 12787 if (!cells) return false 12788 12789 return cells.every(cell => cell.getTextContent().trim() === "") 12790 } 12791 12792 #isFirstCellInRow() { 12793 if (!this.currentTableNode) return false 12794 12795 const cells = this.currentRowCells; 12796 if (!cells) return false 12797 12798 return cells.indexOf(this.currentCell) === 0 12799 } 12800 12801 #registerKeyHandlers() {
12802 // We can't prevent these externally using regular keydown because Lexical handles it first. 12803 this.unregisterBackspaceKeyHandler = this.editor.registerCommand(we$1, (event) => this.#handleBackspaceKey(event), Bi); 12804 this.unregisterEnterKeyHandler = this.editor.registerCommand(Ne$2, (event) => this.#handleEnterKey(event), Bi); 12805 } 12806 12807 #unregisterKeyHandlers() { 12808 this.unregisterBackspaceKeyHandler?.(); 12809 this.unregisterEnterKeyHandler?.(); 12810 12811 this.unregisterBackspaceKeyHandler = null; 12812 this.unregisterEnterKeyHandler = null; 12813 } 12814 12815 #handleBackspaceKey(event) { 12816 if (!this.currentTableNode) return false 12817 12818 if (this.#isCurrentRowEmpty() && this.#isFirstCellInRow()) { 12819 event.preventDefault(); 12820 this.#deleteRowAndSelectLastCell(); 12821 return true 12822 } 12823 12824 if (this.#isCurrentCellEmpty() && !this.#isFirstCellInRow()) { 12825 event.preventDefault(); 12826 this.#selectPreviousCell(); 12827 return true 12828 } 12829 12830 return false 12831 } 12832 12833 #handleEnterKey(event) { 12834 if ((event.ctrlKey || event.metaKey) || event.shiftKey || !this.currentTableNode) return false 12835 12836 if (this.selection.isInsideList || this.selection.isInsideCodeBlock) return false 12837 12838 event.preventDefault(); 12839 12840 if (this.#isCurrentRowLast() && this.#isCurrentRowEmpty()) { 12841 this.#deleteRowAndSelectNextNode(); 12842 } else if (this.#isCurrentRowLast()) { 12843 this.#insertRowAndSelectFirstCell(); 12844 } else { 12845 this.#selectNextRow(); 12846 } 12847 12848 return true 12849 } 12850} 12851 12852var TableIcons = { 12853 "insert-row-before": 12854 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12855 <path fill-rule="evenodd" clip-rule="evenodd" d="M7.86804e-07 15C8.29055e-07 15.8284 0.671574 16.5 1.5 16.5H15L15.1533 16.4922C15.8593 16.4205 16.4205 15.8593 16.4922 15.1533L16.5 15V4.5L16.4922 4.34668C16.4154 3.59028 15.7767 3 15 3H13.5L13.5 4.5H15V9H1.5L1.5 4.5L3 4.5V3H1.5C0.671574 3 1.20956e-06 3.67157 1.24577e-06 4.5L7.86804e-07 15ZM15 10.5V15H1.5L1.5 10.5H15Z"/> 12856 <path d="M4.5 4.5H7.5V7.5H9V4.5H12L12 3L9 3V6.55671e-08L7.5 0V3L4.5 3V4.5Z"/> 12857 </svg>`, 12858 12859 "insert-row-after": 12860 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12861 <path fill-rule="evenodd" clip-rule="evenodd" d="M7.86804e-07 13.5C7.50592e-07 14.3284 0.671574 15 1.5 15H3V13.5H1.5L1.5 9L15 9V13.5H13.5V15H15C15.7767 15 16.4154 14.4097 16.4922 13.6533L16.5 13.5V3L16.4922 2.84668C16.4205 2.14069 15.8593 1.57949 15.1533 1.50781L15 1.5L1.5 1.5C0.671574 1.5 1.28803e-06 2.17157 1.24577e-06 3L7.86804e-07 13.5ZM15 3V7.5L1.5 7.5L1.5 3L15 3Z"/> 12862 <path d="M7.5 15V18H9V15H12V13.5H9V10.5H7.5V13.5H4.5V15H7.5Z"/> 12863 </svg>`, 12864 12865 "delete-row": 12866 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12867 <path d="M16.4922 12.1533C16.4154 12.9097 15.7767 13.5 15 13.5L12 13.5V12H15V6L1.5 6L1.5 12H4.5V13.5H1.5C0.723337 13.5 0.0846104 12.9097 0.00781328 12.1533L7.86804e-07 12L1.04907e-06 6C1.17362e-06 5.22334 0.590278 4.58461 1.34668 4.50781L1.5 4.5L15 4.5C15.8284 4.5 16.5 5.17157 16.5 6V12L16.4922 12.1533Z"/> 12868 <path d="M10.3711 15.9316L8.25 13.8096L6.12793 15.9316L5.06738 14.8711L7.18945 12.75L5.06738 10.6289L6.12793 9.56836L8.25 11.6895L10.3711 9.56836L11.4316 10.6289L9.31055 12.75L11.4316 14.8711L10.3711 15.9316Z"/> 12869 </svg>`, 12870 12871 "toggle-row": 12872 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12873 <path fill-rule="evenodd" clip-rule="evenodd" d="M0.00781328 13.6533C0.0846108 14.4097 0.723337 15 1.5 15L15 15L15.1533 14.9922C15.8593 14.9205 16.4205 14.3593 16.4922 13.6533L16.5 13.5V4.5L16.4922 4.34668C16.4205 3.64069 15.8593 3.07949 15.1533 3.00781L15 3L1.5 3C0.671574 3 1.24863e-06 3.67157 1.18021e-06 4.5L7.86804e-07 13.5L0.00781328 13.6533ZM15 9V13.5L1.5 13.5L1.5 9L15 9Z"/> 12874 </svg>`, 12875 12876 "insert-column-before": 12877 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12878 <path fill-rule="evenodd" clip-rule="evenodd" d="M4.5 0C3.67157 0 3 0.671573 3 1.5V3H4.5V1.5H9V15H4.5V13.5H3V15C3 15.7767 3.59028 16.4154 4.34668 16.4922L4.5 16.5H15L15.1533 16.4922C15.8593 16.4205 16.4205 15.8593 16.4922 15.1533L16.5 15V1.5C16.5 0.671573 15.8284 6.03989e-09 15 0H4.5ZM15 15H10.5V1.5H15V15Z"/> 12879 <path d="M3 7.5H0V9H3V12H4.5V9H7.5V7.5H4.5V4.5H3V7.5Z"/> 12880 </svg>`, 12881 12882 "insert-column-after": 12883 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12884 <path fill-rule="evenodd" clip-rule="evenodd" d="M13.5 0C14.3284 0 15 0.671573 15 1.5V3H13.5V1.5H9V15H13.5V13.5H15V15C15 15.7767 14.4097 16.4154 13.6533 16.4922L13.5 16.5H3L2.84668 16.4922C2.14069 16.4205 1.57949 15.8593 1.50781 15.1533L1.5 15V1.5C1.5 0.671573 2.17157 6.03989e-09 3 0H13.5ZM3
1288415H7.5V1.5H3V15Z"/> 12885 <path d="M15 7.5H18V9H15V12H13.5V9H10.5V7.5H13.5V4.5H15V7.5Z"/> 12886 </svg>`, 12887 12888 "delete-column": 12889 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12890 <path d="M12.1533 0.0078125C12.9097 0.0846097 13.5 0.723336 13.5 1.5V4.5H12V1.5H6V15H12V12H13.5V15C13.5 15.7767 12.9097 16.4154 12.1533 16.4922L12 16.5H6C5.22334 16.5 4.58461 15.9097 4.50781 15.1533L4.5 15V1.5C4.5 0.671573 5.17157 2.41596e-08 6 0H12L12.1533 0.0078125Z"/> 12891 <path d="M15.9316 6.12891L13.8105 8.24902L15.9326 10.3711L14.8711 11.4316L12.75 9.31055L10.6289 11.4316L9.56738 10.3711L11.6885 8.24902L9.56836 6.12891L10.6289 5.06836L12.75 7.18848L14.8711 5.06836L15.9316 6.12891Z"/> 12892 </svg>`, 12893 12894 "toggle-column": 12895 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12896 <path fill-rule="evenodd" clip-rule="evenodd" d="M13.6533 17.9922C14.4097 17.9154 15 17.2767 15 16.5L15 3L14.9922 2.84668C14.9205 2.14069 14.3593 1.57949 13.6533 1.50781L13.5 1.5L4.5 1.5L4.34668 1.50781C3.59028 1.58461 3 2.22334 3 3L3 16.5C3 17.2767 3.59028 17.9154 4.34668 17.9922L4.5 18L13.5 18L13.6533 17.9922ZM9 3L13.5 3L13.5 16.5L9 16.5L9 3Z"/> 12897 </svg>`, 12898 12899 "delete-table": 12900 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12901 <path d="M11.2041 1.01074C12.2128 1.113 13 1.96435 13 3V4H15L15.1025 4.00488C15.6067 4.05621 16 4.48232 16 5C16 5.55228 15.5523 6 15 6H14.8457L14.1416 15.1533C14.0614 16.1953 13.1925 17 12.1475 17H5.85254L5.6582 16.9902C4.76514 16.9041 4.03607 16.2296 3.88184 15.3457L3.8584 15.1533L3.1543 6H3C2.44772 6 2 5.55228 2 5C2 4.44772 2.44772 4 3 4H5V3C5 1.89543 5.89543 1 7 1H11L11.2041 1.01074ZM5.85254 15H12.1475L12.8398 6H5.16016L5.85254 15ZM7 4H11V3H7V4Z"/> 12902 </svg>` 12903}; 12904 12905class TableTools extends HTMLElement { 12906 connectedCallback() { 12907 this.tableController = new TableController(this.#editorElement); 12908 this.classList.add("lexxy-floating-controls"); 12909 12910 this.#setUpButtons(); 12911 this.#hide(); 12912 this.#monitorForTableSelection(); 12913 this.#registerKeyboardShortcuts(); 12914 } 12915 12916 disconnectedCallback() { 12917 this.#unregisterKeyboardShortcuts(); 12918 12919 this.unregisterUpdateListener?.(); 12920 this.unregisterUpdateListener = null; 12921 12922 this.removeEventListener("keydown", this.#handleToolsKeydown); 12923 12924 this.tableController?.destroy(); 12925 this.tableController = null; 12926 } 12927 12928 get #editor() { 12929 return this.#editorElement.editor 12930 } 12931 12932 get #editorElement() { 12933 return this.closest("lexxy-editor") 12934 } 12935 12936 get #tableToolsButtons() { 12937 return Array.from(this.querySelectorAll("button, details > summary")) 12938 } 12939 12940 #setUpButtons() { 12941 this.appendChild(this.#createRowButtonsContainer()); 12942 this.appendChild(this.#createColumnButtonsContainer()); 12943 12944 this.appendChild(this.#createDeleteTableButton()); 12945 this.addEventListener("keydown", this.#handleToolsKeydown); 12946 } 12947 12948 #createButtonsContainer(childType, setCountProperty, moreMenu) { 12949 const container = createElement("div", { className: `lexxy-floating-controls__group lexxy-table-control lexxy-table-control--${childType}` }); 12950 12951 const plusButton = this.#createButton(`Add ${childType}`, { action: "insert", childType, direction: "after" }, "+"); 12952 const minusButton = this.#createButton(`Remove ${childType}`, { action: "delete", childType }, "â"); 12953 12954 const dropdown = createElement("details", { className: "lexxy-table-control__more-menu" }); 12955 dropdown.setAttribute("name", "lexxy-dropdown"); 12956 dropdown.tabIndex = -1; 12957 12958 const count = createElement("summary", {}, `_ ${childType}s`); 12959 setCountProperty(count); 12960 dropdown.appendChild(count); 12961 12962 dropdown.appendChild(moreMenu); 12963 12964 container.appendChild(minusButton); 12965 container.appendChild(dropdown); 12966 container.appendChild(plusButton); 12967 12968 return container 12969 } 12970 12971 #createRowButtonsContainer() { 12972 return this.#createButtonsContainer( 12973 "row", 12974 (count) => { this.rowCount = count; }, 12975 this.#createMoreMenuSection("row") 12976 ) 12977 } 12978 12979 #createColumnButtonsContainer() { 12980 return this.#createButtonsContainer( 12981 "column", 12982 (count) => { this.columnCount = count; }, 12983 this.#createMoreMenuSection("column") 12984 ) 12985 } 12986 12987 #createMoreMenuSection(childType) { 12988 const section = createElement("div", { className: "lexxy-floating-control
12988s__group lexxy-table-control__more-menu-details" }); 12989 const addBeforeButton = this.#createButton(`Add ${childType} before`, { action: "insert", childType, direction: "before" }); 12990 const addAfterButton = this.#createButton(`Add ${childType} after`, { action: "insert", childType, direction: "after" }); 12991 const toggleStyleButton = this.#createButton(`Toggle ${childType} style`, { action: "toggle", childType }); 12992 const deleteButton = this.#createButton(`Remove ${childType}`, { action: "delete", childType }); 12993 12994 section.appendChild(addBeforeButton); 12995 section.appendChild(addAfterButton); 12996 section.appendChild(toggleStyleButton); 12997 section.appendChild(deleteButton); 12998 12999 return section 13000 } 13001 13002 #createDeleteTableButton() { 13003 const container = createElement("div", { className: "lexxy-table-control lexxy-floating-controls__group" }); 13004 13005 const deleteTableButton = this.#createButton("Delete this table?", { action: "delete", childType: "table" }); 13006 deleteTableButton.classList.add("lexxy-table-control__button--delete-table"); 13007 13008 container.appendChild(deleteTableButton); 13009 13010 this.deleteContainer = container; 13011 13012 return container 13013 } 13014 13015 #createButton(label, command = {}, icon = this.#icon(command)) { 13016 const button = createElement("button", { 13017 className: "lexxy-table-control__button", 13018 "aria-label": label, 13019 type: "button" 13020 }); 13021 button.tabIndex = -1; 13022 button.innerHTML = `${icon} <span>${label}</span>`; 13023 13024 button.dataset.action = command.action; 13025 button.dataset.childType = command.childType; 13026 button.dataset.direction = command.direction; 13027 13028 button.addEventListener("click", () => this.#executeTableCommand(command)); 13029 13030 button.addEventListener("mouseover", () => this.#handleCommandButtonHover()); 13031 button.addEventListener("focus", () => this.#handleCommandButtonHover()); 13032 button.addEventListener("mouseout", () => this.#handleCommandButtonHover()); 13033 13034 return button 13035 } 13036 13037 #registerKeyboardShortcuts() { 13038 this.unregisterKeyboardShortcuts = this.#editor.registerCommand(me$1, this.#handleAccessibilityShortcutKey, Bi); 13039 } 13040 13041 #unregisterKeyboardShortcuts() { 13042 this.unregisterKeyboardShortcuts?.(); 13043 this.unregisterKeyboardShortcuts = null; 13044 } 13045 13046 #handleAccessibilityShortcutKey = (event) => { 13047 if ((event.ctrlKey || event.metaKey) && event.shiftKey && event.key === "F10") { 13048 const firstButton = this.querySelector("button, [tabindex]:not([tabindex='-1'])"); 13049 firstButton?.focus(); 13050 } 13051 } 13052 13053 #handleToolsKeydown = (event) => { 13054 if (event.key === "Escape") { 13055 this.#handleEscapeKey(); 13056 } else { 13057 handleRollingTabIndex(this.#tableToolsButtons, event); 13058 } 13059 } 13060 13061 #handleEscapeKey() { 13062 const cell = this.tableController.currentCell; 13063 if (!cell) return 13064 13065 this.#editor.update(() => { 13066 cell.select(); 13067 this.#editor.focus(); 13068 }); 13069 13070 this.#update(); 13071 } 13072 13073 async #handleCommandButtonHover() { 13074 await nextFrame(); 13075 13076 this.#clearCellStyles(); 13077 13078 const activeElement = this.querySelector("button:hover, button:focus"); 13079 if (!activeElement) return 13080 13081 const command = { 13082 action: activeElement.dataset.action, 13083 childType: activeElement.dataset.childType, 13084 direction: activeElement.dataset.direction 13085 }; 13086 13087 let cellsToHighlight = null; 13088 13089 switch (command.childType) { 13090 case "row": 13091 cellsToHighlight = this.tableController.currentRowCells; 13092 break 13093 case "column": 13094 cellsToHighlight = this.tableController.currentColumnCells; 13095 break 13096 case "table": 13097 cellsToHighlight = this.tableController.tableRows; 13098 break 13099 } 13100 13101 if (!cellsToHighlight) return 13102 13103 cellsToHighlight.forEach(cell => { 13104 const cellElement = this.#editor.getElementByKey(cell.getKey()); 13105 if (!cellElement) return 13106 13107 cellElement.classList.toggle(theme.tableCellHighlight, true); 13108 Object.assign(cellElement.dataset, command); 13109 }); 13110 } 13111 13112 #monitorForTableSelection() { 13113 this.unregisterUpdateListener = this.#editor.registerUpdateListener(() => { 13114 this.tableController.updateSelectedTable(); 13115 13116 const tableNode = this.tableController.currentTableNode; 13117 if (tableNode) { 13118 this.#show(); 13119 } else { 13120 this.#hide(); 13121 } 13122 }); 13123 } 13124 13125 #executeTableCommand(command) { 13126 this.tableController.executeTableCommand(command);
13127 this.#update(); 13128 } 13129 13130 #show() { 13131 this.style.display = "flex"; 13132 this.#update(); 13133 } 13134 13135 #hide() { 13136 this.style.display = "none"; 13137 this.#clearCellStyles(); 13138 } 13139 13140 #update() { 13141 this.#updateButtonsPosition(); 13142 this.#updateRowColumnCount(); 13143 this.#closeMoreMenu(); 13144 this.#handleCommandButtonHover(); 13145 } 13146 13147 #closeMoreMenu() { 13148 this.querySelector("details[open]")?.removeAttribute("open"); 13149 } 13150 13151 #updateButtonsPosition() { 13152 const tableNode = this.tableController.currentTableNode; 13153 if (!tableNode) return 13154 13155 const tableElement = this.#editor.getElementByKey(tableNode.getKey()); 13156 if (!tableElement) return 13157 13158 const tableRect = tableElement.getBoundingClientRect(); 13159 const editorRect = this.#editorElement.getBoundingClientRect(); 13160 13161 const relativeTop = tableRect.top - editorRect.top; 13162 const relativeCenter = (tableRect.left + tableRect.right) / 2 - editorRect.left; 13163 this.style.top = `${relativeTop}px`; 13164 this.style.left = `${relativeCenter}px`; 13165 } 13166 13167 #updateRowColumnCount() { 13168 const tableNode = this.tableController.currentTableNode; 13169 if (!tableNode) return 13170 13171 const tableElement = dn(this.#editor, tableNode); 13172 if (!tableElement) return 13173 13174 const rowCount = tableElement.rows; 13175 const columnCount = tableElement.columns; 13176 13177 this.rowCount.textContent = `${rowCount} row${rowCount === 1 ? "" : "s"}`; 13178 this.columnCount.textContent = `${columnCount} column${columnCount === 1 ? "" : "s"}`; 13179 } 13180 13181 #setTableCellFocus() { 13182 const cell = this.tableController.currentCell; 13183 if (!cell) return 13184 13185 const cellElement = this.#editor.getElementByKey(cell.getKey()); 13186 if (!cellElement) return 13187 13188 cellElement.classList.add(theme.tableCellFocus); 13189 } 13190 13191 #clearCellStyles() { 13192 this.#editorElement.querySelectorAll(`.${theme.tableCellFocus}`)?.forEach(cell => { 13193 cell.classList.remove(theme.tableCellFocus); 13194 }); 13195 13196 this.#editorElement.querySelectorAll(`.${theme.tableCellHighlight}`)?.forEach(cell => { 13197 cell.classList.remove(theme.tableCellHighlight); 13198 cell.removeAttribute("data-action"); 13199 cell.removeAttribute("data-child-type"); 13200 cell.removeAttribute("data-direction"); 13201 }); 13202 13203 this.#setTableCellFocus(); 13204 } 13205 13206 #icon(command) { 13207 const { action, childType } = command; 13208 const direction = (action == "insert" ? command.direction : null); 13209 const iconId = [ action, childType, direction ].filter(Boolean).join("-"); 13210 return TableIcons[iconId] 13211 } 13212} 13213 13214function defineElements() { 13215 const elements = { 13216 "lexxy-toolbar": LexicalToolbarElement, 13217 "lexxy-editor": LexicalEditorElement, 13218 "lexxy-link-dropdown": LinkDropdown, 13219 "lexxy-highlight-dropdown": HighlightDropdown, 13220 "lexxy-prompt": LexicalPromptElement, 13221 "lexxy-code-language-picker": CodeLanguagePicker, 13222 "lexxy-node-delete-button": NodeDeleteButton, 13223 "lexxy-table-tools": TableTools, 13224 }; 13225 13226 Object.entries(elements).forEach(([ name, element ]) => { 13227 customElements.define(name, element); 13228 }); 13229} 13230 13231function highlightCode() { 13232 const elements = document.querySelectorAll("pre[data-language]"); 13233 13234 elements.forEach(preElement => { 13235 highlightElement(preElement); 13236 }); 13237} 13238 13239function highlightElement(preElement) { 13240 const language = preElement.getAttribute("data-language"); 13241 let code = preElement.innerHTML.replace(/<br\s*\/?>/gi, "\n"); 13242 13243 const grammar = Prism$1.languages?.[language]; 13244 if (!grammar) return 13245 13246 // unescape HTML entities in the code block 13247 code = new DOMParser().parseFromString(code, "text/html").body.textContent || ""; 13248 13249 const highlightedHtml = Prism$1.highlight(code, grammar, language); 13250 const codeElement = createElement("code", { "data-language": language, innerHTML: highlightedHtml }); 13251 preElement.replaceWith(codeElement); 13252} 13253 13254const configure = Lexxy.configure; 13255 13256// Pushing elements definition to after the current call stack to allow global configuration to take place first 13257setTimeout(defineElements, 0); 13258 13259export { $createActionTextAttachmentNode, $createActionTextAttachmentUploadNode, $isActionTextAttachmentNode, ActionTextAttachmentNode, ActionTextAttachmentUploadNode, CustomActionTextAttachmentNode, LexxyExtension as Extension, HorizontalDividerNode, configure, highlightCode as highlightAll, highlightCode }; 13260//# sourceMappingURL=/assets/lexxy-e7d432ad.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.