All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.esm.index.js Maven / Gradle / Ivy

/**
 * @toast-ui/editor
 * @version 3.2.0 | Fri Aug 05 2022
 * @author NHN Cloud FE Development Lab 
 * @license MIT
 */

import { Fragment, Schema, Slice, NodeRange, Mark as Mark$1, DOMParser, Node as Node$3 } from 'prosemirror-model';
import { DecorationSet, Decoration, EditorView } from 'prosemirror-view';
import { ReplaceAroundStep, liftTarget, canSplit, StepMap } from 'prosemirror-transform';
import { TextSelection, Plugin, PluginKey, EditorState, AllSelection, Selection, SelectionRange, NodeSelection } from 'prosemirror-state';
import { keymap } from 'prosemirror-keymap';
import { deleteSelection, selectAll, baseKeymap, chainCommands, joinForward, newlineInCode, setBlockType, wrapIn, toggleMark as toggleMark$1, exitCode } from 'prosemirror-commands';
import { InputRule, inputRules, undoInputRule } from 'prosemirror-inputrules';
import { undo, redo, history, undoDepth } from 'prosemirror-history';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */

var extendStatics$1 = function(d, b) {
    extendStatics$1 = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
    return extendStatics$1(d, b);
};

function __extends$1(d, b) {
    if (typeof b !== "function" && b !== null)
        throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
    extendStatics$1(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

var __assign$1 = function() {
    __assign$1 = Object.assign || function __assign(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
        }
        return t;
    };
    return __assign$1.apply(this, arguments);
};

function __spreadArray$1(to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
}

function __makeTemplateObject(cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
}

/**
 * @fileoverview Execute the provided callback once for each property of object which actually exist.
 * @author NHN FE Development Lab 
 */

/**
 * Execute the provided callback once for each property of object which actually exist.
 * If the callback function returns false, the loop will be stopped.
 * Callback function(iteratee) is invoked with three arguments:
 *  1) The value of the property
 *  2) The name of the property
 *  3) The object being traversed
 * @param {Object} obj The object that will be traversed
 * @param {function} iteratee  Callback function
 * @param {Object} [context] Context(this) of callback function
 * @memberof module:collection
 * @example
 * // ES6
 * import forEachOwnProperties from 'tui-code-snippet/collection/forEachOwnProperties';
 * 
 * // CommonJS
 * const forEachOwnProperties = require('tui-code-snippet/collection/forEachOwnProperties'); 
 *
 * let sum = 0;
 *
 * forEachOwnProperties({a:1,b:2,c:3}, function(value){
 *   sum += value;
 * });
 * alert(sum); // 6
 */
function forEachOwnProperties$2(obj, iteratee, context) {
  var key;

  context = context || null;

  for (key in obj) {
    if (obj.hasOwnProperty(key)) {
      if (iteratee.call(context, obj[key], key, obj) === false) {
        break;
      }
    }
  }
}

var forEachOwnProperties_1 = forEachOwnProperties$2;

/**
 * @fileoverview Extend the target object from other objects.
 * @author NHN FE Development Lab 
 */

/**
 * @module object
 */

/**
 * Extend the target object from other objects.
 * @param {object} target - Object that will be extended
 * @param {...object} objects - Objects as sources
 * @returns {object} Extended object
 * @memberof module:object
 */
function extend(target, objects) { // eslint-disable-line no-unused-vars
  var hasOwnProp = Object.prototype.hasOwnProperty;
  var source, prop, i, len;

  for (i = 1, len = arguments.length; i < len; i += 1) {
    source = arguments[i];
    for (prop in source) {
      if (hasOwnProp.call(source, prop)) {
        target[prop] = source[prop];
      }
    }
  }

  return target;
}

var extend_1 = extend;

/**
 * @fileoverview Check whether the given variable is a string or not.
 * @author NHN FE Development Lab 
 */

/**
 * Check whether the given variable is a string or not.
 * If the given variable is a string, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is string?
 * @memberof module:type
 */
function isString$3(obj) {
  return typeof obj === 'string' || obj instanceof String;
}

var isString_1 = isString$3;

/**
 * @fileoverview Check whether the given variable is an instance of Array or not.
 * @author NHN FE Development Lab 
 */

/**
 * Check whether the given variable is an instance of Array or not.
 * If the given variable is an instance of Array, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is array instance?
 * @memberof module:type
 */
function isArray$3(obj) {
  return obj instanceof Array;
}

var isArray_1 = isArray$3;

/**
 * @fileoverview Execute the provided callback once for each element present in the array(or Array-like object) in ascending order.
 * @author NHN FE Development Lab 
 */

/**
 * Execute the provided callback once for each element present
 * in the array(or Array-like object) in ascending order.
 * If the callback function returns false, the loop will be stopped.
 * Callback function(iteratee) is invoked with three arguments:
 *  1) The value of the element
 *  2) The index of the element
 *  3) The array(or Array-like object) being traversed
 * @param {Array|Arguments|NodeList} arr The array(or Array-like object) that will be traversed
 * @param {function} iteratee Callback function
 * @param {Object} [context] Context(this) of callback function
 * @memberof module:collection
 * @example
 * // ES6
 * import forEachArray from 'tui-code-snippet/collection/forEachArray';
 * 
 * // CommonJS
 * const forEachArray = require('tui-code-snippet/collection/forEachArray'); 
 *
 * let sum = 0;
 *
 * forEachArray([1,2,3], function(value){
 *   sum += value;
 * });
 * alert(sum); // 6
 */
function forEachArray$3(arr, iteratee, context) {
  var index = 0;
  var len = arr.length;

  context = context || null;

  for (; index < len; index += 1) {
    if (iteratee.call(context, arr[index], index, arr) === false) {
      break;
    }
  }
}

var forEachArray_1 = forEachArray$3;

/**
 * @fileoverview Execute the provided callback once for each property of object(or element of array) which actually exist.
 * @author NHN FE Development Lab 
 */

var isArray$2 = isArray_1;
var forEachArray$2 = forEachArray_1;
var forEachOwnProperties$1 = forEachOwnProperties_1;

/**
 * @module collection
 */

/**
 * Execute the provided callback once for each property of object(or element of array) which actually exist.
 * If the object is Array-like object(ex-arguments object), It needs to transform to Array.(see 'ex2' of example).
 * If the callback function returns false, the loop will be stopped.
 * Callback function(iteratee) is invoked with three arguments:
 *  1) The value of the property(or The value of the element)
 *  2) The name of the property(or The index of the element)
 *  3) The object being traversed
 * @param {Object} obj The object that will be traversed
 * @param {function} iteratee Callback function
 * @param {Object} [context] Context(this) of callback function
 * @memberof module:collection
 * @example
 * // ES6
 * import forEach from 'tui-code-snippet/collection/forEach'; 
 * 
 * // CommonJS
 * const forEach = require('tui-code-snippet/collection/forEach'); 
 *
 * let sum = 0;
 *
 * forEach([1,2,3], function(value){
 *   sum += value;
 * });
 * alert(sum); // 6
 *
 * // In case of Array-like object
 * const array = Array.prototype.slice.call(arrayLike); // change to array
 * forEach(array, function(value){
 *   sum += value;
 * });
 */
function forEach$4(obj, iteratee, context) {
  if (isArray$2(obj)) {
    forEachArray$2(obj, iteratee, context);
  } else {
    forEachOwnProperties$1(obj, iteratee, context);
  }
}

var forEach_1 = forEach$4;

/**
 * @fileoverview Setting element style
 * @author NHN FE Development Lab 
 */

var isString$2 = isString_1;
var forEach$3 = forEach_1;

/**
 * Setting element style
 * @param {(HTMLElement|SVGElement)} element - element to setting style
 * @param {(string|object)} key - style prop name or {prop: value} pair object
 * @param {string} [value] - style value
 * @memberof module:domUtil
 */
function css(element, key, value) {
  var style = element.style;

  if (isString$2(key)) {
    style[key] = value;

    return;
  }

  forEach$3(key, function(v, k) {
    style[k] = v;
  });
}

var css_1 = css;

/* eslint-disable complexity */

var isArray$1 = isArray_1;

/**
 * @module array
 */

/**
 * Returns the first index at which a given element can be found in the array
 * from start index(default 0), or -1 if it is not present.
 * It compares searchElement to elements of the Array using strict equality
 * (the same method used by the ===, or triple-equals, operator).
 * @param {*} searchElement Element to locate in the array
 * @param {Array} array Array that will be traversed.
 * @param {number} startIndex Start index in array for searching (default 0)
 * @returns {number} the First index at which a given element, or -1 if it is not present
 * @memberof module:array
 * @example
 * // ES6
 * import inArray from 'tui-code-snippet/array/inArray';
 * 
 * // CommonJS
 * const inArray = require('tui-code-snippet/array/inArray');
 *
 * const arr = ['one', 'two', 'three', 'four'];
 * const idx1 = inArray('one', arr, 3); // -1
 * const idx2 = inArray('one', arr); // 0
 */
function inArray$4(searchElement, array, startIndex) {
  var i;
  var length;
  startIndex = startIndex || 0;

  if (!isArray$1(array)) {
    return -1;
  }

  if (Array.prototype.indexOf) {
    return Array.prototype.indexOf.call(array, searchElement, startIndex);
  }

  length = array.length;
  for (i = startIndex; startIndex >= 0 && i < length; i += 1) {
    if (array[i] === searchElement) {
      return i;
    }
  }

  return -1;
}

var inArray_1 = inArray$4;

/**
 * @fileoverview Check whether the given variable is undefined or not.
 * @author NHN FE Development Lab 
 */

/**
 * Check whether the given variable is undefined or not.
 * If the given variable is undefined, returns true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is undefined?
 * @memberof module:type
 */
function isUndefined$4(obj) {
  return obj === undefined; // eslint-disable-line no-undefined
}

var isUndefined_1 = isUndefined$4;

/**
 * @fileoverview Get HTML element's design classes.
 * @author NHN FE Development Lab 
 */

var isUndefined$3 = isUndefined_1;

/**
 * Get HTML element's design classes.
 * @param {(HTMLElement|SVGElement)} element target element
 * @returns {string} element css class name
 * @memberof module:domUtil
 */
function getClass$3(element) {
  if (!element || !element.className) {
    return '';
  }

  if (isUndefined$3(element.className.baseVal)) {
    return element.className;
  }

  return element.className.baseVal;
}

var getClass_1 = getClass$3;

/**
 * @fileoverview Set className value
 * @author NHN FE Development Lab 
 */

var isArray = isArray_1;
var isUndefined$2 = isUndefined_1;

/**
 * Set className value
 * @param {(HTMLElement|SVGElement)} element - target element
 * @param {(string|string[])} cssClass - class names
 * @private
 */
function setClassName$2(element, cssClass) {
  cssClass = isArray(cssClass) ? cssClass.join(' ') : cssClass;

  cssClass = cssClass.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');

  if (isUndefined$2(element.className.baseVal)) {
    element.className = cssClass;

    return;
  }

  element.className.baseVal = cssClass;
}

var _setClassName = setClassName$2;

/**
 * @fileoverview Add css class to element
 * @author NHN FE Development Lab 
 */

var forEach$2 = forEach_1;
var inArray$3 = inArray_1;
var getClass$2 = getClass_1;
var setClassName$1 = _setClassName;

/**
 * domUtil module
 * @module domUtil
 */

/**
 * Add css class to element
 * @param {(HTMLElement|SVGElement)} element - target element
 * @param {...string} cssClass - css classes to add
 * @memberof module:domUtil
 */
function addClass(element) {
  var cssClass = Array.prototype.slice.call(arguments, 1);
  var classList = element.classList;
  var newClass = [];
  var origin;

  if (classList) {
    forEach$2(cssClass, function(name) {
      element.classList.add(name);
    });

    return;
  }

  origin = getClass$2(element);

  if (origin) {
    cssClass = [].concat(origin.split(/\s+/), cssClass);
  }

  forEach$2(cssClass, function(cls) {
    if (inArray$3(cls, newClass) < 0) {
      newClass.push(cls);
    }
  });

  setClassName$1(element, newClass);
}

var addClass_1 = addClass;

/**
 * @fileoverview Remove css class from element
 * @author NHN FE Development Lab 
 */

var forEachArray$1 = forEachArray_1;
var inArray$2 = inArray_1;
var getClass$1 = getClass_1;
var setClassName = _setClassName;

/**
 * Remove css class from element
 * @param {(HTMLElement|SVGElement)} element - target element
 * @param {...string} cssClass - css classes to remove
 * @memberof module:domUtil
 */
function removeClass(element) {
  var cssClass = Array.prototype.slice.call(arguments, 1);
  var classList = element.classList;
  var origin, newClass;

  if (classList) {
    forEachArray$1(cssClass, function(name) {
      classList.remove(name);
    });

    return;
  }

  origin = getClass$1(element).split(/\s+/);
  newClass = [];
  forEachArray$1(origin, function(name) {
    if (inArray$2(name, cssClass) < 0) {
      newClass.push(name);
    }
  });

  setClassName(element, newClass);
}

var removeClass_1 = removeClass;

/**
 * @fileoverview Check whether the given variable is a number or not.
 * @author NHN FE Development Lab 
 */

/**
 * Check whether the given variable is a number or not.
 * If the given variable is a number, return true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is number?
 * @memberof module:type
 */
function isNumber(obj) {
  return typeof obj === 'number' || obj instanceof Number;
}

var isNumber_1 = isNumber;

/**
 * @fileoverview Check whether the given variable is null or not.
 * @author NHN FE Development Lab 
 */

/**
 * Check whether the given variable is null or not.
 * If the given variable(arguments[0]) is null, returns true.
 * @param {*} obj - Target for checking
 * @returns {boolean} Is null?
 * @memberof module:type
 */
function isNull$1(obj) {
  return obj === null;
}

var isNull_1 = isNull$1;

/**
 * @fileoverview Request image ping.
 * @author NHN FE Development Lab 
 */

var forEachOwnProperties = forEachOwnProperties_1;

/**
 * @module request
 */

/**
 * Request image ping.
 * @param {String} url url for ping request
 * @param {Object} trackingInfo infos for make query string
 * @returns {HTMLElement}
 * @memberof module:request
 * @example
 * // ES6
 * import imagePing from 'tui-code-snippet/request/imagePing';
 * 
 * // CommonJS
 * const imagePing = require('tui-code-snippet/request/imagePing');
 *
 * imagePing('https://www.google-analytics.com/collect', {
 *   v: 1,
 *   t: 'event',
 *   tid: 'trackingid',
 *   cid: 'cid',
 *   dp: 'dp',
 *   dh: 'dh'
 * });
 */
function imagePing$1(url, trackingInfo) {
  var trackingElement = document.createElement('img');
  var queryString = '';
  forEachOwnProperties(trackingInfo, function(value, key) {
    queryString += '&' + key + '=' + value;
  });
  queryString = queryString.substring(1);

  trackingElement.src = url + '?' + queryString;

  trackingElement.style.display = 'none';
  document.body.appendChild(trackingElement);
  document.body.removeChild(trackingElement);

  return trackingElement;
}

var imagePing_1 = imagePing$1;

/**
 * @fileoverview Send hostname on DOMContentLoaded.
 * @author NHN FE Development Lab 
 */

var isUndefined$1 = isUndefined_1;
var imagePing = imagePing_1;

var ms7days = 7 * 24 * 60 * 60 * 1000;

/**
 * Check if the date has passed 7 days
 * @param {number} date - milliseconds
 * @returns {boolean}
 * @private
 */
function isExpired(date) {
  var now = new Date().getTime();

  return now - date > ms7days;
}

/**
 * Send hostname on DOMContentLoaded.
 * To prevent hostname set tui.usageStatistics to false.
 * @param {string} appName - application name
 * @param {string} trackingId - GA tracking ID
 * @ignore
 */
function sendHostname(appName, trackingId) {
  var url = 'https://www.google-analytics.com/collect';
  var hostname = location.hostname;
  var hitType = 'event';
  var eventCategory = 'use';
  var applicationKeyForStorage = 'TOAST UI ' + appName + ' for ' + hostname + ': Statistics';
  var date = window.localStorage.getItem(applicationKeyForStorage);

  // skip if the flag is defined and is set to false explicitly
  if (!isUndefined$1(window.tui) && window.tui.usageStatistics === false) {
    return;
  }

  // skip if not pass seven days old
  if (date && !isExpired(date)) {
    return;
  }

  window.localStorage.setItem(applicationKeyForStorage, new Date().getTime());

  setTimeout(function() {
    if (document.readyState === 'interactive' || document.readyState === 'complete') {
      imagePing(url, {
        v: 1,
        t: hitType,
        tid: trackingId,
        cid: hostname,
        dp: hostname,
        dh: appName,
        el: appName,
        ec: eventCategory
      });
    }
  }, 1000);
}

var sendHostname_1 = sendHostname;

/Mac/.test(navigator.platform);
var reSpaceMoreThanOne = /[\u0020]+/g;
var reEscapeChars$1 = /[>(){}[\]+-.!#|]/g;
var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\>])*\/?>|<(\/)([a-zA-Z_][a-zA-Z0-9\-._]*)\s*\/?>||<([a-zA-Z_][a-zA-Z0-9\-.:/]*)>/g;
var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
var reEscapePairedChars = /[*_~`]/g;
var reMdImageSyntax = /!\[.*\]\(.*\)/g;
var reEscapedCharInLinkSyntax = /[[\]]/g;
var reEscapeBackSlashInSentence = /(?:^|[^\\])\\(?!\\)/g;
var XMLSPECIAL$1 = '[&<>"]';
var reXmlSpecial$1 = new RegExp(XMLSPECIAL$1, 'g');
function replaceUnsafeChar$1(char) {
    switch (char) {
        case '&':
            return '&';
        case '<':
            return '<';
        case '>':
            return '>';
        case '"':
            return '"';
        default:
            return char;
    }
}
function escapeXml$1(text) {
    if (reXmlSpecial$1.test(text)) {
        return text.replace(reXmlSpecial$1, replaceUnsafeChar$1);
    }
    return text;
}
function sendHostName() {
    sendHostname_1('editor', 'UA-129966929-1');
}
function includes(arr, targetItem) {
    return arr.indexOf(targetItem) !== -1;
}
var availableLinkAttributes = ['rel', 'target', 'hreflang', 'type'];
var reMarkdownTextToEscapeMap = {
    codeblock: /(^ {4}[^\n]+\n*)+/,
    thematicBreak: /^ *((\* *){3,}|(- *){3,} *|(_ *){3,}) */,
    atxHeading: /^(#{1,6}) +[\s\S]+/,
    seTextheading: /^([^\n]+)\n *(=|-){2,} */,
    blockquote: /^( *>[^\n]+.*)+/,
    list: /^ *(\*+|-+|\d+\.) [\s\S]+/,
    def: /^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? */,
    link: /!?\[.*\]\(.*\)/,
    reflink: /!?\[.*\]\s*\[([^\]]*)\]/,
    verticalBar: /\u007C/,
    fencedCodeblock: /^((`|~){3,})/,
};
function sanitizeLinkAttribute(attribute) {
    if (!attribute) {
        return null;
    }
    var linkAttributes = {};
    availableLinkAttributes.forEach(function (key) {
        if (!isUndefined_1(attribute[key])) {
            linkAttributes[key] = attribute[key];
        }
    });
    return linkAttributes;
}
function repeat$1(text, count) {
    var result = '';
    for (var i = 0; i < count; i += 1) {
        result += text;
    }
    return result;
}
function isNeedEscapeText(text) {
    var needEscape = false;
    forEachOwnProperties_1(reMarkdownTextToEscapeMap, function (reMarkdownTextToEscape) {
        if (reMarkdownTextToEscape.test(text)) {
            needEscape = true;
        }
        return !needEscape;
    });
    return needEscape;
}
function escapeTextForLink(text) {
    var imageSyntaxRanges = [];
    var result = reMdImageSyntax.exec(text);
    while (result) {
        imageSyntaxRanges.push([result.index, result.index + result[0].length]);
        result = reMdImageSyntax.exec(text);
    }
    return text.replace(reEscapedCharInLinkSyntax, function (matched, offset) {
        var isDelimiter = imageSyntaxRanges.some(function (range) { return offset > range[0] && offset < range[1]; });
        return isDelimiter ? matched : "\\" + matched;
    });
}
function escape$1(text) {
    var aheadReplacer = function (matched) { return "\\" + matched; };
    var behindReplacer = function (matched) { return matched + "\\"; };
    var escapedText = text.replace(reSpaceMoreThanOne, ' ');
    if (reEscapeBackSlash.test(escapedText)) {
        escapedText = escapedText.replace(reEscapeBackSlash, aheadReplacer);
    }
    if (reEscapeBackSlashInSentence.test(escapedText)) {
        escapedText = escapedText.replace(reEscapeBackSlashInSentence, behindReplacer);
    }
    escapedText = escapedText.replace(reEscapePairedChars, aheadReplacer);
    if (reEscapeHTML.test(escapedText)) {
        escapedText = escapedText.replace(reEscapeHTML, aheadReplacer);
    }
    if (isNeedEscapeText(escapedText)) {
        escapedText = escapedText.replace(reEscapeChars$1, aheadReplacer);
    }
    return escapedText;
}
function quote(text) {
    var result;
    if (text.indexOf('"') === -1) {
        result = '""';
    }
    else {
        result = text.indexOf("'") === -1 ? "''" : '()';
    }
    return result[0] + text + result[1];
}
function isNil(value) {
    return isNull_1(value) || isUndefined_1(value);
}
function shallowEqual(o1, o2) {
    if (o1 === null && o1 === o2) {
        return true;
    }
    if (typeof o1 !== 'object' || typeof o2 !== 'object' || isNil(o1) || isNil(o2)) {
        return o1 === o2;
    }
    for (var key in o1) {
        if (o1[key] !== o2[key]) {
            return false;
        }
    }
    for (var key in o2) {
        if (!(key in o1)) {
            return false;
        }
    }
    return true;
}
function last$1(arr) {
    return arr[arr.length - 1];
}
function between$1(value, min, max) {
    return value >= min && value <= max;
}
function isObject$1(obj) {
    return typeof obj === 'object' && obj !== null;
}
function deepMergedCopy(targetObj, obj) {
    var resultObj = __assign$1({}, targetObj);
    if (targetObj && obj) {
        Object.keys(obj).forEach(function (prop) {
            if (isObject$1(resultObj[prop])) {
                if (Array.isArray(obj[prop])) {
                    resultObj[prop] = deepCopyArray(obj[prop]);
                }
                else if (resultObj.hasOwnProperty(prop)) {
                    resultObj[prop] = deepMergedCopy(resultObj[prop], obj[prop]);
                }
                else {
                    resultObj[prop] = deepCopy(obj[prop]);
                }
            }
            else {
                resultObj[prop] = obj[prop];
            }
        });
    }
    return resultObj;
}
function deepCopyArray(items) {
    return items.map(function (item) {
        if (isObject$1(item)) {
            return Array.isArray(item) ? deepCopyArray(item) : deepCopy(item);
        }
        return item;
    });
}
function deepCopy(obj) {
    var keys = Object.keys(obj);
    if (!keys.length) {
        return obj;
    }
    return keys.reduce(function (acc, prop) {
        if (isObject$1(obj[prop])) {
            acc[prop] = Array.isArray(obj[prop]) ? deepCopyArray(obj[prop]) : deepCopy(obj[prop]);
        }
        else {
            acc[prop] = obj[prop];
        }
        return acc;
    }, {});
}
function assign(targetObj, obj) {
    if (obj === void 0) { obj = {}; }
    Object.keys(obj).forEach(function (prop) {
        if (targetObj.hasOwnProperty(prop) && typeof targetObj[prop] === 'object') {
            if (Array.isArray(obj[prop])) {
                targetObj[prop] = obj[prop];
            }
            else {
                assign(targetObj[prop], obj[prop]);
            }
        }
        else {
            targetObj[prop] = obj[prop];
        }
    });
    return targetObj;
}
function getSortedNumPair(valueA, valueB) {
    return valueA > valueB ? [valueB, valueA] : [valueA, valueB];
}
function isStartWithSpace(text) {
    var reStartWithSpace = /^\s(\S*)/g;
    return reStartWithSpace.test(text);
}
function isEndWithSpace(text) {
    var reEndWithSpace = /(\S*)\s$/g;
    return reEndWithSpace.test(text);
}

/**
 * @fileoverview Transform the Array-like object to Array.
 * @author NHN FE Development Lab 
 */

var forEachArray = forEachArray_1;

/**
 * Transform the Array-like object to Array.
 * In low IE (below 8), Array.prototype.slice.call is not perfect. So, try-catch statement is used.
 * @param {*} arrayLike Array-like object
 * @returns {Array} Array
 * @memberof module:collection
 * @example
 * // ES6
 * import toArray from 'tui-code-snippet/collection/toArray'; 
 * 
 * // CommonJS
 * const toArray = require('tui-code-snippet/collection/toArray'); 
 *
 * const arrayLike = {
 *   0: 'one',
 *   1: 'two',
 *   2: 'three',
 *   3: 'four',
 *   length: 4
 * };
 * const result = toArray(arrayLike);
 *
 * alert(result instanceof Array); // true
 * alert(result); // one,two,three,four
 */
function toArray$1(arrayLike) {
  var arr;
  try {
    arr = Array.prototype.slice.call(arrayLike);
  } catch (e) {
    arr = [];
    forEachArray(arrayLike, function(value) {
      arr.push(value);
    });
  }

  return arr;
}

var toArray_1 = toArray$1;

function createParagraph(schema, content) {
    var paragraph = schema.nodes.paragraph;
    if (!content) {
        return paragraph.createAndFill();
    }
    return paragraph.create(null, isString_1(content) ? schema.text(content) : content);
}
function createTextNode$1(schema, text, marks) {
    return schema.text(text, marks);
}
function createTextSelection(tr, from, to) {
    if (to === void 0) { to = from; }
    var contentSize = tr.doc.content.size;
    var size = contentSize > 0 ? contentSize - 1 : 1;
    return TextSelection.create(tr.doc, Math.min(from, size), Math.min(to, size));
}
function addParagraph(tr, _a, schema) {
    var pos = _a.pos;
    tr.replaceWith(pos, pos, createParagraph(schema));
    return tr.setSelection(createTextSelection(tr, pos + 1));
}
function replaceTextNode(_a) {
    var state = _a.state, from = _a.from, startIndex = _a.startIndex, endIndex = _a.endIndex, createText = _a.createText;
    var tr = state.tr, doc = state.doc, schema = state.schema;
    for (var i = startIndex; i <= endIndex; i += 1) {
        var _b = doc.child(i), nodeSize = _b.nodeSize, textContent = _b.textContent, content = _b.content;
        var text = createText(textContent);
        var node = text ? createTextNode$1(schema, text) : Fragment.empty;
        var mappedFrom = tr.mapping.map(from);
        var mappedTo = mappedFrom + content.size;
        tr.replaceWith(mappedFrom, mappedTo, node);
        from += nodeSize;
    }
    return tr;
}
function splitAndExtendBlock(tr, pos, text, node) {
    var textLen = text.length;
    tr.split(pos)
        .delete(pos - textLen, pos)
        .insert(tr.mapping.map(pos), node)
        .setSelection(createTextSelection(tr, tr.mapping.map(pos) - textLen));
}

function getMdStartLine(mdNode) {
    return mdNode.sourcepos[0][0];
}
function getMdEndLine(mdNode) {
    return mdNode.sourcepos[1][0];
}
function getMdStartCh(mdNode) {
    return mdNode.sourcepos[0][1];
}
function getMdEndCh(mdNode) {
    return mdNode.sourcepos[1][1];
}
function isHTMLNode(mdNode) {
    var type = mdNode.type;
    return type === 'htmlBlock' || type === 'htmlInline';
}
function isStyledInlineNode(mdNode) {
    var type = mdNode.type;
    return (type === 'strike' ||
        type === 'strong' ||
        type === 'emph' ||
        type === 'code' ||
        type === 'link' ||
        type === 'image');
}
function isCodeBlockNode(mdNode) {
    return mdNode && mdNode.type === 'codeBlock';
}
function isListNode$1(mdNode) {
    return mdNode && (mdNode.type === 'item' || mdNode.type === 'list');
}
function isOrderedListNode(mdNode) {
    return isListNode$1(mdNode) && mdNode.listData.type === 'ordered';
}
function isBulletListNode(mdNode) {
    return isListNode$1(mdNode) && mdNode.listData.type !== 'ordered';
}
function isTableCellNode(mdNode) {
    return mdNode && (mdNode.type === 'tableCell' || mdNode.type === 'tableDelimCell');
}
function isInlineNode$1(mdNode) {
    switch (mdNode.type) {
        case 'code':
        case 'text':
        case 'emph':
        case 'strong':
        case 'strike':
        case 'link':
        case 'image':
        case 'htmlInline':
        case 'linebreak':
        case 'softbreak':
        case 'customInline':
            return true;
        default:
            return false;
    }
}
function findClosestNode(mdNode, condition, includeSelf) {
    if (includeSelf === void 0) { includeSelf = true; }
    mdNode = includeSelf ? mdNode : mdNode.parent;
    while (mdNode && mdNode.type !== 'document') {
        if (condition(mdNode)) {
            return mdNode;
        }
        mdNode = mdNode.parent;
    }
    return null;
}
function traverseParentNodes(mdNode, iteratee, includeSelf) {
    if (includeSelf === void 0) { includeSelf = true; }
    mdNode = includeSelf ? mdNode : mdNode.parent;
    while (mdNode && mdNode.type !== 'document') {
        iteratee(mdNode);
        mdNode = mdNode.parent;
    }
}
function addOffsetPos(originPos, offset) {
    return [originPos[0], originPos[1] + offset];
}
function setOffsetPos(originPos, newOffset) {
    return [originPos[0], newOffset];
}
function getInlineMarkdownText(mdNode) {
    var text = mdNode.firstChild.literal;
    switch (mdNode.type) {
        case 'emph':
            return "*" + text + "*";
        case 'strong':
            return "**" + text + "**";
        case 'strike':
            return "~~" + text + "~~";
        case 'code':
            return "`" + text + "`";
        case 'link':
        case 'image':
            /* eslint-disable no-case-declarations */
            var _a = mdNode, destination = _a.destination, title = _a.title;
            var delim = mdNode.type === 'link' ? '' : '!';
            return delim + "[" + text + "](" + destination + (title ? " \"" + title + "\"" : '') + ")";
        default:
            return null;
    }
}
function isContainer$2(node) {
    switch (node.type) {
        case 'document':
        case 'blockQuote':
        case 'list':
        case 'item':
        case 'paragraph':
        case 'heading':
        case 'emph':
        case 'strong':
        case 'strike':
        case 'link':
        case 'image':
        case 'table':
        case 'tableHead':
        case 'tableBody':
        case 'tableRow':
        case 'tableCell':
        case 'tableDelimRow':
        case 'customInline':
            return true;
        default:
            return false;
    }
}
function getChildrenText$1(node) {
    var buffer = [];
    var walker = node.walker();
    var event = null;
    while ((event = walker.next())) {
        var childNode = event.node;
        if (childNode.type === 'text') {
            buffer.push(childNode.literal);
        }
    }
    return buffer.join('');
}

var widgetRules = [];
var widgetRuleMap = {};
var reWidgetPrefix = /\$\$widget\d+\s/;
function unwrapWidgetSyntax(text) {
    var index = text.search(reWidgetPrefix);
    if (index !== -1) {
        var rest = text.substring(index);
        var replaced = rest.replace(reWidgetPrefix, '').replace('$$', '');
        text = text.substring(0, index);
        text += unwrapWidgetSyntax(replaced);
    }
    return text;
}
function createWidgetContent(info, text) {
    return "$$" + info + " " + text + "$$";
}
function widgetToDOM(info, text) {
    var _a = widgetRuleMap[info], rule = _a.rule, toDOM = _a.toDOM;
    var matches = unwrapWidgetSyntax(text).match(rule);
    if (matches) {
        text = matches[0];
    }
    return toDOM(text);
}
function getWidgetRules() {
    return widgetRules;
}
function setWidgetRules(rules) {
    widgetRules = rules;
    widgetRules.forEach(function (rule, index) {
        widgetRuleMap["widget" + index] = rule;
    });
}
function mergeNodes(nodes, text, schema, ruleIndex) {
    return nodes.concat(createNodesWithWidget(text, schema, ruleIndex));
}
/**
 * create nodes with plain text and replace text matched to the widget rules with the widget node
 * For example, in case the text and widget rules as below
 *
 * text: $test plain text #test
 * widget rules: [{ rule: /$.+/ }, { rule: /#.+/ }]
 *
 * The creating node process is recursive and is as follows.
 *
 * in first widget rule(/$.+/)
 *  $test -> widget node
 *  plain text -> match with next widget rule
 *  #test -> match with next widget rule
 *
 * in second widget rule(/#.+/)
 *  plain text -> text node(no rule for matching)
 *  #test -> widget node
 */
function createNodesWithWidget(text, schema, ruleIndex) {
    if (ruleIndex === void 0) { ruleIndex = 0; }
    var nodes = [];
    var rule = (widgetRules[ruleIndex] || {}).rule;
    var nextRuleIndex = ruleIndex + 1;
    text = unwrapWidgetSyntax(text);
    if (rule && rule.test(text)) {
        var index = void 0;
        while ((index = text.search(rule)) !== -1) {
            var prev = text.substring(0, index);
            // get widget node on first splitted text using next widget rule
            if (prev) {
                nodes = mergeNodes(nodes, prev, schema, nextRuleIndex);
            }
            // build widget node using current widget rule
            text = text.substring(index);
            var literal = text.match(rule)[0];
            var info = "widget" + ruleIndex;
            nodes.push(schema.nodes.widget.create({ info: info }, schema.text(createWidgetContent(info, literal))));
            text = text.substring(literal.length);
        }
        // get widget node on last splitted text using next widget rule
        if (text) {
            nodes = mergeNodes(nodes, text, schema, nextRuleIndex);
        }
    }
    else if (text) {
        nodes =
            ruleIndex < widgetRules.length - 1
                ? mergeNodes(nodes, text, schema, nextRuleIndex)
                : [schema.text(text)];
    }
    return nodes;
}
function getWidgetContent(widgetNode) {
    var event;
    var text = '';
    var walker = widgetNode.walker();
    while ((event = walker.next())) {
        var node = event.node, entering = event.entering;
        if (entering) {
            if (node !== widgetNode && node.type !== 'text') {
                text += getInlineMarkdownText(node);
                // skip the children
                walker.resumeAt(widgetNode, false);
                walker.next();
            }
            else if (node.type === 'text') {
                text += node.literal;
            }
        }
    }
    return text;
}

function getDefaultCommands() {
    return {
        deleteSelection: function () { return deleteSelection; },
        selectAll: function () { return selectAll; },
        undo: function () { return undo; },
        redo: function () { return redo; },
    };
}

function placeholder(options) {
    return new Plugin({
        props: {
            decorations: function (state) {
                var doc = state.doc;
                if (options.text &&
                    doc.childCount === 1 &&
                    doc.firstChild.isTextblock &&
                    doc.firstChild.content.size === 0) {
                    var placeHolder = document.createElement('span');
                    addClass_1(placeHolder, 'placeholder');
                    if (options.className) {
                        addClass_1(placeHolder, options.className);
                    }
                    placeHolder.textContent = options.text;
                    return DecorationSet.create(doc, [Decoration.widget(1, placeHolder)]);
                }
                return null;
            },
        },
    });
}

/**
 * @fileoverview Check element has specific css class
 * @author NHN FE Development Lab 
 */

var inArray$1 = inArray_1;
var getClass = getClass_1;

/**
 * Check element has specific css class
 * @param {(HTMLElement|SVGElement)} element - target element
 * @param {string} cssClass - css class
 * @returns {boolean}
 * @memberof module:domUtil
 */
function hasClass(element, cssClass) {
  var origin;

  if (element.classList) {
    return element.classList.contains(cssClass);
  }

  origin = getClass(element).split(/\s+/);

  return inArray$1(cssClass, origin) > -1;
}

var hasClass_1 = hasClass;

/**
 * @fileoverview Check element match selector
 * @author NHN FE Development Lab 
 */

var inArray = inArray_1;
var toArray = toArray_1;

var elProto = Element.prototype;
var matchSelector = elProto.matches ||
    elProto.webkitMatchesSelector ||
    elProto.mozMatchesSelector ||
    elProto.msMatchesSelector ||
    function(selector) {
      var doc = this.document || this.ownerDocument;

      return inArray(this, toArray(doc.querySelectorAll(selector))) > -1;
    };

/**
 * Check element match selector
 * @param {HTMLElement} element - element to check
 * @param {string} selector - selector to check
 * @returns {boolean} is selector matched to element?
 * @memberof module:domUtil
 */
function matches(element, selector) {
  return matchSelector.call(element, selector);
}

var matches_1 = matches;

var TAG_NAME = '[A-Za-z][A-Za-z0-9-]*';
var ATTRIBUTE_NAME = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
var UNQUOTED_VALUE = '[^"\'=<>`\\x00-\\x20]+';
var SINGLE_QUOTED_VALUE = "'[^']*'";
var DOUBLE_QUOTED_VALUE = '"[^"]*"';
var ATTRIBUTE_VALUE = "(?:" + UNQUOTED_VALUE + "|" + SINGLE_QUOTED_VALUE + "|" + DOUBLE_QUOTED_VALUE + ")";
var ATTRIBUTE_VALUE_SPEC = "" + '(?:\\s*=\\s*' + ATTRIBUTE_VALUE + ")";
var ATTRIBUTE$1 = "" + '(?:\\s+' + ATTRIBUTE_NAME + ATTRIBUTE_VALUE_SPEC + "?)";
var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE$1 + ")*\\s*/?>";
var CLOSE_TAG = "]";
var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
var reBR = //i;
var reHTMLComment = /|/;
var ALTERNATIVE_TAG_FOR_BR = '

'; var DEFAULT_TEXT_NOT_START_OR_END_WITH_SPACE = 'a'; function isPositionInBox(style, offsetX, offsetY) { var left = parseInt(style.left, 10); var top = parseInt(style.top, 10); var width = parseInt(style.width, 10) + parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10); var height = parseInt(style.height, 10) + parseInt(style.paddingTop, 10) + parseInt(style.paddingBottom, 10); return offsetX >= left && offsetX <= left + width && offsetY >= top && offsetY <= top + height; } var CLS_PREFIX = 'toastui-editor-'; function cls() { var names = []; for (var _i = 0; _i < arguments.length; _i++) { names[_i] = arguments[_i]; } var result = []; for (var _a = 0, names_1 = names; _a < names_1.length; _a++) { var name_1 = names_1[_a]; var className = void 0; if (Array.isArray(name_1)) { className = name_1[0] ? name_1[1] : null; } else { className = name_1; } if (className) { result.push("" + CLS_PREFIX + className); } } return result.join(' '); } function clsWithMdPrefix() { var names = []; for (var _i = 0; _i < arguments.length; _i++) { names[_i] = arguments[_i]; } return names.map(function (className) { return CLS_PREFIX + "md-" + className; }).join(' '); } function isTextNode(node) { return (node === null || node === void 0 ? void 0 : node.nodeType) === Node.TEXT_NODE; } function isElemNode(node) { return node && node.nodeType === Node.ELEMENT_NODE; } function findNodes(element, selector) { var nodeList = toArray_1(element.querySelectorAll(selector)); if (nodeList.length) { return nodeList; } return []; } function appendNodes(node, nodesToAppend) { nodesToAppend = isArray_1(nodesToAppend) ? toArray_1(nodesToAppend) : [nodesToAppend]; nodesToAppend.forEach(function (nodeToAppend) { node.appendChild(nodeToAppend); }); } function insertBeforeNode(insertedNode, node) { if (node.parentNode) { node.parentNode.insertBefore(insertedNode, node); } } function removeNode$1(node) { if (node.parentNode) { node.parentNode.removeChild(node); } } function unwrapNode(node) { var result = []; while (node.firstChild) { result.push(node.firstChild); if (node.parentNode) { node.parentNode.insertBefore(node.firstChild, node); } } removeNode$1(node); return result; } function toggleClass(element, className, state) { if (isUndefined_1(state)) { state = !hasClass_1(element, className); } var toggleFn = state ? addClass_1 : removeClass_1; toggleFn(element, className); } function createElementWith(contents, target) { var container = document.createElement('div'); if (isString_1(contents)) { container.innerHTML = contents; } else { container.appendChild(contents); } var firstChild = container.firstChild; if (target) { target.appendChild(firstChild); } return firstChild; } function getOuterWidth(el) { var computed = window.getComputedStyle(el); return (['margin-left', 'margin-right'].reduce(function (acc, type) { return acc + parseInt(computed.getPropertyValue(type), 10); }, 0) + el.offsetWidth); } function closest(node, found) { var condition; if (isString_1(found)) { condition = function (target) { return matches_1(target, found); }; } else { condition = function (target) { return target === found; }; } while (node && node !== document) { if (isElemNode(node) && condition(node)) { return node; } node = node.parentNode; } return null; } function getTotalOffset(el, root) { var offsetTop = 0; var offsetLeft = 0; while (el && el !== root) { var top_1 = el.offsetTop, left = el.offsetLeft, offsetParent = el.offsetParent; offsetTop += top_1; offsetLeft += left; if (offsetParent === root.offsetParent) { break; } el = el.offsetParent; } return { offsetTop: offsetTop, offsetLeft: offsetLeft }; } function setAttributes(attributes, element) { Object.keys(attributes).forEach(function (attrName) { if (isNil(attributes[attrName])) { element.removeAttribute(attrName); } else { element.setAttribute(attrName, attributes[attrName]); } }); } function replaceBRWithEmptyBlock(html) { // remove br in paragraph to compatible with markdown var replacedHTML = html.replace(/

<\/p>/gi, '

'); var reHTMLTag = new RegExp(HTML_TAG, 'ig'); var htmlTagMatched = replacedHTML.match(reHTMLTag); htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) { if (reBR.test(htmlTag)) { var alternativeTag = ALTERNATIVE_TAG_FOR_BR; if (index) { var prevTag = htmlTagMatched[index - 1]; var openTagMatched = prevTag.match(OPEN_TAG); if (openTagMatched && !/br/i.test(openTagMatched[1])) { var tagName = openTagMatched[1]; alternativeTag = "<" + tagName + ">"; } } replacedHTML = replacedHTML.replace(reBR, alternativeTag); } }); return replacedHTML; } function removeProseMirrorHackNodes(html) { var reProseMirrorImage = //g; var reProseMirrorTrailingBreak = / class="ProseMirror-trailingBreak"/g; var resultHTML = html; resultHTML = resultHTML.replace(reProseMirrorImage, ''); resultHTML = resultHTML.replace(reProseMirrorTrailingBreak, ''); return resultHTML; } var pluginKey$1 = new PluginKey('widget'); var MARGIN = 5; var PopupWidget = /** @class */ (function () { function PopupWidget(view, eventEmitter) { var _this = this; this.popup = null; this.removeWidget = function () { if (_this.popup) { _this.rootEl.removeChild(_this.popup); _this.popup = null; } }; this.rootEl = view.dom.parentElement; this.eventEmitter = eventEmitter; this.eventEmitter.listen('blur', this.removeWidget); this.eventEmitter.listen('loadUI', function () { _this.rootEl = closest(view.dom.parentElement, "." + cls('defaultUI')); }); this.eventEmitter.listen('removePopupWidget', this.removeWidget); } PopupWidget.prototype.update = function (view) { var widget = pluginKey$1.getState(view.state); this.removeWidget(); if (widget) { var node = widget.node, style = widget.style; var _a = view.coordsAtPos(widget.pos), top_1 = _a.top, left = _a.left, bottom = _a.bottom; var height = bottom - top_1; var rect = this.rootEl.getBoundingClientRect(); var relTopPos = top_1 - rect.top; css_1(node, { opacity: '0' }); this.rootEl.appendChild(node); css_1(node, { position: 'absolute', left: left - rect.left + MARGIN + "px", top: (style === 'bottom' ? relTopPos + height - MARGIN : relTopPos - height) + "px", opacity: '1', }); this.popup = node; view.focus(); } }; PopupWidget.prototype.destroy = function () { this.eventEmitter.removeEventHandler('blur', this.removeWidget); }; return PopupWidget; }()); function addWidget(eventEmitter) { return new Plugin({ key: pluginKey$1, state: { init: function () { return null; }, apply: function (tr) { return tr.getMeta('widget'); }, }, view: function (editorView) { return new PopupWidget(editorView, eventEmitter); }, }); } function addDefaultImageBlobHook(eventEmitter) { eventEmitter.listen('addImageBlobHook', function (blob, callback) { var reader = new FileReader(); reader.onload = function (_a) { var target = _a.target; return callback(target.result); }; reader.readAsDataURL(blob); }); } function emitImageBlobHook(eventEmitter, blob, type) { var hook = function (imageUrl, altText) { eventEmitter.emit('command', 'addImage', { imageUrl: imageUrl, altText: altText || blob.name || 'image', }); }; eventEmitter.emit('addImageBlobHook', blob, hook, type); } function pasteImageOnly(items) { var images = toArray_1(items).filter(function (_a) { var type = _a.type; return type.indexOf('image') !== -1; }); if (images.length === 1) { var item = images[0]; if (item) { return item.getAsFile(); } } return null; } function dropImage(_a) { var eventEmitter = _a.eventEmitter; return new Plugin({ props: { handleDOMEvents: { drop: function (_, ev) { var _a; var items = (_a = ev.dataTransfer) === null || _a === void 0 ? void 0 : _a.files; if (items) { forEachArray_1(items, function (item) { if (item.type.indexOf('image') !== -1) { ev.preventDefault(); ev.stopPropagation(); emitImageBlobHook(eventEmitter, item, ev.type); return false; } return true; }); } return true; }, }, }, }); } var Node$2 = /** @class */ (function () { function Node() { } Object.defineProperty(Node.prototype, "type", { get: function () { return 'node'; }, enumerable: false, configurable: true }); Node.prototype.setContext = function (context) { this.context = context; }; return Node; }()); function widgetNodeView(pmNode) { var dom = document.createElement('span'); var node = widgetToDOM(pmNode.attrs.info, pmNode.textContent); dom.className = 'tui-widget'; dom.appendChild(node); return { dom: dom }; } function isWidgetNode(pmNode) { return pmNode.type.name === 'widget'; } var Widget = /** @class */ (function (_super) { __extends$1(Widget, _super); function Widget() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Widget.prototype, "name", { get: function () { return 'widget'; }, enumerable: false, configurable: true }); Object.defineProperty(Widget.prototype, "schema", { get: function () { return { attrs: { info: { default: null }, }, group: 'inline', inline: true, content: 'text*', selectable: false, atom: true, toDOM: function () { return ['span', { class: 'tui-widget' }, 0]; }, parseDOM: [ { tag: 'span.tui-widget', getAttrs: function (dom) { var text = dom.textContent; var _a = text.match(/\$\$(widget\d+)/), info = _a[1]; return { info: info }; }, }, ], }; }, enumerable: false, configurable: true }); return Widget; }(Node$2)); var EditorBase = /** @class */ (function () { function EditorBase(eventEmitter) { this.timer = null; this.el = document.createElement('div'); this.el.className = 'toastui-editor'; this.eventEmitter = eventEmitter; this.placeholder = { text: '' }; } EditorBase.prototype.createState = function () { return EditorState.create({ schema: this.schema, plugins: this.createPlugins(), }); }; EditorBase.prototype.initEvent = function () { var _a = this, eventEmitter = _a.eventEmitter, view = _a.view, editorType = _a.editorType; view.dom.addEventListener('focus', function () { return eventEmitter.emit('focus', editorType); }); view.dom.addEventListener('blur', function () { return eventEmitter.emit('blur', editorType); }); }; EditorBase.prototype.emitChangeEvent = function (tr) { this.eventEmitter.emit('caretChange', this.editorType); if (tr.docChanged) { this.eventEmitter.emit('change', this.editorType); } }; Object.defineProperty(EditorBase.prototype, "defaultPlugins", { get: function () { var rules = this.createInputRules(); var plugins = __spreadArray$1(__spreadArray$1([], this.keymaps), [ keymap(__assign$1({ 'Shift-Enter': baseKeymap.Enter }, baseKeymap)), history(), placeholder(this.placeholder), addWidget(this.eventEmitter), dropImage(this.context), ]); return rules ? plugins.concat(rules) : plugins; }, enumerable: false, configurable: true }); EditorBase.prototype.createInputRules = function () { var widgetRules = getWidgetRules(); var rules = widgetRules.map(function (_a) { var rule = _a.rule; return new InputRule(rule, function (state, match, start, end) { var schema = state.schema, tr = state.tr, doc = state.doc; var allMatched = match.input.match(new RegExp(rule, 'g')); var pos = doc.resolve(start); var parent = pos.parent; var count = 0; if (isWidgetNode(parent)) { parent = pos.node(pos.depth - 1); } parent.forEach(function (child) { return isWidgetNode(child) && (count += 1); }); // replace the content only if the count of matched rules in whole text is greater than current widget node count if (allMatched.length > count) { var content = last$1(allMatched); var nodes = createNodesWithWidget(content, schema); // adjust start position based on widget content return tr.replaceWith(end - content.length + 1, end, nodes); } return null; }); }); return rules.length ? inputRules({ rules: rules }) : null; }; EditorBase.prototype.clearTimer = function () { if (this.timer) { clearTimeout(this.timer); this.timer = null; } }; EditorBase.prototype.createSchema = function () { return new Schema({ nodes: this.specs.nodes, marks: this.specs.marks, }); }; EditorBase.prototype.createKeymaps = function (useCommandShortcut) { var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo; var allKeymaps = this.specs.keymaps(useCommandShortcut); var historyKeymap = { 'Mod-z': undo(), 'Shift-Mod-z': redo(), }; return useCommandShortcut ? allKeymaps.concat(keymap(historyKeymap)) : allKeymaps; }; EditorBase.prototype.createCommands = function () { return this.specs.commands(this.view); }; EditorBase.prototype.createPluginProps = function () { var _this = this; return this.extraPlugins.map(function (plugin) { return plugin(_this.eventEmitter); }); }; EditorBase.prototype.focus = function () { var _this = this; this.clearTimer(); // prevent the error for IE11 this.timer = setTimeout(function () { _this.view.focus(); _this.view.dispatch(_this.view.state.tr.scrollIntoView()); }); }; EditorBase.prototype.blur = function () { this.view.dom.blur(); }; EditorBase.prototype.destroy = function () { var _this = this; this.clearTimer(); this.view.destroy(); Object.keys(this).forEach(function (prop) { delete _this[prop]; }); }; EditorBase.prototype.moveCursorToStart = function (focus) { var tr = this.view.state.tr; this.view.dispatch(tr.setSelection(createTextSelection(tr, 1)).scrollIntoView()); if (focus) { this.focus(); } }; EditorBase.prototype.moveCursorToEnd = function (focus) { var tr = this.view.state.tr; this.view.dispatch(tr.setSelection(createTextSelection(tr, tr.doc.content.size - 1)).scrollIntoView()); if (focus) { this.focus(); } }; EditorBase.prototype.setScrollTop = function (top) { this.view.dom.scrollTop = top; }; EditorBase.prototype.getScrollTop = function () { return this.view.dom.scrollTop; }; EditorBase.prototype.setPlaceholder = function (text) { this.placeholder.text = text; this.view.dispatch(this.view.state.tr.scrollIntoView()); }; EditorBase.prototype.setHeight = function (height) { css_1(this.el, { height: height + "px" }); }; EditorBase.prototype.setMinHeight = function (minHeight) { css_1(this.el, { minHeight: minHeight + "px" }); }; EditorBase.prototype.getElement = function () { return this.el; }; return EditorBase; }()); /** * @fileoverview Check whether the given variable is a function or not. * @author NHN FE Development Lab */ /** * Check whether the given variable is a function or not. * If the given variable is a function, return true. * @param {*} obj - Target for checking * @returns {boolean} Is function? * @memberof module:type */ function isFunction(obj) { return obj instanceof Function; } var isFunction_1 = isFunction; var defaultCommandShortcuts = [ 'Enter', 'Shift-Enter', 'Mod-Enter', 'Tab', 'Shift-Tab', 'Delete', 'Backspace', 'Mod-Delete', 'Mod-Backspace', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Mod-d', 'Mod-D', 'Alt-ArrowUp', 'Alt-ArrowDown', ]; function execCommand(view, command, payload) { view.focus(); return command(payload)(view.state, view.dispatch, view); } var SpecManager = /** @class */ (function () { function SpecManager(specs) { this.specs = specs; } Object.defineProperty(SpecManager.prototype, "nodes", { get: function () { return this.specs .filter(function (spec) { return spec.type === 'node'; }) .reduce(function (nodes, _a) { var _b; var name = _a.name, schema = _a.schema; return __assign$1(__assign$1({}, nodes), (_b = {}, _b[name] = schema, _b)); }, {}); }, enumerable: false, configurable: true }); Object.defineProperty(SpecManager.prototype, "marks", { get: function () { return this.specs .filter(function (spec) { return spec.type === 'mark'; }) .reduce(function (marks, _a) { var _b; var name = _a.name, schema = _a.schema; return __assign$1(__assign$1({}, marks), (_b = {}, _b[name] = schema, _b)); }, {}); }, enumerable: false, configurable: true }); SpecManager.prototype.commands = function (view, addedCommands) { var specCommands = this.specs .filter(function (_a) { var commands = _a.commands; return commands; }) .reduce(function (allCommands, spec) { var commands = {}; var specCommand = spec.commands(); if (isFunction_1(specCommand)) { commands[spec.name] = function (payload) { return execCommand(view, specCommand, payload); }; } else { Object.keys(specCommand).forEach(function (name) { commands[name] = function (payload) { return execCommand(view, specCommand[name], payload); }; }); } return __assign$1(__assign$1({}, allCommands), commands); }, {}); var defaultCommands = getDefaultCommands(); Object.keys(defaultCommands).forEach(function (name) { specCommands[name] = function (payload) { return execCommand(view, defaultCommands[name], payload); }; }); if (addedCommands) { Object.keys(addedCommands).forEach(function (name) { specCommands[name] = function (payload) { return execCommand(view, addedCommands[name], payload); }; }); } return specCommands; }; SpecManager.prototype.keymaps = function (useCommandShortcut) { var specKeymaps = this.specs.filter(function (spec) { return spec.keymaps; }).map(function (spec) { return spec.keymaps(); }); return specKeymaps.map(function (keys) { if (!useCommandShortcut) { Object.keys(keys).forEach(function (key) { if (!includes(defaultCommandShortcuts, key)) { delete keys[key]; } }); } return keymap(keys); }); }; SpecManager.prototype.setContext = function (context) { this.specs.forEach(function (spec) { spec.setContext(context); }); }; return SpecManager; }()); function resolveSelectionPos(selection) { var from = selection.from, to = selection.to; if (selection instanceof AllSelection) { return [from + 1, to - 1]; } return [from, to]; } function getMdLine(resolvedPos) { return resolvedPos.index(0) + 1; } function getWidgetNodePos(node, chPos, direction) { if (direction === void 0) { direction = 1; } var additionalPos = 0; node.forEach(function (child, pos) { // add or subtract widget node tag if (isWidgetNode(child) && pos + 2 < chPos) { additionalPos += 2 * direction; } }); return additionalPos; } function getEditorToMdPos(doc, from, to) { if (to === void 0) { to = from; } var collapsed = from === to; var startResolvedPos = doc.resolve(from); var startLine = getMdLine(startResolvedPos); var endLine = startLine; var startOffset = startResolvedPos.start(1); var endOffset = startOffset; if (!collapsed) { // prevent the end offset from pointing to the root document position var endResolvedPos = doc.resolve(to === doc.content.size ? to - 1 : to); endOffset = endResolvedPos.start(1); endLine = getMdLine(endResolvedPos); // To resolve the end offset excluding document tag size if (endResolvedPos.pos === doc.content.size) { to = doc.content.size - 2; } } var startCh = Math.max(from - startOffset + 1, 1); var endCh = Math.max(to - endOffset + 1, 1); return [ [startLine, startCh + getWidgetNodePos(doc.child(startLine - 1), startCh, -1)], [endLine, endCh + getWidgetNodePos(doc.child(endLine - 1), endCh, -1)], ]; } function getStartPosListPerLine(doc, endIndex) { var startPosListPerLine = []; for (var i = 0, pos = 0; i < endIndex; i += 1) { var child = doc.child(i); startPosListPerLine[i] = pos; pos += child.nodeSize; } return startPosListPerLine; } function getMdToEditorPos(doc, startPos, endPos) { var startPosListPerLine = getStartPosListPerLine(doc, endPos[0]); var startIndex = startPos[0] - 1; var endIndex = endPos[0] - 1; var startNode = doc.child(startIndex); var endNode = doc.child(endIndex); // calculate the position corresponding to the line var from = startPosListPerLine[startIndex]; var to = startPosListPerLine[endIndex]; // calculate the position corresponding to the character offset of the line from += startPos[1] + getWidgetNodePos(startNode, startPos[1] - 1); to += endPos[1] + getWidgetNodePos(endNode, endPos[1] - 1); return [from, Math.min(to, doc.content.size)]; } function getRangeInfo(selection) { var $from = selection.$from, $to = selection.$to; var from = selection.from, to = selection.to; var doc = $from.doc; if (selection instanceof AllSelection) { $from = doc.resolve(from + 1); $to = doc.resolve(to - 1); } if ($from.depth === 0) { $from = doc.resolve(from - 1); $to = $from; } return { startFromOffset: $from.start(1), endFromOffset: $to.start(1), startToOffset: $from.end(1), endToOffset: $to.end(1), startIndex: $from.index(0), endIndex: $to.index(0), from: $from.pos, to: $to.pos, }; } function getNodeContentOffsetRange(doc, targetIndex) { var startOffset = 1; var endOffset = 1; for (var i = 0, offset = 0; i < doc.childCount; i += 1) { var nodeSize = doc.child(i).nodeSize; // calculate content start, end offset(not node offset) startOffset = offset + 1; endOffset = offset + nodeSize - 1; if (i === targetIndex) { break; } offset += nodeSize; } return { startOffset: startOffset, endOffset: endOffset }; } var HEADING = 'heading'; var BLOCK_QUOTE = 'blockQuote'; var LIST_ITEM = 'listItem'; var TABLE = 'table'; var TABLE_CELL = 'tableCell'; var CODE_BLOCK = 'codeBlock'; var THEMATIC_BREAK = 'thematicBreak'; var LINK = 'link'; var CODE = 'code'; var META = 'meta'; var DELIM = 'delimiter'; var TASK_DELIM = 'taskDelimiter'; var TEXT = 'markedText'; var HTML = 'html'; var CUSTOM_BLOCK = 'customBlock'; var delimSize = { strong: 2, emph: 1, strike: 2, }; function markInfo(start, end, type, attrs) { return { start: start, end: end, spec: { type: type, attrs: attrs } }; } function heading$1(_a, start, end) { var level = _a.level, headingType = _a.headingType; var marks = [markInfo(start, end, HEADING, { level: level })]; if (headingType === 'atx') { marks.push(markInfo(start, addOffsetPos(start, level), DELIM)); } else { marks.push(markInfo(setOffsetPos(end, 0), end, HEADING, { seText: true })); } return marks; } function emphasisAndStrikethrough(_a, start, end) { var type = _a.type; var startDelimPos = addOffsetPos(start, delimSize[type]); var endDelimPos = addOffsetPos(end, -delimSize[type]); return [ markInfo(startDelimPos, endDelimPos, type), markInfo(start, startDelimPos, DELIM), markInfo(endDelimPos, end, DELIM), ]; } function markLink(start, end, linkTextStart, lastChildCh) { return [ markInfo(start, end, LINK), markInfo(setOffsetPos(start, linkTextStart[1] + 1), setOffsetPos(end, lastChildCh), LINK, { desc: true, }), markInfo(setOffsetPos(end, lastChildCh + 2), addOffsetPos(end, -1), LINK, { url: true }), ]; } function image$1(_a, start, end) { var lastChild = _a.lastChild; var lastChildCh = lastChild ? getMdEndCh(lastChild) + 1 : 3; // 3: length of '![]' var linkTextEnd = addOffsetPos(start, 1); return __spreadArray$1([markInfo(start, linkTextEnd, META)], markLink(start, end, linkTextEnd, lastChildCh)); } function link(_a, start, end) { var lastChild = _a.lastChild, extendedAutolink = _a.extendedAutolink; var lastChildCh = lastChild ? getMdEndCh(lastChild) + 1 : 2; // 2: length of '[]' return extendedAutolink ? [markInfo(start, end, LINK, { desc: true })] : markLink(start, end, start, lastChildCh); } function code(_a, start, end) { var tickCount = _a.tickCount; var openDelimEnd = addOffsetPos(start, tickCount); var closeDelimStart = addOffsetPos(end, -tickCount); return [ markInfo(start, end, CODE), markInfo(start, openDelimEnd, CODE, { start: true }), markInfo(openDelimEnd, closeDelimStart, CODE, { marked: true }), markInfo(closeDelimStart, end, CODE, { end: true }), ]; } function lineBackground(parent, start, end, prefix) { var defaultBackground = { start: start, end: end, spec: { attrs: { className: prefix + "-line-background", codeStart: start[0], codeEnd: end[0] }, }, lineBackground: true, }; return parent.type !== 'item' && parent.type !== 'blockQuote' ? [ __assign$1(__assign$1({}, defaultBackground), { end: start, spec: { attrs: { className: prefix + "-line-background start" } } }), __assign$1(__assign$1({}, defaultBackground), { start: [Math.min(start[0] + 1, end[0]), start[1]] }), ] : null; } function codeBlock$1(node, start, end, endLine) { var fenceOffset = node.fenceOffset, fenceLength = node.fenceLength, fenceChar = node.fenceChar, info = node.info, infoPadding = node.infoPadding, parent = node.parent; var fenceEnd = fenceOffset + fenceLength; var marks = [markInfo(setOffsetPos(start, 1), end, CODE_BLOCK)]; if (fenceChar) { marks.push(markInfo(start, addOffsetPos(start, fenceEnd), DELIM)); } if (info) { marks.push(markInfo(addOffsetPos(start, fenceLength), addOffsetPos(start, fenceLength + infoPadding + info.length), META)); } var codeBlockEnd = "^(\\s{0,4})(" + fenceChar + "{" + fenceLength + ",})"; var reCodeBlockEnd = new RegExp(codeBlockEnd); if (reCodeBlockEnd.test(endLine)) { marks.push(markInfo(setOffsetPos(end, 1), end, DELIM)); } var lineBackgroundMarkInfo = lineBackground(parent, start, end, 'code-block'); return lineBackgroundMarkInfo ? marks.concat(lineBackgroundMarkInfo) : marks; } function customBlock$2(node, start, end) { var _a = node, offset = _a.offset, syntaxLength = _a.syntaxLength, info = _a.info, parent = _a.parent; var syntaxEnd = offset + syntaxLength; var marks = [markInfo(setOffsetPos(start, 1), end, CUSTOM_BLOCK)]; marks.push(markInfo(start, addOffsetPos(start, syntaxEnd), DELIM)); if (info) { marks.push(markInfo(addOffsetPos(start, syntaxEnd), addOffsetPos(start, syntaxLength + info.length), META)); } marks.push(markInfo(setOffsetPos(end, 1), end, DELIM)); var lineBackgroundMarkInfo = lineBackground(parent, start, end, 'custom-block'); return lineBackgroundMarkInfo ? marks.concat(lineBackgroundMarkInfo) : marks; } function markListItemChildren(node, markType) { var marks = []; while (node) { var type = node.type; if (type === 'paragraph' || type === 'codeBlock') { marks.push(markInfo([getMdStartLine(node), getMdStartCh(node) - 1], [getMdEndLine(node), getMdEndCh(node) + 1], markType)); } node = node.next; } return marks; } function markParagraphInBlockQuote(node) { var marks = []; while (node) { marks.push(markInfo([getMdStartLine(node), getMdStartCh(node)], [getMdEndLine(node), getMdEndCh(node) + 1], TEXT)); node = node.next; } return marks; } function blockQuote$2(node, start, end) { var marks = node.parent && node.parent.type !== 'blockQuote' ? [markInfo(start, end, BLOCK_QUOTE)] : []; if (node.firstChild) { var childMarks = []; if (node.firstChild.type === 'paragraph') { childMarks = markParagraphInBlockQuote(node.firstChild.firstChild); } else if (node.firstChild.type === 'list') { childMarks = markListItemChildren(node.firstChild, TEXT); } marks = __spreadArray$1(__spreadArray$1([], marks), childMarks); } return marks; } function getSpecOfListItemStyle(node) { var depth = 0; while (node.parent.parent && node.parent.parent.type === 'item') { node = node.parent.parent; depth += 1; } var attrs = [{ odd: true }, { even: true }][depth % 2]; return [LIST_ITEM, __assign$1(__assign$1({}, attrs), { listStyle: true })]; } function item$1(node, start) { var _a = node.listData, padding = _a.padding, task = _a.task; var spec = getSpecOfListItemStyle(node); var marks = [markInfo.apply(void 0, __spreadArray$1([start, addOffsetPos(start, padding)], spec))]; if (task) { marks.push(markInfo(addOffsetPos(start, padding), addOffsetPos(start, padding + 3), TASK_DELIM)); marks.push(markInfo(addOffsetPos(start, padding + 1), addOffsetPos(start, padding + 2), META)); } return marks.concat(markListItemChildren(node.firstChild, TEXT)); } var markNodeFuncMap = { heading: heading$1, strong: emphasisAndStrikethrough, emph: emphasisAndStrikethrough, strike: emphasisAndStrikethrough, link: link, image: image$1, code: code, codeBlock: codeBlock$1, blockQuote: blockQuote$2, item: item$1, customBlock: customBlock$2, }; var simpleMarkClassNameMap = { thematicBreak: THEMATIC_BREAK, table: TABLE, tableCell: TABLE_CELL, htmlInline: HTML, }; function getMarkInfo(node, start, end, endLine) { var type = node.type; if (isFunction_1(markNodeFuncMap[type])) { // @ts-ignore return markNodeFuncMap[type](node, start, end, endLine); } if (simpleMarkClassNameMap[type]) { return [markInfo(start, end, simpleMarkClassNameMap[type])]; } return null; } var removingBackgroundIndexMap = {}; function syntaxHighlight(_a) { var schema = _a.schema, toastMark = _a.toastMark; return new Plugin({ appendTransaction: function (transactions, _, newState) { var tr = transactions[0]; var newTr = newState.tr; if (tr.docChanged) { var markInfo_1 = []; var editResult = tr.getMeta('editResult'); editResult.forEach(function (result) { var nodes = result.nodes, removedNodeRange = result.removedNodeRange; if (nodes.length) { markInfo_1 = markInfo_1.concat(getMarkForRemoving(newTr, nodes)); for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { var parent_1 = nodes_1[_i]; var walker = parent_1.walker(); var event_1 = walker.next(); while (event_1) { var node = event_1.node, entering = event_1.entering; if (entering) { markInfo_1 = markInfo_1.concat(getMarkForAdding(node, toastMark)); } event_1 = walker.next(); } } } else if (removedNodeRange) { var maxIndex = newTr.doc.childCount - 1; var _a = removedNodeRange.line, startLine = _a[0], endLine = _a[1]; var startIndex = Math.min(startLine, maxIndex); var endIndex = Math.min(endLine, maxIndex); // cache the index to remove code block, custom block background when there are no adding nodes for (var i = startIndex; i <= endIndex; i += 1) { removingBackgroundIndexMap[i] = true; } } }); appendMarkTr(newTr, schema, markInfo_1); } return newTr.setMeta('widget', tr.getMeta('widget')); }, }); } function isDifferentBlock(doc, index, attrs) { return Object.keys(attrs).some(function (name) { return attrs[name] !== doc.child(index).attrs[name]; }); } function addLineBackground(tr, doc, paragraph, blockPosInfo, attrs) { if (attrs === void 0) { attrs = {}; } var startIndex = blockPosInfo.startIndex, endIndex = blockPosInfo.endIndex, from = blockPosInfo.from, to = blockPosInfo.to; var shouldChangeBlockType = false; for (var i = startIndex; i <= endIndex; i += 1) { // prevent to remove background of the node that need to have background delete removingBackgroundIndexMap[i]; shouldChangeBlockType = isDifferentBlock(doc, i, attrs); } if (shouldChangeBlockType) { tr.setBlockType(from, to, paragraph, attrs); } } function appendMarkTr(tr, schema, marks) { var doc = tr.doc; var paragraph = schema.nodes.paragraph; // get start position per line for lazy calculation var startPosListPerLine = getStartPosListPerLine(doc, doc.childCount); marks.forEach(function (_a) { var start = _a.start, end = _a.end, spec = _a.spec, lineBackground = _a.lineBackground; var startIndex = Math.min(start[0], doc.childCount) - 1; var endIndex = Math.min(end[0], doc.childCount) - 1; var startNode = doc.child(startIndex); var endNode = doc.child(endIndex); // calculate the position corresponding to the line var from = startPosListPerLine[startIndex]; var to = startPosListPerLine[endIndex]; // calculate the position corresponding to the character offset of the line from += start[1] + getWidgetNodePos(startNode, start[1] - 1); to += end[1] + getWidgetNodePos(endNode, end[1] - 1); if (spec) { if (lineBackground) { var posInfo = { from: from, to: to, startIndex: startIndex, endIndex: endIndex }; addLineBackground(tr, doc, paragraph, posInfo, spec.attrs); } else { tr.addMark(from, to, schema.mark(spec.type, spec.attrs)); } } else { tr.removeMark(from, to); } }); removeBlockBackground(tr, startPosListPerLine, paragraph); } function removeBlockBackground(tr, startPosListPerLine, paragraph) { Object.keys(removingBackgroundIndexMap).forEach(function (index) { var startIndex = Number(index); // get the end position of the current line with the next node start position. var endIndex = Math.min(Number(index) + 1, tr.doc.childCount - 1); var from = startPosListPerLine[startIndex]; // subtract '1' for getting end position of the line var to = startPosListPerLine[endIndex] - 1; if (startIndex === endIndex) { to += 2; } tr.setBlockType(from, to, paragraph); }); } function cacheIndexToRemoveBackground(doc, start, end) { var skipLines = []; removingBackgroundIndexMap = {}; for (var i = start[0] - 1; i < end[0]; i += 1) { var node = doc.child(i); var codeEnd = node.attrs.codeEnd; var codeStart = node.attrs.codeStart; if (codeStart && codeEnd && !includes(skipLines, codeStart)) { skipLines.push(codeStart); codeEnd = Math.min(codeEnd, doc.childCount); // should subtract '1' to markdown line position // because markdown parser has '1'(not zero) as the start number var startIndex = codeStart - 1; var endIndex = end[0]; for (var index = startIndex; index < endIndex; index += 1) { removingBackgroundIndexMap[index] = true; } } } } function getMarkForRemoving(_a, nodes) { var doc = _a.doc; var start = nodes[0].sourcepos[0]; var _b = last$1(nodes).sourcepos, end = _b[1]; var startPos = [start[0], start[1]]; var endPos = [end[0], end[1] + 1]; var marks = []; cacheIndexToRemoveBackground(doc, start, end); marks.push({ start: startPos, end: endPos }); return marks; } function getMarkForAdding(node, toastMark) { var lineTexts = toastMark.getLineTexts(); var startPos = [getMdStartLine(node), getMdStartCh(node)]; var endPos = [getMdEndLine(node), getMdEndCh(node) + 1]; var markInfo = getMarkInfo(node, startPos, endPos, lineTexts[endPos[0] - 1]); return markInfo !== null && markInfo !== void 0 ? markInfo : []; } var defaultToolbarStateKeys = [ 'taskList', 'orderedList', 'bulletList', 'table', 'strong', 'emph', 'strike', 'heading', 'thematicBreak', 'blockQuote', 'code', 'codeBlock', 'indent', 'outdent', ]; function getToolbarStateType$1(mdNode) { var type = mdNode.type; if (isListNode$1(mdNode)) { if (mdNode.listData.task) { return 'taskList'; } return mdNode.listData.type === 'ordered' ? 'orderedList' : 'bulletList'; } if (type.indexOf('table') !== -1) { return 'table'; } if (!includes(defaultToolbarStateKeys, type)) { return null; } return type; } function getToolbarState$1(targetNode) { var toolbarState = { indent: { active: false, disabled: true }, outdent: { active: false, disabled: true }, }; var listEnabled = true; traverseParentNodes(targetNode, function (mdNode) { var type = getToolbarStateType$1(mdNode); if (!type) { return; } if (type === 'bulletList' || type === 'orderedList') { // to apply the nearlist list state in the nested list if (listEnabled) { toolbarState[type] = { active: true }; toolbarState.indent.disabled = false; toolbarState.outdent.disabled = false; listEnabled = false; } } else { toolbarState[type] = { active: true }; } }); return toolbarState; } function previewHighlight(_a) { var toastMark = _a.toastMark, eventEmitter = _a.eventEmitter; return new Plugin({ view: function () { return { update: function (view, prevState) { var state = view.state; var doc = state.doc, selection = state.selection; if (prevState && prevState.doc.eq(doc) && prevState.selection.eq(selection)) { return; } var from = selection.from; var startChOffset = state.doc.resolve(from).start(); var line = state.doc.content.findIndex(from).index + 1; var ch = from - startChOffset; if (from === startChOffset) { ch += 1; } var cursorPos = [line, ch]; var mdNode = toastMark.findNodeAtPosition(cursorPos); var toolbarState = getToolbarState$1(mdNode); eventEmitter.emit('changeToolbarState', { cursorPos: cursorPos, mdNode: mdNode, toolbarState: toolbarState, }); eventEmitter.emit('setFocusedNode', mdNode); }, }; }, }); } var Doc$1 = /** @class */ (function (_super) { __extends$1(Doc, _super); function Doc() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Doc.prototype, "name", { get: function () { return 'doc'; }, enumerable: false, configurable: true }); Object.defineProperty(Doc.prototype, "schema", { get: function () { return { content: 'block+', }; }, enumerable: false, configurable: true }); return Doc; }(Node$2)); var Mark = /** @class */ (function () { function Mark() { } Object.defineProperty(Mark.prototype, "type", { get: function () { return 'mark'; }, enumerable: false, configurable: true }); Mark.prototype.setContext = function (context) { this.context = context; }; return Mark; }()); function getTextByMdLine(doc, mdLine) { return getTextContent(doc, mdLine - 1); } function getTextContent(doc, index) { return doc.child(index).textContent; } var reBlockQuote = /^\s*> ?/; var BlockQuote$1 = /** @class */ (function (_super) { __extends$1(BlockQuote, _super); function BlockQuote() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(BlockQuote.prototype, "name", { get: function () { return 'blockQuote'; }, enumerable: false, configurable: true }); Object.defineProperty(BlockQuote.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('block-quote') }, 0]; }, }; }, enumerable: false, configurable: true }); BlockQuote.prototype.createBlockQuoteText = function (text, isBlockQuote) { return isBlockQuote ? text.replace(reBlockQuote, '').trim() : "> " + text.trim(); }; BlockQuote.prototype.extendBlockQuote = function () { var _this = this; return function (_a, dispatch) { var selection = _a.selection, doc = _a.doc, tr = _a.tr, schema = _a.schema; var _b = getRangeInfo(selection), endFromOffset = _b.endFromOffset, endToOffset = _b.endToOffset, endIndex = _b.endIndex, to = _b.to; var textContent = getTextContent(doc, endIndex); var isBlockQuote = reBlockQuote.test(textContent); if (isBlockQuote && to > endFromOffset && selection.empty) { var isEmpty = !textContent.replace(reBlockQuote, '').trim(); if (isEmpty) { tr.deleteRange(endFromOffset, endToOffset).split(tr.mapping.map(endToOffset)); } else { var slicedText = textContent.slice(to - endFromOffset).trim(); var node = createTextNode$1(schema, _this.createBlockQuoteText(slicedText)); splitAndExtendBlock(tr, endToOffset, slicedText, node); } dispatch(tr); return true; } return false; }; }; BlockQuote.prototype.commands = function () { var _this = this; return function () { return function (state, dispatch) { var selection = state.selection, doc = state.doc; var _a = getRangeInfo(selection), startFromOffset = _a.startFromOffset, endToOffset = _a.endToOffset, startIndex = _a.startIndex, endIndex = _a.endIndex; var isBlockQuote = reBlockQuote.test(getTextContent(doc, startIndex)); var tr = replaceTextNode({ state: state, startIndex: startIndex, endIndex: endIndex, from: startFromOffset, createText: function (textContent) { return _this.createBlockQuoteText(textContent, isBlockQuote); }, }); dispatch(tr.setSelection(createTextSelection(tr, tr.mapping.map(endToOffset)))); return true; }; }; }; BlockQuote.prototype.keymaps = function () { var blockQuoteCommand = this.commands()(); return { 'alt-q': blockQuoteCommand, 'alt-Q': blockQuoteCommand, Enter: this.extendBlockQuote(), }; }; return BlockQuote; }(Mark)); var reList = /(^\s*)([-*+] |[\d]+\. )/; var reOrderedList = /(^\s*)([\d])+\.( \[[ xX]])? /; var reOrderedListGroup = /^(\s*)((\d+)([.)]\s(?:\[(?:x|\s)\]\s)?))(.*)/; var reCanBeTaskList = /(^\s*)([-*+]|[\d]+\.)( \[[ xX]])? /; var reBulletListGroup = /^(\s*)([-*+]+(\s(?:\[(?:x|\s)\]\s)?))(.*)/; var reTaskList = /(^\s*)([-*+] |[\d]+\. )(\[[ xX]] )/; var reBulletTaskList = /(^\s*)([-*+])( \[[ xX]]) /; function getListType(text) { return reOrderedList.test(text) ? 'ordered' : 'bullet'; } function getListDepth(mdNode) { var depth = 0; while (mdNode && mdNode.type !== 'document') { if (mdNode.type === 'list') { depth += 1; } mdNode = mdNode.parent; } return depth; } function findSameDepthList(toastMark, currentLine, depth, backward) { var lineTexts = toastMark.getLineTexts(); var lineLen = lineTexts.length; var result = []; var line = currentLine; while (backward ? line < lineLen : line > 1) { line = backward ? line + 1 : line - 1; var mdNode = toastMark.findFirstNodeAtLine(line); var currentListDepth = getListDepth(mdNode); if (currentListDepth === depth) { result.push({ line: line, depth: depth, mdNode: mdNode }); } else if (currentListDepth < depth) { break; } } return result; } function getSameDepthItems(_a) { var toastMark = _a.toastMark, mdNode = _a.mdNode, line = _a.line; var depth = getListDepth(mdNode); var forwardList = findSameDepthList(toastMark, line, depth, false).reverse(); var backwardList = findSameDepthList(toastMark, line, depth, true); return forwardList.concat([{ line: line, depth: depth, mdNode: mdNode }]).concat(backwardList); } function textToBullet(text) { if (!reList.test(text)) { return "* " + text; } var type = getListType(text); if (type === 'bullet' && reCanBeTaskList.test(text)) { text = text.replace(reBulletTaskList, '$1$2 '); } else if (type === 'ordered') { text = text.replace(reOrderedList, '$1* '); } return text; } function textToOrdered(text, ordinalNum) { if (!reList.test(text)) { return ordinalNum + ". " + text; } var type = getListType(text); if (type === 'bullet' || (type === 'ordered' && reCanBeTaskList.test(text))) { text = text.replace(reCanBeTaskList, "$1" + ordinalNum + ". "); } else if (type === 'ordered') { // eslint-disable-next-line prefer-destructuring var start = reOrderedListGroup.exec(text)[3]; if (Number(start) !== ordinalNum) { text = text.replace(reOrderedList, "$1" + ordinalNum + ". "); } } return text; } function getChangedInfo(doc, sameDepthItems, type, start) { if (start === void 0) { start = 0; } var firstIndex = Number.MAX_VALUE; var lastIndex = 0; var changedResults = sameDepthItems.map(function (_a, index) { var line = _a.line; firstIndex = Math.min(line - 1, firstIndex); lastIndex = Math.max(line - 1, lastIndex); var text = getTextByMdLine(doc, line); text = type === 'bullet' ? textToBullet(text) : textToOrdered(text, index + 1 + start); return { text: text, line: line }; }); return { changedResults: changedResults, firstIndex: firstIndex, lastIndex: lastIndex }; } function getBulletOrOrdered(type, context) { var sameDepthListInfo = getSameDepthItems(context); return getChangedInfo(context.doc, sameDepthListInfo, type); } var otherListToList = { bullet: function (context) { return getBulletOrOrdered('bullet', context); }, ordered: function (context) { return getBulletOrOrdered('ordered', context); }, task: function (_a) { var mdNode = _a.mdNode, doc = _a.doc, line = _a.line; var text = getTextByMdLine(doc, line); if (mdNode.listData.task) { text = text.replace(reTaskList, '$1$2'); } else if (isListNode$1(mdNode)) { text = text.replace(reList, '$1$2[ ] '); } return { changedResults: [{ text: text, line: line }] }; }, }; var otherNodeToList = { bullet: function (_a) { var doc = _a.doc, line = _a.line; var lineText = getTextByMdLine(doc, line); var changedResults = [{ text: "* " + lineText, line: line }]; return { changedResults: changedResults }; }, ordered: function (_a) { var toastMark = _a.toastMark, doc = _a.doc, line = _a.line, startLine = _a.startLine; var lineText = getTextByMdLine(doc, line); var firstOrderedListNum = 1; var firstOrderedListLine = startLine; var skipped = 0; for (var i = startLine - 1; i > 0; i -= 1) { var mdNode = toastMark.findFirstNodeAtLine(i); var text = getTextByMdLine(doc, i); var canBeListNode = text && !!findClosestNode(mdNode, function (targetNode) { return isListNode$1(targetNode); }); var searchResult = reOrderedListGroup.exec(getTextByMdLine(doc, i)); if (!searchResult && !canBeListNode) { break; } if (!searchResult && canBeListNode) { skipped += 1; continue; } var _b = searchResult, indent = _b[1], start = _b[3]; // basis on one depth list if (!indent) { firstOrderedListNum = Number(start); firstOrderedListLine = i; break; } } var ordinalNum = firstOrderedListNum + line - firstOrderedListLine - skipped; var changedResults = [{ text: ordinalNum + ". " + lineText, line: line }]; return { changedResults: changedResults }; }, task: function (_a) { var doc = _a.doc, line = _a.line; var lineText = getTextByMdLine(doc, line); var changedResults = [{ text: "* [ ] " + lineText, line: line }]; return { changedResults: changedResults }; }, }; var extendList = { bullet: function (_a) { var line = _a.line, doc = _a.doc; var lineText = getTextByMdLine(doc, line); var _b = reBulletListGroup.exec(lineText), indent = _b[1], delimiter = _b[2]; return { listSyntax: "" + indent + delimiter }; }, ordered: function (_a) { var toastMark = _a.toastMark, line = _a.line, mdNode = _a.mdNode, doc = _a.doc; var depth = getListDepth(mdNode); var lineText = getTextByMdLine(doc, line); var _b = reOrderedListGroup.exec(lineText), indent = _b[1], start = _b[3], delimiter = _b[4]; var ordinalNum = Number(start) + 1; var listSyntax = "" + indent + ordinalNum + delimiter; var backwardList = findSameDepthList(toastMark, line, depth, true); var filteredList = backwardList.filter(function (info) { var searchResult = reOrderedListGroup.exec(getTextByMdLine(doc, info.line)); return (searchResult && searchResult[1].length === indent.length && !!findClosestNode(info.mdNode, function (targetNode) { return isOrderedListNode(targetNode); })); }); return __assign$1({ listSyntax: listSyntax }, getChangedInfo(doc, filteredList, 'ordered', ordinalNum)); }, }; function getReorderedListInfo(doc, schema, line, ordinalNum, prevIndentLength) { var nodes = []; var lineText = getTextByMdLine(doc, line); var searchResult = reOrderedListGroup.exec(lineText); while (searchResult) { var indent = searchResult[1], delimiter = searchResult[4], text = searchResult[5]; var indentLength = indent.length; if (indentLength === prevIndentLength) { nodes.push(createTextNode$1(schema, "" + indent + ordinalNum + delimiter + text)); ordinalNum += 1; line += 1; } else if (indentLength > prevIndentLength) { var nestedListInfo = getReorderedListInfo(doc, schema, line, 1, indentLength); line = nestedListInfo.line; nodes = nodes.concat(nestedListInfo.nodes); } if (indentLength < prevIndentLength || line > doc.childCount) { break; } lineText = getTextByMdLine(doc, line); searchResult = reOrderedListGroup.exec(lineText); } return { nodes: nodes, line: line }; } var reStartSpace = /(^\s{1,4})(.*)/; function isBlockUnit(from, to, text) { return from < to || reList.test(text) || reBlockQuote.test(text); } function isInTableCellNode(doc, schema, selection) { var $pos = selection.$from; if ($pos.depth === 0) { $pos = doc.resolve($pos.pos - 1); } var node = $pos.node(1); var startOffset = $pos.start(1); var contentSize = node.content.size; return (node.rangeHasMark(0, contentSize, schema.marks.table) && $pos.pos - startOffset !== contentSize && $pos.pos !== startOffset); } function createSelection(tr, posInfo) { var from = posInfo.from, to = posInfo.to; if (posInfo.type === 'indent') { var softTabLen = 4; from += softTabLen; to += (posInfo.lineLen + 1) * softTabLen; } else { var spaceLenList = posInfo.spaceLenList; from -= spaceLenList[0]; for (var i = 0; i < spaceLenList.length; i += 1) { to -= spaceLenList[i]; } } return createTextSelection(tr, from, to); } var Paragraph$1 = /** @class */ (function (_super) { __extends$1(Paragraph, _super); function Paragraph() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Paragraph.prototype, "name", { get: function () { return 'paragraph'; }, enumerable: false, configurable: true }); Object.defineProperty(Paragraph.prototype, "schema", { get: function () { return { content: 'inline*', attrs: { className: { default: null }, codeStart: { default: null }, codeEnd: { default: null }, }, selectable: false, group: 'block', parseDOM: [{ tag: 'div' }], toDOM: function (_a) { var attrs = _a.attrs; return attrs.className ? ['div', { class: clsWithMdPrefix(attrs.className) }, 0] : ['div', 0]; }, }; }, enumerable: false, configurable: true }); Paragraph.prototype.reorderList = function (startLine, endLine) { var _a = this.context, view = _a.view, toastMark = _a.toastMark, schema = _a.schema; var _b = view.state, tr = _b.tr, selection = _b.selection, doc = _b.doc; var mdNode = toastMark.findFirstNodeAtLine(startLine); var topListNode = mdNode; while (mdNode && !isBulletListNode(mdNode) && mdNode.parent.type !== 'document') { mdNode = mdNode.parent; if (isOrderedListNode(mdNode)) { topListNode = mdNode; break; } } if (topListNode) { startLine = topListNode.sourcepos[0][0]; } var _c = reOrderedListGroup.exec(getTextByMdLine(doc, startLine)), indent = _c[1], start = _c[3]; var indentLen = indent.length; var _d = getReorderedListInfo(doc, schema, startLine, Number(start), indentLen), line = _d.line, nodes = _d.nodes; endLine = Math.max(endLine, line - 1); var startOffset = getNodeContentOffsetRange(doc, startLine - 1).startOffset; for (var i = startLine - 1; i <= endLine - 1; i += 1) { var _e = doc.child(i), nodeSize = _e.nodeSize, content = _e.content; var mappedFrom = tr.mapping.map(startOffset); var mappedTo = mappedFrom + content.size; tr.replaceWith(mappedFrom, mappedTo, nodes[i - startLine + 1]); startOffset += nodeSize; } var newSelection = createTextSelection(tr, selection.from, selection.to); view.dispatch(tr.setSelection(newSelection)); }; Paragraph.prototype.indent = function (tabKey) { var _this = this; if (tabKey === void 0) { tabKey = false; } return function () { return function (state, dispatch) { var schema = state.schema, selection = state.selection, doc = state.doc; var _a = getRangeInfo(selection), from = _a.from, to = _a.to, startFromOffset = _a.startFromOffset, startIndex = _a.startIndex, endIndex = _a.endIndex; if (tabKey && isInTableCellNode(doc, schema, selection)) { return false; } var startLineText = getTextContent(doc, startIndex); if ((tabKey && isBlockUnit(from, to, startLineText)) || (!tabKey && reList.test(startLineText))) { var tr = replaceTextNode({ state: state, from: startFromOffset, startIndex: startIndex, endIndex: endIndex, createText: function (textContent) { return " " + textContent; }, }); var posInfo = { type: 'indent', from: from, to: to, lineLen: endIndex - startIndex, }; dispatch(tr.setSelection(createSelection(tr, posInfo))); if (reOrderedListGroup.test(startLineText)) { _this.reorderList(startIndex + 1, endIndex + 1); } } else if (tabKey) { dispatch(state.tr.insert(to, createTextNode$1(schema, ' '))); } return true; }; }; }; Paragraph.prototype.outdent = function (tabKey) { var _this = this; if (tabKey === void 0) { tabKey = false; } return function () { return function (state, dispatch) { var selection = state.selection, doc = state.doc, schema = state.schema; var _a = getRangeInfo(selection), from = _a.from, to = _a.to, startFromOffset = _a.startFromOffset, startIndex = _a.startIndex, endIndex = _a.endIndex; if (tabKey && isInTableCellNode(doc, schema, selection)) { return false; } var startLineText = getTextContent(doc, startIndex); if ((tabKey && isBlockUnit(from, to, startLineText)) || (!tabKey && reList.test(startLineText))) { var spaceLenList_1 = []; var tr = replaceTextNode({ state: state, from: startFromOffset, startIndex: startIndex, endIndex: endIndex, createText: function (textContent) { var searchResult = reStartSpace.exec(textContent); spaceLenList_1.push(searchResult ? searchResult[1].length : 0); return textContent.replace(reStartSpace, '$2'); }, }); var posInfo = { type: 'outdent', from: from, to: to, spaceLenList: spaceLenList_1 }; dispatch(tr.setSelection(createSelection(tr, posInfo))); if (reOrderedListGroup.test(startLineText)) { _this.reorderList(startIndex + 1, endIndex + 1); } } else if (tabKey) { var startText = startLineText.slice(0, to - startFromOffset); var startTextWithoutSpace = startText.replace(/\s{1,4}$/, ''); var deletStart = to - (startText.length - startTextWithoutSpace.length); dispatch(state.tr.delete(deletStart, to)); } return true; }; }; }; Paragraph.prototype.deleteLines = function () { var _this = this; return function (state, dispatch) { var view = _this.context.view; var _a = getRangeInfo(state.selection), startFromOffset = _a.startFromOffset, endToOffset = _a.endToOffset; var deleteRange = function () { dispatch(state.tr.deleteRange(startFromOffset, endToOffset)); return true; }; return chainCommands(deleteRange, joinForward)(state, dispatch, view); }; }; Paragraph.prototype.moveDown = function () { return function (state, dispatch) { var doc = state.doc, tr = state.tr, selection = state.selection, schema = state.schema; var _a = getRangeInfo(selection), startFromOffset = _a.startFromOffset, endToOffset = _a.endToOffset, endIndex = _a.endIndex; if (endIndex < doc.content.childCount - 1) { var _b = doc.child(endIndex + 1), nodeSize = _b.nodeSize, textContent = _b.textContent; tr.delete(endToOffset, endToOffset + nodeSize) .split(startFromOffset) // subtract 2(start, end tag length) to insert prev line .insert(tr.mapping.map(startFromOffset) - 2, createTextNode$1(schema, textContent)); dispatch(tr); return true; } return false; }; }; Paragraph.prototype.moveUp = function () { return function (state, dispatch) { var tr = state.tr, doc = state.doc, selection = state.selection, schema = state.schema; var _a = getRangeInfo(selection), startFromOffset = _a.startFromOffset, endToOffset = _a.endToOffset, startIndex = _a.startIndex; if (startIndex > 0) { var _b = doc.child(startIndex - 1), nodeSize = _b.nodeSize, textContent = _b.textContent; tr.delete(startFromOffset - nodeSize, startFromOffset) .split(tr.mapping.map(endToOffset)) .insert(tr.mapping.map(endToOffset), createTextNode$1(schema, textContent)); dispatch(tr); return true; } return false; }; }; Paragraph.prototype.commands = function () { return { indent: this.indent(), outdent: this.outdent(), }; }; Paragraph.prototype.keymaps = function () { return { Tab: this.indent(true)(), 'Shift-Tab': this.outdent(true)(), 'Mod-d': this.deleteLines(), 'Mod-D': this.deleteLines(), 'Alt-ArrowUp': this.moveUp(), 'Alt-ArrowDown': this.moveDown(), }; }; return Paragraph; }(Node$2)); var Text$1 = /** @class */ (function (_super) { __extends$1(Text, _super); function Text() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Text.prototype, "name", { get: function () { return 'text'; }, enumerable: false, configurable: true }); Object.defineProperty(Text.prototype, "schema", { get: function () { return { group: 'inline', }; }, enumerable: false, configurable: true }); return Text; }(Node$2)); var reHeading = /^#{1,6}\s/; var Heading$1 = /** @class */ (function (_super) { __extends$1(Heading, _super); function Heading() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Heading.prototype, "name", { get: function () { return 'heading'; }, enumerable: false, configurable: true }); Object.defineProperty(Heading.prototype, "schema", { get: function () { return { attrs: { level: { default: 1 }, seText: { default: false }, }, toDOM: function (_a) { var attrs = _a.attrs; var level = attrs.level, seText = attrs.seText; var classNames = "heading|heading" + level; if (seText) { classNames += '|delimiter|setext'; } return ['span', { class: clsWithMdPrefix.apply(void 0, classNames.split('|')) }, 0]; }, }; }, enumerable: false, configurable: true }); Heading.prototype.createHeadingText = function (level, text, curHeadingSyntax) { var textContent = text.replace(curHeadingSyntax, '').trim(); var headingText = ''; while (level > 0) { headingText += '#'; level -= 1; } return headingText + " " + textContent; }; Heading.prototype.commands = function () { var _this = this; return function (payload) { return function (state, dispatch) { var level = payload.level; var _a = getRangeInfo(state.selection), startFromOffset = _a.startFromOffset, endToOffset = _a.endToOffset, startIndex = _a.startIndex, endIndex = _a.endIndex; var tr = replaceTextNode({ state: state, from: startFromOffset, startIndex: startIndex, endIndex: endIndex, createText: function (textContent) { var matchedHeading = textContent.match(reHeading); var curHeadingSyntax = matchedHeading ? matchedHeading[0] : ''; return _this.createHeadingText(level, textContent, curHeadingSyntax); }, }); dispatch(tr.setSelection(createTextSelection(tr, tr.mapping.map(endToOffset)))); return true; }; }; }; return Heading; }(Mark)); var fencedCodeBlockSyntax = '```'; var CodeBlock$1 = /** @class */ (function (_super) { __extends$1(CodeBlock, _super); function CodeBlock() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(CodeBlock.prototype, "name", { get: function () { return 'codeBlock'; }, enumerable: false, configurable: true }); Object.defineProperty(CodeBlock.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('code-block') }, 0]; }, }; }, enumerable: false, configurable: true }); CodeBlock.prototype.commands = function () { return function () { return function (state, dispatch) { var selection = state.selection, schema = state.schema, tr = state.tr; var _a = getRangeInfo(selection), startFromOffset = _a.startFromOffset, endToOffset = _a.endToOffset; var fencedNode = createTextNode$1(schema, fencedCodeBlockSyntax); // add fenced start block tr.insert(startFromOffset, fencedNode).split(startFromOffset + fencedCodeBlockSyntax.length); // add fenced end block tr.split(tr.mapping.map(endToOffset)).insert(tr.mapping.map(endToOffset), fencedNode); dispatch(tr.setSelection( // subtract fenced syntax length and open, close tag(2) createTextSelection(tr, tr.mapping.map(endToOffset) - (fencedCodeBlockSyntax.length + 2)))); return true; }; }; }; CodeBlock.prototype.keepIndentation = function () { var _this = this; return function (_a, dispatch) { var selection = _a.selection, tr = _a.tr, doc = _a.doc, schema = _a.schema; var toastMark = _this.context.toastMark; var _b = getRangeInfo(selection), startFromOffset = _b.startFromOffset, endToOffset = _b.endToOffset, endIndex = _b.endIndex, from = _b.from, to = _b.to; var textContent = getTextContent(doc, endIndex); if (from === to && textContent.trim()) { var matched = textContent.match(/^\s+/); var mdNode = toastMark.findFirstNodeAtLine(endIndex + 1); if (isCodeBlockNode(mdNode) && matched) { var spaces = matched[0]; var slicedText = textContent.slice(to - startFromOffset); var node = createTextNode$1(schema, spaces + slicedText); splitAndExtendBlock(tr, endToOffset, slicedText, node); dispatch(tr); return true; } } return false; }; }; CodeBlock.prototype.keymaps = function () { var codeBlockCommand = this.commands()(); return { 'Shift-Mod-p': codeBlockCommand, 'Shift-Mod-P': codeBlockCommand, Enter: this.keepIndentation(), }; }; return CodeBlock; }(Mark)); var reEmptyTable = /\||\s/g; function createTableHeader(columnCount) { return [createTableRow(columnCount), createTableRow(columnCount, true)]; } function createTableBody$1(columnCount, rowCount) { var bodyRows = []; for (var i = 0; i < rowCount; i += 1) { bodyRows.push(createTableRow(columnCount)); } return bodyRows; } function createTableRow(columnCount, delim) { var row = '|'; for (var i = 0; i < columnCount; i += 1) { row += delim ? ' --- |' : ' |'; } return row; } function createTargetTypes(moveNext) { return moveNext ? { type: 'next', parentType: 'tableHead', childType: 'firstChild' } : { type: 'prev', parentType: 'tableBody', childType: 'lastChild' }; } var Table$1 = /** @class */ (function (_super) { __extends$1(Table, _super); function Table() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Table.prototype, "name", { get: function () { return 'table'; }, enumerable: false, configurable: true }); Object.defineProperty(Table.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('table') }, 0]; }, }; }, enumerable: false, configurable: true }); Table.prototype.extendTable = function () { var _this = this; return function (_a, dispatch) { var selection = _a.selection, doc = _a.doc, tr = _a.tr, schema = _a.schema; if (!selection.empty) { return false; } var _b = getRangeInfo(selection), endFromOffset = _b.endFromOffset, endToOffset = _b.endToOffset, endIndex = _b.endIndex, to = _b.to; var textContent = getTextContent(doc, endIndex); // should add `1` to line for the markdown parser // because markdown parser has `1`(not zero) as the start number var mdPos = [endIndex + 1, to - endFromOffset + 1]; var mdNode = _this.context.toastMark.findNodeAtPosition(mdPos); var cellNode = findClosestNode(mdNode, function (node) { return isTableCellNode(node) && (node.parent.type === 'tableDelimRow' || node.parent.parent.type === 'tableBody'); }); if (cellNode) { var isEmpty = !textContent.replace(reEmptyTable, '').trim(); var parent_1 = cellNode.parent; var columnCount = parent_1.parent.parent.columns.length; var row = createTableRow(columnCount); if (isEmpty) { tr.deleteRange(endFromOffset, endToOffset).split(tr.mapping.map(endToOffset)); } else { tr .split(endToOffset) .insert(tr.mapping.map(endToOffset), createTextNode$1(schema, row)) // should subtract `2` to selection end position considering ` |` text .setSelection(createTextSelection(tr, tr.mapping.map(endToOffset) - 2)); } dispatch(tr); return true; } return false; }; }; Table.prototype.moveTableCell = function (moveNext) { var _this = this; return function (_a, dispatch) { var selection = _a.selection, tr = _a.tr; var _b = getRangeInfo(selection), endFromOffset = _b.endFromOffset, endIndex = _b.endIndex, to = _b.to; var mdPos = [endIndex + 1, to - endFromOffset]; var mdNode = _this.context.toastMark.findNodeAtPosition(mdPos); var cellNode = findClosestNode(mdNode, function (node) { return isTableCellNode(node); }); if (cellNode) { var parent_2 = cellNode.parent; var _c = createTargetTypes(moveNext), type = _c.type, parentType = _c.parentType, childType = _c.childType; var chOffset = getMdEndCh(cellNode); if (cellNode[type]) { chOffset = getMdEndCh(cellNode[type]) - 1; } else { var row = !parent_2[type] && parent_2.parent.type === parentType ? parent_2.parent[type][childType] : parent_2[type]; if (type === 'next') { // if there is next row, the base offset would be end position of the next row's first child. // Otherwise, the base offset is zero. var baseOffset = row ? getMdEndCh(row[childType]) : 0; // calculate tag(open, close) position('2') for selection chOffset += baseOffset + 2; } else if (type === 'prev') { // if there is prev row, the target position would be '-4' for calculating ' |' characters and tag(open, close) // Otherwise, the target position is zero. chOffset = row ? -4 : 0; } } dispatch(tr.setSelection(createTextSelection(tr, endFromOffset + chOffset))); return true; } return false; }; }; Table.prototype.addTable = function () { return function (payload) { return function (_a, dispatch) { var selection = _a.selection, tr = _a.tr, schema = _a.schema; var _b = payload, columnCount = _b.columnCount, rowCount = _b.rowCount; var endToOffset = getRangeInfo(selection).endToOffset; var headerRows = createTableHeader(columnCount); var bodyRows = createTableBody$1(columnCount, rowCount - 1); var rows = __spreadArray$1(__spreadArray$1([], headerRows), bodyRows); rows.forEach(function (row) { tr.split(tr.mapping.map(endToOffset)).insert(tr.mapping.map(endToOffset), createTextNode$1(schema, row)); }); // should add `4` to selection position considering `| ` text and start block tag length dispatch(tr.setSelection(createTextSelection(tr, endToOffset + 4))); return true; }; }; }; Table.prototype.commands = function () { return { addTable: this.addTable() }; }; Table.prototype.keymaps = function () { return { Enter: this.extendTable(), Tab: this.moveTableCell(true), 'Shift-Tab': this.moveTableCell(false), }; }; return Table; }(Mark)); var thematicBreakSyntax = '***'; var ThematicBreak$1 = /** @class */ (function (_super) { __extends$1(ThematicBreak, _super); function ThematicBreak() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(ThematicBreak.prototype, "name", { get: function () { return 'thematicBreak'; }, enumerable: false, configurable: true }); Object.defineProperty(ThematicBreak.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('thematic-break') }, 0]; }, }; }, enumerable: false, configurable: true }); ThematicBreak.prototype.hr = function () { return function () { return function (state, dispatch) { var selection = state.selection, schema = state.schema, tr = state.tr; var _a = getRangeInfo(selection), from = _a.from, to = _a.to, endToOffset = _a.endToOffset; var node = createTextNode$1(schema, thematicBreakSyntax); tr .split(from) .replaceWith(tr.mapping.map(from), tr.mapping.map(to), node) .split(tr.mapping.map(to)).setSelection(createTextSelection(tr, tr.mapping.map(endToOffset))); dispatch(tr); return true; }; }; }; ThematicBreak.prototype.commands = function () { return { hr: this.hr() }; }; ThematicBreak.prototype.keymaps = function () { var lineCommand = this.hr()(); return { 'Mod-l': lineCommand, 'Mod-L': lineCommand }; }; return ThematicBreak; }(Mark)); function cannotBeListNode(_a, line) { var type = _a.type, sourcepos = _a.sourcepos; // eslint-disable-next-line prefer-destructuring var startLine = sourcepos[0][0]; return line <= startLine && (type === 'codeBlock' || type === 'heading' || type.match('table')); } var ListItem$1 = /** @class */ (function (_super) { __extends$1(ListItem, _super); function ListItem() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(ListItem.prototype, "name", { get: function () { return 'listItem'; }, enumerable: false, configurable: true }); Object.defineProperty(ListItem.prototype, "schema", { get: function () { return { attrs: { odd: { default: false }, even: { default: false }, listStyle: { default: false }, }, toDOM: function (_a) { var attrs = _a.attrs; var odd = attrs.odd, even = attrs.even, listStyle = attrs.listStyle; var classNames = 'list-item'; if (listStyle) { classNames += '|list-item-style'; } if (odd) { classNames += '|list-item-odd'; } if (even) { classNames += '|list-item-even'; } return ['span', { class: clsWithMdPrefix.apply(void 0, classNames.split('|')) }, 0]; }, }; }, enumerable: false, configurable: true }); ListItem.prototype.extendList = function () { var _this = this; return function (_a, dispatch) { var selection = _a.selection, doc = _a.doc, schema = _a.schema, tr = _a.tr; var toastMark = _this.context.toastMark; var _b = getRangeInfo(selection), to = _b.to, startFromOffset = _b.startFromOffset, endFromOffset = _b.endFromOffset, endIndex = _b.endIndex, endToOffset = _b.endToOffset; var textContent = getTextContent(doc, endIndex); var isList = reList.test(textContent); if (!isList || selection.from === startFromOffset || !selection.empty) { return false; } var isEmpty = !textContent.replace(reCanBeTaskList, '').trim(); if (isEmpty) { tr.deleteRange(endFromOffset, endToOffset).split(tr.mapping.map(endToOffset)); } else { var commandType = getListType(textContent); // should add `1` to line for the markdown parser // because markdown parser has `1`(not zero) as the start number var mdNode = toastMark.findFirstNodeAtLine(endIndex + 1); var slicedText = textContent.slice(to - endFromOffset); var context = { toastMark: toastMark, mdNode: mdNode, doc: doc, line: endIndex + 1 }; var _c = extendList[commandType](context), listSyntax = _c.listSyntax, changedResults = _c.changedResults; // change ordinal number of backward ordered list if (changedResults === null || changedResults === void 0 ? void 0 : changedResults.length) { // split the block tr.split(to); // set first ordered list info changedResults.unshift({ text: listSyntax + slicedText, line: endIndex + 1 }); _this.changeToListPerLine(tr, changedResults, { from: to, // don't subtract 1 because the line has increased through 'split' command. startLine: changedResults[0].line, endLine: last$1(changedResults).line, }); var pos = tr.mapping.map(endToOffset) - slicedText.length; tr.setSelection(createTextSelection(tr, pos)); } else { var node = createTextNode$1(schema, listSyntax + slicedText); splitAndExtendBlock(tr, endToOffset, slicedText, node); } } dispatch(tr); return true; }; }; ListItem.prototype.toList = function (commandType) { var _this = this; return function () { return function (_a, dispatch) { var doc = _a.doc, tr = _a.tr, selection = _a.selection; var toastMark = _this.context.toastMark; var rangeInfo = getRangeInfo(selection); // should add `1` to line for the markdown parser // because markdown parser has `1`(not zero) as the start number var startLine = rangeInfo.startIndex + 1; var endLine = rangeInfo.endIndex + 1; var endToOffset = rangeInfo.endToOffset; var skipLines = []; for (var line = startLine; line <= endLine; line += 1) { var mdNode = toastMark.findFirstNodeAtLine(line); if (mdNode && cannotBeListNode(mdNode, line)) { break; } // to skip unnecessary processing if (skipLines.indexOf(line) !== -1) { continue; } var context = { toastMark: toastMark, mdNode: mdNode, doc: doc, line: line, startLine: startLine }; var changedResults = (isListNode$1(mdNode) ? otherListToList[commandType](context) : otherNodeToList[commandType](context)).changedResults; var endOffset = _this.changeToListPerLine(tr, changedResults, { from: getNodeContentOffsetRange(doc, changedResults[0].line - 1).startOffset, startLine: changedResults[0].line, endLine: last$1(changedResults).line, indexDiff: 1, }); endToOffset = Math.max(endOffset, endToOffset); if (changedResults) { skipLines = skipLines.concat(changedResults.map(function (info) { return info.line; })); } } dispatch(tr.setSelection(createTextSelection(tr, tr.mapping.map(endToOffset)))); return true; }; }; }; ListItem.prototype.changeToListPerLine = function (tr, changedResults, _a) { var from = _a.from, startLine = _a.startLine, endLine = _a.endLine, _b = _a.indexDiff, indexDiff = _b === void 0 ? 0 : _b; var maxEndOffset = 0; var _loop_1 = function (i) { var _c = tr.doc.child(i), nodeSize = _c.nodeSize, content = _c.content; var mappedFrom = tr.mapping.map(from); var mappedTo = mappedFrom + content.size; var changedResult = changedResults.filter(function (result) { return result.line - indexDiff === i; })[0]; if (changedResult) { tr.replaceWith(mappedFrom, mappedTo, createTextNode$1(this_1.context.schema, changedResult.text)); maxEndOffset = Math.max(maxEndOffset, from + content.size); } from += nodeSize; }; var this_1 = this; for (var i = startLine - indexDiff; i <= endLine - indexDiff; i += 1) { _loop_1(i); } return maxEndOffset; }; ListItem.prototype.toggleTask = function () { var _this = this; return function (_a, dispatch) { var selection = _a.selection, tr = _a.tr, doc = _a.doc, schema = _a.schema; var toastMark = _this.context.toastMark; var _b = getRangeInfo(selection), startIndex = _b.startIndex, endIndex = _b.endIndex; var newTr = null; for (var i = startIndex; i <= endIndex; i += 1) { var mdNode = toastMark.findFirstNodeAtLine(i + 1); if (isListNode$1(mdNode) && mdNode.listData.task) { var _c = mdNode.listData, checked = _c.checked, padding = _c.padding; var stateChar = checked ? ' ' : 'x'; var mdPos = mdNode.sourcepos[0]; var startOffset = getNodeContentOffsetRange(doc, mdPos[0] - 1).startOffset; startOffset += mdPos[1] + padding; newTr = tr.replaceWith(startOffset, startOffset + 1, schema.text(stateChar)); } } if (newTr) { dispatch(newTr); return true; } return false; }; }; ListItem.prototype.commands = function () { return { bulletList: this.toList('bullet'), orderedList: this.toList('ordered'), taskList: this.toList('task'), }; }; ListItem.prototype.keymaps = function () { var bulletCommand = this.toList('bullet')(); var orderedCommand = this.toList('ordered')(); var taskCommand = this.toList('task')(); var togleTaskCommand = this.toggleTask(); return { 'Mod-u': bulletCommand, 'Mod-U': bulletCommand, 'Mod-o': orderedCommand, 'Mod-O': orderedCommand, 'alt-t': taskCommand, 'alt-T': taskCommand, 'Shift-Ctrl-x': togleTaskCommand, 'Shift-Ctrl-X': togleTaskCommand, Enter: this.extendList(), }; }; return ListItem; }(Mark)); function toggleMark(condition, syntax) { return function () { return function (_a, dispatch) { var tr = _a.tr, selection = _a.selection; var conditionFn = !isFunction_1(condition) ? function (text) { return condition.test(text); } : condition; var syntaxLen = syntax.length; var doc = tr.doc; var _b = resolveSelectionPos(selection), from = _b[0], to = _b[1]; var prevPos = Math.max(from - syntaxLen, 1); var nextPos = Math.min(to + syntaxLen, doc.content.size - 1); var slice = selection.content(); var textContent = slice.content.textBetween(0, slice.content.size, '\n'); var prevText = doc.textBetween(prevPos, from, '\n'); var nextText = doc.textBetween(to, nextPos, '\n'); textContent = "" + prevText + textContent + nextText; if (prevText && nextText && conditionFn(textContent)) { tr.delete(nextPos - syntaxLen, nextPos).delete(prevPos, prevPos + syntaxLen); } else { tr.insertText(syntax, to).insertText(syntax, from); var newSelection = selection.empty ? createTextSelection(tr, from + syntaxLen) : createTextSelection(tr, from + syntaxLen, to + syntaxLen); tr.setSelection(newSelection); } dispatch(tr); return true; }; }; } var reStrong = /^(\*{2}|_{2}).*([\s\S]*)\1$/m; var strongSyntax = '**'; var Strong$1 = /** @class */ (function (_super) { __extends$1(Strong, _super); function Strong() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Strong.prototype, "name", { get: function () { return 'strong'; }, enumerable: false, configurable: true }); Object.defineProperty(Strong.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('strong') }, 0]; }, }; }, enumerable: false, configurable: true }); Strong.prototype.bold = function () { return toggleMark(reStrong, strongSyntax); }; Strong.prototype.commands = function () { return { bold: this.bold() }; }; Strong.prototype.keymaps = function () { var boldCommand = this.bold()(); return { 'Mod-b': boldCommand, 'Mod-B': boldCommand }; }; return Strong; }(Mark)); var reStrike = /^(~{2}).*([\s\S]*)\1$/m; var strikeSyntax = '~~'; var Strike$1 = /** @class */ (function (_super) { __extends$1(Strike, _super); function Strike() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Strike.prototype, "name", { get: function () { return 'strike'; }, enumerable: false, configurable: true }); Object.defineProperty(Strike.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('strike') }, 0]; }, }; }, enumerable: false, configurable: true }); Strike.prototype.commands = function () { return toggleMark(reStrike, strikeSyntax); }; Strike.prototype.keymaps = function () { var strikeCommand = this.commands()(); return { 'Mod-s': strikeCommand, 'Mod-S': strikeCommand }; }; return Strike; }(Mark)); var reEmph = /^(\*|_).*([\s\S]*)\1$/m; var emphSyntax = '*'; var Emph$1 = /** @class */ (function (_super) { __extends$1(Emph, _super); function Emph() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Emph.prototype, "name", { get: function () { return 'emph'; }, enumerable: false, configurable: true }); Object.defineProperty(Emph.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('emph') }, 0]; }, }; }, enumerable: false, configurable: true }); Emph.prototype.italic = function () { return toggleMark(reEmph, emphSyntax); }; Emph.prototype.commands = function () { return { italic: this.italic() }; }; Emph.prototype.keymaps = function () { var italicCommand = this.italic()(); return { 'Mod-i': italicCommand, 'Mod-I': italicCommand }; }; return Emph; }(Mark)); var reCode = /^(`).*([\s\S]*)\1$/m; var codeSyntax = '`'; var Code$1 = /** @class */ (function (_super) { __extends$1(Code, _super); function Code() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Code.prototype, "name", { get: function () { return 'code'; }, enumerable: false, configurable: true }); Object.defineProperty(Code.prototype, "schema", { get: function () { return { attrs: { start: { default: false }, end: { default: false }, marked: { default: false }, }, toDOM: function (mark) { var _a = mark.attrs, start = _a.start, end = _a.end, marked = _a.marked; var classNames = 'code'; if (start) { classNames += '|delimiter|start'; } if (end) { classNames += '|delimiter|end'; } if (marked) { classNames += '|marked-text'; } return ['span', { class: clsWithMdPrefix.apply(void 0, classNames.split('|')) }, 0]; }, }; }, enumerable: false, configurable: true }); Code.prototype.commands = function () { return toggleMark(reCode, codeSyntax); }; Code.prototype.keymaps = function () { var codeCommand = this.commands()(); return { 'Shift-Mod-c': codeCommand, 'Shift-Mod-C': codeCommand }; }; return Code; }(Mark)); var Link$1 = /** @class */ (function (_super) { __extends$1(Link, _super); function Link() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Link.prototype, "name", { get: function () { return 'link'; }, enumerable: false, configurable: true }); Object.defineProperty(Link.prototype, "schema", { get: function () { return { attrs: { url: { default: false }, desc: { default: false }, }, toDOM: function (_a) { var attrs = _a.attrs; var url = attrs.url, desc = attrs.desc; var classNames = 'link'; if (url) { classNames += '|link-url|marked-text'; } if (desc) { classNames += '|link-desc|marked-text'; } return ['span', { class: clsWithMdPrefix.apply(void 0, classNames.split('|')) }, 0]; }, }; }, enumerable: false, configurable: true }); Link.prototype.addLinkOrImage = function (commandType) { return function (payload) { return function (_a, dispatch) { var selection = _a.selection, tr = _a.tr, schema = _a.schema; var _b = resolveSelectionPos(selection), from = _b[0], to = _b[1]; var _c = payload, linkText = _c.linkText, altText = _c.altText, linkUrl = _c.linkUrl, imageUrl = _c.imageUrl; var text = linkText; var url = linkUrl; var syntax = ''; if (commandType === 'image') { text = altText; url = imageUrl; syntax = '!'; } text = escapeTextForLink(text); syntax += "[" + text + "](" + url + ")"; dispatch(tr.replaceWith(from, to, createTextNode$1(schema, syntax))); return true; }; }; }; Link.prototype.commands = function () { return { addImage: this.addLinkOrImage('image'), addLink: this.addLinkOrImage('link'), }; }; return Link; }(Mark)); var TaskDelimiter = /** @class */ (function (_super) { __extends$1(TaskDelimiter, _super); function TaskDelimiter() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(TaskDelimiter.prototype, "name", { get: function () { return 'taskDelimiter'; }, enumerable: false, configurable: true }); Object.defineProperty(TaskDelimiter.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('delimiter', 'list-item') }, 0]; }, }; }, enumerable: false, configurable: true }); return TaskDelimiter; }(Mark)); var Delimiter = /** @class */ (function (_super) { __extends$1(Delimiter, _super); function Delimiter() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Delimiter.prototype, "name", { get: function () { return 'delimiter'; }, enumerable: false, configurable: true }); Object.defineProperty(Delimiter.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('delimiter') }, 0]; }, }; }, enumerable: false, configurable: true }); return Delimiter; }(Mark)); var Meta = /** @class */ (function (_super) { __extends$1(Meta, _super); function Meta() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Meta.prototype, "name", { get: function () { return 'meta'; }, enumerable: false, configurable: true }); Object.defineProperty(Meta.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('meta') }, 0]; }, }; }, enumerable: false, configurable: true }); return Meta; }(Mark)); var MarkedText = /** @class */ (function (_super) { __extends$1(MarkedText, _super); function MarkedText() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(MarkedText.prototype, "name", { get: function () { return 'markedText'; }, enumerable: false, configurable: true }); Object.defineProperty(MarkedText.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('marked-text') }, 0]; }, }; }, enumerable: false, configurable: true }); return MarkedText; }(Mark)); var TableCell = /** @class */ (function (_super) { __extends$1(TableCell, _super); function TableCell() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(TableCell.prototype, "name", { get: function () { return 'tableCell'; }, enumerable: false, configurable: true }); Object.defineProperty(TableCell.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('table-cell') }, 0]; }, }; }, enumerable: false, configurable: true }); return TableCell; }(Mark)); var Html = /** @class */ (function (_super) { __extends$1(Html, _super); function Html() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Html.prototype, "name", { get: function () { return 'html'; }, enumerable: false, configurable: true }); Object.defineProperty(Html.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('html') }, 0]; }, }; }, enumerable: false, configurable: true }); return Html; }(Mark)); var customBlockSyntax = '$$'; var CustomBlock$1 = /** @class */ (function (_super) { __extends$1(CustomBlock, _super); function CustomBlock() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(CustomBlock.prototype, "name", { get: function () { return 'customBlock'; }, enumerable: false, configurable: true }); Object.defineProperty(CustomBlock.prototype, "schema", { get: function () { return { toDOM: function () { return ['span', { class: clsWithMdPrefix('custom-block') }, 0]; }, }; }, enumerable: false, configurable: true }); CustomBlock.prototype.commands = function () { return function (payload) { return function (state, dispatch) { var selection = state.selection, schema = state.schema, tr = state.tr; var _a = getRangeInfo(selection), startFromOffset = _a.startFromOffset, endToOffset = _a.endToOffset; if (!(payload === null || payload === void 0 ? void 0 : payload.info)) { return false; } var customBlock = "" + customBlockSyntax + payload.info; var startNode = createTextNode$1(schema, customBlock); var endNode = createTextNode$1(schema, customBlockSyntax); tr.insert(startFromOffset, startNode).split(startFromOffset + customBlock.length); tr.split(tr.mapping.map(endToOffset)).insert(tr.mapping.map(endToOffset), endNode); dispatch(tr.setSelection(createTextSelection(tr, tr.mapping.map(endToOffset) - (customBlockSyntax.length + 2)))); return true; }; }; }; return CustomBlock; }(Mark)); var reTaskMarkerKey = /x|backspace/i; var reTaskMarker = /^\[(\s*)(x?)(\s*)\](?:\s+)/i; function smartTask(_a) { var schema = _a.schema, toastMark = _a.toastMark; return new Plugin({ props: { handleDOMEvents: { keyup: function (view, ev) { var _a; var _b = view.state, doc = _b.doc, tr = _b.tr, selection = _b.selection; if (selection.empty && reTaskMarkerKey.test(ev.key)) { var _c = getRangeInfo(selection), startIndex = _c.startIndex, startFromOffset = _c.startFromOffset, from = _c.from; // should add `1` to line for the markdown parser // because markdown parser has `1`(not zero) as the start number var mdPos = [startIndex + 1, from - startFromOffset + 1]; var mdNode = toastMark.findNodeAtPosition(mdPos); var paraNode = findClosestNode(mdNode, function (node) { var _a; return node.type === 'paragraph' && ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === 'item'; }); if ((_a = paraNode === null || paraNode === void 0 ? void 0 : paraNode.firstChild) === null || _a === void 0 ? void 0 : _a.literal) { var firstChild = paraNode.firstChild; var matched = firstChild.literal.match(reTaskMarker); if (matched) { var startMdPos = firstChild.sourcepos[0]; var startSpaces = matched[1], stateChar = matched[2], lastSpaces = matched[3]; var spaces = startSpaces.length + lastSpaces.length; var startOffset = getNodeContentOffsetRange(doc, startMdPos[0] - 1).startOffset; var startPos = startMdPos[1] + startOffset; if (stateChar) { var addedPos = spaces ? spaces + 1 : 0; tr.replaceWith(startPos, addedPos + startPos, schema.text(stateChar)); view.dispatch(tr); } else if (!spaces) { tr.insertText(' ', startPos); view.dispatch(tr); } } } } return false; }, }, }, }); } var EVENT_TYPE = 'cut'; var reLineEnding$2 = /\r\n|\n|\r/; var MdEditor = /** @class */ (function (_super) { __extends$1(MdEditor, _super); function MdEditor(eventEmitter, options) { var _this = _super.call(this, eventEmitter) || this; var toastMark = options.toastMark, _a = options.useCommandShortcut, useCommandShortcut = _a === void 0 ? true : _a, _b = options.mdPlugins, mdPlugins = _b === void 0 ? [] : _b; _this.editorType = 'markdown'; _this.el.classList.add('md-mode'); _this.toastMark = toastMark; _this.extraPlugins = mdPlugins; _this.specs = _this.createSpecs(); _this.schema = _this.createSchema(); _this.context = _this.createContext(); _this.keymaps = _this.createKeymaps(useCommandShortcut); _this.view = _this.createView(); _this.commands = _this.createCommands(); _this.specs.setContext(__assign$1(__assign$1({}, _this.context), { view: _this.view })); _this.createClipboard(); // To prevent unnecessary focus setting during initial rendering _this.eventEmitter.listen('changePreviewTabWrite', function (isMarkdownTabMounted) { return _this.toggleActive(true, isMarkdownTabMounted); }); _this.eventEmitter.listen('changePreviewTabPreview', function () { return _this.toggleActive(false); }); _this.initEvent(); return _this; } MdEditor.prototype.toggleActive = function (active, isMarkdownTabMounted) { toggleClass(this.el, 'active', active); if (active) { if (!isMarkdownTabMounted) { this.focus(); } } else { this.blur(); } }; MdEditor.prototype.createClipboard = function () { var _this = this; this.clipboard = document.createElement('textarea'); this.clipboard.className = cls('pseudo-clipboard'); this.clipboard.addEventListener('paste', function (ev) { var clipboardData = ev.clipboardData || window.clipboardData; var items = clipboardData && clipboardData.items; if (items) { var containRtfItem = toArray_1(items).some(function (item) { return item.kind === 'string' && item.type === 'text/rtf'; }); // if it contains rtf, it's most likely copy paste from office -> no image if (!containRtfItem) { var imageBlob = pasteImageOnly(items); if (imageBlob) { ev.preventDefault(); emitImageBlobHook(_this.eventEmitter, imageBlob, ev.type); } } } }); // process the pasted data in input event for IE11 this.clipboard.addEventListener('input', function (ev) { var text = ev.target.value; _this.replaceSelection(text); ev.preventDefault(); ev.target.value = ''; }); this.el.insertBefore(this.clipboard, this.view.dom); }; MdEditor.prototype.createContext = function () { return { toastMark: this.toastMark, schema: this.schema, eventEmitter: this.eventEmitter, }; }; MdEditor.prototype.createSpecs = function () { return new SpecManager([ new Doc$1(), new Paragraph$1(), new Widget(), new Text$1(), new Heading$1(), new BlockQuote$1(), new CodeBlock$1(), new CustomBlock$1(), new Table$1(), new TableCell(), new ThematicBreak$1(), new ListItem$1(), new Strong$1(), new Strike$1(), new Emph$1(), new Code$1(), new Link$1(), new Delimiter(), new TaskDelimiter(), new MarkedText(), new Meta(), new Html(), ]); }; MdEditor.prototype.createPlugins = function () { return __spreadArray$1([ syntaxHighlight(this.context), previewHighlight(this.context), smartTask(this.context) ], this.createPluginProps()).concat(this.defaultPlugins); }; MdEditor.prototype.createView = function () { var _this = this; return new EditorView(this.el, { state: this.createState(), dispatchTransaction: function (tr) { _this.updateMarkdown(tr); var state = _this.view.state.applyTransaction(tr).state; _this.view.updateState(state); _this.emitChangeEvent(tr); }, handleKeyDown: function (_, ev) { if ((ev.metaKey || ev.ctrlKey) && ev.key.toUpperCase() === 'V') { _this.clipboard.focus(); } _this.eventEmitter.emit('keydown', _this.editorType, ev); return false; }, handleDOMEvents: { copy: function (_, ev) { return _this.captureCopy(ev); }, cut: function (_, ev) { return _this.captureCopy(ev, EVENT_TYPE); }, scroll: function () { _this.eventEmitter.emit('scroll', 'editor'); return true; }, keyup: function (_, ev) { _this.eventEmitter.emit('keyup', _this.editorType, ev); return false; }, }, nodeViews: { widget: widgetNodeView, }, }); }; MdEditor.prototype.createCommands = function () { return this.specs.commands(this.view); }; MdEditor.prototype.captureCopy = function (ev, type) { ev.preventDefault(); var _a = this.view.state, selection = _a.selection, tr = _a.tr; if (selection.empty) { return true; } var text = this.getChanged(selection.content()); if (ev.clipboardData) { ev.clipboardData.setData('text/plain', text); } else { window.clipboardData.setData('Text', text); } if (type === EVENT_TYPE) { this.view.dispatch(tr.deleteSelection().scrollIntoView().setMeta('uiEvent', EVENT_TYPE)); } return true; }; MdEditor.prototype.updateMarkdown = function (tr) { var _this = this; if (tr.docChanged) { tr.steps.forEach(function (step, index) { if (step.slice && !(step instanceof ReplaceAroundStep)) { var doc = tr.docs[index]; var _a = [step.from, step.to], from = _a[0], to = _a[1]; var _b = getEditorToMdPos(doc, from, to), startPos = _b[0], endPos = _b[1]; var changed = _this.getChanged(step.slice); if (startPos[0] === endPos[0] && startPos[1] === endPos[1] && changed === '') { changed = '\n'; } var editResult = _this.toastMark.editMarkdown(startPos, endPos, changed); _this.eventEmitter.emit('updatePreview', editResult); tr.setMeta('editResult', editResult).scrollIntoView(); } }); } }; MdEditor.prototype.getChanged = function (slice) { var changed = ''; var from = 0; var to = slice.content.size; slice.content.nodesBetween(from, to, function (node, pos) { if (node.isText) { changed += node.text.slice(Math.max(from, pos) - pos, to - pos); } else if (node.isBlock && pos > 0) { changed += '\n'; } }); return changed; }; MdEditor.prototype.setSelection = function (start, end) { if (end === void 0) { end = start; } var tr = this.view.state.tr; var _a = getMdToEditorPos(tr.doc, start, end), from = _a[0], to = _a[1]; this.view.dispatch(tr.setSelection(createTextSelection(tr, from, to)).scrollIntoView()); }; MdEditor.prototype.replaceSelection = function (text, start, end) { var newTr; var _a = this.view.state, tr = _a.tr, schema = _a.schema, doc = _a.doc; var lineTexts = text.split(reLineEnding$2); var nodes = lineTexts.map(function (lineText) { return createParagraph(schema, createNodesWithWidget(lineText, schema)); }); var slice = new Slice(Fragment.from(nodes), 1, 1); this.focus(); if (start && end) { var _b = getMdToEditorPos(doc, start, end), from = _b[0], to = _b[1]; newTr = tr.replaceRange(from, to, slice); } else { newTr = tr.replaceSelection(slice); } this.view.dispatch(newTr.scrollIntoView()); }; MdEditor.prototype.deleteSelection = function (start, end) { var newTr; var _a = this.view.state, tr = _a.tr, doc = _a.doc; if (start && end) { var _b = getMdToEditorPos(doc, start, end), from = _b[0], to = _b[1]; newTr = tr.deleteRange(from, to); } else { newTr = tr.deleteSelection(); } this.view.dispatch(newTr.scrollIntoView()); }; MdEditor.prototype.getSelectedText = function (start, end) { var _a = this.view.state, doc = _a.doc, selection = _a.selection; var from = selection.from, to = selection.to; if (start && end) { var pos = getMdToEditorPos(doc, start, end); from = pos[0]; to = pos[1]; } return doc.textBetween(from, to, '\n'); }; MdEditor.prototype.getSelection = function () { var _a = this.view.state.selection, from = _a.from, to = _a.to; return getEditorToMdPos(this.view.state.tr.doc, from, to); }; MdEditor.prototype.setMarkdown = function (markdown, cursorToEnd) { if (cursorToEnd === void 0) { cursorToEnd = true; } var lineTexts = markdown.split(reLineEnding$2); var _a = this.view.state, tr = _a.tr, doc = _a.doc, schema = _a.schema; var nodes = lineTexts.map(function (lineText) { return createParagraph(schema, createNodesWithWidget(lineText, schema)); }); this.view.dispatch(tr.replaceWith(0, doc.content.size, nodes)); if (cursorToEnd) { this.moveCursorToEnd(true); } }; MdEditor.prototype.addWidget = function (node, style, mdPos) { var _a = this.view.state, tr = _a.tr, doc = _a.doc, selection = _a.selection; var pos = mdPos ? getMdToEditorPos(doc, mdPos, mdPos)[0] : selection.to; this.view.dispatch(tr.setMeta('widget', { pos: pos, node: node, style: style })); }; MdEditor.prototype.replaceWithWidget = function (start, end, text) { var _a = this.view.state, tr = _a.tr, schema = _a.schema, doc = _a.doc; var pos = getMdToEditorPos(doc, start, end); var nodes = createNodesWithWidget(text, schema); this.view.dispatch(tr.replaceWith(pos[0], pos[1], nodes)); }; MdEditor.prototype.getRangeInfoOfNode = function (pos) { var _a = this.view.state, doc = _a.doc, selection = _a.selection; var mdPos = pos || getEditorToMdPos(doc, selection.from)[0]; var mdNode = this.toastMark.findNodeAtPosition(mdPos); if (mdNode.type === 'text' && mdNode.parent.type !== 'paragraph') { mdNode = mdNode.parent; } // add 1 sync for prosemirror position mdNode.sourcepos[1][1] += 1; return { range: mdNode.sourcepos, type: mdNode.type }; }; MdEditor.prototype.getMarkdown = function () { return this.toastMark .getLineTexts() .map(function (lineText) { return unwrapWidgetSyntax(lineText); }) .join('\n'); }; MdEditor.prototype.getToastMark = function () { return this.toastMark; }; return MdEditor; }(EditorBase)); /** * @fileoverview Get event collection for specific HTML element * @author NHN FE Development Lab */ var EVENT_KEY = '_feEventKey'; /** * Get event collection for specific HTML element * @param {HTMLElement} element - HTML element * @param {string} type - event type * @returns {array} * @private */ function safeEvent$2(element, type) { var events = element[EVENT_KEY]; var handlers; if (!events) { events = element[EVENT_KEY] = {}; } handlers = events[type]; if (!handlers) { handlers = events[type] = []; } return handlers; } var _safeEvent = safeEvent$2; /** * @fileoverview Unbind DOM events * @author NHN FE Development Lab */ var isString$1 = isString_1; var forEach$1 = forEach_1; var safeEvent$1 = _safeEvent; /** * Unbind DOM events * If a handler function is not passed, remove all events of that type. * @param {HTMLElement} element - element to unbind events * @param {(string|object)} types - Space splitted events names or eventName:handler object * @param {function} [handler] - handler function * @memberof module:domEvent * @example * // Following the example of domEvent#on * * // Unbind one event from an element. * off(div, 'click', toggle); * * // Unbind multiple events with a same handler from multiple elements at once. * // Use event names splitted by a space. * off(element, 'mouseenter mouseleave', changeColor); * * // Unbind multiple events with different handlers from an element at once. * // Use an object which of key is an event name and value is a handler function. * off(div, { * keydown: highlight, * keyup: dehighlight * }); * * // Unbind events without handlers. * off(div, 'drag'); */ function off(element, types, handler) { if (isString$1(types)) { forEach$1(types.split(/\s+/g), function(type) { unbindEvent(element, type, handler); }); return; } forEach$1(types, function(func, type) { unbindEvent(element, type, func); }); } /** * Unbind DOM events * If a handler function is not passed, remove all events of that type. * @param {HTMLElement} element - element to unbind events * @param {string} type - events name * @param {function} [handler] - handler function * @private */ function unbindEvent(element, type, handler) { var events = safeEvent$1(element, type); var index; if (!handler) { forEach$1(events, function(item) { removeHandler(element, type, item.wrappedHandler); }); events.splice(0, events.length); } else { forEach$1(events, function(item, idx) { if (handler === item.handler) { removeHandler(element, type, item.wrappedHandler); index = idx; return false; } return true; }); events.splice(index, 1); } } /** * Remove an event handler * @param {HTMLElement} element - An element to remove an event * @param {string} type - event type * @param {function} handler - event handler * @private */ function removeHandler(element, type, handler) { if ('removeEventListener' in element) { element.removeEventListener(type, handler); } else if ('detachEvent' in element) { element.detachEvent('on' + type, handler); } } var off_1 = off; /** * @fileoverview Bind DOM events * @author NHN FE Development Lab */ var isString = isString_1; var forEach = forEach_1; var safeEvent = _safeEvent; /** * Bind DOM events. * @param {HTMLElement} element - element to bind events * @param {(string|object)} types - Space splitted events names or eventName:handler object * @param {(function|object)} handler - handler function or context for handler method * @param {object} [context] context - context for handler method. * @memberof module:domEvent * @example * const div = document.querySelector('div'); * * // Bind one event to an element. * on(div, 'click', toggle); * * // Bind multiple events with a same handler to multiple elements at once. * // Use event names splitted by a space. * on(div, 'mouseenter mouseleave', changeColor); * * // Bind multiple events with different handlers to an element at once. * // Use an object which of key is an event name and value is a handler function. * on(div, { * keydown: highlight, * keyup: dehighlight * }); * * // Set a context for handler method. * const name = 'global'; * const repository = {name: 'CodeSnippet'}; * on(div, 'drag', function() { * console.log(this.name); * }, repository); * // Result when you drag a div: "CodeSnippet" */ function on(element, types, handler, context) { if (isString(types)) { forEach(types.split(/\s+/g), function(type) { bindEvent(element, type, handler, context); }); return; } forEach(types, function(func, type) { bindEvent(element, type, func, handler); }); } /** * Bind DOM events * @param {HTMLElement} element - element to bind events * @param {string} type - events name * @param {function} handler - handler function or context for handler method * @param {object} [context] context - context for handler method. * @private */ function bindEvent(element, type, handler, context) { /** * Event handler * @param {Event} e - event object */ function eventHandler(e) { handler.call(context || element, e || window.event); } if ('addEventListener' in element) { element.addEventListener(type, eventHandler); } else if ('attachEvent' in element) { element.attachEvent('on' + type, eventHandler); } memorizeHandler(element, type, handler, eventHandler); } /** * Memorize DOM event handler for unbinding. * @param {HTMLElement} element - element to bind events * @param {string} type - events name * @param {function} handler - handler function that user passed at on() use * @param {function} wrappedHandler - handler function that wrapped by domevent for implementing some features * @private */ function memorizeHandler(element, type, handler, wrappedHandler) { var events = safeEvent(element, type); var existInEvents = false; forEach(events, function(obj) { if (obj.handler === handler) { existInEvents = true; return false; } return true; }); if (!existInEvents) { events.push({ handler: handler, wrappedHandler: wrappedHandler }); } } var on_1 = on; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; var encodeCache = {}; // Create a lookup array where anything but characters in `chars` string // and alphanumeric chars is percent-encoded. // function getEncodeCache(exclude) { var i, ch, cache = encodeCache[exclude]; if (cache) { return cache; } cache = encodeCache[exclude] = []; for (i = 0; i < 128; i++) { ch = String.fromCharCode(i); if (/^[0-9a-z]$/i.test(ch)) { // always allow unencoded alphanumeric characters cache.push(ch); } else { cache.push('%' + ('0' + i.toString(16).toUpperCase()).slice(-2)); } } for (i = 0; i < exclude.length; i++) { cache[exclude.charCodeAt(i)] = exclude[i]; } return cache; } // Encode unsafe characters with percent-encoding, skipping already // encoded sequences. // // - string - string to encode // - exclude - list of characters to ignore (in addition to a-zA-Z0-9) // - keepEscaped - don't encode '%' in a correct escape sequence (default: true) // function encode$1(string, exclude, keepEscaped) { var i, l, code, nextCode, cache, result = ''; if (typeof exclude !== 'string') { // encode(string, keepEscaped) keepEscaped = exclude; exclude = encode$1.defaultChars; } if (typeof keepEscaped === 'undefined') { keepEscaped = true; } cache = getEncodeCache(exclude); for (i = 0, l = string.length; i < l; i++) { code = string.charCodeAt(i); if (keepEscaped && code === 0x25 /* % */ && i + 2 < l) { if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) { result += string.slice(i, i + 3); i += 2; continue; } } if (code < 128) { result += cache[code]; continue; } if (code >= 0xD800 && code <= 0xDFFF) { if (code >= 0xD800 && code <= 0xDBFF && i + 1 < l) { nextCode = string.charCodeAt(i + 1); if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) { result += encodeURIComponent(string[i] + string[i + 1]); i++; continue; } } result += '%EF%BF%BD'; continue; } result += encodeURIComponent(string[i]); } return result; } encode$1.defaultChars = ";/?:@&=+$,-_.!~*'()#"; encode$1.componentChars = "-_.!~*'()"; var encode_1 = encode$1; var lib = {}; var decode = {}; var Aacute$1 = "Á"; var aacute$1 = "á"; var Abreve = "Ă"; var abreve = "ă"; var ac = "∾"; var acd = "∿"; var acE = "∾̳"; var Acirc$1 = "Â"; var acirc$1 = "â"; var acute$1 = "´"; var Acy = "А"; var acy = "а"; var AElig$1 = "Æ"; var aelig$1 = "æ"; var af = "⁡"; var Afr = "𝔄"; var afr = "𝔞"; var Agrave$1 = "À"; var agrave$1 = "à"; var alefsym = "ℵ"; var aleph = "ℵ"; var Alpha = "Α"; var alpha = "α"; var Amacr = "Ā"; var amacr = "ā"; var amalg = "⨿"; var amp$2 = "&"; var AMP$1 = "&"; var andand = "⩕"; var And = "⩓"; var and = "∧"; var andd = "⩜"; var andslope = "⩘"; var andv = "⩚"; var ang = "∠"; var ange = "⦤"; var angle = "∠"; var angmsdaa = "⦨"; var angmsdab = "⦩"; var angmsdac = "⦪"; var angmsdad = "⦫"; var angmsdae = "⦬"; var angmsdaf = "⦭"; var angmsdag = "⦮"; var angmsdah = "⦯"; var angmsd = "∡"; var angrt = "∟"; var angrtvb = "⊾"; var angrtvbd = "⦝"; var angsph = "∢"; var angst = "Å"; var angzarr = "⍼"; var Aogon = "Ą"; var aogon = "ą"; var Aopf = "𝔸"; var aopf = "𝕒"; var apacir = "⩯"; var ap = "≈"; var apE = "⩰"; var ape = "≊"; var apid = "≋"; var apos$1 = "'"; var ApplyFunction = "⁡"; var approx = "≈"; var approxeq = "≊"; var Aring$1 = "Å"; var aring$1 = "å"; var Ascr = "𝒜"; var ascr = "𝒶"; var Assign = "≔"; var ast = "*"; var asymp = "≈"; var asympeq = "≍"; var Atilde$1 = "Ã"; var atilde$1 = "ã"; var Auml$1 = "Ä"; var auml$1 = "ä"; var awconint = "∳"; var awint = "⨑"; var backcong = "≌"; var backepsilon = "϶"; var backprime = "‵"; var backsim = "∽"; var backsimeq = "⋍"; var Backslash = "∖"; var Barv = "⫧"; var barvee = "⊽"; var barwed = "⌅"; var Barwed = "⌆"; var barwedge = "⌅"; var bbrk = "⎵"; var bbrktbrk = "⎶"; var bcong = "≌"; var Bcy = "Б"; var bcy = "б"; var bdquo = "„"; var becaus = "∵"; var because = "∵"; var Because = "∵"; var bemptyv = "⦰"; var bepsi = "϶"; var bernou = "ℬ"; var Bernoullis = "ℬ"; var Beta = "Β"; var beta = "β"; var beth = "ℶ"; var between = "≬"; var Bfr = "𝔅"; var bfr = "𝔟"; var bigcap = "⋂"; var bigcirc = "◯"; var bigcup = "⋃"; var bigodot = "⨀"; var bigoplus = "⨁"; var bigotimes = "⨂"; var bigsqcup = "⨆"; var bigstar = "★"; var bigtriangledown = "▽"; var bigtriangleup = "△"; var biguplus = "⨄"; var bigvee = "⋁"; var bigwedge = "⋀"; var bkarow = "⤍"; var blacklozenge = "⧫"; var blacksquare = "▪"; var blacktriangle = "▴"; var blacktriangledown = "▾"; var blacktriangleleft = "◂"; var blacktriangleright = "▸"; var blank = "␣"; var blk12 = "▒"; var blk14 = "░"; var blk34 = "▓"; var block = "█"; var bne = "=⃥"; var bnequiv = "≡⃥"; var bNot = "⫭"; var bnot = "⌐"; var Bopf = "𝔹"; var bopf = "𝕓"; var bot = "⊥"; var bottom = "⊥"; var bowtie = "⋈"; var boxbox = "⧉"; var boxdl = "┐"; var boxdL = "╕"; var boxDl = "╖"; var boxDL = "╗"; var boxdr = "┌"; var boxdR = "╒"; var boxDr = "╓"; var boxDR = "╔"; var boxh = "─"; var boxH = "═"; var boxhd = "┬"; var boxHd = "╤"; var boxhD = "╥"; var boxHD = "╦"; var boxhu = "┴"; var boxHu = "╧"; var boxhU = "╨"; var boxHU = "╩"; var boxminus = "⊟"; var boxplus = "⊞"; var boxtimes = "⊠"; var boxul = "┘"; var boxuL = "╛"; var boxUl = "╜"; var boxUL = "╝"; var boxur = "└"; var boxuR = "╘"; var boxUr = "╙"; var boxUR = "╚"; var boxv = "│"; var boxV = "║"; var boxvh = "┼"; var boxvH = "╪"; var boxVh = "╫"; var boxVH = "╬"; var boxvl = "┤"; var boxvL = "╡"; var boxVl = "╢"; var boxVL = "╣"; var boxvr = "├"; var boxvR = "╞"; var boxVr = "╟"; var boxVR = "╠"; var bprime = "‵"; var breve = "˘"; var Breve = "˘"; var brvbar$1 = "¦"; var bscr = "𝒷"; var Bscr = "ℬ"; var bsemi = "⁏"; var bsim = "∽"; var bsime = "⋍"; var bsolb = "⧅"; var bsol = "\\"; var bsolhsub = "⟈"; var bull = "•"; var bullet = "•"; var bump = "≎"; var bumpE = "⪮"; var bumpe = "≏"; var Bumpeq = "≎"; var bumpeq = "≏"; var Cacute = "Ć"; var cacute = "ć"; var capand = "⩄"; var capbrcup = "⩉"; var capcap = "⩋"; var cap = "∩"; var Cap = "⋒"; var capcup = "⩇"; var capdot = "⩀"; var CapitalDifferentialD = "ⅅ"; var caps = "∩︀"; var caret = "⁁"; var caron = "ˇ"; var Cayleys = "ℭ"; var ccaps = "⩍"; var Ccaron = "Č"; var ccaron = "č"; var Ccedil$1 = "Ç"; var ccedil$1 = "ç"; var Ccirc = "Ĉ"; var ccirc = "ĉ"; var Cconint = "∰"; var ccups = "⩌"; var ccupssm = "⩐"; var Cdot = "Ċ"; var cdot = "ċ"; var cedil$1 = "¸"; var Cedilla = "¸"; var cemptyv = "⦲"; var cent$1 = "¢"; var centerdot = "·"; var CenterDot = "·"; var cfr = "𝔠"; var Cfr = "ℭ"; var CHcy = "Ч"; var chcy = "ч"; var check = "✓"; var checkmark = "✓"; var Chi = "Χ"; var chi = "χ"; var circ = "ˆ"; var circeq = "≗"; var circlearrowleft = "↺"; var circlearrowright = "↻"; var circledast = "⊛"; var circledcirc = "⊚"; var circleddash = "⊝"; var CircleDot = "⊙"; var circledR = "®"; var circledS = "Ⓢ"; var CircleMinus = "⊖"; var CirclePlus = "⊕"; var CircleTimes = "⊗"; var cir = "○"; var cirE = "⧃"; var cire = "≗"; var cirfnint = "⨐"; var cirmid = "⫯"; var cirscir = "⧂"; var ClockwiseContourIntegral = "∲"; var CloseCurlyDoubleQuote = "”"; var CloseCurlyQuote = "’"; var clubs = "♣"; var clubsuit = "♣"; var colon = ":"; var Colon = "∷"; var Colone = "⩴"; var colone = "≔"; var coloneq = "≔"; var comma = ","; var commat = "@"; var comp = "∁"; var compfn = "∘"; var complement = "∁"; var complexes = "ℂ"; var cong = "≅"; var congdot = "⩭"; var Congruent = "≡"; var conint = "∮"; var Conint = "∯"; var ContourIntegral = "∮"; var copf = "𝕔"; var Copf = "ℂ"; var coprod = "∐"; var Coproduct = "∐"; var copy$1 = "©"; var COPY$1 = "©"; var copysr = "℗"; var CounterClockwiseContourIntegral = "∳"; var crarr = "↵"; var cross = "✗"; var Cross = "⨯"; var Cscr = "𝒞"; var cscr = "𝒸"; var csub = "⫏"; var csube = "⫑"; var csup = "⫐"; var csupe = "⫒"; var ctdot = "⋯"; var cudarrl = "⤸"; var cudarrr = "⤵"; var cuepr = "⋞"; var cuesc = "⋟"; var cularr = "↶"; var cularrp = "⤽"; var cupbrcap = "⩈"; var cupcap = "⩆"; var CupCap = "≍"; var cup = "∪"; var Cup = "⋓"; var cupcup = "⩊"; var cupdot = "⊍"; var cupor = "⩅"; var cups = "∪︀"; var curarr = "↷"; var curarrm = "⤼"; var curlyeqprec = "⋞"; var curlyeqsucc = "⋟"; var curlyvee = "⋎"; var curlywedge = "⋏"; var curren$1 = "¤"; var curvearrowleft = "↶"; var curvearrowright = "↷"; var cuvee = "⋎"; var cuwed = "⋏"; var cwconint = "∲"; var cwint = "∱"; var cylcty = "⌭"; var dagger = "†"; var Dagger = "‡"; var daleth = "ℸ"; var darr = "↓"; var Darr = "↡"; var dArr = "⇓"; var dash = "‐"; var Dashv = "⫤"; var dashv = "⊣"; var dbkarow = "⤏"; var dblac = "˝"; var Dcaron = "Ď"; var dcaron = "ď"; var Dcy = "Д"; var dcy = "д"; var ddagger = "‡"; var ddarr = "⇊"; var DD = "ⅅ"; var dd = "ⅆ"; var DDotrahd = "⤑"; var ddotseq = "⩷"; var deg$1 = "°"; var Del = "∇"; var Delta = "Δ"; var delta = "δ"; var demptyv = "⦱"; var dfisht = "⥿"; var Dfr = "𝔇"; var dfr = "𝔡"; var dHar = "⥥"; var dharl = "⇃"; var dharr = "⇂"; var DiacriticalAcute = "´"; var DiacriticalDot = "˙"; var DiacriticalDoubleAcute = "˝"; var DiacriticalGrave = "`"; var DiacriticalTilde = "˜"; var diam = "⋄"; var diamond = "⋄"; var Diamond = "⋄"; var diamondsuit = "♦"; var diams = "♦"; var die = "¨"; var DifferentialD = "ⅆ"; var digamma = "ϝ"; var disin = "⋲"; var div = "÷"; var divide$1 = "÷"; var divideontimes = "⋇"; var divonx = "⋇"; var DJcy = "Ђ"; var djcy = "ђ"; var dlcorn = "⌞"; var dlcrop = "⌍"; var dollar = "$"; var Dopf = "𝔻"; var dopf = "𝕕"; var Dot = "¨"; var dot = "˙"; var DotDot = "⃜"; var doteq = "≐"; var doteqdot = "≑"; var DotEqual = "≐"; var dotminus = "∸"; var dotplus = "∔"; var dotsquare = "⊡"; var doublebarwedge = "⌆"; var DoubleContourIntegral = "∯"; var DoubleDot = "¨"; var DoubleDownArrow = "⇓"; var DoubleLeftArrow = "⇐"; var DoubleLeftRightArrow = "⇔"; var DoubleLeftTee = "⫤"; var DoubleLongLeftArrow = "⟸"; var DoubleLongLeftRightArrow = "⟺"; var DoubleLongRightArrow = "⟹"; var DoubleRightArrow = "⇒"; var DoubleRightTee = "⊨"; var DoubleUpArrow = "⇑"; var DoubleUpDownArrow = "⇕"; var DoubleVerticalBar = "∥"; var DownArrowBar = "⤓"; var downarrow = "↓"; var DownArrow = "↓"; var Downarrow = "⇓"; var DownArrowUpArrow = "⇵"; var DownBreve = "̑"; var downdownarrows = "⇊"; var downharpoonleft = "⇃"; var downharpoonright = "⇂"; var DownLeftRightVector = "⥐"; var DownLeftTeeVector = "⥞"; var DownLeftVectorBar = "⥖"; var DownLeftVector = "↽"; var DownRightTeeVector = "⥟"; var DownRightVectorBar = "⥗"; var DownRightVector = "⇁"; var DownTeeArrow = "↧"; var DownTee = "⊤"; var drbkarow = "⤐"; var drcorn = "⌟"; var drcrop = "⌌"; var Dscr = "𝒟"; var dscr = "𝒹"; var DScy = "Ѕ"; var dscy = "ѕ"; var dsol = "⧶"; var Dstrok = "Đ"; var dstrok = "đ"; var dtdot = "⋱"; var dtri = "▿"; var dtrif = "▾"; var duarr = "⇵"; var duhar = "⥯"; var dwangle = "⦦"; var DZcy = "Џ"; var dzcy = "џ"; var dzigrarr = "⟿"; var Eacute$1 = "É"; var eacute$1 = "é"; var easter = "⩮"; var Ecaron = "Ě"; var ecaron = "ě"; var Ecirc$1 = "Ê"; var ecirc$1 = "ê"; var ecir = "≖"; var ecolon = "≕"; var Ecy = "Э"; var ecy = "э"; var eDDot = "⩷"; var Edot = "Ė"; var edot = "ė"; var eDot = "≑"; var ee = "ⅇ"; var efDot = "≒"; var Efr = "𝔈"; var efr = "𝔢"; var eg = "⪚"; var Egrave$1 = "È"; var egrave$1 = "è"; var egs = "⪖"; var egsdot = "⪘"; var el = "⪙"; var Element$1 = "∈"; var elinters = "⏧"; var ell = "ℓ"; var els = "⪕"; var elsdot = "⪗"; var Emacr = "Ē"; var emacr = "ē"; var empty = "∅"; var emptyset = "∅"; var EmptySmallSquare = "◻"; var emptyv = "∅"; var EmptyVerySmallSquare = "▫"; var emsp13 = " "; var emsp14 = " "; var emsp = " "; var ENG = "Ŋ"; var eng = "ŋ"; var ensp = " "; var Eogon = "Ę"; var eogon = "ę"; var Eopf = "𝔼"; var eopf = "𝕖"; var epar = "⋕"; var eparsl = "⧣"; var eplus = "⩱"; var epsi = "ε"; var Epsilon = "Ε"; var epsilon = "ε"; var epsiv = "ϵ"; var eqcirc = "≖"; var eqcolon = "≕"; var eqsim = "≂"; var eqslantgtr = "⪖"; var eqslantless = "⪕"; var Equal = "⩵"; var equals = "="; var EqualTilde = "≂"; var equest = "≟"; var Equilibrium = "⇌"; var equiv = "≡"; var equivDD = "⩸"; var eqvparsl = "⧥"; var erarr = "⥱"; var erDot = "≓"; var escr = "ℯ"; var Escr = "ℰ"; var esdot = "≐"; var Esim = "⩳"; var esim = "≂"; var Eta = "Η"; var eta = "η"; var ETH$1 = "Ð"; var eth$1 = "ð"; var Euml$1 = "Ë"; var euml$1 = "ë"; var euro = "€"; var excl = "!"; var exist = "∃"; var Exists = "∃"; var expectation = "ℰ"; var exponentiale = "ⅇ"; var ExponentialE = "ⅇ"; var fallingdotseq = "≒"; var Fcy = "Ф"; var fcy = "ф"; var female = "♀"; var ffilig = "ffi"; var fflig = "ff"; var ffllig = "ffl"; var Ffr = "𝔉"; var ffr = "𝔣"; var filig = "fi"; var FilledSmallSquare = "◼"; var FilledVerySmallSquare = "▪"; var fjlig = "fj"; var flat = "♭"; var fllig = "fl"; var fltns = "▱"; var fnof = "ƒ"; var Fopf = "𝔽"; var fopf = "𝕗"; var forall = "∀"; var ForAll = "∀"; var fork = "⋔"; var forkv = "⫙"; var Fouriertrf = "ℱ"; var fpartint = "⨍"; var frac12$1 = "½"; var frac13 = "⅓"; var frac14$1 = "¼"; var frac15 = "⅕"; var frac16 = "⅙"; var frac18 = "⅛"; var frac23 = "⅔"; var frac25 = "⅖"; var frac34$1 = "¾"; var frac35 = "⅗"; var frac38 = "⅜"; var frac45 = "⅘"; var frac56 = "⅚"; var frac58 = "⅝"; var frac78 = "⅞"; var frasl = "⁄"; var frown = "⌢"; var fscr = "𝒻"; var Fscr = "ℱ"; var gacute = "ǵ"; var Gamma = "Γ"; var gamma = "γ"; var Gammad = "Ϝ"; var gammad = "ϝ"; var gap = "⪆"; var Gbreve = "Ğ"; var gbreve = "ğ"; var Gcedil = "Ģ"; var Gcirc = "Ĝ"; var gcirc = "ĝ"; var Gcy = "Г"; var gcy = "г"; var Gdot = "Ġ"; var gdot = "ġ"; var ge = "≥"; var gE = "≧"; var gEl = "⪌"; var gel = "⋛"; var geq = "≥"; var geqq = "≧"; var geqslant = "⩾"; var gescc = "⪩"; var ges = "⩾"; var gesdot = "⪀"; var gesdoto = "⪂"; var gesdotol = "⪄"; var gesl = "⋛︀"; var gesles = "⪔"; var Gfr = "𝔊"; var gfr = "𝔤"; var gg = "≫"; var Gg = "⋙"; var ggg = "⋙"; var gimel = "ℷ"; var GJcy = "Ѓ"; var gjcy = "ѓ"; var gla = "⪥"; var gl = "≷"; var glE = "⪒"; var glj = "⪤"; var gnap = "⪊"; var gnapprox = "⪊"; var gne = "⪈"; var gnE = "≩"; var gneq = "⪈"; var gneqq = "≩"; var gnsim = "⋧"; var Gopf = "𝔾"; var gopf = "𝕘"; var grave = "`"; var GreaterEqual = "≥"; var GreaterEqualLess = "⋛"; var GreaterFullEqual = "≧"; var GreaterGreater = "⪢"; var GreaterLess = "≷"; var GreaterSlantEqual = "⩾"; var GreaterTilde = "≳"; var Gscr = "𝒢"; var gscr = "ℊ"; var gsim = "≳"; var gsime = "⪎"; var gsiml = "⪐"; var gtcc = "⪧"; var gtcir = "⩺"; var gt$2 = ">"; var GT$1 = ">"; var Gt = "≫"; var gtdot = "⋗"; var gtlPar = "⦕"; var gtquest = "⩼"; var gtrapprox = "⪆"; var gtrarr = "⥸"; var gtrdot = "⋗"; var gtreqless = "⋛"; var gtreqqless = "⪌"; var gtrless = "≷"; var gtrsim = "≳"; var gvertneqq = "≩︀"; var gvnE = "≩︀"; var Hacek = "ˇ"; var hairsp = " "; var half = "½"; var hamilt = "ℋ"; var HARDcy = "Ъ"; var hardcy = "ъ"; var harrcir = "⥈"; var harr = "↔"; var hArr = "⇔"; var harrw = "↭"; var Hat = "^"; var hbar = "ℏ"; var Hcirc = "Ĥ"; var hcirc = "ĥ"; var hearts = "♥"; var heartsuit = "♥"; var hellip = "…"; var hercon = "⊹"; var hfr = "𝔥"; var Hfr = "ℌ"; var HilbertSpace = "ℋ"; var hksearow = "⤥"; var hkswarow = "⤦"; var hoarr = "⇿"; var homtht = "∻"; var hookleftarrow = "↩"; var hookrightarrow = "↪"; var hopf = "𝕙"; var Hopf = "ℍ"; var horbar = "―"; var HorizontalLine = "─"; var hscr = "𝒽"; var Hscr = "ℋ"; var hslash = "ℏ"; var Hstrok = "Ħ"; var hstrok = "ħ"; var HumpDownHump = "≎"; var HumpEqual = "≏"; var hybull = "⁃"; var hyphen = "‐"; var Iacute$1 = "Í"; var iacute$1 = "í"; var ic = "⁣"; var Icirc$1 = "Î"; var icirc$1 = "î"; var Icy = "И"; var icy = "и"; var Idot = "İ"; var IEcy = "Е"; var iecy = "е"; var iexcl$1 = "¡"; var iff = "⇔"; var ifr = "𝔦"; var Ifr = "ℑ"; var Igrave$1 = "Ì"; var igrave$1 = "ì"; var ii = "ⅈ"; var iiiint = "⨌"; var iiint = "∭"; var iinfin = "⧜"; var iiota = "℩"; var IJlig = "IJ"; var ijlig = "ij"; var Imacr = "Ī"; var imacr = "ī"; var image = "ℑ"; var ImaginaryI = "ⅈ"; var imagline = "ℐ"; var imagpart = "ℑ"; var imath = "ı"; var Im = "ℑ"; var imof = "⊷"; var imped = "Ƶ"; var Implies = "⇒"; var incare = "℅"; var infin = "∞"; var infintie = "⧝"; var inodot = "ı"; var intcal = "⊺"; var int = "∫"; var Int = "∬"; var integers = "ℤ"; var Integral = "∫"; var intercal = "⊺"; var Intersection = "⋂"; var intlarhk = "⨗"; var intprod = "⨼"; var InvisibleComma = "⁣"; var InvisibleTimes = "⁢"; var IOcy = "Ё"; var iocy = "ё"; var Iogon = "Į"; var iogon = "į"; var Iopf = "𝕀"; var iopf = "𝕚"; var Iota = "Ι"; var iota = "ι"; var iprod = "⨼"; var iquest$1 = "¿"; var iscr = "𝒾"; var Iscr = "ℐ"; var isin = "∈"; var isindot = "⋵"; var isinE = "⋹"; var isins = "⋴"; var isinsv = "⋳"; var isinv = "∈"; var it = "⁢"; var Itilde = "Ĩ"; var itilde = "ĩ"; var Iukcy = "І"; var iukcy = "і"; var Iuml$1 = "Ï"; var iuml$1 = "ï"; var Jcirc = "Ĵ"; var jcirc = "ĵ"; var Jcy = "Й"; var jcy = "й"; var Jfr = "𝔍"; var jfr = "𝔧"; var jmath = "ȷ"; var Jopf = "𝕁"; var jopf = "𝕛"; var Jscr = "𝒥"; var jscr = "𝒿"; var Jsercy = "Ј"; var jsercy = "ј"; var Jukcy = "Є"; var jukcy = "є"; var Kappa = "Κ"; var kappa = "κ"; var kappav = "ϰ"; var Kcedil = "Ķ"; var kcedil = "ķ"; var Kcy = "К"; var kcy = "к"; var Kfr = "𝔎"; var kfr = "𝔨"; var kgreen = "ĸ"; var KHcy = "Х"; var khcy = "х"; var KJcy = "Ќ"; var kjcy = "ќ"; var Kopf = "𝕂"; var kopf = "𝕜"; var Kscr = "𝒦"; var kscr = "𝓀"; var lAarr = "⇚"; var Lacute = "Ĺ"; var lacute = "ĺ"; var laemptyv = "⦴"; var lagran = "ℒ"; var Lambda = "Λ"; var lambda = "λ"; var lang = "⟨"; var Lang = "⟪"; var langd = "⦑"; var langle = "⟨"; var lap = "⪅"; var Laplacetrf = "ℒ"; var laquo$1 = "«"; var larrb = "⇤"; var larrbfs = "⤟"; var larr = "←"; var Larr = "↞"; var lArr = "⇐"; var larrfs = "⤝"; var larrhk = "↩"; var larrlp = "↫"; var larrpl = "⤹"; var larrsim = "⥳"; var larrtl = "↢"; var latail = "⤙"; var lAtail = "⤛"; var lat = "⪫"; var late = "⪭"; var lates = "⪭︀"; var lbarr = "⤌"; var lBarr = "⤎"; var lbbrk = "❲"; var lbrace = "{"; var lbrack = "["; var lbrke = "⦋"; var lbrksld = "⦏"; var lbrkslu = "⦍"; var Lcaron = "Ľ"; var lcaron = "ľ"; var Lcedil = "Ļ"; var lcedil = "ļ"; var lceil = "⌈"; var lcub = "{"; var Lcy = "Л"; var lcy = "л"; var ldca = "⤶"; var ldquo = "“"; var ldquor = "„"; var ldrdhar = "⥧"; var ldrushar = "⥋"; var ldsh = "↲"; var le = "≤"; var lE = "≦"; var LeftAngleBracket = "⟨"; var LeftArrowBar = "⇤"; var leftarrow = "←"; var LeftArrow = "←"; var Leftarrow = "⇐"; var LeftArrowRightArrow = "⇆"; var leftarrowtail = "↢"; var LeftCeiling = "⌈"; var LeftDoubleBracket = "⟦"; var LeftDownTeeVector = "⥡"; var LeftDownVectorBar = "⥙"; var LeftDownVector = "⇃"; var LeftFloor = "⌊"; var leftharpoondown = "↽"; var leftharpoonup = "↼"; var leftleftarrows = "⇇"; var leftrightarrow = "↔"; var LeftRightArrow = "↔"; var Leftrightarrow = "⇔"; var leftrightarrows = "⇆"; var leftrightharpoons = "⇋"; var leftrightsquigarrow = "↭"; var LeftRightVector = "⥎"; var LeftTeeArrow = "↤"; var LeftTee = "⊣"; var LeftTeeVector = "⥚"; var leftthreetimes = "⋋"; var LeftTriangleBar = "⧏"; var LeftTriangle = "⊲"; var LeftTriangleEqual = "⊴"; var LeftUpDownVector = "⥑"; var LeftUpTeeVector = "⥠"; var LeftUpVectorBar = "⥘"; var LeftUpVector = "↿"; var LeftVectorBar = "⥒"; var LeftVector = "↼"; var lEg = "⪋"; var leg = "⋚"; var leq = "≤"; var leqq = "≦"; var leqslant = "⩽"; var lescc = "⪨"; var les = "⩽"; var lesdot = "⩿"; var lesdoto = "⪁"; var lesdotor = "⪃"; var lesg = "⋚︀"; var lesges = "⪓"; var lessapprox = "⪅"; var lessdot = "⋖"; var lesseqgtr = "⋚"; var lesseqqgtr = "⪋"; var LessEqualGreater = "⋚"; var LessFullEqual = "≦"; var LessGreater = "≶"; var lessgtr = "≶"; var LessLess = "⪡"; var lesssim = "≲"; var LessSlantEqual = "⩽"; var LessTilde = "≲"; var lfisht = "⥼"; var lfloor = "⌊"; var Lfr = "𝔏"; var lfr = "𝔩"; var lg = "≶"; var lgE = "⪑"; var lHar = "⥢"; var lhard = "↽"; var lharu = "↼"; var lharul = "⥪"; var lhblk = "▄"; var LJcy = "Љ"; var ljcy = "љ"; var llarr = "⇇"; var ll = "≪"; var Ll = "⋘"; var llcorner = "⌞"; var Lleftarrow = "⇚"; var llhard = "⥫"; var lltri = "◺"; var Lmidot = "Ŀ"; var lmidot = "ŀ"; var lmoustache = "⎰"; var lmoust = "⎰"; var lnap = "⪉"; var lnapprox = "⪉"; var lne = "⪇"; var lnE = "≨"; var lneq = "⪇"; var lneqq = "≨"; var lnsim = "⋦"; var loang = "⟬"; var loarr = "⇽"; var lobrk = "⟦"; var longleftarrow = "⟵"; var LongLeftArrow = "⟵"; var Longleftarrow = "⟸"; var longleftrightarrow = "⟷"; var LongLeftRightArrow = "⟷"; var Longleftrightarrow = "⟺"; var longmapsto = "⟼"; var longrightarrow = "⟶"; var LongRightArrow = "⟶"; var Longrightarrow = "⟹"; var looparrowleft = "↫"; var looparrowright = "↬"; var lopar = "⦅"; var Lopf = "𝕃"; var lopf = "𝕝"; var loplus = "⨭"; var lotimes = "⨴"; var lowast = "∗"; var lowbar = "_"; var LowerLeftArrow = "↙"; var LowerRightArrow = "↘"; var loz = "◊"; var lozenge = "◊"; var lozf = "⧫"; var lpar = "("; var lparlt = "⦓"; var lrarr = "⇆"; var lrcorner = "⌟"; var lrhar = "⇋"; var lrhard = "⥭"; var lrm = "‎"; var lrtri = "⊿"; var lsaquo = "‹"; var lscr = "𝓁"; var Lscr = "ℒ"; var lsh = "↰"; var Lsh = "↰"; var lsim = "≲"; var lsime = "⪍"; var lsimg = "⪏"; var lsqb = "["; var lsquo = "‘"; var lsquor = "‚"; var Lstrok = "Ł"; var lstrok = "ł"; var ltcc = "⪦"; var ltcir = "⩹"; var lt$2 = "<"; var LT$1 = "<"; var Lt = "≪"; var ltdot = "⋖"; var lthree = "⋋"; var ltimes = "⋉"; var ltlarr = "⥶"; var ltquest = "⩻"; var ltri = "◃"; var ltrie = "⊴"; var ltrif = "◂"; var ltrPar = "⦖"; var lurdshar = "⥊"; var luruhar = "⥦"; var lvertneqq = "≨︀"; var lvnE = "≨︀"; var macr$1 = "¯"; var male = "♂"; var malt = "✠"; var maltese = "✠"; var map = "↦"; var mapsto = "↦"; var mapstodown = "↧"; var mapstoleft = "↤"; var mapstoup = "↥"; var marker = "▮"; var mcomma = "⨩"; var Mcy = "М"; var mcy = "м"; var mdash = "—"; var mDDot = "∺"; var measuredangle = "∡"; var MediumSpace = " "; var Mellintrf = "ℳ"; var Mfr = "𝔐"; var mfr = "𝔪"; var mho = "℧"; var micro$1 = "µ"; var midast = "*"; var midcir = "⫰"; var mid = "∣"; var middot$1 = "·"; var minusb = "⊟"; var minus = "−"; var minusd = "∸"; var minusdu = "⨪"; var MinusPlus = "∓"; var mlcp = "⫛"; var mldr = "…"; var mnplus = "∓"; var models = "⊧"; var Mopf = "𝕄"; var mopf = "𝕞"; var mp = "∓"; var mscr = "𝓂"; var Mscr = "ℳ"; var mstpos = "∾"; var Mu = "Μ"; var mu = "μ"; var multimap = "⊸"; var mumap = "⊸"; var nabla = "∇"; var Nacute = "Ń"; var nacute = "ń"; var nang = "∠⃒"; var nap = "≉"; var napE = "⩰̸"; var napid = "≋̸"; var napos = "ʼn"; var napprox = "≉"; var natural = "♮"; var naturals = "ℕ"; var natur = "♮"; var nbsp$1 = " "; var nbump = "≎̸"; var nbumpe = "≏̸"; var ncap = "⩃"; var Ncaron = "Ň"; var ncaron = "ň"; var Ncedil = "Ņ"; var ncedil = "ņ"; var ncong = "≇"; var ncongdot = "⩭̸"; var ncup = "⩂"; var Ncy = "Н"; var ncy = "н"; var ndash = "–"; var nearhk = "⤤"; var nearr = "↗"; var neArr = "⇗"; var nearrow = "↗"; var ne = "≠"; var nedot = "≐̸"; var NegativeMediumSpace = "​"; var NegativeThickSpace = "​"; var NegativeThinSpace = "​"; var NegativeVeryThinSpace = "​"; var nequiv = "≢"; var nesear = "⤨"; var nesim = "≂̸"; var NestedGreaterGreater = "≫"; var NestedLessLess = "≪"; var NewLine = "\n"; var nexist = "∄"; var nexists = "∄"; var Nfr = "𝔑"; var nfr = "𝔫"; var ngE = "≧̸"; var nge = "≱"; var ngeq = "≱"; var ngeqq = "≧̸"; var ngeqslant = "⩾̸"; var nges = "⩾̸"; var nGg = "⋙̸"; var ngsim = "≵"; var nGt = "≫⃒"; var ngt = "≯"; var ngtr = "≯"; var nGtv = "≫̸"; var nharr = "↮"; var nhArr = "⇎"; var nhpar = "⫲"; var ni = "∋"; var nis = "⋼"; var nisd = "⋺"; var niv = "∋"; var NJcy = "Њ"; var njcy = "њ"; var nlarr = "↚"; var nlArr = "⇍"; var nldr = "‥"; var nlE = "≦̸"; var nle = "≰"; var nleftarrow = "↚"; var nLeftarrow = "⇍"; var nleftrightarrow = "↮"; var nLeftrightarrow = "⇎"; var nleq = "≰"; var nleqq = "≦̸"; var nleqslant = "⩽̸"; var nles = "⩽̸"; var nless = "≮"; var nLl = "⋘̸"; var nlsim = "≴"; var nLt = "≪⃒"; var nlt = "≮"; var nltri = "⋪"; var nltrie = "⋬"; var nLtv = "≪̸"; var nmid = "∤"; var NoBreak = "⁠"; var NonBreakingSpace = " "; var nopf = "𝕟"; var Nopf = "ℕ"; var Not = "⫬"; var not$1 = "¬"; var NotCongruent = "≢"; var NotCupCap = "≭"; var NotDoubleVerticalBar = "∦"; var NotElement = "∉"; var NotEqual = "≠"; var NotEqualTilde = "≂̸"; var NotExists = "∄"; var NotGreater = "≯"; var NotGreaterEqual = "≱"; var NotGreaterFullEqual = "≧̸"; var NotGreaterGreater = "≫̸"; var NotGreaterLess = "≹"; var NotGreaterSlantEqual = "⩾̸"; var NotGreaterTilde = "≵"; var NotHumpDownHump = "≎̸"; var NotHumpEqual = "≏̸"; var notin = "∉"; var notindot = "⋵̸"; var notinE = "⋹̸"; var notinva = "∉"; var notinvb = "⋷"; var notinvc = "⋶"; var NotLeftTriangleBar = "⧏̸"; var NotLeftTriangle = "⋪"; var NotLeftTriangleEqual = "⋬"; var NotLess = "≮"; var NotLessEqual = "≰"; var NotLessGreater = "≸"; var NotLessLess = "≪̸"; var NotLessSlantEqual = "⩽̸"; var NotLessTilde = "≴"; var NotNestedGreaterGreater = "⪢̸"; var NotNestedLessLess = "⪡̸"; var notni = "∌"; var notniva = "∌"; var notnivb = "⋾"; var notnivc = "⋽"; var NotPrecedes = "⊀"; var NotPrecedesEqual = "⪯̸"; var NotPrecedesSlantEqual = "⋠"; var NotReverseElement = "∌"; var NotRightTriangleBar = "⧐̸"; var NotRightTriangle = "⋫"; var NotRightTriangleEqual = "⋭"; var NotSquareSubset = "⊏̸"; var NotSquareSubsetEqual = "⋢"; var NotSquareSuperset = "⊐̸"; var NotSquareSupersetEqual = "⋣"; var NotSubset = "⊂⃒"; var NotSubsetEqual = "⊈"; var NotSucceeds = "⊁"; var NotSucceedsEqual = "⪰̸"; var NotSucceedsSlantEqual = "⋡"; var NotSucceedsTilde = "≿̸"; var NotSuperset = "⊃⃒"; var NotSupersetEqual = "⊉"; var NotTilde = "≁"; var NotTildeEqual = "≄"; var NotTildeFullEqual = "≇"; var NotTildeTilde = "≉"; var NotVerticalBar = "∤"; var nparallel = "∦"; var npar = "∦"; var nparsl = "⫽⃥"; var npart = "∂̸"; var npolint = "⨔"; var npr = "⊀"; var nprcue = "⋠"; var nprec = "⊀"; var npreceq = "⪯̸"; var npre = "⪯̸"; var nrarrc = "⤳̸"; var nrarr = "↛"; var nrArr = "⇏"; var nrarrw = "↝̸"; var nrightarrow = "↛"; var nRightarrow = "⇏"; var nrtri = "⋫"; var nrtrie = "⋭"; var nsc = "⊁"; var nsccue = "⋡"; var nsce = "⪰̸"; var Nscr = "𝒩"; var nscr = "𝓃"; var nshortmid = "∤"; var nshortparallel = "∦"; var nsim = "≁"; var nsime = "≄"; var nsimeq = "≄"; var nsmid = "∤"; var nspar = "∦"; var nsqsube = "⋢"; var nsqsupe = "⋣"; var nsub = "⊄"; var nsubE = "⫅̸"; var nsube = "⊈"; var nsubset = "⊂⃒"; var nsubseteq = "⊈"; var nsubseteqq = "⫅̸"; var nsucc = "⊁"; var nsucceq = "⪰̸"; var nsup = "⊅"; var nsupE = "⫆̸"; var nsupe = "⊉"; var nsupset = "⊃⃒"; var nsupseteq = "⊉"; var nsupseteqq = "⫆̸"; var ntgl = "≹"; var Ntilde$1 = "Ñ"; var ntilde$1 = "ñ"; var ntlg = "≸"; var ntriangleleft = "⋪"; var ntrianglelefteq = "⋬"; var ntriangleright = "⋫"; var ntrianglerighteq = "⋭"; var Nu = "Ν"; var nu = "ν"; var num = "#"; var numero = "№"; var numsp = " "; var nvap = "≍⃒"; var nvdash = "⊬"; var nvDash = "⊭"; var nVdash = "⊮"; var nVDash = "⊯"; var nvge = "≥⃒"; var nvgt = ">⃒"; var nvHarr = "⤄"; var nvinfin = "⧞"; var nvlArr = "⤂"; var nvle = "≤⃒"; var nvlt = "<⃒"; var nvltrie = "⊴⃒"; var nvrArr = "⤃"; var nvrtrie = "⊵⃒"; var nvsim = "∼⃒"; var nwarhk = "⤣"; var nwarr = "↖"; var nwArr = "⇖"; var nwarrow = "↖"; var nwnear = "⤧"; var Oacute$1 = "Ó"; var oacute$1 = "ó"; var oast = "⊛"; var Ocirc$1 = "Ô"; var ocirc$1 = "ô"; var ocir = "⊚"; var Ocy = "О"; var ocy = "о"; var odash = "⊝"; var Odblac = "Ő"; var odblac = "ő"; var odiv = "⨸"; var odot = "⊙"; var odsold = "⦼"; var OElig = "Œ"; var oelig = "œ"; var ofcir = "⦿"; var Ofr = "𝔒"; var ofr = "𝔬"; var ogon = "˛"; var Ograve$1 = "Ò"; var ograve$1 = "ò"; var ogt = "⧁"; var ohbar = "⦵"; var ohm = "Ω"; var oint = "∮"; var olarr = "↺"; var olcir = "⦾"; var olcross = "⦻"; var oline = "‾"; var olt = "⧀"; var Omacr = "Ō"; var omacr = "ō"; var Omega = "Ω"; var omega = "ω"; var Omicron = "Ο"; var omicron = "ο"; var omid = "⦶"; var ominus = "⊖"; var Oopf = "𝕆"; var oopf = "𝕠"; var opar = "⦷"; var OpenCurlyDoubleQuote = "“"; var OpenCurlyQuote = "‘"; var operp = "⦹"; var oplus = "⊕"; var orarr = "↻"; var Or = "⩔"; var or = "∨"; var ord = "⩝"; var order = "ℴ"; var orderof = "ℴ"; var ordf$1 = "ª"; var ordm$1 = "º"; var origof = "⊶"; var oror = "⩖"; var orslope = "⩗"; var orv = "⩛"; var oS = "Ⓢ"; var Oscr = "𝒪"; var oscr = "ℴ"; var Oslash$1 = "Ø"; var oslash$1 = "ø"; var osol = "⊘"; var Otilde$1 = "Õ"; var otilde$1 = "õ"; var otimesas = "⨶"; var Otimes = "⨷"; var otimes = "⊗"; var Ouml$1 = "Ö"; var ouml$1 = "ö"; var ovbar = "⌽"; var OverBar = "‾"; var OverBrace = "⏞"; var OverBracket = "⎴"; var OverParenthesis = "⏜"; var para$1 = "¶"; var parallel = "∥"; var par = "∥"; var parsim = "⫳"; var parsl = "⫽"; var part = "∂"; var PartialD = "∂"; var Pcy = "П"; var pcy = "п"; var percnt = "%"; var period = "."; var permil = "‰"; var perp = "⊥"; var pertenk = "‱"; var Pfr = "𝔓"; var pfr = "𝔭"; var Phi = "Φ"; var phi = "φ"; var phiv = "ϕ"; var phmmat = "ℳ"; var phone = "☎"; var Pi = "Π"; var pi = "π"; var pitchfork = "⋔"; var piv = "ϖ"; var planck = "ℏ"; var planckh = "ℎ"; var plankv = "ℏ"; var plusacir = "⨣"; var plusb = "⊞"; var pluscir = "⨢"; var plus = "+"; var plusdo = "∔"; var plusdu = "⨥"; var pluse = "⩲"; var PlusMinus = "±"; var plusmn$1 = "±"; var plussim = "⨦"; var plustwo = "⨧"; var pm = "±"; var Poincareplane = "ℌ"; var pointint = "⨕"; var popf = "𝕡"; var Popf = "ℙ"; var pound$1 = "£"; var prap = "⪷"; var Pr = "⪻"; var pr = "≺"; var prcue = "≼"; var precapprox = "⪷"; var prec = "≺"; var preccurlyeq = "≼"; var Precedes = "≺"; var PrecedesEqual = "⪯"; var PrecedesSlantEqual = "≼"; var PrecedesTilde = "≾"; var preceq = "⪯"; var precnapprox = "⪹"; var precneqq = "⪵"; var precnsim = "⋨"; var pre = "⪯"; var prE = "⪳"; var precsim = "≾"; var prime = "′"; var Prime = "″"; var primes = "ℙ"; var prnap = "⪹"; var prnE = "⪵"; var prnsim = "⋨"; var prod = "∏"; var Product = "∏"; var profalar = "⌮"; var profline = "⌒"; var profsurf = "⌓"; var prop = "∝"; var Proportional = "∝"; var Proportion = "∷"; var propto = "∝"; var prsim = "≾"; var prurel = "⊰"; var Pscr = "𝒫"; var pscr = "𝓅"; var Psi = "Ψ"; var psi = "ψ"; var puncsp = " "; var Qfr = "𝔔"; var qfr = "𝔮"; var qint = "⨌"; var qopf = "𝕢"; var Qopf = "ℚ"; var qprime = "⁗"; var Qscr = "𝒬"; var qscr = "𝓆"; var quaternions = "ℍ"; var quatint = "⨖"; var quest = "?"; var questeq = "≟"; var quot$2 = "\""; var QUOT$1 = "\""; var rAarr = "⇛"; var race = "∽̱"; var Racute = "Ŕ"; var racute = "ŕ"; var radic = "√"; var raemptyv = "⦳"; var rang = "⟩"; var Rang = "⟫"; var rangd = "⦒"; var range = "⦥"; var rangle = "⟩"; var raquo$1 = "»"; var rarrap = "⥵"; var rarrb = "⇥"; var rarrbfs = "⤠"; var rarrc = "⤳"; var rarr = "→"; var Rarr = "↠"; var rArr = "⇒"; var rarrfs = "⤞"; var rarrhk = "↪"; var rarrlp = "↬"; var rarrpl = "⥅"; var rarrsim = "⥴"; var Rarrtl = "⤖"; var rarrtl = "↣"; var rarrw = "↝"; var ratail = "⤚"; var rAtail = "⤜"; var ratio = "∶"; var rationals = "ℚ"; var rbarr = "⤍"; var rBarr = "⤏"; var RBarr = "⤐"; var rbbrk = "❳"; var rbrace = "}"; var rbrack = "]"; var rbrke = "⦌"; var rbrksld = "⦎"; var rbrkslu = "⦐"; var Rcaron = "Ř"; var rcaron = "ř"; var Rcedil = "Ŗ"; var rcedil = "ŗ"; var rceil = "⌉"; var rcub = "}"; var Rcy = "Р"; var rcy = "р"; var rdca = "⤷"; var rdldhar = "⥩"; var rdquo = "”"; var rdquor = "”"; var rdsh = "↳"; var real = "ℜ"; var realine = "ℛ"; var realpart = "ℜ"; var reals = "ℝ"; var Re = "ℜ"; var rect = "▭"; var reg$1 = "®"; var REG$1 = "®"; var ReverseElement = "∋"; var ReverseEquilibrium = "⇋"; var ReverseUpEquilibrium = "⥯"; var rfisht = "⥽"; var rfloor = "⌋"; var rfr = "𝔯"; var Rfr = "ℜ"; var rHar = "⥤"; var rhard = "⇁"; var rharu = "⇀"; var rharul = "⥬"; var Rho = "Ρ"; var rho = "ρ"; var rhov = "ϱ"; var RightAngleBracket = "⟩"; var RightArrowBar = "⇥"; var rightarrow = "→"; var RightArrow = "→"; var Rightarrow = "⇒"; var RightArrowLeftArrow = "⇄"; var rightarrowtail = "↣"; var RightCeiling = "⌉"; var RightDoubleBracket = "⟧"; var RightDownTeeVector = "⥝"; var RightDownVectorBar = "⥕"; var RightDownVector = "⇂"; var RightFloor = "⌋"; var rightharpoondown = "⇁"; var rightharpoonup = "⇀"; var rightleftarrows = "⇄"; var rightleftharpoons = "⇌"; var rightrightarrows = "⇉"; var rightsquigarrow = "↝"; var RightTeeArrow = "↦"; var RightTee = "⊢"; var RightTeeVector = "⥛"; var rightthreetimes = "⋌"; var RightTriangleBar = "⧐"; var RightTriangle = "⊳"; var RightTriangleEqual = "⊵"; var RightUpDownVector = "⥏"; var RightUpTeeVector = "⥜"; var RightUpVectorBar = "⥔"; var RightUpVector = "↾"; var RightVectorBar = "⥓"; var RightVector = "⇀"; var ring = "˚"; var risingdotseq = "≓"; var rlarr = "⇄"; var rlhar = "⇌"; var rlm = "‏"; var rmoustache = "⎱"; var rmoust = "⎱"; var rnmid = "⫮"; var roang = "⟭"; var roarr = "⇾"; var robrk = "⟧"; var ropar = "⦆"; var ropf = "𝕣"; var Ropf = "ℝ"; var roplus = "⨮"; var rotimes = "⨵"; var RoundImplies = "⥰"; var rpar = ")"; var rpargt = "⦔"; var rppolint = "⨒"; var rrarr = "⇉"; var Rrightarrow = "⇛"; var rsaquo = "›"; var rscr = "𝓇"; var Rscr = "ℛ"; var rsh = "↱"; var Rsh = "↱"; var rsqb = "]"; var rsquo = "’"; var rsquor = "’"; var rthree = "⋌"; var rtimes = "⋊"; var rtri = "▹"; var rtrie = "⊵"; var rtrif = "▸"; var rtriltri = "⧎"; var RuleDelayed = "⧴"; var ruluhar = "⥨"; var rx = "℞"; var Sacute = "Ś"; var sacute = "ś"; var sbquo = "‚"; var scap = "⪸"; var Scaron = "Š"; var scaron = "š"; var Sc = "⪼"; var sc = "≻"; var sccue = "≽"; var sce = "⪰"; var scE = "⪴"; var Scedil = "Ş"; var scedil = "ş"; var Scirc = "Ŝ"; var scirc = "ŝ"; var scnap = "⪺"; var scnE = "⪶"; var scnsim = "⋩"; var scpolint = "⨓"; var scsim = "≿"; var Scy = "С"; var scy = "с"; var sdotb = "⊡"; var sdot = "⋅"; var sdote = "⩦"; var searhk = "⤥"; var searr = "↘"; var seArr = "⇘"; var searrow = "↘"; var sect$1 = "§"; var semi = ";"; var seswar = "⤩"; var setminus = "∖"; var setmn = "∖"; var sext = "✶"; var Sfr = "𝔖"; var sfr = "𝔰"; var sfrown = "⌢"; var sharp = "♯"; var SHCHcy = "Щ"; var shchcy = "щ"; var SHcy = "Ш"; var shcy = "ш"; var ShortDownArrow = "↓"; var ShortLeftArrow = "←"; var shortmid = "∣"; var shortparallel = "∥"; var ShortRightArrow = "→"; var ShortUpArrow = "↑"; var shy$1 = "­"; var Sigma = "Σ"; var sigma = "σ"; var sigmaf = "ς"; var sigmav = "ς"; var sim = "∼"; var simdot = "⩪"; var sime = "≃"; var simeq = "≃"; var simg = "⪞"; var simgE = "⪠"; var siml = "⪝"; var simlE = "⪟"; var simne = "≆"; var simplus = "⨤"; var simrarr = "⥲"; var slarr = "←"; var SmallCircle = "∘"; var smallsetminus = "∖"; var smashp = "⨳"; var smeparsl = "⧤"; var smid = "∣"; var smile = "⌣"; var smt = "⪪"; var smte = "⪬"; var smtes = "⪬︀"; var SOFTcy = "Ь"; var softcy = "ь"; var solbar = "⌿"; var solb = "⧄"; var sol = "/"; var Sopf = "𝕊"; var sopf = "𝕤"; var spades = "♠"; var spadesuit = "♠"; var spar = "∥"; var sqcap = "⊓"; var sqcaps = "⊓︀"; var sqcup = "⊔"; var sqcups = "⊔︀"; var Sqrt = "√"; var sqsub = "⊏"; var sqsube = "⊑"; var sqsubset = "⊏"; var sqsubseteq = "⊑"; var sqsup = "⊐"; var sqsupe = "⊒"; var sqsupset = "⊐"; var sqsupseteq = "⊒"; var square = "□"; var Square = "□"; var SquareIntersection = "⊓"; var SquareSubset = "⊏"; var SquareSubsetEqual = "⊑"; var SquareSuperset = "⊐"; var SquareSupersetEqual = "⊒"; var SquareUnion = "⊔"; var squarf = "▪"; var squ = "□"; var squf = "▪"; var srarr = "→"; var Sscr = "𝒮"; var sscr = "𝓈"; var ssetmn = "∖"; var ssmile = "⌣"; var sstarf = "⋆"; var Star = "⋆"; var star = "☆"; var starf = "★"; var straightepsilon = "ϵ"; var straightphi = "ϕ"; var strns = "¯"; var sub = "⊂"; var Sub = "⋐"; var subdot = "⪽"; var subE = "⫅"; var sube = "⊆"; var subedot = "⫃"; var submult = "⫁"; var subnE = "⫋"; var subne = "⊊"; var subplus = "⪿"; var subrarr = "⥹"; var subset = "⊂"; var Subset = "⋐"; var subseteq = "⊆"; var subseteqq = "⫅"; var SubsetEqual = "⊆"; var subsetneq = "⊊"; var subsetneqq = "⫋"; var subsim = "⫇"; var subsub = "⫕"; var subsup = "⫓"; var succapprox = "⪸"; var succ = "≻"; var succcurlyeq = "≽"; var Succeeds = "≻"; var SucceedsEqual = "⪰"; var SucceedsSlantEqual = "≽"; var SucceedsTilde = "≿"; var succeq = "⪰"; var succnapprox = "⪺"; var succneqq = "⪶"; var succnsim = "⋩"; var succsim = "≿"; var SuchThat = "∋"; var sum = "∑"; var Sum = "∑"; var sung = "♪"; var sup1$1 = "¹"; var sup2$1 = "²"; var sup3$1 = "³"; var sup = "⊃"; var Sup = "⋑"; var supdot = "⪾"; var supdsub = "⫘"; var supE = "⫆"; var supe = "⊇"; var supedot = "⫄"; var Superset = "⊃"; var SupersetEqual = "⊇"; var suphsol = "⟉"; var suphsub = "⫗"; var suplarr = "⥻"; var supmult = "⫂"; var supnE = "⫌"; var supne = "⊋"; var supplus = "⫀"; var supset = "⊃"; var Supset = "⋑"; var supseteq = "⊇"; var supseteqq = "⫆"; var supsetneq = "⊋"; var supsetneqq = "⫌"; var supsim = "⫈"; var supsub = "⫔"; var supsup = "⫖"; var swarhk = "⤦"; var swarr = "↙"; var swArr = "⇙"; var swarrow = "↙"; var swnwar = "⤪"; var szlig$1 = "ß"; var Tab = "\t"; var target = "⌖"; var Tau = "Τ"; var tau = "τ"; var tbrk = "⎴"; var Tcaron = "Ť"; var tcaron = "ť"; var Tcedil = "Ţ"; var tcedil = "ţ"; var Tcy = "Т"; var tcy = "т"; var tdot = "⃛"; var telrec = "⌕"; var Tfr = "𝔗"; var tfr = "𝔱"; var there4 = "∴"; var therefore = "∴"; var Therefore = "∴"; var Theta = "Θ"; var theta = "θ"; var thetasym = "ϑ"; var thetav = "ϑ"; var thickapprox = "≈"; var thicksim = "∼"; var ThickSpace = "  "; var ThinSpace = " "; var thinsp = " "; var thkap = "≈"; var thksim = "∼"; var THORN$1 = "Þ"; var thorn$1 = "þ"; var tilde = "˜"; var Tilde = "∼"; var TildeEqual = "≃"; var TildeFullEqual = "≅"; var TildeTilde = "≈"; var timesbar = "⨱"; var timesb = "⊠"; var times$1 = "×"; var timesd = "⨰"; var tint = "∭"; var toea = "⤨"; var topbot = "⌶"; var topcir = "⫱"; var top = "⊤"; var Topf = "𝕋"; var topf = "𝕥"; var topfork = "⫚"; var tosa = "⤩"; var tprime = "‴"; var trade = "™"; var TRADE = "™"; var triangle = "▵"; var triangledown = "▿"; var triangleleft = "◃"; var trianglelefteq = "⊴"; var triangleq = "≜"; var triangleright = "▹"; var trianglerighteq = "⊵"; var tridot = "◬"; var trie = "≜"; var triminus = "⨺"; var TripleDot = "⃛"; var triplus = "⨹"; var trisb = "⧍"; var tritime = "⨻"; var trpezium = "⏢"; var Tscr = "𝒯"; var tscr = "𝓉"; var TScy = "Ц"; var tscy = "ц"; var TSHcy = "Ћ"; var tshcy = "ћ"; var Tstrok = "Ŧ"; var tstrok = "ŧ"; var twixt = "≬"; var twoheadleftarrow = "↞"; var twoheadrightarrow = "↠"; var Uacute$1 = "Ú"; var uacute$1 = "ú"; var uarr = "↑"; var Uarr = "↟"; var uArr = "⇑"; var Uarrocir = "⥉"; var Ubrcy = "Ў"; var ubrcy = "ў"; var Ubreve = "Ŭ"; var ubreve = "ŭ"; var Ucirc$1 = "Û"; var ucirc$1 = "û"; var Ucy = "У"; var ucy = "у"; var udarr = "⇅"; var Udblac = "Ű"; var udblac = "ű"; var udhar = "⥮"; var ufisht = "⥾"; var Ufr = "𝔘"; var ufr = "𝔲"; var Ugrave$1 = "Ù"; var ugrave$1 = "ù"; var uHar = "⥣"; var uharl = "↿"; var uharr = "↾"; var uhblk = "▀"; var ulcorn = "⌜"; var ulcorner = "⌜"; var ulcrop = "⌏"; var ultri = "◸"; var Umacr = "Ū"; var umacr = "ū"; var uml$1 = "¨"; var UnderBar = "_"; var UnderBrace = "⏟"; var UnderBracket = "⎵"; var UnderParenthesis = "⏝"; var Union = "⋃"; var UnionPlus = "⊎"; var Uogon = "Ų"; var uogon = "ų"; var Uopf = "𝕌"; var uopf = "𝕦"; var UpArrowBar = "⤒"; var uparrow = "↑"; var UpArrow = "↑"; var Uparrow = "⇑"; var UpArrowDownArrow = "⇅"; var updownarrow = "↕"; var UpDownArrow = "↕"; var Updownarrow = "⇕"; var UpEquilibrium = "⥮"; var upharpoonleft = "↿"; var upharpoonright = "↾"; var uplus = "⊎"; var UpperLeftArrow = "↖"; var UpperRightArrow = "↗"; var upsi = "υ"; var Upsi = "ϒ"; var upsih = "ϒ"; var Upsilon = "Υ"; var upsilon = "υ"; var UpTeeArrow = "↥"; var UpTee = "⊥"; var upuparrows = "⇈"; var urcorn = "⌝"; var urcorner = "⌝"; var urcrop = "⌎"; var Uring = "Ů"; var uring = "ů"; var urtri = "◹"; var Uscr = "𝒰"; var uscr = "𝓊"; var utdot = "⋰"; var Utilde = "Ũ"; var utilde = "ũ"; var utri = "▵"; var utrif = "▴"; var uuarr = "⇈"; var Uuml$1 = "Ü"; var uuml$1 = "ü"; var uwangle = "⦧"; var vangrt = "⦜"; var varepsilon = "ϵ"; var varkappa = "ϰ"; var varnothing = "∅"; var varphi = "ϕ"; var varpi = "ϖ"; var varpropto = "∝"; var varr = "↕"; var vArr = "⇕"; var varrho = "ϱ"; var varsigma = "ς"; var varsubsetneq = "⊊︀"; var varsubsetneqq = "⫋︀"; var varsupsetneq = "⊋︀"; var varsupsetneqq = "⫌︀"; var vartheta = "ϑ"; var vartriangleleft = "⊲"; var vartriangleright = "⊳"; var vBar = "⫨"; var Vbar = "⫫"; var vBarv = "⫩"; var Vcy = "В"; var vcy = "в"; var vdash = "⊢"; var vDash = "⊨"; var Vdash = "⊩"; var VDash = "⊫"; var Vdashl = "⫦"; var veebar = "⊻"; var vee = "∨"; var Vee = "⋁"; var veeeq = "≚"; var vellip = "⋮"; var verbar = "|"; var Verbar = "‖"; var vert = "|"; var Vert = "‖"; var VerticalBar = "∣"; var VerticalLine = "|"; var VerticalSeparator = "❘"; var VerticalTilde = "≀"; var VeryThinSpace = " "; var Vfr = "𝔙"; var vfr = "𝔳"; var vltri = "⊲"; var vnsub = "⊂⃒"; var vnsup = "⊃⃒"; var Vopf = "𝕍"; var vopf = "𝕧"; var vprop = "∝"; var vrtri = "⊳"; var Vscr = "𝒱"; var vscr = "𝓋"; var vsubnE = "⫋︀"; var vsubne = "⊊︀"; var vsupnE = "⫌︀"; var vsupne = "⊋︀"; var Vvdash = "⊪"; var vzigzag = "⦚"; var Wcirc = "Ŵ"; var wcirc = "ŵ"; var wedbar = "⩟"; var wedge = "∧"; var Wedge = "⋀"; var wedgeq = "≙"; var weierp = "℘"; var Wfr = "𝔚"; var wfr = "𝔴"; var Wopf = "𝕎"; var wopf = "𝕨"; var wp = "℘"; var wr = "≀"; var wreath = "≀"; var Wscr = "𝒲"; var wscr = "𝓌"; var xcap = "⋂"; var xcirc = "◯"; var xcup = "⋃"; var xdtri = "▽"; var Xfr = "𝔛"; var xfr = "𝔵"; var xharr = "⟷"; var xhArr = "⟺"; var Xi = "Ξ"; var xi = "ξ"; var xlarr = "⟵"; var xlArr = "⟸"; var xmap = "⟼"; var xnis = "⋻"; var xodot = "⨀"; var Xopf = "𝕏"; var xopf = "𝕩"; var xoplus = "⨁"; var xotime = "⨂"; var xrarr = "⟶"; var xrArr = "⟹"; var Xscr = "𝒳"; var xscr = "𝓍"; var xsqcup = "⨆"; var xuplus = "⨄"; var xutri = "△"; var xvee = "⋁"; var xwedge = "⋀"; var Yacute$1 = "Ý"; var yacute$1 = "ý"; var YAcy = "Я"; var yacy = "я"; var Ycirc = "Ŷ"; var ycirc = "ŷ"; var Ycy = "Ы"; var ycy = "ы"; var yen$1 = "¥"; var Yfr = "𝔜"; var yfr = "𝔶"; var YIcy = "Ї"; var yicy = "ї"; var Yopf = "𝕐"; var yopf = "𝕪"; var Yscr = "𝒴"; var yscr = "𝓎"; var YUcy = "Ю"; var yucy = "ю"; var yuml$1 = "ÿ"; var Yuml = "Ÿ"; var Zacute = "Ź"; var zacute = "ź"; var Zcaron = "Ž"; var zcaron = "ž"; var Zcy = "З"; var zcy = "з"; var Zdot = "Ż"; var zdot = "ż"; var zeetrf = "ℨ"; var ZeroWidthSpace = "​"; var Zeta = "Ζ"; var zeta = "ζ"; var zfr = "𝔷"; var Zfr = "ℨ"; var ZHcy = "Ж"; var zhcy = "ж"; var zigrarr = "⇝"; var zopf = "𝕫"; var Zopf = "ℤ"; var Zscr = "𝒵"; var zscr = "𝓏"; var zwj = "‍"; var zwnj = "‌"; var require$$1$1 = { Aacute: Aacute$1, aacute: aacute$1, Abreve: Abreve, abreve: abreve, ac: ac, acd: acd, acE: acE, Acirc: Acirc$1, acirc: acirc$1, acute: acute$1, Acy: Acy, acy: acy, AElig: AElig$1, aelig: aelig$1, af: af, Afr: Afr, afr: afr, Agrave: Agrave$1, agrave: agrave$1, alefsym: alefsym, aleph: aleph, Alpha: Alpha, alpha: alpha, Amacr: Amacr, amacr: amacr, amalg: amalg, amp: amp$2, AMP: AMP$1, andand: andand, And: And, and: and, andd: andd, andslope: andslope, andv: andv, ang: ang, ange: ange, angle: angle, angmsdaa: angmsdaa, angmsdab: angmsdab, angmsdac: angmsdac, angmsdad: angmsdad, angmsdae: angmsdae, angmsdaf: angmsdaf, angmsdag: angmsdag, angmsdah: angmsdah, angmsd: angmsd, angrt: angrt, angrtvb: angrtvb, angrtvbd: angrtvbd, angsph: angsph, angst: angst, angzarr: angzarr, Aogon: Aogon, aogon: aogon, Aopf: Aopf, aopf: aopf, apacir: apacir, ap: ap, apE: apE, ape: ape, apid: apid, apos: apos$1, ApplyFunction: ApplyFunction, approx: approx, approxeq: approxeq, Aring: Aring$1, aring: aring$1, Ascr: Ascr, ascr: ascr, Assign: Assign, ast: ast, asymp: asymp, asympeq: asympeq, Atilde: Atilde$1, atilde: atilde$1, Auml: Auml$1, auml: auml$1, awconint: awconint, awint: awint, backcong: backcong, backepsilon: backepsilon, backprime: backprime, backsim: backsim, backsimeq: backsimeq, Backslash: Backslash, Barv: Barv, barvee: barvee, barwed: barwed, Barwed: Barwed, barwedge: barwedge, bbrk: bbrk, bbrktbrk: bbrktbrk, bcong: bcong, Bcy: Bcy, bcy: bcy, bdquo: bdquo, becaus: becaus, because: because, Because: Because, bemptyv: bemptyv, bepsi: bepsi, bernou: bernou, Bernoullis: Bernoullis, Beta: Beta, beta: beta, beth: beth, between: between, Bfr: Bfr, bfr: bfr, bigcap: bigcap, bigcirc: bigcirc, bigcup: bigcup, bigodot: bigodot, bigoplus: bigoplus, bigotimes: bigotimes, bigsqcup: bigsqcup, bigstar: bigstar, bigtriangledown: bigtriangledown, bigtriangleup: bigtriangleup, biguplus: biguplus, bigvee: bigvee, bigwedge: bigwedge, bkarow: bkarow, blacklozenge: blacklozenge, blacksquare: blacksquare, blacktriangle: blacktriangle, blacktriangledown: blacktriangledown, blacktriangleleft: blacktriangleleft, blacktriangleright: blacktriangleright, blank: blank, blk12: blk12, blk14: blk14, blk34: blk34, block: block, bne: bne, bnequiv: bnequiv, bNot: bNot, bnot: bnot, Bopf: Bopf, bopf: bopf, bot: bot, bottom: bottom, bowtie: bowtie, boxbox: boxbox, boxdl: boxdl, boxdL: boxdL, boxDl: boxDl, boxDL: boxDL, boxdr: boxdr, boxdR: boxdR, boxDr: boxDr, boxDR: boxDR, boxh: boxh, boxH: boxH, boxhd: boxhd, boxHd: boxHd, boxhD: boxhD, boxHD: boxHD, boxhu: boxhu, boxHu: boxHu, boxhU: boxhU, boxHU: boxHU, boxminus: boxminus, boxplus: boxplus, boxtimes: boxtimes, boxul: boxul, boxuL: boxuL, boxUl: boxUl, boxUL: boxUL, boxur: boxur, boxuR: boxuR, boxUr: boxUr, boxUR: boxUR, boxv: boxv, boxV: boxV, boxvh: boxvh, boxvH: boxvH, boxVh: boxVh, boxVH: boxVH, boxvl: boxvl, boxvL: boxvL, boxVl: boxVl, boxVL: boxVL, boxvr: boxvr, boxvR: boxvR, boxVr: boxVr, boxVR: boxVR, bprime: bprime, breve: breve, Breve: Breve, brvbar: brvbar$1, bscr: bscr, Bscr: Bscr, bsemi: bsemi, bsim: bsim, bsime: bsime, bsolb: bsolb, bsol: bsol, bsolhsub: bsolhsub, bull: bull, bullet: bullet, bump: bump, bumpE: bumpE, bumpe: bumpe, Bumpeq: Bumpeq, bumpeq: bumpeq, Cacute: Cacute, cacute: cacute, capand: capand, capbrcup: capbrcup, capcap: capcap, cap: cap, Cap: Cap, capcup: capcup, capdot: capdot, CapitalDifferentialD: CapitalDifferentialD, caps: caps, caret: caret, caron: caron, Cayleys: Cayleys, ccaps: ccaps, Ccaron: Ccaron, ccaron: ccaron, Ccedil: Ccedil$1, ccedil: ccedil$1, Ccirc: Ccirc, ccirc: ccirc, Cconint: Cconint, ccups: ccups, ccupssm: ccupssm, Cdot: Cdot, cdot: cdot, cedil: cedil$1, Cedilla: Cedilla, cemptyv: cemptyv, cent: cent$1, centerdot: centerdot, CenterDot: CenterDot, cfr: cfr, Cfr: Cfr, CHcy: CHcy, chcy: chcy, check: check, checkmark: checkmark, Chi: Chi, chi: chi, circ: circ, circeq: circeq, circlearrowleft: circlearrowleft, circlearrowright: circlearrowright, circledast: circledast, circledcirc: circledcirc, circleddash: circleddash, CircleDot: CircleDot, circledR: circledR, circledS: circledS, CircleMinus: CircleMinus, CirclePlus: CirclePlus, CircleTimes: CircleTimes, cir: cir, cirE: cirE, cire: cire, cirfnint: cirfnint, cirmid: cirmid, cirscir: cirscir, ClockwiseContourIntegral: ClockwiseContourIntegral, CloseCurlyDoubleQuote: CloseCurlyDoubleQuote, CloseCurlyQuote: CloseCurlyQuote, clubs: clubs, clubsuit: clubsuit, colon: colon, Colon: Colon, Colone: Colone, colone: colone, coloneq: coloneq, comma: comma, commat: commat, comp: comp, compfn: compfn, complement: complement, complexes: complexes, cong: cong, congdot: congdot, Congruent: Congruent, conint: conint, Conint: Conint, ContourIntegral: ContourIntegral, copf: copf, Copf: Copf, coprod: coprod, Coproduct: Coproduct, copy: copy$1, COPY: COPY$1, copysr: copysr, CounterClockwiseContourIntegral: CounterClockwiseContourIntegral, crarr: crarr, cross: cross, Cross: Cross, Cscr: Cscr, cscr: cscr, csub: csub, csube: csube, csup: csup, csupe: csupe, ctdot: ctdot, cudarrl: cudarrl, cudarrr: cudarrr, cuepr: cuepr, cuesc: cuesc, cularr: cularr, cularrp: cularrp, cupbrcap: cupbrcap, cupcap: cupcap, CupCap: CupCap, cup: cup, Cup: Cup, cupcup: cupcup, cupdot: cupdot, cupor: cupor, cups: cups, curarr: curarr, curarrm: curarrm, curlyeqprec: curlyeqprec, curlyeqsucc: curlyeqsucc, curlyvee: curlyvee, curlywedge: curlywedge, curren: curren$1, curvearrowleft: curvearrowleft, curvearrowright: curvearrowright, cuvee: cuvee, cuwed: cuwed, cwconint: cwconint, cwint: cwint, cylcty: cylcty, dagger: dagger, Dagger: Dagger, daleth: daleth, darr: darr, Darr: Darr, dArr: dArr, dash: dash, Dashv: Dashv, dashv: dashv, dbkarow: dbkarow, dblac: dblac, Dcaron: Dcaron, dcaron: dcaron, Dcy: Dcy, dcy: dcy, ddagger: ddagger, ddarr: ddarr, DD: DD, dd: dd, DDotrahd: DDotrahd, ddotseq: ddotseq, deg: deg$1, Del: Del, Delta: Delta, delta: delta, demptyv: demptyv, dfisht: dfisht, Dfr: Dfr, dfr: dfr, dHar: dHar, dharl: dharl, dharr: dharr, DiacriticalAcute: DiacriticalAcute, DiacriticalDot: DiacriticalDot, DiacriticalDoubleAcute: DiacriticalDoubleAcute, DiacriticalGrave: DiacriticalGrave, DiacriticalTilde: DiacriticalTilde, diam: diam, diamond: diamond, Diamond: Diamond, diamondsuit: diamondsuit, diams: diams, die: die, DifferentialD: DifferentialD, digamma: digamma, disin: disin, div: div, divide: divide$1, divideontimes: divideontimes, divonx: divonx, DJcy: DJcy, djcy: djcy, dlcorn: dlcorn, dlcrop: dlcrop, dollar: dollar, Dopf: Dopf, dopf: dopf, Dot: Dot, dot: dot, DotDot: DotDot, doteq: doteq, doteqdot: doteqdot, DotEqual: DotEqual, dotminus: dotminus, dotplus: dotplus, dotsquare: dotsquare, doublebarwedge: doublebarwedge, DoubleContourIntegral: DoubleContourIntegral, DoubleDot: DoubleDot, DoubleDownArrow: DoubleDownArrow, DoubleLeftArrow: DoubleLeftArrow, DoubleLeftRightArrow: DoubleLeftRightArrow, DoubleLeftTee: DoubleLeftTee, DoubleLongLeftArrow: DoubleLongLeftArrow, DoubleLongLeftRightArrow: DoubleLongLeftRightArrow, DoubleLongRightArrow: DoubleLongRightArrow, DoubleRightArrow: DoubleRightArrow, DoubleRightTee: DoubleRightTee, DoubleUpArrow: DoubleUpArrow, DoubleUpDownArrow: DoubleUpDownArrow, DoubleVerticalBar: DoubleVerticalBar, DownArrowBar: DownArrowBar, downarrow: downarrow, DownArrow: DownArrow, Downarrow: Downarrow, DownArrowUpArrow: DownArrowUpArrow, DownBreve: DownBreve, downdownarrows: downdownarrows, downharpoonleft: downharpoonleft, downharpoonright: downharpoonright, DownLeftRightVector: DownLeftRightVector, DownLeftTeeVector: DownLeftTeeVector, DownLeftVectorBar: DownLeftVectorBar, DownLeftVector: DownLeftVector, DownRightTeeVector: DownRightTeeVector, DownRightVectorBar: DownRightVectorBar, DownRightVector: DownRightVector, DownTeeArrow: DownTeeArrow, DownTee: DownTee, drbkarow: drbkarow, drcorn: drcorn, drcrop: drcrop, Dscr: Dscr, dscr: dscr, DScy: DScy, dscy: dscy, dsol: dsol, Dstrok: Dstrok, dstrok: dstrok, dtdot: dtdot, dtri: dtri, dtrif: dtrif, duarr: duarr, duhar: duhar, dwangle: dwangle, DZcy: DZcy, dzcy: dzcy, dzigrarr: dzigrarr, Eacute: Eacute$1, eacute: eacute$1, easter: easter, Ecaron: Ecaron, ecaron: ecaron, Ecirc: Ecirc$1, ecirc: ecirc$1, ecir: ecir, ecolon: ecolon, Ecy: Ecy, ecy: ecy, eDDot: eDDot, Edot: Edot, edot: edot, eDot: eDot, ee: ee, efDot: efDot, Efr: Efr, efr: efr, eg: eg, Egrave: Egrave$1, egrave: egrave$1, egs: egs, egsdot: egsdot, el: el, Element: Element$1, elinters: elinters, ell: ell, els: els, elsdot: elsdot, Emacr: Emacr, emacr: emacr, empty: empty, emptyset: emptyset, EmptySmallSquare: EmptySmallSquare, emptyv: emptyv, EmptyVerySmallSquare: EmptyVerySmallSquare, emsp13: emsp13, emsp14: emsp14, emsp: emsp, ENG: ENG, eng: eng, ensp: ensp, Eogon: Eogon, eogon: eogon, Eopf: Eopf, eopf: eopf, epar: epar, eparsl: eparsl, eplus: eplus, epsi: epsi, Epsilon: Epsilon, epsilon: epsilon, epsiv: epsiv, eqcirc: eqcirc, eqcolon: eqcolon, eqsim: eqsim, eqslantgtr: eqslantgtr, eqslantless: eqslantless, Equal: Equal, equals: equals, EqualTilde: EqualTilde, equest: equest, Equilibrium: Equilibrium, equiv: equiv, equivDD: equivDD, eqvparsl: eqvparsl, erarr: erarr, erDot: erDot, escr: escr, Escr: Escr, esdot: esdot, Esim: Esim, esim: esim, Eta: Eta, eta: eta, ETH: ETH$1, eth: eth$1, Euml: Euml$1, euml: euml$1, euro: euro, excl: excl, exist: exist, Exists: Exists, expectation: expectation, exponentiale: exponentiale, ExponentialE: ExponentialE, fallingdotseq: fallingdotseq, Fcy: Fcy, fcy: fcy, female: female, ffilig: ffilig, fflig: fflig, ffllig: ffllig, Ffr: Ffr, ffr: ffr, filig: filig, FilledSmallSquare: FilledSmallSquare, FilledVerySmallSquare: FilledVerySmallSquare, fjlig: fjlig, flat: flat, fllig: fllig, fltns: fltns, fnof: fnof, Fopf: Fopf, fopf: fopf, forall: forall, ForAll: ForAll, fork: fork, forkv: forkv, Fouriertrf: Fouriertrf, fpartint: fpartint, frac12: frac12$1, frac13: frac13, frac14: frac14$1, frac15: frac15, frac16: frac16, frac18: frac18, frac23: frac23, frac25: frac25, frac34: frac34$1, frac35: frac35, frac38: frac38, frac45: frac45, frac56: frac56, frac58: frac58, frac78: frac78, frasl: frasl, frown: frown, fscr: fscr, Fscr: Fscr, gacute: gacute, Gamma: Gamma, gamma: gamma, Gammad: Gammad, gammad: gammad, gap: gap, Gbreve: Gbreve, gbreve: gbreve, Gcedil: Gcedil, Gcirc: Gcirc, gcirc: gcirc, Gcy: Gcy, gcy: gcy, Gdot: Gdot, gdot: gdot, ge: ge, gE: gE, gEl: gEl, gel: gel, geq: geq, geqq: geqq, geqslant: geqslant, gescc: gescc, ges: ges, gesdot: gesdot, gesdoto: gesdoto, gesdotol: gesdotol, gesl: gesl, gesles: gesles, Gfr: Gfr, gfr: gfr, gg: gg, Gg: Gg, ggg: ggg, gimel: gimel, GJcy: GJcy, gjcy: gjcy, gla: gla, gl: gl, glE: glE, glj: glj, gnap: gnap, gnapprox: gnapprox, gne: gne, gnE: gnE, gneq: gneq, gneqq: gneqq, gnsim: gnsim, Gopf: Gopf, gopf: gopf, grave: grave, GreaterEqual: GreaterEqual, GreaterEqualLess: GreaterEqualLess, GreaterFullEqual: GreaterFullEqual, GreaterGreater: GreaterGreater, GreaterLess: GreaterLess, GreaterSlantEqual: GreaterSlantEqual, GreaterTilde: GreaterTilde, Gscr: Gscr, gscr: gscr, gsim: gsim, gsime: gsime, gsiml: gsiml, gtcc: gtcc, gtcir: gtcir, gt: gt$2, GT: GT$1, Gt: Gt, gtdot: gtdot, gtlPar: gtlPar, gtquest: gtquest, gtrapprox: gtrapprox, gtrarr: gtrarr, gtrdot: gtrdot, gtreqless: gtreqless, gtreqqless: gtreqqless, gtrless: gtrless, gtrsim: gtrsim, gvertneqq: gvertneqq, gvnE: gvnE, Hacek: Hacek, hairsp: hairsp, half: half, hamilt: hamilt, HARDcy: HARDcy, hardcy: hardcy, harrcir: harrcir, harr: harr, hArr: hArr, harrw: harrw, Hat: Hat, hbar: hbar, Hcirc: Hcirc, hcirc: hcirc, hearts: hearts, heartsuit: heartsuit, hellip: hellip, hercon: hercon, hfr: hfr, Hfr: Hfr, HilbertSpace: HilbertSpace, hksearow: hksearow, hkswarow: hkswarow, hoarr: hoarr, homtht: homtht, hookleftarrow: hookleftarrow, hookrightarrow: hookrightarrow, hopf: hopf, Hopf: Hopf, horbar: horbar, HorizontalLine: HorizontalLine, hscr: hscr, Hscr: Hscr, hslash: hslash, Hstrok: Hstrok, hstrok: hstrok, HumpDownHump: HumpDownHump, HumpEqual: HumpEqual, hybull: hybull, hyphen: hyphen, Iacute: Iacute$1, iacute: iacute$1, ic: ic, Icirc: Icirc$1, icirc: icirc$1, Icy: Icy, icy: icy, Idot: Idot, IEcy: IEcy, iecy: iecy, iexcl: iexcl$1, iff: iff, ifr: ifr, Ifr: Ifr, Igrave: Igrave$1, igrave: igrave$1, ii: ii, iiiint: iiiint, iiint: iiint, iinfin: iinfin, iiota: iiota, IJlig: IJlig, ijlig: ijlig, Imacr: Imacr, imacr: imacr, image: image, ImaginaryI: ImaginaryI, imagline: imagline, imagpart: imagpart, imath: imath, Im: Im, imof: imof, imped: imped, Implies: Implies, incare: incare, "in": "∈", infin: infin, infintie: infintie, inodot: inodot, intcal: intcal, int: int, Int: Int, integers: integers, Integral: Integral, intercal: intercal, Intersection: Intersection, intlarhk: intlarhk, intprod: intprod, InvisibleComma: InvisibleComma, InvisibleTimes: InvisibleTimes, IOcy: IOcy, iocy: iocy, Iogon: Iogon, iogon: iogon, Iopf: Iopf, iopf: iopf, Iota: Iota, iota: iota, iprod: iprod, iquest: iquest$1, iscr: iscr, Iscr: Iscr, isin: isin, isindot: isindot, isinE: isinE, isins: isins, isinsv: isinsv, isinv: isinv, it: it, Itilde: Itilde, itilde: itilde, Iukcy: Iukcy, iukcy: iukcy, Iuml: Iuml$1, iuml: iuml$1, Jcirc: Jcirc, jcirc: jcirc, Jcy: Jcy, jcy: jcy, Jfr: Jfr, jfr: jfr, jmath: jmath, Jopf: Jopf, jopf: jopf, Jscr: Jscr, jscr: jscr, Jsercy: Jsercy, jsercy: jsercy, Jukcy: Jukcy, jukcy: jukcy, Kappa: Kappa, kappa: kappa, kappav: kappav, Kcedil: Kcedil, kcedil: kcedil, Kcy: Kcy, kcy: kcy, Kfr: Kfr, kfr: kfr, kgreen: kgreen, KHcy: KHcy, khcy: khcy, KJcy: KJcy, kjcy: kjcy, Kopf: Kopf, kopf: kopf, Kscr: Kscr, kscr: kscr, lAarr: lAarr, Lacute: Lacute, lacute: lacute, laemptyv: laemptyv, lagran: lagran, Lambda: Lambda, lambda: lambda, lang: lang, Lang: Lang, langd: langd, langle: langle, lap: lap, Laplacetrf: Laplacetrf, laquo: laquo$1, larrb: larrb, larrbfs: larrbfs, larr: larr, Larr: Larr, lArr: lArr, larrfs: larrfs, larrhk: larrhk, larrlp: larrlp, larrpl: larrpl, larrsim: larrsim, larrtl: larrtl, latail: latail, lAtail: lAtail, lat: lat, late: late, lates: lates, lbarr: lbarr, lBarr: lBarr, lbbrk: lbbrk, lbrace: lbrace, lbrack: lbrack, lbrke: lbrke, lbrksld: lbrksld, lbrkslu: lbrkslu, Lcaron: Lcaron, lcaron: lcaron, Lcedil: Lcedil, lcedil: lcedil, lceil: lceil, lcub: lcub, Lcy: Lcy, lcy: lcy, ldca: ldca, ldquo: ldquo, ldquor: ldquor, ldrdhar: ldrdhar, ldrushar: ldrushar, ldsh: ldsh, le: le, lE: lE, LeftAngleBracket: LeftAngleBracket, LeftArrowBar: LeftArrowBar, leftarrow: leftarrow, LeftArrow: LeftArrow, Leftarrow: Leftarrow, LeftArrowRightArrow: LeftArrowRightArrow, leftarrowtail: leftarrowtail, LeftCeiling: LeftCeiling, LeftDoubleBracket: LeftDoubleBracket, LeftDownTeeVector: LeftDownTeeVector, LeftDownVectorBar: LeftDownVectorBar, LeftDownVector: LeftDownVector, LeftFloor: LeftFloor, leftharpoondown: leftharpoondown, leftharpoonup: leftharpoonup, leftleftarrows: leftleftarrows, leftrightarrow: leftrightarrow, LeftRightArrow: LeftRightArrow, Leftrightarrow: Leftrightarrow, leftrightarrows: leftrightarrows, leftrightharpoons: leftrightharpoons, leftrightsquigarrow: leftrightsquigarrow, LeftRightVector: LeftRightVector, LeftTeeArrow: LeftTeeArrow, LeftTee: LeftTee, LeftTeeVector: LeftTeeVector, leftthreetimes: leftthreetimes, LeftTriangleBar: LeftTriangleBar, LeftTriangle: LeftTriangle, LeftTriangleEqual: LeftTriangleEqual, LeftUpDownVector: LeftUpDownVector, LeftUpTeeVector: LeftUpTeeVector, LeftUpVectorBar: LeftUpVectorBar, LeftUpVector: LeftUpVector, LeftVectorBar: LeftVectorBar, LeftVector: LeftVector, lEg: lEg, leg: leg, leq: leq, leqq: leqq, leqslant: leqslant, lescc: lescc, les: les, lesdot: lesdot, lesdoto: lesdoto, lesdotor: lesdotor, lesg: lesg, lesges: lesges, lessapprox: lessapprox, lessdot: lessdot, lesseqgtr: lesseqgtr, lesseqqgtr: lesseqqgtr, LessEqualGreater: LessEqualGreater, LessFullEqual: LessFullEqual, LessGreater: LessGreater, lessgtr: lessgtr, LessLess: LessLess, lesssim: lesssim, LessSlantEqual: LessSlantEqual, LessTilde: LessTilde, lfisht: lfisht, lfloor: lfloor, Lfr: Lfr, lfr: lfr, lg: lg, lgE: lgE, lHar: lHar, lhard: lhard, lharu: lharu, lharul: lharul, lhblk: lhblk, LJcy: LJcy, ljcy: ljcy, llarr: llarr, ll: ll, Ll: Ll, llcorner: llcorner, Lleftarrow: Lleftarrow, llhard: llhard, lltri: lltri, Lmidot: Lmidot, lmidot: lmidot, lmoustache: lmoustache, lmoust: lmoust, lnap: lnap, lnapprox: lnapprox, lne: lne, lnE: lnE, lneq: lneq, lneqq: lneqq, lnsim: lnsim, loang: loang, loarr: loarr, lobrk: lobrk, longleftarrow: longleftarrow, LongLeftArrow: LongLeftArrow, Longleftarrow: Longleftarrow, longleftrightarrow: longleftrightarrow, LongLeftRightArrow: LongLeftRightArrow, Longleftrightarrow: Longleftrightarrow, longmapsto: longmapsto, longrightarrow: longrightarrow, LongRightArrow: LongRightArrow, Longrightarrow: Longrightarrow, looparrowleft: looparrowleft, looparrowright: looparrowright, lopar: lopar, Lopf: Lopf, lopf: lopf, loplus: loplus, lotimes: lotimes, lowast: lowast, lowbar: lowbar, LowerLeftArrow: LowerLeftArrow, LowerRightArrow: LowerRightArrow, loz: loz, lozenge: lozenge, lozf: lozf, lpar: lpar, lparlt: lparlt, lrarr: lrarr, lrcorner: lrcorner, lrhar: lrhar, lrhard: lrhard, lrm: lrm, lrtri: lrtri, lsaquo: lsaquo, lscr: lscr, Lscr: Lscr, lsh: lsh, Lsh: Lsh, lsim: lsim, lsime: lsime, lsimg: lsimg, lsqb: lsqb, lsquo: lsquo, lsquor: lsquor, Lstrok: Lstrok, lstrok: lstrok, ltcc: ltcc, ltcir: ltcir, lt: lt$2, LT: LT$1, Lt: Lt, ltdot: ltdot, lthree: lthree, ltimes: ltimes, ltlarr: ltlarr, ltquest: ltquest, ltri: ltri, ltrie: ltrie, ltrif: ltrif, ltrPar: ltrPar, lurdshar: lurdshar, luruhar: luruhar, lvertneqq: lvertneqq, lvnE: lvnE, macr: macr$1, male: male, malt: malt, maltese: maltese, "Map": "⤅", map: map, mapsto: mapsto, mapstodown: mapstodown, mapstoleft: mapstoleft, mapstoup: mapstoup, marker: marker, mcomma: mcomma, Mcy: Mcy, mcy: mcy, mdash: mdash, mDDot: mDDot, measuredangle: measuredangle, MediumSpace: MediumSpace, Mellintrf: Mellintrf, Mfr: Mfr, mfr: mfr, mho: mho, micro: micro$1, midast: midast, midcir: midcir, mid: mid, middot: middot$1, minusb: minusb, minus: minus, minusd: minusd, minusdu: minusdu, MinusPlus: MinusPlus, mlcp: mlcp, mldr: mldr, mnplus: mnplus, models: models, Mopf: Mopf, mopf: mopf, mp: mp, mscr: mscr, Mscr: Mscr, mstpos: mstpos, Mu: Mu, mu: mu, multimap: multimap, mumap: mumap, nabla: nabla, Nacute: Nacute, nacute: nacute, nang: nang, nap: nap, napE: napE, napid: napid, napos: napos, napprox: napprox, natural: natural, naturals: naturals, natur: natur, nbsp: nbsp$1, nbump: nbump, nbumpe: nbumpe, ncap: ncap, Ncaron: Ncaron, ncaron: ncaron, Ncedil: Ncedil, ncedil: ncedil, ncong: ncong, ncongdot: ncongdot, ncup: ncup, Ncy: Ncy, ncy: ncy, ndash: ndash, nearhk: nearhk, nearr: nearr, neArr: neArr, nearrow: nearrow, ne: ne, nedot: nedot, NegativeMediumSpace: NegativeMediumSpace, NegativeThickSpace: NegativeThickSpace, NegativeThinSpace: NegativeThinSpace, NegativeVeryThinSpace: NegativeVeryThinSpace, nequiv: nequiv, nesear: nesear, nesim: nesim, NestedGreaterGreater: NestedGreaterGreater, NestedLessLess: NestedLessLess, NewLine: NewLine, nexist: nexist, nexists: nexists, Nfr: Nfr, nfr: nfr, ngE: ngE, nge: nge, ngeq: ngeq, ngeqq: ngeqq, ngeqslant: ngeqslant, nges: nges, nGg: nGg, ngsim: ngsim, nGt: nGt, ngt: ngt, ngtr: ngtr, nGtv: nGtv, nharr: nharr, nhArr: nhArr, nhpar: nhpar, ni: ni, nis: nis, nisd: nisd, niv: niv, NJcy: NJcy, njcy: njcy, nlarr: nlarr, nlArr: nlArr, nldr: nldr, nlE: nlE, nle: nle, nleftarrow: nleftarrow, nLeftarrow: nLeftarrow, nleftrightarrow: nleftrightarrow, nLeftrightarrow: nLeftrightarrow, nleq: nleq, nleqq: nleqq, nleqslant: nleqslant, nles: nles, nless: nless, nLl: nLl, nlsim: nlsim, nLt: nLt, nlt: nlt, nltri: nltri, nltrie: nltrie, nLtv: nLtv, nmid: nmid, NoBreak: NoBreak, NonBreakingSpace: NonBreakingSpace, nopf: nopf, Nopf: Nopf, Not: Not, not: not$1, NotCongruent: NotCongruent, NotCupCap: NotCupCap, NotDoubleVerticalBar: NotDoubleVerticalBar, NotElement: NotElement, NotEqual: NotEqual, NotEqualTilde: NotEqualTilde, NotExists: NotExists, NotGreater: NotGreater, NotGreaterEqual: NotGreaterEqual, NotGreaterFullEqual: NotGreaterFullEqual, NotGreaterGreater: NotGreaterGreater, NotGreaterLess: NotGreaterLess, NotGreaterSlantEqual: NotGreaterSlantEqual, NotGreaterTilde: NotGreaterTilde, NotHumpDownHump: NotHumpDownHump, NotHumpEqual: NotHumpEqual, notin: notin, notindot: notindot, notinE: notinE, notinva: notinva, notinvb: notinvb, notinvc: notinvc, NotLeftTriangleBar: NotLeftTriangleBar, NotLeftTriangle: NotLeftTriangle, NotLeftTriangleEqual: NotLeftTriangleEqual, NotLess: NotLess, NotLessEqual: NotLessEqual, NotLessGreater: NotLessGreater, NotLessLess: NotLessLess, NotLessSlantEqual: NotLessSlantEqual, NotLessTilde: NotLessTilde, NotNestedGreaterGreater: NotNestedGreaterGreater, NotNestedLessLess: NotNestedLessLess, notni: notni, notniva: notniva, notnivb: notnivb, notnivc: notnivc, NotPrecedes: NotPrecedes, NotPrecedesEqual: NotPrecedesEqual, NotPrecedesSlantEqual: NotPrecedesSlantEqual, NotReverseElement: NotReverseElement, NotRightTriangleBar: NotRightTriangleBar, NotRightTriangle: NotRightTriangle, NotRightTriangleEqual: NotRightTriangleEqual, NotSquareSubset: NotSquareSubset, NotSquareSubsetEqual: NotSquareSubsetEqual, NotSquareSuperset: NotSquareSuperset, NotSquareSupersetEqual: NotSquareSupersetEqual, NotSubset: NotSubset, NotSubsetEqual: NotSubsetEqual, NotSucceeds: NotSucceeds, NotSucceedsEqual: NotSucceedsEqual, NotSucceedsSlantEqual: NotSucceedsSlantEqual, NotSucceedsTilde: NotSucceedsTilde, NotSuperset: NotSuperset, NotSupersetEqual: NotSupersetEqual, NotTilde: NotTilde, NotTildeEqual: NotTildeEqual, NotTildeFullEqual: NotTildeFullEqual, NotTildeTilde: NotTildeTilde, NotVerticalBar: NotVerticalBar, nparallel: nparallel, npar: npar, nparsl: nparsl, npart: npart, npolint: npolint, npr: npr, nprcue: nprcue, nprec: nprec, npreceq: npreceq, npre: npre, nrarrc: nrarrc, nrarr: nrarr, nrArr: nrArr, nrarrw: nrarrw, nrightarrow: nrightarrow, nRightarrow: nRightarrow, nrtri: nrtri, nrtrie: nrtrie, nsc: nsc, nsccue: nsccue, nsce: nsce, Nscr: Nscr, nscr: nscr, nshortmid: nshortmid, nshortparallel: nshortparallel, nsim: nsim, nsime: nsime, nsimeq: nsimeq, nsmid: nsmid, nspar: nspar, nsqsube: nsqsube, nsqsupe: nsqsupe, nsub: nsub, nsubE: nsubE, nsube: nsube, nsubset: nsubset, nsubseteq: nsubseteq, nsubseteqq: nsubseteqq, nsucc: nsucc, nsucceq: nsucceq, nsup: nsup, nsupE: nsupE, nsupe: nsupe, nsupset: nsupset, nsupseteq: nsupseteq, nsupseteqq: nsupseteqq, ntgl: ntgl, Ntilde: Ntilde$1, ntilde: ntilde$1, ntlg: ntlg, ntriangleleft: ntriangleleft, ntrianglelefteq: ntrianglelefteq, ntriangleright: ntriangleright, ntrianglerighteq: ntrianglerighteq, Nu: Nu, nu: nu, num: num, numero: numero, numsp: numsp, nvap: nvap, nvdash: nvdash, nvDash: nvDash, nVdash: nVdash, nVDash: nVDash, nvge: nvge, nvgt: nvgt, nvHarr: nvHarr, nvinfin: nvinfin, nvlArr: nvlArr, nvle: nvle, nvlt: nvlt, nvltrie: nvltrie, nvrArr: nvrArr, nvrtrie: nvrtrie, nvsim: nvsim, nwarhk: nwarhk, nwarr: nwarr, nwArr: nwArr, nwarrow: nwarrow, nwnear: nwnear, Oacute: Oacute$1, oacute: oacute$1, oast: oast, Ocirc: Ocirc$1, ocirc: ocirc$1, ocir: ocir, Ocy: Ocy, ocy: ocy, odash: odash, Odblac: Odblac, odblac: odblac, odiv: odiv, odot: odot, odsold: odsold, OElig: OElig, oelig: oelig, ofcir: ofcir, Ofr: Ofr, ofr: ofr, ogon: ogon, Ograve: Ograve$1, ograve: ograve$1, ogt: ogt, ohbar: ohbar, ohm: ohm, oint: oint, olarr: olarr, olcir: olcir, olcross: olcross, oline: oline, olt: olt, Omacr: Omacr, omacr: omacr, Omega: Omega, omega: omega, Omicron: Omicron, omicron: omicron, omid: omid, ominus: ominus, Oopf: Oopf, oopf: oopf, opar: opar, OpenCurlyDoubleQuote: OpenCurlyDoubleQuote, OpenCurlyQuote: OpenCurlyQuote, operp: operp, oplus: oplus, orarr: orarr, Or: Or, or: or, ord: ord, order: order, orderof: orderof, ordf: ordf$1, ordm: ordm$1, origof: origof, oror: oror, orslope: orslope, orv: orv, oS: oS, Oscr: Oscr, oscr: oscr, Oslash: Oslash$1, oslash: oslash$1, osol: osol, Otilde: Otilde$1, otilde: otilde$1, otimesas: otimesas, Otimes: Otimes, otimes: otimes, Ouml: Ouml$1, ouml: ouml$1, ovbar: ovbar, OverBar: OverBar, OverBrace: OverBrace, OverBracket: OverBracket, OverParenthesis: OverParenthesis, para: para$1, parallel: parallel, par: par, parsim: parsim, parsl: parsl, part: part, PartialD: PartialD, Pcy: Pcy, pcy: pcy, percnt: percnt, period: period, permil: permil, perp: perp, pertenk: pertenk, Pfr: Pfr, pfr: pfr, Phi: Phi, phi: phi, phiv: phiv, phmmat: phmmat, phone: phone, Pi: Pi, pi: pi, pitchfork: pitchfork, piv: piv, planck: planck, planckh: planckh, plankv: plankv, plusacir: plusacir, plusb: plusb, pluscir: pluscir, plus: plus, plusdo: plusdo, plusdu: plusdu, pluse: pluse, PlusMinus: PlusMinus, plusmn: plusmn$1, plussim: plussim, plustwo: plustwo, pm: pm, Poincareplane: Poincareplane, pointint: pointint, popf: popf, Popf: Popf, pound: pound$1, prap: prap, Pr: Pr, pr: pr, prcue: prcue, precapprox: precapprox, prec: prec, preccurlyeq: preccurlyeq, Precedes: Precedes, PrecedesEqual: PrecedesEqual, PrecedesSlantEqual: PrecedesSlantEqual, PrecedesTilde: PrecedesTilde, preceq: preceq, precnapprox: precnapprox, precneqq: precneqq, precnsim: precnsim, pre: pre, prE: prE, precsim: precsim, prime: prime, Prime: Prime, primes: primes, prnap: prnap, prnE: prnE, prnsim: prnsim, prod: prod, Product: Product, profalar: profalar, profline: profline, profsurf: profsurf, prop: prop, Proportional: Proportional, Proportion: Proportion, propto: propto, prsim: prsim, prurel: prurel, Pscr: Pscr, pscr: pscr, Psi: Psi, psi: psi, puncsp: puncsp, Qfr: Qfr, qfr: qfr, qint: qint, qopf: qopf, Qopf: Qopf, qprime: qprime, Qscr: Qscr, qscr: qscr, quaternions: quaternions, quatint: quatint, quest: quest, questeq: questeq, quot: quot$2, QUOT: QUOT$1, rAarr: rAarr, race: race, Racute: Racute, racute: racute, radic: radic, raemptyv: raemptyv, rang: rang, Rang: Rang, rangd: rangd, range: range, rangle: rangle, raquo: raquo$1, rarrap: rarrap, rarrb: rarrb, rarrbfs: rarrbfs, rarrc: rarrc, rarr: rarr, Rarr: Rarr, rArr: rArr, rarrfs: rarrfs, rarrhk: rarrhk, rarrlp: rarrlp, rarrpl: rarrpl, rarrsim: rarrsim, Rarrtl: Rarrtl, rarrtl: rarrtl, rarrw: rarrw, ratail: ratail, rAtail: rAtail, ratio: ratio, rationals: rationals, rbarr: rbarr, rBarr: rBarr, RBarr: RBarr, rbbrk: rbbrk, rbrace: rbrace, rbrack: rbrack, rbrke: rbrke, rbrksld: rbrksld, rbrkslu: rbrkslu, Rcaron: Rcaron, rcaron: rcaron, Rcedil: Rcedil, rcedil: rcedil, rceil: rceil, rcub: rcub, Rcy: Rcy, rcy: rcy, rdca: rdca, rdldhar: rdldhar, rdquo: rdquo, rdquor: rdquor, rdsh: rdsh, real: real, realine: realine, realpart: realpart, reals: reals, Re: Re, rect: rect, reg: reg$1, REG: REG$1, ReverseElement: ReverseElement, ReverseEquilibrium: ReverseEquilibrium, ReverseUpEquilibrium: ReverseUpEquilibrium, rfisht: rfisht, rfloor: rfloor, rfr: rfr, Rfr: Rfr, rHar: rHar, rhard: rhard, rharu: rharu, rharul: rharul, Rho: Rho, rho: rho, rhov: rhov, RightAngleBracket: RightAngleBracket, RightArrowBar: RightArrowBar, rightarrow: rightarrow, RightArrow: RightArrow, Rightarrow: Rightarrow, RightArrowLeftArrow: RightArrowLeftArrow, rightarrowtail: rightarrowtail, RightCeiling: RightCeiling, RightDoubleBracket: RightDoubleBracket, RightDownTeeVector: RightDownTeeVector, RightDownVectorBar: RightDownVectorBar, RightDownVector: RightDownVector, RightFloor: RightFloor, rightharpoondown: rightharpoondown, rightharpoonup: rightharpoonup, rightleftarrows: rightleftarrows, rightleftharpoons: rightleftharpoons, rightrightarrows: rightrightarrows, rightsquigarrow: rightsquigarrow, RightTeeArrow: RightTeeArrow, RightTee: RightTee, RightTeeVector: RightTeeVector, rightthreetimes: rightthreetimes, RightTriangleBar: RightTriangleBar, RightTriangle: RightTriangle, RightTriangleEqual: RightTriangleEqual, RightUpDownVector: RightUpDownVector, RightUpTeeVector: RightUpTeeVector, RightUpVectorBar: RightUpVectorBar, RightUpVector: RightUpVector, RightVectorBar: RightVectorBar, RightVector: RightVector, ring: ring, risingdotseq: risingdotseq, rlarr: rlarr, rlhar: rlhar, rlm: rlm, rmoustache: rmoustache, rmoust: rmoust, rnmid: rnmid, roang: roang, roarr: roarr, robrk: robrk, ropar: ropar, ropf: ropf, Ropf: Ropf, roplus: roplus, rotimes: rotimes, RoundImplies: RoundImplies, rpar: rpar, rpargt: rpargt, rppolint: rppolint, rrarr: rrarr, Rrightarrow: Rrightarrow, rsaquo: rsaquo, rscr: rscr, Rscr: Rscr, rsh: rsh, Rsh: Rsh, rsqb: rsqb, rsquo: rsquo, rsquor: rsquor, rthree: rthree, rtimes: rtimes, rtri: rtri, rtrie: rtrie, rtrif: rtrif, rtriltri: rtriltri, RuleDelayed: RuleDelayed, ruluhar: ruluhar, rx: rx, Sacute: Sacute, sacute: sacute, sbquo: sbquo, scap: scap, Scaron: Scaron, scaron: scaron, Sc: Sc, sc: sc, sccue: sccue, sce: sce, scE: scE, Scedil: Scedil, scedil: scedil, Scirc: Scirc, scirc: scirc, scnap: scnap, scnE: scnE, scnsim: scnsim, scpolint: scpolint, scsim: scsim, Scy: Scy, scy: scy, sdotb: sdotb, sdot: sdot, sdote: sdote, searhk: searhk, searr: searr, seArr: seArr, searrow: searrow, sect: sect$1, semi: semi, seswar: seswar, setminus: setminus, setmn: setmn, sext: sext, Sfr: Sfr, sfr: sfr, sfrown: sfrown, sharp: sharp, SHCHcy: SHCHcy, shchcy: shchcy, SHcy: SHcy, shcy: shcy, ShortDownArrow: ShortDownArrow, ShortLeftArrow: ShortLeftArrow, shortmid: shortmid, shortparallel: shortparallel, ShortRightArrow: ShortRightArrow, ShortUpArrow: ShortUpArrow, shy: shy$1, Sigma: Sigma, sigma: sigma, sigmaf: sigmaf, sigmav: sigmav, sim: sim, simdot: simdot, sime: sime, simeq: simeq, simg: simg, simgE: simgE, siml: siml, simlE: simlE, simne: simne, simplus: simplus, simrarr: simrarr, slarr: slarr, SmallCircle: SmallCircle, smallsetminus: smallsetminus, smashp: smashp, smeparsl: smeparsl, smid: smid, smile: smile, smt: smt, smte: smte, smtes: smtes, SOFTcy: SOFTcy, softcy: softcy, solbar: solbar, solb: solb, sol: sol, Sopf: Sopf, sopf: sopf, spades: spades, spadesuit: spadesuit, spar: spar, sqcap: sqcap, sqcaps: sqcaps, sqcup: sqcup, sqcups: sqcups, Sqrt: Sqrt, sqsub: sqsub, sqsube: sqsube, sqsubset: sqsubset, sqsubseteq: sqsubseteq, sqsup: sqsup, sqsupe: sqsupe, sqsupset: sqsupset, sqsupseteq: sqsupseteq, square: square, Square: Square, SquareIntersection: SquareIntersection, SquareSubset: SquareSubset, SquareSubsetEqual: SquareSubsetEqual, SquareSuperset: SquareSuperset, SquareSupersetEqual: SquareSupersetEqual, SquareUnion: SquareUnion, squarf: squarf, squ: squ, squf: squf, srarr: srarr, Sscr: Sscr, sscr: sscr, ssetmn: ssetmn, ssmile: ssmile, sstarf: sstarf, Star: Star, star: star, starf: starf, straightepsilon: straightepsilon, straightphi: straightphi, strns: strns, sub: sub, Sub: Sub, subdot: subdot, subE: subE, sube: sube, subedot: subedot, submult: submult, subnE: subnE, subne: subne, subplus: subplus, subrarr: subrarr, subset: subset, Subset: Subset, subseteq: subseteq, subseteqq: subseteqq, SubsetEqual: SubsetEqual, subsetneq: subsetneq, subsetneqq: subsetneqq, subsim: subsim, subsub: subsub, subsup: subsup, succapprox: succapprox, succ: succ, succcurlyeq: succcurlyeq, Succeeds: Succeeds, SucceedsEqual: SucceedsEqual, SucceedsSlantEqual: SucceedsSlantEqual, SucceedsTilde: SucceedsTilde, succeq: succeq, succnapprox: succnapprox, succneqq: succneqq, succnsim: succnsim, succsim: succsim, SuchThat: SuchThat, sum: sum, Sum: Sum, sung: sung, sup1: sup1$1, sup2: sup2$1, sup3: sup3$1, sup: sup, Sup: Sup, supdot: supdot, supdsub: supdsub, supE: supE, supe: supe, supedot: supedot, Superset: Superset, SupersetEqual: SupersetEqual, suphsol: suphsol, suphsub: suphsub, suplarr: suplarr, supmult: supmult, supnE: supnE, supne: supne, supplus: supplus, supset: supset, Supset: Supset, supseteq: supseteq, supseteqq: supseteqq, supsetneq: supsetneq, supsetneqq: supsetneqq, supsim: supsim, supsub: supsub, supsup: supsup, swarhk: swarhk, swarr: swarr, swArr: swArr, swarrow: swarrow, swnwar: swnwar, szlig: szlig$1, Tab: Tab, target: target, Tau: Tau, tau: tau, tbrk: tbrk, Tcaron: Tcaron, tcaron: tcaron, Tcedil: Tcedil, tcedil: tcedil, Tcy: Tcy, tcy: tcy, tdot: tdot, telrec: telrec, Tfr: Tfr, tfr: tfr, there4: there4, therefore: therefore, Therefore: Therefore, Theta: Theta, theta: theta, thetasym: thetasym, thetav: thetav, thickapprox: thickapprox, thicksim: thicksim, ThickSpace: ThickSpace, ThinSpace: ThinSpace, thinsp: thinsp, thkap: thkap, thksim: thksim, THORN: THORN$1, thorn: thorn$1, tilde: tilde, Tilde: Tilde, TildeEqual: TildeEqual, TildeFullEqual: TildeFullEqual, TildeTilde: TildeTilde, timesbar: timesbar, timesb: timesb, times: times$1, timesd: timesd, tint: tint, toea: toea, topbot: topbot, topcir: topcir, top: top, Topf: Topf, topf: topf, topfork: topfork, tosa: tosa, tprime: tprime, trade: trade, TRADE: TRADE, triangle: triangle, triangledown: triangledown, triangleleft: triangleleft, trianglelefteq: trianglelefteq, triangleq: triangleq, triangleright: triangleright, trianglerighteq: trianglerighteq, tridot: tridot, trie: trie, triminus: triminus, TripleDot: TripleDot, triplus: triplus, trisb: trisb, tritime: tritime, trpezium: trpezium, Tscr: Tscr, tscr: tscr, TScy: TScy, tscy: tscy, TSHcy: TSHcy, tshcy: tshcy, Tstrok: Tstrok, tstrok: tstrok, twixt: twixt, twoheadleftarrow: twoheadleftarrow, twoheadrightarrow: twoheadrightarrow, Uacute: Uacute$1, uacute: uacute$1, uarr: uarr, Uarr: Uarr, uArr: uArr, Uarrocir: Uarrocir, Ubrcy: Ubrcy, ubrcy: ubrcy, Ubreve: Ubreve, ubreve: ubreve, Ucirc: Ucirc$1, ucirc: ucirc$1, Ucy: Ucy, ucy: ucy, udarr: udarr, Udblac: Udblac, udblac: udblac, udhar: udhar, ufisht: ufisht, Ufr: Ufr, ufr: ufr, Ugrave: Ugrave$1, ugrave: ugrave$1, uHar: uHar, uharl: uharl, uharr: uharr, uhblk: uhblk, ulcorn: ulcorn, ulcorner: ulcorner, ulcrop: ulcrop, ultri: ultri, Umacr: Umacr, umacr: umacr, uml: uml$1, UnderBar: UnderBar, UnderBrace: UnderBrace, UnderBracket: UnderBracket, UnderParenthesis: UnderParenthesis, Union: Union, UnionPlus: UnionPlus, Uogon: Uogon, uogon: uogon, Uopf: Uopf, uopf: uopf, UpArrowBar: UpArrowBar, uparrow: uparrow, UpArrow: UpArrow, Uparrow: Uparrow, UpArrowDownArrow: UpArrowDownArrow, updownarrow: updownarrow, UpDownArrow: UpDownArrow, Updownarrow: Updownarrow, UpEquilibrium: UpEquilibrium, upharpoonleft: upharpoonleft, upharpoonright: upharpoonright, uplus: uplus, UpperLeftArrow: UpperLeftArrow, UpperRightArrow: UpperRightArrow, upsi: upsi, Upsi: Upsi, upsih: upsih, Upsilon: Upsilon, upsilon: upsilon, UpTeeArrow: UpTeeArrow, UpTee: UpTee, upuparrows: upuparrows, urcorn: urcorn, urcorner: urcorner, urcrop: urcrop, Uring: Uring, uring: uring, urtri: urtri, Uscr: Uscr, uscr: uscr, utdot: utdot, Utilde: Utilde, utilde: utilde, utri: utri, utrif: utrif, uuarr: uuarr, Uuml: Uuml$1, uuml: uuml$1, uwangle: uwangle, vangrt: vangrt, varepsilon: varepsilon, varkappa: varkappa, varnothing: varnothing, varphi: varphi, varpi: varpi, varpropto: varpropto, varr: varr, vArr: vArr, varrho: varrho, varsigma: varsigma, varsubsetneq: varsubsetneq, varsubsetneqq: varsubsetneqq, varsupsetneq: varsupsetneq, varsupsetneqq: varsupsetneqq, vartheta: vartheta, vartriangleleft: vartriangleleft, vartriangleright: vartriangleright, vBar: vBar, Vbar: Vbar, vBarv: vBarv, Vcy: Vcy, vcy: vcy, vdash: vdash, vDash: vDash, Vdash: Vdash, VDash: VDash, Vdashl: Vdashl, veebar: veebar, vee: vee, Vee: Vee, veeeq: veeeq, vellip: vellip, verbar: verbar, Verbar: Verbar, vert: vert, Vert: Vert, VerticalBar: VerticalBar, VerticalLine: VerticalLine, VerticalSeparator: VerticalSeparator, VerticalTilde: VerticalTilde, VeryThinSpace: VeryThinSpace, Vfr: Vfr, vfr: vfr, vltri: vltri, vnsub: vnsub, vnsup: vnsup, Vopf: Vopf, vopf: vopf, vprop: vprop, vrtri: vrtri, Vscr: Vscr, vscr: vscr, vsubnE: vsubnE, vsubne: vsubne, vsupnE: vsupnE, vsupne: vsupne, Vvdash: Vvdash, vzigzag: vzigzag, Wcirc: Wcirc, wcirc: wcirc, wedbar: wedbar, wedge: wedge, Wedge: Wedge, wedgeq: wedgeq, weierp: weierp, Wfr: Wfr, wfr: wfr, Wopf: Wopf, wopf: wopf, wp: wp, wr: wr, wreath: wreath, Wscr: Wscr, wscr: wscr, xcap: xcap, xcirc: xcirc, xcup: xcup, xdtri: xdtri, Xfr: Xfr, xfr: xfr, xharr: xharr, xhArr: xhArr, Xi: Xi, xi: xi, xlarr: xlarr, xlArr: xlArr, xmap: xmap, xnis: xnis, xodot: xodot, Xopf: Xopf, xopf: xopf, xoplus: xoplus, xotime: xotime, xrarr: xrarr, xrArr: xrArr, Xscr: Xscr, xscr: xscr, xsqcup: xsqcup, xuplus: xuplus, xutri: xutri, xvee: xvee, xwedge: xwedge, Yacute: Yacute$1, yacute: yacute$1, YAcy: YAcy, yacy: yacy, Ycirc: Ycirc, ycirc: ycirc, Ycy: Ycy, ycy: ycy, yen: yen$1, Yfr: Yfr, yfr: yfr, YIcy: YIcy, yicy: yicy, Yopf: Yopf, yopf: yopf, Yscr: Yscr, yscr: yscr, YUcy: YUcy, yucy: yucy, yuml: yuml$1, Yuml: Yuml, Zacute: Zacute, zacute: zacute, Zcaron: Zcaron, zcaron: zcaron, Zcy: Zcy, zcy: zcy, Zdot: Zdot, zdot: zdot, zeetrf: zeetrf, ZeroWidthSpace: ZeroWidthSpace, Zeta: Zeta, zeta: zeta, zfr: zfr, Zfr: Zfr, ZHcy: ZHcy, zhcy: zhcy, zigrarr: zigrarr, zopf: zopf, Zopf: Zopf, Zscr: Zscr, zscr: zscr, zwj: zwj, zwnj: zwnj }; var Aacute = "Á"; var aacute = "á"; var Acirc = "Â"; var acirc = "â"; var acute = "´"; var AElig = "Æ"; var aelig = "æ"; var Agrave = "À"; var agrave = "à"; var amp$1 = "&"; var AMP = "&"; var Aring = "Å"; var aring = "å"; var Atilde = "Ã"; var atilde = "ã"; var Auml = "Ä"; var auml = "ä"; var brvbar = "¦"; var Ccedil = "Ç"; var ccedil = "ç"; var cedil = "¸"; var cent = "¢"; var copy = "©"; var COPY = "©"; var curren = "¤"; var deg = "°"; var divide = "÷"; var Eacute = "É"; var eacute = "é"; var Ecirc = "Ê"; var ecirc = "ê"; var Egrave = "È"; var egrave = "è"; var ETH = "Ð"; var eth = "ð"; var Euml = "Ë"; var euml = "ë"; var frac12 = "½"; var frac14 = "¼"; var frac34 = "¾"; var gt$1 = ">"; var GT = ">"; var Iacute = "Í"; var iacute = "í"; var Icirc = "Î"; var icirc = "î"; var iexcl = "¡"; var Igrave = "Ì"; var igrave = "ì"; var iquest = "¿"; var Iuml = "Ï"; var iuml = "ï"; var laquo = "«"; var lt$1 = "<"; var LT = "<"; var macr = "¯"; var micro = "µ"; var middot = "·"; var nbsp = " "; var not = "¬"; var Ntilde = "Ñ"; var ntilde = "ñ"; var Oacute = "Ó"; var oacute = "ó"; var Ocirc = "Ô"; var ocirc = "ô"; var Ograve = "Ò"; var ograve = "ò"; var ordf = "ª"; var ordm = "º"; var Oslash = "Ø"; var oslash = "ø"; var Otilde = "Õ"; var otilde = "õ"; var Ouml = "Ö"; var ouml = "ö"; var para = "¶"; var plusmn = "±"; var pound = "£"; var quot$1 = "\""; var QUOT = "\""; var raquo = "»"; var reg = "®"; var REG = "®"; var sect = "§"; var shy = "­"; var sup1 = "¹"; var sup2 = "²"; var sup3 = "³"; var szlig = "ß"; var THORN = "Þ"; var thorn = "þ"; var times = "×"; var Uacute = "Ú"; var uacute = "ú"; var Ucirc = "Û"; var ucirc = "û"; var Ugrave = "Ù"; var ugrave = "ù"; var uml = "¨"; var Uuml = "Ü"; var uuml = "ü"; var Yacute = "Ý"; var yacute = "ý"; var yen = "¥"; var yuml = "ÿ"; var require$$1 = { Aacute: Aacute, aacute: aacute, Acirc: Acirc, acirc: acirc, acute: acute, AElig: AElig, aelig: aelig, Agrave: Agrave, agrave: agrave, amp: amp$1, AMP: AMP, Aring: Aring, aring: aring, Atilde: Atilde, atilde: atilde, Auml: Auml, auml: auml, brvbar: brvbar, Ccedil: Ccedil, ccedil: ccedil, cedil: cedil, cent: cent, copy: copy, COPY: COPY, curren: curren, deg: deg, divide: divide, Eacute: Eacute, eacute: eacute, Ecirc: Ecirc, ecirc: ecirc, Egrave: Egrave, egrave: egrave, ETH: ETH, eth: eth, Euml: Euml, euml: euml, frac12: frac12, frac14: frac14, frac34: frac34, gt: gt$1, GT: GT, Iacute: Iacute, iacute: iacute, Icirc: Icirc, icirc: icirc, iexcl: iexcl, Igrave: Igrave, igrave: igrave, iquest: iquest, Iuml: Iuml, iuml: iuml, laquo: laquo, lt: lt$1, LT: LT, macr: macr, micro: micro, middot: middot, nbsp: nbsp, not: not, Ntilde: Ntilde, ntilde: ntilde, Oacute: Oacute, oacute: oacute, Ocirc: Ocirc, ocirc: ocirc, Ograve: Ograve, ograve: ograve, ordf: ordf, ordm: ordm, Oslash: Oslash, oslash: oslash, Otilde: Otilde, otilde: otilde, Ouml: Ouml, ouml: ouml, para: para, plusmn: plusmn, pound: pound, quot: quot$1, QUOT: QUOT, raquo: raquo, reg: reg, REG: REG, sect: sect, shy: shy, sup1: sup1, sup2: sup2, sup3: sup3, szlig: szlig, THORN: THORN, thorn: thorn, times: times, Uacute: Uacute, uacute: uacute, Ucirc: Ucirc, ucirc: ucirc, Ugrave: Ugrave, ugrave: ugrave, uml: uml, Uuml: Uuml, uuml: uuml, Yacute: Yacute, yacute: yacute, yen: yen, yuml: yuml }; var amp = "&"; var apos = "'"; var gt = ">"; var lt = "<"; var quot = "\""; var require$$0$1 = { amp: amp, apos: apos, gt: gt, lt: lt, quot: quot }; var decode_codepoint = {}; var require$$0 = { "0": 65533, "128": 8364, "130": 8218, "131": 402, "132": 8222, "133": 8230, "134": 8224, "135": 8225, "136": 710, "137": 8240, "138": 352, "139": 8249, "140": 338, "142": 381, "145": 8216, "146": 8217, "147": 8220, "148": 8221, "149": 8226, "150": 8211, "151": 8212, "152": 732, "153": 8482, "154": 353, "155": 8250, "156": 339, "158": 382, "159": 376 }; var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(decode_codepoint, "__esModule", { value: true }); var decode_json_1 = __importDefault$2(require$$0); // Adapted from https://github.com/mathiasbynens/he/blob/master/src/he.js#L94-L119 var fromCodePoint$2 = // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition String.fromCodePoint || function (codePoint) { var output = ""; if (codePoint > 0xffff) { codePoint -= 0x10000; output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800); codePoint = 0xdc00 | (codePoint & 0x3ff); } output += String.fromCharCode(codePoint); return output; }; function decodeCodePoint(codePoint) { if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) { return "\uFFFD"; } if (codePoint in decode_json_1.default) { codePoint = decode_json_1.default[codePoint]; } return fromCodePoint$2(codePoint); } decode_codepoint.default = decodeCodePoint; var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(decode, "__esModule", { value: true }); decode.decodeHTML = decode.decodeHTMLStrict = decode.decodeXML = void 0; var entities_json_1$1 = __importDefault$1(require$$1$1); var legacy_json_1 = __importDefault$1(require$$1); var xml_json_1$1 = __importDefault$1(require$$0$1); var decode_codepoint_1 = __importDefault$1(decode_codepoint); var strictEntityRe = /&(?:[a-zA-Z0-9]+|#[xX][\da-fA-F]+|#\d+);/g; decode.decodeXML = getStrictDecoder(xml_json_1$1.default); decode.decodeHTMLStrict = getStrictDecoder(entities_json_1$1.default); function getStrictDecoder(map) { var replace = getReplacer(map); return function (str) { return String(str).replace(strictEntityRe, replace); }; } var sorter = function (a, b) { return (a < b ? 1 : -1); }; decode.decodeHTML = (function () { var legacy = Object.keys(legacy_json_1.default).sort(sorter); var keys = Object.keys(entities_json_1$1.default).sort(sorter); for (var i = 0, j = 0; i < keys.length; i++) { if (legacy[j] === keys[i]) { keys[i] += ";?"; j++; } else { keys[i] += ";"; } } var re = new RegExp("&(?:" + keys.join("|") + "|#[xX][\\da-fA-F]+;?|#\\d+;?)", "g"); var replace = getReplacer(entities_json_1$1.default); function replacer(str) { if (str.substr(-1) !== ";") str += ";"; return replace(str); } // TODO consider creating a merged map return function (str) { return String(str).replace(re, replacer); }; })(); function getReplacer(map) { return function replace(str) { if (str.charAt(1) === "#") { var secondChar = str.charAt(2); if (secondChar === "X" || secondChar === "x") { return decode_codepoint_1.default(parseInt(str.substr(3), 16)); } return decode_codepoint_1.default(parseInt(str.substr(2), 10)); } // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing return map[str.slice(1, -1)] || str; }; } var encode = {}; var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(encode, "__esModule", { value: true }); encode.escapeUTF8 = encode.escape = encode.encodeNonAsciiHTML = encode.encodeHTML = encode.encodeXML = void 0; var xml_json_1 = __importDefault(require$$0$1); var inverseXML = getInverseObj(xml_json_1.default); var xmlReplacer = getInverseReplacer(inverseXML); /** * Encodes all non-ASCII characters, as well as characters not valid in XML * documents using XML entities. * * If a character has no equivalent entity, a * numeric hexadecimal reference (eg. `ü`) will be used. */ encode.encodeXML = getASCIIEncoder(inverseXML); var entities_json_1 = __importDefault(require$$1$1); var inverseHTML = getInverseObj(entities_json_1.default); var htmlReplacer = getInverseReplacer(inverseHTML); /** * Encodes all entities and non-ASCII characters in the input. * * This includes characters that are valid ASCII characters in HTML documents. * For example `#` will be encoded as `#`. To get a more compact output, * consider using the `encodeNonAsciiHTML` function. * * If a character has no equivalent entity, a * numeric hexadecimal reference (eg. `ü`) will be used. */ encode.encodeHTML = getInverse(inverseHTML, htmlReplacer); /** * Encodes all non-ASCII characters, as well as characters not valid in HTML * documents using HTML entities. * * If a character has no equivalent entity, a * numeric hexadecimal reference (eg. `ü`) will be used. */ encode.encodeNonAsciiHTML = getASCIIEncoder(inverseHTML); function getInverseObj(obj) { return Object.keys(obj) .sort() .reduce(function (inverse, name) { inverse[obj[name]] = "&" + name + ";"; return inverse; }, {}); } function getInverseReplacer(inverse) { var single = []; var multiple = []; for (var _i = 0, _a = Object.keys(inverse); _i < _a.length; _i++) { var k = _a[_i]; if (k.length === 1) { // Add value to single array single.push("\\" + k); } else { // Add value to multiple array multiple.push(k); } } // Add ranges to single characters. single.sort(); for (var start = 0; start < single.length - 1; start++) { // Find the end of a run of characters var end = start; while (end < single.length - 1 && single[end].charCodeAt(1) + 1 === single[end + 1].charCodeAt(1)) { end += 1; } var count = 1 + end - start; // We want to replace at least three characters if (count < 3) continue; single.splice(start, count, single[start] + "-" + single[end]); } multiple.unshift("[" + single.join("") + "]"); return new RegExp(multiple.join("|"), "g"); } // /[^\0-\x7F]/gu var reNonASCII = /(?:[\x80-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g; var getCodePoint = // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition String.prototype.codePointAt != null ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion function (str) { return str.codePointAt(0); } : // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae function (c) { return (c.charCodeAt(0) - 0xd800) * 0x400 + c.charCodeAt(1) - 0xdc00 + 0x10000; }; function singleCharReplacer(c) { return "&#x" + (c.length > 1 ? getCodePoint(c) : c.charCodeAt(0)) .toString(16) .toUpperCase() + ";"; } function getInverse(inverse, re) { return function (data) { return data .replace(re, function (name) { return inverse[name]; }) .replace(reNonASCII, singleCharReplacer); }; } var reEscapeChars = new RegExp(xmlReplacer.source + "|" + reNonASCII.source, "g"); /** * Encodes all non-ASCII characters, as well as characters not valid in XML * documents using numeric hexadecimal reference (eg. `ü`). * * Have a look at `escapeUTF8` if you want a more concise output at the expense * of reduced transportability. * * @param data String to escape. */ function escape(data) { return data.replace(reEscapeChars, singleCharReplacer); } encode.escape = escape; /** * Encodes all characters not valid in XML documents using numeric hexadecimal * reference (eg. `ü`). * * Note that the output will be character-set dependent. * * @param data String to escape. */ function escapeUTF8(data) { return data.replace(xmlReplacer, singleCharReplacer); } encode.escapeUTF8 = escapeUTF8; function getASCIIEncoder(obj) { return function (data) { return data.replace(reEscapeChars, function (c) { return obj[c] || singleCharReplacer(c); }); }; } (function (exports) { Object.defineProperty(exports, "__esModule", { value: true }); exports.decodeXMLStrict = exports.decodeHTML5Strict = exports.decodeHTML4Strict = exports.decodeHTML5 = exports.decodeHTML4 = exports.decodeHTMLStrict = exports.decodeHTML = exports.decodeXML = exports.encodeHTML5 = exports.encodeHTML4 = exports.escapeUTF8 = exports.escape = exports.encodeNonAsciiHTML = exports.encodeHTML = exports.encodeXML = exports.encode = exports.decodeStrict = exports.decode = void 0; var decode_1 = decode; var encode_1 = encode; /** * Decodes a string with entities. * * @param data String to decode. * @param level Optional level to decode at. 0 = XML, 1 = HTML. Default is 0. * @deprecated Use `decodeXML` or `decodeHTML` directly. */ function decode$1(data, level) { return (!level || level <= 0 ? decode_1.decodeXML : decode_1.decodeHTML)(data); } exports.decode = decode$1; /** * Decodes a string with entities. Does not allow missing trailing semicolons for entities. * * @param data String to decode. * @param level Optional level to decode at. 0 = XML, 1 = HTML. Default is 0. * @deprecated Use `decodeHTMLStrict` or `decodeXML` directly. */ function decodeStrict(data, level) { return (!level || level <= 0 ? decode_1.decodeXML : decode_1.decodeHTMLStrict)(data); } exports.decodeStrict = decodeStrict; /** * Encodes a string with entities. * * @param data String to encode. * @param level Optional level to encode at. 0 = XML, 1 = HTML. Default is 0. * @deprecated Use `encodeHTML`, `encodeXML` or `encodeNonAsciiHTML` directly. */ function encode$1(data, level) { return (!level || level <= 0 ? encode_1.encodeXML : encode_1.encodeHTML)(data); } exports.encode = encode$1; var encode_2 = encode; Object.defineProperty(exports, "encodeXML", { enumerable: true, get: function () { return encode_2.encodeXML; } }); Object.defineProperty(exports, "encodeHTML", { enumerable: true, get: function () { return encode_2.encodeHTML; } }); Object.defineProperty(exports, "encodeNonAsciiHTML", { enumerable: true, get: function () { return encode_2.encodeNonAsciiHTML; } }); Object.defineProperty(exports, "escape", { enumerable: true, get: function () { return encode_2.escape; } }); Object.defineProperty(exports, "escapeUTF8", { enumerable: true, get: function () { return encode_2.escapeUTF8; } }); // Legacy aliases (deprecated) Object.defineProperty(exports, "encodeHTML4", { enumerable: true, get: function () { return encode_2.encodeHTML; } }); Object.defineProperty(exports, "encodeHTML5", { enumerable: true, get: function () { return encode_2.encodeHTML; } }); var decode_2 = decode; Object.defineProperty(exports, "decodeXML", { enumerable: true, get: function () { return decode_2.decodeXML; } }); Object.defineProperty(exports, "decodeHTML", { enumerable: true, get: function () { return decode_2.decodeHTML; } }); Object.defineProperty(exports, "decodeHTMLStrict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } }); // Legacy aliases (deprecated) Object.defineProperty(exports, "decodeHTML4", { enumerable: true, get: function () { return decode_2.decodeHTML; } }); Object.defineProperty(exports, "decodeHTML5", { enumerable: true, get: function () { return decode_2.decodeHTML; } }); Object.defineProperty(exports, "decodeHTML4Strict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } }); Object.defineProperty(exports, "decodeHTML5Strict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } }); Object.defineProperty(exports, "decodeXMLStrict", { enumerable: true, get: function () { return decode_2.decodeXML; } }); }(lib)); var ENTITY = '&(?:#x[a-f0-9]{1,6}|#[0-9]{1,7}|[a-z][a-z0-9]{1,31});'; var C_BACKSLASH$1 = 92; var reBackslashOrAmp = /[\\&]/; var ESCAPABLE = '[!"#$%&\'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]'; var reEntityOrEscapedChar = new RegExp("\\\\" + ESCAPABLE + "|" + ENTITY, 'gi'); var XMLSPECIAL = '[&<>"]'; var reXmlSpecial = new RegExp(XMLSPECIAL, 'g'); var unescapeChar = function (s) { if (s.charCodeAt(0) === C_BACKSLASH$1) { return s.charAt(1); } return lib.decodeHTML(s); }; // Replace entities and backslash escapes with literal characters. function unescapeString(s) { if (reBackslashOrAmp.test(s)) { return s.replace(reEntityOrEscapedChar, unescapeChar); } return s; } function normalizeURI(uri) { try { return encode_1(uri); } catch (err) { return uri; } } function replaceUnsafeChar(s) { switch (s) { case '&': return '&'; case '<': return '<'; case '>': return '>'; case '"': return '"'; default: return s; } } function escapeXml(s) { if (reXmlSpecial.test(s)) { return s.replace(reXmlSpecial, replaceUnsafeChar); } return s; } function repeat(str, count) { var arr = []; for (var i = 0; i < count; i++) { arr.push(str); } return arr.join(''); } function isEmpty(str) { if (!str) { return true; } return !/[^ \t]+/.test(str); } var NodeWalker = /** @class */ (function () { function NodeWalker(root) { this.current = root; this.root = root; this.entering = true; } NodeWalker.prototype.next = function () { var cur = this.current; var entering = this.entering; if (cur === null) { return null; } var container = isContainer$1(cur); if (entering && container) { if (cur.firstChild) { this.current = cur.firstChild; this.entering = true; } else { // stay on node but exit this.entering = false; } } else if (cur === this.root) { this.current = null; } else if (cur.next === null) { this.current = cur.parent; this.entering = false; } else { this.current = cur.next; this.entering = true; } return { entering: entering, node: cur }; }; NodeWalker.prototype.resumeAt = function (node, entering) { this.current = node; this.entering = entering === true; }; return NodeWalker; }()); function isContainer$1(node) { switch (node.type) { case 'document': case 'blockQuote': case 'list': case 'item': case 'paragraph': case 'heading': case 'emph': case 'strong': case 'strike': case 'link': case 'image': case 'table': case 'tableHead': case 'tableBody': case 'tableRow': case 'tableCell': case 'tableDelimRow': case 'customInline': return true; default: return false; } } var lastNodeId = 1; var nodeMap = {}; function getNodeById(id) { return nodeMap[id]; } function removeNodeById(id) { delete nodeMap[id]; } function removeAllNode() { nodeMap = {}; } var Node$1 = /** @class */ (function () { function Node(nodeType, sourcepos) { this.parent = null; this.prev = null; this.next = null; // only for container node this.firstChild = null; this.lastChild = null; // only for leaf node this.literal = null; if (nodeType === 'document') { this.id = -1; } else { this.id = lastNodeId++; } this.type = nodeType; this.sourcepos = sourcepos; nodeMap[this.id] = this; } Node.prototype.isContainer = function () { return isContainer$1(this); }; Node.prototype.unlink = function () { if (this.prev) { this.prev.next = this.next; } else if (this.parent) { this.parent.firstChild = this.next; } if (this.next) { this.next.prev = this.prev; } else if (this.parent) { this.parent.lastChild = this.prev; } this.parent = null; this.next = null; this.prev = null; }; Node.prototype.replaceWith = function (node) { this.insertBefore(node); this.unlink(); }; Node.prototype.insertAfter = function (sibling) { sibling.unlink(); sibling.next = this.next; if (sibling.next) { sibling.next.prev = sibling; } sibling.prev = this; this.next = sibling; if (this.parent) { sibling.parent = this.parent; if (!sibling.next) { sibling.parent.lastChild = sibling; } } }; Node.prototype.insertBefore = function (sibling) { sibling.unlink(); sibling.prev = this.prev; if (sibling.prev) { sibling.prev.next = sibling; } sibling.next = this; this.prev = sibling; sibling.parent = this.parent; if (!sibling.prev) { sibling.parent.firstChild = sibling; } }; Node.prototype.appendChild = function (child) { child.unlink(); child.parent = this; if (this.lastChild) { this.lastChild.next = child; child.prev = this.lastChild; this.lastChild = child; } else { this.firstChild = child; this.lastChild = child; } }; Node.prototype.prependChild = function (child) { child.unlink(); child.parent = this; if (this.firstChild) { this.firstChild.prev = child; child.next = this.firstChild; this.firstChild = child; } else { this.firstChild = child; this.lastChild = child; } }; Node.prototype.walker = function () { return new NodeWalker(this); }; return Node; }()); var BlockNode = /** @class */ (function (_super) { __extends(BlockNode, _super); function BlockNode(nodeType, sourcepos) { var _this = _super.call(this, nodeType, sourcepos) || this; // temporal data (for parsing) _this.open = true; _this.lineOffsets = null; _this.stringContent = null; _this.lastLineBlank = false; _this.lastLineChecked = false; _this.type = nodeType; return _this; } return BlockNode; }(Node$1)); var ListNode = /** @class */ (function (_super) { __extends(ListNode, _super); function ListNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.listData = null; return _this; } return ListNode; }(BlockNode)); var HeadingNode = /** @class */ (function (_super) { __extends(HeadingNode, _super); function HeadingNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.level = 0; _this.headingType = 'atx'; return _this; } return HeadingNode; }(BlockNode)); var CodeBlockNode = /** @class */ (function (_super) { __extends(CodeBlockNode, _super); function CodeBlockNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.isFenced = false; _this.fenceChar = null; _this.fenceLength = 0; _this.fenceOffset = -1; _this.info = null; _this.infoPadding = 0; return _this; } return CodeBlockNode; }(BlockNode)); var TableNode = /** @class */ (function (_super) { __extends(TableNode, _super); function TableNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.columns = []; return _this; } return TableNode; }(BlockNode)); var TableCellNode = /** @class */ (function (_super) { __extends(TableCellNode, _super); function TableCellNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.startIdx = 0; _this.endIdx = 0; _this.paddingLeft = 0; _this.paddingRight = 0; _this.ignored = false; return _this; } return TableCellNode; }(BlockNode)); var RefDefNode = /** @class */ (function (_super) { __extends(RefDefNode, _super); function RefDefNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.title = ''; _this.dest = ''; _this.label = ''; return _this; } return RefDefNode; }(BlockNode)); var CustomBlockNode = /** @class */ (function (_super) { __extends(CustomBlockNode, _super); function CustomBlockNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.syntaxLength = 0; _this.offset = -1; _this.info = ''; return _this; } return CustomBlockNode; }(BlockNode)); var HtmlBlockNode = /** @class */ (function (_super) { __extends(HtmlBlockNode, _super); function HtmlBlockNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.htmlBlockType = -1; return _this; } return HtmlBlockNode; }(BlockNode)); var LinkNode = /** @class */ (function (_super) { __extends(LinkNode, _super); function LinkNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.destination = null; _this.title = null; _this.extendedAutolink = false; return _this; } return LinkNode; }(Node$1)); var CodeNode = /** @class */ (function (_super) { __extends(CodeNode, _super); function CodeNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.tickCount = 0; return _this; } return CodeNode; }(Node$1)); var CustomInlineNode = /** @class */ (function (_super) { __extends(CustomInlineNode, _super); function CustomInlineNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.info = ''; return _this; } return CustomInlineNode; }(Node$1)); function createNode$1(type, sourcepos) { switch (type) { case 'heading': return new HeadingNode(type, sourcepos); case 'list': case 'item': return new ListNode(type, sourcepos); case 'link': case 'image': return new LinkNode(type, sourcepos); case 'codeBlock': return new CodeBlockNode(type, sourcepos); case 'htmlBlock': return new HtmlBlockNode(type, sourcepos); case 'table': return new TableNode(type, sourcepos); case 'tableCell': return new TableCellNode(type, sourcepos); case 'document': case 'paragraph': case 'blockQuote': case 'thematicBreak': case 'tableRow': case 'tableBody': case 'tableHead': case 'frontMatter': return new BlockNode(type, sourcepos); case 'code': return new CodeNode(type, sourcepos); case 'refDef': return new RefDefNode(type, sourcepos); case 'customBlock': return new CustomBlockNode(type, sourcepos); case 'customInline': return new CustomInlineNode(type, sourcepos); default: return new Node$1(type, sourcepos); } } function isCodeBlock(node) { return node.type === 'codeBlock'; } function isHtmlBlock(node) { return node.type === 'htmlBlock'; } function isHeading(node) { return node.type === 'heading'; } function isList(node) { return node.type === 'list'; } function isTable(node) { return node.type === 'table'; } function isRefDef(node) { return node.type === 'refDef'; } function isCustomBlock(node) { return node.type === 'customBlock'; } function isCustomInline(node) { return node.type === 'customInline'; } function text$1(s, sourcepos) { var node = createNode$1('text', sourcepos); node.literal = s; return node; } var TAGNAME = '[A-Za-z][A-Za-z0-9-]*'; var ATTRIBUTENAME = '[a-zA-Z_:][a-zA-Z0-9:._-]*'; var UNQUOTEDVALUE = '[^"\'=<>`\\x00-\\x20]+'; var SINGLEQUOTEDVALUE = "'[^']*'"; var DOUBLEQUOTEDVALUE = '"[^"]*"'; var ATTRIBUTEVALUE = "(?:" + UNQUOTEDVALUE + "|" + SINGLEQUOTEDVALUE + "|" + DOUBLEQUOTEDVALUE + ")"; var ATTRIBUTEVALUESPEC = "" + '(?:\\s*=\\s*' + ATTRIBUTEVALUE + ")"; var ATTRIBUTE = "" + '(?:\\s+' + ATTRIBUTENAME + ATTRIBUTEVALUESPEC + "?)"; var OPENTAG = "<" + TAGNAME + ATTRIBUTE + "*\\s*/?>"; var CLOSETAG = "]"; var HTMLCOMMENT = '|'; var PROCESSINGINSTRUCTION = '[<][?].*?[?][>]'; var DECLARATION = ']*>'; var CDATA = ''; var HTMLTAG = "(?:" + OPENTAG + "|" + CLOSETAG + "|" + HTMLCOMMENT + "|" + PROCESSINGINSTRUCTION + "|" + DECLARATION + "|" + CDATA + ")"; var reHtmlTag = new RegExp("^" + HTMLTAG, 'i'); // derived from https://github.com/mathiasbynens/String.fromCodePoint /*! http://mths.be/fromcodepoint v0.2.1 by @mathias */ var fromCodePoint; if (String.fromCodePoint) { fromCodePoint = function (_) { try { return String.fromCodePoint(_); } catch (e) { if (e instanceof RangeError) { return String.fromCharCode(0xfffd); } throw e; } }; } else { var stringFromCharCode_1 = String.fromCharCode; var floor_1 = Math.floor; fromCodePoint = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var MAX_SIZE = 0x4000; var codeUnits = []; var highSurrogate; var lowSurrogate; var index = -1; var length = args.length; if (!length) { return ''; } var result = ''; while (++index < length) { var codePoint = Number(args[index]); if (!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity` codePoint < 0 || // not a valid Unicode code point codePoint > 0x10ffff || // not a valid Unicode code point floor_1(codePoint) !== codePoint // not an integer ) { return String.fromCharCode(0xfffd); } if (codePoint <= 0xffff) { // BMP code point codeUnits.push(codePoint); } else { // Astral code point; split in surrogate halves // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae codePoint -= 0x10000; highSurrogate = (codePoint >> 10) + 0xd800; lowSurrogate = (codePoint % 0x400) + 0xdc00; codeUnits.push(highSurrogate, lowSurrogate); } if (index + 1 === length || codeUnits.length > MAX_SIZE) { result += stringFromCharCode_1.apply(void 0, codeUnits); codeUnits.length = 0; } } return result; }; } var fromCodePoint$1 = fromCodePoint; var DOMAIN = '(?:[w-]+.)*[A-Za-z0-9-]+.[A-Za-z0-9-]+'; var PATH = '[^<\\s]*[^ lastIdx) { newNodes.push(text$1(literal.substring(lastIdx, range[0]), sourcepos(lastIdx, range[0] - 1))); } var linkNode = createNode$1('link', sourcepos.apply(void 0, range)); linkNode.appendChild(text$1(linkText, sourcepos.apply(void 0, range))); linkNode.destination = url; linkNode.extendedAutolink = true; newNodes.push(linkNode); lastIdx = range[1] + 1; } if (lastIdx < literal.length) { newNodes.push(text$1(literal.substring(lastIdx), sourcepos(lastIdx, literal.length - 1))); } for (var _c = 0, newNodes_1 = newNodes; _c < newNodes_1.length; _c++) { var newNode = newNodes_1[_c]; node.insertBefore(newNode); } node.unlink(); } }; while ((event = walker.next())) { _loop_1(); } } function last(arr) { return arr[arr.length - 1]; } // normalize a reference in reference link (remove []s, trim, // collapse internal space, unicode case fold. // See commonmark/commonmark.js#168. function normalizeReference(str) { return str .slice(1, str.length - 1) .trim() .replace(/[ \t\r\n]+/, ' ') .toLowerCase() .toUpperCase(); } function iterateObject(obj, iteratee) { Object.keys(obj).forEach(function (key) { iteratee(key, obj[key]); }); } function omit(obj) { var propNames = []; for (var _i = 1; _i < arguments.length; _i++) { propNames[_i - 1] = arguments[_i]; } var resultMap = __assign({}, obj); propNames.forEach(function (key) { delete resultMap[key]; }); return resultMap; } function isEmptyObj(obj) { return !Object.keys(obj).length; } function clearObj(obj) { Object.keys(obj).forEach(function (key) { delete obj[key]; }); } var C_NEWLINE = 10; var C_ASTERISK = 42; var C_UNDERSCORE = 95; var C_BACKTICK = 96; var C_OPEN_BRACKET$1 = 91; var C_CLOSE_BRACKET = 93; var C_TILDE = 126; var C_LESSTHAN$1 = 60; var C_BANG = 33; var C_BACKSLASH = 92; var C_AMPERSAND = 38; var C_OPEN_PAREN = 40; var C_CLOSE_PAREN = 41; var C_COLON = 58; var C_SINGLEQUOTE = 39; var C_DOUBLEQUOTE = 34; var C_DOLLAR = 36; // Some regexps used in inline parser: var ESCAPED_CHAR = "\\\\" + ESCAPABLE; var rePunctuation = new RegExp(/[!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/); var reLinkTitle = new RegExp("^(?:\"(" + ESCAPED_CHAR + "|[^\"\\x00])*\"" + "|" + ("'(" + ESCAPED_CHAR + "|[^'\\x00])*'") + "|" + ("\\((" + ESCAPED_CHAR + "|[^()\\x00])*\\))")); var reLinkDestinationBraces = /^(?:<(?:[^<>\n\\\x00]|\\.)*>)/; var reEscapable = new RegExp("^" + ESCAPABLE); var reEntityHere = new RegExp("^" + ENTITY, 'i'); var reTicks = /`+/; var reTicksHere = /^`+/; var reEllipses = /\.\.\./g; var reDash = /--+/g; var reEmailAutolink = /^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/; var reAutolink = /^<[A-Za-z][A-Za-z0-9.+-]{1,31}:[^<>\x00-\x20]*>/i; var reSpnl = /^ *(?:\n *)?/; var reWhitespaceChar = /^[ \t\n\x0b\x0c\x0d]/; var reUnicodeWhitespaceChar = /^\s/; var reFinalSpace = / *$/; var reInitialSpace = /^ */; var reSpaceAtEndOfLine = /^ *(?:\n|$)/; var reLinkLabel = /^\[(?:[^\\\[\]]|\\.){0,1000}\]/; // Matches a string of non-special characters. var reMain = /^[^\n`\[\]\\!<&*_'"~$]+/m; var InlineParser = /** @class */ (function () { function InlineParser(options) { // An InlineParser keeps track of a subject (a string to be parsed) // and a position in that subject. this.subject = ''; this.delimiters = null; // used by handleDelim method this.brackets = null; this.pos = 0; this.lineStartNum = 0; this.lineIdx = 0; this.lineOffsets = [0]; this.linePosOffset = 0; this.refMap = {}; this.refLinkCandidateMap = {}; this.refDefCandidateMap = {}; this.options = options; } InlineParser.prototype.sourcepos = function (start, end) { var linePosOffset = this.linePosOffset + this.lineOffsets[this.lineIdx]; var lineNum = this.lineStartNum + this.lineIdx; var startpos = [lineNum, start + linePosOffset]; if (typeof end === 'number') { return [startpos, [lineNum, end + linePosOffset]]; } return startpos; }; InlineParser.prototype.nextLine = function () { this.lineIdx += 1; this.linePosOffset = -this.pos; }; // If re matches at current position in the subject, advance // position in subject and return the match; otherwise return null. InlineParser.prototype.match = function (re) { var m = re.exec(this.subject.slice(this.pos)); if (m === null) { return null; } this.pos += m.index + m[0].length; return m[0]; }; // Returns the code for the character at the current subject position, or -1 // there are no more characters. InlineParser.prototype.peek = function () { if (this.pos < this.subject.length) { return this.subject.charCodeAt(this.pos); } return -1; }; // Parse zero or more space characters, including at most one newline InlineParser.prototype.spnl = function () { this.match(reSpnl); return true; }; // All of the parsers below try to match something at the current position // in the subject. If they succeed in matching anything, they // return the inline matched, advancing the subject. // Attempt to parse backticks, adding either a backtick code span or a // literal sequence of backticks. InlineParser.prototype.parseBackticks = function (block) { var startpos = this.pos + 1; var ticks = this.match(reTicksHere); if (ticks === null) { return false; } var afterOpenTicks = this.pos; var matched; while ((matched = this.match(reTicks)) !== null) { if (matched === ticks) { var contents = this.subject.slice(afterOpenTicks, this.pos - ticks.length); var sourcepos = this.sourcepos(startpos, this.pos); var lines = contents.split('\n'); if (lines.length > 1) { var lastLine = last(lines); this.lineIdx += lines.length - 1; this.linePosOffset = -(this.pos - lastLine.length - ticks.length); sourcepos[1] = this.sourcepos(this.pos); contents = lines.join(' '); } var node = createNode$1('code', sourcepos); if (contents.length > 0 && contents.match(/[^ ]/) !== null && contents[0] == ' ' && contents[contents.length - 1] == ' ') { node.literal = contents.slice(1, contents.length - 1); } else { node.literal = contents; } node.tickCount = ticks.length; block.appendChild(node); return true; } } // If we got here, we didn't match a closing backtick sequence. this.pos = afterOpenTicks; block.appendChild(text$1(ticks, this.sourcepos(startpos, this.pos - 1))); return true; }; // Parse a backslash-escaped special character, adding either the escaped // character, a hard line break (if the backslash is followed by a newline), // or a literal backslash to the block's children. Assumes current character // is a backslash. InlineParser.prototype.parseBackslash = function (block) { var subj = this.subject; var node; this.pos += 1; var startpos = this.pos; if (this.peek() === C_NEWLINE) { this.pos += 1; node = createNode$1('linebreak', this.sourcepos(this.pos - 1, this.pos)); block.appendChild(node); this.nextLine(); } else if (reEscapable.test(subj.charAt(this.pos))) { block.appendChild(text$1(subj.charAt(this.pos), this.sourcepos(startpos, this.pos))); this.pos += 1; } else { block.appendChild(text$1('\\', this.sourcepos(startpos, startpos))); } return true; }; // Attempt to parse an autolink (URL or email in pointy brackets). InlineParser.prototype.parseAutolink = function (block) { var m; var dest; var node; var startpos = this.pos + 1; if ((m = this.match(reEmailAutolink))) { dest = m.slice(1, m.length - 1); node = createNode$1('link', this.sourcepos(startpos, this.pos)); node.destination = normalizeURI("mailto:" + dest); node.title = ''; node.appendChild(text$1(dest, this.sourcepos(startpos + 1, this.pos - 1))); block.appendChild(node); return true; } if ((m = this.match(reAutolink))) { dest = m.slice(1, m.length - 1); node = createNode$1('link', this.sourcepos(startpos, this.pos)); node.destination = normalizeURI(dest); node.title = ''; node.appendChild(text$1(dest, this.sourcepos(startpos + 1, this.pos - 1))); block.appendChild(node); return true; } return false; }; // Attempt to parse a raw HTML tag. InlineParser.prototype.parseHtmlTag = function (block) { var startpos = this.pos + 1; var m = this.match(reHtmlTag); if (m === null) { return false; } var node = createNode$1('htmlInline', this.sourcepos(startpos, this.pos)); node.literal = m; block.appendChild(node); return true; }; // Scan a sequence of characters with code cc, and return information about // the number of delimiters and whether they are positioned such that // they can open and/or close emphasis or strong emphasis. A utility // function for strong/emph parsing. InlineParser.prototype.scanDelims = function (cc) { var numdelims = 0; var startpos = this.pos; if (cc === C_SINGLEQUOTE || cc === C_DOUBLEQUOTE) { numdelims++; this.pos++; } else { while (this.peek() === cc) { numdelims++; this.pos++; } } if (numdelims === 0 || (numdelims < 2 && (cc === C_TILDE || cc === C_DOLLAR))) { this.pos = startpos; return null; } var charBefore = startpos === 0 ? '\n' : this.subject.charAt(startpos - 1); var ccAfter = this.peek(); var charAfter; if (ccAfter === -1) { charAfter = '\n'; } else { charAfter = fromCodePoint$1(ccAfter); } var afterIsWhitespace = reUnicodeWhitespaceChar.test(charAfter); var afterIsPunctuation = rePunctuation.test(charAfter); var beforeIsWhitespace = reUnicodeWhitespaceChar.test(charBefore); var beforeIsPunctuation = rePunctuation.test(charBefore); var leftFlanking = !afterIsWhitespace && (!afterIsPunctuation || beforeIsWhitespace || beforeIsPunctuation); var rightFlanking = !beforeIsWhitespace && (!beforeIsPunctuation || afterIsWhitespace || afterIsPunctuation); var canOpen; var canClose; if (cc === C_UNDERSCORE) { canOpen = leftFlanking && (!rightFlanking || beforeIsPunctuation); canClose = rightFlanking && (!leftFlanking || afterIsPunctuation); } else if (cc === C_SINGLEQUOTE || cc === C_DOUBLEQUOTE) { canOpen = leftFlanking && !rightFlanking; canClose = rightFlanking; } else if (cc === C_DOLLAR) { canOpen = !afterIsWhitespace; canClose = !beforeIsWhitespace; } else { canOpen = leftFlanking; canClose = rightFlanking; } this.pos = startpos; return { numdelims: numdelims, canOpen: canOpen, canClose: canClose }; }; // Handle a delimiter marker for emphasis or a quote. InlineParser.prototype.handleDelim = function (cc, block) { var res = this.scanDelims(cc); if (!res) { return false; } var numdelims = res.numdelims; var startpos = this.pos + 1; var contents; this.pos += numdelims; if (cc === C_SINGLEQUOTE) { contents = '\u2019'; } else if (cc === C_DOUBLEQUOTE) { contents = '\u201C'; } else { contents = this.subject.slice(startpos - 1, this.pos); } var node = text$1(contents, this.sourcepos(startpos, this.pos)); block.appendChild(node); // Add entry to stack for this opener if ((res.canOpen || res.canClose) && (this.options.smart || (cc !== C_SINGLEQUOTE && cc !== C_DOUBLEQUOTE))) { this.delimiters = { cc: cc, numdelims: numdelims, origdelims: numdelims, node: node, previous: this.delimiters, next: null, canOpen: res.canOpen, canClose: res.canClose, }; if (this.delimiters.previous) { this.delimiters.previous.next = this.delimiters; } } return true; }; InlineParser.prototype.removeDelimiter = function (delim) { if (delim.previous !== null) { delim.previous.next = delim.next; } if (delim.next === null) { // top of stack this.delimiters = delim.previous; } else { delim.next.previous = delim.previous; } }; InlineParser.prototype.removeDelimitersBetween = function (bottom, top) { if (bottom.next !== top) { bottom.next = top; top.previous = bottom; } }; /** * Process all delimiters - emphasis, strong emphasis, strikethrough(gfm) * If the smart punctuation options is true, * convert single/double quotes to corresponding unicode characters. **/ InlineParser.prototype.processEmphasis = function (stackBottom) { var _a; var opener; var closer; var oldCloser; var openerInl, closerInl; var openerFound; var oddMatch = false; var openersBottom = (_a = {}, _a[C_UNDERSCORE] = [stackBottom, stackBottom, stackBottom], _a[C_ASTERISK] = [stackBottom, stackBottom, stackBottom], _a[C_SINGLEQUOTE] = [stackBottom], _a[C_DOUBLEQUOTE] = [stackBottom], _a[C_TILDE] = [stackBottom], _a[C_DOLLAR] = [stackBottom], _a); // find first closer above stackBottom: closer = this.delimiters; while (closer !== null && closer.previous !== stackBottom) { closer = closer.previous; } // move forward, looking for closers, and handling each while (closer !== null) { var closercc = closer.cc; var closerEmph = closercc === C_UNDERSCORE || closercc === C_ASTERISK; if (!closer.canClose) { closer = closer.next; } else { // found emphasis closer. now look back for first matching opener: opener = closer.previous; openerFound = false; while (opener !== null && opener !== stackBottom && opener !== openersBottom[closercc][closerEmph ? closer.origdelims % 3 : 0]) { oddMatch = closerEmph && (closer.canOpen || opener.canClose) && closer.origdelims % 3 !== 0 && (opener.origdelims + closer.origdelims) % 3 === 0; if (opener.cc === closer.cc && opener.canOpen && !oddMatch) { openerFound = true; break; } opener = opener.previous; } oldCloser = closer; if (closerEmph || closercc === C_TILDE || closercc === C_DOLLAR) { if (!openerFound) { closer = closer.next; } else if (opener) { // (null opener check for type narrowing) // calculate actual number of delimiters used from closer var useDelims = closer.numdelims >= 2 && opener.numdelims >= 2 ? 2 : 1; var emptyDelims = closerEmph ? 0 : 1; openerInl = opener.node; closerInl = closer.node; // build contents for new emph element var nodeType = closerEmph ? useDelims === 1 ? 'emph' : 'strong' : 'strike'; if (closercc === C_DOLLAR) { nodeType = 'customInline'; } var newNode = createNode$1(nodeType); var openerEndPos = openerInl.sourcepos[1]; var closerStartPos = closerInl.sourcepos[0]; newNode.sourcepos = [ [openerEndPos[0], openerEndPos[1] - useDelims + 1], [closerStartPos[0], closerStartPos[1] + useDelims - 1], ]; openerInl.sourcepos[1][1] -= useDelims; closerInl.sourcepos[0][1] += useDelims; openerInl.literal = openerInl.literal.slice(useDelims); closerInl.literal = closerInl.literal.slice(useDelims); opener.numdelims -= useDelims; closer.numdelims -= useDelims; // remove used delimiters from stack elts and inlines var tmp = openerInl.next; var next = void 0; while (tmp && tmp !== closerInl) { next = tmp.next; tmp.unlink(); newNode.appendChild(tmp); tmp = next; } // build custom inline node if (closercc === C_DOLLAR) { var textNode = newNode.firstChild; var literal = textNode.literal || ''; var info = literal.split(/\s/)[0]; newNode.info = info; if (literal.length <= info.length) { textNode.unlink(); } else { textNode.sourcepos[0][1] += info.length; textNode.literal = literal.replace(info + " ", ''); } } openerInl.insertAfter(newNode); // remove elts between opener and closer in delimiters stack this.removeDelimitersBetween(opener, closer); // if opener has 0 delims, remove it and the inline // if opener has 1 delims and character is tilde, remove delimiter only if (opener.numdelims <= emptyDelims) { if (opener.numdelims === 0) { openerInl.unlink(); } this.removeDelimiter(opener); } // if closer has 0 delims, remove it and the inline // if closer has 1 delims and character is tilde, remove delimiter only if (closer.numdelims <= emptyDelims) { if (closer.numdelims === 0) { closerInl.unlink(); } var tempstack = closer.next; this.removeDelimiter(closer); closer = tempstack; } } } else if (closercc === C_SINGLEQUOTE) { closer.node.literal = '\u2019'; if (openerFound) { opener.node.literal = '\u2018'; } closer = closer.next; } else if (closercc === C_DOUBLEQUOTE) { closer.node.literal = '\u201D'; if (openerFound) { opener.node.literal = '\u201C'; } closer = closer.next; } if (!openerFound) { // Set lower bound for future searches for openers: openersBottom[closercc][closerEmph ? oldCloser.origdelims % 3 : 0] = oldCloser.previous; if (!oldCloser.canOpen) { // We can remove a closer that can't be an opener, // once we've seen there's no matching opener: this.removeDelimiter(oldCloser); } } } } // remove all delimiters while (this.delimiters !== null && this.delimiters !== stackBottom) { this.removeDelimiter(this.delimiters); } }; // Attempt to parse link title (sans quotes), returning the string // or null if no match. InlineParser.prototype.parseLinkTitle = function () { var title = this.match(reLinkTitle); if (title === null) { return null; } // chop off quotes from title and unescape: return unescapeString(title.substr(1, title.length - 2)); }; // Attempt to parse link destination, returning the string or null if no match. InlineParser.prototype.parseLinkDestination = function () { var res = this.match(reLinkDestinationBraces); if (res === null) { if (this.peek() === C_LESSTHAN$1) { return null; } // @TODO handrolled parser; res should be null or the string var savepos = this.pos; var openparens = 0; var c = void 0; while ((c = this.peek()) !== -1) { if (c === C_BACKSLASH && reEscapable.test(this.subject.charAt(this.pos + 1))) { this.pos += 1; if (this.peek() !== -1) { this.pos += 1; } } else if (c === C_OPEN_PAREN) { this.pos += 1; openparens += 1; } else if (c === C_CLOSE_PAREN) { if (openparens < 1) { break; } else { this.pos += 1; openparens -= 1; } } else if (reWhitespaceChar.exec(fromCodePoint$1(c)) !== null) { break; } else { this.pos += 1; } } if (this.pos === savepos && c !== C_CLOSE_PAREN) { return null; } if (openparens !== 0) { return null; } res = this.subject.substr(savepos, this.pos - savepos); return normalizeURI(unescapeString(res)); } // chop off surrounding <..>: return normalizeURI(unescapeString(res.substr(1, res.length - 2))); }; // Attempt to parse a link label, returning number of characters parsed. InlineParser.prototype.parseLinkLabel = function () { var m = this.match(reLinkLabel); if (m === null || m.length > 1001) { return 0; } return m.length; }; // Add open bracket to delimiter stack and add a text node to block's children. InlineParser.prototype.parseOpenBracket = function (block) { var startpos = this.pos; this.pos += 1; var node = text$1('[', this.sourcepos(this.pos, this.pos)); block.appendChild(node); // Add entry to stack for this opener this.addBracket(node, startpos, false); return true; }; // IF next character is [, and ! delimiter to delimiter stack and // add a text node to block's children. Otherwise just add a text node. InlineParser.prototype.parseBang = function (block) { var startpos = this.pos; this.pos += 1; if (this.peek() === C_OPEN_BRACKET$1) { this.pos += 1; var node = text$1('![', this.sourcepos(this.pos - 1, this.pos)); block.appendChild(node); // Add entry to stack for this opener this.addBracket(node, startpos + 1, true); } else { var node = text$1('!', this.sourcepos(this.pos, this.pos)); block.appendChild(node); } return true; }; // Try to match close bracket against an opening in the delimiter // stack. Add either a link or image, or a plain [ character, // to block's children. If there is a matching delimiter, // remove it from the delimiter stack. InlineParser.prototype.parseCloseBracket = function (block) { var dest = null; var title = null; var matched = false; this.pos += 1; var startpos = this.pos; // get last [ or ![ var opener = this.brackets; if (opener === null) { // no matched opener, just return a literal block.appendChild(text$1(']', this.sourcepos(startpos, startpos))); return true; } if (!opener.active) { // no matched opener, just return a literal block.appendChild(text$1(']', this.sourcepos(startpos, startpos))); // take opener off brackets stack this.removeBracket(); return true; } // If we got here, open is a potential opener var isImage = opener.image; // Check to see if we have a link/image var savepos = this.pos; // Inline link? if (this.peek() === C_OPEN_PAREN) { this.pos++; if (this.spnl() && (dest = this.parseLinkDestination()) !== null && this.spnl() && // make sure there's a space before the title: ((reWhitespaceChar.test(this.subject.charAt(this.pos - 1)) && (title = this.parseLinkTitle())) || true) && this.spnl() && this.peek() === C_CLOSE_PAREN) { this.pos += 1; matched = true; } else { this.pos = savepos; } } var refLabel = ''; if (!matched) { // Next, see if there's a link label var beforelabel = this.pos; var n = this.parseLinkLabel(); if (n > 2) { refLabel = this.subject.slice(beforelabel, beforelabel + n); } else if (!opener.bracketAfter) { // Empty or missing second label means to use the first label as the reference. // The reference must not contain a bracket. If we know there's a bracket, we don't even bother checking it. refLabel = this.subject.slice(opener.index, startpos); } if (n === 0) { // If shortcut reference link, rewind before spaces we skipped. this.pos = savepos; } if (refLabel) { refLabel = normalizeReference(refLabel); // lookup rawlabel in refMap var link = this.refMap[refLabel]; if (link) { dest = link.destination; title = link.title; matched = true; } } } if (matched) { var node = createNode$1(isImage ? 'image' : 'link'); node.destination = dest; node.title = title || ''; node.sourcepos = [opener.startpos, this.sourcepos(this.pos)]; var tmp = opener.node.next; var next = void 0; while (tmp) { next = tmp.next; tmp.unlink(); node.appendChild(tmp); tmp = next; } block.appendChild(node); this.processEmphasis(opener.previousDelimiter); this.removeBracket(); opener.node.unlink(); // We remove this bracket and processEmphasis will remove later delimiters. // Now, for a link, we also deactivate earlier link openers. // (no links in links) if (!isImage) { opener = this.brackets; while (opener !== null) { if (!opener.image) { opener.active = false; // deactivate this opener } opener = opener.previous; } } if (this.options.referenceDefinition) { this.refLinkCandidateMap[block.id] = { node: block, refLabel: refLabel }; } return true; } // no match this.removeBracket(); // remove this opener from stack this.pos = startpos; block.appendChild(text$1(']', this.sourcepos(startpos, startpos))); if (this.options.referenceDefinition) { this.refLinkCandidateMap[block.id] = { node: block, refLabel: refLabel }; } return true; }; InlineParser.prototype.addBracket = function (node, index, image) { if (this.brackets !== null) { this.brackets.bracketAfter = true; } this.brackets = { node: node, startpos: this.sourcepos(index + (image ? 0 : 1)), previous: this.brackets, previousDelimiter: this.delimiters, index: index, image: image, active: true, }; }; InlineParser.prototype.removeBracket = function () { if (this.brackets) { this.brackets = this.brackets.previous; } }; // Attempt to parse an entity. InlineParser.prototype.parseEntity = function (block) { var m; var startpos = this.pos + 1; if ((m = this.match(reEntityHere))) { block.appendChild(text$1(lib.decodeHTML(m), this.sourcepos(startpos, this.pos))); return true; } return false; }; // Parse a run of ordinary characters, or a single character with // a special meaning in markdown, as a plain string. InlineParser.prototype.parseString = function (block) { var m; var startpos = this.pos + 1; if ((m = this.match(reMain))) { if (this.options.smart) { var lit = m.replace(reEllipses, '\u2026').replace(reDash, function (chars) { var enCount = 0; var emCount = 0; if (chars.length % 3 === 0) { // If divisible by 3, use all em dashes emCount = chars.length / 3; } else if (chars.length % 2 === 0) { // If divisible by 2, use all en dashes enCount = chars.length / 2; } else if (chars.length % 3 === 2) { // If 2 extra dashes, use en dash for last 2; em dashes for rest enCount = 1; emCount = (chars.length - 2) / 3; } else { // Use en dashes for last 4 hyphens; em dashes for rest enCount = 2; emCount = (chars.length - 4) / 3; } return repeat('\u2014', emCount) + repeat('\u2013', enCount); }); block.appendChild(text$1(lit, this.sourcepos(startpos, this.pos))); } else { var node = text$1(m, this.sourcepos(startpos, this.pos)); block.appendChild(node); } return true; } return false; }; // Parse a newline. If it was preceded by two spaces, return a hard // line break; otherwise a soft line break. InlineParser.prototype.parseNewline = function (block) { this.pos += 1; // assume we're at a \n // check previous node for trailing spaces var lastc = block.lastChild; if (lastc && lastc.type === 'text' && lastc.literal[lastc.literal.length - 1] === ' ') { var hardbreak = lastc.literal[lastc.literal.length - 2] === ' '; var litLen = lastc.literal.length; lastc.literal = lastc.literal.replace(reFinalSpace, ''); var finalSpaceLen = litLen - lastc.literal.length; lastc.sourcepos[1][1] -= finalSpaceLen; block.appendChild(createNode$1(hardbreak ? 'linebreak' : 'softbreak', this.sourcepos(this.pos - finalSpaceLen, this.pos))); } else { block.appendChild(createNode$1('softbreak', this.sourcepos(this.pos, this.pos))); } this.nextLine(); this.match(reInitialSpace); // gobble leading spaces in next line return true; }; // Attempt to parse a link reference, modifying refmap. InlineParser.prototype.parseReference = function (block, refMap) { if (!this.options.referenceDefinition) { return 0; } this.subject = block.stringContent; this.pos = 0; var title = null; var startpos = this.pos; // label: var matchChars = this.parseLinkLabel(); if (matchChars === 0) { return 0; } var rawlabel = this.subject.substr(0, matchChars); // colon: if (this.peek() === C_COLON) { this.pos++; } else { this.pos = startpos; return 0; } // link url this.spnl(); var dest = this.parseLinkDestination(); if (dest === null) { this.pos = startpos; return 0; } var beforetitle = this.pos; this.spnl(); if (this.pos !== beforetitle) { title = this.parseLinkTitle(); } if (title === null) { title = ''; // rewind before spaces this.pos = beforetitle; } // make sure we're at line end: var atLineEnd = true; if (this.match(reSpaceAtEndOfLine) === null) { if (title === '') { atLineEnd = false; } else { // the potential title we found is not at the line end, // but it could still be a legal link reference if we // discard the title title = ''; // rewind before spaces this.pos = beforetitle; // and instead check if the link URL is at the line end atLineEnd = this.match(reSpaceAtEndOfLine) !== null; } } if (!atLineEnd) { this.pos = startpos; return 0; } var normalLabel = normalizeReference(rawlabel); if (normalLabel === '') { // label must contain non-whitespace characters this.pos = startpos; return 0; } var sourcepos = this.getReferenceDefSourcepos(block); block.sourcepos[0][0] = sourcepos[1][0] + 1; var node = createNode$1('refDef', sourcepos); node.title = title; node.dest = dest; node.label = normalLabel; block.insertBefore(node); if (!refMap[normalLabel]) { refMap[normalLabel] = createRefDefState(node); } else { this.refDefCandidateMap[node.id] = node; } return this.pos - startpos; }; InlineParser.prototype.mergeTextNodes = function (walker) { var event; var textNodes = []; while ((event = walker.next())) { var entering = event.entering, node = event.node; if (entering && node.type === 'text') { textNodes.push(node); } else if (textNodes.length === 1) { textNodes = []; } else if (textNodes.length > 1) { var firstNode = textNodes[0]; var lastNode = textNodes[textNodes.length - 1]; if (firstNode.sourcepos && lastNode.sourcepos) { firstNode.sourcepos[1] = lastNode.sourcepos[1]; } firstNode.next = lastNode.next; if (firstNode.next) { firstNode.next.prev = firstNode; } for (var i = 1; i < textNodes.length; i += 1) { firstNode.literal += textNodes[i].literal; textNodes[i].unlink(); } textNodes = []; } } }; InlineParser.prototype.getReferenceDefSourcepos = function (block) { var lines = block.stringContent.split(/\n|\r\n/); var passedUrlLine = false; var quotationCount = 0; var lastLineOffset = { line: 0, ch: 0 }; for (var i = 0; i < lines.length; i += 1) { var line = lines[i]; if (reWhitespaceChar.test(line)) { break; } if (/\:/.test(line) && quotationCount === 0) { if (passedUrlLine) { break; } var lineOffset = line.indexOf(':') === line.length - 1 ? i + 1 : i; lastLineOffset = { line: lineOffset, ch: lines[lineOffset].length }; passedUrlLine = true; } // should consider extendable title var matched = line.match(/'|"/g); if (matched) { quotationCount += matched.length; } if (quotationCount === 2) { lastLineOffset = { line: i, ch: line.length }; break; } } return [ [block.sourcepos[0][0], block.sourcepos[0][1]], [block.sourcepos[0][0] + lastLineOffset.line, lastLineOffset.ch], ]; }; // Parse the next inline element in subject, advancing subject position. // On success, add the result to block's children and return true. // On failure, return false. InlineParser.prototype.parseInline = function (block) { var _a; var res = false; var c = this.peek(); if (c === -1) { return false; } switch (c) { case C_NEWLINE: res = this.parseNewline(block); break; case C_BACKSLASH: res = this.parseBackslash(block); break; case C_BACKTICK: res = this.parseBackticks(block); break; case C_ASTERISK: case C_UNDERSCORE: case C_TILDE: case C_DOLLAR: res = this.handleDelim(c, block); break; case C_SINGLEQUOTE: case C_DOUBLEQUOTE: res = !!((_a = this.options) === null || _a === void 0 ? void 0 : _a.smart) && this.handleDelim(c, block); break; case C_OPEN_BRACKET$1: res = this.parseOpenBracket(block); break; case C_BANG: res = this.parseBang(block); break; case C_CLOSE_BRACKET: res = this.parseCloseBracket(block); break; case C_LESSTHAN$1: res = this.parseAutolink(block) || this.parseHtmlTag(block); break; case C_AMPERSAND: if (!block.disabledEntityParse) { res = this.parseEntity(block); } break; default: res = this.parseString(block); break; } if (!res) { this.pos += 1; block.appendChild(text$1(fromCodePoint$1(c), this.sourcepos(this.pos, this.pos + 1))); } return true; }; // Parse string content in block into inline children, // using refmap to resolve references. InlineParser.prototype.parse = function (block) { this.subject = block.stringContent.trim(); this.pos = 0; this.delimiters = null; this.brackets = null; this.lineOffsets = block.lineOffsets || [0]; this.lineIdx = 0; this.linePosOffset = 0; this.lineStartNum = block.sourcepos[0][0]; if (isHeading(block)) { this.lineOffsets[0] += block.level + 1; } while (this.parseInline(block)) { } block.stringContent = null; // allow raw string to be garbage collected this.processEmphasis(null); this.mergeTextNodes(block.walker()); var _a = this.options, extendedAutolinks = _a.extendedAutolinks, customParser = _a.customParser; if (extendedAutolinks) { convertExtAutoLinks(block.walker(), extendedAutolinks); } if (customParser && block.firstChild) { var event_1; var walker = block.firstChild.walker(); while ((event_1 = walker.next())) { var node = event_1.node, entering = event_1.entering; if (customParser[node.type]) { customParser[node.type](node, { entering: entering, options: this.options }); } } } }; return InlineParser; }()); var reTaskListItemMarker = /^\[([ \txX])\][ \t]+/; // finalize for block handler function taskListItemFinalize(_, block) { if (block.firstChild && block.firstChild.type === 'paragraph') { var p = block.firstChild; var m = p.stringContent.match(reTaskListItemMarker); if (m) { var mLen = m[0].length; p.stringContent = p.stringContent.substring(mLen - 1); p.sourcepos[0][1] += mLen; p.lineOffsets[0] += mLen; block.listData.task = true; block.listData.checked = /[xX]/.test(m[1]); } } } var table = { continue: function () { return 0 /* Go */; }, finalize: function () { }, canContain: function (t) { return t === 'tableHead' || t === 'tableBody'; }, acceptsLines: false, }; var tableBody$1 = { continue: function () { return 0 /* Go */; }, finalize: function () { }, canContain: function (t) { return t === 'tableRow'; }, acceptsLines: false, }; var tableHead$1 = { continue: function () { return 1 /* Stop */; }, finalize: function () { }, canContain: function (t) { return t === 'tableRow' || t === 'tableDelimRow'; }, acceptsLines: false, }; var tableDelimRow = { continue: function () { return 1 /* Stop */; }, finalize: function () { }, canContain: function (t) { return t === 'tableDelimCell'; }, acceptsLines: false, }; var tableDelimCell = { continue: function () { return 1 /* Stop */; }, finalize: function () { }, canContain: function () { return false; }, acceptsLines: false, }; var tableRow = { continue: function () { return 1 /* Stop */; }, finalize: function () { }, canContain: function (t) { return t === 'tableCell'; }, acceptsLines: false, }; var tableCell = { continue: function () { return 1 /* Stop */; }, finalize: function () { }, canContain: function () { return false; }, acceptsLines: false, }; var CODE_INDENT = 4; var C_TAB = 9; var C_GREATERTHAN = 62; var C_LESSTHAN = 60; var C_SPACE = 32; var C_OPEN_BRACKET = 91; var reNonSpace = /[^ \t\f\v\r\n]/; var reClosingCodeFence = /^(?:`{3,}|~{3,})(?= *$)/; // Returns true if block ends with a blank line, descending if needed // into lists and sublists. function endsWithBlankLine(block) { var curBlock = block; while (curBlock) { if (curBlock.lastLineBlank) { return true; } var t = curBlock.type; if (!curBlock.lastLineChecked && (t === 'list' || t === 'item')) { curBlock.lastLineChecked = true; curBlock = curBlock.lastChild; } else { curBlock.lastLineChecked = true; break; } } return false; } function peek(ln, pos) { if (pos < ln.length) { return ln.charCodeAt(pos); } return -1; } // Returns true if string contains only space characters. function isBlank(s) { return !reNonSpace.test(s); } function isSpaceOrTab(c) { return c === C_SPACE || c === C_TAB; } var reClosingCustomBlock = /^\$\$$/; var customBlock$1 = { continue: function (parser, container) { var line = parser.currentLine; var match = line.match(reClosingCustomBlock); if (match) { // closing custom block parser.lastLineLength = match[0].length; parser.finalize(container, parser.lineNumber); return 2 /* Finished */; } // skip optional spaces of custom block offset var i = container.offset; while (i > 0 && isSpaceOrTab(peek(line, parser.offset))) { parser.advanceOffset(1, true); i--; } return 0 /* Go */; }, finalize: function (_, block) { if (block.stringContent === null) { return; } // first line becomes info string var content = block.stringContent; var newlinePos = content.indexOf('\n'); var firstLine = content.slice(0, newlinePos); var rest = content.slice(newlinePos + 1); var infoString = firstLine.match(/^(\s*)(.*)/); block.info = unescapeString(infoString[2].trim()); block.literal = rest; block.stringContent = null; }, canContain: function () { return false; }, acceptsLines: true, }; var noop = { continue: function () { return 1 /* Stop */; }, finalize: function () { }, canContain: function () { return false; }, acceptsLines: true, }; var document$1 = { continue: function () { return 0 /* Go */; }, finalize: function () { }, canContain: function (t) { return t !== 'item'; }, acceptsLines: false, }; var list = { continue: function () { return 0 /* Go */; }, finalize: function (_, block) { var item = block.firstChild; while (item) { // check for non-final list item ending with blank line: if (endsWithBlankLine(item) && item.next) { block.listData.tight = false; break; } // recurse into children of list item, to see if there are // spaces between any of them: var subitem = item.firstChild; while (subitem) { if (endsWithBlankLine(subitem) && (item.next || subitem.next)) { block.listData.tight = false; break; } subitem = subitem.next; } item = item.next; } }, canContain: function (t) { return t === 'item'; }, acceptsLines: false, }; var blockQuote$1 = { continue: function (parser) { var ln = parser.currentLine; if (!parser.indented && peek(ln, parser.nextNonspace) === C_GREATERTHAN) { parser.advanceNextNonspace(); parser.advanceOffset(1, false); if (isSpaceOrTab(peek(ln, parser.offset))) { parser.advanceOffset(1, true); } } else { return 1 /* Stop */; } return 0 /* Go */; }, finalize: function () { }, canContain: function (t) { return t !== 'item'; }, acceptsLines: false, }; var item = { continue: function (parser, container) { if (parser.blank) { if (container.firstChild === null) { // Blank line after empty list item return 1 /* Stop */; } parser.advanceNextNonspace(); } else if (parser.indent >= container.listData.markerOffset + container.listData.padding) { parser.advanceOffset(container.listData.markerOffset + container.listData.padding, true); } else { return 1 /* Stop */; } return 0 /* Go */; }, finalize: taskListItemFinalize, canContain: function (t) { return t !== 'item'; }, acceptsLines: false, }; var heading = { continue: function () { // a heading can never container > 1 line, so fail to match: return 1 /* Stop */; }, finalize: function () { }, canContain: function () { return false; }, acceptsLines: false, }; var thematicBreak$1 = { continue: function () { // a thematic break can never container > 1 line, so fail to match: return 1 /* Stop */; }, finalize: function () { }, canContain: function () { return false; }, acceptsLines: false, }; var codeBlock = { continue: function (parser, container) { var ln = parser.currentLine; var indent = parser.indent; if (container.isFenced) { // fenced var match = indent <= 3 && ln.charAt(parser.nextNonspace) === container.fenceChar && ln.slice(parser.nextNonspace).match(reClosingCodeFence); if (match && match[0].length >= container.fenceLength) { // closing fence - we're at end of line, so we can return parser.lastLineLength = parser.offset + indent + match[0].length; parser.finalize(container, parser.lineNumber); return 2 /* Finished */; } // skip optional spaces of fence offset var i = container.fenceOffset; while (i > 0 && isSpaceOrTab(peek(ln, parser.offset))) { parser.advanceOffset(1, true); i--; } } else { // indented if (indent >= CODE_INDENT) { parser.advanceOffset(CODE_INDENT, true); } else if (parser.blank) { parser.advanceNextNonspace(); } else { return 1 /* Stop */; } } return 0 /* Go */; }, finalize: function (_, block) { var _a; if (block.stringContent === null) { return; } if (block.isFenced) { // fenced // first line becomes info string var content = block.stringContent; var newlinePos = content.indexOf('\n'); var firstLine = content.slice(0, newlinePos); var rest = content.slice(newlinePos + 1); var infoString = firstLine.match(/^(\s*)(.*)/); block.infoPadding = infoString[1].length; block.info = unescapeString(infoString[2].trim()); block.literal = rest; } else { // indented block.literal = (_a = block.stringContent) === null || _a === void 0 ? void 0 : _a.replace(/(\n *)+$/, '\n'); } block.stringContent = null; // allow GC }, canContain: function () { return false; }, acceptsLines: true, }; var htmlBlock$1 = { continue: function (parser, container) { return parser.blank && (container.htmlBlockType === 6 || container.htmlBlockType === 7) ? 1 /* Stop */ : 0 /* Go */; }, finalize: function (_, block) { var _a; block.literal = ((_a = block.stringContent) === null || _a === void 0 ? void 0 : _a.replace(/(\n *)+$/, '')) || null; block.stringContent = null; // allow GC }, canContain: function () { return false; }, acceptsLines: true, }; var paragraph = { continue: function (parser) { return parser.blank ? 1 /* Stop */ : 0 /* Go */; }, finalize: function (parser, block) { if (block.stringContent === null) { return; } var pos; var hasReferenceDefs = false; // try parsing the beginning as link reference definitions: while (peek(block.stringContent, 0) === C_OPEN_BRACKET && (pos = parser.inlineParser.parseReference(block, parser.refMap))) { block.stringContent = block.stringContent.slice(pos); hasReferenceDefs = true; } if (hasReferenceDefs && isBlank(block.stringContent)) { block.unlink(); } }, canContain: function () { return false; }, acceptsLines: true, }; var refDef = noop; var frontMatter$2 = noop; var blockHandlers = { document: document$1, list: list, blockQuote: blockQuote$1, item: item, heading: heading, thematicBreak: thematicBreak$1, codeBlock: codeBlock, htmlBlock: htmlBlock$1, paragraph: paragraph, table: table, tableBody: tableBody$1, tableHead: tableHead$1, tableRow: tableRow, tableCell: tableCell, tableDelimRow: tableDelimRow, tableDelimCell: tableDelimCell, refDef: refDef, customBlock: customBlock$1, frontMatter: frontMatter$2, }; function parseRowContent(content) { var startIdx = 0; var offset = 0; var cells = []; for (var i = 0; i < content.length; i += 1) { if (content[i] === '|' && content[i - 1] !== '\\') { var cell = content.substring(startIdx, i); if (startIdx === 0 && isEmpty(cell)) { offset = i + 1; } else { cells.push(cell); } startIdx = i + 1; } } if (startIdx < content.length) { var cell = content.substring(startIdx, content.length); if (!isEmpty(cell)) { cells.push(cell); } } return [offset, cells]; } function generateTableCells(cellType, contents, lineNum, chPos) { var cells = []; for (var _i = 0, contents_1 = contents; _i < contents_1.length; _i++) { var content = contents_1[_i]; var preSpaces = content.match(/^[ \t]+/); var paddingLeft = preSpaces ? preSpaces[0].length : 0; var paddingRight = void 0, trimmed = void 0; if (paddingLeft === content.length) { paddingLeft = 0; paddingRight = 0; trimmed = ''; } else { var postSpaces = content.match(/[ \t]+$/); paddingRight = postSpaces ? postSpaces[0].length : 0; trimmed = content.slice(paddingLeft, content.length - paddingRight); } var chPosStart = chPos + paddingLeft; var tableCell = createNode$1(cellType, [ [lineNum, chPos], [lineNum, chPos + content.length - 1], ]); tableCell.stringContent = trimmed.replace(/\\\|/g, '|'); // replace esacped pipe(\|) tableCell.startIdx = cells.length; tableCell.endIdx = cells.length; tableCell.lineOffsets = [chPosStart - 1]; tableCell.paddingLeft = paddingLeft; tableCell.paddingRight = paddingRight; cells.push(tableCell); chPos += content.length + 1; } return cells; } function getColumnFromDelimCell(cellNode) { var align = null; var content = cellNode.stringContent; var firstCh = content[0]; var lastCh = content[content.length - 1]; if (lastCh === ':') { align = firstCh === ':' ? 'center' : 'right'; } else if (firstCh === ':') { align = 'left'; } return { align: align }; } var tableHead = function (parser, container) { var stringContent = container.stringContent; if (container.type === 'paragraph' && !parser.indented && !parser.blank) { var lastNewLineIdx = stringContent.length - 1; var lastLineStartIdx = stringContent.lastIndexOf('\n', lastNewLineIdx - 1) + 1; var headerContent = stringContent.slice(lastLineStartIdx, lastNewLineIdx); var delimContent = parser.currentLine.slice(parser.nextNonspace); var _a = parseRowContent(headerContent), headerOffset = _a[0], headerCells = _a[1]; var _b = parseRowContent(delimContent), delimOffset = _b[0], delimCells = _b[1]; var reValidDelimCell_1 = /^[ \t]*:?-+:?[ \t]*$/; if ( // not checking if the number of header cells and delimiter cells are the same // to consider the case of merged-column (via plugin) !headerCells.length || !delimCells.length || delimCells.some(function (cell) { return !reValidDelimCell_1.test(cell); }) || // to prevent to regard setTextHeading as tabel delim cell with 'disallowDeepHeading' option (delimCells.length === 1 && delimContent.indexOf('|') !== 0)) { return 0 /* None */; } var lineOffsets = container.lineOffsets; var firstLineNum = parser.lineNumber - 1; var firstLineStart = last(lineOffsets) + 1; var table = createNode$1('table', [ [firstLineNum, firstLineStart], [parser.lineNumber, parser.offset], ]); // eslint-disable-next-line arrow-body-style table.columns = delimCells.map(function () { return ({ align: null }); }); container.insertAfter(table); if (lineOffsets.length === 1) { container.unlink(); } else { container.stringContent = stringContent.slice(0, lastLineStartIdx); var paraLastLineStartIdx = stringContent.lastIndexOf('\n', lastLineStartIdx - 2) + 1; var paraLastLineLen = lastLineStartIdx - paraLastLineStartIdx - 1; parser.lastLineLength = lineOffsets[lineOffsets.length - 2] + paraLastLineLen; parser.finalize(container, firstLineNum - 1); } parser.advanceOffset(parser.currentLine.length - parser.offset, false); var tableHead_1 = createNode$1('tableHead', [ [firstLineNum, firstLineStart], [parser.lineNumber, parser.offset], ]); table.appendChild(tableHead_1); var tableHeadRow_1 = createNode$1('tableRow', [ [firstLineNum, firstLineStart], [firstLineNum, firstLineStart + headerContent.length - 1], ]); var tableDelimRow_1 = createNode$1('tableDelimRow', [ [parser.lineNumber, parser.nextNonspace + 1], [parser.lineNumber, parser.offset], ]); tableHead_1.appendChild(tableHeadRow_1); tableHead_1.appendChild(tableDelimRow_1); generateTableCells('tableCell', headerCells, firstLineNum, firstLineStart + headerOffset).forEach(function (cellNode) { tableHeadRow_1.appendChild(cellNode); }); var delimCellNodes = generateTableCells('tableDelimCell', delimCells, parser.lineNumber, parser.nextNonspace + 1 + delimOffset); delimCellNodes.forEach(function (cellNode) { tableDelimRow_1.appendChild(cellNode); }); table.columns = delimCellNodes.map(getColumnFromDelimCell); parser.tip = table; return 2 /* Leaf */; } return 0 /* None */; }; var tableBody = function (parser, container) { if ((container.type !== 'table' && container.type !== 'tableBody') || (!parser.blank && parser.currentLine.indexOf('|') === -1)) { return 0 /* None */; } parser.advanceOffset(parser.currentLine.length - parser.offset, false); if (parser.blank) { var table_1 = container; if (container.type === 'tableBody') { table_1 = container.parent; parser.finalize(container, parser.lineNumber - 1); } parser.finalize(table_1, parser.lineNumber - 1); return 0 /* None */; } var tableBody = container; if (container.type === 'table') { tableBody = parser.addChild('tableBody', parser.nextNonspace); tableBody.stringContent = null; } var tableRow = createNode$1('tableRow', [ [parser.lineNumber, parser.nextNonspace + 1], [parser.lineNumber, parser.currentLine.length], ]); tableBody.appendChild(tableRow); var table = tableBody.parent; var content = parser.currentLine.slice(parser.nextNonspace); var _a = parseRowContent(content), offset = _a[0], cellContents = _a[1]; generateTableCells('tableCell', cellContents, parser.lineNumber, parser.nextNonspace + 1 + offset).forEach(function (cellNode, idx) { if (idx >= table.columns.length) { cellNode.ignored = true; } tableRow.appendChild(cellNode); }); return 2 /* Leaf */; }; var reCustomBlock = /^(\$\$)(\s*[a-zA-Z])+/; var reCanBeCustomInline = /^(\$\$)(\s*[a-zA-Z])+.*(\$\$)/; var customBlock = function (parser) { var match; if (!parser.indented && !reCanBeCustomInline.test(parser.currentLine) && (match = parser.currentLine.match(reCustomBlock))) { var syntaxLength = match[1].length; parser.closeUnmatchedBlocks(); var container = parser.addChild('customBlock', parser.nextNonspace); container.syntaxLength = syntaxLength; container.offset = parser.indent; parser.advanceNextNonspace(); parser.advanceOffset(syntaxLength, false); return 2 /* Leaf */; } return 0 /* None */; }; var reCodeFence = /^`{3,}(?!.*`)|^~{3,}/; var reHtmlBlockOpen = [ /./, /^<(?:script|pre|style)(?:\s|>|$)/i, /^/, /\?>/, />/, /\]\]>/, ]; var reMaybeSpecial = /^[#`~*+_=<>0-9-;$]/; var reLineEnding$1 = /\r\n|\n|\r/; function document$2() { return createNode$1('document', [ [1, 1], [0, 0], ]); } var defaultOptions$1 = { smart: false, tagFilter: false, extendedAutolinks: false, disallowedHtmlBlockTags: [], referenceDefinition: false, disallowDeepHeading: false, customParser: null, frontMatter: false, }; var Parser = /** @class */ (function () { function Parser(options) { this.options = __assign(__assign({}, defaultOptions$1), options); this.doc = document$2(); this.tip = this.doc; this.oldtip = this.doc; this.lineNumber = 0; this.offset = 0; this.column = 0; this.nextNonspace = 0; this.nextNonspaceColumn = 0; this.indent = 0; this.currentLine = ''; this.indented = false; this.blank = false; this.partiallyConsumedTab = false; this.allClosed = true; this.lastMatchedContainer = this.doc; this.refMap = {}; this.refLinkCandidateMap = {}; this.refDefCandidateMap = {}; this.lastLineLength = 0; this.lines = []; if (this.options.frontMatter) { blockHandlers.frontMatter = frontMatter; blockStarts.unshift(frontMatter$1); } this.inlineParser = new InlineParser(this.options); } Parser.prototype.advanceOffset = function (count, columns) { if (columns === void 0) { columns = false; } var currentLine = this.currentLine; var charsToTab, charsToAdvance; var c; while (count > 0 && (c = currentLine[this.offset])) { if (c === '\t') { charsToTab = 4 - (this.column % 4); if (columns) { this.partiallyConsumedTab = charsToTab > count; charsToAdvance = charsToTab > count ? count : charsToTab; this.column += charsToAdvance; this.offset += this.partiallyConsumedTab ? 0 : 1; count -= charsToAdvance; } else { this.partiallyConsumedTab = false; this.column += charsToTab; this.offset += 1; count -= 1; } } else { this.partiallyConsumedTab = false; this.offset += 1; this.column += 1; // assume ascii; block starts are ascii count -= 1; } } }; Parser.prototype.advanceNextNonspace = function () { this.offset = this.nextNonspace; this.column = this.nextNonspaceColumn; this.partiallyConsumedTab = false; }; Parser.prototype.findNextNonspace = function () { var currentLine = this.currentLine; var i = this.offset; var cols = this.column; var c; while ((c = currentLine.charAt(i)) !== '') { if (c === ' ') { i++; cols++; } else if (c === '\t') { i++; cols += 4 - (cols % 4); } else { break; } } this.blank = c === '\n' || c === '\r' || c === ''; this.nextNonspace = i; this.nextNonspaceColumn = cols; this.indent = this.nextNonspaceColumn - this.column; this.indented = this.indent >= CODE_INDENT; }; // Add a line to the block at the tip. We assume the tip // can accept lines -- that check should be done before calling this. Parser.prototype.addLine = function () { if (this.partiallyConsumedTab) { this.offset += 1; // skip over tab // add space characters: var charsToTab = 4 - (this.column % 4); this.tip.stringContent += repeat(' ', charsToTab); } if (this.tip.lineOffsets) { this.tip.lineOffsets.push(this.offset); } else { this.tip.lineOffsets = [this.offset]; } this.tip.stringContent += this.currentLine.slice(this.offset) + "\n"; }; // Add block of type tag as a child of the tip. If the tip can't // accept children, close and finalize it and try its parent, // and so on til we find a block that can accept children. Parser.prototype.addChild = function (tag, offset) { while (!blockHandlers[this.tip.type].canContain(tag)) { this.finalize(this.tip, this.lineNumber - 1); } var columnNumber = offset + 1; // offset 0 = column 1 var newBlock = createNode$1(tag, [ [this.lineNumber, columnNumber], [0, 0], ]); newBlock.stringContent = ''; this.tip.appendChild(newBlock); this.tip = newBlock; return newBlock; }; // Finalize and close any unmatched blocks. Parser.prototype.closeUnmatchedBlocks = function () { if (!this.allClosed) { // finalize any blocks not matched while (this.oldtip !== this.lastMatchedContainer) { var parent_1 = this.oldtip.parent; this.finalize(this.oldtip, this.lineNumber - 1); this.oldtip = parent_1; } this.allClosed = true; } }; // Finalize a block. Close it and do any necessary postprocessing, // e.g. creating stringContent from strings, setting the 'tight' // or 'loose' status of a list, and parsing the beginnings // of paragraphs for reference definitions. Reset the tip to the // parent of the closed block. Parser.prototype.finalize = function (block, lineNumber) { var above = block.parent; block.open = false; block.sourcepos[1] = [lineNumber, this.lastLineLength]; blockHandlers[block.type].finalize(this, block); this.tip = above; }; // Walk through a block & children recursively, parsing string content // into inline content where appropriate. Parser.prototype.processInlines = function (block) { var event; var customParser = this.options.customParser; var walker = block.walker(); this.inlineParser.refMap = this.refMap; this.inlineParser.refLinkCandidateMap = this.refLinkCandidateMap; this.inlineParser.refDefCandidateMap = this.refDefCandidateMap; this.inlineParser.options = this.options; while ((event = walker.next())) { var node = event.node, entering = event.entering; var t = node.type; if (customParser && customParser[t]) { customParser[t](node, { entering: entering, options: this.options }); } if (!entering && (t === 'paragraph' || t === 'heading' || (t === 'tableCell' && !node.ignored))) { this.inlineParser.parse(node); } } }; // Analyze a line of text and update the document appropriately. // We parse markdown text by calling this on each line of input, // then finalizing the document. Parser.prototype.incorporateLine = function (ln) { var container = this.doc; this.oldtip = this.tip; this.offset = 0; this.column = 0; this.blank = false; this.partiallyConsumedTab = false; this.lineNumber += 1; // replace NUL characters for security if (ln.indexOf('\u0000') !== -1) { ln = ln.replace(/\0/g, '\uFFFD'); } this.currentLine = ln; // For each containing block, try to parse the associated line start. // Bail out on failure: container will point to the last matching block. // Set allMatched to false if not all containers match. var allMatched = true; var lastChild; while ((lastChild = container.lastChild) && lastChild.open) { container = lastChild; this.findNextNonspace(); switch (blockHandlers[container.type]['continue'](this, container)) { case 0 /* Go */: // we've matched, keep going break; case 1 /* Stop */: // we've failed to match a block allMatched = false; break; case 2 /* Finished */: // we've hit end of line for fenced code close and can return this.lastLineLength = ln.length; return; default: throw new Error('continue returned illegal value, must be 0, 1, or 2'); } if (!allMatched) { container = container.parent; // back up to last matching block break; } } this.allClosed = container === this.oldtip; this.lastMatchedContainer = container; var matchedLeaf = container.type !== 'paragraph' && blockHandlers[container.type].acceptsLines; var blockStartsLen = blockStarts.length; // Unless last matched container is a code block, try new container starts, // adding children to the last matched container: while (!matchedLeaf) { this.findNextNonspace(); // this is a little performance optimization: if (container.type !== 'table' && container.type !== 'tableBody' && container.type !== 'paragraph' && !this.indented && !reMaybeSpecial.test(ln.slice(this.nextNonspace))) { this.advanceNextNonspace(); break; } var i = 0; while (i < blockStartsLen) { var res = blockStarts[i](this, container); if (res === 1 /* Container */) { container = this.tip; break; } else if (res === 2 /* Leaf */) { container = this.tip; matchedLeaf = true; break; } else { i++; } } if (i === blockStartsLen) { // nothing matched this.advanceNextNonspace(); break; } } // What remains at the offset is a text line. Add the text to the // appropriate container. // First check for a lazy paragraph continuation: if (!this.allClosed && !this.blank && this.tip.type === 'paragraph') { // lazy paragraph continuation this.addLine(); } else { // not a lazy continuation // finalize any blocks not matched this.closeUnmatchedBlocks(); if (this.blank && container.lastChild) { container.lastChild.lastLineBlank = true; } var t = container.type; // Block quote lines are never blank as they start with > // and we don't count blanks in fenced code for purposes of tight/loose // lists or breaking out of lists. We also don't set _lastLineBlank // on an empty list item, or if we just closed a fenced block. var lastLineBlank = this.blank && !(t === 'blockQuote' || (isCodeBlock(container) && container.isFenced) || (t === 'item' && !container.firstChild && container.sourcepos[0][0] === this.lineNumber)); // propagate lastLineBlank up through parents: var cont = container; while (cont) { cont.lastLineBlank = lastLineBlank; cont = cont.parent; } if (blockHandlers[t].acceptsLines) { this.addLine(); // if HtmlBlock, check for end condition if (isHtmlBlock(container) && container.htmlBlockType >= 1 && container.htmlBlockType <= 5 && reHtmlBlockClose[container.htmlBlockType].test(this.currentLine.slice(this.offset))) { this.lastLineLength = ln.length; this.finalize(container, this.lineNumber); } } else if (this.offset < ln.length && !this.blank) { // create paragraph container for line container = this.addChild('paragraph', this.offset); this.advanceNextNonspace(); this.addLine(); } } this.lastLineLength = ln.length; }; // The main parsing function. Returns a parsed document AST. Parser.prototype.parse = function (input, lineTexts) { this.doc = document$2(); this.tip = this.doc; this.lineNumber = 0; this.lastLineLength = 0; this.offset = 0; this.column = 0; this.lastMatchedContainer = this.doc; this.currentLine = ''; var lines = input.split(reLineEnding$1); var len = lines.length; this.lines = lineTexts ? lineTexts : lines; if (this.options.referenceDefinition) { this.clearRefMaps(); } if (input.charCodeAt(input.length - 1) === C_NEWLINE) { // ignore last blank line created by final newline len -= 1; } for (var i = 0; i < len; i++) { this.incorporateLine(lines[i]); } while (this.tip) { this.finalize(this.tip, len); } this.processInlines(this.doc); return this.doc; }; Parser.prototype.partialParseStart = function (lineNumber, lines) { this.doc = document$2(); this.tip = this.doc; this.lineNumber = lineNumber - 1; this.lastLineLength = 0; this.offset = 0; this.column = 0; this.lastMatchedContainer = this.doc; this.currentLine = ''; var len = lines.length; for (var i = 0; i < len; i++) { this.incorporateLine(lines[i]); } return this.doc; }; Parser.prototype.partialParseExtends = function (lines) { for (var i = 0; i < lines.length; i++) { this.incorporateLine(lines[i]); } }; Parser.prototype.partialParseFinish = function () { while (this.tip) { this.finalize(this.tip, this.lineNumber); } this.processInlines(this.doc); }; Parser.prototype.setRefMaps = function (refMap, refLinkCandidateMap, refDefCandidateMap) { this.refMap = refMap; this.refLinkCandidateMap = refLinkCandidateMap; this.refDefCandidateMap = refDefCandidateMap; }; Parser.prototype.clearRefMaps = function () { [this.refMap, this.refLinkCandidateMap, this.refDefCandidateMap].forEach(function (map) { clearObj(map); }); }; return Parser; }()); function comparePos(p1, p2) { if (p1[0] < p2[0]) { return 1 /* LT */; } if (p1[0] > p2[0]) { return -1 /* GT */; } if (p1[1] < p2[1]) { return 1 /* LT */; } if (p1[1] > p2[1]) { return -1 /* GT */; } return 0 /* EQ */; } function compareRangeAndPos(_a, pos) { var startPos = _a[0], endPos = _a[1]; if (comparePos(endPos, pos) === 1 /* LT */) { return 1 /* LT */; } if (comparePos(startPos, pos) === -1 /* GT */) { return -1 /* GT */; } return 0 /* EQ */; } function removeNextUntil(node, last) { if (node.parent !== last.parent || node === last) { return; } var next = node.next; while (next && next !== last) { var temp = next.next; for (var _i = 0, _a = ['parent', 'prev', 'next']; _i < _a.length; _i++) { var type = _a[_i]; if (next[type]) { removeNodeById(next[type].id); next[type] = null; } } next = temp; } node.next = last.next; if (last.next) { last.next.prev = node; } else { node.parent.lastChild = node; } } function getChildNodes(parent) { var nodes = []; var curr = parent.firstChild; while (curr) { nodes.push(curr); curr = curr.next; } return nodes; } function insertNodesBefore(target, nodes) { for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { var node = nodes_1[_i]; target.insertBefore(node); } } function prependChildNodes(parent, nodes) { for (var i = nodes.length - 1; i >= 0; i -= 1) { parent.prependChild(nodes[i]); } } function updateNextLineNumbers(base, diff) { if (!base || !base.parent || diff === 0) { return; } var walker = base.parent.walker(); walker.resumeAt(base, true); var event; while ((event = walker.next())) { var node = event.node, entering = event.entering; if (entering) { node.sourcepos[0][0] += diff; node.sourcepos[1][0] += diff; } } } function compareRangeAndLine(_a, line) { var startPos = _a[0], endPos = _a[1]; if (endPos[0] < line) { return 1 /* LT */; } if (startPos[0] > line) { return -1 /* GT */; } return 0 /* EQ */; } function findChildNodeAtLine(parent, line) { var node = parent.firstChild; while (node) { var comp = compareRangeAndLine(node.sourcepos, line); if (comp === 0 /* EQ */) { return node; } if (comp === -1 /* GT */) { // To consider that top line is blank line return node.prev || node; } node = node.next; } return parent.lastChild; } function lastLeafNode(node) { while (node.lastChild) { node = node.lastChild; } return node; } function sameLineTopAncestor(node) { while (node.parent && node.parent.type !== 'document' && node.parent.sourcepos[0][0] === node.sourcepos[0][0]) { node = node.parent; } return node; } function findFirstNodeAtLine(parent, line) { var node = parent.firstChild; var prev = null; while (node) { var comp = compareRangeAndLine(node.sourcepos, line); if (comp === 0 /* EQ */) { if (node.sourcepos[0][0] === line || !node.firstChild) { return node; } prev = node; node = node.firstChild; } else if (comp === -1 /* GT */) { break; } else { prev = node; node = node.next; } } if (prev) { return sameLineTopAncestor(lastLeafNode(prev)); } return null; } function findNodeAtPosition(parent, pos) { var node = parent; var prev = null; while (node) { var comp = compareRangeAndPos(node.sourcepos, pos); if (comp === 0 /* EQ */) { if (node.firstChild) { prev = node; node = node.firstChild; } else { return node; } } else if (comp === -1 /* GT */) { return prev; } else if (node.next) { node = node.next; } else { return prev; } } return node; } function findNodeById(id) { return getNodeById(id) || null; } function invokeNextUntil(callback, start, end) { if (end === void 0) { end = null; } if (start) { var walker = start.walker(); while (start && start !== end) { callback(start); var next = walker.next(); if (next) { start = next.node; } else { break; } } } } function isUnlinked(id) { var node = findNodeById(id); if (!node) { return true; } while (node && node.type !== 'document') { // eslint-disable-next-line no-loop-func if (!node.parent && !node.prev && !node.next) { return true; } node = node.parent; } return false; } var reLineEnding = /\r\n|\n|\r/; function canBeContinuedListItem(lineText) { var spaceMatch = lineText.match(/^[ \t]+/); if (spaceMatch && (spaceMatch[0].length >= 2 || /\t/.test(spaceMatch[0]))) { return true; } var leftTrimmed = spaceMatch ? lineText.slice(spaceMatch.length) : lineText; return reBulletListMarker.test(leftTrimmed) || reOrderedListMarker.test(leftTrimmed); } function canBeContinuedTableBody(lineText) { return !isBlank(lineText) && lineText.indexOf('|') !== -1; } function createRefDefState(node) { var id = node.id, title = node.title, sourcepos = node.sourcepos, dest = node.dest; return { id: id, title: title, sourcepos: sourcepos, unlinked: false, destination: dest, }; } var ToastMark = /** @class */ (function () { function ToastMark(contents, options) { this.refMap = {}; this.refLinkCandidateMap = {}; this.refDefCandidateMap = {}; this.referenceDefinition = !!(options === null || options === void 0 ? void 0 : options.referenceDefinition); this.parser = new Parser(options); this.parser.setRefMaps(this.refMap, this.refLinkCandidateMap, this.refDefCandidateMap); this.eventHandlerMap = { change: [] }; contents = contents || ''; this.lineTexts = contents.split(reLineEnding); this.root = this.parser.parse(contents, this.lineTexts); } ToastMark.prototype.updateLineTexts = function (startPos, endPos, newText) { var _a; var startLine = startPos[0], startCol = startPos[1]; var endLine = endPos[0], endCol = endPos[1]; var newLines = newText.split(reLineEnding); var newLineLen = newLines.length; var startLineText = this.lineTexts[startLine - 1]; var endLineText = this.lineTexts[endLine - 1]; newLines[0] = startLineText.slice(0, startCol - 1) + newLines[0]; newLines[newLineLen - 1] = newLines[newLineLen - 1] + endLineText.slice(endCol - 1); var removedLineLen = endLine - startLine + 1; (_a = this.lineTexts).splice.apply(_a, __spreadArray([startLine - 1, removedLineLen], newLines)); return newLineLen - removedLineLen; }; ToastMark.prototype.updateRootNodeState = function () { if (this.lineTexts.length === 1 && this.lineTexts[0] === '') { this.root.lastLineBlank = true; this.root.sourcepos = [ [1, 1], [1, 0], ]; return; } if (this.root.lastChild) { this.root.lastLineBlank = this.root.lastChild.lastLineBlank; } var lineTexts = this.lineTexts; var idx = lineTexts.length - 1; while (lineTexts[idx] === '') { idx -= 1; } if (lineTexts.length - 2 > idx) { idx += 1; } this.root.sourcepos[1] = [idx + 1, lineTexts[idx].length]; }; ToastMark.prototype.replaceRangeNodes = function (startNode, endNode, newNodes) { if (!startNode) { if (endNode) { insertNodesBefore(endNode, newNodes); removeNodeById(endNode.id); endNode.unlink(); } else { prependChildNodes(this.root, newNodes); } } else { insertNodesBefore(startNode, newNodes); removeNextUntil(startNode, endNode); [startNode.id, endNode.id].forEach(function (id) { return removeNodeById(id); }); startNode.unlink(); } }; ToastMark.prototype.getNodeRange = function (startPos, endPos) { var startNode = findChildNodeAtLine(this.root, startPos[0]); var endNode = findChildNodeAtLine(this.root, endPos[0]); // extend node range to include a following block which doesn't have preceding blank line if (endNode && endNode.next && endPos[0] + 1 === endNode.next.sourcepos[0][0]) { endNode = endNode.next; } return [startNode, endNode]; }; ToastMark.prototype.trigger = function (eventName, param) { this.eventHandlerMap[eventName].forEach(function (handler) { handler(param); }); }; ToastMark.prototype.extendEndLine = function (line) { while (this.lineTexts[line] === '') { line += 1; } return line; }; ToastMark.prototype.parseRange = function (startNode, endNode, startLine, endLine) { // extends starting range if the first node can be a continued list item if (startNode && startNode.prev && ((isList(startNode.prev) && canBeContinuedListItem(this.lineTexts[startLine - 1])) || (isTable(startNode.prev) && canBeContinuedTableBody(this.lineTexts[startLine - 1])))) { startNode = startNode.prev; startLine = startNode.sourcepos[0][0]; } var editedLines = this.lineTexts.slice(startLine - 1, endLine); var root = this.parser.partialParseStart(startLine, editedLines); // extends ending range if the following node can be a fenced code block or a continued list item var nextNode = endNode ? endNode.next : this.root.firstChild; var lastChild = root.lastChild; var isOpenedLastChildCodeBlock = lastChild && isCodeBlock(lastChild) && lastChild.open; var isOpenedLastChildCustomBlock = lastChild && isCustomBlock(lastChild) && lastChild.open; var isLastChildList = lastChild && isList(lastChild); while (((isOpenedLastChildCodeBlock || isOpenedLastChildCustomBlock) && nextNode) || (isLastChildList && nextNode && (nextNode.type === 'list' || nextNode.sourcepos[0][1] >= 2))) { var newEndLine = this.extendEndLine(nextNode.sourcepos[1][0]); this.parser.partialParseExtends(this.lineTexts.slice(endLine, newEndLine)); if (!startNode) { startNode = endNode; } endNode = nextNode; endLine = newEndLine; nextNode = nextNode.next; } this.parser.partialParseFinish(); var newNodes = getChildNodes(root); return { newNodes: newNodes, extStartNode: startNode, extEndNode: endNode }; }; ToastMark.prototype.getRemovedNodeRange = function (extStartNode, extEndNode) { if (!extStartNode || (extStartNode && isRefDef(extStartNode)) || (extEndNode && isRefDef(extEndNode))) { return null; } return { id: [extStartNode.id, extEndNode.id], line: [extStartNode.sourcepos[0][0] - 1, extEndNode.sourcepos[1][0] - 1], }; }; ToastMark.prototype.markDeletedRefMap = function (extStartNode, extEndNode) { var _this = this; if (!isEmptyObj(this.refMap)) { var markDeleted = function (node) { if (isRefDef(node)) { var refDefState = _this.refMap[node.label]; if (refDefState && node.id === refDefState.id) { refDefState.unlinked = true; } } }; if (extStartNode) { invokeNextUntil(markDeleted, extStartNode.parent, extEndNode); } if (extEndNode) { invokeNextUntil(markDeleted, extEndNode); } } }; ToastMark.prototype.replaceWithNewRefDefState = function (nodes) { var _this = this; if (!isEmptyObj(this.refMap)) { var replaceWith_1 = function (node) { if (isRefDef(node)) { var label = node.label; var refDefState = _this.refMap[label]; if (!refDefState || refDefState.unlinked) { _this.refMap[label] = createRefDefState(node); } } }; nodes.forEach(function (node) { invokeNextUntil(replaceWith_1, node); }); } }; ToastMark.prototype.replaceWithRefDefCandidate = function () { var _this = this; if (!isEmptyObj(this.refDefCandidateMap)) { iterateObject(this.refDefCandidateMap, function (_, candidate) { var label = candidate.label, sourcepos = candidate.sourcepos; var refDefState = _this.refMap[label]; if (!refDefState || refDefState.unlinked || refDefState.sourcepos[0][0] > sourcepos[0][0]) { _this.refMap[label] = createRefDefState(candidate); } }); } }; ToastMark.prototype.getRangeWithRefDef = function (startLine, endLine, startNode, endNode, lineDiff) { if (this.referenceDefinition && !isEmptyObj(this.refMap)) { var prevNode = findChildNodeAtLine(this.root, startLine - 1); var nextNode = findChildNodeAtLine(this.root, endLine + 1); if (prevNode && isRefDef(prevNode) && prevNode !== startNode && prevNode !== endNode) { startNode = prevNode; startLine = startNode.sourcepos[0][0]; } if (nextNode && isRefDef(nextNode) && nextNode !== startNode && nextNode !== endNode) { endNode = nextNode; endLine = this.extendEndLine(endNode.sourcepos[1][0] + lineDiff); } } return [startNode, endNode, startLine, endLine]; }; ToastMark.prototype.parse = function (startPos, endPos, lineDiff) { if (lineDiff === void 0) { lineDiff = 0; } var range = this.getNodeRange(startPos, endPos); var startNode = range[0], endNode = range[1]; var startLine = startNode ? Math.min(startNode.sourcepos[0][0], startPos[0]) : startPos[0]; var endLine = this.extendEndLine((endNode ? Math.max(endNode.sourcepos[1][0], endPos[0]) : endPos[0]) + lineDiff); var parseResult = this.parseRange.apply(this, this.getRangeWithRefDef(startLine, endLine, startNode, endNode, lineDiff)); var newNodes = parseResult.newNodes, extStartNode = parseResult.extStartNode, extEndNode = parseResult.extEndNode; var removedNodeRange = this.getRemovedNodeRange(extStartNode, extEndNode); var nextNode = extEndNode ? extEndNode.next : this.root.firstChild; if (this.referenceDefinition) { this.markDeletedRefMap(extStartNode, extEndNode); this.replaceRangeNodes(extStartNode, extEndNode, newNodes); this.replaceWithNewRefDefState(newNodes); } else { this.replaceRangeNodes(extStartNode, extEndNode, newNodes); } return { nodes: newNodes, removedNodeRange: removedNodeRange, nextNode: nextNode }; }; ToastMark.prototype.parseRefLink = function () { var _this = this; var result = []; if (!isEmptyObj(this.refMap)) { iterateObject(this.refMap, function (label, value) { if (value.unlinked) { delete _this.refMap[label]; } iterateObject(_this.refLinkCandidateMap, function (_, candidate) { var node = candidate.node, refLabel = candidate.refLabel; if (refLabel === label) { result.push(_this.parse(node.sourcepos[0], node.sourcepos[1])); } }); }); } return result; }; ToastMark.prototype.removeUnlinkedCandidate = function () { if (!isEmptyObj(this.refDefCandidateMap)) { [this.refLinkCandidateMap, this.refDefCandidateMap].forEach(function (candidateMap) { iterateObject(candidateMap, function (id) { if (isUnlinked(id)) { delete candidateMap[id]; } }); }); } }; ToastMark.prototype.editMarkdown = function (startPos, endPos, newText) { var lineDiff = this.updateLineTexts(startPos, endPos, newText); var parseResult = this.parse(startPos, endPos, lineDiff); var editResult = omit(parseResult, 'nextNode'); updateNextLineNumbers(parseResult.nextNode, lineDiff); this.updateRootNodeState(); var result = [editResult]; if (this.referenceDefinition) { this.removeUnlinkedCandidate(); this.replaceWithRefDefCandidate(); result = result.concat(this.parseRefLink()); } this.trigger('change', result); return result; }; ToastMark.prototype.getLineTexts = function () { return this.lineTexts; }; ToastMark.prototype.getRootNode = function () { return this.root; }; ToastMark.prototype.findNodeAtPosition = function (pos) { var node = findNodeAtPosition(this.root, pos); if (!node || node === this.root) { return null; } return node; }; ToastMark.prototype.findFirstNodeAtLine = function (line) { return findFirstNodeAtLine(this.root, line); }; ToastMark.prototype.on = function (eventName, callback) { this.eventHandlerMap[eventName].push(callback); }; ToastMark.prototype.off = function (eventName, callback) { var handlers = this.eventHandlerMap[eventName]; var idx = handlers.indexOf(callback); handlers.splice(idx, 1); }; ToastMark.prototype.findNodeById = function (id) { return findNodeById(id); }; ToastMark.prototype.removeAllNode = function () { removeAllNode(); }; return ToastMark; }()); var disallowedTags = [ 'title', 'textarea', 'style', 'xmp', 'iframe', 'noembed', 'noframes', 'script', 'plaintext', ]; var reDisallowedTag = new RegExp("<(/?(?:" + disallowedTags.join('|') + ")[^>]*>)", 'ig'); function filterDisallowedTags(str) { if (reDisallowedTag.test(str)) { return str.replace(reDisallowedTag, function (_, group) { return "<" + group; }); } return str; } var baseConvertors$1 = { heading: function (node, _a) { var entering = _a.entering; return { type: entering ? 'openTag' : 'closeTag', tagName: "h" + node.level, outerNewLine: true, }; }, text: function (node) { return { type: 'text', content: node.literal, }; }, softbreak: function (_, _a) { var options = _a.options; return { type: 'html', content: options.softbreak, }; }, linebreak: function () { return { type: 'html', content: '
\n', }; }, emph: function (_, _a) { var entering = _a.entering; return { type: entering ? 'openTag' : 'closeTag', tagName: 'em', }; }, strong: function (_, _a) { var entering = _a.entering; return { type: entering ? 'openTag' : 'closeTag', tagName: 'strong', }; }, paragraph: function (node, _a) { var _b; var entering = _a.entering; var grandparent = (_b = node.parent) === null || _b === void 0 ? void 0 : _b.parent; if (grandparent && grandparent.type === 'list') { if (grandparent.listData.tight) { return null; } } return { type: entering ? 'openTag' : 'closeTag', tagName: 'p', outerNewLine: true, }; }, thematicBreak: function () { return { type: 'openTag', tagName: 'hr', outerNewLine: true, selfClose: true, }; }, blockQuote: function (_, _a) { var entering = _a.entering; return { type: entering ? 'openTag' : 'closeTag', tagName: 'blockquote', outerNewLine: true, innerNewLine: true, }; }, list: function (node, _a) { var entering = _a.entering; var _b = node.listData, type = _b.type, start = _b.start; var tagName = type === 'bullet' ? 'ul' : 'ol'; var attributes = {}; if (tagName === 'ol' && start !== null && start !== 1) { attributes.start = start.toString(); } return { type: entering ? 'openTag' : 'closeTag', tagName: tagName, attributes: attributes, outerNewLine: true, }; }, item: function (_, _a) { var entering = _a.entering; return { type: entering ? 'openTag' : 'closeTag', tagName: 'li', outerNewLine: true, }; }, htmlInline: function (node, _a) { var options = _a.options; var content = options.tagFilter ? filterDisallowedTags(node.literal) : node.literal; return { type: 'html', content: content }; }, htmlBlock: function (node, _a) { var options = _a.options; var content = options.tagFilter ? filterDisallowedTags(node.literal) : node.literal; if (options.nodeId) { return [ { type: 'openTag', tagName: 'div', outerNewLine: true }, { type: 'html', content: content }, { type: 'closeTag', tagName: 'div', outerNewLine: true }, ]; } return { type: 'html', content: content, outerNewLine: true }; }, code: function (node) { return [ { type: 'openTag', tagName: 'code' }, { type: 'text', content: node.literal }, { type: 'closeTag', tagName: 'code' }, ]; }, codeBlock: function (node) { var infoStr = node.info; var infoWords = infoStr ? infoStr.split(/\s+/) : []; var codeClassNames = []; if (infoWords.length > 0 && infoWords[0].length > 0) { codeClassNames.push("language-" + escapeXml(infoWords[0])); } return [ { type: 'openTag', tagName: 'pre', outerNewLine: true }, { type: 'openTag', tagName: 'code', classNames: codeClassNames }, { type: 'text', content: node.literal }, { type: 'closeTag', tagName: 'code' }, { type: 'closeTag', tagName: 'pre', outerNewLine: true }, ]; }, link: function (node, _a) { var entering = _a.entering; if (entering) { var _b = node, title = _b.title, destination = _b.destination; return { type: 'openTag', tagName: 'a', attributes: __assign({ href: escapeXml(destination) }, (title && { title: escapeXml(title) })), }; } return { type: 'closeTag', tagName: 'a' }; }, image: function (node, _a) { var getChildrenText = _a.getChildrenText, skipChildren = _a.skipChildren; var _b = node, title = _b.title, destination = _b.destination; skipChildren(); return { type: 'openTag', tagName: 'img', selfClose: true, attributes: __assign({ src: escapeXml(destination), alt: getChildrenText(node) }, (title && { title: escapeXml(title) })), }; }, customBlock: function (node, context, convertors) { var info = node.info.trim().toLowerCase(); var customConvertor = convertors[info]; if (customConvertor) { try { return customConvertor(node, context); } catch (e) { console.warn("[@toast-ui/editor] - The error occurred when " + info + " block node was parsed in markdown renderer: " + e); } } return [ { type: 'openTag', tagName: 'div', outerNewLine: true }, { type: 'text', content: node.literal }, { type: 'closeTag', tagName: 'div', outerNewLine: true }, ]; }, frontMatter: function (node) { return [ { type: 'openTag', tagName: 'div', outerNewLine: true, // Because front matter is metadata, it should not be render. attributes: { style: 'white-space: pre; display: none;' }, }, { type: 'text', content: node.literal }, { type: 'closeTag', tagName: 'div', outerNewLine: true }, ]; }, customInline: function (node, context, convertors) { var _a = node, info = _a.info, firstChild = _a.firstChild; var nomalizedInfo = info.trim().toLowerCase(); var customConvertor = convertors[nomalizedInfo]; var entering = context.entering; if (customConvertor) { try { return customConvertor(node, context); } catch (e) { console.warn("[@toast-ui/editor] - The error occurred when " + nomalizedInfo + " inline node was parsed in markdown renderer: " + e); } } return entering ? [ { type: 'openTag', tagName: 'span' }, { type: 'text', content: "$$" + info + (firstChild ? ' ' : '') }, ] : [ { type: 'text', content: '$$' }, { type: 'closeTag', tagName: 'span' }, ]; }, }; var gfmConvertors = { strike: function (_, _a) { var entering = _a.entering; return { type: entering ? 'openTag' : 'closeTag', tagName: 'del', }; }, item: function (node, _a) { var entering = _a.entering; var _b = node.listData, checked = _b.checked, task = _b.task; if (entering) { var itemTag = { type: 'openTag', tagName: 'li', outerNewLine: true, }; if (task) { return [ itemTag, { type: 'openTag', tagName: 'input', selfClose: true, attributes: __assign(__assign({}, (checked && { checked: '' })), { disabled: '', type: 'checkbox' }), }, { type: 'text', content: ' ', }, ]; } return itemTag; } return { type: 'closeTag', tagName: 'li', outerNewLine: true, }; }, table: function (_, _a) { var entering = _a.entering; return { type: entering ? 'openTag' : 'closeTag', tagName: 'table', outerNewLine: true, }; }, tableHead: function (_, _a) { var entering = _a.entering; return { type: entering ? 'openTag' : 'closeTag', tagName: 'thead', outerNewLine: true, }; }, tableBody: function (_, _a) { var entering = _a.entering; return { type: entering ? 'openTag' : 'closeTag', tagName: 'tbody', outerNewLine: true, }; }, tableRow: function (node, _a) { var entering = _a.entering; if (entering) { return { type: 'openTag', tagName: 'tr', outerNewLine: true, }; } var result = []; if (node.lastChild) { var columnLen = node.parent.parent.columns.length; var lastColIdx = node.lastChild.endIdx; for (var i = lastColIdx + 1; i < columnLen; i += 1) { result.push({ type: 'openTag', tagName: 'td', outerNewLine: true, }, { type: 'closeTag', tagName: 'td', outerNewLine: true, }); } } result.push({ type: 'closeTag', tagName: 'tr', outerNewLine: true, }); return result; }, tableCell: function (node, _a) { var entering = _a.entering; if (node.ignored) { return { type: 'text', content: '', }; } var tablePart = node.parent.parent; var tagName = tablePart.type === 'tableHead' ? 'th' : 'td'; var table = tablePart.parent; var columnInfo = table.columns[node.startIdx]; var attributes = (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.align) ? { align: columnInfo.align } : null; if (entering) { return __assign({ type: 'openTag', tagName: tagName, outerNewLine: true }, (attributes && { attributes: attributes })); } return { type: 'closeTag', tagName: tagName, outerNewLine: true, }; }, }; var defaultOptions = { softbreak: '\n', gfm: false, tagFilter: false, nodeId: false, }; function getChildrenText(node) { var buffer = []; var walker = node.walker(); var event = null; while ((event = walker.next())) { var node_1 = event.node; if (node_1.type === 'text') { buffer.push(node_1.literal); } } return buffer.join(''); } var Renderer = /** @class */ (function () { function Renderer(customOptions) { this.buffer = []; this.options = __assign(__assign({}, defaultOptions), customOptions); this.convertors = this.createConvertors(); delete this.options.convertors; } Renderer.prototype.createConvertors = function () { var convertors = __assign({}, baseConvertors$1); if (this.options.gfm) { convertors = __assign(__assign({}, convertors), gfmConvertors); } if (this.options.convertors) { var customConvertors_1 = this.options.convertors; var nodeTypes = Object.keys(customConvertors_1); var defaultConvertors_1 = __assign(__assign({}, baseConvertors$1), gfmConvertors); nodeTypes.forEach(function (nodeType) { var orgConvertor = convertors[nodeType]; var convertor = customConvertors_1[nodeType]; var convertorType = Object.keys(defaultConvertors_1).indexOf(nodeType) === -1 ? nodeType.toLowerCase() : nodeType; if (orgConvertor) { convertors[convertorType] = function (node, context, convertors) { context.origin = function () { return orgConvertor(node, context, convertors); }; return convertor(node, context); }; } else { convertors[convertorType] = convertor; } }); } return convertors; }; Renderer.prototype.getConvertors = function () { return this.convertors; }; Renderer.prototype.getOptions = function () { return this.options; }; Renderer.prototype.render = function (rootNode) { var _this = this; this.buffer = []; var walker = rootNode.walker(); var event = null; var _loop_1 = function () { var node = event.node, entering = event.entering; var convertor = this_1.convertors[node.type]; if (!convertor) { return "continue"; } var skipped = false; var context = { entering: entering, leaf: !isContainer$1(node), options: this_1.options, getChildrenText: getChildrenText, skipChildren: function () { skipped = true; }, }; var converted = isCustomBlock(node) || isCustomInline(node) ? convertor(node, context, this_1.convertors) : convertor(node, context); if (converted) { var htmlNodes = Array.isArray(converted) ? converted : [converted]; htmlNodes.forEach(function (htmlNode, index) { if (htmlNode.type === 'openTag' && _this.options.nodeId && index === 0) { if (!htmlNode.attributes) { htmlNode.attributes = {}; } htmlNode.attributes['data-nodeid'] = String(node.id); } _this.renderHTMLNode(htmlNode); }); if (skipped) { walker.resumeAt(node, false); walker.next(); } } }; var this_1 = this; while ((event = walker.next())) { _loop_1(); } this.addNewLine(); return this.buffer.join(''); }; Renderer.prototype.renderHTMLNode = function (node) { switch (node.type) { case 'openTag': case 'closeTag': this.renderElementNode(node); break; case 'text': this.renderTextNode(node); break; case 'html': this.renderRawHtmlNode(node); break; // no-default-case } }; Renderer.prototype.generateOpenTagString = function (node) { var _this = this; var tagName = node.tagName, classNames = node.classNames, attributes = node.attributes; this.buffer.push("<" + tagName); if (classNames && classNames.length > 0) { this.buffer.push(" class=\"" + classNames.join(' ') + "\""); } if (attributes) { Object.keys(attributes).forEach(function (attrName) { var attrValue = attributes[attrName]; _this.buffer.push(" " + attrName + "=\"" + attrValue + "\""); }); } if (node.selfClose) { this.buffer.push(' /'); } this.buffer.push('>'); }; Renderer.prototype.generateCloseTagString = function (_a) { var tagName = _a.tagName; this.buffer.push(""); }; Renderer.prototype.addNewLine = function () { if (this.buffer.length && last(last(this.buffer)) !== '\n') { this.buffer.push('\n'); } }; Renderer.prototype.addOuterNewLine = function (node) { if (node.outerNewLine) { this.addNewLine(); } }; Renderer.prototype.addInnerNewLine = function (node) { if (node.innerNewLine) { this.addNewLine(); } }; Renderer.prototype.renderTextNode = function (node) { this.buffer.push(escapeXml(node.content)); }; Renderer.prototype.renderRawHtmlNode = function (node) { this.addOuterNewLine(node); this.buffer.push(node.content); this.addOuterNewLine(node); }; Renderer.prototype.renderElementNode = function (node) { if (node.type === 'openTag') { this.addOuterNewLine(node); this.generateOpenTagString(node); if (node.selfClose) { this.addOuterNewLine(node); } else { this.addInnerNewLine(node); } } else { this.addInnerNewLine(node); this.generateCloseTagString(node); this.addOuterNewLine(node); } }; return Renderer; }()); /*! @license DOMPurify 2.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.3/LICENSE */ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var hasOwnProperty = Object.hasOwnProperty, setPrototypeOf = Object.setPrototypeOf, isFrozen = Object.isFrozen, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var freeze = Object.freeze, seal = Object.seal, create = Object.create; // eslint-disable-line import/no-mutable-exports var _ref = typeof Reflect !== 'undefined' && Reflect, apply = _ref.apply, construct = _ref.construct; if (!apply) { apply = function apply(fun, thisValue, args) { return fun.apply(thisValue, args); }; } if (!freeze) { freeze = function freeze(x) { return x; }; } if (!seal) { seal = function seal(x) { return x; }; } if (!construct) { construct = function construct(Func, args) { return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))(); }; } var arrayForEach = unapply(Array.prototype.forEach); var arrayPop = unapply(Array.prototype.pop); var arrayPush = unapply(Array.prototype.push); var stringToLowerCase = unapply(String.prototype.toLowerCase); var stringMatch = unapply(String.prototype.match); var stringReplace = unapply(String.prototype.replace); var stringIndexOf = unapply(String.prototype.indexOf); var stringTrim = unapply(String.prototype.trim); var regExpTest = unapply(RegExp.prototype.test); var typeErrorCreate = unconstruct(TypeError); function unapply(func) { return function (thisArg) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } return apply(func, thisArg, args); }; } function unconstruct(func) { return function () { for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } return construct(func, args); }; } /* Add properties to a lookup table */ function addToSet(set, array) { if (setPrototypeOf) { // Make 'in' and truthy checks like Boolean(set.constructor) // independent of any properties defined on Object.prototype. // Prevent prototype setters from intercepting set as a this value. setPrototypeOf(set, null); } var l = array.length; while (l--) { var element = array[l]; if (typeof element === 'string') { var lcElement = stringToLowerCase(element); if (lcElement !== element) { // Config presets (e.g. tags.js, attrs.js) are immutable. if (!isFrozen(array)) { array[l] = lcElement; } element = lcElement; } } set[element] = true; } return set; } /* Shallow clone an object */ function clone(object) { var newObject = create(null); var property = void 0; for (property in object) { if (apply(hasOwnProperty, object, [property])) { newObject[property] = object[property]; } } return newObject; } /* IE10 doesn't support __lookupGetter__ so lets' * simulate it. It also automatically checks * if the prop is function or getter and behaves * accordingly. */ function lookupGetter(object, prop) { while (object !== null) { var desc = getOwnPropertyDescriptor(object, prop); if (desc) { if (desc.get) { return unapply(desc.get); } if (typeof desc.value === 'function') { return unapply(desc.value); } } object = getPrototypeOf(object); } function fallbackValue(element) { console.warn('fallback value for', element); return null; } return fallbackValue; } var html$2 = 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', 'section', 'select', 'shadow', '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']); // SVG var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); // List of SVG elements that are disallowed by default. // We still need to know them so that we can do namespace // checks properly in case one wants to add them to // allow-list. var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'feimage', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']); // Similarly to SVG, we want to know all MathML elements, // even those that we disallow by default. var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); var text = freeze(['#text']); var html$1$1 = 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', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']); var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', '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', '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', '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', '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', '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', 'targetx', 'targety', 'transform', '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']); var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); // eslint-disable-next-line unicorn/better-regex var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm); var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape ); var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex ); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var getGlobal = function getGlobal() { return typeof window === 'undefined' ? null : window; }; /** * Creates a no-op policy for internal use only. * Don't export this function outside this module! * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory. * @param {Document} document The document object (to determine policy name suffix) * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types * are not supported). */ var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) { if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { return null; } // Allow the callers to control the unique policy name // by adding a data-tt-policy-suffix to the script element with the DOMPurify. // Policy creation with duplicate names throws in Trusted Types. var suffix = null; var ATTR_NAME = 'data-tt-policy-suffix'; if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) { suffix = document.currentScript.getAttribute(ATTR_NAME); } var policyName = 'dompurify' + (suffix ? '#' + suffix : ''); try { return trustedTypes.createPolicy(policyName, { createHTML: function createHTML(html$$1) { return html$$1; } }); } catch (_) { // Policy creation failed (most likely another DOMPurify script has // already run). Skip creating the policy, as this will only cause errors // if TT are enforced. console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); return null; } }; function createDOMPurify() { var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); var DOMPurify = function DOMPurify(root) { return createDOMPurify(root); }; /** * Version label, exposed for easier checks * if DOMPurify is up to date or not */ DOMPurify.version = '2.3.3'; /** * Array of elements that DOMPurify removed during sanitation. * Empty if nothing was removed. */ DOMPurify.removed = []; if (!window || !window.document || window.document.nodeType !== 9) { // Not running in a browser, provide a factory function // so that you can pass your own Window DOMPurify.isSupported = false; return DOMPurify; } var originalDocument = window.document; var document = window.document; var DocumentFragment = window.DocumentFragment, HTMLTemplateElement = window.HTMLTemplateElement, Node = window.Node, Element = window.Element, NodeFilter = window.NodeFilter, _window$NamedNodeMap = window.NamedNodeMap, NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, Text = window.Text, Comment = window.Comment, DOMParser = window.DOMParser, trustedTypes = window.trustedTypes; var ElementPrototype = Element.prototype; var cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); var getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a // new document created via createHTMLDocument. As per the spec // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) // a new empty registry is used when creating a template contents owner // document, so we use that as our parent document to ensure nothing // is inherited. if (typeof HTMLTemplateElement === 'function') { var template = document.createElement('template'); if (template.content && template.content.ownerDocument) { document = template.content.ownerDocument; } } var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument); var emptyHTML = trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML('') : ''; var _document = document, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName; var importNode = originalDocument.importNode; var documentMode = {}; try { documentMode = clone(document).documentMode ? document.documentMode : {}; } catch (_) {} var hooks = {}; /** * Expose whether this browser supports running the full DOMPurify. */ DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9; var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR, ERB_EXPR$$1 = ERB_EXPR, DATA_ATTR$$1 = DATA_ATTR, ARIA_ATTR$$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$$1 = ATTR_WHITESPACE; var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI; /** * We consider the elements and attributes below to be safe. Ideally * don't add any new ones but feel free to remove unwanted ones. */ /* allowed element names */ var ALLOWED_TAGS = null; var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html$2), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text))); /* Allowed attribute names */ var ALLOWED_ATTR = null; var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml))); /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ var FORBID_TAGS = null; /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ var FORBID_ATTR = null; /* Decide if ARIA attributes are okay */ var ALLOW_ARIA_ATTR = true; /* Decide if custom data attributes are okay */ var ALLOW_DATA_ATTR = true; /* Decide if unknown protocols are okay */ var ALLOW_UNKNOWN_PROTOCOLS = false; /* Output should be safe for common template engines. * This means, DOMPurify removes data attributes, mustaches and ERB */ var SAFE_FOR_TEMPLATES = false; /* Decide if document with ... should be returned */ var WHOLE_DOCUMENT = false; /* Track whether config is already set on this instance of DOMPurify. */ var SET_CONFIG = false; /* Decide if all elements (e.g. style, script) must be children of * document.body. By default, browsers might move them to document.head */ var FORCE_BODY = false; /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html * string (or a TrustedHTML object if Trusted Types are supported). * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead */ var RETURN_DOM = false; /* Decide if a DOM `DocumentFragment` should be returned, instead of a html * string (or a TrustedHTML object if Trusted Types are supported) */ var RETURN_DOM_FRAGMENT = false; /* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM * `Node` is imported into the current `Document`. If this flag is not enabled the * `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by * DOMPurify. * * This defaults to `true` starting DOMPurify 2.2.0. Note that setting it to `false` * might cause XSS from attacks hidden in closed shadowroots in case the browser * supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/ */ var RETURN_DOM_IMPORT = true; /* Try to return a Trusted Type object instead of a string, return a string in * case Trusted Types are not supported */ var RETURN_TRUSTED_TYPE = false; /* Output should be free from DOM clobbering attacks? */ var SANITIZE_DOM = true; /* Keep element content when removing element? */ var KEEP_CONTENT = true; /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead * of importing it into a new Document and returning a sanitized copy */ var IN_PLACE = false; /* Allow usage of profiles like html, svg and mathMl */ var USE_PROFILES = {}; /* Tags to ignore content of when KEEP_CONTENT is true */ var FORBID_CONTENTS = null; var DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); /* Tags that are safe for data: URIs */ var DATA_URI_TAGS = null; var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); /* Attributes safe for values like "javascript:" */ var URI_SAFE_ATTRIBUTES = null; var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; /* Document namespace */ var NAMESPACE = HTML_NAMESPACE; var IS_EMPTY_INPUT = false; /* Parsing of strict XHTML documents */ var PARSER_MEDIA_TYPE = void 0; var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; var DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; var transformCaseFunc = void 0; /* Keep a reference to config to pass to hooks */ var CONFIG = null; /* Ideally, do not touch anything below this line */ /* ______________________________________________ */ var formElement = document.createElement('form'); /** * _parseConfig * * @param {Object} cfg optional config literal */ // eslint-disable-next-line complexity var _parseConfig = function _parseConfig(cfg) { if (CONFIG && CONFIG === cfg) { return; } /* Shield configuration object from tampering */ if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') { cfg = {}; } /* Shield configuration object from prototype pollution */ cfg = clone(cfg); /* Set configuration parameters */ ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS; ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR; URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES; DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS; FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS) : DEFAULT_FORBID_CONTENTS; FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {}; FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {}; USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false; ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false RETURN_DOM = cfg.RETURN_DOM || false; // Default false RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT !== false; // Default true RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false FORCE_BODY = cfg.FORCE_BODY || false; // Default false SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true IN_PLACE = cfg.IN_PLACE || false; // Default false IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1; NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) { return x; } : stringToLowerCase; if (SAFE_FOR_TEMPLATES) { ALLOW_DATA_ATTR = false; } if (RETURN_DOM_FRAGMENT) { RETURN_DOM = true; } /* Parse profile info */ if (USE_PROFILES) { ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text))); ALLOWED_ATTR = []; if (USE_PROFILES.html === true) { addToSet(ALLOWED_TAGS, html$2); addToSet(ALLOWED_ATTR, html$1$1); } if (USE_PROFILES.svg === true) { addToSet(ALLOWED_TAGS, svg); addToSet(ALLOWED_ATTR, svg$1); addToSet(ALLOWED_ATTR, xml); } if (USE_PROFILES.svgFilters === true) { addToSet(ALLOWED_TAGS, svgFilters); addToSet(ALLOWED_ATTR, svg$1); addToSet(ALLOWED_ATTR, xml); } if (USE_PROFILES.mathMl === true) { addToSet(ALLOWED_TAGS, mathMl); addToSet(ALLOWED_ATTR, mathMl$1); addToSet(ALLOWED_ATTR, xml); } } /* Merge configuration parameters */ if (cfg.ADD_TAGS) { if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { ALLOWED_TAGS = clone(ALLOWED_TAGS); } addToSet(ALLOWED_TAGS, cfg.ADD_TAGS); } if (cfg.ADD_ATTR) { if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { ALLOWED_ATTR = clone(ALLOWED_ATTR); } addToSet(ALLOWED_ATTR, cfg.ADD_ATTR); } if (cfg.ADD_URI_SAFE_ATTR) { addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR); } if (cfg.FORBID_CONTENTS) { if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { FORBID_CONTENTS = clone(FORBID_CONTENTS); } addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS); } /* Add #text in case KEEP_CONTENT is set to true */ if (KEEP_CONTENT) { ALLOWED_TAGS['#text'] = true; } /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ if (WHOLE_DOCUMENT) { addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); } /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ if (ALLOWED_TAGS.table) { addToSet(ALLOWED_TAGS, ['tbody']); delete FORBID_TAGS.tbody; } // Prevent further manipulation of configuration. // Not available in IE8, Safari 5, etc. if (freeze) { freeze(cfg); } CONFIG = cfg; }; var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); /* Keep track of all possible SVG and MathML tags * so that we can perform the namespace checks * correctly. */ var ALL_SVG_TAGS = addToSet({}, svg); addToSet(ALL_SVG_TAGS, svgFilters); addToSet(ALL_SVG_TAGS, svgDisallowed); var ALL_MATHML_TAGS = addToSet({}, mathMl); addToSet(ALL_MATHML_TAGS, mathMlDisallowed); /** * * * @param {Element} element a DOM element whose namespace is being checked * @returns {boolean} Return false if the element has a * namespace that a spec-compliant parser would never * return. Return true otherwise. */ var _checkValidNamespace = function _checkValidNamespace(element) { var parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode // can be null. We just simulate parent in this case. if (!parent || !parent.tagName) { parent = { namespaceURI: HTML_NAMESPACE, tagName: 'template' }; } var tagName = stringToLowerCase(element.tagName); var parentTagName = stringToLowerCase(parent.tagName); if (element.namespaceURI === SVG_NAMESPACE) { // The only way to switch from HTML namespace to SVG // is via . If it happens via any other tag, then // it should be killed. if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === 'svg'; } // The only way to switch from MathML to SVG is via // svg if parent is either or MathML // text integration points. if (parent.namespaceURI === MATHML_NAMESPACE) { return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); } // We only allow elements that are defined in SVG // spec. All others are disallowed in SVG namespace. return Boolean(ALL_SVG_TAGS[tagName]); } if (element.namespaceURI === MATHML_NAMESPACE) { // The only way to switch from HTML namespace to MathML // is via . If it happens via any other tag, then // it should be killed. if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === 'math'; } // The only way to switch from SVG to MathML is via // and HTML integration points if (parent.namespaceURI === SVG_NAMESPACE) { return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; } // We only allow elements that are defined in MathML // spec. All others are disallowed in MathML namespace. return Boolean(ALL_MATHML_TAGS[tagName]); } if (element.namespaceURI === HTML_NAMESPACE) { // The only way to switch from SVG to HTML is via // HTML integration points, and from MathML to HTML // is via MathML text integration points if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { return false; } if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { return false; } // Certain elements are allowed in both SVG and HTML // namespace. We need to specify them explicitly // so that they don't get erronously deleted from // HTML namespace. var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']); // We disallow tags that are specific for MathML // or SVG and should never appear in HTML namespace return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]); } // The code should never reach this place (this means // that the element somehow got namespace that is not // HTML, SVG or MathML). Return false just in case. return false; }; /** * _forceRemove * * @param {Node} node a DOM node */ var _forceRemove = function _forceRemove(node) { arrayPush(DOMPurify.removed, { element: node }); try { // eslint-disable-next-line unicorn/prefer-dom-node-remove node.parentNode.removeChild(node); } catch (_) { try { node.outerHTML = emptyHTML; } catch (_) { node.remove(); } } }; /** * _removeAttribute * * @param {String} name an Attribute name * @param {Node} node a DOM node */ var _removeAttribute = function _removeAttribute(name, node) { try { arrayPush(DOMPurify.removed, { attribute: node.getAttributeNode(name), from: node }); } catch (_) { arrayPush(DOMPurify.removed, { attribute: null, from: node }); } node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes if (name === 'is' && !ALLOWED_ATTR[name]) { if (RETURN_DOM || RETURN_DOM_FRAGMENT) { try { _forceRemove(node); } catch (_) {} } else { try { node.setAttribute(name, ''); } catch (_) {} } } }; /** * _initDocument * * @param {String} dirty a string of dirty markup * @return {Document} a DOM, filled with the dirty markup */ var _initDocument = function _initDocument(dirty) { /* Create a HTML document */ var doc = void 0; var leadingWhitespace = void 0; if (FORCE_BODY) { dirty = '' + dirty; } else { /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ var matches = stringMatch(dirty, /^[\r\n\t ]+/); leadingWhitespace = matches && matches[0]; } if (PARSER_MEDIA_TYPE === 'application/xhtml+xml') { // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict) dirty = '' + dirty + ''; } var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; /* * Use the DOMParser API by default, fallback later if needs be * DOMParser not work for svg when has multiple root element. */ if (NAMESPACE === HTML_NAMESPACE) { try { doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); } catch (_) {} } /* Use createHTMLDocument in case DOMParser is not available */ if (!doc || !doc.documentElement) { doc = implementation.createDocument(NAMESPACE, 'template', null); try { doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload; } catch (_) { // Syntax error if dirtyPayload is invalid xml } } var body = doc.body || doc.documentElement; if (dirty && leadingWhitespace) { body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null); } /* Work on whole document or just its body */ if (NAMESPACE === HTML_NAMESPACE) { return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; } return WHOLE_DOCUMENT ? doc.documentElement : body; }; /** * _createIterator * * @param {Document} root document/fragment to create iterator for * @return {Iterator} iterator instance */ var _createIterator = function _createIterator(root) { return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false); }; /** * _isClobbered * * @param {Node} elm element to check for clobbering attacks * @return {Boolean} true if clobbered, false if safe */ var _isClobbered = function _isClobbered(elm) { if (elm instanceof Text || elm instanceof Comment) { return false; } if (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function') { return true; } return false; }; /** * _isNode * * @param {Node} obj object to check whether it's a DOM node * @return {Boolean} true is object is a DOM node */ var _isNode = function _isNode(object) { return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'; }; /** * _executeHook * Execute user configurable hooks * * @param {String} entryPoint Name of the hook's entry point * @param {Node} currentNode node to work on with the hook * @param {Object} data additional hook parameters */ var _executeHook = function _executeHook(entryPoint, currentNode, data) { if (!hooks[entryPoint]) { return; } arrayForEach(hooks[entryPoint], function (hook) { hook.call(DOMPurify, currentNode, data, CONFIG); }); }; /** * _sanitizeElements * * @protect nodeName * @protect textContent * @protect removeChild * * @param {Node} currentNode to check for permission to exist * @return {Boolean} true if node was killed, false if left alive */ var _sanitizeElements = function _sanitizeElements(currentNode) { var content = void 0; /* Execute a hook if present */ _executeHook('beforeSanitizeElements', currentNode, null); /* Check if element is clobbered or can clobber */ if (_isClobbered(currentNode)) { _forceRemove(currentNode); return true; } /* Check if tagname contains Unicode */ if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) { _forceRemove(currentNode); return true; } /* Now let's check the element's type and name */ var tagName = transformCaseFunc(currentNode.nodeName); /* Execute a hook if present */ _executeHook('uponSanitizeElement', currentNode, { tagName: tagName, allowedTags: ALLOWED_TAGS }); /* Detect mXSS attempts abusing namespace confusion */ if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { _forceRemove(currentNode); return true; } /* Mitigate a problem with templates inside select */ if (tagName === 'select' && regExpTest(/