var codePoints = toCodePoints(str); var length = codePoints.length; var index = 0; var lastEnd = 0; var classTypes = codePoints.map(codePointToClass); return { next: function() { if (index >= length) { return { done: true, value: null }; } var graphemeBreak = BREAK_NOT_ALLOWED; while (index < length && (graphemeBreak = _graphemeBreakAtIndex(codePoints, classTypes, ++index)) === BREAK_NOT_ALLOWED) { } if (graphemeBreak !== BREAK_NOT_ALLOWED || index === length) { var value = fromCodePoint.apply(null, codePoints.slice(lastEnd, index)); lastEnd = index; return { value, done: false }; } return { done: true, value: null }; } }; }; var splitGraphemes = function(str) { var breaker = GraphemeBreaker(str); var graphemes = []; var bk; while (!(bk = breaker.next()).done) { if (bk.value) { graphemes.push(bk.value.slice()); } } return graphemes; }; var testRangeBounds = function(document2) { var TEST_HEIGHT = 123; if (document2.createRange) { var range = document2.createRange(); if (range.getBoundingClientRect) { var testElement = document2.createElement("boundtest"); testElement.style.height = TEST_HEIGHT + "px"; testElement.style.display = "block"; document2.body.appendChild(testElement); range.selectNode(testElement); var rangeBounds = range.getBoundingClientRect(); var rangeHeight = Math.round(rangeBounds.height); document2.body.removeChild(testElement); if (rangeHeight === TEST_HEIGHT) { return true; } } } return false; }; var testIOSLineBreak = function(document2) { var testElement = document2.createElement("boundtest"); testElement.style.width = "50px"; testElement.style.display = "block"; testElement.style.fontSize = "12px"; testElement.style.letterSpacing = "0px"; testElement.style.wordSpacing = "0px"; document2.body.appendChild(testElement); var range = document2.createRange(); testElement.innerHTML = typeof "".repeat === "function" ? "👨".repeat(10) : ""; var node = testElement.firstChild; var textList = toCodePoints$1(node.data).map(function(i) { return fromCodePoint$1(i); }); var offset = 0; var prev = {}; var supports = textList.every(function(text, i) { range.setStart(node, offset); range.setEnd(node, offset + text.length); var rect = range.getBoundingClientRect(); offset += text.length; var boundAhead = rect.x > prev.x || rect.y > prev.y; prev = rect; if (i === 0) { return true; } return boundAhead; }); document2.body.removeChild(testElement); return supports; }; var testCORS = function() { return typeof new Image().crossOrigin !== "undefined"; }; var testResponseType = function() { return typeof new XMLHttpRequest().responseType === "string"; }; var testSVG = function(document2) { var img = new Image(); var canvas = document2.createElement("canvas"); var ctx = canvas.getContext("2d"); if (!ctx) { return false; } img.src = "data:image/svg+xml,"; try { ctx.drawImage(img, 0, 0); canvas.toDataURL(); } catch (e2) { return false; } return true; }; var isGreenPixel = function(data) { return data[0] === 0 && data[1] === 255 && data[2] === 0 && data[3] === 255; }; var testForeignObject = function(document2) { var canvas = document2.createElement("canvas"); var size = 100; canvas.width = size; canvas.height = size; var ctx = canvas.getContext("2d"); if (!ctx) { return Promise.reject(false); } ctx.fillStyle = "rgb(0, 255, 0)"; ctx.fillRect(0, 0, size, size); var img = new Image(); var greenImageSrc = canvas.toDataURL(); img.src = greenImageSrc; var svg = createForeignObjectSVG(size, size, 0, 0, img); ctx.fillStyle = "red"; ctx.fillRect(0, 0, size, size); return loadSerializedSVG$1(svg).then(function(img2) { ctx.drawImage(img2, 0, 0); var data = ctx.getImageData(0, 0, size, size).data; ctx.fillStyle = "red"; ctx.fillRect(0, 0, size, size); var node = document2.createElement("div"); node.style.backgroundImage = "url(" + greenImageSrc + ")"; node.style.height = size + "px"; return isGreenPixel(data) ? loadSerializedSVG$1(createForeignObjectSVG(size, size, 0, 0, node)) : Promise.reject(false); }).then(function(img2) { ctx.drawImage(img2, 0, 0); return isGreenPixel(ctx.getImageData(0, 0, size, size).data); }).catch(function() { return false; }); }; var createForeignObjectSVG = function(width, height, x, y, node) { var xmlns = "http://www.w3.org/2000/svg"; var svg = document.createElementNS(xmlns, "svg"); var foreignObject = document.createElementNS(xmlns, "foreignObject"); svg.setAttributeNS(null, "width", width.toString()); svg.setAttributeNS(null, "height", height.toString()); foreignObject.setAttributeNS(null, "width", "100%"); foreignObject.setAttributeNS(null, "height", "100%"); foreignObject.setAttributeNS(null, "x", x.toString()); foreignObject.setAttributeNS(null, "y", y.toString()); foreignObject.setAttributeNS(null, "externalResourcesRequired", "true"); svg.appendChild(foreignObject); foreignObject.appendChild(node); return svg; }; var loadSerializedSVG$1 = function(svg) { return new Promise(function(resolve, reject) { var img = new Image(); img.onload = function() { return resolve(img); }; img.onerror = reject; img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg)); }); }; var FEATURES = { get SUPPORT_RANGE_BOUNDS() { var value = testRangeBounds(document); Object.defineProperty(FEATURES, "SUPPORT_RANGE_BOUNDS", { value }); return value; }, get SUPPORT_WORD_BREAKING() { var value = FEATURES.SUPPORT_RANGE_BOUNDS && testIOSLineBreak(document); Object.defineProperty(FEATURES, "SUPPORT_WORD_BREAKING", { value }); return value; }, get SUPPORT_SVG_DRAWING() { var value = testSVG(document); Object.defineProperty(FEATURES, "SUPPORT_SVG_DRAWING", { value }); return value; }, get SUPPORT_FOREIGNOBJECT_DRAWING() { var value = typeof Array.from === "function" && typeof window.fetch === "function" ? testForeignObject(document) : Promise.resolve(false); Object.defineProperty(FEATURES, "SUPPORT_FOREIGNOBJECT_DRAWING", { value }); return value; }, get SUPPORT_CORS_IMAGES() { var value = testCORS(); Object.defineProperty(FEATURES, "SUPPORT_CORS_IMAGES", { value }); return value; }, get SUPPORT_RESPONSE_TYPE() { var value = testResponseType(); Object.defineProperty(FEATURES, "SUPPORT_RESPONSE_TYPE", { value }); return value; }, get SUPPORT_CORS_XHR() { var value = "withCredentials" in new XMLHttpRequest(); Object.defineProperty(FEATURES, "SUPPORT_CORS_XHR", { value }); return value; }, get SUPPORT_NATIVE_TEXT_SEGMENTATION() { var value = !!(typeof Intl !== "undefined" && Intl.Segmenter); Object.defineProperty(FEATURES, "SUPPORT_NATIVE_TEXT_SEGMENTATION", { value }); return value; } }; var TextBounds = ( /** @class */ /* @__PURE__ */ function() { function TextBounds2(text, bounds) { this.text = text; this.bounds = bounds; } return TextBounds2; }() ); var parseTextBounds = function(context, value, styles, node) { var textList = breakText(value, styles); var textBounds = []; var offset = 0; textList.forEach(function(text) { if (styles.textDecorationLine.length || text.trim().length > 0) { if (FEATURES.SUPPORT_RANGE_BOUNDS) { var clientRects = createRange(node, offset, text.length).getClientRects(); if (clientRects.length > 1) { var subSegments = segmentGraphemes(text); var subOffset_1 = 0; subSegments.forEach(function(subSegment) { textBounds.push(new TextBounds(subSegment, Bounds.fromDOMRectList(context, createRange(node, subOffset_1 + offset, subSegment.length).getClientRects()))); subOffset_1 += subSegment.length; }); } else { textBounds.push(new TextBounds(text, Bounds.fromDOMRectList(context, clientRects))); } } else { var replacementNode = node.splitText(text.length); textBounds.push(new TextBounds(text, getWrapperBounds(context, node))); node = replacementNode; } } else if (!FEATURES.SUPPORT_RANGE_BOUNDS) { node = node.splitText(text.length); } offset += text.length; }); return textBounds; }; var getWrapperBounds = function(context, node) { var ownerDocument = node.ownerDocument; if (ownerDocument) { var wrapper = ownerDocument.createElement("html2canvaswrapper"); wrapper.appendChild(node.cloneNode(true)); var parentNode = node.parentNode; if (parentNode) { parentNode.replaceChild(wrapper, node); var bounds = parseBounds(context, wrapper); if (wrapper.firstChild) { parentNode.replaceChild(wrapper.firstChild, wrapper); } return bounds; } } return Bounds.EMPTY; }; var createRange = function(node, offset, length) { var ownerDocument = node.ownerDocument; if (!ownerDocument) { throw new Error("Node has no owner document"); } var range = ownerDocument.createRange(); range.setStart(node, offset); range.setEnd(node, offset + length); return range; }; var segmentGraphemes = function(value) { if (FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) { var segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" }); return Array.from(segmenter.segment(value)).map(function(segment) { return segment.segment; }); } return splitGraphemes(value); }; var segmentWords = function(value, styles) { if (FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) { var segmenter = new Intl.Segmenter(void 0, { granularity: "word" }); return Array.from(segmenter.segment(value)).map(function(segment) { return segment.segment; }); } return breakWords(value, styles); }; var breakText = function(value, styles) { return styles.letterSpacing !== 0 ? segmentGraphemes(value) : segmentWords(value, styles); }; var wordSeparators = [32, 160, 4961, 65792, 65793, 4153, 4241]; var breakWords = function(str, styles) { var breaker = LineBreaker(str, { lineBreak: styles.lineBreak, wordBreak: styles.overflowWrap === "break-word" ? "break-word" : styles.wordBreak }); var words = []; var bk; var _loop_1 = function() { if (bk.value) { var value = bk.value.slice(); var codePoints = toCodePoints$1(value); var word_1 = ""; codePoints.forEach(function(codePoint) { if (wordSeparators.indexOf(codePoint) === -1) { word_1 += fromCodePoint$1(codePoint); } else { if (word_1.length) { words.push(word_1); } words.push(fromCodePoint$1(codePoint)); word_1 = ""; } }); if (word_1.length) { words.push(word_1); } } }; while (!(bk = breaker.next()).done) { _loop_1(); } return words; }; var TextContainer = ( /** @class */ /* @__PURE__ */ function() { function TextContainer2(context, node, styles) { this.text = transform(node.data, styles.textTransform); this.textBounds = parseTextBounds(context, this.text, styles, node); } return TextContainer2; }() ); var transform = function(text, transform2) { switch (transform2) { case 1: return text.toLowerCase(); case 3: return text.replace(CAPITALIZE, capitalize); case 2: return text.toUpperCase(); default: return text; } }; var CAPITALIZE = /(^|\s|:|-|\(|\))([a-z])/g; var capitalize = function(m, p1, p2) { if (m.length > 0) { return p1 + p2.toUpperCase(); } return m; }; var ImageElementContainer = ( /** @class */ function(_super) { __extends(ImageElementContainer2, _super); function ImageElementContainer2(context, img) { var _this = _super.call(this, context, img) || this; _this.src = img.currentSrc || img.src; _this.intrinsicWidth = img.naturalWidth; _this.intrinsicHeight = img.naturalHeight; _this.context.cache.addImage(_this.src); return _this; } return ImageElementContainer2; }(ElementContainer) ); var CanvasElementContainer = ( /** @class */ function(_super) { __extends(CanvasElementContainer2, _super); function CanvasElementContainer2(context, canvas) { var _this = _super.call(this, context, canvas) || this; _this.canvas = canvas; _this.intrinsicWidth = canvas.width; _this.intrinsicHeight = canvas.height; return _this; } return CanvasElementContainer2; }(ElementContainer) ); var SVGElementContainer = ( /** @class */ function(_super) { __extends(SVGElementContainer2, _super); function SVGElementContainer2(context, img) { var _this = _super.call(this, context, img) || this; var s = new XMLSerializer(); var bounds = parseBounds(context, img); img.setAttribute("width", bounds.width + "px"); img.setAttribute("height", bounds.height + "px"); _this.svg = "data:image/svg+xml," + encodeURIComponent(s.serializeToString(img)); _this.intrinsicWidth = img.width.baseVal.value; _this.intrinsicHeight = img.height.baseVal.value; _this.context.cache.addImage(_this.svg); return _this; } return SVGElementContainer2; }(ElementContainer) ); var LIElementContainer = ( /** @class */ function(_super) { __extends(LIElementContainer2, _super); function LIElementContainer2(context, element) { var _this = _super.call(this, context, element) || this; _this.value = element.value; return _this; } return LIElementContainer2; }(ElementContainer) ); var OLElementContainer = ( /** @class */ function(_super) { __extends(OLElementContainer2, _super); function OLElementContainer2(context, element) { var _this = _super.call(this, context, element) || this; _this.start = element.start; _this.reversed = typeof element.reversed === "boolean" && element.reversed === true; return _this; } return OLElementContainer2; }(ElementContainer) ); var CHECKBOX_BORDER_RADIUS = [ { type: 15, flags: 0, unit: "px", number: 3 } ]; var RADIO_BORDER_RADIUS = [ { type: 16, flags: 0, number: 50 } ]; var reformatInputBounds = function(bounds) { if (bounds.width > bounds.height) { return new Bounds(bounds.left + (bounds.width - bounds.height) / 2, bounds.top, bounds.height, bounds.height); } else if (bounds.width < bounds.height) { return new Bounds(bounds.left, bounds.top + (bounds.height - bounds.width) / 2, bounds.width, bounds.width); } return bounds; }; var getInputValue = function(node) { var value = node.type === PASSWORD ? new Array(node.value.length + 1).join("•") : node.value; return value.length === 0 ? node.placeholder || "" : value; }; var CHECKBOX = "checkbox"; var RADIO = "radio"; var PASSWORD = "password"; var INPUT_COLOR = 707406591; var InputElementContainer = ( /** @class */ function(_super) { __extends(InputElementContainer2, _super); function InputElementContainer2(context, input) { var _this = _super.call(this, context, input) || this; _this.type = input.type.toLowerCase(); _this.checked = input.checked; _this.value = getInputValue(input); if (_this.type === CHECKBOX || _this.type === RADIO) { _this.styles.backgroundColor = 3739148031; _this.styles.borderTopColor = _this.styles.borderRightColor = _this.styles.borderBottomColor = _this.styles.borderLeftColor = 2779096575; _this.styles.borderTopWidth = _this.styles.borderRightWidth = _this.styles.borderBottomWidth = _this.styles.borderLeftWidth = 1; _this.styles.borderTopStyle = _this.styles.borderRightStyle = _this.styles.borderBottomStyle = _this.styles.borderLeftStyle = 1; _this.styles.backgroundClip = [ 0 /* BORDER_BOX */ ]; _this.styles.backgroundOrigin = [ 0 /* BORDER_BOX */ ]; _this.bounds = reformatInputBounds(_this.bounds); } switch (_this.type) { case CHECKBOX: _this.styles.borderTopRightRadius = _this.styles.borderTopLeftRadius = _this.styles.borderBottomRightRadius = _this.styles.borderBottomLeftRadius = CHECKBOX_BORDER_RADIUS; break; case RADIO: _this.styles.borderTopRightRadius = _this.styles.borderTopLeftRadius = _this.styles.borderBottomRightRadius = _this.styles.borderBottomLeftRadius = RADIO_BORDER_RADIUS; break; } return _this; } return InputElementContainer2; }(ElementContainer) ); var SelectElementContainer = ( /** @class */ function(_super) { __extends(SelectElementContainer2, _super); function SelectElementContainer2(context, element) { var _this = _super.call(this, context, element) || this; var option = element.options[element.selectedIndex || 0]; _this.value = option ? option.text || "" : ""; return _this; } return SelectElementContainer2; }(ElementContainer) ); var TextareaElementContainer = ( /** @class */ function(_super) { __extends(TextareaElementContainer2, _super); function TextareaElementContainer2(context, element) { var _this = _super.call(this, context, element) || this; _this.value = element.value; return _this; } return TextareaElementContainer2; }(ElementContainer) ); var IFrameElementContainer = ( /** @class */ function(_super) { __extends(IFrameElementContainer2, _super); function IFrameElementContainer2(context, iframe) { var _this = _super.call(this, context, iframe) || this; _this.src = iframe.src; _this.width = parseInt(iframe.width, 10) || 0; _this.height = parseInt(iframe.height, 10) || 0; _this.backgroundColor = _this.styles.backgroundColor; try { if (iframe.contentWindow && iframe.contentWindow.document && iframe.contentWindow.document.documentElement) { _this.tree = parseTree(context, iframe.contentWindow.document.documentElement); var documentBackgroundColor = iframe.contentWindow.document.documentElement ? parseColor(context, getComputedStyle(iframe.contentWindow.document.documentElement).backgroundColor) : COLORS.TRANSPARENT; var bodyBackgroundColor = iframe.contentWindow.document.body ? parseColor(context, getComputedStyle(iframe.contentWindow.document.body).backgroundColor) : COLORS.TRANSPARENT; _this.backgroundColor = isTransparent(documentBackgroundColor) ? isTransparent(bodyBackgroundColor) ? _this.styles.backgroundColor : bodyBackgroundColor : documentBackgroundColor; } } catch (e2) { } return _this; } return IFrameElementContainer2; }(ElementContainer) ); var LIST_OWNERS = ["OL", "UL", "MENU"]; var parseNodeTree = function(context, node, parent, root) { for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) { nextNode = childNode.nextSibling; if (isTextNode(childNode) && childNode.data.trim().length > 0) { parent.textNodes.push(new TextContainer(context, childNode, parent.styles)); } else if (isElementNode(childNode)) { if (isSlotElement(childNode) && childNode.assignedNodes) { childNode.assignedNodes().forEach(function(childNode2) { return parseNodeTree(context, childNode2, parent, root); }); } else { var container = createContainer(context, childNode); if (container.styles.isVisible()) { if (createsRealStackingContext(childNode, container, root)) { container.flags |= 4; } else if (createsStackingContext(container.styles)) { container.flags |= 2; } if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) { container.flags |= 8; } parent.elements.push(container); childNode.slot; if (childNode.shadowRoot) { parseNodeTree(context, childNode.shadowRoot, container, root); } else if (!isTextareaElement(childNode) && !isSVGElement(childNode) && !isSelectElement(childNode)) { parseNodeTree(context, childNode, container, root); } } } } } }; var createContainer = function(context, element) { if (isImageElement(element)) { return new ImageElementContainer(context, element); } if (isCanvasElement(element)) { return new CanvasElementContainer(context, element); } if (isSVGElement(element)) { return new SVGElementContainer(context, element); } if (isLIElement(element)) { return new LIElementContainer(context, element); } if (isOLElement(element)) { return new OLElementContainer(context, element); } if (isInputElement(element)) { return new InputElementContainer(context, element); } if (isSelectElement(element)) { return new SelectElementContainer(context, element); } if (isTextareaElement(element)) { return new TextareaElementContainer(context, element); } if (isIFrameElement(element)) { return new IFrameElementContainer(context, element); } return new ElementContainer(context, element); }; var parseTree = function(context, element) { var container = createContainer(context, element); container.flags |= 4; parseNodeTree(context, element, container, container); return container; }; var createsRealStackingContext = function(node, container, root) { return container.styles.isPositionedWithZIndex() || container.styles.opacity < 1 || container.styles.isTransformed() || isBodyElement(node) && root.styles.isTransparent(); }; var createsStackingContext = function(styles) { return styles.isPositioned() || styles.isFloating(); }; var isTextNode = function(node) { return node.nodeType === Node.TEXT_NODE; }; var isElementNode = function(node) { return node.nodeType === Node.ELEMENT_NODE; }; var isHTMLElementNode = function(node) { return isElementNode(node) && typeof node.style !== "undefined" && !isSVGElementNode(node); }; var isSVGElementNode = function(element) { return typeof element.className === "object"; }; var isLIElement = function(node) { return node.tagName === "LI"; }; var isOLElement = function(node) { return node.tagName === "OL"; }; var isInputElement = function(node) { return node.tagName === "INPUT"; }; var isHTMLElement = function(node) { return node.tagName === "HTML"; }; var isSVGElement = function(node) { return node.tagName === "svg"; }; var isBodyElement = function(node) { return node.tagName === "BODY"; }; var isCanvasElement = function(node) { return node.tagName === "CANVAS"; }; var isVideoElement = function(node) { return node.tagName === "VIDEO"; }; var isImageElement = function(node) { return node.tagName === "IMG"; }; var isIFrameElement = function(node) { return node.tagName === "IFRAME"; }; var isStyleElement = function(node) { return node.tagName === "STYLE"; }; var isScriptElement = function(node) { return node.tagName === "SCRIPT"; }; var isTextareaElement = function(node) { return node.tagName === "TEXTAREA"; }; var isSelectElement = function(node) { return node.tagName === "SELECT"; }; var isSlotElement = function(node) { return node.tagName === "SLOT"; }; var isCustomElement = function(node) { return node.tagName.indexOf("-") > 0; }; var CounterState = ( /** @class */ function() { function CounterState2() { this.counters = {}; } CounterState2.prototype.getCounterValue = function(name) { var counter = this.counters[name]; if (counter && counter.length) { return counter[counter.length - 1]; } return 1; }; CounterState2.prototype.getCounterValues = function(name) { var counter = this.counters[name]; return counter ? counter : []; }; CounterState2.prototype.pop = function(counters) { var _this = this; counters.forEach(function(counter) { return _this.counters[counter].pop(); }); }; CounterState2.prototype.parse = function(style) { var _this = this; var counterIncrement2 = style.counterIncrement; var counterReset2 = style.counterReset; var canReset = true; if (counterIncrement2 !== null) { counterIncrement2.forEach(function(entry) { var counter = _this.counters[entry.counter]; if (counter && entry.increment !== 0) { canReset = false; if (!counter.length) { counter.push(1); } counter[Math.max(0, counter.length - 1)] += entry.increment; } }); } var counterNames = []; if (canReset) { counterReset2.forEach(function(entry) { var counter = _this.counters[entry.counter]; counterNames.push(entry.counter); if (!counter) { counter = _this.counters[entry.counter] = []; } counter.push(entry.reset); }); } return counterNames; }; return CounterState2; }() ); var ROMAN_UPPER = { integers: [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1], values: ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"] }; var ARMENIAN = { integers: [ 9e3, 8e3, 7e3, 6e3, 5e3, 4e3, 3e3, 2e3, 1e3, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ], values: [ "Ք", "Փ", "Ւ", "Ց", "Ր", "Տ", "Վ", "Ս", "Ռ", "Ջ", "Պ", "Չ", "Ո", "Շ", "Ն", "Յ", "Մ", "Ճ", "Ղ", "Ձ", "Հ", "Կ", "Ծ", "Խ", "Լ", "Ի", "Ժ", "Թ", "Ը", "Է", "Զ", "Ե", "Դ", "Գ", "Բ", "Ա" ] }; var HEBREW = { integers: [ 1e4, 9e3, 8e3, 7e3, 6e3, 5e3, 4e3, 3e3, 2e3, 1e3, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 19, 18, 17, 16, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ], values: [ "י׳", "ט׳", "ח׳", "ז׳", "ו׳", "ה׳", "ד׳", "ג׳", "ב׳", "א׳", "ת", "ש", "ר", "ק", "צ", "פ", "ע", "ס", "נ", "מ", "ל", "כ", "יט", "יח", "יז", "טז", "טו", "י", "ט", "ח", "ז", "ו", "ה", "ד", "ג", "ב", "א" ] }; var GEORGIAN = { integers: [ 1e4, 9e3, 8e3, 7e3, 6e3, 5e3, 4e3, 3e3, 2e3, 1e3, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ], values: [ "ჵ", "ჰ", "ჯ", "ჴ", "ხ", "ჭ", "წ", "ძ", "ც", "ჩ", "შ", "ყ", "ღ", "ქ", "ფ", "ჳ", "ტ", "ს", "რ", "ჟ", "პ", "ო", "ჲ", "ნ", "მ", "ლ", "კ", "ი", "თ", "ჱ", "ზ", "ვ", "ე", "დ", "გ", "ბ", "ა" ] }; var createAdditiveCounter = function(value, min, max, symbols, fallback, suffix) { if (value < min || value > max) { return createCounterText(value, fallback, suffix.length > 0); } return symbols.integers.reduce(function(string, integer, index) { while (value >= integer) { value -= integer; string += symbols.values[index]; } return string; }, "") + suffix; }; var createCounterStyleWithSymbolResolver = function(value, codePointRangeLength, isNumeric, resolver) { var string = ""; do { if (!isNumeric) { value--; } string = resolver(value) + string; value /= codePointRangeLength; } while (value * codePointRangeLength >= codePointRangeLength); return string; }; var createCounterStyleFromRange = function(value, codePointRangeStart, codePointRangeEnd, isNumeric, suffix) { var codePointRangeLength = codePointRangeEnd - codePointRangeStart + 1; return (value < 0 ? "-" : "") + (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, isNumeric, function(codePoint) { return fromCodePoint$1(Math.floor(codePoint % codePointRangeLength) + codePointRangeStart); }) + suffix); }; var createCounterStyleFromSymbols = function(value, symbols, suffix) { if (suffix === void 0) { suffix = ". "; } var codePointRangeLength = symbols.length; return createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, false, function(codePoint) { return symbols[Math.floor(codePoint % codePointRangeLength)]; }) + suffix; }; var CJK_ZEROS = 1 << 0; var CJK_TEN_COEFFICIENTS = 1 << 1; var CJK_TEN_HIGH_COEFFICIENTS = 1 << 2; var CJK_HUNDRED_COEFFICIENTS = 1 << 3; var createCJKCounter = function(value, numbers, multipliers, negativeSign, suffix, flags) { if (value < -9999 || value > 9999) { return createCounterText(value, 4, suffix.length > 0); } var tmp = Math.abs(value); var string = suffix; if (tmp === 0) { return numbers[0] + string; } for (var digit = 0; tmp > 0 && digit <= 4; digit++) { var coefficient = tmp % 10; if (coefficient === 0 && contains(flags, CJK_ZEROS) && string !== "") { string = numbers[coefficient] + string; } else if (coefficient > 1 || coefficient === 1 && digit === 0 || coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_COEFFICIENTS) || coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_HIGH_COEFFICIENTS) && value > 100 || coefficient === 1 && digit > 1 && contains(flags, CJK_HUNDRED_COEFFICIENTS)) { string = numbers[coefficient] + (digit > 0 ? multipliers[digit - 1] : "") + string; } else if (coefficient === 1 && digit > 0) { string = multipliers[digit - 1] + string; } tmp = Math.floor(tmp / 10); } return (value < 0 ? negativeSign : "") + string; }; var CHINESE_INFORMAL_MULTIPLIERS = "十百千萬"; var CHINESE_FORMAL_MULTIPLIERS = "拾佰仟萬"; var JAPANESE_NEGATIVE = "マイナス"; var KOREAN_NEGATIVE = "마이너스"; var createCounterText = function(value, type, appendSuffix) { var defaultSuffix = appendSuffix ? ". " : ""; var cjkSuffix = appendSuffix ? "、" : ""; var koreanSuffix = appendSuffix ? ", " : ""; var spaceSuffix = appendSuffix ? " " : ""; switch (type) { case 0: return "•" + spaceSuffix; case 1: return "◦" + spaceSuffix; case 2: return "◾" + spaceSuffix; case 5: var string = createCounterStyleFromRange(value, 48, 57, true, defaultSuffix); return string.length < 4 ? "0" + string : string; case 4: return createCounterStyleFromSymbols(value, "〇一二三四五六七八九", cjkSuffix); case 6: return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3, defaultSuffix).toLowerCase(); case 7: return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3, defaultSuffix); case 8: return createCounterStyleFromRange(value, 945, 969, false, defaultSuffix); case 9: return createCounterStyleFromRange(value, 97, 122, false, defaultSuffix); case 10: return createCounterStyleFromRange(value, 65, 90, false, defaultSuffix); case 11: return createCounterStyleFromRange(value, 1632, 1641, true, defaultSuffix); case 12: case 49: return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3, defaultSuffix); case 35: return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3, defaultSuffix).toLowerCase(); case 13: return createCounterStyleFromRange(value, 2534, 2543, true, defaultSuffix); case 14: case 30: return createCounterStyleFromRange(value, 6112, 6121, true, defaultSuffix); case 15: return createCounterStyleFromSymbols(value, "子丑寅卯辰巳午未申酉戌亥", cjkSuffix); case 16: return createCounterStyleFromSymbols(value, "甲乙丙丁戊己庚辛壬癸", cjkSuffix); case 17: case 48: return createCJKCounter(value, "零一二三四五六七八九", CHINESE_INFORMAL_MULTIPLIERS, "負", cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS); case 47: return createCJKCounter(value, "零壹貳參肆伍陸柒捌玖", CHINESE_FORMAL_MULTIPLIERS, "負", cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS); case 42: return createCJKCounter(value, "零一二三四五六七八九", CHINESE_INFORMAL_MULTIPLIERS, "负", cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS); case 41: return createCJKCounter(value, "零壹贰叁肆伍陆柒捌玖", CHINESE_FORMAL_MULTIPLIERS, "负", cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS); case 26: return createCJKCounter(value, "〇一二三四五六七八九", "十百千万", JAPANESE_NEGATIVE, cjkSuffix, 0); case 25: return createCJKCounter(value, "零壱弐参四伍六七八九", "拾百千万", JAPANESE_NEGATIVE, cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS); case 31: return createCJKCounter(value, "영일이삼사오육칠팔구", "십백천만", KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS); case 33: return createCJKCounter(value, "零一二三四五六七八九", "十百千萬", KOREAN_NEGATIVE, koreanSuffix, 0); case 32: return createCJKCounter(value, "零壹貳參四五六七八九", "拾百千", KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS); case 18: return createCounterStyleFromRange(value, 2406, 2415, true, defaultSuffix); case 20: return createAdditiveCounter(value, 1, 19999, GEORGIAN, 3, defaultSuffix); case 21: return createCounterStyleFromRange(value, 2790, 2799, true, defaultSuffix); case 22: return createCounterStyleFromRange(value, 2662, 2671, true, defaultSuffix); case 22: return createAdditiveCounter(value, 1, 10999, HEBREW, 3, defaultSuffix); case 23: return createCounterStyleFromSymbols(value, "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん"); case 24: return createCounterStyleFromSymbols(value, "いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす"); case 27: return createCounterStyleFromRange(value, 3302, 3311, true, defaultSuffix); case 28: return createCounterStyleFromSymbols(value, "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン", cjkSuffix); case 29: return createCounterStyleFromSymbols(value, "イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス", cjkSuffix); case 34: return createCounterStyleFromRange(value, 3792, 3801, true, defaultSuffix); case 37: return createCounterStyleFromRange(value, 6160, 6169, true, defaultSuffix); case 38: return createCounterStyleFromRange(value, 4160, 4169, true, defaultSuffix); case 39: return createCounterStyleFromRange(value, 2918, 2927, true, defaultSuffix); case 40: return createCounterStyleFromRange(value, 1776, 1785, true, defaultSuffix); case 43: return createCounterStyleFromRange(value, 3046, 3055, true, defaultSuffix); case 44: return createCounterStyleFromRange(value, 3174, 3183, true, defaultSuffix); case 45: return createCounterStyleFromRange(value, 3664, 3673, true, defaultSuffix); case 46: return createCounterStyleFromRange(value, 3872, 3881, true, defaultSuffix); case 3: default: return createCounterStyleFromRange(value, 48, 57, true, defaultSuffix); } }; var IGNORE_ATTRIBUTE = "data-html2canvas-ignore"; var DocumentCloner = ( /** @class */ function() { function DocumentCloner2(context, element, options) { this.context = context; this.options = options; this.scrolledElements = []; this.referenceElement = element; this.counters = new CounterState(); this.quoteDepth = 0; if (!element.ownerDocument) { throw new Error("Cloned element does not have an owner document"); } this.documentElement = this.cloneNode(element.ownerDocument.documentElement, false); } DocumentCloner2.prototype.toIFrame = function(ownerDocument, windowSize) { var _this = this; var iframe = createIFrameContainer(ownerDocument, windowSize); if (!iframe.contentWindow) { return Promise.reject("Unable to find iframe window"); } var scrollX = ownerDocument.defaultView.pageXOffset; var scrollY = ownerDocument.defaultView.pageYOffset; var cloneWindow = iframe.contentWindow; var documentClone = cloneWindow.document; var iframeLoad = iframeLoader(iframe).then(function() { return __awaiter(_this, void 0, void 0, function() { var onclone, referenceElement; return __generator(this, function(_a) { switch (_a.label) { case 0: this.scrolledElements.forEach(restoreNodeScroll); if (cloneWindow) { cloneWindow.scrollTo(windowSize.left, windowSize.top); if (/(iPad|iPhone|iPod)/g.test(navigator.userAgent) && (cloneWindow.scrollY !== windowSize.top || cloneWindow.scrollX !== windowSize.left)) { this.context.logger.warn("Unable to restore scroll position for cloned document"); this.context.windowBounds = this.context.windowBounds.add(cloneWindow.scrollX - windowSize.left, cloneWindow.scrollY - windowSize.top, 0, 0); } } onclone = this.options.onclone; referenceElement = this.clonedReferenceElement; if (typeof referenceElement === "undefined") { return [2, Promise.reject("Error finding the " + this.referenceElement.nodeName + " in the cloned document")]; } if (!(documentClone.fonts && documentClone.fonts.ready)) return [3, 2]; return [4, documentClone.fonts.ready]; case 1: _a.sent(); _a.label = 2; case 2: if (!/(AppleWebKit)/g.test(navigator.userAgent)) return [3, 4]; return [4, imagesReady(documentClone)]; case 3: _a.sent(); _a.label = 4; case 4: if (typeof onclone === "function") { return [2, Promise.resolve().then(function() { return onclone(documentClone, referenceElement); }).then(function() { return iframe; })]; } return [2, iframe]; } }); }); }); documentClone.open(); documentClone.write(serializeDoctype(document.doctype) + ""); restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY); documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement); documentClone.close(); return iframeLoad; }; DocumentCloner2.prototype.createElementClone = function(node) { if (isDebugging( node, 2 /* CLONE */ )) { debugger; } if (isCanvasElement(node)) { return this.createCanvasClone(node); } if (isVideoElement(node)) { return this.createVideoClone(node); } if (isStyleElement(node)) { return this.createStyleClone(node); } var clone = node.cloneNode(false); if (isImageElement(clone)) { if (isImageElement(node) && node.currentSrc && node.currentSrc !== node.src) { clone.src = node.currentSrc; clone.srcset = ""; } if (clone.loading === "lazy") { clone.loading = "eager"; } } if (isCustomElement(clone)) { return this.createCustomElementClone(clone); } return clone; }; DocumentCloner2.prototype.createCustomElementClone = function(node) { var clone = document.createElement("html2canvascustomelement"); copyCSSStyles(node.style, clone); return clone; }; DocumentCloner2.prototype.createStyleClone = function(node) { try { var sheet = node.sheet; if (sheet && sheet.cssRules) { var css = [].slice.call(sheet.cssRules, 0).reduce(function(css2, rule) { if (rule && typeof rule.cssText === "string") { return css2 + rule.cssText; } return css2; }, ""); var style = node.cloneNode(false); style.textContent = css; return style; } } catch (e2) { this.context.logger.error("Unable to access cssRules property", e2); if (e2.name !== "SecurityError") { throw e2; } } return node.cloneNode(false); }; DocumentCloner2.prototype.createCanvasClone = function(canvas) { var _a; if (this.options.inlineImages && canvas.ownerDocument) { var img = canvas.ownerDocument.createElement("img"); try { img.src = canvas.toDataURL(); return img; } catch (e2) { this.context.logger.info("Unable to inline canvas contents, canvas is tainted", canvas); } } var clonedCanvas = canvas.cloneNode(false); try { clonedCanvas.width = canvas.width; clonedCanvas.height = canvas.height; var ctx = canvas.getContext("2d"); var clonedCtx = clonedCanvas.getContext("2d"); if (clonedCtx) { if (!this.options.allowTaint && ctx) { clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0); } else { var gl = (_a = canvas.getContext("webgl2")) !== null && _a !== void 0 ? _a : canvas.getContext("webgl"); if (gl) { var attribs = gl.getContextAttributes(); if ((attribs === null || attribs === void 0 ? void 0 : attribs.preserveDrawingBuffer) === false) { this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false", canvas); } } clonedCtx.drawImage(canvas, 0, 0); } } return clonedCanvas; } catch (e2) { this.context.logger.info("Unable to clone canvas as it is tainted", canvas); } return clonedCanvas; }; DocumentCloner2.prototype.createVideoClone = function(video) { var canvas = video.ownerDocument.createElement("canvas"); canvas.width = video.offsetWidth; canvas.height = video.offsetHeight; var ctx = canvas.getContext("2d"); try { if (ctx) { ctx.drawImage(video, 0, 0, canvas.width, canvas.height); if (!this.options.allowTaint) { ctx.getImageData(0, 0, canvas.width, canvas.height); } } return canvas; } catch (e2) { this.context.logger.info("Unable to clone video as it is tainted", video); } var blankCanvas = video.ownerDocument.createElement("canvas"); blankCanvas.width = video.offsetWidth; blankCanvas.height = video.offsetHeight; return blankCanvas; }; DocumentCloner2.prototype.appendChildNode = function(clone, child, copyStyles) { if (!isElementNode(child) || !isScriptElement(child) && !child.hasAttribute(IGNORE_ATTRIBUTE) && (typeof this.options.ignoreElements !== "function" || !this.options.ignoreElements(child))) { if (!this.options.copyStyles || !isElementNode(child) || !isStyleElement(child)) { clone.appendChild(this.cloneNode(child, copyStyles)); } } }; DocumentCloner2.prototype.cloneChildNodes = function(node, clone, copyStyles) { var _this = this; for (var child = node.shadowRoot ? node.shadowRoot.firstChild : node.firstChild; child; child = child.nextSibling) { if (isElementNode(child) && isSlotElement(child) && typeof child.assignedNodes === "function") { var assignedNodes = child.assignedNodes(); if (assignedNodes.length) { assignedNodes.forEach(function(assignedNode) { return _this.appendChildNode(clone, assignedNode, copyStyles); }); } } else { this.appendChildNode(clone, child, copyStyles); } } }; DocumentCloner2.prototype.cloneNode = function(node, copyStyles) { if (isTextNode(node)) { return document.createTextNode(node.data); } if (!node.ownerDocument) { return node.cloneNode(false); } var window2 = node.ownerDocument.defaultView; if (window2 && isElementNode(node) && (isHTMLElementNode(node) || isSVGElementNode(node))) { var clone = this.createElementClone(node); clone.style.transitionProperty = "none"; var style = window2.getComputedStyle(node); var styleBefore = window2.getComputedStyle(node, ":before"); var styleAfter = window2.getComputedStyle(node, ":after"); if (this.referenceElement === node && isHTMLElementNode(clone)) { this.clonedReferenceElement = clone; } if (isBodyElement(clone)) { createPseudoHideStyles(clone); } var counters = this.counters.parse(new CSSParsedCounterDeclaration(this.context, style)); var before = this.resolvePseudoContent(node, clone, styleBefore, PseudoElementType.BEFORE); if (isCustomElement(node)) { copyStyles = true; } if (!isVideoElement(node)) { this.cloneChildNodes(node, clone, copyStyles); } if (before) { clone.insertBefore(before, clone.firstChild); } var after = this.resolvePseudoContent(node, clone, styleAfter, PseudoElementType.AFTER); if (after) { clone.appendChild(after); } this.counters.pop(counters); if (style && (this.options.copyStyles || isSVGElementNode(node)) && !isIFrameElement(node) || copyStyles) { copyCSSStyles(style, clone); } if (node.scrollTop !== 0 || node.scrollLeft !== 0) { this.scrolledElements.push([clone, node.scrollLeft, node.scrollTop]); } if ((isTextareaElement(node) || isSelectElement(node)) && (isTextareaElement(clone) || isSelectElement(clone))) { clone.value = node.value; } return clone; } return node.cloneNode(false); }; DocumentCloner2.prototype.resolvePseudoContent = function(node, clone, style, pseudoElt) { var _this = this; if (!style) { return; } var value = style.content; var document2 = clone.ownerDocument; if (!document2 || !value || value === "none" || value === "-moz-alt-content" || style.display === "none") { return; } this.counters.parse(new CSSParsedCounterDeclaration(this.context, style)); var declaration = new CSSParsedPseudoDeclaration(this.context, style); var anonymousReplacedElement = document2.createElement("html2canvaspseudoelement"); copyCSSStyles(style, anonymousReplacedElement); declaration.content.forEach(function(token) { if (token.type === 0) { anonymousReplacedElement.appendChild(document2.createTextNode(token.value)); } else if (token.type === 22) { var img = document2.createElement("img"); img.src = token.value; img.style.opacity = "1"; anonymousReplacedElement.appendChild(img); } else if (token.type === 18) { if (token.name === "attr") { var attr = token.values.filter(isIdentToken); if (attr.length) { anonymousReplacedElement.appendChild(document2.createTextNode(node.getAttribute(attr[0].value) || "")); } } else if (token.name === "counter") { var _a = token.values.filter(nonFunctionArgSeparator), counter = _a[0], counterStyle = _a[1]; if (counter && isIdentToken(counter)) { var counterState = _this.counters.getCounterValue(counter.value); var counterType = counterStyle && isIdentToken(counterStyle) ? listStyleType.parse(_this.context, counterStyle.value) : 3; anonymousReplacedElement.appendChild(document2.createTextNode(createCounterText(counterState, counterType, false))); } } else if (token.name === "counters") { var _b = token.values.filter(nonFunctionArgSeparator), counter = _b[0], delim = _b[1], counterStyle = _b[2]; if (counter && isIdentToken(counter)) { var counterStates = _this.counters.getCounterValues(counter.value); var counterType_1 = counterStyle && isIdentToken(counterStyle) ? listStyleType.parse(_this.context, counterStyle.value) : 3; var separator = delim && delim.type === 0 ? delim.value : ""; var text = counterStates.map(function(value2) { return createCounterText(value2, counterType_1, false); }).join(separator); anonymousReplacedElement.appendChild(document2.createTextNode(text)); } } else ; } else if (token.type === 20) { switch (token.value) { case "open-quote": anonymousReplacedElement.appendChild(document2.createTextNode(getQuote(declaration.quotes, _this.quoteDepth++, true))); break; case "close-quote": anonymousReplacedElement.appendChild(document2.createTextNode(getQuote(declaration.quotes, --_this.quoteDepth, false))); break; default: anonymousReplacedElement.appendChild(document2.createTextNode(token.value)); } } }); anonymousReplacedElement.className = PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER; var newClassName = pseudoElt === PseudoElementType.BEFORE ? " " + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE : " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER; if (isSVGElementNode(clone)) { clone.className.baseValue += newClassName; } else { clone.className += newClassName; } return anonymousReplacedElement; }; DocumentCloner2.destroy = function(container) { if (container.parentNode) { container.parentNode.removeChild(container); return true; } return false; }; return DocumentCloner2; }() ); var PseudoElementType; (function(PseudoElementType2) { PseudoElementType2[PseudoElementType2["BEFORE"] = 0] = "BEFORE"; PseudoElementType2[PseudoElementType2["AFTER"] = 1] = "AFTER"; })(PseudoElementType || (PseudoElementType = {})); var createIFrameContainer = function(ownerDocument, bounds) { var cloneIframeContainer = ownerDocument.createElement("iframe"); cloneIframeContainer.className = "html2canvas-container"; cloneIframeContainer.style.visibility = "hidden"; cloneIframeContainer.style.position = "fixed"; cloneIframeContainer.style.left = "-10000px"; cloneIframeContainer.style.top = "0px"; cloneIframeContainer.style.border = "0"; cloneIframeContainer.width = bounds.width.toString(); cloneIframeContainer.height = bounds.height.toString(); cloneIframeContainer.scrolling = "no"; cloneIframeContainer.setAttribute(IGNORE_ATTRIBUTE, "true"); ownerDocument.body.appendChild(cloneIframeContainer); return cloneIframeContainer; }; var imageReady = function(img) { return new Promise(function(resolve) { if (img.complete) { resolve(); return; } if (!img.src) { resolve(); return; } img.onload = resolve; img.onerror = resolve; }); }; var imagesReady = function(document2) { return Promise.all([].slice.call(document2.images, 0).map(imageReady)); }; var iframeLoader = function(iframe) { return new Promise(function(resolve, reject) { var cloneWindow = iframe.contentWindow; if (!cloneWindow) { return reject("No window assigned for iframe"); } var documentClone = cloneWindow.document; cloneWindow.onload = iframe.onload = function() { cloneWindow.onload = iframe.onload = null; var interval = setInterval(function() { if (documentClone.body.childNodes.length > 0 && documentClone.readyState === "complete") { clearInterval(interval); resolve(iframe); } }, 50); }; }); }; var ignoredStyleProperties = [ "all", "d", "content" // Safari shows pseudoelements if content is set ]; var copyCSSStyles = function(style, target) { for (var i = style.length - 1; i >= 0; i--) { var property = style.item(i); if (ignoredStyleProperties.indexOf(property) === -1) { target.style.setProperty(property, style.getPropertyValue(property)); } } return target; }; var serializeDoctype = function(doctype) { var str = ""; if (doctype) { str += ""; } return str; }; var restoreOwnerScroll = function(ownerDocument, x, y) { if (ownerDocument && ownerDocument.defaultView && (x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset)) { ownerDocument.defaultView.scrollTo(x, y); } }; var restoreNodeScroll = function(_a) { var element = _a[0], x = _a[1], y = _a[2]; element.scrollLeft = x; element.scrollTop = y; }; var PSEUDO_BEFORE = ":before"; var PSEUDO_AFTER = ":after"; var PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = "___html2canvas___pseudoelement_before"; var PSEUDO_HIDE_ELEMENT_CLASS_AFTER = "___html2canvas___pseudoelement_after"; var PSEUDO_HIDE_ELEMENT_STYLE = '{\n content: "" !important;\n display: none !important;\n}'; var createPseudoHideStyles = function(body) { createStyles(body, "." + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + PSEUDO_BEFORE + PSEUDO_HIDE_ELEMENT_STYLE + "\n ." + PSEUDO_HIDE_ELEMENT_CLASS_AFTER + PSEUDO_AFTER + PSEUDO_HIDE_ELEMENT_STYLE); }; var createStyles = function(body, styles) { var document2 = body.ownerDocument; if (document2) { var style = document2.createElement("style"); style.textContent = styles; body.appendChild(style); } }; var CacheStorage = ( /** @class */ function() { function CacheStorage2() { } CacheStorage2.getOrigin = function(url) { var link = CacheStorage2._link; if (!link) { return "about:blank"; } link.href = url; link.href = link.href; return link.protocol + link.hostname + link.port; }; CacheStorage2.isSameOrigin = function(src) { return CacheStorage2.getOrigin(src) === CacheStorage2._origin; }; CacheStorage2.setContext = function(window2) { CacheStorage2._link = window2.document.createElement("a"); CacheStorage2._origin = CacheStorage2.getOrigin(window2.location.href); }; CacheStorage2._origin = "about:blank"; return CacheStorage2; }() ); var Cache = ( /** @class */ function() { function Cache2(context, _options) { this.context = context; this._options = _options; this._cache = {}; } Cache2.prototype.addImage = function(src) { var result = Promise.resolve(); if (this.has(src)) { return result; } if (isBlobImage(src) || isRenderable(src)) { (this._cache[src] = this.loadImage(src)).catch(function() { }); return result; } return result; }; Cache2.prototype.match = function(src) { return this._cache[src]; }; Cache2.prototype.loadImage = function(key) { return __awaiter(this, void 0, void 0, function() { var isSameOrigin, useCORS, useProxy, src; var _this = this; return __generator(this, function(_a) { switch (_a.label) { case 0: isSameOrigin = CacheStorage.isSameOrigin(key); useCORS = !isInlineImage(key) && this._options.useCORS === true && FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin; useProxy = !isInlineImage(key) && !isSameOrigin && !isBlobImage(key) && typeof this._options.proxy === "string" && FEATURES.SUPPORT_CORS_XHR && !useCORS; if (!isSameOrigin && this._options.allowTaint === false && !isInlineImage(key) && !isBlobImage(key) && !useProxy && !useCORS) { return [ 2 /*return*/ ]; } src = key; if (!useProxy) return [3, 2]; return [4, this.proxy(src)]; case 1: src = _a.sent(); _a.label = 2; case 2: this.context.logger.debug("Added image " + key.substring(0, 256)); return [4, new Promise(function(resolve, reject) { var img = new Image(); img.onload = function() { return resolve(img); }; img.onerror = reject; if (isInlineBase64Image(src) || useCORS) { img.crossOrigin = "anonymous"; } img.src = src; if (img.complete === true) { setTimeout(function() { return resolve(img); }, 500); } if (_this._options.imageTimeout > 0) { setTimeout(function() { return reject("Timed out (" + _this._options.imageTimeout + "ms) loading image"); }, _this._options.imageTimeout); } })]; case 3: return [2, _a.sent()]; } }); }); }; Cache2.prototype.has = function(key) { return typeof this._cache[key] !== "undefined"; }; Cache2.prototype.keys = function() { return Promise.resolve(Object.keys(this._cache)); }; Cache2.prototype.proxy = function(src) { var _this = this; var proxy = this._options.proxy; if (!proxy) { throw new Error("No proxy defined"); } var key = src.substring(0, 256); return new Promise(function(resolve, reject) { var responseType = FEATURES.SUPPORT_RESPONSE_TYPE ? "blob" : "text"; var xhr = new XMLHttpRequest(); xhr.onload = function() { if (xhr.status === 200) { if (responseType === "text") { resolve(xhr.response); } else { var reader_1 = new FileReader(); reader_1.addEventListener("load", function() { return resolve(reader_1.result); }, false); reader_1.addEventListener("error", function(e2) { return reject(e2); }, false); reader_1.readAsDataURL(xhr.response); } } else { reject("Failed to proxy resource " + key + " with status code " + xhr.status); } }; xhr.onerror = reject; var queryString = proxy.indexOf("?") > -1 ? "&" : "?"; xhr.open("GET", "" + proxy + queryString + "url=" + encodeURIComponent(src) + "&responseType=" + responseType); if (responseType !== "text" && xhr instanceof XMLHttpRequest) { xhr.responseType = responseType; } if (_this._options.imageTimeout) { var timeout_1 = _this._options.imageTimeout; xhr.timeout = timeout_1; xhr.ontimeout = function() { return reject("Timed out (" + timeout_1 + "ms) proxying " + key); }; } xhr.send(); }); }; return Cache2; }() ); var INLINE_SVG = /^data:image\/svg\+xml/i; var INLINE_BASE64 = /^data:image\/.*;base64,/i; var INLINE_IMG = /^data:image\/.*/i; var isRenderable = function(src) { return FEATURES.SUPPORT_SVG_DRAWING || !isSVG(src); }; var isInlineImage = function(src) { return INLINE_IMG.test(src); }; var isInlineBase64Image = function(src) { return INLINE_BASE64.test(src); }; var isBlobImage = function(src) { return src.substr(0, 4) === "blob"; }; var isSVG = function(src) { return src.substr(-3).toLowerCase() === "svg" || INLINE_SVG.test(src); }; var Vector = ( /** @class */ function() { function Vector2(x, y) { this.type = 0; this.x = x; this.y = y; } Vector2.prototype.add = function(deltaX, deltaY) { return new Vector2(this.x + deltaX, this.y + deltaY); }; return Vector2; }() ); var lerp = function(a2, b, t) { return new Vector(a2.x + (b.x - a2.x) * t, a2.y + (b.y - a2.y) * t); }; var BezierCurve = ( /** @class */ function() { function BezierCurve2(start, startControl, endControl, end) { this.type = 1; this.start = start; this.startControl = startControl; this.endControl = endControl; this.end = end; } BezierCurve2.prototype.subdivide = function(t, firstHalf) { var ab = lerp(this.start, this.startControl, t); var bc = lerp(this.startControl, this.endControl, t); var cd = lerp(this.endControl, this.end, t); var abbc = lerp(ab, bc, t); var bccd = lerp(bc, cd, t); var dest = lerp(abbc, bccd, t); return firstHalf ? new BezierCurve2(this.start, ab, abbc, dest) : new BezierCurve2(dest, bccd, cd, this.end); }; BezierCurve2.prototype.add = function(deltaX, deltaY) { return new BezierCurve2(this.start.add(deltaX, deltaY), this.startControl.add(deltaX, deltaY), this.endControl.add(deltaX, deltaY), this.end.add(deltaX, deltaY)); }; BezierCurve2.prototype.reverse = function() { return new BezierCurve2(this.end, this.endControl, this.startControl, this.start); }; return BezierCurve2; }() ); var isBezierCurve = function(path) { return path.type === 1; }; var BoundCurves = ( /** @class */ /* @__PURE__ */ function() { function BoundCurves2(element) { var styles = element.styles; var bounds = element.bounds; var _a = getAbsoluteValueForTuple(styles.borderTopLeftRadius, bounds.width, bounds.height), tlh = _a[0], tlv = _a[1]; var _b = getAbsoluteValueForTuple(styles.borderTopRightRadius, bounds.width, bounds.height), trh = _b[0], trv = _b[1]; var _c = getAbsol