lexxy 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascript/lexxy.js +2239 -374
- data/app/assets/javascript/lexxy.js.br +0 -0
- data/app/assets/javascript/lexxy.js.gz +0 -0
- data/app/assets/javascript/lexxy.js.map +1 -1
- data/app/assets/javascript/lexxy.min.js +4 -4
- data/app/assets/javascript/lexxy.min.js.br +0 -0
- data/app/assets/javascript/lexxy.min.js.gz +0 -0
- data/lib/lexxy/engine.rb +4 -2
- data/lib/lexxy/version.rb +1 -1
- metadata +1 -1
|
@@ -4827,24 +4827,65 @@ Prism$1.languages.webmanifest = Prism$1.languages.json;
|
|
|
4827
4827
|
window.Prism ||= {};
|
|
4828
4828
|
window.Prism.manual = true;
|
|
4829
4829
|
|
|
4830
|
-
/*! @license DOMPurify 3.
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4830
|
+
/*! @license DOMPurify 3.4.13 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.13/LICENSE */
|
|
4831
|
+
|
|
4832
|
+
function _arrayLikeToArray(r, a) {
|
|
4833
|
+
(null == a || a > r.length) && (a = r.length);
|
|
4834
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
4835
|
+
return n;
|
|
4836
|
+
}
|
|
4837
|
+
function _arrayWithHoles(r) {
|
|
4838
|
+
if (Array.isArray(r)) return r;
|
|
4839
|
+
}
|
|
4840
|
+
function _iterableToArrayLimit(r, l) {
|
|
4841
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
4842
|
+
if (null != t) {
|
|
4843
|
+
var e,
|
|
4844
|
+
n,
|
|
4845
|
+
i,
|
|
4846
|
+
u,
|
|
4847
|
+
a = [],
|
|
4848
|
+
f = true,
|
|
4849
|
+
o = false;
|
|
4850
|
+
try {
|
|
4851
|
+
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
4852
|
+
} catch (r) {
|
|
4853
|
+
o = true, n = r;
|
|
4854
|
+
} finally {
|
|
4855
|
+
try {
|
|
4856
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
4857
|
+
} finally {
|
|
4858
|
+
if (o) throw n;
|
|
4859
|
+
}
|
|
4860
|
+
}
|
|
4861
|
+
return a;
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4864
|
+
function _nonIterableRest() {
|
|
4865
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4866
|
+
}
|
|
4867
|
+
function _slicedToArray(r, e) {
|
|
4868
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
4869
|
+
}
|
|
4870
|
+
function _unsupportedIterableToArray(r, a) {
|
|
4871
|
+
if (r) {
|
|
4872
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
4873
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
4874
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
4875
|
+
}
|
|
4876
|
+
}
|
|
4877
|
+
|
|
4878
|
+
const entries = Object.entries,
|
|
4879
|
+
setPrototypeOf = Object.setPrototypeOf,
|
|
4880
|
+
isFrozen = Object.isFrozen,
|
|
4881
|
+
getPrototypeOf = Object.getPrototypeOf,
|
|
4882
|
+
getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
4883
|
+
let freeze = Object.freeze,
|
|
4884
|
+
seal = Object.seal,
|
|
4885
|
+
create = Object.create; // eslint-disable-line import/no-mutable-exports
|
|
4886
|
+
let _ref = typeof Reflect !== 'undefined' && Reflect,
|
|
4887
|
+
apply = _ref.apply,
|
|
4888
|
+
construct = _ref.construct;
|
|
4848
4889
|
if (!freeze) {
|
|
4849
4890
|
freeze = function freeze(x) {
|
|
4850
4891
|
return x;
|
|
@@ -4876,13 +4917,19 @@ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
|
4876
4917
|
const arrayPop = unapply(Array.prototype.pop);
|
|
4877
4918
|
const arrayPush = unapply(Array.prototype.push);
|
|
4878
4919
|
const arraySplice = unapply(Array.prototype.splice);
|
|
4920
|
+
const arrayIsArray = Array.isArray;
|
|
4879
4921
|
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
4880
4922
|
const stringToString = unapply(String.prototype.toString);
|
|
4881
4923
|
const stringMatch = unapply(String.prototype.match);
|
|
4882
4924
|
const stringReplace = unapply(String.prototype.replace);
|
|
4883
4925
|
const stringIndexOf = unapply(String.prototype.indexOf);
|
|
4884
4926
|
const stringTrim = unapply(String.prototype.trim);
|
|
4927
|
+
const numberToString = unapply(Number.prototype.toString);
|
|
4928
|
+
const booleanToString = unapply(Boolean.prototype.toString);
|
|
4929
|
+
const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
|
|
4930
|
+
const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
|
|
4885
4931
|
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
4932
|
+
const objectToString = unapply(Object.prototype.toString);
|
|
4886
4933
|
const regExpTest = unapply(RegExp.prototype.test);
|
|
4887
4934
|
const typeErrorCreate = unconstruct(TypeError);
|
|
4888
4935
|
/**
|
|
@@ -4932,6 +4979,9 @@ function addToSet(set, array) {
|
|
|
4932
4979
|
// Prevent prototype setters from intercepting set as a this value.
|
|
4933
4980
|
setPrototypeOf(set, null);
|
|
4934
4981
|
}
|
|
4982
|
+
if (!arrayIsArray(array)) {
|
|
4983
|
+
return set;
|
|
4984
|
+
}
|
|
4935
4985
|
let l = array.length;
|
|
4936
4986
|
while (l--) {
|
|
4937
4987
|
let element = array[l];
|
|
@@ -4972,10 +5022,13 @@ function cleanArray(array) {
|
|
|
4972
5022
|
*/
|
|
4973
5023
|
function clone(object) {
|
|
4974
5024
|
const newObject = create(null);
|
|
4975
|
-
for (const
|
|
5025
|
+
for (const _ref2 of entries(object)) {
|
|
5026
|
+
var _ref3 = _slicedToArray(_ref2, 2);
|
|
5027
|
+
const property = _ref3[0];
|
|
5028
|
+
const value = _ref3[1];
|
|
4976
5029
|
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
4977
5030
|
if (isPropertyExist) {
|
|
4978
|
-
if (
|
|
5031
|
+
if (arrayIsArray(value)) {
|
|
4979
5032
|
newObject[property] = cleanArray(value);
|
|
4980
5033
|
} else if (value && typeof value === 'object' && value.constructor === Object) {
|
|
4981
5034
|
newObject[property] = clone(value);
|
|
@@ -4986,6 +5039,58 @@ function clone(object) {
|
|
|
4986
5039
|
}
|
|
4987
5040
|
return newObject;
|
|
4988
5041
|
}
|
|
5042
|
+
/**
|
|
5043
|
+
* Convert non-node values into strings without depending on direct property access.
|
|
5044
|
+
*
|
|
5045
|
+
* @param value - The value to stringify.
|
|
5046
|
+
* @returns A string representation of the provided value.
|
|
5047
|
+
*/
|
|
5048
|
+
function stringifyValue(value) {
|
|
5049
|
+
switch (typeof value) {
|
|
5050
|
+
case 'string':
|
|
5051
|
+
{
|
|
5052
|
+
return value;
|
|
5053
|
+
}
|
|
5054
|
+
case 'number':
|
|
5055
|
+
{
|
|
5056
|
+
return numberToString(value);
|
|
5057
|
+
}
|
|
5058
|
+
case 'boolean':
|
|
5059
|
+
{
|
|
5060
|
+
return booleanToString(value);
|
|
5061
|
+
}
|
|
5062
|
+
case 'bigint':
|
|
5063
|
+
{
|
|
5064
|
+
return bigintToString ? bigintToString(value) : '0';
|
|
5065
|
+
}
|
|
5066
|
+
case 'symbol':
|
|
5067
|
+
{
|
|
5068
|
+
return symbolToString ? symbolToString(value) : 'Symbol()';
|
|
5069
|
+
}
|
|
5070
|
+
case 'undefined':
|
|
5071
|
+
{
|
|
5072
|
+
return objectToString(value);
|
|
5073
|
+
}
|
|
5074
|
+
case 'function':
|
|
5075
|
+
case 'object':
|
|
5076
|
+
{
|
|
5077
|
+
if (value === null) {
|
|
5078
|
+
return objectToString(value);
|
|
5079
|
+
}
|
|
5080
|
+
const valueAsRecord = value;
|
|
5081
|
+
const valueToString = lookupGetter(valueAsRecord, 'toString');
|
|
5082
|
+
if (typeof valueToString === 'function') {
|
|
5083
|
+
const stringified = valueToString(valueAsRecord);
|
|
5084
|
+
return typeof stringified === 'string' ? stringified : objectToString(stringified);
|
|
5085
|
+
}
|
|
5086
|
+
return objectToString(value);
|
|
5087
|
+
}
|
|
5088
|
+
default:
|
|
5089
|
+
{
|
|
5090
|
+
return objectToString(value);
|
|
5091
|
+
}
|
|
5092
|
+
}
|
|
5093
|
+
}
|
|
4989
5094
|
/**
|
|
4990
5095
|
* This method automatically checks if the prop is function or getter and behaves accordingly.
|
|
4991
5096
|
*
|
|
@@ -5011,6 +5116,14 @@ function lookupGetter(object, prop) {
|
|
|
5011
5116
|
}
|
|
5012
5117
|
return fallbackValue;
|
|
5013
5118
|
}
|
|
5119
|
+
function isRegex(value) {
|
|
5120
|
+
try {
|
|
5121
|
+
regExpTest(value, '');
|
|
5122
|
+
return true;
|
|
5123
|
+
} catch (_unused) {
|
|
5124
|
+
return false;
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
5014
5127
|
|
|
5015
5128
|
const 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']);
|
|
5016
5129
|
const 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']);
|
|
@@ -5026,15 +5139,14 @@ const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mgly
|
|
|
5026
5139
|
const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
5027
5140
|
const text = freeze(['#text']);
|
|
5028
5141
|
|
|
5029
|
-
const 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'
|
|
5030
|
-
const 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']);
|
|
5031
|
-
const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', '
|
|
5142
|
+
const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'command', 'commandfor', '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']);
|
|
5143
|
+
const 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', 'dominant-baseline', '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-orientation', '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']);
|
|
5144
|
+
const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnalign', 'columnlines', 'columnspacing', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lquote', 'lspace', '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']);
|
|
5032
5145
|
const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
5033
5146
|
|
|
5034
|
-
|
|
5035
|
-
const
|
|
5036
|
-
const
|
|
5037
|
-
const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex
|
|
5147
|
+
const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
|
|
5148
|
+
const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
|
|
5149
|
+
const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
|
|
5038
5150
|
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
|
|
5039
5151
|
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
5040
5152
|
const 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
|
|
@@ -5044,30 +5156,31 @@ const ATTR_WHITESPACE$1 = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u2
|
|
|
5044
5156
|
);
|
|
5045
5157
|
const DOCTYPE_NAME = seal(/^html$/i);
|
|
5046
5158
|
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
5159
|
+
// Markup-significant character probes used by _sanitizeElements.
|
|
5160
|
+
// Shared module-level instances are safe despite the sticky /g flags:
|
|
5161
|
+
// unapply() resets lastIndex for RegExp receivers before every call.
|
|
5162
|
+
const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
|
|
5163
|
+
const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
|
|
5164
|
+
const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
|
|
5165
|
+
const SELF_CLOSING_TAG = seal(/\/>/i);
|
|
5047
5166
|
|
|
5048
|
-
var EXPRESSIONS = /*#__PURE__*/Object.freeze({
|
|
5049
|
-
__proto__: null,
|
|
5050
|
-
ARIA_ATTR: ARIA_ATTR,
|
|
5051
|
-
ATTR_WHITESPACE: ATTR_WHITESPACE$1,
|
|
5052
|
-
CUSTOM_ELEMENT: CUSTOM_ELEMENT,
|
|
5053
|
-
DATA_ATTR: DATA_ATTR,
|
|
5054
|
-
DOCTYPE_NAME: DOCTYPE_NAME,
|
|
5055
|
-
ERB_EXPR: ERB_EXPR,
|
|
5056
|
-
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
|
5057
|
-
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
|
5058
|
-
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
|
5059
|
-
TMPLIT_EXPR: TMPLIT_EXPR
|
|
5060
|
-
});
|
|
5061
|
-
|
|
5062
|
-
/* eslint-disable @typescript-eslint/indent */
|
|
5063
5167
|
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
|
5064
5168
|
const NODE_TYPE = {
|
|
5065
5169
|
element: 1,
|
|
5170
|
+
attribute: 2,
|
|
5066
5171
|
text: 3,
|
|
5172
|
+
cdataSection: 4,
|
|
5173
|
+
entityReference: 5,
|
|
5174
|
+
// Deprecated
|
|
5175
|
+
entityNode: 6,
|
|
5067
5176
|
// Deprecated
|
|
5068
|
-
|
|
5177
|
+
processingInstruction: 7,
|
|
5069
5178
|
comment: 8,
|
|
5070
|
-
document: 9
|
|
5179
|
+
document: 9,
|
|
5180
|
+
documentType: 10,
|
|
5181
|
+
documentFragment: 11,
|
|
5182
|
+
notation: 12 // Deprecated
|
|
5183
|
+
};
|
|
5071
5184
|
const getGlobal = function getGlobal() {
|
|
5072
5185
|
return typeof window === 'undefined' ? null : window;
|
|
5073
5186
|
};
|
|
@@ -5122,10 +5235,25 @@ const _createHooksMap = function _createHooksMap() {
|
|
|
5122
5235
|
uponSanitizeShadowNode: []
|
|
5123
5236
|
};
|
|
5124
5237
|
};
|
|
5238
|
+
/**
|
|
5239
|
+
* Resolve a set-valued configuration option: a fresh set built from
|
|
5240
|
+
* cfg[key] when it is an own array property (seeded with a clone of
|
|
5241
|
+
* options.base when given, case-normalized via options.transform),
|
|
5242
|
+
* the fallback set otherwise.
|
|
5243
|
+
*
|
|
5244
|
+
* @param cfg the cloned, prototype-free configuration object
|
|
5245
|
+
* @param key the configuration property to read
|
|
5246
|
+
* @param fallback the set to use when the option is absent or not an array
|
|
5247
|
+
* @param options transform and optional base set to merge into
|
|
5248
|
+
* @returns the resolved set
|
|
5249
|
+
*/
|
|
5250
|
+
const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
|
|
5251
|
+
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
5252
|
+
};
|
|
5125
5253
|
function createDOMPurify() {
|
|
5126
5254
|
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
5127
5255
|
const DOMPurify = root => createDOMPurify(root);
|
|
5128
|
-
DOMPurify.version = '3.
|
|
5256
|
+
DOMPurify.version = '3.4.13';
|
|
5129
5257
|
DOMPurify.removed = [];
|
|
5130
5258
|
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
5131
5259
|
// Not running in a browser, provide a factory function
|
|
@@ -5133,28 +5261,30 @@ function createDOMPurify() {
|
|
|
5133
5261
|
DOMPurify.isSupported = false;
|
|
5134
5262
|
return DOMPurify;
|
|
5135
5263
|
}
|
|
5136
|
-
let
|
|
5137
|
-
document
|
|
5138
|
-
} = window;
|
|
5264
|
+
let document = window.document;
|
|
5139
5265
|
const originalDocument = document;
|
|
5140
5266
|
const currentScript = originalDocument.currentScript;
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
NamedNodeMap
|
|
5148
|
-
HTMLFormElement
|
|
5149
|
-
DOMParser,
|
|
5150
|
-
trustedTypes
|
|
5151
|
-
} = window;
|
|
5267
|
+
window.DocumentFragment;
|
|
5268
|
+
const HTMLTemplateElement = window.HTMLTemplateElement,
|
|
5269
|
+
Node = window.Node,
|
|
5270
|
+
Element = window.Element,
|
|
5271
|
+
NodeFilter = window.NodeFilter,
|
|
5272
|
+
_window$NamedNodeMap = window.NamedNodeMap;
|
|
5273
|
+
_window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap;
|
|
5274
|
+
window.HTMLFormElement;
|
|
5275
|
+
const DOMParser = window.DOMParser,
|
|
5276
|
+
trustedTypes = window.trustedTypes;
|
|
5152
5277
|
const ElementPrototype = Element.prototype;
|
|
5153
5278
|
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
5154
5279
|
const remove = lookupGetter(ElementPrototype, 'remove');
|
|
5155
5280
|
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
5156
5281
|
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
5157
5282
|
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
5283
|
+
const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
|
|
5284
|
+
const getAttributes = lookupGetter(ElementPrototype, 'attributes');
|
|
5285
|
+
const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
|
|
5286
|
+
const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
|
|
5287
|
+
const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, 'ownerDocument') : null;
|
|
5158
5288
|
// As per issue #47, the web-components registry is inherited by a
|
|
5159
5289
|
// new document created via createHTMLDocument. As per the spec
|
|
5160
5290
|
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
@@ -5169,33 +5299,74 @@ function createDOMPurify() {
|
|
|
5169
5299
|
}
|
|
5170
5300
|
let trustedTypesPolicy;
|
|
5171
5301
|
let emptyHTML = '';
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5302
|
+
// The instance's own internal Trusted Types policy. Unlike a caller-supplied
|
|
5303
|
+
// `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws
|
|
5304
|
+
// on duplicate policy names — and is the only policy allowed to persist
|
|
5305
|
+
// across configurations and survive `clearConfig()`.
|
|
5306
|
+
let defaultTrustedTypesPolicy;
|
|
5307
|
+
let defaultTrustedTypesPolicyResolved = false;
|
|
5308
|
+
// Tracks whether we are already inside a call to the configured Trusted Types
|
|
5309
|
+
// policy (`createHTML` or `createScriptURL`). If a supplied policy callback
|
|
5310
|
+
// itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
|
|
5311
|
+
// re-enter the policy and recurse until the stack overflows. We detect that
|
|
5312
|
+
// re-entry and throw a clear, actionable error instead. The guard is shared
|
|
5313
|
+
// across both callbacks, because either one re-entering `sanitize` triggers
|
|
5314
|
+
// the same unbounded recursion.
|
|
5315
|
+
let IN_TRUSTED_TYPES_POLICY = 0;
|
|
5316
|
+
const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
|
|
5317
|
+
if (IN_TRUSTED_TYPES_POLICY > 0) {
|
|
5318
|
+
throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or ' + 'createScriptURL) must not call DOMPurify.sanitize, as that causes ' + 'infinite recursion. Do not pass a policy whose callbacks wrap ' + 'DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted ' + 'Types" section of the README.');
|
|
5319
|
+
}
|
|
5320
|
+
};
|
|
5321
|
+
const _createTrustedHTML = function _createTrustedHTML(html) {
|
|
5322
|
+
_assertNotInTrustedTypesPolicy();
|
|
5323
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
5324
|
+
try {
|
|
5325
|
+
return trustedTypesPolicy.createHTML(html);
|
|
5326
|
+
} finally {
|
|
5327
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
5328
|
+
}
|
|
5329
|
+
};
|
|
5330
|
+
const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
|
|
5331
|
+
_assertNotInTrustedTypesPolicy();
|
|
5332
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
5333
|
+
try {
|
|
5334
|
+
return trustedTypesPolicy.createScriptURL(scriptUrl);
|
|
5335
|
+
} finally {
|
|
5336
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
5337
|
+
}
|
|
5338
|
+
};
|
|
5339
|
+
// Lazily resolve (and cache) the instance's internal default policy.
|
|
5340
|
+
// Resolution is attempted at most once: a successful `createPolicy` cannot be
|
|
5341
|
+
// repeated (Trusted Types throws on duplicate names), and a failed or
|
|
5342
|
+
// unsupported attempt must not be retried on every parse.
|
|
5343
|
+
const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
|
|
5344
|
+
if (!defaultTrustedTypesPolicyResolved) {
|
|
5345
|
+
defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
5346
|
+
defaultTrustedTypesPolicyResolved = true;
|
|
5347
|
+
}
|
|
5348
|
+
return defaultTrustedTypesPolicy;
|
|
5349
|
+
};
|
|
5350
|
+
const _document = document,
|
|
5351
|
+
implementation = _document.implementation,
|
|
5352
|
+
createNodeIterator = _document.createNodeIterator,
|
|
5353
|
+
createDocumentFragment = _document.createDocumentFragment,
|
|
5354
|
+
getElementsByTagName = _document.getElementsByTagName;
|
|
5355
|
+
const importNode = originalDocument.importNode;
|
|
5181
5356
|
let hooks = _createHooksMap();
|
|
5182
5357
|
/**
|
|
5183
5358
|
* Expose whether this browser supports running the full DOMPurify.
|
|
5184
5359
|
*/
|
|
5185
5360
|
DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
|
|
5186
|
-
const
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
} = EXPRESSIONS;
|
|
5196
|
-
let {
|
|
5197
|
-
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
5198
|
-
} = EXPRESSIONS;
|
|
5361
|
+
const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
|
|
5362
|
+
ERB_EXPR$1 = ERB_EXPR,
|
|
5363
|
+
TMPLIT_EXPR$1 = TMPLIT_EXPR,
|
|
5364
|
+
DATA_ATTR$1 = DATA_ATTR,
|
|
5365
|
+
ARIA_ATTR$1 = ARIA_ATTR,
|
|
5366
|
+
IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
|
|
5367
|
+
ATTR_WHITESPACE$1$1 = ATTR_WHITESPACE$1,
|
|
5368
|
+
CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
|
|
5369
|
+
let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
|
|
5199
5370
|
/**
|
|
5200
5371
|
* We consider the elements and attributes below to be safe. Ideally
|
|
5201
5372
|
* don't add any new ones but feel free to remove unwanted ones.
|
|
@@ -5272,6 +5443,13 @@ function createDOMPurify() {
|
|
|
5272
5443
|
let WHOLE_DOCUMENT = false;
|
|
5273
5444
|
/* Track whether config is already set on this instance of DOMPurify. */
|
|
5274
5445
|
let SET_CONFIG = false;
|
|
5446
|
+
/* Pristine allowlist bindings captured at setConfig() time. On the
|
|
5447
|
+
* persistent-config path sanitize() restores the sets from these before
|
|
5448
|
+
* the per-walk hook clone-guard, so a hook's in-call widening cannot
|
|
5449
|
+
* carry across calls. Null until setConfig() is called; reset by
|
|
5450
|
+
* clearConfig(). */
|
|
5451
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
5452
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
5275
5453
|
/* Decide if all elements (e.g. style, script) must be children of
|
|
5276
5454
|
* document.body. By default, browsers might move them to document.head */
|
|
5277
5455
|
let FORCE_BODY = false;
|
|
@@ -5314,7 +5492,17 @@ function createDOMPurify() {
|
|
|
5314
5492
|
let USE_PROFILES = {};
|
|
5315
5493
|
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
5316
5494
|
let FORBID_CONTENTS = null;
|
|
5317
|
-
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
|
|
5495
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
|
|
5496
|
+
// <selectedcontent> mirrors the selected <option>'s subtree, cloned by
|
|
5497
|
+
// the UA (customizable <select>) — including any on* handlers — and the
|
|
5498
|
+
// engine re-mirrors synchronously whenever a removal changes which
|
|
5499
|
+
// option/selectedcontent is current, even inside DOMPurify's inert
|
|
5500
|
+
// DOMParser document. Hoisting its children on removal re-inserts a fresh
|
|
5501
|
+
// mirror target ahead of the walk, which the engine refills, looping
|
|
5502
|
+
// forever (DoS) and amplifying output. Dropping its content on removal
|
|
5503
|
+
// (rather than hoisting) breaks that cascade; the content is a duplicate
|
|
5504
|
+
// of the option, which is sanitized on its own. See campaign-3 F1/F6.
|
|
5505
|
+
'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
|
5318
5506
|
/* Tags that are safe for data: URIs */
|
|
5319
5507
|
let DATA_URI_TAGS = null;
|
|
5320
5508
|
const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
@@ -5330,8 +5518,10 @@ function createDOMPurify() {
|
|
|
5330
5518
|
/* Allowed XHTML+XML namespaces */
|
|
5331
5519
|
let ALLOWED_NAMESPACES = null;
|
|
5332
5520
|
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
5333
|
-
|
|
5334
|
-
let
|
|
5521
|
+
const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
5522
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
5523
|
+
const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);
|
|
5524
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
5335
5525
|
// Certain elements are allowed in both SVG and HTML
|
|
5336
5526
|
// namespace. We need to specify them explicitly
|
|
5337
5527
|
// so that they don't get erroneously deleted from
|
|
@@ -5373,15 +5563,33 @@ function createDOMPurify() {
|
|
|
5373
5563
|
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
5374
5564
|
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
5375
5565
|
/* Set configuration parameters */
|
|
5376
|
-
ALLOWED_TAGS =
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5566
|
+
ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {
|
|
5567
|
+
transform: transformCaseFunc
|
|
5568
|
+
});
|
|
5569
|
+
ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {
|
|
5570
|
+
transform: transformCaseFunc
|
|
5571
|
+
});
|
|
5572
|
+
ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {
|
|
5573
|
+
transform: stringToString
|
|
5574
|
+
});
|
|
5575
|
+
URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {
|
|
5576
|
+
transform: transformCaseFunc,
|
|
5577
|
+
base: DEFAULT_URI_SAFE_ATTRIBUTES
|
|
5578
|
+
});
|
|
5579
|
+
DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {
|
|
5580
|
+
transform: transformCaseFunc,
|
|
5581
|
+
base: DEFAULT_DATA_URI_TAGS
|
|
5582
|
+
});
|
|
5583
|
+
FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {
|
|
5584
|
+
transform: transformCaseFunc
|
|
5585
|
+
});
|
|
5586
|
+
FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {
|
|
5587
|
+
transform: transformCaseFunc
|
|
5588
|
+
});
|
|
5589
|
+
FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {
|
|
5590
|
+
transform: transformCaseFunc
|
|
5591
|
+
});
|
|
5592
|
+
USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
5385
5593
|
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
5386
5594
|
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
5387
5595
|
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
@@ -5397,20 +5605,22 @@ function createDOMPurify() {
|
|
|
5397
5605
|
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
|
|
5398
5606
|
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
5399
5607
|
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
5400
|
-
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP
|
|
5401
|
-
NAMESPACE = cfg.NAMESPACE
|
|
5402
|
-
MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS
|
|
5403
|
-
HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5608
|
+
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
|
|
5609
|
+
NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
|
|
5610
|
+
MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'MATHML_TEXT_INTEGRATION_POINTS') && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === 'object' ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS); // Default built-in map
|
|
5611
|
+
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS); // Default built-in map
|
|
5612
|
+
const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
|
|
5613
|
+
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
5614
|
+
if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
|
|
5615
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
|
|
5616
|
+
}
|
|
5617
|
+
if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
|
|
5618
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
|
|
5619
|
+
}
|
|
5620
|
+
if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
|
|
5621
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
|
|
5622
|
+
}
|
|
5623
|
+
seal(CUSTOM_ELEMENT_HANDLING);
|
|
5414
5624
|
if (SAFE_FOR_TEMPLATES) {
|
|
5415
5625
|
ALLOW_DATA_ATTR = false;
|
|
5416
5626
|
}
|
|
@@ -5420,7 +5630,7 @@ function createDOMPurify() {
|
|
|
5420
5630
|
/* Parse profile info */
|
|
5421
5631
|
if (USE_PROFILES) {
|
|
5422
5632
|
ALLOWED_TAGS = addToSet({}, text);
|
|
5423
|
-
ALLOWED_ATTR =
|
|
5633
|
+
ALLOWED_ATTR = create(null);
|
|
5424
5634
|
if (USE_PROFILES.html === true) {
|
|
5425
5635
|
addToSet(ALLOWED_TAGS, html$1);
|
|
5426
5636
|
addToSet(ALLOWED_ATTR, html);
|
|
@@ -5441,36 +5651,46 @@ function createDOMPurify() {
|
|
|
5441
5651
|
addToSet(ALLOWED_ATTR, xml);
|
|
5442
5652
|
}
|
|
5443
5653
|
}
|
|
5654
|
+
/* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
|
|
5655
|
+
* leaking across calls when switching from function to array config */
|
|
5656
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
5657
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
5444
5658
|
/* Merge configuration parameters */
|
|
5445
|
-
if (cfg
|
|
5659
|
+
if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
|
|
5446
5660
|
if (typeof cfg.ADD_TAGS === 'function') {
|
|
5447
5661
|
EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
|
|
5448
|
-
} else {
|
|
5662
|
+
} else if (arrayIsArray(cfg.ADD_TAGS)) {
|
|
5449
5663
|
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
5450
5664
|
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
5451
5665
|
}
|
|
5452
5666
|
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
5453
5667
|
}
|
|
5454
5668
|
}
|
|
5455
|
-
if (cfg
|
|
5669
|
+
if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
|
|
5456
5670
|
if (typeof cfg.ADD_ATTR === 'function') {
|
|
5457
5671
|
EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
|
|
5458
|
-
} else {
|
|
5672
|
+
} else if (arrayIsArray(cfg.ADD_ATTR)) {
|
|
5459
5673
|
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
5460
5674
|
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
5461
5675
|
}
|
|
5462
5676
|
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
5463
5677
|
}
|
|
5464
5678
|
}
|
|
5465
|
-
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
5679
|
+
if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
|
|
5466
5680
|
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
5467
5681
|
}
|
|
5468
|
-
if (cfg.FORBID_CONTENTS) {
|
|
5682
|
+
if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {
|
|
5469
5683
|
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
5470
5684
|
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
5471
5685
|
}
|
|
5472
5686
|
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
5473
5687
|
}
|
|
5688
|
+
if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
|
|
5689
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
5690
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
5691
|
+
}
|
|
5692
|
+
addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
|
|
5693
|
+
}
|
|
5474
5694
|
/* Add #text in case KEEP_CONTENT is set to true */
|
|
5475
5695
|
if (KEEP_CONTENT) {
|
|
5476
5696
|
ALLOWED_TAGS['#text'] = true;
|
|
@@ -5484,6 +5704,13 @@ function createDOMPurify() {
|
|
|
5484
5704
|
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
5485
5705
|
delete FORBID_TAGS.tbody;
|
|
5486
5706
|
}
|
|
5707
|
+
// Re-derive the active Trusted Types policy from this configuration on
|
|
5708
|
+
// every parse. The active policy must never be sticky closure state that
|
|
5709
|
+
// outlives the config that set it: a caller-supplied policy left in place
|
|
5710
|
+
// after `clearConfig()` — or after a later call that supplied none, or
|
|
5711
|
+
// `TRUSTED_TYPES_POLICY: null` — could sign a subsequent "default"
|
|
5712
|
+
// `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.
|
|
5713
|
+
// See GHSA-vxr8-fq34-vvx9.
|
|
5487
5714
|
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
5488
5715
|
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
|
|
5489
5716
|
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
@@ -5491,18 +5718,45 @@ function createDOMPurify() {
|
|
|
5491
5718
|
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
|
|
5492
5719
|
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
5493
5720
|
}
|
|
5494
|
-
//
|
|
5721
|
+
// A caller-supplied policy applies to this configuration only.
|
|
5722
|
+
const previousTrustedTypesPolicy = trustedTypesPolicy;
|
|
5495
5723
|
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
5496
|
-
// Sign local variables required by `sanitize`.
|
|
5497
|
-
|
|
5724
|
+
// Sign local variables required by `sanitize`. If the supplied policy's
|
|
5725
|
+
// `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
|
|
5726
|
+
// throws via the re-entrancy guard. Restore the previous policy first so
|
|
5727
|
+
// the instance is not left in a poisoned state. See #1422.
|
|
5728
|
+
try {
|
|
5729
|
+
emptyHTML = _createTrustedHTML('');
|
|
5730
|
+
} catch (error) {
|
|
5731
|
+
trustedTypesPolicy = previousTrustedTypesPolicy;
|
|
5732
|
+
throw error;
|
|
5733
|
+
}
|
|
5734
|
+
} else if (cfg.TRUSTED_TYPES_POLICY === null) {
|
|
5735
|
+
// Explicit opt-out for this call: perform no Trusted Types signing and
|
|
5736
|
+
// create nothing (so a strict `trusted-types` CSP that disallows a
|
|
5737
|
+
// `dompurify` policy can still call `sanitize` from inside its own
|
|
5738
|
+
// policy — see #1422). Resetting to `undefined` rather than a sticky
|
|
5739
|
+
// `null` also drops any previously retained caller policy, so it cannot
|
|
5740
|
+
// resurface on a later call, while still allowing the next config-less
|
|
5741
|
+
// call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.
|
|
5742
|
+
trustedTypesPolicy = undefined;
|
|
5743
|
+
emptyHTML = '';
|
|
5498
5744
|
} else {
|
|
5499
|
-
//
|
|
5745
|
+
// No policy supplied: keep the currently active policy if one is set — a
|
|
5746
|
+
// previously supplied policy is intentionally sticky across config-less
|
|
5747
|
+
// calls — otherwise fall back to the instance's own internal policy,
|
|
5748
|
+
// created at most once. (A policy supplied for a *single* call still
|
|
5749
|
+
// lingers by design; what must not linger is a policy whose configuration
|
|
5750
|
+
// has been torn down via `clearConfig()`, which restores the default.)
|
|
5500
5751
|
if (trustedTypesPolicy === undefined) {
|
|
5501
|
-
trustedTypesPolicy =
|
|
5752
|
+
trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
|
|
5502
5753
|
}
|
|
5503
|
-
//
|
|
5504
|
-
|
|
5505
|
-
|
|
5754
|
+
// Sign internal variables only when a policy is active. A falsy policy
|
|
5755
|
+
// (Trusted Types unsupported, creation failed, or an explicit opt-out)
|
|
5756
|
+
// leaves `emptyHTML` as a plain string, so we never call `.createHTML` on
|
|
5757
|
+
// a non-policy and throw. See #1422.
|
|
5758
|
+
if (trustedTypesPolicy && typeof emptyHTML === 'string') {
|
|
5759
|
+
emptyHTML = _createTrustedHTML('');
|
|
5506
5760
|
}
|
|
5507
5761
|
}
|
|
5508
5762
|
// Prevent further manipulation of configuration.
|
|
@@ -5517,6 +5771,77 @@ function createDOMPurify() {
|
|
|
5517
5771
|
* correctly. */
|
|
5518
5772
|
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
5519
5773
|
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
5774
|
+
/**
|
|
5775
|
+
* Namespace rules for an element in the SVG namespace.
|
|
5776
|
+
*
|
|
5777
|
+
* @param tagName the element's lowercase tag name
|
|
5778
|
+
* @param parent the (possibly simulated) parent node
|
|
5779
|
+
* @param parentTagName the parent's lowercase tag name
|
|
5780
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
5781
|
+
*/
|
|
5782
|
+
const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
|
|
5783
|
+
// The only way to switch from HTML namespace to SVG
|
|
5784
|
+
// is via <svg>. If it happens via any other tag, then
|
|
5785
|
+
// it should be killed.
|
|
5786
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
5787
|
+
return tagName === 'svg';
|
|
5788
|
+
}
|
|
5789
|
+
// The only way to switch from MathML to SVG is via <svg>
|
|
5790
|
+
// if the parent is either <annotation-xml> or a MathML
|
|
5791
|
+
// text integration point.
|
|
5792
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
5793
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
5794
|
+
}
|
|
5795
|
+
// We only allow elements that are defined in SVG
|
|
5796
|
+
// spec. All others are disallowed in SVG namespace.
|
|
5797
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
5798
|
+
};
|
|
5799
|
+
/**
|
|
5800
|
+
* Namespace rules for an element in the MathML namespace.
|
|
5801
|
+
*
|
|
5802
|
+
* @param tagName the element's lowercase tag name
|
|
5803
|
+
* @param parent the (possibly simulated) parent node
|
|
5804
|
+
* @param parentTagName the parent's lowercase tag name
|
|
5805
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
5806
|
+
*/
|
|
5807
|
+
const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
|
|
5808
|
+
// The only way to switch from HTML namespace to MathML
|
|
5809
|
+
// is via <math>. If it happens via any other tag, then
|
|
5810
|
+
// it should be killed.
|
|
5811
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
5812
|
+
return tagName === 'math';
|
|
5813
|
+
}
|
|
5814
|
+
// The only way to switch from SVG to MathML is via
|
|
5815
|
+
// <math> and HTML integration points
|
|
5816
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
5817
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
5818
|
+
}
|
|
5819
|
+
// We only allow elements that are defined in MathML
|
|
5820
|
+
// spec. All others are disallowed in MathML namespace.
|
|
5821
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
5822
|
+
};
|
|
5823
|
+
/**
|
|
5824
|
+
* Namespace rules for an element in the HTML namespace.
|
|
5825
|
+
*
|
|
5826
|
+
* @param tagName the element's lowercase tag name
|
|
5827
|
+
* @param parent the (possibly simulated) parent node
|
|
5828
|
+
* @param parentTagName the parent's lowercase tag name
|
|
5829
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
5830
|
+
*/
|
|
5831
|
+
const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
|
|
5832
|
+
// The only way to switch from SVG to HTML is via
|
|
5833
|
+
// HTML integration points, and from MathML to HTML
|
|
5834
|
+
// is via MathML text integration points
|
|
5835
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
5836
|
+
return false;
|
|
5837
|
+
}
|
|
5838
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
5839
|
+
return false;
|
|
5840
|
+
}
|
|
5841
|
+
// We disallow tags that are specific for MathML
|
|
5842
|
+
// or SVG and should never appear in HTML namespace
|
|
5843
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
5844
|
+
};
|
|
5520
5845
|
/**
|
|
5521
5846
|
* @param element a DOM element whose namespace is being checked
|
|
5522
5847
|
* @returns Return false if the element has a
|
|
@@ -5539,51 +5864,13 @@ function createDOMPurify() {
|
|
|
5539
5864
|
return false;
|
|
5540
5865
|
}
|
|
5541
5866
|
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
5542
|
-
|
|
5543
|
-
// is via <svg>. If it happens via any other tag, then
|
|
5544
|
-
// it should be killed.
|
|
5545
|
-
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
5546
|
-
return tagName === 'svg';
|
|
5547
|
-
}
|
|
5548
|
-
// The only way to switch from MathML to SVG is via`
|
|
5549
|
-
// svg if parent is either <annotation-xml> or MathML
|
|
5550
|
-
// text integration points.
|
|
5551
|
-
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
5552
|
-
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
5553
|
-
}
|
|
5554
|
-
// We only allow elements that are defined in SVG
|
|
5555
|
-
// spec. All others are disallowed in SVG namespace.
|
|
5556
|
-
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
5867
|
+
return _checkSvgNamespace(tagName, parent, parentTagName);
|
|
5557
5868
|
}
|
|
5558
5869
|
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
5559
|
-
|
|
5560
|
-
// is via <math>. If it happens via any other tag, then
|
|
5561
|
-
// it should be killed.
|
|
5562
|
-
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
5563
|
-
return tagName === 'math';
|
|
5564
|
-
}
|
|
5565
|
-
// The only way to switch from SVG to MathML is via
|
|
5566
|
-
// <math> and HTML integration points
|
|
5567
|
-
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
5568
|
-
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
5569
|
-
}
|
|
5570
|
-
// We only allow elements that are defined in MathML
|
|
5571
|
-
// spec. All others are disallowed in MathML namespace.
|
|
5572
|
-
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
5870
|
+
return _checkMathMlNamespace(tagName, parent, parentTagName);
|
|
5573
5871
|
}
|
|
5574
5872
|
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
5575
|
-
|
|
5576
|
-
// HTML integration points, and from MathML to HTML
|
|
5577
|
-
// is via MathML text integration points
|
|
5578
|
-
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
5579
|
-
return false;
|
|
5580
|
-
}
|
|
5581
|
-
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
5582
|
-
return false;
|
|
5583
|
-
}
|
|
5584
|
-
// We disallow tags that are specific for MathML
|
|
5585
|
-
// or SVG and should never appear in HTML namespace
|
|
5586
|
-
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
5873
|
+
return _checkHtmlNamespace(tagName, parent, parentTagName);
|
|
5587
5874
|
}
|
|
5588
5875
|
// For XHTML and XML documents that support custom namespaces
|
|
5589
5876
|
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
@@ -5608,7 +5895,81 @@ function createDOMPurify() {
|
|
|
5608
5895
|
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
5609
5896
|
getParentNode(node).removeChild(node);
|
|
5610
5897
|
} catch (_) {
|
|
5898
|
+
/* The normal detach failed — this is reached for a parentless node
|
|
5899
|
+
(getParentNode() is null, so .removeChild throws). Element.prototype
|
|
5900
|
+
.remove() is itself a spec no-op on a parentless node, so a recorded
|
|
5901
|
+
"removal" would otherwise hand the caller back an intact,
|
|
5902
|
+
payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or
|
|
5903
|
+
the style-with-element-child rule decided to kill). Fail closed by
|
|
5904
|
+
throwing — exactly as a clobbered root does at the IN_PLACE entry —
|
|
5905
|
+
rather than trying to "neutralize" the node via its own methods.
|
|
5906
|
+
Neutralizing would mean calling getAttributeNames()/removeAttribute()
|
|
5907
|
+
on the node, both of which a <form> root can clobber via a named child
|
|
5908
|
+
(and _isClobbered does not even probe getAttributeNames), so the
|
|
5909
|
+
neutralize step could itself be silently defeated, leaving the payload
|
|
5910
|
+
intact. A throw touches only the cached, clobber-safe remove() and
|
|
5911
|
+
getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)
|
|
5912
|
+
to every root-kill reason. REPORT-3.
|
|
5913
|
+
This lives inside the catch, so it never fires for a normally-removed
|
|
5914
|
+
in-tree node: those have a parent, removeChild() succeeds, and the
|
|
5915
|
+
catch is not entered. Only a kept (parentless) root reaches here. */
|
|
5611
5916
|
remove(node);
|
|
5917
|
+
if (!getParentNode(node)) {
|
|
5918
|
+
throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');
|
|
5919
|
+
}
|
|
5920
|
+
}
|
|
5921
|
+
};
|
|
5922
|
+
/**
|
|
5923
|
+
* _neutralizeRoot
|
|
5924
|
+
*
|
|
5925
|
+
* Fail-closed teardown of an in-place root after the sanitize walk aborts
|
|
5926
|
+
* (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
|
|
5927
|
+
* custom element's reaction detaches a node so `_forceRemove`'s deliberate
|
|
5928
|
+
* parentless guard throws, or any other re-entrant engine mutation — would
|
|
5929
|
+
* otherwise leave the caller's *live* tree half-sanitized, with everything
|
|
5930
|
+
* after the abort point still carrying its handlers. There is no safe way
|
|
5931
|
+
* to resume the walk (the tree mutated under us), so we strip the root bare:
|
|
5932
|
+
* remove every child and every attribute, then let the caller's catch see
|
|
5933
|
+
* the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
|
|
5934
|
+
* getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
|
|
5935
|
+
*
|
|
5936
|
+
* @param root the in-place root to empty
|
|
5937
|
+
*/
|
|
5938
|
+
const _neutralizeRoot = function _neutralizeRoot(root) {
|
|
5939
|
+
/* Strip every disallowed attribute (on* handlers included) off the whole
|
|
5940
|
+
subtree BEFORE detaching anything. Detaching first would hand back
|
|
5941
|
+
handler-bearing originals (e.g. an already-loading `<img onerror>`)
|
|
5942
|
+
whose queued resource event still fires in page scope after we throw.
|
|
5943
|
+
Clobber-safe reads; a doomed clobbered node's own attributes are
|
|
5944
|
+
irrelevant while its non-clobbered descendants are reached and scrubbed. */
|
|
5945
|
+
_neutralizeSubtree(root);
|
|
5946
|
+
const childNodes = getChildNodes(root);
|
|
5947
|
+
if (childNodes) {
|
|
5948
|
+
const snapshot = [];
|
|
5949
|
+
arrayForEach(childNodes, child => {
|
|
5950
|
+
arrayPush(snapshot, child);
|
|
5951
|
+
});
|
|
5952
|
+
arrayForEach(snapshot, child => {
|
|
5953
|
+
try {
|
|
5954
|
+
remove(child);
|
|
5955
|
+
} catch (_) {
|
|
5956
|
+
/* Best-effort teardown; a still-attached child is handled below */
|
|
5957
|
+
}
|
|
5958
|
+
});
|
|
5959
|
+
}
|
|
5960
|
+
const attributes = getAttributes(root);
|
|
5961
|
+
if (attributes) {
|
|
5962
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
5963
|
+
const attribute = attributes[i];
|
|
5964
|
+
const name = attribute && attribute.name;
|
|
5965
|
+
if (typeof name === 'string') {
|
|
5966
|
+
try {
|
|
5967
|
+
root.removeAttribute(name);
|
|
5968
|
+
} catch (_) {
|
|
5969
|
+
/* Clobbered removeAttribute — ignore (fail-closed best effort) */
|
|
5970
|
+
}
|
|
5971
|
+
}
|
|
5972
|
+
}
|
|
5612
5973
|
}
|
|
5613
5974
|
};
|
|
5614
5975
|
/**
|
|
@@ -5643,6 +6004,148 @@ function createDOMPurify() {
|
|
|
5643
6004
|
}
|
|
5644
6005
|
}
|
|
5645
6006
|
};
|
|
6007
|
+
/**
|
|
6008
|
+
* _stripDisallowedAttributes
|
|
6009
|
+
*
|
|
6010
|
+
* Removes every attribute the active configuration does not allow from a
|
|
6011
|
+
* single element, using the same allowlist as the main attribute pass (so
|
|
6012
|
+
* `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
|
|
6013
|
+
* neutralise nodes that are being discarded from an in-place tree.
|
|
6014
|
+
*
|
|
6015
|
+
* @param element the element to strip
|
|
6016
|
+
*/
|
|
6017
|
+
const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
|
|
6018
|
+
const attributes = getAttributes(element);
|
|
6019
|
+
if (!attributes) {
|
|
6020
|
+
return;
|
|
6021
|
+
}
|
|
6022
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
6023
|
+
const attribute = attributes[i];
|
|
6024
|
+
const name = attribute && attribute.name;
|
|
6025
|
+
if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {
|
|
6026
|
+
continue;
|
|
6027
|
+
}
|
|
6028
|
+
try {
|
|
6029
|
+
element.removeAttribute(name);
|
|
6030
|
+
} catch (_) {
|
|
6031
|
+
/* Clobbered removeAttribute on a doomed node — ignore */
|
|
6032
|
+
}
|
|
6033
|
+
}
|
|
6034
|
+
};
|
|
6035
|
+
/**
|
|
6036
|
+
* _neutralizeSubtree
|
|
6037
|
+
*
|
|
6038
|
+
* Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
|
|
6039
|
+
* move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
|
|
6040
|
+
* namespace, comment, processing-instruction and KEEP_CONTENT:false removals
|
|
6041
|
+
* all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
|
|
6042
|
+
* those dropped nodes are detached from the caller's LIVE tree but a
|
|
6043
|
+
* handler-bearing original among them (an `<img onerror>`/`<video>` that was
|
|
6044
|
+
* loading) keeps its queued resource event, which fires in page scope after
|
|
6045
|
+
* sanitize returns. This walks a removed subtree and strips every attribute
|
|
6046
|
+
* the active configuration does not allow — so `on*` handlers are cancelled
|
|
6047
|
+
* through the SAME allowlist that governs kept nodes, not a separate `/^on/`
|
|
6048
|
+
* blocklist. Run synchronously before sanitize returns, i.e. before any
|
|
6049
|
+
* queued event can fire. Hook-free by design: these nodes leave the output,
|
|
6050
|
+
* so firing attribute hooks for them would be surprising. Clobber-safe reads;
|
|
6051
|
+
* a doomed clobbered node may shadow `removeAttribute` (its own attributes are
|
|
6052
|
+
* irrelevant — it is discarded — while its non-clobbered descendants, e.g.
|
|
6053
|
+
* the `<img>`, are reached and scrubbed).
|
|
6054
|
+
*
|
|
6055
|
+
* @param root the root of a removed subtree to neutralise
|
|
6056
|
+
*/
|
|
6057
|
+
const _neutralizeSubtree = function _neutralizeSubtree(root) {
|
|
6058
|
+
const stack = [root];
|
|
6059
|
+
while (stack.length > 0) {
|
|
6060
|
+
const node = stack.pop();
|
|
6061
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
6062
|
+
if (nodeType === NODE_TYPE.element) {
|
|
6063
|
+
_stripDisallowedAttributes(node);
|
|
6064
|
+
}
|
|
6065
|
+
const childNodes = getChildNodes(node);
|
|
6066
|
+
if (childNodes) {
|
|
6067
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
6068
|
+
stack.push(childNodes[i]);
|
|
6069
|
+
}
|
|
6070
|
+
}
|
|
6071
|
+
}
|
|
6072
|
+
};
|
|
6073
|
+
/**
|
|
6074
|
+
* _neutralizePatchLinkage
|
|
6075
|
+
*
|
|
6076
|
+
* IN_PLACE entry pre-pass (declarative-partial-updates / streaming
|
|
6077
|
+
* hardening, https://github.com/WICG/declarative-partial-updates).
|
|
6078
|
+
*
|
|
6079
|
+
* The main walk strips patch linkage (`for`/`patchsrc`) and removes range
|
|
6080
|
+
* markers (PIs / markup comments) node-by-node, in document order, AS it
|
|
6081
|
+
* reaches each node. On a live in-place root that leaves a window: from the
|
|
6082
|
+
* moment the root is connected until the walk arrives at a given node, that
|
|
6083
|
+
* node's linkage is live. A patch applied on connection/stream can fire as
|
|
6084
|
+
* a microtask during the walk and inject or teleport an unsanitized DOM
|
|
6085
|
+
* range into a region the iterator has already passed and will not revisit,
|
|
6086
|
+
* so the post-return "tree is sanitized" contract is violated. Sweep the
|
|
6087
|
+
* whole tree once up front and sever every linkage before the walk begins,
|
|
6088
|
+
* closing that window.
|
|
6089
|
+
*
|
|
6090
|
+
* This CANNOT undo a patch that already fired before sanitize ran — that is
|
|
6091
|
+
* the irreducible "do not IN_PLACE a live-connected attacker tree" caveat —
|
|
6092
|
+
* but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML
|
|
6093
|
+
* to group with the rest of the declarative-partial-updates handling and
|
|
6094
|
+
* stay overridable, consistent with the codebase.
|
|
6095
|
+
*
|
|
6096
|
+
* Clobber-safe traversal (cached childNodes getter); per-node try/catch so a
|
|
6097
|
+
* clobbered root cannot defeat the sweep of its non-clobbered descendants.
|
|
6098
|
+
*
|
|
6099
|
+
* NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe
|
|
6100
|
+
* .html Q1): this mirrors the existing policy of keeping `for` on
|
|
6101
|
+
* <label>/<output>. If the shipping feature can drive a patch through a
|
|
6102
|
+
* surviving `for`-on-label/output + `id` pair, this pre-pass and the
|
|
6103
|
+
* attribute check at _isBasicCustomElement's caller must additionally drop
|
|
6104
|
+
* that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.
|
|
6105
|
+
*
|
|
6106
|
+
* @param root the in-place root to sweep
|
|
6107
|
+
*/
|
|
6108
|
+
const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
|
|
6109
|
+
if (!SAFE_FOR_XML) {
|
|
6110
|
+
return;
|
|
6111
|
+
}
|
|
6112
|
+
const stack = [root];
|
|
6113
|
+
while (stack.length > 0) {
|
|
6114
|
+
const node = stack.pop();
|
|
6115
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
6116
|
+
/* Remove range markers (the target side of a patch linkage): every
|
|
6117
|
+
processing instruction, and any markup-bearing comment. */
|
|
6118
|
+
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
6119
|
+
try {
|
|
6120
|
+
remove(node);
|
|
6121
|
+
} catch (_) {
|
|
6122
|
+
/* Best-effort */
|
|
6123
|
+
}
|
|
6124
|
+
continue;
|
|
6125
|
+
}
|
|
6126
|
+
/* Strip patch-source attributes (the source side) off elements. */
|
|
6127
|
+
if (nodeType === NODE_TYPE.element) {
|
|
6128
|
+
const element = node;
|
|
6129
|
+
const lcTag = transformCaseFunc(getNodeName ? getNodeName(node) : node.nodeName);
|
|
6130
|
+
try {
|
|
6131
|
+
if (element.hasAttribute && element.hasAttribute('patchsrc')) {
|
|
6132
|
+
element.removeAttribute('patchsrc');
|
|
6133
|
+
}
|
|
6134
|
+
if (element.hasAttribute && element.hasAttribute('for') && lcTag !== 'label' && lcTag !== 'output') {
|
|
6135
|
+
element.removeAttribute('for');
|
|
6136
|
+
}
|
|
6137
|
+
} catch (_) {
|
|
6138
|
+
/* Clobbered removeAttribute/hasAttribute on a doomed node — ignore */
|
|
6139
|
+
}
|
|
6140
|
+
}
|
|
6141
|
+
const childNodes = getChildNodes(node);
|
|
6142
|
+
if (childNodes) {
|
|
6143
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
6144
|
+
stack.push(childNodes[i]);
|
|
6145
|
+
}
|
|
6146
|
+
}
|
|
6147
|
+
}
|
|
6148
|
+
};
|
|
5646
6149
|
/**
|
|
5647
6150
|
* _initDocument
|
|
5648
6151
|
*
|
|
@@ -5664,7 +6167,7 @@ function createDOMPurify() {
|
|
|
5664
6167
|
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
5665
6168
|
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
5666
6169
|
}
|
|
5667
|
-
const dirtyPayload = trustedTypesPolicy ?
|
|
6170
|
+
const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
|
|
5668
6171
|
/*
|
|
5669
6172
|
* Use the DOMParser API by default, fallback later if needs be
|
|
5670
6173
|
* DOMParser not work for svg when has multiple root element.
|
|
@@ -5700,33 +6203,297 @@ function createDOMPurify() {
|
|
|
5700
6203
|
* @return The created NodeIterator
|
|
5701
6204
|
*/
|
|
5702
6205
|
const _createNodeIterator = function _createNodeIterator(root) {
|
|
5703
|
-
|
|
6206
|
+
/* Read ownerDocument through the cached Node.prototype getter, never the
|
|
6207
|
+
direct property. HTMLFormElement has [LegacyOverrideBuiltIns], so a
|
|
6208
|
+
clobbering child (<input name="ownerDocument"> or a form-associated
|
|
6209
|
+
external input) shadows the prototype getter and makes a direct read
|
|
6210
|
+
return that <input>. createNodeIterator.call(<input>, ...) then throws
|
|
6211
|
+
"Illegal invocation", and on the IN_PLACE path that throw lands before
|
|
6212
|
+
the walk's fail-closed barrier - leaving the caller's live tree, with
|
|
6213
|
+
any already-armed handler in it, un-neutralized. The cached getter
|
|
6214
|
+
returns the real Document regardless of the clobber. */
|
|
6215
|
+
const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
|
|
6216
|
+
return createNodeIterator.call(doc || root, root,
|
|
5704
6217
|
// eslint-disable-next-line no-bitwise
|
|
5705
6218
|
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
5706
6219
|
};
|
|
6220
|
+
/**
|
|
6221
|
+
* Replace template expression syntax (mustache, ERB, template
|
|
6222
|
+
* literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
|
|
6223
|
+
* sites. Order matters: mustache, then ERB, then template literal.
|
|
6224
|
+
*
|
|
6225
|
+
* @param value the string to scrub
|
|
6226
|
+
* @returns the scrubbed string
|
|
6227
|
+
*/
|
|
6228
|
+
const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
|
|
6229
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
|
|
6230
|
+
value = stringReplace(value, ERB_EXPR$1, ' ');
|
|
6231
|
+
value = stringReplace(value, TMPLIT_EXPR$1, ' ');
|
|
6232
|
+
return value;
|
|
6233
|
+
};
|
|
6234
|
+
/**
|
|
6235
|
+
* Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
|
|
6236
|
+
* character data of an element subtree. Used as the final safety net for
|
|
6237
|
+
* SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
|
|
6238
|
+
* which only form after text-node normalization (e.g. fragments split across
|
|
6239
|
+
* stripped elements) cannot survive into a template-evaluating framework.
|
|
6240
|
+
*
|
|
6241
|
+
* Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
|
|
6242
|
+
* in place rather than round-tripping through innerHTML. This preserves
|
|
6243
|
+
* descendant node references (important for IN_PLACE callers), avoids a
|
|
6244
|
+
* serialize/reparse cycle, and reads literal character data — which means
|
|
6245
|
+
* `<%...%>` in text content matches the ERB regex against its real bytes
|
|
6246
|
+
* instead of the HTML-entity-escaped form innerHTML would produce.
|
|
6247
|
+
*
|
|
6248
|
+
* Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
|
|
6249
|
+
* attributes is performed during the per-node `_sanitizeAttributes` pass.
|
|
6250
|
+
*
|
|
6251
|
+
* @param node The root element whose character data should be scrubbed.
|
|
6252
|
+
*/
|
|
6253
|
+
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
6254
|
+
var _node$querySelectorAl;
|
|
6255
|
+
node.normalize();
|
|
6256
|
+
/* Clobber-safe ownerDocument read, same reasoning as _createNodeIterator:
|
|
6257
|
+
under SAFE_FOR_TEMPLATES this runs on the live IN_PLACE root, which may
|
|
6258
|
+
carry a form-named-getter override of ownerDocument. */
|
|
6259
|
+
const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
|
|
6260
|
+
const walker = createNodeIterator.call(doc || node, node,
|
|
6261
|
+
// eslint-disable-next-line no-bitwise
|
|
6262
|
+
NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
|
|
6263
|
+
let currentNode = walker.nextNode();
|
|
6264
|
+
while (currentNode) {
|
|
6265
|
+
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
6266
|
+
currentNode = walker.nextNode();
|
|
6267
|
+
}
|
|
6268
|
+
// NodeIterator does not descend into <template>.content per the DOM spec,
|
|
6269
|
+
// so we must explicitly recurse into each template's content fragment,
|
|
6270
|
+
// mirroring the approach used by _sanitizeShadowDOM.
|
|
6271
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');
|
|
6272
|
+
if (templates) {
|
|
6273
|
+
arrayForEach(templates, tmpl => {
|
|
6274
|
+
if (_isDocumentFragment(tmpl.content)) {
|
|
6275
|
+
_scrubTemplateExpressions2(tmpl.content);
|
|
6276
|
+
}
|
|
6277
|
+
});
|
|
6278
|
+
}
|
|
6279
|
+
};
|
|
5707
6280
|
/**
|
|
5708
6281
|
* _isClobbered
|
|
5709
6282
|
*
|
|
6283
|
+
* Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
|
|
6284
|
+
* interface with [LegacyOverrideBuiltIns]; a descendant element with a
|
|
6285
|
+
* `name` attribute matching a prototype property shadows that property
|
|
6286
|
+
* on direct reads. We use this check at the IN_PLACE entry-point and
|
|
6287
|
+
* during attribute sanitization to refuse clobbered forms.
|
|
6288
|
+
*
|
|
5710
6289
|
* @param element element to check for clobbering attacks
|
|
5711
6290
|
* @return true if clobbered, false if safe
|
|
5712
6291
|
*/
|
|
5713
6292
|
const _isClobbered = function _isClobbered(element) {
|
|
5714
|
-
|
|
6293
|
+
// Realm-independent tag-name probe. If we can't determine the tag
|
|
6294
|
+
// name at all, we can't reason about clobbering — return false
|
|
6295
|
+
// (the caller's other defences still apply).
|
|
6296
|
+
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
6297
|
+
if (typeof realTagName !== 'string') {
|
|
6298
|
+
return false;
|
|
6299
|
+
}
|
|
6300
|
+
if (transformCaseFunc(realTagName) !== 'form') {
|
|
6301
|
+
return false;
|
|
6302
|
+
}
|
|
6303
|
+
return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
|
|
6304
|
+
// Realm-safe NamedNodeMap detection: equality against the cached
|
|
6305
|
+
// prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
|
|
6306
|
+
// makes the direct read diverge from the cached read; a clean form
|
|
6307
|
+
// (same-realm OR foreign-realm) has both reads pointing at the same
|
|
6308
|
+
// canonical NamedNodeMap.
|
|
6309
|
+
element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
|
|
6310
|
+
// NodeType clobbering probe. Cached Node.prototype.nodeType getter
|
|
6311
|
+
// returns the integer 1 for any Element regardless of realm; direct
|
|
6312
|
+
// read on a clobbered form (e.g. <input name="nodeType">) returns
|
|
6313
|
+
// the named child element. Cheap addition — nodeType is read from
|
|
6314
|
+
// an internal slot, no serialization cost — and removes a residual
|
|
6315
|
+
// clobbering surface used by several mXSS / PI / comment branches
|
|
6316
|
+
// in _sanitizeElements that compare currentNode.nodeType directly.
|
|
6317
|
+
element.nodeType !== getNodeType(element) ||
|
|
6318
|
+
// HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
|
|
6319
|
+
// "childNodes" shadows the prototype getter. Direct reads of
|
|
6320
|
+
// form.childNodes from a clobbered form return the named child
|
|
6321
|
+
// instead of the real NodeList, so any walk that reads it directly
|
|
6322
|
+
// skips the form's real children. Compare the direct read to the
|
|
6323
|
+
// cached Node.prototype getter — when the form's named-property
|
|
6324
|
+
// getter intercepts the read, the two values differ and we flag
|
|
6325
|
+
// the form. This catches every clobbering child type (input,
|
|
6326
|
+
// select, etc.) regardless of whether the named child happens to
|
|
6327
|
+
// carry a numeric .length, which a typeof-based probe would miss
|
|
6328
|
+
// (e.g. HTMLSelectElement.length is a defined unsigned-long).
|
|
6329
|
+
element.childNodes !== getChildNodes(element);
|
|
6330
|
+
};
|
|
6331
|
+
/**
|
|
6332
|
+
* Checks whether the given value is a DocumentFragment from any realm.
|
|
6333
|
+
*
|
|
6334
|
+
* The realm-independent replacement reads `nodeType` through the cached
|
|
6335
|
+
* Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
|
|
6336
|
+
* constant (11). nodeType is a numeric value resolved from the node's
|
|
6337
|
+
* internal slot, identical across realms for the same kind of node.
|
|
6338
|
+
*
|
|
6339
|
+
* @param value object to check
|
|
6340
|
+
* @return true if value is a DocumentFragment-shaped node from any realm
|
|
6341
|
+
*/
|
|
6342
|
+
const _isDocumentFragment = function _isDocumentFragment(value) {
|
|
6343
|
+
if (!getNodeType || typeof value !== 'object' || value === null) {
|
|
6344
|
+
return false;
|
|
6345
|
+
}
|
|
6346
|
+
try {
|
|
6347
|
+
return getNodeType(value) === NODE_TYPE.documentFragment;
|
|
6348
|
+
} catch (_) {
|
|
6349
|
+
return false;
|
|
6350
|
+
}
|
|
5715
6351
|
};
|
|
5716
6352
|
/**
|
|
5717
|
-
* Checks whether the given object is a DOM node
|
|
6353
|
+
* Checks whether the given object is a DOM node, including nodes that
|
|
6354
|
+
* originate from a different window/realm (e.g. an iframe's
|
|
6355
|
+
* contentDocument). The previous `value instanceof Node` check was
|
|
6356
|
+
* realm-bound: nodes from a different window failed it, causing
|
|
6357
|
+
* sanitize() to silently stringify them and reset IN_PLACE to false,
|
|
6358
|
+
* returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
|
|
5718
6359
|
*
|
|
5719
6360
|
* @param value object to check whether it's a DOM node
|
|
5720
|
-
* @return true
|
|
6361
|
+
* @return true if value is a DOM node from any realm
|
|
5721
6362
|
*/
|
|
5722
6363
|
const _isNode = function _isNode(value) {
|
|
5723
|
-
|
|
6364
|
+
if (!getNodeType || typeof value !== 'object' || value === null) {
|
|
6365
|
+
return false;
|
|
6366
|
+
}
|
|
6367
|
+
try {
|
|
6368
|
+
return typeof getNodeType(value) === 'number';
|
|
6369
|
+
} catch (_) {
|
|
6370
|
+
return false;
|
|
6371
|
+
}
|
|
5724
6372
|
};
|
|
5725
6373
|
function _executeHooks(hooks, currentNode, data) {
|
|
6374
|
+
if (hooks.length === 0) {
|
|
6375
|
+
return;
|
|
6376
|
+
}
|
|
5726
6377
|
arrayForEach(hooks, hook => {
|
|
5727
6378
|
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
5728
6379
|
});
|
|
5729
6380
|
}
|
|
6381
|
+
/**
|
|
6382
|
+
* Structural-threat checks that condemn a node regardless of the
|
|
6383
|
+
* allowlists: mXSS via namespace confusion, risky CSS construction,
|
|
6384
|
+
* processing instructions, markup-bearing comments. Pure predicate;
|
|
6385
|
+
* the caller removes. Check order is load-bearing.
|
|
6386
|
+
*
|
|
6387
|
+
* @param currentNode the node to inspect
|
|
6388
|
+
* @param tagName the node's transformCaseFunc'd tag name
|
|
6389
|
+
* @return true if the node must be removed
|
|
6390
|
+
*/
|
|
6391
|
+
const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
|
|
6392
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
6393
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
|
|
6394
|
+
return true;
|
|
6395
|
+
}
|
|
6396
|
+
/* Remove risky CSS construction leading to mXSS */
|
|
6397
|
+
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
|
|
6398
|
+
return true;
|
|
6399
|
+
}
|
|
6400
|
+
/* Remove any occurrence of processing instructions */
|
|
6401
|
+
if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
|
|
6402
|
+
return true;
|
|
6403
|
+
}
|
|
6404
|
+
/* Remove any kind of possibly harmful comments */
|
|
6405
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
|
|
6406
|
+
return true;
|
|
6407
|
+
}
|
|
6408
|
+
return false;
|
|
6409
|
+
};
|
|
6410
|
+
/**
|
|
6411
|
+
* Handle a node whose tag is forbidden or not allowlisted: keep
|
|
6412
|
+
* allowed custom elements (false return exits _sanitizeElements
|
|
6413
|
+
* early - the namespace and fallback-tag removal checks are
|
|
6414
|
+
* intentionally skipped for kept custom elements), else hoist
|
|
6415
|
+
* content per KEEP_CONTENT and remove.
|
|
6416
|
+
*
|
|
6417
|
+
* A kept custom element is the ONLY case in which this function
|
|
6418
|
+
* returns false, so the caller uses that return value to run the
|
|
6419
|
+
* afterSanitizeElements hook on the kept element and keep the
|
|
6420
|
+
* element-hook lifecycle consistent with normal allowlisted
|
|
6421
|
+
* elements (GHSA-c2j3-45gr-mqc4).
|
|
6422
|
+
*
|
|
6423
|
+
* @param currentNode the disallowed node
|
|
6424
|
+
* @param tagName the node's transformCaseFunc'd tag name
|
|
6425
|
+
* @return true if the node was removed, false if kept
|
|
6426
|
+
*/
|
|
6427
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
|
|
6428
|
+
/* Check if we have a custom element to handle */
|
|
6429
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
6430
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
6431
|
+
return false;
|
|
6432
|
+
}
|
|
6433
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
6434
|
+
return false;
|
|
6435
|
+
}
|
|
6436
|
+
}
|
|
6437
|
+
/* Keep content except for bad-listed elements.
|
|
6438
|
+
Use the cached prototype getters exclusively — the previous code
|
|
6439
|
+
had `|| currentNode.parentNode` / `|| currentNode.childNodes`
|
|
6440
|
+
fallbacks, but the cached getters always return the canonical
|
|
6441
|
+
value (or null for a real parent-less node), so the fallback
|
|
6442
|
+
path was dead in safe cases and a clobbering surface in unsafe
|
|
6443
|
+
ones. Falsy cached results stay falsy; the `if (childNodes &&
|
|
6444
|
+
parentNode)` check already gates correctly. */
|
|
6445
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
6446
|
+
const parentNode = getParentNode(currentNode);
|
|
6447
|
+
const childNodes = getChildNodes(currentNode);
|
|
6448
|
+
if (childNodes && parentNode) {
|
|
6449
|
+
const childCount = childNodes.length;
|
|
6450
|
+
/* Hoist by moving each child up one level rather than deep-cloning
|
|
6451
|
+
it. Moving transfers every descendant exactly once, so a chain of
|
|
6452
|
+
nested disallowed elements costs O(n) instead of the O(n^2) that
|
|
6453
|
+
re-cloning the shrinking subtree at each level produced; it also
|
|
6454
|
+
empties the removed original, so `DOMPurify.removed` no longer
|
|
6455
|
+
pins whole subtrees. Moving preserves the in-place guarantee too:
|
|
6456
|
+
an original carrying already-queued resource events (`<img
|
|
6457
|
+
onerror>`, `<video>`/`<audio>` error, lazy/`onload`, …) is
|
|
6458
|
+
relocated and sanitised rather than left detached but still armed.
|
|
6459
|
+
The sole case that must clone is removing the walk root itself.
|
|
6460
|
+
The result is serialised from the root's subtree, so a restrictive
|
|
6461
|
+
ALLOWED_TAGS that strips the root (`body` on the string path) must
|
|
6462
|
+
leave the content inside it, which only cloning does. In IN_PLACE
|
|
6463
|
+
the root is pre-validated as an allowed tag and so is never removed
|
|
6464
|
+
here, so that path always takes the move branch.
|
|
6465
|
+
`childNodes` is live; a tail-to-head walk keeps `childNodes[i]`
|
|
6466
|
+
valid whether we move (drops the trailing entry) or clone (leaves
|
|
6467
|
+
the list intact). */
|
|
6468
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
6469
|
+
const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
|
|
6470
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
6471
|
+
}
|
|
6472
|
+
}
|
|
6473
|
+
}
|
|
6474
|
+
_forceRemove(currentNode);
|
|
6475
|
+
return true;
|
|
6476
|
+
};
|
|
6477
|
+
/**
|
|
6478
|
+
* Fork a hook-mutable allowlist off its shared binding the first time a
|
|
6479
|
+
* (possibly lazily-installed) uponSanitize* hook is about to see it, so the
|
|
6480
|
+
* hook cannot widen the per-instance default or the setConfig binding by
|
|
6481
|
+
* reference and leak past the call. Returns the set unchanged once it is
|
|
6482
|
+
* already call-local, so repeated calls across elements are idempotent.
|
|
6483
|
+
*
|
|
6484
|
+
* @param hookList the uponSanitize* hook array for this event
|
|
6485
|
+
* @param set the current ALLOWED_TAGS / ALLOWED_ATTR binding
|
|
6486
|
+
* @param defaultSet the per-instance DEFAULT_ALLOWED_* constant
|
|
6487
|
+
* @param setConfigSet the captured setConfig() binding, or null
|
|
6488
|
+
* @return a call-local clone if a hook is present and set is still shared,
|
|
6489
|
+
* else set unchanged
|
|
6490
|
+
*/
|
|
6491
|
+
const _forkSharedAllowlist = function _forkSharedAllowlist(hookList, set, defaultSet, setConfigSet) {
|
|
6492
|
+
if (hookList.length === 0) {
|
|
6493
|
+
return set;
|
|
6494
|
+
}
|
|
6495
|
+
return set === defaultSet || set === setConfigSet ? clone(set) : set;
|
|
6496
|
+
};
|
|
5730
6497
|
/**
|
|
5731
6498
|
* _sanitizeElements
|
|
5732
6499
|
*
|
|
@@ -5736,81 +6503,112 @@ function createDOMPurify() {
|
|
|
5736
6503
|
* @param currentNode to check for permission to exist
|
|
5737
6504
|
* @return true if node was killed, false if left alive
|
|
5738
6505
|
*/
|
|
5739
|
-
|
|
5740
|
-
|
|
6506
|
+
// eslint-disable-next-line complexity
|
|
6507
|
+
const _sanitizeElements = function _sanitizeElements(currentNode, root) {
|
|
5741
6508
|
/* Execute a hook if present */
|
|
5742
6509
|
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
6510
|
+
/* A hook may have detached the node - treat it as removed (see the
|
|
6511
|
+
detached-node comment after the uponSanitizeElement hook below). On
|
|
6512
|
+
the IN_PLACE path, neutralize the detached subtree first so a queued
|
|
6513
|
+
resource handler on it cannot fire in page scope after we return. */
|
|
6514
|
+
if (currentNode !== root && getParentNode(currentNode) === null) {
|
|
6515
|
+
if (IN_PLACE) {
|
|
6516
|
+
_neutralizeSubtree(currentNode);
|
|
6517
|
+
}
|
|
6518
|
+
return true;
|
|
6519
|
+
}
|
|
5743
6520
|
/* Check if element is clobbered or can clobber */
|
|
5744
6521
|
if (_isClobbered(currentNode)) {
|
|
5745
6522
|
_forceRemove(currentNode);
|
|
5746
6523
|
return true;
|
|
5747
6524
|
}
|
|
5748
6525
|
/* Now let's check the element's type and name */
|
|
5749
|
-
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
6526
|
+
const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
|
|
6527
|
+
/* Close the pre-walk clone-guard's timing gap: an uponSanitizeElement
|
|
6528
|
+
hook may have been installed after that guard sampled the hook arrays
|
|
6529
|
+
(e.g. lazily from beforeSanitizeElements), leaving ALLOWED_TAGS still
|
|
6530
|
+
aliasing a shared binding that a widening hook would mutate by
|
|
6531
|
+
reference. Fork it before exposing it to the hook. */
|
|
6532
|
+
ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
|
|
5750
6533
|
/* Execute a hook if present */
|
|
5751
6534
|
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
5752
6535
|
tagName,
|
|
5753
6536
|
allowedTags: ALLOWED_TAGS
|
|
5754
6537
|
});
|
|
5755
|
-
/*
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
6538
|
+
/* A hook may have detached the node from the tree — a long-standing
|
|
6539
|
+
user pattern (issue #469; draw.io-style foreignObject filtering).
|
|
6540
|
+
Per the cached, unclobberable parentNode getter the node is
|
|
6541
|
+
genuinely out of the tree, so it can reach neither the serialized
|
|
6542
|
+
output nor an IN_PLACE live tree; treat it as removed and stop
|
|
6543
|
+
processing it. Without this guard, the unsafe-node / namespace
|
|
6544
|
+
checks below would call _forceRemove on a parentless node and hit
|
|
6545
|
+
the REPORT-3 fail-closed throw — which exists for nodes DOMPurify
|
|
6546
|
+
wants gone but *cannot* detach (clobbered / parentless roots), the
|
|
6547
|
+
opposite of a node that is already safely gone. The walk root is
|
|
6548
|
+
exempt: a detached IN_PLACE root is legitimate input and must still
|
|
6549
|
+
be fully sanitized, and a kill-decision on it must keep hitting the
|
|
6550
|
+
REPORT-3 throw. Nodes detached by hooks stay the hook's
|
|
6551
|
+
responsibility for placement: they are not recorded in
|
|
6552
|
+
DOMPurify.removed, so the post-walk IN_PLACE pass (which iterates
|
|
6553
|
+
DOMPurify.removed) does not reach them. But a hook-detached subtree
|
|
6554
|
+
can still hold a queued resource-event handler - e.g. an <img onload>
|
|
6555
|
+
that began loading when the caller built the live tree - which fires
|
|
6556
|
+
in page scope after sanitize returns even though the handler never
|
|
6557
|
+
reached the returned tree. That is the audit-5 F1 hazard, and the
|
|
6558
|
+
documented node.remove() hook pattern walks straight into it. So on
|
|
6559
|
+
the IN_PLACE path we neutralize the detached subtree inline here,
|
|
6560
|
+
stripping its non-allow-listed attributes before returning, exactly
|
|
6561
|
+
as the post-walk pass does for _forceRemove'd subtrees. */
|
|
6562
|
+
if (currentNode !== root && getParentNode(currentNode) === null) {
|
|
6563
|
+
if (IN_PLACE) {
|
|
6564
|
+
_neutralizeSubtree(currentNode);
|
|
6565
|
+
}
|
|
5763
6566
|
return true;
|
|
5764
6567
|
}
|
|
5765
|
-
/* Remove
|
|
5766
|
-
if (
|
|
6568
|
+
/* Remove mXSS vectors, processing instructions and risky comments */
|
|
6569
|
+
if (_isUnsafeNode(currentNode, tagName)) {
|
|
5767
6570
|
_forceRemove(currentNode);
|
|
5768
6571
|
return true;
|
|
5769
6572
|
}
|
|
5770
6573
|
/* Remove element if anything forbids its presence */
|
|
5771
|
-
if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) &&
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
const childCount = childNodes.length;
|
|
5787
|
-
for (let i = childCount - 1; i >= 0; --i) {
|
|
5788
|
-
const childClone = cloneNode(childNodes[i], true);
|
|
5789
|
-
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
|
5790
|
-
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
5791
|
-
}
|
|
5792
|
-
}
|
|
6574
|
+
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
6575
|
+
const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
|
|
6576
|
+
/* A false return means the node is a custom element kept via
|
|
6577
|
+
CUSTOM_ELEMENT_HANDLING - the only keep path through
|
|
6578
|
+
_sanitizeDisallowedNode. Run afterSanitizeElements on it so the
|
|
6579
|
+
element-hook lifecycle matches normal allowlisted elements: a
|
|
6580
|
+
security policy applied in this hook (e.g. stripping an attribute
|
|
6581
|
+
from every surviving element) must not silently skip kept custom
|
|
6582
|
+
elements (GHSA-c2j3-45gr-mqc4). This mirrors the normal-element
|
|
6583
|
+
tail below - the hook runs, then the walker's subsequent
|
|
6584
|
+
_sanitizeAttributes pass sanitizes the element's attributes. The
|
|
6585
|
+
deliberately skipped namespace and fallback-tag removal checks stay
|
|
6586
|
+
skipped; they are removal decisions, not the hook contract. */
|
|
6587
|
+
if (removed === false) {
|
|
6588
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
5793
6589
|
}
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
6590
|
+
return removed;
|
|
6591
|
+
}
|
|
6592
|
+
/* Check whether element has a valid namespace.
|
|
6593
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
|
|
6594
|
+
nodeType getter rather than `instanceof Element`, which is realm-
|
|
6595
|
+
bound and short-circuits to false for any node minted in a different
|
|
6596
|
+
realm — letting a foreign-realm element with a forbidden namespace
|
|
6597
|
+
slip past the namespace check entirely. */
|
|
6598
|
+
const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
|
|
6599
|
+
if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
5799
6600
|
_forceRemove(currentNode);
|
|
5800
6601
|
return true;
|
|
5801
6602
|
}
|
|
5802
6603
|
/* Make sure that older browsers don't get fallback-tag mXSS */
|
|
5803
|
-
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(
|
|
6604
|
+
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
5804
6605
|
_forceRemove(currentNode);
|
|
5805
6606
|
return true;
|
|
5806
6607
|
}
|
|
5807
6608
|
/* Sanitize element content to be template-safe */
|
|
5808
6609
|
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
5809
6610
|
/* Get the element's text content */
|
|
5810
|
-
content = currentNode.textContent;
|
|
5811
|
-
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
5812
|
-
content = stringReplace(content, expr, ' ');
|
|
5813
|
-
});
|
|
6611
|
+
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
5814
6612
|
if (currentNode.textContent !== content) {
|
|
5815
6613
|
arrayPush(DOMPurify.removed, {
|
|
5816
6614
|
element: currentNode.cloneNode()
|
|
@@ -5832,15 +6630,47 @@ function createDOMPurify() {
|
|
|
5832
6630
|
*/
|
|
5833
6631
|
// eslint-disable-next-line complexity
|
|
5834
6632
|
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
6633
|
+
/* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
|
|
6634
|
+
if (FORBID_ATTR[lcName]) {
|
|
6635
|
+
return false;
|
|
6636
|
+
}
|
|
6637
|
+
/* Reject declarative-partial-updates patch-linkage attributes
|
|
6638
|
+
(https://github.com/WICG/declarative-partial-updates).
|
|
6639
|
+
Empirical note (Chrome 150, verified — see
|
|
6640
|
+
test/declarative-patch-probe-v3.html): expansion is NOT applied after
|
|
6641
|
+
sanitization. For the string path it fires during sanitize()'s own
|
|
6642
|
+
parse, so the walk sees and sanitizes the fully materialized expanded
|
|
6643
|
+
tree — teleports into MathML/SVG integration points included; a
|
|
6644
|
+
weaponized `<template for>`->`<img onerror>` comes back with the handler
|
|
6645
|
+
stripped. For the IN_PLACE path it fires on connection, before the walk.
|
|
6646
|
+
Either way DOMPurify is NOT blind to the patch.
|
|
6647
|
+
This removal is therefore defense-in-depth rather than the sole barrier:
|
|
6648
|
+
it prevents live linkage from surviving into the OUTPUT and re-expanding
|
|
6649
|
+
in the caller's context, and keeps behaviour deterministic if a future
|
|
6650
|
+
engine defers expansion. `for` is legitimate only on <label>/<output>;
|
|
6651
|
+
anywhere else (notably <template for>) it links the element to a patch
|
|
6652
|
+
target and teleports or removes an arbitrary DOM range by id/marker name.
|
|
6653
|
+
`patchsrc` fetches remote markup and is treated as a script-loading
|
|
6654
|
+
mechanism (CSP). Gated on SAFE_FOR_XML so the removal groups with the
|
|
6655
|
+
other structural-threat checks and stays overridable, consistent with
|
|
6656
|
+
the rest of the codebase. PI range markers are already removed by
|
|
6657
|
+
_isUnsafeNode. */
|
|
6658
|
+
if (SAFE_FOR_XML && lcName === 'patchsrc') {
|
|
6659
|
+
return false;
|
|
6660
|
+
}
|
|
6661
|
+
if (SAFE_FOR_XML && lcName === 'for' && lcTag !== 'label' && lcTag !== 'output') {
|
|
6662
|
+
return false;
|
|
6663
|
+
}
|
|
5835
6664
|
/* Make sure attribute cannot clobber */
|
|
5836
6665
|
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
5837
6666
|
return false;
|
|
5838
6667
|
}
|
|
6668
|
+
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
5839
6669
|
/* Allow valid data-* attributes: At least one character after "-"
|
|
5840
6670
|
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
5841
6671
|
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
5842
6672
|
We don't need to check the value; it's always URI safe. */
|
|
5843
|
-
if (ALLOW_DATA_ATTR &&
|
|
6673
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted) {
|
|
5844
6674
|
if (
|
|
5845
6675
|
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
5846
6676
|
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
@@ -5852,11 +6682,15 @@ function createDOMPurify() {
|
|
|
5852
6682
|
return false;
|
|
5853
6683
|
}
|
|
5854
6684
|
/* Check value is safe. First, is attr inert? If so, is safe */
|
|
5855
|
-
} 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) {
|
|
6685
|
+
} else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1$1, ''))) ; 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$1, stringReplace(value, ATTR_WHITESPACE$1$1, ''))) ; else if (value) {
|
|
5856
6686
|
return false;
|
|
5857
6687
|
} else ;
|
|
5858
6688
|
return true;
|
|
5859
6689
|
};
|
|
6690
|
+
/* Names the HTML spec reserves from valid-custom-element-name; these must
|
|
6691
|
+
* never be treated as basic custom elements even when a permissive
|
|
6692
|
+
* CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
|
|
6693
|
+
const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ['annotation-xml', 'color-profile', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'missing-glyph']);
|
|
5860
6694
|
/**
|
|
5861
6695
|
* _isBasicCustomElement
|
|
5862
6696
|
* checks if at least one dash is included in tagName, and it's not the first char
|
|
@@ -5866,7 +6700,64 @@ function createDOMPurify() {
|
|
|
5866
6700
|
* @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
|
5867
6701
|
*/
|
|
5868
6702
|
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
5869
|
-
return tagName
|
|
6703
|
+
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
6704
|
+
};
|
|
6705
|
+
/**
|
|
6706
|
+
* Wrap an attribute value in the matching Trusted Types object when
|
|
6707
|
+
* the active policy requires it. Namespaced attributes pass through
|
|
6708
|
+
* unchanged (no TT support yet, see
|
|
6709
|
+
* https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
|
|
6710
|
+
*
|
|
6711
|
+
* @param lcTag lowercase tag name of the containing element
|
|
6712
|
+
* @param lcName lowercase attribute name
|
|
6713
|
+
* @param namespaceURI the attribute's namespace, if any
|
|
6714
|
+
* @param value the attribute value to wrap
|
|
6715
|
+
* @return the value, wrapped when Trusted Types demand it
|
|
6716
|
+
*/
|
|
6717
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
|
|
6718
|
+
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {
|
|
6719
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
6720
|
+
case 'TrustedHTML':
|
|
6721
|
+
{
|
|
6722
|
+
return _createTrustedHTML(value);
|
|
6723
|
+
}
|
|
6724
|
+
case 'TrustedScriptURL':
|
|
6725
|
+
{
|
|
6726
|
+
return _createTrustedScriptURL(value);
|
|
6727
|
+
}
|
|
6728
|
+
}
|
|
6729
|
+
}
|
|
6730
|
+
return value;
|
|
6731
|
+
};
|
|
6732
|
+
/**
|
|
6733
|
+
* Write a modified attribute value back onto the element. On
|
|
6734
|
+
* success, re-probe for clobbering introduced by the new value and
|
|
6735
|
+
* remove the element when found; otherwise pop the removal entry
|
|
6736
|
+
* recorded by the earlier _removeAttribute (long-standing pairing
|
|
6737
|
+
* with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
|
|
6738
|
+
* failure, remove the attribute instead.
|
|
6739
|
+
*
|
|
6740
|
+
* @param currentNode the element carrying the attribute
|
|
6741
|
+
* @param name the attribute name as present on the element
|
|
6742
|
+
* @param namespaceURI the attribute's namespace, if any
|
|
6743
|
+
* @param value the new attribute value
|
|
6744
|
+
*/
|
|
6745
|
+
const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
|
|
6746
|
+
try {
|
|
6747
|
+
if (namespaceURI) {
|
|
6748
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
6749
|
+
} else {
|
|
6750
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
6751
|
+
currentNode.setAttribute(name, value);
|
|
6752
|
+
}
|
|
6753
|
+
if (_isClobbered(currentNode)) {
|
|
6754
|
+
_forceRemove(currentNode);
|
|
6755
|
+
} else {
|
|
6756
|
+
arrayPop(DOMPurify.removed);
|
|
6757
|
+
}
|
|
6758
|
+
} catch (_) {
|
|
6759
|
+
_removeAttribute(name, currentNode);
|
|
6760
|
+
}
|
|
5870
6761
|
};
|
|
5871
6762
|
/**
|
|
5872
6763
|
* _sanitizeAttributes
|
|
@@ -5881,13 +6772,14 @@ function createDOMPurify() {
|
|
|
5881
6772
|
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
5882
6773
|
/* Execute a hook if present */
|
|
5883
6774
|
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
5884
|
-
const
|
|
5885
|
-
attributes
|
|
5886
|
-
} = currentNode;
|
|
6775
|
+
const attributes = currentNode.attributes;
|
|
5887
6776
|
/* Check if we have attributes; if not we might have a text node */
|
|
5888
6777
|
if (!attributes || _isClobbered(currentNode)) {
|
|
5889
6778
|
return;
|
|
5890
6779
|
}
|
|
6780
|
+
/* Same lazy-install guard as uponSanitizeElement (see there): fork the
|
|
6781
|
+
attribute allowlist off its shared binding before a hook can see it. */
|
|
6782
|
+
ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
|
|
5891
6783
|
const hookEvent = {
|
|
5892
6784
|
attrName: '',
|
|
5893
6785
|
attrValue: '',
|
|
@@ -5896,14 +6788,13 @@ function createDOMPurify() {
|
|
|
5896
6788
|
forceKeepAttr: undefined
|
|
5897
6789
|
};
|
|
5898
6790
|
let l = attributes.length;
|
|
6791
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
5899
6792
|
/* Go backwards over all attributes; safely remove bad ones */
|
|
5900
6793
|
while (l--) {
|
|
5901
6794
|
const attr = attributes[l];
|
|
5902
|
-
const
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
value: attrValue
|
|
5906
|
-
} = attr;
|
|
6795
|
+
const name = attr.name,
|
|
6796
|
+
namespaceURI = attr.namespaceURI,
|
|
6797
|
+
attrValue = attr.value;
|
|
5907
6798
|
const lcName = transformCaseFunc(name);
|
|
5908
6799
|
const initValue = attrValue;
|
|
5909
6800
|
let value = name === 'value' ? initValue : stringTrim(initValue);
|
|
@@ -5917,14 +6808,16 @@ function createDOMPurify() {
|
|
|
5917
6808
|
/* Full DOM Clobbering protection via namespace isolation,
|
|
5918
6809
|
* Prefix id and name attributes with `user-content-`
|
|
5919
6810
|
*/
|
|
5920
|
-
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
6811
|
+
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
5921
6812
|
// Remove the attribute with this value
|
|
5922
6813
|
_removeAttribute(name, currentNode);
|
|
5923
6814
|
// Prefix the value and later re-create the attribute with the sanitized value
|
|
5924
6815
|
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
5925
6816
|
}
|
|
6817
|
+
// Else: already prefixed, leave the attribute alone — the prefix is
|
|
6818
|
+
// itself the clobbering protection, and re-applying it is incorrect.
|
|
5926
6819
|
/* Work around a security issue with comments inside attributes */
|
|
5927
|
-
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, value)) {
|
|
6820
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
|
5928
6821
|
_removeAttribute(name, currentNode);
|
|
5929
6822
|
continue;
|
|
5930
6823
|
}
|
|
@@ -5933,7 +6826,7 @@ function createDOMPurify() {
|
|
|
5933
6826
|
_removeAttribute(name, currentNode);
|
|
5934
6827
|
continue;
|
|
5935
6828
|
}
|
|
5936
|
-
/* Did the hooks
|
|
6829
|
+
/* Did the hooks force-keep the attribute? */
|
|
5937
6830
|
if (hookEvent.forceKeepAttr) {
|
|
5938
6831
|
continue;
|
|
5939
6832
|
}
|
|
@@ -5943,56 +6836,24 @@ function createDOMPurify() {
|
|
|
5943
6836
|
continue;
|
|
5944
6837
|
}
|
|
5945
6838
|
/* Work around a security issue in jQuery 3.0 */
|
|
5946
|
-
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(
|
|
6839
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
5947
6840
|
_removeAttribute(name, currentNode);
|
|
5948
6841
|
continue;
|
|
5949
6842
|
}
|
|
5950
6843
|
/* Sanitize attribute content to be template-safe */
|
|
5951
6844
|
if (SAFE_FOR_TEMPLATES) {
|
|
5952
|
-
|
|
5953
|
-
value = stringReplace(value, expr, ' ');
|
|
5954
|
-
});
|
|
6845
|
+
value = _stripTemplateExpressions(value);
|
|
5955
6846
|
}
|
|
5956
6847
|
/* Is `value` valid for this attribute? */
|
|
5957
|
-
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
5958
6848
|
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
5959
6849
|
_removeAttribute(name, currentNode);
|
|
5960
6850
|
continue;
|
|
5961
6851
|
}
|
|
5962
6852
|
/* Handle attributes that require Trusted Types */
|
|
5963
|
-
|
|
5964
|
-
if (namespaceURI) ; else {
|
|
5965
|
-
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
5966
|
-
case 'TrustedHTML':
|
|
5967
|
-
{
|
|
5968
|
-
value = trustedTypesPolicy.createHTML(value);
|
|
5969
|
-
break;
|
|
5970
|
-
}
|
|
5971
|
-
case 'TrustedScriptURL':
|
|
5972
|
-
{
|
|
5973
|
-
value = trustedTypesPolicy.createScriptURL(value);
|
|
5974
|
-
break;
|
|
5975
|
-
}
|
|
5976
|
-
}
|
|
5977
|
-
}
|
|
5978
|
-
}
|
|
6853
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
5979
6854
|
/* Handle invalid data-* attribute set by try-catching it */
|
|
5980
6855
|
if (value !== initValue) {
|
|
5981
|
-
|
|
5982
|
-
if (namespaceURI) {
|
|
5983
|
-
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
5984
|
-
} else {
|
|
5985
|
-
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
5986
|
-
currentNode.setAttribute(name, value);
|
|
5987
|
-
}
|
|
5988
|
-
if (_isClobbered(currentNode)) {
|
|
5989
|
-
_forceRemove(currentNode);
|
|
5990
|
-
} else {
|
|
5991
|
-
arrayPop(DOMPurify.removed);
|
|
5992
|
-
}
|
|
5993
|
-
} catch (_) {
|
|
5994
|
-
_removeAttribute(name, currentNode);
|
|
5995
|
-
}
|
|
6856
|
+
_setAttributeValue(currentNode, name, namespaceURI, value);
|
|
5996
6857
|
}
|
|
5997
6858
|
}
|
|
5998
6859
|
/* Execute a hook if present */
|
|
@@ -6003,7 +6864,7 @@ function createDOMPurify() {
|
|
|
6003
6864
|
*
|
|
6004
6865
|
* @param fragment to iterate over recursively
|
|
6005
6866
|
*/
|
|
6006
|
-
const
|
|
6867
|
+
const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
|
|
6007
6868
|
let shadowNode = null;
|
|
6008
6869
|
const shadowIterator = _createNodeIterator(fragment);
|
|
6009
6870
|
/* Execute a hook if present */
|
|
@@ -6012,17 +6873,136 @@ function createDOMPurify() {
|
|
|
6012
6873
|
/* Execute a hook if present */
|
|
6013
6874
|
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
6014
6875
|
/* Sanitize tags and elements */
|
|
6015
|
-
_sanitizeElements(shadowNode);
|
|
6876
|
+
_sanitizeElements(shadowNode, fragment);
|
|
6016
6877
|
/* Check attributes next */
|
|
6017
6878
|
_sanitizeAttributes(shadowNode);
|
|
6018
|
-
/* Deep shadow DOM detected
|
|
6019
|
-
|
|
6020
|
-
|
|
6879
|
+
/* Deep shadow DOM detected.
|
|
6880
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
|
|
6881
|
+
DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
|
|
6882
|
+
recurse into <template>.content from foreign realms too. */
|
|
6883
|
+
if (_isDocumentFragment(shadowNode.content)) {
|
|
6884
|
+
_sanitizeShadowDOM2(shadowNode.content);
|
|
6885
|
+
}
|
|
6886
|
+
/* An element iterated here may itself host an attached
|
|
6887
|
+
shadow root. The default NodeIterator does not enter shadow
|
|
6888
|
+
trees, so a shadow root nested inside template.content was
|
|
6889
|
+
previously reached by no walk at all (the pre-pass at
|
|
6890
|
+
_sanitizeAttachedShadowRoots descends via childNodes, which
|
|
6891
|
+
doesn't enter template.content; the template-content recursion
|
|
6892
|
+
above iterates the content but never inspected shadowRoot).
|
|
6893
|
+
Walk it explicitly. The nodeType guard avoids reading
|
|
6894
|
+
shadowRoot off text / comment / CDATA / PI nodes that the
|
|
6895
|
+
iterator also surfaces. */
|
|
6896
|
+
const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
|
|
6897
|
+
if (shadowNodeType === NODE_TYPE.element) {
|
|
6898
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
6899
|
+
if (_isDocumentFragment(innerSr)) {
|
|
6900
|
+
_sanitizeAttachedShadowRoots(innerSr);
|
|
6901
|
+
_sanitizeShadowDOM2(innerSr);
|
|
6902
|
+
}
|
|
6021
6903
|
}
|
|
6022
6904
|
}
|
|
6023
6905
|
/* Execute a hook if present */
|
|
6024
6906
|
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
6025
6907
|
};
|
|
6908
|
+
/**
|
|
6909
|
+
* _sanitizeAttachedShadowRoots
|
|
6910
|
+
*
|
|
6911
|
+
* Walks `root` and feeds every attached shadow root we encounter into
|
|
6912
|
+
* the existing _sanitizeShadowDOM pipeline. The default node iterator
|
|
6913
|
+
* does not descend into shadow trees, so nodes inside an attached
|
|
6914
|
+
* shadow root would otherwise be skipped entirely.
|
|
6915
|
+
*
|
|
6916
|
+
* Two real input paths put attached shadow roots in front of us:
|
|
6917
|
+
* 1. IN_PLACE on a DOM node that already has shadow roots attached.
|
|
6918
|
+
* 2. DOM-node input where importNode(dirty, true) deep-clones the
|
|
6919
|
+
* shadow root because it was created with `clonable: true`.
|
|
6920
|
+
*
|
|
6921
|
+
* This pass runs once, up front, so the main iteration loop (and the
|
|
6922
|
+
* existing _sanitizeShadowDOM template-content recursion) stay
|
|
6923
|
+
* untouched — string-input paths are not affected.
|
|
6924
|
+
*
|
|
6925
|
+
* @param root the subtree root to walk for attached shadow roots
|
|
6926
|
+
*/
|
|
6927
|
+
const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
|
|
6928
|
+
/* Iterative (explicit stack) rather than per-child recursion. DOM APIs
|
|
6929
|
+
impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data
|
|
6930
|
+
built straight into the DOM — the IN_PLACE surface) deeper than the JS
|
|
6931
|
+
call-stack budget would otherwise overflow native recursion here and
|
|
6932
|
+
throw at the IN_PLACE entry pre-pass, before a single node is
|
|
6933
|
+
sanitized, leaving the caller's live tree untouched (fail-open). See
|
|
6934
|
+
campaign-3 F4. A heap stack keeps depth off the call stack.
|
|
6935
|
+
Each work item is either a node to descend into, or a deferred
|
|
6936
|
+
`_sanitizeShadowDOM` for an already-walked shadow root. The deferred
|
|
6937
|
+
form preserves the original post-order discipline: a shadow root's
|
|
6938
|
+
nested shadow roots are discovered before the outer shadow is
|
|
6939
|
+
sanitized (which may remove hosts). Pushes are in reverse of the
|
|
6940
|
+
desired processing order (LIFO): template content, then children, then
|
|
6941
|
+
the shadow-sanitize, then the shadow walk — so the order matches the
|
|
6942
|
+
previous recursion exactly. */
|
|
6943
|
+
const stack = [{
|
|
6944
|
+
node: root,
|
|
6945
|
+
shadow: null
|
|
6946
|
+
}];
|
|
6947
|
+
while (stack.length > 0) {
|
|
6948
|
+
const item = stack.pop();
|
|
6949
|
+
/* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */
|
|
6950
|
+
if (item.shadow) {
|
|
6951
|
+
_sanitizeShadowDOM2(item.shadow);
|
|
6952
|
+
continue;
|
|
6953
|
+
}
|
|
6954
|
+
const node = item.node;
|
|
6955
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
6956
|
+
const isElement = nodeType === NODE_TYPE.element;
|
|
6957
|
+
/* (pushed last → processed first) Children, snapshotted in reverse so
|
|
6958
|
+
the first child is processed first. Snapshotting matters because a
|
|
6959
|
+
hook may detach siblings mid-walk. */
|
|
6960
|
+
const childNodes = getChildNodes(node);
|
|
6961
|
+
if (childNodes) {
|
|
6962
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
6963
|
+
stack.push({
|
|
6964
|
+
node: childNodes[i],
|
|
6965
|
+
shadow: null
|
|
6966
|
+
});
|
|
6967
|
+
}
|
|
6968
|
+
}
|
|
6969
|
+
/* (pushed before children → processed after them, matching the old
|
|
6970
|
+
"template content last" order) When the node is a <template>,
|
|
6971
|
+
descend into its content. */
|
|
6972
|
+
if (isElement) {
|
|
6973
|
+
const rootName = getNodeName ? getNodeName(node) : null;
|
|
6974
|
+
if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
|
|
6975
|
+
const content = node.content;
|
|
6976
|
+
if (_isDocumentFragment(content)) {
|
|
6977
|
+
stack.push({
|
|
6978
|
+
node: content,
|
|
6979
|
+
shadow: null
|
|
6980
|
+
});
|
|
6981
|
+
}
|
|
6982
|
+
}
|
|
6983
|
+
}
|
|
6984
|
+
/* Shadow root (processed first): walk its subtree, then sanitise it.
|
|
6985
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
|
|
6986
|
+
rather than `instanceof DocumentFragment`, which is realm-bound and
|
|
6987
|
+
silently skipped foreign-realm shadow roots (e.g.
|
|
6988
|
+
iframe.contentDocument attachShadow). */
|
|
6989
|
+
if (isElement) {
|
|
6990
|
+
const sr = getShadowRoot(node);
|
|
6991
|
+
if (_isDocumentFragment(sr)) {
|
|
6992
|
+
/* Push the deferred sanitise first so it pops after the shadow
|
|
6993
|
+
walk we push next, i.e. nested shadow roots are discovered
|
|
6994
|
+
before this one is sanitised. */
|
|
6995
|
+
stack.push({
|
|
6996
|
+
node: null,
|
|
6997
|
+
shadow: sr
|
|
6998
|
+
}, {
|
|
6999
|
+
node: sr,
|
|
7000
|
+
shadow: null
|
|
7001
|
+
});
|
|
7002
|
+
}
|
|
7003
|
+
}
|
|
7004
|
+
}
|
|
7005
|
+
};
|
|
6026
7006
|
// eslint-disable-next-line complexity
|
|
6027
7007
|
DOMPurify.sanitize = function (dirty) {
|
|
6028
7008
|
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -6039,13 +7019,9 @@ function createDOMPurify() {
|
|
|
6039
7019
|
}
|
|
6040
7020
|
/* Stringify, in case dirty is an object */
|
|
6041
7021
|
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
throw typeErrorCreate('dirty is not a string, aborting');
|
|
6046
|
-
}
|
|
6047
|
-
} else {
|
|
6048
|
-
throw typeErrorCreate('toString is not a function');
|
|
7022
|
+
dirty = stringifyValue(dirty);
|
|
7023
|
+
if (typeof dirty !== 'string') {
|
|
7024
|
+
throw typeErrorCreate('dirty is not a string, aborting');
|
|
6049
7025
|
}
|
|
6050
7026
|
}
|
|
6051
7027
|
/* Return dirty HTML if DOMPurify cannot run */
|
|
@@ -6053,24 +7029,90 @@ function createDOMPurify() {
|
|
|
6053
7029
|
return dirty;
|
|
6054
7030
|
}
|
|
6055
7031
|
/* Assign config vars */
|
|
6056
|
-
if (
|
|
7032
|
+
if (SET_CONFIG) {
|
|
7033
|
+
/* Persistent setConfig() path: _parseConfig is skipped, so the sets are
|
|
7034
|
+
* not re-derived per call. Restore them from the pristine bindings
|
|
7035
|
+
* captured at setConfig() time so a previous call's hook clone (mutated
|
|
7036
|
+
* below) does not carry over. */
|
|
7037
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
7038
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
7039
|
+
} else {
|
|
6057
7040
|
_parseConfig(cfg);
|
|
6058
7041
|
}
|
|
7042
|
+
/* Clone the hook-mutable allowlists before the walk whenever an
|
|
7043
|
+
* uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS
|
|
7044
|
+
* and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so
|
|
7045
|
+
* a hook that widens them would otherwise mutate the shared set
|
|
7046
|
+
* permanently: across later calls and across every element. Cloning per
|
|
7047
|
+
* walk keeps documented in-call widening working while scoping it to the
|
|
7048
|
+
* call. A single guard for both config paths - the per-call path rebinds
|
|
7049
|
+
* the sets in _parseConfig each call, the persistent path restores them
|
|
7050
|
+
* from the captured bindings just above - so the two cannot diverge. */
|
|
7051
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
|
|
7052
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
7053
|
+
}
|
|
7054
|
+
if (hooks.uponSanitizeAttribute.length > 0) {
|
|
7055
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
7056
|
+
}
|
|
6059
7057
|
/* Clean up removed elements */
|
|
6060
7058
|
DOMPurify.removed = [];
|
|
6061
|
-
/*
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
7059
|
+
/* Resolve IN_PLACE for this call without mutating persistent config.
|
|
7060
|
+
Writing the IN_PLACE closure variable here leaks under setConfig(),
|
|
7061
|
+
where _parseConfig is skipped on later calls: a single string call would
|
|
7062
|
+
disable in-place mode for every subsequent node call, returning a
|
|
7063
|
+
sanitized copy while leaving the caller's node — which in-place callers
|
|
7064
|
+
keep using and whose return value they ignore — unsanitized. REPORT-2. */
|
|
7065
|
+
const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);
|
|
7066
|
+
if (inPlace) {
|
|
7067
|
+
/* Declarative-partial-updates / streaming pre-pass: sever every patch
|
|
7068
|
+
linkage across the live tree BEFORE the walk, so no patch can fire
|
|
7069
|
+
mid-walk and inject into an already-processed region. Runs first, so
|
|
7070
|
+
it also covers the forbidden/clobbered roots that throw below. */
|
|
7071
|
+
_neutralizePatchLinkage(dirty);
|
|
7072
|
+
/* Do some early pre-sanitization to avoid unsafe root nodes.
|
|
7073
|
+
Read nodeName through the cached prototype getter — a clobbering
|
|
7074
|
+
child named "nodeName" on the form root would otherwise shadow
|
|
7075
|
+
the property and let this check skip the root-allowlist
|
|
7076
|
+
validation entirely. */
|
|
7077
|
+
const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
|
|
7078
|
+
if (typeof nn === 'string') {
|
|
7079
|
+
const tagName = transformCaseFunc(nn);
|
|
6069
7080
|
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
7081
|
+
/* Fail closed on a live root: neutralize handlers/children before
|
|
7082
|
+
throwing, exactly as the mid-walk abort path does. */
|
|
7083
|
+
_neutralizeRoot(dirty);
|
|
6070
7084
|
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
|
6071
7085
|
}
|
|
6072
7086
|
}
|
|
6073
|
-
|
|
7087
|
+
/* Pre-flight the root through _isClobbered. The iterator-driven
|
|
7088
|
+
removal path can not detach a parent-less root: _forceRemove
|
|
7089
|
+
falls through to Element.prototype.remove(), which per spec
|
|
7090
|
+
is a no-op on a node with no parent. A clobbered root would
|
|
7091
|
+
then survive the main loop with its attributes uninspected,
|
|
7092
|
+
because _sanitizeAttributes early-returns on _isClobbered. The
|
|
7093
|
+
result would be an attacker-controlled form, complete with any
|
|
7094
|
+
event-handler attributes the caller passed in, handed back to
|
|
7095
|
+
the application unsanitized. Refuse to sanitize such a root
|
|
7096
|
+
the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
|
|
7097
|
+
if (_isClobbered(dirty)) {
|
|
7098
|
+
/* Fail closed on a live clobbered root before throwing.
|
|
7099
|
+
_neutralizeRoot's reads are clobber-safe (cached getters); the
|
|
7100
|
+
form's non-clobbered descendants, e.g. an armed <img>, are scrubbed. */
|
|
7101
|
+
_neutralizeRoot(dirty);
|
|
7102
|
+
throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
|
|
7103
|
+
}
|
|
7104
|
+
/* Sanitize attached shadow roots before the main iterator runs.
|
|
7105
|
+
The iterator does not descend into shadow trees. Same fail-closed
|
|
7106
|
+
barrier as the main walk (campaign-3 F2): a custom-element reaction
|
|
7107
|
+
inside a shadow root could abort this pre-pass before the walk runs,
|
|
7108
|
+
which would otherwise leave the entire live tree unsanitized. */
|
|
7109
|
+
try {
|
|
7110
|
+
_sanitizeAttachedShadowRoots(dirty);
|
|
7111
|
+
} catch (error) {
|
|
7112
|
+
_neutralizeRoot(dirty);
|
|
7113
|
+
throw error;
|
|
7114
|
+
}
|
|
7115
|
+
} else if (_isNode(dirty)) {
|
|
6074
7116
|
/* If dirty is a DOM element, append to an empty document to avoid
|
|
6075
7117
|
elements being stripped by the parser */
|
|
6076
7118
|
body = _initDocument('<!---->');
|
|
@@ -6084,12 +7126,18 @@ function createDOMPurify() {
|
|
|
6084
7126
|
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
6085
7127
|
body.appendChild(importedNode);
|
|
6086
7128
|
}
|
|
7129
|
+
/* Clonable shadow roots are deep-cloned by importNode(); sanitize
|
|
7130
|
+
them before the main iterator runs, since the iterator does not
|
|
7131
|
+
descend into shadow trees. The walk routes every read through a
|
|
7132
|
+
cached prototype getter so clobbering descendants on a form root
|
|
7133
|
+
cannot hide a shadow host from this pass. */
|
|
7134
|
+
_sanitizeAttachedShadowRoots(importedNode);
|
|
6087
7135
|
} else {
|
|
6088
7136
|
/* Exit directly if we have nothing to do */
|
|
6089
7137
|
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
6090
7138
|
// eslint-disable-next-line unicorn/prefer-includes
|
|
6091
7139
|
dirty.indexOf('<') === -1) {
|
|
6092
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ?
|
|
7140
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
|
|
6093
7141
|
}
|
|
6094
7142
|
/* Initialize the document to work on */
|
|
6095
7143
|
body = _initDocument(dirty);
|
|
@@ -6103,24 +7151,72 @@ function createDOMPurify() {
|
|
|
6103
7151
|
_forceRemove(body.firstChild);
|
|
6104
7152
|
}
|
|
6105
7153
|
/* Get node iterator */
|
|
6106
|
-
const
|
|
6107
|
-
/* Now start iterating over the created document
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
7154
|
+
const walkRoot = inPlace ? dirty : body;
|
|
7155
|
+
/* Now start iterating over the created document.
|
|
7156
|
+
The walk runs inside an exception barrier (campaign-3 F2): a re-entrant
|
|
7157
|
+
engine/custom-element mutation can detach a node mid-walk so
|
|
7158
|
+
`_forceRemove`'s parentless guard throws, aborting the loop. Without the
|
|
7159
|
+
barrier the caller's in-place tree would be left half-sanitized with the
|
|
7160
|
+
unvisited tail still armed. _createNodeIterator itself is inside the
|
|
7161
|
+
barrier too: constructing the iterator dereferences the root's document,
|
|
7162
|
+
and any failure there (e.g. an exotic/clobbered root) must still fail
|
|
7163
|
+
closed rather than skip the neutralize. On any throw we fail closed -
|
|
7164
|
+
strip the in-place root bare - then rethrow so the existing throw
|
|
7165
|
+
contract is preserved. (String/DOM-copy paths never return the partial
|
|
7166
|
+
body, so the propagating throw is already fail-closed there.) */
|
|
7167
|
+
try {
|
|
7168
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
7169
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
7170
|
+
/* Sanitize tags and elements */
|
|
7171
|
+
_sanitizeElements(currentNode, walkRoot);
|
|
7172
|
+
/* Check attributes next */
|
|
7173
|
+
_sanitizeAttributes(currentNode);
|
|
7174
|
+
/* Shadow DOM detected, sanitize it.
|
|
7175
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
|
|
7176
|
+
instead of instanceof, so foreign-realm <template>.content is
|
|
7177
|
+
walked correctly. */
|
|
7178
|
+
if (_isDocumentFragment(currentNode.content)) {
|
|
7179
|
+
_sanitizeShadowDOM2(currentNode.content);
|
|
7180
|
+
}
|
|
6116
7181
|
}
|
|
7182
|
+
} catch (error) {
|
|
7183
|
+
if (inPlace) {
|
|
7184
|
+
_neutralizeRoot(dirty);
|
|
7185
|
+
/* Nodes _forceRemove'd earlier in the aborted walk are already
|
|
7186
|
+
detached from the root, so _neutralizeRoot's subtree pass does not
|
|
7187
|
+
reach them. Defuse them too, mirroring the success-path loop below. */
|
|
7188
|
+
arrayForEach(DOMPurify.removed, entry => {
|
|
7189
|
+
if (entry.element) {
|
|
7190
|
+
_neutralizeSubtree(entry.element);
|
|
7191
|
+
}
|
|
7192
|
+
});
|
|
7193
|
+
}
|
|
7194
|
+
throw error;
|
|
6117
7195
|
}
|
|
6118
7196
|
/* If we sanitized `dirty` in-place, return it. */
|
|
6119
|
-
if (
|
|
7197
|
+
if (inPlace) {
|
|
7198
|
+
/* Fail-closed completion of the audit-5 F1 fix: every node removed from
|
|
7199
|
+
the caller's live tree is detached but may still hold a queued
|
|
7200
|
+
resource-event handler that fires in page scope after we return. The
|
|
7201
|
+
move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the
|
|
7202
|
+
non-allow-listed attributes off every other removed subtree (clobber,
|
|
7203
|
+
mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are
|
|
7204
|
+
cancelled before any event can fire. Runs synchronously, pre-return. */
|
|
7205
|
+
arrayForEach(DOMPurify.removed, entry => {
|
|
7206
|
+
if (entry.element) {
|
|
7207
|
+
_neutralizeSubtree(entry.element);
|
|
7208
|
+
}
|
|
7209
|
+
});
|
|
7210
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
7211
|
+
_scrubTemplateExpressions2(dirty);
|
|
7212
|
+
}
|
|
6120
7213
|
return dirty;
|
|
6121
7214
|
}
|
|
6122
7215
|
/* Return sanitized string or DOM */
|
|
6123
7216
|
if (RETURN_DOM) {
|
|
7217
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
7218
|
+
_scrubTemplateExpressions2(body);
|
|
7219
|
+
}
|
|
6124
7220
|
if (RETURN_DOM_FRAGMENT) {
|
|
6125
7221
|
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
6126
7222
|
while (body.firstChild) {
|
|
@@ -6149,20 +7245,28 @@ function createDOMPurify() {
|
|
|
6149
7245
|
}
|
|
6150
7246
|
/* Sanitize final string template-safe */
|
|
6151
7247
|
if (SAFE_FOR_TEMPLATES) {
|
|
6152
|
-
|
|
6153
|
-
serializedHTML = stringReplace(serializedHTML, expr, ' ');
|
|
6154
|
-
});
|
|
7248
|
+
serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
6155
7249
|
}
|
|
6156
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ?
|
|
7250
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
6157
7251
|
};
|
|
6158
7252
|
DOMPurify.setConfig = function () {
|
|
6159
7253
|
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6160
7254
|
_parseConfig(cfg);
|
|
6161
7255
|
SET_CONFIG = true;
|
|
7256
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
7257
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
6162
7258
|
};
|
|
6163
7259
|
DOMPurify.clearConfig = function () {
|
|
6164
7260
|
CONFIG = null;
|
|
6165
7261
|
SET_CONFIG = false;
|
|
7262
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
7263
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
7264
|
+
// Drop any caller-supplied Trusted Types policy so it cannot poison later
|
|
7265
|
+
// `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and
|
|
7266
|
+
// never recreated — Trusted Types throws on duplicate names) is restored by
|
|
7267
|
+
// the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.
|
|
7268
|
+
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
7269
|
+
emptyHTML = '';
|
|
6166
7270
|
};
|
|
6167
7271
|
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
6168
7272
|
/* Initialize shared config vars if necessary. */
|
|
@@ -6177,9 +7281,19 @@ function createDOMPurify() {
|
|
|
6177
7281
|
if (typeof hookFunction !== 'function') {
|
|
6178
7282
|
return;
|
|
6179
7283
|
}
|
|
7284
|
+
/* Reject unknown entry points. Without this, a non-hook key (e.g.
|
|
7285
|
+
* '__proto__') indexes off the prototype chain rather than a real
|
|
7286
|
+
* hook array, and arrayPush then writes to Object.prototype. Guard
|
|
7287
|
+
* with an own-property check against the known hook names. */
|
|
7288
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
7289
|
+
return;
|
|
7290
|
+
}
|
|
6180
7291
|
arrayPush(hooks[entryPoint], hookFunction);
|
|
6181
7292
|
};
|
|
6182
7293
|
DOMPurify.removeHook = function (entryPoint, hookFunction) {
|
|
7294
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
7295
|
+
return undefined;
|
|
7296
|
+
}
|
|
6183
7297
|
if (hookFunction !== undefined) {
|
|
6184
7298
|
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
6185
7299
|
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
@@ -6187,6 +7301,9 @@ function createDOMPurify() {
|
|
|
6187
7301
|
return arrayPop(hooks[entryPoint]);
|
|
6188
7302
|
};
|
|
6189
7303
|
DOMPurify.removeHooks = function (entryPoint) {
|
|
7304
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
7305
|
+
return;
|
|
7306
|
+
}
|
|
6190
7307
|
hooks[entryPoint] = [];
|
|
6191
7308
|
};
|
|
6192
7309
|
DOMPurify.removeAllHooks = function () {
|
|
@@ -6204,7 +7321,7 @@ var purify = createDOMPurify();
|
|
|
6204
7321
|
*
|
|
6205
7322
|
*/
|
|
6206
7323
|
|
|
6207
|
-
function 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&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,c=n&&/Android/.test(navigator.userAgent),a=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!c,u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&c&&u,d$1=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!u,h$1=0,g=1,_$3=2,p=1,y$1=2,m$1=4,x$1=8,C$4=16,S$1=32,v$1=64,k$3=128,T$2=2047,N$3=1,b$3=2,w$3=3,E$4=4,O$4=5,M$5=6,A$3=a||l||d$1?"\xa0":"\u200b",D$4="\n\n",P$3=o?"\xa0":A$3,F$7="\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc",L$4="A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff",I$6=new RegExp("^[^"+L$4+"]*["+F$7+"]"),K$4=new RegExp("^[^"+F$7+"]*["+L$4+"]"),z$7={bold:1,capitalize:1024,code:16,highlight:k$3,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},R$4={directionless:1,unmergeable:2},B$5={center:2,end:6,justify:4,left:1,right:3,start:5},W$5={[b$3]:"center",[M$5]:"end",[E$4]:"justify",[N$3]:"left",[w$3]:"right",[O$4]:"start"},$$4={normal:0,segmented:2,token:1},J$7={[h$1]:"normal",[_$3]:"segmented",[g]:"token"},j$7="$",U$6="$config";let V$7 = class V{_front=new Set;_back=new Set;_cache;get size(){return this._front.size+this._back.size}addBack(t){return delete this._cache,this._front.has(t)||this._back.add(t),this}addFront(t){return delete this._cache,this._back.has(t)||this._front.add(t),this}delete(t){return delete this._cache,this._front.delete(t)||this._back.delete(t)}toArray(){const t=Array.from(this._front).reverse();for(const e of this._back)t.push(e);return t}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}};function Y$5(t,e,n,r,i,o){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Wi(s)&&Y$5(s,t,n,r,i,o),n.has(t)||o.delete(t),i.push(t)),s=s.getNextSibling();}}let q$7=false,H$7=0;function G$a(t){H$7=t.timeStamp;}function X$6(t,e,n){const r="BR"===t.nodeName,i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&void 0!==Ho(t,n)}function Q$9(t,e,n){const r=Js(Ps(n));let i=null,o=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,o=r.focusOffset);const s=t.nodeValue;null!==s&&cs(e,s,i,o,false);}function Z$5(t,e,n){if(Fr(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return false}return Ko(e)&&n.isAttached()}function tt$4(t,e,n,r){for(let i=t;i&&!cl(i);i=bs(i)){const t=Ho(i,e);if(void 0!==t){const e=Yo(t,n);if(e)return ji(e)||!Ys(i)?void 0:[i,e]}else if(i===r)return [r,ts(n)]}}function et$2(t,e,n){q$7=true;const r=performance.now()-H$7>100;try{Ki(t,()=>{const i=Qr()||function(t){return t.getEditorState().read(()=>{const t=Qr();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&&Tr(y)&&Ko(g)&&Z$5(i,g,y)&&Q$9(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=qo(r),s=r.parentNode;if(null!=s&&r!==a&&null===i&&!X$6(r,s,t)){if(o){const t=(Ys(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$6(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$6(n,i,t)||o.removeChild(n);}}n.takeRecords();}null!==i&&(u&&es(i),o&&ks(t)&&i.insertRawText(f));});}finally{q$7=false;}}function nt$4(t){const e=t._observer;if(null!==e){et$2(t,e.takeRecords(),e);}}function rt$4(t){!function(t){0===H$7&&Ps(t).addEventListener("textInput",G$a,true);}(t),t._observer=new MutationObserver((e,n)=>{et$2(t,e,n);});}let it$2 = class it{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||gt$3).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=e.resetOnCopyNode||false;}};function ot$3(t,e){return new it$2(t,e)}function st$2(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function lt$3(t,e,n){const r=st$2(t,n,"direct"),i=st$2(e,n,"direct");return n.isEqual(r,i)?null:[r,i]}function ct$2(t,e,n){let r;if(xi(),"function"==typeof n){const i=t.getLatest(),o=st$2(i,e);if(r=n(o),e.isEqual(o,r))return i}else r=n;const i=t.getWritable();return ft$2(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}=ul(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$3 = 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$3(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)}resetOnCopyNode(){for(const t of this.knownState.keys())t.resetOnCopyNode&&this.knownState.set(t,t.defaultValue);return this}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$3(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$2(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new ut$3(e,dt$3(e));return e.__state=n,n}function dt$3(t){return t.__state?t.__state.sharedNodeState:No(Zs(),t.getType()).sharedNodeState}function ht$3(t){if(t)for(const e in t)return t}function gt$3(t){return t}function _t$3(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;if(e!==i&&!r.isEqual(e,i))return true}return false}function pt$3(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$6(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function mt$3(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;const n=new Set;return !(t&&_t$3(n,t,e)||e&&_t$3(n,e,t)||t&&pt$3(n,t,e)||e&&pt$3(n,e,t))}(c,a))}function xt$3(t,e){const n=t.mergeWithSibling(e),r=vi()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function Ct$2(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&Tr(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(mt$3(e,r)){r=xt$3(e,r);break}break}e.remove();}for(;null!==(n=r.getNextSibling())&&Tr(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(mt$3(r,n)){r=xt$3(r,n);break}break}n.remove();}}else r.remove();}function St$3(t){return vt$3(t.anchor),vt$3(t.focus),t}function vt$3(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),Tr(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",true);break}if(!Wi(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",true);}}let kt$3,Tt$5,Nt$3,bt$3,wt$3,Et$4,Ot$4,Mt$3,At$3,Dt$5,Pt$4,Ft$3="",Lt$4=null,It$2=null,Kt$3=false,zt$5=false;function Rt$4(t,e){const n=Ot$4.get(t);if(null!==e){const n=ne$5(t);n.parentNode===e&&e.removeChild(n);}if(Mt$3.has(t)||Tt$5._keyToDOMMap.delete(t),Wi(n)){const t=hl(n,Ot$4);Bt$4(t,0,t.length-1,null);} void 0!==n&&xs(Dt$5,Nt$3,bt$3,n,"destroyed");}function Bt$4(t,e,n,r){for(let i=e;i<=n;++i){const e=t[i];void 0!==e&&Rt$4(e,r);}}function Wt$4(t,e){t.setProperty("text-align",e);}const $t$3="40px";function Jt$4(t,e){const n=kt$3.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);}if(0===e)return void t.style.setProperty("padding-inline-start","");const r=getComputedStyle(Tt$5._rootElement||t).getPropertyValue("--lexical-indent-base-value")||$t$3;t.style.setProperty("padding-inline-start",`calc(${e} * ${r})`);}function jt$3(t,e){const n=t.style;0===e?Wt$4(n,""):1===e?Wt$4(n,"left"):2===e?Wt$4(n,"center"):3===e?Wt$4(n,"right"):4===e?Wt$4(n,"justify"):5===e?Wt$4(n,"start"):6===e&&Wt$4(n,"end");}function Ut$4(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(Vi(t))return null;const n=t.getParentOrThrow();return Vi(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir");}function Vt$3(e,n){const r=Mt$3.get(e);void 0===r&&t(60);const i=Pt$4.$createDOM(r,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),Tr(r)?i.setAttribute("data-lexical-text","true"):ji(r)&&i.setAttribute("data-lexical-decorator","true"),Wi(r)){const t=r.__indent,e=r.__size;if(Ut$4(i,r),0!==t&&Jt$4(i,t),0!==e){const t=e-1;Yt$3(hl(r,Mt$3),r,0,t,Pt$4.$getDOMSlot(r,i,Tt$5));}const n=r.__format;0!==n&&jt$3(i,n),r.isInline()||Ht$4(null,r,i);}else {const t=r.getTextContent();if(ji(r)){const t=r.decorate(Tt$5,kt$3);null!==t&&Qt$3(e,t),i.contentEditable="false";}Ft$3+=t;}return null!==n&&n.insertChild(i),Pt$4.$decorateDOM(r,null,i,Tt$5),xs(Dt$5,Nt$3,bt$3,r,"created"),i}function Yt$3(t,e,n,r,i){const o=Ft$3;Ft$3="";let s=n;for(;s<=r;++s){Vt$3(t[s],i);const e=Mt$3.get(t[s]);null!==e&&Tr(e)?null===Lt$4&&(Lt$4=e.getFormat(),It$2=e.getStyle()):Wi(e)&&s<r&&!e.isInline()&&(Ft$3+=D$4);}i.element.__lexicalTextContent=Ft$3,Ft$3=o+Ft$3;}function qt$4(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return sr(t)?"line-break":ji(t)&&t.isInline()?"decorator":null}return "empty"}return null}function Ht$4(t,e,n){const r=qt$4(t,Ot$4),i=qt$4(e,Mt$3);r!==i&&Pt$4.$getDOMSlot(e,n,Tt$5).setManagedLineBreak(i);}function Gt$3(e,n,r){var i;Lt$4=null,It$2=null,function(e,n,r){const i=Ft$3,o=e.__size,s=n.__size;Ft$3="";const l=r.element;if(1===o&&1===s){const t=e.__first,r=n.__first;if(t===r)Xt$4(t,l);else {const e=ne$5(t),n=Vt$3(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$4(t,null);}const i=Mt$3.get(r);Tr(i)&&null===Lt$4&&(Lt$4=i.getFormat(),It$2=i.getStyle());}else {const i=hl(e,Ot$4),c=hl(n,Mt$3);if(i.length!==o&&t(227),c.length!==s&&t(228),0===o)0!==s&&Yt$3(c,0,0,s-1,r);else 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=Zt$3(Xt$4(r,o.element)),f++,d++;else {if(void 0===a&&(a=te$5(n,d)),void 0===c)c=te$5(e,f);else if(!c.has(t)){f++;continue}if(!a.has(t)){u=Zt$3(ne$5(t)),Rt$4(t,o.element),f++,c.delete(t);continue}if(c.has(r)){const t=Ns(Tt$5,r);t!==u&&o.withBefore(u).insertChild(t),u=Zt$3(Xt$4(r,o.element)),f++,d++;}else Vt$3(r,o.withBefore(u)),d++;}const i=Mt$3.get(r);null!==i&&Tr(i)?null===Lt$4&&(Lt$4=i.getFormat(),It$2=i.getStyle()):Wi(i)&&d<=l&&!i.isInline()&&(Ft$3+=D$4);}const h=f>s,g=d>l;if(h&&!g){const t=n[l+1],e=void 0===t?null:Tt$5.getElementByKey(t);Yt$3(n,0,d,l,o.withBefore(e));}else g&&!h&&Bt$4(e,f,s,o.element);}(0,i,c,o,s,r);}l.__lexicalTextContent=Ft$3,Ft$3=i+Ft$3;}(e,n,Pt$4.$getDOMSlot(n,r,Tt$5)),i=n,null==Lt$4||Lt$4===i.__textFormat||zt$5||i.setTextFormat(Lt$4),function(t){null==It$2||It$2===t.__textStyle||zt$5||t.setTextStyle(It$2);}(n);}function Xt$4(e,n){const r=Ot$4.get(e);let i=Mt$3.get(e);void 0!==r&&void 0!==i||t(61);const o=Kt$3||Et$4.has(e)||wt$3.has(e),s=Ns(Tt$5,e);if(r===i&&!o){let t;if(Wi(r)){const e=s.__lexicalTextContent;"string"==typeof e?t=e:(t=r.getTextContent(),s.__lexicalTextContent=t);}else t=r.getTextContent();return Ft$3+=t,s}if(r!==i&&o&&xs(Dt$5,Nt$3,bt$3,i,"updated"),Pt$4.$updateDOM(i,r,s,Tt$5)){const r=Vt$3(e,null);return null===n&&t(62),n.replaceChild(r,s),Rt$4(e,null),r}if(Wi(r)){Wi(i)||t(334,e);const n=i.__indent;(Kt$3||n!==r.__indent)&&Jt$4(s,n);const l=i.__format;if((Kt$3||l!==r.__format)&&jt$3(s,l),o)Gt$3(r,i,s),Vi(i)||i.isInline()||Ht$4(r,i,s);else {const t=s.__lexicalTextContent;let e;"string"==typeof t?e=t:(e=r.getTextContent(),s.__lexicalTextContent=e),Ft$3+=e;}if((Kt$3||i.__dir!==r.__dir)&&(Ut$4(s,i),Vi(i)&&!Kt$3))for(const t of i.getChildren())if(Wi(t)){Ut$4(Ns(Tt$5,t.getKey()),t);}}else {const t=i.getTextContent();if(ji(i)){const t=i.decorate(Tt$5,kt$3);null!==t&&Qt$3(e,t);}Ft$3+=t;}if(!zt$5&&Vi(i)&&i.__cachedText!==Ft$3){const t=i.getWritable();t.__cachedText=Ft$3,i=t;}return Pt$4.$decorateDOM(i,r,s,Tt$5),s}function Qt$3(t,e){let n=Tt$5._pendingDecorators;const r=Tt$5._decorators;if(null===n){if(r[t]===e)return;n=Xo(Tt$5);}n[t]=e;}function Zt$3(t){let e=t.nextSibling;return null!==e&&e===Tt$5._blockCursorElement&&(e=e.nextSibling),e}function te$5(t,e){const n=new Set;for(let r=e;r<t.length;r++)n.add(t[r]);return n}function ee$4(t,e,n,r,i,o){Ft$3="",Kt$3=2===r,Tt$5=n,kt$3=n._config,Pt$4=n._config.dom||po,Nt$3=n._nodes,bt$3=Tt$5._listeners.mutation,wt$3=i,Et$4=o,Ot$4=t._nodeMap,Mt$3=e._nodeMap,zt$5=e._readOnly,At$3=new Map(n._keyToDOMMap);const s=new Map;return Dt$5=s,Xt$4("root",null),Tt$5=void 0,Nt$3=void 0,wt$3=void 0,Et$4=void 0,Ot$4=void 0,Mt$3=void 0,kt$3=void 0,At$3=void 0,Dt$5=void 0,Pt$4=po,s}function ne$5(e){const n=At$3.get(e);return void 0===n&&t(75,e),n}function re$5(t){return {type:t}}const ie$4=re$5("SELECTION_CHANGE_COMMAND"),oe$6=re$5("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),se$5=re$5("CLICK_COMMAND"),le$3=re$5("BEFORE_INPUT_COMMAND"),ce$4=re$5("INPUT_COMMAND"),ae$4=re$5("COMPOSITION_START_COMMAND"),ue$4=re$5("COMPOSITION_END_COMMAND"),fe$4=re$5("DELETE_CHARACTER_COMMAND"),de$4=re$5("INSERT_LINE_BREAK_COMMAND"),he$3=re$5("INSERT_PARAGRAPH_COMMAND"),ge$3=re$5("CONTROLLED_TEXT_INSERTION_COMMAND"),_e$2=re$5("PASTE_COMMAND"),pe$3=re$5("REMOVE_TEXT_COMMAND"),ye$2=re$5("DELETE_WORD_COMMAND"),me$3=re$5("DELETE_LINE_COMMAND"),xe=re$5("FORMAT_TEXT_COMMAND"),Ce$2=re$5("UNDO_COMMAND"),Se$2=re$5("REDO_COMMAND"),ve$2=re$5("KEYDOWN_COMMAND"),ke$2=re$5("KEY_ARROW_RIGHT_COMMAND"),Te$2=re$5("MOVE_TO_END"),Ne$1=re$5("KEY_ARROW_LEFT_COMMAND"),be$1=re$5("MOVE_TO_START"),we$1=re$5("KEY_ARROW_UP_COMMAND"),Ee$3=re$5("KEY_ARROW_DOWN_COMMAND"),Oe$2=re$5("KEY_ENTER_COMMAND"),Me$2=re$5("KEY_SPACE_COMMAND"),Ae$3=re$5("KEY_BACKSPACE_COMMAND"),De$2=re$5("KEY_ESCAPE_COMMAND"),Pe$2=re$5("KEY_DELETE_COMMAND"),Fe$2=re$5("KEY_TAB_COMMAND"),Le$2=re$5("INSERT_TAB_COMMAND"),Ie$3=re$5("INDENT_CONTENT_COMMAND"),Ke$2=re$5("OUTDENT_CONTENT_COMMAND"),ze$2=re$5("DROP_COMMAND"),Re$1=re$5("FORMAT_ELEMENT_COMMAND"),Be$2=re$5("DRAGSTART_COMMAND"),We$2=re$5("DRAGOVER_COMMAND"),$e$2=re$5("DRAGEND_COMMAND"),Je$2=re$5("COPY_COMMAND"),je$2=re$5("CUT_COMMAND"),Ue$2=re$5("SELECT_ALL_COMMAND"),Ve$2=re$5("CLEAR_EDITOR_COMMAND"),Ye$1=re$5("CLEAR_HISTORY_COMMAND"),qe$2=re$5("CAN_REDO_COMMAND"),He$2=re$5("CAN_UNDO_COMMAND"),Ge$2=re$5("FOCUS_COMMAND"),Xe$2=re$5("BLUR_COMMAND"),Qe$1=re$5("KEY_MODIFIER_COMMAND"),Ze$1=Object.freeze({}),tn$1=[["keydown",function(t,e){if(en$1=t.timeStamp,nn$1=t.key,e.isComposing())return;Ts(e,ve$2,t);}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;qs(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&Ki(e,()=>{Eo(n)||(an$1=true);});}],["compositionstart",function(t,e){Ts(e,ae$4,t);}],["compositionend",function(t,e){o?fn$1=true:l||!a&&!d$1?Ts(e,ue$4,t):(dn$1=true,hn$1=t.data);}],["input",function(t,e){t.stopPropagation(),Ki(e,()=>{e.dispatchCommand(ce$4,t);},{event:t}),on$1=null;}],["click",function(t,e){Ki(e,()=>{const n=Qr(),r=Js(Ps(e)),i=Zr();if(r)if(Fr(n)){const e=n.anchor,o=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!Vi(o)&&1===Zo().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=dl(o,t=>Wi(t)&&!t.isInline());Wi(t)&&t.select(0);}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Ys(n)||Ko(n)){es(Xr(i,r,e,t));}}Ts(e,se$5,t);});}],["cut",Ze$1],["copy",Ze$1],["dragstart",Ze$1],["dragover",Ze$1],["dragend",Ze$1],["paste",Ze$1],["focus",Ze$1],["blur",Ze$1],["drop",Ze$1]];s$1&&tn$1.push(["beforeinput",(t,e)=>function(t,e){const n=t.inputType;if("deleteCompositionText"===n||o&&ks(e))return;if("insertCompositionText"===n)return;Ts(e,le$3,t);}(t,e)]);let en$1=0,nn$1=null,rn$1=0,on$1=null;const sn$1=new WeakMap,ln$1=new WeakMap;let cn$1=false,an$1=false,un$1=false,fn$1=false,dn$1=false,hn$1="",gn$1=null,_n$1=[0,"",0,"root",0];function pn$1(t,e,n,r,i){const o=t.anchor,l=t.focus,c=o.getNode(),a=vi(),u=Js(Ps(a)),f=null!==u?u.anchorNode:null,d=o.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!Tr(c)||(!i&&(!s$1||rn$1<r+50)||c.isDirty()&&g<2||rs(n))&&o.offset!==l.offset&&!c.isComposing()||Io(c)||c.isDirty()&&g>1||(i||!s$1)&&null!==h&&!c.isComposing()&&f!==Ro(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||!c.isComposing()&&(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=Lo(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return (Tr(e)||Wi(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}(t,c)}function yn$1(t,e){return Ko(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function mn$1(e,n,r){const{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:l}=e;cn$1&&(cn$1=false,yn$1(i,o)&&yn$1(s,l)&&!gn$1)||Ki(n,()=>{if(!r)return void es(null);if(!Mo(n,i,s))return;let c=Qr();if(gn$1&&Fr(c)&&c.isCollapsed()){const t=c.anchor,e=gn$1.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=gn$1.clone(),es(c));}if(gn$1=null,Fr(c)){const r=c.anchor,i=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=true);const o=Ps(n).event,s=o?o.timeStamp:performance.now(),[l,a,u,f,d]=_n$1,h=Zo(),g=false===n.isComposing()&&""===h.getTextContent();if(s<d+200&&r.offset===u&&r.key===f)xn$1(c,l,a);else if("text"===r.type)Tr(i)||t(141),Cn$1(c,i);else if("element"===r.type&&!g){Wi(i)||t(259);const e=r.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),r=e.getTextStyle();xn$1(t,n,r);}(c,e):xn$1(c,c.format,"");}}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(Tr(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;}}Ts(n,ie$4,void 0);});}function xn$1(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=true);}function Cn$1(t,e){xn$1(t,e.getFormat(),e.getStyle());}function Sn$1(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function vn$1(e){const n=e.inputType,r=Sn$1(e),i=vi(),o=Qr();if("deleteContentBackward"===n){if(null===o){const t=Zr();if(!Fr(t))return true;es(t.clone());}if(Fr(o)){const n=o.anchor.key===o.focus.key;if(s=e.timeStamp,"MediaLast"===nn$1&&s<en$1+30&&i.isComposing()&&n){if(Uo(null),en$1=0,setTimeout(()=>{Ki(i,()=>{Uo(null);});},30),Fr(o)){const e=o.anchor.getNode();e.markDirty(),Tr(e)||t(142),Cn$1(o,e);}}else {Uo(null),e.preventDefault();const t=o.anchor.getNode(),r=t.getTextContent(),s=t.canInsertTextAfter(),l=0===o.anchor.offset&&o.focus.offset===r.length;let c=f&&n&&!l&&s;if(c&&o.isCollapsed()&&(c=!ji(vs(o.anchor,true))),!c){Ts(i,fe$4,true);const t=Qr();f&&Fr(t)&&t.isCollapsed()&&(gn$1=t,setTimeout(()=>gn$1=null));}}return true}}var s;if(!Fr(o))return true;const c=e.data;null!==on$1&&ls(false,i,on$1),o.dirty&&null===on$1||!o.isCollapsed()||Vi(o.anchor.getNode())||null===r||o.applyDOMRange(r),on$1=null;const a=o.anchor,u=o.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===c)e.preventDefault(),Ts(i,de$4,false);else if(c===D$4)e.preventDefault(),Ts(i,he$3,void 0);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),o.insertRawText(t);}else null!=c&&pn$1(o,r,c,e.timeStamp,true)?(e.preventDefault(),Ts(i,ge$3,c)):on$1=c;return rn$1=e.timeStamp,true}switch(e.preventDefault(),n){case "insertFromYank":case "insertFromDrop":case "insertReplacementText":Ts(i,ge$3,e);break;case "insertFromComposition":Uo(null),Ts(i,ge$3,e);break;case "insertLineBreak":Uo(null),Ts(i,de$4,false);break;case "insertParagraph":Uo(null),un$1&&!l?(un$1=false,Ts(i,de$4,false)):Ts(i,he$3,void 0);break;case "insertFromPaste":case "insertFromPasteAsQuotation":Ts(i,_e$2,e);break;case "deleteByComposition":(function(t,e){return t!==e||Wi(t)||Wi(e)||!Lo(t)||!Lo(e)})(d,h)&&Ts(i,pe$3,e);break;case "deleteByDrag":Os(Hn),Ts(i,pe$3,e);break;case "deleteByCut":Ts(i,pe$3,e);break;case "deleteContent":Ts(i,fe$4,false);break;case "deleteWordBackward":Ts(i,ye$2,true);break;case "deleteWordForward":Ts(i,ye$2,false);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":Ts(i,me$3,true);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":Ts(i,me$3,false);break;case "formatStrikeThrough":Ts(i,xe,"strikethrough");break;case "formatBold":Ts(i,xe,"bold");break;case "formatItalic":Ts(i,xe,"italic");break;case "formatUnderline":Ts(i,xe,"underline");break;case "historyUndo":Ts(i,Ce$2,void 0);break;case "historyRedo":Ts(i,Se$2,void 0);}return true}function kn$1(t){if(Ys(t.target)&&Eo(t.target))return true;const e=vi(),n=Qr(),r=t.data,i=Sn$1(t);if(null!=r&&Fr(n)&&pn$1(n,i,r,t.timeStamp,false)){fn$1&&(bn$1(e,r),fn$1=false);const i=n.anchor.getNode(),l=Js(Ps(e));if(null===l)return true;const c=n.isBackward(),a=c?n.anchor.offset:n.focus.offset,u=c?n.focus.offset:n.anchor.offset;s$1&&!n.isCollapsed()&&Tr(i)&&null!==l.anchorNode&&i.getTextContent().slice(0,a)+r+i.getTextContent().slice(a+u)===ss(l.anchorNode)||Ts(e,ge$3,r);const d=r.length;o&&d>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=d),f&&e.isComposing()&&(en$1=0,Uo(null));}else {ls(false,e,null!==r?r:void 0),fn$1&&(bn$1(e,r||void 0),fn$1=false);}return function(){xi();const t=vi();nt$4(t);}(),true}function Tn$1(t){const e=vi(),n=Qr();if(Fr(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();Uo(r.key),Os(Gn),(t.timeStamp<en$1+30||"element"===r.type||!n.isCollapsed()||i.getFormat()!==n.format||Tr(i)&&i.getStyle()!==n.style)&&Ts(e,ge$3,P$3);}return true}function Nn$1(t){return bn$1(vi(),t.data),Os(Xn),true}function bn$1(t,e){const n=t._compositionKey;if(Uo(null),null!==n&&null!=e){if(""===e){const e=Yo(n),r=Ro(t.getElementByKey(n));if(null!==r&&null!==r.nodeValue&&Tr(e)){const n=Js(Ps(t));let i=null,o=null;null!==n&&n.anchorNode===r&&(i=n.anchorOffset,o=n.focusOffset),cs(e,r.nodeValue,i,o,true);}return}if("\n"===e[e.length-1]){const e=Qr();if(Fr(e)||Ir(e)){if(Fr(e)){const t=e.focus;e.anchor.set(t.key,t.offset,t.type);}return void Ts(t,Oe$2,null)}}}ls(true,t,e);}function wn$1(t){const e=vi();if(null==t.key)return true;if(dn$1){if(_s(t))return Ki(e,()=>{bn$1(e,hn$1);}),dn$1=false,hn$1="",true;dn$1=false,hn$1="";}if(function(t){return ds(t,"ArrowRight",{shiftKey:"any"})}(t))Ts(e,ke$2,t);else if(function(t){return ds(t,"ArrowRight",hs)}(t))Ts(e,Te$2,t);else if(function(t){return ds(t,"ArrowLeft",{shiftKey:"any"})}(t))Ts(e,Ne$1,t);else if(function(t){return ds(t,"ArrowLeft",hs)}(t))Ts(e,be$1,t);else if(function(t){return ds(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Ts(e,we$1,t);else if(function(t){return ds(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Ts(e,Ee$3,t);else if(function(t){return ds(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:true})}(t))un$1=true,Ts(e,Oe$2,t);else if(function(t){return " "===t.key}(t))Ts(e,Me$2,t);else if(function(t){return i&&ds(t,"o",{ctrlKey:true})}(t))t.preventDefault(),un$1=true,Ts(e,de$4,true);else if(function(t){return ds(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))un$1=false,Ts(e,Oe$2,t);else if(function(t){return ds(t,"Backspace",{shiftKey:"any"})||i&&ds(t,"h",{ctrlKey:true})}(t))_s(t)?Ts(e,Ae$3,t):(t.preventDefault(),Ts(e,fe$4,true));else if(function(t){return "Escape"===t.key}(t))Ts(e,De$2,t);else if(function(t){return ds(t,"Delete",{})||i&&ds(t,"d",{ctrlKey:true})}(t))!function(t){return "Delete"===t.key}(t)?(t.preventDefault(),Ts(e,fe$4,false)):Ts(e,Pe$2,t);else if(function(t){return ds(t,"Backspace",gs)}(t))t.preventDefault(),Ts(e,ye$2,true);else if(function(t){return ds(t,"Delete",gs)}(t))t.preventDefault(),Ts(e,ye$2,false);else if(function(t){return i&&ds(t,"Backspace",{metaKey:true})}(t))t.preventDefault(),Ts(e,me$3,true);else if(function(t){return i&&(ds(t,"Delete",{metaKey:true})||ds(t,"k",{ctrlKey:true}))}(t))t.preventDefault(),Ts(e,me$3,false);else if(function(t){return ds(t,"b",hs)}(t))t.preventDefault(),Ts(e,xe,"bold");else if(function(t){return ds(t,"u",hs)}(t))t.preventDefault(),Ts(e,xe,"underline");else if(function(t){return ds(t,"i",hs)}(t))t.preventDefault(),Ts(e,xe,"italic");else if(function(t){return ds(t,"Tab",{shiftKey:"any"})}(t))Ts(e,Fe$2,t);else if(function(t){return ds(t,"z",hs)}(t))t.preventDefault(),Ts(e,Ce$2,void 0);else if(function(t){if(i)return ds(t,"z",{metaKey:true,shiftKey:true});return ds(t,"y",{ctrlKey:true})||ds(t,"z",{ctrlKey:true,shiftKey:true})}(t))t.preventDefault(),Ts(e,Se$2,void 0);else {const n=e._editorState._selection;null===n||Fr(n)?ps(t)&&(t.preventDefault(),Ts(e,Ue$2,t)):!function(t){return ds(t,"c",hs)}(t)?!function(t){return ds(t,"x",hs)}(t)?ps(t)&&(t.preventDefault(),Ts(e,Ue$2,t)):(t.preventDefault(),Ts(e,je$2,t)):(t.preventDefault(),Ts(e,Je$2,t));}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(Qe$1,t),true}function En$1(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const On$1=new Map;function Mn(t){const e=js(t.target);if(null===e)return;const n=Do(e.anchorNode);if(null===n)return;an$1&&(an$1=false,Ki(n,()=>{const r=Zr(),i=e.anchorNode;if(Ys(i)||Ko(i)){es(Xr(r,e,n,t));}}));const r=is(n),i=r[r.length-1],o=i._key,s=On$1.get(o),l=s||i;l!==n&&mn$1(e,l,false),mn$1(e,n,true),n!==i?On$1.set(o,n):s&&On$1.delete(o);}function An$1(t){t._lexicalHandled=true;}function Dn(t){return true===t._lexicalHandled}function Fn$1(e){const n=sn$1.get(e);if(void 0===n)return void 0;const r=ln$1.get(n);if(void 0===r)return void 0;const i=r-1;i>=0||t(164),sn$1.delete(e),ln$1.set(n,i),0===i&&n.removeEventListener("selectionchange",Mn);const o=Po(e);Ao(o)?(!function(t){if(null!==t._parentEditor){const e=is(t),n=e[e.length-1]._key;On$1.get(n)===t&&On$1.delete(n);}else On$1.delete(t._key);}(o),e.__lexicalEditor=null):o&&t(198);const s=En$1(e);for(let t=0;t<s.length;t++)s[t]();e.__lexicalEventHandles=[];}function Ln(t,e,n){xi();const r=t.__key,i=t.getParent();if(null===i)return;const o=function(t){const e=Qr();if(!Fr(e)||!Wi(t))return e;const{anchor:n,focus:r}=e,i=n.getNode(),o=r.getNode();As(i,t)&&n.set(t.__key,0,"element");As(o,t)&&r.set(t.__key,0,"element");return e}(t);let s=false;if(Fr(o)&&e){const e=o.anchor,n=o.focus;e.key===r&&(ni(e,t,i,t.getPreviousSibling(),t.getNextSibling()),s=true),n.key===r&&(ni(n,t,i,t.getPreviousSibling(),t.getNextSibling()),s=true);}else Ir(o)&&e&&t.isSelected()&&t.selectPrevious();if(Fr(o)&&e&&!s){const e=t.getIndexWithinParent();Jo(t),ti(o,i,e,-1);}else Jo(t);n||Is(i)||i.canBeEmpty()||!i.isEmpty()||Ln(i,e),e&&o&&Vi(i)&&i.isEmpty()&&i.selectEnd();}function In(t){return t}const Kn$1=Symbol.for("ephemeral");function zn(t){return t[Kn$1]||false}let Rn$1 = class Rn{__type;__key;__parent;__prev;__next;__state;static getType(){const{ownNodeType:e}=ul(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));}resetOnCopyNodeFrom(t){this.__state&&(this.__state=this.__state.getWritable(this).resetOnCopyNode());}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}),$o(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=Yo(t);if(null===e)break;t=e.__parent;}return false}isSelected(t){const e=t||Qr();if(null==e)return false;const n=e.getNodes().some(t=>t.__key===this.__key);if(Tr(this))return n;if(Fr(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return false;const t=this.getParent();if(ji(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:Yo(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(Is(n))return Wi(e)||e===this&&ji(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:Yo(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:Yo(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Wi(this)?this:this.getParent(),n=Wi(t)?t:t.getParent(),r=e&&n?Yl(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Yl(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===jl(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),false)))}isParentOf(t){const e=Yl(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=Wi(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=vi()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(zn(this))return this;const e=Yo(this.__key);return null===e&&t(113),e}getWritable(){if(zn(this))return this;xi();const t=Si(),e=vi(),n=t._nodeMap,r=this.__key,i=this.getLatest(),o=e._cloneNotNeeded,s=Qr();if(null!==s&&s.setCachedNodes(null),o.has(r))return jo(i),i;const l=il(i);return o.add(r),jo(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$3(n).flatKeys)t in e&&(void 0!==i&&i!==r||(i={...r}),i[t]=e[t]);return (n.__state||i)&&ft$2(t).updateFromJSON(i),n}(this,t)}static transform(){return null}remove(t){Ln(this,true,t);}replace(e,n){xi();let r=Qr();null!==r&&(r=r.clone()),Rs(this,e);const i=this.getLatest(),o=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;Jo(l);const u=i.getPreviousSibling(),f=i.getNextSibling(),d=i.__prev,h=i.__next,g=i.__parent;if(Ln(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&&(Wi(this)&&Wi(l)||t(139),this.getChildren().forEach(t=>{l.append(t);})),Fr(r)){es(r);const t=r.anchor,e=r.focus;t.key===o&&Dr(t,l),e.key===o&&Dr(e,l);}return Vo()===o&&Uo(s),l}insertAfter(t,e=true){xi(),Rs(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),o=Qr();let s=false,l=false;if(null!==i){const e=t.getIndexWithinParent();if(Jo(r),Fr(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&&Fr(o)){const t=this.getIndexWithinParent();ti(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){xi(),Rs(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;Jo(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=Qr();if(e&&Fr(a)){ti(a,this.getParentOrThrow(),c);}return t}isParentRequired(){return false}createParentElementNode(){return eo()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){xi();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Wi(n))return n.select();if(!Tr(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){xi();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Wi(n))return n.select(0,0);if(!Tr(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable();}reconcileObservedMutation(t,e){this.markDirty();}};function Bn(t){return t instanceof Rn$1}const Wn$1="historic",$n$1="history-push",Jn="history-merge",jn="paste",Un="collaboration",Vn="skip-collab",Yn="skip-scroll-into-view",qn="skip-dom-selection",Hn="skip-selection-focus",Gn="composition-start",Xn="composition-end",Qn=/\s*!important\s*$/i;function Zn(t){const e={};if(!t)return e;let n="",r="",i=null,o=false,s=false,l=false,c=0;for(let a=0;a<t.length;a++){const u=t[a];if(o)"*"===u&&"/"===t[a+1]&&(o=false,a++);else if(s)l?r+=u:n+=u,s=false;else if(null===i)if("/"!==u||"*"!==t[a+1])if('"'!==u&&"'"!==u)if("("!==u)if(")"!==u)if(l||":"!==u||0!==c){if(";"===u&&0===c){const t=n.trim(),i=r.trim();""!==t&&""!==i&&(e[t]=i),n="",r="",l=false;continue}l?r+=u:n+=u;}else l=true;else c=Math.max(0,c-1),l?r+=u:n+=u;else c++,l?r+=u:n+=u;else i=u,l?r+=u:n+=u;else o=true,a++;else l?r+=u:n+=u,"\\"===u?s=true:u===i&&(i=null);}const a=n.trim(),u=r.trim();return ""!==a&&""!==u&&(e[a]=u),e}function tr(t,e,n){const r=Qn.test(n)?"important":"",i=""===r?n:n.replace(Qn,"").trim();t.setProperty(e,i,r);}function er(t,e){for(const n in e){const r=e[n];null==r?t.removeProperty(n):tr(t,n,r);}}function nr(t,e,n=""){if(e===n)return;const r=Zn(n),i=Zn(e);for(const e in i)delete r[e],tr(t,e,i[e]);for(const e in r)t.removeProperty(e);}class rr extends Rn$1{static getType(){return "linebreak"}static clone(t){return new rr(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&&Xs(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&lr(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&lr(n))return true}}return false}(t)||function(t){const e=t.parentElement;if(null!==e&&Xs(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&lr(n))return false;const r=e.lastChild;if(r===t||r.previousSibling===t&&lr(r))return true}return false}(t)?null:{conversion:ir,priority:0}}}static importJSON(t){return or().updateFromJSON(t)}}function ir(t){return {node:or()}}function or(){return zs(new rr)}function sr(t){return t instanceof rr}function lr(t){return Ko(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function cr(t,e){return 16&e?"code":e&k$3?"mark":32&e?"sub":64&e?"sup":null}function ar(t,e){return 1&e?"strong":2&e?"em":"span"}function ur(t,e,n,r,i){const o=r.classList;let s=ms(i,"base");void 0!==s&&o.add(...s),s=ms(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 z$7){const r=z$7[t];if(s=ms(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 fr(t,e,n){const r=e.firstChild,i=n.isComposing(),s=t+(i?A$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 dr(t,e,n,r,i,o){fr(i,t,e);const s=o.theme.text;void 0!==s&&ur(0,0,r,t,s);}function hr(t,e){const n=document.createElement(e);return n.appendChild(t),n}class gr extends Rn$1{__text;__format;__style;__mode;__detail;static getType(){return "text"}static clone(t){return new gr(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 J$7[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===Vo()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return !!(1&this.getLatest().__detail)}isUnmergeable(){return !!(2&this.getLatest().__detail)}hasFormat(t){const e=z$7[t];return 0!==(this.getFormat()&e)}isSimpleText(){return "text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return Bo(this.getLatest().__format,t,e)}canHaveFormat(){return true}isInline(){return true}createDOM(t,e){const n=this.__format,r=cr(0,n),i=ar(0,n),o=null===r?i:r,s=document.createElement(o);let l=s;this.hasFormat("code")&&s.setAttribute("spellcheck","false"),null!==r&&(l=document.createElement(i),s.appendChild(l));dr(l,this,0,n,this.__text,t);const c=this.__style;return ""!==c&&nr(s.style,c),s}updateDOM(e,n,r){const i=this.__text,o=e.__format,s=this.__format,l=cr(0,o),c=cr(0,s),a=ar(0,o),u=ar(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 dr(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)),fr(i,f,this);const d=r.theme.text;void 0!==d&&o!==s&&ur(0,o,s,f,d);const h=e.__style,g=this.__style;return h!==g&&nr(n.style,g,h),false}static importDOM(){return {"#text":()=>({conversion:xr,priority:0}),b:()=>({conversion:pr,priority:0}),code:()=>({conversion:vr,priority:0}),em:()=>({conversion:vr,priority:0}),i:()=>({conversion:vr,priority:0}),mark:()=>({conversion:vr,priority:0}),s:()=>({conversion:vr,priority:0}),span:()=>({conversion:_r,priority:0}),strong:()=>({conversion:vr,priority:0}),sub:()=>({conversion:vr,priority:0}),sup:()=>({conversion:vr,priority:0}),u:()=>({conversion:vr,priority:0})}}static importJSON(t){return kr().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 Ys(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=hr(n,"b")),this.hasFormat("italic")&&(n=hr(n,"i")),this.hasFormat("strikethrough")&&(n=hr(n,"s")),this.hasFormat("underline")&&(n=hr(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?z$7[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?R$4[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=Bo(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=$$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){xi();let n=t,r=e;const i=Qr(),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(!Fr(i))return Yr(s,n,s,r,"text","text");{const t=Vo();t!==i.anchor.key&&t!==i.focus.key||Uo(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=Qr();if(r&&Fr(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){xi();const e=this.getLatest(),n=e.getTextContent();if(""===n)return [];const r=e.__key,i=Vo(),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=Qr();if(Fr(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=kr(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=yt$6(e,f),_=true):f=e.setTextContent(a);const x=[f];for(let t=1;t<c;t++){const n=kr(s[t]);n.__format=d,n.__style=h,n.__detail=g,n.__state=yt$6(e,n);const o=n.__key;i===r&&Uo(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&&jo(e);null!==n&&jo(n);}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),Fr(m)&&ti(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;Vo()===i&&Uo(r);const l=Qr();if(Fr(l)){const t=l.anchor,o=l.focus;null!==t&&t.key===i&&ri(t,n,r,e,s),null!==o&&o.key===i&&ri(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 _r(t){return {forChild:Nr(t.style),node:null}}function pr(t){const e=t,n="normal"===e.style.fontWeight;return {forChild:Nr(e.style,n?void 0:"bold"),node:null}}const yr=new WeakMap;function mr(t){if(!Ys(t))return false;if("PRE"===t.nodeName)return true;const e=t.style.whiteSpace;return "string"==typeof e&&e.startsWith("pre")}function xr(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=yr.get(n))&&!mr(n);)r.push(n),n=n.parentNode;const i=void 0===e?n:e;for(let t=0;t<r.length;t++)yr.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(or()):"\t"===n?e.push(wr()):""!==n&&e.push(kr(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=Cr(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=Cr(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}:{node:kr(r)}}function Cr(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,Ys(n)){const t=n.style.display;if(""===t&&!Gs(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(Ko(n))return n;if("BR"===n.nodeName)return null}}const Sr={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function vr(t){const e=Sr[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Nr(t.style,e),node:null}}function kr(t=""){return zs(new gr(t))}function Tr(t){return t instanceof gr}function Nr(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=>Tr(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 br extends gr{static getType(){return "tab"}static clone(t){return new br(t.__key)}constructor(t){super("\t",t),this.__detail=2;}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=ms(t.theme,"tab");if(void 0!==n){e.classList.add(...n);}return e}static importJSON(t){return wr().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 wr(){return zs(new br)}function Er(t){return t instanceof br}class Or{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 Jl(rc(ql(this,"next")),rc(ql(t,"next")))<0}getNode(){const e=Yo(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,mi()||(Vo()===o&&Uo(t),null!==i&&(i.setCachedNodes(null),i.dirty=true)));}}function Mr(t,e,n){return new Or(t,e,n)}function Ar(t,e){let n=e.__key,r=t.offset,i="element";if(Tr(e)){i="text";const t=e.getTextContentSize();r>t&&(r=t);}else if(!Wi(e)){const t=e.getNextSibling();if(Tr(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 Dr(t,e){if(Wi(e)){const n=e.getLastDescendant();Wi(n)||Tr(n)?Ar(t,n):Ar(t,e);}else Ar(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(!Ir(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(Tr(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=Yo(t);null!==e&&n.push(e);}return mi()||(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((Qr()||Zr())===this&&t[0]){const e=Ol(t[0],"next");Gl(Wl(e,e));}for(const e of t)e.remove();}}function Fr(t){return t instanceof Lr}class Lr{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 !!Fr(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(Nl(n)){const{origin:t}=n;0===e.length?i.add(t):(o.add(t),e.push(t));}else {const{origin:t}=n;Wi(t)&&o.has(t)||e.push(t);}r&&e.push(r.caret.origin);if(Tl(t.focus)&&Wi(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=Pl(t.focus.origin,"previous");Nl(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=Ll(n))i.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!Wi(t)||o.has(t)||t.isEmpty()||i.has(t))break;e.pop();}if(0===e.length&&t.isCollapsed()){const n=rc(t.anchor),r=rc(t.anchor.getFlipped()),i=t=>vl(t)?t.origin:t.getNodeAtCaret(),o=i(n)||i(r)||(t.anchor.getNodeAtCaret()?n.origin:r.origin);e.push(o);}return e}(sc(Ql(this),"next"));return mi()||(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]=zr(this);let c="",a=true;for(let u=0;u<t.length;u++){const f=t[u];if(Wi(f)&&!f.isInline())a||(c+="\n"),a=!f.isEmpty();else if(a=false,Tr(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 !ji(f)&&!sr(f)||f===n&&this.isCollapsed()||(c+=f.getTextContent());}return c}applyDOMRange(t){const e=vi(),n=e.getEditorState()._selection,r=Ur(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$3(this);}clone(){const t=this.anchor,e=this.focus;return new Lr(Mr(t.key,t.offset,t.type),Mr(e.key,e.offset,e.type),this.format,this.style)}toggleFormat(t){this.format=Bo(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=z$7[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(or()):"\t"===r?n.push(wr()):n.push(kr(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=kr();if(s.setFormat(n),s.setStyle(r),no(o))o.splice(0,0,[s]);else {const t=Vi(i)?eo().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&&Hl(l,rc(ql(l,"next")));const c=s.offset;let a=l.offset;const u=this.getNodes(),f=u.length;let d=u[0];Tr(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&&(Io(d)||!d.canInsertTextAfter()||!g.canInsertTextAfter()&&null===d.getNextSibling())){let t=d.getNextSibling();if(Tr(t)&&t.canInsertTextBefore()&&!Io(t)||(t=kr(),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&&(Io(d)||!d.canInsertTextBefore()||!g.canInsertTextBefore()&&null===d.getPreviousSibling())){let t=d.getPreviousSibling();if(Tr(t)&&!Io(t)||(t=kr(),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=kr(d.getTextContent());t.setFormat(i),d.replace(t),d=t;}else if(!this.isCollapsed()&&""!==e){const t=_.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||Wi(t)&&(!t.canInsertTextBefore()||!t.canInsertTextAfter()))return this.insertText(""),jr(this.anchor,this.focus),void this.insertText(e)}if(1===f){if(Lo(d)){const t=kr(e);return t.select(),void d.replace(t)}const t=d.getFormat(),n=d.getStyle();if(c!==a||t===i&&n===o){if(Er(d)){const t=kr(e);return t.setFormat(i),t.setStyle(o),t.select(),void d.replace(t)}}else {if(""!==d.getTextContent()){const t=kr(e);if(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&&(this.format=t,this.style=n,d.isComposing()&&(this.anchor.offset-=e.length));}else {const t=new Set([...d.getParentKeys(),..._.getParentKeys()]),n=Wi(d)?d:d.getParentOrThrow();let r=Wi(_)?_:_.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(Tr(_)&&!Lo(_)&&a!==_.getTextContentSize()){if(_.isSegmented()){const t=kr(_.getTextContent());_.replace(t),_=t;}Vi(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];if(e.is(d)||Wi(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(Lo(d))if(c===h)d.select();else {const t=kr(e);t.select(),d.replace(t);}else d=d.spliceText(c,h-c,e,true),""===d.getTextContent()?d.remove():"text"===this.anchor.type&&(this.format=d.getFormat(),this.style=d.getStyle(),d.isComposing()&&(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=Qr()===this;Xl(this,nc(Ql(this))),t&&Qr()!==this&&es(this);}formatText(t,e=null){if(this.isCollapsed())return this.toggleFormat(t),void Uo(null);const n=this.getNodes(),r=[];for(const t of n)Tr(t)&&r.push(t);const i=e=>{n.forEach(n=>{if(Wi(n)){const r=n.getFormatFlags(t,e);n.setTextFormat(r);}});},o=r.length;if(0===o)return this.toggleFormat(t),Uo(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(Io(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||Io(d)||([,d]=d.splitText(h),h=0),d.setFormat(g);const m=p.getFormatFlags(t,g);y>0&&(y===p.getTextContentSize()||Io(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=Qr();return Fr(n)||t(134),n.insertNodes(e)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=dl(n,Qs),i=e[e.length-1];if(Wi(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else {const t=ai(this);r.splice(t,0,e),i.selectEnd();}return}if(!e.some(t=>(Wi(t)||ji(t))&&!t.isInline())){Wi(r)||t(211,n.constructor.name,n.getType());const o=ai(this);return r.splice(o,0,e),void i.selectEnd()}const o=function(t){const e=eo();let n=null;for(let r=0;r<t.length;r++){const i=t[r],o=sr(i);if(o||ji(i)&&i.isInline()||Wi(i)&&i.isInline()||Tr(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=!Wi(r)||!r.isEmpty()?this.insertParagraph():null,a=l[l.length-1];let u=l[0];var f;Wi(f=u)&&Qs(f)&&!f.isEmpty()&&Wi(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(Wi(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=dl(s,Qs);c&&Wi(d)&&(c.canMergeWhenEmpty()||Qs(a))&&(d.append(...c.getChildren()),c.remove()),Wi(r)&&r.isEmpty()&&r.remove(),s.selectEnd();const h=Wi(r)?r.getLastChild():null;sr(h)&&d!==r&&h.remove();}insertParagraph(){if("root"===this.anchor.key){const t=eo();return Zo().splice(this.anchor.offset,0,[t]),t.select(),t}const e=ai(this),n=dl(this.anchor.getNode(),Qs);Wi(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=or();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]=zr(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(Tr(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(Tr(n)&&(a===n.getTextContentSize()?t.shift():0!==a&&([,n]=n.splitText(a),t[0]=n,l.set(n.getKey(),0,"text"))),Tr(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(fi(this,t,e,n))return;const r="move"===t,i=vi(),o=Js(Ps(i));if(!o)return;const s=i._blockCursorElement,l=i._rootElement,c=this.focus.getNode();if(null===l||null===s||!Wi(c)||c.isInline()||c.canBeEmpty()||$s(s,i,l),this.dirty){let t=Ns(i,this.anchor.key),e=Ns(i,this.focus.key);"text"===this.anchor.type&&(t=Ro(t)),"text"===this.focus.type&&(e=Ro(e)),t&&e&&ii(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=Vi(n)?n:Ls(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];As(e,i)?r.push(e):s=true;}if(s&&r.length>0)if(e){const t=r[0];Wi(t)?t.selectStart():t.getParentOrThrow().selectStart();}else {const t=r[r.length-1];Wi(t)?t.selectEnd():t.getParentOrThrow().selectEnd();}o.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&&fi(this,t,e,n,"decorators");}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Wi(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(Wi(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=Rl(ql(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(Nl(e))if(e.origin.isInline());else {if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Wi(r.anchor.origin)&&r.anchor.origin.isEmpty()){const t=rc(e);Xl(this,Wl(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(Tl(e)){if(Wi(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(ji(e.origin)){if(e.origin.isIsolated());else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Wi(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const t=Hr();t.add(e.origin.getKey()),es(t);}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;return Xl(this,Wl(!e.origin.isEmpty()&&n.isEmpty()?Zl(Ol(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&&Rr(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 Wr(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 Wr(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 !(rs(t)||Br(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()&&Vi(t.getParent())&&null===t.getPreviousSibling()&&Rr(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.isCollapsed()?this.deleteCharacter(t):this.removeText();}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return [this.anchor,this.focus]}}function Ir(t){return t instanceof Pr}function Kr(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function zr(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]:[Kr(n),Kr(r)]}function Rr(t,e){for(let n=e;n;n=n.getParent()){if(Wi(n)){if(n.collapseAtStart(t))return true;if(Is(n))break}if(n.getPreviousSibling())break}return false}const Br=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("\u2764\ufe0f")&&e("#\ufe0f\u20e3")&&e("\u{1f44d}"))return e}catch(t){}return ()=>false})();function Wr(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 $r(e,n,r,i){let o,s=n;if(Ys(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=ns(f),Tr(o))s=Al(o,l?"next":"previous");else {let c=ns(e);if(null===c)return null;if(Wi(c)){const a=i.getElementByKey(c.getKey());null===a&&t(214);const u=tl(i).$getDOMSlot(c,a,i);[c,s]=u.resolveChildIndex(c,a,e,n),Wi(c)||t(215),l&&s>=c.getChildrenSize()&&(s=Math.max(0,c.getChildrenSize()-1));let f=c.getChildAtIndex(s);if(Wi(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=Wi(f)?f:f.getParentOrThrow()),s=0;}Tr(f)?(o=f,c=null,s=Al(f,l?"next":"previous")):f!==c&&l&&!d&&(Wi(c)||t(216),s=Math.min(c.getChildrenSize(),s+1));}else {const t=c.getIndexWithinParent();s=0===n&&ji(c)&&ns(e)===c?t:t+1,c=c.getParentOrThrow();}if(Wi(c))return Mr(c.__key,s,"element")}}else o=ns(e);return Tr(o)?Mr(o.__key,Al(o,s,"clamp"),"text"):null}function Jr(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&&Wi(o)&&o.isInline()){const e=o.getPreviousSibling();Tr(e)&&t.set(e.__key,e.getTextContent().length,"text");}}else Wi(r)&&!n&&r.isInline()?t.set(r.__key,r.getChildrenSize(),"element"):Tr(r)&&t.set(r.__key,r.getTextContent().length,"text");}else if(r===i.getTextContent().length){const r=i.getNextSibling(),o=i.getParent();if(e&&Wi(r)&&r.isInline())t.set(r.__key,0,"element");else if((n||e)&&null===r&&Wi(o)&&o.isInline()&&!o.canInsertTextAfter()){const e=o.getNextSibling();Tr(e)&&t.set(e.__key,0,"text");}}}function jr(t,e,n){if("text"===t.type&&"text"===e.type){const n=t.isBefore(e),r=t.is(e);Jr(t,n,r),Jr(e,!n,r),r&&e.set(t.key,t.offset,t.type);}}function Ur(t,e,n,r,i,o){if(null===t||null===n||!Mo(i,t,n))return null;const s=$r(t,e,Fr(o)?o.anchor:null,i);if(null===s)return null;const l=$r(n,r,Fr(o)?o.focus:null,i);if(null===l)return null;if("element"===s.type&&"element"===l.type){const e=ns(t),r=ns(n);if(ji(e)&&ji(r))return null}return jr(s,l),[s,l]}function Vr(t){return Wi(t)&&!t.isInline()}function Yr(t,e,n,r,i,o){const s=Si(),l=new Lr(Mr(t,e,i),Mr(n,r,o),0,"");return l.dirty=true,s._selection=l,l}function qr(){const t=Mr("root",0,"element"),e=Mr("root",0,"element");return new Lr(t,e,0,"")}function Hr(){return new Pr(new Set)}function Gr(t,e){return Xr(null,t,e,null)}function Xr(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$7&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&o&&3===o.detail||"drop"===s||void 0===s);let a,u,f,d;if(Fr(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)&&Fr(t)&&!Mo(n,a,u))return t.clone();const h=Ur(a,f,u,d,n,t);if(null===h)return null;const[g,_]=h;let p=0,y="";if(Fr(t)){const e=t.anchor;if(g.key===e.key)p=t.format,y=t.style;else {const t=g.getNode();Tr(t)?(p=t.getFormat(),y=t.getStyle()):Wi(t)&&(p=t.getTextFormat(),y=t.getTextStyle());}}return new Lr(g,_,p,y)}function Qr(){return Si()._selection}function Zr(){return vi()._editorState._selection}function ti(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"),ei(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");}}ei(t);}function ei(t){const e=t.anchor,n=e.offset,r=t.focus,i=r.offset,o=e.getNode(),s=r.getNode();if(t.isCollapsed()){if(!Wi(o))return;const t=o.getChildrenSize(),i=n>=t,s=i?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(Tr(s)){let t=0;i&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),r.set(s.__key,t,"text");}return}if(Wi(o)){const t=o.getChildrenSize(),r=n>=t,i=r?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(Tr(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text");}}if(Wi(s)){const t=s.getChildrenSize(),e=i>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(i);if(Tr(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text");}}}function ni(t,e,n,r,i){let o=null,s=0,l=null;null!==r?(o=r.__key,Tr(r)?(s=r.getTextContentSize(),l="text"):Wi(r)&&(s=r.getChildrenSize(),l="element")):null!==i&&(o=i.__key,Tr(i)?l="text":Wi(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 ri(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 ii(t,e,n,r,i){try{t.setBaseAndExtent(e,n,r,i);}catch(t){}}function oi(t,e,n){const r=Ns(t,e.getKey());if(Wi(e)){const i=tl(t).$getDOMSlot(e,r,t);return [i.element,n+i.getFirstChildOffset()]}return [r,n]}function si(t,e,n,r,i,s,l){const c=r.anchorNode,a=r.focusNode,u=r.anchorOffset,f=r.focusOffset,d=document.activeElement;if(i.has(Un)&&d!==s||null!==d&&Oo(d))return;if(!Fr(e))return void(null!==t&&Mo(n,c,a)&&r.removeAllRanges());const h=e.anchor,g=e.focus,_=h.getNode(),p=g.getNode(),[y,m]=oi(n,_,h.offset),[x,C]=oi(n,p,g.offset),S=e.format,v=e.style,k=e.isCollapsed();let T=y,N=x,b=false;var w,E,O,M,A;if(("text"===h.type?(T=Ro(y),b=_.getFormat()!==S||_.getStyle()!==v):Fr(t)&&"text"===t.anchor.type&&(b=true),"text"===g.type&&(N=Ro(x)),null!==T&&null!==N)&&(k&&(null===t||b||Fr(t)&&(t.format!==S||t.style!==v))&&(w=S,E=v,O=m,M=h.key,A=performance.now(),_n$1=[w,E,O,M,A]),u!==m||f!==C||c!==T||a!==N||"Range"===r.type&&k||(null!==d&&s.contains(d)||i.has(Hn)||s.focus({preventScroll:true}),"element"===h.type))){if(ii(r,T,m,N,C),!o||!e.isCollapsed()||null===s||i.has(Hn)||null!==document.activeElement&&s.contains(document.activeElement)||s.focus({preventScroll:true}),!i.has(Yn)&&e.isCollapsed()&&null!==s&&s===document.activeElement){const t=Fr(e)&&"element"===e.anchor.type?T.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=ws(n),i=Ds(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=Ps(t).innerHeight;const e=i.getComputedStyle(r.documentElement),n=parseFloat(e.scrollPaddingTop),o=parseFloat(e.scrollPaddingBottom);isFinite(n)&&(l+=n),isFinite(o)&&(c-=o);}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=bs(a);}}(n,e,s);}}cn$1=true;}}function li(t){let e=Qr()||Zr();null===e&&(e=Zo().selectEnd()),e.insertNodes(t);}function ci(){const t=Qr();return null===t?"":t.getTextContent()}function ai(e){let n=e;e.isCollapsed()||n.removeText();const r=Qr();Fr(r)&&(n=r),Fr(n)||t(161);const i=n.anchor;let o=i.getNode(),s=i.offset;for(;!Qs(o);){const t=o;if([o,s]=ui(o,s),t.is(o))break}return s}function ui(t,e){const n=t.getParent();if(!n){const t=eo();return Zo().append(t),t.select(),[Zo(),0]}if(Tr(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(!Wi(t)||0===e)return [n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new Lr(Mr(t.__key,e,"element"),Mr(t.__key,e,"element"),0,""),i=t.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings());}return [n,t.getIndexWithinParent()+1]}function fi(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=ql(t.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===e;let c=o,a="decorators-and-blocks"===i;if(!ic(c)){for(const t of c){a=false;const{origin:e}=t;if(!ji(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of Rl(o).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(Nl(t))t.origin.isInline()||(c=t);else {if(Wi(t.origin))continue;ji(t.origin)&&!t.origin.isInline()&&(c=t);}break}}if(c===o)return false;if(l&&!s&&ji(c.origin)&&c.origin.isKeyboardSelectable()){const t=Hr();return t.add(c.origin.getKey()),es(t),true}return c=rc(c),l&&Hl(t.anchor,c),Hl(t.focus,c),a||!s}let di=null,hi=null,gi=false,_i=false,pi=0;const yi={characterData:true,childList:true,subtree:true};function mi(){return gi||null!==di&&di._readOnly}function xi(){gi&&t(13);}function Ci(){pi>99&&t(14);}function Si(){return null===di&&t(195,ki()),di}function vi(){return null===hi&&t(337,ki()),hi}function ki(){let t=0;const e=new Set,n=Co.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const i=Po(r);if(Ao(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 Ti(){return hi}function Ni(t,e,n){const r=e.__type,i=No(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 bi(t,e){return void 0!==t&&t.__key!==e&&t.isAttached()}function wi(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 Ei(t){return Oi(t,vi()._nodes)}function Oi(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(Wi(s)&&Array.isArray(l))for(let t=0;t<l.length;t++){const e=Oi(l[t],n);s.append(e);}return s}function Mi(t,e,n){const r=di,i=gi,o=hi;di=e,gi=true,hi=t;try{return n()}finally{di=r,gi=i,hi=o;}}function Ai(t,e){const n=t._pendingEditorState,r=t._rootElement,i=t._headless||null===r;if(null===n)return void(t._deferred.length>0&&Fi(t,t._deferred));const o=t._editorState,s=o._selection,l=n._selection,c=0!==t._dirtyType,a=di,u=gi,f=hi,d=t._updating,h=t._observer;let g=null;if(t._pendingEditorState=null,t._editorState=n,!i&&c&&null!==h){hi=t,di=n,gi=false,t._updating=true;try{const e=t._dirtyType,r=t._dirtyElements,i=t._dirtyLeaves;h.disconnect(),g=ee$4(o,n,t,e,r,i);}catch(e){if(e instanceof Error&&t._onError(e),_i)throw e;return go(t,null,r,n),rt$4(t),t._dirtyType=2,_i=true,Ai(t,o),void(_i=false)}finally{h.observe(r,yi),t._updating=d,di=a,gi=u,hi=f;}}n._readOnly||(n._readOnly=true);const _=t._dirtyLeaves,p=t._dirtyElements,y=t._normalizedNodes,m=t._updateTags,x=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;for(o in r)i.has(o)||(r===n&&(r=Xo(t)),delete r[o]);}(t,n);const C=i?null:Js(Ps(t));if(t._editable&&null!==C&&(c||null===l||l.dirty||!l.is(s))&&null!==r&&!m.has(qn)){hi=t,di=n;try{if(null!==h&&h.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&$s(e,t,r),si(s,l,t,C,m,r);}!function(t,e,n){let r=t._blockCursorElement;if(Fr(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()){Ws(o.getChildAtIndex(s-1))&&(l=!0);}else {const e=o.getChildAtIndex(s);if(null!==e&&Ws(e)){const n=e.getPreviousSibling();(null===n||Ws(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=yc(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!==h&&h.observe(r,yi),hi=f,di=a;}}null!==g&&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,g,m,_,o),Fr(l)||null===l||null!==s&&s.is(l)||t.dispatchCommand(ie$4,void 0);const S=t._pendingDecorators;null!==S&&(t._decorators=S,t._pendingDecorators=null,Di("decorator",t,true,S)),function(t,e,n){const r=Qo(e),i=Qo(n);r!==i&&Di("textcontent",t,true,i);}(t,e||o,n),Di("update",t,true,{dirtyElements:p,dirtyLeaves:_,editorState:n,mutatedNodes:g,normalizedNodes:y,prevEditorState:e||o,tags:m}),Fi(t,x),function(t){const e=t._updates;if(0!==e.length){const n=e.shift();if(n){const[e,r]=n;Ii(t,e,r);}}}(t);}function Di(t,e,n,...r){const i=e._updating;e._updating=n;try{const n=e._listeners[t],i=Array.from(n);for(const[t,e]of i){e&&e();const i=t(...r);n.has(t)?n.set(t,i):i&&i();}}finally{e._updating=i;}}function Pi(t,e,n,r){const i=is(t);let o;for(let t=4;t>=0;t--)for(let s=0;s<i.length;s++){const l=i[s];if(s>0&&l._updating){o=l;break}const c=l._commands.get(e);if(void 0!==c){const e=c[t];if(e.size>0){let t=false;if(Ki(l,()=>{for(const i of e)if(i(n,r))return void(t=true)}),t)return t}}}return o&&o.update(()=>{Pi(o,e,n,r);}),false}function Fi(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;}}}function Li(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),wi(e,o.tag)),null==s?Ii(e,r,o):r();}}return i}function Ii(e,n,r){const i=e._updateTags;let o,s=false,l=false;void 0!==r&&(o=r.onUpdate,wi(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=Yi(a||c),u=true),a._flushSync=l;const f=di,d=gi,h=hi,g=e._updating;di=a,gi=false,e._updating=true,hi=e;const _=e._headless||null===e.getRootElement();vo(null);try{u&&(_?null!==c._selection&&(a._selection=c._selection.clone()):a._selection=function(t,e){const n=t.getEditorState()._selection,r=Js(Ps(t));return Fr(n)||null==n?Xr(n,r,t,e):n.clone()}(e,r&&r.event||null));const i=e._compositionKey;n(),s=Li(e,s),function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(Fr(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);Tr(e)&&e.isAttached()&&e.isSimpleText()&&!e.isUnmergeable()&&Ct$2(e);}}(a,e):function(t,e){const n=e._dirtyLeaves,r=e._dirtyElements,i=t._nodeMap,o=Vo(),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);Tr(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&Ct$2(r),void 0!==r&&bi(r,o)&&Ni(e,r,s),n.add(t);}if(l=e._dirtyLeaves,c=l.size,c>0){pi++;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&&bi(c,o)&&Ni(e,c,s);}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,pi++;}e._dirtyLeaves=n,e._dirtyElements=r;}(a,e),Li(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()||(Wi(e)&&Y$5(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(Fr(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 Ir(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 Ai(e)}finally{di=f,gi=d,hi=h,e._updating=g,pi=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,Ai(e)):u&&wo(()=>{Ai(e);}):(a._flushSync=false,u&&(i.clear(),e._deferred=[],e._pendingEditorState=null));}function Ki(t,e,n){hi===t&&void 0===n?e():Ii(t,e,n);}class zi{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null;}withBefore(t){return new zi(this.element,t,this.after)}withAfter(t){return new zi(this.element,this.before,t)}withElement(t){return this.element===t?this:new zi(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||l||a);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.setProperty("display","inline","important"),t.style.setProperty("border","0px","important"),t.style.setProperty("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=Ri(e,n);i.push(r);const o=Ri(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 Ri(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 Bi extends Rn$1{__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 W$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=vi()._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(Tr(e)&&t.push(e),Wi(e)){const n=e.getAllTextNodes();t.push(...n);}e=e.getNextSibling();}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Wi(t);){const e=t.getFirstChild();if(null===e)break;t=e;}return t}getLastDescendant(){let t=this.getLastChild();for(;Wi(t);){const e=t.getLastChild();if(null===e)break;t=e;}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return Wi(t)&&t.getLastDescendant()||t||null}const r=e[t];return Wi(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:Yo(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:Yo(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(),Wi(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(),Wi(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=B$5[t];return 0!==(this.getFormat()&e)}return false}hasTextFormat(t){const e=z$7[t];return 0!==(this.getTextFormat()&e)}getFormatFlags(t,e){return Bo(this.getLatest().__textFormat,t,e)}getTextStyle(){return this.getLatest().__textStyle}select(t,e){xi();const n=Qr();let r=t,i=e;const o=this.getChildrenSize();if(!this.canBeEmpty())if(0===t&&0===e){const t=this.getFirstChild();if(Tr(t)||Wi(t))return t.select(0,0)}else if(!(void 0!==t&&t!==o||void 0!==e&&e!==o)){const t=this.getLastChild();if(Tr(t)||Wi(t))return t.select()} void 0===r&&(r=o),void 0===i&&(i=o);const s=this.__key;return Fr(n)?(n.anchor.set(s,r,"element"),n.focus.set(s,i,"element"),n.dirty=true,n):Yr(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();return 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&&B$5[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){zn(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;Jo(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--,Jo(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=Qr();if(Fr(t)){const e=new Set(c),n=new Set(l),{anchor:r,focus:i}=t;$i(r,e,n)&&ni(r,r.getNode(),this,u,a),$i(i,e,n)&&ni(i,i.getNode(),this,u,a),0!==f||this.canBeEmpty()||Is(this)||this.remove();}}return o}getDOMSlot(t){return new zi(t)}exportDOM(t){const{element:e}=super.exportDOM(t);if(Ys(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&&""===n||Is(this)||this.getChildren().some(Tr)||(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=tl(e).$getDOMSlot(this,t,e);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 Wi(t){return t instanceof Bi}function $i(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 Ji extends Rn$1{decorate(t,e){return null}isIsolated(){return false}isInline(){return true}isKeyboardSelectable(){return true}}function ji(t){return t instanceof Ji}class Ui extends Bi{__cachedText;static getType(){return "root"}static clone(){return new Ui}constructor(){super("root"),this.__cachedText=null;}getTopLevelElementOrThrow(){t(51);}getTextContent(){const t=this.__cachedText;return !mi()&&0!==vi()._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)Wi(e)||ji(e)||t(282);return super.splice(e,n,r)}static importJSON(t){return Zo().updateFromJSON(t)}collapseAtStart(){return true}}function Vi(t){return t instanceof Ui}function Yi(t){return new Xi(new Map(t._nodeMap))}function qi(){return new Xi(new Map([["root",new Ui]]))}function Hi(e){const n=e.exportJSON(),r=e.constructor;if(n.type!==r.getType()&&t(130,r.name),Wi(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=Hi(o[t]);i.push(e);}}return n}function Gi(t){return t instanceof Xi}class Xi{_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 Mi(e&&e.editor||null,this,t)}clone(t){const e=new Xi(this._nodeMap,void 0===t?this._selection:t);return e._readOnly=true,e}toJSON(){return Mi(null,this,()=>({root:Hi(Zo())}))}}class Qi extends Bi{static getType(){return "artificial"}createDOM(t){return document.createElement("div")}}class Zi extends Bi{static getType(){return "paragraph"}static clone(t){return new Zi(t.__key)}createDOM(t){const e=document.createElement("p"),n=ms(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:to,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Ys(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);}return {element:e}}static importJSON(t){return eo().updateFromJSON(t)}exportJSON(){const t=super.exportJSON();if(void 0===t.textFormat||void 0===t.textStyle){const e=this.getChildren().find(Tr);e?(t.textFormat=e.getFormat(),t.textStyle=e.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle());}return t}insertNewAfter(t,e){const n=eo();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||Tr(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 to(t){const e=eo();if(t.style&&(e.setFormat(t.style.textAlign),sl(t,e)),""===e.getFormatType()){const n=t.getAttribute("align");n&&n&&n in B$5&&e.setFormat(n);}return {node:e}}function eo(){return zs(new Zi)}function no(t){return t instanceof Zi}const ro=0,io=1,oo=2,so=3,lo=4,co=-8,ao=-7,uo=-6,fo=-5,ho=-4;function go(t,e,n,r){const i=t._keyToDOMMap;i.clear(),t._editorState=qi(),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 _o(t){const e=new Set,n=new Set;let r=t;for(;r;){const{ownNodeConfig:t}=ul(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 Rn$1&&t!==Rn$1?t:void 0;}}return e}const po={$createDOM:(t,e)=>t.createDOM(e._config,e),$decorateDOM:(t,e,n,r)=>{},$exportDOM:(t,e)=>{const n=bo(e,t.getType());return n&&void 0!==n.exportDOM?n.exportDOM(e,t):t.exportDOM(e)},$extractWithChild:(t,e,n,r,i)=>Wi(t)&&t.extractWithChild(e,n,r),$getDOMSlot:(e,n,r)=>(Wi(e)||t(336,e.getKey(),e.getType()),e.getDOMSlot(n)),$shouldExclude:(t,e,n)=>Wi(t)&&t.excludeFromCopy("html"),$shouldInclude:(t,e,n)=>!e||t.isSelected(e),$updateDOM:(t,e,n,r)=>t.updateDOM(e,n,r._config)};function yo(t){const e=t||{},n=Ti(),r=e.theme||{},i=void 0===t?n:e.parentEditor||null,o=e.disableEvents||false,s=qi(),l=e.namespace||(null!==i?i._config.namespace:os()),c=e.editorState,a=[Ui,gr,rr,br,Zi,Qi,...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;}ul(e);const i=e.getType(),o=_o(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 Co(s,i,h,{disableEvents:o,dom:{...po,...t&&t.dom},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),function(t){t.registerCommand(le$3,vn$1,ro),t.registerCommand(ce$4,kn$1,ro),t.registerCommand(ae$4,Tn$1,ro),t.registerCommand(ue$4,Nn$1,ro),t.registerCommand(ve$2,wn$1,ro);}(g),g}function mo(t,e){const n=t.get(e);t.delete(e),n&&n();}function xo(t,e,n){return t.set(e,n),mo.bind(null,t,e)}class Co{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 Map,editable:new Map,mutation:new Map,root:new Map,textcontent:new Map,update:new Map},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=os(),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){return xo(this._listeners.update,t)}registerEditableListener(t){return xo(this._listeners.editable,t)}registerDecoratorListener(t){return xo(this._listeners.decorator,t)}registerTextContentListener(t){return xo(this._listeners.textcontent,t)}registerRootListener(t){const e=this._listeners.root;return Cc(xo(e,t,t(this._rootElement,null)||void 0),()=>function(t,e,n){const r=t.get(e);r&&r(),t.set(e,e(...n)||void 0);}(e,t,[null,this._rootElement]))}registerCommand(e,n,r){ void 0===r&&t(35);const i=this._commands;i.has(e)||i.set(e,[new V$7,new V$7,new V$7,new V$7,new V$7]);const o=i.get(e);void 0===o&&t(36,String(e));const s=function(t){return 7&t}(r),l=o[s];return s!==r?l.addFront(n):l.addBack(n),()=>{l.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=rl(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=rl(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=Yo(e);t&&t.markDirty();}},null===t._pendingEditorState?{tag:Jn}: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 Ts(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=ms(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,go(this,e,t,r),null!==e&&(this._config.disableEvents||Fn$1(e),null!=n&&e.classList.remove(...n)),null!==t){const e=Ds(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$4(this),this._updateTags.add(Jn),Ai(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;sn$1.set(t,n);const r=ln$1.get(n)??0;r<1&&n.addEventListener("selectionchange",Mn),ln$1.set(n,r+1),t.__lexicalEditor=e;const i=En$1(t);for(let n=0;n<tn$1.length;n++){const[r,o]=tn$1[n],s="function"==typeof o?t=>{Dn(t)||(An$1(t),(e.isEditable()||"click"===r)&&o(t,e));}:t=>{if(Dn(t))return;An$1(t);const n=e.isEditable();switch(r){case "cut":return n&&Ts(e,je$2,t);case "copy":return Ts(e,Je$2,t);case "paste":return n&&Ts(e,_e$2,t);case "dragstart":return n&&Ts(e,Be$2,t);case "dragover":return n&&Ts(e,We$2,t);case "dragend":return n&&Ts(e,$e$2,t);case "focus":return n&&Ts(e,Ge$2,t);case "blur":return n&&Ts(e,Xe$2,t);case "drop":return n&&Ts(e,ze$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(Jn),Ai(this);Di("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=Yi(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),Ai(this)),this._pendingEditorState=r,this._dirtyType=2,this._dirtyElements.set("root",false),this._compositionKey=null,null!=s&&o.add(s),this._updating||Ai(this);}parseEditorState(t,e){return function(t,e,n){const r=qi(),i=di,o=gi,s=hi,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,di=r,gi=false,hi=e,vo(null);try{const i=e._nodes;Oi(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,di=i,gi=o,hi=s;}return r}("string"==typeof t?JSON.parse(t):t,this,e)}read(t){return Ai(this),this.getEditorState().read(t,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):Ii(t,e,n);}(this,t,e);}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),Ki(this,()=>{const r=Qr(),i=Zo();null!==r?r.dirty||es(r.clone()):0!==i.getChildrenSize()&&("rootStart"===e.defaultSelection?i.selectStart():i.selectEnd()),Os("focus"),Ms(()=>{n.removeAttribute("autocapitalize"),t&&t();});}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"));}blur(){const t=this._rootElement;null!==t&&t.blur();const e=Js(this._window);null!==e&&e.removeAllRanges();}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,Di("editable",this,true,t));}toJSON(){return {editorState:this._editorState.toJSON()}}}Co.version="0.44.0+prod.esm";let So=null;function vo(t){So=t;}let ko=1;function To(){ko=1;}function No(e,n){const r=bo(e,n);return void 0===r&&t(30,n),r}function bo(t,e){return t._nodes.get(e)}const wo="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t);};function Eo(t){return ji(Go(t))}function Oo(t){const e=document.activeElement;if(!Ys(e))return false;const n=e.nodeName;return ji(Go(t))&&("INPUT"===n||"TEXTAREA"===n||"true"===e.contentEditable&&null==Po(e))}function Mo(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!Oo(e)&&Do(e)===t}catch(t){return false}}function Ao(t){return t instanceof Co}function Do(t){let e=t;for(;null!=e;){const t=Po(e);if(Ao(t))return t;e=bs(e);}return null}function Po(t){return t?t.__lexicalEditor:null}function Fo(t){return I$6.test(t)?"rtl":K$4.test(t)?"ltr":null}function Lo(t){return Er(t)||t.isToken()}function Io(t){return Lo(t)||t.isSegmented()}function Ko(t){return qs(t)&&3===t.nodeType}function zo(t){return qs(t)&&9===t.nodeType}function Ro(t){let e=t;for(;null!=e;){if(Ko(e))return e;e=e.firstChild;}return null}function Bo(t,e,n){const r=z$7[e];if(null!==n&&(t&r)===(n&r))return t;let i=t^r;return "subscript"===e?i&=~z$7.superscript:"superscript"===e?i&=~z$7.subscript:"lowercase"===e?(i&=~z$7.uppercase,i&=~z$7.capitalize):"uppercase"===e?(i&=~z$7.lowercase,i&=~z$7.capitalize):"capitalize"===e&&(i&=~z$7.lowercase,i&=~z$7.uppercase),i}function Wo(t){return Tr(t)||sr(t)||ji(t)}function $o(t,e){const n=function(){const t=So;return So=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);xi(),Ci();const r=vi(),i=Si(),o=""+ko++;i._nodeMap.set(o,t),Wi(t)?r._dirtyElements.set(o,true):r._dirtyLeaves.add(o),r._cloneNotNeeded.add(o),r._dirtyType=1,t.__key=o;}function Jo(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 jo(e){Ci(),zn(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),r=n.__parent,i=Si(),o=vi(),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,Wi(e)?l.set(c,true):o._dirtyLeaves.add(c);}function Uo(t){xi();const e=vi(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=Yo(n);null!==t&&t.getWritable();}if(null!==t){const e=Yo(t);null!==e&&e.getWritable();}}}function Vo(){if(mi())return null;return vi()._compositionKey}function Yo(t,e){const n=(e||Si())._nodeMap.get(t);return void 0===n?null:n}function qo(t,e){const n=Ho(t,vi());return void 0!==n?Yo(n,e):null}function Ho(t,e){return t[`__lexicalKey_${e._key}`]}function Go(t,e){let n=t;for(;null!=n;){const t=qo(n,e);if(null!==t)return t;n=bs(n);}return null}function Xo(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function Qo(t){return t.read(()=>Zo().getTextContent())}function Zo(){return ts(Si())}function ts(t){return t._nodeMap.get("root")}function es(t){xi();const e=Si();null!==t&&(t.dirty=true,t.setCachedNodes(null)),e._selection=t;}function ns(t){const e=vi(),n=function(t,e){let n=t;for(;null!=n;){const t=Ho(n,e);if(void 0!==t)return t;n=bs(n);}return null}(t,e);if(null===n){return t===e.getRootElement()?Yo("root"):null}return Yo(n)}function rs(t){return /[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function is(t){const e=[];for(let n=t;null!==n;n=n._parentEditor)e.push(n);return e}function os(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function ss(t){return Ko(t)?t.nodeValue:null}function ls(t,e,n){const r=Js(Ps(e));if(null===r)return;const i=r.anchorNode;let{anchorOffset:o,focusOffset:s}=r;if(null!==i){let e=ss(i);const r=Go(i);if(null!==e&&Tr(r)){if((e===A$3||e===P$3)&&n){const t=n.length;e=n,o=t,s=t;}null!==e&&cs(r,e,o,s,t);}}}function cs(t,e,n,r,i){let o=t;if(o.isAttached()&&(i||!o.isDirty())){const s=o.isComposing();let c=e;if((s||i)&&(e.endsWith(A$3)&&(c=e.slice(0,-A$3.length)),i)){const t=P$3;let e;for(;-1!==(e=c.indexOf(t));)c=c.slice(0,e)+c.slice(e+t.length),null!==n&&n>e&&(n=Math.max(e,n-t.length)),null!==r&&r>e&&(r=Math.max(e,r-t.length));}const u=o.getTextContent();if(i||c!==u){if(""===c){if(Uo(null),a||l||d$1)o.remove();else {const t=vi();setTimeout(()=>{t.update(()=>{o.isAttached()&&o.remove();});},20);}return}const e=o.getParent(),i=Zr(),u=o.getTextContentSize(),f=Vo(),h=o.getKey();if(o.isToken()||null!==f&&h===f&&!s||Fr(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=Qr();if(!Fr(g)||null===n||null===r)return void as(o,c,g);if(g.setTextNodeRange(o,n,o,r),o.isSegmented()){const t=kr(o.getTextContent());o.replace(t),o=t;}as(o,c,g);}}}function as(t,e,n){if(t.setTextContent(e),Fr(n)){const e=t.getKey();for(const r of ["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===e&&(i.offset=Al(t,i.offset,"clamp"));}}}function us(t,e,n){const r=e[n]||false;return "any"===r||r===t[n]}function fs(t,e){return us(t,e,"altKey")&&us(t,e,"ctrlKey")&&us(t,e,"shiftKey")&&us(t,e,"metaKey")}function ds(t,e,n){if(!fs(t,n))return false;if(t.key.toLowerCase()===e.toLowerCase())return true;if(e.length>1)return false;if(1===t.key.length&&t.key.charCodeAt(0)<=127)return false;if(t.code.startsWith("Digit")&&/^\d$/.test(e))return t.code===`Digit${e}`;const r="Key"+e.toUpperCase();return t.code===r}const hs={ctrlKey:!i,metaKey:i},gs={altKey:i,ctrlKey:!i};function _s(t){return "Backspace"===t.key}function ps(t){return ds(t,"a",hs)}function ys(t){const e=Zo();if(Fr(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$3(t),t}{const t=e.select(0,e.getChildrenSize());return es(St$3(t)),t}}function ms(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=yc(i);return n[e]=t,t}return i}function xs(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 Cs(t){const e=t.getType(),n=Si();if(n._readOnly){const t=rl(n).get(e);return t?Array.from(t.values()):[]}const r=n._nodeMap,i=[];for(const[,n]of r)n instanceof t&&n.__type===e&&n.isAttached()&&i.push(n);return i}function Ss(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 vs(t,e){const n=t.offset;if("element"===t.type){return Ss(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?Ss(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function ks(t){const e=Ps(t).event,n=e&&e.inputType;return "insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Ts(t,e,n){return Pi(t,e,n,t)}function Ns(e,n){const r=e._keyToDOMMap.get(n);return void 0===r&&t(75,n),r}function bs(t){const e=t.assignedSlot||t.parentElement;return Hs(e)?e.host:e}function ws(t){return zo(t)?t:Ys(t)?t.ownerDocument:null}function Es(t){return vi()._updateTags.has(t)}function Os(t){xi();vi()._updateTags.add(t);}function Ms(t){xi();vi()._deferred.push(t);}function As(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return true;n=n.getParent();}return false}function Ds(t){const e=ws(t);return e?e.defaultView:null}function Ps(e){const n=e._window;return null===n&&t(78),n}function Fs(t){return Wi(t)&&t.isInline()||ji(t)&&t.isInline()}function Ls(t){let e=t.getParentOrThrow();for(;null!==e;){if(Is(e))return e;e=e.getParentOrThrow();}return e}function Is(t){return Vi(t)||Wi(t)&&t.isShadowRoot()}function Ks(t,e=false){const n=t.constructor.clone(t);return $o(n,null),n.afterCloneFrom(t),e||n.resetOnCopyNodeFrom(t),n}function zs(e){const n=vi(),r=e.getType(),i=bo(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 Rs(e,n){!Vi(e.getParent())||Wi(n)||ji(n)||t(99);}function Bs(e){const n=Yo(e);return null===n&&t(63,e),n}function Ws(t){return (ji(t)||Wi(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 Js(t){return n?(t||window).getSelection():null}function js(t){const e=Ds(t);return e?e.getSelection():null}function Us(e,n){let r=e.getChildAtIndex(n);null==r&&(r=e),Is(e)&&t(102);const i=e=>{const n=e.getParentOrThrow(),o=Is(n),s=e!==r||o?Ks(e):e;if(o)return Wi(e)&&Wi(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 Vs(t){return Ys(t)&&"A"===t.tagName}function Ys(t){return qs(t)&&1===t.nodeType}function qs(t){return "object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function Hs(t){return qs(t)&&11===t.nodeType}function Gs(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 Xs(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 Qs(t){if(ji(t)&&!t.isInline())return true;if(!Wi(t)||Is(t))return false;const e=t.getFirstChild(),n=null===e||sr(e)||Tr(e)||e.isInline();return !t.isInline()&&false!==t.canBeEmpty()&&n}function Zs(){return vi()}function tl(t=Zs()){return t._config.dom||po}const el=new WeakMap,nl=new Map;function rl(e){if(!e._readOnly&&e.isEmpty())return nl;e._readOnly||t(192);let n=el.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),el.set(e,n)),n}function il(t){const e=t.constructor.clone(t);return e.afterCloneFrom(t),e}function ol(t){return (e=il(t))[Kn$1]=true,e;var e;}function sl(t,e){const n=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(n/40);e.setIndent(r);}function ll(t){t.__lexicalUnmanaged=true;}function cl(t){return true===t.__lexicalUnmanaged}function al(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==Rn$1[e]}function ul(e){const n=U$6 in e.prototype?e.prototype[U$6]():void 0,r=function(e){if(!(e===Rn$1||e.prototype instanceof Rn$1)){let n="<unknown>",r="<unknown>";try{n=e.getType();}catch(t){}try{Co.version&&(r=JSON.parse(Co.version));}catch(t){}t(290,e.name,n,r);}return e===Ji||e===Bi||e===Rn$1}(e),i=!r&&al(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&&(al(e,"getType")||(e.getType=()=>s),al(e,"clone")||(e.clone=t=>(vo(t),new e)),al(e,"importJSON")||(e.importJSON=o&&o.$importJSON||(t=>(new e).updateFromJSON(t))),!al(e,"importDOM")&&o)){const{importDOM:t}=o;t&&(e.importDOM=()=>t);}return {ownNodeConfig:o,ownNodeType:s}}function fl(t){const e=Zs();xi();return new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)}const dl=(t,e)=>{let n=t;for(;null!=n&&!Vi(n);){if(e(n))return n;n=n.getParent();}return null};function hl(e,n){const r=[];let i=e.__first;for(;null!==i;){const e=null===n?Yo(i):n.get(i);null==e&&t(174),r.push(i),i=e.__next;}return r}const gl={next:"previous",previous:"next"};class _l{origin;constructor(t){this.origin=t;}[Symbol.iterator](){return $l({hasNext:Tl,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return Ol(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Ol(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=Ol(e,this.direction);}for(const t of l.values())t.remove();return this}}class pl extends _l{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Pl(t,this.direction)}getParentCaret(t="root"){return Ol(xl(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ml(this.direction);return Ol(this.getNodeAtCaret(),t)||Pl(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof pl&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const yl={root:Vi,shadowRoot:Is};function ml(t){return gl[t]}function xl(t,e="root"){return yl[e](t)?null:t}class Cl extends _l{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ol(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Wi(this.origin)?Pl(this.origin,this.direction):null}getParentCaret(t="root"){return Ol(xl(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ml(this.direction);return Ol(this.getNodeAtCaret(),t)||Pl(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Cl&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return (t instanceof Cl||t instanceof Sl)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Sl extends _l{type="text";offset;constructor(t,e){super(t),this.offset=e;}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ml(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return Ol(xl(this.getParentAtCaret(),t),this.direction)}getFlipped(){return Ml(this.origin,ml(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Sl&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return (t instanceof Cl||t instanceof Sl)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return Ol(this.origin,this.direction)}}function vl(t){return t instanceof Sl}function kl(t){return t instanceof _l}function Tl(t){return t instanceof Cl}function Nl(t){return t instanceof pl}const bl={next:class extends Sl{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Sl{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},wl={next:class extends Cl{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Cl{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},El={next:class extends pl{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends pl{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function Ol(t,e){return t?new wl[e](t):null}function Ml(t,e,n){return t?new bl[e](t,Al(t,n)):null}function Al(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 Dl(t,e){return new Kl(t,e)}function Pl(t,e){return Wi(t)?new El[e](t):null}function Fl(t){return t&&t.getChildCaret()||t}function Ll(t){return t&&Fl(t.getAdjacentCaret())}class Il{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 Il(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return vl(e)?function(t,e){const{direction:n,origin:r}=t,i=Al(r,"focus"===e?ml(n):n);return Dl(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 [Dl(t,r.offset-t.offset),null]}return [e,n]}iterNodeCarets(t="root"){const e=vl(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=vl(n),i=e=>e.isSameNodeCaret(n)?null:Ll(e)||e.getParentCaret(t);return $l({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 Kl{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 Ml(t.setTextContent(i.slice(0,n)+i.slice(r)),e,n)}}function zl(t){return t instanceof Kl}function Rl(t){return Wl(t,Ol(Zo(),t.direction))}function Bl(t){return Wl(t,t)}function Wl(e,n){return e.direction!==n.direction&&t(265),new Il(e,n,e.direction)}function $l(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 Jl(e,n){const r=Yl(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 jl(r)}}function jl(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 Ul(t,e){return e.is(t)}function Vl(t){return Wi(t)?[t.getLatest(),null]:[t.getParent(),t.getLatest()]}function Yl(e,n){if(e.is(n))return {commonAncestor:e,type:"same"};const r=new Map;for(let[t,n]=Vl(e);t;n=t,t=t.getParent())r.set(t,n);for(let[i,o]=Vl(n);i;o=i,i=i.getParent()){const s=r.get(i);if(void 0!==s)return null===s?(Ul(e,i)||t(276),{commonAncestor:i,type:"ancestor"}):null===o?(Ul(n,i)||t(277),{commonAncestor:i,type:"descendant"}):((Wi(s)||Ul(e,s))&&(Wi(o)||Ul(n,o))&&i.is(s.getParent())&&i.is(o.getParent())||t(278),{a:s,b:o,commonAncestor:i,type:"branch"})}return null}function ql(e,n){const{type:r,key:i,offset:o}=e,s=Bs(e.key);return "text"===r?(Tr(s)||t(266,s.getType(),i),Ml(s,n,o)):(Wi(s)||t(267,s.getType(),i),lc(s,e.offset,n))}function Hl(e,n){const{origin:r,direction:i}=n,o="next"===i;vl(n)?e.set(r.getKey(),n.offset,"text"):Tl(n)?Tr(r)?e.set(r.getKey(),Al(r,i),"text"):e.set(r.getParentOrThrow().getKey(),r.getIndexWithinParent()+(o?1:0),"element"):(Nl(n)&&Wi(r)||t(268),e.set(r.getKey(),o?0:r.getChildrenSize(),"element"));}function Gl(t){const e=Qr(),n=Fr(e)?e:qr();return Xl(n,t),es(n),n}function Xl(t,e){Hl(t.anchor,e.anchor),Hl(t.focus,e.focus);}function Ql(t){const{anchor:e,focus:n}=t,r=ql(e,"next"),i=ql(n,"next"),o=Jl(r,i)<=0?"next":"previous";return Wl(oc(r,o),oc(i,o))}function Zl(t){const{direction:e,origin:n}=t,r=Ol(n,ml(e)).getNodeAtCaret();return r?Ol(r,e):Pl(n.getParentOrThrow(),e)}function tc(t,e="root"){const n=[t];for(let r=Nl(t)?t.getParentCaret(e):t.getSiblingCaret();null!==r;r=r.getParentCaret(e))n.push(Zl(r));return n}function ec(t){return !!t&&t.origin.isAttached()}function nc(e,n="removeEmptySlices"){if(e.isCollapsed())return e;const r="root",i="next";let o=n;const s=sc(e,i),l=tc(s.anchor,r),c=tc(s.focus.getFlipped(),r),a=new Set,u=[];for(const t of s.iterNodeCarets(r))if(Nl(t))a.add(t.origin.getKey());else if(Tl(t)){const{origin:e}=t;Wi(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=Zl(Ol(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=kr(t.getTextContent()).setStyle(t.getStyle()).setFormat(t.getFormat());r.replaceOrInsert(n),e=Ml(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(ec(t)){f=rc(t);break}for(const t of c)if(ec(t)){d=rc(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];if(Is(i))return;!n&&e(i)&&(n=i);}return n},u=a(o,Qs),f=u&&a(s,t=>n.has(t.getKey())&&Qs(t));return u&&f?[u,f]:null}(f,d,a);if(h){const[t,e]=h;Pl(t,"previous").splice(0,e.getChildren());let n=e.getParent();for(e.remove(true);n&&n.isEmpty();){const t=n;n=n.getParent(),t.remove(true);}}const g=[f,d,...l,...c].find(ec);if(g){return Bl(oc(rc(g),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)));}function rc(t){const e=function(t){let e=t;for(;Nl(e);){const t=Ll(e);if(!Nl(t))break;e=t;}return e}(t.getLatest()),{direction:n}=e;if(Tr(e.origin))return vl(e)?e:Ml(e.origin,n,n);const r=e.getAdjacentCaret();return Tl(r)&&Tr(r.origin)?Ml(r.origin,n,ml(n)):e}function ic(t){return vl(t)&&t.offset!==Al(t.origin,t.direction)}function oc(t,e){return t.direction===e?t:t.getFlipped()}function sc(t,e){return t.direction===e?t:Wl(oc(t.focus,e),oc(t.anchor,e))}function lc(t,e,n){let r=Pl(t,"next");for(let t=0;t<e;t++){const t=r.getAdjacentCaret();if(null===t)break;r=t;}return oc(r,n)}function cc(t,e="root"){let n=0,r=t,i=Ll(r);for(;null===i;){if(n--,i=r.getParentCaret(e),!i)return null;r=i,i=Ll(r);}return i&&[i,n]}function ac(e){const{origin:n,offset:r,direction:i}=e;if(r===Al(n,i))return e.getSiblingCaret();if(r===Al(n,ml(i)))return Zl(e.getSiblingCaret());const[o]=n.splitText(r);return Tr(o)||t(281),oc(Ol(o,"next"),i)}function uc(t,e){return true}function fc(t,{$copyElementNode:e=Ks,$splitTextPointCaretNext:n=ac,rootMode:r="shadowRoot",$shouldSplit:i=uc,removeEmptyDestination:o=false}={}){if(vl(t))return n(t);const s=t.getParentCaret(r);if(s){const{origin:n}=s;if(Nl(t)){const t=Zl(s);if(o&&n.isEmpty())return n.remove(),t;if(!n.canBeEmpty()||!i(n,"first"))return t}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||!o&&n.canBeEmpty()&&i(n,"last"))&&s.insert(e(n).splice(0,0,r));}return s}function dc(t){return t}function hc(...t){return t}function gc(t,e){return [t,e]}function _c(t){return t}function pc(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return {...t,...e};return t}function yc(...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 mc(t,...e){const n=yc(...e);n.length>0&&t.classList.add(...n);}function xc(t,...e){const n=yc(...e);n.length>0&&t.classList.remove(...n);}function Cc(...t){return ()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0;}}
|
|
7324
|
+
function 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&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,c=n&&/Android/.test(navigator.userAgent),a=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!c,u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&c&&u,d$1=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!u,h$1=0,g=1,_$3=2,p=1,y$1=2,m$1=4,x$1=8,C$4=16,S$1=32,v$1=64,k$3=128,T$2=2047,N$3=1,b$3=2,w$3=3,E$4=4,O$4=5,M$5=6,A$3=a||l||d$1?"\xa0":"\u200b",D$4="\n\n",P$3=o?"\xa0":A$3,F$7="\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc",L$4="A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff",I$6=new RegExp("^[^"+L$4+"]*["+F$7+"]"),K$4=new RegExp("^[^"+F$7+"]*["+L$4+"]"),z$7={bold:1,capitalize:1024,code:16,highlight:k$3,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},R$4={directionless:1,unmergeable:2},B$6={center:2,end:6,justify:4,left:1,right:3,start:5},W$6={[b$3]:"center",[M$5]:"end",[E$4]:"justify",[N$3]:"left",[w$3]:"right",[O$4]:"start"},$$4={normal:0,segmented:2,token:1},J$8={[h$1]:"normal",[_$3]:"segmented",[g]:"token"},j$7="$",U$6="$config";let V$7 = class V{_front=new Set;_back=new Set;_cache;get size(){return this._front.size+this._back.size}addBack(t){return delete this._cache,this._front.has(t)||this._back.add(t),this}addFront(t){return delete this._cache,this._back.has(t)||this._front.add(t),this}delete(t){return delete this._cache,this._front.delete(t)||this._back.delete(t)}toArray(){const t=Array.from(this._front).reverse();for(const e of this._back)t.push(e);return t}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}};function Y$6(t,e,n,r,i,o){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Wi(s)&&Y$6(s,t,n,r,i,o),n.has(t)||o.delete(t),i.push(t)),s=s.getNextSibling();}}let q$7=false,H$7=0;function G$a(t){H$7=t.timeStamp;}function X$6(t,e,n){const r="BR"===t.nodeName,i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&void 0!==Ho(t,n)}function Q$9(t,e,n){const r=Js(Ps(n));let i=null,o=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,o=r.focusOffset);const s=t.nodeValue;null!==s&&cs(e,s,i,o,false);}function Z$6(t,e,n){if(Fr(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return false}return Ko(e)&&n.isAttached()}function tt$5(t,e,n,r){for(let i=t;i&&!cl(i);i=bs(i)){const t=Ho(i,e);if(void 0!==t){const e=Yo(t,n);if(e)return ji(e)||!Ys(i)?void 0:[i,e]}else if(i===r)return [r,ts(n)]}}function et$2(t,e,n){q$7=true;const r=performance.now()-H$7>100;try{Ki(t,()=>{const i=Qr()||function(t){return t.getEditorState().read(()=>{const t=Qr();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$5(g,t,c,l);if(!_)continue;const[p,y]=_;if("characterData"===h)r&&Tr(y)&&Ko(g)&&Z$6(i,g,y)&&Q$9(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=qo(r),s=r.parentNode;if(null!=s&&r!==a&&null===i&&!X$6(r,s,t)){if(o){const t=(Ys(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$6(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$6(n,i,t)||o.removeChild(n);}}n.takeRecords();}null!==i&&(u&&es(i),o&&ks(t)&&i.insertRawText(f));});}finally{q$7=false;}}function nt$4(t){const e=t._observer;if(null!==e){et$2(t,e.takeRecords(),e);}}function rt$4(t){!function(t){0===H$7&&Ps(t).addEventListener("textInput",G$a,true);}(t),t._observer=new MutationObserver((e,n)=>{et$2(t,e,n);});}let it$2 = class it{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||gt$3).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=e.resetOnCopyNode||false;}};function ot$3(t,e){return new it$2(t,e)}function st$2(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function lt$3(t,e,n){const r=st$2(t,n,"direct"),i=st$2(e,n,"direct");return n.isEqual(r,i)?null:[r,i]}function ct$2(t,e,n){let r;if(xi(),"function"==typeof n){const i=t.getLatest(),o=st$2(i,e);if(r=n(o),e.isEqual(o,r))return i}else r=n;const i=t.getWritable();return ft$2(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}=ul(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$3 = 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$3(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)}resetOnCopyNode(){for(const t of this.knownState.keys())t.resetOnCopyNode&&this.knownState.set(t,t.defaultValue);return this}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$3(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$2(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new ut$3(e,dt$3(e));return e.__state=n,n}function dt$3(t){return t.__state?t.__state.sharedNodeState:No(Zs(),t.getType()).sharedNodeState}function ht$3(t){if(t)for(const e in t)return t}function gt$3(t){return t}function _t$3(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;if(e!==i&&!r.isEqual(e,i))return true}return false}function pt$3(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$6(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function mt$3(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;const n=new Set;return !(t&&_t$3(n,t,e)||e&&_t$3(n,e,t)||t&&pt$3(n,t,e)||e&&pt$3(n,e,t))}(c,a))}function xt$3(t,e){const n=t.mergeWithSibling(e),r=vi()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function Ct$2(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&Tr(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(mt$3(e,r)){r=xt$3(e,r);break}break}e.remove();}for(;null!==(n=r.getNextSibling())&&Tr(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(mt$3(r,n)){r=xt$3(r,n);break}break}n.remove();}}else r.remove();}function St$3(t){return vt$3(t.anchor),vt$3(t.focus),t}function vt$3(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),Tr(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",true);break}if(!Wi(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",true);}}let kt$3,Tt$5,Nt$3,bt$3,wt$3,Et$4,Ot$4,Mt$3,At$3,Dt$5,Pt$4,Ft$3="",Lt$4=null,It$2=null,Kt$3=false,zt$5=false;function Rt$4(t,e){const n=Ot$4.get(t);if(null!==e){const n=ne$5(t);n.parentNode===e&&e.removeChild(n);}if(Mt$3.has(t)||Tt$5._keyToDOMMap.delete(t),Wi(n)){const t=hl(n,Ot$4);Bt$4(t,0,t.length-1,null);} void 0!==n&&xs(Dt$5,Nt$3,bt$3,n,"destroyed");}function Bt$4(t,e,n,r){for(let i=e;i<=n;++i){const e=t[i];void 0!==e&&Rt$4(e,r);}}function Wt$4(t,e){t.setProperty("text-align",e);}const $t$3="40px";function Jt$4(t,e){const n=kt$3.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);}if(0===e)return void t.style.setProperty("padding-inline-start","");const r=getComputedStyle(Tt$5._rootElement||t).getPropertyValue("--lexical-indent-base-value")||$t$3;t.style.setProperty("padding-inline-start",`calc(${e} * ${r})`);}function jt$3(t,e){const n=t.style;0===e?Wt$4(n,""):1===e?Wt$4(n,"left"):2===e?Wt$4(n,"center"):3===e?Wt$4(n,"right"):4===e?Wt$4(n,"justify"):5===e?Wt$4(n,"start"):6===e&&Wt$4(n,"end");}function Ut$4(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(Vi(t))return null;const n=t.getParentOrThrow();return Vi(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir");}function Vt$3(e,n){const r=Mt$3.get(e);void 0===r&&t(60);const i=Pt$4.$createDOM(r,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),Tr(r)?i.setAttribute("data-lexical-text","true"):ji(r)&&i.setAttribute("data-lexical-decorator","true"),Wi(r)){const t=r.__indent,e=r.__size;if(Ut$4(i,r),0!==t&&Jt$4(i,t),0!==e){const t=e-1;Yt$3(hl(r,Mt$3),r,0,t,Pt$4.$getDOMSlot(r,i,Tt$5));}const n=r.__format;0!==n&&jt$3(i,n),r.isInline()||Ht$4(null,r,i);}else {const t=r.getTextContent();if(ji(r)){const t=r.decorate(Tt$5,kt$3);null!==t&&Qt$3(e,t),i.contentEditable="false";}Ft$3+=t;}return null!==n&&n.insertChild(i),Pt$4.$decorateDOM(r,null,i,Tt$5),xs(Dt$5,Nt$3,bt$3,r,"created"),i}function Yt$3(t,e,n,r,i){const o=Ft$3;Ft$3="";let s=n;for(;s<=r;++s){Vt$3(t[s],i);const e=Mt$3.get(t[s]);null!==e&&Tr(e)?null===Lt$4&&(Lt$4=e.getFormat(),It$2=e.getStyle()):Wi(e)&&s<r&&!e.isInline()&&(Ft$3+=D$4);}i.element.__lexicalTextContent=Ft$3,Ft$3=o+Ft$3;}function qt$4(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return sr(t)?"line-break":ji(t)&&t.isInline()?"decorator":null}return "empty"}return null}function Ht$4(t,e,n){const r=qt$4(t,Ot$4),i=qt$4(e,Mt$3);r!==i&&Pt$4.$getDOMSlot(e,n,Tt$5).setManagedLineBreak(i);}function Gt$3(e,n,r){var i;Lt$4=null,It$2=null,function(e,n,r){const i=Ft$3,o=e.__size,s=n.__size;Ft$3="";const l=r.element;if(1===o&&1===s){const t=e.__first,r=n.__first;if(t===r)Xt$4(t,l);else {const e=ne$5(t),n=Vt$3(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$4(t,null);}const i=Mt$3.get(r);Tr(i)&&null===Lt$4&&(Lt$4=i.getFormat(),It$2=i.getStyle());}else {const i=hl(e,Ot$4),c=hl(n,Mt$3);if(i.length!==o&&t(227),c.length!==s&&t(228),0===o)0!==s&&Yt$3(c,0,0,s-1,r);else 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=Zt$3(Xt$4(r,o.element)),f++,d++;else {if(void 0===a&&(a=te$5(n,d)),void 0===c)c=te$5(e,f);else if(!c.has(t)){f++;continue}if(!a.has(t)){u=Zt$3(ne$5(t)),Rt$4(t,o.element),f++,c.delete(t);continue}if(c.has(r)){const t=Ns(Tt$5,r);t!==u&&o.withBefore(u).insertChild(t),u=Zt$3(Xt$4(r,o.element)),f++,d++;}else Vt$3(r,o.withBefore(u)),d++;}const i=Mt$3.get(r);null!==i&&Tr(i)?null===Lt$4&&(Lt$4=i.getFormat(),It$2=i.getStyle()):Wi(i)&&d<=l&&!i.isInline()&&(Ft$3+=D$4);}const h=f>s,g=d>l;if(h&&!g){const t=n[l+1],e=void 0===t?null:Tt$5.getElementByKey(t);Yt$3(n,0,d,l,o.withBefore(e));}else g&&!h&&Bt$4(e,f,s,o.element);}(0,i,c,o,s,r);}l.__lexicalTextContent=Ft$3,Ft$3=i+Ft$3;}(e,n,Pt$4.$getDOMSlot(n,r,Tt$5)),i=n,null==Lt$4||Lt$4===i.__textFormat||zt$5||i.setTextFormat(Lt$4),function(t){null==It$2||It$2===t.__textStyle||zt$5||t.setTextStyle(It$2);}(n);}function Xt$4(e,n){const r=Ot$4.get(e);let i=Mt$3.get(e);void 0!==r&&void 0!==i||t(61);const o=Kt$3||Et$4.has(e)||wt$3.has(e),s=Ns(Tt$5,e);if(r===i&&!o){let t;if(Wi(r)){const e=s.__lexicalTextContent;"string"==typeof e?t=e:(t=r.getTextContent(),s.__lexicalTextContent=t);}else t=r.getTextContent();return Ft$3+=t,s}if(r!==i&&o&&xs(Dt$5,Nt$3,bt$3,i,"updated"),Pt$4.$updateDOM(i,r,s,Tt$5)){const r=Vt$3(e,null);return null===n&&t(62),n.replaceChild(r,s),Rt$4(e,null),r}if(Wi(r)){Wi(i)||t(334,e);const n=i.__indent;(Kt$3||n!==r.__indent)&&Jt$4(s,n);const l=i.__format;if((Kt$3||l!==r.__format)&&jt$3(s,l),o)Gt$3(r,i,s),Vi(i)||i.isInline()||Ht$4(r,i,s);else {const t=s.__lexicalTextContent;let e;"string"==typeof t?e=t:(e=r.getTextContent(),s.__lexicalTextContent=e),Ft$3+=e;}if((Kt$3||i.__dir!==r.__dir)&&(Ut$4(s,i),Vi(i)&&!Kt$3))for(const t of i.getChildren())if(Wi(t)){Ut$4(Ns(Tt$5,t.getKey()),t);}}else {const t=i.getTextContent();if(ji(i)){const t=i.decorate(Tt$5,kt$3);null!==t&&Qt$3(e,t);}Ft$3+=t;}if(!zt$5&&Vi(i)&&i.__cachedText!==Ft$3){const t=i.getWritable();t.__cachedText=Ft$3,i=t;}return Pt$4.$decorateDOM(i,r,s,Tt$5),s}function Qt$3(t,e){let n=Tt$5._pendingDecorators;const r=Tt$5._decorators;if(null===n){if(r[t]===e)return;n=Xo(Tt$5);}n[t]=e;}function Zt$3(t){let e=t.nextSibling;return null!==e&&e===Tt$5._blockCursorElement&&(e=e.nextSibling),e}function te$5(t,e){const n=new Set;for(let r=e;r<t.length;r++)n.add(t[r]);return n}function ee$4(t,e,n,r,i,o){Ft$3="",Kt$3=2===r,Tt$5=n,kt$3=n._config,Pt$4=n._config.dom||po,Nt$3=n._nodes,bt$3=Tt$5._listeners.mutation,wt$3=i,Et$4=o,Ot$4=t._nodeMap,Mt$3=e._nodeMap,zt$5=e._readOnly,At$3=new Map(n._keyToDOMMap);const s=new Map;return Dt$5=s,Xt$4("root",null),Tt$5=void 0,Nt$3=void 0,wt$3=void 0,Et$4=void 0,Ot$4=void 0,Mt$3=void 0,kt$3=void 0,At$3=void 0,Dt$5=void 0,Pt$4=po,s}function ne$5(e){const n=At$3.get(e);return void 0===n&&t(75,e),n}function re$5(t){return {type:t}}const ie$4=re$5("SELECTION_CHANGE_COMMAND"),oe$6=re$5("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),se$5=re$5("CLICK_COMMAND"),le$3=re$5("BEFORE_INPUT_COMMAND"),ce$4=re$5("INPUT_COMMAND"),ae$4=re$5("COMPOSITION_START_COMMAND"),ue$4=re$5("COMPOSITION_END_COMMAND"),fe$4=re$5("DELETE_CHARACTER_COMMAND"),de$4=re$5("INSERT_LINE_BREAK_COMMAND"),he$3=re$5("INSERT_PARAGRAPH_COMMAND"),ge$3=re$5("CONTROLLED_TEXT_INSERTION_COMMAND"),_e$2=re$5("PASTE_COMMAND"),pe$3=re$5("REMOVE_TEXT_COMMAND"),ye$2=re$5("DELETE_WORD_COMMAND"),me$3=re$5("DELETE_LINE_COMMAND"),xe=re$5("FORMAT_TEXT_COMMAND"),Ce$2=re$5("UNDO_COMMAND"),Se$2=re$5("REDO_COMMAND"),ve$2=re$5("KEYDOWN_COMMAND"),ke$2=re$5("KEY_ARROW_RIGHT_COMMAND"),Te$2=re$5("MOVE_TO_END"),Ne$1=re$5("KEY_ARROW_LEFT_COMMAND"),be$1=re$5("MOVE_TO_START"),we$1=re$5("KEY_ARROW_UP_COMMAND"),Ee$3=re$5("KEY_ARROW_DOWN_COMMAND"),Oe$2=re$5("KEY_ENTER_COMMAND"),Me$2=re$5("KEY_SPACE_COMMAND"),Ae$3=re$5("KEY_BACKSPACE_COMMAND"),De$2=re$5("KEY_ESCAPE_COMMAND"),Pe$2=re$5("KEY_DELETE_COMMAND"),Fe$2=re$5("KEY_TAB_COMMAND"),Le$2=re$5("INSERT_TAB_COMMAND"),Ie$3=re$5("INDENT_CONTENT_COMMAND"),Ke$2=re$5("OUTDENT_CONTENT_COMMAND"),ze$2=re$5("DROP_COMMAND"),Re$1=re$5("FORMAT_ELEMENT_COMMAND"),Be$2=re$5("DRAGSTART_COMMAND"),We$2=re$5("DRAGOVER_COMMAND"),$e$2=re$5("DRAGEND_COMMAND"),Je$2=re$5("COPY_COMMAND"),je$2=re$5("CUT_COMMAND"),Ue$2=re$5("SELECT_ALL_COMMAND"),Ve$2=re$5("CLEAR_EDITOR_COMMAND"),Ye$1=re$5("CLEAR_HISTORY_COMMAND"),qe$2=re$5("CAN_REDO_COMMAND"),He$2=re$5("CAN_UNDO_COMMAND"),Ge$2=re$5("FOCUS_COMMAND"),Xe$2=re$5("BLUR_COMMAND"),Qe$1=re$5("KEY_MODIFIER_COMMAND"),Ze$1=Object.freeze({}),tn$1=[["keydown",function(t,e){if(en$1=t.timeStamp,nn$1=t.key,e.isComposing())return;Ts(e,ve$2,t);}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;qs(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&Ki(e,()=>{Eo(n)||(an$1=true);});}],["compositionstart",function(t,e){Ts(e,ae$4,t);}],["compositionend",function(t,e){o?fn$1=true:l||!a&&!d$1?Ts(e,ue$4,t):(dn$1=true,hn$1=t.data);}],["input",function(t,e){t.stopPropagation(),Ki(e,()=>{e.dispatchCommand(ce$4,t);},{event:t}),on$1=null;}],["click",function(t,e){Ki(e,()=>{const n=Qr(),r=Js(Ps(e)),i=Zr();if(r)if(Fr(n)){const e=n.anchor,o=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!Vi(o)&&1===Zo().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=dl(o,t=>Wi(t)&&!t.isInline());Wi(t)&&t.select(0);}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Ys(n)||Ko(n)){es(Xr(i,r,e,t));}}Ts(e,se$5,t);});}],["cut",Ze$1],["copy",Ze$1],["dragstart",Ze$1],["dragover",Ze$1],["dragend",Ze$1],["paste",Ze$1],["focus",Ze$1],["blur",Ze$1],["drop",Ze$1]];s$1&&tn$1.push(["beforeinput",(t,e)=>function(t,e){const n=t.inputType;if("deleteCompositionText"===n||o&&ks(e))return;if("insertCompositionText"===n)return;Ts(e,le$3,t);}(t,e)]);let en$1=0,nn$1=null,rn$1=0,on$1=null;const sn$1=new WeakMap,ln$1=new WeakMap;let cn$1=false,an$1=false,un$1=false,fn$1=false,dn$1=false,hn$1="",gn$1=null,_n$1=[0,"",0,"root",0];function pn$1(t,e,n,r,i){const o=t.anchor,l=t.focus,c=o.getNode(),a=vi(),u=Js(Ps(a)),f=null!==u?u.anchorNode:null,d=o.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!Tr(c)||(!i&&(!s$1||rn$1<r+50)||c.isDirty()&&g<2||rs(n))&&o.offset!==l.offset&&!c.isComposing()||Io(c)||c.isDirty()&&g>1||(i||!s$1)&&null!==h&&!c.isComposing()&&f!==Ro(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||!c.isComposing()&&(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=Lo(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return (Tr(e)||Wi(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}(t,c)}function yn$1(t,e){return Ko(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function mn$1(e,n,r){const{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:l}=e;cn$1&&(cn$1=false,yn$1(i,o)&&yn$1(s,l)&&!gn$1)||Ki(n,()=>{if(!r)return void es(null);if(!Mo(n,i,s))return;let c=Qr();if(gn$1&&Fr(c)&&c.isCollapsed()){const t=c.anchor,e=gn$1.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=gn$1.clone(),es(c));}if(gn$1=null,Fr(c)){const r=c.anchor,i=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=true);const o=Ps(n).event,s=o?o.timeStamp:performance.now(),[l,a,u,f,d]=_n$1,h=Zo(),g=false===n.isComposing()&&""===h.getTextContent();if(s<d+200&&r.offset===u&&r.key===f)xn$1(c,l,a);else if("text"===r.type)Tr(i)||t(141),Cn$1(c,i);else if("element"===r.type&&!g){Wi(i)||t(259);const e=r.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),r=e.getTextStyle();xn$1(t,n,r);}(c,e):xn$1(c,c.format,"");}}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(Tr(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;}}Ts(n,ie$4,void 0);});}function xn$1(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=true);}function Cn$1(t,e){xn$1(t,e.getFormat(),e.getStyle());}function Sn$1(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function vn$1(e){const n=e.inputType,r=Sn$1(e),i=vi(),o=Qr();if("deleteContentBackward"===n){if(null===o){const t=Zr();if(!Fr(t))return true;es(t.clone());}if(Fr(o)){const n=o.anchor.key===o.focus.key;if(s=e.timeStamp,"MediaLast"===nn$1&&s<en$1+30&&i.isComposing()&&n){if(Uo(null),en$1=0,setTimeout(()=>{Ki(i,()=>{Uo(null);});},30),Fr(o)){const e=o.anchor.getNode();e.markDirty(),Tr(e)||t(142),Cn$1(o,e);}}else {Uo(null),e.preventDefault();const t=o.anchor.getNode(),r=t.getTextContent(),s=t.canInsertTextAfter(),l=0===o.anchor.offset&&o.focus.offset===r.length;let c=f&&n&&!l&&s;if(c&&o.isCollapsed()&&(c=!ji(vs(o.anchor,true))),!c){Ts(i,fe$4,true);const t=Qr();f&&Fr(t)&&t.isCollapsed()&&(gn$1=t,setTimeout(()=>gn$1=null));}}return true}}var s;if(!Fr(o))return true;const c=e.data;null!==on$1&&ls(false,i,on$1),o.dirty&&null===on$1||!o.isCollapsed()||Vi(o.anchor.getNode())||null===r||o.applyDOMRange(r),on$1=null;const a=o.anchor,u=o.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===c)e.preventDefault(),Ts(i,de$4,false);else if(c===D$4)e.preventDefault(),Ts(i,he$3,void 0);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),o.insertRawText(t);}else null!=c&&pn$1(o,r,c,e.timeStamp,true)?(e.preventDefault(),Ts(i,ge$3,c)):on$1=c;return rn$1=e.timeStamp,true}switch(e.preventDefault(),n){case "insertFromYank":case "insertFromDrop":case "insertReplacementText":Ts(i,ge$3,e);break;case "insertFromComposition":Uo(null),Ts(i,ge$3,e);break;case "insertLineBreak":Uo(null),Ts(i,de$4,false);break;case "insertParagraph":Uo(null),un$1&&!l?(un$1=false,Ts(i,de$4,false)):Ts(i,he$3,void 0);break;case "insertFromPaste":case "insertFromPasteAsQuotation":Ts(i,_e$2,e);break;case "deleteByComposition":(function(t,e){return t!==e||Wi(t)||Wi(e)||!Lo(t)||!Lo(e)})(d,h)&&Ts(i,pe$3,e);break;case "deleteByDrag":Os(Hn),Ts(i,pe$3,e);break;case "deleteByCut":Ts(i,pe$3,e);break;case "deleteContent":Ts(i,fe$4,false);break;case "deleteWordBackward":Ts(i,ye$2,true);break;case "deleteWordForward":Ts(i,ye$2,false);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":Ts(i,me$3,true);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":Ts(i,me$3,false);break;case "formatStrikeThrough":Ts(i,xe,"strikethrough");break;case "formatBold":Ts(i,xe,"bold");break;case "formatItalic":Ts(i,xe,"italic");break;case "formatUnderline":Ts(i,xe,"underline");break;case "historyUndo":Ts(i,Ce$2,void 0);break;case "historyRedo":Ts(i,Se$2,void 0);}return true}function kn$1(t){if(Ys(t.target)&&Eo(t.target))return true;const e=vi(),n=Qr(),r=t.data,i=Sn$1(t);if(null!=r&&Fr(n)&&pn$1(n,i,r,t.timeStamp,false)){fn$1&&(bn$1(e,r),fn$1=false);const i=n.anchor.getNode(),l=Js(Ps(e));if(null===l)return true;const c=n.isBackward(),a=c?n.anchor.offset:n.focus.offset,u=c?n.focus.offset:n.anchor.offset;s$1&&!n.isCollapsed()&&Tr(i)&&null!==l.anchorNode&&i.getTextContent().slice(0,a)+r+i.getTextContent().slice(a+u)===ss(l.anchorNode)||Ts(e,ge$3,r);const d=r.length;o&&d>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=d),f&&e.isComposing()&&(en$1=0,Uo(null));}else {ls(false,e,null!==r?r:void 0),fn$1&&(bn$1(e,r||void 0),fn$1=false);}return function(){xi();const t=vi();nt$4(t);}(),true}function Tn$1(t){const e=vi(),n=Qr();if(Fr(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();Uo(r.key),Os(Gn),(t.timeStamp<en$1+30||"element"===r.type||!n.isCollapsed()||i.getFormat()!==n.format||Tr(i)&&i.getStyle()!==n.style)&&Ts(e,ge$3,P$3);}return true}function Nn$1(t){return bn$1(vi(),t.data),Os(Xn),true}function bn$1(t,e){const n=t._compositionKey;if(Uo(null),null!==n&&null!=e){if(""===e){const e=Yo(n),r=Ro(t.getElementByKey(n));if(null!==r&&null!==r.nodeValue&&Tr(e)){const n=Js(Ps(t));let i=null,o=null;null!==n&&n.anchorNode===r&&(i=n.anchorOffset,o=n.focusOffset),cs(e,r.nodeValue,i,o,true);}return}if("\n"===e[e.length-1]){const e=Qr();if(Fr(e)||Ir(e)){if(Fr(e)){const t=e.focus;e.anchor.set(t.key,t.offset,t.type);}return void Ts(t,Oe$2,null)}}}ls(true,t,e);}function wn$1(t){const e=vi();if(null==t.key)return true;if(dn$1){if(_s(t))return Ki(e,()=>{bn$1(e,hn$1);}),dn$1=false,hn$1="",true;dn$1=false,hn$1="";}if(function(t){return ds(t,"ArrowRight",{shiftKey:"any"})}(t))Ts(e,ke$2,t);else if(function(t){return ds(t,"ArrowRight",hs)}(t))Ts(e,Te$2,t);else if(function(t){return ds(t,"ArrowLeft",{shiftKey:"any"})}(t))Ts(e,Ne$1,t);else if(function(t){return ds(t,"ArrowLeft",hs)}(t))Ts(e,be$1,t);else if(function(t){return ds(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Ts(e,we$1,t);else if(function(t){return ds(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Ts(e,Ee$3,t);else if(function(t){return ds(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:true})}(t))un$1=true,Ts(e,Oe$2,t);else if(function(t){return " "===t.key}(t))Ts(e,Me$2,t);else if(function(t){return i&&ds(t,"o",{ctrlKey:true})}(t))t.preventDefault(),un$1=true,Ts(e,de$4,true);else if(function(t){return ds(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))un$1=false,Ts(e,Oe$2,t);else if(function(t){return ds(t,"Backspace",{shiftKey:"any"})||i&&ds(t,"h",{ctrlKey:true})}(t))_s(t)?Ts(e,Ae$3,t):(t.preventDefault(),Ts(e,fe$4,true));else if(function(t){return "Escape"===t.key}(t))Ts(e,De$2,t);else if(function(t){return ds(t,"Delete",{})||i&&ds(t,"d",{ctrlKey:true})}(t))!function(t){return "Delete"===t.key}(t)?(t.preventDefault(),Ts(e,fe$4,false)):Ts(e,Pe$2,t);else if(function(t){return ds(t,"Backspace",gs)}(t))t.preventDefault(),Ts(e,ye$2,true);else if(function(t){return ds(t,"Delete",gs)}(t))t.preventDefault(),Ts(e,ye$2,false);else if(function(t){return i&&ds(t,"Backspace",{metaKey:true})}(t))t.preventDefault(),Ts(e,me$3,true);else if(function(t){return i&&(ds(t,"Delete",{metaKey:true})||ds(t,"k",{ctrlKey:true}))}(t))t.preventDefault(),Ts(e,me$3,false);else if(function(t){return ds(t,"b",hs)}(t))t.preventDefault(),Ts(e,xe,"bold");else if(function(t){return ds(t,"u",hs)}(t))t.preventDefault(),Ts(e,xe,"underline");else if(function(t){return ds(t,"i",hs)}(t))t.preventDefault(),Ts(e,xe,"italic");else if(function(t){return ds(t,"Tab",{shiftKey:"any"})}(t))Ts(e,Fe$2,t);else if(function(t){return ds(t,"z",hs)}(t))t.preventDefault(),Ts(e,Ce$2,void 0);else if(function(t){if(i)return ds(t,"z",{metaKey:true,shiftKey:true});return ds(t,"y",{ctrlKey:true})||ds(t,"z",{ctrlKey:true,shiftKey:true})}(t))t.preventDefault(),Ts(e,Se$2,void 0);else {const n=e._editorState._selection;null===n||Fr(n)?ps(t)&&(t.preventDefault(),Ts(e,Ue$2,t)):!function(t){return ds(t,"c",hs)}(t)?!function(t){return ds(t,"x",hs)}(t)?ps(t)&&(t.preventDefault(),Ts(e,Ue$2,t)):(t.preventDefault(),Ts(e,je$2,t)):(t.preventDefault(),Ts(e,Je$2,t));}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(Qe$1,t),true}function En$1(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const On$1=new Map;function Mn(t){const e=js(t.target);if(null===e)return;const n=Do(e.anchorNode);if(null===n)return;an$1&&(an$1=false,Ki(n,()=>{const r=Zr(),i=e.anchorNode;if(Ys(i)||Ko(i)){es(Xr(r,e,n,t));}}));const r=is(n),i=r[r.length-1],o=i._key,s=On$1.get(o),l=s||i;l!==n&&mn$1(e,l,false),mn$1(e,n,true),n!==i?On$1.set(o,n):s&&On$1.delete(o);}function An$1(t){t._lexicalHandled=true;}function Dn(t){return true===t._lexicalHandled}function Fn$1(e){const n=sn$1.get(e);if(void 0===n)return void 0;const r=ln$1.get(n);if(void 0===r)return void 0;const i=r-1;i>=0||t(164),sn$1.delete(e),ln$1.set(n,i),0===i&&n.removeEventListener("selectionchange",Mn);const o=Po(e);Ao(o)?(!function(t){if(null!==t._parentEditor){const e=is(t),n=e[e.length-1]._key;On$1.get(n)===t&&On$1.delete(n);}else On$1.delete(t._key);}(o),e.__lexicalEditor=null):o&&t(198);const s=En$1(e);for(let t=0;t<s.length;t++)s[t]();e.__lexicalEventHandles=[];}function Ln(t,e,n){xi();const r=t.__key,i=t.getParent();if(null===i)return;const o=function(t){const e=Qr();if(!Fr(e)||!Wi(t))return e;const{anchor:n,focus:r}=e,i=n.getNode(),o=r.getNode();As(i,t)&&n.set(t.__key,0,"element");As(o,t)&&r.set(t.__key,0,"element");return e}(t);let s=false;if(Fr(o)&&e){const e=o.anchor,n=o.focus;e.key===r&&(ni(e,t,i,t.getPreviousSibling(),t.getNextSibling()),s=true),n.key===r&&(ni(n,t,i,t.getPreviousSibling(),t.getNextSibling()),s=true);}else Ir(o)&&e&&t.isSelected()&&t.selectPrevious();if(Fr(o)&&e&&!s){const e=t.getIndexWithinParent();Jo(t),ti(o,i,e,-1);}else Jo(t);n||Is(i)||i.canBeEmpty()||!i.isEmpty()||Ln(i,e),e&&o&&Vi(i)&&i.isEmpty()&&i.selectEnd();}function In(t){return t}const Kn$1=Symbol.for("ephemeral");function zn(t){return t[Kn$1]||false}let Rn$1 = class Rn{__type;__key;__parent;__prev;__next;__state;static getType(){const{ownNodeType:e}=ul(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));}resetOnCopyNodeFrom(t){this.__state&&(this.__state=this.__state.getWritable(this).resetOnCopyNode());}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}),$o(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=Yo(t);if(null===e)break;t=e.__parent;}return false}isSelected(t){const e=t||Qr();if(null==e)return false;const n=e.getNodes().some(t=>t.__key===this.__key);if(Tr(this))return n;if(Fr(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return false;const t=this.getParent();if(ji(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:Yo(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(Is(n))return Wi(e)||e===this&&ji(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:Yo(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:Yo(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Wi(this)?this:this.getParent(),n=Wi(t)?t:t.getParent(),r=e&&n?Yl(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Yl(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===jl(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),false)))}isParentOf(t){const e=Yl(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=Wi(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=vi()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(zn(this))return this;const e=Yo(this.__key);return null===e&&t(113),e}getWritable(){if(zn(this))return this;xi();const t=Si(),e=vi(),n=t._nodeMap,r=this.__key,i=this.getLatest(),o=e._cloneNotNeeded,s=Qr();if(null!==s&&s.setCachedNodes(null),o.has(r))return jo(i),i;const l=il(i);return o.add(r),jo(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$3(n).flatKeys)t in e&&(void 0!==i&&i!==r||(i={...r}),i[t]=e[t]);return (n.__state||i)&&ft$2(t).updateFromJSON(i),n}(this,t)}static transform(){return null}remove(t){Ln(this,true,t);}replace(e,n){xi();let r=Qr();null!==r&&(r=r.clone()),Rs(this,e);const i=this.getLatest(),o=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;Jo(l);const u=i.getPreviousSibling(),f=i.getNextSibling(),d=i.__prev,h=i.__next,g=i.__parent;if(Ln(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&&(Wi(this)&&Wi(l)||t(139),this.getChildren().forEach(t=>{l.append(t);})),Fr(r)){es(r);const t=r.anchor,e=r.focus;t.key===o&&Dr(t,l),e.key===o&&Dr(e,l);}return Vo()===o&&Uo(s),l}insertAfter(t,e=true){xi(),Rs(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),o=Qr();let s=false,l=false;if(null!==i){const e=t.getIndexWithinParent();if(Jo(r),Fr(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&&Fr(o)){const t=this.getIndexWithinParent();ti(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){xi(),Rs(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;Jo(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=Qr();if(e&&Fr(a)){ti(a,this.getParentOrThrow(),c);}return t}isParentRequired(){return false}createParentElementNode(){return eo()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){xi();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Wi(n))return n.select();if(!Tr(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){xi();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Wi(n))return n.select(0,0);if(!Tr(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable();}reconcileObservedMutation(t,e){this.markDirty();}};function Bn(t){return t instanceof Rn$1}const Wn$1="historic",$n$1="history-push",Jn="history-merge",jn="paste",Un="collaboration",Vn="skip-collab",Yn="skip-scroll-into-view",qn="skip-dom-selection",Hn="skip-selection-focus",Gn="composition-start",Xn="composition-end",Qn=/\s*!important\s*$/i;function Zn(t){const e={};if(!t)return e;let n="",r="",i=null,o=false,s=false,l=false,c=0;for(let a=0;a<t.length;a++){const u=t[a];if(o)"*"===u&&"/"===t[a+1]&&(o=false,a++);else if(s)l?r+=u:n+=u,s=false;else if(null===i)if("/"!==u||"*"!==t[a+1])if('"'!==u&&"'"!==u)if("("!==u)if(")"!==u)if(l||":"!==u||0!==c){if(";"===u&&0===c){const t=n.trim(),i=r.trim();""!==t&&""!==i&&(e[t]=i),n="",r="",l=false;continue}l?r+=u:n+=u;}else l=true;else c=Math.max(0,c-1),l?r+=u:n+=u;else c++,l?r+=u:n+=u;else i=u,l?r+=u:n+=u;else o=true,a++;else l?r+=u:n+=u,"\\"===u?s=true:u===i&&(i=null);}const a=n.trim(),u=r.trim();return ""!==a&&""!==u&&(e[a]=u),e}function tr(t,e,n){const r=Qn.test(n)?"important":"",i=""===r?n:n.replace(Qn,"").trim();t.setProperty(e,i,r);}function er(t,e){for(const n in e){const r=e[n];null==r?t.removeProperty(n):tr(t,n,r);}}function nr(t,e,n=""){if(e===n)return;const r=Zn(n),i=Zn(e);for(const e in i)delete r[e],tr(t,e,i[e]);for(const e in r)t.removeProperty(e);}class rr extends Rn$1{static getType(){return "linebreak"}static clone(t){return new rr(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&&Xs(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&lr(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&lr(n))return true}}return false}(t)||function(t){const e=t.parentElement;if(null!==e&&Xs(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&lr(n))return false;const r=e.lastChild;if(r===t||r.previousSibling===t&&lr(r))return true}return false}(t)?null:{conversion:ir,priority:0}}}static importJSON(t){return or().updateFromJSON(t)}}function ir(t){return {node:or()}}function or(){return zs(new rr)}function sr(t){return t instanceof rr}function lr(t){return Ko(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function cr(t,e){return 16&e?"code":e&k$3?"mark":32&e?"sub":64&e?"sup":null}function ar(t,e){return 1&e?"strong":2&e?"em":"span"}function ur(t,e,n,r,i){const o=r.classList;let s=ms(i,"base");void 0!==s&&o.add(...s),s=ms(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 z$7){const r=z$7[t];if(s=ms(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 fr(t,e,n){const r=e.firstChild,i=n.isComposing(),s=t+(i?A$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 dr(t,e,n,r,i,o){fr(i,t,e);const s=o.theme.text;void 0!==s&&ur(0,0,r,t,s);}function hr(t,e){const n=document.createElement(e);return n.appendChild(t),n}class gr extends Rn$1{__text;__format;__style;__mode;__detail;static getType(){return "text"}static clone(t){return new gr(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 J$8[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===Vo()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return !!(1&this.getLatest().__detail)}isUnmergeable(){return !!(2&this.getLatest().__detail)}hasFormat(t){const e=z$7[t];return 0!==(this.getFormat()&e)}isSimpleText(){return "text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return Bo(this.getLatest().__format,t,e)}canHaveFormat(){return true}isInline(){return true}createDOM(t,e){const n=this.__format,r=cr(0,n),i=ar(0,n),o=null===r?i:r,s=document.createElement(o);let l=s;this.hasFormat("code")&&s.setAttribute("spellcheck","false"),null!==r&&(l=document.createElement(i),s.appendChild(l));dr(l,this,0,n,this.__text,t);const c=this.__style;return ""!==c&&nr(s.style,c),s}updateDOM(e,n,r){const i=this.__text,o=e.__format,s=this.__format,l=cr(0,o),c=cr(0,s),a=ar(0,o),u=ar(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 dr(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)),fr(i,f,this);const d=r.theme.text;void 0!==d&&o!==s&&ur(0,o,s,f,d);const h=e.__style,g=this.__style;return h!==g&&nr(n.style,g,h),false}static importDOM(){return {"#text":()=>({conversion:xr,priority:0}),b:()=>({conversion:pr,priority:0}),code:()=>({conversion:vr,priority:0}),em:()=>({conversion:vr,priority:0}),i:()=>({conversion:vr,priority:0}),mark:()=>({conversion:vr,priority:0}),s:()=>({conversion:vr,priority:0}),span:()=>({conversion:_r,priority:0}),strong:()=>({conversion:vr,priority:0}),sub:()=>({conversion:vr,priority:0}),sup:()=>({conversion:vr,priority:0}),u:()=>({conversion:vr,priority:0})}}static importJSON(t){return kr().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 Ys(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=hr(n,"b")),this.hasFormat("italic")&&(n=hr(n,"i")),this.hasFormat("strikethrough")&&(n=hr(n,"s")),this.hasFormat("underline")&&(n=hr(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?z$7[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?R$4[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=Bo(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=$$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){xi();let n=t,r=e;const i=Qr(),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(!Fr(i))return Yr(s,n,s,r,"text","text");{const t=Vo();t!==i.anchor.key&&t!==i.focus.key||Uo(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=Qr();if(r&&Fr(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){xi();const e=this.getLatest(),n=e.getTextContent();if(""===n)return [];const r=e.__key,i=Vo(),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=Qr();if(Fr(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=kr(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=yt$6(e,f),_=true):f=e.setTextContent(a);const x=[f];for(let t=1;t<c;t++){const n=kr(s[t]);n.__format=d,n.__style=h,n.__detail=g,n.__state=yt$6(e,n);const o=n.__key;i===r&&Uo(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&&jo(e);null!==n&&jo(n);}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),Fr(m)&&ti(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;Vo()===i&&Uo(r);const l=Qr();if(Fr(l)){const t=l.anchor,o=l.focus;null!==t&&t.key===i&&ri(t,n,r,e,s),null!==o&&o.key===i&&ri(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 _r(t){return {forChild:Nr(t.style),node:null}}function pr(t){const e=t,n="normal"===e.style.fontWeight;return {forChild:Nr(e.style,n?void 0:"bold"),node:null}}const yr=new WeakMap;function mr(t){if(!Ys(t))return false;if("PRE"===t.nodeName)return true;const e=t.style.whiteSpace;return "string"==typeof e&&e.startsWith("pre")}function xr(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=yr.get(n))&&!mr(n);)r.push(n),n=n.parentNode;const i=void 0===e?n:e;for(let t=0;t<r.length;t++)yr.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(or()):"\t"===n?e.push(wr()):""!==n&&e.push(kr(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=Cr(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=Cr(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}:{node:kr(r)}}function Cr(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,Ys(n)){const t=n.style.display;if(""===t&&!Gs(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(Ko(n))return n;if("BR"===n.nodeName)return null}}const Sr={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function vr(t){const e=Sr[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Nr(t.style,e),node:null}}function kr(t=""){return zs(new gr(t))}function Tr(t){return t instanceof gr}function Nr(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=>Tr(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 br extends gr{static getType(){return "tab"}static clone(t){return new br(t.__key)}constructor(t){super("\t",t),this.__detail=2;}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=ms(t.theme,"tab");if(void 0!==n){e.classList.add(...n);}return e}static importJSON(t){return wr().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 wr(){return zs(new br)}function Er(t){return t instanceof br}class Or{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 Jl(rc(ql(this,"next")),rc(ql(t,"next")))<0}getNode(){const e=Yo(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,mi()||(Vo()===o&&Uo(t),null!==i&&(i.setCachedNodes(null),i.dirty=true)));}}function Mr(t,e,n){return new Or(t,e,n)}function Ar(t,e){let n=e.__key,r=t.offset,i="element";if(Tr(e)){i="text";const t=e.getTextContentSize();r>t&&(r=t);}else if(!Wi(e)){const t=e.getNextSibling();if(Tr(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 Dr(t,e){if(Wi(e)){const n=e.getLastDescendant();Wi(n)||Tr(n)?Ar(t,n):Ar(t,e);}else Ar(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(!Ir(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(Tr(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=Yo(t);null!==e&&n.push(e);}return mi()||(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((Qr()||Zr())===this&&t[0]){const e=Ol(t[0],"next");Gl(Wl(e,e));}for(const e of t)e.remove();}}function Fr(t){return t instanceof Lr}class Lr{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 !!Fr(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(Nl(n)){const{origin:t}=n;0===e.length?i.add(t):(o.add(t),e.push(t));}else {const{origin:t}=n;Wi(t)&&o.has(t)||e.push(t);}r&&e.push(r.caret.origin);if(Tl(t.focus)&&Wi(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=Pl(t.focus.origin,"previous");Nl(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=Ll(n))i.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!Wi(t)||o.has(t)||t.isEmpty()||i.has(t))break;e.pop();}if(0===e.length&&t.isCollapsed()){const n=rc(t.anchor),r=rc(t.anchor.getFlipped()),i=t=>vl(t)?t.origin:t.getNodeAtCaret(),o=i(n)||i(r)||(t.anchor.getNodeAtCaret()?n.origin:r.origin);e.push(o);}return e}(sc(Ql(this),"next"));return mi()||(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]=zr(this);let c="",a=true;for(let u=0;u<t.length;u++){const f=t[u];if(Wi(f)&&!f.isInline())a||(c+="\n"),a=!f.isEmpty();else if(a=false,Tr(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 !ji(f)&&!sr(f)||f===n&&this.isCollapsed()||(c+=f.getTextContent());}return c}applyDOMRange(t){const e=vi(),n=e.getEditorState()._selection,r=Ur(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$3(this);}clone(){const t=this.anchor,e=this.focus;return new Lr(Mr(t.key,t.offset,t.type),Mr(e.key,e.offset,e.type),this.format,this.style)}toggleFormat(t){this.format=Bo(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=z$7[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(or()):"\t"===r?n.push(wr()):n.push(kr(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=kr();if(s.setFormat(n),s.setStyle(r),no(o))o.splice(0,0,[s]);else {const t=Vi(i)?eo().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&&Hl(l,rc(ql(l,"next")));const c=s.offset;let a=l.offset;const u=this.getNodes(),f=u.length;let d=u[0];Tr(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&&(Io(d)||!d.canInsertTextAfter()||!g.canInsertTextAfter()&&null===d.getNextSibling())){let t=d.getNextSibling();if(Tr(t)&&t.canInsertTextBefore()&&!Io(t)||(t=kr(),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&&(Io(d)||!d.canInsertTextBefore()||!g.canInsertTextBefore()&&null===d.getPreviousSibling())){let t=d.getPreviousSibling();if(Tr(t)&&!Io(t)||(t=kr(),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=kr(d.getTextContent());t.setFormat(i),d.replace(t),d=t;}else if(!this.isCollapsed()&&""!==e){const t=_.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||Wi(t)&&(!t.canInsertTextBefore()||!t.canInsertTextAfter()))return this.insertText(""),jr(this.anchor,this.focus),void this.insertText(e)}if(1===f){if(Lo(d)){const t=kr(e);return t.select(),void d.replace(t)}const t=d.getFormat(),n=d.getStyle();if(c!==a||t===i&&n===o){if(Er(d)){const t=kr(e);return t.setFormat(i),t.setStyle(o),t.select(),void d.replace(t)}}else {if(""!==d.getTextContent()){const t=kr(e);if(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&&(this.format=t,this.style=n,d.isComposing()&&(this.anchor.offset-=e.length));}else {const t=new Set([...d.getParentKeys(),..._.getParentKeys()]),n=Wi(d)?d:d.getParentOrThrow();let r=Wi(_)?_:_.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(Tr(_)&&!Lo(_)&&a!==_.getTextContentSize()){if(_.isSegmented()){const t=kr(_.getTextContent());_.replace(t),_=t;}Vi(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];if(e.is(d)||Wi(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(Lo(d))if(c===h)d.select();else {const t=kr(e);t.select(),d.replace(t);}else d=d.spliceText(c,h-c,e,true),""===d.getTextContent()?d.remove():"text"===this.anchor.type&&(this.format=d.getFormat(),this.style=d.getStyle(),d.isComposing()&&(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=Qr()===this;Xl(this,nc(Ql(this))),t&&Qr()!==this&&es(this);}formatText(t,e=null){if(this.isCollapsed())return this.toggleFormat(t),void Uo(null);const n=this.getNodes(),r=[];for(const t of n)Tr(t)&&r.push(t);const i=e=>{n.forEach(n=>{if(Wi(n)){const r=n.getFormatFlags(t,e);n.setTextFormat(r);}});},o=r.length;if(0===o)return this.toggleFormat(t),Uo(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(Io(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||Io(d)||([,d]=d.splitText(h),h=0),d.setFormat(g);const m=p.getFormatFlags(t,g);y>0&&(y===p.getTextContentSize()||Io(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=Qr();return Fr(n)||t(134),n.insertNodes(e)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=dl(n,Qs),i=e[e.length-1];if(Wi(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else {const t=ai(this);r.splice(t,0,e),i.selectEnd();}return}if(!e.some(t=>(Wi(t)||ji(t))&&!t.isInline())){Wi(r)||t(211,n.constructor.name,n.getType());const o=ai(this);return r.splice(o,0,e),void i.selectEnd()}const o=function(t){const e=eo();let n=null;for(let r=0;r<t.length;r++){const i=t[r],o=sr(i);if(o||ji(i)&&i.isInline()||Wi(i)&&i.isInline()||Tr(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=!Wi(r)||!r.isEmpty()?this.insertParagraph():null,a=l[l.length-1];let u=l[0];var f;Wi(f=u)&&Qs(f)&&!f.isEmpty()&&Wi(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(Wi(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=dl(s,Qs);c&&Wi(d)&&(c.canMergeWhenEmpty()||Qs(a))&&(d.append(...c.getChildren()),c.remove()),Wi(r)&&r.isEmpty()&&r.remove(),s.selectEnd();const h=Wi(r)?r.getLastChild():null;sr(h)&&d!==r&&h.remove();}insertParagraph(){if("root"===this.anchor.key){const t=eo();return Zo().splice(this.anchor.offset,0,[t]),t.select(),t}const e=ai(this),n=dl(this.anchor.getNode(),Qs);Wi(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=or();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]=zr(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(Tr(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(Tr(n)&&(a===n.getTextContentSize()?t.shift():0!==a&&([,n]=n.splitText(a),t[0]=n,l.set(n.getKey(),0,"text"))),Tr(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(fi(this,t,e,n))return;const r="move"===t,i=vi(),o=Js(Ps(i));if(!o)return;const s=i._blockCursorElement,l=i._rootElement,c=this.focus.getNode();if(null===l||null===s||!Wi(c)||c.isInline()||c.canBeEmpty()||$s(s,i,l),this.dirty){let t=Ns(i,this.anchor.key),e=Ns(i,this.focus.key);"text"===this.anchor.type&&(t=Ro(t)),"text"===this.focus.type&&(e=Ro(e)),t&&e&&ii(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=Vi(n)?n:Ls(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];As(e,i)?r.push(e):s=true;}if(s&&r.length>0)if(e){const t=r[0];Wi(t)?t.selectStart():t.getParentOrThrow().selectStart();}else {const t=r[r.length-1];Wi(t)?t.selectEnd():t.getParentOrThrow().selectEnd();}o.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&&fi(this,t,e,n,"decorators");}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Wi(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(Wi(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=Rl(ql(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(Nl(e))if(e.origin.isInline());else {if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Wi(r.anchor.origin)&&r.anchor.origin.isEmpty()){const t=rc(e);Xl(this,Wl(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(Tl(e)){if(Wi(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(ji(e.origin)){if(e.origin.isIsolated());else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Wi(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const t=Hr();t.add(e.origin.getKey()),es(t);}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;return Xl(this,Wl(!e.origin.isEmpty()&&n.isEmpty()?Zl(Ol(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&&Rr(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 Wr(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 Wr(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 !(rs(t)||Br(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()&&Vi(t.getParent())&&null===t.getPreviousSibling()&&Rr(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.isCollapsed()?this.deleteCharacter(t):this.removeText();}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return [this.anchor,this.focus]}}function Ir(t){return t instanceof Pr}function Kr(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function zr(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]:[Kr(n),Kr(r)]}function Rr(t,e){for(let n=e;n;n=n.getParent()){if(Wi(n)){if(n.collapseAtStart(t))return true;if(Is(n))break}if(n.getPreviousSibling())break}return false}const Br=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("\u2764\ufe0f")&&e("#\ufe0f\u20e3")&&e("\u{1f44d}"))return e}catch(t){}return ()=>false})();function Wr(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 $r(e,n,r,i){let o,s=n;if(Ys(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=ns(f),Tr(o))s=Al(o,l?"next":"previous");else {let c=ns(e);if(null===c)return null;if(Wi(c)){const a=i.getElementByKey(c.getKey());null===a&&t(214);const u=tl(i).$getDOMSlot(c,a,i);[c,s]=u.resolveChildIndex(c,a,e,n),Wi(c)||t(215),l&&s>=c.getChildrenSize()&&(s=Math.max(0,c.getChildrenSize()-1));let f=c.getChildAtIndex(s);if(Wi(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=Wi(f)?f:f.getParentOrThrow()),s=0;}Tr(f)?(o=f,c=null,s=Al(f,l?"next":"previous")):f!==c&&l&&!d&&(Wi(c)||t(216),s=Math.min(c.getChildrenSize(),s+1));}else {const t=c.getIndexWithinParent();s=0===n&&ji(c)&&ns(e)===c?t:t+1,c=c.getParentOrThrow();}if(Wi(c))return Mr(c.__key,s,"element")}}else o=ns(e);return Tr(o)?Mr(o.__key,Al(o,s,"clamp"),"text"):null}function Jr(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&&Wi(o)&&o.isInline()){const e=o.getPreviousSibling();Tr(e)&&t.set(e.__key,e.getTextContent().length,"text");}}else Wi(r)&&!n&&r.isInline()?t.set(r.__key,r.getChildrenSize(),"element"):Tr(r)&&t.set(r.__key,r.getTextContent().length,"text");}else if(r===i.getTextContent().length){const r=i.getNextSibling(),o=i.getParent();if(e&&Wi(r)&&r.isInline())t.set(r.__key,0,"element");else if((n||e)&&null===r&&Wi(o)&&o.isInline()&&!o.canInsertTextAfter()){const e=o.getNextSibling();Tr(e)&&t.set(e.__key,0,"text");}}}function jr(t,e,n){if("text"===t.type&&"text"===e.type){const n=t.isBefore(e),r=t.is(e);Jr(t,n,r),Jr(e,!n,r),r&&e.set(t.key,t.offset,t.type);}}function Ur(t,e,n,r,i,o){if(null===t||null===n||!Mo(i,t,n))return null;const s=$r(t,e,Fr(o)?o.anchor:null,i);if(null===s)return null;const l=$r(n,r,Fr(o)?o.focus:null,i);if(null===l)return null;if("element"===s.type&&"element"===l.type){const e=ns(t),r=ns(n);if(ji(e)&&ji(r))return null}return jr(s,l),[s,l]}function Vr(t){return Wi(t)&&!t.isInline()}function Yr(t,e,n,r,i,o){const s=Si(),l=new Lr(Mr(t,e,i),Mr(n,r,o),0,"");return l.dirty=true,s._selection=l,l}function qr(){const t=Mr("root",0,"element"),e=Mr("root",0,"element");return new Lr(t,e,0,"")}function Hr(){return new Pr(new Set)}function Gr(t,e){return Xr(null,t,e,null)}function Xr(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$7&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&o&&3===o.detail||"drop"===s||void 0===s);let a,u,f,d;if(Fr(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)&&Fr(t)&&!Mo(n,a,u))return t.clone();const h=Ur(a,f,u,d,n,t);if(null===h)return null;const[g,_]=h;let p=0,y="";if(Fr(t)){const e=t.anchor;if(g.key===e.key)p=t.format,y=t.style;else {const t=g.getNode();Tr(t)?(p=t.getFormat(),y=t.getStyle()):Wi(t)&&(p=t.getTextFormat(),y=t.getTextStyle());}}return new Lr(g,_,p,y)}function Qr(){return Si()._selection}function Zr(){return vi()._editorState._selection}function ti(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"),ei(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");}}ei(t);}function ei(t){const e=t.anchor,n=e.offset,r=t.focus,i=r.offset,o=e.getNode(),s=r.getNode();if(t.isCollapsed()){if(!Wi(o))return;const t=o.getChildrenSize(),i=n>=t,s=i?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(Tr(s)){let t=0;i&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),r.set(s.__key,t,"text");}return}if(Wi(o)){const t=o.getChildrenSize(),r=n>=t,i=r?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(Tr(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text");}}if(Wi(s)){const t=s.getChildrenSize(),e=i>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(i);if(Tr(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text");}}}function ni(t,e,n,r,i){let o=null,s=0,l=null;null!==r?(o=r.__key,Tr(r)?(s=r.getTextContentSize(),l="text"):Wi(r)&&(s=r.getChildrenSize(),l="element")):null!==i&&(o=i.__key,Tr(i)?l="text":Wi(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 ri(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 ii(t,e,n,r,i){try{t.setBaseAndExtent(e,n,r,i);}catch(t){}}function oi(t,e,n){const r=Ns(t,e.getKey());if(Wi(e)){const i=tl(t).$getDOMSlot(e,r,t);return [i.element,n+i.getFirstChildOffset()]}return [r,n]}function si(t,e,n,r,i,s,l){const c=r.anchorNode,a=r.focusNode,u=r.anchorOffset,f=r.focusOffset,d=document.activeElement;if(i.has(Un)&&d!==s||null!==d&&Oo(d))return;if(!Fr(e))return void(null!==t&&Mo(n,c,a)&&r.removeAllRanges());const h=e.anchor,g=e.focus,_=h.getNode(),p=g.getNode(),[y,m]=oi(n,_,h.offset),[x,C]=oi(n,p,g.offset),S=e.format,v=e.style,k=e.isCollapsed();let T=y,N=x,b=false;var w,E,O,M,A;if(("text"===h.type?(T=Ro(y),b=_.getFormat()!==S||_.getStyle()!==v):Fr(t)&&"text"===t.anchor.type&&(b=true),"text"===g.type&&(N=Ro(x)),null!==T&&null!==N)&&(k&&(null===t||b||Fr(t)&&(t.format!==S||t.style!==v))&&(w=S,E=v,O=m,M=h.key,A=performance.now(),_n$1=[w,E,O,M,A]),u!==m||f!==C||c!==T||a!==N||"Range"===r.type&&k||(null!==d&&s.contains(d)||i.has(Hn)||s.focus({preventScroll:true}),"element"===h.type))){if(ii(r,T,m,N,C),!o||!e.isCollapsed()||null===s||i.has(Hn)||null!==document.activeElement&&s.contains(document.activeElement)||s.focus({preventScroll:true}),!i.has(Yn)&&e.isCollapsed()&&null!==s&&s===document.activeElement){const t=Fr(e)&&"element"===e.anchor.type?T.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=ws(n),i=Ds(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=Ps(t).innerHeight;const e=i.getComputedStyle(r.documentElement),n=parseFloat(e.scrollPaddingTop),o=parseFloat(e.scrollPaddingBottom);isFinite(n)&&(l+=n),isFinite(o)&&(c-=o);}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=bs(a);}}(n,e,s);}}cn$1=true;}}function li(t){let e=Qr()||Zr();null===e&&(e=Zo().selectEnd()),e.insertNodes(t);}function ci(){const t=Qr();return null===t?"":t.getTextContent()}function ai(e){let n=e;e.isCollapsed()||n.removeText();const r=Qr();Fr(r)&&(n=r),Fr(n)||t(161);const i=n.anchor;let o=i.getNode(),s=i.offset;for(;!Qs(o);){const t=o;if([o,s]=ui(o,s),t.is(o))break}return s}function ui(t,e){const n=t.getParent();if(!n){const t=eo();return Zo().append(t),t.select(),[Zo(),0]}if(Tr(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(!Wi(t)||0===e)return [n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new Lr(Mr(t.__key,e,"element"),Mr(t.__key,e,"element"),0,""),i=t.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings());}return [n,t.getIndexWithinParent()+1]}function fi(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=ql(t.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===e;let c=o,a="decorators-and-blocks"===i;if(!ic(c)){for(const t of c){a=false;const{origin:e}=t;if(!ji(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of Rl(o).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(Nl(t))t.origin.isInline()||(c=t);else {if(Wi(t.origin))continue;ji(t.origin)&&!t.origin.isInline()&&(c=t);}break}}if(c===o)return false;if(l&&!s&&ji(c.origin)&&c.origin.isKeyboardSelectable()){const t=Hr();return t.add(c.origin.getKey()),es(t),true}return c=rc(c),l&&Hl(t.anchor,c),Hl(t.focus,c),a||!s}let di=null,hi=null,gi=false,_i=false,pi=0;const yi={characterData:true,childList:true,subtree:true};function mi(){return gi||null!==di&&di._readOnly}function xi(){gi&&t(13);}function Ci(){pi>99&&t(14);}function Si(){return null===di&&t(195,ki()),di}function vi(){return null===hi&&t(337,ki()),hi}function ki(){let t=0;const e=new Set,n=Co.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const i=Po(r);if(Ao(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 Ti(){return hi}function Ni(t,e,n){const r=e.__type,i=No(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 bi(t,e){return void 0!==t&&t.__key!==e&&t.isAttached()}function wi(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 Ei(t){return Oi(t,vi()._nodes)}function Oi(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(Wi(s)&&Array.isArray(l))for(let t=0;t<l.length;t++){const e=Oi(l[t],n);s.append(e);}return s}function Mi(t,e,n){const r=di,i=gi,o=hi;di=e,gi=true,hi=t;try{return n()}finally{di=r,gi=i,hi=o;}}function Ai(t,e){const n=t._pendingEditorState,r=t._rootElement,i=t._headless||null===r;if(null===n)return void(t._deferred.length>0&&Fi(t,t._deferred));const o=t._editorState,s=o._selection,l=n._selection,c=0!==t._dirtyType,a=di,u=gi,f=hi,d=t._updating,h=t._observer;let g=null;if(t._pendingEditorState=null,t._editorState=n,!i&&c&&null!==h){hi=t,di=n,gi=false,t._updating=true;try{const e=t._dirtyType,r=t._dirtyElements,i=t._dirtyLeaves;h.disconnect(),g=ee$4(o,n,t,e,r,i);}catch(e){if(e instanceof Error&&t._onError(e),_i)throw e;return go(t,null,r,n),rt$4(t),t._dirtyType=2,_i=true,Ai(t,o),void(_i=false)}finally{h.observe(r,yi),t._updating=d,di=a,gi=u,hi=f;}}n._readOnly||(n._readOnly=true);const _=t._dirtyLeaves,p=t._dirtyElements,y=t._normalizedNodes,m=t._updateTags,x=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;for(o in r)i.has(o)||(r===n&&(r=Xo(t)),delete r[o]);}(t,n);const C=i?null:Js(Ps(t));if(t._editable&&null!==C&&(c||null===l||l.dirty||!l.is(s))&&null!==r&&!m.has(qn)){hi=t,di=n;try{if(null!==h&&h.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&$s(e,t,r),si(s,l,t,C,m,r);}!function(t,e,n){let r=t._blockCursorElement;if(Fr(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()){Ws(o.getChildAtIndex(s-1))&&(l=!0);}else {const e=o.getChildAtIndex(s);if(null!==e&&Ws(e)){const n=e.getPreviousSibling();(null===n||Ws(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=yc(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!==h&&h.observe(r,yi),hi=f,di=a;}}null!==g&&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,g,m,_,o),Fr(l)||null===l||null!==s&&s.is(l)||t.dispatchCommand(ie$4,void 0);const S=t._pendingDecorators;null!==S&&(t._decorators=S,t._pendingDecorators=null,Di("decorator",t,true,S)),function(t,e,n){const r=Qo(e),i=Qo(n);r!==i&&Di("textcontent",t,true,i);}(t,e||o,n),Di("update",t,true,{dirtyElements:p,dirtyLeaves:_,editorState:n,mutatedNodes:g,normalizedNodes:y,prevEditorState:e||o,tags:m}),Fi(t,x),function(t){const e=t._updates;if(0!==e.length){const n=e.shift();if(n){const[e,r]=n;Ii(t,e,r);}}}(t);}function Di(t,e,n,...r){const i=e._updating;e._updating=n;try{const n=e._listeners[t],i=Array.from(n);for(const[t,e]of i){e&&e();const i=t(...r);n.has(t)?n.set(t,i):i&&i();}}finally{e._updating=i;}}function Pi(t,e,n,r){const i=is(t);let o;for(let t=4;t>=0;t--)for(let s=0;s<i.length;s++){const l=i[s];if(s>0&&l._updating){o=l;break}const c=l._commands.get(e);if(void 0!==c){const e=c[t];if(e.size>0){let t=false;if(Ki(l,()=>{for(const i of e)if(i(n,r))return void(t=true)}),t)return t}}}return o&&o.update(()=>{Pi(o,e,n,r);}),false}function Fi(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;}}}function Li(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),wi(e,o.tag)),null==s?Ii(e,r,o):r();}}return i}function Ii(e,n,r){const i=e._updateTags;let o,s=false,l=false;void 0!==r&&(o=r.onUpdate,wi(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=Yi(a||c),u=true),a._flushSync=l;const f=di,d=gi,h=hi,g=e._updating;di=a,gi=false,e._updating=true,hi=e;const _=e._headless||null===e.getRootElement();vo(null);try{u&&(_?null!==c._selection&&(a._selection=c._selection.clone()):a._selection=function(t,e){const n=t.getEditorState()._selection,r=Js(Ps(t));return Fr(n)||null==n?Xr(n,r,t,e):n.clone()}(e,r&&r.event||null));const i=e._compositionKey;n(),s=Li(e,s),function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(Fr(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);Tr(e)&&e.isAttached()&&e.isSimpleText()&&!e.isUnmergeable()&&Ct$2(e);}}(a,e):function(t,e){const n=e._dirtyLeaves,r=e._dirtyElements,i=t._nodeMap,o=Vo(),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);Tr(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&Ct$2(r),void 0!==r&&bi(r,o)&&Ni(e,r,s),n.add(t);}if(l=e._dirtyLeaves,c=l.size,c>0){pi++;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&&bi(c,o)&&Ni(e,c,s);}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,pi++;}e._dirtyLeaves=n,e._dirtyElements=r;}(a,e),Li(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()||(Wi(e)&&Y$6(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(Fr(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 Ir(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 Ai(e)}finally{di=f,gi=d,hi=h,e._updating=g,pi=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,Ai(e)):u&&wo(()=>{Ai(e);}):(a._flushSync=false,u&&(i.clear(),e._deferred=[],e._pendingEditorState=null));}function Ki(t,e,n){hi===t&&void 0===n?e():Ii(t,e,n);}class zi{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null;}withBefore(t){return new zi(this.element,t,this.after)}withAfter(t){return new zi(this.element,this.before,t)}withElement(t){return this.element===t?this:new zi(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||l||a);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.setProperty("display","inline","important"),t.style.setProperty("border","0px","important"),t.style.setProperty("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=Ri(e,n);i.push(r);const o=Ri(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 Ri(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 Bi extends Rn$1{__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 W$6[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=vi()._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(Tr(e)&&t.push(e),Wi(e)){const n=e.getAllTextNodes();t.push(...n);}e=e.getNextSibling();}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Wi(t);){const e=t.getFirstChild();if(null===e)break;t=e;}return t}getLastDescendant(){let t=this.getLastChild();for(;Wi(t);){const e=t.getLastChild();if(null===e)break;t=e;}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return Wi(t)&&t.getLastDescendant()||t||null}const r=e[t];return Wi(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:Yo(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:Yo(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(),Wi(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(),Wi(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=B$6[t];return 0!==(this.getFormat()&e)}return false}hasTextFormat(t){const e=z$7[t];return 0!==(this.getTextFormat()&e)}getFormatFlags(t,e){return Bo(this.getLatest().__textFormat,t,e)}getTextStyle(){return this.getLatest().__textStyle}select(t,e){xi();const n=Qr();let r=t,i=e;const o=this.getChildrenSize();if(!this.canBeEmpty())if(0===t&&0===e){const t=this.getFirstChild();if(Tr(t)||Wi(t))return t.select(0,0)}else if(!(void 0!==t&&t!==o||void 0!==e&&e!==o)){const t=this.getLastChild();if(Tr(t)||Wi(t))return t.select()} void 0===r&&(r=o),void 0===i&&(i=o);const s=this.__key;return Fr(n)?(n.anchor.set(s,r,"element"),n.focus.set(s,i,"element"),n.dirty=true,n):Yr(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();return 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&&B$6[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){zn(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;Jo(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--,Jo(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=Qr();if(Fr(t)){const e=new Set(c),n=new Set(l),{anchor:r,focus:i}=t;$i(r,e,n)&&ni(r,r.getNode(),this,u,a),$i(i,e,n)&&ni(i,i.getNode(),this,u,a),0!==f||this.canBeEmpty()||Is(this)||this.remove();}}return o}getDOMSlot(t){return new zi(t)}exportDOM(t){const{element:e}=super.exportDOM(t);if(Ys(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&&""===n||Is(this)||this.getChildren().some(Tr)||(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=tl(e).$getDOMSlot(this,t,e);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 Wi(t){return t instanceof Bi}function $i(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 Ji extends Rn$1{decorate(t,e){return null}isIsolated(){return false}isInline(){return true}isKeyboardSelectable(){return true}}function ji(t){return t instanceof Ji}class Ui extends Bi{__cachedText;static getType(){return "root"}static clone(){return new Ui}constructor(){super("root"),this.__cachedText=null;}getTopLevelElementOrThrow(){t(51);}getTextContent(){const t=this.__cachedText;return !mi()&&0!==vi()._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)Wi(e)||ji(e)||t(282);return super.splice(e,n,r)}static importJSON(t){return Zo().updateFromJSON(t)}collapseAtStart(){return true}}function Vi(t){return t instanceof Ui}function Yi(t){return new Xi(new Map(t._nodeMap))}function qi(){return new Xi(new Map([["root",new Ui]]))}function Hi(e){const n=e.exportJSON(),r=e.constructor;if(n.type!==r.getType()&&t(130,r.name),Wi(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=Hi(o[t]);i.push(e);}}return n}function Gi(t){return t instanceof Xi}class Xi{_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 Mi(e&&e.editor||null,this,t)}clone(t){const e=new Xi(this._nodeMap,void 0===t?this._selection:t);return e._readOnly=true,e}toJSON(){return Mi(null,this,()=>({root:Hi(Zo())}))}}class Qi extends Bi{static getType(){return "artificial"}createDOM(t){return document.createElement("div")}}class Zi extends Bi{static getType(){return "paragraph"}static clone(t){return new Zi(t.__key)}createDOM(t){const e=document.createElement("p"),n=ms(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:to,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Ys(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);}return {element:e}}static importJSON(t){return eo().updateFromJSON(t)}exportJSON(){const t=super.exportJSON();if(void 0===t.textFormat||void 0===t.textStyle){const e=this.getChildren().find(Tr);e?(t.textFormat=e.getFormat(),t.textStyle=e.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle());}return t}insertNewAfter(t,e){const n=eo();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||Tr(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 to(t){const e=eo();if(t.style&&(e.setFormat(t.style.textAlign),sl(t,e)),""===e.getFormatType()){const n=t.getAttribute("align");n&&n&&n in B$6&&e.setFormat(n);}return {node:e}}function eo(){return zs(new Zi)}function no(t){return t instanceof Zi}const ro=0,io=1,oo=2,so=3,lo=4,co=-8,ao=-7,uo=-6,fo=-5,ho=-4;function go(t,e,n,r){const i=t._keyToDOMMap;i.clear(),t._editorState=qi(),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 _o(t){const e=new Set,n=new Set;let r=t;for(;r;){const{ownNodeConfig:t}=ul(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 Rn$1&&t!==Rn$1?t:void 0;}}return e}const po={$createDOM:(t,e)=>t.createDOM(e._config,e),$decorateDOM:(t,e,n,r)=>{},$exportDOM:(t,e)=>{const n=bo(e,t.getType());return n&&void 0!==n.exportDOM?n.exportDOM(e,t):t.exportDOM(e)},$extractWithChild:(t,e,n,r,i)=>Wi(t)&&t.extractWithChild(e,n,r),$getDOMSlot:(e,n,r)=>(Wi(e)||t(336,e.getKey(),e.getType()),e.getDOMSlot(n)),$shouldExclude:(t,e,n)=>Wi(t)&&t.excludeFromCopy("html"),$shouldInclude:(t,e,n)=>!e||t.isSelected(e),$updateDOM:(t,e,n,r)=>t.updateDOM(e,n,r._config)};function yo(t){const e=t||{},n=Ti(),r=e.theme||{},i=void 0===t?n:e.parentEditor||null,o=e.disableEvents||false,s=qi(),l=e.namespace||(null!==i?i._config.namespace:os()),c=e.editorState,a=[Ui,gr,rr,br,Zi,Qi,...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;}ul(e);const i=e.getType(),o=_o(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 Co(s,i,h,{disableEvents:o,dom:{...po,...t&&t.dom},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),function(t){t.registerCommand(le$3,vn$1,ro),t.registerCommand(ce$4,kn$1,ro),t.registerCommand(ae$4,Tn$1,ro),t.registerCommand(ue$4,Nn$1,ro),t.registerCommand(ve$2,wn$1,ro);}(g),g}function mo(t,e){const n=t.get(e);t.delete(e),n&&n();}function xo(t,e,n){return t.set(e,n),mo.bind(null,t,e)}class Co{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 Map,editable:new Map,mutation:new Map,root:new Map,textcontent:new Map,update:new Map},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=os(),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){return xo(this._listeners.update,t)}registerEditableListener(t){return xo(this._listeners.editable,t)}registerDecoratorListener(t){return xo(this._listeners.decorator,t)}registerTextContentListener(t){return xo(this._listeners.textcontent,t)}registerRootListener(t){const e=this._listeners.root;return Cc(xo(e,t,t(this._rootElement,null)||void 0),()=>function(t,e,n){const r=t.get(e);r&&r(),t.set(e,e(...n)||void 0);}(e,t,[null,this._rootElement]))}registerCommand(e,n,r){ void 0===r&&t(35);const i=this._commands;i.has(e)||i.set(e,[new V$7,new V$7,new V$7,new V$7,new V$7]);const o=i.get(e);void 0===o&&t(36,String(e));const s=function(t){return 7&t}(r),l=o[s];return s!==r?l.addFront(n):l.addBack(n),()=>{l.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=rl(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=rl(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=Yo(e);t&&t.markDirty();}},null===t._pendingEditorState?{tag:Jn}: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 Ts(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=ms(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,go(this,e,t,r),null!==e&&(this._config.disableEvents||Fn$1(e),null!=n&&e.classList.remove(...n)),null!==t){const e=Ds(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$4(this),this._updateTags.add(Jn),Ai(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;sn$1.set(t,n);const r=ln$1.get(n)??0;r<1&&n.addEventListener("selectionchange",Mn),ln$1.set(n,r+1),t.__lexicalEditor=e;const i=En$1(t);for(let n=0;n<tn$1.length;n++){const[r,o]=tn$1[n],s="function"==typeof o?t=>{Dn(t)||(An$1(t),(e.isEditable()||"click"===r)&&o(t,e));}:t=>{if(Dn(t))return;An$1(t);const n=e.isEditable();switch(r){case "cut":return n&&Ts(e,je$2,t);case "copy":return Ts(e,Je$2,t);case "paste":return n&&Ts(e,_e$2,t);case "dragstart":return n&&Ts(e,Be$2,t);case "dragover":return n&&Ts(e,We$2,t);case "dragend":return n&&Ts(e,$e$2,t);case "focus":return n&&Ts(e,Ge$2,t);case "blur":return n&&Ts(e,Xe$2,t);case "drop":return n&&Ts(e,ze$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(Jn),Ai(this);Di("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=Yi(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),Ai(this)),this._pendingEditorState=r,this._dirtyType=2,this._dirtyElements.set("root",false),this._compositionKey=null,null!=s&&o.add(s),this._updating||Ai(this);}parseEditorState(t,e){return function(t,e,n){const r=qi(),i=di,o=gi,s=hi,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,di=r,gi=false,hi=e,vo(null);try{const i=e._nodes;Oi(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,di=i,gi=o,hi=s;}return r}("string"==typeof t?JSON.parse(t):t,this,e)}read(t){return Ai(this),this.getEditorState().read(t,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):Ii(t,e,n);}(this,t,e);}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),Ki(this,()=>{const r=Qr(),i=Zo();null!==r?r.dirty||es(r.clone()):0!==i.getChildrenSize()&&("rootStart"===e.defaultSelection?i.selectStart():i.selectEnd()),Os("focus"),Ms(()=>{n.removeAttribute("autocapitalize"),t&&t();});}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"));}blur(){const t=this._rootElement;null!==t&&t.blur();const e=Js(this._window);null!==e&&e.removeAllRanges();}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,Di("editable",this,true,t));}toJSON(){return {editorState:this._editorState.toJSON()}}}Co.version="0.44.0+prod.esm";let So=null;function vo(t){So=t;}let ko=1;function To(){ko=1;}function No(e,n){const r=bo(e,n);return void 0===r&&t(30,n),r}function bo(t,e){return t._nodes.get(e)}const wo="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t);};function Eo(t){return ji(Go(t))}function Oo(t){const e=document.activeElement;if(!Ys(e))return false;const n=e.nodeName;return ji(Go(t))&&("INPUT"===n||"TEXTAREA"===n||"true"===e.contentEditable&&null==Po(e))}function Mo(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!Oo(e)&&Do(e)===t}catch(t){return false}}function Ao(t){return t instanceof Co}function Do(t){let e=t;for(;null!=e;){const t=Po(e);if(Ao(t))return t;e=bs(e);}return null}function Po(t){return t?t.__lexicalEditor:null}function Fo(t){return I$6.test(t)?"rtl":K$4.test(t)?"ltr":null}function Lo(t){return Er(t)||t.isToken()}function Io(t){return Lo(t)||t.isSegmented()}function Ko(t){return qs(t)&&3===t.nodeType}function zo(t){return qs(t)&&9===t.nodeType}function Ro(t){let e=t;for(;null!=e;){if(Ko(e))return e;e=e.firstChild;}return null}function Bo(t,e,n){const r=z$7[e];if(null!==n&&(t&r)===(n&r))return t;let i=t^r;return "subscript"===e?i&=~z$7.superscript:"superscript"===e?i&=~z$7.subscript:"lowercase"===e?(i&=~z$7.uppercase,i&=~z$7.capitalize):"uppercase"===e?(i&=~z$7.lowercase,i&=~z$7.capitalize):"capitalize"===e&&(i&=~z$7.lowercase,i&=~z$7.uppercase),i}function Wo(t){return Tr(t)||sr(t)||ji(t)}function $o(t,e){const n=function(){const t=So;return So=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);xi(),Ci();const r=vi(),i=Si(),o=""+ko++;i._nodeMap.set(o,t),Wi(t)?r._dirtyElements.set(o,true):r._dirtyLeaves.add(o),r._cloneNotNeeded.add(o),r._dirtyType=1,t.__key=o;}function Jo(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 jo(e){Ci(),zn(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),r=n.__parent,i=Si(),o=vi(),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,Wi(e)?l.set(c,true):o._dirtyLeaves.add(c);}function Uo(t){xi();const e=vi(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=Yo(n);null!==t&&t.getWritable();}if(null!==t){const e=Yo(t);null!==e&&e.getWritable();}}}function Vo(){if(mi())return null;return vi()._compositionKey}function Yo(t,e){const n=(e||Si())._nodeMap.get(t);return void 0===n?null:n}function qo(t,e){const n=Ho(t,vi());return void 0!==n?Yo(n,e):null}function Ho(t,e){return t[`__lexicalKey_${e._key}`]}function Go(t,e){let n=t;for(;null!=n;){const t=qo(n,e);if(null!==t)return t;n=bs(n);}return null}function Xo(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function Qo(t){return t.read(()=>Zo().getTextContent())}function Zo(){return ts(Si())}function ts(t){return t._nodeMap.get("root")}function es(t){xi();const e=Si();null!==t&&(t.dirty=true,t.setCachedNodes(null)),e._selection=t;}function ns(t){const e=vi(),n=function(t,e){let n=t;for(;null!=n;){const t=Ho(n,e);if(void 0!==t)return t;n=bs(n);}return null}(t,e);if(null===n){return t===e.getRootElement()?Yo("root"):null}return Yo(n)}function rs(t){return /[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function is(t){const e=[];for(let n=t;null!==n;n=n._parentEditor)e.push(n);return e}function os(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function ss(t){return Ko(t)?t.nodeValue:null}function ls(t,e,n){const r=Js(Ps(e));if(null===r)return;const i=r.anchorNode;let{anchorOffset:o,focusOffset:s}=r;if(null!==i){let e=ss(i);const r=Go(i);if(null!==e&&Tr(r)){if((e===A$3||e===P$3)&&n){const t=n.length;e=n,o=t,s=t;}null!==e&&cs(r,e,o,s,t);}}}function cs(t,e,n,r,i){let o=t;if(o.isAttached()&&(i||!o.isDirty())){const s=o.isComposing();let c=e;if((s||i)&&(e.endsWith(A$3)&&(c=e.slice(0,-A$3.length)),i)){const t=P$3;let e;for(;-1!==(e=c.indexOf(t));)c=c.slice(0,e)+c.slice(e+t.length),null!==n&&n>e&&(n=Math.max(e,n-t.length)),null!==r&&r>e&&(r=Math.max(e,r-t.length));}const u=o.getTextContent();if(i||c!==u){if(""===c){if(Uo(null),a||l||d$1)o.remove();else {const t=vi();setTimeout(()=>{t.update(()=>{o.isAttached()&&o.remove();});},20);}return}const e=o.getParent(),i=Zr(),u=o.getTextContentSize(),f=Vo(),h=o.getKey();if(o.isToken()||null!==f&&h===f&&!s||Fr(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=Qr();if(!Fr(g)||null===n||null===r)return void as(o,c,g);if(g.setTextNodeRange(o,n,o,r),o.isSegmented()){const t=kr(o.getTextContent());o.replace(t),o=t;}as(o,c,g);}}}function as(t,e,n){if(t.setTextContent(e),Fr(n)){const e=t.getKey();for(const r of ["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===e&&(i.offset=Al(t,i.offset,"clamp"));}}}function us(t,e,n){const r=e[n]||false;return "any"===r||r===t[n]}function fs(t,e){return us(t,e,"altKey")&&us(t,e,"ctrlKey")&&us(t,e,"shiftKey")&&us(t,e,"metaKey")}function ds(t,e,n){if(!fs(t,n))return false;if(t.key.toLowerCase()===e.toLowerCase())return true;if(e.length>1)return false;if(1===t.key.length&&t.key.charCodeAt(0)<=127)return false;if(t.code.startsWith("Digit")&&/^\d$/.test(e))return t.code===`Digit${e}`;const r="Key"+e.toUpperCase();return t.code===r}const hs={ctrlKey:!i,metaKey:i},gs={altKey:i,ctrlKey:!i};function _s(t){return "Backspace"===t.key}function ps(t){return ds(t,"a",hs)}function ys(t){const e=Zo();if(Fr(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$3(t),t}{const t=e.select(0,e.getChildrenSize());return es(St$3(t)),t}}function ms(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=yc(i);return n[e]=t,t}return i}function xs(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 Cs(t){const e=t.getType(),n=Si();if(n._readOnly){const t=rl(n).get(e);return t?Array.from(t.values()):[]}const r=n._nodeMap,i=[];for(const[,n]of r)n instanceof t&&n.__type===e&&n.isAttached()&&i.push(n);return i}function Ss(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 vs(t,e){const n=t.offset;if("element"===t.type){return Ss(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?Ss(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function ks(t){const e=Ps(t).event,n=e&&e.inputType;return "insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Ts(t,e,n){return Pi(t,e,n,t)}function Ns(e,n){const r=e._keyToDOMMap.get(n);return void 0===r&&t(75,n),r}function bs(t){const e=t.assignedSlot||t.parentElement;return Hs(e)?e.host:e}function ws(t){return zo(t)?t:Ys(t)?t.ownerDocument:null}function Es(t){return vi()._updateTags.has(t)}function Os(t){xi();vi()._updateTags.add(t);}function Ms(t){xi();vi()._deferred.push(t);}function As(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return true;n=n.getParent();}return false}function Ds(t){const e=ws(t);return e?e.defaultView:null}function Ps(e){const n=e._window;return null===n&&t(78),n}function Fs(t){return Wi(t)&&t.isInline()||ji(t)&&t.isInline()}function Ls(t){let e=t.getParentOrThrow();for(;null!==e;){if(Is(e))return e;e=e.getParentOrThrow();}return e}function Is(t){return Vi(t)||Wi(t)&&t.isShadowRoot()}function Ks(t,e=false){const n=t.constructor.clone(t);return $o(n,null),n.afterCloneFrom(t),e||n.resetOnCopyNodeFrom(t),n}function zs(e){const n=vi(),r=e.getType(),i=bo(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 Rs(e,n){!Vi(e.getParent())||Wi(n)||ji(n)||t(99);}function Bs(e){const n=Yo(e);return null===n&&t(63,e),n}function Ws(t){return (ji(t)||Wi(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 Js(t){return n?(t||window).getSelection():null}function js(t){const e=Ds(t);return e?e.getSelection():null}function Us(e,n){let r=e.getChildAtIndex(n);null==r&&(r=e),Is(e)&&t(102);const i=e=>{const n=e.getParentOrThrow(),o=Is(n),s=e!==r||o?Ks(e):e;if(o)return Wi(e)&&Wi(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 Vs(t){return Ys(t)&&"A"===t.tagName}function Ys(t){return qs(t)&&1===t.nodeType}function qs(t){return "object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function Hs(t){return qs(t)&&11===t.nodeType}function Gs(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 Xs(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 Qs(t){if(ji(t)&&!t.isInline())return true;if(!Wi(t)||Is(t))return false;const e=t.getFirstChild(),n=null===e||sr(e)||Tr(e)||e.isInline();return !t.isInline()&&false!==t.canBeEmpty()&&n}function Zs(){return vi()}function tl(t=Zs()){return t._config.dom||po}const el=new WeakMap,nl=new Map;function rl(e){if(!e._readOnly&&e.isEmpty())return nl;e._readOnly||t(192);let n=el.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),el.set(e,n)),n}function il(t){const e=t.constructor.clone(t);return e.afterCloneFrom(t),e}function ol(t){return (e=il(t))[Kn$1]=true,e;var e;}function sl(t,e){const n=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(n/40);e.setIndent(r);}function ll(t){t.__lexicalUnmanaged=true;}function cl(t){return true===t.__lexicalUnmanaged}function al(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==Rn$1[e]}function ul(e){const n=U$6 in e.prototype?e.prototype[U$6]():void 0,r=function(e){if(!(e===Rn$1||e.prototype instanceof Rn$1)){let n="<unknown>",r="<unknown>";try{n=e.getType();}catch(t){}try{Co.version&&(r=JSON.parse(Co.version));}catch(t){}t(290,e.name,n,r);}return e===Ji||e===Bi||e===Rn$1}(e),i=!r&&al(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&&(al(e,"getType")||(e.getType=()=>s),al(e,"clone")||(e.clone=t=>(vo(t),new e)),al(e,"importJSON")||(e.importJSON=o&&o.$importJSON||(t=>(new e).updateFromJSON(t))),!al(e,"importDOM")&&o)){const{importDOM:t}=o;t&&(e.importDOM=()=>t);}return {ownNodeConfig:o,ownNodeType:s}}function fl(t){const e=Zs();xi();return new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)}const dl=(t,e)=>{let n=t;for(;null!=n&&!Vi(n);){if(e(n))return n;n=n.getParent();}return null};function hl(e,n){const r=[];let i=e.__first;for(;null!==i;){const e=null===n?Yo(i):n.get(i);null==e&&t(174),r.push(i),i=e.__next;}return r}const gl={next:"previous",previous:"next"};class _l{origin;constructor(t){this.origin=t;}[Symbol.iterator](){return $l({hasNext:Tl,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return Ol(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Ol(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=Ol(e,this.direction);}for(const t of l.values())t.remove();return this}}class pl extends _l{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Pl(t,this.direction)}getParentCaret(t="root"){return Ol(xl(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ml(this.direction);return Ol(this.getNodeAtCaret(),t)||Pl(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof pl&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const yl={root:Vi,shadowRoot:Is};function ml(t){return gl[t]}function xl(t,e="root"){return yl[e](t)?null:t}class Cl extends _l{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ol(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Wi(this.origin)?Pl(this.origin,this.direction):null}getParentCaret(t="root"){return Ol(xl(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ml(this.direction);return Ol(this.getNodeAtCaret(),t)||Pl(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Cl&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return (t instanceof Cl||t instanceof Sl)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Sl extends _l{type="text";offset;constructor(t,e){super(t),this.offset=e;}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ml(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return Ol(xl(this.getParentAtCaret(),t),this.direction)}getFlipped(){return Ml(this.origin,ml(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Sl&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return (t instanceof Cl||t instanceof Sl)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return Ol(this.origin,this.direction)}}function vl(t){return t instanceof Sl}function kl(t){return t instanceof _l}function Tl(t){return t instanceof Cl}function Nl(t){return t instanceof pl}const bl={next:class extends Sl{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Sl{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},wl={next:class extends Cl{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Cl{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},El={next:class extends pl{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends pl{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function Ol(t,e){return t?new wl[e](t):null}function Ml(t,e,n){return t?new bl[e](t,Al(t,n)):null}function Al(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 Dl(t,e){return new Kl(t,e)}function Pl(t,e){return Wi(t)?new El[e](t):null}function Fl(t){return t&&t.getChildCaret()||t}function Ll(t){return t&&Fl(t.getAdjacentCaret())}class Il{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 Il(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return vl(e)?function(t,e){const{direction:n,origin:r}=t,i=Al(r,"focus"===e?ml(n):n);return Dl(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 [Dl(t,r.offset-t.offset),null]}return [e,n]}iterNodeCarets(t="root"){const e=vl(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=vl(n),i=e=>e.isSameNodeCaret(n)?null:Ll(e)||e.getParentCaret(t);return $l({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 Kl{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 Ml(t.setTextContent(i.slice(0,n)+i.slice(r)),e,n)}}function zl(t){return t instanceof Kl}function Rl(t){return Wl(t,Ol(Zo(),t.direction))}function Bl(t){return Wl(t,t)}function Wl(e,n){return e.direction!==n.direction&&t(265),new Il(e,n,e.direction)}function $l(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 Jl(e,n){const r=Yl(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 jl(r)}}function jl(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 Ul(t,e){return e.is(t)}function Vl(t){return Wi(t)?[t.getLatest(),null]:[t.getParent(),t.getLatest()]}function Yl(e,n){if(e.is(n))return {commonAncestor:e,type:"same"};const r=new Map;for(let[t,n]=Vl(e);t;n=t,t=t.getParent())r.set(t,n);for(let[i,o]=Vl(n);i;o=i,i=i.getParent()){const s=r.get(i);if(void 0!==s)return null===s?(Ul(e,i)||t(276),{commonAncestor:i,type:"ancestor"}):null===o?(Ul(n,i)||t(277),{commonAncestor:i,type:"descendant"}):((Wi(s)||Ul(e,s))&&(Wi(o)||Ul(n,o))&&i.is(s.getParent())&&i.is(o.getParent())||t(278),{a:s,b:o,commonAncestor:i,type:"branch"})}return null}function ql(e,n){const{type:r,key:i,offset:o}=e,s=Bs(e.key);return "text"===r?(Tr(s)||t(266,s.getType(),i),Ml(s,n,o)):(Wi(s)||t(267,s.getType(),i),lc(s,e.offset,n))}function Hl(e,n){const{origin:r,direction:i}=n,o="next"===i;vl(n)?e.set(r.getKey(),n.offset,"text"):Tl(n)?Tr(r)?e.set(r.getKey(),Al(r,i),"text"):e.set(r.getParentOrThrow().getKey(),r.getIndexWithinParent()+(o?1:0),"element"):(Nl(n)&&Wi(r)||t(268),e.set(r.getKey(),o?0:r.getChildrenSize(),"element"));}function Gl(t){const e=Qr(),n=Fr(e)?e:qr();return Xl(n,t),es(n),n}function Xl(t,e){Hl(t.anchor,e.anchor),Hl(t.focus,e.focus);}function Ql(t){const{anchor:e,focus:n}=t,r=ql(e,"next"),i=ql(n,"next"),o=Jl(r,i)<=0?"next":"previous";return Wl(oc(r,o),oc(i,o))}function Zl(t){const{direction:e,origin:n}=t,r=Ol(n,ml(e)).getNodeAtCaret();return r?Ol(r,e):Pl(n.getParentOrThrow(),e)}function tc(t,e="root"){const n=[t];for(let r=Nl(t)?t.getParentCaret(e):t.getSiblingCaret();null!==r;r=r.getParentCaret(e))n.push(Zl(r));return n}function ec(t){return !!t&&t.origin.isAttached()}function nc(e,n="removeEmptySlices"){if(e.isCollapsed())return e;const r="root",i="next";let o=n;const s=sc(e,i),l=tc(s.anchor,r),c=tc(s.focus.getFlipped(),r),a=new Set,u=[];for(const t of s.iterNodeCarets(r))if(Nl(t))a.add(t.origin.getKey());else if(Tl(t)){const{origin:e}=t;Wi(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=Zl(Ol(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=kr(t.getTextContent()).setStyle(t.getStyle()).setFormat(t.getFormat());r.replaceOrInsert(n),e=Ml(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(ec(t)){f=rc(t);break}for(const t of c)if(ec(t)){d=rc(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];if(Is(i))return;!n&&e(i)&&(n=i);}return n},u=a(o,Qs),f=u&&a(s,t=>n.has(t.getKey())&&Qs(t));return u&&f?[u,f]:null}(f,d,a);if(h){const[t,e]=h;Pl(t,"previous").splice(0,e.getChildren());let n=e.getParent();for(e.remove(true);n&&n.isEmpty();){const t=n;n=n.getParent(),t.remove(true);}}const g=[f,d,...l,...c].find(ec);if(g){return Bl(oc(rc(g),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)));}function rc(t){const e=function(t){let e=t;for(;Nl(e);){const t=Ll(e);if(!Nl(t))break;e=t;}return e}(t.getLatest()),{direction:n}=e;if(Tr(e.origin))return vl(e)?e:Ml(e.origin,n,n);const r=e.getAdjacentCaret();return Tl(r)&&Tr(r.origin)?Ml(r.origin,n,ml(n)):e}function ic(t){return vl(t)&&t.offset!==Al(t.origin,t.direction)}function oc(t,e){return t.direction===e?t:t.getFlipped()}function sc(t,e){return t.direction===e?t:Wl(oc(t.focus,e),oc(t.anchor,e))}function lc(t,e,n){let r=Pl(t,"next");for(let t=0;t<e;t++){const t=r.getAdjacentCaret();if(null===t)break;r=t;}return oc(r,n)}function cc(t,e="root"){let n=0,r=t,i=Ll(r);for(;null===i;){if(n--,i=r.getParentCaret(e),!i)return null;r=i,i=Ll(r);}return i&&[i,n]}function ac(e){const{origin:n,offset:r,direction:i}=e;if(r===Al(n,i))return e.getSiblingCaret();if(r===Al(n,ml(i)))return Zl(e.getSiblingCaret());const[o]=n.splitText(r);return Tr(o)||t(281),oc(Ol(o,"next"),i)}function uc(t,e){return true}function fc(t,{$copyElementNode:e=Ks,$splitTextPointCaretNext:n=ac,rootMode:r="shadowRoot",$shouldSplit:i=uc,removeEmptyDestination:o=false}={}){if(vl(t))return n(t);const s=t.getParentCaret(r);if(s){const{origin:n}=s;if(Nl(t)){const t=Zl(s);if(o&&n.isEmpty())return n.remove(),t;if(!n.canBeEmpty()||!i(n,"first"))return t}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||!o&&n.canBeEmpty()&&i(n,"last"))&&s.insert(e(n).splice(0,0,r));}return s}function dc(t){return t}function hc(...t){return t}function gc(t,e){return [t,e]}function _c(t){return t}function pc(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return {...t,...e};return t}function yc(...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 mc(t,...e){const n=yc(...e);n.length>0&&t.classList.add(...n);}function xc(t,...e){const n=yc(...e);n.length>0&&t.classList.remove(...n);}function Cc(...t){return ()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0;}}
|
|
6208
7325
|
|
|
6209
7326
|
var Lexical_prod = /*#__PURE__*/Object.freeze({
|
|
6210
7327
|
__proto__: null,
|
|
@@ -6452,7 +7569,7 @@ var Lexical_prod = /*#__PURE__*/Object.freeze({
|
|
|
6452
7569
|
*
|
|
6453
7570
|
*/
|
|
6454
7571
|
|
|
6455
|
-
function E$3(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.`)}function F$6(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function b$2(e){const n=Zs().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function z$6(e){return b$2(Vi(e)?e:e.getParentOrThrow())}function O$3(e){const t=z$6(e);return null!==t&&"rtl"===t.direction}function R$3(e,t,n="self"){const o=e.getStartEndPoints();if(t.isSelected(e)&&!Io(t)&&null!==o){const[l,r]=o,s=e.isBackward(),i=l.getNode(),u=r.getNode(),g=t.is(i),a=t.is(u);if(g||a){const[o,l]=zr(e),r=i.is(u),g=t.is(s?u:i),a=t.is(s?i:u);let d,p=0;if(r)p=o>l?l:o,d=o>l?o:l;else if(g){p=s?l:o,d=void 0;}else if(a){p=0,d=s?o:l;}const h=t.__text.slice(p,d);h!==t.__text&&("clone"===n&&(t=ol(t)),t.__text=h);}}return t}function A$2(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return Wi(t)||E$3(177),e.offset===t.getChildrenSize()}function M$4(t,n){(Fr(t)?t.isCollapsed():Tr(t)||Wi(t))||E$3(280);const o=Zn(Fr(t)?t.style:Tr(t)?t.getStyle():t.getTextStyle()),r=F$6(Object.entries(n).reduce((e,[n,l])=>("function"==typeof l?e[n]=l(o[n],t):null===l?delete e[n]:e[n]=l,e),{...o}));Fr(t)||Tr(t)?t.setStyle(r):t.setTextStyle(r);}function $$3(e,t){if(Fr(e)&&e.isCollapsed()){M$4(e,t);const n=e.anchor.getNode();Wi(n)&&n.isEmpty()&&M$4(n,t);}D$3(e=>{M$4(e,t);});const n=e.getNodes();if(n.length>0){const e=new Set;for(const o of n){if(!Wi(o)||!o.canBeEmpty()||0!==o.getChildrenSize())continue;const n=o.getKey();e.has(n)||(e.add(n),M$4(o,t));}}}function D$3(t){const n=Qr();if(!n)return;const i=new Map,c=e=>i.get(e.getKey())||[0,e.getTextContentSize()];if(Fr(n))for(const e of Ql(n).getTextSlices())e&&i.set(e.caret.origin.getKey(),e.getSliceIndices());const f=n.getNodes();for(const n of f){if(!Tr(n)||!n.canHaveFormat())continue;const[o,l]=c(n);if(l!==o)if(Io(n)||0===o&&l===n.getTextContentSize())t(n);else {t(n.splitText(o,l)[0===o?0:1]);}}Fr(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&j$6(n);}function j$6(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 U$5(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o);}function H$6(e,t,n=U$5){if(null===e)return;const l=e.getStartEndPoints(),r=new Map;let s=null;if(l){const[e,t]=l;s=qr(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const n=dl(e.getNode(),Qs),o=dl(t.getNode(),Qs);Wi(n)&&r.set(n.getKey(),n),Wi(o)&&r.set(o.getKey(),o);}for(const t of e.getNodes())if(Wi(t)&&Qs(t))r.set(t.getKey(),t);else if(null===l){const e=dl(t,Qs);Wi(e)&&r.set(e.getKey(),e);}for(const[e,o]of r){const l=t();n(o,l),o.replace(l,true),s&&(e===s.anchor.key&&s.anchor.set(l.getKey(),s.anchor.offset,s.anchor.type),e===s.focus.key&&s.focus.set(l.getKey(),s.focus.offset,s.focus.type));}s&&e.is(Qr())&&es(s);}function G$9(e){const t=J$
|
|
7572
|
+
function E$3(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.`)}function F$6(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function b$2(e){const n=Zs().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function z$6(e){return b$2(Vi(e)?e:e.getParentOrThrow())}function O$3(e){const t=z$6(e);return null!==t&&"rtl"===t.direction}function R$3(e,t,n="self"){const o=e.getStartEndPoints();if(t.isSelected(e)&&!Io(t)&&null!==o){const[l,r]=o,s=e.isBackward(),i=l.getNode(),u=r.getNode(),g=t.is(i),a=t.is(u);if(g||a){const[o,l]=zr(e),r=i.is(u),g=t.is(s?u:i),a=t.is(s?i:u);let d,p=0;if(r)p=o>l?l:o,d=o>l?o:l;else if(g){p=s?l:o,d=void 0;}else if(a){p=0,d=s?o:l;}const h=t.__text.slice(p,d);h!==t.__text&&("clone"===n&&(t=ol(t)),t.__text=h);}}return t}function A$2(e){if("text"===e.type)return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return Wi(t)||E$3(177),e.offset===t.getChildrenSize()}function M$4(t,n){(Fr(t)?t.isCollapsed():Tr(t)||Wi(t))||E$3(280);const o=Zn(Fr(t)?t.style:Tr(t)?t.getStyle():t.getTextStyle()),r=F$6(Object.entries(n).reduce((e,[n,l])=>("function"==typeof l?e[n]=l(o[n],t):null===l?delete e[n]:e[n]=l,e),{...o}));Fr(t)||Tr(t)?t.setStyle(r):t.setTextStyle(r);}function $$3(e,t){if(Fr(e)&&e.isCollapsed()){M$4(e,t);const n=e.anchor.getNode();Wi(n)&&n.isEmpty()&&M$4(n,t);}D$3(e=>{M$4(e,t);});const n=e.getNodes();if(n.length>0){const e=new Set;for(const o of n){if(!Wi(o)||!o.canBeEmpty()||0!==o.getChildrenSize())continue;const n=o.getKey();e.has(n)||(e.add(n),M$4(o,t));}}}function D$3(t){const n=Qr();if(!n)return;const i=new Map,c=e=>i.get(e.getKey())||[0,e.getTextContentSize()];if(Fr(n))for(const e of Ql(n).getTextSlices())e&&i.set(e.caret.origin.getKey(),e.getSliceIndices());const f=n.getNodes();for(const n of f){if(!Tr(n)||!n.canHaveFormat())continue;const[o,l]=c(n);if(l!==o)if(Io(n)||0===o&&l===n.getTextContentSize())t(n);else {t(n.splitText(o,l)[0===o?0:1]);}}Fr(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&j$6(n);}function j$6(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 U$5(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o);}function H$6(e,t,n=U$5){if(null===e)return;const l=e.getStartEndPoints(),r=new Map;let s=null;if(l){const[e,t]=l;s=qr(),s.anchor.set(e.key,e.offset,e.type),s.focus.set(t.key,t.offset,t.type);const n=dl(e.getNode(),Qs),o=dl(t.getNode(),Qs);Wi(n)&&r.set(n.getKey(),n),Wi(o)&&r.set(o.getKey(),o);}for(const t of e.getNodes())if(Wi(t)&&Qs(t))r.set(t.getKey(),t);else if(null===l){const e=dl(t,Qs);Wi(e)&&r.set(e.getKey(),e);}for(const[e,o]of r){const l=t();n(o,l),o.replace(l,true),s&&(e===s.anchor.key&&s.anchor.set(l.getKey(),s.anchor.offset,s.anchor.type),e===s.focus.key&&s.focus.set(l.getKey(),s.focus.offset,s.focus.type));}s&&e.is(Qr())&&es(s);}function G$9(e){const t=J$7(e);return null!==t&&"vertical-rl"===t.writingMode}function J$7(e){const t=e.anchor.getNode();return Wi(t)?b$2(t):z$6(t)}function Q$8(e,t){let n=G$9(e)?!t:t;Z$5(e)&&(n=!n);const o=ql(e.focus,n?"previous":"next");if(ic(o))return false;for(const e of Rl(o)){if(Nl(e))return !e.origin.isInline();if(!Wi(e.origin)){if(ji(e.origin))return true;break}}return false}function Y$5(e,t,n,o){e.modify(t?"extend":"move",n,o);}function Z$5(e){const t=J$7(e);return null!==t&&"rtl"===t.direction}function ee$3(e,t,n){const o=Z$5(e);let l;l=G$9(e)||o?!n:n,Y$5(e,t,l,"character");}function te$4(e,t,n){const o=e.getStyle(),l=Zn(o);return null!==l&&l[t]||n}function ne$4(t,n,o=""){let r=null;const s=t.getNodes(),i=t.anchor,c=t.focus,f=t.isBackward(),u=f?c.getNode():i.getNode(),g=f?i.getNode():c.getNode(),a=f?c.offset:i.offset,p=f?i.offset:c.offset;if(Fr(t)&&t.isCollapsed()&&""!==t.style){const e=t.style,o=Zn(e);if(null!==o&&n in o)return o[n]}for(let t=0;t<s.length;t++){const l=s[t];if((0!==t||!l.is(u)||!Tr(l)||a!==l.getTextContentSize())&&((0===t||!l.is(g)||0!==p)&&Tr(l))){const e=te$4(l,n,o);if(null===r)r=e;else if(r!==e){r="";break}}}return null===r?o:r}const oe$5=Zn;
|
|
6456
7573
|
|
|
6457
7574
|
function deepMerge(target, source) {
|
|
6458
7575
|
const result = { ...target, ...source };
|
|
@@ -7223,6 +8340,17 @@ function stripTrailingCodeBlockNewlines(doc) {
|
|
|
7223
8340
|
}
|
|
7224
8341
|
}
|
|
7225
8342
|
|
|
8343
|
+
// Browsers ignore spaces around a link's address when they follow it, but Lexical
|
|
8344
|
+
// doesn't: an address that doesn't start with a scheme gets https:// put in front,
|
|
8345
|
+
// so " https://example.com" becomes "https:// https://example.com", a dead link.
|
|
8346
|
+
function trimLinkAddresses(doc) {
|
|
8347
|
+
for (const link of doc.querySelectorAll("a[href]")) {
|
|
8348
|
+
const href = link.getAttribute("href");
|
|
8349
|
+
const trimmed = href.trim();
|
|
8350
|
+
if (trimmed !== href) link.setAttribute("href", trimmed);
|
|
8351
|
+
}
|
|
8352
|
+
}
|
|
8353
|
+
|
|
7226
8354
|
function lastDescendantOf(node) {
|
|
7227
8355
|
while (node.lastChild) node = node.lastChild;
|
|
7228
8356
|
return node
|
|
@@ -8185,7 +9313,11 @@ class ToolbarDropdown extends HTMLElement {
|
|
|
8185
9313
|
async #focusFirstInteractive() {
|
|
8186
9314
|
// Ask for the ring explicitly: opening the menu with the mouse otherwise leaves the
|
|
8187
9315
|
// first item focused without a focus ring, since focus() inherits the mouse modality.
|
|
8188
|
-
|
|
9316
|
+
// Only scroll when the item is off screen (e.g. a shortcut opened the dropdown with the
|
|
9317
|
+
// toolbar scrolled away). Otherwise a sticky toolbar inside the page's scroll padding
|
|
9318
|
+
// would scroll the page on every open.
|
|
9319
|
+
const element = this.#interactiveElements[0];
|
|
9320
|
+
element?.focus({ focusVisible: true, preventScroll: isInViewport(element) });
|
|
8189
9321
|
if (this.panel.role === "menu") await this.#resetTabIndexValues();
|
|
8190
9322
|
}
|
|
8191
9323
|
|
|
@@ -8205,6 +9337,11 @@ class ToolbarDropdown extends HTMLElement {
|
|
|
8205
9337
|
}
|
|
8206
9338
|
}
|
|
8207
9339
|
|
|
9340
|
+
function isInViewport(element) {
|
|
9341
|
+
const { top, bottom } = element.getBoundingClientRect();
|
|
9342
|
+
return top >= 0 && bottom <= window.innerHeight
|
|
9343
|
+
}
|
|
9344
|
+
|
|
8208
9345
|
const HEADING_BUTTON_SELECTOR = "button.lexxy-heading-button";
|
|
8209
9346
|
|
|
8210
9347
|
const HEADING_PRESETS = [
|
|
@@ -8662,7 +9799,7 @@ function F$5(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URL
|
|
|
8662
9799
|
*
|
|
8663
9800
|
*/
|
|
8664
9801
|
|
|
8665
|
-
const Q$7=Symbol.for("preact-signals");function X$5(){if(ot$2>1)return void ot$2--;let t,e=false;for(!function(){let t=it$1;for(it$1=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o;}();void 0!==et$1;){let n=et$1;for(et$1=void 0,st$1++;void 0!==n;){const i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&<$1(n))try{n.c();}catch(n){e||(t=n,e=true);}n=i;}}if(st$1=0,ot$2--,e)throw t}function Y$3(t){if(ot$2>0)return t();ct$1=++rt$3,ot$2++;try{return t()}finally{X$5();}}let tt$3,et$1;function nt$3(t){const e=tt$3;tt$3=void 0;try{return t()}finally{tt$3=e;}}let it$1,ot$2=0,st$1=0,rt$3=0,ct$1=0,at$2=0;function dt$2(t){if(void 0===tt$3)return;let e=t.n;return void 0===e||e.t!==tt$3?(e={i:0,S:t,p:tt$3.s,n:void 0,t:tt$3,e:void 0,x:void 0,r:e},void 0!==tt$3.s&&(tt$3.s.n=e),tt$3.s=e,t.n=e,32&tt$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=tt$3.s,e.n=void 0,tt$3.s.n=e,tt$3.s=e),e):void 0}function ut$2(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=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 ft$1(t,e){return new ut$2(t,e)}function lt$1(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function ht$2(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 gt$2(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 pt$1(t,e){ut$2.call(this,void 0),this.x=t,this.s=void 0,this.g=at$2-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 vt$1(t){const e=t.m;if(t.m=void 0,"function"==typeof e){ot$2++;const n=tt$3;tt$3=void 0;try{e();}catch(e){throw t.f&=-2,t.f|=8,xt$2(t),e}finally{tt$3=n,X$5();}}}function xt$2(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,vt$1(t);}function yt$4(t){if(tt$3!==this)throw new Error("Out-of-order effect");gt$2(this),tt$3=t,this.f&=-2,8&this.f&&xt$2(this),X$5();}function Et$2(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name;}function St$2(t,e){const n=new Et$2(t,e);try{n.c();}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function bt$2(t,e={}){const n={};for(const i in t){const o=e[i],s=ft$1(void 0===o?t[i]:o);n[i]=s;}return n}ut$2.prototype.brand=Q$7,ut$2.prototype.h=function(){return true},ut$2.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:nt$3(()=>{var t;null==(t=this.W)||t.call(this);}));},ut$2.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&&nt$3(()=>{var t;null==(t=this.Z)||t.call(this);}));}},ut$2.prototype.subscribe=function(t){return St$2(()=>{const e=this.value,n=tt$3;tt$3=void 0;try{t(e);}finally{tt$3=n;}},{name:"sub"})},ut$2.prototype.valueOf=function(){return this.value},ut$2.prototype.toString=function(){return this.value+""},ut$2.prototype.toJSON=function(){return this.value},ut$2.prototype.peek=function(){const t=tt$3;tt$3=void 0;try{return this.value}finally{tt$3=t;}},Object.defineProperty(ut$2.prototype,"value",{get(){const t=dt$2(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(st$1>100)throw new Error("Cycle detected");!function(t){0!==ot$2&&0===st$1&&t.l!==ct$1&&(t.l=ct$1,it$1={S:t,v:t.v,i:t.i,o:it$1});}(this),this.v=t,this.i++,at$2++,ot$2++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N();}finally{X$5();}}}}),pt$1.prototype=new ut$2,pt$1.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===at$2)return true;if(this.g=at$2,this.f|=1,this.i>0&&!lt$1(this))return this.f&=-2,true;const t=tt$3;try{ht$2(this),tt$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 tt$3=t,gt$2(this),this.f&=-2,true},pt$1.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);}ut$2.prototype.S.call(this,t);},pt$1.prototype.U=function(t){if(void 0!==this.t&&(ut$2.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);}},pt$1.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N();}},Object.defineProperty(pt$1.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=dt$2(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),Et$2.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.m=t);}finally{t();}},Et$2.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,vt$1(this),ht$2(this),ot$2++;const t=tt$3;return tt$3=this,yt$4.bind(this,t)},Et$2.prototype.N=function(){2&this.f||(this.f|=2,this.u=et$1,et$1=this);},Et$2.prototype.d=function(){this.f|=8,1&this.f||xt$2(this);},Et$2.prototype.dispose=function(){this.d();};function Ct$1(t){const e=new Set,n=new Set;for(const i of Dt$3(t)){const t="function"==typeof i?i:i.replace;ul(t),e.add(t.getType()),n.add(t);}return {nodes:n,types:e}}function Dt$3(t){return ("function"==typeof t.nodes?t.nodes():t.nodes)||[]}ot$3("format",{parse:t=>"number"==typeof t?t:0});function zt$3(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 Lt$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]=Lt$3(n[t],i[t]);return t}return e}const Ut$2=0,Tt$3=1,Bt$2=2,Wt$3=3,Gt$2=4,Vt$2=5,Zt$2=6,Jt$3=7;function Ht$2(t){return t.id===Ut$2}function qt$3(t){return t.id===Bt$2}function Qt$2(t){return function(t){return t.id===Tt$3}(t)||zt$3(305,String(t.id),String(Tt$3)),Object.assign(t,{id:Bt$2})}const Xt$3=new Set;let Yt$2 = class Yt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:Ut$2};}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):pc;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;qt$3(e)||zt$3(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$3,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:Gt$2,initResult:e,registerState:n})}(o,s,i);}build(t){const e=this.state;let n;e.id!==Gt$2&&zt$3(307,String(e.id),String(Vt$2)),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:Vt$2,output:e,registerState:n})}(e,n,i);}register(t,e){this._signal=e;const n=this.state;n.id!==Vt$2&&zt$3(308,String(n.id),String(Vt$2));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Zt$2})}(n),()=>{const t=this.state;t.id!==Jt$3&&zt$3(309,String(n.id),String(Jt$3)),this.state=function(t){return Object.assign(t,{id:Vt$2})}(t),i&&i();}}afterRegistration(t){const e=this.state;let n;return e.id!==Zt$2&&zt$3(310,String(e.id),String(Zt$2)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Jt$3})}(e),n}getSignal(){return void 0===this._signal&&zt$3(311),this._signal}getInitResult(){ void 0===this.extension.init&&zt$3(312,this.extension.name);const t=this.state;return function(t){return t.id>=Gt$2}(t)||zt$3(313,String(t.id),String(Gt$2)),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$3}(t)||zt$3(314,String(t.id),String(Wt$3)),{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&&zt$3(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&zt$3(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Jt$3}(t)||zt$3(316,String(t.id),String(Jt$3)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Xt$3}getPeerNameSet(){let t=this._peerNameSet;return 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>=Vt$2}))(t)||zt$3(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output};}return this._dependency}};const te$3={tag:Jn};function ee$2(){const t=Zo();t.isEmpty()&&t.append(eo());}const ne$3=dc({config:_c({setOptions:te$3,updateOptions:te$3}),init:({$initialEditorState:t=ee$2})=>({$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(Gi(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:[Ui,gr,rr,br,Zi]}),ie$3=Symbol.for("@lexical/extension/LexicalBuilder");function oe$4(...t){return de$3.fromExtensions(t).buildEditor()}function se$4(){}function re$4(t){throw t}function ce$3(t){return Array.isArray(t)?t:[t]}const ae$3="0.44.0+prod.esm";let de$3 = class de{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=ae$3,this.roots=t;for(const e of t)this.addExtension(e);}static fromExtensions(t){const e=[ce$3(ne$3)];for(const n of t)e.push(ce$3(n));return new de(e)}static maybeFromEditor(t){const e=t[ie$3];return e&&(e.PACKAGE_VERSION!==ae$3&&zt$3(292,e.PACKAGE_VERSION,ae$3),e instanceof de||zt$3(293)),e}static fromEditor(t){const e=de.maybeFromEditor(t);return void 0===e&&zt$3(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(yo({...n,...e?{onError:t=>{e(t,i);}}:{}}),{[ie$3]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=se$4;function e(){try{t();}finally{t=se$4;}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=Cc(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&&zt$3(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&&zt$3(296);const e=ce$3(t),[n]=e;"string"!=typeof n.name&&zt$3(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&zt$3(298,n.name),!i){i=new Yt$2(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&zt$3(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&zt$3(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=ce$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(qt$3(o))return;const s=n.extension.name;var r;Ht$2(o)||zt$3(300,s,i||"[unknown]"),Ht$2(r=o)||zt$3(304,String(r.id),String(Ut$2)),o=Object.assign(r,{id:Tt$3}),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=Qt$2(o),n.state=o,t.push(n);};for(const t of this.extensionNameMap.values())Ht$2(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&&zt$3(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 Cc(...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 Dt$3(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&zt$3(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&&Lt$3(s,r.theme);}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,a=i.size>0;(c||a)&&(t.html={},c&&(t.html.import=o),a&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=re$4),t}};function ue$3(t,e){const n=de$3.fromEditor(t).getExtensionRep(e);return void 0===n&&zt$3(303,e.name),n.getExtensionDependency()}function fe$3(t,e){const n=de$3.maybeFromEditor(t);if(!n)return;const i=n.extensionNameMap.get(e);return i?i.getExtensionDependency():void 0}
|
|
9802
|
+
const Q$7=Symbol.for("preact-signals");function X$5(){if(ot$2>1)return void ot$2--;let t,e=false;for(!function(){let t=it$1;for(it$1=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o;}();void 0!==et$1;){let n=et$1;for(et$1=void 0,st$1++;void 0!==n;){const i=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&<$1(n))try{n.c();}catch(n){e||(t=n,e=true);}n=i;}}if(st$1=0,ot$2--,e)throw t}function Y$4(t){if(ot$2>0)return t();ct$1=++rt$3,ot$2++;try{return t()}finally{X$5();}}let tt$4,et$1;function nt$3(t){const e=tt$4;tt$4=void 0;try{return t()}finally{tt$4=e;}}let it$1,ot$2=0,st$1=0,rt$3=0,ct$1=0,at$2=0;function dt$2(t){if(void 0===tt$4)return;let e=t.n;return void 0===e||e.t!==tt$4?(e={i:0,S:t,p:tt$4.s,n:void 0,t:tt$4,e:void 0,x:void 0,r:e},void 0!==tt$4.s&&(tt$4.s.n=e),tt$4.s=e,t.n=e,32&tt$4.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=tt$4.s,e.n=void 0,tt$4.s.n=e,tt$4.s=e),e):void 0}function ut$2(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=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 ft$1(t,e){return new ut$2(t,e)}function lt$1(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function ht$2(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 gt$2(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 pt$1(t,e){ut$2.call(this,void 0),this.x=t,this.s=void 0,this.g=at$2-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 vt$1(t){const e=t.m;if(t.m=void 0,"function"==typeof e){ot$2++;const n=tt$4;tt$4=void 0;try{e();}catch(e){throw t.f&=-2,t.f|=8,xt$2(t),e}finally{tt$4=n,X$5();}}}function xt$2(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,vt$1(t);}function yt$4(t){if(tt$4!==this)throw new Error("Out-of-order effect");gt$2(this),tt$4=t,this.f&=-2,8&this.f&&xt$2(this),X$5();}function Et$2(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name;}function St$2(t,e){const n=new Et$2(t,e);try{n.c();}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function bt$2(t,e={}){const n={};for(const i in t){const o=e[i],s=ft$1(void 0===o?t[i]:o);n[i]=s;}return n}ut$2.prototype.brand=Q$7,ut$2.prototype.h=function(){return true},ut$2.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:nt$3(()=>{var t;null==(t=this.W)||t.call(this);}));},ut$2.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&&nt$3(()=>{var t;null==(t=this.Z)||t.call(this);}));}},ut$2.prototype.subscribe=function(t){return St$2(()=>{const e=this.value,n=tt$4;tt$4=void 0;try{t(e);}finally{tt$4=n;}},{name:"sub"})},ut$2.prototype.valueOf=function(){return this.value},ut$2.prototype.toString=function(){return this.value+""},ut$2.prototype.toJSON=function(){return this.value},ut$2.prototype.peek=function(){const t=tt$4;tt$4=void 0;try{return this.value}finally{tt$4=t;}},Object.defineProperty(ut$2.prototype,"value",{get(){const t=dt$2(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(st$1>100)throw new Error("Cycle detected");!function(t){0!==ot$2&&0===st$1&&t.l!==ct$1&&(t.l=ct$1,it$1={S:t,v:t.v,i:t.i,o:it$1});}(this),this.v=t,this.i++,at$2++,ot$2++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N();}finally{X$5();}}}}),pt$1.prototype=new ut$2,pt$1.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===at$2)return true;if(this.g=at$2,this.f|=1,this.i>0&&!lt$1(this))return this.f&=-2,true;const t=tt$4;try{ht$2(this),tt$4=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 tt$4=t,gt$2(this),this.f&=-2,true},pt$1.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);}ut$2.prototype.S.call(this,t);},pt$1.prototype.U=function(t){if(void 0!==this.t&&(ut$2.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);}},pt$1.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N();}},Object.defineProperty(pt$1.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=dt$2(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),Et$2.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.m=t);}finally{t();}},Et$2.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,vt$1(this),ht$2(this),ot$2++;const t=tt$4;return tt$4=this,yt$4.bind(this,t)},Et$2.prototype.N=function(){2&this.f||(this.f|=2,this.u=et$1,et$1=this);},Et$2.prototype.d=function(){this.f|=8,1&this.f||xt$2(this);},Et$2.prototype.dispose=function(){this.d();};function Ct$1(t){const e=new Set,n=new Set;for(const i of Dt$3(t)){const t="function"==typeof i?i:i.replace;ul(t),e.add(t.getType()),n.add(t);}return {nodes:n,types:e}}function Dt$3(t){return ("function"==typeof t.nodes?t.nodes():t.nodes)||[]}ot$3("format",{parse:t=>"number"==typeof t?t:0});function zt$3(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 Lt$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]=Lt$3(n[t],i[t]);return t}return e}const Ut$2=0,Tt$3=1,Bt$2=2,Wt$3=3,Gt$2=4,Vt$2=5,Zt$2=6,Jt$3=7;function Ht$2(t){return t.id===Ut$2}function qt$3(t){return t.id===Bt$2}function Qt$2(t){return function(t){return t.id===Tt$3}(t)||zt$3(305,String(t.id),String(Tt$3)),Object.assign(t,{id:Bt$2})}const Xt$3=new Set;let Yt$2 = class Yt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:Ut$2};}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):pc;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;qt$3(e)||zt$3(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$3,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:Gt$2,initResult:e,registerState:n})}(o,s,i);}build(t){const e=this.state;let n;e.id!==Gt$2&&zt$3(307,String(e.id),String(Vt$2)),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:Vt$2,output:e,registerState:n})}(e,n,i);}register(t,e){this._signal=e;const n=this.state;n.id!==Vt$2&&zt$3(308,String(n.id),String(Vt$2));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Zt$2})}(n),()=>{const t=this.state;t.id!==Jt$3&&zt$3(309,String(n.id),String(Jt$3)),this.state=function(t){return Object.assign(t,{id:Vt$2})}(t),i&&i();}}afterRegistration(t){const e=this.state;let n;return e.id!==Zt$2&&zt$3(310,String(e.id),String(Zt$2)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Jt$3})}(e),n}getSignal(){return void 0===this._signal&&zt$3(311),this._signal}getInitResult(){ void 0===this.extension.init&&zt$3(312,this.extension.name);const t=this.state;return function(t){return t.id>=Gt$2}(t)||zt$3(313,String(t.id),String(Gt$2)),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$3}(t)||zt$3(314,String(t.id),String(Wt$3)),{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&&zt$3(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&zt$3(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Jt$3}(t)||zt$3(316,String(t.id),String(Jt$3)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Xt$3}getPeerNameSet(){let t=this._peerNameSet;return 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>=Vt$2}))(t)||zt$3(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output};}return this._dependency}};const te$3={tag:Jn};function ee$2(){const t=Zo();t.isEmpty()&&t.append(eo());}const ne$3=dc({config:_c({setOptions:te$3,updateOptions:te$3}),init:({$initialEditorState:t=ee$2})=>({$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(Gi(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:[Ui,gr,rr,br,Zi]}),ie$3=Symbol.for("@lexical/extension/LexicalBuilder");function oe$4(...t){return de$3.fromExtensions(t).buildEditor()}function se$4(){}function re$4(t){throw t}function ce$3(t){return Array.isArray(t)?t:[t]}const ae$3="0.44.0+prod.esm";let de$3 = class de{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=ae$3,this.roots=t;for(const e of t)this.addExtension(e);}static fromExtensions(t){const e=[ce$3(ne$3)];for(const n of t)e.push(ce$3(n));return new de(e)}static maybeFromEditor(t){const e=t[ie$3];return e&&(e.PACKAGE_VERSION!==ae$3&&zt$3(292,e.PACKAGE_VERSION,ae$3),e instanceof de||zt$3(293)),e}static fromEditor(t){const e=de.maybeFromEditor(t);return void 0===e&&zt$3(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(yo({...n,...e?{onError:t=>{e(t,i);}}:{}}),{[ie$3]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=se$4;function e(){try{t();}finally{t=se$4;}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=Cc(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&&zt$3(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&&zt$3(296);const e=ce$3(t),[n]=e;"string"!=typeof n.name&&zt$3(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&zt$3(298,n.name),!i){i=new Yt$2(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&zt$3(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&zt$3(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=ce$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(qt$3(o))return;const s=n.extension.name;var r;Ht$2(o)||zt$3(300,s,i||"[unknown]"),Ht$2(r=o)||zt$3(304,String(r.id),String(Ut$2)),o=Object.assign(r,{id:Tt$3}),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=Qt$2(o),n.state=o,t.push(n);};for(const t of this.extensionNameMap.values())Ht$2(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&&zt$3(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 Cc(...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 Dt$3(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&zt$3(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&&Lt$3(s,r.theme);}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,a=i.size>0;(c||a)&&(t.html={},c&&(t.html.import=o),a&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=re$4),t}};function ue$3(t,e){const n=de$3.fromEditor(t).getExtensionRep(e);return void 0===n&&zt$3(303,e.name),n.getExtensionDependency()}function fe$3(t,e){const n=de$3.maybeFromEditor(t);if(!n)return;const i=n.extensionNameMap.get(e);return i?i.getExtensionDependency():void 0}
|
|
8666
9803
|
|
|
8667
9804
|
/**
|
|
8668
9805
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -8672,7 +9809,7 @@ const Q$7=Symbol.for("preact-signals");function X$5(){if(ot$2>1)return void ot$2
|
|
|
8672
9809
|
*
|
|
8673
9810
|
*/
|
|
8674
9811
|
|
|
8675
|
-
function q$6(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.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.`)}function G$8(e){let t=1,n=e.getParent();for(;null!=n;){if(pe$2(n)){const e=n.getParent();if(Se$1(e)){t++,n=e.getParent();continue}q$6(40);}return t}return t}function Q$6(e){let t=e.getParent();Se$1(t)||q$6(40);let n=t;for(;null!==n;)n=n.getParent(),Se$1(n)&&(t=n);return t}function Y$2(e){let t=[];const n=e.getChildren().filter(pe$2);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();Se$1(i)?t=t.concat(Y$2(i)):t.push(r);}return t}function Z$3(e){return pe$2(e)&&Se$1(e.getFirstChild())}function ee$1(e){return fe$2().append(e)}function te$2(e,t){return pe$2(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function ne$2(e){const t=Qr();if(null!==t){let n=t.getNodes();if(Fr(t)){const r=t.getStartEndPoints();null===r&&q$6(143);const[i]=r,s=i.getNode(),o=s.getParent();if(Is(s)){const e=s.getFirstChild();if(e)n=e.selectStart().getNodes();else {const e=eo();s.append(e),n=e.select().getNodes();}}else if(te$2(s,n)){const t=Te$1(e);if(Is(o)){s.replace(t);const e=fe$2();Wi(s)&&(e.setFormat(s.getFormatType()),e.setIndent(s.getIndent())),t.append(e);}else if(pe$2(s)){const e=s.getParentOrThrow();re$3(t,e.getChildren()),e.replace(t);}return}}const r=new Set;for(let t=0;t<n.length;t++){const i=n[t];if(Wi(i)&&i.isEmpty()&&!pe$2(i)&&!r.has(i.getKey())){ie$2(i,e);continue}let s=Wo(i)?i.getParent():pe$2(i)&&i.isEmpty()?i:null;for(;null!=s;){const t=s.getKey();if(Se$1(s)){if(!r.has(t)){const n=Te$1(e);re$3(n,s.getChildren()),s.replace(n),r.add(t);}break}{const n=s.getParent();if(Is(n)&&!r.has(t)){r.add(t),ie$2(s,e);break}s=n;}}}}}function re$3(e,t){e.splice(e.getChildrenSize(),0,t);}function ie$2(e,t){if(Se$1(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),i=fe$2();let s;if(re$3(i,e.getChildren()),Se$1(n)&&t===n.getListType())n.append(i),Se$1(r)&&t===r.getListType()&&(re$3(n,r.getChildren()),r.remove()),s=n;else if(Se$1(r)&&t===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else {const n=Te$1(t);n.append(i),e.replace(n),s=n;}i.setFormat(e.getFormatType()),i.setIndent(e.getIndent());const o=Qr();return Fr(o)&&(s.getKey()===o.anchor.key&&o.anchor.set(i.getKey(),o.anchor.offset,"element"),s.getKey()===o.focus.key&&o.focus.set(i.getKey(),o.focus.offset,"element")),e.remove(),s}function se$3(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&Z$3(n)&&Z$3(r)&&(se$3(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove();}function oe$3(){const e=Qr();if(Fr(e)){const t=new Set,r=e.getNodes(),i=e.anchor.getNode();if(te$2(i,r))t.add(Q$6(i));else for(let e=0;e<r.length;e++){const i=r[e];if(Wo(i)){const e=At$2(i,ge$2);null!=e&&t.add(Q$6(e));}}for(const n of t){let t=n;const r=Y$2(n);for(const n of r){const r=eo().setTextStyle(e.style).setTextFormat(e.format);re$3(r,n.getChildren()),t.insertAfter(r),t=r,n.__key===e.anchor.key&&Hl(e.anchor,rc(Pl(r,"next"))),n.__key===e.focus.key&&Hl(e.focus,rc(Pl(r,"next"))),n.remove();}n.remove();}}}function le$2(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())pe$2(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),Se$1(r.getFirstChild())||n++);}function ce$2(e){const t=new Set;if(Z$3(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(Z$3(r)&&Z$3(i)){const n=i.getFirstChild();if(Se$1(n)){n.append(e);const i=r.getFirstChild();if(Se$1(i)){re$3(n,i.getChildren()),r.remove(),t.add(r.getKey());}}}else if(Z$3(r)){const t=r.getFirstChild();if(Se$1(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e);}}else if(Z$3(i)){const t=i.getFirstChild();Se$1(t)&&t.append(e);}else if(Se$1(n)){const t=Ks(e),s=Ks(n);t.append(s),s.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t);}}function ae$2(e){if(Z$3(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(Se$1(n?n.getParent():void 0)&&pe$2(n)&&Se$1(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(i))n.insertAfter(e),t.isEmpty()&&n.remove();else {const r=Ks(e),i=Ks(t);r.append(i),e.getPreviousSiblings().forEach(e=>i.append(e));const s=Ks(e),o=Ks(t);s.append(o),re$3(o,e.getNextSiblings()),n.insertBefore(r),n.insertAfter(s),n.replace(e);}}}function ue$2(e=false){const t=Qr();if(!Fr(t)||!t.isCollapsed())return false;const n=t.anchor.getNode();let r=null;if(pe$2(n)&&0===n.getChildrenSize())r=n;else if(Tr(n)){const e=n.getParent();pe$2(e)&&e.getChildren().every(e=>Tr(e)&&""===e.getTextContent().trim())&&(r=e);}if(null===r)return false;const i=Q$6(r),s=r.getParent();Se$1(s)||q$6(40);const o=s.getParent();let l;if(Is(o))l=eo(),i.insertAfter(l);else {if(!pe$2(o))return false;l=Ks(o),o.insertAfter(l);}l.setTextStyle(t.style).setTextFormat(t.format).select();const c=r.getNextSiblings();if(c.length>0){const t=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(s,r):1,n=Ks(s).setStart(t);if(pe$2(l)){const e=Ks(l);e.append(n),l.insertAfter(e);}else l.insertAfter(n);n.append(...c);}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!pe$2(e)&&!Se$1(e))break;t=e;}t.remove();}(r),true}let ge$2 = class ge extends Bi{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const t=e.getParent();if(Se$1(t))"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0);else if(t){const n=e.createParentElementNode();Se$1(n)||q$6(340);const i=[e];for(const t of ["previous","next"]){i.reverse();for(const{origin:n}of Ol(e,t)){if(!pe$2(n))break;i.push(n);}}e.insertBefore(n),n.splice(0,0,i),Is(t)||(Rt$3(n,Zl(Ol(n,"next")),{$shouldSplit:()=>false,removeEmptyDestination:true}),t.isEmpty()&&t.isAttached()&&t.remove());}},extends:Bi,importDOM:In({li:()=>({conversion:he$2,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t;}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked;}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,n){!function(e,t,n){const r=t.getParent();!Se$1(r)||"check"!==r.getListType()||Se$1(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),n&&t.__checked===n.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"));}(t,this,e),t.value=this.__value,function(e,t,n){const r=[],o=[],l=t.list,c=l?l.listitem:void 0;let a;l&&l.nested&&(a=l.nested.listitem);void 0!==c&&r.push(...yc(c));if(l){const e=n.getParent(),t=Se$1(e)&&"check"===e.getListType(),i=n.getChecked();t&&!i||o.push(l.listitemUnchecked),t&&i||o.push(l.listitemChecked),t&&r.push(i?l.listitemChecked:l.listitemUnchecked);}if(void 0!==a){const e=yc(a);n.getChildren().some(e=>Se$1(e))?r.push(...e):o.push(...e);}o.length>0&&xc(e,...o);r.length>0&&mc(e,...r);}(t,n.theme,this);const r=e?e.__style:"",o=this.__style;r!==o&&nr(t.style,o,r),function(e,t,n){const r=t.__textStyle,i=n?n.__textStyle:"";if(null!==n&&i===r)return;const s=Zn(r);for(const t in s)e.style.setProperty(`--listitem-marker-${t}`,s[t]);if(""!==i)for(const t in Zn(i))t in s||e.style.removeProperty(`--listitem-marker-${t}`);}(t,this,e);}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),false}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),n=this.getFormatType();n&&(t.style.textAlign=n);const r=this.getDirection();return r&&(t.dir=r),Z$3(this)?{after(e){if(Ys(e)){const t=e.previousElementSibling;if(Ys(t)&&"LI"===t.nodeName){for(;e.firstChild;)t.append(e.firstChild);e.remove();}}return e},element:t}:{element:t}}exportJSON(){return {...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(Wi(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove();}else super.append(n);}return this}replace(e,t){if(pe$2(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Se$1(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else {const t=Ks(n);let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e);}n.insertAfter(e),e.insertAfter(t);}return t&&(Wi(e)||q$6(139),this.getChildren().forEach(t=>{e.append(t);})),this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=true){const n=this.getParentOrThrow();if(Se$1(n)||q$6(39),pe$2(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=Ks(n);r.forEach(e=>i.append(e)),e.insertAfter(i,t);}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Z$3(t)&&Z$3(n)&&(se$3(t.getFirstChild(),n.getFirstChild()),n.remove());}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(false);}insertNewAfter(e,t=true){const n=Ks(this);return this.insertAfter(n,t),n}collapseAtStart(e){const t=eo();this.getChildren().forEach(e=>t.append(e));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=pe$2(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else {n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,s=t.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(t),this.remove();return true}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Se$1(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;pe$2(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&q$6(117),(e=Math.floor(e))>=0||q$6(199);let t=this.getIndent();for(;t!==e;)t<e?(ce$2(this),t++):(ae$2(this),t--);return this}canInsertAfter(e){return pe$2(e)}canReplaceWith(e){return pe$2(e)}canMergeWith(e){return pe$2(e)||no(e)}extractWithChild(e,t){if(!Fr(t))return false;const n=t.anchor.getNode(),r=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return true}createParentElementNode(){return Te$1("bullet")}canMergeWhenEmpty(){return true}};function he$2(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return de$2(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return de$2(t.children[0]);const t=e.getAttribute("aria-checked");return {node:fe$2("true"===t||"false"!==t&&void 0)}}function de$2(e){if(!("checkbox"===e.getAttribute("type")))return {node:null};return {node:fe$2(e.hasAttribute("checked"))}}function fe$2(e){return zs(new ge$2(void 0,e))}function pe$2(e){return e instanceof ge$2}let me$2 = class me extends Bi{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();Se$1(t)&&e.getListType()===t.getListType()&&se$3(e,t);}(e),le$2(e);},extends:Bi,importDOM:In({ol:()=>({conversion:ye$1,priority:0}),ul:()=>({conversion:ye$1,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=ve$1[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t;}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start;}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,_e$1(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(_e$1(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),false)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return Ys(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return {...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return false}canIndent(){return false}splice(e,t,n){const r=n.find(pe$2)??this.getChildren().find(pe$2),i=r?()=>Ks(r):fe$2;let s=n;for(let e=0;e<n.length;e++){const t=n[e];pe$2(t)||(s===n&&(s=[...n]),s[e]=i().append(!Wi(t)||Se$1(t)||t.isInline()?t:kr(t.getTextContent())));}return super.splice(e,t,s)}extractWithChild(e){return pe$2(e)}};function _e$1(e,t,n){const r=[],o=[],l=t.list;if(void 0!==l){const e=l[`${n.__tag}Depth`]||[],t=G$8(n)-1,i=t%e.length,s=e[i],c=l[n.__tag];let a;const u=l.nested,g=l.checklist;if(void 0!==u&&u.list&&(a=u.list),void 0!==c&&r.push(c),void 0!==g&&"check"===n.__listType&&r.push(g),void 0!==s){r.push(...yc(s));for(let t=0;t<e.length;t++)t!==i&&o.push(n.__tag+t);}if(void 0!==a){const e=yc(a);t>1?r.push(...e):o.push(...e);}}o.length>0&&xc(e,...o),r.length>0&&mc(e,...r);}function Ce$1(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(pe$2(r)){t.push(r);const e=r.getChildren();e.length>1&&e.forEach(e=>{Se$1(e)&&t.push(ee$1(e));});}else t.push(ee$1(r));}return t}function ye$1(e){const t=e.nodeName.toLowerCase();let n=null;if("ol"===t){n=Te$1("number",e.start);}else "ul"===t&&(n=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return true;for(const t of e.childNodes)if(Ys(t)&&t.hasAttribute("aria-checked"))return true;return false}(e)?Te$1("check"):Te$1("bullet"));return {after:Ce$1,node:n}}const ve$1={ol:"number",ul:"bullet"};function Te$1(e="number",t=1){return zs(new me$2(e,t))}function Se$1(e){return e instanceof me$2}const Fe$1=re$5("UPDATE_LIST_START_COMMAND"),Ee$2=re$5("INSERT_UNORDERED_LIST_COMMAND"),Oe$1=re$5("INSERT_ORDERED_LIST_COMMAND"),Ae$2=re$5("REMOVE_LIST_COMMAND");function Ie$2(e,t){return Cc(e.registerCommand(Oe$1,()=>(ne$2("number"),true),io),e.registerCommand(Fe$1,e=>{const{listNodeKey:t,newStart:n}=e,r=Yo(t);return !!Se$1(r)&&("number"===r.getListType()&&(r.setStart(n),le$2(r)),true)},io),e.registerCommand(Ee$2,()=>(ne$2("bullet"),true),io),e.registerCommand(Ae$2,()=>(oe$3(),true),io),e.registerCommand(he$3,()=>ue$2(false),io),e.registerNodeTransform(ge$2,e=>{const t=e.getFirstChild();if(t){if(Tr(t)){const n=t.getStyle(),r=t.getFormat();e.getTextStyle()!==n&&e.setTextStyle(n),e.getTextFormat()!==r&&e.setTextFormat(r);}}else {const t=Qr();Fr(t)&&(t.style!==e.getTextStyle()||t.format!==e.getTextFormat())&&t.isCollapsed()&&e.is(t.anchor.getNode())&&e.setTextStyle(t.style).setTextFormat(t.format);}}),e.registerNodeTransform(gr,e=>{const t=e.getParent();if(pe$2(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r);}}))}
|
|
9812
|
+
function q$6(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.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.`)}function G$8(e){let t=1,n=e.getParent();for(;null!=n;){if(pe$2(n)){const e=n.getParent();if(Se$1(e)){t++,n=e.getParent();continue}q$6(40);}return t}return t}function Q$6(e){let t=e.getParent();Se$1(t)||q$6(40);let n=t;for(;null!==n;)n=n.getParent(),Se$1(n)&&(t=n);return t}function Y$3(e){let t=[];const n=e.getChildren().filter(pe$2);for(let e=0;e<n.length;e++){const r=n[e],i=r.getFirstChild();Se$1(i)?t=t.concat(Y$3(i)):t.push(r);}return t}function Z$4(e){return pe$2(e)&&Se$1(e.getFirstChild())}function ee$1(e){return fe$2().append(e)}function te$2(e,t){return pe$2(e)&&(0===t.length||1===t.length&&e.is(t[0])&&0===e.getChildrenSize())}function ne$2(e){const t=Qr();if(null!==t){let n=t.getNodes();if(Fr(t)){const r=t.getStartEndPoints();null===r&&q$6(143);const[i]=r,s=i.getNode(),o=s.getParent();if(Is(s)){const e=s.getFirstChild();if(e)n=e.selectStart().getNodes();else {const e=eo();s.append(e),n=e.select().getNodes();}}else if(te$2(s,n)){const t=Te$1(e);if(Is(o)){s.replace(t);const e=fe$2();Wi(s)&&(e.setFormat(s.getFormatType()),e.setIndent(s.getIndent())),t.append(e);}else if(pe$2(s)){const e=s.getParentOrThrow();re$3(t,e.getChildren()),e.replace(t);}return}}const r=new Set;for(let t=0;t<n.length;t++){const i=n[t];if(Wi(i)&&i.isEmpty()&&!pe$2(i)&&!r.has(i.getKey())){ie$2(i,e);continue}let s=Wo(i)?i.getParent():pe$2(i)&&i.isEmpty()?i:null;for(;null!=s;){const t=s.getKey();if(Se$1(s)){if(!r.has(t)){const n=Te$1(e);re$3(n,s.getChildren()),s.replace(n),r.add(t);}break}{const n=s.getParent();if(Is(n)&&!r.has(t)){r.add(t),ie$2(s,e);break}s=n;}}}}}function re$3(e,t){e.splice(e.getChildrenSize(),0,t);}function ie$2(e,t){if(Se$1(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),i=fe$2();let s;if(re$3(i,e.getChildren()),Se$1(n)&&t===n.getListType())n.append(i),Se$1(r)&&t===r.getListType()&&(re$3(n,r.getChildren()),r.remove()),s=n;else if(Se$1(r)&&t===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else {const n=Te$1(t);n.append(i),e.replace(n),s=n;}i.setFormat(e.getFormatType()),i.setIndent(e.getIndent());const o=Qr();return Fr(o)&&(s.getKey()===o.anchor.key&&o.anchor.set(i.getKey(),o.anchor.offset,"element"),s.getKey()===o.focus.key&&o.focus.set(i.getKey(),o.focus.offset,"element")),e.remove(),s}function se$3(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&Z$4(n)&&Z$4(r)&&(se$3(n.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&e.append(...i),t.remove();}function oe$3(){const e=Qr();if(Fr(e)){const t=new Set,r=e.getNodes(),i=e.anchor.getNode();if(te$2(i,r))t.add(Q$6(i));else for(let e=0;e<r.length;e++){const i=r[e];if(Wo(i)){const e=At$2(i,ge$2);null!=e&&t.add(Q$6(e));}}for(const n of t){let t=n;const r=Y$3(n);for(const n of r){const r=eo().setTextStyle(e.style).setTextFormat(e.format);re$3(r,n.getChildren()),t.insertAfter(r),t=r,n.__key===e.anchor.key&&Hl(e.anchor,rc(Pl(r,"next"))),n.__key===e.focus.key&&Hl(e.focus,rc(Pl(r,"next"))),n.remove();}n.remove();}}}function le$2(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())pe$2(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),Se$1(r.getFirstChild())||n++);}function ce$2(e){const t=new Set;if(Z$4(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(Z$4(r)&&Z$4(i)){const n=i.getFirstChild();if(Se$1(n)){n.append(e);const i=r.getFirstChild();if(Se$1(i)){re$3(n,i.getChildren()),r.remove(),t.add(r.getKey());}}}else if(Z$4(r)){const t=r.getFirstChild();if(Se$1(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e);}}else if(Z$4(i)){const t=i.getFirstChild();Se$1(t)&&t.append(e);}else if(Se$1(n)){const t=Ks(e),s=Ks(n);t.append(s),s.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t);}}function ae$2(e){if(Z$4(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(Se$1(n?n.getParent():void 0)&&pe$2(n)&&Se$1(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(i))n.insertAfter(e),t.isEmpty()&&n.remove();else {const r=Ks(e),i=Ks(t);r.append(i),e.getPreviousSiblings().forEach(e=>i.append(e));const s=Ks(e),o=Ks(t);s.append(o),re$3(o,e.getNextSiblings()),n.insertBefore(r),n.insertAfter(s),n.replace(e);}}}function ue$2(e=false){const t=Qr();if(!Fr(t)||!t.isCollapsed())return false;const n=t.anchor.getNode();let r=null;if(pe$2(n)&&0===n.getChildrenSize())r=n;else if(Tr(n)){const e=n.getParent();pe$2(e)&&e.getChildren().every(e=>Tr(e)&&""===e.getTextContent().trim())&&(r=e);}if(null===r)return false;const i=Q$6(r),s=r.getParent();Se$1(s)||q$6(40);const o=s.getParent();let l;if(Is(o))l=eo(),i.insertAfter(l);else {if(!pe$2(o))return false;l=Ks(o),o.insertAfter(l);}l.setTextStyle(t.style).setTextFormat(t.format).select();const c=r.getNextSiblings();if(c.length>0){const t=e?function(e,t){return e.getStart()+t.getIndexWithinParent()}(s,r):1,n=Ks(s).setStart(t);if(pe$2(l)){const e=Ks(l);e.append(n),l.insertAfter(e);}else l.insertAfter(n);n.append(...c);}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!pe$2(e)&&!Se$1(e))break;t=e;}t.remove();}(r),true}let ge$2 = class ge extends Bi{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const t=e.getParent();if(Se$1(t))"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0);else if(t){const n=e.createParentElementNode();Se$1(n)||q$6(340);const i=[e];for(const t of ["previous","next"]){i.reverse();for(const{origin:n}of Ol(e,t)){if(!pe$2(n))break;i.push(n);}}e.insertBefore(n),n.splice(0,0,i),Is(t)||(Rt$3(n,Zl(Ol(n,"next")),{$shouldSplit:()=>false,removeEmptyDestination:true}),t.isEmpty()&&t.isAttached()&&t.remove());}},extends:Bi,importDOM:In({li:()=>({conversion:he$2,priority:0})})})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t;}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked;}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,n){!function(e,t,n){const r=t.getParent();!Se$1(r)||"check"!==r.getListType()||Se$1(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),n&&t.__checked===n.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"));}(t,this,e),t.value=this.__value,function(e,t,n){const r=[],o=[],l=t.list,c=l?l.listitem:void 0;let a;l&&l.nested&&(a=l.nested.listitem);void 0!==c&&r.push(...yc(c));if(l){const e=n.getParent(),t=Se$1(e)&&"check"===e.getListType(),i=n.getChecked();t&&!i||o.push(l.listitemUnchecked),t&&i||o.push(l.listitemChecked),t&&r.push(i?l.listitemChecked:l.listitemUnchecked);}if(void 0!==a){const e=yc(a);n.getChildren().some(e=>Se$1(e))?r.push(...e):o.push(...e);}o.length>0&&xc(e,...o);r.length>0&&mc(e,...r);}(t,n.theme,this);const r=e?e.__style:"",o=this.__style;r!==o&&nr(t.style,o,r),function(e,t,n){const r=t.__textStyle,i=n?n.__textStyle:"";if(null!==n&&i===r)return;const s=Zn(r);for(const t in s)e.style.setProperty(`--listitem-marker-${t}`,s[t]);if(""!==i)for(const t in Zn(i))t in s||e.style.removeProperty(`--listitem-marker-${t}`);}(t,this,e);}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),false}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),n=this.getFormatType();n&&(t.style.textAlign=n);const r=this.getDirection();return r&&(t.dir=r),Z$4(this)?{after(e){if(Ys(e)){const t=e.previousElementSibling;if(Ys(t)&&"LI"===t.nodeName){for(;e.firstChild;)t.append(e.firstChild);e.remove();}}return e},element:t}:{element:t}}exportJSON(){return {...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(Wi(n)&&this.canMergeWith(n)){const e=n.getChildren();this.append(...e),n.remove();}else super.append(n);}return this}replace(e,t){if(pe$2(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Se$1(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else {const t=Ks(n);let r=this.getNextSibling();for(;r;){const e=r;r=r.getNextSibling(),t.append(e);}n.insertAfter(e),e.insertAfter(t);}return t&&(Wi(e)||q$6(139),this.getChildren().forEach(t=>{e.append(t);})),this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=true){const n=this.getParentOrThrow();if(Se$1(n)||q$6(39),pe$2(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=Ks(n);r.forEach(e=>i.append(e)),e.insertAfter(i,t);}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Z$4(t)&&Z$4(n)&&(se$3(t.getFirstChild(),n.getFirstChild()),n.remove());}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(false);}insertNewAfter(e,t=true){const n=Ks(this);return this.insertAfter(n,t),n}collapseAtStart(e){const t=eo();this.getChildren().forEach(e=>t.append(e));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=pe$2(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else {n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,s=t.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(t),this.remove();return true}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Se$1(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;pe$2(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&q$6(117),(e=Math.floor(e))>=0||q$6(199);let t=this.getIndent();for(;t!==e;)t<e?(ce$2(this),t++):(ae$2(this),t--);return this}canInsertAfter(e){return pe$2(e)}canReplaceWith(e){return pe$2(e)}canMergeWith(e){return pe$2(e)||no(e)}extractWithChild(e,t){if(!Fr(t))return false;const n=t.anchor.getNode(),r=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return true}createParentElementNode(){return Te$1("bullet")}canMergeWhenEmpty(){return true}};function he$2(e){if(e.classList.contains("task-list-item"))for(const t of e.children)if("INPUT"===t.tagName)return de$2(t);if(e.classList.contains("joplin-checkbox"))for(const t of e.children)if(t.classList.contains("checkbox-wrapper")&&t.children.length>0&&"INPUT"===t.children[0].tagName)return de$2(t.children[0]);const t=e.getAttribute("aria-checked");return {node:fe$2("true"===t||"false"!==t&&void 0)}}function de$2(e){if(!("checkbox"===e.getAttribute("type")))return {node:null};return {node:fe$2(e.hasAttribute("checked"))}}function fe$2(e){return zs(new ge$2(void 0,e))}function pe$2(e){return e instanceof ge$2}let me$2 = class me extends Bi{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();Se$1(t)&&e.getListType()===t.getListType()&&se$3(e,t);}(e),le$2(e);},extends:Bi,importDOM:In({ol:()=>({conversion:ye$1,priority:0}),ul:()=>({conversion:ye$1,priority:0})})})}constructor(e="number",t=1,n){super(n);const r=ve$1[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t;}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start;}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,_e$1(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(_e$1(t,n.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),false)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return Ys(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return {...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return false}canIndent(){return false}splice(e,t,n){const r=n.find(pe$2)??this.getChildren().find(pe$2),i=r?()=>Ks(r):fe$2;let s=n;for(let e=0;e<n.length;e++){const t=n[e];pe$2(t)||(s===n&&(s=[...n]),s[e]=i().append(!Wi(t)||Se$1(t)||t.isInline()?t:kr(t.getTextContent())));}return super.splice(e,t,s)}extractWithChild(e){return pe$2(e)}};function _e$1(e,t,n){const r=[],o=[],l=t.list;if(void 0!==l){const e=l[`${n.__tag}Depth`]||[],t=G$8(n)-1,i=t%e.length,s=e[i],c=l[n.__tag];let a;const u=l.nested,g=l.checklist;if(void 0!==u&&u.list&&(a=u.list),void 0!==c&&r.push(c),void 0!==g&&"check"===n.__listType&&r.push(g),void 0!==s){r.push(...yc(s));for(let t=0;t<e.length;t++)t!==i&&o.push(n.__tag+t);}if(void 0!==a){const e=yc(a);t>1?r.push(...e):o.push(...e);}}o.length>0&&xc(e,...o),r.length>0&&mc(e,...r);}function Ce$1(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(pe$2(r)){t.push(r);const e=r.getChildren();e.length>1&&e.forEach(e=>{Se$1(e)&&t.push(ee$1(e));});}else t.push(ee$1(r));}return t}function ye$1(e){const t=e.nodeName.toLowerCase();let n=null;if("ol"===t){n=Te$1("number",e.start);}else "ul"===t&&(n=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return true;for(const t of e.childNodes)if(Ys(t)&&t.hasAttribute("aria-checked"))return true;return false}(e)?Te$1("check"):Te$1("bullet"));return {after:Ce$1,node:n}}const ve$1={ol:"number",ul:"bullet"};function Te$1(e="number",t=1){return zs(new me$2(e,t))}function Se$1(e){return e instanceof me$2}const Fe$1=re$5("UPDATE_LIST_START_COMMAND"),Ee$2=re$5("INSERT_UNORDERED_LIST_COMMAND"),Oe$1=re$5("INSERT_ORDERED_LIST_COMMAND"),Ae$2=re$5("REMOVE_LIST_COMMAND");function Ie$2(e,t){return Cc(e.registerCommand(Oe$1,()=>(ne$2("number"),true),io),e.registerCommand(Fe$1,e=>{const{listNodeKey:t,newStart:n}=e,r=Yo(t);return !!Se$1(r)&&("number"===r.getListType()&&(r.setStart(n),le$2(r)),true)},io),e.registerCommand(Ee$2,()=>(ne$2("bullet"),true),io),e.registerCommand(Ae$2,()=>(oe$3(),true),io),e.registerCommand(he$3,()=>ue$2(false),io),e.registerNodeTransform(ge$2,e=>{const t=e.getFirstChild();if(t){if(Tr(t)){const n=t.getStyle(),r=t.getFormat();e.getTextStyle()!==n&&e.setTextStyle(n),e.getTextFormat()!==r&&e.setTextFormat(r);}}else {const t=Qr();Fr(t)&&(t.style!==e.getTextStyle()||t.format!==e.getTextFormat())&&t.isCollapsed()&&e.is(t.anchor.getNode())&&e.setTextStyle(t.style).setTextFormat(t.format);}}),e.registerNodeTransform(gr,e=>{const t=e.getParent();if(pe$2(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r);}}))}
|
|
8676
9813
|
|
|
8677
9814
|
/**
|
|
8678
9815
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -8682,7 +9819,7 @@ function q$6(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URL
|
|
|
8682
9819
|
*
|
|
8683
9820
|
*/
|
|
8684
9821
|
|
|
8685
|
-
const M$3=new Set(["http:","https:","mailto:","sms:","tel:"]);let F$4 = class F extends Bi{__url;__target;__rel;__title;static getType(){return "link"}static clone(t){return new F(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:s=null}=e;this.__url=t,this.__target=r,this.__rel=i,this.__title=s;}afterCloneFrom(t){super.afterCloneFrom(t),this.__url=t.__url,this.__rel=t.__rel,this.__target=t.__target,this.__title=t.__title;}createDOM(e){const n=document.createElement("a");return this.updateLinkDOM(null,n,e),mc(n,e.theme.link),n}updateLinkDOM(t,n,r){if(Vs(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:K$3,priority:1})}}static importJSON(t){return $$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=X$4(t);try{const e=new URL(X$4(t));if(!M$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=Ks(this);return this.insertAfter(n,e),n}canInsertTextBefore(){return false}canInsertTextAfter(){return false}canBeEmpty(){return false}isInline(){return true}extractWithChild(t,e,n){if(!Fr(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://")}shouldMergeAdjacentLink(t){return this.getType()===t.getType()&&this.__url===t.__url&&this.__target===t.__target&&this.__rel===t.__rel&&this.__title===t.__title}};function K$3(t){let n=null;if(Vs(t)){const e=t.textContent;(null!==e&&""!==e||t.children.length>0)&&(n=$$2(t.getAttribute("href")||"",{rel:t.getAttribute("rel"),target:t.getAttribute("target"),title:t.getAttribute("title")}));}return {node:n}}function $$2(t="",e){return zs(new F$4(t,e))}function z$5(t){return t instanceof F$4}let j$5 = class j extends F$4{__isUnlinked;constructor(t="",e={},n){super(t,e,n),this.__isUnlinked=void 0!==e.isUnlinked&&null!==e.isUnlinked&&e.isUnlinked;}afterCloneFrom(t){super.afterCloneFrom(t),this.__isUnlinked=t.__isUnlinked;}static getType(){return "autolink"}static clone(t){return new j(t.__url,{isUnlinked:t.__isUnlinked,rel:t.__rel,target:t.__target,title:t.__title},t.__key)}shouldMergeAdjacentLink(t){return false}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 H$5().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=H$5(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,e),n}};function H$5(t="",e){return zs(new j$5(t,e))}function G$7(t){return t instanceof j$5}function q$5(t,e){if("element"===t.type){const n=t.getNode();Wi(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 Q$5(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:s}=e,l=void 0===e.rel?"noreferrer":e.rel,a=Qr();if(null===a||!Fr(a)&&!Ir(a))return;if(Ir(a)){const t=a.getNodes();if(0===t.length)return;return void t.forEach(t=>{if(null===r){const e=dl(t,t=>!G$7(t)&&z$5(t));e&&(e.insertBefore(t),0===e.getChildren().length&&e.remove());}else {const e=dl(t,t=>!G$7(t)&&z$5(t));if(e)e.setURL(r),void 0!==i&&e.setTarget(i),void 0!==l&&e.setRel(l);else {const e=$$2(r,{rel:l,target:i});t.insertBefore(e),e.append(t);}}})}if(a.isCollapsed()&&null===r)for(const t of a.getNodes()){const e=dl(t,t=>!G$7(t)&&z$5(t));return void(null!==e&&(e.getChildren().forEach(t=>{e.insertBefore(t);}),e.remove()))}const c=a.extract();if(null===r){const t=new Set;return void c.forEach(e=>{const r=dl(e,t=>!G$7(t)&&z$5(t));if(null!==r){const e=r.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=>n.has(r.getKey())||Wi(r)&&e.some(e=>t.isParentOf(e)&&r.isParentOf(e)),s=r.filter(i);if(s.length===r.length)return r.forEach(e=>t.insertBefore(e)),void t.remove();const l=r.findIndex(i),u=r.findLastIndex(i),a=0===l,c=u===r.length-1;if(a)s.forEach(e=>t.insertBefore(e));else if(c)for(let e=s.length-1;e>=0;e--)t.insertAfter(s[e]);else {for(let e=s.length-1;e>=0;e--)t.insertAfter(s[e]);const e=r.slice(u+1);if(e.length>0){const n=Ks(t);s[s.length-1].insertAfter(n),e.forEach(t=>n.append(t));}}}(r,c),t.add(e);}})}const _=new Set,m=t=>{_.has(t.getKey())||(_.add(t.getKey()),t.setURL(r),void 0!==i&&t.setTarget(i),void 0!==l&&t.setRel(l),void 0!==s&&t.setTitle(s));};if(1===c.length){const t=c[0],e=dl(t,z$5);if(null!==e)return m(e)}!function(t){const e=Qr();if(!Fr(e))return t();const n=St$3(e),r=n.isBackward(),i=q$5(n.anchor,r?-1:0),s=q$5(n.focus,r?0:-1);t();if(i||s){const t=Qr();if(Fr(t)){const e=t.clone();if(i){const t=i.getParent();t&&e.anchor.set(t.getKey(),i.getIndexWithinParent()+(r?1:0),"element");}if(s){const t=s.getParent();t&&e.focus.set(t.getKey(),s.getIndexWithinParent()+(r?0:1),"element");}es(St$3(e));}}}(()=>{let t=null;for(const e of c){if(!e.isAttached())continue;const o=dl(e,z$5);if(o){m(o);continue}if(Wi(e)){if(!e.isInline())continue;if(z$5(e)){if(!(G$7(e)||null!==t&&t.getParentOrThrow().isParentOf(e))){m(e),t=e;continue}for(const t of e.getChildren())e.insertBefore(t);e.remove();continue}}const u=e.getPreviousSibling();z$5(u)&&u.is(t)?u.append(e):(t=$$2(r,{rel:l,target:i,title:s}),e.insertAfter(t),t.append(e));}});}const V$6=/^\+?[0-9\s()-]{5,}$/;function X$4(t){return t.match(/^[a-z][a-z0-9+.-]*:/i)||t.match(/^[/#.]/)?t:t.includes("@")?`mailto:${t}`:V$6.test(t)?`tel:${t}`:`https://${t}`}
|
|
9822
|
+
const M$3=new Set(["http:","https:","mailto:","sms:","tel:"]);let F$4 = class F extends Bi{__url;__target;__rel;__title;static getType(){return "link"}static clone(t){return new F(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:s=null}=e;this.__url=t,this.__target=r,this.__rel=i,this.__title=s;}afterCloneFrom(t){super.afterCloneFrom(t),this.__url=t.__url,this.__rel=t.__rel,this.__target=t.__target,this.__title=t.__title;}createDOM(e){const n=document.createElement("a");return this.updateLinkDOM(null,n,e),mc(n,e.theme.link),n}updateLinkDOM(t,n,r){if(Vs(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:K$3,priority:1})}}static importJSON(t){return $$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=X$4(t);try{const e=new URL(X$4(t));if(!M$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=Ks(this);return this.insertAfter(n,e),n}canInsertTextBefore(){return false}canInsertTextAfter(){return false}canBeEmpty(){return false}isInline(){return true}extractWithChild(t,e,n){if(!Fr(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://")}shouldMergeAdjacentLink(t){return this.getType()===t.getType()&&this.__url===t.__url&&this.__target===t.__target&&this.__rel===t.__rel&&this.__title===t.__title}};function J$6(t){const e=ql(t,"next");return [e,e.getFlipped()]}function W$5(t,e){for(const n of e)if(n.origin.isAttached()){const e=rc(n);return void Hl(t,e)}}function B$5(t){const e=Qr();let n=null,i=null;function s(){Fr(e)&&(W$5(e.anchor,n),W$5(e.focus,i),St$3(e));}Fr(e)&&(n=J$6(e.anchor),i=J$6(e.focus));let l=false;for(const e of Pl(t,"next")){const n=e.origin;if(Wi(n)&&!n.isInline()){const i=n.getChildren();if(i.length>0){const e=Ks(t);e.append(...i),n.append(e),l=true;}Rt$3(n,Zl(e),{$shouldSplit:()=>false});}}function a(t,e,n){const[r,i]=t,s=t=>Tl(t)&&t.origin.is(e);if(!s(r)&&!s(i))return t;const l=rc(Pl(n,"next"));return [l,l.getFlipped()]}if(t.isAttached()){const e=t.getPreviousSibling();if(z$5(e)&&e.shouldMergeAdjacentLink(t))return n&&(n=a(n,e,t)),i&&(i=a(i,e,t)),e.append(...t.getChildren()),t.remove(),void s();const r=t.getNextSibling();z$5(r)&&t.shouldMergeAdjacentLink(r)&&(n&&(n=a(n,t,r)),i&&(i=a(i,t,r)),t.append(...r.getChildren()),r.remove(),l=true);}if(l){if(!t.canBeEmpty()&&t.isEmpty()){const e=t.getParent();t.remove(),e&&e.isEmpty()&&e.remove();}s();}}function K$3(t){let n=null;if(Vs(t)){const e=t.textContent;(null!==e&&""!==e||t.children.length>0)&&(n=$$2(t.getAttribute("href")||"",{rel:t.getAttribute("rel"),target:t.getAttribute("target"),title:t.getAttribute("title")}));}return {node:n}}function $$2(t="",e){return zs(new F$4(t,e))}function z$5(t){return t instanceof F$4}let j$5 = class j extends F$4{__isUnlinked;constructor(t="",e={},n){super(t,e,n),this.__isUnlinked=void 0!==e.isUnlinked&&null!==e.isUnlinked&&e.isUnlinked;}afterCloneFrom(t){super.afterCloneFrom(t),this.__isUnlinked=t.__isUnlinked;}static getType(){return "autolink"}static clone(t){return new j(t.__url,{isUnlinked:t.__isUnlinked,rel:t.__rel,target:t.__target,title:t.__title},t.__key)}shouldMergeAdjacentLink(t){return false}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 H$5().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=H$5(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,e),n}};function H$5(t="",e){return zs(new j$5(t,e))}function G$7(t){return t instanceof j$5}const Z$3=re$5("TOGGLE_LINK_COMMAND");function q$5(t,e){if("element"===t.type){const n=t.getNode();Wi(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 Q$5(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:s}=e,l=void 0===e.rel?"noreferrer":e.rel,a=Qr();if(null===a||!Fr(a)&&!Ir(a))return;if(Ir(a)){const t=a.getNodes();if(0===t.length)return;return void t.forEach(t=>{if(null===r){const e=dl(t,t=>!G$7(t)&&z$5(t));e&&(e.insertBefore(t),0===e.getChildren().length&&e.remove());}else {const e=dl(t,t=>!G$7(t)&&z$5(t));if(e)e.setURL(r),void 0!==i&&e.setTarget(i),void 0!==l&&e.setRel(l);else {const e=$$2(r,{rel:l,target:i});t.insertBefore(e),e.append(t);}}})}if(a.isCollapsed()&&null===r)for(const t of a.getNodes()){const e=dl(t,t=>!G$7(t)&&z$5(t));return void(null!==e&&(e.getChildren().forEach(t=>{e.insertBefore(t);}),e.remove()))}const c=a.extract();if(null===r){const t=new Set;return void c.forEach(e=>{const r=dl(e,t=>!G$7(t)&&z$5(t));if(null!==r){const e=r.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=>n.has(r.getKey())||Wi(r)&&e.some(e=>t.isParentOf(e)&&r.isParentOf(e)),s=r.filter(i);if(s.length===r.length)return r.forEach(e=>t.insertBefore(e)),void t.remove();const l=r.findIndex(i),u=r.findLastIndex(i),a=0===l,c=u===r.length-1;if(a)s.forEach(e=>t.insertBefore(e));else if(c)for(let e=s.length-1;e>=0;e--)t.insertAfter(s[e]);else {for(let e=s.length-1;e>=0;e--)t.insertAfter(s[e]);const e=r.slice(u+1);if(e.length>0){const n=Ks(t);s[s.length-1].insertAfter(n),e.forEach(t=>n.append(t));}}}(r,c),t.add(e);}})}const _=new Set,m=t=>{_.has(t.getKey())||(_.add(t.getKey()),t.setURL(r),void 0!==i&&t.setTarget(i),void 0!==l&&t.setRel(l),void 0!==s&&t.setTitle(s));};if(1===c.length){const t=c[0],e=dl(t,z$5);if(null!==e)return m(e)}!function(t){const e=Qr();if(!Fr(e))return t();const n=St$3(e),r=n.isBackward(),i=q$5(n.anchor,r?-1:0),s=q$5(n.focus,r?0:-1);t();if(i||s){const t=Qr();if(Fr(t)){const e=t.clone();if(i){const t=i.getParent();t&&e.anchor.set(t.getKey(),i.getIndexWithinParent()+(r?1:0),"element");}if(s){const t=s.getParent();t&&e.focus.set(t.getKey(),s.getIndexWithinParent()+(r?0:1),"element");}es(St$3(e));}}}(()=>{let t=null;for(const e of c){if(!e.isAttached())continue;const o=dl(e,z$5);if(o){m(o);continue}if(Wi(e)){if(!e.isInline())continue;if(z$5(e)){if(!(G$7(e)||null!==t&&t.getParentOrThrow().isParentOf(e))){m(e),t=e;continue}for(const t of e.getChildren())e.insertBefore(t);e.remove();continue}}const u=e.getPreviousSibling();z$5(u)&&u.is(t)?u.append(e):(t=$$2(r,{rel:l,target:i,title:s}),e.insertAfter(t),t.append(e));}});}const V$6=/^\+?[0-9\s()-]{5,}$/;function X$4(t){return t.match(/^[a-z][a-z0-9+.-]*:/i)||t.match(/^[/#.]/)?t:t.includes("@")?`mailto:${t}`:V$6.test(t)?`tel:${t}`:`https://${t}`}function Y$2(t,e){return Cc(t.registerNodeTransform(F$4,B$5),t.registerCommand(Z$3,t=>{const n=e.validateUrl.peek(),r=e.attributes.peek();if(null===t)return Q$5(null),true;if("string"==typeof t)return !(void 0!==n&&!n(t))&&(Q$5(t,r),true);{const{url:e,target:n,rel:i,title:s}=t;return Q$5(e,{...r,rel:i,target:n,title:s}),true}},ro),St$2(()=>{const n=e.validateUrl.value;if(!n)return;const r=e.attributes.value;return t.registerCommand(_e$2,e=>{const i=Qr();if(!Fr(i)||i.isCollapsed()||!Bt$3(e,ClipboardEvent))return false;if(null===e.clipboardData)return false;const l=e.clipboardData.getData("text");return !!n(l)&&(!i.getNodes().some(t=>Wi(t))&&(t.dispatchCommand(Z$3,{...r,url:l}),e.preventDefault(),true))},io)}))}const tt$3=dc({build:(t,e,n)=>bt$2(e),config:{attributes:void 0,validateUrl:void 0},mergeConfig(t,e){const n=pc(t,e);return t.attributes&&(n.attributes=pc(t.attributes,n.attributes)),n},name:"@lexical/link/Link",nodes:()=>[F$4],register:(t,e,n)=>Y$2(t,n.getOutput())});
|
|
8686
9823
|
|
|
8687
9824
|
/**
|
|
8688
9825
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -9220,7 +10357,7 @@ function parseBoolean(value) {
|
|
|
9220
10357
|
*
|
|
9221
10358
|
*/
|
|
9222
10359
|
|
|
9223
|
-
function C$2(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(!(Fr(i)&&Fr(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||Vi(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)&&Tr(r)&&1===r.__text.length&&1===i.anchor.offset?2:0}const d=s[0],l=t._nodeMap.get(d.__key);if(!Tr(l)||!Tr(d)||l.__mode!==d.__mode)return 0;const u=l.__text,c=d.__text;if(u===c)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,g=c.length-u.length;return 1===g&&m===h-1?2:-1===g&&m===h+1?3:-1===g&&m===h?4:0}function b$1(t,e,n){let r=n(),o=0,i=r,a=0,s=null;return (d,l,u,c,f,p)=>{const h=n();if(p.has(Gn)&&(i=r,a=o,s=d),p.has(Wn$1))return o=0,r=h,2;p.has(Xn)&&s&&(r=i,o=a,d=s);const x=C$2(d,l,c,f,t.isComposing()),b=(()=>{const n=null===u||u.editor===t,i=p.has($n$1);if(!i&&n&&p.has(Jn))return 0;if(1===x)return 2;if(null===d)return 1;const a=l._selection;if(!(c.size>0||f.size>0))return null!==a?0:2;const s="number"==typeof e?e:e.peek();if(false===i&&0!==x&&x===o&&h<r+s&&n)return 0;if(1===c.size){if(function(t,e,n){const r=e._nodeMap.get(t),o=n._nodeMap.get(t),i=e._selection,a=n._selection;return !(Fr(i)&&Fr(a)&&"element"===i.anchor.type&&"element"===i.focus.type&&"text"===a.anchor.type&&"text"===a.focus.type||!Tr(r)||!Tr(o)||r.__parent!==o.__parent)&&JSON.stringify(e.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>o.exportJSON()))}(Array.from(c)[0],d,l))return 0}return 1})();return r=h,o=x,b}}function w$2(t){t.undoStack=[],t.redoStack=[],t.current=null;}function E$1(t,e,n,r=Date.now){const i=b$1(t,n,r);return Cc(t.registerCommand(Ce$2,()=>(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(qe$2,true)),0===r.length&&t.dispatchCommand(He$2,false),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:Wn$1});}}(t,e),true),ro),t.registerCommand(Se$2,()=>(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(He$2,true));const i=n.pop();0===n.length&&t.dispatchCommand(qe$2,false),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:Wn$1});}}(t,e),true),ro),t.registerCommand(Ve$2,()=>(w$2(e),false),ro),t.registerCommand(Ye$1,()=>(w$2(e),t.dispatchCommand(qe$2,false),t.dispatchCommand(He$2,false),true),ro),t.registerUpdateListener(({editorState:n,prevEditorState:r,dirtyLeaves:o,dirtyElements:a,tags:s})=>{const d=e.current,l=e.redoStack,u=e.undoStack,c=null===d?null:d.editorState;if(null!==d&&n===c)return;const f=i(r,n,d,o,a,s);if(1===f)0!==l.length&&(e.redoStack=[],t.dispatchCommand(qe$2,false)),null!==d&&(u.push({...d}),t.dispatchCommand(He$2,true));else if(2===f)return;e.current={editor:t,editorState:n};}))}function M$2(){return {current:null,redoStack:[],undoStack:[]}}const O$1=dc({build:(t,{delay:n,createInitialHistoryState:r,disabled:o,now:i})=>bt$2({delay:n,disabled:o,historyState:r(t),now:i}),config:_c({createInitialHistoryState:M$2,delay:300,disabled:"undefined"==typeof window,now:Date.now}),name:"@lexical/history/History",register:(e,n,r)=>{const o=r.getOutput();return St$2(()=>o.disabled.value?void 0:E$1(e,o.historyState.value,o.delay,()=>o.now.peek()()))}});dc({build:(t,{disabled:n,parentEditor:r})=>bt$2({disabled:n,parentEditor:r||t._parentEditor}),config:_c({disabled:false,parentEditor:null}),dependencies:[hc(O$1,{disabled:true})],name:"@lexical/history/SharedHistory",register:(e,o,i)=>St$2(()=>{const{disabled:t,parentEditor:e}=i.getOutput();if(!t.value){const{output:t}=i.getDependency(O$1),o=function(t){return t?fe$3(t,O$1.name):null}(e.value);if(!o)return;const a=o.output;Y$
|
|
10360
|
+
function C$2(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(!(Fr(i)&&Fr(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||Vi(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)&&Tr(r)&&1===r.__text.length&&1===i.anchor.offset?2:0}const d=s[0],l=t._nodeMap.get(d.__key);if(!Tr(l)||!Tr(d)||l.__mode!==d.__mode)return 0;const u=l.__text,c=d.__text;if(u===c)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,g=c.length-u.length;return 1===g&&m===h-1?2:-1===g&&m===h+1?3:-1===g&&m===h?4:0}function b$1(t,e,n){let r=n(),o=0,i=r,a=0,s=null;return (d,l,u,c,f,p)=>{const h=n();if(p.has(Gn)&&(i=r,a=o,s=d),p.has(Wn$1))return o=0,r=h,2;p.has(Xn)&&s&&(r=i,o=a,d=s);const x=C$2(d,l,c,f,t.isComposing()),b=(()=>{const n=null===u||u.editor===t,i=p.has($n$1);if(!i&&n&&p.has(Jn))return 0;if(1===x)return 2;if(null===d)return 1;const a=l._selection;if(!(c.size>0||f.size>0))return null!==a?0:2;const s="number"==typeof e?e:e.peek();if(false===i&&0!==x&&x===o&&h<r+s&&n)return 0;if(1===c.size){if(function(t,e,n){const r=e._nodeMap.get(t),o=n._nodeMap.get(t),i=e._selection,a=n._selection;return !(Fr(i)&&Fr(a)&&"element"===i.anchor.type&&"element"===i.focus.type&&"text"===a.anchor.type&&"text"===a.focus.type||!Tr(r)||!Tr(o)||r.__parent!==o.__parent)&&JSON.stringify(e.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>o.exportJSON()))}(Array.from(c)[0],d,l))return 0}return 1})();return r=h,o=x,b}}function w$2(t){t.undoStack=[],t.redoStack=[],t.current=null;}function E$1(t,e,n,r=Date.now){const i=b$1(t,n,r);return Cc(t.registerCommand(Ce$2,()=>(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(qe$2,true)),0===r.length&&t.dispatchCommand(He$2,false),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:Wn$1});}}(t,e),true),ro),t.registerCommand(Se$2,()=>(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(He$2,true));const i=n.pop();0===n.length&&t.dispatchCommand(qe$2,false),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:Wn$1});}}(t,e),true),ro),t.registerCommand(Ve$2,()=>(w$2(e),false),ro),t.registerCommand(Ye$1,()=>(w$2(e),t.dispatchCommand(qe$2,false),t.dispatchCommand(He$2,false),true),ro),t.registerUpdateListener(({editorState:n,prevEditorState:r,dirtyLeaves:o,dirtyElements:a,tags:s})=>{const d=e.current,l=e.redoStack,u=e.undoStack,c=null===d?null:d.editorState;if(null!==d&&n===c)return;const f=i(r,n,d,o,a,s);if(1===f)0!==l.length&&(e.redoStack=[],t.dispatchCommand(qe$2,false)),null!==d&&(u.push({...d}),t.dispatchCommand(He$2,true));else if(2===f)return;e.current={editor:t,editorState:n};}))}function M$2(){return {current:null,redoStack:[],undoStack:[]}}const O$1=dc({build:(t,{delay:n,createInitialHistoryState:r,disabled:o,now:i})=>bt$2({delay:n,disabled:o,historyState:r(t),now:i}),config:_c({createInitialHistoryState:M$2,delay:300,disabled:"undefined"==typeof window,now:Date.now}),name:"@lexical/history/History",register:(e,n,r)=>{const o=r.getOutput();return St$2(()=>o.disabled.value?void 0:E$1(e,o.historyState.value,o.delay,()=>o.now.peek()()))}});dc({build:(t,{disabled:n,parentEditor:r})=>bt$2({disabled:n,parentEditor:r||t._parentEditor}),config:_c({disabled:false,parentEditor:null}),dependencies:[hc(O$1,{disabled:true})],name:"@lexical/history/SharedHistory",register:(e,o,i)=>St$2(()=>{const{disabled:t,parentEditor:e}=i.getOutput();if(!t.value){const{output:t}=i.getDependency(O$1),o=function(t){return t?fe$3(t,O$1.name):null}(e.value);if(!o)return;const a=o.output;Y$4(()=>{t.delay.value=a.delay.value,t.historyState.value=a.historyState.value,t.now.value=a.now.value,t.disabled.value=a.disabled.value;});}})});
|
|
9224
10361
|
|
|
9225
10362
|
class LexxyExtension {
|
|
9226
10363
|
#editorElement
|
|
@@ -9543,7 +10680,12 @@ function $expandSelectionToLineBreaksAndSplitAtEdges(selection, fallbackAncestor
|
|
|
9543
10680
|
const anchorOuter = anchorBrCaret && $splitAroundLineBreak(anchorBrCaret);
|
|
9544
10681
|
|
|
9545
10682
|
const innerStart = anchorOuter?.getNextSibling() ?? fallbackAncestor(selection.anchor.getNode());
|
|
9546
|
-
|
|
10683
|
+
let innerEnd = focusOuter?.getPreviousSibling() ?? fallbackAncestor(selection.focus.getNode());
|
|
10684
|
+
|
|
10685
|
+
// Splitting at the anchor's <br> moves everything after it into a new
|
|
10686
|
+
// paragraph, but a focus point on the paragraph element itself (a cursor
|
|
10687
|
+
// after a trailing <br>) still names the original one, now the line above.
|
|
10688
|
+
if (anchorOuter && innerEnd?.is(anchorOuter)) innerEnd = innerStart;
|
|
9547
10689
|
if (!innerStart || !innerEnd) return
|
|
9548
10690
|
|
|
9549
10691
|
Gl(Wl(
|
|
@@ -10812,25 +11954,117 @@ function $tryCreateUploadFromDataURI(node, editorElement) {
|
|
|
10812
11954
|
if (file && editorElement.acceptsFile(file)) {
|
|
10813
11955
|
return editorElement.contents.$createUploadNode(file)
|
|
10814
11956
|
}
|
|
10815
|
-
return null
|
|
11957
|
+
return null
|
|
11958
|
+
}
|
|
11959
|
+
|
|
11960
|
+
function dataURIToFile(dataURI) {
|
|
11961
|
+
try {
|
|
11962
|
+
const [ header, data ] = dataURI.split(",");
|
|
11963
|
+
|
|
11964
|
+
// https://datatracker.ietf.org/doc/html/rfc6838#section-4.2
|
|
11965
|
+
const mimeType = header.match(/^data:(image\/[A-Za-z0-9][A-Za-z0-9!#$&\-^_.+]*)/)?.[1];
|
|
11966
|
+
if (mimeType) {
|
|
11967
|
+
const bytes = Uint8Array.from(atob(data), (c) => c.charCodeAt(0));
|
|
11968
|
+
const extension = mimeTypeToExtension(mimeType) ?? "png";
|
|
11969
|
+
return new File([ bytes ], `pasted-image-${Date.now()}.${extension}`, { type: mimeType })
|
|
11970
|
+
} else {
|
|
11971
|
+
return null
|
|
11972
|
+
}
|
|
11973
|
+
} catch {
|
|
11974
|
+
return null
|
|
11975
|
+
}
|
|
11976
|
+
}
|
|
11977
|
+
|
|
11978
|
+
const NON_BREAKING_SPACE = "\u00a0";
|
|
11979
|
+
|
|
11980
|
+
// HTML collapses runs of spaces and a space that starts a line, and so does
|
|
11981
|
+
// Lexical's HTML importer, so a document that kept them as plain spaces lost
|
|
11982
|
+
// them on every re-save. Like Trix, the export writes such spaces as
|
|
11983
|
+
// non-breaking spaces, alternating with plain ones so lines can still wrap.
|
|
11984
|
+
// The import turns that encoding back into plain spaces, so they edit like the
|
|
11985
|
+
// spaces the person typed: runs mixing both kinds of space, and a non-breaking
|
|
11986
|
+
// space that starts a line or follows a space. Runs made only of non-breaking
|
|
11987
|
+
// spaces, and a lone one between words, are left alone. A pasted fragment's
|
|
11988
|
+
// top-level nodes have no line around them yet, so their leading space is too.
|
|
11989
|
+
|
|
11990
|
+
function $encodeCollapsibleSpaces(text, textNode) {
|
|
11991
|
+
if ($isInCodeBlock(textNode)) return text
|
|
11992
|
+
|
|
11993
|
+
let encoded = text.replace(/ {2,}/g, (run) => alternatingSpaces(run.length));
|
|
11994
|
+
|
|
11995
|
+
if ($collapsesLeadingSpace(textNode)) {
|
|
11996
|
+
encoded = encoded.replace(/^ /, NON_BREAKING_SPACE);
|
|
11997
|
+
}
|
|
11998
|
+
|
|
11999
|
+
return encoded
|
|
12000
|
+
}
|
|
12001
|
+
|
|
12002
|
+
function $decodeCollapsibleSpaces(nodes) {
|
|
12003
|
+
for (const node of nodes) {
|
|
12004
|
+
if (Tr(node) && !$isInCodeBlock(node)) {
|
|
12005
|
+
$decodeTextNode(node);
|
|
12006
|
+
} else if (Wi(node) && !W$1(node)) {
|
|
12007
|
+
$decodeCollapsibleSpaces(node.getChildren());
|
|
12008
|
+
}
|
|
12009
|
+
}
|
|
12010
|
+
}
|
|
12011
|
+
|
|
12012
|
+
function $decodeTextNode(textNode) {
|
|
12013
|
+
const text = textNode.getTextContent();
|
|
12014
|
+
let decoded = text.replace(/[ \u00a0]{2,}/g, (run) => decodeRun(run));
|
|
12015
|
+
|
|
12016
|
+
if ($isAttachedToLine(textNode) && $collapsesLeadingSpace(textNode)) {
|
|
12017
|
+
decoded = decoded.replace(/^\u00a0/, " ");
|
|
12018
|
+
}
|
|
12019
|
+
|
|
12020
|
+
if (decoded !== text) {
|
|
12021
|
+
textNode.setTextContent(decoded);
|
|
12022
|
+
}
|
|
12023
|
+
}
|
|
12024
|
+
|
|
12025
|
+
function decodeRun(run) {
|
|
12026
|
+
if (run.includes(" ")) {
|
|
12027
|
+
return " ".repeat(run.length)
|
|
12028
|
+
} else {
|
|
12029
|
+
return run
|
|
12030
|
+
}
|
|
12031
|
+
}
|
|
12032
|
+
|
|
12033
|
+
function alternatingSpaces(length) {
|
|
12034
|
+
return `${NON_BREAKING_SPACE} `.repeat(Math.ceil(length / 2)).slice(0, length)
|
|
12035
|
+
}
|
|
12036
|
+
|
|
12037
|
+
function $isInCodeBlock(textNode) {
|
|
12038
|
+
return W$1(textNode.getParent())
|
|
12039
|
+
}
|
|
12040
|
+
|
|
12041
|
+
function $collapsesLeadingSpace(node) {
|
|
12042
|
+
const previous = $previousInLine(node);
|
|
12043
|
+
return previous === null || sr(previous) || /[ \t\n]$/.test(previous.getTextContent())
|
|
12044
|
+
}
|
|
12045
|
+
|
|
12046
|
+
function $previousInLine(node) {
|
|
12047
|
+
let current = node;
|
|
12048
|
+
|
|
12049
|
+
while (current.getPreviousSibling() === null && $isInlineElement(current.getParent())) {
|
|
12050
|
+
current = current.getParent();
|
|
12051
|
+
}
|
|
12052
|
+
|
|
12053
|
+
return current.getPreviousSibling()
|
|
10816
12054
|
}
|
|
10817
12055
|
|
|
10818
|
-
function
|
|
10819
|
-
|
|
10820
|
-
const [ header, data ] = dataURI.split(",");
|
|
12056
|
+
function $isAttachedToLine(node) {
|
|
12057
|
+
let current = node;
|
|
10821
12058
|
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
if (mimeType) {
|
|
10825
|
-
const bytes = Uint8Array.from(atob(data), (c) => c.charCodeAt(0));
|
|
10826
|
-
const extension = mimeTypeToExtension(mimeType) ?? "png";
|
|
10827
|
-
return new File([ bytes ], `pasted-image-${Date.now()}.${extension}`, { type: mimeType })
|
|
10828
|
-
} else {
|
|
10829
|
-
return null
|
|
10830
|
-
}
|
|
10831
|
-
} catch {
|
|
10832
|
-
return null
|
|
12059
|
+
while ($isInlineElement(current.getParent())) {
|
|
12060
|
+
current = current.getParent();
|
|
10833
12061
|
}
|
|
12062
|
+
|
|
12063
|
+
return current.getParent() !== null
|
|
12064
|
+
}
|
|
12065
|
+
|
|
12066
|
+
function $isInlineElement(node) {
|
|
12067
|
+
return Wi(node) && node.isInline()
|
|
10834
12068
|
}
|
|
10835
12069
|
|
|
10836
12070
|
/**
|
|
@@ -11205,9 +12439,15 @@ class ImageGalleryNode extends Bi {
|
|
|
11205
12439
|
|
|
11206
12440
|
static #isGalleryElement(element) {
|
|
11207
12441
|
const attachmentChildren = element.querySelectorAll(`:scope > :is(${this.#attachmentTags.join()})`);
|
|
11208
|
-
return
|
|
11209
|
-
&& attachmentChildren.length > 0
|
|
12442
|
+
return attachmentChildren.length > 0
|
|
11210
12443
|
&& element.children.length === attachmentChildren.length
|
|
12444
|
+
&& !this.#hasLooseText(element)
|
|
12445
|
+
}
|
|
12446
|
+
|
|
12447
|
+
// Text inside an attachment is its rendered caption, which the attachment conversion
|
|
12448
|
+
// discards. Only text sitting directly in the div means it isn't a gallery.
|
|
12449
|
+
static #hasLooseText(element) {
|
|
12450
|
+
return Array.from(element.childNodes).some(node => node.nodeType === Node.TEXT_NODE && node.textContent.trim() !== "")
|
|
11211
12451
|
}
|
|
11212
12452
|
|
|
11213
12453
|
static get #attachmentTags() {
|
|
@@ -11541,6 +12781,37 @@ function segmentTextByRanges(text, textStart, ranges) {
|
|
|
11541
12781
|
return segments
|
|
11542
12782
|
}
|
|
11543
12783
|
|
|
12784
|
+
const TRIX_LANGUAGE_ATTR = "language";
|
|
12785
|
+
|
|
12786
|
+
// Lexical reads a code block's language from data-language alone. Trix writes it
|
|
12787
|
+
// as `language` on <pre>, and markdown renderers as `lang` on <pre> or as a
|
|
12788
|
+
// `language-*` class on its <code>.
|
|
12789
|
+
function importedCodeLanguage(preElement) {
|
|
12790
|
+
if (preElement.hasAttribute("data-language")) {
|
|
12791
|
+
return preElement.getAttribute("data-language")
|
|
12792
|
+
} else if (preElement.hasAttribute(TRIX_LANGUAGE_ATTR)) {
|
|
12793
|
+
return V$1(preElement.getAttribute(TRIX_LANGUAGE_ATTR))
|
|
12794
|
+
} else {
|
|
12795
|
+
return markdownCodeLanguage(preElement)
|
|
12796
|
+
}
|
|
12797
|
+
}
|
|
12798
|
+
|
|
12799
|
+
function markdownCodeLanguage(preElement) {
|
|
12800
|
+
const language = V$1(preElement.getAttribute("lang") || codeLanguageClass(preElement) || "");
|
|
12801
|
+
|
|
12802
|
+
if (te$1(language)) {
|
|
12803
|
+
return language
|
|
12804
|
+
} else {
|
|
12805
|
+
return null
|
|
12806
|
+
}
|
|
12807
|
+
}
|
|
12808
|
+
|
|
12809
|
+
function codeLanguageClass(preElement) {
|
|
12810
|
+
const code = preElement.querySelector(":scope > code");
|
|
12811
|
+
const languageClass = Array.from(code?.classList ?? []).find(name => name.startsWith("language-"));
|
|
12812
|
+
return languageClass?.replace("language-", "")
|
|
12813
|
+
}
|
|
12814
|
+
|
|
11544
12815
|
const TOGGLE_HIGHLIGHT_COMMAND = re$5();
|
|
11545
12816
|
const REMOVE_HIGHLIGHT_COMMAND = re$5();
|
|
11546
12817
|
const BLANK_STYLES = { "color": null, "background-color": null };
|
|
@@ -11570,7 +12841,8 @@ class HighlightExtension extends LexxyExtension {
|
|
|
11570
12841
|
},
|
|
11571
12842
|
html: {
|
|
11572
12843
|
import: {
|
|
11573
|
-
mark: $markConversion
|
|
12844
|
+
mark: $markConversion,
|
|
12845
|
+
code: $inlineCodeConversion
|
|
11574
12846
|
}
|
|
11575
12847
|
},
|
|
11576
12848
|
register(editor, config) {
|
|
@@ -11580,7 +12852,7 @@ class HighlightExtension extends LexxyExtension {
|
|
|
11580
12852
|
// Register the <pre> converter directly in the conversion cache so it
|
|
11581
12853
|
// coexists with other extensions' "pre" converters (the extension-level
|
|
11582
12854
|
// html.import uses Object.assign, which means only one "pre" per key).
|
|
11583
|
-
$registerPreConversion(editor);
|
|
12855
|
+
$registerPreConversion(editor, canonicalizers);
|
|
11584
12856
|
|
|
11585
12857
|
return Cc(
|
|
11586
12858
|
editor.registerCommand(TOGGLE_HIGHLIGHT_COMMAND, (styles) => $toggleSelectionStyles(editor, styles), oo),
|
|
@@ -11617,11 +12889,28 @@ function $markConversion() {
|
|
|
11617
12889
|
}
|
|
11618
12890
|
}
|
|
11619
12891
|
|
|
12892
|
+
// Highlighted inline code exports as <code style="...">, so read the highlight
|
|
12893
|
+
// back from that element. Code blocks keep their own <pre> and multi-line
|
|
12894
|
+
// <code> conversions.
|
|
12895
|
+
function $inlineCodeConversion(element) {
|
|
12896
|
+
if (!hasHighlightStyles(extractHighlightStyleFromElement(element) ?? "")) return null
|
|
12897
|
+
if (element.closest("pre") || isMultiLineCodeElement(element)) return null
|
|
12898
|
+
|
|
12899
|
+
return {
|
|
12900
|
+
conversion: extendTextNodeConversion("code", $applyHighlightStyle),
|
|
12901
|
+
priority: 1
|
|
12902
|
+
}
|
|
12903
|
+
}
|
|
12904
|
+
|
|
12905
|
+
function isMultiLineCodeElement(element) {
|
|
12906
|
+
return /\r?\n/.test(element.textContent) || element.querySelector("br") !== null
|
|
12907
|
+
}
|
|
12908
|
+
|
|
11620
12909
|
// Register a custom <pre> converter directly in the editor's HTML conversion
|
|
11621
12910
|
// cache. We can't use the extension-level html.import because Object.assign
|
|
11622
12911
|
// merges all extensions' converters by tag, and a later extension (e.g.
|
|
11623
12912
|
// TrixContentExtension) would overwrite ours.
|
|
11624
|
-
function $registerPreConversion(editor) {
|
|
12913
|
+
function $registerPreConversion(editor, canonicalizers) {
|
|
11625
12914
|
if (!editor._htmlConversions) return
|
|
11626
12915
|
|
|
11627
12916
|
let preEntries = editor._htmlConversions.get("pre");
|
|
@@ -11629,21 +12918,25 @@ function $registerPreConversion(editor) {
|
|
|
11629
12918
|
preEntries = [];
|
|
11630
12919
|
editor._htmlConversions.set("pre", preEntries);
|
|
11631
12920
|
}
|
|
11632
|
-
preEntries.push($preConversionWithHighlightsFactory(editor));
|
|
12921
|
+
preEntries.push($preConversionWithHighlightsFactory(editor, canonicalizers));
|
|
11633
12922
|
}
|
|
11634
12923
|
|
|
11635
12924
|
// Returns a <pre> converter factory scoped to a specific editor instance.
|
|
11636
12925
|
// The factory extracts highlight ranges from <mark> elements before the code
|
|
11637
12926
|
// retokenizer can destroy them. The ranges are stored in pendingCodeHighlights
|
|
11638
12927
|
// and restored by the highlight-preserving tokenizer during retokenization.
|
|
11639
|
-
|
|
12928
|
+
// Pasted highlights are canonicalized like those in the rest of the content,
|
|
12929
|
+
// so a color frozen by the copy (e.g. a resolved rgb() value) maps back to
|
|
12930
|
+
// its palette variable and follows the current theme.
|
|
12931
|
+
function $preConversionWithHighlightsFactory(editor, canonicalizers) {
|
|
11640
12932
|
return function $preConversionWithHighlights(domNode) {
|
|
11641
|
-
|
|
12933
|
+
let highlights = extractHighlightRanges(domNode);
|
|
12934
|
+
if (Es(jn)) highlights = canonicalizeHighlightRanges(highlights, canonicalizers);
|
|
11642
12935
|
if (highlights.length === 0) return null
|
|
11643
12936
|
|
|
11644
12937
|
return {
|
|
11645
12938
|
conversion: (domNode) => {
|
|
11646
|
-
const language = domNode
|
|
12939
|
+
const language = importedCodeLanguage(domNode);
|
|
11647
12940
|
const codeNode = I$1(language);
|
|
11648
12941
|
$getPendingHighlights(editor).set(codeNode.getKey(), highlights);
|
|
11649
12942
|
return { node: codeNode }
|
|
@@ -11694,6 +12987,12 @@ function extractHighlightRanges(preElement) {
|
|
|
11694
12987
|
return ranges
|
|
11695
12988
|
}
|
|
11696
12989
|
|
|
12990
|
+
function canonicalizeHighlightRanges(ranges, canonicalizers) {
|
|
12991
|
+
return ranges
|
|
12992
|
+
.map((range) => ({ ...range, style: applyCanonicalizers(range.style, canonicalizers) }))
|
|
12993
|
+
.filter((range) => hasHighlightStyles(range.style))
|
|
12994
|
+
}
|
|
12995
|
+
|
|
11697
12996
|
function $getPendingHighlights(editor) {
|
|
11698
12997
|
let map = pendingCodeHighlights.get(editor);
|
|
11699
12998
|
if (!map) {
|
|
@@ -12287,7 +13586,13 @@ class CommandDispatcher {
|
|
|
12287
13586
|
}
|
|
12288
13587
|
|
|
12289
13588
|
dispatchInsertTable() {
|
|
13589
|
+
const selection = Qr()?.clone();
|
|
13590
|
+
|
|
12290
13591
|
this.editor.dispatchCommand(ze$1, { "rows": 3, "columns": 3, "includeHeaders": true });
|
|
13592
|
+
|
|
13593
|
+
if (Es(qn)) {
|
|
13594
|
+
this.#keepSelectionWithPageCaret(selection);
|
|
13595
|
+
}
|
|
12291
13596
|
}
|
|
12292
13597
|
|
|
12293
13598
|
dispatchUndo() {
|
|
@@ -12302,6 +13607,35 @@ class CommandDispatcher {
|
|
|
12302
13607
|
this.#listeners.dispose();
|
|
12303
13608
|
}
|
|
12304
13609
|
|
|
13610
|
+
// Inserting a table selects its first cell, but with focus on the toolbar the
|
|
13611
|
+
// page caret stays put. Keep the editor's selection with the caret, or the next
|
|
13612
|
+
// key acts on a cell the user can't see (ArrowDown lands in row 2).
|
|
13613
|
+
#keepSelectionWithPageCaret(selection) {
|
|
13614
|
+
if (Fr(selection) && this.#isPointStillValid(selection.anchor) && this.#isPointStillValid(selection.focus)) {
|
|
13615
|
+
es(selection);
|
|
13616
|
+
}
|
|
13617
|
+
}
|
|
13618
|
+
|
|
13619
|
+
// Inserting can split the text a range covered, leaving a point attached but
|
|
13620
|
+
// past the end of what remains.
|
|
13621
|
+
#isPointStillValid(point) {
|
|
13622
|
+
const node = point.getNode();
|
|
13623
|
+
|
|
13624
|
+
if (node.isAttached()) {
|
|
13625
|
+
return point.offset <= this.#pointSize(node)
|
|
13626
|
+
} else {
|
|
13627
|
+
return false
|
|
13628
|
+
}
|
|
13629
|
+
}
|
|
13630
|
+
|
|
13631
|
+
#pointSize(node) {
|
|
13632
|
+
if (Tr(node)) {
|
|
13633
|
+
return node.getTextContentSize()
|
|
13634
|
+
} else {
|
|
13635
|
+
return node.getChildrenSize()
|
|
13636
|
+
}
|
|
13637
|
+
}
|
|
13638
|
+
|
|
12305
13639
|
#applyConfiguredHeadingFormat(index) {
|
|
12306
13640
|
const tag = this.editorElement.config.get("headings")[index];
|
|
12307
13641
|
if (tag) this.contents.applyHeadingFormat(tag);
|
|
@@ -13793,8 +15127,11 @@ class ListItemNodeInserter extends BaseNodeInserter {
|
|
|
13793
15127
|
}
|
|
13794
15128
|
|
|
13795
15129
|
const topItem = this.#topLevelItemFor(anchorNode, outerList);
|
|
13796
|
-
const
|
|
13797
|
-
|
|
15130
|
+
const splitIndex = this.#splitIndexFor(topItem);
|
|
15131
|
+
const splitsList = splitIndex > 0 && splitIndex < outerList.getChildrenSize();
|
|
15132
|
+
const [ listBefore, listAfter ] = this.#split(outerList, splitIndex);
|
|
15133
|
+
if (topItem && this.#isBareInsertionPoint(topItem)) { topItem.remove(); }
|
|
15134
|
+
if (splitsList) this.#continueNumbering(outerList, $firstListIn(listAfter));
|
|
13798
15135
|
|
|
13799
15136
|
let anchor = listBefore ?? listAfter;
|
|
13800
15137
|
for (const node of nodes) {
|
|
@@ -13808,14 +15145,15 @@ class ListItemNodeInserter extends BaseNodeInserter {
|
|
|
13808
15145
|
}
|
|
13809
15146
|
|
|
13810
15147
|
// A blank top-level bullet is just the insertion point (e.g. the user pressed
|
|
13811
|
-
// Enter to leave the list); break out of it entirely. A bullet
|
|
15148
|
+
// Enter to leave the list); break out of it entirely. A bullet holding only a
|
|
15149
|
+
// soft line break was kept on purpose, so it stays. A bullet with content —
|
|
13812
15150
|
// including one wrapping a nested list — splits so its content stays in the
|
|
13813
15151
|
// list. With no top-level bullet at all — removeText() relocated the anchor
|
|
13814
15152
|
// onto the list node itself — the anchor offset is the boundary between items.
|
|
13815
15153
|
#splitIndexFor(topItem) {
|
|
13816
15154
|
if (!topItem) return this.selection.anchor.offset
|
|
13817
15155
|
|
|
13818
|
-
const splitAfterItem =
|
|
15156
|
+
const splitAfterItem = this.#isBareInsertionPoint(topItem) ? topItem.getPreviousSibling() : topItem;
|
|
13819
15157
|
return splitAfterItem ? splitAfterItem.getIndexWithinParent() + 1 : 0
|
|
13820
15158
|
}
|
|
13821
15159
|
|
|
@@ -13832,6 +15170,21 @@ class ListItemNodeInserter extends BaseNodeInserter {
|
|
|
13832
15170
|
}
|
|
13833
15171
|
}
|
|
13834
15172
|
|
|
15173
|
+
#isBareInsertionPoint(item) {
|
|
15174
|
+
return $isBlankNode(item) && !$containsLineBreak(item)
|
|
15175
|
+
}
|
|
15176
|
+
|
|
15177
|
+
// Splitting a numbered list copies its start, so the second half would count
|
|
15178
|
+
// from 1 again. Continue it from where the first half ends instead. The first
|
|
15179
|
+
// half is the split list itself; $splitNode moves the rest into a copy.
|
|
15180
|
+
#continueNumbering(listBefore, listAfter) {
|
|
15181
|
+
if (!listAfter || listBefore.isEmpty() || listAfter.isEmpty()) return
|
|
15182
|
+
if (listBefore.getListType() !== "number") return
|
|
15183
|
+
|
|
15184
|
+
const numberedItems = listBefore.getChildren().filter(item => !$isNestedListWrapper(item));
|
|
15185
|
+
listAfter.setStart(listBefore.getStart() + numberedItems.length);
|
|
15186
|
+
}
|
|
15187
|
+
|
|
13835
15188
|
#outermostList(node) {
|
|
13836
15189
|
return [ node, ...node.getParents() ].reverse().find(Se$1)
|
|
13837
15190
|
}
|
|
@@ -13858,6 +15211,23 @@ class ListItemNodeInserter extends BaseNodeInserter {
|
|
|
13858
15211
|
}
|
|
13859
15212
|
}
|
|
13860
15213
|
|
|
15214
|
+
// For a list inside quotes, the second half of the split is a quote (or a chain
|
|
15215
|
+
// of nested quotes) that starts with the copy of the list.
|
|
15216
|
+
function $firstListIn(node) {
|
|
15217
|
+
if (Se$1(node)) return node
|
|
15218
|
+
if (Mt$2(node)) return $firstListIn(node.getFirstChild())
|
|
15219
|
+
return null
|
|
15220
|
+
}
|
|
15221
|
+
|
|
15222
|
+
function $containsLineBreak(node) {
|
|
15223
|
+
return node.getChildren().some(child => sr(child) || (Wi(child) && $containsLineBreak(child)))
|
|
15224
|
+
}
|
|
15225
|
+
|
|
15226
|
+
// A list item that only wraps a nested list takes no number of its own.
|
|
15227
|
+
function $isNestedListWrapper(item) {
|
|
15228
|
+
return pe$2(item) && item.getChildrenSize() === 1 && Se$1(item.getFirstChild())
|
|
15229
|
+
}
|
|
15230
|
+
|
|
13861
15231
|
// Lexical's RangeSelection.insertNodes requires every selection point to have a block
|
|
13862
15232
|
// ancestor with inline children. An element point on a container of block nodes — e.g.
|
|
13863
15233
|
// a quote holding paragraphs — has none, so Lexical throws invariant #211 or #212.
|
|
@@ -14140,6 +15510,22 @@ const PRESERVABLE_STYLES = {
|
|
|
14140
15510
|
p: [ "margin-top", "margin-bottom" ]
|
|
14141
15511
|
};
|
|
14142
15512
|
|
|
15513
|
+
// Elements that show nothing once they hold no text, as in the spacer cells
|
|
15514
|
+
// email layouts pad themselves with.
|
|
15515
|
+
const SPACER_ELEMENTS = new Set([ "BR", "DIV", "P", "SPAN", "FONT", "CENTER", "A", "B", "STRONG", "I", "EM", "U" ]);
|
|
15516
|
+
|
|
15517
|
+
const BLOCK_ELEMENTS$1 = new Set([
|
|
15518
|
+
"ADDRESS", "ARTICLE", "ASIDE", "BLOCKQUOTE", "CAPTION", "CENTER", "DD", "DETAILS", "DIALOG", "DIV", "DL", "DT",
|
|
15519
|
+
"FIELDSET", "FIGCAPTION", "FIGURE", "FOOTER", "FORM", "H1", "H2", "H3", "H4", "H5", "H6", "HEADER", "HGROUP", "HR",
|
|
15520
|
+
"LEGEND", "LI", "MAIN", "MENU", "NAV", "OL", "P", "PRE", "SEARCH", "SECTION", "SUMMARY", "TABLE", "TD", "TH", "UL"
|
|
15521
|
+
]);
|
|
15522
|
+
|
|
15523
|
+
// Elements that show something on a line without any text inside them.
|
|
15524
|
+
const INLINE_CONTENT_ELEMENTS = new Set([ "ACTION-TEXT-ATTACHMENT", "AUDIO", "EMBED", "IFRAME", "IMG", "OBJECT", "PICTURE", "SVG", "VIDEO" ]);
|
|
15525
|
+
|
|
15526
|
+
// Elements whose text never shows on the page.
|
|
15527
|
+
const HIDDEN_ELEMENTS = new Set([ "SCRIPT", "STYLE", "TEMPLATE", "TITLE", "META", "LINK" ]);
|
|
15528
|
+
|
|
14143
15529
|
class PastedContentFormatter {
|
|
14144
15530
|
constructor(doc) {
|
|
14145
15531
|
this.doc = doc;
|
|
@@ -14150,11 +15536,14 @@ class PastedContentFormatter {
|
|
|
14150
15536
|
this.#stripStyleElements();
|
|
14151
15537
|
this.#stripInterchangeNewlines();
|
|
14152
15538
|
this.#unwrapPlaceholderAnchors();
|
|
15539
|
+
this.#unwrapLayoutTables();
|
|
14153
15540
|
this.#stripTableCellColorStyles();
|
|
14154
15541
|
new OfficeFormatter(this.doc).format();
|
|
14155
15542
|
this.#unwrapWrappedListChildren();
|
|
14156
15543
|
this.#nestStrayListChildren();
|
|
14157
15544
|
this.#stripStrayListChildren();
|
|
15545
|
+
this.#stripBreaksBeforeBlocks();
|
|
15546
|
+
this.#convertBlankLineDivsToParagraphs();
|
|
14158
15547
|
this.#replaceGmailEmojiImgTags();
|
|
14159
15548
|
return this.doc
|
|
14160
15549
|
}
|
|
@@ -14226,6 +15615,87 @@ class PastedContentFormatter {
|
|
|
14226
15615
|
}
|
|
14227
15616
|
}
|
|
14228
15617
|
|
|
15618
|
+
// Email clients (Gmail, Apple Mail) and newsletters lay out messages with
|
|
15619
|
+
// tables: a full-width wrapper, a fixed-width body, single-cell rows, often
|
|
15620
|
+
// nested several deep. They hold the message, not tabular data, and imported
|
|
15621
|
+
// as real tables they paste as a table inside a table that the author never
|
|
15622
|
+
// wrote. Dissolve each layout table into its cells' content, outermost first,
|
|
15623
|
+
// so a data table inside one is still judged on its own and survives.
|
|
15624
|
+
#unwrapLayoutTables() {
|
|
15625
|
+
const nestedInLayout = new WeakSet();
|
|
15626
|
+
|
|
15627
|
+
let table = this.#firstLayoutTable(nestedInLayout);
|
|
15628
|
+
while (table) {
|
|
15629
|
+
for (const nested of table.querySelectorAll("table")) {
|
|
15630
|
+
nestedInLayout.add(nested);
|
|
15631
|
+
}
|
|
15632
|
+
this.#unwrapTable(table);
|
|
15633
|
+
table = this.#firstLayoutTable(nestedInLayout);
|
|
15634
|
+
}
|
|
15635
|
+
}
|
|
15636
|
+
|
|
15637
|
+
#firstLayoutTable(nestedInLayout) {
|
|
15638
|
+
for (const table of this.doc.querySelectorAll("table")) {
|
|
15639
|
+
if (this.#isLayoutTable(table, nestedInLayout.has(table))) return table
|
|
15640
|
+
}
|
|
15641
|
+
return null
|
|
15642
|
+
}
|
|
15643
|
+
|
|
15644
|
+
// A layout table often says so with its role, and rarely holds data, so one
|
|
15645
|
+
// holding another table is layout too, unless it declares itself tabular with
|
|
15646
|
+
// header cells or a table role. Inside a layout table, a single-column table
|
|
15647
|
+
// is one more layout row; pasted on its own it may be a column copied from a
|
|
15648
|
+
// spreadsheet, so it stays a table.
|
|
15649
|
+
#isLayoutTable(table, nestedInLayout) {
|
|
15650
|
+
const role = table.getAttribute("role");
|
|
15651
|
+
if (role === "presentation" || role === "none") return true
|
|
15652
|
+
if (this.#isExplicitlyTabular(table)) return false
|
|
15653
|
+
|
|
15654
|
+
return table.querySelector("table") !== null || (nestedInLayout && this.#isSingleColumn(table))
|
|
15655
|
+
}
|
|
15656
|
+
|
|
15657
|
+
#isExplicitlyTabular(table) {
|
|
15658
|
+
const role = table.getAttribute("role");
|
|
15659
|
+
return role === "table" || role === "grid" || role === "treegrid" ||
|
|
15660
|
+
this.#ownCells(table).some((cell) => cell.tagName === "TH")
|
|
15661
|
+
}
|
|
15662
|
+
|
|
15663
|
+
#isSingleColumn(table) {
|
|
15664
|
+
return Array.from(table.rows).every((row) => row.cells.length <= 1)
|
|
15665
|
+
}
|
|
15666
|
+
|
|
15667
|
+
// The caption and each cell become a block of their own, so the text of
|
|
15668
|
+
// neighbouring cells doesn't run together. Cells with nothing to show are
|
|
15669
|
+
// spacers and go.
|
|
15670
|
+
#unwrapTable(table) {
|
|
15671
|
+
const blocks = [];
|
|
15672
|
+
for (const part of [ ...this.#ownCaptions(table), ...this.#ownCells(table) ]) {
|
|
15673
|
+
if (this.#hasVisibleContent(part)) {
|
|
15674
|
+
const block = this.doc.createElement("div");
|
|
15675
|
+
block.append(...part.childNodes);
|
|
15676
|
+
blocks.push(block);
|
|
15677
|
+
}
|
|
15678
|
+
}
|
|
15679
|
+
table.replaceWith(...blocks);
|
|
15680
|
+
}
|
|
15681
|
+
|
|
15682
|
+
#ownCaptions(table) {
|
|
15683
|
+
return Array.from(table.children).filter((child) => child.tagName === "CAPTION")
|
|
15684
|
+
}
|
|
15685
|
+
|
|
15686
|
+
// Only this table's cells, not those of the tables nested inside them.
|
|
15687
|
+
#ownCells(table) {
|
|
15688
|
+
return Array.from(table.querySelectorAll("td, th")).filter((cell) => cell.closest("table") === table)
|
|
15689
|
+
}
|
|
15690
|
+
|
|
15691
|
+
// Spacer cells hold at most whitespace, line breaks and empty wrappers. Any
|
|
15692
|
+
// other element, such as an image, a video or an attachment that renders from
|
|
15693
|
+
// its attributes, is content.
|
|
15694
|
+
#hasVisibleContent(cell) {
|
|
15695
|
+
return cell.textContent.trim() !== "" ||
|
|
15696
|
+
Array.from(cell.querySelectorAll("*")).some((element) => !SPACER_ELEMENTS.has(element.tagName))
|
|
15697
|
+
}
|
|
15698
|
+
|
|
14229
15699
|
// Table cells copied from a page inherit the source theme's inline color
|
|
14230
15700
|
// styles (e.g. dark-mode backgrounds). Strip them so pasted tables adopt
|
|
14231
15701
|
// the current theme instead of carrying stale colors.
|
|
@@ -14295,6 +15765,101 @@ class PastedContentFormatter {
|
|
|
14295
15765
|
}
|
|
14296
15766
|
}
|
|
14297
15767
|
|
|
15768
|
+
// Trix writes a blank line as <div><br></div>. Lexical has no importer for
|
|
15769
|
+
// <div>, and it drops a <br> that is a block's only child, so the blank line
|
|
15770
|
+
// would vanish and the paragraphs around it would run together. An empty
|
|
15771
|
+
// paragraph is how Lexxy writes a blank line, so turn each one into that.
|
|
15772
|
+
// List items are left alone: a paragraph can't sit inside one.
|
|
15773
|
+
#convertBlankLineDivsToParagraphs() {
|
|
15774
|
+
for (const div of this.doc.querySelectorAll("div")) {
|
|
15775
|
+
if (this.#isBlankLineDiv(div) && !div.closest("li")) {
|
|
15776
|
+
const paragraph = this.doc.createElement("p");
|
|
15777
|
+
paragraph.appendChild(this.doc.createElement("br"));
|
|
15778
|
+
div.replaceWith(paragraph);
|
|
15779
|
+
}
|
|
15780
|
+
}
|
|
15781
|
+
}
|
|
15782
|
+
|
|
15783
|
+
#isBlankLineDiv(div) {
|
|
15784
|
+
const children = Array.from(div.childNodes).filter((node) => !this.#isIgnorableTrailingNode(node));
|
|
15785
|
+
return children.length === 1 && children[0].nodeName === "BR"
|
|
15786
|
+
}
|
|
15787
|
+
|
|
15788
|
+
// Outlook, and the web apps that show its mail, end a line with <br> right before
|
|
15789
|
+
// a list or other block starts. The block starts a new line anyway, so that <br>
|
|
15790
|
+
// only ends the line before it and shows nothing, but imported it becomes a line
|
|
15791
|
+
// break that adds a blank line. A <br> with no content before it on its line
|
|
15792
|
+
// shows as an empty line, so it stays.
|
|
15793
|
+
#stripBreaksBeforeBlocks() {
|
|
15794
|
+
for (const br of Array.from(this.doc.querySelectorAll("br"))) {
|
|
15795
|
+
if (this.#blockFollowsOnLine(br) && this.#hasContentBeforeOnLine(br)) {
|
|
15796
|
+
br.remove();
|
|
15797
|
+
}
|
|
15798
|
+
}
|
|
15799
|
+
}
|
|
15800
|
+
|
|
15801
|
+
// Whether a block comes right after the <br>, stepping out of and into inline
|
|
15802
|
+
// wrappers such as the <span>s Outlook puts around each run of text.
|
|
15803
|
+
#blockFollowsOnLine(br) {
|
|
15804
|
+
for (let node = br; node !== this.doc.body && !this.#isBlockElement(node); node = node.parentNode) {
|
|
15805
|
+
for (let sibling = node.nextSibling; sibling; sibling = sibling.nextSibling) {
|
|
15806
|
+
const start = this.#lineEdgeIn(sibling, "start");
|
|
15807
|
+
if (start) return start === "block"
|
|
15808
|
+
}
|
|
15809
|
+
}
|
|
15810
|
+
return false
|
|
15811
|
+
}
|
|
15812
|
+
|
|
15813
|
+
// Whether text or media comes before the <br> since its block, or the block
|
|
15814
|
+
// before it, began, looking through earlier breaks and empty inline wrappers.
|
|
15815
|
+
#hasContentBeforeOnLine(br) {
|
|
15816
|
+
for (let node = br; node !== this.doc.body && !this.#isBlockElement(node); node = node.parentNode) {
|
|
15817
|
+
for (let sibling = node.previousSibling; sibling; sibling = sibling.previousSibling) {
|
|
15818
|
+
const end = this.#lineEdgeIn(sibling, "end");
|
|
15819
|
+
if (end) return end === "content"
|
|
15820
|
+
}
|
|
15821
|
+
}
|
|
15822
|
+
return false
|
|
15823
|
+
}
|
|
15824
|
+
|
|
15825
|
+
// What a node shows first ("start") or last ("end") on its line: "content", a
|
|
15826
|
+
// "block" that starts a line of its own, or null for nothing at all. Looking
|
|
15827
|
+
// ahead, a <br> counts as content, since it ends a line of its own; looking
|
|
15828
|
+
// back, it doesn't, so a run of breaks needs text or media before it.
|
|
15829
|
+
#lineEdgeIn(node, edge) {
|
|
15830
|
+
if (this.#isBlockElement(node)) return "block"
|
|
15831
|
+
if (node.nodeType === Node.TEXT_NODE) return this.#isCollapsibleWhitespace(node) ? null : "content"
|
|
15832
|
+
if (node.nodeType !== Node.ELEMENT_NODE) return null
|
|
15833
|
+
if (node.nodeName === "BR") return edge === "start" ? "content" : null
|
|
15834
|
+
if (HIDDEN_ELEMENTS.has(node.nodeName)) return null
|
|
15835
|
+
if (INLINE_CONTENT_ELEMENTS.has(node.nodeName.toUpperCase())) return "content"
|
|
15836
|
+
|
|
15837
|
+
const children = Array.from(node.childNodes);
|
|
15838
|
+
if (edge === "end") children.reverse();
|
|
15839
|
+
for (const child of children) {
|
|
15840
|
+
const found = this.#lineEdgeIn(child, edge);
|
|
15841
|
+
if (found) return found
|
|
15842
|
+
}
|
|
15843
|
+
return null
|
|
15844
|
+
}
|
|
15845
|
+
|
|
15846
|
+
// HTML collapses spaces, tabs and newlines but not non-breaking spaces, which
|
|
15847
|
+
// hold a line open.
|
|
15848
|
+
#isCollapsibleWhitespace(node) {
|
|
15849
|
+
if (node.nodeType === Node.COMMENT_NODE) return true
|
|
15850
|
+
return node.nodeType === Node.TEXT_NODE && /^[ \t\n\r\f]*$/.test(node.textContent)
|
|
15851
|
+
}
|
|
15852
|
+
|
|
15853
|
+
// An inline display style decides, as it does in the browser, so a <span> shown as a
|
|
15854
|
+
// block starts a line of its own and a <div> shown inline doesn't.
|
|
15855
|
+
#isBlockElement(node) {
|
|
15856
|
+
if (node?.nodeType !== Node.ELEMENT_NODE) return false
|
|
15857
|
+
|
|
15858
|
+
const display = node.style?.display;
|
|
15859
|
+
if (display) return !display.startsWith("inline") && display !== "contents" && display !== "none"
|
|
15860
|
+
return BLOCK_ELEMENTS$1.has(node.nodeName)
|
|
15861
|
+
}
|
|
15862
|
+
|
|
14298
15863
|
// Read the rules from a sheet we build rather than from this.doc.styleSheets: the
|
|
14299
15864
|
// document came from DOMParser, so it has no browsing context, and WebKit leaves
|
|
14300
15865
|
// its styleSheets empty. Parsing the text ourselves still expands the shorthands
|
|
@@ -14418,12 +15983,17 @@ class Contents {
|
|
|
14418
15983
|
}, { tag });
|
|
14419
15984
|
}
|
|
14420
15985
|
|
|
15986
|
+
// The text takes the formatting at the caret, as typed text would.
|
|
14421
15987
|
insertText(text, { tag } = {}) {
|
|
14422
15988
|
this.editor.update(() => {
|
|
15989
|
+
const selection = Qr();
|
|
15990
|
+
const format = Fr(selection) ? selection.format : 0;
|
|
15991
|
+
const style = Fr(selection) ? selection.style : "";
|
|
15992
|
+
|
|
14423
15993
|
const paragraph = eo();
|
|
14424
15994
|
text.split(/\r\n|\r|\n/).forEach((line, index) => {
|
|
14425
15995
|
if (index > 0) paragraph.append(or());
|
|
14426
|
-
paragraph.append(kr(line));
|
|
15996
|
+
paragraph.append(kr(line).setFormat(format).setStyle(style));
|
|
14427
15997
|
});
|
|
14428
15998
|
this.insertAtCursor(paragraph);
|
|
14429
15999
|
}, { tag });
|
|
@@ -14441,7 +16011,7 @@ class Contents {
|
|
|
14441
16011
|
if (!Fr(selection)) return
|
|
14442
16012
|
|
|
14443
16013
|
$expandSelectionToLineBreaksAndSplitAtEdges(selection, (node) => Nt$2(node));
|
|
14444
|
-
H$6(selection, () => eo());
|
|
16014
|
+
H$6(selection, () => eo(), $copyBlockFormat);
|
|
14445
16015
|
}
|
|
14446
16016
|
|
|
14447
16017
|
applyHeadingFormat(tag) {
|
|
@@ -14449,7 +16019,7 @@ class Contents {
|
|
|
14449
16019
|
if (!Fr(selection)) return
|
|
14450
16020
|
|
|
14451
16021
|
$expandSelectionToLineBreaksAndSplitAtEdges(selection);
|
|
14452
|
-
H$6(selection, () => Jt$2(tag));
|
|
16022
|
+
H$6(selection, () => Jt$2(tag), $copyBlockFormat);
|
|
14453
16023
|
}
|
|
14454
16024
|
|
|
14455
16025
|
applyUnorderedListFormat() {
|
|
@@ -14473,7 +16043,7 @@ class Contents {
|
|
|
14473
16043
|
|
|
14474
16044
|
this.#topLevelElementsInSelection(selection).filter(Mt$2).forEach(node => this.#unwrap(node));
|
|
14475
16045
|
|
|
14476
|
-
H$6(selection, () => eo());
|
|
16046
|
+
H$6(selection, () => eo(), $copyBlockFormat);
|
|
14477
16047
|
}
|
|
14478
16048
|
|
|
14479
16049
|
toggleCodeBlock() {
|
|
@@ -14517,7 +16087,8 @@ class Contents {
|
|
|
14517
16087
|
} else {
|
|
14518
16088
|
topLevelElements.filter(Mt$2).forEach(node => this.#unwrap(node));
|
|
14519
16089
|
|
|
14520
|
-
|
|
16090
|
+
this.#splitListsAroundSelectedItems(selection);
|
|
16091
|
+
$expandSelectionToLineBreaksAndSplitAtEdges(selection);
|
|
14521
16092
|
const elements = this.#topLevelElementsInSelection(selection);
|
|
14522
16093
|
if (elements.length === 0) return
|
|
14523
16094
|
|
|
@@ -14936,6 +16507,42 @@ class Contents {
|
|
|
14936
16507
|
return runs.filter((run) => run.size > 0).map((run) => Array.from(run))
|
|
14937
16508
|
}
|
|
14938
16509
|
|
|
16510
|
+
// Quoting part of a list quotes only the selected items: the items before and
|
|
16511
|
+
// after them move to lists of their own, numbered where they were.
|
|
16512
|
+
#splitListsAroundSelectedItems(selection) {
|
|
16513
|
+
const [ start, end ] = selection.getStartEndPoints().sort((a, b) => a.isBefore(b) ? -1 : 1);
|
|
16514
|
+
|
|
16515
|
+
for (const list of this.#topLevelElementsInSelection(selection).filter(Se$1)) {
|
|
16516
|
+
const lastIndex = list.getChildrenSize() - 1;
|
|
16517
|
+
let first = this.#listItemIndexAt(list, start) ?? 0;
|
|
16518
|
+
let last = this.#listItemIndexAt(list, end) ?? lastIndex;
|
|
16519
|
+
|
|
16520
|
+
if (first < last && $isAtBlockEnd(start, list.getChildAtIndex(first))) first++;
|
|
16521
|
+
if (first < last && $isAtBlockStart(end, list.getChildAtIndex(last))) last--;
|
|
16522
|
+
|
|
16523
|
+
this.#moveListItemsToNewListAfter(list, last + 1);
|
|
16524
|
+
this.#moveListItemsToNewListAfter(list, first);
|
|
16525
|
+
}
|
|
16526
|
+
}
|
|
16527
|
+
|
|
16528
|
+
#listItemIndexAt(list, point) {
|
|
16529
|
+
const item = dl(point.getNode(), (node) => node.getParent()?.is(list));
|
|
16530
|
+
return item?.getIndexWithinParent()
|
|
16531
|
+
}
|
|
16532
|
+
|
|
16533
|
+
#moveListItemsToNewListAfter(list, index) {
|
|
16534
|
+
const items = list.getChildren().slice(index);
|
|
16535
|
+
if (index === 0 || items.length === 0) return
|
|
16536
|
+
|
|
16537
|
+
// Wrapper items that only hold a nested list don't take a number, so start
|
|
16538
|
+
// from the first numbered item that moves rather than from its index.
|
|
16539
|
+
const numberedItem = items.find(item => !Se$1(item.getFirstChild())) ?? items[0];
|
|
16540
|
+
const start = list.getListType() === "number" ? numberedItem.getValue() : 1;
|
|
16541
|
+
const newList = Te$1(list.getListType(), start);
|
|
16542
|
+
list.insertAfter(newList);
|
|
16543
|
+
newList.append(...items);
|
|
16544
|
+
}
|
|
16545
|
+
|
|
14939
16546
|
#topLevelElementsInSelection(selection) {
|
|
14940
16547
|
const elements = new Set();
|
|
14941
16548
|
for (const node of selection.getNodes()) {
|
|
@@ -15095,6 +16702,14 @@ class Contents {
|
|
|
15095
16702
|
}
|
|
15096
16703
|
}
|
|
15097
16704
|
|
|
16705
|
+
// Lexical's default carries the source block's indent over, but indentation
|
|
16706
|
+
// only exists in Lexxy as list nesting: a list item turned into a paragraph or
|
|
16707
|
+
// heading would keep an indent nothing else can create or remove.
|
|
16708
|
+
function $copyBlockFormat(source, target) {
|
|
16709
|
+
const format = source.getFormatType();
|
|
16710
|
+
if (format !== target.getFormatType()) target.setFormat(format);
|
|
16711
|
+
}
|
|
16712
|
+
|
|
15098
16713
|
/**
|
|
15099
16714
|
* marked v16.4.1 - a markdown parser
|
|
15100
16715
|
* Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
|
|
@@ -15198,10 +16813,87 @@ function parsePastedMarkdown(text) {
|
|
|
15198
16813
|
// code-region collection, or lexer-option syncing required. This renderer fires
|
|
15199
16814
|
// only for genuine raw-HTML tokens, and marked inserts its return value verbatim
|
|
15200
16815
|
// (it does not re-encode), so we escape unsupported tags to literal text here.
|
|
16816
|
+
//
|
|
16817
|
+
// An HTML snippet is a different matter. Embed codes, tracking snippets and HTML
|
|
16818
|
+
// samples carry tags the importer can't keep: it drops script and style along
|
|
16819
|
+
// with everything inside them, and an iframe or the empty <div id="widget"> an
|
|
16820
|
+
// embed code hangs off has no content to keep either. Rendered as HTML, such a
|
|
16821
|
+
// paste loses its code, often all of it, with no error. When any raw HTML in the
|
|
16822
|
+
// paste holds one of those tags, the user is pasting code to show, so every raw
|
|
16823
|
+
// HTML token in it pastes as the literal text they copied: a block of HTML as a
|
|
16824
|
+
// code block, which keeps its indentation and spacing, and HTML within a line
|
|
16825
|
+
// as inline code. The Markdown around it still renders. Within a line, marked
|
|
16826
|
+
// reads only the tags as HTML and parses what sits between them as Markdown, so
|
|
16827
|
+
// an inline element of this kind is tokenized whole, contents included.
|
|
16828
|
+
const DISCARDED_ELEMENTS = new Set([ "script", "style", "iframe", "noscript", "template", "object", "embed", "link", "meta" ]);
|
|
16829
|
+
|
|
16830
|
+
const INLINE_DISCARDED_ELEMENT_START = /<(?:script|style|iframe|noscript|template|object)(?=[\s/>])/i;
|
|
16831
|
+
const INLINE_DISCARDED_ELEMENT_OPENING = /^<(script|style|iframe|noscript|template|object)(?=[\s/>])(?:"[^"]*"|'[^']*'|[^'">])*>/i;
|
|
16832
|
+
|
|
16833
|
+
// Script, style and iframe hold raw text, so their first closing tag ends them.
|
|
16834
|
+
// The others can nest, so they end at the closing tag that balances the opening.
|
|
16835
|
+
const RAW_TEXT_ELEMENTS = new Set([ "script", "style", "iframe" ]);
|
|
16836
|
+
|
|
16837
|
+
const inlineDiscardedElement = {
|
|
16838
|
+
name: "inlineDiscardedElement",
|
|
16839
|
+
level: "inline",
|
|
16840
|
+
start: (src) => src.match(INLINE_DISCARDED_ELEMENT_START)?.index,
|
|
16841
|
+
tokenizer(src) {
|
|
16842
|
+
const opening = src.match(INLINE_DISCARDED_ELEMENT_OPENING);
|
|
16843
|
+
if (!opening) return
|
|
16844
|
+
|
|
16845
|
+
const end = closingTagEnd(src, opening[1].toLowerCase(), opening[0].length);
|
|
16846
|
+
if (end !== -1) {
|
|
16847
|
+
const raw = src.slice(0, end);
|
|
16848
|
+
return { type: "html", raw, text: raw, block: false, inLink: false, inRawBlock: false }
|
|
16849
|
+
}
|
|
16850
|
+
}
|
|
16851
|
+
};
|
|
16852
|
+
|
|
16853
|
+
function closingTagEnd(src, name, from) {
|
|
16854
|
+
const tags = new RegExp(`<(/?)${name}(?=[\\s/>])(?:"[^"]*"|'[^']*'|[^'">])*>`, "gi");
|
|
16855
|
+
tags.lastIndex = from;
|
|
16856
|
+
|
|
16857
|
+
let depth = 1;
|
|
16858
|
+
for (let match = tags.exec(src); match; match = tags.exec(src)) {
|
|
16859
|
+
if (match[1]) {
|
|
16860
|
+
depth--;
|
|
16861
|
+
} else if (!RAW_TEXT_ELEMENTS.has(name)) {
|
|
16862
|
+
depth++;
|
|
16863
|
+
}
|
|
16864
|
+
if (depth === 0) return tags.lastIndex
|
|
16865
|
+
}
|
|
16866
|
+
return -1
|
|
16867
|
+
}
|
|
16868
|
+
|
|
15201
16869
|
const pasteMarked = new B({
|
|
15202
16870
|
breaks: true,
|
|
15203
16871
|
renderer: { html: renderPastedHtmlToken }
|
|
15204
|
-
}).use({
|
|
16872
|
+
}).use({
|
|
16873
|
+
extensions: [ inlineDiscardedElement ],
|
|
16874
|
+
tokenizer: { code: () => undefined },
|
|
16875
|
+
hooks: { processAllTokens: markHtmlSnippetTokens }
|
|
16876
|
+
});
|
|
16877
|
+
|
|
16878
|
+
function markHtmlSnippetTokens(tokens) {
|
|
16879
|
+
const htmlTokens = [];
|
|
16880
|
+
pasteMarked.walkTokens(tokens, (token) => {
|
|
16881
|
+
if (token.type === "html") htmlTokens.push(token);
|
|
16882
|
+
});
|
|
16883
|
+
|
|
16884
|
+
if (htmlTokens.some(containsDiscardedElement)) {
|
|
16885
|
+
for (const token of htmlTokens) token.literal = true;
|
|
16886
|
+
}
|
|
16887
|
+
|
|
16888
|
+
return tokens
|
|
16889
|
+
}
|
|
16890
|
+
|
|
16891
|
+
function containsDiscardedElement(token) {
|
|
16892
|
+
for (const [ , , name ] of token.text.matchAll(HTML_TAG_LEXEME)) {
|
|
16893
|
+
if (DISCARDED_ELEMENTS.has(name.toLowerCase())) return true
|
|
16894
|
+
}
|
|
16895
|
+
return false
|
|
16896
|
+
}
|
|
15205
16897
|
|
|
15206
16898
|
// Matches a single HTML tag lexeme: an optional "/", a tag name, then attribute
|
|
15207
16899
|
// characters up to the closing ">". Quoted attribute values may contain ">" —
|
|
@@ -15219,11 +16911,21 @@ const HTML_TAG_LEXEME = /<(\/?)([a-zA-Z][a-zA-Z0-9-]*)((?:"[^"]*"|'[^']*'|[^'">]
|
|
|
15219
16911
|
// the <div> so it still renders, and escape the nested <v Name> so it survives
|
|
15220
16912
|
// as literal text rather than being unwrapped and dropped by the importer.
|
|
15221
16913
|
function renderPastedHtmlToken(token) {
|
|
16914
|
+
if (token.literal) return renderLiteralHtmlToken(token)
|
|
16915
|
+
|
|
15222
16916
|
return token.text.replace(HTML_TAG_LEXEME, (lexeme, _slash, name) => {
|
|
15223
16917
|
return isSupportedHtmlElement(name) ? lexeme : escapeHtml(lexeme)
|
|
15224
16918
|
})
|
|
15225
16919
|
}
|
|
15226
16920
|
|
|
16921
|
+
function renderLiteralHtmlToken(token) {
|
|
16922
|
+
if (token.block) {
|
|
16923
|
+
return `<pre data-language="html"><code>${escapeHtml(token.text.replace(/\n+$/, ""))}</code></pre>`
|
|
16924
|
+
} else {
|
|
16925
|
+
return `<code>${escapeHtml(token.text)}</code>`
|
|
16926
|
+
}
|
|
16927
|
+
}
|
|
16928
|
+
|
|
15227
16929
|
// The renderer's output is final, so escape the full lexeme — "&", "<" and ">" —
|
|
15228
16930
|
// for an exact round-trip (e.g. "<v A B>" → "<v A&nbsp;B>").
|
|
15229
16931
|
function escapeHtml(text) {
|
|
@@ -15255,6 +16957,12 @@ function isSupportedHtmlElement(name) {
|
|
|
15255
16957
|
return !(document.createElement(tag) instanceof HTMLUnknownElement) && !tag.includes("-")
|
|
15256
16958
|
}
|
|
15257
16959
|
|
|
16960
|
+
const CODE_EDITOR_PROSE_LANGUAGES = [ "markdown", "plaintext" ];
|
|
16961
|
+
|
|
16962
|
+
// The `[text](` that opens a Markdown inline link, matching the link text the
|
|
16963
|
+
// way Lexical's LINK transformer does (one level of nested brackets).
|
|
16964
|
+
const MARKDOWN_LINK_DESTINATION_START = /\[[^[\]]*(?:\[[^[\]]*\][^[\]]*)*\]\($/;
|
|
16965
|
+
|
|
15258
16966
|
class Clipboard {
|
|
15259
16967
|
#listeners = new ListenerBin()
|
|
15260
16968
|
|
|
@@ -15320,7 +17028,11 @@ class Clipboard {
|
|
|
15320
17028
|
|
|
15321
17029
|
const url = $bareUrlFromSingleLink(nodes);
|
|
15322
17030
|
if (url && Fr(selection)) {
|
|
15323
|
-
this
|
|
17031
|
+
if (this.editorElement.supportsMarkdown && $isInMarkdownLinkDestination(selection)) {
|
|
17032
|
+
selection.insertText(url);
|
|
17033
|
+
} else {
|
|
17034
|
+
this.#insertSingleLinkAt(selection, url);
|
|
17035
|
+
}
|
|
15324
17036
|
return true
|
|
15325
17037
|
}
|
|
15326
17038
|
|
|
@@ -15331,7 +17043,9 @@ class Clipboard {
|
|
|
15331
17043
|
}
|
|
15332
17044
|
|
|
15333
17045
|
#isPlainTextOrURLPasted(clipboardData) {
|
|
15334
|
-
return this.#isOnlyPlainTextPasted(clipboardData)
|
|
17046
|
+
return this.#isOnlyPlainTextPasted(clipboardData)
|
|
17047
|
+
|| this.#isOnlyURLPasted(clipboardData)
|
|
17048
|
+
|| this.#isProseCopiedFromCodeEditor(clipboardData)
|
|
15335
17049
|
}
|
|
15336
17050
|
|
|
15337
17051
|
#isOnlyPlainTextPasted(clipboardData) {
|
|
@@ -15360,6 +17074,22 @@ class Clipboard {
|
|
|
15360
17074
|
return !html || this.#htmlIsBareLinkToURL(html, text)
|
|
15361
17075
|
}
|
|
15362
17076
|
|
|
17077
|
+
// VS Code, and editors built on it such as Cursor, copy syntax-highlighted HTML next to the
|
|
17078
|
+
// plain text, which pastes as a code block. That suits source code, but Markdown or plain text
|
|
17079
|
+
// copied from them should paste as plain text, so the Markdown converts. The editor names the
|
|
17080
|
+
// file's language in vscode-editor-data, which Chromium-based browsers expose.
|
|
17081
|
+
#isProseCopiedFromCodeEditor(clipboardData) {
|
|
17082
|
+
const types = Array.from(clipboardData.types);
|
|
17083
|
+
if (!types.includes("vscode-editor-data") || !types.includes("text/plain")) return false
|
|
17084
|
+
|
|
17085
|
+
try {
|
|
17086
|
+
const { mode } = JSON.parse(clipboardData.getData("vscode-editor-data"));
|
|
17087
|
+
return CODE_EDITOR_PROSE_LANGUAGES.includes(mode)
|
|
17088
|
+
} catch {
|
|
17089
|
+
return false
|
|
17090
|
+
}
|
|
17091
|
+
}
|
|
17092
|
+
|
|
15363
17093
|
#htmlIsBareLinkToURL(html, url) {
|
|
15364
17094
|
const doc = parseHtml(html);
|
|
15365
17095
|
if (doc.body.textContent.trim() !== url) return false
|
|
@@ -15435,6 +17165,19 @@ class Clipboard {
|
|
|
15435
17165
|
});
|
|
15436
17166
|
}
|
|
15437
17167
|
|
|
17168
|
+
#isCaretInMarkdownLinkDestination() {
|
|
17169
|
+
if (!this.editorElement.supportsMarkdown) return false
|
|
17170
|
+
|
|
17171
|
+
return this.editor.getEditorState().read(() => $isInMarkdownLinkDestination(Qr()))
|
|
17172
|
+
}
|
|
17173
|
+
|
|
17174
|
+
#pasteURLAsText(url) {
|
|
17175
|
+
this.editor.update(() => {
|
|
17176
|
+
const selection = Qr();
|
|
17177
|
+
if (Fr(selection)) selection.insertText(url);
|
|
17178
|
+
}, { tag: jn });
|
|
17179
|
+
}
|
|
17180
|
+
|
|
15438
17181
|
#plainTextOrURLItem(clipboardData) {
|
|
15439
17182
|
const items = Array.from(clipboardData.items);
|
|
15440
17183
|
return items.find((item) => item.type === "text/plain") || items.find((item) => item.type === "text/uri-list")
|
|
@@ -15443,6 +17186,8 @@ class Clipboard {
|
|
|
15443
17186
|
#pasteURL(url) {
|
|
15444
17187
|
if (this.contents.hasSelectedText()) {
|
|
15445
17188
|
this.contents.createLinkWithSelectedText(url);
|
|
17189
|
+
} else if (this.#isCaretInMarkdownLinkDestination()) {
|
|
17190
|
+
this.#pasteURLAsText(url);
|
|
15446
17191
|
} else {
|
|
15447
17192
|
const nodeKey = this.contents.createLink(url);
|
|
15448
17193
|
this.#dispatchLinkInsertEvent(nodeKey, { url });
|
|
@@ -15603,6 +17348,19 @@ function $bareUrlFromLink(linkNode) {
|
|
|
15603
17348
|
return linkNode.getTextContent() === url ? url : null
|
|
15604
17349
|
}
|
|
15605
17350
|
|
|
17351
|
+
// Typing `[text](`, pasting the URL and typing `)` should produce a link through
|
|
17352
|
+
// the Markdown link shortcut. That shortcut only matches plain text, so a URL
|
|
17353
|
+
// pasted there stays plain text instead of becoming a link of its own.
|
|
17354
|
+
function $isInMarkdownLinkDestination(selection) {
|
|
17355
|
+
if (!Fr(selection) || !selection.isCollapsed()) return false
|
|
17356
|
+
|
|
17357
|
+
const node = selection.anchor.getNode();
|
|
17358
|
+
if (!Tr(node) || dl(node, z$5)) return false
|
|
17359
|
+
|
|
17360
|
+
const textBeforeCaret = node.getTextContent().slice(0, selection.anchor.offset);
|
|
17361
|
+
return MARKDOWN_LINK_DESTINATION_START.test(textBeforeCaret)
|
|
17362
|
+
}
|
|
17363
|
+
|
|
15606
17364
|
class Extensions {
|
|
15607
17365
|
|
|
15608
17366
|
constructor(lexxyElement) {
|
|
@@ -15824,22 +17582,25 @@ function linkAttributesFrom(linkNode) {
|
|
|
15824
17582
|
//
|
|
15825
17583
|
// This custom export skips <b> when <strong> is already present and <i> when <em> is
|
|
15826
17584
|
// already present, while preserving <s> and <u> wrappers which have no semantic equivalents
|
|
15827
|
-
// in createDOM's output.
|
|
17585
|
+
// in createDOM's output. On highlighted text, <s> and <u> go inside the <mark>.
|
|
15828
17586
|
//
|
|
15829
17587
|
// Any <span> elements produced by createDOM() are unwrapped, since they only carry
|
|
15830
17588
|
// editor classes that aren't meaningful in exported HTML.
|
|
17589
|
+
//
|
|
17590
|
+
// Spaces that HTML would collapse are exported as non-breaking spaces; see
|
|
17591
|
+
// collapsible_spaces_helper.js.
|
|
15831
17592
|
|
|
15832
17593
|
// A CodeHighlightNode exports like any other text node, plus an <a> wrapper
|
|
15833
17594
|
// when it carries link state — that's how a link survives inside a code
|
|
15834
17595
|
// block, whose retokenizer would destroy an actual LinkNode child.
|
|
15835
17596
|
function exportCodeHighlightNodeDOM(editor, codeHighlightNode) {
|
|
15836
|
-
const
|
|
17597
|
+
const element = exportFormattedTextDOM(editor, codeHighlightNode);
|
|
15837
17598
|
const link = $getCodeLink(codeHighlightNode);
|
|
15838
17599
|
|
|
15839
17600
|
if (link) {
|
|
15840
|
-
return { element: wrapWithAnchor(
|
|
17601
|
+
return { element: wrapWithAnchor(element, link) }
|
|
15841
17602
|
} else {
|
|
15842
|
-
return
|
|
17603
|
+
return { element }
|
|
15843
17604
|
}
|
|
15844
17605
|
}
|
|
15845
17606
|
|
|
@@ -15854,6 +17615,12 @@ function wrapWithAnchor(element, link) {
|
|
|
15854
17615
|
}
|
|
15855
17616
|
|
|
15856
17617
|
function exportTextNodeDOM(editor, textNode) {
|
|
17618
|
+
const element = exportFormattedTextDOM(editor, textNode);
|
|
17619
|
+
$preserveSpaces(element, textNode);
|
|
17620
|
+
return { element }
|
|
17621
|
+
}
|
|
17622
|
+
|
|
17623
|
+
function exportFormattedTextDOM(editor, textNode) {
|
|
15857
17624
|
const element = textNode.createDOM(editor._config, editor);
|
|
15858
17625
|
element.style.whiteSpace = "pre-wrap";
|
|
15859
17626
|
|
|
@@ -15874,13 +17641,13 @@ function exportTextNodeDOM(editor, textNode) {
|
|
|
15874
17641
|
result = wrapWith(result, "i");
|
|
15875
17642
|
}
|
|
15876
17643
|
if (textNode.hasFormat("strikethrough")) {
|
|
15877
|
-
result =
|
|
17644
|
+
result = wrapDecoration(result, element, "s");
|
|
15878
17645
|
}
|
|
15879
17646
|
if (textNode.hasFormat("underline")) {
|
|
15880
|
-
result =
|
|
17647
|
+
result = wrapDecoration(result, element, "u");
|
|
15881
17648
|
}
|
|
15882
17649
|
|
|
15883
|
-
return
|
|
17650
|
+
return unwrapSpans(result)
|
|
15884
17651
|
}
|
|
15885
17652
|
|
|
15886
17653
|
function containsTag(element, tagName) {
|
|
@@ -15896,6 +17663,19 @@ function wrapWith(element, tag) {
|
|
|
15896
17663
|
return wrapper
|
|
15897
17664
|
}
|
|
15898
17665
|
|
|
17666
|
+
// A text decoration line is drawn in the color of the element that declares it,
|
|
17667
|
+
// so <s> and <u> go inside a highlight's <mark> to take its color.
|
|
17668
|
+
function wrapDecoration(result, element, tag) {
|
|
17669
|
+
if (element.tagName === "MARK") {
|
|
17670
|
+
const wrapper = document.createElement(tag);
|
|
17671
|
+
wrapper.append(...element.childNodes);
|
|
17672
|
+
element.appendChild(wrapper);
|
|
17673
|
+
return result
|
|
17674
|
+
} else {
|
|
17675
|
+
return wrapWith(result, tag)
|
|
17676
|
+
}
|
|
17677
|
+
}
|
|
17678
|
+
|
|
15899
17679
|
function unwrapSpans(element) {
|
|
15900
17680
|
if (element.tagName === "SPAN") return element.firstChild
|
|
15901
17681
|
|
|
@@ -15906,6 +17686,22 @@ function unwrapSpans(element) {
|
|
|
15906
17686
|
return element
|
|
15907
17687
|
}
|
|
15908
17688
|
|
|
17689
|
+
function $preserveSpaces(element, textNode) {
|
|
17690
|
+
const domText = findTextNode(element);
|
|
17691
|
+
|
|
17692
|
+
if (domText) {
|
|
17693
|
+
domText.data = $encodeCollapsibleSpaces(domText.data, textNode);
|
|
17694
|
+
}
|
|
17695
|
+
}
|
|
17696
|
+
|
|
17697
|
+
function findTextNode(element) {
|
|
17698
|
+
if (element.nodeType === Node.TEXT_NODE) {
|
|
17699
|
+
return element
|
|
17700
|
+
} else {
|
|
17701
|
+
return document.createTreeWalker(element, NodeFilter.SHOW_TEXT).nextNode()
|
|
17702
|
+
}
|
|
17703
|
+
}
|
|
17704
|
+
|
|
15909
17705
|
class ProvisionalParagraphNode extends Zi {
|
|
15910
17706
|
$config() {
|
|
15911
17707
|
return this.config("provisional_paragraph", {
|
|
@@ -16139,8 +17935,6 @@ function buildMarkupPreservingTokenizer(editor) {
|
|
|
16139
17935
|
}
|
|
16140
17936
|
}
|
|
16141
17937
|
|
|
16142
|
-
const TRIX_LANGUAGE_ATTR = "language";
|
|
16143
|
-
|
|
16144
17938
|
class TrixContentExtension extends LexxyExtension {
|
|
16145
17939
|
|
|
16146
17940
|
get enabled() {
|
|
@@ -16189,12 +17983,11 @@ function $applyStrikethrough(textNode) {
|
|
|
16189
17983
|
}
|
|
16190
17984
|
|
|
16191
17985
|
function onlyPreLanguageElements(element, conversion) {
|
|
16192
|
-
return element.hasAttribute(
|
|
17986
|
+
return !element.hasAttribute("data-language") && importedCodeLanguage(element) ? conversion : null
|
|
16193
17987
|
}
|
|
16194
17988
|
|
|
16195
17989
|
function $applyLanguage(conversionOutput, element) {
|
|
16196
|
-
|
|
16197
|
-
conversionOutput.node.setLanguage(language);
|
|
17990
|
+
conversionOutput.node.setLanguage(importedCodeLanguage(element));
|
|
16198
17991
|
}
|
|
16199
17992
|
|
|
16200
17993
|
class WrappedTableNode extends vn {
|
|
@@ -17435,7 +19228,7 @@ class FormatEscapeExtension extends LexxyExtension {
|
|
|
17435
19228
|
return Cc(
|
|
17436
19229
|
editor.registerCommand(
|
|
17437
19230
|
he$3,
|
|
17438
|
-
() => $
|
|
19231
|
+
() => $handleInsertParagraph(),
|
|
17439
19232
|
so
|
|
17440
19233
|
),
|
|
17441
19234
|
editor.registerCommand(
|
|
@@ -17450,8 +19243,8 @@ class FormatEscapeExtension extends LexxyExtension {
|
|
|
17450
19243
|
}
|
|
17451
19244
|
}
|
|
17452
19245
|
|
|
17453
|
-
function $
|
|
17454
|
-
return $escapeBeforeBlockquoteStart() || $escapeFromBlankBlockquoteParagraph()
|
|
19246
|
+
function $handleInsertParagraph() {
|
|
19247
|
+
return $escapeBeforeBlockquoteStart() || $escapeFromBlankBlockquoteParagraph() || $insertUnformattedParagraphBefore()
|
|
17455
19248
|
}
|
|
17456
19249
|
|
|
17457
19250
|
function $escapeBeforeBlockquoteStart() {
|
|
@@ -17494,6 +19287,33 @@ function $escapeFromBlankBlockquoteParagraph() {
|
|
|
17494
19287
|
return false
|
|
17495
19288
|
}
|
|
17496
19289
|
|
|
19290
|
+
// Enter at the start of a paragraph leaves an empty line above it. Lexical keeps
|
|
19291
|
+
// the original paragraph there, with the text format its content had, so typing
|
|
19292
|
+
// on that line picks up the formatting of the text that moved down. Insert a
|
|
19293
|
+
// fresh paragraph instead, keeping only the block-level alignment and indent.
|
|
19294
|
+
function $insertUnformattedParagraphBefore() {
|
|
19295
|
+
const selection = Qr();
|
|
19296
|
+
if (!Fr(selection) || !selection.isCollapsed()) return false
|
|
19297
|
+
|
|
19298
|
+
const paragraph = At$2(selection.anchor.getNode(), Zi);
|
|
19299
|
+
if (!paragraph || $isBlankNode(paragraph) || !$isAtParagraphStart(selection.anchor, paragraph)) return false
|
|
19300
|
+
if (paragraph.getTextFormat() === 0 && paragraph.getTextStyle() === "") return false
|
|
19301
|
+
|
|
19302
|
+
const emptyParagraph = eo();
|
|
19303
|
+
emptyParagraph.setFormat(paragraph.getFormatType());
|
|
19304
|
+
emptyParagraph.setIndent(paragraph.getIndent());
|
|
19305
|
+
emptyParagraph.setDirection(paragraph.getDirection());
|
|
19306
|
+
paragraph.insertBefore(emptyParagraph);
|
|
19307
|
+
return true
|
|
19308
|
+
}
|
|
19309
|
+
|
|
19310
|
+
function $isAtParagraphStart(point, paragraph) {
|
|
19311
|
+
if (point.offset !== 0) return false
|
|
19312
|
+
|
|
19313
|
+
const node = point.getNode();
|
|
19314
|
+
return node.is(paragraph) || node.is(paragraph.getFirstDescendant())
|
|
19315
|
+
}
|
|
19316
|
+
|
|
17497
19317
|
function $splitQuoteNode(node, paragraph) {
|
|
17498
19318
|
const splitQuotes = Us(node, paragraph.getIndexWithinParent());
|
|
17499
19319
|
splitQuotes[0].insertAfter(paragraph);
|
|
@@ -17589,6 +19409,18 @@ function $openLink(target) {
|
|
|
17589
19409
|
}
|
|
17590
19410
|
}
|
|
17591
19411
|
|
|
19412
|
+
// Lexical's link extension merges adjacent links that share a URL, so linking a
|
|
19413
|
+
// selection that contains a link produces one link instead of fragments.
|
|
19414
|
+
class LinkMergingExtension extends LexxyExtension {
|
|
19415
|
+
get enabled() {
|
|
19416
|
+
return this.editorElement.supportsRichText
|
|
19417
|
+
}
|
|
19418
|
+
|
|
19419
|
+
get lexicalExtension() {
|
|
19420
|
+
return tt$3
|
|
19421
|
+
}
|
|
19422
|
+
}
|
|
19423
|
+
|
|
17592
19424
|
class PreventLexicalTripleClickExtension extends LexxyExtension {
|
|
17593
19425
|
get lexicalExtension() {
|
|
17594
19426
|
return dc({
|
|
@@ -18184,6 +20016,7 @@ class LexicalEditorElement extends HTMLElement {
|
|
|
18184
20016
|
AttachmentsExtension,
|
|
18185
20017
|
FormatEscapeExtension,
|
|
18186
20018
|
LinkOpenerExtension,
|
|
20019
|
+
LinkMergingExtension,
|
|
18187
20020
|
PreventLexicalTripleClickExtension,
|
|
18188
20021
|
CustomAttachmentDragAndDropExtension,
|
|
18189
20022
|
LineSeparatorsExtension
|
|
@@ -18233,7 +20066,9 @@ class LexicalEditorElement extends HTMLElement {
|
|
|
18233
20066
|
|
|
18234
20067
|
$generateNodesFromDOM(doc, { editor = this.editor } = {}) {
|
|
18235
20068
|
stripTrailingCodeBlockNewlines(doc);
|
|
20069
|
+
trimLinkAddresses(doc);
|
|
18236
20070
|
let nodes = dt$1(editor, doc);
|
|
20071
|
+
$decodeCollapsibleSpaces(nodes);
|
|
18237
20072
|
if (Es(jn)) nodes = $convertInlineImageDataURIs(nodes, this);
|
|
18238
20073
|
return $filterDisallowedCode(filterDisallowedAttachmentNodes(nodes, this), this)
|
|
18239
20074
|
}
|
|
@@ -18378,7 +20213,7 @@ class LexicalEditorElement extends HTMLElement {
|
|
|
18378
20213
|
|
|
18379
20214
|
#readSanitizedEditorValue() {
|
|
18380
20215
|
return this.editor?.read(() => {
|
|
18381
|
-
return withoutEmptyParagraph(this.sanitizer.sanitize(
|
|
20216
|
+
return withoutEmptyParagraph(this.sanitizer.sanitize($generateHtmlWithoutExportArtifacts(this.editor)))
|
|
18382
20217
|
}) ?? null
|
|
18383
20218
|
}
|
|
18384
20219
|
|
|
@@ -19006,13 +20841,29 @@ function $getReadableTextContent(node) {
|
|
|
19006
20841
|
// way Trix stores them. A <br> that ends a block renders nothing and is dropped
|
|
19007
20842
|
// on import, so without it a Shift+Enter at the end of an item would vanish from
|
|
19008
20843
|
// the rendered content and from the editor on reload.
|
|
19009
|
-
|
|
19010
|
-
|
|
20844
|
+
//
|
|
20845
|
+
// They're removed from the exported elements rather than from the HTML string,
|
|
20846
|
+
// where text that reads the same would go too.
|
|
20847
|
+
function $generateHtmlWithoutExportArtifacts(editor) {
|
|
20848
|
+
const container = at$1(document.createElement("div"), null, editor);
|
|
20849
|
+
|
|
20850
|
+
for (const element of container.querySelectorAll("[data-lexical-indent]")) {
|
|
20851
|
+
element.removeAttribute("data-lexical-indent");
|
|
20852
|
+
}
|
|
20853
|
+
|
|
20854
|
+
for (const lineBreak of container.querySelectorAll("br[data-lexical-managed-linebreak]")) {
|
|
20855
|
+
if (isLastChildOfListItem(lineBreak)) {
|
|
20856
|
+
lineBreak.removeAttribute("data-lexical-managed-linebreak");
|
|
20857
|
+
} else {
|
|
20858
|
+
lineBreak.remove();
|
|
20859
|
+
}
|
|
20860
|
+
}
|
|
20861
|
+
|
|
20862
|
+
return container.innerHTML
|
|
20863
|
+
}
|
|
19011
20864
|
|
|
19012
|
-
function
|
|
19013
|
-
return
|
|
19014
|
-
.replace(LIST_ITEM_MANAGED_LINE_BREAK, "<br></li>")
|
|
19015
|
-
.replace(LEXICAL_EXPORT_ARTIFACTS, "")
|
|
20865
|
+
function isLastChildOfListItem(node) {
|
|
20866
|
+
return node.parentElement?.tagName === "LI" && !node.nextSibling
|
|
19016
20867
|
}
|
|
19017
20868
|
|
|
19018
20869
|
// An empty editor still holds one paragraph, so there is somewhere to type and
|
|
@@ -19336,6 +21187,11 @@ class LexicalPromptElement extends HTMLElement {
|
|
|
19336
21187
|
if (!this.#promptContentTypePermitted) return
|
|
19337
21188
|
|
|
19338
21189
|
this.#popoverListeners.track(this.#editor.registerUpdateListener(({ editorState }) => {
|
|
21190
|
+
// A value set while focus is elsewhere, such as a restored draft that ends in
|
|
21191
|
+
// the trigger, leaves no cursor to anchor the menu to: it opened at a
|
|
21192
|
+
// meaningless spot and stayed there once the user came back to the editor.
|
|
21193
|
+
if (!isEditorFocused(this.#editor)) return
|
|
21194
|
+
|
|
19339
21195
|
editorState.read(() => {
|
|
19340
21196
|
if (this.#selection.isInsideCodeBlock) return
|
|
19341
21197
|
|
|
@@ -20271,8 +22127,8 @@ class AttachmentToolbar extends HTMLElement {
|
|
|
20271
22127
|
this.#alternativeTextButton = createElement("button", {
|
|
20272
22128
|
type: "button",
|
|
20273
22129
|
className: "lexxy-attachment-toolbar__alternative-text",
|
|
20274
|
-
ariaLabel: "
|
|
20275
|
-
title: "
|
|
22130
|
+
ariaLabel: "Alt text",
|
|
22131
|
+
title: "Alt text",
|
|
20276
22132
|
ariaHasPopup: "dialog",
|
|
20277
22133
|
tabIndex: -1
|
|
20278
22134
|
});
|
|
@@ -20929,7 +22785,10 @@ class TableTools extends HTMLElement {
|
|
|
20929
22785
|
this.appendChild(this.#createColumnButtonsContainer());
|
|
20930
22786
|
|
|
20931
22787
|
this.appendChild(this.#createDeleteTableButton());
|
|
20932
|
-
this.#listeners.track(
|
|
22788
|
+
this.#listeners.track(
|
|
22789
|
+
registerEventListener(this, "keydown", this.#handleToolsKeydown),
|
|
22790
|
+
registerEventListener(this, "focusout", () => this.#handleCommandButtonHover())
|
|
22791
|
+
);
|
|
20933
22792
|
}
|
|
20934
22793
|
|
|
20935
22794
|
#createButtonsContainer(childType, setCountProperty, moreMenu) {
|
|
@@ -21032,7 +22891,7 @@ class TableTools extends HTMLElement {
|
|
|
21032
22891
|
button.addEventListener("click", () => this.#executeTableCommand(command));
|
|
21033
22892
|
|
|
21034
22893
|
button.addEventListener("mouseover", () => this.#handleCommandButtonHover());
|
|
21035
|
-
button.addEventListener("focus", () => this.#handleCommandButtonHover());
|
|
22894
|
+
button.addEventListener("focus", () => this.#handleCommandButtonHover(button));
|
|
21036
22895
|
button.addEventListener("mouseout", () => this.#handleCommandButtonHover());
|
|
21037
22896
|
|
|
21038
22897
|
return button
|
|
@@ -21078,12 +22937,18 @@ class TableTools extends HTMLElement {
|
|
|
21078
22937
|
this.#update();
|
|
21079
22938
|
}
|
|
21080
22939
|
|
|
21081
|
-
async #handleCommandButtonHover() {
|
|
22940
|
+
async #handleCommandButtonHover(focusedButton) {
|
|
21082
22941
|
await nextFrame();
|
|
21083
22942
|
|
|
21084
22943
|
this.#clearCellStyles();
|
|
21085
22944
|
|
|
21086
|
-
|
|
22945
|
+
let activeElement;
|
|
22946
|
+
if (focusedButton?.matches(":focus")) {
|
|
22947
|
+
activeElement = focusedButton;
|
|
22948
|
+
} else {
|
|
22949
|
+
activeElement = this.querySelector("button[data-action]:hover") ||
|
|
22950
|
+
this.querySelector("button[data-action]:focus");
|
|
22951
|
+
}
|
|
21087
22952
|
if (!activeElement) return
|
|
21088
22953
|
|
|
21089
22954
|
const command = {
|